akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}

	inline int ts(char *s)
	{
		int a=0,c=fetch();
		while(c<=32 && c!=EOF)c=fetch();
		while(c>32 && c!=EOF)s[a++]=c,c=fetch();
		s[a]=0;
		return a;
	}
}
using ae86::ty;
using ae86::ts;

const int _ = 200007 , mo = 998244353;

int n;char s[_],t[_];
lint f[_]={0};

int main()
{
	n=ty(),ts(s+1);
	for(int i=1;i<=n;i++)s[i]-=48;
	
	for(int i=1;i<=n;i++)
	{
		if(n%i!=0 || (n/i)%2!=1)continue;

		lint val=0;
		for(int j=1;j<=i;j++)t[j]=s[j],val=(val*2+t[j])%mo;
		val=(val+1)%mo;
		for(int j=i+1;j<=n;j++)t[j]=t[j-i]^1;
		for(int j=1;j<=n;j++){if(s[j]==t[j])continue;if(s[j]<t[j])val=(val-1+mo)%mo;break;}
		f[i]=(f[i]+val)%mo;
	}
	lint ans=0;
	for(int i=1;i<=n;i++)
	{
		if(!f[i] || n%i!=0 || (n/i)%2!=1)continue;
		for(int j=i+i;j<=n;j+=i)f[j]=(f[j]-f[i]+mo)%mo;
		ans=(ans+2ll*i*f[i]%mo)%mo;
	}

	printf("%lld\n",ans);

	return 0;
}



Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
const int maxn=2e5+7;
const int mod=998244353;
set<string> all;
void dfs(string s)
{
    if(all.count(s)) return;
    //dbg(s);
    all.insert(s);
    for(int i=0;i<s.length()-1;i++)
    {
        string tmp=s;
        if(s[i]!=s[i+1])
        {
            if(s[i]!='a'&&s[i+1]!='a') tmp[i]=tmp[i+1]='a';
            if(s[i]!='b'&&s[i+1]!='b') tmp[i]=tmp[i+1]='b';
            if(s[i]!='c'&&s[i+1]!='c') tmp[i]=tmp[i+1]='c';
            dfs(tmp);
        }
    }
}
ll dp[maxn][3][3][2];
int main()
{
    string s;
    cin>>s;
    int n=s.length();
    int pre=0;
    bool sa=1;
    for(int i=0;i<s.length();i++) 
    {
        pre+=s[i]-'a';
        if(i&&s[i]!=s[i-1]) sa=0;
    }
    pre%=3;
    ll ans=0;
    if(sa) ans=1;
    else if(n<=3)
    {
        dfs(s);
        ans=all.size();
    }
    else{
        dp[0][0][0][0]=dp[0][1][1][0]=dp[0][2][2][0]=1;
        for(int i=1;i<n;i++)
        {
            for(int j=0;j<3;j++)
            {
                for(int k=0;k<3;k++)
                {
                    for(int cc=0;cc<3;cc++)
                    {
                        if(j==cc)
                            dp[i][cc][(k+cc)%3][1]=(dp[i-1][j][k][0]+dp[i-1][j][k][1]+dp[i][cc][(k+cc)%3][1])%mod;
                        else{
                            dp[i][cc][(k+cc)%3][1]=(dp[i-1][j][k][1]+dp[i][cc][(k+cc)%3][1])%mod;
                            dp[i][cc][(k+cc)%3][0]=(dp[i-1][j][k][0]+dp[i][cc][(k+cc)%3][0])%mod;
                        }
                    }
                }
            }
        }
        for(int j=0;j<3;j++) ans=(ans+dp[n-1][j][pre][1])%mod;
        bool ad=1;
        for(int i=1;i<n;i++) if(s[i]==s[i-1]) ad=0;
        ans=(ans+ad)%mod;
    }
    print(ans);
}

Measured memory_bytes: 28676
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
   return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
   os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  int k;cin>>k;
  
  if(k%10==3)cout<<"bon"<<ENDL;
  else if(k%10==0 || k%10==1 ||k%10==6 ||k%10==8 ){
    cout<<"pon"<<ENDL;
  }else{
    cout<<"hon"<<ENDL;
  }
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 3656
#define s(a,b) (t=a,a=b,b=t)
char p[9],m;a,b,c,d,e,f,t,r,q;main(n){while(scanf("%d",&n),n){a=1,b=6,c=2,d=5,e=3,f=4,r=1;while(n--){scanf("%s",p);m=*p;if(m==76||m==82){s(c,e);s(d,f);q=m^76?s(e,f):s(c,d);}else if(m==78||m==83){s(a,c);s(b,d);q=m^83?s(c,d):s(a,b);}else{s(a,e);s(b,f);q=m^69?s(e,f):s(a,b);}r+=a;}printf("%d\n",r);}}

