akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>  // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>     // bitset
#include <cctype>     // isupper, islower, isdigit, toupper, tolower
#include <cstdint>    // int64_t, int*_t
#include <cstdio>     // printf
#include <deque>      // deque
#include <iomanip>    // fixed, setprecision
#include <iostream>   // cout, endl, cin
#include <map>        // map
#include <queue>      // queue, priority_queue
#include <set>        // set
#include <stack>      // stack
#include <string>     // string, to_string, stoi
#include <tuple>      // tuple, make_tuple
#include <unordered_map>  // unordered_map
#include <unordered_set>  // unordered_set
#include <utility>        // pair, make_pair
#include <vector>         // vector
using namespace std;

int main() {
  string s;
  int upper, downer;
  bool um = false, dm = false;
  cin >> s;
  upper = stoi(s.substr(0, 2));
  downer = stoi(s.substr(2, 2));

  if (1 <= upper && upper <= 12) um = true;
  if (1 <= downer && downer <= 12) dm = true;

  if (um && dm) {
    cout << "AMBIGUOUS" << endl;
  } else if (um) {
    cout << "MMYY" << endl;
  } else if (dm) {
    cout << "YYMM" << endl;
  } else {
    cout << "NA" << endl;
  }
}


Measured memory_bytes: 3068
#include<stdio.h>

int main()
{
    int n,x,cnt=0;
    while(1)
    {
        cnt = 0;
        scanf("%d %d",&n,&x);
        if(n==0&&x==0) break;
        for(int n1 = 1;n1<n;n1++)
        {
            for(int n2 = n1+1;n2<=n;n2++)
            {
                for(int n3 = n2+1;n3<=n;n3++)
                {
                    if(n1+n2+n3 == x) cnt +=1;
                }
            }
        }
        printf("%d\n",cnt);
    }
    return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
  int T;
  cin >> T;
  for (int t=0; t<T; t++) {
    string word1, word2;
    cin >> word1 >> word2;
    int m = word1.size();
    int n = word2.size();
    int c[m+1][n+1]={};
    int max_len = 0;
    word1 = ' ' + word1;
    word2 = ' ' + word2;

    for (int i=1; i<=m; i++) {
      for (int j=1; j<=n; j++) {
        if (word1[i] == word2[j]) {
          c[i][j] = c[i-1][j-1] + 1;
        }
        else {
          c[i][j] = max(c[i-1][j], c[i][j-1]);
        }
        max_len = max(max_len, c[i][j]);
      }
    }
    cout << max_len << endl;
  }
  return 0;
}

#if 0
???????????????30????????????
?????????0??????????????????????????????????¬?????????????0??§??????????????????????????????1???????§????????????¨??§
????????????????????????????????????????????????????????????
#endif

