akhauriyash/Code-Regression huggingface dataset:
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(IN())
mod=1000000007

#+++++

def main():
	n = int(input())
	#b , c = tin()
	#s = input()
	ss=set()
	for _ in range(n):
		c = int(input())
		ss.add(c)
	print(len(ss))
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
struct edge {
    ll to, cost;
};
typedef vector<vector<edge> > AdjList;
AdjList graph;
 
const ll INF = 1001001001001001001;
 
vector<ll> dist; 
vector<ll> prever;
void dijkstra(int n, int s){
    dist = vector<ll>(n,INF);
    prever = vector<ll>(n,-1);
    dist[s] = 0;
 
    priority_queue<P, vector<P>, greater<P> > que;
    que.push(P(0,s));
 
    while(!que.empty()){
        P p = que.top();
        que.pop();
        ll v = p.second;
        if(dist[v] < p.first){
            continue;
        }
        for(int i=0;i<graph[v].size();i++){
            edge e = graph[v][i];
            if(dist[e.to] > dist[v] + e.cost){
                dist[e.to] = dist[v] + e.cost;
                prever[e.to] = v;
                que.push(P(dist[e.to],e.to));
            }
        }
    }
}

vector<ll> get_path(int t){ //頂点tへの最短路
    vector<ll> path;
    for(; t != -1;t=prever[t]){
        path.push_back(t);
    }
 
    reverse(path.begin(), path.end());
    return path;
}

int main(void){
    int n;
    cin >> n;
    graph = AdjList(n);
    for(int i=0;i<n-1;i++){
      long from, to, cost;
      cin >> from >> to >> cost ;
      from--;
      to--;
      graph[from].push_back((edge){to,cost});
      graph[to].push_back((edge){from,cost});
    }
  int q,k;
  cin>>q>>k;
  dijkstra(n,k-1);
  rep(i,q){ 
    int a,b;
    cin>>a>>b;
    cout<<dist[a-1]+dist[b-1]<<endl;
  }
}

Measured memory_bytes: 14880
#include<bits/stdc++.h>
#define maxk 100000
using namespace std;
int a[maxk+10];
typedef long long LL;
int main(){
	int k;
	cin>>k;
	for(int i=1;i<=k;i++)scanf("%d",a+i);
	LL k1=1,k2=2/a[k];
	for(int i=k;i>1;i--){
		if(k1>k2)break;
		k1=k1*a[i];
		k1=k1/a[i-1]+1-(k1%a[i-1]==0);
		k2=(k2+1)*a[i];
		k2=k2/a[i-1]-(k2%a[i-1]==0);
	}
	if(k1>k2)puts("-1");
	else printf("%lld %lld",k1*a[1],(k2+1)*a[1]-1);
	return 0;
}

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

int main() {
  int n;
  string s;
  cin>>n>>s;
  for(int i=0;i<s.size();i++){
   if(n<=('Z'-s[i])) cout<<(char)(s[i]+n);
    else cout<<(char)(n-('Z'-s[i])-1+'A');
  }
  cout<<endl;
}

Measured memory_bytes: 256
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from math import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    K = II()
    ans = 0
    for a in range(1,K+1):
        for b in range(1,K+1):
            tmp = gcd(a,b)
            for c in range(1,K+1):
                ans += gcd(tmp,c)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 68368
#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b);
int main(){
    int n,sum=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                sum+=gcd(gcd(i,j),k);
            }
        }
    }cout<<sum<<endl;
}
int gcd(int a,int b){
    if(!b)return a;
    else return gcd(b,a%b);
}


