akhauriyash/Code-Regression huggingface dataset:
n,d = map(int,input().split())

p = [list(map(int,input().split())) for i in range(n)]

kyori = d * d
count = 0

for s in range(n):
  nagasa = p[s][0] * p[s][0] + p[s][1] * p[s][1]
  if nagasa <= kyori:
    count += 1
    
print(count)


Measured memory_bytes: 45464
hp_t,at_t,hp_a,at_a=map(int,input().split())

judge=1
while judge > 0:
    hp_a=hp_a-at_t
    if hp_a<=0:
        print('Yes')
        break
    hp_t=hp_t-at_a
    if hp_t<=0:
        print('No')
        break
    

Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n,m;
	cin>>n>>m;
	for(int i=0; i<=n; i++) {
		for(int j=0; j<=n; j++) {
			int k=m-(i*10000)-(j*5000);
			k/=1000;
			if(i+j+k==n&&k>=0) {
				cout<<i<<" "<<j<<" "<<k<<endl;
				return 0;
			}
		}
	}
	cout<<-1<<" "<<-1<<" "<<-1<<endl;
}

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

using namespace std;

int main(){
    int a, b;
    string aa, bb;
    cin>>a>>b;
    for(int i=0;i<a;i++){
        aa+=('0'+b);
    }
    for(int i=0;i<b;i++){
        bb+=('0'+a);
    }
    if(aa<bb){
        cout<<aa<<endl;
    }
    else{
        cout<<bb<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  ll a,b,k;
  cin >> a >> b >> k;
  ll aa = a;
  a -= k;
  k -= aa;
  k = max((ll)0,k);
  b -= k;
  cout << max(a,(ll)0) << " " << max(b,(ll)0) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
ll gcd(ll a,ll b){
    return (b?gcd(b,a%b):a);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin >> n;
    vector<ll> a(n);
    ll allg=0;
    REP(i,n){
        cin >> a[i];
        allg=gcd(allg,a[i]);
    }
    if(allg!=1){
        cout << "not coprime" << endl;
        return 0;
    }
    const int vmax=1000001;
    vector<int> d(vmax);
    REP(i,n){
        int num=a[i];
        for(int j=2;j*j<=a[i];j++){
            int cnt=0;
            while(num%j==0){
                cnt++;
                num/=j;
            }
            if(cnt){
                if(d[j]){
                    cout << "setwise coprime" << endl;
                    return 0;
                }
                else{
                    d[j]+=cnt;
                }
            }
            if(num==1){
                break;
            }
        }
        if(num!=1){
            if(d[num]){
                cout << "setwise coprime" << endl;
                return 0;
            }
            else{
                d[num]++;
            }
        }
    }
    cout << "pairwise coprime" << endl;
}

Measured memory_bytes: 14972
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

#define rep(i,s,n) for(ll (i)=(s);(i)<(n);(i)++)
#define repd(i,n,s) for(ll (i)=(n-1);(i)>=(s);(i)--)
#define all(x) x.begin(),x.end()
#define size(x) ((ll)(x).size()
#define PB push_back

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> ans(n);
  rep(i,0,n-1){
     cin >> a[i];
     ans[a[i]-1]++; 
  }    
  
  rep(i,0,n){
     cout << ans[i] << endl;
  }
  

}





Measured memory_bytes: 4848
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			if(n == 0){
				break;
			}
			int[] ice = new int[10];
			for(int i = 0;i < n;i++){
				ice[scan.nextInt()] += 1;
			}
			for(int i = 0;i < 10;i++){
				if(ice[i] == 0){
					System.out.print("-");
				}else{
					for(int j = 0;j < ice[i];j++){
						System.out.print("*");
					}
				}
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 54144
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =1001001001;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




/*10億7。　　　100000007
2*2行列 H*W
vector<vector<int>> vec(H,vector<int>(W));
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
cin>>vec[i][j];
  }
}

文字列→数列
string S;int A=atoi(S.c_str());
数列→文字列
int A;string S=to_string(A);
数字判定　isdigit(a)
pair宣言　pair<int,int> p(5,7);
ソート　sort(vec.begin(),vec.end());
キュー　queue<int> q;
   q.push(7);　//７が入る
   cout << q.front() << endl;  // 先頭の値を出力
   q.pop();  // 先頭の値を削除
   q.empty();
*/
//座標　corrdinateト深さヲ保持スルタメノ構造体
struct Coor{
  ll y;
  ll x;
  ll depth;
};
 ll N,M;  
 ll sy,sx,gy,gx;
 ll y,x,depth;//キューから取り出した座標
vector<string> vec;
queue<Coor> q;
vector<ll> y_vec={0,0,-1,+1};//technique
vector<ll> x_vec={-1,+1,0,0};

int BFS(){
  while(!q.empty()){
    Coor now=q.front();q.pop();//キューの先頭を取り出す
    y=now.y,x=now.x,depth=now.depth;
    
    //停止条件
    if(y==gy&&x==gx){return depth;}
    
    //上下左右４方向を探索、進むことができればキューに格納
    for(int i=0;i<4;i++){
      Coor next={y+y_vec[i],x+x_vec[i],depth+1};
      if(0<=next.y&&next.y<=N-1&&0<=next.x&&next.x<=M-1&&vec[next.y][next.x]=='.'){
        vec[next.y][next.x]='x';//同じ場所を探索しないようにする
        q.push(next);
      }
    }
  }
  return 0;
}
                   
  


int main(void){
cout<<fixed<<setprecision(14);
//cin.tie(0); ios::sync_with_stdio(false);

  
  string S;cin>>S;
int counter=0;
 
   if(S[0]=='1')counter++;
   if(S[1]=='1')counter++;
   if(S[2]=='1')counter++;
  cout<<counter<<endl;
  
  
  
  
  
  
  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
using ll = long long;
using namespace std;
const ll mod = 998244353;

#define div meow

const int bound = 1000050;

vector<ll> inv(bound);

ll power( ll a, ll b ){
	ll res = 1;
	while( b > 0 ){
		if( b & 1 ) res = res * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return res;
}

void inv_init(){
	inv[0] = 1;
	for( int k = 1; k < bound; ++k ) inv[k] = power(k, mod-2);
}

// vector<int> div[k] := k の約数のベクトル
vector<ll> div[bound];

void div_init( ll maxv ){
	for( ll d = 1; d <= maxv; ++d ){
		for( int k = d; k <= maxv; k += d ){
			div[k].push_back(d);
		}
	}
}

// sum_all[k] := k を約数として持つような a の要素の和
// sum_sq[k] := k を約数として持つような a の要素の二乗の和
vector<ll> sum_all(bound, 0);
vector<ll> sum_sq(bound, 0);

vector<ll> f(bound);

int main(){
	int n; cin >> n;
	vector<ll> a(n);
	ll maxv = 0;
	for( auto &k : a ){
		cin >> k;
		maxv = max(maxv, k);
	}
	inv_init();
	div_init(maxv);
	for( auto &k : a ){
		for( auto &d : div[k] ){
			sum_all[d] += k;
			sum_all[d] %= mod;
			sum_sq[d] += (k*k)%mod;
			sum_sq[d] %= mod;
		}
	}
	ll ans = 0;
	for( ll d = maxv; d > 0; --d ){
		ll g = ( sum_all[d]*sum_all[d]%mod - sum_sq[d] + mod ) % mod * inv[2] % mod;
		for( ll k = 2; k*d <= maxv; ++k ){
			g += ( - f[k*d] + mod ) % mod;
			g %= mod;
		}
		f[d] = g;
		// cout << "d = " << d << ": " << (f[d]*inv[d])%mod << endl;
		ans += ((f[d]*inv[d])%mod);
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 213760
#include<stdio.h>
void swap(int* a,int* b){
	int c;
	c=*a;
	*a=*b;
	*b=c;
}
int main(void){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b)swap(&a,&b);
	if(b>c)swap(&b,&c);
	if(a>b)swap(&a,&b);
	printf("%d %d %d\n",a,b,c);
	return 0;
}



Measured memory_bytes: 2104
import java.util.*;

class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                while(sc.hasNextLine()){
                        String S = sc.nextLine();
                        int JOI = 0, IOI = 0;
                        if(S.length() >= 3){
                                for (int i = 0; i <= S.length() - 3; i++) {
                                        if (S.substring(i, i + 3).equals("JOI")) {
                                                JOI++;
                                        }else if (S.substring(i, i + 3).equals("IOI")) {
                                                IOI++;
                                        }
                                }
                        }
                        System.out.println(JOI);
                        System.out.println(IOI);
                }
        }
}

Measured memory_bytes: 28728
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 2000000001;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int M,K;
    cin >> M >> K;
    if(M == 0) {
        if(K == 0) {
            cout << 0 << " " << 0 << endl;
        }
        else {
            cout << -1 << endl;
        }
    }
    else if(M == 1) {
        if(K == 0) {
            cout << "0 1 1 0" << endl;
        }
        else {
            cout << -1 << endl;
        }
    }
    else {
        M = pow(2,M) - 1;
        if(M < K) {
            cout << -1 << endl;
        }
        else {
            for(int i = M;i >= 0;i--) {
                if(i != K) {
                    cout << i << " ";
                }
            }
            cout << K << " ";
            for(int i = 0;i <= M;i++) {
                if(i != K) {
                    cout << i << " ";
                }
            }
            cout << K << endl;
        }
    }
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n;
int a[200000];
vector<int> et[200000];

int INF = 1e+10;
int dp[200001];	//dp[length] = min_value
int ans[200001];
void dfs(int p, int v, int len) {
	int pos = lower_bound(dp, dp + len, a[v]) - dp;
	int tmp = dp[pos];
	int nlen = len;
	if (pos == len) { nlen = len + 1; }
	dp[pos] = a[v];
	
	ans[v] = nlen;
	int i;
	rep(i, et[v].size()) {
		int nv = et[v][i];
		if (nv == p) continue;
		dfs(v, nv, nlen);
	}
	dp[pos] = tmp;
}

signed main() {
	int i;
	
	cin >> n;
	rep(i, n) cin >> a[i];
	rep(i, n - 1) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		et[u].push_back(v);
		et[v].push_back(u);
	}
	
	rep(i, n + 1) dp[i] = INF;
	dfs(-1, 0, 0);
	rep(i, n) cout << ans[i]  << endl;
	return 0;
}

Measured memory_bytes: 33444
#include <stdio.h>
 
int main() {
  int n,m,s=0;
  scanf("%d %d",&n, &m);
  if (n != 0){
    s=s+(n*(n-1))/2;
  }
  if (m != 0){
    s=s+(m*(m-1))/2;
  }
  printf("%d",s);
  return 0;
}

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

int Par[100001],Rank[100001];

void init(int n)
{
	for(int i = 0;i<n;i++)
	{
		Par[i] = i;
	}
}

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

void unit(int x,int y)
{
	x = find(x);
	y = find(y);
	Par[x]=y;
}

int main()
{
	int n,m;
	cin >> n >> m;
	init(n);
	while (m--)
	{
		int x,y,z;
		cin >> x >> y >> z;
		x--;y--;
		unit(x,y);
	}
	vector<int> ans(n);
	for(int i = 0;i<n;i++)
	{
		ans[i] = find(i);
		//cout<<ans[i]<<endl;
	}
	sort(ans.begin(),ans.end());
	int cnt =1;
	for(int i = 0;i<n-1;i++)
	{
		if(ans[i]!=ans[i+1])cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int x[100];
int main()
{
    int n,m,c=0,s;
    cin>>n;
    for(int i=1;i<=n;i++){
        m=i;
        s=0;
        while(m){
            s++;
            m/=10;
        }
        if(s%2)c++;
    }
    cout<<c<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    ll b = (s[0]-'0')*100 + (s[2]-'0')*10 + s[3]-'0';

    ll ans = a * b / 100;

    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3628
# 2019/09/03

h,w=map(int,input().split())

if (h*w)%3==0:
    print(0)
    exit()


def solve(s):
    global h,w
    
    cnt=float('inf')
    if s==h:
        H,W=w,h
    else:
        H,W=h,w
    for i in range(1,s+1):
        a=i*H
        rest=H*(w-i)
        if rest%2==0:
            b=c=rest//2
        else:
            ww=W-i
            hh=H
            bb=max(ww,hh)//2
            cc=bb+1
            b=min(ww,hh)*bb
            c=min(ww,hh)*cc
        cnt=min((max(a,b,c)-min(a,b,c)),cnt)

    return cnt


ans=min(solve(h),solve(w))
print(ans)
        


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n,m;
	cin >> n >> m;
	vector<int> v(m);
	rep(i,0,m)cin >> v[i];
	sort(all(v));
	vector<int> len(m-1);
	rep(i,0,m-1)len[i] = v[i+1] - v[i];
	sort(all(len));
	int ans = 0;
	rep(i,0,max(m-n,0))ans += len[i];
	cout << ans << '\n';
}


Measured memory_bytes: 1024
#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 A,B,C,X;
	std::cin >> A;
	std::cin >> B;
	std::cin >> C;
	std::cin >> X;
	int cnt = 0;
	for ( int i = 0 ; i <= A ; i++ ) {
		for ( int ii = 0 ; ii <= B ; ii++ ) {
			for ( int iii = 0 ; iii <= C ; iii++ ) {
				if((500*i+100*ii+50*iii) == X) cnt ++;
			}
		}
	}
	std::cout << cnt << std::endl;
	return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextLineToStringArray() []string {
	line := nextLine()
	return strings.Split(line, " ")
}

func nextLineToIntArray() []int {
	parts := nextLineToStringArray()
	arr := make([]int, len(parts))
	for i, s := range parts {
		arr[i], _ = strconv.Atoi(s)
	}
	return arr
}

func nextLineToInt64Array() []int64 {
	parts := nextLineToStringArray()
	arr := make([]int64, len(parts))
	for i, s := range parts {
		arr[i], _ = strconv.ParseInt(s, 10, 64)
	}
	return arr
}

func nextLineToFloat32Array() []float32 {
	parts := nextLineToStringArray()
	arr := make([]float32, len(parts))
	for i, s := range parts {
		n, _ := strconv.ParseFloat(s, 32)
		arr[i] = float32(n)
	}
	return arr
}

func nextLineToFloat64Array() []float64 {
	parts := nextLineToStringArray()
	arr := make([]float64, len(parts))
	for i, s := range parts {
		arr[i], _ = strconv.ParseFloat(s, 64)
	}
	return arr
}

func readLines(n int) []string {
	arr := make([]string, n)
	for i := 0; i < n; i++ {
		arr[i] = nextLine()
	}
	return arr
}

func readLinesInt(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i], _ = strconv.Atoi(nextLine())
	}
	return arr
}

func readLinesInt64(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i], _ = strconv.ParseInt(nextLine(), 10, 64)
	}
	return arr
}