Measured memory_bytes: 0
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()

	ids := make(map[[2]int]int)
	id := 1
	for i := 1; i <= n; i++ {
		for j := i + 1; j <= n; j++ {
			ids[[2]int{i, j}] = id
			ids[[2]int{j, i}] = id
			id++
		}
	}

	used := make(map[[2]int]bool)
	g := make([][]int, n*(n-1)/2+1)
	for i := 1; i <= n; i++ {
		pre := -1
		for j := 0; j < n-1; j++ {
			a := nextInt()
			id := ids[[2]int{i, a}]
			key := [2]int{i, id}
			if !used[key] && pre != -1 {
				g[pre] = append(g[pre], id)
			}
			used[key] = true
			pre = id
		}
	}

	ans := tsort(g)
	fmt.Println(ans)
}

func tsort(g [][]int) int {
	ds := make([]int, len(g)+1)
	for i := 0; i < len(ds); i++ {
		ds[i] = 1
	}

	sorted := make([]int, 0)
	seen := make(map[int]int)
	var dfs func(i int) int
	dfs = func(u int) int {
		if seen[u] == 1 {
			return -1
		}
		if seen[u] == 0 {
			seen[u] = 1
			for _, v := range g[u] {
				d := dfs(v)
				if d == -1 {
					return -1
				}
				ds[u] = max(ds[u], d+1)
			}
			seen[u] = 2
			sorted = append(sorted, u)
		}
		return ds[u]
	}

	ans := -1
	for i := 1; i < len(g); i++ {
		if seen[i] != 0 {
			continue
		}
		res := dfs(i)
		if res == -1 {
			ans = -1
			break
		}
		ans = max(ans, res)
	}
	sort.Sort(sort.Reverse(sort.IntSlice(sorted)))

	return ans
}

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

var sc = bufio.NewScanner(os.Stdin)

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


Measured memory_bytes: 234992
n,m=map(int,input().split())
a=[[i for i in input()] for i in range(n)]
b=[[i for i in input()] for i in range(m)]
ans='No'
for i in range(n-m+1):
    for j in range(n-m+1):
        c=[]
        for k in range(m):
#インデックスi+kのリストのインデックスj以上j+m未満の要素
            c.append(a[i+k][j:j+m])
            if c==b:
                ans='Yes'
                break
print(ans)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){
  string S, T;
  int i;

  cin >> S; cin >> T;

  int count = 0;
  for(i=0; i<3; i++){
    // cout << S[i] << "&" << T[i] << endl;
    if(S[i] == T[i])
      count++;
  }

  cout << count << endl;
  

  return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<string, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

int n;
vector<ll> r(100), c(100);
ll dp[100][100];

// dp[l][r]
ll calc(int lx, int rx)
{
    if (dp[lx][rx] != 1e15)
    {
        return dp[lx][rx];
    }
    for (int i = lx; i < rx; i++)
    {
        dp[lx][rx] = min(dp[lx][rx], calc(lx, i) + calc(i + 1, rx) + r[lx] * c[i] * c[rx]);
    }
    return dp[lx][rx];
}

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

    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> r[i] >> c[i];
    for (int i = 0; i < n; i++)
    {
        dp[i][i] = 0;
        for (int j = i + 1; j < n; j++)
        {
            dp[i][j] = 1e15;
        }
    }
    cout << calc(0, n - 1) << endl;
}



Measured memory_bytes: 3288
#include <stdio.h>

int main(void) {
	int N;
	int yakusimaruhiroko = 0, yosinagasayuri = 0;
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		int A, B;
		if (scanf("%d%d", &A, &B) != 2) return 1;
		if (A > yakusimaruhiroko) {
			yakusimaruhiroko = A;
			yosinagasayuri = B;
		}
	}
	printf("%d\n", yakusimaruhiroko + yosinagasayuri);
	return 0;
}


Measured memory_bytes: 1736
import itertools

X = [int(input()) for _ in range(5)]
mi = 10 ** 5
for xi in itertools.permutations(X, 5):
    count = 0
    for i, a in enumerate(xi):
        count += a
        if i < 4:
            count += (10 - (count % 10)) % 10
    mi = min(mi, count)

print(mi)


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<pair<T, T>>& vp) {
	for (int i = 0; i < vp.size(); ++i) {
		s << "(" << vp[i].first << "," << vp[i].second << ")" << ( i+1 == vp.size() ? "" : ",\t" );
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
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...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
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);
}

//main code

