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

int main(){
  int N;
  cin >> N;
  set<int> s;
  for(int i=0;i<N;i++){
    int A;
    cin >> A;
    s.insert(A);
  }
  if(s.size()==N){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 9600
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    
    int n = N;
    int sum = 0;
    while(n > 0){
      sum += n%10;
      n /= 10;
    }
    System.out.println(N%sum == 0 ? "Yes" : "No");
  }
}

Measured memory_bytes: 23508
INF = 1 << 29
def solve
  memo = [INF] * (1<<$n)
  memo[0] = 0
  (1<<$n).times do |bits|
    next if memo[bits] == INF
    $n.times do |i|
      next if bits & (1<<i) != 0
      nbits = bits | (1<<i)
      mint = 0
      (0..$n).each do |j|
        k = $stg[i][j][0]
        if k == 0 || bits & 1<<(k-1) != 0
          mint = memo[bits] + $stg[i][j][1]
          break
        end
      end
      memo[nbits] = mint if memo[nbits] > mint
    end
  end
  memo[(1<<$n)-1]
end

while $n = gets.to_i
  break if $n == 0
  $stg = $n.times.map{ gets.split.map(&:to_i) }
  $stg.map! do |s|
    h = {}
    s.each_with_index{ |t, i| h[i] = t }
    h.sort_by{|k, v| v}
  end
  p solve
end

Measured memory_bytes: 15832
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;

int main()
{
    ll N,K,res;
    cin >> N >> K;

    if ( N < K )res = 0;
    else res = 10;

    cout << res << endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >> s;
	if (s[s.size() - 1] != 's')
		cout << s << "s" << endl;
	else
		cout << s << "es" << endl;

}

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

def gcd(a, b):
    big, small = max(a, b), min(a,b)
    if big % small == 0:
        return small
    return gcd(small, big%small)


n = int(input())
a = list(map(int, input().split()))

ans = a[0]
for a_val in a:
    ans = gcd(ans, a_val)

print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef __int128_t LL;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define F first
#define S second
#define pb push_back
mt19937 rnd;

const int N = 2e3 + 10;
int a[N], b[N];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int n, x;
    cin >> n >> x;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    ll ans = 1e18 + 10, cur = 0;
    for (int i = 1; i <= n; i++) {
        b[i] = a[i];
        cur += a[i];
    }
    for (int cnt = 0; cnt <= n - 1; cnt++) {
        ans = min(ans, cur + 1ll * cnt * x);
        for (int i = 1; i <= n; i++) {
            int j = (i - cnt - 1 + n) % n;
            if (!j) j = n;
            if (b[i] > a[j]) {
                cur += a[j] - b[i];
                b[i] = a[j];
            }
        }
    }
    cout << ans << "\n";

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>

int main(int argc, char **argv)
{
    std::string N;
    std::cin >> N;
    for(unsigned int i = 0; i < N.size(); i++){
        if(N.at(i) == '7'){
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }
    std::cout << "No" << std::endl;
}


Measured memory_bytes: 3592
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k= int(input())
print(a[k-1])

Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    int h;
    while(1){
        cin>>h;
        if(h==0)break;
        vvi v(2*h,vector<int> (5,-1));
        for(int i=h;i<2*h;i++){
            rep(j,5){
                cin>>v[i][j];
            }
        }
        int sum=0;

        while(1){
            bool ch=false;
            for(int i=h;i<2*h;i++){
                int l=0,r=0;
                if(v[i][2]==-1)continue;
                while(1-l>=0&&v[i][2]==v[i][1-l])l++;
                while(3+r<=5&&v[i][2]==v[i][3+r])r++;
                if(l+r>=2){
                    rep(j,l)v[i][1-j]=-1;
                    rep(j,r)v[i][3+j]=-1;
                    sum+=(l+r+1)*v[i][2];
                    ch=true;
                    v[i][2]=-1;
                }
                
            }
            
            for(int n=0;n<200;n++){
                for(int i=2*h-1;i>=h;i--){
                    for(int j=0;j<5;j++){
                        if(v[i][j]==-1&&v[i-1][j]!=-1){
                            v[i][j]=v[i-1][j];
                            v[i-1][j]=-1;
                        }
                    }
                }
            }
            
/*
            cout<<endl;
            for(int i=h;i<2*h;i++){
                for(int j=0;j<5;j++)cout<<v[i][j]<<" ";
                cout<<endl;
            }
            cout<<endl;
*/
            if(!ch)break;

        }
        
        
        cout<<sum<<endl;
    }
//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 3220
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m int
	var score int64
	var power []int

	fmt.Scanf("%d %d", &n, &m)

	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scanf("%d", &tmp)
		power = append(power, tmp)
	}

	sort.Ints(power)

	min := findByBTree(power, m, numOfElem)

	score, minNum, count := calcTotal(power, min)

	if m < count {
		score -= int64(minNum * (count - m))
	}

	fmt.Print(score)
}

