akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys


def great_common_divisor(a, b):
    '''Calculate the great common divisor (GCD) of a and b
    Args:
        a (int) : value
        b (int) : value
    Returns:
        gcd (int) : the great common divisor of a and b
    Note:
        This function uses Euclidean Algorithm
    '''
    while b != 0:
        a, b = b, a % b
    return a

def least_common_multiple(a, b):
    '''Calculate the least common multiple (LCM) of a and b
    Args:
        a (int) : value
        b (int) : value
    Returns:
       lcm (int) : the least common multiple of a and b
    '''
    return (a * b) // great_common_divisor(a, b)



def solve(A: int, B: int, C: int, D: int):
    lcm = least_common_multiple(C, D)

    num_B = (B - B // C - B // D + B // lcm)

    # 「以上」「以下」の境界値に注意する。
    A = A - 1
    num_A = (A - A // C - A // D + A // lcm)

    print(num_B - num_A)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(A, B, C, D)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mp make_pair
  #define pb push_back
  #define inf INT_MAX
  #define f first
  #define s second
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define all(v) v.begin(), v.end()
  #define mod INT_MAX 
  const int MOD=1e9+7;
  const int N=2e5+2;

  int32_t main()
  {
    /*#ifndef ONLINE_JUDGE
       freopen("in.txt","r",stdin);
       freopen("out.txt","w",stdout);
    #endif*/
       IOS
       int n;
       cin>>n;
       vector<int> v(n);
       map<int,int> mp;
       int sum=0;
       for(int i=0;i<n;i++)
       {
         cin>>v[i];
         sum+=v[i];
         mp[v[i]]++;
       }
       int q,b,c;
       cin>>q;
       while(q--)
       {
        cin>>b>>c;
        /*for(auto it:mp)
          cout<<it.first<<" "<<it.second<<"\n";*/
        int x=mp[b];
        int d=c-b;
        //trace3(x,d,sum);
        sum+=(x*d);

        cout<<sum<<"\n";
        mp.erase(b);
        mp[c]+=x;
       }
       
       return 0;
      }

Measured memory_bytes: 7856
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
k  = int(input())
s  = input()
#  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

if len(s) <= k:
    print(s)
else:
    print(f'{s[:k]}...')


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

namespace abc168_b
{
    class Program
    {
        static void Main(string[] args)
        {
            var K = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();

            if (K >=S.Length)
            {
                Console.WriteLine(S);
            }

            else
            {
                Console.WriteLine(S.Substring(0, K) + "...");
            }

            Console.Read();
        }
    }
}


Measured memory_bytes: 27468
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

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

	ll tmp1 = N / K, tmp2 = (N + K / 2) / K;
	if(K % 2)
		cout << tmp1 * tmp1 * tmp1 << "\n";
	else
		cout << tmp1 * tmp1 * tmp1 + tmp2 * tmp2 * tmp2 << "\n";
	return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[1000];	//????????????????????\??????
	char rev[1000];	//reverse??¨??????????????\??????
	char p[1000];	//??\???????????????????????\??????
	char ordr[8];	//??????????????\??????
	int num = 0;	//???????????°
	int a = 0;		//??°?????????
	int b = 0;		//??°?????????

	int i = 0;		//??°?????????????????¨
	int j = 0;		//??°?????????????????¨
	int k = 0;		//??°?????????????????¨

	/* ???????????????	*/
	for(i = 0; i < 1000; i++)
	{
		str[i] = 0;
	}
	
	scanf("%s", str);						/* ???????????????		*/
	scanf("%d", &num);						/* ???????????°??\???		*/
	
	for(i = 0; i < num; i++)
	{
		/* ??????????????????p??¨ordr????????????0??\??? */
		for(j = 0; j < 1000; j++)
			{
				p[j] = 0;
			}
		for(j = 0; j < 8; j++)
		{
			ordr[j] = 0;
		}
		for(j = 0; j < 1000; j++)
		{
			rev[j] = 0;
		}
		
		scanf("%s %d %d", ordr, &a, &b);		/* ??????????????°???		*/

		if(strcmp(ordr, "print") == 0)
		{
			for(j = a; j < b + 1; j++)
			{
				printf("%c", str[j]);
			}
			printf("\n");
		}
		else if(strcmp(ordr, "reverse") == 0)
		{
			k = 0;
			for(j = b; j >= a; j--)
			{
				rev[k] =  str[j];
				k++;
			}
			k = 0;
			for(j = a; j <= b; j++)
			{
				str[j] = rev[k];
				k ++;
			}
		}
		else if(strcmp(ordr, "replace") == 0)
		{
			scanf("%s", p);				/* ???????????\???	*/
			k = 0;
			for(j = a; j <= b; j++)
			{
				str[j] = p[k];
				k++;
			}
		}
		else
		{
			/* NOP	*/
		}
	}

	return 0;
}

Measured memory_bytes: 576
"""
Atcoder Beginner Contest 173
F - Intervals on Tree

"""
## Using 1 indexing

n = int(input())

# Computing number of times a particular node can come in an interval
ans =0
for i in range(1,n+1):
    ans+= i*(n-i+1)

# Inputting edges and subtracting from ans all the ranges which include both the edges
for _ in range(n-1):
    u,v = map(int,input().split())
    minn = min(u,v)
    maxx = max(u,v)
    ans-= minn*(n-maxx+1)

print(ans)

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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v.at(i);
  vector<int> w(100000);
  vector<int> x(100000);
  
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) w.at(v.at(i)-1)++;
    else x.at(v.at(i)-1)++;
  }
  
  int wmax = w.at(0);
  int xmax = x.at(0);
  int ww,xx;
  
  for (int i = 0; i < 100000; i++) {
    if (wmax < w.at(i)) {
      wmax = w.at(i);
      ww = i+1;
    }
    if (xmax < x.at(i)) {
      xmax = x.at(i);
      xx = i+1;
    }
  }
  
  sort(w.begin(),w.end());
  sort(x.begin(),x.end());
  if (ww == xx) cout << n + min(w.at(99999)-w.at(99998),x.at(99999)-x.at(99998)) -w.at(99999) - x.at(99999) << endl;   
  else cout << n - w.at(99999) -x.at(99999) << endl;
}

