akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef long long int LLN;

int main(){
    LLN maxn = 100000;
    LLN N = 1;
    while(scanf("%lld", &N) != -1){
        LLN left = 1, right = maxn;

        while(left < right){
            LLN mid = left + (right - left + 1) / 2;

            if(mid * mid <= N){
                left = mid;
            }
            else{
                right = mid - 1;
            }
        }

        printf("%lld\n", left * left );
    }

    return 0;
}

Measured memory_bytes: 128
// finish date: 2018/07/14
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>>
        vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>>
        vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    int N, T;
    cin >> N >> T;
    vi A(N);
    rep(i, N) cin >> A[i];
    int cnt = 0;
    int mi = A[0];
    int space = 0;
    FOR(i, 1, N) {
        if (A[i] < mi) {
            mi = A[i];
        } else {
            if (A[i] - mi > space) {
                space = A[i] - mi;
                cnt = 1;
            } else if (A[i] - mi == space) {
                cnt++;
            }
        }
    }
    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int N;
ll H[5000], A[5000];
ll dp[5005][5005];
P p[5000];
const ll INF = 1e+15;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> H[i] >> A[i];
        p[i] = P(H[i]+A[i], i);
    }
    sort(p, p+N);
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N; j++){
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    for(int i = 1; i <= N; i++){
        int idx = p[i-1].second;
        ll h = H[idx];
        ll a = A[idx];
        for(int j = 0; j <= N; j++){
            dp[i][j] = dp[i-1][j];
        }
        for(int j = 1; j <= N; j++){
            if(dp[i-1][j-1] <= h) dp[i][j] = min(dp[i][j], dp[i-1][j-1]+a);
        }
    }
    int ans = 0;
    for(int i = 1; i <= N; i++){
        if(dp[N][i] != INF) ans = i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 195968
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    unused_imports,
    dead_code
)]
//use proconio::fastout;
use proconio::input;
use proconio::marker::*;
use std::cmp::*;
use std::collections::*;
//use std::collections::VecDeque;

fn main() {
    input! {
       N:usize,
       XYP:[(i64,i64,i64);N]
    }
    // 各鉄道パターンについて、集落からの距離
    let inf = std::i64::MAX;
    let mut dtate = vec![vec![0i64; N]; 2i64.pow(N as u32) as usize];
    let mut dyoko = vec![vec![0i64; N]; 2i64.pow(N as u32) as usize];
    for i in 0..dtate.len() {
        let l: Vec<bool> = format!("{:0>15b}", i).chars().map(|c| c == '1').collect();
        //let sum = l.iter().fold(0, |sum, &a| sum + if a { 1 } else { 0 });

        for j in 0..N {
            dtate[i][j] = XYP[j].0.abs();
            dyoko[i][j] = XYP[j].1.abs();
            for k in 0..N {
                if l[14 - k] {
                    dtate[i][j] = min(dtate[i][j], (XYP[j].0 - XYP[k].0).abs());
                    dyoko[i][j] = min(dyoko[i][j], (XYP[j].1 - XYP[k].1).abs());
                }
            }
            dtate[i][j] *= XYP[j].2;
            dyoko[i][j] *= XYP[j].2;
        }
    }
    let mut ans = vec![std::i64::MAX; N + 1];
    for i in 0..(3usize.pow(N as u32)) {
        // i の j bit目が0なら、j番目の町に路線なし、1なら東西線、2なら南北線とする。
        // iから、dtate[x]とdyoko[y]のxとyを求める。
        let mut x = 0;
        let mut y = 0;
        let mut ii = i;
        let mut n = N;
        for j in 0..N {
            let tmp = ii % 3;
            // 順番がおかしくなるけど、全部合計するので気にしない。
            x *= 2;
            y *= 2;
            match tmp {
                1 => x += 1,
                2 => y += 1,
                _ => n -= 1,
            }
            ii /= 3;
        }
        let mut t = 0;
        for j in 0..N {
            t += min(dtate[x][j], dyoko[y][j]);
        }
        ans[n] = min(ans[n], t);
    }
    for i in 0..=N {
        println!("{}", ans[i]);
    }
}


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

int main()
{
  int n;
  cin>>n;
  string w[n];
  for(int i=0; i<n; i++)
  {
    cin>>w[i];
  }
  bool check=true;
  for(int i=1; i<n; i++)
  {
    if(w[i][0]!=w[i-1][w[i-1].length()-1]) check=false;
    for(int j=0; j<i; j++)
    {
      if(w[i]==w[j])
      {
        check=false;
        break;
      }
    }
    if(!check) break;
  }
  if(check) cout<<"Yes\n";
  else cout<<"No\n";
  return 0;
}

Measured memory_bytes: 256
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy


def main():
	count = 0
	num = int(input())
	strings = input()
	
	for i in range(0,num-2,1):
		if strings[i] == "A" and strings[i+1] == "B" and strings[i+2] == "C":	
			count += 1
	print(count)

if __name__ == '__main__':
	main()


Measured memory_bytes: 68132
import java.io.*;
import java.util.*;


public class Main{ 

	public static void main(String args[]){
		
		Scanner scan = new Scanner(System.in);
		Range rng = new Range(scan.nextInt(),scan.nextInt(),scan.nextInt());
		if(rng.judge())
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

class Range{
	int a,b,c;
	public Range(int x,int y,int z){
		a=x;
		b=y;
		c=z;
	}
	public boolean judge(){
		return a<b && b<c;
	}
	
}

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

int main()
{
	int sum{}, a[5]{};
	for (int i{}; i < 5; i++)
		scanf("%d", a + i);
	std::sort(a, a + 5, [](const auto& a, const auto& b) { return (a + 9) % 10 < (b + 9) % 10; });
	for (int i{1}; i < 5; i++)
		sum += (a[i] + 9) / 10 * 10;
	sum += a[0];
	printf("%d\n", sum);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
    IOS;
 	int n,x,y;
 	cin>>n>>x>>y;
 	int ans[n+1]={0};
 	for(int i=1;i<=n;i++){
 		for(int j=i+1;j<=n;j++){
 			int res=1e9;
 			res=(j-i);
			res=min(res,abs(i-x)+abs(j-y)+(int)1);
			ans[res]++;
 		}
 	}
 	for(int i=1;i<n;i++) cout<<ans[i]<<endl;
}

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

#ifdef LOCAL
#include "../debug.h"
#else
#define debug(x...) 141
#endif
#define forn(i,x,n) for(int i = x; i < n; ++i)
#define forit(it, m) for(auto it = m.begin(); it!=m.end(); ++it)
typedef long long ll;

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

    cin>>n;
    cout<<(n>=30?"Yes":"No")<<'\n';
    
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
using namespace std;
int mark[100001],A[100001];
int main ()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int n,i,j,k,x,y,z,c;
cin>>n;
for(i=1;i<=n;i++)cin>>A[i];
x=1;
c=0;
mark[1]=1;
while(x!=2)
{
c++;
x=A[x];
if(mark[x])break;
mark[x]=1;
}
if(x==2)cout<<c<<endl;
else cout<<-1<<endl;
return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#define inf 0x3f3f3f3f
#define met(a,b) memset(a,b,sizeof a)
#define pb push_back
typedef long long ll;
using namespace std;
const int N = 1e5+5;
const int M = 24005;
int n,m,k;
int a[N];
int main() {
    scanf("%d%d%d",&a[0],&a[1],&a[2]);
    sort(a,a+3);
    if(a[0]==a[1]&&a[2]>a[1])puts("YES");
    else puts("NO");
    return 0;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
A = [0] + A + [0]
s = 0
for i in range(1, n+2):
    s += abs(A[i-1]-A[i])

for i in range(1, n+1):
    s_ = s - abs(A[i-1]-A[i])-abs(A[i]-A[i+1])+abs(A[i-1]-A[i+1])
    print(s_)


Measured memory_bytes: 14044
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1001001001
#define LINF (1LL << 62)
using namespace std;
using ll = long long;
using P = pair<int, int>;

void solv() {
    string s;
    cin >> s;
    int n = s.size();
    int g = 0, p = 0, point = 0;
    rep(i, n) {
        if (p < g) {
            if (s[i] == 'g') {
                p++;
                point++;
            } else {
                p++;
            }
        } 
        else {
            if (s[i] == 'g') {
                g++;
            } else {
                g++;
                point--;
            }
        }
    }
    cout << point << endl;
}

int main() {
    solv();
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t; cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	if (abs(a - b) > 1000000000000000000) {
		cout << "Unfair" << endl;
		return 0;
	}
	if (k % 2 == 0) cout << a - b << endl;
	else cout << b - a << endl;
}

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

using namespace std;

int main()
{
	int n;
	
	cin >> n;
	
	if(n<1200)
	{
		cout << "ABC" << endl;
	}
	else if(n<2800)
	{
		cout << "ARC" << endl;
	}
	else if(n<=4208){
		cout << "AGC" << endl;
	}
	
	return 0;
}

	



Measured memory_bytes: 256
def insertion_sort(A, n, g):
    cnt = 0

    for i in range(g, n, 1):
        v = A[i]
        j = i - g

        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt = cnt + 1
        A[j+g] = v

    return cnt

def shell_sort(A, n):
    G = [1]
    j = 1
    while True:
        next_g = G[j-1]*3 + 1
        if next_g < n:
            G.append(next_g)
            j = j + 1
        else:
            break
    # print(G)

    G.reverse()
    print(len(G))
    G_str = map(str, G)
    print(' '.join(G_str))

    cnt = 0
    for g in G:
        cnt = cnt + insertion_sort(A, n, g)

    print(cnt)


N = int(input())
A = []
cnt = 0
# print(N)
for i in range(N):
    A.append(int(input()))
# print(N, A)

shell_sort(A, N)

for a in A:
    print(a)




Measured memory_bytes: 45516
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  string s,t;
  cin >> s >> t;
  vector<vector<int>> dp(s.size()+1,vector<int>(t.size()+1));
  vector<vector<pair<int,int>>> fr(s.size()+1,vector<pair<int,int>>(t.size()+1,make_pair(0,0)));

  for(int i=1;i<=s.size();i++){
    for(int j=1;j<=t.size();j++){
      if(s[i-1]==t[j-1]){
        dp[i][j]=dp[i-1][j-1]+1;
        fr[i][j].first=i-1; fr[i][j].second=j-1;
      }else{
        if(dp[i][j-1]<dp[i-1][j]){
          dp[i][j]=dp[i-1][j];
          fr[i][j].first=i-1; fr[i][j].second=j;
        }else{
          dp[i][j]=dp[i][j-1];
          fr[i][j].first=i; fr[i][j].second=j-1;
        }
      }
      //cout << dp[i][j] << " ";
    }
    //cout << endl;
  }

  pair<int,int> ne=make_pair(s.size(),t.size());
  string res;
  while(ne.first!=0 && ne.second!=0){
    if(s[ne.first-1]==t[ne.second-1]) res+=s[ne.first-1];
    ne=fr[ne.first][ne.second];
  }
  reverse(res.begin(),res.end());
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 105984
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe
    
int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
  int n,m;
  cin >>n>>m;
  cout << (n-1)*(m-1) << endl;
  
  
  
  
    
  
  
    


//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
T1,T2=map(int,input().split())
A1,A2=map(int,input().split())
B1,B2=map(int,input().split())

if A1<B1:
    A1,B1=B1,A1
    A2,B2=B2,A2

if A2>=B2:
    print(0)
else:
    sta=T1*(A1-B1)
    gen=T2*(A2-B2)
    if sta==-gen:
        print("infinity")
    elif sta+gen>0:
        print(0)        
    else:
        ans=sta//abs(sta+gen)*2+1
        if sta%abs(sta+gen)==0:
            ans-=1
        print(ans)

Measured memory_bytes: 80312
#coding:UTF-8
def MCS(A,n):
    B=sorted(A)
    B0=B[0]
    cost=0
    for i in range(n-1):
        Bi,t_cost,count=B[i],0,0
        si=A.index(Bi)
        while si!=i:
            bsi=B[si]
            sj=A.index(bsi)
            A[si],A[sj]=bsi,Bi
            t_cost+=Bi+bsi
            count+=1
            si=sj
        if count:
            cost+=min(t_cost,(Bi + B0) * 2 + t_cost - (Bi - B0) * count) 
    print(cost)
if __name__=="__main__":
    n=int(input())
    A=input().split(" ")
    for i in range(n):
        A[i]=int(A[i])
    MCS(A,n)

Measured memory_bytes: 7780
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vit vector<lint>::iterator
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define graph_set(n) struct edge{int to,int cost;} vector<edge> G((n))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define range(x,y) ((x) >= 0 && (x) < h && (y) >= 0 && (y) < w)
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
typedef vector<long long> vi;
typedef vector<pair<long long, long long>> vp;
typedef vector<vector<long long>> vvi;
typedef pair<long long, long long> pi;
typedef long long lint;
typedef long long ll;
lint qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e14;

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

int main(void) {
	ll n, m; cin >> n >> m;
	vi a(n), c(n + 1, 0LL);

	rep(n) {
		ll x; cin >> x;
		a[i] = x % m;
		c[i + 1] = (c[i] + a[i]) % m;
	}
	
	map<ll, ll> mp;
	mp[0]++;
	rep(n)mp[c[i + 1]]++;
	ll ans = 0;
	for (auto i : mp) {
		ans += (i.second*(i.second-1LL)) / 2LL;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;



//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#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 INF 1000000000000
#define NCK_MAX 510000
#define MOD ll(1e9+7)
#define PB push_back
#define MP make_pair
#define F first
#define S second

ll myPow(ll x, ll n, ll m)
{
    if (n == 0)
        return 1;
    if (n % 2 == 0)
        return myPow(x * x % m, n / 2, m);
    else
        return x * myPow(x, n - 1, m) % m;
}

ll fac[NCK_MAX], finv[NCK_MAX], inv[NCK_MAX], facn[NCK_MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    facn[1] = NCK_MAX;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < NCK_MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        facn[i] = facn[i - 1] * (NCK_MAX - i + 1) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll modinv(ll a, ll mod)
{
    return myPow(a, mod - 2, mod);
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(int argc, char const *argv[]) {
    int n,k;
    cin >> n >> k;

    COMinit();
    ll ans = 0;
    FOR(i,1,k)
    {
        ans = COM(n+1-k,i) * COM(k-1,i-1) % MOD;
        // cout << n+1-k << "C" << i << " = " << COM(n+1-k,i) << endl;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 16128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
const int N=1000050;
char s[N];
int pre[N],suf[N];
int main()
{
	int n,i;
	scanf("%i",&n);
	scanf("%s",s+1);
	for(i=1;i<=n;i++) pre[i]=pre[i-1]+(s[i]=='#');
	for(i=n;i>=1;i--) suf[i]=suf[i+1]+(s[i]=='.');
	int ans=1e9+7;
	for(i=0;i<=n;i++) ans=min(pre[i]+suf[i+1],ans);
	printf("%i\n",ans);
	return 0;
}

Measured memory_bytes: 7168
/**
                 MD.Faysal Hasan
                Comilla Univesity               **/

#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include <stdlib.h>
using namespace std;

#define         rep(i,n)       for ( i=0 ; i<n ; i++ )
#define         rep1(i,n)      for ( i=1 ; i<=n ; i++ )
#define         sajo(str)      sort(str.begin(),str.end())
#define         rev(str)       reverse(str.begin(),str.end())
#define         usajo(str)     sort(str.rbegin(),str.rend())
#define         pi             2*acos(0.0)
#define         nel            printf("\n")
#define         longmx         92233720368547758
#define         gcd(a,b)       __gcd(a,b)
#define         lcm(a,b)       (a/gcd(a,b))*b
#define         yes            cout<<"Yes"<<"\n"
#define         no             cout<<"No"<<"\n"
#define         pb             push_back
#define         prl            pair< ll , ll >
#define         mkp(x,y)       make_pair(x,y)
#define         ff             first
#define         ss             second
#define         Faysal         ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef         long long int  lli;
typedef         long long      ll;

int main(){Faysal

    ll ans,sum,tot,cnt,mx,mn,idx,chk,rem,ret,tmp,mid,lft,rgt,pos;

    ll tc,n,m,a,b,c,d,g,h,l,r,x,y,i,j,k;

    cin>>n;
    vector<ll>v;
    mn=ans=longmx,mx=0;
    rep(i,n)
    {
        cin>>x;
        mx=max(mx,x),mn=min(mn,x);
        v.push_back(x);
    }
    for(i=mn;i<=mx;i++)
    {
        tmp=0;
        rep(j,n)
            {
                tmp+=((i-v[j])*(i-v[j]));
            }
            ans=min(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n,rank;
    char handle;
    cin>>n;
    bool arr[4][13];
    for(int h=0;h<=3;h++){
        for(int r=0;r<=12;r++){
            arr[h][r]=0;
        }
    }
    for(int i=0;i<=n-1;i++){
        cin>>handle>>rank;
        if(handle=='S')arr[0][rank-1]=1;
        if(handle=='H')arr[1][rank-1]=1;
        if(handle=='C')arr[2][rank-1]=1;
        if(handle=='D')arr[3][rank-1]=1;
    }
    for(int h=0;h<=3;h++){
        for(int r=0;r<=12;r++){
            if(arr[h][r]==1)continue;
            if(h==0){
                handle='S';
            }else if(h==1){
                handle='H';
            }else if(h==2){
                handle='C';
            }else{
                handle='D';
            }
            cout<<handle<<" "<<r+1<<endl;
        }
    }
    return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n;cin >> n;
    int a, b;cin >> a >> b;
    int mmin = min(a, b);
    int mmax = 0;
    if(a+b > n){
        mmax = a+b-n;
    }
    cout << mmin << " " << mmax << endl;
    return 0;
}


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

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double N, K;
    cin >> N >> K;
    double cnt = 0;
    double ans = 0;
    for(int i=1;i<=N;i++){
        if(i >= K){
            ans += 1 / N;
            continue;
        }
        int num = i;
        int cnt = 0;
        while(num < K){
            num *= 2;
            cnt++;
        }
        ans += (1 / N) * pow(0.5, cnt);
    }
    printf("%.12lf\n", ans);
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author ExplodingFreeze
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define f(i,a,b) for(int i=(a);i<(b);i++)
const int MOD=1e9+7;
using pii=std::pair<int,int>;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

using namespace std;

int n;
class DHandstand2 {
public:
	void solve(std::istream& in, std::ostream& out) {
		in >> n;
		int cnt[10][10]={0};
		f(i,1,n+1)
			cnt[i%10][firstdig(i)]++;
		int ans=0;
		f(i,1,10)
			f(j,1,10)
				ans+=cnt[i][j]*cnt[j][i];
		out << ans << "\n";
	}
	int firstdig(int x)
	{
		while(x!=x%10)
			x/=10;
		return x;
	}
};


int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	DHandstand2 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	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++)
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;

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

    map<int, int> mp;
    int ai;
    rep(i, N) {
        cin >> ai;
        if (mp.count(ai)) mp[ai]++;
        else mp[ai] = 1;
    }

    ll h = 0, w = 0;
    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
        if (itr->second >= 2) {
            w = max(w, h);
            h = max(h, (ll) (itr->first));
        }
        if (itr->second >= 4) {
            w = max(w, (ll) (itr->first));
            h = max(h, (ll) (itr->first));
        }        
    }

    cout << w * h << endl;

    return 0;
}

Measured memory_bytes: 4992
import itertools
n,m,q = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(q)]
l = []
for i in range(1,m+1):
    l.append(i)
#print(l)
l_list = list(itertools.combinations_with_replacement(l,n))
#print(l_list)

ans = 0
#print(len(l_list))
for i in range(len(l_list)):
    b = 0
    for j in range(q):
        if (l_list[i][a[j][1]-1] - l_list[i][a[j][0]-1] == a[j][2]):
            b += a[j][3]
    #print(b)
    if (ans < b):
        ans = b
print(ans)

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

int main(){
  
  int R,G,B;
  
  cin >> R >> G >> B;
  
  int total = 100 * R + 10 * G + B; //カードを並べた時の数
  
  //total が 4 の倍数だったら YES,そうじゃなかったら NO
  
  if(total % 4 ==0)    cout << "YES" << endl;
  else	cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
int main()
{
    int N, K;
    std::cin >> N >> K;
    std::vector<int> h(N);
    for (int i = 0; i < N; i++) { std::cin >> h[i]; }
    constexpr int INF = 1 << 30;
    std::vector<int> dp(N, INF);
    dp[0] = 0;
    for (int i = 1; i < N; i++) {
        for (int j = i - 1; j >= std::max(i - K, 0); j--) { dp[i] = std::min(dp[i], dp[j] + std::abs(h[i] - h[j])); }
    }
    std::cout << dp[N - 1] << std::endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int ans = 0;
int n;
void dfs(ll x, bool three, bool five, bool seven){
  if(x<=n){
    if(three && five && seven){
      ans++;
    }
  }
  else{
    return;
  }
  dfs(10*x+3, true, five, seven);
  dfs(10*x+5, three, true, seven);
  dfs(10*x+7, three, five, true);
}
int main() {
  cin >> n;
  dfs(0, false, false, false);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
<?php
// Your code here!
// $n,$= explode(" ",trim(fgets(STDIN)));
fscanf(STDIN,"%s",$n);
// if($n[-1])
// echo strlen($n);
// echo $n[strlen($n)-1];
if($n[strlen($n)-1] == "2" || $n[strlen($n)-1] == "4" || $n[strlen($n)-1] == "5" || $n[strlen($n)-1] == "7" || $n[strlen($n)-1] == "9"){
    echo "hon";
}elseif($n[strlen($n)-1] == "0" || $n[strlen($n)-1] == "1" || $n[strlen($n)-1] == "6" || $n[strlen($n)-1] == "8"){
    echo "pon";
}else{
    echo "bon";
}


?>

Measured memory_bytes: 16032
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};


const in N =1000000/*値*/;
void eratosthenes( bool prime[N]){
    rep(i,N) prime[i] = 1;
    prime[0] = prime[1] = 0;
    rep(i,N){
        if(prime[i]){
            for(int j = i + i; j < N; j+=i){
                prime[j] = 0;
            }
        }
    }
}

int main(){
  in n;
  cin>>n;
  bool prime[N];
  vector<pair<in,int>> p;
  eratosthenes(prime);
  rep(i,N){
    if(prime[i]){
      pair<in,int> a;
      a.first=i;
      a.second=0;
      p.push_back(a);
    }
      
  }
  int adi=0;
  int m = p.size();
  //int M=1;
  /*rep(i,m){
    if(p.at(i).first*p.at(i).first>n) break;
    M=i;
  }*/
  
  while(n>1){
    rep(i,m+1){
      
      if(i!=m&&n%p.at(i).first==0){
        //cout<<p.at(i).first;
        
        p.at(i).second++;
        if(p.at(i).first!=0)
         n=n/p.at(i).first;
        break;
      }
      if(i==m){
        adi=1;
        n=1;
        break;
      }
    }
  }
  
  int ans=adi;
  //cout<<ans<<endl;
  
  rep(i,m){
    int b=p.at(i).second;
    if(b==0) continue;
    if(b<3){
      ans+=1;
      continue;
    }
    if(b<6){
      ans+=2;
      continue;
    }
    if(b<10){
      ans+=3;
      continue;
    }
    if(b<15){
      ans+=4;
      continue;
    }
    if(b<21){
      ans+=5;
      continue;
    }
    if(b<28){
      ans+=6;
      continue;
    }
    if(b<36){
      ans+=7;
      continue;
    }
    ans+=8;
    
  }
 
  
  cout<<ans<<endl;
  /*rep(i,50)
    cout<<p.at(i).first<<" ";*/
  //cout<<m<
}

Measured memory_bytes: 6344
import re
A,B = map(int,input().split(" "))
S = list(input())
judge=True
for i in range(len(S)):
    if i == A:
        if S[i] == "-":
            pass
        else:
            judge = False
    else:
        try:
            int(S[i])
        except:
            judge =False
if judge:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3188
#include<stdio.h>

int main(void){
	int N;
	int i;
	int A[100];
	scanf("%d", &N);
	for(i=0;i<N;i++){
		scanf("%d",&A[i]);
	}

	int flag = 1;
	int j;
	int tmp;
	int count=0;
	while (flag){
		flag = 0;
		for(j=N-1;j>0;j--){
			if(A[j]<A[j-1]){
				tmp = A[j];
				A[j] = A[j-1];
				A[j-1] = tmp;
				flag=1;
				count++;
			}
		}
	}
	for(j=0;j<N;j++){
		if(j==N-1){
			printf("%d\n",A[j]);
		}else{
			printf("%d ",A[j]);
		}
	}
	printf("%d\n", count);


	return 0;

}

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

#define X first
#define Y second
#define MP make_pair
#define PB push_back
#define ll long long

using namespace std;

int mat[15][15][15];
int niz[15],niz1[30005],niz2[15];
int rj;
char c;

int main () {
	
	int n;
	cin>>n;
	for(int i=0; i<n; i++){
		cin>> c;
		niz1[i]=c-'0';
		niz[niz1[i]]++;
	}
	niz[niz1[0]]--;
	niz2[niz1[0]]++;
	for(int i=1; i<n-1; i++){
		niz[niz1[i]]--;
		for(int j=0; j<10; j++){
			for(int k=0; k<10; k++){
				if(niz[j]>0 && niz2[k]>0 && mat[k][niz1[i]][j]==0){
					mat[k][niz1[i]][j]=1;
					//cout<<k<<niz1[i]<<j<<endl;
					rj++;
				}
			}
		}
		niz2[niz1[i]]++;
	}
	cout<<rj;
	
	return 0;
}

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

int main(){
	int x, y, z;
  	cin>>x>>y>>z;
  
  	int tmp=x;
  	x=y;
  	y=tmp;
  	
  	tmp=x;
  	x=z;
  	z=tmp;
  	
  	cout<<x<<" "<<y<<" "<<z<<endl;

}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	char X, Y;
	cin >>X >>Y;
	if (X>Y)
		cout <<'>' <<endl;
	else if (X<Y)
		cout <<'<' <<endl;
	else
		cout <<'=' <<endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int A = sc.nextInt();
   int B = sc.nextInt();
   
   int ans =0;
   int tmp10000=0;
   int tmp1000=0;
   int tmp100=0;
   int tmp10=0;
   int tmp1=0;
   int tmp;
   for(int i=A;i<=B;i++) 
   {
     tmp =i;
     tmp1=tmp%10;
     tmp= (tmp-tmp1)/10;
     tmp10=tmp%10;
     tmp= (tmp-tmp10)/10;
     tmp100=tmp%10;
     tmp= (tmp-tmp100)/10;
     tmp1000=tmp%10;
     tmp= (tmp-tmp1000)/10;
     tmp10000=tmp%10;
     
     if(tmp1==tmp10000&&tmp10==tmp1000) ans++;
   } 

   System.out.println(ans);
 }
}

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

using namespace std;

int n,s[50],dp[55][2005],book[55][2005];

int solve(int i,int m)
{
    if(book[i][m]){
        return dp[i][m];
    }
	if(m==0){
        book[i][m]=1;
		dp[i][m]=1;
		return dp[i][m];
	}else if(i>=n){
	    book[i][m]=1;
		dp[i][m]=0;
		return dp[i][m];
	}
	if(solve(i+1,m)){
        book[i][m]=1;
        dp[i][m]=1;
	}else if(solve(i+1,m-s[i])){
	    book[i][m]=1;
        dp[i][m]=1;
    }else{
        book[i][m]=1;
        dp[i][m]=0;
    }
	return dp[i][m];
}

int main()
{
	int q,m;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&s[i]);
	}
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		scanf("%d",&m);
		if(solve(0,m)){
			printf("yes\n");
		}else{
			printf("no\n");
		}
	}
	return 0;
}


Measured memory_bytes: 3452
#include <iostream>
#include<time.h>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include<cassert>
#include<cctype>
#include<iterator>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1<<30
#define INFTY 1000000000000000001LL
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Graph=vector<vector<int> >;//int と P
// g++ -o a a.cpp -Wall -lm -std=c++14
int n,x,y;
int main(){
    cin>>n>>x>>y;
    x--;y--;
    Graph G(n);
    G[x].push_back(y);
    G[y].push_back(x);
    rep(i,n-1){
        G[i].push_back(i+1);
        G[i+1].push_back(i);
    }
    queue<int> q;
    int path[n+1][n+1];
    memset(path,-1,sizeof(path));
    for(int i=0;i<n;i++){
            queue<int> q;
            q.push(i);
            path[i][i]=0;
            while(!q.empty()){
                int v=q.front();
                q.pop();
                for(auto u:G[v]){
                    if(path[i][u]!=-1)continue;
                    q.push(u);
                    path[i][u]=path[i][v]+1;                    
                }
            }
    }
    int s[MAX];
    memset(s,0,sizeof(s));
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            s[path[i][j]]++;
        }
    }
    for(int i=1;i<n;i++){
        cout<<s[i]<<endl;
    }
}

Measured memory_bytes: 19584
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define COUT(x) cout << (x) << endl
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */


int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    int ans = 0;
    rrep(i, n - 2) {
        if((p[i - 1] > p[i] && p[i] > p[i + 1]) || (p[i - 1] < p[i] && p[i] < p[i + 1])) ans++;
    }
    COUT(ans);
    
    return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.function.IntConsumer;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<Integer, Integer> factor = new HashMap<>();
        IntConsumer add = (int i) -> {
            if (factor.containsKey(i)) factor.put(i, factor.get(i) + 1);
            else factor.put(i, 1);
        };
        for (int i = 2; i <= n; i++) {
            int num = i;
            for (int j = 2; j <= 10; j++) {
                while (num % j == 0) {
                    num /= j;
                    add.accept(j);
                }
            }
            if (num != 1) add.accept(num);
        }

        int over4 = 0, over2 = 0, over14 = 0, over4_14 = 0, over24 = 0, over2_24 = 0, over74 = 0;
        for (int value : factor.values()) {
            over4 += incIfInRange(value, 4, Integer.MAX_VALUE);
            over2 += incIfInRange(value, 2, 4);
            over14 += incIfInRange(value, 14, Integer.MAX_VALUE);
            over4_14 += incIfInRange(value, 4, 14);
            over24 += incIfInRange(value, 24, Integer.MAX_VALUE);
            over2_24 += incIfInRange(value, 2, 24);
            over74 += incIfInRange(value, 74, Integer.MAX_VALUE);
        }

        System.out.println(over4 * (over4 - 1) * (over2 + over4 - 2) / 2 + over14 * (over4_14 + over14 - 1) + over24 * (over2_24 + over24 - 1) + over74);
    }