func calcTotal(array []int, min int) (int64, int, int) {
	l := len(array)
	total := int64(0)
	minNum := 200000
	count := 0
	cache := []int64{0}
	cacheBound := make(map[int]int)
	sum := 0
	for _, a := range array {
		cache = append(cache, int64(a+sum))
		sum += a
	}

	max := cache[len(cache) - 1]
	for _, a := range array {
		bound := 0
		if val, ok := cacheBound[a]; ok {
			bound = val
		} else {
			bound = findLowerBound(array, min - a)
			cacheBound[a] = bound
		}
		if bound != -1 {
			count += l - bound
			total += max - cache[bound] + int64(a * (l - bound))
			if minNum > a + array[bound] {
				minNum = a + array[bound]
			}
		}
	}
	return total, minNum, count
}

func findByBTree(array []int, target int, check func(array []int, min int, target int) int) int {
	left := array[0]
	right := array[len(array)-1] * 2
	mid := 0
	count := 0
	var countCache []int
	var midCache []int
	for left <= right {
		mid = (left + right) / 2
		count = check(array, mid, target)
		if count == target {
			return mid
		} else if count > target {
			left = mid + 1
		} else if count < target {
			right = mid - 1
		}
		countCache = append(countCache, count)
		midCache = append(midCache, mid)
	}

	if count >= target {
		return mid
	}
	for i := len(countCache) - 1; i >= 0; i-- {
		if countCache[i] > target {
			return midCache[i]
		}
	}
	return -1
}

func numOfElem(array []int, min int, target int) int {
	len := len(array)
	count := 0
	cacheBound := make(map[int]int)
	for i := len - 1; i >= 0; i-- {
		if target < count {
			break
		}
		index := 0
		if val, ok := cacheBound[min - array[i]]; ok {
			index = val
		} else {
			index = findLowerBound(array, min-array[i])
			cacheBound[min-array[i]] = index
		}
		if index != -1 {
			count += len - index
		}
	}

	return count
}

func findLowerBound(array []int, target int) int {
	l := len(array)
	left := 0
	right := l - 1
	mid := -1
	tmp := 0
	var tmpCache []int
	var midCache []int
	for left <= right {
		mid = (left + right) / 2
		tmp = array[mid]
		if tmp == target {
			for mid > 1 && array[mid] == array[mid-1] {
				mid--
			}
			break
		} else if tmp < target {
			left = mid + 1
		} else if tmp > target {
			right = mid - 1
		}
		tmpCache = append(tmpCache, tmp)
		midCache = append(midCache, mid)
		if left > right {
			if left == l {
				mid = -1
			}
			break
		}
	}

	if tmp >= target {
		return mid
	}
	for i := len(tmpCache) - 1; i >= 0; i-- {
		if tmpCache[i] > target {
			return midCache[i]
		}
	}
	return -1
}


Measured memory_bytes: 14908
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
typedef long long ll;
ll x;
ll f (ll n) {
    if (n == -1) return 0;
    else return n / x + 1;
}
int main (void) {
    ll a, b;

    cin >> a >> b >> x;

    cout << f(b) - f(a - 1) << endl;

    return 0;
}

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

using namespace std;

int main(){
  int N,M; 
  cin >> N >> M;
  
  vector<int> vec (2*M);
  vector<int> cnt (N,0);
  
  for(int i=0; i< 2*M; i++){
    cin >> vec.at(i);
    cnt.at(vec.at(i)-1)++;
  }
  
  for(int i=0;i<N;i++)
    cout<<cnt.at(i) <<endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        long[] a = new long[n+1];
        long[] b = new long[m+1];
        a[0] = 0;
        for(int i=1; i<=n; i++) {
            a[i] = a[i-1] + Long.parseLong(sc.next());
        }
        b[0] = 0;
        for(int i=1; i<=m; i++) {
            b[i] = b[i-1] + Long.parseLong(sc.next());
        }
        
        int maxb = m;
        long ans = 0;
        for(int i=0; i<=n; i++) {
            for(int j=maxb; j>=0; j--) {
                if(a[i]+b[j] <= k) {
                    if(ans < i+j) ans = i+j;
                    maxb = j;
                    break;
                }
            }
        }
        
        System.out.println(ans);
        
    }
}

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

int f[110], a[110], ans = 0;

int main() {
    int n; cin >> n;
    for(int i = 1; i <= n; ++i) cin >> a[i];
    int now = 0;
	for(int i = 1; i <= n; ++i) {
		if(now <= a[i]) ++ans;
		now = max(now, a[i]);
	}
	cout << ans;
}

Measured memory_bytes: 256
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = set(A)
    L = [0 for i in range(N+1)]
    for i in A:
        L[i] += 1
    L.sort()
    if len(B) <= K:
        print('0')
    else:
        print(str(sum(L[0:N+1-K])))


