akhauriyash/Code-Regression huggingface dataset:
r,c,k = map(int,input().split())
v = [[0]*(c+1) for i in range(r+1)]
for i in range(k):
  x,y,z = map(int,input().split())
  v[x][y] = z
dp = [[0]*4 for i in range(r+1)]
for i in range(1,c+1):
  for j in range(1,r+1):
    if v[j][i]>0:
      dp[j][3] = max(dp[j][2]+v[j][i],dp[j][3])
      dp[j][2] = max(dp[j][1]+v[j][i],dp[j][2])
      dp[j][1] = max(dp[j][0]+v[j][i],dp[j][1],max(dp[j-1])+v[j][i])
    dp[j][0] = max(dp[j][0],max(dp[j-1]))
print(max(dp[r]))

Measured memory_bytes: 141260
package main

import (
	"fmt"
	"io"
	"os"
)

func answer(reader io.Reader, writer io.Writer) {
	var n, k int
	var in string
	fmt.Fscan(reader, &n, &k)
	fmt.Fscan(reader, &in)
	a := make([]int, n+2)
	a[0] = 0
	last := "1"
	ind := 0
	//fmt.Printf("%d, %d, %s\n", n, k, in)
	for i := 0; i < n; i++ {
		c := string(in[i])
		if c != "0" && c != "1" {
			break
		}
		if last != c {
			ind++
			a[ind] = 0
			last = c
		}
		a[ind]++
	}
	//fmt.Printf("%v\n", a)
	sum := 0
	max := 0
	for i := 0; i < n+2; i++ {
		sum += a[i]
		if i > k*2 {
			sum -= a[i-k*2-1]
		}
		if i%2 == 0 && max < sum {
			max = sum
		}
		//fmt.Printf("i: %v, sum: %v, max: %v\n", i, sum, max)
	}
	_, _ = fmt.Fprintf(writer, "%d\n", max)
}

func main() {
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 2432
using System;
using System.Collections.Generic;
using System.Linq;
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Long() + add;
        }
        return Array;
    }
}
class Program {
    static Scanner cin = new Scanner();
    static void Main() {
        int a = cin.Int();
        int b = cin.Int();
        if (a + b == 15) Console.WriteLine("+");
        else if (a * b == 15) Console.WriteLine("*");
        else Console.WriteLine("x");
        Console.ReadLine();
    }
}

Measured memory_bytes: 13140
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int h, w, k; cin >> h >> w >> k;
	vector<string> v(h); for (int i = 0; i <= h - 1; i++) cin >> v[i];

	int ans = 0;
	for (int rwc = 0; rwc <= ((1 << h) - 1); rwc++) {
		for (int clc = 0; clc <= ((1 << w) - 1); clc++) {

			int cnt = 0;
			for (int i = 0; i <= h - 1; i++) {
				for (int j = 0; j <= w - 1; j++) {
					if ((rwc & (1 << i)) != 0 or (clc & (1 << j)) != 0) continue;
					if (v[i][j] == '#') cnt++;
				}
			}

			if (cnt == k) ans++;
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[200010];
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	ll ans=0;
	for(int i=n-1;i>=1;i--){
		if(a[i]>a[i-1]+1){
			cout << -1;
			return 0;
		}
		if(a[i]==a[i-1]+1){
			ans++;
		}
		else{
			ans+=a[i];
		}
	}
	if(a[0]!=0){
		cout <<-1;
		return 0;
	}
	cout << ans;
	// your code goes here
	return 0;
}

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

int main(){
  ll N; cin >> N;
  ll ans = 0, sqs = 0;
  for(ll i = 0; i < N; i++){
    ll a; cin >> a;
    ans += a;
    sqs += a*a;
  }
  ans = ans * ans;
  cout << (ans - sqs) / 2 << endl;
}

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

int main() {
    int N; cin >> N;
    vector<pair<int, int>> A(N); //first Ai; second number
    for (int i = 0; i < N; i++) {
        A.at(i).second = i + 1;
        cin >> A.at(i).first;
    }
    sort(A.begin(), A.end());
    for (int i = 0; i < N; i++) {
        if (i < N - 1) {
            cout << A.at(i).second << " ";
        }
        else {
            cout << A.at(i).second << endl;
        }
    }
}

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

int main() {
  vector<int64_t> L(87);
  int64_t N;
  cin >> N;
  L.at(0) = 2;
  L.at(1) = 1;
  for (int i=2; i<N+1; i++){
    L.at(i) = L.at(i-1) + L.at(i-2);
  }
  
  cout << L.at(N) <<endl;
}


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var n int
  fmt.Scan(&n)
  ws := make([]string, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&ws[i])
  }
  result := "Yes"
  next := ws[0][0]
  wMap := make(map[string]bool)
  for _, w := range ws {
    if wMap[w] || next != w[0] {
      result = "No"
      break
    }
    wMap[w] = true
    next = w[len(w)-1]
  }
  fmt.Println(result)
}

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

int main() {
	ios_base::sync_with_stdio( false );

	int N;
	cin >> N;

	vector<int> A( N );
	for( auto& v: A ) { cin >> v; }

	int all = 1;
	int odd = 1;

	for( int i = 0; i < N; ++i ) {
		all *= 3;
		odd *= (A[i] % 2 == 0 ? 2 : 1);
	}

	cout << all - odd << endl;

	return 0;
}