func readLinesFloat32(n int) []float32 {
	arr := make([]float32, n)
	for i := 0; i < n; i++ {
		n, _ := strconv.ParseFloat(nextLine(), 32)
		arr[i] = float32(n)
	}
	return arr
}

func readLinesFloat64(n int) []float64 {
	arr := make([]float64, n)
	for i := 0; i < n; i++ {
		arr[i], _ = strconv.ParseFloat(nextLine(), 64)
	}
	return arr
}

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 abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func submit(n int, line string) int {
	return 0
}

var memo = make(map[int64]int64)

func fib(i int64) int64 {
	if v, ok := memo[i]; ok {
		return v
	}
	if i == 0 {
		return 0
	}
	if i == 1 {
		return 1
	}
	memo[i] = (fib(i-2) + fib(i-1)) % 1000000007
	return memo[i]
}

func main() {
	arr := nextLineToIntArray()
	n := arr[0]
	m := arr[1]
	A := readLinesInt64(m)
	A = append(A, int64(n+1))

	var i int64
	var ans int64 = 1
	for _, a := range A {
		t := a - i
		if t == 0 {
			ans = 0
			break
		}
		ans = (ans * fib(t)) % 1000000007
		i = a + 1
	}
	fmt.Println(ans)
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n, k;
    cin >> n >> k;

    vector<bool> b(n);
    for (auto _ : irange(0L, k)) {
        int64_t d;
        cin >> d;

        for (auto __ : irange(0L, d)) {
            int64_t a;
            cin >> a;
            b[a - 1] = true;
        }
    }

    int64_t ans = count(b.begin(), b.end(), false);
    cout << ans << endl;
}