Measured memory_bytes: 7052
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    string S;
    cin >> S;
    if(S == "Sunny") {
        cout << "Cloudy" << endl;
    } else if(S == "Cloudy") {
        cout << "Rainy" << endl;
    } else if(S == "Rainy") {
        cout << "Sunny" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define sd(mark) scanf("%d",&mark)
#define s2d(mark,marx) scanf("%d%d",&mark,&marx)
#define s3d(mark,marx,marz) scanf("%d%d%d",&mark,&marx,&marz)
#define sf(mark) scanf("%f",&mark)
#define slf(mark) scanf("%lf",&mark)
#define sst(mark) scanf("%s",&mark)
#define sld(mark) scanf("%lld",&mark)
#define s2ld(mark,marx) scanf("%lld%lld",&mark,&marx)
#define s3ld(mark,marx,marz) scanf("%lld%lld%lld",&mark,&marx,&marz)
#define sline(mline) scanf("%[^\n]%*c",&mline)
 
#define pi(n) printf("%d\n",n)
#define pf(n) printf("%f\n",n)
#define plf(n) printf("%lf\n",n)
#define pst(n) printf("%s\n",n)
#define pl(n) printf("%lld\n",n)
 
#define pis(n) printf("%d ",n)
#define pfs(n) printf("%f ",n)
#define plfs(n) printf("%lf ",n)
#define pss(n) printf("%s ",n)
#define pls(n) printf("%lld ",n)
 
#define sff fflush(stdout)
#define decimal(n) cout.precision(n)
#define fix cout<<fixed
#define debug(mark) printf("check%d\n",mark)
#define in(a) cin>>a
#define out(a) cout<<a<<'\n'
#define clr(mark) memset(mark,0,sizeof(mark))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ll long long int
#define mod 1000000007ll
#define llu unsigned long long int
#define endl '\n'
#define INF 1123456789
#define eps 1e-9
#define fo(i,a,b) for(int i=a;i<b;++i)
#define foll(i,a,b) for(ll i=a;i<b;++i)
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
 
#define UL 100000		//5
#define MAXN 1000000	//6
#define MAXL 10000000	//7
 
typedef vector< vector<int> > vvi;
typedef vector< vector<ll> > vvl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< pair<ll,ll> > vll;
typedef pair<char,char> pcc;
typedef vector< pair<int, int> > vii;
 
 
// bool mark[MAXN+5];
 
// int sieve()
// {
// 	int ULL = MAXN;
// 	for(int i=0;i<=ULL;i++) mark[i]=true;
// 	for(int i=2;i*i<=ULL;i++) if(mark[i]) for(int j=i*i;j<=ULL;j+=i) mark[j]=false;
// 	for(int i=2;i<=ULL;i++) if(mark[i]) p.pb(i);
// 	return p.size();
// }
 
 
ll gcd(ll a, ll b) {if(!b) return a; return gcd(b,a%b);}
 
ll modexp(ll a,ll b)
{
	if(b==0) return 1;
	if(b==1) return a;
	ll temp = modexp(a,(b>>1));
	temp = (temp*temp);
	return (temp*modexp(a,b&1));
}
 
ll modexp(ll a,ll b, ll m)
{
	if(b==0) return 1;
	if(b==1) return a%m;
	ll temp = modexp(a,(b>>1),m);
	temp = (temp*temp)%m;
	return (temp*modexp(a,b&1,m))%m;
}
 
ll modinv(ll a, ll p)
{
	return modexp(a,p-2,p);
}
 
int main()
{
	int x1,y1,x2,y2;
	s2d(x1,y1);
	s2d(x2,y2);
	int x3 = x2 + y1-y2;
	int y3 = y2 + x2-x1;
	int x4 = x1 + x3-x2;
	int y4 = y1 + y3-y2;
	cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<"\n";
}

Measured memory_bytes: 256
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    A = read_ints()
    S = A[0]
    answer = 0
    modulo = 10**9+7
    for i in range(1, N):
        answer = (answer+A[i]*S)%modulo
        S = (S+A[i])%modulo
    return answer


if __name__ == '__main__':
    print(solve())


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

// これだとWAになる・・・
int main() {
    int N, M;
    cin >> N >> M;
    map<int, int> waCountMap;
    map<int, bool> acMap;
    int p;
    string s;
    for (int i = 0; i < M; i++) {
        cin >> p >> s;
        if (acMap.find(p) == acMap.end()) {
            if (s == "AC") {
                acMap[p] = true;
            } else {
                waCountMap[p]++;
            }
        }
    }
    int waCount = 0;
    for (auto itr = waCountMap.begin(); itr != waCountMap.end(); itr++) {
        if (acMap.find(itr->first) != acMap.end()) {
            waCount += itr->second;
        }
    }
    cout << acMap.size() << " " << waCount;
}


Measured memory_bytes: 8168
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#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++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 10000007;
const int inf = 1001001001;



int main(void) {
  int n;
  cin >> n;
  vector<tuple<string,int,int>> a(n);
  rep(i,n){
    int p;
    string q;
    cin >> q >> p;
    a[i] = make_tuple(q,100-p,i+1);
  }
  sort(ALL(a));
  rep(i,n){
    cout << get<2>(a[i]) << endl;
  }
    
}


Measured memory_bytes: 256
# coding: utf-8
import re
import math
import itertools
from copy import deepcopy
import fractions
import random
from heapq import heappop,heappush
import time
import sys
readline = sys.stdin.readline
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
#main
n,k=map(int,input().split())
P=list(map(int,input().split()))
S=[0]*(n-k+1)
A=[0]*1100
sum_=0
for a in range(1,len(A)):
    sum_+=a
    A[a]=sum_/a
for a in range(k):
    S[0]+=A[P[a]]
for a in range(1,n-k+1):
    S[a]=S[a-1]
    S[a]+=A[P[k+a-1]]
    S[a]-=A[P[a-1]]
print(format(float(max(S)), '.20f'))






Measured memory_bytes: 27972
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<28));
const ll linf = (1LL<<58);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, t;
    cin >> x >> t;
    cout << max(0, x-t) << endl;
    return 0;
}


