akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>

using namespace std;

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

	for (int i = 0; i < 3; i++) {
		if (n[i] == '1') {
			cout << 9;
		}
		else{
			cout << 1;
		}
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>

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

        int a, b;
        std::cin >>  a;
        std::cin >>  b;

        if(1 <= a && a <= 9 && 1 <= b && b <= 9)
        {
                std::cout << a * b << std::endl;
        }
        else
        {
                std::cout << -1 << std::endl;
        }

        return 0;
}


Measured memory_bytes: 256
S=input()
T=input()
alp=[chr(i) for i in range(97, 97+26)]
words_T=[[] for _ in range(len(alp))]
words_S=[[] for _ in range(len(alp))]
num=0
for al in alp:
    for n in range(len(T)):
        if T[n]==al:
            words_T[num].append(n)
    num+=1
num=0
for al in alp:
    for n in range(len(T)):
        if S[n]==al:
            words_S[num].append(n)
    num+=1
flag=0
for word in words_T:
    if len(word)<=1:
        continue
    wo=S[word[0]]
    for w in word:
        if wo==S[w]:
            continue
        else:
            flag=1
            break
for word in words_S:
    if len(word)<=1:
        continue
    wo=T[word[0]]
    for w in word:
        if wo==T[w]:
            continue
        else:
            flag=1
            break
if flag==0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 91828
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>

using namespace std;

int main()
{
    int n,m,a[51]={0},x,y;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        if(x==y)a[x]-=2;
        a[x]++;
        a[y]++;
    }
    for(int i=1;i<=n;i++)
        cout<<a[i]<<endl;
}


Measured memory_bytes: 256
class Node:
    def __init__(self):
        """
        parent: Parent of the node
        left: Child of the node. THe most left
        right: Sibling of the note. The node next to the node (right side)
        """
        self.parent = None
        self.left = None
        self.right = None
        self.id = None
        self.depth = None
        self.type = None
    def __str__(self):
        if self.type == 'root':
            return 'parent = ' + str(-1) + ', depth = ' + str(self.depth) + ', ' + self.type
        else:
            return 'parent = ' + str(self.parent.id) + ', depth = ' + str(self.depth) + ', ' + self.type

def getDepth(node):
    """
    :param node: node
    :return: depth of the node (int)
    """
    depth = 0
    while node.parent is not None:
        node = node.parent
        depth += 1
    return depth

def getType(node):
    """
    :param node: node
    :return: node type (string)
    """
    if node.parent is None:
        return 'root'
    elif node.left is None:
        return 'leaf'
    else:
        return 'internal node'

def getChildren(node):
    """
    :param node: node
    :return: childrent of the node (list)
    """
    children = []
    result = [] # list of ids of children
    child = node.left
    while child is not None:
        children.append(child)
        child = child.right
    if not children:
        return '[]'
    for i in children:
        result.append(i.id)
    return result

n = int(input())
nodesDic = {}

for i in range(n):
    id, k, *c = map(int, input().split())
    # id がすでにあれば既存 node, なければ新規 node 作成
    if id not in nodesDic.keys():
        node = Node()
        nodesDic[id] = node
        node.id = id
    else:
        node = nodesDic[id]

    # c が empty (children なし) のとき
    if not c:
        pass
    else:
        # c の id の node が存在しなければ作成, right, parent を設定
        for j in range(len(c)-1, -1, -1): # c を末尾から読む (right の設定がこの for loop 内で可能(
            if c[j] not in nodesDic.keys():
                childNode = Node()
                nodesDic[c[j]] = childNode
                childNode.id = c[j]

            nodesDic[c[j]].parent = node
            if len(c) == 1 or j == len(c)-1: # c が要素 1 つのみのとき or 最も右側の node のとき
                pass
            else:
                nodesDic[c[j]].right = nodesDic[c[j+1]]
        node.left = nodesDic[c[0]]

for i in range(n):
    node = nodesDic[i]
    node.depth = getDepth(node)
    node.type = getType(node)
    children = getChildren(node)
    print('node', str(i) + ':', end=' ')
    print(node, end=', ')
    print(children)


Measured memory_bytes: 37324
h, w, k = map(int, input().split())

c = [0] * h

for i in range(h):
    c[i] = input()

cnt = 0

# ビット全探索
for rows in range(1 << h):
    for cols in range(1 << w):
        black = 0
        for i in range(h):
            if(rows >> i) % 2 == 1:
                continue
            for j in range(w):
                if(cols >> j) % 2 == 1:
                    continue
                black += c[i][j] == '#'
        if black == k:
            cnt += 1

print(cnt)

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