if __name__ == "__main__":
    main()


Measured memory_bytes: 25644
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        double[] hensa;
        double[] s;
            s = new double[1000];
        hensa = new double[100];
        int i,j,k;
        double n,sum=0,sum2=0;
        double jou,ave;
        for(i=0;i<100;i++){
            sum=0;
            sum2=0;
            n = scan.nextInt();
            if(n==0) break;
            for(j=0;j<n;j++){
                s[j] = scan.nextInt();
                sum+=s[j];
            }
            ave = (double)sum/n;
            for(j=0;j<n;j++){
                jou=(ave-s[j])*(ave-s[j]);
                sum2+=jou;
            }
            hensa[i]=Math.sqrt(sum2/n);   
        }

        for(k=0;k<i;k++){
            System.out.println(String.format("%.8f",hensa[k]));        
        }

}
}


Measured memory_bytes: 32336
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{
    private const int INF = 1000000007;
    public static void Main()
    {
        Console.WriteLine("A" + Console.ReadLine().Split(' ')[1][0] + "C");
    }
}

public class AtCoder
{
    public static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int GCD(int a, int b)
    {
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (b != 0)
        {
            d = a % b;
            a = b;
            b = d;
        }
        return a;
    }
    public static long LCM(int a, int b)
    {
        return (long)a * b / GCD(a, b);
    }
    public static string StrReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int IntRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static long[] LSRead()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
    public static long Combination(int n, int r)
    {
        if (n == r) return 1;
        return
            Enumerable.Range((n - r + 1), r).ToList().Aggregate((now, next) => now * next) /
            Enumerable.Range(1, r).ToList().Aggregate((now, next) => now * next);
    }
    public static long Permutation(int n, int r)
    {
        if (n == r) return 1;
        return
            Enumerable.Range((n - r), r).ToList().Aggregate((now, next) => now * next);
    }
    public static long RepPow(long x, long p, long m = 1000000007)
    {
        if (p == 1) return x % m;
        long b = RepPow(x, p / 2, m) % m;
        if (p % 2 == 0) { return (b * b) % m; }
        else { return (x * ((b * b) % m)) % m; }
    }
    public static long LongRead()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] LongLine()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
    public static int[] IntLine()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
}


Measured memory_bytes: 11092
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        w: f64,
        h: f64,
        x: f64,
        y: f64,
    }
    let c = if 2. * x == w && 2. * y == h {
        1
    } else {
        0
    };
    println!("{} {}", w * h / 2., c);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define lli long long int
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	char a[100000];
	cin >> a;
	lli n = strlen(a);
	// cout << "N is" << n;
	lli flag = 0;
	if (n % 2 == 0)
	{
		cout << "No" << endl;
		return 0;
	}

	else
	{ // cout<<"WOW";
		for (lli i = 0; i < (n / 2) ; i++)
		{
			// cout << "here " << i << a[i] << endl;
			// cout << "here " << ((n + 1) / 2) + i << a[((n + 1) / 2) + i] << endl;
			// if (i % 2 == 0)
			
				if (a[i] == a[((n + 1) / 2) + i])
				{	// 	cout<<"a[i] is "<<a[i];
					// 	cout<<"a[((n + i) / 2)] is "<<a[((n + i) / 2)];
					continue;
					// flag=0;
				}
			
			// if (i % 2 == 1)
			// {
			// 	if (a[i] == a[((n + i) / 2) + 1])
			// 	{	// 	cout<<"a[i] is "<<a[i];
			// 		// 	cout<<"a[((n + i) / 2)] is "<<a[((n + i) / 2)];
			// 		continue;
			// 		// flag=0;
			// 	}
			// }
			else
			{
				flag = 1;
				break;
			}
		}
		if (flag == 1)
			cout << "No" << endl;
		else if (flag == 0)
		{
			cout << "Yes" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
    string s; cin >> s;

    for (char c = 'a'; c <= 'z'; c++) {
        for (int i = 0; i + 1 < s.length(); i++) {
            if (s[i] == c && s[i + 1] == c) {
                cout << i + 1 << " " << i + 2 << endl;
                return 0;
            }
        }
        for (int i = 0; i + 2 < s.length(); i++) {
            if (s[i] == c && s[i + 2] == c) {
                cout << i + 1 << " " << i + 3 << endl;
                return 0;
            }
        }
    }

    cout << -1 << " " << -1 << endl;

    return 0;
}

Measured memory_bytes: 512
n = gets.to_i
min = 100000000
for i in 0..n do
  count = 0
  cc = i
  while cc > 0
    count += ( cc % 6 )
    cc -= ( cc % 6 )
    cc /= 6
  end

  dd = n - i
  while dd > 0
    count += ( dd % 9 )
    dd -= ( dd % 9 )
    dd /= 9
  end

  if count < min
    min = count
  end

end

p min

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n; i++)
#define all(a) (a).begin(),(a).end();