Measured memory_bytes: 3632
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	while(kbd.hasNext()){
	    solve();
	}
    }
    
    static void solve(){
	int[] num = new int[5];
	int i;
	for(i=0; i<num.length; i++){
	    num[i] = kbd.nextInt();
	}
	sort(num);
	for(i=0; i<num.length; i++){
	    System.out.print(num[i]);
	    if(i+1<num.length){
		System.out.print(" ");
	    }
	}
	System.out.println();
    }

    static void sort(int[] num){
	int i, j;
	for(i=0; i<num.length; i++){
	    for(j=i+1; j<num.length; j++){
		if(num[i]<num[j]){
		    int w = num[i];
		    num[i] = num[j];
		    num[j] = w;
		}
	    }
	}
    }
}

Measured memory_bytes: 17168
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    
    // 標準入力から整数の入力
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    int h = scanner.nextInt();
    
    // 台形の面積を求める
    // (上辺　+ 底辺)　*　高さ /　2
    System.out.println((a + b) * h / 2);
  }
}

Measured memory_bytes: 35580
/* nothing is impossible */
#include <bits/stdc++.h> 
 
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define fi first
#define se second
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef long double ld;
typedef string st;
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
const ll MOD = 1e9 + 7 ;
const ll INF=1e14;                                                                                           
ll mpow(ll a,ll b,ll p=MOD){a=a%p;ll res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}             
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n,m;
  cin>>n>>m;
  st a,b;
  cin>>a>>b;
  ll lcm=(n*m)/(__gcd(n,m));
  ll k1=lcm/n;
  ll k2=lcm/m;
  forn(i,n)
  {
    ll o=i*m;
    if(o%n==0)
    {
      if(a[i]!=b[o/n])
      {
        cout<<"-1";
        return 0;
      }
    }
  }
  forn(i,m)
  {
    ll o=i*n;
    if(o%m==0)
    {
      if(b[i]!=a[o/m])
      {
        cout<<"-1";
        return 0;
      }
    }
  }
  cout<<lcm;
  return 0;   
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int a[N];
  for(int i = 0;i<N;i++){
    cin>>a[i];
  }
  int temp = 0;
  for(int i = 0;i<N-1;i++){
    if(i%2 == 0){
      temp += a[i];
    }
    else{
      temp -= a[i];
    }
  }
  cout << a[N-1]+temp << endl;
  int anstemp = a[N-1]+temp;
  for(int i = 0;i<N-1;i++){
    anstemp = 2*a[i]-anstemp;
    cout << anstemp << endl;
  }
  return 0;
}

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

