akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int A[5];
	int an = 0;
	int max = 0;
	for (int i = 0; i < 5; i++) {
		cin >> A[i];
		if (A[i] % 10 == 0) an += A[i];
		else {
			an += A[i] + (10 - A[i] % 10);
			if ((10 - A[i] % 10) > max) {
				max = 10 - A[i] % 10;
			}
		}
	}
	an -= max;
	cout << an << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int n;
  scanf("%d",&n);
  int ans[10010] = {0};


  for(int i = 1;i <= 100;i ++){
    for(int j = 1;j <= 100; j ++){
      for(int k = 1;k <= 100;k ++){
        if(i*i + j*j + k*k + i*j + j*k + k*i <= 10000)
        ans[i*i + j*j + k*k + i*j + j*k + k*i] ++;
      }
    }
  }

  for(int i = 1;i <= n;i ++){
    printf("%d\n",ans[i]);
  }

  return 0; 

}

Measured memory_bytes: 1724
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}

ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};


ll bit[1<<18];
void bit_add(ll i, ll x){
  int cnt = 0;
  while(i <= (ll)(1<<18)){
    bit[i] += x;
    i += i & -i;
  }
}

ll bit_sum(ll x){
  ll res = 0;
  while(x > 0){
    res += bit[x];
    x -= x & -x;
  }
  return res;
}

ll Tnt(vector<ll> S){
  ll res = 0;
  for(int i = 0; i < S.size(); i++){
    res += i - bit_sum(S[i]);
    bit_add(S[i], 1);
  }
  return res;
}

void compress(vector<ll> &S){
  vector<ll> xs;
  rep(i, S.size()) xs.push_back(S[i]);
  sort(xs.begin(), xs.end());
  xs.erase(unique(xs.begin(), xs.end()), xs.end());
  rep(i, S.size()){
    S[i] = lower_bound(xs.begin(), xs.end(), S[i]) - xs.begin() + 1;
  }
}

ll N, K;
vector<ll> A(200010);
vector<ll> S(200010);
int main(){
  cin >> N >> K;
  A.resize(N);
  S.resize(N+1);
  rep(i, N){
    cin >> A[i]; A[i] -= K;
  }
  rep(i, N) S[i+1] = S[i] + A[i];
  compress(S);
  cout << (N+1) * N / 2 - Tnt(S) << endl;
}


Measured memory_bytes: 6484
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<pair<int,int>> vec(n);
  rep(i,0,n) {
    int a;
    cin>>a;
    vec[i]=make_pair(a,i);
  }
  
  
  sort(all(vec ));
  int cnt=0;
  rep(i,0,n) {
    if(vec[i].second%2!=i%2) cnt++;
  }
  
  cout<<cnt/2<<endl;

}

Measured memory_bytes: 1024
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    A, B, C = map(int, readline().split())

    x = A - B

    print(max(0, C - x))


if __name__ == '__main__':
    main()