Measured memory_bytes: 256
H,W=map(int,input().split())

S=list(map(int,input().split()))
G=list(map(int,input().split()))
S[0]+=1
S[1]+=1
G[0]+=1
G[1]+=1

L=[]
l=[-1 for i in range(W+4)]
L.append(l)
L.append(l)
for i in range(H):
    s=list(input())
    for j in range(W):
        if s[j]=="#":
            s[j]=-1
        else:
            s[j]=10**12
    L.append([-1,-1]+s+[-1,-1])
L.append(l)
L.append(l)
#L[S[0]][S[1]]=0
#(L)
X=[1,-1,0,0]
Y=[0,0,1,-1]
F=0
Q=[[S[0],S[1]]]

for x in range(10**6):
    if len(Q)==0:
        break
    for i in range(10**7):
        if i==len(Q):
            break
        H,W=Q[i]
        #print(H,W)
        if L[H][W]==10**12:
            L[H][W]=x
            for xy in range(4):
                if L[H+X[xy]][W+Y[xy]]==10**12:
                    Q.append([H+X[xy],W+Y[xy]])
    q={}
    for i in range(len(Q)):
        H,W=Q[i]
        for h in range(-2,3):
            for w in range(-2,3):
                if L[H+h][W+w]==10**12:
                    q[(H+h,W+w)]=1
    #print(q)
    Q=list(q.keys())
    #print(Q)
if L[G[0]][G[1]]==10**12:
    print(-1)
else:
    print(L[G[0]][G[1]])

Measured memory_bytes: 114156
#include<stdio.h>
int main(void)
{
  int r,c;
  int rc[101][101]={{0}};
  scanf("%d %d",&r,&c);
  for(int i=0;i<r;i++){
    for(int j=0;j<c;j++){
      scanf("%d ",&rc[i][j]);
      rc[i][c]+=rc[i][j];
      rc[r][j]+=rc[i][j];
      rc[r][c]+=rc[i][j];
    }
  }
  for(int i=0;i<=r;i++){
    for(int j=0;j<=c;j++){
        printf("%d",rc[i][j]); 
      if(j!=c){
        printf(" ");
      }
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2104
//赤とんぼ
#include <stdio.h>

int main() {
  int x1,x2;
	scanf("%d %d",&x1,&x2);
  if(x1>x2) {
  printf("%d\n",x1-x2);
  }
  else{ 
  printf("%d\n",x2-x1);
  }
  return 0;
}



Measured memory_bytes: 2124
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define str string
#define mask vector<bool>
#define vs vector<str>
#define pq priority_queue
#define ordered_set_of(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define nub(x) x.resize(unique(all(x)) - x.begin())
#define TWO class T1, class T2
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define MOD 998244353LL
#define MAXN (int)2E5
#define GAME_OVER return 0
using namespace std;
using namespace __gnu_pbds;
char _$ = ' ';
struct sep {sep(char c) {_$ = c;}};
ostream& operator<<(ostream& o, sep s) {return o;}
template<TWO> ostream& operator<<(ostream& o, pair<T1, T2> x) {return o << x.fi << ' ' << x.se;}
template<TWO> istream& operator>>(istream& i, pair<T1, T2>& x) {return i >> x.fi >> x.se;}
template<class T> ostream& operator<<(ostream& o, vector<T> x) {for (auto it : x) o << it << _$; return o;}
template<class T> istream& operator>>(istream& i, vector<T>& x) {for (auto& it : x) i >> it; return i;}
vi fac(MAXN + 1);
int add(int a, int b)
{
    return (a + b) % MOD;
}
int mul(int a, int b)
{
    return a * b % MOD;
}
int binpow(int a, int b)
{
    int res = 1;
    while (b)
    {
        if (b % 2)
            res = mul(res, a);
        a = mul(a, a);
        b /= 2;
    }
    return res;
}
int inv(int a)
{
    return binpow(a, MOD - 2);
}
int divide(int a, int b)
{
    return mul(a, inv(b));
}
int cnk(int n, int k)
{
    return divide(fac[n], mul(fac[k], fac[n - k]));
}
void precalc()
{
    fac[0] = 1;
    for (int i = 1; i < sz(fac); i++)
        fac[i] = mul(fac[i - 1], i);
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    precalc();
    int n, m, k;
    cin >> n >> m >> k;
    int res = 0;
    for (int i = 0; i <= k; i++)
        res = add(res, mul(cnk(n - 1, i), mul(m, binpow(m - 1, n - 1 - i))));
    cout << res << endl;
    GAME_OVER;
}

Measured memory_bytes: 4732
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n = sc.next()

    println(n.toVector.last.toString match {
      case "2" | "4" | "5" | "7" | "9" => "hon"
      case "0" | "1" | "6" | "8" => "pon"
      case _ => "bon"
    })

  }
}


Measured memory_bytes: 55476
class Dice:
    
    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
        
    def setNumber(self, n0, n1, n2, n3, n4, n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5

    def roll(self, dir):
        for i in range(6):
            self.work[i] = self.number[i]
        if dir == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif dir == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif dir == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif dir == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])

    def top(self):
        return self.number[0]
        
