akhauriyash/Code-Regression huggingface dataset:
using System;

namespace _0209
{
    class Program
    {
        static int n, m;
        static int[,] w = new int[100, 100];
        static int[,] p = new int[50, 50];
        static int[,] p90 = new int[50, 50];
        static int[,] p180 = new int[50, 50];
        static int[,] p270 = new int[50, 50];
        static void Main(string[] args)
        {
            while (ReadInput()) Solve();
        }

        static void Solve()
        {
            for (int i = 0; i <= n - m; i++)
            {
                for (int j = 0; j <= n - m; j++)
                {
                    int resX = 100, resY = 100;
                    Match(i, j, p, ref resX, ref resY);
                    Match(i, j, p90, ref resX, ref resY);
                    Match(i, j, p180, ref resX, ref resY);
                    Match(i, j, p270, ref resX, ref resY);
                    if (resX != 100)
                    {
                        Console.WriteLine("{1} {0}", resX + 1, resY + 1);
                        return;
                    }
                }
            }
            Console.WriteLine("NA");
        }

        static void Match(int x, int y, int[,] p, ref int resx, ref int resy)
        {
            int sx = -1, sy = -1;
            for (int i = 0; i < m; i++)
            {
                for (int j = 0; j < m; j++)
                {
                    var val = p[i, j];
                    if (val != -1)
                    {
                        if (sx == -1)
                        {
                            sx = x + i;
                            sy = y + j;
                        }
                        if (val != w[x + i, y + j]) return;
                    }
                }
            }
            if (sx < resx || (sx == resx && sy < resy))
            {
                resx = sx;
                resy = sy;
            }
        }

        static bool ReadInput()
        {
            var strs = Console.ReadLine().Split(' ');
            n = int.Parse(strs[0]);
            m = int.Parse(strs[1]);
            if (n == 0 && m == 0) return false;
            for (int i = 0; i < n; i++)
            {
                strs = Console.ReadLine().Split(' ');
                for (int j = 0; j < n; j++) w[i, j] = int.Parse(strs[j]);
            }
            for (int i = 0; i < m; i++)
            {
                strs = Console.ReadLine().Split(' ');
                for (int j = 0, temp = 0; j < m; temp++)
                {
                    try
                    {
                        var val = int.Parse(strs[temp].Trim());
                        var d = m - 1;
                        p[i, j] = val;
                        p90[-j + d, i] = val;
                        p180[-i + d, -j + d] = val;
                        p270[j, -i + d] = val;
                        j++;
                    }
                    catch { }
                }
            }
            return true;
        }
    }
}

Measured memory_bytes: 9508
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x, y, sum=0;
    cin>> x>> y;
    if(x==y && x==1) {
            cout<<1000000;
        return 0;
    }
    if(x==1) sum+=300000;
    if(y==1) sum+=300000;
    if(x==2) sum+=200000;
    if(y==2) sum+=200000;
    if(x==3) sum+=100000;
    if(y==3) sum+=100000;
    cout<< sum;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
typedef unordered_map<ll,ll> umap;
#define pb emplace_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;

int main(){
	ll n, inp, x=0, y=0, z=0, zs;
	double dp[305][305][305]={0}, mm;
	cin >> n;
	rep(i,1,n){
		cin >> inp;
		if(inp == 1) x++;
		if(inp == 2) y++;
		if(inp == 3) z++;
	}
	rep(s,1,n){
		rep(k,0,s){
			rep(j,0,s-k){
				ll i = s - j - k;
				mm = 0;
				if(i >= 1) mm += (1.0 + dp[i-1][j][k]) * i / n;
				if(j >= 1) mm += (1.0 + dp[i+1][j-1][k]) * j / n;
				if(k >= 1) mm += (1.0 + dp[i][j+1][k-1]) * k / n;
				dp[i][j][k] = (n * mm + n - s) / s;
			}
		}
	}
	cout << setprecision(13) << dp[x][y][z] << endl;
    return 0;
}


Measured memory_bytes: 221952
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

signed main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
    B.at(i) = A.at(i) - i - 1;
  }
  
  sort(B.begin(), B.end());
  int b = B.at(N / 2);

  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    ans += abs(B.at(i) - b);
  }
  
  cout << ans << endl;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/

