akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double db;
typedef long double ldb;
#define rep(i,a,b) for(i=a;i<b;i++)
#define repu(i,a,b) for(i=a;i<=b;i++)
#define repd(i,a,b) for(i=a;i>=b;i--)
#define repc(i,a,b,c) for(i=a;i<b;i+=c)
#define repcu(i,a,b,c) for(i=a;i<=b;i+=c)
#define repcd(i,a,b,c) for(i=a;i>=b;i-=c)
#define FIN freopen("input.in","r",stdin)
#define FOUT freopen("output.out","w",stdout)
#define CC(a) memset(a,0,sizeof(a))
#define MST(a,b) memset(a,b,sizeof(a))
#define PII pair<int,int>
#define PLL pair<long long,long long>
#define VI vector<int>
#define VL vector<long long>
#define VII vector<PII>
#define VLL vector<PLL>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second

template<typename T>inline void gn(T &x){
	x=0;T f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
template<typename T>inline void gt(T x){
	if(!x)return;
	gt(x/10);putchar(x%10+'0');
}

const LL N=100003;
struct NODE{
	LL a,b;
}gg[N];
LL t,n,m,ans;
LL MOD=1e9+7,inf=0x1f1f1f1f;
db eps=1e-5;
LL ff[N];

LL cmp(NODE a,NODE b){
	if(a.b!=b.b)return a.b<b.b;
	else return a.a<b.a;
}
LL cmp2(NODE a,NODE b){
	if(a.a!=b.a)return a.a<b.a;
	else return a.b<b.b;
}


int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	LL i,j,k,l,ca=0,u,v,d;
	cin>>n;
	repu(i,1,n)cin>>ff[i],gg[i].b=ff[i],gg[i].a=i;
	sort(gg+1,gg+n+1,cmp);
	repu(i,1,n)gg[i].b=i;
	sort(gg+1,gg+n+1,cmp2);
	repu(i,1,n){
		ans+=(gg[i].b-gg[i].a)&1;
	}
	cout<<ans/2<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<stack>
using namespace std;
typedef long long ll;
#define MAX 120000
#define INFTY 9000000000

ll E[MAX],O[MAX];

int main(){
  ll n,data;
  cin>>n;
  for(ll i=1;i<=n;i++){
    cin>>data;
    if(i%2==0) E[data]++;
    else O[data]++;
  }
  ll firstE=0,secondE=0,firstO=0,secondO=0;
  for(ll i=1;i<MAX;i++){
    if(E[firstE]<E[i]){
      secondE=firstE;
      firstE=i;
    }else if(E[secondE]<E[i]){
      secondE=i;
    }
    if(O[firstO]<O[i]){
      secondO=firstO;
      firstO=i;
    }else if(O[secondO]<O[i]){
      secondO=i;
    }
  }
  ll ansE,ansO,ans;
  if(firstE!=firstO){
    ansE=n/2-E[firstE];
    ansO=n/2-O[firstO];
    ans=ansE+ansO;
  }else{
    ansE=n/2-E[firstE];
    ansO=n/2-O[firstO];
    ans=ansE+ansO+min(E[firstE]-E[secondE],O[firstO]-O[secondO]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>

using namespace std;

string S;
long long int K;
int check[105];

int main(void) {

	cin >> S;
	cin >> K;

	int sign = 0;
	int N = S.size();

	for (int i = 1; i < N; i++) {
		if (S[i] != S[i - 1]) { sign = 1; }
	}

	if (sign == 0) {
		cout << (K*N) / 2 << endl; return 0;
	}

	S += S;

	long long int ans = 0;

	if (S[0] != S[N-1]) {

		string tmp = S;
		for (int i = 1; i < N; i++) {
			if (tmp[i] == tmp[i - 1]) { tmp[i] = '?';  ans++; }
		}
		ans *= K;
	}
	else {

		int p = 0;
		int q = 0;
		int w = 0;
		for (int i = 0; i < N; i++) {
			if (S[0] == S[i]) { w++; p = i; }
			else { break; }
		}
		for (int i = N - 1; i >= 0; i--) {
			if (S[0] == S[i]) { w++; q = i; }
			else { break; }
		}

		ans += (K - 1)*(w / 2);

		string tmp = S;

		for (int i = 0; i <= p; i++) {
			if (tmp[i] == tmp[i - 1]) { tmp[i] = '?'; ans++; }
		}

		tmp = S;

		for (int i = p + 1; i < q; i++) {
			if (tmp[i] == tmp[i - 1]) { tmp[i] = '?'; ans+=K; }
		}


		tmp = S;
		for (int i = q; i < N; i++) {
			if (tmp[i] == tmp[i - 1]) { tmp[i] = '?'; ans++; }
		}

	}

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] ar = new int[n+1];
        for (int i = 0; i < n-1; i++) {
            int f = scan.nextInt();
            ar[f]+=1;
        }

        for (int i = 1; i < ar.length; i++) {
            System.out.println(ar[i]);
        }
    }
}


Measured memory_bytes: 61820
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string s;
  cin >> s;
  string rsl = "";
  rep(i, 0, s.size()) {
      if(s[i] + n > 'Z') {
          rsl += s[i] + n - 26;
      } else {
          rsl += s[i] + n;
      }
  }
  cout << rsl << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <time.h>
#define ll long long
#define mod 1000000007
int main(){
    int length;
    char s[1003]={};
    scanf("%s",s);
    length=strlen(s);
    if(s[length-1]!='s')s[length]='s';
    else {
        s[length]='e';
        s[length+1]='s';
    }
    printf("%s",s);
    return 0;
}

Measured memory_bytes: 1732
import Control.Monad.ST
import Data.Char
 
 
readInt :: IO Int
readInt = read <$> getLine :: IO Int
 
readIntSplit :: IO [Int]
readIntSplit = map read . words <$> getLine :: IO [Int]
 
readStr :: IO String
readStr = getLine
 
readStrSplit :: IO [String]
readStrSplit = map read . words <$> getLine

solve :: Int -> Int -> Int -> (Int, Int)
solve value x k
  | value <= k = (x * value, k - value)
  | k > 0 = (x * k, 0)
  | otherwise = (0, 0)

main = do
  [a, b, c, k] <- readIntSplit
  let (ans1, k1) = solve a 1 k
  let (_, k2) = solve b 0 k1
  let (ans3, _) = solve c (-1) k2
  print $ ans1 + ans3


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

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


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def make_divisors(n):
    divisors = []
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

def main():
    n=int(input())
    ans=0
    div_n=make_divisors(n)
    for p in div_n:
        m=(n-p)//p
        if m>0 and n%m==p:
            ans+=m
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 3280
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(void){
	long long a,b,c;
	cin>>a>>b>>c;
	long long res1=4*a*b,res2=(c-a-b)*(c-a-b);
	if(c-a-b<=2)
	printf("No\n");
	else if(res1<res2)
	printf("Yes\n");
	else
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using std::cout;
using std::cin;
using std::endl;
int main() {

	int m, f, r;// ??????????¨?(50)?????????????¨?(50)??????????¨?(100)
	// ????¨???????????????????????????°-1
	while (1)
	{

		cin >> m >> f >> r;
		// ???????????¶
		if (m == -1 && f == -1 && r == -1)
		{
			break;
		}


		if ((m == -1 || f == -1) || (m + f < 30)) {
			cout << "F" << endl;
		}
		else if (m + f >= 80)
		{
			cout << "A" << endl;
		}
		else if (65 <= m + f  && m + f < 80) {
			cout << "B" << endl;
		}
		else if (50 <= m + f && m + f < 65)
		{
			cout << "C" << endl;
		}
		else if (30 <= m + f && m + f < 50) {
			if (r >= 50)
			{
				cout << "C" << endl;
			}
			else
			{
				cout << "D" << endl;
			}
		}

	}

	return 0;
}

Measured memory_bytes: 3076
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int N, M;

    scanf("%d%d", &N, &M);

    int c[N+1];

    for(int i = 1; i <= N; i++){
        c[i] = 0;
    }

    int a[M], b[M];

    for(int i = 0; i < M; i++){
        scanf("%d%d", &a[i], &b[i]);
        c[a[i]]++;
        c[b[i]]++;
    }

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

    return 0;
}

Measured memory_bytes: 1728
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
#define MOD (1000000007ll)

bool sugar[3333],water[3333];

bool conccomp(int x, int y, int p, int q){
	return (p*y>x*q);
}

int main(void){
	int a,b,c,d,e,f,ans[2],i,j;
	fill(sugar,sugar+3333,false);
	fill(water,water+3333,false);
	cin >> a >> b >> c >> d >> e >> f;
	a *= 100;
	b *= 100;
	ans[0] = a;
	ans[1] = 0;
	sugar[0] = true;
	water[0] = true;
	for(i=0; i<=f; ++i){
		if(water[i]){
			if(i+a<=f){
				water[i+a] = true;
			}
			if(i+b<=f){
				water[i+b] = true;
			}
		}
	}

	for(j=0; j<=f; ++j){
		if(sugar[j]){
			if(j+c<=f){
				sugar[j+c] = true;
			}
			if(j+d<=f){
				sugar[j+d] = true;
			}
		}
	}
	for(i=1; i<=f; ++i){
		if(!water[i]){
			continue;
		}
		for(j=1; j<=f; ++j){
			if(!sugar[j] || i+j>f){
				continue;
			}
			if(conccomp(i+j,j,ans[0],ans[1]) && !conccomp(i+j,j,(100+e),e)){
				ans[0] = (i+j);
				ans[1] = j;
			}
		}
	}
	cout << ans[0] << " " << ans[1] << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<stack>
#define rnt register int
using namespace std;
int n,m[200001],cnt;
int d[200001];
stack <int> s;
int main()
{
	scanf("%d",&n);
	for(rnt i=1;i<=n;i=-~i)
		scanf("%d",&d[i]);
	for(rnt i=n;i>0;i--)
	{
		if(i*2>n)
		{
			m[i]=d[i];
			if(m[i])
				s.push(i),cnt++;
		}
		else
		{
			for(rnt k=2;i*k<=n;k=-~k)
				m[i]+=m[i*k];
			m[i]=d[i]-m[i]%2;
			if(m[i]==-1)
				m[i]=1;
			if(m[i])
				s.push(i),cnt++;
		}
	}
	printf("%d\n",cnt);
	if(cnt)
		while(!s.empty())
		{
			printf("%d ",s.top());
			s.pop();
		}
	return 0;
}

Measured memory_bytes: 3072
/*  ex2_3
    Rikuta */

#include<stdio.h>

int main(void){

    int length,wh,bl,area;
    //マス目の一辺の数，白のマス数の入力
    scanf("%d",&length);
    scanf("%d",&wh);
    //マスの数の計算
    area = length*length;
    //黒のマス数の計算
    bl = area - wh;
    //黒のマス数の出力
    printf("%d\n",bl);
}


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

int main() {
  int D;cin>>D;
  string x = "Christmas",y="Eve";
  if(D==25) cout << x << endl;
  if(D==24) cout << x << " " << y << endl;
  if(D==23) cout << x << " " << y << " " << y << endl;
  if(D==22) cout << x << " " << y << " " << y << " " << y << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace abc060_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            bool ret = false;
            for (int i = 1; i < 10000; i++) if ((x[0] * i) % x[1] == x[2]) ret = true;
            Console.WriteLine(ret ? "YES" : "NO");
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n, q;
vector<vector<i64>> g;
vector<i64> w;

void dfs(i64 u, i64 x) {
  w[u] += x;
  for (i64 v : g[u]) {
    dfs(v, w[u]);
  }
}

int main() {
  cin >> n >> q;
  init_n(g, n + 1);
  for (i64 i = 0; i < n - 1; ++i) {
    i64 a, b;
    cin >> a >> b;
    g[a].push_back(b);
  }
  init_n(w, n + 1);
  for (i64 i = 0; i < q; ++i) {
    i64 p, x;
    cin >> p >> x;
    w[p] += x;
  }

  dfs(1, 0);

  for (i64 u = 1; u <= n; ++u) cout << w[u] << ' ';
  cout << endl;
  return 0;
}



Measured memory_bytes: 21120
// atcoder/abc137/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, m;
  while (cin >> n >> m) {
    vector<pair<int, int>> v(n);
    cin >> v;

    map<int, vector<int>> b;
    each (i, v) {
      b[m - i.first].push_back(i.second);
    }

    lli sum = 0;
    priority_queue<lli> q;
    for (int day = m - 1; 0 <= day; --day) {
      if (b[day].size()) {
        each (i, b[day]) q.push(i);
      }
      if (q.size()) {
        sum += q.top();
        q.pop();
      }
    }
    cout << sum << endl;
  }

  return 0;
}


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

int main(){
	ll N,ans,Q;
	cin >> N;
	ans = 0;
	for(int i=1;i<=sqrt(N);i++){
		if (N % i == 0){
			if (N/i != 1){
				ll m1 = N/i-1;
				if( N/m1 == N%m1){
					ans += m1;
				}
			}
			if (N/(N/i) != 1){
				ll m2 = N/(N/i)-1;
				if (N/m2 == N%m2){
					ans += m2;
				}
			}
		}
	}
	cout << ans;
	cin >> N;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define j1 j1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  int N,C; cin>>N>>C;

  int D[C][C];
  int c[N][N];

  rep(i,C){
    rep(j,C){
      int d; cin>>d;
      D[i][j]=d;
    }
  }

  rep(i,N){
    rep(j,N){
      int cc; cin>>cc; --cc;
      c[i][j]=cc;
    }
  }

  ll ans=INF;

  ll temp1[C]={};
  ll temp2[C]={};
  ll temp3[C]={};

  rep(i1,C){
    rep(j,N){
      rep(k,N){
        if((j+k)%3!=0) continue;
        temp1[i1]+=D[c[j][k]][i1];
      }
    }
  }

  rep(i2,C){
    rep(j,N){
      rep(k,N){
        if((j+k)%3!=1) continue;
        temp2[i2]+=D[c[j][k]][i2];
      }
    }
  }


  rep(i3,C){
    rep(j,N){
      rep(k,N){
        if((j+k)%3!=2) continue;
        temp3[i3]+=D[c[j][k]][i3];
      }
    }
  }

  rep(i,C){
    rep(j,C){
      rep(k,C){
        if(i==j or j==k or i==k) continue;
        mini(ans,(temp1[i]+temp2[j]+temp3[k]));
      }
    }
  }

  cout<< ans<<"\n";

}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
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;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;

int N,X,M;
int sum[100005];
int used[100005];
signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	memset(used,-1,sizeof(used));
	cin>>N>>X>>M;
	rep(i,N){
		if(used[X]!=-1){
			int ans=sum[used[X]];
			ans+=(sum[i]-sum[used[X]])*((N-used[X])/(i-used[X]));
			ans+=sum[used[X]+(N-used[X])%(i-used[X])]-sum[used[X]];
			cout<<ans<<"\n";
			return 0;
		}else if(!X){
			cout<<sum[i]<<"\n";return 0;
		}
		else {
			sum[i+1]=sum[i]+X;
			used[X]=i;
			(X*=X)%=M;
		}
	}
	cout<<sum[N]<<"\n";
}

Measured memory_bytes: 4724
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            long N = Long.parseLong(sc.next());
            StringBuilder ans = new StringBuilder();
            while(N > 0) {
                N--;
                ans.insert(0, (char) ('a' + (N % 26)));
                N /= 26;
            }
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 35532
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using i64 = int64_t;

const int INF = 1 << 29;

struct state {
    vector<int> pz;
    int count;
    state() {}
    state(vector<int> a, int b): pz(a), count(b) {}
};

map<vector<int>, int> conv;

void init() {
    vector<int> v({0, 1, 2, 3, 4, 5, 6, 7});
    int num = 0;
    do {
        conv[v] = num++;
    } while (next_permutation(begin(v), end(v)));
}

int puzzle[8];
int ans[40320];

void solve() {
    fill(ans, ans + 40320, INF);

    vector<int> sv({0, 1, 2, 3, 4, 5, 6, 7});

    queue<state> que;
    que.emplace(sv, 0);
    ans[conv[sv]] = 0;

    while (!que.empty()) {
        state st = que.front(); que.pop();

        vector<int> pv(st.pz);

        int zi = -1;
        for (int j = 0; j < 8; ++j) {
            if (pv[j] == 0) {
                zi = j;
                break;
            }
        }

        if (zi % 4 > 0) {
            swap(pv[zi], pv[zi-1]);
            if (st.count+1 < ans[conv[pv]]) {
                ans[conv[pv]] = st.count+1;
                que.emplace(pv, st.count+1);
            }
            swap(pv[zi], pv[zi-1]);
        }

        if (zi % 4 < 3) {
            swap(pv[zi], pv[zi+1]);
            if (st.count+1 < ans[conv[pv]]) {
                ans[conv[pv]] = st.count+1;
                que.emplace(pv, st.count+1);
            }
            swap(pv[zi], pv[zi+1]);
        }

        if (zi >= 4) {
            swap(pv[zi], pv[zi-4]);
            if (st.count+1 < ans[conv[pv]]) {
                ans[conv[pv]] = st.count+1;
                que.emplace(pv, st.count+1);
            }
            swap(pv[zi], pv[zi-4]);
        }

        if (zi < 4) {
            swap(pv[zi], pv[zi+4]);
            if (st.count+1 < ans[conv[pv]]) {
                ans[conv[pv]] = st.count+1;
                que.emplace(pv, st.count+1);
            }
            swap(pv[zi], pv[zi+4]);
        }
    }
}

int main() {
    init(); solve();
    while (cin >> puzzle[0]) {
        vector<int> vv;
        for (int j = 1; j < 8; ++j) cin >> puzzle[j];
        for (int j = 0; j < 8; ++j) vv.push_back(puzzle[j]);
        cout << ans[conv[vv]] << endl;
    }
    return 0;
}

Measured memory_bytes: 8360
#include<stdio.h>

unsigned long powi(unsigned long n, unsigned long m){
        if(m == 0) return 1;
        else {
                unsigned long buff = powi(n, m/2);
                return buff*buff*( m%2 == 0 ? 1 : n );
        }
}

int main(){
        unsigned long N, K;
        char line[128];

        fgets(line, 128, stdin);
        sscanf(line, "%lu %lu", &N, &K);

        printf("%lu\n", K*powi(K-1, N-1));

        return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(void){
  int r, g, b;
  cin >> r >> g >> b;

  int N = 100*r+10*g+b;

  
  if(N%4 == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  
  return 0;
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};

ll f(ll n){
    ll ret = 0;
    if(n % 2 == 0){
        if(n / 2 % 2 == 0) return 0 ^ n;
        else return 1 ^ n;
    }else{
        if((n + 1) / 2 % 2 == 0) return 0;
        else return 1;
    }
}

signed main(){
    ll A, B;
    cin >> A >> B;
    PRINT(f(A - 1) ^ f(B));
    return 0;
}

Measured memory_bytes: 256
fn get_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line
}

fn main() {
    let nums: Vec<usize> = get_line().trim()
        .split_whitespace()
        .map(|n| n.parse().unwrap())
        .collect();
    let (n, m) = (nums[0], nums[1]);

    let mut mat: Vec<Vec<i64>> = Vec::new();
    for _ in 0..n {
        let row: Vec<i64> = get_line().trim().split_whitespace().map(|n| n.parse().unwrap()).collect();
        mat.push(row);
    }

    let mut v: Vec<i64> = Vec::new();
    for _ in 0..m {
        v.push(get_line().trim().parse().unwrap());
    }

    let mut sum;
    for row in mat.iter() {
        sum = 0;
        for i in 0..m {
            sum += row[i] * v[i];
        }
        println!("{}", sum);
    }
}



Measured memory_bytes: 5052
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n,m;
string s;

void solve(){
    cin >> n >> m;
    cin >> s;
    int pos=n,num=0;
    vector<int> ans={};
    while(pos>0){
        //cout << pos << endl;
        Per(i,1,m+1){
            if (pos-i>=0){
                if (s[pos-i]=='0') {
                    num++;
                    ans.push_back(i);
                    pos-=i;
                    break;
                }
            }
            if (i==1) {
                cout << -1 << endl;
                return;
            }
        }
    }

    rep(i,num){
        cout << ans[num-i-1] << " ";
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

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

int main() {
	int N;
	string S;
	cin >> N;
	while(true){
		S=to_string(N);
		if(S.at(0)==S.at(1) && S.at(0)==S.at(2))break;
		N++;
	}
	cout<<N<<endl;
}





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

ans = []
s=[]
s.insert(0,'.'*(w+2))
for i in range(h):
    s.append('.'+input()+'.')
s.append('.'*(w+2))

for y in range(1,h+1):
    column=[]
    for x in range(1,1+w):
        if s[y][x]=='#':
            column.append('#')
        else:
            column.append(str(s[y-1][x-1:x+2].count('#')+s[y][x-1:x+2].count('#')+s[y+1][x-1:x+2].count('#')))
    ans.append(''.join(column))
for i in ans:
    print(i)


Measured memory_bytes: 9220
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
using namespace std;
const int N = 1e6 + 5;
const ll inf = -1e18;
const int MOD = 1e9 + 7;



int main(){
   fast;
   ll n, sum = 0, x;
   cin >> n;
   while(n--){
   	cin >> x;
   	sum += x - 1;
   }
   cout << sum;




   return 0;
} 

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

using namespace std;

set<long long> gd(long long n) {
    set<long long> divs;
    divs.insert(n);
    for (long long x = 2; x * x <= n; x++) {
        if (n % x == 0) {
            divs.insert(x);
            divs.insert(n/x);
        }
    }
    return divs;
}

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

    long long n;
    cin >> n;

    if (n == 2) {
        cout << 1 << endl;
        return 0;
    }

    set<long long> ans = gd(n-1);
    set<long long> d = gd(n);
    for (long long cd : d) {
        long long cn = n;
        while (cn % cd == 0) {
            cn /= cd;
        }
        if (cn % cd == 1) {
            ans.insert(cd);
        }
    }
    cout << ans.size() << endl;

    return 0;
}


Measured memory_bytes: 512
from collections import defaultdict
from math import gcd

n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
mod = 10 ** 9 + 7

p = defaultdict(int)
m = defaultdict(int)
ab0 = 0
for a, b in ab:
    if a == 0 and b == 0:
        ab0 += 1

    elif a == 0:
        m[(0, 1)] += 1
        p[(1, 0)]

    elif b == 0:
        p[(1, 0)] += 1

    else:
        g = gcd(a, b)
        a //= g
        b //= g
        sign = a * b
        a = abs(a)
        b = abs(b)
        if sign < 0:
            m[(a, b)] += 1
            p[(b, a)]
        else:
            p[(a, b)] += 1

ans = 1
for (a, b), v in p.items():
    ans *= pow(2, v, mod) + pow(2, m[(b, a)], mod) - 1
    ans %= mod

ans -= 1
ans += ab0
ans %= mod
print(ans)


Measured memory_bytes: 112020
import math
a,b,x = map(int,input().split())

#水がba**2/2よりも少ないとき
if x <= (a**2)*b//2:
  y = 2*x/(a*b)
  print(math.degrees(math.atan(b/y)))
else:
  y = 2*(b-x/(a**2))
  print(math.degrees(math.atan(y/a)))
  
  
  

Measured memory_bytes: 3060
#include <bits/stdc++.h> 
#define MOD 1000000007
using namespace std;
 
typedef long long int ll;
typedef unsigned long long ull;
int dp[100002];

int main(){

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    int n,k;
    cin >> n >> k;
    int h[n];
    for(int i = 0;i<n;i++){
        cin >> h[i];
        dp[i] = INT_MAX;
    }
    
    dp[0] = 0;
    for(int i = 1; i < n; ++i) {
        for(int j = 1; j <= k; ++j) {
            if(0<= i-j) {
                dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
            }
        }
    }
    printf("%d\n", dp[n-1]);
}


Measured memory_bytes: 4408
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int l[n];
    for(int i=0;i<n;i++)cin >> l[i];
    sort(l,l+n);
    int sum=0;
    for(int i=0;i<n-1;i++)sum+=l[i];
    if(l[n-1]>=sum)cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{

    int n, i, a[7], b[7], c[7];

    for(i = 0; i < 7; i++) {
        scanf("%d %d", &a[i], &b[i]);
        c[i] = a[i] - b[i];
    }

    for(i = 0; i < 7; i++)
        printf("%d\n", c[i]);

    return 0;
}

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

typedef struct {double x, y;}Point;

void koch(int, Point, Point);

int main(){
  Point a, b;
  int n;

  scanf("%d",&n);

  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;

  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);

  return 0;

}

void koch(int n, Point a, Point b)
{
  if(n==0)return;
  Point s, t, u;
  double th = M_PI*60.0/180.0;

  s.x=(2.0*a.x+1.0*b.x)/3.0;
  s.y=(2.0*a.y+1.0*b.y)/3.0;
  t.x=(1.0*a.x+2.0*b.x)/3.0;
  t.y=(1.0*a.y+2.0*b.y)/3.0;
  u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
  u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);
}



Measured memory_bytes: 2056
import java.util.Arrays;
import java.util.Scanner;


public class Main {


	public static void main(String[] args) {

//		long ans = 0;
//		double ans = 0.0;
		int ans = 0;
//		String ans = "";

		Scanner sc = new Scanner(System.in);
//		double waru = 1000000007;


//		long n = sc.nextLong();
//		long m = sc.nextLong();
//		long k = sc.nextLong();

		int A = sc.nextInt();
		int B = sc.nextInt();
		int M = sc.nextInt();
//		int v = sc.nextInt();
//		String s = sc.next();


//		String string = sc.next();
//		StringBuilder s = new StringBuilder(string);

		boolean f = false;

//		String[] s = new String[n];

		int[] a = new int[A];
		int[] b = new int[B];
		int[] x = new int[M];
		int[] y = new int[M];
		int[] c = new int[M];
//		long[] a = new long[n];
//		long[] b = new long[n];
//		int[][] a = new int[n][m];

//		ArrayList<Long> list = new ArrayList<>();

		for (int i = 0; i < A; i++) {
			a[i]= sc.nextInt();
		}
		for (int i = 0; i < B; i++) {
			b[i]= sc.nextInt();
		}
		for (int i = 0; i < M; i++) {
			x[i]= sc.nextInt();
			y[i]= sc.nextInt();
			c[i]= sc.nextInt();
		}

//		for (int i = 0; i < h; i++) {
//			for(int j = 0; j < w; j++) {
//				a[i][j] = sc.nextInt();
//			}
//		}

		ans = 1000000;
		for(int i = 0; i < M; i++) {
			int tmp = a[x[i]-1] + b[y[i]-1] - c[i];
			if(tmp <= ans) {
				ans = tmp;
			}
		}
		Arrays.sort(a);
		Arrays.sort(b);
		if(ans > a[0]+b[0]) {
			ans = a[0]+b[0];
		}

		System.out.println(ans);

		sc.close();
	}
}

Measured memory_bytes: 158172
input()
s = input()

n_total = {'R':0,'G':0,'B':0}
n_0 = {'R':0,'G':0,'B':0}

for i,mid in enumerate(s):
    n_total[mid] += 1
n_1 = n_total.copy()

cnt = 0
for i,mid in enumerate(s):
    n_0[mid] += 1
    n_1[mid] -= 1
    if mid == 'R':
        cnt += n_0['G'] * n_1['B'] + n_0['B'] * n_1['G']
    if mid == 'G':
        cnt += n_0['R'] * n_1['B'] + n_0['B'] * n_1['R'] 
    if mid == 'B':
        cnt += n_0['G'] * n_1['R'] + n_0['R'] * n_1['G'] 
    for j in range(1,min(i, len(s) - 1 - i)+1):
        if (mid != s[i-j]) & (mid != s[i+j]) & (s[i+j] != s[i-j]):
            cnt -=1
print(cnt)    

Measured memory_bytes: 9192
var s:ansistring;
begin
  readln(s);
  if s[pos(' ',s)-1]<>s[pos(' ',s)+1] then
  begin
    writeln('NO');
    halt;
  end;
  delete(s,pos(' ',s),1);
  if s[pos(' ',s)-1]<>s[pos(' ',s)+1] then
  begin
    writeln('NO');
    halt;
  end;
  writeln('YES');
end.

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
 
int main() {
	int i, a, n, max, min;
	scanf("%d", &n);
	for (i=0; i < n ;i++) {
		scanf("%d", &a);
		if (i == 0) {
			max = a;
			min = a;
		}
		if (a > max) max = a;
		if (a < min) min = a;
	}
        printf("%d\n", max-min);
	return 0;
}

Measured memory_bytes: 128
//
// Created by moono on 2018/10/27.
//

#include <stdio.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

bool check(int n, int A, int B){
    int sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }


    if(A <= sum && sum <= B)
        return true;


    return false;
}


int main() {
    int N, A, B;
    char S[16];
    
    // 
    cin >> N >> A >> B;

    int ans = 0;
    for (int i = 0; i <= N; ++i) {
        if(check(i, A, B)) ans += i;
    }

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

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

class Program
{
    public Program()
    {
        string[] inputs = Console.ReadLine().Split();
        int h = int.Parse(inputs[0]);
        int w = int.Parse(inputs[1]);
        int k = int.Parse(inputs[2]) - 1;
        int[] pattern = new int[w - 1];
        int maxPattern = 0;
        foreach(int i in Enumerable.Range(0, (int)Math.Pow(2, w - 1)))
        {
            if(w > 1 && Enumerable.Range(0, w - 1)
                .Any(x => (((i >> x) & (i >> (x + 1))) & 1) == 1))
                continue;
            //Console.WriteLine(Convert.ToString(i, 2).PadLeft(w));
            foreach(int j in Enumerable.Range(0, w - 1))
            {
                if(((i >> j) & 1) == 1)
                pattern[j]++;
            }
            maxPattern++;
        }
        //Console.WriteLine(string.Join(",", pattern));
        //Console.WriteLine(maxPattern);
        
        long[][] dp = Enumerable.Range(0, h + 1).Select(x => new long[w]).ToArray();
        dp[0][0] = 1;
        foreach(int y in Enumerable.Range(0, h))
            foreach(int x in Enumerable.Range(0, w))
            {
                if(dp[y][x] >= 1000000007)
                    dp[y][x] %= 1000000007;
                int p = maxPattern;
                if(x != 0)
                {
                    p -= pattern[x - 1];
                    dp[y + 1][x - 1] += dp[y][x] * pattern[x - 1];
                }
                if(x != w - 1)
                {
                    p -= pattern[x];
                    dp[y + 1][x + 1] += dp[y][x] * pattern[x];    
                }
                dp[y + 1][x] += dp[y][x] * p;
                    
            }
        Console.WriteLine(dp[h][k] % 1000000007);
    }
    static void Main(string[] args)
    {
        var p = new Program();
    }
}


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


void solve(long long X, long long A){
    if(X<A){
        cout<<0<<endl;
    }
    else cout<<10<<endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    long long A;
    scanf("%lld",&A);
    solve(X, A);
    return 0;
}


Measured memory_bytes: 256
//C
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while (true)

long long D,G;
long long p[10],c[10];
map<pair<vector<bool>,long long>,long long> dp;

long long solve(vector<bool> state, long long nokori){
    if(dp.count(make_pair(state,nokori)) == 1) return dp[make_pair(state,nokori)];
    long long re = LL_MAX;
    for(long long i=0; i<D; i++){
        if(state[i] == false){
            long long tmp = nokori;
            for(long long j=0; j<p[i]; j++){
                tmp -= (i+1) * 100;
                if(tmp <= 0){
                    re = min(re,j+1);
                    break;
                }
            }
            tmp -= c[i];
            if(tmp <= 0){
                re = min(re,p[i]);
                continue;
            }
            state[i] = true;
            re = min(re,p[i]+solve(state,tmp));
            state[i] = false;
        }
    }
    dp[make_pair(state,nokori)] = re;
    return re;
}

int main(){
    
    cin >> D >> G;
    vector<bool> state;
    for(long long i=0; i<D; i++){
        cin >> p[i] >> c[i];
        state.push_back(false);
    }

    cout << solve(state,G) << endl;
    

    return 0;
}

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

const ll mod = 1e9 + 7;

ll mod_pow(ll x, ll n) {
    ll ret = 1;
    while (n) {
        if (n&1) {
            ret = ret * x % mod;
            x = x * x % mod;
            n >>= 1;
        }
        else {
            x = x * x % mod;
            n >>= 1;
        }
    }
    return ret;
}

int n;
vector<int> g[201010];
ll ans = 0;

ll dfs(int v, int p) {
    vector<int> child;
    int sz = 0;

    for (auto & u : g[v]) {
        if (u == p) continue;
        child.push_back(dfs(u, v));
        sz += child[child.size()-1];
    }

    child.push_back(n - 1 - sz);

    ll prob = mod_pow(mod_pow(2, n), mod-2);
    for (auto & c : child) {
        prob += mod_pow(mod_pow(2, n-c), mod-2) * (1 - mod_pow(mod_pow(2, c), mod-2)) % mod;
    }
    ans += (mod_pow(2, mod-2) - prob) % mod;
    ans %= mod;

    return sz + 1;
}

int main() {
    cin >> n;

    rep(i, n-1) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    dfs(0, -1);
    cout << ans << endl;
}


Measured memory_bytes: 24832
#include<iostream>
using namespace std;
int main()
{
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  while(a>=b){
    b*=2;
    k--;
  }
  while(b>=c){
    c*=2;
    k--;
  }
  if(k>=0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3628
n=int(input())
import math
print(math.factorial(n)%1000000007)

'''
p,m=map(int,input().split())
s=bin(p)
s=s[2:]
n=len(s)


ans=pow(2,n) -1
if(m>=2):
    print(ans)
else:
    print(p)


m,n=map(int,input().split())
a=[False]*(n+1)
a[0]=True
for i in range(m):
    temp=list(map(int,input().split()))
    for kk in temp[1:]:
        a[kk]=True
ans=True
for nn in a:
    ans = nn and ans
if(ans):
    print("YES")
else:
    print("NO")



y,b,r = map(int,input().split())

if(r>b):
    if(b>y):
        print(int((3*y)+3))
    else:
        print(int(3*b))
else:
    if(b<y):
        print(int((3*y)-3))
    else:
        print()


  '''  




        

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

typedef long long int ll;
using ii= pair<ll,ll>;
#define all(o) (o).begin(),(o).end()
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ld long double
#define eps 0.00000000001

class prioritize{
    public: bool operator() (ii &p1,ii &p2){
        return p1.F<p2.F;
    }
};

int main()
{
    
    #ifndef ONLINE_JUDGE
        freopen("input1.txt","r", stdin);
        freopen("output1.txt","w",stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    ll n,d;
    cin>>n>>d;
    ll cc=0;
    while(n--){
        ll x,y;
        cin>>x>>y;

        if(x*x+y*y<=d*d){
             cc++;
        }
    }

    cout<<cc<<"\n";

}

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

int main()
{
    int r;
    cin >> r;
    cout << 2 * 3.141592 * r << endl;
    return 0;
}

Measured memory_bytes: 3700
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        int[] array = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        Scanner in = new Scanner(System.in);
        int k = in.nextInt();
        System.out.print(array[k-1]);

    }

}


Measured memory_bytes: 21716
# 一番シンプルな code
# このパターンで約数を計算で求めると TLE_※がミソ

n = int(input())
l = list(map(int,input().split()))

num = max(l)+1
rcd = [0 for _ in range(num)]

for x in l: #※ 重複、自信を含めて約数調査
    for y in range(x, num, x): #※ 計算ではなく倍数で約数をカウントして...
            rcd[y] += 1

ans = 0
for k in l: # 各要素について...
    if rcd[k] == 1: # 約数の数が'1'の場合, 'ans'としてカウント
        ans += 1

print(ans)


Measured memory_bytes: 32324
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for (int i = (m); i < (int)(n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define all(vec) vec.begin(), vec.end()
using namespace std;

int main(){
  int a, b, c, d, e;
  //string c;
  cin >> a >> b >> c >> d >> e;

  //int ans = 0;
  string ans = "Yes";
  if (c - e < 0 || c + e > a || d - e < 0 || d + e > b) ans = "No";
  
  cout << ans << endl;
}


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

int main(void){
	char S[101];
	scanf("%s",S);
	int i;
	for (i = 0; i < strlen(S); i++){
		if(1 == i % 2){
			if(S[i] == 'R'){
				printf("No");
				return 0;
			}
		}
		else{
			if(S[i] == 'L'){
				printf("No");
				return 0;
			}	
		}
	}
	printf("Yes");
	return 0;
}


Measured memory_bytes: 128
let () =
  let n = read_int () in
  let ans = ref (-1) in
  for i = 0 to n do
    let x = float_of_int i *. 1.08 |> int_of_float in
    if x = n then ans := i else ()
  done;
  if !ans >= 0 then print_int !ans else print_string ":(";
  print_newline ()


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v) cerr << #v << ":"; rep(i, v.size()) cerr << " " << v[i]; cerr<<endl
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 = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> P(n);
    rep(i, n) cin >> P[i];
    sort(all(P));
    int ans = 0;
    rep(i, k) {
        ans += P[i];
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3652
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに実装したソースコード
 */
public class Main {

	private static final long MOD = 998_244_353L;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), k = scanner.nextInt();
			long[] dp = new long[n + 2];
			Arrays.fill(dp, 0L);
			dp[0] = 1L;
			dp[2] = -1L;
			int[] l = new int[k], r = new int[k];
			IntStream.range(0, k).forEach(i -> {
				l[i] = scanner.nextInt();
				r[i] = scanner.nextInt();
			});
			IntStream.rangeClosed(1, n).forEach(i -> {
				dp[i] = (dp[i] + dp[i - 1]) % MOD;
				IntStream.range(0, k).filter(j -> i + l[j] <= n).forEach(j -> {
					dp[i + l[j]] = (dp[i + l[j]] + dp[i]) % MOD;
					dp[Math.min(n + 1, i + r[j] + 1)] = (dp[Math.min(n + 1, i + r[j] + 1)] - dp[i] + MOD) % MOD;
				});
			});
			System.out.println(dp[n]);
		}
	}
}


Measured memory_bytes: 59108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii  = pair<int,int>;
const int INF=1001001001;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define MOD 1000000007
#define EPS 10e-8
int gcd(int a,int b){return b?gcd(b,a%b):a;}    //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数

int main(){
    int a, b;
    cin >> a >> b;
    if(a>9||b>9)
        cout << -1 << endl;
    else{
        cout << a * b << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
int main()
{
    std::string N;
    std::cin >> N;

    int sum = 0;
    for (int i = 0; i < N.size(); i++) { sum += N[i] - '0'; }

    if (std::stoi(N) % sum == 0) { std::cout << "Yes" << std::endl; }
    else
    {
        std::cout << "No" << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct tree
{
	int node;
	int parent = -1;
	int depth = 0;
	vector<int> edge;
};
vector<struct tree> T(100010);
void dep(int u);

int main()
{
	int n;
	cin >> n;
	for(int i=0; i<n; i++)
	{
		int id, k;
		scanf("%d%d", &id, &k);
		T[id].node = id;
		for(int j=0; j<k; j++)
		{
			int c;
			scanf("%d", &c);
			T[c].parent = id;
			T[id].edge.push_back(c);
		}
	}
	int root;
	for(int i=0; i<n; i++)
	{
		if(T[i].parent != -1) continue;
		root = i;
	}
	dep(root);

	for(int i=0; i<n; i++)
	{
		printf("node %d: parent = %d, depth = %d, ", i, T[i].parent, T[i].depth);
	   if(T[i].parent == -1)
		   cout << "root, [";
	   else if(T[i].edge.size() != 0)
		   printf("internal node, [");
	   else
		   printf("leaf, [");
	   for(int j=0; j<T[i].edge.size(); j++)
	   {
		   if(j != T[i].edge.size() -1)
			   printf("%d, ", T[i].edge[j]);
		   else
			   printf("%d", T[i].edge[j]);
	   }
	   printf("]\n");
	}  	   
}
void dep(int u)
{
	//cout << "root_size :" << T[u].edge.size() << endl;
	for(int i=0; i<T[u].edge.size(); i++)
	{
		int next = T[u].edge[i];
		T[next].depth = T[u].depth + 1;
		dep(next);
	}
}


Measured memory_bytes: 7620
#include <bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  long ans = 0, count = 0;
  for(int i = 0; i < S.size(); i++){
    if(S.at(i) == 'B')count++;
    else ans += count;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main()
{
 int A,B,l;
 l=0;
 cin >> A >> B;
 l=A*B;
 if((A+B)>l)
 l=A+B;
 if((A-B)>l)
 l=A-B;
 cout << l;
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>

using namespace std;
typedef long long lint;

const int MAXN = 100100;
vector<pair<int, int> > G[MAXN];
lint depth[MAXN];
bool visited[MAXN];

bool dfs(int v, lint d) {
    depth[v] = d;
    visited[v] = true;
    for (const auto e : G[v]) {
        if (visited[e.first]) {
            if (depth[e.first] != d + e.second) {
                return false;
            }
        } else {
            if (!dfs(e.first, d + e.second)) {
                return false;
            }
        }
    }
    return true;
}

int main() {
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int l, r, d;
        cin >> l >> r >> d;
        --l; --r;
        G[l].emplace_back(r, d);
        G[r].emplace_back(l, -d);
    }
    for (int i = 0; i < N; i++) {
        if (visited[i]) continue;
        if (!dfs(i, 0)) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 11520
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define PI acos(-1)
#define fs first
#define sc second
#define MAX 0x3f3f3f3f
#define debug freopen("1.in", "r", stdin), freopen("1.out", "w", stdout);
#define ios                                                                    \
    ios::sync_with_stdio(false);                                               \
    cin.tie(0);                                                                \
    cout.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const ll maxn = 2e5 + 7;
ll a, b, c, d, ans;

int main() {
    cin >> a >> b >> c >> d;
    ans = max(a * c, a * d);
    ans = max(ans, b * c);
    ans = max(ans, b * d);
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3180