    private static int incIfInRange(int value, int st, int end) {
        if (value >= st && value < end) return 1;
        return 0;
    }
}


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

int main(){
  int N;
  int tho;
  int hun;
  int ten;
  int one;
  cin >> N;
  tho = N/1000;
  hun = (N - tho*1000)/100;
  ten = (N - tho*1000 - hun*100)/10;
  one = (N - tho*1000 - hun*100 - ten*10);
  
  if(hun == ten){
    if (tho == hun || ten == one){
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  
  else{
    cout << "No" << endl;
  }
  
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    vector<ll> x(3); rep(i, 3){cin >> x.at(i);}
    sort(x.begin(), x.end(), greater<ll>());
    ll res = 2 * x.at(0) - x.at(1) - x.at(2);
    if (res % 2 == 0){
        cout << res / 2 << endl;
    } else { // maxも一加算すると丁度良くなる
        cout << res / 2 + 2<< endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
from sys import stdin, setrecursionlimit


def initialize_cmb(m, mod):
    fac = [0] * m
    finv = [0] * m
    inv = [0] * m
    fac[0] = 1
    finv[0] = 1
    if m > 1:
        fac[1] = 1
        finv[1] = 1
        inv[1] = 1
        for i in range(2, m):
            fac[i] = fac[i-1] * i % mod
            inv[i] = mod - inv[mod % i] * (mod // i) % mod
            finv[i] = finv[i - 1] * inv[i] % mod
    return fac, finv


def cmb(n, k, mod, fac, finv):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod


def main():
    input = stdin.buffer.readline
    n, m, k = map(int, input().split())
    mod = 998244353

    fac, finv = initialize_cmb(n + 10, mod)

    c = [0] * (n + 1)
    c[0] = m
    for i in range(n):
        c[i + 1] = c[i] * (m - 1) % mod

    ans = c[n - 1]

    for i in range(k):
        ans += c[n - i - 2] * cmb(n - 1, i + 1, mod, fac, finv)
        ans %= mod

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 74024
#include <stdio.h>
int main() {
	char b, c;
	scanf("%c", &b);
	switch(b) {
		case 'A':
			c = 'T';
		break;
		case 'C':
			c = 'G';
		break;
		case 'G':
			c = 'C';
		break;
		case 'T':
			c = 'A';
		break;
	}
	printf("%c", c);
	return 0;
}


Measured memory_bytes: 128
import math
def isPrime(n):
    p = True
    for i in range(2, int(math.sqrt(n))+1, 1):
        if n % i == 0:
            p = False
    return p

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

print(len([i for i in a if isPrime(i)]))





Measured memory_bytes: 6016
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define con_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define con_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
using namespace std;
using ll = long long;
template <typename T>T digitsum(T n);
template <typename T>bool isPrime(T n);
template <typename T>vector<pair<T, T>> prime_factor(T n);
long long int intpow(long long int,long long int);
template <typename T>T intlog(T);

int main(){
    int a,b,m;
    cin>>a>>b>>m;
    vector<int> fri(a),ran(b);
    con_input(fri);
    con_input(ran);
    int x,y,c,minv;
    rep(i,m){
        cin>>x>>y>>c;
        if(i==0)minv=fri[x-1]+ran[y-1]-c;
        else{
            minv=min(minv,fri[x-1]+ran[y-1]-c);
        }
    }
    sort(all(fri));
    sort(all(ran));
    minv=min(minv,fri[0]+ran[0]);
    cout<<minv<<endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;

int main()
{
	string S; cin >> S;
	string T = "ATCG";

	int ans = 0;
	int now = 0;

	for (int i = 0; i < S.size(); i++)
	{
		bool isATCG = false;
		for (int j = 0; j < T.size(); j++)
		{
			if (S[i] == T[j]) isATCG = true;
		}

		if (!isATCG) now = 0;
		else
		{
			now++;
			ans = max(now, ans);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1<<(i))))
#define setbit1(n,i) ((n)|(1<<(i)))
#define togglebit(n,i) ((n)^(1<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
   
int main()
{
    fastread;
    ll n,k;
    cin>>n>>k;
    ll cnt=0;
    while(n!=0){
    	n/=k;
    	cnt++;
	}
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int p(int x, int y){
    if(y==0){return 1;}
    if(y==1){return x;}
    return p(x,y-1)*x;
}

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

    int n;
    cin >> n;
    vi v(n);
    vi c(n);
    vi sa(n,0);

    rep(i,n){
        cin >> v[i];
    }
    rep(i,n){
        cin >> c[i];
        sa[i] = v[i]-c[i];
    }
    int sum = 0;
    rep(i,n){
        if(sa[i]>0) sum += sa[i];
    }
    cout << sum <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 200005
#define eps 1e-12
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
	res = 0;T f = 1;char c = getchar();
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) {
		out(x / 10);
	}
	putchar('0' + x % 10);
}
int H,W,d;
bool vis[1005][1005];
string s = "RBGY";
void Solve() {
	read(H);read(W);read(d);
	for(int i = 1 ; i <= H ; ++i) {
		for(int j = 1 ; j <= W ; ++j) {
			int t = 0;
			if((i + j - 1) / d & 1) t |= 2;
			if((i - j + 500 - 1) / d & 1) t |= 1;
			putchar(s[t]);
		}
		enter;
	}
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	Solve();
}


Measured memory_bytes: 512
import numpy as np


def solve(dd, c_arr, s_arr):
    missing_d = np.zeros(26, dtype=np.int64)
    # score = 0
    res_list = []
    for d in range(dd):

        missing_d += 1

        score_add = s_arr[d, :]
        score_miss = c_arr * missing_d

        t = np.argmax(score_add + score_miss)

        # score += score_add[t] + score_miss[t] - score_miss.sum()

        res_list.append(t + 1)
        missing_d[t] = 0

    # print(score)

    return res_list


def main():
    d = np.int64(input())
    c_arr = np.array(list(map(int, input().split()))).astype(np.int64)
    s_arr = np.array([list(map(int, input().split())) for _ in range(d)]).astype(np.int64)
    res = solve(d, c_arr, s_arr)
    for r in res:
        print(r)


if __name__ == "__main__":
    main()


Measured memory_bytes: 27404