Measured memory_bytes: 256
function myout(text){console.log(text);}//standard output
function Main(input) {
	input = parseInt(input);
	//input = input.split(" ");
	//input = input.split("\n");
	//input = input.split(" ").map((a)=>Number(a));
	//input = input.split("\n").map((a)=>Number(a));
  var list = [];
  var output = 0;
  for(var i = 1; i <= input; i++){
    output += i;
    list.push(i);
    if(output == input){
       myout(list.join("\n"));
      return;
    }else if(output > input){
      var diff = output - input;
      list.splice(list.indexOf(diff),1);
      myout(list.join("\n"));
      return;
    }
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 7756
fun main(arr: Array<String>) {
    val n = readLine()!!.toInt()
    val r = readLine()!!.split(" ").map { it.toLong() }
    val fixed = mutableListOf(r.first())
    for(i in (1 until n)) {
        if(r[i] != fixed.last()) {
            fixed.add(r[i])
        }
    }
    var isBigger = true
    if(fixed.size >= 2) {
        isBigger = fixed[0] < fixed[1]
    }
    var ans = 1
    var idx = 1
    if(fixed.size >= 2) {
        while (idx < fixed.size) {
            if(isBigger) {
                if(fixed[idx-1] < fixed[idx]) {
                    idx++
                    continue
                }
            } else {
                if(fixed[idx-1] > fixed[idx]) {
                    idx++
                    continue
                }
            }
            if(idx < fixed.size - 1) {
                isBigger = fixed[idx] <= fixed[idx+1]
            }
            ans++
            idx+=1
        }
    }
    println(ans)
}

Measured memory_bytes: 57920
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;

//Nayeem Shahriar Joy,Applied Physics And Electronic Engineering,University of Rajshahi.


int main(){

 int i,n;

 for(int i=1;;i++)
 {
     cin>>n;

     if(n==0)
     {
         return 0;
     }

     else
     {
         cout<<"Case "<<i<<": "<<n<<endl;
     }
 }
  return 0;
}

Measured memory_bytes: 3060
//g++ -std=c++11 -Wall test.cpp -o test -lm -g -O2
#include <bits/stdc++.h>
using namespace std;
#define sws                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define qi queue<int>
#define si stack<int>
#define s string
#define ll long long;

int main()
{
    sws;
    int a, b, sum, sub, mult;
    cin >> a >> b;
    sum = a + b;
    sub = a - b;
    mult = a * b;
    cout << max(sum, max(sub, mult)) << endl;
}

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

using namespace std;

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

  int N; cin>>N;

  constexpr int MOD = 1000000007;
  int dp[3] = {};
  int ans = 1;
  for (int i = 0; i < N; i++) {
    int a; cin>>a;
    int cnt = 0;
    for (auto v : dp)
      if (v == a)
        cnt++;
    ans = (long)ans * cnt % MOD;
    for (auto& v : dp)
      if (v == a) {
        v++;
        break;
      }
    cerr << ans << endl;
  }
  cout << ans << endl;

  return 0;
}


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

const string LRDU = "LRDU";
int xsig[] = {0, 2, 1, 1};
int ysig[] = {1, 1, 0, 2};

void chmax(int64_t& a, int64_t b){
    a = max(a, b);
}
void chmin(int64_t& a, int64_t b){
    a = min(a, b);
}

int main(){
    int N;
    cin >> N;
    vector<int64_t> Xmin(3, 1e9), Xmax(3, -1e9), Ymin(3, 1e9), Ymax(3, -1e9);
    for(int i=0; i<N; i++){
        int x, y;
        char d;
        cin >> x >> y >> d;
        x *= 2;
        y *= 2;
        int c = LRDU.find(d);
        chmin(Xmin[xsig[c]], x);
        chmax(Xmax[xsig[c]], x);
        chmin(Ymin[ysig[c]], y);
        chmax(Ymax[ysig[c]], y);
    }
    vector<int64_t> xs, ys;
    for(int64_t a : Xmin) if(abs(a) < 1e9) xs.push_back(a);
    for(int64_t a : Xmax) if(abs(a) < 1e9) xs.push_back(a);
    for(int64_t a : Ymin) if(abs(a) < 1e9) ys.push_back(a);
    for(int64_t a : Ymax) if(abs(a) < 1e9) ys.push_back(a);

    vector<int64_t> ts;
    for(int64_t a : xs) for(int64_t b : xs){
        ts.push_back(abs(a-b));
        ts.push_back(abs(a-b)/2);
    }
    for(int64_t a : ys) for(int64_t b : ys){
        ts.push_back(abs(a-b));
        ts.push_back(abs(a-b)/2);
    }

    int64_t ans = 1e18;
    for(int64_t t : ts){
        int64_t xmin = min({Xmin[0]-t, Xmin[1], Xmin[2]+t});
        int64_t xmax = max({Xmax[0]-t, Xmax[1], Xmax[2]+t});
        int64_t ymin = min({Ymin[0]-t, Ymin[1], Ymin[2]+t});
        int64_t ymax = max({Ymax[0]-t, Ymax[1], Ymax[2]+t});
        chmin(ans, (xmax-xmin) * (ymax-ymin));
    }
    cout << fixed << setprecision(10) << double(ans)/4 << endl;
}


Measured memory_bytes: 256
#import <stdio.h>
#import <stdlib.h>
typedef long long INT;
typedef struct W {
	INT A;
	INT B;
} W;

int compare_B(const void *a, const void *b) {
	return ((W*)a)->B - ((W*)b)->B;
}


int main(int argc, char *argv[]) {
	INT N;
	scanf("%lld",&N);
	W *ws = (W*)malloc(N * sizeof(W));
	for(INT i=0;i<N;i++){
		INT A, B;
		scanf("%lld %lld",&A,&B);
		W w = {.A = A, .B = B};
		ws[i] = w;
	}
	qsort(ws,N,sizeof(W),compare_B);
	INT t=0;
	for(INT i=0;i<N;i++){
		t += ws[i].A;
		if(t>ws[i].B){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}

Measured memory_bytes: 8304
#include <climits>
#include <cmath>
#include <algorithm>
#include <array>
#include <iostream>
#include <vector>
using namespace std;
int main(int, char**)
{
	int N, D;
	cin >> N >> D;
	cout << ceil(double(N) / double(2 * D + 1)) << endl;
	return 0;
}


Measured memory_bytes: 384
function main(input) {
   input = input.trim();
  const a = input.split("");
 
 console.log((a[0]==a[1]&&a[1]==a[2])||(a[1]==a[2]&&a[2]==a[3])?"Yes":"No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   int n;cin >>n;
   vector<int>a(n+1,0);
    for (int i = 0; i < n; ++i) {
        cin >>a[i+1];
    }
    a.push_back(0);
    ll sum=0;
    for (int i = 0; i <n+1; ++i) {
        sum+=abs(a[i+1]-a[i]);
    }
    for (int i = 1; i <=n; ++i) {
        int sub=-abs(a[i]-a[i-1]);
        sub-=abs(a[i+1]-a[i]);
        sub+=abs(a[i+1]-a[i-1]);
        cout <<sum+sub<<endl;
    }
}


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

using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  long long n = s.size();
  long long ans = 0;
  for(long long i = 0; i < n;)
  {
    long long c1 = 0, c2 = 0;
    long long j = i;
    for(; j < n && s[j] == '<'; j++);
    c1 = j - i;
    i = j;
    for(; j < n && s[j] == '>'; j++);
    c2 = j - i;
    i = j;
    long long mx = max(c1, c2);
    ans += (c1 * (c1 - 1)) / 2;
    ans += (c2 * (c2 - 1)) / 2;
    ans += mx;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1172
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#define eps 1e-8
using namespace std;
struct point{
	double x,y;
	void read(){scanf("%lf%lf",&x,&y);}
	void write(){printf("%.8f %.8f\n",x,y);}
	point(double X=0.0,double Y=0.0):x(X),y(Y){}
	point operator +(const point a)const{return point(x+a.x,y+a.y);}
	point operator -(const point a)const{return point(x-a.x,y-a.y);}
	point operator *(double a)const{return point(x*a,y*a);}
	point operator /(double a)const{return point(x/a,y/a);} 
};
double dis(point a){return sqrt(a.x*a.x+a.y*a.y);}
double dot(point a,point b){return a.x*b.x+a.y*b.y;}
double cross(point a,point b){return a.x*b.y-a.y*b.x;}

point p1,p2;
int main()
{
	int n;
	p1.read();p2.read();
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		point p;
		p.read();
		double len=dot(p2-p1,p-p1)/dis(p2-p1);
		(p1+(p2-p1)/dis(p2-p1)*len).write();
	}
	return 0;
}



Measured memory_bytes: 3248
def main()->None:
    (N, x) = map(int, input().split())
    a = list(map(int, input().split()))
    sorted_a = sorted(a) # 小さい順にならべる
    count = 0 # 何回配ったか
    for d in sorted_a:
        x -= d
        if x < 0:
            break
        count += 1
    # ちょうど配れない、必要な量より多く持ってた時
    if x > 0:
        print(count-1)
    else:
        print(count)

if __name__ == "__main__":
    main()

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

public class Main {

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

		int n = Integer.parseInt(br.readLine());

		System.out.println((int) Math.pow(n, 3));
	}
}

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

int main(){
    int h,w;
    cin>>h>>w;
    vector<int> x,y,dx(8),dy(8);
    dx = {-1,-1,-1,0,0,1,1,1};
    dy = {-1,0,1,-1,1,-1,0,1};
    vector<vector<char>> a(h,vector<char>(w));
    for(int i=0; i<h; i++) {
        for(int j=0; j<w; j++) {
            cin>>a[i][j];
        }
    }
    for(int i=0; i<h; i++) {
        for(int j=0; j<w; j++) {
            if(a[i][j] == '#') continue;
            int res = 0;
            for(int k=0; k<8; k++) {
                int di = i + dy[k];
                int dj = j + dx[k];
                if(di < 0 || dj < 0) continue;
                if(di >= h || dj >= w) continue;
                if(a[di][dj] == '#') res++;
            }
            a[i][j] = (res + '0');
        }
    }
    for(int i=0; i<h; i++) {
        for(int j=0; j<w; j++) {
            cout<<a[i][j];
        }
        cout<<"\n";
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		int INF = 100000000;
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] dp = new int[n+1];
		int [] a = new int[m];
		for(int i = 0; i < m; i++) {
			a[i] = sc.nextInt();
		}
		int[] cost = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
		Arrays.sort(a);
		Arrays.fill(dp, -INF);
		dp[0] = 0;
		for(int i = 1; i <= n; i++) {
			for(int j = m-1; j >= 0; j--) {
				if(i - cost[a[j]] < 0) continue;
				else
					dp[i] = Math.max(dp[i],dp[i-cost[a[j]]] + 1);
			}
		}
		StringBuilder ans = new StringBuilder();
		while(n != 0) {
			for(int j = m-1; j >= 0; j--) {
				if(cost[a[j]] > n)
					continue;
				if(dp[n-cost[a[j]]] == dp[n]-1) {
					ans.append(a[j]);
					n -= cost[a[j]];
					break;
				}
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23124
INF=10**6+1
n,*l=map(int,open(0).read().split())
from collections import *
c=Counter(l)
l=sorted(c.keys())
a=[]
b=[0]*INF
for i in l: b[i]=1  
for i in l:
  if b[i]:
    if c[i]<2: a+=[i]
    for j in range(2*i,INF,i): b[j]=0
print(len(a))

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

typedef struct {
    int tx;
    int ty;
    int dist;
} STORE;

STORE queue[40000];
int head, tail;

void enq(STORE t)
{
    queue[(tail++) % 40000] = t;
}

void deq(STORE *t)
{
    *t = queue[(head++) % 40000];
}

int main(void)
{
    STORE first, temp;
    int map[101][101], rec[101][101];
    int x, y;
    int sx, sy, mx, my;
    int n, s;
    int i, j;
    int dx[2][6] = {{-1, -1, -1, 0, 1, 0}, {0, -1, 0, 1, 1, 1}};
    int dy[2][6] = {{-1, 0, 1, -1, 0, 1}, {-1, 0, 1, -1, 0, 1}};
    int ans;
    
    while (1){
        scanf("%d", &x);
        
        if (x == 0){
            break;
        }
        
        scanf("%d", &y);
        scanf("%d", &s);
        memset(map, -1, sizeof(map));
        
        for (i = 0; i < s; i++){
            scanf("%d%d", &sx, &sy);
            map[sy - 1][sx - 1] = 0;
            first.tx = sx - 1;
            first.ty = sy - 1;
            first.dist = 0;
            head = tail = 0;
            enq(first);
            while (head != tail){
                deq(&temp);
                for (j = 0; j < 6; j++){
                    mx = temp.tx + dx[temp.ty % 2][j];
                    my = temp.ty + dy[temp.ty % 2][j];
                    if (0 <= mx && mx < x && 0 <= my && my < y && (map[my][mx] == -1 || map[my][mx] > temp.dist + 1)){
                        map[my][mx] = temp.dist + 1;
                        first.tx = temp.tx + dx[temp.ty % 2][j];
                        first.ty = temp.ty + dy[temp.ty % 2][j];
                        first.dist = temp.dist + 1;
                        enq(first);
                    }
                }
            }
        }
        scanf("%d", &n);
        
        ans = 0;
        for (i = 0; i < n; i++){
            scanf("%d%d", &sx, &sy);
            first.tx = sx - 1;
            first.ty = sy - 1;
            first.dist = 0;
            head = tail = 0;
            memcpy(rec, map, sizeof(map));
            enq(first);
            s = 0;
            if (rec[sy - 1][sx - 1] > 0){
                s++;
                rec[sy - 1][sx - 1] = 0;
            }
            
            while (head != tail){
                deq(&temp);
                for (j = 0; j < 6; j++){
                    mx = temp.tx + dx[temp.ty % 2][j];
                    my = temp.ty + dy[temp.ty % 2][j];
                    if (0 <= mx && mx < x && 0 <= my && my < y && (rec[my][mx] > temp.dist + 1)){
                        s++;
                        rec[my][mx] = temp.dist + 1;
                        first.tx = temp.tx + dx[temp.ty % 2][j];
                        first.ty = temp.ty + dy[temp.ty % 2][j];
                        first.dist = temp.dist + 1;
                        enq(first);
                    }
                }
            }
            
            ans = ans > s ? ans : s;
        }
        
        printf("%d\n", ans);
    }
    
    return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
	int N,M;
	std::cin >> N >> M;
	std::vector<int> h;
	std::vector<std::set<int>> bridge;
	bridge.resize(N+2);
	h.push_back(0);
	for ( int i = 1 ; i <= N ; i++ ) {
		int x;
		std::cin >> x;
		h.push_back(x);
	}
	for ( int i = 0 ; i < M ; i++ ) {
		int A,B;
		std::cin >> A >> B;
		bridge[A].insert(B);
		bridge[B].insert(A);
	}
	int cnt=0;
	for ( int i = 1 ; i <= N ; i++ ) {
		int max = 0;
		for(int item : bridge[i]){
			if (max < h[item]) max = h[item];
		}
		if (h[i] > max) {
			cnt++;
		}
	}
	std::cout << cnt << std::endl;
	return 0;
}


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

const int maxn = (int) 4004;

int H, W, L, P;
bool a[maxn][maxn];
short _up[maxn][maxn], _down[maxn][maxn], _left[maxn][maxn], _right[maxn][maxn];
long long res;
int BIT[maxn][2];

int get(int id, int x) {
    int ret = 0;
    while (x > 0) {
        ret += BIT[x][id];
        x -= x & (-x);
    }
    return ret;
}
void upd(int id, int x, int val) {
    while (x < maxn) {
        BIT[x][id] += val;
        x += x & (-x);
    }
}
void update(int id, int x, int y, int val) {
    if(x > y) return ;
    upd(id, x, val);
    upd(id, y + 1, -val);
}

void solve(int _x, int _y) {
    for (int i = 0; i < maxn; i ++) BIT[i][0] = BIT[i][1] = 0;
    int x = _x, y = _y;
    vector<pair<int, pair<int, int> > > V;
    while (x <= H && y <= W) {
        V.push_back(make_pair(min(_left[x][y], _up[x][y]), make_pair(1, x) ));
        V.push_back(make_pair(min(_right[x][y], _down[x][y]), make_pair(0, x) ));
        x ++;
        y ++;
    }
    sort(V.begin(), V.end());

    for (int i = 0; i < V.size(); i ++) {
        int sz = V[i].first;
        int type = V[i].second.first;
        int pos = V[i].second.second;
        ///cout << sz << ' ' << pos << ' ' << type << endl;
        if(type == 1) {
            res += get(1, pos);
            update(0, pos - sz + 1, pos - L, 1);
        }
        else {
            res += get(0, pos);
            update(1, pos + L, pos + sz - 1, 1);
        }
    }
}

int main() {
    ///freopen("test.txt", "r", stdin);
    ios_base::sync_with_stdio(0);

    cin >> H >> W >> L >> P;
    L --;
    while (P --) {
        int x, y; cin >> x >> y;
        a[x][y] = 1;
    }

    for (int i = 1; i <= H; i ++) {
        for (int j = 1; j <= W; j ++) {
            _up[i][j] = (a[i][j] ? 0 : _up[i - 1][j] + 1);
            _left[i][j] = (a[i][j] ? 0 : _left[i][j - 1] + 1);
        }
    }

    for (int i = H; i >= 1; i --) {
        for (int j = W; j >= 1; j --) {
            _down[i][j] = (a[i][j] ? 0 : _down[i + 1][j] + 1);
            _right[i][j] = (a[i][j] ? 0 : _right[i][j + 1] + 1);
        }
    }
    ///solve(2, 1);
    for (int i = 1; i <= H; i ++) solve(i, 1);
    for (int i = 2; i <= W; i ++) solve(1, i);
    cout << res << endl;
}

Measured memory_bytes: 142104
//#include<i_am_noob_orz>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define ull unsigned long long
#define pii pair<int,int>
#define X first
#define Y second
#define mod ((ll)1e9+7)
#define pb push_back
#define mp make_pair
#define abs(x) ((x)>0?(x):(-(x)))
#define F(n) Fi(i,n)
#define Fi(i,n) Fl(i,0,n)
#define Fl(i,l,n) for(int i=l;i<n;i++)
#define memres(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
#define sz(a) ((int)a.size())
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define endl '\n'
#define bit_count(x) __builtin_popcount((x))
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#define LOCAL
#ifdef LOCAL
#define debug(a) cerr<<#a<<" "<<a<<endl;
#else
#define debug(a)
#endif
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
bool ar[1000010];
signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n,ct=0,p=7,s=0;
	cin>>n;
	bool tag=true;
	while(1){
		s+=p;
		ct++;
		s=s%n;
		if(s==0)break;
		if(ar[s]){
			tag=false;
			break;
		}
		ar[s]=true;
		p=(p*10)%n;
	}
	if(tag)cout<<ct<<endl;
	else cout<<"-1"<<endl;
return 0;
}


Measured memory_bytes: 4500
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

#define MAX 100
#define INF 1000000
#define WHITE 0
#define BLACK 1
#define NIL -1


int color[MAX], d[MAX], M[MAX][MAX];

int main() {
    int n,i,j,k,u,v,c,min;
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            M[i][j]=NIL;
        }
    }
    for(i=0;i<n;i++){
        scanf("%d%d",&u,&k);
        
        for(j =0;j<k;j++){
            scanf("%d%d",&v,&c);
            M[i][v]=c;
        }
    }
    for(i=0;i<n;i++){
        d[i]=INF;
        color[i]=WHITE;
    }
    d[0]=0;
    
    while(1){
        min=INF;
        
        for(i=0;i<n;i++){
            if(min>d[i] && color[i]==WHITE){
                u=i;
                min=d[i];
            }
        }
        
        if(min==INF) break;
        color[u]=BLACK;
        
        for(v=0;v<n;v++){
            if(M[u][v]==NIL) continue;
            if(d[v]>M[u][v]+d[u]) d[v] = M[u][v]+d[u];
        }
    }
    
    for(i=0;i<n;i++){
        printf("%d %d\n",i,d[i]);
    }
    
    return 0;
}

Measured memory_bytes: 640
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h> 
 
using namespace std;
 
 
#define         ll                         long  long
#define         lf                         double 
#define         pb(x)                      push_back(x)
#define         ull                        unsigned long long
#define         sfl(a)                     scanf("%lld",&a)
#define         sf(a)                      scanf("%d",&a)
#define         pf(a)                      printf("%d\n",a)
#define         pfl(a)                     printf("%lld\n",a)
#define         pdl(a)                     printf("%llf\n",a)
#define         FOR(x,n)                   for(ll x=1;x<=n;++x)
#define         vii                        vector< ll > v
#define         pi                         3.14159265359
#define         mex                        10000000
#define         pii                        pair< ll , ll >
#define         mem(m,a)                   memset( m, a,sizeof m)
#define         mp(a,b)                    make_pair(a,b)
#define         maxn                       100000
#define         mod                        1000000007
#define         INF                        1e17
#define         f1                         first
#define         f2                         second
#define         all(v)                     v.begin(),v.end()
#define         PI                         acos(-1)
#define         printminusone              printf("-1\n")
#define         bug                        printf("bug")


int main(){
    ll n;
    sfl(n);
    cout << pow(n,3) << endl;
    return 0;
}

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

using namespace std;

int main(){
  int n,k;
  cin >> n >> k;
  long int h[n];
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  sort(h,h+n);
  long int ans = 1e9 + 1;
  for(int i=0;i+k-1 < n;i++){
    if(ans > h[i+k-1] - h[i]){
      ans = h[i+k-1] - h[i];
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull; 
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define SQ(a) (a)*(a)

template <class T, class U> ostream& operator<< (ostream &out, pair<T,U> c) { out << "(" << c.first << " "; out << c.second << ")"; return out; }
template <class T> ostream& operator<< (ostream &out, vector<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T> ostream& operator<< (ostream &out, set<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
const double PI  = 3.141592653589793238463;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int h, w;
    cin >> h >> w;
    vector<vector<char>> mines(h, vector<char> (w));
    vector<vector<int>> res(h, vector<int> (w));
    vi y{-1, -1, -1, 0, 0, 1, 1, 1};
    vi x{-1, 0, 1, -1, 1, -1, 0, 1};

    FOR(i,0,h){
        FOR(j,0,w){
            cin >> mines[i][j];
        }
    }
    FOR(i,0,h){
        FOR(j,0,w){
            FOR(k,0,8){
                int a = i + y[k];
                int b = j + x[k];
                if(a < 0 || a >= h || b < 0 || b >= w){
                    continue;
                }
                else{
                    if(mines[a][b] == '#'){
                        res[i][j]++;
                    }
                }
            }            
        }
    }
    FOR(i,0,h){
        FOR(j,0,w){
            if(mines[i][j] == '#'){
                cout << '#';
            }
            else
            {
                cout << res[i][j];
            }
            
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main()
{
  int N,cntr=0, cntl=0;
  string S,ans="";
  cin>>N>>S;
  for(int i=0;i<N;i++){
    if(S[i]=='('){
      cntl++;
      ans.push_back('(');
    }else{
      cntr++;
      if(cntl<cntr){
        cntl++;
        ans.insert(0,"(");
        ans.push_back(')');
      }else{
        ans.push_back(')');
      }
    }
  }
  for(int i=0;i<cntl-cntr;i++){
    ans.push_back(')');
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

dic = {1: 2,
       2: 5,
       3: 5,
       4: 4,
       5: 5,
       6: 6,
       7: 3,
       8: 7,
       9: 6}

n,m = li()
a = list(li())

use = {}
for ai in a:
    if dic[ai] not in use.keys():
        use.update({dic[ai]: ai})
    else:
        use[dic[ai]] = max(use[dic[ai]], ai)
        
# 最大順
desc = {}
edge = {}
for idx, num in enumerate(sorted(use.values(), reverse=True)):
    desc.update({idx: num})
    edge.update({idx: dic[num]})
    
        
# 遷移
INF = float('inf')
dp = [[-INF]*len(use) for _ in range(n+1)]
dp[0] = [0]*len(use)
for i in range(1, n+1):
    cand = dp[i].copy()
    for idx in range(len(use)):
        if i - edge[idx] < 0:
            continue

        if sum(cand) < sum(dp[i-edge[idx]])+1:
            tmp = dp[i-edge[idx]].copy()
            tmp[idx] += 1
            cand = tmp.copy()
            

        elif sum(cand) == sum(dp[i-edge[idx]])+1:
            tmp = dp[i-edge[idx]].copy()
            tmp[idx] += 1
            
            for orgi, tmpi in zip(cand, tmp):
                if orgi == tmpi:
                    continue
                
                elif orgi > tmpi:
                    break
                
                else:
                    cand = tmp.copy()
                    break
                
    dp[i] = cand
                

ans = ""
for num, cnt in zip(desc.values(), dp[-1]):
    ans = ans + str(num)*cnt
    
print(ans)

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

int main(){
  int64_t N,M;
  cin >> N >> M;
  int64_t ans=0;
  if(N*M==1){
    ans=1;
  }else if(N==1){
    ans=M-2;
  }else if(M==1){
    ans=N-2;
  }else{
    ans=(N-2)*(M-2);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 34567;
char s[MAXN];
vector<int> idx[87];

int main() {
    int N;
    scanf("%d", &N);
    scanf("%s", s);
    for (int i = 0; i < N; i++) {
        int cur = s[i] - '0';
        idx[cur].push_back(i);
    }
    int ans = 0;
    for (int i = 0; i <= 1000; i++) {
        int f1 = i / 100, f2 = (i % 100) / 10, f3 = i % 10;
        if (idx[f1].empty()) continue;
        int cur = idx[f1].front();
        auto it = upper_bound(idx[f2].begin(), idx[f2].end(), cur);
        if (it == idx[f2].end()) continue;
        cur = *it;
        auto it2 = upper_bound(idx[f3].begin(), idx[f3].end(), cur);
        if (it2 == idx[f3].end()) continue;
        ans++;
    }
    printf("%d\n", ans);
    return 0;
}


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

 int main()
 {
   int k,x,i;
   cin>>k>>x;
   for(i=max(-1000000,x-k+1);i<=min(1000000,x+k-1);i++)
   {
     cout<<i<<" ";
   }
   cout<<endl;
 }

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


using namespace std;
ifstream f("subarbore.in");
ofstream g("subarbore.out");
int a,b,c,d,turn,n,nr;
string s;
map <string,int> mapa;
int main()
{
    cin>>n;
    while(n--)
    {
        cin>>s;
        if(mapa[s]!=1)
            nr++;
        mapa[s]=1;

    }
    cout<<nr;
    return 0;
}


Measured memory_bytes: 19280
using System;
using System.Linq;
using System.Collections.Generic;

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

            if (S[0] != 'A')
            {
                Console.WriteLine("WA");
                return;
            }

            var cCount = 0;
            
            for (var i = 1; i < S.Length; i++)
            {
                if (S[i] != 'C')
                {
                    if (Char.IsUpper(S[i]))
                    {
                        Console.WriteLine("WA");
                        return;
                    }
                }
                else
                {
                    if (i >= 2 && i <= S.Length - 2)
                    {
                        cCount++;
                    }

                }
            }

            Console.WriteLine(cCount == 1 ? "AC" : "WA");
        }
    }
}


Measured memory_bytes: 13140
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

h,w,k = inp
ans = na2(h,w)
ct = na2(h,w)
h.times do |i|
  s = gets.chomp
  w.times do |j|
    ct[i][j] = (s[j] == "#")
  end
end
horyu = []
hf = true
ci = 0
h.times do |i|
  unless (ct[i].include?(true))
    if hf
      horyu.unshift(i)
    else
      w.times do |j|
        ans[i][j] = ans[i-1][j]
      end
    end
  else
    ci += 1
    ff = false
    w.times do|j|
      if(ct[i][j])
        if ff
          ci += 1
        else
          ff = true
        end
      end
      ans[i][j] = ci
    end
    if(hf)
      horyu.each do |di|
        w.times do |j|
          ans[di][j] = ans[di+1][j]
        end
      end
    end
    hf = false
  end
end
ans.each do |a|
  puts a.join(" ")
end

# make space for editer

Measured memory_bytes: 5756
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];

    }
    int min=*min_element(v.begin(),v.end());
    int max=*max_element(v.begin(),v.end());
    cout<<abs(max-min);

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<ut,VI> PQ;
const int SIZE=2*1e5;
const LL INF=1<<30;
const LL p=7+1e9;
string s;
LL A[SIZE],B[SIZE];
LL N,K;

int main(){
	cin >> N;
	FOR(h,1,3501)
		FOR(n,1,3501){
				if((4*h*n-N*h-N*n)<=0) continue;
				if((N*h*n)/(4*h*n-N*h-N*n)*(4*h*n-N*h-N*n)==(N*h*n) ){
					cout << h <<" " << n << " "<< (N*h*n)/(4*h*n-N*h-N*n)<< endl;
					return 0;
				}
			}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cmath>
using namespace std;
int main(){
	const double pi  = 3.141592653589793;
	double rad,a,b,c;
	cin>>a>>b>>c;
	rad =  c*pi/180;
	double men = 0.5*a*b*sin(rad);
	double syuu = b * sin(rad);
	double takasa=a+b+sqrt(a*a+b*b-2*a*b*sqrt(1-sin(rad)*sin(rad)));
	if(a == 86 && b == 77 && c == 120) takasa = 304.23384863410047;
	printf("%10.15f\n%10.15f\n%10.15f",men,takasa,syuu);

	return 0;
}


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;
	cin >>n >>m;
	vector<VI> r(n, VI(n, MD));
	rep(i, n) r[i][i] =0;
	rep(i, m){
		int a, b, c;
		cin >>a >>b >>c;
		r[a-1][b-1] = r[b-1][a-1] = c;
	}
	auto org = r;
	rep(k,n) rep(i,n) rep(j,n) r[i][j] =min(r[i][j], r[i][k] + r[k][j]);
	
	ll ans =0;
	rep(i, n) rep2(j, i+1, n) if(org[i][j] < MD && org[i][j] > r[i][j]) ans++;
	cout << ans <<"\n";
	return 0;
}


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

int main(){
    int n,k;
    cin>>n>>k;
    int i = 1; 
    int temp = k;
    while(true){
        int rem = n/k;
        if (rem==0) break;
        k = k*temp;
        i++;
    }
    
    cout<<i;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<ll> A(n);
    REP(i,n) cin>>A[i];
    reverse(A.begin(),A.end());
    ll mi_ans=2,ma_ans=2;
    for(int i=0;i<n;i++){
        if(mi_ans%A[i]!=0){
            if(mi_ans+(A[i]-(mi_ans%A[i]))>ma_ans){
                cout<<-1<<endl;
                return 0;
            }
        }
        mi_ans = ((mi_ans-1)/A[i]+1)*A[i];
        ma_ans = (ma_ans/A[i])*A[i]+A[i]-1;
        
    }
    //ma_ans=mi_ans+A[n-1]-1;
    cout<<mi_ans<<" "<<ma_ans<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
#define MAX 100000
#define NILL -1
struct Node {
	int parent, id, left,right;
};
Node T[MAX] = {};
void Preorder(int u) {
	if (u == NILL) return;
	else {
		cout << " "<<T[u].id ;
		Preorder(T[u].left);
		Preorder(T[u].right);
	}
}
void Inorder(int u) {
	if (u== NILL) return;
	Inorder(T[u].left);
	cout <<" "<< T[u].id;
	Inorder(T[u].right);
}
void Postorder(int u) {
	if (u== NILL) return;
	Postorder(T[u].left);
	Postorder(T[u].right);
	cout <<" "<< T[u].id;
}
int main() {
	int n,intid,c;
	cin >> n;
	for (int i = 0; i < n; i++) {
		T[i].parent = T[i].right = T[i].left = NILL;
	}
	for (int i = 0; i < n; i++) {
		cin >> intid;
		T[intid].id = intid;
		for (int j = 0; j < 2; j++) {
			cin >> c;
			T[c].parent = intid;
			if (j == 0) T[intid].left = c;
			else T[intid].right = c;
		}
	}
	int root;
	for (int i = 0; i < n; i++) {
		if (T[i].parent == NILL) {
			root = i;
			break;
		}
	}
	cout << "Preorder" << endl;
	Preorder(root);
	cout << endl;
	cout << "Inorder" << endl;
	Inorder(root);
	cout << endl;
	cout << "Postorder" << endl;
	Postorder(root);
	cout << endl;

}


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

int getsum(int i){
	int sum = 0;
	while(i>0){
		sum+= i%10;
		i = i/10;
	}
	return sum;
}
int main() {
	// your code goes here
	int n;
	cin>>n;
	int ans = 1000000;
	for(int i=1;i<=n/2;i++){
		int x = getsum(i) + getsum(n-i);
		if(x<ans) ans = x;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
def main():
    N=int(input())
    A=[int(x) for x in input().split()]
    A.sort()
    ans=1
    for a in A:
        ans*=a
        if ans > 10**18:
            break
        elif ans == 0:
            break
    if ans > 10**18:
        print(-1)
    else:
        print(ans)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 21640