int main() {
    int H, W;
    while (cin >> W >> H, H || W) {
        int sx, sy, gx, gy;
        cin >> sx >> sy >> gx >> gy;
        int M;
        cin >> M;
        vector<vector<int> > d(W+1, vector<int>(H+1));
        vector<vector<int> > used(W+1, vector<int>(H+1));

        for (int i = 0; i < M; i++) {
            int c, dir, x, y;
            cin >> c >> dir >> x >> y;
            if (!dir) {
                for (int j = 0; j < 4; j++) {
                    for (int k = 0; k < 2; k++) {
                        d[x + j][y + k] = c;
                    }
                }
            } else {
                for (int j = 0; j < 2; j++) {
                    for (int k = 0; k < 4; k++) {
                        d[x + j][y + k] = c;
                    }
                }
            }
        }

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

        queue<int> qx, qy;
        qx.push(sx);
        qy.push(sy);

        while (qx.size()) {
            int x = qx.front(); qx.pop();
            int y = qy.front(); qy.pop();

            if (used[x][y]) continue;
            used[x][y] = 1;

            for (int i = 0; i < 4; i++) {
                int nx = x + dx[i];
                int ny = y + dy[i];

                if (0 < nx && nx <= W && 0 < ny && ny <= H && !used[nx][ny] && d[x][y] == d[nx][ny]) {
                    qx.push(nx);
                    qy.push(ny);
                }
            }
        }

        if (d[gx][gy] > 0 && used[gx][gy]) cout << "OK" << endl;
        else cout << "NG" << endl;
    }

    return 0;
}

Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
int n,m,c,x,a[105][105],i,j,l;
int main()
{
    cin>>n>>m>>c;
    for(int k=1;k<=c;k++)
    {
        cin>>x;
        while(x--)
        {
            a[i][j]=k;
            j+=(l?-1:1);
            if(l&&j==-1)l=0,i++,j=0;
            else if(!l&&j==m)l=1,i++,j=m-1;
        }
    }
    for(i=0;i<n;i++,cout<<'\n')
        for(j=0;j<m;j++)
            cout<<a[i][j]<<" ";
}


Measured memory_bytes: 384
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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 all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

bool solve(){  
  ll n,x;cin>>n>>x;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  ll ans=0;
  rep(i,n-1){
    if(a[i]+a[i+1]>x){
      ans+=a[i]+a[i+1]-x;
      a[i+1]=max((x-a[i]),(ll)0);
    }
  }
  cout<<ans<<endl;
  return false;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}


Measured memory_bytes: 1024
import math
K,A,B = map(int,input().split())
if A <= B:
  if K > A:
    print(-1)
  else:
    print(1)
else:
  n = (K-A)//(A-B)
  if n <= 0:
    print(1)
  else:
    if (A-B)*n+A >= K:
      print(2*n+1)
    else:
      print(2*n+3)

Measured memory_bytes: 3060
n, m = map(int, input().split())
am = [int(input()) for _ in range(m)]
hole = [False]*(n+1)

for i in am:
    hole[i] = True

dp = [0]*(n+1)
dp[0] = 1
for i in range(n):
    for j in range(i+1, min(n, i+2)+1):
        if not hole[j]:
            dp[j] += dp[i]
            dp[j] %=1000000007
print(dp[n])


Measured memory_bytes: 14296
# -*- coding: utf-8 -*-
import math
import sys
import itertools
import numpy as np
import functools
from collections import Counter
mo = 1000000007
r = range

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

c = Counter(a.tolist())

if n % 2 == 1 and (0 not in c or c[0] != 1):
    print(0)
    exit()