int main()
{
    int n; cin >> n;
    set<int> A;
    rep(i,n){
        int Ai; cin >> Ai;
        A.insert(Ai);
    }
    int m; cin >> m;
    set<int> B;
    rep(i,m){
        int Bi; cin >> Bi;
        B.insert(Bi);
    }
    bool is = true;
    for(auto Bi: B){
        if(A.count(Bi) == 0){
            is = false;
            break;
        }
    }
    if(is) cout << 1 << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 21832
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int MOD=INF+7;
#define int ll
signed main(){
    int n; cin>>n;
    map<int, int>mp;
    vi v(n); rep(i,n){
        cin>>v[i];
        mp[v[i]]++;
    }
    if(n%2){
        bool flag=true;
        for(int i=2;i<=n; i+=2)
            if(mp[i]!=2)flag=false;
        if(flag&&mp[0]==1){
            int ans=1;
            rep(i,n/2){
                ans*=2;
                ans%=MOD;
            }
            cout<<ans<<endl;
        }
        else cout<<0<<endl;
        return 0;
    }else {
        bool flag=true;
        for(int i=1;i<=n; i+=2)
            if(mp[i]!=2)flag=false;
        if(flag){
            int ans=1;
            rep(i,n/2){
                ans*=2;
                ans%=MOD;
            }
            cout<<ans<<endl;
        }
        else cout<<0<<endl;
        return 0;
    }
    
}

Measured memory_bytes: 6144
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
static const int giga = pow(10,9);

int main(void){
  int a,b;
  char c;
  cin >> a >> c >> b;
  if(c == '+'){
    cout << a + b << endl;
  } else {
    cout << a - b << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define NMAX 100013
using namespace std;
int N, M, R, C, x, y, start;
int sol;
int dp[NMAX * 2][2];
string s;
pii Puncte[9];
long double dist(pii pe1, pii pe2) {
    return sqrt((double) (pe1.first - pe2.first) * (pe1.first - pe2.first) + (pe1.second - pe2.second) * (pe1.second - pe2.second));
}
pii operator +(pii pe1, pii pe2) {
    return {pe1.first + pe2.first, pe1.second + pe2.second};
}




int main() {
    cin >> s;
    if (s.length() == 1) {
        cout << 1;
        return 0;
    }
    dp[0][0] = dp[0][1] = 1;
    int N = s.length();
    for (int i = 1; i < N; ++i) {
        if (i >= 2) dp[i][0] = dp[i - 2][1] + 1;
        dp[i][1] = dp[i - 1][0] + 1;
        if (s[i] != s[i - 1]) {
            dp[i][0] = max(dp[i][0], dp[i - 1][0] + 1);
        }
        if (i >= 2 && i < N - 1) {
            if (s[i - 2] != s[i] || s[i - 1]  != s[i + 1])
                dp[i][1] = max(dp[i][1], dp[i - 2][1] + 1);
        }
    }
    sol = dp[N - 1][0];
    if (N >= 2) sol = max(sol, dp[N - 2][1]);
    cout << sol;
    return 0;
}


Measured memory_bytes: 2180
K, N = map(int, input().split())
A = list(map(int, input().split()))

L = []
for i in range(N):
    if (i < N - 1):
        L.append(A[i + 1] - A[i])
    elif (i == N - 1):
        L.append(K - A[i] + A[0])


print(sum(L) - max(L))


Measured memory_bytes: 26420
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>P;
long long MAX=1000000000;
char D[1010][1010];
int E[1010][1010];
int H,W;
int CH,CW;
int DH,DW;
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};

int bfs(int x,int y){
  E[x][y]=0;
  deque<P>que;
  que.push_front(P(x,y));
  
  while(que.size()){
    P p=que.front();que.pop_front();
    //cout<<p.first<<"***"<<p.second<<endl;
    
  
    for(int i=0;i<4;i++){
      int nx=p.first+dx[i],ny=p.second+dy[i];
        //コスト０で移動できる場合フロントに挿入する
      if(D[nx][ny]=='.' && E[nx][ny]>E[p.first][p.second] && 0<=nx && nx<H && 0<=ny && ny<W){
          que.push_front(P(nx,ny));
          E[nx][ny]=E[p.first][p.second];
       //cout<<nx<<" "<<ny<<"!"<<E[nx][ny]<<endl;
      }
    }
    
    //５×５を探索する
    //cout<<"###"<<endl;
    for(int j=p.first-2;j<=p.first+2;j++){
      for(int k=p.second-2;k<=p.second+2;k++){
        if(0<=j && j<H && 0<=k && k<W && E[j][k]>E[p.first][p.second]+1 && D[j][k]=='.'){
          que.push_back(P(j,k));
          E[j][k]=E[p.first][p.second]+1;
        }
      }
    }
  }
  return 0;
}

int main(){
  cin>>H>>W;
  cin>>CH>>CW;
  CH--;CW--;
  cin>>DH>>DW;
  DH--;DW--;
  
  //Eを最大値で初期化
  for(int i=0;i<1005;i++){
    for(int j=0;j<1005;j++){
      E[i][j]=MAX;
    }
  }
  
  //グリッド入力
  string S;
  for(int i=0;i<H;i++){
    cin>>S;    
    for(int j=0;j<W;j++){
      D[i][j]=S.at(j);
    }
  }
  
  bfs(CH,CW);
  if(E[DH][DW]==MAX){
    cout<<-1<<endl;
  }
  else{
    cout<<E[DH][DW]<<endl;
  }
  return 0;
}


Measured memory_bytes: 8608
#include <bits/stdc++.h>
using namespace std;
int main(){
	int X, N; cin >> X >> N; 
	int P[114514] = {}; 
	for(int i = 0; i < N; i++){
		int p; cin >> p; P[p] ++; 
	}
	for(int d = 0; d <= 114514; d++){
		if(X - d < 0){
			cout << X - d << endl; return 0; 
		}
		if(P[X - d] == 0){
			cout << X - d << endl; return 0;
		}
		if(P[X + d] == 0){
			cout << X + d << endl; return 0;
		}
	}
}

Measured memory_bytes: 4080
alp = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ALP = list(alp)

che = 'XYZABCDEFGHIJKLMNOPQRSTUVW'
CHE = list(che)

d = input()
D = list(d)

for i in range(len(D)):
    for j in range(len(ALP)):
        if D[i] == ALP[j]:
            D[i] = CHE[j]
            break

D = ''.join(D)
print(D)


Measured memory_bytes: 5568
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		boolean kk=false;
		boolean uu=false;
		if(s.charAt(0)=='0'){
			if(s.charAt(1)-'0'>=1 && s.charAt(1)-'0'<=9){
				kk=true;
			}
		}
		if(s.charAt(0)=='1'){
			if(s.charAt(1)-'0'<=2 && s.charAt(1)-'0'>=0){
				kk=true;
			}
		}
		if(s.charAt(2)=='0'){
			if(s.charAt(3)-'0'>=1 && s.charAt(3)-'0'<=9){
				uu=true;
			}
		}
		if(s.charAt(2)=='1'){
			if(s.charAt(3)-'0'<=2 && s.charAt(3)-'0'>=0){
				uu=true;
			}
		}
		if(kk && uu){
			System.out.println("AMBIGUOUS");
		}else if(kk){
			System.out.println("MMYY");
		}else if(uu){
			System.out.println("YYMM");
		}else{
			System.out.println("NA");
		}
	}
}