dice = Dice()
table = list(map(int, input().split()))
dice.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])

dirction = input()
for d in dirction:
    dice.roll(d)
print("%d" %dice.top())



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

int main() {
int ax,ao,po;
cin>>ax>>ao>>po;
if(ao>=po){
  cout<<ao+po<<endl;
  return 0;
}

long ans=0;
ans += ao*2;
po -=ao;

if(ax>=po){
  cout<<ans+po<<endl;
  return 0;
}

cout<<ans+ax+1<<endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////


int main() {

	ll N;
	cin >> N;

	vector<ll> A(N + 1,0);
	repn(i, N) cin >> A[i];

	sort(++A.begin(), A.end());

	vector<ll> B(1);
	vector<ll> C(1);
	ll M = 0;

	repn(i, N) {
		if (A[i] != A[i - 1]) {
			M++;
			C.push_back(A[i]);
			B.push_back(1);
		}

		else { B[M]++; }
	}

	ll ans = 0;

	for (ll i = M; i > 0; i--) {
		ll p = 1;

		while (p <= C[i]) {
			p *= 2;
		}

		ll X = p - C[i];
		auto itr = lower_bound(++C.begin(), C.end(), X);
		ll j = distance(C.begin(), itr);

		if (C[j] != X) { continue; }

		if (i == j) { ans += B[i] / 2; }
		if (j < i) { ans += min(B[i], B[j]); B[j] -= min(B[i], B[j]); }
		
	}

	cout << ans;

	system("PAUSE");

}





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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)

const char sp = ' ';
const char cmm = ',';
const int MOD = 1000000007;

using ll = long long;

ll mod(ll a, ll b){return (a%b+b)%b;}
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);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int dp[101][100001];
int main(){

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

    int n;
    cin >> n;

    int W;
    cin >> W;

    vector<int> w(n+1), v(n+1);

    w[0] = 0; v[0] = 0;
    rep(i, n){
        cin >> w[i+1] >> v[i+1];
    }

    fill_n(*dp, 101*100001, 1000000007);

    dp[0][0] = 0;
    for(int i = 1; i <= n; ++i){
        for(int j = 0; j <= 100000; ++j){
            if(j-v[i] >= 0) dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]]+w[i]);
            else dp[i][j] = dp[i-1][j];
        }
    }
    int ans = 100000;
    while(dp[n][ans] > W) --ans;
    ppp(ans);

    return 0;
}


Measured memory_bytes: 39808
package main

import "fmt"

func main() {
    var h, w int

    for {
        fmt.Scanf("%d %d", &h, &w)
        if h == 0 && w == 0 {
            break
        }

        for i:=0; i<h; i++ {
            for j:=0; j<w; j++ {
                if i>0 && i<h-1 && j>0 && j<w-1 {
                    fmt.Print(".")
                } else {
                    fmt.Print("#")
                }
            }
            fmt.Println("")
        }
        fmt.Println("")
    }
}


Measured memory_bytes: 1120
#include <stdio.h>
char a[10];
int main() {
	scanf(" %s", a);
	if (a[0] == 'S' && a[1] == 'U')printf("7\n");
	if (a[0] == 'M' && a[1] == 'O')printf("6\n");
	if (a[0] == 'T' && a[1] == 'U')printf("5\n");
	if (a[0] == 'W' && a[1] == 'E')printf("4\n");
	if (a[0] == 'T' && a[1] == 'H')printf("3\n");
	if (a[0] == 'F' && a[1] == 'R')printf("2\n");
	if (a[0] == 'S' && a[1] == 'A')printf("1\n");
}

Measured memory_bytes: 128
N, S = map(int,input().split())
A = list(map(int,input().split()))
mod = 998244353
dp = [[0 for j in range(S + 1)] for i in range(N + 1)]
dp[0][0] = 1
for i in range(N) : 
    for j in range(S + 1) : 
        dp[i + 1][j] += 2 * dp[i][j]
        dp[i + 1][j] %= mod 
        if j + A[i] <= S : 
            dp[i + 1][j + A[i]] += dp[i][j]
            dp[i + 1][j + A[i]] %= mod
print(dp[N][S])

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

using namespace std;

#define ios         ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll          long long
#define cn          37
#define sn          2007
#define bn          1000007
#define M           100000007
#define inf         LLONG_MAX

ll f[bn];
bool f2[bn];

int main()
{
        ios;
        ll n,m = 0; cin >> n;
        for(ll i = 1; i <= n; i++)
        {
                ll x; cin >> x; f[x]++;
                m = max(m,x);
        }
        bool a1 = 1,a2 = 1;
        for(ll i = 2; i <= m; i++)
        {
                ll c = 0;
                for(ll j = i; j <= m; j += i)
                {
                        c += f[j];
                        f2[j] = 1;
                }
                if(c > 1) a1 = 0;
                if(c == n) a2 = 0;
        }
        if(a1) cout << "pairwise coprime";
        else if(a2) cout << "setwise coprime";
        else cout << "not coprime";
}