for i in r(n//2):
    x = i * 2 + (1 if n % 2 == 0 else 2)
    if x not in c or c[x] != 2:
        print(0)
        exit()

print(2 ** (n//2) % mo)

Measured memory_bytes: 23420
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main(){
  int W, a, b;
  cin >> W >> a >> b;
  if((a <= b && b <= a + W) || (a <= b + W && b + W <= a + W)){
    cout << 0 << endl;
    return 0;
  }

  cout << min(abs(a+W - b), abs(b+W - a)) << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
const int maxn = 100100;
typedef long long ll;
std::map<ll, ll> map;
int q;
ll a[maxn], s;
ll ans[maxn];
int main() {
	std::ios::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> *a >> q;
	for(int i = 1;i <= q;++i) std::cin >> a[i];
	map[a[q]] = 1;
	for(int i = q - 1;i >= 0;--i) {
		auto it = map.upper_bound(a[i]);
		for(auto j = it;j != map.end();++j) { 
			map[a[i]] += j -> first / a[i] * j -> second;
			map[j -> first % a[i]] += j -> second;
		}
		map.erase(it, map.end());
	}
	for(int i = *a;i >= 1;--i) ans[i] = ans[i + 1] + map[i];
	for(int i = 1;i <= *a;++i) std::cout << ans[i] << '\n';
}


Measured memory_bytes: 12416
#import sys
MOD = 10 ** 9 + 7
#input = sys.stdin.readline
import math

import itertools

#import bisect

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]
def main():
    x=int(input())
    sosu=0
    i=x
    while True:
        if sosuhante(i):
            sosu=i
            break
        i+=1
    print(sosu)












if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
a,b,c,x,y = map(int,input().split())

ans = max(x,y)*c*2
ans = min(ans,x*a+y*b)
temp = min(x,y)*c*2+(x-y)*a
if y > x:
    temp = min(x,y)*c*2+(y-x)*b
ans = min(ans,temp)

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		if (s.length() + 1 == t.length() && t.substring(0, t.length() - 1).equals(s)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 35672
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> pll;
pll arr[100005],arr1[100005];
vector<pair<ll,pll> > vect;
int root[100005];
int _rank[100005];

int findroot(int a){
	while(a!=root[a])
		a=root[a];
	return a;
}

void uni(int a, int b){
	int x=findroot(a);
	int y=findroot(b);
	if (_rank[x]>_rank[y]){
		root[y]=x;
	}
	else{
		root[x]=y;
		if (_rank[x]==_rank[y])
			_rank[y]+=1;
	}
}


int main(){
	for(int i=0;i<100005;i++)
		root[i]=i;
	int n; ll a,b;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lld%lld",&a,&b);
		arr[i].f=a; arr[i].s=i;
		arr1[i].f=b; arr1[i].s=i;
	}
	sort(arr,arr+n);
	for(int i=0;i<n-1;i++){
		vect.pb(mp((arr[i+1].f-arr[i].f),mp(arr[i+1].s,arr[i].s)));
	}
	sort(arr1,arr1+n);
	for(int i=0;i<n-1;i++){
		vect.pb(mp((arr1[i+1].f-arr1[i].f),mp(arr1[i+1].s,arr1[i].s)));
	}		
	ll ans=0;
	int len=vect.size();
	sort(vect.begin(),vect.end());
	for(int i=0;i<len;i++){
		if(findroot(vect[i].s.f)!=findroot(vect[i].s.s)){
			uni(vect[i].s.f,vect[i].s.s);
			ans+=vect[i].f;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 12016
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    B=[int(_) for _ in input().split()]
    ans=B[0]+B[-1]
    for i in range(n-2):
        ans+=min(B[i],B[i+1])
    print(ans)
if __name__=='__main__':
    main()

Measured memory_bytes: 3060
N = int(input())
H = list(map(int, input().split()))


def decreasing(number_list):
    n = len(number_list) - 1
    result = ["F"] * n
    for i in range(n):
        if number_list[i + 1] <= number_list[i]:
            result[i] = "T"

    return result


print(max(map(len, "".join(decreasing(H)).split("F"))))

Measured memory_bytes: 14252
#include<iostream>
using namespace std;
int main() {
  
  long long int n,a,b;
  scanf("%lld %lld %lld",&n,&a,&b);
  long long int t = n/(a+b);
  long long int bb = t*a;
  long long int p = n - t*(a+b);
  if(p<=a) {
    bb = bb + p;
  }
  else {
    bb = bb + a;
  }
  printf("%lld",bb);

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n;
	cin>>m;
	if(m!=1&&n!=1){
			cout<<"1"<<endl;
	}else if(m!=2&&n!=2){
			cout<<"2"<<endl;
	}else if(m!=3&&n!=3){	
		cout<<"3"<<endl;
	}
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys

N=input()
A=map(int, sys.stdin.readline().split())

dp=[ [ None for i in range(N) ]  for j in range(N) ]


for i in range(N-1,-1,-1):
	if N%2==0:
		dp[i][i]=A[i]*-1
	else:
		dp[i][i]=A[i]


for i in range(N-2,-1,-1):
	for j in range(i+1,N):
		t=N-(j-i+1)	#残りの要素数
		if t%2==0:
			if dp[i][j] is None : dp[i][j]=float("-inf")
			dp[i][j]=max(dp[i][j] , dp[i][j-1]+A[j])
			dp[i][j]=max(dp[i][j] , dp[i+1][j]+A[i])
		else:
			if dp[i][j] is None : dp[i][j]=float("inf")
			dp[i][j]=min(dp[i][j] , dp[i][j-1]-A[j])
			dp[i][j]=min(dp[i][j] , dp[i+1][j]-A[i])

print dp[0][N-1]


Measured memory_bytes: 174748
k, n = map(int, input().split())
a = list(map(int, input().split()))

d = 0
pre = a[0]
for i in a[1:]:
    if i - pre > d:
        d = i - pre
    pre = i
if k - a[-1] + a[0] > d:
    d = k - a[-1] + a[0]
print(k - d)


Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,h,m;
    cin>>a>>b>>h>>m;
    float hour=30.0*h+(m/2.0);
    float min=m*6;
    float diff=min-hour;
    //cout<<diff<<"\n";
    cout<<setprecision(12)<<sqrt(a*a+b*b-2*a*b*cos((M_PI*diff)/180.0));
}

Measured memory_bytes: 4196
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  string s,ans;
  for(int i=0;i<N;i++){
  cin>>s;
   if(s=="Y"){
     ans="Four";
     break;
   }else{
     ans="Three";
   }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
def uf_find(n,p):

    ufl = []

    while p[n] != n:
        ufl.append(n)
        n = p[n]

    for i in ufl:
        p[i] = n

    return n


def uf_union(a,b,p,rank,s):

    ap = uf_find(a,p)
    bp = uf_find(b,p)

    if ap == bp:
        return True
    else:

        if rank[ap] > rank[bp]:
            p[bp] = ap
            s[ap] += s[bp]
        elif rank[ap] < rank[bp]:
            p[ap] = bp
            s[bp] += s[ap]
        else:
            p[bp] = ap
            s[ap] += s[bp]
            rank[ap] += 1

        return False

from sys import stdin
N,M = map(int,stdin.readline().split())

p = [i for i in range(N)]
rank = [0] * N
s = [1] * N

for i in range(M):

    A,B = map(int,stdin.readline().split())
    A -= 1
    B -= 1
    uf_union(A,B,p,rank,s)

print (max(s))


Measured memory_bytes: 83672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=100005,INF=1<<30;

struct UF{
    int n;
    vector<int> par,size;
    
    void init(int n_){
        n=n_;
        par.assign(n,-1);
        size.assign(n,1);
        
        for(int i=0;i<n;i++){
            par[i]=i;
        }
    }
    
    int root(int a){
        if(par[a]==a) return a;
        else return par[a]=root(par[a]);
    }
    
    void unite(int a,int b){
        if(root(a)!=root(b)){
            size[root(a)]+=size[root(b)];
            par[root(b)]=root(a);
        }
    }
    
    bool check(int a,int b){
        return root(a)==root(b);
    }
};

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,M;cin>>N>>M;
    UF uf;
    uf.init(N);
    
    for(int i=0;i<M;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        uf.unite(a,b);
    }
    
    int ans=0;
    
    for(int i=0;i<N;i++) chmax(ans,uf.size[uf.root(i)]);
    
    cout<<ans<<endl;
}




Measured memory_bytes: 5028
nyuryoku = []

try:
    while True:
        s = input()
        if s == 0:
            break
        nyuryoku.append(s)

except EOFError:
    pass

for i in range(len(nyuryoku) - 1):
    print('Case ' + str(i + 1) + ": " + str(nyuryoku[i]))


Measured memory_bytes: 6228
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

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

        int N = scanner.nextInt();

        Integer[] nums = new Integer[N];

        for (int i = 0; i < N; i++) {
            nums[i] = scanner.nextInt();
        }

        Arrays.sort(nums, Collections.reverseOrder());
        
        int current = nums[0];
        int count = 1;

        for (int i = 1; i < N; i++) {
            if (current != nums[i]) {
                count++;
                current = nums[i];
            }
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <array>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    vector<ll> s(n);
    for (int i = 0; i < n; i++) {
        char c[11];
        cin >> c;

        ll x = 0;
        int y = 5 * 10;
        for (int j = 0; c[j]; j++) {
            x ^= (ll)(c[j] - 'a' + 1) << y;
            y -= 5;
        }
        s[i] = x;
    }
    sort(s.begin(), s.end());

    vector<int> c(n);
    ll t = 0;
    int k, l = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == t) {
            k++;
        } else {
            t = s[i];
            k = 0;
        }
        c[i] = k;
        l = max(l, k);
    }

    for (int i = 0; i < n; i++) {
        if (c[i] == l) {
            char c[11];
            ll x = s[i];
            int y = 5 * 10;
            for (int j = 0;; j++) {
                c[j] = x >> y & 31;
                if (c[j] == 0) {
                    cout << c << '\n';
                    break;
                } else {
                    c[j] += 'a' - 1;
                }
                y -= 5;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

int main()
{
	int n, m, x = 0, i = 1;
	cin >> n >> m;
	x = (1900 * m + (n - m) * 100) * pow(2, m);
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
#include <utility>
#include <vector>
#include <iostream>
#include <cstdlib>
#include<bits/stdc++.h>
#include <limits>
#include <set>
#include <map>
#include <string>
#include <sstream>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef unsigned long long ull;
ull gcd(ull a, ull b){return b? gcd(b, a%b):a;}
using namespace std;

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

	int X[N];
	int sum = 0;
	REP(i,N){
		cin >> X[i];
		sum += X[i];
	}
	int balance = (int)(sum/N)+1;
	int balance2 = balance-1;
	int balance3 = balance+1;
	if(balance2 <= 1){
		balance2 = 1;
	}
	if(balance3 >= 100){
		balance3 = 100;
	}
	
	int ans = 0;
	int ans2 = 0;
	int ans3 = 0;
	REP(i, N){
		ans += pow(balance - X[i], 2);
		ans2 += pow(balance2 -X[i], 2);
		ans3 += pow(balance3 -X[i], 2);
	}
	if(ans2 < ans){
		ans = ans2;
	}
	if(ans3 < ans){
		ans = ans3;
	}

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


Measured memory_bytes: 256
N, M, X = map(int, input().split())

A = list(map(int, input().split()))

#print(N, M, X)
#print(A)
num_left = len(list(filter(lambda a: X > a, A)))
num_right = len(list(filter(lambda a: X < a, A)))
#print(num_left)
#print(num_right)
result = num_left if num_left < num_right else num_right

print(result)


Measured memory_bytes: 2940
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>


#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s

typedef long long ll;

using namespace std;

vector<vector<int>> memoization(3, vector<int>(200003, -1));

int answer(string& s, int k, int ends_with) {
    if (memoization[ends_with][k] != -1) {  return memoization[ends_with][k]; }
    if (k==1) { return 1; }
    if (k<=0) { return 0;  }
    if (k==ends_with) {  return 1;  }
    int ret = 0;
    forr(i,1,2) {
        if (k >= ends_with+i) {
            if (s.substr(k-ends_with, ends_with) != s.substr(k-i-ends_with, i))
            ret = max(ret, 1+answer(s, k-ends_with, i));
        }
    }
    memoization[ends_with][k] = ret;
    return ret;
}

int main()   {
    cout.precision(17);
    ll modd = 1000 * 1000 * 1000 + 7;
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no
    ll infinit = 10000000000000000;


//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readstring(s);

        cout << max(answer(s, s.size(), 1), answer(s, s.size(), 2)) << endl;
    }
    return 0;
}


Measured memory_bytes: 33136
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<string> A;


  return (A != "AAA" && A != "BBB" ? "Yes" : "No");
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}


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

using namespace std;

int n;
double ans, x[10];
string u[10];

int main(){
	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> x[i] >> u[i];
	}
	for(int i = 0; i < n; ++i){
		if(u[i] == "JPY") ans += x[i];
		else ans += x[i] * 380000.0;
	}
	printf("%f\n", ans);
}

Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split()]

t = max(a)
b = []

for i in range(n):
  if t != a[i]:
    u = abs(t / 2 - a[i])
    b.append(u)
  else:
    b.append(t)

v = a[b.index(min(b))]
print(t, v)


Measured memory_bytes: 14052
from collections import deque

K = int(input())
LunLun = []
Q = deque()
dx = (-1, 0, 1)
for i in range(1, 10):
    LunLun.append(i)
    Q.append(i)

while len(LunLun) <= K:
    x = Q.popleft()
    y = x % 10
    for i in range(3):
        nx = y + dx[i]
        if (nx >= 0) and (nx <= 9):
            Q.append(10 * x + nx)
            LunLun.append(10 * x + nx)

print(LunLun[K-1])


Measured memory_bytes: 10620
while line = gets
  count = line.to_i - 1
  c = 100000 * 1.05
  count.times do
    c = c * 1.05 * 1.0
    tmp = c
    zzz = tmp % 1000
    zzz == 0 ? x = 0 : x = 1000
    c = tmp + x - zzz
  end
  printf("%d\n", c)
end

Measured memory_bytes: 8616
import sys,queue,math
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in input().split()]
_LI = lambda : [int(x)-1 for x in input().split()]

N,M = LI()
B = [_LI() for _ in range(M)]

g = [i for i in range(N)]
c = [1 for _ in range(N)]

def root(x):
    if x != g[x]: g[x] = root(g[x])
    return g[x]

def union(x,y):
    rx = root(x)
    ry = root(y)
    if rx != ry:
        if c[ry] > c[rx]: ry,rx = rx,ry
        g[ry] = rx
        c[rx] += c[ry]
        c[ry] = 0

ans = []
B.reverse()
for a,b in B:
    ra = root(a)
    rb = root(b)
    if ra == rb:
        ans.append(0)
    else:
        ans.append(c[ra]*c[rb])
        union(ra,rb)

ans.reverse()
x = 0
for a in ans:
    x += a
    print (x)

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

struct data {
    int let[26];
    data() {
        memset(let, 0, sizeof let);
    }
};

const int N = 500005;
data seg[4 * N];
string s;
int n;

void build(int node, int l, int r)
{
    if (l == r) {
        seg[node].let[s[l] - 'a']++;
        return ;
    }
    int mid, left, right;
    mid = l + (r - l) / 2;
    left = 2 * node;
    right = left + 1;
    build(left, l, mid);
    build(right, mid + 1, r);
    for (int i = 0; i < 26; i++) {
        seg[node].let[i] = seg[left].let[i] + seg[right].let[i];
    }
}

void update(int node, int l, int r, int i, char ch)
{
    if (l == r) {
        seg[node].let[s[l] - 'a']--;
        s[l] = ch;
        seg[node].let[s[l] - 'a']++;
        return ;
    }
    int mid, left, right;
    mid = l + (r - l) / 2;
    left = 2 * node;
    right = left + 1;
    if (i <= mid) update(left, l, mid, i, ch);
    else          update(right, mid + 1, r, i, ch);
    for (int i = 0; i < 26; i++) {
        seg[node].let[i] = seg[left].let[i] + seg[right].let[i];
    }
}

data query(int node, int l, int r, int i, int j)
{
    //cout << l << " " << r << '\n';
    data res;
    if (i > r || j < l) {
        return res;
    }
    if (i <= l && r <= j) {
        return seg[node];
    }
    int mid, left, right;
    mid = l + (r - l) / 2;
    left = 2 * node;
    right = left + 1;
    data r1 = query(left, l, mid, i, j);
    data r2 = query(right, mid + 1, r, i, j);
    for (int i = 0; i < 26; i++) {
        res.let[i] = r1.let[i] + r2.let[i];
    }
    return res;
}

int main( )
{
    cin >> n;
    cin >> s;
    build(1, 0, n - 1);
    int q, op, pos, l, r;
    char ch;
    cin >> q;
    while (q--) {
        cin >> op;
        if (op == 1) {
            cin >> pos >> ch;
            pos--;
            update(1, 0, n - 1, pos, ch);
        }
        else {
            cin >> l >> r;
            l--;
            r--;
            data res = query(1, 0, n - 1, l, r);
            int c = 0;
            for (int i = 0; i < 26; i++) {
                if (res.let[i] != 0) {
                    c++;
                }
            }
            cout << c << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 204036
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;

typedef pair<int,int> P;

int main(){
  int h,w,answ;
  P ans,input;

  while(cin >> h >> w,h||w){
    input = P(h*h+w*w,h);
    ans = P(-1,-1);
    for(int i=1;i<=150;i++){
      for(int j=i+1;j<=150;j++){
	P tmp = P(i*i+j*j,i);
	if(input < tmp){
	  if(ans.first < 0 || tmp < ans){
	    ans = tmp;
	    answ = j;
	  }
	}
      }
    }

    cout << ans.second << " " << answ << endl;
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


int main() {
	init();

	int N; cin >> N;
	vector<vector<pair<int, ll>>>G(N);
	rep(i, 0, N - 1) {
		int a, b, c; cin >> a >> b >> c;
		--a; --b;
		G[a].push_back({ b,c });
		G[b].push_back({ a,c });
	}

	int Q, K; cin >> Q >> K;
	queue<pair<int, ll>>que;
	vector<ll>dist(N, (ll)1e18);
	que.push({ K - 1,0 });
	dist[K - 1] = 0;
	while (!que.empty()) {
		auto hoge = que.front();
		que.pop();
		ll cost = hoge.second;
		for (auto v : G[hoge.first]) {
			if (chmin(dist[v.first], cost + v.second)) {
				que.push({ v.first,dist[v.first] });
			}
		}
	}

	rep(i, 0, Q) {
		int x, y; cin >> x >> y;
		--x; --y;
		cout << dist[x] + dist[y] << "\n";
	}

	return 0;
}


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

public class Main {

	final static int INPUT_COUNT = 2;

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

		int num[] = new int[INPUT_COUNT+1];

		for(int i=0;i<=INPUT_COUNT;i++){
			num[i] = scan.nextInt();
		}

		Arrays.sort(num);

		System.out.println(num[0] + " " + num[1] + " " + num[2]);

		scan.close();

	}
}

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

#define ll long long
#define ld long double
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
#define For(i, a, b) for(long long int i = (a); i <= (b); i++)
#define Forr(i, a, b) for(long long int i = (a); i >= (b); i--)
#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
const int MOD=1e9+7;
const ll dx[4]={-1, 0, 1, 0} , dy[4]={0, 1, 0, -1};
const ll dxx[8]={-1, -1, 0, 1, 1, 1, 0, -1} , dyy[8]={0, 1, 1, 1, 0, -1, -1, -1};
const int MAX=1e6+1;
int factor[MAX]={0};
void generatefactors(){
	factor[1] = 1; 
  
    // Initializes all the positions with their value. 
    for (int i = 2; i < MAX; i++) 
        factor[i] = i; 
  
    // Initializes all multiples of 2 with 2 
    for (int i = 4; i < MAX; i += 2) 
        factor[i] = 2; 
  
    // A modified version of Sieve of Eratosthenes to 
    // store the smallest prime factor that divides 
    // every number. 
    for (int i = 3; i * i < MAX; i++) { 
        // check if it has no prime factor. 
        if (factor[i] == i) { 
            // Initializes of j starting from i*i 
            for (int j = i * i; j < MAX; j += i) { 
                // if it has no prime factor before, then 
                // stores the smallest prime divisor 
                if (factor[j] == j) 
                    factor[j] = i; 
            } 
        } 
    } 
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;cin>>n;
	generatefactors();
	int maxans=1;
	For(i,2,n-1){
		int ans=1;
		int dup = factor[i]; 
	  
		// stores the count of number of times 
		// a prime number divides n. 
		int c = 1; 
	  
		// reduces to the next number after prime 
		// factorization of n 
		int j = i / factor[i]; 
	  
		// false when prime factorization is done 
		while (j != 1) { 
			// if the same prime number is dividing n, 
			// then we increase the count 
			if (factor[j] == dup) 
				c += 1; 
	  
			/* if its a new prime factor that is factorizing n,  
			   then we again set c=1 and change dup to the new  
			   prime factor, and apply the formula explained  
			   above. */
			else { 
				dup = factor[j]; 
				ans = ans * (c + 1); 
				c = 1; 
			} 
	  
			// prime factorizes a number 
			j = j / factor[j]; 
		} 
	  
		// for the last prime factor 
		ans = ans * (c + 1);
		maxans+=ans;
	}
    cout<<maxans;
	return 0;
}


Measured memory_bytes: 7552
import java.util.*;

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

        String s = sc.next();

        int ans = 0;

        switch(s){
            case "SSR":
            case "SRS":
            case "RSS":
            case "RSR":
                ans = 1;
                break;
            case "SRR":
            case "RRS":
                ans = 2;
                break;
            case "RRR":
                ans = 3;
                break;
        }

        System.out.print(ans);

    }
}


Measured memory_bytes: 35500
def abc177_c_2():
    n = int(input())
    a = list(map(int, input().split(' ')))

    mod = 10 ** 9 + 7
    ans = 0
    x = 0

    for i in range(n):
        ans = (ans + a[i] * x) % mod
        x = (x + a[i]) % mod

    print(ans)

if __name__ == '__main__':
    abc177_c_2()

Measured memory_bytes: 31576
// https://vjudge.net/contest/378535?fbclid=IwAR00nkK6t49s25Hz5fkmrsZcwz2RUlqKp9LeOpVaw3HpuhIcE_s5Gotpe60#problem/A
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define vv vector
#define pp pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define fastio                    \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);
typedef pair<ll, ll> pll;
typedef vv<ll> vll;
typedef vv<pll> vpll;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//adds two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set]
//(2)set.order_of_key(k)[count of elements strictly less than k]
#define LG(args...)                               \
	{                                             \
		string _s = #args;                        \
		replace(_s.begin(), _s.end(), ',', ' ');  \
		stringstream _ss(_s);                     \
		err(istream_iterator<string>(_ss), args); \
		cerr << endl;                             \
	}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "(" << *it << ":" << a << ") ";
	err(++it, args...);
}
//:::::::::::::::::::::::::::::::::::::::::::::
const ll INF = 9e18;
const ll MOD = 1e9 + 7;
// #define dbg

int main(){
	fastio;
	ll n;
	cin>>n;
	vll a(n);
	for(ll i=0; i<n; i++){
		cin>>a[i];
	}
	auto df=[](ll a, ll b){
		return abs(a-b);
	};
	vll dp(n,INF);
	dp[0]=0;
	dp[1]= df(a[0], a[1]);
	for(ll i=2; i<n; i++){
		dp[i] = min(dp[i-1]+ df(a[i-1], a[i]), dp[i-2]+df(a[i-2], a[i]));
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 4720
#include<bits/stdc++.h>
using namespace std;
#define int long long int
std::vector<int> v;

int32_t main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","rb",stdin);
    // #endif
    int n;
    string s;
    cin >> s;
    n = s.length();
    stack <char> st;
    int ans = 0;
    for(int i=0;i<n;i++){
         if(st.empty() || s[i]==st.top())st.push(s[i]);
         else if(s[i]!=st.top()){
            ans+=2;
            st.pop();
         }
    }
 cout << ans ;
return 0;
}

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

using namespace std;

#define pb push_back
#define pp pop_back
#define F first
#define S second
#define endl "\n"
#define m_p make_pair

typedef long long ll;
typedef long double ld;

void INeedIt() {
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int t[1001];
int main() {
	INeedIt();
	int n, m, sum=0;
	cin>>n;
	for (int i=1;i<=n;i++) {
		cin>>t[i];
		sum+=t[i];
	}
	cin>>m;
	for (int i=1;i<=m;i++) {
		int p, x;
		cin>>p>>x;
		cout<<sum-t[p]+x<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define se second
#define fr first
using namespace std;

const ll N = 2e5 + 7;
ll n , m , k , a , cnt , ans , b , c , d , sum , sum1 , mx , mx1;
vector<pair< ll , ll > >p;
map<ll , ll>mp;
int main()
{
    cin >> a >> b >> c >> d;
    cnt = a * d;
    ans = a * c;
    sum = b * c;
    sum1 = b * d;
    mx = max( cnt , ans );
    mx1 = max( sum , sum1 );
    cout << max( mx1 , mx );
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    ll n,k;
    in(n,k);
    vector<ll> vec(n);
    in(vec);
    for(int i=k;i<n;i++){
        yn(vec[i]>vec[i-k]);
    }
}

Measured memory_bytes: 4860
import java.util.Scanner;

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

		while (true) {
			int h = sc.nextInt();
			int w = sc.nextInt();
			if (h == 0 && w == 0) break;
			draw(h, w);
			System.out.println();
		}

	}

	public static void draw(int h, int w) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if(i%2 == 0) {
					if(j%2 == 0) System.out.print("#");
					else System.out.print(".");
				} else {
					if(j%2 == 0) System.out.print(".");
					else System.out.print("#");
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 26832
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans = min(a, b) + min(c, d);
    cout << ans << endl;
}


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

def solve():
    N, K = list(map(int, input().split()))
    Vs = list(map(int, input().split()))

    """方針
    Dequeueから宝石をとる。最後に好きなだけ宝石を戻す。
    dp[i][j] := 左からi個、右からj個取ったときの最大値
    """
    dp = [[0 for _ in range(K+1)] for __ in range(K+1)]
    dp[0][0] = 0  # dpを使ってなくて草

    ans = -float("inf")
    for i in range(0, K+1):
        for j in range(0, K+1):
            if i+j > K: break
            if i+j > N: break
            if i==0 and j==0:
                ans = 0
                continue

            hasVs = Vs[0:i] + Vs[N-j:N]
            hasVs.sort(reverse=True)

            restK = K - (i+j)
            while restK > 0:
                restK -= 1
                if hasVs == []:
                    break
                if hasVs[-1] < 0:
                    hasVs.pop(-1)
                    continue
                break

            ans = max(ans, sum(hasVs))

    print(ans)



if __name__ == "__main__":
    solve()


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

int main(){
  int N;
  cin >> N;
  vector<ll> T(N);
  for(int i = 0;i < N;i++)cin >> T[i];

  ll ans = 1;
  for(int i = 0;i < N;i++){
    ans = (T[i]/__gcd(ans,T[i]))*(ans/__gcd(ans,T[i]))*__gcd(ans,T[i]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int N;
  scanf("%d",&N);
  if(N<=999) {
    N = N%10%10;
    if(N==3) {
      printf("bon");
    }else if(N==0 || N==1 || N==6 || N==8) {
      printf("pon");
    }else {
      printf("hon");
    }
  }
  return 0;
}

Measured memory_bytes: 1724
def main():
    _ = int(input())
    a = [int(an) for an in input().split()]
    a.sort(reverse=True)
    line = -1
    lines = []
    for an in a:
        if line == an:
            lines.append(an)
            if len(lines) == 2:
                break
            line = -1
        else:
            line = an
    print(lines[0] * lines[1] if len(lines) == 2 else 0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20064
def main():
	N, K = map(int, input().split())
	S = input()
	current = "1"
	current_len = 0
	nums = []
	for i in range(N):
		if S[i] != current:
			nums.append(current_len)
			current_len = 1
			current = S[i]
		else:
			current_len += 1

	nums.append(current_len)
	if len(nums) %2 == 0:
		nums.append(0)

	distance = 2*K+1
	ans = 0
	left, right = 0, 0
	tmp = 0
	for i in range(0, len(nums), 2):
		next_left = i
		next_right = min(i+distance, len(nums))
		# move left
		while next_left > left:
			tmp -= nums[left]
			left += 1
		# move right
		while next_right > right:
			tmp += nums[right]
			right += 1
		ans = max(tmp, ans)

	print(ans)


if __name__ == '__main__':
    main()

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


int main() {
	int n, x;
	cin >> n >> x;
	vector<int> vec;
	vec.push_back(0);
	for(int i = 0; i < n; i++) {
		int l; cin >> l;
		vec.push_back(vec[i]+ l);
	}int res = 0;
	for(int i = 0; i <= n;i++) {
		if(vec[i] <= x) res++;
		else break;
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int64_t powi(int64_t base, int64_t index)
{
    int64_t ret = 1;
    for (int i = 0; i < index; i++)
    {
        ret *= base;
    }
    return ret;
}

int main()
{
    int64_t x;
    cin >> x;

    for (int64_t a = 1; a <= 1000; a++)
    {
        for (int64_t b = a - 1; - 1000 <= b; b--)
        {
            const auto left = powi(a, 5) - powi(b, 5);
            if (left == x)
            {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3168
n = int(input())
a = list(map(int, input().split()))
b = [0 for i in range(n)]
if n % 2 == 0:
    for i in range(n//2):
        b[i + n//2] = a[2*i]
        b[n//2 - i -1] = a[2*i+1]

else:
    b[n//2] = a[0]
    for i in range(n//2):
        b[1 + i + n//2] = a[2*i + 1]
        b[n//2 - i - 1] = a[2*i + 2]

ans = str(b[0])
for i in range(n-1):
    ans += " " + str(b[i+1])
print(ans)


Measured memory_bytes: 25748