Measured memory_bytes: 1408
package main

import (
	"fmt"
	)

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

	
func main() {
	var n int
	fmt.Scan(&n)
	a:=[][]int{}
	dp:=make([][3]int,n+1)
	for i:=0;i<n;i++{
		var ai,bi,ci int
		fmt.Scan(&ai,&bi,&ci)
		a=append(a,[]int{ai,bi,ci})
	}
	
	for i:=0;i<n;i++{
		for j:=0;j<3;j++{
			if j == 0{
				dp[i+1][j] = max(dp[i][1], dp[i][2]) + a[i][j]
			} else if j == 1 {
				dp[i+1][j] = max(dp[i][0], dp[i][2]) + a[i][j]
			} else if j == 2 {
				dp[i+1][j] = max(dp[i][0], dp[i][1]) + a[i][j]
			}
		}
	}

	fmt.Println(max(max(dp[n][0],dp[n][1]),dp[n][2]))
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

    int N;
    cin >> N;
    vector<char> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }

    unordered_set<char> st;
    for (int i = 0; i < N; i++) {
        st.insert(S[i]);
    }

    if (st.find('Y') != st.end()) {
        cout << "Four\n";
    }
    else {
        cout << "Three\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;


int main()
{
    int N;
    int x;
    int a[maxn];
    cin>>N;
    for(int i=1; i<=N; i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+1+N);

    if(N==2)
    {
        cout<<a[2]<<" "<<a[1]<<endl;
    }
    else
    {
        int tmp=0;
        int t=0;
        for(int i=1;i<N;i++){
                int tb=min(a[i],a[N]-a[i]);
                if(a[i]!=a[N])
                {
                    if(tmp<tb){
                        tmp=tb;t=i;
                    }
                }
        }
        cout<<a[N]<<" "<<a[t]<<endl;
    }
    return 0;
}


Measured memory_bytes: 640
<?php
$n=trim(fgets(STDIN));
$a=explode(" ",trim(fgets(STDIN)));
$i=1;
$c=$a[0];
$ans=0;
while($i<$n){
if($a[$i]==$c){
++$ans;
$c=0;
}else{
$c=$a[$i];
}
++$i;
}
echo $ans;

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

int main(){

  int l, c, len, m_len, m_cnt;
  int cnt[500] = {};
  string str, word[500];

  while(cin >> str){
    for(int i=0; i<500; i++){
      if(word[i] == ""){
        word[i] = str;
        cnt[i] = 1;
        break;
      }
      else if(word[i] == str){
        cnt[i]++;
        break;
      }
    }
  }

  m_len = 0;
  m_cnt = 0;
  for(int i=0; word[i] != ""; i++){
    if(m_cnt < cnt[i]){
      m_cnt = cnt[i];
      c = i;
    }
    len = word[i].length();
    if(m_len < len){
      m_len = len;
      l = i;
    }
  }

  cout << word[c] << " " << word[l] << endl;

  return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <bitset>
#include<vector>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    long judge = a[0];
    for (int i = 1; i < n; i++) {
        judge = judge ^ a[i];
    }
    if (judge == 0) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
using namespace std;
typedef long long LL;
const int N=1e6;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
int main()
{
	int n=gi();
	long double ans=0,a=gi(),b=gi();
	while (n) {
		ans+=a+(n-0.5)*b;
		if (n--) {
			a=(2*a+2.5*b+a*n)/(n+1);
			b=b*(3+n)/(n+1);
		}
	}
	printf("%.10Lf\n",ans);
	return 0;
}


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

int a[100002];
int main()
{
    
    int n;
    cin >> n;
    rep(i,1,n+1)
        cin >> a[i];
    
    int ans = a[1];
    rep(i,2,n+1)
        ans ^= a[i];
    
    if(ans == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

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

//unionfind
//init: union_find name(size)

class union_find{
private:
    //根にはグループの要素数に―1をかけたもの、それ以外には根の値
    //初期値は-1
    vector<int> uni;
public:
    //Constructer
    //uniを必要なサイズで初期化する、初期値は―1
    union_find(int unisize) : uni(unisize,-1){}

    //引数aの根を求める、なければaを根として返す
    int root(int a){
        if(uni[a] < 0) return a;
        return uni[a] = root(uni[a]);  
    }

    //頂点aとbを繋ぐ関数unite
    //戻り値：
    //  元々同じグループであればfalse
    //  連結に成功すればtrue
    bool unite(int a, int b){
        //a, bにそれぞれが属するグループの根を入れる
        //uni[a], uni[b]がa, bがそれぞれが属するグループのサイズになる
        a = root(a);
        b = root(b);
        if(a == b) return false;
        if(uni[a] > uni[b]) swap(a,b); //bの方を大きいものにする
        uni[a] += uni[b];
        uni[b] = a; //大きい方のグループに属するものの親を小さいものの根にする(rootが高速で動くようになる)
        return true;
    }
    //頂点aとbが同じグループかを調べる
    bool isConnected(int a, int b){
        return root(a) == root(b);
    }
    //頂点aを含むグループの頂点数を調べる
    int unisize(int a){
        return -uni[root(a)];
    }
};

int main(){
    int n,m; cin >> n >> m;
    union_find graph(n+1);
    int x,y,z;
    int ans = 0;
    rep(i,m){
        cin >> x >> y >> z;
        graph.unite(x,y);
    }
    rep(i,n) if(graph.root(i+1) == i+1) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

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

#define rep(i, n) for (ll i = 0LL; i < n; i++)
#define repext(i, a, b) for (ll i = a; i < b; i++)
#define reprev(i, n) for (ll i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (ll i = b - 1; i >= a; i--)

#define repv(v, values) for (auto v : values)

#define vec_all(vec) vec.begin(), vec.end()
#define sum(vec) accumulate(vec_all(vec), 0LL)
#define srt(vec) sort(vec_all(vec))
#define rev(vec) reverse(vec_all(vec))
#define revsrt(vec) \
    srt(vec);       \
    rev(vec)

// vectorデバッグ
template <typename T>
void dump_vec(vector<T> vec)
{
    rep(i, vec.size())
    {
        cout << i << ": " << vec[i] << endl;
    }
}

template <typename T, typename S>
void dump_dic(map<T, S> dic)
{
    for (auto v : dic)
    {
        cout << v.first << ": " << v.second << endl;
    }
}

// --- notice ---
// intの和はllにしろ

int main()
{
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(q);
    rep(i, q) {
        cin >> a[i];
    }

    vector<int> solve(n + 1, 0);
    rep(i, q) {
        solve[a[i]]++;
    }

    rep(i, n) {
        if (k - q + solve[i + 1] > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <unordered_set>
#include <numeric>
using namespace std;

#define ll long long


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

	int ans = 1;
	int bounce = 0;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		
		bounce += a;
		
		if (bounce <= x)
		{
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[10];
int alpha[26];
bool myf(){
	int k=0;
	for(int i=0;i<26;i++){
		if(alpha[i]==2) k++;
		else if(alpha[i]!=0) return false; 
	}
	if(k!=2) return false;
	return true;
}
int main(void){
	scanf("%s",s);
	for(int i=0;i<(int)strlen(s);i++){
		alpha[s[i]-'A']++;
	}
	if(myf()) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
n,k = [int(s) for s in input().split()]
#n,k = [int(s) for s in data.pop().split()]
#n,k = 100000,100000
w_org = []
[w_org.append(int(input())) for i in range(n)]
#[w_org.append(int(data.pop())) for i in range(n)]
#w_org = [1 for i in range(n)]


def can(p_org,k):
	p = p_org
	w = w_org[::-1]
	while k and w:
		ww = w[-1]
		if ww <= p:
			p -= ww
			w.pop()
		else:
			p = p_org
			k -= 1
		if p == 0:
			p = p_org
			k -= 1
		#print(ww,k,p)
	return not(w)


left,right = max(w_org)-1,sum(w_org)+1
roop = 0
while left+1 < right:
	roop += 1
	middle = (left+right) // 2
	if can(middle,k):
		right = middle
	else:
		left = middle
print(right)

Measured memory_bytes: 12332
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M); vector<vector<ll> > v(4);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()), sort(v.rbegin(), v.rend()); //sort
// char '' str ""
int main(void)
{
    double T,X;cin>>T>>X;
    int cnt = 0;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define debug1(a) cout<<" a : "<<a<<"\n"
#define debug2(a,b) cout<<" a : "<<a<<" b : "<<b<<"\n"
#define debug3(a,b,c) cout<<" a : "<<a<<" b : "<<b<<" c : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" a : "<<a<<" b : "<<b<<" c : "<<c<<" d : "<<d<<"\n"
// #define M 421412341324321
#define MOD 998244353 

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n;
	cin>>n;
	string s[n];
	rep(i,n) 
	{
		string temp;
		cin>>temp;
		sort(all(temp));
		s[i]=temp;
		// debug1(temp);
	}
	sort(s,s+n);
	string pre = "";
	int cnt=1, ans=0;
	rep(i,n)
	{
		if (pre==s[i]) cnt++;
		else
		{
			pre = s[i];
			ans+=(cnt*(cnt-1))/2;
			cnt=1;
		}
	}
	ans+=(cnt*(cnt-1))/2;
	cout<<ans<<" ";

	return 0;
}


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

using namespace std;
int main()
{
    int a, b,c,d;
    cin >> a;
    cin >> b;
    d = 0;
    int i = 0;
    while(i<b){
        cin >> c;
        d += c;
        i++;
    }
    if(d>a){
        cout << -1;
    }
    else {
        cout << a-d;
    }
}

Measured memory_bytes: 3608
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000000
#define MAX 200001
#define MOD 1000000007

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

int main(){
    int N;
    ll res = INF;
    cin >> N;
    vector<int> X(N);
    for(int i = 0;i < N; i++) cin >> X[i];
    for(int i = 1;i < 101; i++){
        ll ans = 0;
        for(int j = 0; j < N; j++){
            ans += (i - X[j]) * (i - X[j]);
        }
        res= min(res, ans);
    }
    cout << res << endl;
}


Measured memory_bytes: 3592
s = list(input())
count = 0
m = 0
for i in range(len(s)):
  
  if s[i] == "A" or s[i] == "T" or s[i] == "C" or s[i] ==  "G":
    count += 1
  else:
    if m < count:
      m = count
      count = 0
    else:
      count = 0
if m < count:
      m = count
print(m)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
#define INF 1<<30

int main()
{
    int N;
    cin >> N;
    for(int i=N;i<1000;i++){
        if(i%111==0){
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int i = 0;
		int j = 0;

		while(true){

			String[] input = br.readLine().split(" ");

			int H = Integer.parseInt(input[0]);
			int W = Integer.parseInt(input[1]);

			if( H==0 && W==0) break;

			for( i=0 ; i<H ; i++ ){
				if( i==0 | i==H-1 ){
					for( j=0 ; j<W ; j++){
						System.out.print("#");
					}
				}else{
					for( j=0 ; j<W ; j++ ){
						if( j==0|| j==W-1){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
	}
}

Measured memory_bytes: 34884
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}


int main() {
    int N, H, W;
    cin >> N >> H >> W;

    int a = (N - H) + 1;
    int b = (N - W) + 1;

    cout << a * b << endl;

    return 0;
}

Measured memory_bytes: 3184
#include <stdio.h>
#include<stdlib.h>

#define N 100000
#define INF 1000000

typedef struct{
  int go, back, cost;
}Date;

int n, d[N];
Date a[500000];
void root(int);

int main(){
  int i, j, u, k, count = 0;
  scanf("%d", &n);
  for( i = 0 ; i < n ; i++) {
    scanf("%d%d", &u, &k);
    for( j = 0 ; j < k ; j++){
      a[count].back=u;
      scanf("%d%d", &a[count].go, &a[count].cost);
      count++;
    }
  }
  root(count);
  for( i = 0 ; i < n ; i++) printf("%d %d\n", i, d[i]);
  return 0;
}



void root(int b){
  int i, flag = 1;

  for( i = 0 ; i < n ; i++) d[i] = INF;
  d[0] = 0;

  while(flag != 0){
    flag = 0;
    for( i = 0 ; i < b ; i++){
      if(a[i].cost + d[a[i].back] < d[a[i].go]){
        d[a[i].go] = a[i].cost + d[a[i].back];
        flag = 1;
      }
    }
  }
}



Measured memory_bytes: 7664
while True:
    x = int(input())
    if x==0 :
        break
    if x > 0:
        x = 1000 - x
        a = x//500
        x = x%500
        b = x//100
        x = x%100
        c = x//50
        x = x%50
        d = x//10
        x = x%10
        e = x//5
        f = x%5
        print(a+b+c+d+e+f)


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

using namespace std;

int main(){
  int d, n; cin>>d>>n;
  
  int x = 1;
  if(d == 1) x = 100;
  else if(d == 2) x = 10000;
  if(n == 100) n = 101;
  
  cout<<n*x<<"\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define br cout << "\n";
#define pb push_back
#define ll long long 
#define ff first 
#define ss second
#define all(x) x.begin(),x.end()
#define in(a , idx , n ) for (int i = idx ; i < n ; ++i)cin >>a[i];
using namespace std;
const int MOD = 1000*1000*1000 + 7 ; 
const int MAXN = 1000*100 +10 ;
const ll INF = 1e18 ; 
int dp[1000+10][1000+10];
void solve(){
	int n , m ;
	cin >> n >> m ;
	char a[n+1][m+1];
	for(int i = 1 ; i <= n ; ++i )
		for(int j = 1 ; j <= m ; ++j ) 
			cin >> a[i][j];
	dp[0][1] = 1 ;		
	for(int i = 1 ; i <= n ; ++i )
	{
		for(int j = 1 ; j <= m ; ++j )
		{
			if(a[i][j] == '#')
				dp[i][j] = 0 ;
			else
				dp[i][j] = (dp[i-1][j] % MOD  + dp[i][j-1] % MOD ) % MOD ;
				
		}
	}

		// for(int i = 1 ; i <= n ; ++i )
		// {
		// for(int j = 1 ; j <= m ; ++j )
		// {
			// cout << dp[i][j] <<" " ; 
		// }
		// cout << endl; 
	// }		
	cout << dp[n][m] , br 
}
int main (){ 
	int t = 1  ;
	// cin >> t ;
	while (t--){
		solve() ; 
	}
    
return 0 ; 
}


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

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define         MAX         262144


int main()
{
    int i,j,k,l,m,n,cnt=0,ans=0;

    cin >> n ;

    cnt=1;

    for(i=0; i<n; i++)
    {
        cin >> l;
        if(cnt==l)
        {
            cnt++;
            ans++;
        }
    }
//    if(mpp.size() == n)return cout<<0<<endl,0;
//
//    int prv = 0,ans=0;
//    bool ok = true;
//    for(auto x : mpp)
//    {
//        cout << x.F <<" "<<x.S<<endl;
//        if(x.F==prv+1 && ok)
//        {
//            prv = x.F;
//            ans += x.S-1;
//        }
//        else
//        {
//            ok = false;
//            ans += x.S;
//        }
//    }
   if(cnt) cnt--;
    ans = n-cnt;
    if(ans > n-1)
        cout<<-1<<endl;
    else
        cout<<ans<<endl;
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;

#define REP(i,n) for (ll i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()

int N, K;
vi X, Y;
vii XY;

int main() {

  cin >> N >> K;

  X = Y = vi(N);
  XY = vii(N);
  REP (i, N) {
    cin >> X[i] >> Y[i];
    XY[i] = make_pair(X[i], Y[i]);
  }

  sort(ALL(X));
  sort(ALL(Y));

  ll ans = (X[N-1]-X[0]) * (Y[N-1]-Y[0]);

  REP (b, N) REP (a, b) {
    REP (d, N) REP (c, d) {
      int k = 0;
      ll Xmn = X[a], Xmx = X[b];
      ll Ymn = Y[c], Ymx = Y[d];
      REP (i, N) {
        ll x = XY[i].first;
        ll y = XY[i].second;
        if (Xmn <= x && x <= Xmx && Ymn <= y && y <= Ymx) k++;
      }
      if (k >= K) ans = min(ans, (Xmx-Xmn)*(Ymx-Ymn));
    }
  }

  cout << ans << endl;
  return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
#define chmax(a,b) a=max(a,b)

/*Coding Space*/
int main(){
  int a,b; cin >> a >> b;
  int nmax = -100000;
  nmax = max(nmax, a+b);
  nmax = max(nmax, a-b);
  nmax = max(nmax, a*b);
  cout << nmax << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int n;
    cin >> n;
    int t = n, w = 0;
    while(t > 0){
        w += t % 10;
        t /= 10;
    }
    Yes(n % w == 0);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int A, B;
	cin >> A >> B;
	int sum = 0;
	for (int i = A; i <= B; ++i) {
		int s = i % 10;
		int t = i / 10 % 10;
		int r = i / 10 / 10 / 10 % 10;
		int u = i / 10 / 10 / 10 / 10 % 10;
		if (s == u && t == r)
			sum++;
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"time"
)

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	d := nextLine()
	layout := "2006/01/02"
	limit, _ := time.Parse(layout, "2019/04/30")
	t, _ := time.Parse(layout, d)

	if t.Unix() <= limit.Unix() {
		fmt.Println("Heisei")
	} else {
		fmt.Println("TBD")
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
vector<vector<int> >g(52);
int edgenum[52][52], edgemask[52], par[52];
void dfs(int v, int p){
    par[v] = p;
    for(int i = 0; i < g[v].size(); i++){
        int to = g[v][i];
        if(to == p){
            continue;
        }
        dfs(to, v);
    }
}
void calc(int src, int des, int num){
    dfs(src, 0);
    int v = des;
    while(v != src){
        int u = par[v];
        edgemask[edgenum[v][u]] |= (1 << num);
        v = u;
    }
}
int n, m;
long long dp[51][(1 << 20) + 2];
long long solve(int pos, int mask){
    if(pos == n){
        if(__builtin_popcount(mask) == m){
            return 1;
        }
        return 0;
    }
    if(dp[pos][mask] != -1){
        return dp[pos][mask];
    }
    dp[pos][mask] = solve(pos + 1, mask) + solve(pos + 1, mask | edgemask[pos]);
    return dp[pos][mask];
}
int main(){
    cin >> n;
    for(int i = 1; i < n; i++){
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
        edgenum[u][v] = i;
        edgenum[v][u] = i;
    }
    cin >> m;
    for(int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        calc(u, v, i);
    }
    memset(dp, -1, sizeof(dp));
    cout << solve(1, 0);
    return 0;
}

Measured memory_bytes: 421244
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>

using namespace std;
int main() {


	string s;

	cin >> s;

	int countc=0,countf=0;


	int i = 0;
	while (s[i]) {

		if (s[i] == 'C') {
			countc=1;

		}
		if (s[i] == 'F' && countc == 1) {

			countf = 1;

		}
		i++;
	}
	if (countf == 1 && countc == 1) {


		cout << "Yes";
	}
	else {
		cout << "No";
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD				1000000007
#define MOD1			998244353
#define EPS				1e-9
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
using namespace __gnu_pbds;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int tam = 10000010;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	//freopen("qwe.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	ll n, ar[5];
	cin>>n;
	fore(i, 0, 5)
	{
		cin>>ar[i];
		ar[0] = min(ar[0], ar[i]);
	}
	if(n == 0) {cout<<"0\n"; return 0;}
	cout<<4 +(n/ ar[0] + (n%ar[0] > 0 ? 1 : 0))<<'\n';
	return 
	0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>


#define int  long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define pf push_front
#define eb emplace_back //FASTER THAN PUSH BACK!
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define mi multiset<int>
#define mii multiset<pii>
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>


// using namespace __gnu_pbds;
using namespace std;

int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}

int modp(int a,int n)
{
    if(n==0) return 1;
    if(n==1) return a%mod;
    int res=modp(a,n/2);
    if(n%2==0) return (res*res)%mod;
    else return (a*res*res)%mod;
}

// vi adj[100005];
// vector<bool> vis(100005,false);


// void dfs(int s)
// {
//     vis[s]=true;
    
//     for(int u:adj[s])
//     {
//         if(!vis[u])
//         {
//             vis[u]=true;
//             dfs(u);
//         }
//     }
// }

void solve()
{
    int t,n,m,i,k,l,r,u,v,w,j,s,sum=0,pos=-5,flag=0,count=0;
    string S,T,U;
    
    cin>>s>>w;
    if(w>=s) cout<<"unsafe";
    else cout<<"safe";
}




signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3664
#include <stdio.h>

int main()
{
int S,h,m,s,a;
   scanf("%d",&S);

    h = S/60/60;
    a = S%3600;
    m = a/60;
    s = a-m*60;

    

   printf("%d:%d:%d\n",h,m,s);


return(0);
}


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

int main(){
    int s[3][3];
    rep(i, 3) rep(j, 3) cin >> s[i][j];
    bool flag = true;
    rep(i, 2){
        rep(j, 2){
            if (s[i][j+1] - s[i][j] != s[i+1][j+1] - s[i+1][j]) flag =false;
        }
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

const char wall = '#';
vector<vector<ll>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
vector<ll> good;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

ll N, M;
vector<ll> H;

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

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

  cin >> N >> M;
  H.resize(N);
  good.resize(N, 0);
  rep(i, N) {
    cin >> H[i];
    good[i] = H[i];
  }
  ll ans = 0;
  rep(i, M) {
    ll a, b;
    cin >> a >> b;
    good[a-1] = max(good[a-1], H[b-1]+1);
    good[b-1] = max(good[b-1], H[a-1]+1);
  }
  rep(i, N) {
    if (good[i] == H[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4780
n = int(input())
# s = list(map(str,input().split()))
s = input()
count_R = 0
count_W = 0
for ss in s:
    if ss == "R":
        count_R += 1
    else:
        count_W += 1
t_countR = 0
for i in range(count_R):
    if s[i]=="W":
        t_countR += 1

print(t_countR)




Measured memory_bytes: 9452
#include <stdio.h>
#define N_MAX 100

int n, leagues;
int pts[N_MAX];
int sorted[N_MAX];
int max;

int sorter(void){
	int i;
	int x = 1;
	int y;
	while(x <= n){
		y = x;
		for(i = 0; i < n; i++){
			if(sorted[i])continue;
			if(max > pts[i]){
				pts[i]++;
			}else{
				sorted[i] = y;
				x++;
			}
		}
	}
	return 0;
}

int main(void){
	int a,b,c,d;
	int i;
	scanf("%d", &n);
	leagues = n * (n - 1) / 2;
	while(leagues--){
		scanf("%d%d%d%d", &a, &b, &c, &d);
		c -= d;
		if(c > 0){
			pts[a-1] += 3;
		}else if(c < 0){
			pts[b-1] += 3;
		}else{
			pts[a-1]++;
			pts[b-1]++;
		}
		if(pts[a-1] > max){
			max = pts[a-1];
		}
		if(pts[b-1] > max){
			max = pts[b-1];
		}
	}
	sorter();
	for(i = 0; i < n; i++){
		printf("%d\n", sorted[i]);
	}
	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>

int main(){

  char a = '#';
  char A = '.';
  int i,j;
  int b[300][300];
  int x,y;
  
  while(1){
    scanf("%d%d",&x,&y);
  
  if (x ==0 && y ==0){
    break;
  }
    
  for(i=0;i<x;i++){
    for(j=0;j<y;j++){
      
      if(i%2==1 && j%2==1 || i%2==0 && j%2==0) printf("%c",a);
      else printf("%c",A);
      
    }printf("\n");
  }
  printf("\n");
  }

  return 0;
}

     

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

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H;
        int X;
        while (true) {
            H = sc.nextInt();
            X = sc.nextInt();
            if (H == 0 && X == 0) {
                break;
            }

            for (int i = 0; i < H; i++) {
                for (int j = 0; j < X; j++) {
                    if (i % 2 == j % 2) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.println("");
            }
            System.out.println("");
        }
    }
}



Measured memory_bytes: 33260
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    debug("debug test\n");
    ll n,m;cin>>n;
    vll d(n+10, 0);
    vll a(n);
    rep(i, n){
        cin>>a[i];
        d[a[i]]++;
    }
    ll sum = 0;
    rep(i, n+10){
        sum += d[i]*(d[i]-1)/2;
    }
    debug("aa %d\n", sum);
    rep(i, n){
        cout << sum - d[a[i]]*(d[a[i]]-1)/2+(d[a[i]]-1)*(d[a[i]]-2)/2 << endl;
    }

    return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int max_loss = 10000;
  for (int i = 0; i < S.length() - 2; i++) {
    // cout << i << endl;
    int tmp = stoi(S.substr(i, 3));
    max_loss = min(max_loss, abs(753 - tmp));
  }
  cout << max_loss << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>

using std::cin;using std::cout;using std::cerr;using std::endl;

#define rep(i,a,b) for(int i = a;i <= b;++i)
#define per(i,a,b) for(int i = a;i >= b;--i)

int x,ans = 1,val = 7;

int main(){

	std::ios::sync_with_stdio(0);
	cin.tie(0);

	cin>>x;

	if(!(x % 2)||!(x%5)) cout<< -1;
	else{
		while(val%x){
			if(ans > x){
				cout<< -1;
				return 0;
			}
			((val *= 10) += 7) %= x;
			ans++;
		}
		// cout<<val;
		cout<<ans;
	}

	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,k;
  cin >> n >> k;
  long long a[k];
  for(int i=0;i<k;i++){
    cin >> a[i];
  }
  sort(a,a+k);
  reverse(a,a+k);
  cout << max(2*a[0]-n-1,0ll) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n, c;

	while (1) {
		scanf("%d", &n);
		if (n == 0) break;

		c = 0;
		while (1) {
			if (n == 1) break;
			else if (n % 2 == 0) {
				n /= 2;
				c++;
			}
			else {
				n *= 3;
				n += 1;
				c++;
			}
		}
		printf("%d\n", c);
	}
	return 0;
}

Measured memory_bytes: 600
using System;
using System.Linq;

namespace ALDS1_10_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] rowSize = new int[n];
            int[] colSize = new int[n];
            int[,] minMultCount = new int[n, n];
            for(int i = 0; i < n; i++){
                for (int j = 0; j < n; j++)
                {
                    if (i == j)
                    {
                        minMultCount[i, j] = 0;
                    }
                    else
                    {
                        minMultCount[i, j] = -1;
                    }
                }
            }
            for (int i = 0; i < n; i++)
            {
                int[] tmpLine = Console.ReadLine()
                                       .Split(' ')
                                       .Select(s => int.Parse(s))
                                       .ToArray();
                rowSize[i] = tmpLine[0];
                colSize[i] = tmpLine[1];
            }
            Console.WriteLine(Program.GetMinMultCount(rowSize, colSize, minMultCount, 0, n - 1));
            //Console.ReadLine();
        }
        
        private static int GetMinMultCount(int[] rowSize, int[] colSize, int[,] minMultCount, int startIndex, int endIndex){
            if (startIndex > endIndex)
            {
                throw new ArgumentException();
            }
            
            if (minMultCount[startIndex, endIndex] >= 0)
            {
                return minMultCount[startIndex, endIndex];
            }

            int minMultCountTmp = (int)Math.Pow(2, 30);
            for (int i = startIndex; i < endIndex; i++)
            {
                minMultCountTmp = Math.Min(minMultCountTmp
                                           ,Program.GetMinMultCount(rowSize, colSize, minMultCount, startIndex, i)
                                           + Program.GetMinMultCount(rowSize, colSize, minMultCount, i + 1, endIndex)
                                           + rowSize[startIndex] * colSize[i] * colSize[endIndex]);
            }
            
            minMultCount[startIndex, endIndex] = minMultCountTmp;
            return minMultCount[startIndex, endIndex];
        }
    }
}



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

using namespace std;

/**************************************************************/

#define int long long
#define tie() ios_base :: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f(i,from,to) for(int i = from ; i <to ; i++)
#define mem(a , v) memset(a , v , sizeof a)
#define all(v) v.begin() , v.end()
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define what_is(x) cerr << #x << " is : " << x <<endl

const int INF = 1e9 + 7;
const int sz = 1e5 + 20;
/***************************************************************/

int check(string s)
{
    if(s == "SUN") return 7;
    if(s == "MON")  return 6;
    if(s == "TUE")  return 5;
    if(s == "WED")  return 4;
    if(s == "THU")  return 3;
    if(s == "FRI")  return 2;
    if(s == "SAT")  return 1;
}

void solve()
{
    string s;cin>>s;
    cout<<check(s)<<endl;
    return;
}


int32_t main()
{
    clock_t st = clock();
    tie();
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    clog<<(long double)((clock() - st)/CLOCKS_PER_SEC)<<endl;
    return 0;
}


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

import bisect

INF = 1e11

A, B, Q = map(int, input().split())
S = [-INF] + [int(input()) for _ in range(A)] + [INF]
T = [-INF] + [int(input()) for _ in range(B)] + [INF]
X = [int(input()) for _ in range(Q)]

for x in X:
    ans = INF
    iS, iT = bisect.bisect(S, x), bisect.bisect(T, x)

    for s in [S[iS - 1], S[iS]]:
        for t in [T[iT - 1], T[iT]]:
            a1, a2 = abs(s - x) + abs(s - t), abs(t - x) + abs(t - s)
            ans = min(ans, a1, a2)

    print(ans)


Measured memory_bytes: 17536
#include <iostream>
#include <queue>
 
typedef long long ll;
 
int main(){
   ll K;
   std::cin >> K;
   
   ll x, y;
   std::queue<ll> que;
   for(int i=1; i<=9; ++i) que.push(i);
   for(int i=0; i<K-1; ++i){
      x = que.front();
      que.pop();
      
      y = x % 10;
      if(y != 0) que.push(10*x + y - 1);
      que.push(10*x + y);
      if(y != 9) que.push(10*x + y + 1);
   }
   std::cout << que.front() << std::endl;
   return 0;
}

Measured memory_bytes: 5096