Measured memory_bytes: 12424
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,M; cin >> N >> M;
  vector<int> to[1000000];
  vector<bool> visited(1000000,false);
  // 0 ~ 1e5番台が人を、 1e5 + 1 ~ 2e5番代を言語が有するものとする
  for(int i = 0; i < N; i++){
    int k; cin >> k;
    for(int j = 0; j < k; j++){ int l; cin >> l; to[i].push_back(l+100000);
                               to[l+100000].push_back(i);}
    //人から言語に、言語から人に二部グラフを張る（解説準拠）
  }
  
  queue<int> Q; Q.push(0); visited[0] = true;
  
  //BFSで0から全部の人に訪れることができるか調べる
  while(!Q.empty()){
    int p = Q.front(); Q.pop();
    for(int i = 0; i < (int)to[p].size(); i++){
      int q = to[p][i];
      if(visited[q]){ continue;}
      Q.push(q); visited[q] = true;}
  }

for(int i = 0; i < N; i++){
 if(!visited[i]){cout << "NO" <<endl; return 0;}
}
cout << "YES" << endl; return 0;}
  
  

Measured memory_bytes: 27768
#include<iostream>
#include<string>
#include<ctime>
#include<algorithm>
using namespace std;
#pragma warning(disable:4996)
#define JUDGETIME 1500000
#define DIVIDES_MAX 14
#define LLL 40
#define RRR 122
string S, T, U; char d; int t;
int F[DIVIDES_MAX] = { 10,32,41,57,73,89,105,121 };
int GG[DIVIDES_MAX] = { 10,32,33,49,65,81,97,113 };
int GG2[DIVIDES_MAX] = { 10,32,33,49,65,81,97,113 };
inline string solve(int DIVIDES, int TIMES) {
	U = ""; t = clock();
	while (clock() - t < TIMES) {
		while (true) {
			int DD = LLL; int HH = 2 * (RRR - LLL) / (DIVIDES - 3);
			for (int j = 2; j < DIVIDES; j++) { F[j] = DD; DD += rand() % HH + 1; }
			if (F[DIVIDES - 1] >= RRR - 3 && F[DIVIDES - 1] <= RRR)break;
		}
		int bit3[DIVIDES_MAX], bit5[DIVIDES_MAX], bit6[DIVIDES_MAX]; bool bit4[DIVIDES_MAX];
		for (int i = 0; i < DIVIDES_MAX; i++)bit4[i] = false;
		for (int i = 0; i < DIVIDES; i++) {
			while (true) { int D = rand() % DIVIDES; if (bit4[D] == false) { bit4[D] = true; bit3[i] = D; break; } }
		}
		for (int i = 0; i < DIVIDES; i++)bit6[bit3[i]] = i;
		for (int i = 0; i < DIVIDES; i++)bit5[i] = F[i];
		for (int j = 3; j < DIVIDES; j++)GG[bit3[j]] = (F[j - 1] + F[j]) / 2; GG[bit3[0]] = 10; GG[bit3[1]] = 32; GG[bit3[2]] = 33;
		for (int j = 0; j < DIVIDES; j++) {
			int bit7 = 128; for (int k = 0; k < DIVIDES; k++)if (GG[j] < GG[k] && bit7 > GG[k]) { bit7 = GG[k]; }GG2[j] = bit7 - 1;
		}
		for (int i = 0; i < DIVIDES; i++) { for (int j = 0; j < DIVIDES; j++) { if (GG[i] <= bit5[j] && GG2[i] >= bit5[j])F[i] = bit5[j]; } }
		for (int i = 0; i < DIVIDES; i++) { for (int j = 0; j < F[i]; j++)T += "+"; T += ">"; }
		for (int j = 0; j < DIVIDES; j++)T += "<"; int C = 0;
		for (int i = 0; i < S.size(); i++) {
			int D = DIVIDES - 1; for (int j = 0; j < DIVIDES - 1; j++) { if (GG[j] <= (int)S[i] && GG2[j] >= (int)S[i])D = j; }int G = D - C;
			if (G > 0) { for (int i = 0; i < G; i++)T += ">"; }
			if (G < 0) { for (int i = 0; i < -G; i++)T += "<"; }
			int E = (int)(S[i]) - (int)(F[D]);
			if (E > 0) { for (int i = 0; i < E; i++)T += "+"; }
			if (E < 0) { for (int i = 0; i<-E; i++)T += "-"; }
			T += "."; F[D] = (int)S[i]; C = D;
		}
		if (U == "")U = T; if (U.size()>T.size())U = T; T = ""; F[0] = 10; F[1] = 32;
	}
	return U;
}
int main() {
	t = clock(); srand((unsigned)time(NULL));
	cin >> S;//while (~scanf("%c", &d))S += d;
	int DIVIDES = 0; int maxn = 1000000000;
	for (int i = 6; i < DIVIDES_MAX; i++) {
		string A1 = solve(i, JUDGETIME / 20);
		if (A1.size() < maxn) { DIVIDES = i; maxn = A1.size(); }
	}
	string UU = solve(DIVIDES, JUDGETIME*(26 - DIVIDES_MAX) / 20);
	cout << UU << endl;
	return 0;
}

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