Measured memory_bytes: 21844
#include<iostream>

using namespace std;

int main(){

	int A;
	int B;
	int C;

	cin >> A >> B >> C;

	if(A == B){
		cout << C << endl;
	}

	if(B == C){
		cout << A << endl;
	}

	if(C == A){
		cout << B << endl;
	}

	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ctime>
#include <set>
#include <sstream>
#include <bitset>
#define fi first
#define se second
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define MAXN 200009
using namespace std;

int main () {
    double len;
    int r;
    cin>>r;
    len = 2.0 * r * 3.14;
    cout<<len;
}


Measured memory_bytes: 3784
# -*- coding: utf-8 -*-
import sys
from collections import Counter, defaultdict
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline


class RollingHash():
    """
    Original code is https://tjkendev.github.io/procon-library/python/string/rolling_hash.html
    """
    class RH():
        def __init__(self, s, base, mod):
            self.base = base
            self.mod = mod
            self.rev = pow(base, mod-2, mod)

            l = len(s)
            self.h = h = [0]*(l+1)
            tmp = 0
            for i in range(l):
                num = ord(s[i])
                tmp = (tmp*base + num) % mod
                h[i+1] = tmp

            self.pw = pw = [1]*(len(s)+1)
            v = 1
            for i in range(l):
                pw[i+1] = v = v * base % mod

        def calc(self, l, r):
            return (self.h[r] - self.h[l] * self.pw[r-l]) % self.mod

    @staticmethod
    def gen(a, b, num):
        result = set()
        while 1:
            import random
            import math
            random.seed()
            while 1:
                v = random.randint(a, b)//2*2+1
                if v not in result:
                    break
            for x in range(3, int(math.sqrt(v))+1, 2):
                if v % x == 0:
                    break
            else:
                result.add(v)
                if len(result) == num:
                    break
        return result

    def __init__(self, s, rand=False, num=5):
        if rand:
            bases = RollingHash.gen(2, 10**3, num)
        else:
            assert num <= 10
            bases = [641, 103, 661, 293, 547, 311, 29, 457, 613, 599][:num]

        MOD = 10**9+7
        self.rhs = [self.RH(s, b, MOD) for b in bases]

    def calc(self, l, r):
        return tuple(rh.calc(l, r) for rh in self.rhs)


class Bisect:
    def __init__(self, func):
        self.__func = func

    def bisect_left(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if self.__func(mid) < x:
                lo = mid+1
            else:
                hi = mid
        return lo

    def bisect_right(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if x < self.__func(mid):
                hi = mid
            else:
                lo = mid+1
        return lo


def slv(N, S):
    srh = RollingHash(S)

    def f(m):
        h2i = defaultdict(list)
        for i in range(N-m+1):
            j = i + m
            h = srh.calc(i, j)
            h2i[h].append(i)

        for l in h2i.values():
            n = l[-1] - l[0]
            if n >= m:
                return 0
        return 1

    return Bisect(f).bisect_right(0, 1, N//2+1) - 1


def main():
    N = int(input())
    S = input()
    print(slv(N, S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 50012
N,K=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**10]*(N)#dp[i]→i+1番目の柱にくる最小コスト
dp[0]=0
for i in range(N-1):
    dp[i+1]=min(dp[i+1-j]+abs(h[i+1]-h[i+1-j]) for j in range(1,min(i+1,K)+1))
print(dp[N-1])

Measured memory_bytes: 53344
a = [int(input()) for _ in range(5)]
r_min = 10
r_idx = -1
res = 0
for i in range(len(a)):
  r_ = a[i] % 10
  res += (a[i] // 10) * 10 + int(r_ > 0) * 10
  if r_ == 0:
    r_ = 10
  if r_ < r_min:
    r_min = r_
    r_idx = i

if r_min < 10:
  res -= 10 - r_min
print(res)

Measured memory_bytes: 3064
#include<stdio.h>
char exchange(char);
int main(void)
{
  char c='\0';
  while(c!='\n')
    {
      scanf("%c",&c);
      printf("%c",exchange(c));
    }
  return 0;
}
char exchange(char c)
{
  if(c>='A'&&c<='Z') return c+'a'-'A';
  else if(c>='a'&&c<='z') return c+'A'-'a';
  return c;
}


Measured memory_bytes: 2112
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Contest
{
	class Program
	{
		static void Main()
		{
            var NM = Console.ReadLine().Split().Select(int.Parse);
            int N = NM.First(), M = NM.Last();
            long ans = (Permutation(N) * Permutation(M)) % (long)(1e9 + 7);
            if (Math.Abs(N - M) > 1)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(N == M ? ans * 2 % (long)(1e9 + 7) : ans);
            }
#if DEBUG
            Console.ReadKey();
#endif
		}

        static long Permutation(int arg)
        {
            long num = arg;
            for (int i = arg - 1; i > 1; i--)
            {
                num = (num * i) % (long)(1e9 + 7);
            }
            return num;
        }
	}
}

Measured memory_bytes: 11348
#include <stdio.h>
int main() {
	int n, cnt[5];
	long long ans = 0;
	for (int i = 0; i < 5; i++) {
		cnt[i] = 0;
	}
	char s[11];
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", s);
		switch (s[0]) {
			case 'M':
				cnt[0]++;
				break;
			case 'A':
				cnt[1]++;
				break;
			case 'R':
				cnt[2]++;
				break;
			case 'C':
				cnt[3]++;
				break;
			case 'H':
				cnt[4]++;
				break;
			default:
				break;
		}
	}
	for (int i = 0; i < 5; i++) {
		for (int j = i + 1; j < 5; j++) {
			for (int k = j + 1; k < 5; k++) {
				ans += (long long)cnt[i] * cnt[j] * cnt[k];
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
# https://twitter.com/tempura_cpp/status/1259483252919635969

n, k = gets.to_s.split.map{|e|e.to_i}
a = [0] + gets.to_s.split.map{|e|e.to_i}

c = 1

while k > 0
  
  c = a[c] if k & 1 > 0
  
  na = Array.new(n+1)
  
  (n+1).times{ |i| na[i] = a[a[i]] }
  
  a = na.dup
  k >>= 1
end

puts c

Measured memory_bytes: 82620
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
 
function main(){
  var waitTime = calc();
  for(var i = 0, len = input.length - 1; i < len;i++){
    console.log(waitTime[parseInt(input[i], 10)]);
  }
}
 
function calc(){
  var seats = new Int32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);
  var groupMembers = new Int32Array([2,5,2,2,2]);
  var eatTimes = new Int32Array([19,39,25,36,22,42]);
   
  var headGroup = -1;
  var pastMinutes = 0;
  var waitTime = new Int32Array(100);
  var lastMembers = 100;
   
  while(true){
    // たべおわる
    var i;
    for(i = 17; i--;){
      seats[i] = max(--seats[i], 0);
    }
     
    // 来店
    if(headGroup == -1 && pastMinutes % 5 == 0){
      headGroup = pastMinutes / 5;
    }
     
    // ちゃくせき
    while(headGroup != -1 && i != 17){
      var needsSequencialSeats = groupMembers[headGroup % 5];
      var sequencialSeats = 0;
      var startIndex = -1;
       
      for(i = 0; i < 17; i++){
        sequencialSeats = seats[i] == 0 ? sequencialSeats + 1 : 0;
         
        if(sequencialSeats == needsSequencialSeats){
          var eatTime = eatTimes[headGroup % 6];
 
          startIndex = i - (needsSequencialSeats - 1);
          // すわれるみたい
          waitTime[headGroup] = pastMinutes - (headGroup * 5);
          for(var j = startIndex, len = (needsSequencialSeats + startIndex); j < len; j++){
            seats[j] = eatTime;
          }
           
          headGroup = (((headGroup + 1) * 5) <= pastMinutes) ? headGroup + 1 : -1;
          if(!(--lastMembers)){
            // 100グループ着席
            return waitTime;
          }
          break;
        }
      }
    }
     
    pastMinutes++;
  }
   
}
 
function max(a, b){
  var t = (a - b);
  return a - (t & (t >> 31));
}

Measured memory_bytes: 8444
# https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/9/ALDS1_9_B

def max_heapify(A, i):
    left = 2 * i + 1
    right = 2 * i + 2
    if left < len(A) and A[left] > A[i]:
        largest = left
    else:
        largest = i
    if right < len(A) and A[right] > A[largest]:
        largest = right

    if largest != i:
        A[largest], A[i] = A[i], A[largest]
        max_heapify(A, largest)


def main():
    h = int(input())
    A = [int(i) for i in input().split()]
    for i in range(0, h // 2)[::-1]:
        max_heapify(A, i)

    print(" " + " ".join([str(i) for i in A]))


if __name__ == "__main__":
    main()



Measured memory_bytes: 63992
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
using namespace std;

vector<vector<pair<int,int> > > adj;
vector<bool> already;
vector<long long int> cost;
void dfs(int cur,long long int c){
	cost[cur] = c;
	already[cur]=true;
	for(int i=0; i<(int)adj[cur].size(); i++){
		if(!already[adj[cur][i].first]){
			dfs(adj[cur][i].first, c+adj[cur][i].second);
		}
	}
}

int main(){
	int n;
	cin >> n;
	adj.resize(n+1);
	cost.resize(n+1);
	already.resize(n+1);
	for(int i=0; i<n-1; i++){
		int a,b,c;
		cin >> a >> b >> c;
		adj[a].push_back(make_pair(b,c));
		adj[b].push_back(make_pair(a,c));
	}
	
	int q,k;
	cin >> q >> k;
	for(int i=0; i<=n; i++){
		already[i] = false;
	}
	dfs(k, 0);
	
	for(int i=0; i<q; i++){
		int x,y;
		cin >> x >> y;
		cout << cost[x] + cost[y] << endl;
	}
	
	return 0;
}
	

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string st1,st2;
  cin>>st1>>st2;
  int r=0;
  int len=st1.size();
  for(int i=0;i<len;i++)
  {
    if(st1[i]!=st2[i])r++;
  }
  cout<<r<<endl;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;


int main(){
   int n; cin >> n;
   vector<ll> a(n);
   REP(i,n) cin >> a[i];
   deque<ll> b;
   if(n%2){
       REP(i,n){
           if(i%2) b.push_back(a[i]);
           else b.push_front(a[i]);
       }
   } else {
       REP(i,n){
           if(i%2) b.push_front(a[i]);
           else b.push_back(a[i]);
       }
   }

  REP(i,b.size()){
      cout << b[i];
      if(i != b.size()-1) cout << " ";
  }
  cout << endl;
}

Measured memory_bytes: 5376
// Problem : B - Multiple of 9
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb push_back
#define mk make_pair
#define fast                    \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define rep(i, a, b) for (ll i = a; i < b; i++)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define sz(x) (int)x.size()
#define mem(a, val) memset(a, val, sizeof(a))
#define deci(x) cout << fixed << setprecision(x);
#define bitcount(x) __builtin_popcountll(x)

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

const long long int mod = 1e9 + 7;
const long double EPS = 1e-12;
const int N = 1e5 + 20;

void solve() {
  ll sum = 0;
  string s;
  cin >> s;
  for (auto i : s) sum = (sum + (i - '0')) % 9;
  if (sum)
    cout << "No";
  else
    cout << "Yes";
}
int main() {
  fast;
  ll t;
  t = 1;

  // cin>>t;

  while (t--) {
    solve();
  }

  return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SMALLPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
ll inf=1000000007;
const int mod=1000000007;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}
int main(){
  int n;cin>>n;
  ll ans=0;
  vi v(n);
  rep(i,n)cin>>v[i];
  sort(all(v));
  rep(j,n){
    REP(k,j+1,n){
      int d=v[k]-v[j],s=v[k]+v[j];
      auto itl=lower_bound(all(v),d+1);
      auto itr=lower_bound(all(v),s);
      int l=distance(v.begin(),itl);
      int r=distance(v.begin(),itr)-1;
      ans+=r-l+1;
      if(v[l]<=v[k]&&v[k]<=v[r])ans--;
      if(v[l]<=v[j]&&v[j]<=v[r])ans--;
    }
  }
  cout<<ans/3<<endl;
}

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

using namespace std;

const int RIGHT  = 0;
const int CENTER = 1;
const int LEFT   = 2;

const int64_t MOD = 998244353;

int64_t F(int n) {
  static unordered_map<int, int64_t> cache;
  if (cache.find(n) != cache.end()) {
    return cache[n];
  }

  if (n <= 1) {
    return cache[n] = 1;
  } else {
    return cache[n] = F(n - 1) * n % MOD;
  }
}

int main() {
  int64_t L;
  cin >> L;
  string S;
  cin >> S;

  unordered_map<char, int64_t> m;
  int64_t result = F(L);
  int64_t openL = 0;
  int64_t openC = 0;

  string RGB = "RGB";
  for (char c : S) {
    int current_pos = 0;
    for (int i = 0; i < 3; i++) {
      char other = RGB[i];
      if (c == other) continue;
      if (m[c] >= m[other]) current_pos++;
    }
    m[c]++;

    if (current_pos == LEFT) {
      openL += 1;
    } else if (current_pos == CENTER) {
      openC += 1;
      result *= openL;
      result %= MOD;
      openL--;
    } else {
      result *= openC;
      result %= MOD;
      openC--;
    }
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 7836
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define double long double
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define sort(a) sort(all(a))
#define rsort(a) sort(all(a),greater<>())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T> inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<int,int> P;
const long long MOD=1000000007;
clock_t time_ini = clock();
double time_diff(){
  ll time_tmp = clock();
  const double time = static_cast<double>(time_tmp - time_ini) / CLOCKS_PER_SEC * 1000.0;
  return time;
}
#define saiaku if(time_diff() > 1990)
vector <ll> dp;
vector <ll> H;

void solve(long long N, long long K, std::vector<long long> h){
  if(N<=K) K = N-1;
  dp = vector<ll> (N+1, 0);
  for (ll i = 1; i <= K; i++)
  {
    dp[i] = abs(h[i]-h[0]);
  }

  for (ll i = K+1; i < N; i++)
  {
    vector<ll> d;
    for (ll j = 1; j <= K; j++)
    {
      d.push_back(dp[i-j] + abs(h[i] - h[i-j]));
    }
    dp[i] = *min_element(d.begin(), d.end());
  }
  cout << dp[N-1] << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> h(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&h[i]);
    }
    solve(N, K, std::move(h));
    return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, Cost[505][505];
bool occupy[505][505];
int di[4] = {0,1,0,-1}, dj[4] = {1,0,-1,0};

int DFS(int i, int j){
  int now = Cost[i][j] + occupy[i][j];
  for (int k = 0; k < 4; k++){
    int I = i + di[k], J = j + dj[k];
    if (1 <= I && I <= N && 1 <= J && J <= N){
      if (Cost[I][J] > now){
        Cost[I][J] = now;
        DFS(I, J);
      }
    }
  }
  return 0;
}

int main(){
  cin >> N;
  for (int i = 1; i <= N; i++){
    for (int j = 1; j <= N; j++){
      Cost[i][j] = min(min(i, N + 1 - i), min(j, N + 1 - j)) - 1;
      occupy[i][j] = true;
    }
  }

  int ans = 0;
  for (int i = 0; i < N * N; i++){
    int P; cin >> P;
    int I = (P + N - 1) / N, J = P % N;
    if (J == 0) J = N;
    ans += Cost[I][J];
    occupy[I][J] = false;
    DFS(I, J);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 24100
#include <bits/stdc++.h>
#define INF 1023456789
#define sacnf scanf
#define scnf scanf
#define scnaf scanf
#define CRLF <<'\n';
#define ALL(v) v.begin,v.end()
#define SIZE(v) (int)v.size()
#define PRPAIR(x) x.first << x.second
#define DEBUG(x) do { std::cerr <<(x)<<'\n'; } while (0)
#define rep(i,a,b) for(int i=(a);i!=(int)b-((a)>(b));(a)>(b)?--i:++i)
using namespace std;
typedef pair<int,int> ii;
typedef pair<int,ii> pip;
typedef vector<int> vi;
typedef long long ll;
typedef tuple<int,int,int> t;


int main(){
    int n;
    scanf("%d",&n);
    ll arr[n];
    rep(i,0,n){
        scanf("%lld",&arr[i]);
    }
    int c=0;
    rep(i,0,n-2){
        rep(j,i+1,n-1){
            rep(k,j+1,n){
                if (arr[i] != arr[j] && arr[j] != arr[k] && arr[i] != arr[k])
                if (arr[i] + arr[j] > arr[k] && arr[j]+arr[k] > arr[i] && arr[k]+arr[i] > arr[j]){
                    c++;
                }
            }
        }
    }
    cout << c;
}


Measured memory_bytes: 3768
#include<iostream>
#include<complex>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<cstring>
#include<list>

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)
#define fs first
#define sc second
#define pb push_back
#define sz size()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define MAX_V 1000

using namespace std;

typedef complex<double> P;

const int dim = 2;
double dot(P x,P y){return real(conj(x)*y);}

struct min_ball {
  P center;
  double radius2;
  void add(const P& p) {
    ps.push_back(p);
  }
  void compile() {
    m = 0;
    center = P(0,0);
    radius2 = -1;
    make_ball(ps.end());
  }

  list<P> ps;
  list<P>::iterator supp_end;
  int m;
  P v[dim+1], c[dim+1];
  double z[dim+1], r[dim+1];
  void pop() { --m; }
  void push(const P& p) {
    if (m == 0) {
      c[0] = p; r[0] = 0;
    } else {
      double tmp = abs(p-c[m-1]);
      double e = tmp*tmp - r[m-1];
      P delta = p - c[0];
      v[m] = p - c[0];
      for (int i = 1; i < m; ++i)
        v[m] -= v[i] * dot(v[i], delta) / z[i];
      z[m] = dot(v[m], v[m]);
      c[m] = c[m-1] + e*v[m]*(1.0/z[m]/2.0);
      r[m] = r[m-1] + e*e/z[m]/4.0;
    }
    center  = c[m];
    radius2 = r[m]; ++m;
  }
  void make_ball(list<P>::iterator i) {
    supp_end = ps.begin();
    if (m == dim + 1) return;
    for (list<P>::iterator k = ps.begin(); k != i; ) {
      list<P>::iterator j = k++;
      double tmp = abs(*j-center);
      if (tmp*tmp > radius2) {
        push(*j); make_ball(j); pop();
        move_to_front(j);
      }
    }
  }
  void move_to_front(list<P>::iterator j) {
    if (supp_end == j) ++supp_end;
    ps.splice (ps.begin(), ps, j);
  }
};

int n,m,p;
int r[110];
double d[110];
int use1[110],use2[110];
P ver;

int main(){
  cin >> n >> m;
  for(int i=0;i<n;i++){
    cin >> r[i];
    r[i] = r[i]*r[i];
  }

  for(int i=0;i<m;i++){
    cin >> p;
    min_ball ball;
    for(int j=0;j<p;j++){
      cin >> ver.real() >> ver.imag();    
      ball.add(ver);
    }
    ball.compile();
    d[i] = ball.radius2;
  }

  for(int i=0;i<n;i++)use1[i] = false;

  for(int i=0;i<m;i++){
    int j;
    for(j=0;j<n;j++){
      if(!use1[j] && d[i] < r[j]+EPS){
	use1[j] = true;
	bool f = true;
	for(int k=0;k<n;k++)use2[k] = use1[k];
	for(int k=i+1;k<m;k++){
	  int id = -1;
	  for(int l=0;l<n;l++){
	    if(!use2[l] && d[k] < r[l]+EPS)
	      if( id<0 || r[l] < r[id] )id = l;
	  }
	  if(id<0){
	    f = false;
	    break;
	  }else use2[id] = true;
	}
	if(f){
	  cout << j+1 << endl;
	  break;
	}else use1[j] = false;
      }
    }
    if(j==n){
      cout << "NG\n";
      return 0;
    }
  }
}

Measured memory_bytes: 1260
#include <cstdio>
#include <algorithm>
using namespace std;
inline char gc() {
    static char now[1 << 16], *S, *T;
    if (S == T) {T = (S = now) + fread(now, 1, 1 << 16, stdin); if (S == T) return EOF;}
    return *S++;
}
inline int read() {
    int x = 0; char c = gc();
    while (c < '0' || c > '9') c = gc();
    while (c >= '0' && c <= '9') {x = x * 10 + c - 48; c = gc();}
    return x;
}
struct Query {int l, r, id;} q[500010];
int a[500010], pos[1000010], las[500010], BIT[500010], ans[500010];
int n, m;
inline bool cmp(Query A, Query B) {return A.r < B.r;}
inline void add(int x, int v) {for (; x <= n; x += x & -x) BIT[x] += v;}
inline int query(int x) {int ret = 0; for (; x; x -= x & -x) ret += BIT[x]; return ret;}
int main() {
    n = read();
    m = read();
    for (int i = 1; i <= n; ++i) a[i] = read();
    for (int i = 1; i <= n; ++i) las[i] = pos[a[i]], pos[a[i]] = i;
    for (int i = 1; i <= m; ++i)
    {q[i].l = read(); q[i].r = read(); q[i].id = i;}
    sort(q + 1, q + m + 1, cmp); int cur = 0;
    for (int i = 1; i <= m; ++i) {
        while (cur < q[i].r) {
            ++cur;
            add(cur, 1); if (las[cur]) add(las[cur], -1);
        }
        ans[q[i].id] = query(q[i].r) - query(q[i].l - 1);
    }
    for (int i = 1; i <= m; ++i) printf("%d\n", ans[i]);
    return 0;
}


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

int main() {
	int n, a, b;
	string s;
	cin >> n >> a >> b >> s;

	s = "#" + s;
	int pass = 0, frank = 0;

	for ( int i = 1; i <= n; i++ ) {
		if ( s[i] == 'a' ) {
			if ( pass < a + b ) {
				cout << "Yes" << endl;
				pass++;
			}
			else {
				cout << "No" << endl;
			}
		}

		if ( s[i] == 'b' ) {
			frank++;
			if ( pass < a + b && frank <= b ) {
				cout << "Yes" << endl;
				pass++;
			}
			else {
				cout << "No" << endl;
			}
		}

		if ( s[i] == 'c' ) {
			cout << "No" << endl;
		}
	}
}


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

int main(){
  int N, d[101];
  std::cin>>N;
  for(int i=0;i<N;++i){
    std::cin>>d[i];
  }
  std::sort(d,d+N);
  int now=d[0], ans=1;
  for(int i=1;i<N;++i){
    if(now!=d[i]){
      ans++;
      now=d[i];
    }
  }
  std::cout<<ans<<std::endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  string S;
  if ((N%10)==3) S="bon";
  else if ((N%10)==0 || (N%10)==1 || (N%10)==6 || (N%10)==8) S="pon"; 
  else S="hon";
  cout << S << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
  string s;
  cin >> s;
  vector<vector<long long int>> alp(26);
  for (int i = 0; i < s.size(); ++i) {
    alp[s[i] - 'a'].push_back(i);
  }
  /*for (int i = 0; i < alp['e' - 'a'].size(); ++i) {
    cout << alp['e' - 'a'][i] << endl;
  }*/
  for (int i = 0; i < 26; ++i) {
    for (int j = 0; j < alp[i].size(); ++j) {
      for (int k = j + 1; k < alp[i].size(); ++k) {
        long long int char_num = (k - j) + 1;
        long long int length = (alp[i][k] - alp[i][j]) + 1;
        long long int over = length / 2 + 1;
        if(over <= char_num)
        {
          cout << alp[i][j] + 1 << " " << alp[i][k] + 1 << endl;
          return 0;
        }
      }
    }
  }
  cout << -1 << " " << -1 << endl;
  return 0;
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
#define ld long double
using namespace std;

#define ld long double
#define int long long int
#define ps push_back
#define fi first
#define so second
#define mod 1000000007
#define pii pair<int,int>
#define TT int t;cin>>t;while(t--)
#define ina for(i=0;i<n;i++){cin>>a[i];}

signed main()
{
    int x,y,i,j,n,h;
    cin>>h>>n;
    pii a[n];
    map<int,int> mp;
    for(i=0;i<n;i++) {
        cin>>x>>y;
        if(mp.find(x)!=mp.end()) mp[x]=min(mp[x],y);
        else mp[x]=y;
    }
    vector<pii> v;
    for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++)
    {
        v.ps({it->fi,it->so});
    }
    sort(v.begin(),v.end());
    n=v.size();
    int dp[v.size()+1][h+1]={0};
    for(i=0;i<=n;i++) for(j=0;j<=h;j++) dp[i][j]=-1;
    for(i=0;i<=n;i++) dp[i][0]=0;
    for(i=1;i<=h;i++) dp[0][i]=INT_MAX;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=h;j++)
        {
            if(v[i-1].fi>=j) dp[i][j]=min(dp[i-1][j],v[i-1].so);
            else dp[i][j]=min(dp[i-1][j],v[i-1].so+dp[i][j-v[i-1].fi]);
        }
    }
    cout<<dp[n][h];
}


Measured memory_bytes: 78592
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
using namespace std;
#define MAX 1000000010

int solve(string str){
	int a[3] = {0, 0, 0}, ans = 0;
	for(int i = 0;i < str.size();i++){
		if(str[i] == 'J'){
			if(a[1] || a[2])a[0] = a[1] = a[2] = 0;
			if(!a[1] && !a[2])a[0]++;
		}else if(a[0] && str[i] == 'O'){
			if(!a[2])a[1]++;
			else a[0] = a[1] = a[2] = 0;
		}else if(a[0] && a[1] && a[0] >= a[1] && str[i] == 'I'){
			a[2]++;
			if(a[1] == a[2])ans = max(a[1], ans);
		}else{
			a[0] = a[1] = a[2] = 0;
		}
	}
	return ans;
}

int main(){
	string str;
	cin >> str;
	cout << solve(str) << endl;
	
	return 0;
}

Measured memory_bytes: 5052
import java.util.Scanner;
public class Main {
  public static void main(String[] args){
    // "AB+C" → (10 * A) + B + C → (9 * A) + (A + B + C)とし、
    // Aが3つの数値のうち最大値となるようにする
    Scanner sc = new Scanner(System.in);
    int sum = 0;
    int max = 0;
    for (int i = 0; i < 3; i++) {
      int num = sc.nextInt();
      sum += num;
      if (num > max) {
        max = num;
      }
    }
    sum += max * (10 - 1);
	System.out.println(sum);
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) cin >> a[i];
    int c = 0;
    REP(i,N){
        if(a[i] == a[i+1]){
            int s = 1;
            for(int j =i;a[j] == a[j+1];j++){
                s++;
            }
            c += s/2;
            i+=s-1;
            }
        }
    cout << c << "\n";
    return 0;
}

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

int main(){
    int H, W;
    while(1){
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if(i % 2 == 1 && j % 2 == 1 || i % 2 == 0 && j % 2 == 0) cout << '#';
                else cout << '.';
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3080
N, M = map(int, input().split())
g = [[] for _ in range(N + 1)]
for _ in range(M):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)
 
ans = 0
def walk(cur, visited):
    global ans
    tmp = visited + [cur]
    if len(tmp) == N:
        ans += 1
        return
    for nex in g[cur]:
        if nex not in tmp:
            walk(nex, tmp)
walk(1, [])
print(ans)

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

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

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

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

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

//main code

int main(int argc, char const* argv[])
{
    int n,k;
    cin >> n >> k;
    VL a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    SORT(a);
    LL ans = 0;
    for (int i = n - 1; i >= n - k; i--) {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
use strict;

my ($n, $k) = glob<>;
my @h = sort { $b <=> $a } glob<>;
my $s = 0;

if($n <= $k){
	print "0\n";
	exit;
}

foreach my $hi (@h){
    if ($k-- > 0) {
        next;
    }
    $s += $hi;
}

print ($s);

Measured memory_bytes: 62888
def aux(s,ops)
  while ops.length > 0
    op=ops.shift
    t=s.slice!(0,op)
    s += t
  end

  s.join
end

def main
  fh=STDIN
  #fh=File.new("x.txt", "r")
  while fh.gets
    break if ($_.chomp!)=="-"
    s = $_.split(//)
    n=fh.gets.chomp.to_i
    ops = []
    n.times {
      ops << fh.gets.chomp.to_i
    }
    puts aux(s,ops)
  end

end

if $0 == __FILE__ then
  main
end


Measured memory_bytes: 7004
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <array>
#include <algorithm>

using namespace std;

#define SIZE 130
bool table[SIZE][SIZE];
int standed[SIZE][SIZE];

int current_x;
int current_y;
int g_count;
int g_turn;
int g_current_turn;

int g_dx[] = { 0, 1, 1, 0, -1, -1 };
int g_dy[] = { 1, 1, 0, -1, -1, 0 };

int calc(int x) {
	return x + SIZE/2;
}

// 正直幅優先のほうが良い
void solution() {
	if (standed[calc(current_x)][calc(current_y)] == -1) {
		++g_count;
	} else if (standed[calc(current_x)][calc(current_y)] <= g_current_turn) return;
	
	standed[calc(current_x)][calc(current_y)] = g_current_turn;
	if (g_current_turn >= g_turn) return;

	auto x = current_x;
	auto y = current_y;

	for (int i = 0; i < 6; ++i) {
		if (!table[calc(current_x + g_dx[i])][calc(current_y + g_dy[i])]) {
			current_x += g_dx[i];
			current_y += g_dy[i];

			++g_current_turn;
			solution();
			--g_current_turn;

			current_x = x;
			current_y = y;
		}
	}
}

int main() {
	while (true) {
		memset(table, false, sizeof(table));
		memset(standed, -1, sizeof(standed));

		g_count = 0;
		g_current_turn = 0;

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

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

		cin >> current_x >> current_y;

		solution();

		cout << g_count << endl;
	}
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>N;
    vec x(N);
    rep(i,N) cin>>x[i];
    vec memo(N,0);
    reps(i,1,N){
        memo[i] = max({i - (x[i] - 1)/2, memo[i-1], 0LL});
    }
    ll ans = 1, id = 0, num = 1;
    rep(i,N){
        //cout<<i<<' '<<memo[i]<<endl;
        while(memo[id] <= i && id != N - 1) {
            ++id;
            ++num;
        }
        //cout<<num<<endl;
        (ans *= num)%=MOD;
        --num;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 28;
int a[maxn];
pair <int, int> p[maxn];
int main(){
	int n , k;
	string s;
	cin >> n >> k >> s;
	char cur = 'a';
	int st, end;
	int j = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == '0' && cur != '0')
			st = i;
		else if(s[i] == '1' && s[i - 1] == '0'){
			p[j] = {st, i - 1};
			j ++;
		}
		if(i == n - 1 && s[i] == '0'){
			p[j] = {st, i};
			j ++;
		}
		cur = s[i];
	}
//	for(int i = 0; i < j; i++)
//		cout << p[i].first + 1 << " " <<p[i].second + 1 << "\n";
	if(k >= j)
		return cout << n, 0;
	int maxi = 0;
	for(int i = 0; i <= j - k; i++){
		if(i == 0)
			maxi = max(p[i + k].first , maxi);
		else if(i + k - 1 == j - 1)
			maxi = max(n - p[i - 1].second - 1, maxi);
		else
			maxi = max(maxi,((p[i + k].first - 1) - (p[i - 1].second + 1) + 1));		 
//		cout << maxi << "  " << i << " \n\n";
	} 
	cout << maxi;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX-1;

int memo[1111];

int func(int pos, const int& n, const int& width, const vector<int>& a){
  if(memo[pos] != -1) return memo[pos];
  if(pos >= n) return 0;
  int w = 0;
  int res = INF;
  int p;
  int pp = -1;
  for(p = pos; p < n; p++){
    w += a[p];
    int tmp = func(p+1, n, width, a) + abs(width - w);
    if( res > tmp ){
      pp = p;
      res = tmp;
    }
  }
  if(pp+1 == n){
    memo[pos] = max(0, w-width);
    return memo[pos];
  }
  memo[pos] = res;
  return res;
}

int main(void){
  int n, w; 
  int Case = 1;
  while(cin >> n >> w, n | w){
    for(int i = 0; i < 1111; i++) memo[i] = -1;
    vector<int> a(n);
    for(int i = 0;  i< n; i++)
      cin >> a[i];
    cout << "Case " << Case++ << ": " << func(0, n, w, a) << endl;
  }
  return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S;
    cin >> S;
    string T = "";
    
    for(int i = 0; i< S.length() ; i++){
        T = T + "x";
        // T.append("x");
    }

    cout << T << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int N,A,B,C,D,a,b;
	cin>>N>>A>>B>>C>>D;
	a=N/A*B;
	b=N/C*D;
	if(N%A!=0)a=a+B;
	if(N%C!=0)b=b+D;
	if(a<b){
		cout<<a<<endl;
	}else{
		cout<<b<<endl;
	}
	return 0;
}


Measured memory_bytes: 3100