namespace ProgramingStudying2
{
    class Program
    {

        static void Main(string[] args)
        {
            var t = Console.ReadLine();
            var ans = new string[t.Length];
            for(int i = 0; i < t.Length; i++)
            {
                if(t[i] == '?')
                {
                    ans[i] = "D";
                }
                else
                {
                    ans[i] = t[i].ToString();
                }
            }

            foreach(var x in ans)
            {
                Console.Write(x);
            }
        }
    }
}


Measured memory_bytes: 32728
#include<stdio.h>
#define min(x,y) ((x)<(y)?(x):(y))
int main(){
	int i, n, k;
	scanf("%d %d", &n, &k);
	for (i = 0; i < k; i++){
		int x, y;
		scanf("%d %d", &x, &y);
		x = min(x, n + 1 - x);
		y = min(y, n + 1 - y);
		printf("%d\n", (min(x, y) - 1) % 3 + 1);

	}
	return 0;
}

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

s = input()
t = input()

S = list(s)

isPossible = False
for i in range(len(S)):
    temp = s[i:] + s[:i]
    if temp == t:
        isPossible = True

if isPossible:
    print("Yes")
else:
    print("No")


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

using namespace std;

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif // ONPC
    int n, m;
    cin >> n >> m;
    int mx = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            char c;
            cin >> c;
            if (c == '#')
            {
                if (mx > j)
                {
                    cout << "Impossible\n";
                    return 0;
                }
                mx = j;
            }
        }
    }
    cout << "Possible\n";
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<cstdlib> 
#include<string>
#include<math.h>
#include<bitset>
#include<algorithm>
#include<vector>
#include<set>
#include<stack>
#include<queue>
using namespace std;