Measured memory_bytes: 61668
#include<bits/stdc++.h>
#define pb push_back
#define ef(i,u) for(int i=b[u];i;i=nxt[i])
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,b,a) for(int i=b;i>=a;--i)
#define gcd(a,b) __gcd(a,b)
#define MEM(a,x) memset(a,x,sizeof(a))
#define VI vector<int>
#define PII pair<int,int>
#define ull unsigned long long
#define ll long long
#define fi first
#define se second
#define INF 0x3f3f3f3f
using namespace std;
const int N=2e5+5;
template<class T>inline void read(T &res)
{
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
string s,t;
int main(){
    cin>>s>>t;
    int ok=1;
    rep(i,0,s.length()-1){
        if(s[i]!=t[i])ok=0;
    }
    if(ok)puts("Yes");
    else puts("No");
	return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>


int main()
{
    int q,ope;
    long long num,L,R;
    std::cin>>q;
    std::set<long long> S;
    
    for(int i = 0; i < q; i++)
    {
        std::cin>>ope;
        if(ope==1){std::cin>>num; std::cout<<S.count(num)<<std::endl;}
        else if(ope==0){std::cin>>num; S.insert(num); std::cout<<S.size()<<std::endl;}
        else if(ope==2){std::cin>>num; S.erase(num);}
        else{
            std::cin>>L>>R;
            auto a = S.lower_bound(L);
            auto b = S.upper_bound(R);
            for(auto it = a; it!=b; it++){std::cout<<*it<<std::endl;}
        }
    } 
    return 0;
}



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

int main (void){

    int N,o[2]={},T=0,i,j;
    cin >> N;
    int t[N],w[N][2];
    for(i = 0; i < N; i++){
        cin >> t[i];
        for(j = 0; j < 2; j++){
            cin >> w[i][j];
        }
    }
    for(i = 0; i < N; i++){
        if(( t[i] - T ) >= w[i][0] + w[i][1]){
            if((( t[i] - T ) - ( w[i][0] + w[i][1]))%2==0){
                continue;
            }else{
                cout << "No" << endl;
                return 0;
            }
        } else{
            cout << "No" << endl;
            return 0;
        }
        T = t[i];
    }

        cout << "Yes" << endl;

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> W(N);
  for (int i = 0; i < N; i++)
    cin >> W.at(i);
  bool right = true;
  // 単語の重複がないか確認する
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < i; j++) {
      if (W.at(i) == W.at(j))
        right = false;
    }
  }
  // しりをとれているか確認する
  for (int i = 0; i < N-1; i++) {
    if (W.at(i).at(W.at(i).size()-1) != W.at(i+1).at(0))
      right = false;
  }
  if (right == true)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
// 'By Anki'
 
#include<bits/stdc++.h>
// #include<iostream>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define wr(i) cout<<#i<<" = "<<i<<",  ";
#define wre(i) cout<<#i<<"  =  "<<i<<endl;
#define all(v) v.begin(),v.end()
typedef long long ll;
#define lim 1000000007LL
typedef unsigned long long ull;
#define M 10004
using u64= uint64_t;

ll mod(ll n){
  if(n<0)return n+lim;
  else return n%lim;
}


int main()
{
fast
ll t=1LL;
// cin>>t;
while(t--)
{
  ll n;
  cin>>n;
  ll x,y;
  ll ans=0LL;
  for(int i=1;i<=n;i++)ans+=i*(n-i+1);
  // for(int i=1;i<=n;i++)ans+=((i)*(i+1))/2;
  // wr(ans)
  for(int i=1;i<n;i++){
    cin>>x>>y;
    ans-=(n-max(x,y)+1)*min(x,y);
  }
  cout<<ans<<"\n";

}
} 

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
import numpy as np


def main():
    n = int(input())
    a = np.array(input().split(), dtype='int')
    b = np.array(input().split(), dtype='int')
    c = np.array(input().split(), dtype='int')

    ans = 0

    for i in range(n):
        ans += b[a[i] - 1]
        if i != n - 1:
            if a[i + 1] - a[i] == 1:
                ans += c[a[i] - 1]

    print(ans)


main()

Measured memory_bytes: 21404
/*
https://drken1215.hatenablog.com/entry/2020/03/03/071000
勉強させていただいた記事
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    int N,Q;
    string S;
    cin>>N>>S>>Q;
    vector<set<int>> pls(26,set<int>({INF}));
    rep(i,N)pls[S[i]-'a'].insert(i);
    rep(i,Q){
        int t;
        cin>>t;
        if(t==1){
            int i;
            char c;
            cin>>i>>c;
            i--;
            //文字列Sの更新処理
            auto p=S[i];
            S[i]=c;
            //変更前の文字から、その位置のフラグを消し、代わりに変更後の文字の位置にフラグをつける
            pls[p-'a'].erase(i);
            pls[c-'a'].insert(i);
        }else{
            int l,r;
            cin>>l>>r;
            //[l,r)のため、lだけデクリメント
            l--;
            int res=0;
            rep(c,26){
                if(pls[c].empty())continue;
                int lid=*pls[c].lower_bound(l);
                int rid=*pls[c].lower_bound(r);
                //[l,r)の範囲にあるならば、lidはridよりも小さくなるはず
                //ridはrではダメなんだろうか
                if(r>lid)++res;
            }
            cout<<res<<endl;
        }
    }

    return 0;
}

//a=97,z=122

Measured memory_bytes: 24196
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int a, b, k;
    cin >> a >> b >> k;
    for (int i = a; i <= b && i < a + k; i++) cout << i << endl;
    for (int i = max(a + k, b - k + 1); i <= b; i++) cout << i << endl;
    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "vector"
using namespace std;

int main() {
    int n;
    cin >> n;
    int mod = n % 1000, ans;
    if (mod) {
        ans = 1000 * ((n / 1000) + 1) - n;
    } else {
        ans = 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3160
#include <iostream>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

using namespace std;

signed main() {
  IOS;
  int A,B, ans;
  cin >> A >> B;
  if (A == B) ans = A*2;
  else ans = max(A,B)*2-1;
  cout << ans << endl;
  return 0;
}


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

int main() {
     int N; string S;
    cin >> N >> S;
    long  long r = 0 ,g = 0 ,b = 0 ;
     for ( auto c :S){
         if (c == 'R' )++r;
         else  if (c == 'G' )++g;
         else ++b;
    }
    long  long all = r * g * b;
     long  long sub = 0 ;
     for ( int i = 0 ;i <N;++i) {
         for ( int j = i+ 1 ;j <N;++j) {
             if (S[i] == S[j]) continue ;
             int k = j* 2 -i;
             if (k >= N || S[k] == S[i] || S[k] == S [j]) continue ;
            ++sub;
        }
    }
    cout << all-sub << endl;
}


Measured memory_bytes: 3640
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  var a=[];
  [0,1,2].forEach(e=>{
    a=a.concat(input[e].split(' '));
  });
  var array=input.concat([]);
  array.shift();
  array.shift();
  array.shift();
  array.shift();
  var temp;
  var flg=true;
  [0,1,2].forEach(e=>{
    temp=true;
    [0,1,2].forEach(f=>{
      temp=temp&&array.includes(a[e*3+f]);
    });
    if(temp){
      if(flg){
        console.log('Yes');
        flg=false;
      }
    }
    temp=true;
    [0,1,2].forEach(f=>{
      temp=temp&&array.includes(a[e+f*3]);
    });
    if(temp){
      if(flg){
        console.log('Yes');
        flg=false;
      }
    }
  });
  temp=true;
  [0,1,2].forEach(e=>{
    temp=temp&&array.includes(a[e*4]);
  });
  if(temp){
      if(flg){
        console.log('Yes');
        flg=false;
      }
  }
  temp=true;
  [0,1,2].forEach(e=>{
    temp=temp&&array.includes(a[2+e*2]);
  });
  if(temp){
    if(flg){
        console.log('Yes');
        flg=false;
      }
  }
  if(flg){
        console.log('No');
        flg=false;
      }
}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  



  


Measured memory_bytes: 29556
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 10;
int a[N][N];

int sqr(int x) {
  return x * x;
}

int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      scanf("%d", &a[i][j]);
    }
  }
  int ret = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int sum = 0;
      for (int k = 0; k < m; ++k) {
        sum += sqr(a[i][k] - a[j][k]);
      }
      int x = (int)(sqrt((double)sum) + 1e-10);
      if (x * x == sum) ++ret;
      ++x;
      if (x * x == sum) ++ret;
    }
  }
  printf("%d\n", ret);
  return 0;
}


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

int main( void ) {
	int n;

	scanf( "%d", &n );
	while ( n-- ) {
		int base = 0, out = 0, score = 0;

		while ( out != 3 ) {
			char event[ 8 ];

			scanf( "%s", event );
			switch ( event[ 1 ] ) {
			case 'I':
				base++;
				if ( base == 4 ) {
					score++;
					base--;
				}
				break;
			case 'U':
				out++;
				break;
			case 'O':
				score += base + 1;
				base = 0;
				break;
			}
		}

		printf( "%d\n", score );
	}

	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

bool fc(int n){
  int chk = n % 10;
  n /= 10;
  while(n != 0){
    if((n%10) != chk) return false;
    n /= 10;
  }
  return true;
}

int main(){
  int n;
  cin >> n;
  while(1){
    if(fc(n) == true){
      cout << n << endl;
      return 0;
    }
    n++;
  }
  return 0;
}

Measured memory_bytes: 3604
import sys
sys.setrecursionlimit(10**7)

N = int(input())
AB = [list(map(int,input().split())) for _ in [0]*(N-1)]

mod = 10**9+7

m = 10**5*2 +10 
fac = [1]*m
ninv = [1]*m
finv = [1]*m
for i in range(2,m):
    fac[i] = fac[i-1]*i%mod
    ninv[i] = (-(mod//i)*ninv[mod%i])%mod
    finv[i] = finv[i-1]*ninv[i]%mod

E = [[] for _ in [0]*N]
Ef = [[] for _ in [0]*N]
Eb = [[] for _ in [0]*N]
for a,b in AB:
    a-=1
    b-=1
    E[a].append(b)
    E[b].append(a)
done = [False]*N
done[0] = True
q = [0]
while q:
    j = q.pop()
    for k in E[j]:
        if done[k]: continue
        done[k] = True
        q.append(k)
        Ef[j].append(k)
        Eb[k].append(j)
Vf = [None]*N
Mf = [None]*N
def getf(i):
    if Mf[i]!=None:
        return Mf[i]
    Mc = [getf(j) for j in Ef[i]]
    Vc = [Vf[j] for j in Ef[i]]
    Vf[i] = 1 + sum(Vc)
    Mf[i] = fac[Vf[i]-1]
    for mc,vc in zip(Mc,Vc):
        Mf[i] *= (mc*finv[vc])%mod
        Mf[i] %= mod
    return Mf[i]

def getp(i):
    if i==0: return 0
    p = Eb[i][0]
    vp = Vf[p]
    vi = Vf[i]
    ret = ans[p]
    ret *= (((fac[vi]*fac[N-1-vi])%mod)*finv[N-1])%mod
    ret %= mod
    ret *= pow(Mf[i],mod-2,mod)
    ret %= mod
    return ret

ans = [0]*N
ans[0] = getf(0)
q = Ef[0][:]

while q:
    i = q.pop()
    V = [N - Vf[i]]
    M = [getp(i)]
    for j in Ef[i]:
        q.append(j)
        V.append(Vf[j])
        M.append(Mf[j])
    tmp = fac[N-1]
    for mc,vc in zip(M,V):
        tmp *= (mc*finv[vc])%mod
        tmp %= mod
    ans[i] = tmp

for out in ans:
    print(out)

Measured memory_bytes: 212484
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

/*
func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	str := strconv.Itoa(n)
	arr := strings.Split(str, "")
	for i := 0; i < len(arr); i++ {
		if arr[i] == "7" {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}
*/

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	str := strconv.Itoa(n)
	if strings.Index(str, "7") != -1 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

int main() {

	ll t,z, n;
	string s;
	cin >> s;

	n = s.size();

	z = 0;


	for (auto x : s) {
		z += (x - '0');
		z %= 9;
	}

	if (z % 9 == 0)	
	cout<<"Yes"<<endl;
	else 
	cout<<"No"<<endl;
}

Measured memory_bytes: 3732
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;

typedef complex<double> P;

struct L : public vector<P>{//??´???
  L(const P &a, const P &b){
    push_back(a);push_back(b);
  }
};

struct C{//???
  P c; double r;
  C(const P &c,double r): c(c),r(r){}
};

namespace std{//??????????????????
  bool operator < (const P& a,const P& b){
    return real(a)!= real(b) ? real(a) < real(b) : imag(a) < imag(b);
    //return imag(a) != imag(b) ? imag(a) < imag(b) : real(a) < real(b)
  }
  bool operator == (const P& a,const P& b){
    return a.real()==b.real()&&a.imag()==b.imag();
  }
}

double dot(P a,P b){
  return real(conj(a)*b);
}

double cross(P a,P b){
  return imag(conj(a)*b);
}

int ccw(P a, P b, P c){
  b-=a;c-=a;
  if(cross(b,c)>0)   return +1;// counter clockwise 
  if(cross(b,c)<0)   return -1;// clockwise 
  if(dot(b,c)<0)     return +2;// c-a-b on line
  if(norm(b)<norm(c))return -2;// a-b-c on line
  return 0;                    // a-c-b on lone
}

int main()
{
  int i;
  int q;

  cin>>q;

  rep(i,q){
    double xp,yp;

    cin>>xp>>yp;  P p1(xp,yp);
    cin>>xp>>yp;  P p2(xp,yp);
    cin>>xp>>yp;  P p3(xp,yp);
    cin>>xp>>yp;  P p4(xp,yp);

    P s1(p2-p1);
    P s2(p4-p3);

    if(s1.real()*s2.imag()==s1.imag()*s2.real())
      cout<<"2"<<endl;
    else if(dot(s1,s2)==0)
      cout<<"1"<<endl;
    else
      cout<<"0"<<endl;

  }

}

Measured memory_bytes: 3176
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/input.txt"
exit $?
'''
import sys

def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    a, b, n = _ia()
    return (a * min(b-1, n))//b

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


Measured memory_bytes: 61716
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

#include <random>
std::random_device seed_gen;
std::mt19937_64 engine(seed_gen());
// ull a = engine();
ll D;
vll now, c(26);
vvl s;
vector<set<ll>> st(26);
ll now_score = 0;

void init(ll d){
  D = d;
  now.resize(d, 0);
  s = VV(d, 26, 0, ll);
}
void make_set(vll t){
  for(int i=0;i<D;i++) st[t[i]].insert(i);
  for(int i=0;i<26;i++) st[i].insert(-1);
  for(int i=0;i<26;i++) st[i].insert(D);
}
ll calc(vll t){
  ll score = 0;
  vll cnt(26, 0);
  for(int i=0;i<D;i++){
    ll idx = t[i];
    for(int j=0;j<26;j++){
      if(j==idx) cnt[j] = 0;
      else{
        cnt[j]++;
        score -= cnt[j]*c[j];
      }
    }
    score += s[i][idx];
  }
  return score;
}

ll ch_score(ll day, ll after){
  ll score = now_score;
  ll prev = now[day];//前に選択していたもの
  if(prev==after) return score;

  //prevを消したことで減るスコア
  score -= s[day][prev];

  auto itr = st[prev].find(day);
  auto p = itr, q = itr;
  ll x = day - (*--p) - 1;
  ll y = (*++q) - day - 1;

  ll z = x + y + 1;
  //x, y分増え、z分減る
  score += c[prev]*((x*(x+1))/2 + (y*(y+1))/2);
  score -= c[prev]*((z*(z+1))/2);
  //afterを挿入した事で増えるスコア
  score += s[day][after];
  itr = st[after].upper_bound(day);
  p = itr;
  p--;

  z = (*itr) - (*p) - 1;
  x = day - (*p) - 1;
  y = (*itr) - day - 1;

  score += c[after]*(z*(z+1)/2);
  score -= c[after]*((x*(x+1))/2 + (y*(y+1))/2);
  return score;
}

void change(ll day, ll after){
  ll prev = now[day];
  st[prev].erase(day);
  st[after].insert(day);
  now[day] = after;
  now_score = ch_score(day, after);
}

int main(int argc, char const *argv[]) {
  ll d;scanf("%lld", &d);
  init(d);
  re(i, 26) scanf("%lld", &c[i]);
  re(i, D) re(j, 26) scanf("%lld", &s[i][j]);
  //初期値
  re(i, D) now[i] = i%26;
  //初期化
  make_set(now);
  now_score = calc(now);
  //関数:
  // change(day, after) dayをafterに変更
  // ch_score(day, after) dayをafterに変更した場合の試算
  // 共に計算量10~20くらい
  // シミュレート回数10^7
  ll sim = 18000000;
  ll prm = 2;
  ll noc = 0;//更新できていない回数
  ll prev_day = -1;
  while(--sim){
    unsigned long long a = engine(); //更新点から+-prm日に限る
    unsigned long long b = engine();//after
    //unsigned long long C = engine();//

    if(prev_day==-1){
      a %= D, b %= 26;
    }else{
      ll x = min(prm, prev_day);//sita
      ll y = min(prm, D-1-prev_day);//ue
      a %= (x+y+1), b %= 26;
      a -= x;
      a = prev_day + a;
    }
    //std::cout << a << " " << b << '\n';
    if(now_score < ch_score(a, b)){
      change(a, b);
      prev_day = a;
    }else{
      noc++;
      if(noc==20){
        noc=0; prev_day = -1;
      }
    }
  }
  for(int i=0;i<D;i++) std::cout << now[i]+1 << '\n';
  return 0;
}


Measured memory_bytes: 3384
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

long foo (long arg) {
  long result = 0;
  while (arg) {
    result += arg % 10;
    arg /= 10;
  }
  return result;
}

void solve() {
  long N;
  cin >> N;

  long result = 999999999999;

  for (long a = 1; a < N; a++) {
    long b = N - a;
    result = min(result, foo(a) + foo(b));
  }

  cout << result << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

typedef long long ll;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define In(i) cin >> i;

int main(){
    double T,X;
    cin >> T >> X;

    cout << setprecision(10) << T / X << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <iomanip>

using namespace std;
typedef long long ll;

//定義場所//
int i, j, k, l, m, n;
double W, N, K;
////////////

int main()
{
	cin >> N >> K;
	double ans = 0;
	for (i = 1; i <= N; i++) {
		double A = 1 / N;
		int score = i;
		while (score < K) {
			score *= 2;
			double b = 2.000000000;
			A = A / b;
		}
		ans += A;
	}
	cout << setprecision(12) <<ans;
}

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

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int n,m,cnt;
int pw[15],ch[800000][3],tag[800000],fl[800000],ans[800000];
char s[200005];

void insert(int x,int t){
	int p=0;
	for(int i=0;i<n;i++){
		if(!ch[p][x%3]) ch[p][x%3]=++cnt;
		p=ch[p][x%3];
		x/=3;
	}
	fl[p]=t;
}

void add(){
	int p=0;
	for(int i=0;i<n;i++){
		if(tag[p]){
			swap(ch[p][1],ch[p][2]);
			for(int i=0;i<3;i++) tag[ch[p][i]]^=1;
			tag[p]=0;
		}
		swap(ch[p][0],ch[p][1]);
		swap(ch[p][0],ch[p][2]);
		p=ch[p][0];
	}
}

void getans(int id,int num,int dep){
	if(fl[id]) return (void)(ans[fl[id]-1]=num);
	if(tag[id]){
		swap(ch[id][1],ch[id][2]);
		for(int i=0;i<3;i++) tag[ch[id][i]]^=1;
		tag[id]=0;
	}
	getans(ch[id][0],num,dep+1);
	getans(ch[id][1],num+pw[dep],dep+1);
	getans(ch[id][2],num+2*pw[dep],dep+1);
}

int main(){
	n=readint();
	pw[0]=1;
	for(int i=1;i<=n;i++) pw[i]=pw[i-1]*3;
	for(int i=0;i<pw[n];i++) insert(i,i+1);
	scanf("%s",s+1); m=strlen(s+1);
	for(int i=1;i<=m;i++){
		if(s[i]=='S') tag[0]^=1;
		else add();
	}
	getans(0,0,0);
	for(int i=0;i<pw[n];i++) printf("%d ",ans[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 17664
from sys import stdin

def main():
    N, Q = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in [0] * (N - 1)]
    PX = [tuple(map(int, input().split())) for _ in [0] * Q]

    AB.sort()
    point = [0] * (N + 1)
    for p, x in PX:
        point[p] += x

    for a, b in AB:
        point[b] += point[a]

    print(*point[1:])

input = lambda: stdin.readline()
main()


Measured memory_bytes: 71668
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
const int MAX=1e5+9;
const int inf=INT_MAX;
vector<pair<int, int> >adj[MAX];
void dijikstra(int s, int d[]){
	multiset<pair<int,int> >q;
	d[s]=0;
	q.insert(make_pair(d[s],s));
	while(!q.empty()){
		pair<int, int>p=*q.begin();
		int u=p.second;
		q.erase(q.begin());
		for(int i=0;i<adj[u].size();i++){
			if(d[adj[u][i].first]>d[u]+adj[u][i].second){
				d[adj[u][i].first]=d[u]+adj[u][i].second;
				q.insert(make_pair(d[adj[u][i].first],adj[u][i].first));
			}
		}

	}
}
int main(){
	int d[MAX],d1[MAX],d2[MAX],i,n,m;
	cin>>n;
	for(int i=0;i<n-1;i++){
		int x,y,w;
		cin>>x>>y>>w;
		adj[x].push_back(make_pair(y,w));
		adj[y].push_back(make_pair(x,w));
	}
	for(int i=0;i<n;i++){
		d[i]=inf;
		d1[i]=inf;
		d2[i]=inf;
	}
	dijikstra(0,d);
	int l1,l2,mx=INT_MIN;
	for(int i=0;i<n;i++){
		if(mx<d[i]){
			l1=i;
			mx=d[i];
		}
	}
	dijikstra(l1,d1);
	mx=INT_MIN;
	for(int i=0;i<n;i++){
		if(mx<d1[i]){
			mx=d1[i];
			l2=i;
		}
	}
	dijikstra(l2,d2);
	for(int i=0;i<n;i++){
		cout<<max(d1[i],d2[i])<<"\n";
	}

}


Measured memory_bytes: 6360
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define ll long long
const ll INF = 1<<29;
vector<ll> enum_divisors(ll N) {
    vector<long long> res;
    for (ll i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            res.push_back(N/i);
        }
    }
    //res.push_back(N);
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

int main() {
    ll n;
    cin >> n;
    const auto &res = enum_divisors(n);
    ll Size = res.size();
    ll x,y;
    x = res[Size/2-1]; y = res[Size/2];
    //for (int i = 0; i < res.size(); ++i) cout << res[i] << " ";
    cout << x+y-2 << endl;
    return 0;
}

Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

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

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return float64(i)
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

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

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

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

const Mod = 1000000007

func ModComb(n, k int) int {
	if k == 0 {
		return 1
	}
	x, y := n, k
	for i := 1; i < k; i++ {
		x = x * (n - i) % Mod
		y = y * (k - i) % Mod
	}
	inv := ModInv(y)
	return x * inv % Mod
}

func ModFact(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		fact = fact * i % Mod
	}
	return fact
}

func ModInv(x int) int {
	return ModPow(x, Mod-2)
}

func ModPow(a, n int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % Mod
		}
		a = a * a % Mod
		n /= 2
	}
	return res
}

func pow(a, n int) int {
	if n == 0 {
		return 1
	}

	ans := 0
	if n%2 == 0 {
		ans = pow(a*a, n/2)
	} else {
		ans = a * pow(a*a, (n-1)/2)
	}
	return ans
}

func main() {
	sc.Split(bufio.ScanWords)

	n := readInt()

	h := make([]int, n)
	for i := 0; i < n; i++ {
		h[i] = readInt()
	}

	for i := n - 1; i > 0; i-- {
		if h[i]-h[i-1] >= 0 {
			continue
		}
		if h[i]-h[i-1] == -1 {
			h[i-1]--
		}
		if h[i]-h[i-1] < 0 {
			fmt.Println("No")
			return
		}

	}
	fmt.Println("Yes")
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
   ios::sync_with_stdio(0);
   cin.tie(0);
   string s ,s1;
   cin>>s>>s1;
   int c = 0;
   for (int i = 0; i < s.length(); i++)
   {
      if(s[i]!=s1[i]){
          c++;
      }
   }
   cout<<c<<"\n";
}

Measured memory_bytes: 3808
S = input()
K = int(input())
ans_s2, ans_s3 = 0, 0

# 例外処理
if len(S) == 1:
    print(K // 2)
    exit()
elif len(set(S)) == 1:
    print(len(S) * K // 2)
    exit()

S_double = S + S
for i in range(1, len(S_double)):
    if S_double[i] == S_double[i - 1]:
        S_double = S_double[: i] + "?" + S_double[i + 1:]
        ans_s2 += 1

S_triple = S + S + S
for j in range(1, len(S_triple)):
    if S_triple[j] == S_triple[j - 1]:
        S_triple = S_triple[: j] + "?" + S_triple[j + 1:]
        ans_s3 += 1

ans_increase = ans_s3 - ans_s2  #K>=3のときの増分

ans = ans_s2 + max(0, ans_increase * (K - 2))
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

int dp[101][4][4][4];
int mod = 1000000007;
int main() {
    int n;
    cin >> n;
    //T:0A:1G:2C:3
    dp[0][0][0][0] = 1;
    rep(i,n) rep(a,4) rep(b,4) rep(c,4) rep(d,4) {
        //ダメなパターン　AGC,GAC,ACG,AXGC,AGXC
        if(b==1 && c==2 && d==3) continue; // AGC
        if(b==2 && c==1 && d==3) continue; // GAC
        if(b==1 && c==3 && d==2) continue; // ACG
        if(a==1 && c==2 && d==3) continue; // AXGC
        if(a==1 && b==2 && d==3) continue; // AGXC
        dp[i+1][b][c][d] =  (dp[i+1][b][c][d] + dp[i][a][b][c] )%mod;
    }
    int ans = 0;
    rep(a,4)rep(b,4)rep(c,4) {
        ans += dp[n][a][b][c];
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

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

int main(void){
    int a,b ;
    cin >> a >> b ;
    if (a==1){
        if (b==2){
            cout << 3 << endl ;
        } else {
            cout << 2 << endl ;
         }
    } else if (a==2){
        if (b==3){
            cout << 1 << endl ;
        } else {
            cout << 3 << endl ;
        }
    } else {
        if (b==1){
            cout << 2 << endl ;
        } else {
            cout << 1 << endl ;
        }
    }
}

Measured memory_bytes: 256
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

int main(){
    init();
    ll N;cin>>N;
    string s;cin>>s;ll K;cin>>K;K--;
    for(int i=0;i<N;i++){
        if(s[K]==s[i])cout<<s[i];
        else cout<<'*';
    }
    cout<<endl;



}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 1000000

int stuck[MAX];
int top=0;

void push(int);
int pop(void);

int main(){
  int x,a,b;
  char s[100];

  while( scanf("%s", s) != EOF ){
    
    if ( s[0] == '+' ){
      push(pop()+pop());
    } else if ( s[0] == '-' ){
      a = pop();
      b = pop();
      push(b-a);
    } else if ( s[0] == '*' ){
      push(pop()*pop());
    } else {
      x = atoi(s);
      push(x);
    }

  }
  printf("%d\n",pop());

  return 0;
}

void push(int in){
  if(top==MAX-1){
    printf("満杯\n");
  }else{
    top++;
    stuck[top]=in;
  }
}

int pop(){
  int rn;
  if(top==0){
    printf("空\n");
    rn=0;
  }else{
    rn=stuck[top];
    top--;
  }
  return rn;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
LL hako[100100];
LL miti[100100];
int main(){
  LL n;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> hako[i];
  }
  bool flag = true;
  LL buf = hako[0];
  for(int j=1;j<n;j++){
    buf += (flag?-hako[j]:hako[j]);
    flag = !flag;
  }
  miti[0] = buf/2;
  for(int i=1;i<n;i++){
    miti[i] = hako[i-1] - miti[i-1];
  }
  for(int i=0;i<n;i++){
    cout << miti[i]*2 << endl;
  }
  return 0;
}


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

const int N = 5e5 + 10;
char str[N];

int main() {
  int n, ans = 0, mxm = 0;
  scanf("%d", &n);
  vector<int> x(n), y(n);
  vector<pair<int, int>> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &x[i], &y[i]);
    a[i].first = x[i];
    a[i].second = y[i];
    ans = max(ans, a[i].second - a[i].first + 1);
    mxm = max(mxm, a[i].first);
  }
  sort(a.begin(), a.end(), [](pair<int, int> i, pair<int, int> j) {
    return i.second < j.second;
  });
  sort(y.begin(), y.end());
  y.resize(unique(y.begin(), y.end()) - y.begin());
  if (a[0].second >= mxm) ans += a[0].second - mxm + 1;
  int mxbg = a[0].first, p = 0;
  for (int i = 0; i < y.size(); i++) {
    if (y[i] < mxm) continue;
    for (; a[p].second < y[i]; p++) mxbg = max(mxbg, a[p].first);
    ans = max(ans, y[i] - mxm + 1 + y[0] - mxbg + 1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

constexpr ll mod = 998244353;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    
    friend ostream &operator<<(ostream& os,const mint& a){
        return os << a.x;
    }

    friend istream &operator>>(istream& is,mint& a){
        ll t;
        is >> t;
        a = mint(t);
        return (is);
    }

    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,S;
    cin >> N >> S;
    vec<int> A(N);
    for(auto& x:A) cin >> x;
    vvec<mint> dp(N+1,vec<mint>(S+1,0));
    mint ans = 0;
    dp[0][0] = 1;
    for(int i=0;i<N;i++){
        dp[i+1][0] = 1;
        for(int j=0;j<=S;j++){
            dp[i+1][j] += dp[i][j];
            if(j+A[i]<=S) dp[i+1][j+A[i]] += dp[i][j];
        }
        ans += (dp[i+1][S]-dp[i][S])*(N-i);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 73644
fun main(args: Array<String>) {
    while (true) {
        val (H, W) = readLine()!!.split(" ").map { it.toInt() }
        if (H == 0 || W == 0)
            break
        println("#".repeat(W))
        for (h in 2..H-1) {
            println("#%s#".format(".".repeat(W-2)))
        }
        println("#".repeat(W))
        println("")
    }
}


Measured memory_bytes: 32784
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define DBG(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll p = 1e9+7;
const ll INF = 1LL << 60;

int main(){
  int n,h,w;
  cin>>n>>h>>w;
  cout<<(n-h+1)*(n-w+1)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
static int const MIN_COUNT = 1;
static int const MAX_COUNT = 1000;
static int const MIN_VALUE = 0;
static int const MAX_VALUE = 1e3;

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

    cout << A[0];
    for(int i=1;i<N;i++)cout << " " << A[i];
    cout << endl;

    for(int i=1;i<=N-1;i++){
      int v=A[i];
      int j=i-1;
      while(j>=0 && A[j] > v){
        A[j+1] =A[j];
        j--;
        A[j+1] = v;
      }

      cout << A[0];
      for(int i=1;i<N;i++)cout << " " << A[i];
      cout << endl;

    }
    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;

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

long long dp[100001];

int main()
{
    int n;
    string a,b,c;
    cin >> n >> a >> b >> c;
    int ans = 0;
    for(int i = 0; i < n; i++){
        int cnt[26] = {0};
        cnt[a[i]-'a']++;
        cnt[b[i]-'a']++;
        cnt[c[i]-'a']++;
        int k = 0;
        for(int j = 0; j < 26; j++){
            k = max(cnt[j],k);
        }
        ans += (3-k);
    }   
    cout << ans;
}

Measured memory_bytes: 256
#include<cstdio>
#include<math.h>
#include<algorithm>
using namespace std;

int main(){
    long long int n,x,y,i;
    scanf("%lld",&n);
    for(i=sqrt(n);i>0;i--){
       if(n%i==0) break;
    }
    x=i;
    y=n/x;
    i=0;
    while(x!=0){
       x=x/10;
       i++;
    }
    x=i;
    i=0;
    while(y!=0){
       y=y/10;
       i++;
    }
    y=i;
    printf("%lld",max(x,y));
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void)
{
	int i,j,flag;
	flag=0;
	char s[10];
		scanf("%s",s);
		for(i=0;i<=2;i++){
			putchar(s[i]);}
		printf("8");
		for(i=4;i<=9;i++){
			putchar(s[i]);}
	return 0;
}

Measured memory_bytes: 128
/*   Then, everything changed when the Fire Nation attacked. */

#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define mod 1000000007
#define fi first
#define se second
using namespace std;
int n, x, v[1002];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // shuffle(permutation.begin(), permutation.end(), rng);
    cin>>n>>x;
    for(int i = 1; i <= n; ++i)
        cin >> v[i];
    sort(v+1, v+n+1);
    int sol = 0;
    for(int i = 1; i <= n; ++i)
    {
        if(i != n)
        {
            if(x >= v[i])
                ++sol, x-=v[i];
            else
                break;
        }
        else
        {
            if(x==v[i])
                ++sol;
        }
    }
    cout << sol;
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9 + 7;
const int maxn = 100005;

void go() {
    int x;
    cin >> x;
    cout << (x ^ 1) << '\n';
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        go();
    }
    
}

Measured memory_bytes: 3612
import java.util.*

fun <T : Comparable<T>> min(i: T, j:T):T {
    return if (i < j) i else j
}
fun main(args: Array<String>) {
    val (N) = readLine()!!.split(" ").map { it.toLong() }
    val list = makeDivisors(N)
    var min = Long.MAX_VALUE
    list.forEach {
        val a = N / it
        min = min(min, a + it)
    }
    print(min-2)
}

fun makeDivisors(n:Long): LongArray {
    val list = mutableListOf<Long>()
    for (i in 1 .. Math.pow(n.toDouble(), 0.5).toInt() + 1) {
        if (n % i == 0L) {
            list.add(i.toLong())
            if (i.toLong() != (n / i)) {
                list.add(n / i)
            }
        }
    }
    return list.toLongArray()
}

Measured memory_bytes: 38020
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};       
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  ll t=1;
  while(t--)
  {
    int n;
    cin>>n;
    int v[n];
    REP(i,n)cin>>v[i];
    int ans=0;
    while(1)
    {
        if(*max_element(v,v+n)==0)break;
        int i=0;
        while(i<n)
        {
            if(v[i]==0)++i;
            else
            {
                ans++;
                while(i<n && v[i]>0)
                {
                    --v[i];
                    i++;
                }
            }
        }
    }
    cout<<ans;
  }  
  return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main(void){
	ll n;
	cin >> n;

	ll ans = 1LL;
	while((n & ans) != 0) ans<<=1;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll x,k,d,minim=1e17;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>x>>k>>d;
    x=abs(x);
    ll lastpoz=x%d;
    ll nrop1=(x-lastpoz)/d;
    ll nrop2=nrop1+1;
    ll firstneg=lastpoz-d;
    if(nrop1<=k)
    {
        if((k-nrop1)%2==0)
            minim=min(minim,lastpoz);
        else
            minim=min(minim,lastpoz+d);
    }
    if(nrop2<=k)
    {
        if((k-nrop2)%2==0)
            minim=min(minim,(firstneg)*(-1));
        else
            minim=min(minim,(firstneg)*(-1)+d);
    }
    if(nrop1>k)
        minim=x-d*k;
    cout<<minim;
    return 0;
}


Measured memory_bytes: 3648