int main() {

int n,m;
cin>>n>>m;
vector<int> high(n);
for(int i=0;i<n;i++){
    cin>>high[i];
}
vector<int> vec(n,0);
for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    int x,y;
    x=high[a-1];
    y=high[b-1];
    if(x<y){
        vec[a-1]++;
    }
    else if(x==y){
        vec[a-1]++;
        vec[b-1]++;
    }
    else{
        vec[b-1]++;
    }
}
int count=0;
for(int i=0;i<n;i++){
   if(vec[i]==0){
       count++;
   }
}
cout<<count<<endl;

}


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

int main() {
	int n;
	cin >> n;
	int temp = n%10;
	
	if(temp == 3)
	{
	    cout << "bon" << endl;
	}
	else if(temp == 0 || temp == 1 || temp == 6 || temp == 8)
	cout << "pon" << endl;
	else cout << "hon" << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    int L, R;
    cin >> L >> R;

    if (R - L > 3000)
    {
        cout << 0 << endl;
        return (0);
    }

    // (i * j) mod 2019
    // (i mod 2019) * (j mod 2019)

    ll num;
    ll mn = LINF;
    for (ll i = L; i <= R - 1; i++)
    {
        for (ll j = i + 1; j <= R; j++)
        {
            num = (i * j) % 2019;
            mn = min(mn, num);
        }
    }
    printf("%d\n", mn);
    return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;


int main(){
  char s;
  cin >> s;
  int  t;
  t = (int)s + 1;
  cout << (char)t << endl;


  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    string s; cin >> s;
    int res = 700;

    for (int i = 0; i < 3; i++) {
        if(s[i] == 'o') {
            res += 100;
        } 
    }
    
    cout << res << endl;
    return 0;
}



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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll n;
    cin >> n;
    
    ll m = sqrt(n);
    ll ans = 1e12;
    
    for(ll i = 1; i <= m; i++){
        if(n % i == 0){
            ans = min(ans,i+n/i-2);
        }
    }
    cout << ans << endl;
}


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