int main(int argc, char const* argv[])
{
	int x;
	cin >> x;
	vector<bool> dp(x+1, false);
	dp[0] = true;
	for (int i = 100; i <= x; i++) {
		for (int j = 100; j <= 105; j++) {
			if (i - j >= 0) {
				if (dp[i-j]) {
					dp[i] = true;
				}
			}
		}
	}
	cout << (dp[x] ? 1 : 0) << endl;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define ALL(x) (x).begin(),(x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;


int main() {
	IOS;
	int n;
	cin >> n;
	vector<string> s(n);
	map<string, int> mp;
	bool ans = true;;
	REP(i, n) {
		cin >> s[i];
		if (i) {
			if (s[i][0] != s[i - 1][s[i - 1].size() - 1])ans = false;
		}
		mp[s[i]]++;
		if (mp[s[i]] > 1)ans = false;
	}
	dump(ans ? "Yes" : "No");
}

Measured memory_bytes: 256
object Main {
    def main(args:Array[String]) {
        val sc = new java.util.Scanner(System.in)
        while (true) {
            var time = sc.nextInt
            if (time == 0) return
            val n = sc.nextInt
            for (i <- 1 to n) {
                val start, end = sc.nextInt
                time -= (end - start)
            }
            if (time <= 0) println("OK")
            else println(time)
        }
    }
}

Measured memory_bytes: 48912
#include<bits/stdc++.h>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define put(x) cout<<#x<<" = "<<x<<endl;
#define X first
#define Y second
#define pb push_back
#define pp pop_back
#define int num
#pragma GCC optimize("O2")
using namespace std;
typedef long long num;
typedef pair<int,int> point;
const int maxn=1e6+10,inf=1e9+10;

int n,A[maxn];

int get(int x){
    num ans=0;
    rep(i,0,n){
	ans+=llabs(A[i]-(x+i+1));
    }
    return ans;
}

int TS(int l=-inf,int r=inf){
    if(r-l==1) return l;
    int mid=(l+r)/2;
    if(get(mid-1)<get(mid)){
	return TS(l,mid);
    }else{
	return TS(mid,r);
    }
}

int32_t main(){
    scanf("%lld",&n);
    rep(i,0,n){
	scanf("%lld",A+i);
    }
    printf("%lld\n",get(TS()));
}


Measured memory_bytes: 1792
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    MOD = 998244353
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N = NI()
    dat = [LI() for _ in range(N)]
    dat.sort()
    yo = [y for _,y in dat]
    yo.sort()

    up = [0] * N
    dw = [0] * N

    bit = [0] * (N+1)

    def bit_add(i):
        while i <= N:
            bit[i] += 1
            i += i & -i

    def bit_sum(i):
        ret = 0
        while i > 0:
            ret += bit[i]
            i -= i & -i
        return ret

    for i in range(N):
        x,y = dat[i]
        y = bisect.bisect_left(yo,y) + 1
        up[i] = bit_sum(y)
        bit_add(y)

    bit = [0] * (N+1)
    for i in range(N-1,-1,-1):
        x,y = dat[i]
        y = bisect.bisect_left(yo,y) + 1
        dw[i] = bit_sum(y)
        bit_add(y)

    ans = N * pow(2,N-1,MOD)
    for i in range(N):
        a = i - up[i]
        b = up[i]
        c = N-(i+1) - dw[i]
        d = dw[i]
        pa = pow(2,a,MOD)
        pb = pow(2,b,MOD)
        pc = pow(2,c,MOD)
        pd = pow(2,d,MOD)
        p = (pow(2,a+d,MOD)-1) - (pa-1) - (pd-1)
        q = (pow(2,b+c,MOD)-1) - (pb-1) - (pc-1)
        x = p * (pb + pc - 1)
        y = q * (pa + pd - 1)
        z = p * q
        ans = (ans + x + y + z) % MOD
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 123928
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int main(){
 ll n,m ; cin>>n>>m ;
 vector<P> key ;
 rep(i,m){
     ll a,b ; cin >>a>> b;
     ll sum= 0;
     rep(i,b){
         ll c ;cin>>c ;
        c-- ;
        sum = sum | 1<< c ;
     }
     key.eb(sum,a) ;
 }
 vector<ll> dp(1<<n,INF) ;
 dp[0]=0 ;
 rep(i,1<<n){
     rep(j,m){
         dp[i| key[j].fi] = min( dp[i|key[j].fi],
         dp[i]+key[j].se) ;
     }
 }
 ll ans= dp.back() ;
 if(ans== INF) cout<<-1<<endl ;
 else cout<<ans<<endl ;
 return 0 ; 
}



Measured memory_bytes: 3600
s = list(input())

idx_even = [s[x] for x in range(0, len(s), 2)]
idx_odd = [s[x] for x in range(1, len(s), 2)]

# print(s, idx_even, idx_odd)

ans = min(
    idx_even.count("0") + idx_odd.count("1"), idx_even.count("1") + idx_odd.count("0")
)

print(ans)


Measured memory_bytes: 4652
#include<stdio.h>

int main(){
    int a, b, count, r, x;
    a = 2;
    b = 2;
    scanf("%d",&x);
    if(x==1){
        printf("1");
    }else{
        while(1){
            r = a;
            count = 1;

            while(r<=x){
                r = r*a;
                count++;
            }
            r = r/a;

            if(count==2){
                break;
            }

            if(r>=b){
                b = r;
            }

            a++;
        }
        printf("%d\n", b);
    }

    return 0;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, a, b);
  if (1 <= a && a <= 9 && 1 <= b && b <= 9) {
    out(a * b);
  } else {
    out(-1);
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 1e9 + 7;

char str[200005];

int main()
{
	scanf("%s", str);
	int n = strlen(str);
	
	int cur = 0;
	LL ans = 0;
	rep(i, n) if(str[i] == 'B') cur ++;
	else ans += cur;
	printf("%lld\n", ans);
	return 0;
}

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



int main() {
    ll N , A, B; cin >> N >> A >> B;
    ll ans = 0;
    ans += A * (N/(A+B));
    //cout << ans << endl;
    ll rem = N - (N /(A+B)) * (A+B);
    if(rem <= A) ans += rem;
    else ans += A;
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

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

// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

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

    int N, M;
    cin >> N >> M;
    UnionFind uf(N);

    ll tmp_X, tmp_Y, tmp_Z;
    for(int i = 0; i < M; i++){
      cin >> tmp_X >> tmp_Y >>  tmp_Z;
      tmp_X--;
      tmp_Y--;
      uf.merge(tmp_X, tmp_Y);
    }

    map<ll, int> mp;

    for(ll i = 0; i < N; i++){
      mp[uf.root(i)]++;
    }

    cout << mp.size() << endl;


    return 0;
}



Measured memory_bytes: 8064
import sys

alist = []
blist = []
cnt = 0

for line in sys.stdin:
	if cnt%2 == 0: alist.append(map(int, line.split()))
	else: blist.append(map(int, line.split()))
	cnt += 1

for i in range(0, len(alist)):
	a = alist[i]
	b = blist[i]
	hitcount = 0
	blowcount = 0
	for j in range(0, 4):
		if a[j] == b[j]: hitcount += 1
	for j in range(0, 4):
		for k in range(0, 4):
			if a[j] == b[k] and j != k: blowcount += 1
	print str(hitcount)+' '+str(blowcount)


Measured memory_bytes: 4668
import sys, math
from functools import lru_cache
import numpy as np
from collections import defaultdict
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

# nまでの自然数が素数かどうかを表すリストを返す
def makePrimeChecker(n):
    isPrime = [True] * (n + 1)
    isPrime[0] = False
    isPrime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if isPrime[i]:
            for j in range(i * i, n + 1, i):
                isPrime[j] = False
    return isPrime


def main():
    N = ii()
    D = list(mi())
    M = ii()
    T = list(mi())

    d = defaultdict(int)
    for i in range(N):
        d[D[i]] += 1

    t = defaultdict(int)
    for i in range(M):
        d[T[i]] -= 1

    for v in d.values():
        if v < 0:
            print('NO')
            return
    
    print('YES')

if __name__ == '__main__':
    main()


Measured memory_bytes: 61740
def solve():
    
    N = int(input())
    a  = list(map(int, input().split()))

    lists = [0] * ((10**5)+2)

    for i in a:
        lists[i] += 1
        lists[i+1] += 1
        lists[i-1] += 1

    print(max(lists))    

if __name__ == "__main__":
    solve()


Measured memory_bytes: 20584
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0529
# http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2985387#1

import bisect
while True:
    n, m = map(int, input().split())
    if n == 0: break
    p = [int(input()) for i in range(n)]
    p.append(0)
    p.sort()
    s = [i+j for i in p for j in p if i <= j]
    s.sort()
    t = bisect.bisect_left(s, m)
    h = bisect.bisect_left(s, m>>1, 0, t)
    if t < len(s):
        if s[t] == m:
            print(m);
            continue
        s = s[:t]
    ans = 0
    # for i in range(h-1, len(s)):
    for i in range(h):
        t = bisect.bisect_left(s, m-s[i])
        if s[i]+s[t-1] > ans: ans = s[i]+s[t-1]
    print(ans)


Measured memory_bytes: 47984
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	while(cin>>s)
	{
		if(s=="SUN")cout<<7<<endl;
		else if(s=="MON")cout<<6<<endl;
		else if(s=="TUE")cout<<5<<endl;
		else if(s=="WED")cout<<4<<endl;
		else if(s=="THU")cout<<3<<endl;
		else if(s=="FRI")cout<<2<<endl;
		else if(s=="SAT")cout<<1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
w,a,b = map(int,(input().split()))

result = 0
if a < b :
    hantei = b - a - w
else:
    hantei = a - b - w 

for i in range(1,10**5):
    #print("hantei",hantei)
    if hantei <= 0:
        print(result)
        exit()
    else:
        hantei -= 1
        result += 1


Measured memory_bytes: 2940
import java.util.Scanner;
public class Main{
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc =new Scanner(System.in);
	int N=sc.nextInt();
	int N2=sc.nextInt();
	int N3=sc.nextInt();
	if(N+N2+N3>=22) {
		System.out.println("bust");
	}else {
		System.out.println("win");
	}
}
}

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

int main(){
	
	long long n, k, q;
	
	cin >> n >> k >> q;
	
	int b[n+1];
	
	for (int i = 0; i < n; i++){
		b[i] = k-q;
	}
	
	for (int i= 0; i < q; i++){
		int a;
		cin >> a;
		
		b[a-1]++;


	}
		
	for (int i = 0; i < n; i++){
		if (b[i] < 1){
			cout << "No" << endl;
		} else {
			cout << "Yes" << endl;
		}
	}
	
	
	
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 1e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int n;
string s;

void input() {
    cin >> n >> s;
}

void solve() {
    int ans = 0;
    for (int i = 1; i < sz(s); i++) {
        int t = 0;
        for (int j = 0; j + i < sz(s); j++) {
            t = (t + 1) * (s[j] == s[j+i]);
            ans = max(ans, min(t,i));
        }
    }
    cout << ans << endl;
}

int main(int argc, char *argv[]){
    input();
    solve();
    return 0;
}


Measured memory_bytes: 384
N = int(input())

nmap = [[0 for i in range(10)] for j in range(10)]

answer = 0
for n in range(1, N + 1):
  first = int(str(n)[0])
  last = int(str(n)[-1])
  nmap[first][last] += 1

for n in range(1, N + 1):
  _last = int(str(n)[0])
  _first = int(str(n)[-1])
  answer += nmap[_first][_last]
  
print(answer)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
using namespace std;
int main() {
	string str1,str2;
	cin>>str1>>str2;
	int len1=str1.size();
	int len2=str2.size();
	for (register int i=0;i<len2;++i) {
		cout<<str1[i]<<str2[i];
	}
	if (len1>len2) {
		cout<<str1[len1-1];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
#define erase(i) erase(i, 1)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
template<typename T> void remove(std::vector<T>& vector, unsigned int index){vector.erase(vector.begin() + index);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    int n;
    cin >> n;
    vector<double> v(n);
    rep(i,n)cin >> v[i];
    SORT(v);
    rep(i,n-1)
    {
        double tmp = (v[i] + v[i + 1]) / 2;
        v[i + 1] = tmp;
    }
    cout << v[n-1] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)
int n, m, q;
vector<int> a, b, c, d;
int ans = 0;
void dfs(vector<int> A)
{
    // cout << A.size() <<  endl;
    if (A.size() == n + 1)
    {
        int now = 0;
        repi(i, q, 0)
        {
            if (A[b[i]] - A[a[i]] == c[i])
                now += d[i];
        }
        ans = max(ans, now);
        return;
    }
    A.push_back(A.back());
    while (A.back() <= m)
    {
        dfs(A);
        A.back()++;
    }
}
int main()
{
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    repi(i, q, 0)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vector<int>(1, 1));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
# ABC086C - Traveling (ARC089C)
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    A = tuple(tuple(map(int, input().split())) for _ in range(n))
    for t, x, y in A:
        if x + y > t or (t + x + y) % 2 != 0:
            print("No")
            break
    else:
        print("Yes")


if __name__ == "__main__":
    main()

Measured memory_bytes: 17440
#include <stdio.h>
#include <unistd.h>
int main(void){

    int i,k;
    char s[1000];
    scanf("%d", &k);
    scanf("%s", s);
    for (i = 0; s[i] != 0; i++)
        ;
    if (i <= k)
        printf("%s", s);
    else
    {
        write(1, s, k);
        write(1, "...", 3);
    }
    return (0);
}


Measured memory_bytes: 1708
from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))
D_sub=defaultdict(int)
D_add=defaultdict(int)
ans_2=0
for i,a in enumerate(A,1):
    SUB=i-a
    ans_2 += D_sub[SUB]
    D_sub[i+a]+=1

print(ans_2)


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

int main() {
	int n;
	cin >> n;
	long long p=1,j18=pow(10,18);
	vector<long long> a(n);
	for(int i=0;i<n;i++)
	{
		cin >> a.at(i);
		if(a.at(i) == 0)
		{
			p=0;
		}
	}
	for(int i=0;i<n;i++)
	{
		if(p==0)
		{
			break;
		}
		long long p2 =p;
		p *= a.at(i);
		if(p<0||p2> p)
		{
			p=-1;
			break;
		}
	}
	if(p<0||p>j18)
	{
		p=-1;
	}
	cout << p << endl;
	return 0;
}


Measured memory_bytes: 4052
def resolve():
    n = int(input())
    a = [int(i) for i in input().split()]
    counter = 0
    while True:
        if sum([i % 2 for i in a]) != 0:
            break
        a = [i / 2 for i in a]
        counter += 1
        # print(f'list: {a} | counter: {counter}')
    print(counter)

resolve()


Measured memory_bytes: 3060
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Copyright  : @Huki_Hara
# Created    : 2015-03-01

s=[]
W=int(input())
n=int(input())
for i in range(W):
    s.append(i+1)

for _ in range(n):
    a , b = map(int, input().split(","))
    s[a-1], s[b-1] = s[b-1], s[a-1]

for i in s:
    print(i)

Measured memory_bytes: 6720
n = int(input())
p = [int(i) for i in input().split()]

count = 0
for i in range(n-1):
    if i+1 == p[i]:
        p[i], p[i+1] = p[i+1], p[i]
        count += 1
else:
    if n == p[-1]:
        count += 1


print(count)

Measured memory_bytes: 13880
#include <iostream>

using namespace std;

typedef long long LL;

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ALL(a)  (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define dump(x)  cerr << #x << " = " << (x) << endl;

int main() {
  int X;
  cin >> X;
  if (X == 7 || X == 5 || X == 3) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define clr1(arr) memset(arr,-1,sizeof(arr));
#define clr0(arr) memset(arr,0,sizeof(arr));
#define pi pair<int,int>
#define pii pair<int,pi>
#define aint(v) v.begin(),v.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define ump gp_hash_table<int,int,custom_hash>
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
/*int **dp,in main function,int row,col;dp=new int*[n];rep(i,n)dp[i]=new int[m]*/
//**** Maths Section*******/
int power(int x,int y);
bool isPrime(int n);
int modInv(int a,int b);
int gcdExtended(int a,int b,int *x,int* y);
int mpower(int a,int b,int p);
/***************************/
int32_t main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  fastio
  int k;
  cin>>k;
  int rem=0;
  int ct=1;
  while(true)
  {
    rem=(rem*10+7)%k;
    if(rem==0)
    {
      cout<<ct<<endl;
      exit(0);
    }
    ct++;
    if(ct>999982)
    {
      cout<<"-1\n";
      exit(0);
    }
  }
  return 0;
}

int modInv(int a, int m)
{
int x, y;
int g = gcdExtended(a, m, &x, &y);
int res = (x%m + m) % m;
return res;
}

int gcdExtended(int a, int b, int *x, int *y)
{
if (a == 0){
    *x = 0, *y = 1;
    return b;
  }
  int x1, y1;
  int gcd = gcdExtended(b%a, a, &x1, &y1);
  *x = y1 - (b/a) * x1;
  *y = x1;
  return gcd;
}

int mpower(int x, int y, int p)
{
int res = 1;
x = x % p;
while(y > 0){
    if(y & 1) res = (res*x) % p;
      y = y>>1;
      x = (x*x) % p;
    }
    return res;
}
int power(int x, int y)
{
int res = 1;
while (y > 0){
    if (y & 1) res = res*x;
      y = y>>1;
      x = x*x;
    }
    return res;
}

bool isPrime(int n)
{
if (n <= 1)  return false;
  if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
      int p=sqrt(n);
      for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
          return false;
      return true;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> c(3, vector<int>(3));
vector<int>x(3,0);
vector<int>y(3,0);

int main() {

    for(int i = 0; i < 3; i++)
        for(int j = 0; j < 3; j++)
            cin >> c[i][j];
    
    
    for(int i = 0; i < 3; i++) y[i] = c[0][i] - x[0];
    for(int i = 0; i < 3; i++) x[i] = c[i][0] - y[0];
    
    bool ans = true;
    
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            if(x[i]+y[j] != c[i][j]){
                ans = false;
            }
        }
    }
    
    cout << (ans ? "Yes" : "No") << endl;
    
}


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

using namespace std;

// stringをintに
// string a = "123";
// stoi(a)
//
// intをstringに
// int a = 123;
// to_string(a)
//
// charをintに
// char a = '1';
// (int)a - 48 // asciiコードを値にする

// stringのソート
// string str = "abccba";
// sort(str.begin(), str.end());
//
// ハッシュテーブル
// unordered_map<string, int> mp;
// mp["aabbcc"] = 0;

// 配列Aにcinする
//int main() {
//  int N;
//  cin >> N;
//  vector<int> A(N);
//  for (int i = 0; i < N; i++) {
//    cin >> A.at(i);
//  }
//  return 0;
//}

// 標準入出力
//int main() {
//	int a, b;
//	cin >> a >> b;
//  if (a * b % 2 == 0) {
//	  cout << "Even" << endl;
//  } else {
//	  cout << "Odd" << endl;
//  }
//  return 0;
//}

// 文字列を1文字ずつループ
int main() {
  string S;
  string T;
  cin >> S >> T;

  int sum = 0;
  for(int i = 0; i < 3; ++i){
    char s = S[i];
    char t = T[i];
    if (s == t) {
      sum++;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
a = input()
b = input()
c = input()
d = input()
e = input()
k = input()

A = int(a)
B = int(b)
C = int(c)
D = int(d)
E = int(e)
K = int(k)

if E-A > K:
    print(":(")
else:
    print("Yay!")
   

Measured memory_bytes: 2940
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

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

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	N := sc.nextInt()
	L := sc.nextIntSlice(N)
	sort.Ints(L)
	count := 0
	for i := N - 1; i > 1; i-- {
		for j := i - 1; j > 0; j-- {
			lower := L[i] - L[j]
			isOk := func(m int) bool {
				if lower < L[m] {
					return true
				}
				return false
			}
			ng, ok := -1, j
			for abs(ok-ng) > 1 {
				mid := (ok + ng) / 2
				if isOk(mid) {
					ok = mid
				} else {
					ng = mid
				}
			}
			count += j - ok
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 640
import itertools

a, b, c, d = list(input())

for i in itertools.product(["+", "-"], repeat = 3):
    #repeatの数字は項数 i[n]で指定。
    x = a + i[0] + b + i[1] + c + i[2] + d
    if eval(x) == 7:
        break

print(x + "=7")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
#define rrep(i,n) for(int i = n-1; i >= 0 ; i--)
typedef long long ll;
constexpr auto INFI = 2147483647;
const ll INFL = 9223372036854775807;

int main(){
    int n, m, tmp, ans;
    cin >> n >> m;
    int sum = 0;
    rep(i, m){
        cin >> tmp;
        sum += tmp;
    }
    ans = n - sum;

    cout << ((ans >= 0) ? ans : -1) << endl;

    return 0;
}

Measured memory_bytes: 3608
//abc163A
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void) {
  float n, k, i, cou=0, tmp;
  scanf("%f", &n);
  printf("%f", n * 2*M_PI);
}



Measured memory_bytes: 1740
// B
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int main() {
    int a, b;
    cin >> a >> b;
    reg int ans = 0, res = 1;
    while (res < b) {
        res += a - 1;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys


# ## COMBINATION (MOD) ## #
MOD = 10**9 + 7  # , N = 2*10**5 で 0.3s
N_MAX = 10**5 + 1  # 問題サイズに合わせて変えておく

fac = [1, 1]  # 元テーブル
facinv = [1, 1]  # 逆元テーブル
inv = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N_MAX + 1):
    fac.append((fac[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    facinv.append((facinv[-1] * inv[-1]) % MOD)


def cmb(n, r):
    if (r < 0 or r > n):
        return 0
    # r = min(r, n-r)
    return fac[n] * facinv[r] * facinv[n - r] % MOD


def main():
    N, K = map(int, sys.stdin.readline().rstrip().split())
    A = [int(x) for x in sys.stdin.readline().rstrip().split()]

    A.sort()  # 小 -> 大

    # 左から i 番目が選ばれて、i+1番目以降が選ばれない
    sum = 0
    for i in range(N - K + 1):
        sum += cmb(N - i - 1, K - 1) * (A[-(i + 1)] - A[i]) % MOD
        sum %= MOD

    print(sum)


main()


Measured memory_bytes: 31984
#include <bits/stdc++.h>
using namespace std;
 
#define ull     		unsigned long long int
#define ll      		long long int
#define loop(i,s,e)     for(ll i=(s);i<(e);i++)
#define rloop(i,s,e)    for(ll i=(s);i>=(e);i--)
#define scan(any)       for(auto &i:any) cin>>i;
#define print(any)      for(auto i:any) cout<<i<<" "; nl;
#define nl              cout<<'\n'
#define pi 3.141592654
#define hell 1000000007
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define IP(n) int n;cin>>n
#define IP2(a, b) int a,b;cin>>a>>b
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define vi vector<int>
#define pii pair<int,int>
#define piii pair<pair<int,int>,int>
#define all(v) (v).begin(), (v).end()
#define sz(x) (int)x.size()
#define set(a,n) memset(a,n,sizeof(a))
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
const int INF = 1<<29;
inline int two(int n) { return 1 << n; }
inline int last_bit(int n) { return n & (-n); }
inline int test(int n, int b) { return (n>>b)&1; }
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline void set_bit(int & n, int b) { n |= two(b); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////////////////
int main()
{
  int x,y;
  cin>>x>>y;
  int ma=0;
  vector<int>v1(y);
  scan(v1);
  long long int s=0;
  for(int i=1;i<v1.size();i++)
  {
    int p=v1[i]-v1[i-1];
    ma=max(ma,p);
    s+=p;
  }
  s+=v1.front()-0+x-v1.back();
  ma=max(x-v1.back()+v1.front(),ma);
  cout<<s-ma;
return 0;
}





Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

ll H[200000];

int main()
{
	int N, K;
	ll ans = 0;

	cin >> N >> K;
	rep(i, N) cin >> H[i];

	sort(H, H + N);

	rep(i, N - K) ans += H[i];

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
#include<iostream>

using namespace std;

#define SIZE 10010

bool iscomp[SIZE];      //质数为false, 合数为true
int P[SIZE >> 1], Pcnt = 0;     //存放质数的集合, Pcnt记录质数个数

void sieve(){       //线性筛法,筛出1 - SIZE的质数, 即可快速算出1 - SIZE * SIZE以内的数是否为质数
    for(int i = 2; i < SIZE; ++i){
        if(!iscomp[i]) P[++Pcnt] = i;
        for(int j = 1; j <= Pcnt && i * P[j] < SIZE; ++j){
            iscomp[i * P[j]] = true;
            if (i % P[j] == 0) break; 
        }
    }
}

bool isPrime(int x){
    if(x < SIZE) return !iscomp[x];
    for(int i = 1;  P[i] * P[i] <= x && i <= Pcnt; ++i){
        if(x % P[i] == 0) return false;
    }
    return true;
}

int main(){
    int n, x, cnt = 0;
    cin >> n;
    sieve();
    while(n--){
        cin >> x;
        if(isPrime(x)) ++cnt;
    }
    cout << cnt << endl;
    return 0;
}


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

typedef long long ll;
typedef long long LL;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#ifdef DEBUG
    #define cek(x) cout<<x
#else
    #define cek(x) if(false){}
#endif // DEBUG

#define fi first
#define se second
#define INF 1000000000
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define PI acos(-1.0)
#define pb push_back
#define TC() while(tc--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=0;i<=n;i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define REPN(i,a,b) for(int i=a;i<=b;i++)
#define reset(a,b) memset(a,b,sizeof(a))
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define SORTA(v,n) sort(v, v + n)
#define SZ(v) (int) v.size()
#define sc(x) scanf("%d",&x)

void open(){
	freopen("D:/Code/in.txt","r",stdin);
	freopen("D:/Code/out.txt", "w", stdout);
}

int main(void){
	int n;
	sc(n);
	int l = 1;
	int r = INF;
	while(l<r){
		ll mid = l + (r-l)/2;
		if(mid * (mid + 1)/2 >= n){
			r = mid;
		}else l = mid + 1;
	}

	cout << l << endl;

    return 0;

}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();

    String n_sinsu = Integer.toString(n,k);

    System.out.println(n_sinsu.length());

/*  以下のコードを書いたが、NumberFormatExceptionが発生した
    int n_sinsu = Integer.parseInt(Integer.toString(n,k));
    String ans = String.valueOf(n_sinsu);

    System.out.println(ans.length);
*/
  }
}


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

int main()
{
    int x,tmp;
    int ans=0;
    cin >> x;
    for(int i=1; i <= x; i++){
        for(int k=2; k <= x; k++){
            tmp = pow(i,k);
            if(x >= tmp){
                ans = max(ans,tmp);
            }else{
                break;
            }
        }
    }
    
    if(x == 1){
        cout << 1 << endl;
    }else{
        cout << ans << endl;  
    }
}


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

int main() {
  char b;
  cin >> b;
  
  if (b=='A') {
    cout << 'T' << endl;
  }
  if (b=='T') {
    cout << 'A' << endl;
  }
  if (b=='C') {
    cout << 'G' << endl;
  }
  if (b=='G') {
    cout << 'C' << endl;
  }
}

Measured memory_bytes: 256