bool isp[401010];
bool isplr[1<<20];
int l, r;
vector<int> p;

void build(){
  for(int i=0; i*i<=r; i++){
    isp[i] = 1;
  }
  for(int i=l;i<=r;i++)isplr[i-l]=1;
  isp[0] = 0;
  isp[1] = 0;
  for(int i=2; i*i<=r; i++){
    if(!isp[i]) continue;
    for(LL j=i*i; j*j<=r; j+=i){
      isp[j] = 0;
    }
    LL j=max(2*i,(l+i-1)/i*i);
    while(j<=r)isplr[j-l]=0,j+=i;
  }
}
int cnt[1<<20];
int now[1<<20];
int main(){
  cin >> l >> r;
  build();
  for(int i=0; i*i<=r; i++){
    if(isp[i]) p.push_back(i);

  }
  for(int i=l;i<=r;i++)now[i-l]=i;
  int ans = 0;
  for(const auto&x:p)
  {
    int i=max(x,(l+x-1)/x*x);
    while(i<=r)
    {
      int&a=now[i-l];
      while(a%x<1)a/=x,cnt[i-l]++;
      i+=x;
    }
  }
  for(int i=l;i<=r;i++)if(isp[cnt[i-l]+(now[i-l]>1)])ans++;
  cout<<ans<<endl;
return 0;
  for(int i=l; i<=r; i++){
    if(isplr[i-l])continue;
    int tmp = 0, now = i;
    for(const auto &x: p){
      if(now < x) break;
      while(now%x == 0){
        tmp++;
        now /= x;
      }
    }
    if(now > 1) tmp++;
    if(isp[tmp]) ans++;
  }
  cout << ans << endl;

}





Measured memory_bytes: 12004
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

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

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

template<class T>
bool chmax(T &a, initializer_list<T> l)
{
	return chmax(a, *max_element(l.begin(), l.end()));
}

template<class T>
bool chmin(T &a, initializer_list<T> l)
{
	return chmin(a, *min_element(l.begin(), l.end));
}

ll dp[100010][3];

int main(int argc, char **argv)
{
	ll n, k, r, s, p;
	string str;
	cin >> n >> k >> r >> s >> p >> str;

	vector<ll> rv, sv, pv;

	ll res{0};
	ll N = (ll)str.size();
	for (ll i = 0; i < k; ++i)
	{
		if (str[i] == 'r')
			res += p;
		else if (str[i] == 'p')
			res += s;
		else if (str[i] == 's')
			res += r;
	}

	for (ll i = k; i < N; ++i)
	{
		if (str[i-k] == str[i]) str[i] = -1;
		if (str[i] == 'r')
			res += p;
		else if (str[i] == 'p')
			res += s;
		else if (str[i] == 's')
			res += r;
	}
	
	std::cout << res << std::endl;
}

Measured memory_bytes: 512
N, x = map(int, input().split())
a = list(map(int, input().split()))

cnt = 0

if a[0] > x:
    cnt += a[0] - x
    a[0] = x

for i in range(0, N - 1):
    if a[i] + a[i + 1] > x:
        num = a[i] + a[i + 1] - x
        a[i + 1] -= num
        cnt += num
print(cnt)


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

using namespace std;

typedef long long ll;

#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORd(i,a,b) for(int i=a;i>=b;i--)
#define fi first
#define se second
#define II pair<int,int>

const int N=1e6+10;
const ll maxN=1e18+10;
const double pi=3.14159265;
const int MOD=1e9+7;

ll n,k;
ll a[N];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin >> n >> k; 
    ll ans=0;
    FOR(i,k,n+1) {
        ll so=i*(i-1)/2;
        ll bg=n-i+1;
        ll so1=(bg+n)*(n-bg+1)/2;
        ans=(ans+so1-so+1)%MOD;
    }
    cout << ans;
}
    

Measured memory_bytes: 3640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
T = input()

total = 0
for s, t in zip(S, T):
	if s == t:
		total += 1

print(total)

Measured memory_bytes: 5192
#include <bits/stdc++.h>
using namespace std;
int cnt=0;
int binarySearch(vector<int> s,int begin,int end,int a) {
	
//cout << a << endl;
	while (begin < end) {
		int mid = (end + begin) / 2;
		if (s[mid] == a) {
			return ++cnt;
		}
		else if(a<s[mid]){
			end = mid;
		}
		else {
			begin = mid+1;
		}

	}

	return cnt;

}

int main() {
	int n, m;
	vector <int>s, t;
	int tmp;
	int cnt = 0;
	int mid;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		s.push_back(tmp);

	}
	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> tmp;
		t.push_back(tmp);
	}
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());

	for (int i = 0; i < m; i++) {
		cnt=binarySearch(s, 0,n,t[i]);
	}
	

	cout << cnt<<endl;
	
	return 0;
}