Measured memory_bytes: 3588
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
using namespace std;
long long a[3];
int main(){
  for (int i=0;i<3;i++)
    cin>>a[i];
  long long k;
  cin>>k;
  sort(a,a+3);
  for (int i=0;i<k;i++)
    a[2] *= 2;
  long long ans=0;
  for (int i=0;i<3;i++)
    ans += a[i];
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
class Tree:
    root = None

    def insert(self, node):
        y = None
        x = self.root
        while x:
            y = x
            x = x.left if node.key < x.key else x.right
        node.parent = y

        if not y:
            self.root = node
        elif node.key < y.key:
            y.left = node
        else:
            y.right = node

    def find_node(self, value):
        return self.root.find(value)

    def find(self, value):
        print('yes' if self.find_node(value) else 'no')

    def delete(self, value):
        self.find_node(value).delete()

    def print(self):
        print(' ', end='')
        print(*self.root.print_in())
        print(' ', end='')
        print(*self.root.print_pre())


class Node:
    def __init__(self, key):
        self.parent = self.left = self.right = None
        self.key = key

    def find(self, value):
        diff = self.key - value
        if diff == 0:
            return self
        elif diff > 0:
            return self.left and self.left.find(value)
        else:
            return self.right and self.right.find(value)

    def delete(self):
        left, right = self.left, self.right
        if not left and not right:
            self.delete_connect(self.parent, None)
        elif left and not right:
            self.delete_connect(self.parent, left)
        elif not left and right:
            self.delete_connect(self.parent, right)
        else:
            next_node = right.get_leftmost()
            self.key = next_node.key
            next_node.delete()

    def delete_connect(self, parent, child):
        if parent:
            if parent.key > self.key:
                parent.left = child
            else:
                parent.right = child
        if child:
            child.parent = parent

    def get_leftmost(self):
        if self.left:
            return self.left.get_leftmost()
        return self

    def print_pre(self):
        yield self.key
        if self.left:
            for k in self.left.print_pre(): yield k
        if self.right:
            for k in self.right.print_pre(): yield k

    def print_in(self):
        if self.left:
            for k in self.left.print_in(): yield k
        yield self.key
        if self.right:
            for k in self.right.print_in(): yield k


tree = Tree()
m = int(input())

while m:
    l = input()
    f = l[0]
    if f == 'i':
        tree.insert(Node(int(l.split()[1])))
    elif f == 'f':
        tree.find(int(l.split()[1]))
    elif f == 'd':
        tree.delete(int(l.split()[1]))
    else:
        tree.print()
    m -= 1

Measured memory_bytes: 130880
#include <stdio.h>

int main(void)
{
  int a,b,c,tmp;
  scanf("%d %d %d", &a, &b, &c);
  if (a>b) {
    tmp=a;
    a=b;
    b=tmp;
  }
  if (a>c) {
    tmp=a;
    a=c;
    c=tmp;
  }
  if (b>c) {
    tmp=b;
    b=c;
    c=tmp;
  }
  printf("%d %d %d\n", a, b, c);
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=1e6+3;
ll vis[maxn];
ll js(ll n)
{
    return floor((sqrt(1+8*n)-1)/2);
}
ll solve(ll n)
{
    ll kk=n,sum=0,cnt=0,i;
   for(i=2;i<=sqrt(n+0.5);i++)
   {
       if(!vis[i])
       {
           sum=0;
           while(kk%i==0)
           {
               kk/=i;
               sum++;
           }
           cnt+=js(sum);
       }
   }
   if(kk>=i)
    cnt++;
   return cnt;
}
int main()
{
    ll n;
    cin>>n;
    ll m=sqrt(n+0.5);
    for(ll i=2; i<=m; i++)
        for(ll j=2*i;j<=m;j+=i)
                vis[j]=1;
    cout<<solve(n);
  return 0;
}
/*
2
1000000000000000000 1000000000000000000


32432 534342

*/


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

int main() {
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    ll total = 0;
    ll ten = 1;
    vector<ll> cnt(2019, 0);
    cnt[0]++;
    for (ll i = 0; i < s.size(); i++) {
        total += (s[i] - '0') * ten;
        total %= 2019;
        ten *= 10;
        ten %= 2019;
        cnt[total]++;
    }

    ll ans = 0;
    for (ll i = 0; i < 2019; i++) {
        ans += cnt[i] * (cnt[i] - 1) / 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int x;

int32_t main()
{
	IOS;
	cin >> x;
	vector<pair<int, int> > v;
	v.push_back({0, 0});
	for(int i = 1; i * i * i * i  <= 1e18 / i; i++)
	{
		v.push_back({i * i * i * i * i, i});
		v.push_back({-i * i * i * i * i, -i});
	}
	sort(v.begin(), v.end());
	int sz = v.size();
	for(int i = 1; i < v.size(); i++)
	{
		for(int j = 0; j < i; j++)
		{
			if(v[i].first - v[j].first == x)
			{
				cout << v[i].second << " " << v[j].second;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3744
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = InputNum();
            var k = InputNum();
            var x = InputNum();
            var y = InputNum();

            int ans = 0;
            for(int i= 1; i <= n; i++)
            {
                if (i <= k)
                {
                    ans += x;
                }
                else
                {
                    ans += y;
                }
            }
            WriteLine(ans);
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}



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

#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()  
{ 
    FAST_INP;
    int n,a,b,p,s1=0,s2=0,s3=0;
    cin >> n >> a >> b;
    for(int i=0;i<n;i++) {
    	cin >> p;
    	if(p<=a) s1++;
    	else if(a+1<=p&&p<=b) s2++;
    	else if(p>=b+1) s3++;
	}
	
	cout << min({s1,s2,s3});
    return 0;
} 

// 1st: <= A
// 2nd: A+1 <= s <= B
// 3rd: s >= B+1

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

using namespace std;
#define chmax(a,b) a=max(a,b)
#define N 3010
ll f[N][N]; string s,t;
int main(){
    cin>>s>>t;
    for(int i=0;i<N;i++)for(int j=0;j<N;j++)f[i][j]=0;
    for(int i=1;i<=s.size();i++)for(int j=1;j<=t.size();j++){
     if(s[i-1]==t[j-1])chmax(f[i][j],f[i-1][j-1]+1);
     chmax(f[i][j],f[i-1][j]);
     chmax(f[i][j],f[i][j-1]);
    }
    string ans;
    ll x=s.size(),y=t.size();
    //cout<<"#"<<f[x][y]<<endl;
    while(x>0&&y>0){
        if(f[x-1][y-1]==f[x][y]-1&&s[x-1]==t[y-1]){
         ans+=s[x-1];
         x--,y--;
         continue;
        }
        if(f[x-1][y]==f[x][y]){
            x--;
        }
        else y--;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
 return 0;   
}

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


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


import itertools
def main():
    a, b, c = input_to_int_map()
    k = input_int()

    for temp in itertools.product(range(3), repeat=k):
        red = a
        green = b
        blue = c

        if red < green < blue:
            return "Yes"

        for i in temp:
            if i == 0:
                red *= 2
            elif i == 1:
                green *= 2
            elif i == 2:
                blue *= 2

            if red < green < blue:
                return "Yes"

    return "No"


if __name__ == "__main__":
    print(main())


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

using namespace std;
int main(){
    string s;
    cin >> s;
    bool test = false;
    for(int i=0; i<s.size(); i++){
       if(s[2]==s[3] && s[4]==s[5])
          test = true;
    }
    if(test) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

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

	int b = a/100;
	int c = a - 100*b;

	if((b > 0) && (b <= 12)){
		if((c > 0) && (c <= 12 )){
			cout << "AMBIGUOUS" << endl;
		}else{
			cout << "MMYY" << endl;
		}
	}else{
		if((c > 0) && (c <= 12)){
			cout << "YYMM" << endl;
		}else{
			cout << "NA" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lld long long int
#define ld long double
#define mpi 3.14159265358979323846
#define mod 1000000007
using namespace std;
int main()
{
	int h,w;
	cin >> h >> w;
	char m[h+1][w+1];
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			cin >> m[i][j];
		}
	}
	char p[2*h + 1][w+1];
	for(int i=1;i<=2*h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			p[i][j] = m[(i+1)/2][j];
		}
	}
	for(int i=1;i<=2*h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			cout << p[i][j];
		}
		cout << "\n";
	}
	return 0;
}


Measured memory_bytes: 3632
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)

#define INF 1000000001
#define MOD 1000000007
#define INF64 1000000000000000001

#define F first
#define S second

#define Pii pair<SINT32,SINT32>
#define Pll pair<SINT64,SINT64>


using namespace std;

int main() {

	SINT32 A,B,C,D,E,F;
	cin >> A>>B>>C>>D>>E>>F;

	DOUBLE ans = -1;
	SINT32 out1 = 0;
	SINT32 out2 = 0;

	rep(i,0,(F/A)+1) {
		rep(j,0,(F/B)+1) {
			SINT32 full = i*A + j*B;
			if ((i == 0) && (j == 0)) {
				break;
			}

			if (full*100 > F) {
				break;
			}
			rep(k1,0,(F/C)+1) {
				rep(k2,0,(F/D)+1) {
					SINT32 sa = k1*C + k2*D;
					if (full*E < sa) {
						break;
					}
					if (full*100+sa > F) {
						break;
					}
					if (ans < (sa*100.0/(full*100+sa))) {
						ans = (sa*100.0/(full*100+sa));
						out1 = full*100+sa;
						out2 = sa;
					}			
				}
			}
		}
	}

	cout << out1 << " " << out2 << endl;
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());	//ソート後に使用

//	DATA.insert(DATA.begin() + X, 0);	//X番目の要素に0を挿入


//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));	//2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();	//key以上を探す
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/
/* 文字列合成
	string N,M;
	cin >> N >> M;
	SINT64 ans = 0;
	ans = stoi(N+M);
*/



/* SET コンテナ
	set<SINT32> DATA;
	for (SINT32 i = 0; i < N; i++) {
		SINT32 buf;
		cin >> buf;
		DATA.insert(buf);
	}

	//全表示
    set<string>::iterator it; //  イテレータを用意
    for(it = DATA.begin(); it != DATA.end(); it++) {
        cout << *it << endl;
    }

	//N番目を一部表示
	set<string>::iterator it; //  イテレータを用意
	it = DATA.begin();
	rep (i,0,N) {
		it++;
	}
	cout << *it << endl;
*/

/* map
	map<string,SINT32> mp;
	SINT32 N = 0;
	SINT32 mx = 0;

	cin >> N;
	for (SINT32 i = 0; i < N; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	for(auto it=mp.begin();it!=mp.end();it++) {
		mx=max(mx,it->second);
	}

*/

Measured memory_bytes: 256
n,m=map(int,input().split())

import sys
sys.setrecursionlimit(10**9) #再帰の上限をあげる

root=[i for i in range(n+1)] #自分が親なら自身の番号を、そうでないなら（元）親の番号を示す

def r(x):   #親は誰？
    if root[x]==x:
        return x
    else:
        root[x]=r(root[x])
        return root[x]

def unite(x,y):
    x=r(x)
    y=r(y)
    if x==y:
        return
    if x>y:
        x,y=y,x
    root[y]=x

for i in range(m):
    x,y,z=map(int,input().split())
    unite(x,y)

ans=0
for i in range(1,n+1):
    if root[i]==i:
        ans+=1
print(ans)




Measured memory_bytes: 80480
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define MAX 510000
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll n; cin >> n;
    ll d,x; cin >> d >> x;
    ll ans = x;
    rep(i,n){
        ll a; cin >> a;
        ans += 1 + (d-1) / a;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#define min(a,b)    (((a) < (b)) ? (a) : (b))
#define max(a,b)    (((a) > (b)) ? (a) : (b))
#define abs(x)    ((x) < 0 ? -(x) : (x))
#define INF 0x3f3f3f3f
#define delta 0.85
#define eps 1e-3
#define PI 3.14159265358979323846
#define MAX_V 10005
#define MAX_E 10000000
using namespace std;
struct edge{
	int u, v;
	double cost;
}es[MAX_E];
int V, E;
int X[MAX_V], Y[MAX_V];

bool cmp(const edge& e1, const edge& e2){
	return e1.cost > e2.cost;
}

/**** Union_find ****/
int par[MAX_V], rank[MAX_V];

void init_union_find(int n){
	for(int i = 0; i < n; i++){
		par[i] = i, rank[i] = 0;
	}
}

int find(int x){
	if(par[x] == x) return x;
	return par[x] = find(par[x]);
}

bool same(int x, int y){
	return find(x) == find(y);
}

void unite(int x, int y){
	x = find(x), y = find(y);
	if(x == y) return;
	if(rank[x] > rank[y]) par[y] = x;
	else{
		par[x] = y;
		if(rank[x] == rank[y]) ++rank[y];
	}
}
/**** Union_find ****/

// Kruskal
double kruskal(){
	sort(es, es + E, cmp);
	init_union_find(V);
	double res = 0;
	for(int i = 0; i < E; i++){
		edge &e = es[i];
		if(!same(e.u, e.v)){
			res += e.cost;
			unite(e.u, e.v);
		}
	}
	return res;
}

double dist(int u, int v){
	double dx = X[u] - X[v], dy = Y[u] - Y[v];
	return sqrt(dx * dx + dy * dy);
}

int main(){
	while(~scanf("%d%d", &V, &E) && V){
		for(int i = 0; i < V; i++) scanf("%d%d", X + i, Y + i);
		double sum = 0.0;
		for(int i = 0; i < E; i++){
			int u, v;
			scanf("%d%d", &u, &v);
			--u, --v;
			es[i].u = u, es[i].v = v, es[i].cost = dist(u, v);
			sum += es[i].cost;
		}
		printf("%.3f\n", sum - kruskal());
	}
	return 0;
}




Measured memory_bytes: 3840
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>

using namespace std;

#define mod 1000000007

string s;
int l;
vector<vector<set<int> > > result;
vector<vector<bool> > ischecked;

set<int> solve(int i, int n)
{
	// cout << i << " " << n << endl;
	// s???i????????????n????????¨??£????????????????¨???????????????????????????????
	if(ischecked[i][n]) return result[i][n];
	ischecked[i][n] = true;
	stack<int> leftkakko;
	bool noopandkakko = true;
	int num = 0;
	for(int j = 0; j < n; j++){
		if(s[i + j] == '('){
			leftkakko.push(i + j);
			noopandkakko = false;
		} else if(s[i + j] == ')'){
			int tmp = leftkakko.top();
			leftkakko.pop();
			result[tmp][i + j - tmp + 1] = solve(tmp + 1, i + j - tmp - 1);
		} else if(isdigit(s[i + j])){
			num = 10 * num + (s[i + j] - '0');
		} else {
			if(!leftkakko.empty()) continue;
			noopandkakko = false;
			set<int> left, right;
			left = solve(i, j);
			right = solve(i + j + 1, n - j - 1);
			for(auto p = left.begin(); p != left.end(); p++){
				for(auto q = right.begin(); q != right.end(); q++){
					if(s[i + j] == '+'){
						result[i][n].insert((*p) + (*q));
					} else if(s[i + j] == '*'){
						result[i][n].insert((*p) * (*q));
					} else if(s[i + j] == '-'){
						result[i][n].insert((*p) - (*q));
					} else if(s[i + j] == '/'){
						if((*q) != 0) result[i][n].insert((*p) / (*q));
					}
				}
			}
		}
	}
	if(noopandkakko) result[i][n].insert(num);
	// cout << i << " " << n << ":" << endl;
	// for(auto j = result[i][n].begin(); j != result[i][n].end(); j++){
	// 	cout << (*j) << endl;
	// }
	return result[i][n];
}

int main()
{
	while(1){
		cin >> s;
		if(s == "#") break;
		l = s.length();
		result = vector<vector<set<int> > >(l + 1, vector<set<int> >(l + 1));
		ischecked = vector<vector<bool> >(l + 1, vector<bool>(l + 1, false));
		cout << solve(0, l).size() << endl;
	}
	return 0;
}

Measured memory_bytes: 3292
#include <stdio.h>

int main(void)
{
    int N, M;
    int a[100], b[100];
    int min, max;
    int count;
    int i, j;
    
    scanf("%d%d", &N, &M);
    
    for (i = 0; i < M; i++){
        scanf("%d%d", &a[i], &b[i]);
    }
    
    min = 1;
    count = 0;
    while (1){
        max = 0;
        for (i = 0; i < M; i++){
            if (a[i] <= min && b[i] >= min){
                if (max < b[i]){
                    max = b[i];
                }
            }
        }
        count++;
        if (max == N){
            printf("%d\n", count);
            break;
        }
        else if (max == 0){
            printf("Impossible\n");
            break;
        }
        min = max + 1;
    }
    return (0);
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
const int INF=1000000000;

int main()
{
  int N=(1<<16);
  vector<vector<pair<int,int> > > E(N);
  for(int I=0;I<(1<<16);I+=2){
    for(int j=1;j<16;j++){
      for(int k=j+1;k<16;k++){
	if(!((I>>j)&1)||!((I>>k)&1))continue;
	int J=I^(1<<j)^(1<<k)^(1<<(j^k));
	int t=((I>>(j^k))&1)+1;
	E[J].push_back(make_pair(I,t));
      }
    }
  }
  vector<int> V(N,INF);
  V[0]=0;
  priority_queue<pair<int,int> > Q;
  Q.push(make_pair(0,0));
  while(!Q.empty()){
    int d=-Q.top().first,i=Q.top().second;
    Q.pop();
    if(V[i]<d)continue;
    for(int x=0;x<E[i].size();x++){
      int j=E[i][x].first,D=d+E[i][x].second;
      if(D<V[j]){
	V[j]=D;
	Q.push(make_pair(-D,j));
      }
    }
  }
  int n;
  scanf("%d",&n);
  vector<vector<pair<int,int> > > e(n);
  for(int i=0;i<n-1;i++){
    int x,y,a;
    scanf("%d%d%d",&x,&y,&a);
    e[x].push_back(make_pair(y,a));
    e[y].push_back(make_pair(x,a));
  }
  int C[16]={0};
  for(int i=0;i<n;i++){
    int t=0;
    for(int x=0;x<e[i].size();x++){
      t^=e[i][x].second;
    }
    C[t]++;
  }
  int I=0;
  int ans=0;
  for(int t=1;t<16;t++){
    I|=((C[t]&1)<<t);
    ans+=C[t]/2;
  }
  ans+=V[I];
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 18420
def f(a,b):
  if a>b:a,b=b,a
  if a==b or a+1==b:
    return 2*a-2
  else:
    c=int((a*b)**(1/2))
    if c**2==a*b:c-=1
    if c*(c+1)>=a*b:
      return 2*c-2
    else:
      return 2*c-1

q=int(input())
for _ in range(q):
  a,b=map(int,input().split())
  print(f(a,b))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl
#define isort(a) sort(a.begin(),a.end())

using namespace std;

#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

typedef pair<ll,ll> Pair;
typedef vector<ll> vecll;
const ll inf =1000000007;

void asolve(){
    string s,t;
    cin >> s >>t;
    bool can=true;

    for(ll i=0;i<s.size();i++){
        if(s[i]!=t[i]) can=false;
    }

    if(can) cout <<"Yes" << endl;
    else cout <<"No" << endl;


}

void bsolve(){

    ll a,b,c,k;
    cin >> a>> b>> c>>k;

    if(k<=a){
        kaku(k);
    }
    else if(k<=(a+b)){
        kaku(a);
    }
    else if (k<=a+b+c){
        kaku(a+a+b-k);
    }
    else {
        kaku(a-c);
    }

}

void csolve(){

    ll n,m,x;
    cin >> n >> m >>x;
    ll c[n];
    ll a[n][m];
    rep(i,n){
        cin >> c[i];
        rep(j,m){
            cin >> a[i][j];
        }
    }
    ll ri[m];
    ll ans=-1;
    for(ll bit=0;bit<(1LL<<n);bit++){
        rep(i,m) ri[i]=0;
        ll score=0;
        ll can=true;
        rep(i,n){
            if(bit & (1LL<<i)){
                score+=c[i];
                rep(j,m){
                    ri[j]+=a[i][j];
                }
            }
        }
        rep(i,m){
            if(x>ri[i]) can=false;
        }
        if(can){
            if(ans==-1) ans=score;
            else ans=min(ans,score);
        }
    }
    kaku(ans);
}

void dsolve(){

    ll n,k;
    cin >> n>> k;
    map<ll,ll> mp;
    rep(i,n){
        ll a;
        cin >>a;
        mp[i+1]=a;
    }
    ll now=1;

    vecll vec;//いった集合
    vec.pb(1);
    bool visit[n+1];
    rep(i,n+1) visit[i]=false;
    visit[1]=true;
    map<ll,ll> iku;//そこを訪れたのはなん回目か
    iku[1]=0;
    ll loop;
    bool d=false;

    for(ll i=1;i<=k;i++){
        now=mp[now];
        if(visit[now]){
            d=true;
            loop=i;
            break;
        }
        else{
            vec.pb(now);
            iku[now]=i;
            visit[now]=true;
        }
    }
    //loop~iku[now]でループ検出

    //ループ処理
    if(d){
        ll e=loop-iku[now];
        ll u=(k-iku[now])%e;

        now=vec[iku[now]+u];

        cout << now << endl;
    }
    else{
        cout << now << endl;
    }

}


int main(){
    dsolve();
}

Measured memory_bytes: 27172
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
int a, b, k;
void solve() {
	cin >> a >> b >> k;
	for (int i = a; i <= min(b, a + k - 1); ++i) {
		cout << i << endl;
	}
	for (int i = max(a + k, b - k + 1); i <= b; ++i) {
		cout << i << endl;
	}
	return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
	  fac[i] = fac[i-1] * i % MOD;
	  inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
	  finv[i] = finv[i-1] * inv[i] % MOD;
	}
}
//組み合わせ
long long COM (int n, int k) {
	if(n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
	solve();
}

Measured memory_bytes: 256
import java.io.*
import java.util.*

fun solve(A: Long, B: Long){
    fun isPalindromic(x: Long): Boolean{
        return x.toString() == x.toString().reversed()
    }
    println((A..B).count{ isPalindromic(it) })
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val A = sc.next().toLong()
    val B = sc.next().toLong()
    solve(A, B)
}



Measured memory_bytes: 42784
#include <stdio.h>
#define max(X, Y) ((X) > (Y) ? (X) : (Y))

int main()
{
	int n;
	int l;
	int maxv = -1;
	int sum = 0;

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &l);
		maxv = max(maxv, l);
		sum = sum + l;
	}

	if (sum - maxv > maxv) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 128
n, m = [ int(v) for v in input().split() ]
city_list = [ [] for i in range(n+1) ]

for i in range(m):
    p, y = [ int(v) for v in input().split() ]
    city_list[p].append((y,i))
city_list = [ sorted(i) for i in city_list ]

def numbering(a,b):
    a, b = str(a), str(b)
    return a.zfill(6) + b.zfill(6)

ans_list = []
for i, w in enumerate(city_list):
    for j, v in enumerate(w,1):
        ans_list.append((v[1], numbering(i, j)))

for i in sorted(ans_list):
    print(i[1])

Measured memory_bytes: 91296
#include <stdio.h>
int main()
{
	int n, a[1000], i, j, v, gap, ans;
for(;;){
	scanf("%d", &n);
if(n==0) break;
else{
	for (i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	for (i = 2; i <= n; i++) {
		j = i - 1;
		while (j >= 1 && a[j] > a[j + 1]) {
			v = a[j + 1];
			a[j + 1] = a[j];
			a[j] = v;
			j--;
		}
	}
	ans = 1000000;
	for (i = 1; i <= n - 1; i++) {
		gap = a[i + 1] - a[i];
		if (ans>gap) ans = gap;
	}

	printf("%d\n", ans);}}
	return 0;
}


Measured memory_bytes: 2708
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    cout << fixed << setprecision(10);
    int N;
    cin >> N;
    vector<int> a(N + 1);
    REP(i, N) { cin >> a[i + 1]; }
    vector<int> b(N + 1);
    for(int i = N; 0 < i; i--) {
        if(a[i] == 0) {
            int cnt = 0;
            for(int j = i * 2; j <= N; j += i) {
                if(b[j] == 1) {
                    cnt++;
                }
            }
            b[i] = cnt % 2;
        } else {
            int cnt = 0;
            for(int j = i * 2; j <= N; j += i) {
                if(b[j] == 1) {
                    cnt++;
                }
            }
            b[i] = 1 - cnt % 2;
        }
    }
    int sum = 0;
    REP(i, N + 1) if(b[i] == 1) sum++;
    cout << sum << endl;
    REP(i, N + 1) if(b[i] == 1) cout << i << " ";
    return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	for(int i=0;i<s.size();i++)
		s[i]='x';
	cout<<s<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>

using namespace std;

void print(vector<vector<bool>> &field) {
    for (auto row: field) {
        for (auto col: row) {
            cout << (col ? '#' : '.');
        }
        cout << endl;
    }
}

int main() {
    int h, w;
    cin >> h >> w;

    vector<vector<bool>> field(h, vector<bool>(w, false));
    queue<pair<int, int>> q1, q2;

    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
            char t;
            cin >> t;
            field[y][x] = t == '#';
            if (t == '#') q1.push(make_pair(x, y));
        }
    }

    int ans = 0;

    while (!q1.empty() || !q2.empty()) {
        while (!q1.empty()) {
            auto point = q1.front(); q1.pop();
            int x = point.first, y = point.second;

            if (x-1 >= 0 && !field[y][x-1]) {
                field[y][x-1] = true;
                q2.push(make_pair(x-1, y));
            }
            if (x+1 < w && !field[y][x+1]) {
                field[y][x+1] = true;
                q2.push(make_pair(x+1, y));
            }
            if (y-1 >= 0 && !field[y-1][x]) {
                field[y-1][x] = true;
                q2.push(make_pair(x, y-1));
            }
            if (y+1 < h && !field[y+1][x]) {
                field[y+1][x] = true;
                q2.push(make_pair(x, y+1));
            }
        }

        if (!q2.empty()) ans++;
        swap(q1, q2);
    }

    cout << ans << endl;
}


Measured memory_bytes: 8592
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    while(true){
        int n; cin >> n;
        if(n == 0) return 0;
        else{
            vector<int> Score(n);
            REP(i, n) cin >> Score[i];
            int ave = 0;
            whole(sort, Score);
            for(int i = 1; i < n - 1; i++) ave += Score[i];
            ave /= n - 2;
            cout << ave << endl;
        }
    }
}


Measured memory_bytes: 3068
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
c = Counter(S)
ans =[]
maxnum = c.most_common()[0][1]
for k, v in c.items():
    if v == maxnum:
        ans.append(k)
ans.sort()
for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 45040
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc119_a.cpp
 * time   : Fri May  1 14:45:27 2020
 * quest  : A - Still TBD
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  cout << ((s > "2019/04/30") ? "TBD\n" : "Heisei\n");
  return 0;
}


Measured memory_bytes: 256
#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-1); i >= 0; --i)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> p(N);
    for (auto &i : p) cin >> i;

    sort(p.begin(), p.end());

    int ans = 0;
    rep(i, K) ans += p[i];

    cout << ans << endl;
}

Measured memory_bytes: 3628
//cod2017_qualC_c.cpp
//Wed Aug  7 21:46:56 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int forward = 0;
	int reverse = s.length()-1;
	int ans = 0;
	while (forward<reverse){
		if (s[forward]!=s[reverse]){
			if (s[forward]=='x'){
				ans++;
				forward++;
			}else if (s[reverse]=='x'){
				ans++;
				reverse--;
			}else {
				cout << -1 << endl;
				return 0;
			}
		}else {
			forward++;
			reverse--;
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

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

int main() {
    ll A=0, B=0;
    cin >> A >> B;

    ll cnt = 0;
    vector<ll> C;
    ll sqA= sqrt(A);
    ll sqB = sqrt(B);
//    cout << sqA << " " << sqB << endl;

    if(A <= B){
        for(ll i=1; i<=sqA; i++){
            if(A%(i) == 0){
                C.push_back(i);
                if(A/i != i){
                    C.push_back(A/i);
                }
             }
        }
    }
    else{
        for(ll i=1; i<=sqB; i++){
            if(B%(i) == 0){
                C.push_back(i);  
                if(B/i != i){
                    C.push_back(B/i); 
                }    
            }
        }        
    }

    sort(C.begin(), C.end());

    if(A <= B){
        for(ll i=0; i<C.size(); i++){
            if(B%C.at(i) != 0){
                C.at(i) = -1;
             }
        }
    }
    else{
        for(ll i=0; i<C.size(); i++){
            if(A%C.at(i) != 0){
                C.at(i) = -1;
             }
        }    
    }

    for(ll i=1; i<C.size(); i++){
        if(C.at(i) <= 0) continue;
        for(ll j=i+1; j<C.size(); j++){
            if(C.at(j)%C.at(i) == 0){
                C.at(j) = -1;
            }
        }
    }

    rep(i, C.size()){
        if(C.at(i) > 0) cnt++;
//        cout << "C = "<< C.at(i) <<  endl;
    }

    cout << cnt << endl;

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
long long int a[100000];
int main()
{
    long long int n,i,x,y,t,s,d;
   scanf("%lld",&n);
   s=0;
    for(i=0;i<n;i++)
    {
        scanf("%lld",&d);
        a[d]++;
        s+=d;
    }
   scanf("%lld",&t);
    while(t--)
    {
        scanf("%lld%lld",&x,&y);
       a[y]+=a[x];
       s+=(y-x)*a[x];
       a[x]=0;
        printf("%lld\n",s);
    }
    return 0;
}
 

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

int main()
{
    int a, b, k;
    cin >> a >> b >> k;
    if(b-a <= 2*k-1){
        for(int i =a; i<=b; i++){
            cout << i << endl;
        }
        return 0;
    }
    
    for(int i=a; i<a+k; i++){
        cout << i << endl;
    }
    for(int i=b-k+1; i<=b; i++){
        cout << i << endl;
    }
    return 0;
}

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

using namespace std;

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    ll N, A, B;
    cin >> N >> A >> B;
    
    if(B < A) cout << 0 << endl;
    else if(N == 1 && A != B) cout << 0 << endl;
    else if(N == 1 && A == B) cout << 1 << endl;
    else cout << (B-A)*(N-2)+1 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		StringBuilder output = new StringBuilder();
		Scanner scan = new Scanner(System.in);
		while(true) {
			int H = scan.nextInt();
			int W = scan.nextInt();
		
			if (H == 0 && W == 0)
				break;
			
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					output.append("#");
				}
				output.append('\n');
			}
			output.append('\n');
		}
		System.out.print(output);
	}

}

Measured memory_bytes: 20576
n,m = map(int, input().split())

p = [-1]*n
for i in range(m):
  s,c = map(int, input().split())
  s -= 1
  if p[s] != -1 and p[s] != c:
    print(-1)
    exit()
  p[s] = c
  
if n != 1:
  if p[0] == -1:
    p[0] = 1
  for i in range(1, n):
    if p[i] == -1:
      p[i] = 0
else:
  if p[0] == -1:
    p[0] = 0
    
t = ''
for i in p:
  t += str(i)
t = int(t)

if len(str(t)) == n:
  print(t)
else:
  print(-1)

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

class Program
{
    static void Main(string[] args)
    {
    	var sc = new Scanner();
    	int n = sc.NextInt();
    	int y = sc.NextInt();
    	for (int i = 0; i <= y / 10000; i++)
    	{
    		for (int j = 0; j <= y / 5000; j++)
    		{
    			int r = (y - i * 10000 - j * 5000) / 1000;
    			if (r >= 0 && (y - i * 10000 - j * 5000) % 1000 == 0 && i + j + r == n)
    			{
    				Console.WriteLine("{0} {1} {2}", i, j, r);
    				return;
    			}
    		}
    	}
    	Console.WriteLine("-1 -1 -1");
    }
    
    static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }
        
    public long NextLong()
    {
    	CheckNext();
    	return long.Parse(buf[index++]);
    }
    
    public double NextDouble()
    {
    	CheckNext();
    	return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct frep {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr frep(int l_, int r_): l(std::min(l_, r_)), r(r_) {}
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct brep {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr brep(int l_, int r_): r(std::max(l_, r_) - 1), l(l_ - 1) {}
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

template <class T>
inline T scan() {
  T res;
  std::cin >> res;
  return res;
}

using lint = long long;
lint H;
std::map<lint, lint> map;

lint dfs(lint x) {
  if (x == 0) {
    return 0;
  }
  if (map.find(x) != map.end()) {
    return map[x];
  }
  return map[x] = 2 * dfs(x / 2) + 1;
}

int main() {
  std::cin >> H;
  std::cout << dfs(H) << '\n';
  return 0;
}


Measured memory_bytes: 256
from collections import deque

def main():
    H, W = map(int, input().split())
    maze = [list(input()) for _ in range(H)]

    ans = 0
    for h in range(H):
        for w in range(W):
            if maze[h][w] == '#':
                continue

            goal_dists = [[-1] * W for _ in range(H)]
            goal_dists[h][w] = 0
            d = deque([[h, w]])

            while d:
                ht, wt = d.popleft()
                for dh, dw in [[0, 1], [0, -1], [1, 0], [-1, 0]]:
                    if not (0 <= ht+dh < H and 0 <= wt+dw < W):
                        continue
                    if maze[ht+dh][wt+dw] == '#':
                        continue
                    if goal_dists[ht+dh][wt+dw] == -1:
                        goal_dists[ht+dh][wt+dw] = goal_dists[ht][wt] + 1
                        d.append([ht+dh, wt+dw])
            
            ans = max(ans, max([max(l) for l in goal_dists]))

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <numeric>

using namespace std;

typedef long long int ll;
typedef long int li;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main() {
    ll ans=0;
    ll k,p,n,a,b,c;
    cin >> a >> p;
    ans = (3*a+p)/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
    coder:xxjAc
    name:Jury Marks
    time：2017/7/13 
*/
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;
int a[57];
int main(){
	int n,k;
	cin>>n>>k;
	for (int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	int ans=0;
	for (int i=n-1;i>=n-k;i--){
		ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main()
{
  int N;
  cin >> N;
  vint X(N);
  REP(i,N) cin >> X[i];
  sort(X.begin(),X.end());
  
  ll ans = 1000000000;
  for(int i=X[0]; i<=X[N-1]; i++){
    ll sum = 0;
    for(auto x : X){
      sum += (x-i)*(x-i);
    }
    ans = min(ans,sum);
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256