int main(){

	unsigned long long n,t[1000],a[1000];

	cin>>n;
	for(int i=0;i<n;i++)cin >> t[i] >> a[i];

	unsigned long long x=t[0];
	unsigned long long y=a[0];

	for(int i=1;i<n;i++){
		unsigned long long p,q;
		p=x/t[i] +((x%t[i])!=0);
		q=y/a[i] +((y%a[i])!=0);

		if(p>=q){
		x=t[i]*p;
		y=a[i]*p;
		}else{
		x=t[i]*q;
		y=a[i]*q;
		}
		//cout << x << ' ' << y << endl;
	}
	cout << x+y << endl;

	//while(1);
}




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

int main(void){
  char str[256];
  fgets(str,256,stdin);

  //printf("str[0] = %c\n",*(str+0));
  //return 0;

  int n=strlen(str)-1;
  if(n%2==1)n--;
  else{n=n-2;}

 while(n>0){
   //printf("n=%d\n",n);
    int d=n/2;
    int i=0;
    bool b=true;
    for(i=0;i<d;i++){
      //printf("%c %c\n",*(str+i),*(str+i+d));
      if(*(str+i)!=*(str+i+d)){
	b=false;
	break;
      }
    }
    if(b)break;
    n=n-2;
  }
 printf("%d\n",n);
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;

int main() {
  //
  ll k, x;
  cin >> k >> x;
  bool start = false;
  REP(i, -1000000, 1000001) {
    if (abs(i - x) <= k - 1) {
      cout << i;
      start = true;
    }
    if (start) {
      if (abs(i + 1 - x) <= k - 1) {
        cout << " ";
      } else {
        cout << endl;
        break;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 888
#include <iostream>

using namespace std;

int N,M,C;
int B[30]={};
int res=0;

int main(){
  cin >> N >> M >> C;
  for(int i=0;i<M;i++) cin >> B[i];
  for(int i=0;i<N;i++){
    int sum=C;
    for(int j=0;j<M;j++){
      int a;
      cin >> a;
      sum+=a*B[j];
    }
    res+=(sum>0)?1:0;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
a=b=c=d=0
for i in range(n):
    s=input()
    if s=="AC":
        a+=1
    elif s=="WA":
        b+=1
    elif s=="TLE":
        c+=1
    else:
        d+=1
print("AC x",a)
print("WA x",b)
print("TLE x",c)
print("RE x",d)

Measured memory_bytes: 69836
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N, L;
    cin >> N >> L;
    vec<string> s_list;
    range(i, 0, N) {
        string s;
        cin >> s;
        s_list.emplace_back(s);
    }
    sort(s_list.begin(), s_list.end());
    for (const string s : s_list) {
        cout << s;
    }
    // cout << s_list << "\n";
    cout << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int NMAX = 2 * 1e5 + 5;
long long dp[NMAX][3];
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> a(n);
  map<long long, long long> cnt;
  for (int i = 0; i < n; i++){
    cin >> a[i];
    cnt[a[i]]++;
  }
  for (int i = 1; i < n; i++){
    for (int j = 0; j <= 2; j++)
      if (j == 0 || j == i)
        dp[i][j] = 1;
      else
        dp[i][j] = dp[i-1][j-1] + dp[i-1][j];
   }
  long long ans = 0;
  for (auto e: cnt)
    if (e.second != 0)
      ans += dp[e.second][2];
  for (int i = 0; i < n; i++){
    cout << ans - dp[cnt[a[i]]][2] + dp[cnt[a[i]] - 1][2] << '\n';
  }

  return 0;
}


Measured memory_bytes: 15744
#include <iostream>
#include <cstring>

using namespace std;


// returns reamining buns.

// let us 

const int N = 100;
long long layers[N], panny[N];

long long P(int n) {
    if (panny[n] != -1) return panny[n];
    if (n == 0) return 1;

    return panny[n] = P(n - 1) + 1 + P(n - 1);
}

long long L(int n) {
    if (layers[n] != -1) return layers[n];
    if (n == 0) return 1;
    return layers[n] = L(n - 1) + 3 + L(n - 1);
}

long long f(int lvl, long long rem) {
    if (rem == 0) return 0;
    if (lvl == 0) return 1;

    // cout << lvl << ' ' << rem << endl;

    rem--;
    long long L1 = L(lvl - 1);
    if (rem <= L1) {
        return f(lvl - 1, rem);
    }

    long long ans = P(lvl - 1);
    rem -= L1;

    if (rem) {
        ans++;
        rem--;
    }

    long long L2 = L(lvl - 1);
    if (rem <= L2) {
        return ans + f(lvl - 1, rem);
    }

    ans += P(lvl - 1);
    rem -= L2;

    if (rem) rem--;

    return ans;
}

int main() {
    memset(panny, -1, sizeof panny);
    memset(layers, -1, sizeof layers);

    int n; long long rem; cin >> n >> rem;
    long long res = f(n, rem);
    cout << res<< endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr ll mod998=998244353;

int N,M,K;
ll res,F[200001];

ll pw(ll x,int y){
	ll a=1;
	while(y){
		if(y&1)a=a*x%mod998;
		x=x*x%mod998;
		y/=2;
	}
	return a;
}

ll modinv(ll x){
	return pw(x,mod998-2);
}

ll comb(int n,int r){
	return F[n]*modinv(F[r]*F[n-r]%mod998)%mod998;
}

int main(){
	cin>>N>>M>>K;
	F[0]=1;
	for(ll i=1;i<=200000;i++){
		F[i]=F[i-1]*i%mod998;
	}
	for(int i=0;i<=K;i++){
		res+=comb(N-1,i)*pw(M-1,N-i-1)%mod998*M;
		res%=mod998;
	}
	cout<<res<<endl;
}


Measured memory_bytes: 5200
use proconio::*;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
use std::*;

#[allow(dead_code)]
const MOD: i128 = 100_000_007;

#[fastout]
fn main() {
    input!{
        s : String,
        t : String
    }
    let slen = s.len();
    let ans = if s[..slen] == t[..slen] {
        "Yes"
    } else {
        "No"
    };
    println!("{}",ans);
}


Measured memory_bytes: 2152
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author arauf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            final int n = in.nextInt();

            int min = Integer.MAX_VALUE;
            int max = Integer.MIN_VALUE;

            for (int i = 0; i < n; i++) {
                int x = in.nextInt();
                min = Math.min(min, x);
                max = Math.max(max, x);
            }
            out.println(max - min);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int read() {
            if (numChars == -1) throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21332
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct
{
    char name[10];
    int quantum;
}Task;
typedef struct
{
    int tail;
    int head;
    int acSize;
    int maxSize;
}Queue;
void enqueue(Task a,Queue *queue, Task *task);
Task dequeue(Task a,Queue *queue, Task *task);
void getnew (int interval,Queue *queue, Task p[]);
int ifIsFull(Queue *queue);
int main() {
    int interval, size;
    scanf("%d %d",&size, &interval);
    Task task[size];
    Queue queue;
    queue.acSize=0;
    queue.maxSize=size;
    queue.head=0;
    queue.tail=0;
    Task tempTask;
    for(int i = 0; i < size; ++i)
    {
        scanf("%s %d", tempTask.name, &tempTask.quantum);
        enqueue(tempTask, &queue, task);
    }

    getnew(interval,&queue,task);
  
    return 0;
}
void enqueue(Task a,Queue *queue, Task *task)
{
    int tail;
    tail = queue->tail;
    if(ifIsFull(queue)==0)
    {
        task[tail] = a;
        queue->tail = (queue->tail+1) % queue->maxSize;
        queue->acSize++;
    }
    if(queue->acSize == queue->maxSize)
    {
        queue->tail = -1;
    }
}
/*
Task dequeue(Task a,Queue *queue, Task *task)
{
    if(queue->tail < 0 || queue->tail > queue->maxSize - 1)
    {
        queue->tail = queue->head;
    }
    a = task[queue->head];
    queue->head = (queue->head + 1) % queue->maxSize;
    queue->acSize--;
    return a;
    
    
}*/

void getnew (int interval,Queue *queue, Task p[])
{
    Task temp;
    int toltime = 0;
    while(queue->head != queue->tail){  
        if(queue->tail < 0 || queue->tail > queue->maxSize - 1)
        {
            queue->tail = queue->head;
        }
        temp = p[queue->head];
        queue->head = (queue->head + 1) % queue->maxSize;
        queue->acSize--;   
        if(temp.quantum <= interval)
        {
            toltime += temp.quantum;
            printf("%s %d\n",temp.name, toltime);
        }
        else 
        {
            toltime += interval;
            temp.quantum -= interval;
           if(ifIsFull(queue)==0)
        {
            p[queue->tail] = temp;
            queue->tail = (queue->tail+1) % queue->maxSize;
            queue->acSize++;
        }
        if(queue->acSize == queue->maxSize)
        {
            queue->tail = -1;
        }
        }
    }
}
int ifIsFull(Queue *queue)
{
    if(queue->acSize < queue->maxSize)
        return 0;
    else 
        return 1; 
}


Measured memory_bytes: 2468
#include <stdio.h>
#include <math.h>

int calc(int x,int y, int z){
  int ans;
  ans = x*x + y*y + z*z + x*y + x*z + y*z;
  return ans;
}

int main(){
  int n;
  int index;
  int i,j,k;
  int b_1,b_2,b_3,b_4;
  int index_break;
  int ans;
  double tmp;
  scanf("%d",&n);
  int cnt[n+1];
  for(i=1;i<=n;i++){
    cnt[i]=0;
  }
  i=1;
  while(1){
     ans = 1+1+i*i+1+i+i;
     i++;
     if(ans > n){
       index_break=i;
       break;
     }
  }
  /*
  //区分1(3個とも数字が違う場合)
  b_1 = n/3;
  b_2 = 2*n/3;
  //区分２(3個とも数字が同じ場合)
  tmp = n/6;
  b_3 = sqrt(tmp);
  //区分２(2個だけ数字が同じ場合)
*/

  for(i=1;i<=index_break;i++){
    for(j=1;j<=index_break;j++){
      for(k=1;k<=index_break;k++){
        index=calc(i,j,k);
        if(index<=n){
        cnt[index]+=1;
      }
      }
    }
  }
/*

//３個とも同じ数のとき
for(i=1;i<=b_3;i++){
  index=calc(i,i,i);
  if(index<=n){
  cnt[index]+=1;
  }
}
//2個とも同じ数のとき
for(i=1;i<=b_1;i++){
  for(j=b_1+1;j;j--){

  index=calc(i,j,j);
  if(index<=n){
  cnt[index]+=3;
  }
}
}

//３個とも違う場合
  for(i=1;i<=b_1;i++){
    for(j=b_1+1;j<=b_2;j++){
      for(k=b_2+1;k<n;k++){
        index=calc(i,j,k);
        if(index<=n){
        cnt[index]+=6;
      }
      }
    }
  }
  */
  for(i=1;i<=n;i++){
    printf("%d\n",cnt[i]);
  }

  return 0;
}


Measured memory_bytes: 1732
#include <iostream>
using namespace std;
int main(void){
long long N,K;
cin >> N >> K;

long long ans = 0;

for(long long i=K;i<=N+1;i++){
long long max = (2*N + 1 - i) * i / 2;
long long min = (i - 1) * i / 2;
ans += max - min + 1;
ans %= 1000000007;
}

cout << ans << endl;

return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int dp[110][10010];

int main() {
    int n,W;
    cin>>n>>W;
    int v[n],w[n];
    rep(i,n) cin>>v[i]>>w[i];

    dp[0][0]=0;
    rep(i,n){
        for(int j=0;j<=W;j++){
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
            if(j-w[i]>=0) dp[i+1][j]=max(dp[i+1][j],dp[i][j-w[i]]+v[i]);
        }
    }

    cout<<dp[n][W]<<endl;
}




Measured memory_bytes: 6992
/*
Arthor : Ender_zzm
E-mail zzm_ender_wiggin@outlook.com
Blog oi.ender-zzm.pro
*/
#include <bits/stdc++.h>
using namespace std;

template<class T>
inline void read(T &a) {
    register T x = 0, flag = 1;
    register char ch;
    while (!isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), isdigit(ch = getchar()));
    a = x * flag;
}

template <class T>
inline void write(T x) {
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define For(i, a, b) for (int i = (a); i <= (b); i++) 
#define Rep(i, a, b) for (int i = (a); i >= (b); i--) 
#define For_edge(x) for (int i = head[x]; i; i = net[i])
#define mem0(a) memset(a, 0, sizeof a)

int n;
int gcd(int x, int y) {
	if (y == 0) return x;
	else return gcd(y, x % y);
}
int gcd(int x, int y, int z) {
	return gcd(gcd(x, y), z);
}
int main() {
	cin >> n;
	int ans = 0;
	For (i, 1, n) {
		For (j, 1, n) {
			For (k, 1, n) {
				ans += gcd(i, j, k);
			}
		}
	}
	cout << ans;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T, class U>using vp = vector<pair<T, U>>;
template<class T>using vv = vector<vector<T>>; template<class T, class U>using vvp = vv<pair<T, U>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
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; }
constexpr int INF = 1 << 28, MAX = 1e5 + 5, MOD = 1e9 + 7;
constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
constexpr int dy[4] = { 0,1,0,-1 }, dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N, M, R;
vi r;

struct WarshallFloyd {
    int n; // 頂点数
    vector<vector<int>> dist; // cost[from][to]
    vector<bool> s;

    WarshallFloyd() {}
    WarshallFloyd(const int n) : n(n) {
        dist.resize(n, vector<int>(n, INF));
        // 外からでも初期化しやがれ
    }

    void warshall_floyd() {
        for (int k = 0; k < n; k++) {
            // 経由する頂点
            if (s[k]) continue;

            for (int i = 0; i < n; i++)    // 開始頂点
                for (int j = 0; j < n; j++)  // 終端
                    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
        }
    }
} wf;

int main() {
    cin >> N >> M >> R;
    r.resize(R);
    rep(i, R) {
        cin >> r[i];
        r[i]--;
    };

    wf = WarshallFloyd(N);
    rep(i, M) {
        int A, B, C;
        cin >> A >> B >> C;
        A--; B--;
        wf.dist[A][B] = C;
        wf.dist[B][A] = C;
    }
    wf.s.resize(N, false);
    rep(i, R) wf.s[r[i]] = true;
    wf.warshall_floyd();

    sort(all(r));
    int ans = INF;
    do {
        int d = 0;
        rep(i, R - 1) {
            d += wf.dist[r[i]][r[i + 1]];
        }
        chmin(ans, d);
    } while (next_permutation(all(r)));
    
    write(ans);
}

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

int FindSumOfDigits(int n){
  int sum = 0;
  while(n>0){
    sum += n%10;
    n = n/10;
  }
  return sum;
}

int main() {
  int N,f;
  cin >> N;
  f = FindSumOfDigits(N);
  if(N%f == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

  

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stdlib.h>
#include <list>
#include <queue>
#include <map>
#include <stack>
#include <set>
#define inf 0x3f3f3f3f
#define PI acos(double(-1))
using namespace std;

typedef long long ll;
int a,b,c;

int main()
{
    scanf("%d%d%d",&a,&b,&c);
    int i=1000;
    int flag=0;
    int j=1;
    while(i--)
    {
        if(a*j%b==c)
        {
            flag=1;
            break;
        }
        j++;
    }
    if(flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	int n = s.length();
	reverse(s.begin(), s.end());
	vector<int> pre(n, 0);
	int p = 1;
	for(int i = 0; i < n; i++) {
		pre[i] = ( (s[i] - '0') * p ) % 2019;
		if(i) pre[i] = (pre[i] + pre[i-1]) % 2019;
		p = (p * 10) % 2019;
	}
	vector<int> con(2020, 0);
	long long ans = 0;
	for(int i = 0; i < n; i++) {
		if(pre[i] == 0) ans++;
		ans += con[pre[i]];
		con[pre[i]]++;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 4412
import java.util.*;
public class Main
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        double sum=0;
        while(n-->0)
        {
            double d=sc.nextDouble();
            String s=sc.next();
            if(s.charAt(0)=='J')
                sum+=d;
            else
                sum+=d*380000.0;
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 23380
N,M = map(int,input().split())
H = list(map(int,input().split()))
W = [1 for i in range(N)]
for i in range(M):
    a,b = map(int,input().split())
    if H[a-1] >= H[b-1]:
        W[b-1] = 0
    if H[b-1] >= H[a-1]:
        W[a-1] = 0
ans = 0
for i in W:
    ans += i
print(ans)

Measured memory_bytes: 19980
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n, d;
  cin >> n >> d;
  cout << ceil(n/((d*2+1)*1.0)) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  for (int i=0;i<N;i++){
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  int64_t ans=1;
  if (N%2==0){
    for (int i=0;i<N/2;i++){
      if (v[2*i]==2*i+1&&v[2*i+1]==2*i+1){
        ans=ans*2%1000000007;
      }
      else {
        ans=0;
        break;
      }
    }
  }
  else {
    if (v[0]!=0){
      ans=0;
    }
    else {
      for (int i=1;i<(N+1)/2;i++){
        if (v[2*i-1]==2*i&&v[2*i]==2*i){
          ans=ans*2%1000000007;
        }
        else {
          ans=0;
          break;
        }
      }
    }
  }
  cout << ans << endl;
}
    

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int N, M;
	int h, m;
	cin >> N;
	int *A;
	A = new int[N];
	for (int i = 0; i < N; i++){
		cin >> h >> m;
		A[i] = h * 60 + m;
	}

	cin >> M;
	int *B;
	B = new int[M];
	for (int i = 0; i < M; i++){
		cin >> h >> m;
		B[i] = h * 60 + m;
	}

	int *C;
	C = new int[N + M];
	for (int i = 0; i < N; i++){
		C[i] = A[i];
	}
	int cnt = 0;
	for (int i = N; i < N+M; i++){
		C[i] = B[cnt++];
	}

	sort(C, C + N + M);
	for (int i = 0; i < N + M; i++){
		if (C[i] != C[i+1]){
			if (C[i] % 60 < 10){
				cout <<  C[i] / 60 << ":0" << C[i] % 60;
			}
			else{
				cout << C[i] / 60 << ':' << C[i] % 60;
			}

			if (i != N + M - 1){
				cout << ' ';
			}
		}
	}
	cout << endl;

	delete[]A;
	delete[]B;
	delete[]C;
	return 0;
}

Measured memory_bytes: 1216
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import bisect
import sys
import logging
import heapq
logging.basicConfig(level=logging.DEBUG)

input = sys.stdin.readline

setrecursionlimit(1000000)

def main():
    N,M=[int(x) for x in input().split()]
    A=[-int(x) for x in input().split()]

    heapq.heapify(A)
    for _ in range(M):
        a = -heapq.heappop(A) // 2 # 最小値取得
        heapq.heappush(A, -a)
    
    print(-sum(A))

main()

Measured memory_bytes: 98972
// AOJ ITP 1_5_B
#include<cstdio>
#define rep(i,a) for( int i = 0; i != (a); ++i )

int H, W;

int main()
{
	while( scanf( "%d%d", &H, &W ), H|W )
	{
		rep( i, W )
			putchar('#');
		puts("");
		rep( t, H-2 )
		{
			putchar('#');
			rep( i, W-2 )
				putchar('.');
			putchar('#');
			puts("");
		}
		rep( i, W )
			putchar('#');
		puts(""); puts("");
	}

	return 0;
}

Measured memory_bytes: 1016