namespace ConsoleApp11
{
    class Class39
    {
        static void Main()
        {
            var I = Console.ReadLine().Split().Select(int.Parse).ToArray();
            
            int count = 0;
            
            while (!(I[0] == I[1] & I[1] == I[2]))
            {
                var max = Math.Max(I[0], Math.Max(I[1], I[2]));
                int notmax = I.Count(x => x < max);
                if (notmax > 1)
                {
                    I = I.Select(x => x < max ? x + 1 : x).ToArray();
                    count += 1;
                }
                else
                {
                    I = I.Select(x => x < max ? x + 2 : x).ToArray();
                    count += 1;
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ins insert
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define up_b upper_bound
#define low_b lower_bound
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=b;i>=a;i--)
#define boost ios_base::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL)
#define nl '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<pii> vii;

const int N=1e6+1;
const int MXN=1501;
const ll mod=1e9+7;

ll f[N];

ll bp(ll a,ll b){
  if(b==0)return 1;
  if(b%2)return (bp(a,b-1)*a)%mod;
  else{
    ll c=bp(a,b/2);
    return (c*c)%mod;
  }
}

ll inverse(ll a){
  return bp(a,mod-2);
}

ll c(int n,int k){
  return ((f[n]*inverse(f[k]))%mod*inverse(f[n-k]))%mod;
}

int main(){
  int x,y;
  cin>>x>>y;
  ll ans=0;
  f[0]=1;
  for(int i=1;i<=x;i++){
    f[i]=(f[i-1]*i)%mod;
  }

  for(int i=0;i<=x;i++){
    int v=x-i;
    if(v%2)continue;
    if(y!=i*2+v/2)continue;
    ans+=c(i+v/2,i);
    ans%=mod;
  }
  cout<<ans;
}


Measured memory_bytes: 8064
local q, h, s, d = io.read("*n", "*n", "*n", "*n")
local n = io.read("*n")
s = math.min(s, q * 4)
s = math.min(s, h * 2)
if s * 2 < d then
  print(s * n)
else
  print((n // 2) * d + n % 2 * s)
end


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
 
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}



signed main()
{
	IOS();
	int N;
	cin>>N;
	cout<<180*(N-2)<<endl;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    string s;
    cin >> s;
    bool flag = 0;
    int l = s.size();
    if (s.size() % 2 == 1)
        l--;
    while (!flag)
    {
        l -= 2;
        rep(i, l / 2)
        {
            if (s[i] != s[l / 2 + i])
                break;
            if (i == l / 2 - 1)
                flag = 1;
        }
    }
    OP(l);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>
#include <iomanip>
#include <functional>
#include <array>
#include <memory>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#undef NDEBUG
#include <assert.h>

using namespace std;
typedef long long ll;

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

	int n, k;
	cin >> n >> k;
	cout << (n + k - 1) / k - n / k << '\n';

	return 0;
}

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

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

    int arr[n];
    bool flag[n];

    rep(i, n)
    {
        cin >> arr[i];
        flag[i] = true;
    }

    int j = 0;
    int cnt = 1;
    while (flag[j] && arr[j] != 2)
    {
        cnt++;
        flag[j] = false;
        j = arr[j] - 1;
    }
    if (arr[j] == 2)
    {
        cout << cnt << endl;
        return (0);
    }

    cout << -1 << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

using lint = long long;
using ldouble = long double;

template <class T>
T sq(T x) { return x * x; }

struct Ball {
    ldouble x, y, z, r;
};

ldouble dist(Ball a, Ball b) {
    return sqrtl(sq(a.x - b.x) + sq(a.y - b.y) + sq(a.z - b.z)) - (a.r + b.r);
}

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n) {
        iota(par.begin(), par.end(), 0);
    }

    int find(int v) {
        return par[v] == v ? v : par[v] = find(par[v]);
    }

    void unite(int u, int v) {
        u = find(u), v = find(v);
        par[v] = u;
    }

    bool same(int u, int v) {
        return find(u) == find(v);
    }
};

bool solve() {
    int n;
    cin >> n;
    if (n == 0) return false;

    vector<Ball> balls(n);
    for (auto& b : balls) {
        cin >> b.x >> b.y >> b.z >> b.r;
    }

    vector<tuple<ldouble, int, int>> edges;
    for (int u = 0; u < n; ++u) {
        for (int v = u + 1; v < n; ++v) {
            ldouble l = max(0.0L, dist(balls[u], balls[v]));
            edges.emplace_back(l, u, v);
        }
    }

    sort(edges.begin(), edges.end());
    for (auto t : edges) {
        ldouble l;
        int u, v;
        tie(l, u, v) = t;
    }

    UnionFind uf(n);
    ldouble ans = 0;
    for (auto t : edges) {
        ldouble l;
        int u, v;
        tie(l, u, v) = t;
        if (uf.same(u, v)) continue;

        ans += l;
        uf.unite(u, v);
    }

    cout << fixed << setprecision(3) << ans << endl;
    return true;
}

int main() {
    while (solve()) {}
    return 0;
}



Measured memory_bytes: 3524
#include<bits/stdc++.h>
using namespace std;
char c[20][20];
int visited[20][20];

int main()
{
	int H,W;
	cin>>H>>W;
	
	int i,flag=1;
	
	for (i=0;i<H;i++)
	scanf("%s",c[i]);
	
	int posx=0,posy=0;
	visited[0][0]=1;
	
	while(posx!=(H-1) || posy!=(W-1))
	{
		if(c[posx+1][posy]=='#' && c[posx][posy+1]!='#')
		{
			
			visited[posx+1][posy]=1;
			posx++;
			continue;
		}
		
		if(c[posx][posy+1]=='#' && c[posx+1][posy]!='#')
		{
		
			visited[posx][posy+1]=1;
				posy++;
		}
		
		else 
		{
			flag=0;
			break;
		}
		
	}
	
	int j;
	for (i=0;i<H;i++)
	{
		for (j=0;j<W;j++)
		{
			//	cout<<visited[i][j]<<" ";
			if(c[i][j]=='#' && visited[i][j]==0)
			{
				if(i==H-1 && j==W-1)
				continue;
				
			
				else
				flag=0;
				//break;
			}
			
		}
		//cout<<endl;
	}
	
	if(flag)
	cout<<"Possible";
	
	else cout<<"Impossible";
	
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(){
  int n,m,c;
  scanf("%d %d %d\n",&n,&m,&c);
  int *b = (int*)calloc(m,sizeof(int));
  char buff[1000];
  fgets(buff, 1000 ,stdin);
  b[0] = atoi(strtok(buff, " "));
  	  for(int i = 1; i < m; ++i)
  		  b[i] = atoi(strtok(NULL, " "));
  int **a = (int**)calloc(n,sizeof(int*));
  a[0] = (int*)calloc(m*n,sizeof(int));
  for (int i = 0; i < n; ++i)
	  a[i] = a[0]+ i * m;
  for(int i = 0; i < n; ++i){
	  fgets(buff, 1000 ,stdin);
	  a[i][0] = atoi(strtok(buff, " "));
	  for(int j = 1; j < m; ++j)
		  a[i][j] = atoi(strtok(NULL, " "));
  }
  int check;
  int answer = 0;
  for(int i = 0; i < n; ++i){
  	  check = 0;
  	  for(int j = 0; j < m; ++j)
  		  check += a[i][j] * b[j];
  	  if(check + c > 0)
  		  answer++;
    }
  printf("%d", answer);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define SC scanf
using namespace std;

int a[101];

int main()
{
	int n,ans = 0;
	SC("%d",&n);
	for(int i = 1; i <= 2*n; i++)
		SC("%d",&a[i]);
	sort(a+1,a+2*n+1);
	for(int i = 1; i <= 2*n; i+=2)
		ans += a[i];
	printf("%d",ans);
}

Measured memory_bytes: 256
/*
 *  AUTHOR : _crtlC_crtlV
*/
#include<bits/stdc++.h>
#include<functional>
//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

namespace fastio {

	template <class T> istream &operator>>(istream &os, vector<T> & vec) {
		for (auto &u : vec)os >> u;
		return os;
	}
	template <class T> ostream &operator<<(ostream &os, const vector<T> & vec) {
		for (auto &u : vec)os << u << " ";
		return os;
	}
	template<class T1, class T2> inline istream& operator>>(istream& os, pair<T1, T2>& p) {
		return os >> p.first >> p.second;
	}
	template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
		return os << p.first << " " << p.second;
	}
	template <class T> ostream &operator<<(ostream &os, set<T> & con) {
		for (auto &u : con) os << u << " ";
		return os;
	}
	void re() {}
	template <typename T, typename... args> void re(T& x, args&... tail) {
		cin >> x;
		re(tail...);
	}
	void pr() {}
	template <typename T> void pr(const T& x) {
		cout << x;
	}
	template <typename T, typename... args> void pr(const T& x, const args&... tail) {
		cout << x << " ";
		pr(tail...);
	}
	template <typename... args> void prln(const args&... tail) {
		pr(tail...);
		cout << "\n";
	}
}
using namespace fastio;

typedef long long int ll;
typedef long double ld;

const ll mod = 1e9+7;
const ll mod1 = 998244353;

#define fill(array)  memset(array, 0, sizeof(array))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define sss(array) sort(array, array + n)
#define vvv(vect) sort(vect.begin(),vect.end())

int main()
{
	cin.sync_with_stdio(false);
	cin.exceptions(cin.failbit);
	cin.tie(0);
	int n, m;
  	re(n,m);
  	if(n==m) cout << "Yes\n";
  	else cout << "No\n";
}



Measured memory_bytes: 384
n=gets.chomp.to_i
arr=gets.chomp.split(" ").map(&:to_i)
x1=arr.inject(&:+)-2*arr.each_slice(2).select{|n| n if n.size == 2}.map{|n| n[1]}.inject(&:+)
ans=[x1]
xi = x1
i=0
arr.each do |ai|
  break if i == n-1
  xi2 = 2*ai - xi
  xi = xi2
  ans << xi2
  i+=1
end
puts(ans.join(" "))

Measured memory_bytes: 15732
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int a=gi();
	    //int b=gi();
	    //int c=gi();


String b=String.valueOf(a);
String c=new StringBuffer(b).reverse().toString();
       // System.out.println();
        if (b.equals(c) ) {
        	System.out.print("Yes");
        }else {
            System.out.print("No");
        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
}

Measured memory_bytes: 35580
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}

	ans := 0
	for i, v := range a {
		if (i+1) % 2 == 1 && v % 2 == 1 {
			ans += 1
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1764
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
struct TopologicalSort {
    vector<vector<int>> E; TopologicalSort(int N) { E.resize(N); }
    void add_edge(int a, int b) { E[a].push_back(b); }
    bool visit(int v, vector<int>& order, vector<int>& color) { color[v] = 1;
        for (int u : E[v]) { if (color[u] == 2) continue; if (color[u] == 1) return false;
        if (!visit(u, order, color)) return false; } order.push_back(v); color[v] = 2; return true; }
    bool sort(vector<int> &order) { int n = E.size(); vector<int> color(n);
        for (int u = 0; u < n; u++) if (!color[u] && !visit(u, order, color)) return false;
        reverse(order.begin(), order.end()); return true; } };
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int N, M;
vector<int> E[101010];
int dep[101010];
//---------------------------------------------------------------------------------------------------
int ans[101010];
void _main() {
    cin >> N >> M;

    TopologicalSort ts(N);

    rep(i, 0, N + M - 1) {
        int a, b; cin >> a >> b;
        a--; b--;
        E[a].push_back(b);
        ts.add_edge(a, b);
    }
    
    vector<int> ord;
    ts.sort(ord);

    fore(cu, ord) fore(to, E[cu]) chmax(dep[to], dep[cu] + 1);

    int root = ord[0];
    ans[root] = -1;
    rep(cu, 0, N) fore(to, E[cu]) if (dep[cu] + 1 == dep[to]) ans[to] = cu;

    rep(i, 0, N) printf("%d\n", ans[i] + 1);
}

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

int cmp(const int *a,const int *b){
  return *a-*b;
}
int main(){
  int n,m,x[100000],y[100000],i,j,t,sum=0;
  scanf("%d%d",&n,&m);
  for(i=0;i<m;i++){
    scanf("%d",&x[i]);
  }
  qsort(x,m,sizeof(int),cmp);
  for(i=0;i<m-1;i++){
    y[i]=x[i+1]-x[i];
  }
  qsort(y,m-1,sizeof(int),cmp);
  for(i=0;i<m-n;i++){
    sum+=y[i];
  }
  printf("%d",sum);
}


Measured memory_bytes: 1396
import java.util.*;


public class Main {
    public static void main(String[] args) {
      
      Scanner sc = new Scanner(System.in);
      String line = sc.nextLine();
      String array[] = line.split(" ");
      double T = Integer.parseInt(array[0]);
      double X = Integer.parseInt(array[1]);
      double S;
      S = T / X;
      
      System.out.print(String.valueOf(S));
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int a;
  string s;
  cin >> a >> s;
  if(a>=3200) cout << s << endl;
  else cout << "red" << endl;
}

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int n, a, b, h[100001];

bool check(int x) {
  ll cnt = 0;
  rep(i, n) {
    ll hp = h[i] - x * b;
    if (hp <= 0) continue;
    cnt += hp / a;
    if(hp % a) cnt++;
  }
  return cnt <= x;
}

signed main() {
	cin >> n >> a >> b;
  a -= b;
  rep(i, n) cin >> h[i];
  ll ng = 0, ok = mod;
  while(ng != ok) {
    ll x = (ng + ok) / 2;
    if(check(x)) ok = x;
    else ng = x + 1;
  }
  cout << ok << endl;
	return 0;
}

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

int main()
{
    int n;
    cin>>n;
    map<ll,ll>mp;
    ll x;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        mp[x]++;
    }
    int cnt=0;
    for(auto m : mp)
    {
        if(m.first!=m.second)
        {
            if(m.first>m.second)
                cnt+=m.second;
            else
                cnt+=(m.second-m.first);
        }

    }
    cout<<cnt;
}


Measured memory_bytes: 9532
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL N; cin >> N;
		vector<UL> C(N); rep(i, N) { cin >> C[i]; C[i]--; }
		vector<ULL> dp(N + 1); dp[0] = 1;
		vector<UL> P(N);
		vector<UL> CP; CP.assign(200000, (UL)-1);
		rep(i, N) {
			P[i] = CP[C[i]]; CP[C[i]] = i;
		}
		//rep(i, N) cout << P[i] << " "; cout << endl;
		rep(i, N) {
			dp[i + 1] = dp[i];
			if (P[i] != -1) if (P[i] != i - 1) dp[i + 1] += dp[P[i] + 1];
			dp[i + 1] %= 1000000007;
		}
		//rep(i, N) cout << dp[i] << " ";
		cout << dp[N] << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 4224
function Main(input) {
  console.log((() => {
    const inputs = input.split('\n').map(x => x.split(' ').map(y => parseInt(y)));
    const [[N, D], ...P] = inputs;
    return P.filter(([X, Y]) => D ** 2 >= X ** 2 + Y ** 2).length
  })())
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 100092
s = int(input())
count=1
memoL=[s]

while True:
    if s%2==0:
        s/=2
        count+=1
    else:
        s=3*s+1
        count+=1
    if s in memoL:
        print(count)
        break
    else:
        memoL.append(int(s))

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

vector<int> edges[100000];
int indeg[100000], dp[100000];

int main(){
    int N, M;
    cin >> N >> M;
    for(int i=0; i<M; i++){
        int a, b;
        cin >> a >> b;
        indeg[b-1]++;
        edges[a-1].push_back(b-1);
    }

    queue<int> que;
    for(int i=0; i<N; i++) if(indeg[i] == 0) que.push(i);

    while(que.size()){
        int i = que.front(); que.pop();
        for(int j : edges[i]){
            indeg[j]--;
            if(indeg[j] == 0) que.push(j);
            dp[j] = max(dp[j], dp[i]+1);
        }
    }

    cout << *max_element(dp, dp+N) << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <cstdio>
#include <iostream>
#define LL long long 
using namespace std;
LL num[200005];
int main()
{
    int n;scanf("%d",&n);
    for (int i=0;i<n;i++) scanf("%lld",&num[i]);
    LL tmp=0;
    int l=0,r=0;LL ans=0;
    while(1)
	{
        if(r < n && tmp+num[r] == (tmp^num[r])) tmp+=num[r++];
        else
		{
            if(l>n-1)break;
            tmp -= num[l];
            ans+=(LL)(r-l);
            l++;
        }
    }
    printf("%lld",ans);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
long long n;
const int MAX = 1e5+5;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> p(m),y(m);
    for(int i=0;i<m;i++){
        cin >> p[i] >> y[i];
        p[i]--;
    }

    vector<vector<int>> vals(n);
    for(int i=0;i<m;i++){
        vals[p[i]].push_back(y[i]);
    }

    for(int i=0;i<n;i++){
        sort(vals[i].begin(),vals[i].end());
        vals[i].erase(unique(vals[i].begin(),vals[i].end()),vals[i].end());
    }

    for(int i=0;i<m;i++){
        int v = p[i];
        printf("%06d",v+1);

        int id = lower_bound(vals[v].begin(),vals[v].end(),y[i])-vals[v].begin();
        printf("%06d\n",id+1);
    }
}


Measured memory_bytes: 7808
#include<iostream>
#include<string>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<tuple>
#include<vector>
#include<map>
using namespace std;

static const int MAX_N = 1010;

int main(void){
  //入力
  int N, T, A;
  int H[MAX_N];
  float pos_T[MAX_N];
  cin >> N >> T >> A;
  for(int i = 0; i < N; i++){
    cin >> H[i];
  }
  //各地点の平均気温を計算
  for(int i = 0; i < N; i++){
    pos_T[i] = T - H[i]*0.006;
  }
  //Aに最も近い番号を取得
  float min_T = 9999;
  int ans_num = -1;
  for(int i = 0; i < N; i++){
    float dt_abs = abs(pos_T[i] - A);
    if( dt_abs < min_T ){
      min_T = dt_abs;
      ans_num = i;
    }
  }
  //出力
  cout << ans_num+1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
#include <iomanip>
#include <boost/math/special_functions/factorials.hpp>

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

int N; cin >> N;
vector<pair<double, double>> xy(N); 
rep(i, 0, N) cin >> xy[i].first >> xy[i].second;
sort(ALL(xy));
double sum = 0.;
do {
    rep(i, 0, N-1) {
        sum += hypot(xy[i].first - xy[i+1].first, xy[i].second - xy[i+1].second);
    }
}while(next_permutation(ALL(xy)));

cout << fixed << setprecision(10);
cout << sum/boost::math::factorial<double>(N) << endl;
}

// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256