Measured memory_bytes: 4200
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
signed main(){
    ll x;cin>>x;
    if(x>=30){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3648
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
typedef long long ll;
using namespace std;
int n,i,nr[3];
ll x;
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	//freopen("sol.in","r",stdin);
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>x;
		if(x%4==0)nr[2]++;
		else if(x%2==0)nr[1]++;
		else nr[0]++;
	}
	if((nr[2]>=nr[0]-1 && !nr[1]) || (nr[2]>=nr[0] && nr[1]))cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct str{
	int a[2];
	char c;
} s[300010];
int head,tail,tot,q,t,f;
bool r;
char ss[300010],cc[3];
void bck(char c){
	s[tot].c=c;
	s[tail].a[r]=tot;
	s[tot].a[!r]=tail;
	s[tot].a[r]=tail=tot;
	++tot;
}
void beg(char c){
	s[tot].c=c;
	s[head].a[!r]=tot;
	s[tot].a[r]=head;
	s[tot].a[!r]=head=tot;
	++tot;
}
void rev(){
	r=!r;
	swap(head,tail);
}
int main()
{
	scanf("%s",ss);
	head=tail=tot=1;
	r=false;
	for(int i=0;i<strlen(ss);++i){
		bck(ss[i]);
	}
	scanf("%d",&q);
//	 printf("head=%d,tail=%d\n",head,tail);
//		for(int i=1;i<=3;++i){
//			printf("%d %d %c\n",s[i].a[0],s[i].a[1],s[i].c);
//		}
	while(q--){
		scanf("%d",&t);
		if(t==1) rev();
		else{
			scanf("%d%s",&f,cc);
			if(f==1) beg(cc[0]);
			else bck(cc[0]);
		}
//		printf("head=%d,tail=%d\n",head,tail);
//		for(int i=1;i<=3;++i){
//			printf("%d %d %c\n",s[i].a[0],s[i].a[1],s[i].c);
//		}
//		printf("\n");
	}
	int p=head;
	while(1){
		printf("%c",s[p].c);
		if(p==tail) break;
		p=s[p].a[r];
	}
}

Measured memory_bytes: 4096
N,M = map(int,input().split())
PY = [list(map(int,input().split()))+ [i] for i in range(M)]
    
def create(x):
    a = str(x)
    a = list(a)
    n = len(a)
    s = ['0'] * (6-n) + a
    s = ''.join(s)
    return s

ans = [0] * M
PY.sort()
idx = 1
flag = False
for i in range(M):
    if i > 0 and PY[i][0] != PY[i-1][0] : idx = 1
    ans[PY[i][2]] = create(PY[i][0]) + create(idx)
    idx += 1
    
for a in ans:
    print(a)
    
    
    

Measured memory_bytes: 31756
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
    int L;
    while (cin >> L, L) {
        vector<int> M(12), N(12);
        for (int i=0; i<12; ++i) {
            cin >> M[i] >> N[i];
        }
        int month = -1, sum = 0;
        for (int i=0; i<12; ++i) {
            sum = sum + M[i] - N[i];
            if (L <= sum) {
                month = i+1;
                break;
            }
        }
        if (month < 0) {
            cout << "NA" << endl;
        } else {
            cout << month << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
#define mp make_pair
#define ss second
#define ff first
#define ll long long int
#define tcase ll t;cin>>t;while(t--)
#define sz(a) int((a).size())
#define pb push_back
#define YES cout<<"YES\n";
#define NO cout<<"NO\n";
#define Yes cout<<"Yes\n";
#define No cout<<"No\n";
#define yes cout<<"yes\n";
#define no cout<<"no\n";
#define f(i,a,b) for(int i=a;i<b;i++)
#define in insert
#define matrix vector<vector<ll> >
#define E cout<<"\n";
#define I(x) cin>>x;
#define O(x) cout<<x;
#define all(a) a.begin(),a.end()
#define vi vector<int>
const ll M=1000000007;
const double pi=3.1415926;

using namespace std;

//ll modexpo(ll a,ll b,ll p)
//{
//    ll ans=1;
//      a=a%p;  // update a if(a>=p)
//
//        if(a==0)
//            return 0;
//
//                while(b!=0)
//                {
//                    if(b%2==1)
//                        ans=(ans*a)%p;
//
//                    a=(a*a)%M;
//                    b=b/2;
//
//                }
//                return ans;
//
//}

//ll countbit(ll n)
//{
//    ll x=0;
//    while(n!=0)
//    {
//        n=n&(n-1);
//
//        x++;
//    }
//    return x;
//}



//  vector<int> prime1;
//  int prime[10000001];
//
//void sieve(int n)
//{
//       for(long long i=2;i<=n;i++)
//       {
//         if(prime[i]==0)
//         {  prime[i]=i;
//            prime1.pb(i);
//         }
//
//            for(long long j=0;j<sz(prime1) && prime1[j]<=prime[i] && i*prime1[j]<=n;j++)
//            {
//
//                   prime[i*prime1[j]]=prime1[j];
//
//
//            }
//
//
//      }
//
// return ;
//}

//ll gcd(ll a,ll b)
//{
//    if(a==0)
//        return b;
//    else
//        return gcd(b%a,a);
//}
//ll lcm(ll a,ll b)
//{
//    return (a*b)/gcd(a,b);
//}

void fastio()
{
       ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);

}


int main()
{

     fastio();
      bool f=0;
      int c=0;
     tcase
     {

             int x,y;
             cin>>x>>y;

             if(x==y)
             {
                 c++;
             }
             else
                c=0;

             if(c>=3)
                f=1;
     }
      if(f)
        Yes
        else
        No


    return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>
int main(void)
{
  int h, w, i, j;
  char p[101][101], q[102][102];

  scanf("%d %d", &h, &w);
  for(i = 0; i < h; i++)
    scanf("%s", p[i]);

  for(i = 0; i < h+2; i++){
    for(j = 0; j < w+2; j++)
      q[i][j] = '#';
  }

  for(i = 1; i <= h; i++){
    for(j = 1; j <= w; j++)
      q[i][j] = p[i-1][j-1];
  }

  for(i = 0; i < h+2; i++){
    for(j = 0; j < w+2; j++){
      printf("%c", q[i][j]);
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define loop(i,a,b) for(int i=a; i<b; i++)
#define INF 10000000000099ll
#define mod 1000000007
#define prDouble(x) cout<<fixed<<setprecision(10)<<x
ll dp[3001][3001];

ll solve(vector<int>& arr, int i, int j)
{
    if(i>j) return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    ll opt1= arr[i]+ min(solve(arr, i+1, j-1), solve(arr, i+2, j));
    ll opt2= arr[j]+ min(solve(arr, i, j-2), solve(arr, i+1, j-1));
    return dp[i][j]=max(opt1, opt2);
}

int main()
{
    FASTIO;
    int n;
    ll sum=0;
    cin>>n;
    memset(dp, -1, sizeof dp);
    vector<int> arr(n+1);
    loop(i,1, n+1){
        cin>>arr[i];
        sum+=arr[i];
    }
    ll x=solve(arr, 1, n);
    cout<<2*x-sum;
    return 0;
}




Measured memory_bytes: 74096
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  ll N;
  cin >> N;

  vector<ll> a(N);
  for(ll i=0;i<N;i++) cin >> a[i];

  vector<ll> si(N);
  ll sum=0;
  for(ll i=0;i<N;i++){
    sum+=a[i];
    si[i]=sum;
  }

  ll p,q,r,s;
  ll n,m;
  ll ans=sum;

    
  for(ll i=1;i<N-2;i++){
    n=0;
    m=i;
    while(n+1<m){
      if(si[(n+m)/2]*2<si[i]){
	n=(n+m)/2;
      }else{
	m=(n+m)/2;
      }
    }
    if(abs(2*si[m]-si[i])<abs(2*si[n]-si[i])) n=m;
    p=si[n];q=si[i]-si[n];

    n=i+1;
    m=N-2;
    while(n+1<m){
      if((si[(n+m)/2]-si[i])*2<si[N-1]-si[i]){
	n=(n+m)/2;
      }else{
	m=(n+m)/2;
      }
    }
    if(abs(si[N-1]-2*si[m]+si[i])<abs(si[N-1]-2*si[n]+si[i])) n=m;
    r=si[n]-si[i];s=si[N-1]-si[n];

    ans=min(ans, max({p,q,r,s})-min({p,q,r,s}));
  }

  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	int n,k,used;
	cin >> n >> k;
	int res = 0;
	int l[100] = {0};
	
	for(int i = 0; i < n; i++) cin >> l[i];

	
	for(int j = 0; j < k; j++){
		int max = 0;
		for(int i = 0; i < n; i++){
			if(l[i] > max && l[i] != -1){
				max = l[i];
				used = i;
			}
		}
		res += max;
		l[used] = -1;
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,A,B;
    cin >> N >> A >> B;
    if(N<A+B-1 || A*B<N){
        cout << -1 << "\n";
        return 0;
    }
    int a = min(A,B),b = max(A,B);
    int last = N-1;
    vec<int> ans(N);
    int id = 0;
    int c = 0;
    for(int i=N-1;i-a+1>=0;i-=a){
        if(c+last+2-a<b) break;
        for(int j=i-a+1;j<=i;j++) ans[id++] = j;
        c++;
        last = i-a;
    }
//    cerr << last << "\n";
    for(int i=0;i<=last;i+=b-c){
        for(int j=i+(b-c)-1;j>=i;j--) if(j<=last) ans[id++] = j;
    }
    assert(id==N);
    if(A>B) for(int i=0;i<N;i++) ans[i] = N-1-ans[i];
    for(int i=0;i<N;i++) cout << ans[i]+1 << (i!=N-1? " ":"\n");
}

Measured memory_bytes: 4408
def main():
    s = input()
    ans = []
    
    for i in s:
        if i == '0' or i == '1':
            ans.append(i)
        elif i == 'B' and len(ans)>0:
            ans.pop()

    print(''.join(ans))

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

#define N_MAX 10000005

using namespace std;

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

const ll mod = 1e9 + 7;
const int inf = 1e9;
const long long INF = 1LL << 60;

int main()
{
    int n,k;
    cin >> n >> k;
    if(n >= 10){
        cout << k;
    }else{
        cout << (100 * (10 - n) + k);
    }
    
}

Measured memory_bytes: 256
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };
    let a: usize = sc.read();
    let b: usize = sc.read();
    let c: usize = sc.read();
    let mut t = vec![a, b, c];
    t.sort();
    println!("{}", t[0] * t[1] / 2);
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
n, k, q = gets.chop.split.map(&:to_i)
need = q - k + 1
if need <= 0
  n.times { puts 'Yes' }
  exit 0
end
s = []
q.times do
  a = gets.to_i
  s[a] = s[a].to_i + 1
end
(1..n).each do |i|
  puts s[i].to_i >= need ? 'Yes' : 'No'
end


Measured memory_bytes: 3196
#include <stdio.h>

int main()
{
   long int n, k, q;
   
   scanf("%ld%ld%ld", &n, &k, &q);
   
    int arr[n];
    for(long int i=0; i<=n; i++) {
        arr[i] = 0;
    }
    
    
    for(long int i=0; i<q; i++) {
        long int temp;
        scanf("%ld", &temp);
        arr[temp] += 1;
    }
    
    for(long int i=1; i<=n; i++) {
        if(arr[i]>(q-k)) {
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }

    return 0;
}


Measured memory_bytes: 896
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
from itertools import permutations
ans = []
for i,r in enumerate(permutations(range(1,n+1))):
    if all(p[j]==r[j] for j in range(n)):
        ans.append(i)
    if all(q[j]==r[j] for j in range(n)):
        ans.append(i)
ans = abs(ans[0]-ans[1])
print(ans)


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

using namespace std;

int a[1000001];

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    int mx = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        a[x]++;
        mx = max(mx, x);
    }
    int cnt = 0;
    for (int i = 0; i <= mx; ++i) {
        if (i == 0) {
            cnt = max(cnt, a[i] + a[i+1]);
        } else if (i > 0 && i != mx) {
            cnt = max(cnt, a[i-1]+a[i]+a[i+1]);
        } else {
            cnt = max(cnt, a[i-1] + a[i]);
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
using namespace std;
int f(int t1,int x1,int y1,int t2, int x2,int y2){
	int t=t2-t1;
	int d=abs(x2-x1)+abs(y2-y1);
	if(t>=d&&t%2==d%2){
		return 1;
	}
	else{
		return 0;
	}
}
int main(){
	int a[100100][3];
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	}
	for(int j=0;j<N;j++){
		if(j==0){
			if(f(0,0,0,a[0][0],a[0][1],a[0][2])==0){
				printf("No");
				return 0;
			}
		}
		else{
			if(f(a[j-1][0],a[j-1][1],a[j-1][2],a[j][0],a[j][1],a[j][2])==0){
				printf("No");
				return 0;
			}
		}
	}
	printf("Yes");
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
#define all(x) ((x).begin()),((x).end())
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
using pii = pair<int, int>;
int n, m;
int pref[330][330];
int32_t main()
{
    usecppio
    cin >> n >> m;
    for (int i = 1; i<=n; i++)
    {
        for (int j = 1; j<=m; j++)
        {
            int x;
            cin >> x;
            pref[i][x] = m-j+1;
        }
    }
    int best = INT_MAX;
    vector <int> choose;
    for (int i = 1; i<=m; i++)
        choose.push_back(i);
    for (int i = 0; i<m; i++)
    {
        vector <int> vv;
        int best_sport = 0, best_score = 0;
        int choice[330]; memset(choice, 0, sizeof(choice));
        for (int j = 1; j<=n; j++)
        {
            int u = 0, b = 0;
            for (auto it:choose)
            {
                if (pref[j][it]>u)
                {
                    u = pref[j][it];
                    b = it;
                }
            }
            choice[b]++;
        }
        best_sport = (max_element(choice+1, choice+m+1)-choice);
        best_score = choice[best_sport];
        best = min(best, best_score);
        for (auto it:choose)
            if (it != best_sport) 
              vv.push_back(it);
        choose = vv;
    }
    cout << best << '\n';
}

Measured memory_bytes: 640
import sys

lines = 2
inp = list()

for _ in range(lines):
    inp.append(sys.stdin.readline().strip())

a_lst = [int(i) for i in inp[1].split()]

alice = 0
bob = 0

for idx, i in enumerate(sorted(a_lst, reverse=True)):
    if idx % 2 == 0:
        alice += i
        continue
    bob += i

print(alice - bob)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

int main() {
    int n, k;
    cin >> n >> k;
    if ( (n-k)%(k-1) == 0 ) cout << (n-k)/(k-1) + 1 << endl;
    else                    cout << (n-k)/(k-1) + 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<cstdio>
using namespace std;
multiset<int>se;
int main(){
    int n,x;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&x),se.insert(x);
    int ans=0;
    while(se.size()>1){
        int x=*se.rbegin();
        se.erase(se.find(x));
        int now=1;
        while(now<=x) now<<=1;
        auto it=se.find(now-x);
        if(it==se.end()) continue;
        se.erase(it);
        ans++;
    }
    printf("%d",ans);
}


Measured memory_bytes: 9728
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

//map
int main()
{
    int H,W;

    while(true)
    {
        cin >> H >> W;
        if(H + W == 0)break;

        REP(i,H)
        {
            REP(j,W)
            {
                if(i % 2 == 0)
                {
                    if(j % 2 == 0)
                    {
                        cout << "#";
                    }
                    else
                    {
                        cout << ".";
                    }
                }
                else//i % 2 == 1
                {
                    if(j % 2 == 0)
                    {
                        cout << ".";
                    }
                    else
                    {
                        cout << "#";
                    }
                }
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3104
{-# LANGUAGE OverloadedStrings #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import           Data.Char


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las


main = do
    (a:b:c:d:e:f:[]) <- getLine
    putStrLn $ if c == d && e == f then "Yes" else "No"




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

int main() {
  long long int N = 0;
  long long int P = 0;
  long long int cnt_500 = 0;
  long long int cnt_5 = 0;
  cin >> N;
  cnt_500 = N / 500;
  N = N % 500;
  cnt_5 = N / 5;
  cout << cnt_500 * 1000 + cnt_5 * 5;
}


Measured memory_bytes: 256
from heapq import heappush,heappop
n,m=map(int,input().split())
li=[[]for i in range(10**5+1)]
for i in range(n):
    a,b=map(int,input().split())
    li[a].append(b)
li2=[]
#print(li)
ans=0
for i in range(1,m+1):
    for x in li[i]:
        heappush(li2,-x)
    if li2:
        ans+=heappop(li2)
    #print(li2)
   # print(ans)
print(-ans)
        

Measured memory_bytes: 18488
#include <stdio.h>

int main(void)
{
int a[3],i,M,N,L;
scanf("%d %d %d",&a[0],&a[1],&a[2]);
M=a[0]; N=a[0]; L=a[0];
for(i=0;i<3;i++){
	if(M>a[i]){
		M=a[i];
	}
	if(L<a[i]){
		L=a[i];
	}
}
N=a[0]+a[1]+a[2]-M-L;
printf("%d %d %d\n",M,N,L);
return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	int n;
	cin >> n;
	cout << n*(n+1)/2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    REP (i, N) {
        cin >> A[i] >> B[i];
    }
    SORT(A);
    SORT(B);
    int ans = 0;
    if (N % 2 == 0) {
        ans = B[N/2-1]+B[N/2] - (A[N/2-1]+A[N/2]) + 1;
    }
    else {
        ans = B[N/2] - A[N/2] + 1;
    }
    pa;
    

    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc169/abc169_e && sh test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc169/abc169_e && sh etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc169/abc169_e && sh submit_cpp.sh
*/


Measured memory_bytes: 6376
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A[3][3];

    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> A[i][j] ;
        }
    }

    int N;
    cin >> N;
    int B[N-1];
    
    for(int i = 0;i < N;i++){
        cin >> B[i];
    }

    bool C[3][3];

    for(int i = 0; i < 3; i++){//初期化
        for(int j = 0; j < 3; j++){
            C[i][j] = false;
        }
    }

    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3;j++){
            for(int x = 0; x < N; x++){
                if(A[i][j]==B[x]){
                    C[i][j] = true;
                }        
            }
        }
    }
    bool ans = false;

    for(int i = 0; i < 3; i++){
            if(C[i][0] == true && C[i][1] == true && C[i][2] == true){
                ans = true;
            }
            if(C[0][i] == true && C[1][i] == true && C[2][i] == true){
                ans = true;
            }
    }

    if(C[0][0] == true && C[1][1] == true && C[2][2] == true){
            ans = true;
    }
    else if(C[0][2] == true && C[1][1] == true && C[2][0] == true){
        ans = true;
    }

    if(ans == true) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256