akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i, n) for(int i = 0; i < (int)(n);++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define fi first
#define se second
#define pb push_back
#define pll pair<ll,ll>
#define vi vector<int>
#define vb vector<bool>
#define vvi vector<vi>
#define vpll vector<pll>
#define vll vector<ll>
#define vvll vector<vll>
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()


void fastik(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}
//ifstream &cin
void solve() {

}

int main() {
    fastik();
    //ifstream cin("input.txt");
    /*ll t = 1;
    cin >> t;
    while (t--) {
        solve();
    }*/
    ll n,d;
    cin >> n >> d;
    ll ans = n/(2*d+1);
    if(n%(2*d+1)){
        ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))
N = int(input())


def factorint(N):

    table = []
    while(N > 1):
        for i in range(2,N+1):
            if N%i == 0:
                while N%i == 0:
                    N = N//i
                    table.append(i)
                break
    return table

l = []
for n in range(1,N+1):
    l += factorint(n)
c = collections.Counter(l)
com = {74:0,24:0,14:0,4:0,2:0}
# print(c)
for key in c.keys():
    if c[key] >= 74:
        com[74] += 1
    if c[key] >= 24:
        com[24] += 1
    if c[key] >= 14:
        com[14] += 1
    if c[key] >= 4:
        com[4] += 1
    if c[key] >= 2:
        com[2] += 1
# print(com)
ans = 0
ans += com[74]
ans += com[24] * (com[2] - 1)
ans += com[14] * (com[4] - 1)
ans += com[4] * (com[4] - 1)* (com[2] - 2) //2
print(ans)


Measured memory_bytes: 6344
#include <stdio.h>
#include <string.h>
int main(void)
{
	int cnt=1;

	int a=0,b=0,ab=0,o=0;
	char n[3];
	int s;
	while(scanf("%d,%s",&s,n)!=EOF){
		if(strcmp(n,"A")==0)a++;
		else if(strcmp(n,"B")==0)b++;
		else if(strcmp(n,"AB")==0)ab++;
		else o++;
	}
	printf("%d\n%d\n%d\n%d\n",a,b,ab,o);
	return 0;
}

Measured memory_bytes: 596
#editorial
n,k=map(int,input().split())
*lr,=[tuple(map(int, input().split())) for _ in range(k)]
res =[0]*(2*n+3)
##############
diff=[0]*(2*n+3)
######
#res[0]=1

diff[0]=1
diff[1]=-1
mod=998244353

for i in range(n+1):
    res[i]=res[i-1]+diff[i]
    res[i]%=mod
    diff[i]%=mod
    for li,ri in lr:
        diff[i+li]+=res[i]
        diff[i+ri+1]-=res[i]
    #print(res[:n+1])
    #print((diff[:n+1]))
print(res[n-1]%mod)
#print(res[:n+1])
#print((diff[:n+1]))
    

Measured memory_bytes: 79284
#include<stdio.h>
int main(){
int s;
scanf("%d",&s);

int h, m;

h = s / 3600;
m = (s - (3600*h))/60;
s = s - 3600*h - m * 60;
printf("%d:%d:%d\n",h,m,s);
return 0;
}


Measured memory_bytes: 2120
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,k;
  cin>>n>>k;
  vvll t(n,vll(0));
  rep(i,n-1){
    ll a,b;
    cin>>a>>b;
    a--;b--;
    t[a].pb(b);
    t[b].pb(a);
  }
  vll ans(n,-1);
  queue<ll> que;
  que.pu(0);
  ans[0]=k;
  while(sz(que)){
    ll s=que.front();
    que.pop();
    if(s==0){
      ll now=k-1;
      for(auto p:t[s]){
        if(ans[p]!=-1) continue;
        ans[p]=now;
        now--;
        que.pu(p);
      }
    }
    else{
      ll now=k-2;
      for(auto p:t[s]){
        if(ans[p]!=-1) continue;
        ans[p]=now;
        now--;
        que.pu(p);
      }
    }
  }
  ll cu=1;
  rep(i,n){
    cu*=ans[i];
    cu%=MOD;
  }
  COUT(cu);
}

Measured memory_bytes: 8052
#include <cstdio>

using namespace std;

int main()
{

  int n,m,c[204]={0},tmp[204]={0};

  scanf("%d%d",&n,&m);

  for(int i = 1;i <= n*2;i++){
    c[i] = i;
  }

  for(int i = 0;i < m;i++){
    int t;
    scanf("%d",&t);

    if(t == 0){
      for(int j = 1;j <= n*2;j++){
	if(j % 2 == 0){
	  tmp[j] = c[n+j/2];
	}else{
	  tmp[j] = c[(j+1)/2];
	}
      }
    }else{
      for(int j = 1;j <= n*2;j++){
	if(j <= t){
	  tmp[n*2-t+j] = c[j];
	}else{
	  tmp[j-t] = c[j];
	}
      }
    }
    for(int j = 1;j <= n*2;j++){
      c[j] = tmp[j];
    }
  }

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

}


Measured memory_bytes: 1028
#include<iostream>
using namespace std;
int main(){
  int n,over,pr1,pr2;
  int ans;
  cin>>n;
  cin>>over;
  cin>>pr1;
  cin>>pr2;
  if(n>over){
    ans=over*pr1+(n-over)*pr2;
  }else{
    ans=n*pr1;
  }
  cout<<ans;
  return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int res = 0;
  char prev = s[0];
  s += '#';
  for (int i = 1; i < n+1; i++) {
    if (prev == s[i]) continue;
    res++;
    prev = s[i];
  }
  cout << res << endl;
  return 0;
}

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

using namespace std;

const int N=1e5+1;

int n;
struct zyy
{
    int y,lh,yh;
}a[N*3];

bool cmp1(zyy a,zyy b)
{
	return a.y<b.y;
}

bool cmp2(zyy a,zyy b)
{
	return a.yh<b.yh;
}

int book[N*3];
long long vis[N*3];

inline int find(bool x,int k)
{
	if(x==0)
	{
		while(1)
		{
			k+=1;
			if(book[k]!=0)return k;
		}
	}
	if(x==1)
	{
		while(1)
		{
			k-=1;
			if(book[k]!=0)return k;
		}
	}
}

long long f[N*3];

int main()
{
	//freopen("2.in","r",stdin);
	//freopen("33.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n*3;i++)
	{
		scanf("%d",&a[i].y);
		a[i].yh=i;
	}	
	sort(a+1,a+n*3+1,cmp1);
	a[1].lh=1;
	vis[1]=a[1].y;
	for(int i=2;i<=n*3;i++)
	{
		if(a[i].y==a[i-1].y)a[i].lh=a[i-1].lh;
		else a[i].lh=a[i-1].lh+1;
		vis[a[i].lh]=a[i].y;
	}
	sort(a+1,a+3*n+1,cmp2);
	long long num1=0;
	int nummin=2000000000;
	for(int i=1;i<=n;i++)
	{
		num1+=a[i].y;
		book[a[i].lh]+=1;
		nummin=min(nummin,a[i].lh);
	}
	f[n]=num1;
	for(int i=n+1;i<=2*n;i++)
	{
		if(a[i].lh<=nummin)
		{
			f[i]=f[i-1];
		}
		else
		{
			f[i]=f[i-1]-vis[nummin]+a[i].y;
			book[a[i].lh]+=1;
			book[nummin]-=1;
			if(book[nummin]>=1)continue;
			else
			{
				nummin=find(0,nummin);
			}
		}
	}
	memset(book,0,sizeof book);
	int nummax=0;
	long long num2=0;
	for(int i=3*n;i>=2*n+1;i--)
	{
		num2+=a[i].y;
		book[a[i].lh]+=1;
		nummax=max(nummax,a[i].lh);
	}

	long long ans=f[2*n]-num2;
	for(int i=2*n;i>=n+1;i--)
	{
		if(a[i].lh<nummax)
		{
			num2=num2-vis[nummax]+a[i].y;
			book[a[i].lh]+=1;
			book[nummax]-=1;
			if(!book[nummax]) nummax=find(1,nummax);
		}
		ans=max(ans,f[i-1]-num2);
	}
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 8320
#include <bits/stdc++.h>
#define rep(i, n) for (long long int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
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;
}
const long long INF = 1LL << 60;
int cnt = 0;
int main()
{
    int a, b;
    cin >> a >> b;
    if (a % 2 == 0 | b % 2 == 0)
    {
        cout << "Even" << endl;
        return 0;
    }
    else
    {
        cout << "Odd" << endl;
    }
    return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n,k,ans;
bool used[100010];
vector<int>v[100010];
void dfs(int x){
	used[x]=true;
	if(k-(int)v[x].size()-1<0){
		ans=0;
		return;
	}
	if(x==0){
		ans*=kaijo[k-1]*g(kaijo[k-(int)v[x].size()-1])%MOD;
		ans%=MOD;
		for(int i:v[x]){
			dfs(i);
		}
	}
	else{
		ans*=kaijo[k-2]*g(kaijo[k-(int)v[x].size()-1])%MOD;
		ans%=MOD;
		for(int i:v[x]){
			if(!used[i])dfs(i);
		}
	}
}
signed main(){
	cin>>n>>k;
	init_fact(100010);
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		a--,b--;
		v[a].pb(b);
		v[b].pb(a);
	}
	ans=k;
	dfs(0);
	cout<<ans<<endl;
	return 0;
}


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

const long long int inf = 1000000000000000000;

int main()
{
    int n;
    cin >> n;
    long long int ans = 1;
    long long int prev;
    long long int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }
    for (int i = 0; i < n; i++)
    {
        prev = ans;
        if (inf / ans < a[i] || ans < 0 || ans > inf)
        {
            cout << -1 << endl;
            return 0;
        }
        ans *= a[i];
    }
    cout << ans << endl;
    return 0;
}


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

int n, m;

char wcz[307][307];

int inf=1000000000;

int dp[307][307];

int ile[307][307];

int wyn;

void licz(int v)
{
    for (int i=0; i<=n; i++)
        for (int j=0; j<=n; j++)
            dp[i][j]=inf;
    dp[0][0]=0;
    for (int i=0; i<=n; i++)
    {
        for (int j=0; j<=n; j++)
        {
            ile[j][i]=0;
        }
    }
    for (int i=n; i>=0; i--)
    {
        for (int j=n; j>=0; j--)
        {
            ile[i][j]=ile[i+1][j+1]+(wcz[i+1][v]==wcz[j+1][v+1] && i<n && j<n);
        }
    }
    for (int i=0; i<=n; i++)
    {
        for (int j=0; j<=n; j++)
        {
            dp[i+1][j]=min(dp[i+1][j], dp[i][j]+ile[i][j]);
            dp[i][j+1]=min(dp[i][j+1], dp[i][j]+ile[i][j]);
        }
    }
    wyn+=dp[n][n];
}

int main()
{
    scanf("%d%d", &n, &m);
    for (int i=n; i; i--)
        scanf("%s", wcz[i]+1);
    for (int i=1; i<m; i++)
        licz(i);
    printf("%d\n", wyn);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007
#define maxn 300005
#define IN freopen("nocross.in","r",stdin)
#define OUT freopen("nocross.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define ROF(i,a,b) for(i=a ; i>=b ; i--)
#define DBG pf("Hi\n")
#define INF 2000000000000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 20
#define off 1000000
#define sq(x) ((x)*(x))

using namespace __gnu_pbds;
using namespace std ;

template <class T>  inline void smax(T &x,T y){ x = max((x), (y)); }
template <class T>  inline void smin(T &x,T y){ x = min((x), (y)); }

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

vector <int> g[maxn] ;

int bfs(int k)
{
    int vis[k] ;
    int i , j , l ;

    for(i=0 ; i<k ; i++) vis[i] = 50 ;

    queue<int> q ;

    for(i=1 ; i<=9 ; i++){
        if( vis[ i%k ] > i )
        {
            vis[ i%k ] = i ;
            q.push(i%k) ;
        }
    }

    while(!q.empty())
    {
        int u = q.front() ;
        q.pop() ;
        for(i=0 ; i<10 ; i++)
        {
            int v = (u*10+i)%k ;
            if( vis[v]>vis[u]+i ){
                vis[v] = vis[u]+i ;
                q.push(v) ;
            }
        }
    }
    return vis[0] ;
}

int main()
{
    int i , j , k , l , m , n ;

    cin>>k ;

    printf("%d\n",bfs(k)) ;

    return 0 ;
}


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

typedef long long LL;

#define FOR(i, a, b) for (int i = (a), i##_END_ = (b); i <= i##_END_; i++)
#define DNF(i, a, b) for (int i = (a), i##_END_ = (b); i >= i##_END_; i--)

template <typename Tp> void in(Tp &x) {
	char ch = getchar(), f = 1; x = 0;
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') ch = getchar(), f = -1;
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= f;
}

template <typename Tp> void out(Tp x) {
	if (x > 9) out(x / 10);
	putchar(x % 10 + '0');
	return;
}

template <typename Tp> Tp Max(const Tp &x, const Tp &y) {return x > y ? x : y;}
template <typename Tp> Tp Min(const Tp &x, const Tp &y) {return x < y ? x : y;}
template <typename Tp> bool chkmax(Tp &x, Tp y) {return x >= y ? 0 : (x=y, 1);}
template <typename Tp> bool chkmin(Tp &x, Tp y) {return x <= y ? 0 : (x=y, 1);}

int n;

int abs(int x) {return x < 0 ? -x : x;}

int main()
{
	in(n);

	int pret = 0, nx = 0, ny = 0;

	FOR(i, 1, n) {
		int t, x, y;
		in(t); in(x); in(y);
		if (t - pret >= abs(x - nx) + abs(y - ny) &&
			(((t - pret) & 1) == ((abs(x - nx) + abs(y - ny)) & 1)))
		{
			pret = t;
			nx = x;
			ny = y;
			continue;
		}
		else {
			puts("No");
			return 0;
		}
	}

	puts("Yes");
	
	return 0;
}


Measured memory_bytes: 256
while True :
    x, y = map(int, input().split())
    if x == 0 and y == 0 :
        break
    
    ans = 0
    while True :
        if y == 0 :
            break
        if x < y :
            x, y = y, x
        x = x % y
        x, y = y, x
        ans += 1
    
    print(x, ans)


Measured memory_bytes: 5604
#include<stdio.h>
int main ()
{
	int a,b,c;
	int max=0;
	long long sum;
	scanf ("%d%d%d",&a,&b,&c);
//	max=a>b?a:b;
//	max=max>c?max:c;
if (a>b) max=a;
else max=b;
if (max<c) max=c;
	sum=3*max-a-b-c;
	if (sum%2==0) printf ("%lld\n",sum/2);
	else printf("%lld\n",sum/2+2);
//	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#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 all(a) (a).begin(),(a).end()

#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<" "<<#x<<"="<<x

#define bit(k) (1LL<<(k))

typedef long long ll;

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

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

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

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

    int N,R;
    cin>>N>>R;
    if(N >= 10){
        cout<<R<<endl;
    }
    else{
        cout<<R + 100 * (10 -N)<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int i=a;i<b;i++)
#define vi vector<int>
#define vii vector<ll>
#define all(x) x.begin(),x.end()
#define mod 998244353
#define pb push_back
#define ii pair<int,int>
#define iii pair<ll,ll>
#define MAX 10000000000000
#define pi 3.1415926535
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n,k; cin>>n>>k;
    vi a(n), dp(k+1);
    f(i,0,n) cin>>a[i];
    dp[0] = 2;
    f(i,1,k+1) {
        int flag = 0;
        f(j,0,n) {
            if(a[j]>i)
                break;
            
            if(dp[i-a[j]]==2) 
                flag++;
        }
        if(flag)
            dp[i] = 1;
        else
            dp[i] = 2;
    }
    if(dp[k]==1) cout<<"First\n";
    else cout<<"Second\n";
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
	int i,j,n,a[100],cst[300],max,min,min2,sum,cnt;
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&a[i]);
//	for(i=0;i<n;i++) printf("%d\n",a[i]);
	max=-101;
	for(i=0;i<n;i++){
		if(max<a[i]) max=a[i];
	}
	min=101;
	for(i=0;i<n;i++){
		if(min>a[i]) min=a[i];
	}
	cnt=0;
	for(i=min;i<=max;i++){
		sum=0;
		for(j=0;j<n;j++){
			sum+=(a[j]-i)*(a[j]-i);
		}
		cst[cnt]=sum;
		cnt++;
	}
//	for(i=0;i<cnt;i++) printf("%d\n",cst[i]);
	min2=10000000;
	for(i=0;i<cnt;i++){
		if(min2>cst[i]) min2=cst[i];
	}
	printf("%d\n",min2);
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    int ans = 0;
    for(int i = 1; i<n-1; i++){
        if(p[i-1] < p[i] && p[i] < p[i+1]) {
            ans++;
        }
        else if(p[i-1] > p[i] && p[i] > p[i+1]){
            ans++;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int K=sc.nextInt();
        int indexone=0;
        
        for(int i=0;i<N;i++){
            if(sc.nextInt()==1){
                indexone=i;
                break;
            }
        }
        
        int ANS=0;
        
        if(N==K){
            ANS=1;
        }else{
            ANS+=((N-3+K)/(K-1));
        }
        
        System.out.print(ANS);
    }
}

Measured memory_bytes: 48264
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  vector<int> a;
  int n;
  cin >> n;
  for (; n; n /= 10) a.push_back(n % 10);
  bool found = false;
  for (int i = 2; i < 4; ++i) {
    if (a[i] == a[i - 1] && a[i] == a[i - 2]) {
      found = true;
    }
  }
  cout << (found ? "Yes" : "No") << endl;
  return 0;
}


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

int main(){
  int k;
  cin >> k;
  int a, b;
  cin >> a >> b;
  
  int hantei = 0;
  for(int i=1; i <= 1000; i++){
    if(a <= k*i && b >= k*i) {
      hantei = 1;
      break;
    }
  }
  if(hantei){cout << "OK" << endl;
  }else
    cout << "NG" << endl;
}

  

Measured memory_bytes: 3632
from math import gcd


def main():
    input()  # N
    array = [int(x) for x in input().split()]
    MAX_A = 10 ** 6 + 2
    histgram = [0] * MAX_A
    for x in array:
        histgram[int(x)] += 1
    pairwise = True
    for divider in range(2, MAX_A):
        count = 0
        for counted in histgram[divider::divider]:
            count += counted
        if count > 1:
            pairwise = False
    if pairwise:
        return 'pairwise coprime'
    gcd_now = 0
    for x in array:
        gcd_now = gcd(x, gcd_now)
    if gcd_now == 1:
        return 'setwise coprime'
    else:
        return 'not coprime'


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 127180
#include <iostream>
#include<string>
#include<set>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<iomanip>
#include<cmath>
#include<stack>
#include <cctype>
#include <cstdio>
#define endl '\n'
#define Bedoazim ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

const long long N = 1e5 + 5;


int main() {

    Bedoazim

    long long n, monsters[N], heroes[N];

    cin >> n;

    long long totalMonsters = 0;

    for (int i = 0; i < n + 1; i++) {

        cin >> monsters[i];

        totalMonsters += monsters[i];
    }
    for (int i = 0; i < n; i++) {

        cin >> heroes[i];
    }


    for (int i = 0; i < n; i++) {

        if (i == n - 1) {

            if (monsters[n] >= heroes[i]) {

                monsters[n] -= heroes[i];

                heroes[i] = 0;
            }
            else if (monsters[n] > 0) {

                heroes[i] -= monsters[n];

                monsters[n] = 0;
            }
            if (monsters[i] >= heroes[i]) {

                monsters[i] -= heroes[i];

                heroes[i] = 0;
            }
            else if (monsters[i] > 0) {

                heroes[i] -= monsters[i];

                monsters[i] = 0;
            }



        }

        else {

            if (monsters[i] >= heroes[i]) {

                monsters[i] -= heroes[i];

                heroes[i] = 0;
            }
            else if (monsters[i] > 0) {

                heroes[i] -= monsters[i];

                monsters[i] = 0;
            }
            if (monsters[i + 1] >= heroes[i]) {

                monsters[i + 1] -= heroes[i];

                heroes[i] = 0;
            }
            else if (monsters[i + 1] > 0) {

                heroes[i] -= monsters[i + 1];

                monsters[i + 1] = 0;
            }
        }
    }
   
    long long remainMonsters = 0;

    for (int i = 0; i < n + 1; i++) {
        
        remainMonsters += monsters[i];
    }
    
    cout << totalMonsters - remainMonsters;
}

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

int main() {
    int N;
    int Y;
    cin >> N >> Y;
    bool X=0;
    for(int x=0;x<=N;x++){
        if(X==1){
            break;
        }
        for(int y=0;y<=N;y++){
            if(X==1){
                break;
            }
            if(x+y<=N && 10000*x+5000*y==Y-1000*(N-x-y)){
               cout << x << " " << y << " " << N-x-y;
               X=1;
               break;
            }
        }            
    }
    if(X==0){
        cout << -1 << " " << -1 << " " << -1;
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
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;}

////////// 二項係数(N<=10^7) //////////

ll fac[MAX],finv[MAX],inv[MAX];
// fac[i] i!
// finv[i] i!の逆元
// inv[i] iの逆元

// テーブルを作る前処理
void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(ll i=2; i<MAX; ++i){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

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

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

////////// 繰り返し二乗法 //////////

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

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

int main(){
  COMinit();
  ll K,ans=0LL;
  string S;
  cin>>K>>S;
  ll P[2000010],Q[2000010];
  P[0]=1;
  Q[0]=1;
  RREP(i,S.size()+K){
    P[i]=P[i-1]*25%MOD;
    Q[i]=Q[i-1]*26%MOD;
  }
  
  
  REP(i,S.size()){
    ans+=COM(S.size()+K,i)*P[S.size()+K-i];
    ans%=MOD;
  }
  ans=Q[S.size()+K]-ans;
  ans%=MOD;
  if(ans<0) ans+=MOD;
  co(ans);
  return 0;
}

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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  arrll(a,n);
  ll ans=0;
  rep(i,n-1){
    if(a[i]%2==0){
      ans += a[i]/2;
      a[i]=0;
    } else if(a[i+1]==0){
      ans += a[i]/2;
      a[i]=1;
    } else {
      ans += a[i]/2 + 1;
      a[i+1]--;
      a[i]=0;
    }
  }
  ans += a[n-1]/2;
  prt(ans);
}


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

int main(){
  int A,B;
  cin >> A >> B;
  bool ans = false;
  if(A <= 8 && B <= 8) ans = true;  
  if(ans) cout<<"Yay!" << endl;
  else cout<<":(" << endl;
}

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

int x, y, a, b, c;
vector<ll> p(101010), q(101010), r(101010);

int main()
{
    cin >> x >> y >> a >> b >> c;
    rep(i, a) cin >> p[i];
    rep(i, b) cin >> q[i];
    rep(i, c) cin >> r[i];

    sort(p.begin(), p.begin() + a, greater<int>());
    sort(q.begin(), q.begin() + b, greater<int>());

    r.insert(r.begin() + c, p.begin(), p.begin() + x);
    r.insert(r.begin() + c + x, q.begin(), q.begin() + y);
    sort(r.begin(), r.begin() + c + x + y, greater<int>());

    ll res = 0;
    rep(i, x + y) res += r[i];
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 5864
#include <iostream>
#include <cstdio>
#include <map>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <cmath>
#include <queue>
#include <ctime>
#include <utility> // std::pair
#include <functional> // std::greater <int> ()
#define int long long
#define inf 1000000000000000001
#define BASE 29 // hashings mod, can be rand'd
#define mod 998244353 // can be 1000000007
#define pi 3.1415926535897
#define pii pair <int, int>
#define fii first
#define see second

typedef long long ll;
typedef long double ld;
using namespace std;

int a, b;
int ans=0, cur=1;

// functions
void input(){
	cin >> a >> b;
	return;
}

void solve(){
	while(cur<b){
		cur--;
		cur+=a;
		ans++;
	}
	cout << ans;
	return;
}

void output(){
	return;
}

signed main(){
/*
//  REMEMBER TO TURN OFF IFDEF IN PROBLEMS WITH FILE I/O
*/
//#ifdef sheeep
//	freopen("forces.inp", "r", stdin);
//	freopen("forces.out", "w", stdout);
//#endif
	ios_base::sync_with_stdio(false);
//	int t;
//	cin >> t;
//	for(int i=1; i<=t; i++){
		input();
		solve();
		output();
//	}
	return 0;
}
// Author: NamSPro

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

using namespace std;
using ll=long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (n); i < (a); i++)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n,m,c;cin>>n>>m>>c;
  //Ai1*B1 + Ai2*B2 + C > 0 $B$N$H$-(Bac
  int b[m],cnt=0,su,hoge;
  rep(i,m)cin>>b[i];
  rep(i,n){
    su=0;
    rep(j,m){
      cin>>hoge;
      su+=hoge*b[j];
    }
    if(su+c>0)cnt++;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 256
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
  ($line:expr, $name:ident, $t:tt) => {
    let $name = value!($line, $t);
  };
}

macro_rules! values_def {
  ($lines:expr, $n:expr, $name:ident, $t:tt) => {
    let $name = {
      let mut vec = Vec::new();
      for i in 0..$n {
        let mut next = $lines.next().unwrap().split_whitespace();
        vec.push(value!(next, $t));
      }
      vec
    };
  };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
  let mut input = String::new();
  io::stdin().read_to_string(&mut input).unwrap();
  let output = solve(input.trim().to_string());
  println!("{}", output);
}

fn solve(input: String) -> String {
  input!(input=>(n:usize m:usize c:i64)(b_list:[i64]){n;list:[i64]});
  let mut res = 0;
  for prob in list {
    let mut x = c;
    for i in 0..m {
      x += prob[i] * b_list[i];
    }
    if x > 0 {
      res += 1;
    }
  }
  res.to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "2 3 -10\n1 2 3\n3 2 1\n1 2 2\n" => "1\n",
    test2: "5 2 -4\n-2 5\n100 41\n100 40\n-3 0\n-6 -2\n18 -13\n" => "2\n",
    test3: "3 3 0\n100 -100 0\n0 100 100\n100 100 100\n-100 100 100\n" => "0\n",
}


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

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

	string S;
	cin >> S;

	int result = 0;
	for( int i = 0; i < S.size()/2; ++i ) {
		if( S[i] != S[S.size()-1 - i] ) {
			result += 1;
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <cmath>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

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

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; }


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

    int N;
    cin >> N;

    int ans = 0;
    int tmp_div = 0;

    for(int i = 1; i <= N; i = i + 2){
        tmp_div = 0;
        for(int j = 1; j <= i; j++){
            if(i % j == 0){
                tmp_div++;
            }
        }
        if(tmp_div == 8){
            ans++;
        }
    }

    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;

namespace ABC050A___Addition_and_Subtraction_Easy
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();

            string[] fomula = input.Split(' ');

            int num1 = int.Parse(fomula[0]);
            string arithmeticOperator = fomula[1];
            int num2 = int.Parse(fomula[2]);

            int result = 0;
            switch (arithmeticOperator)
            {
                case "+": result = num1 + num2; break;
                case "-": result = num1 - num2; break;

                default: break;
            }

            //DataTable dt = new DataTable();

            //int result = (int)dt.Compute(input, "");


            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
using namespace std;
int s[1000009];
int s1[1000009];
int main(){
    int a;
    cin>>a;
    for(int i=1;i<=a;i++)
    cin>>s[i];
   int max=s[1];
   long long ans=0;
    for(int i=2;i<=a;i++){
       if(s[i]>max){
           ans+=0;
           max=s[i];
       }
       else {
           ans+=max-s[i];
       }

    }
    cout<<ans<<endl;
    system("pause");
}

Measured memory_bytes: 3904
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,c,d=0,e=0,f=2,g=0,h[300001],i,j,k=0,l=0,r=0,p[300001],n[101],m,q,u,v,w,y,z;
    string s,t,x;
    cin>>a>>b>>c;
    d=b+c;
    e=a/d*b;
    e+=min(a%d,b);
    cout<<e;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
#define ALL(x) (x).begin(), (x).end()
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
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;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
ll cnt;
int main(void) {
    ll n;
    cin >> n;
    ll d;
    cin >> d;
    for (ll i = 0; i < n; ++i) {
        ll a, b;
        cin >> a >> b;
        if (sqrt(a * a + b * b) <= d) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3672
#include<cstdio>
#include<iostream>
typedef long long ll;
const ll mod=1e9+7;
const int N=2e5+5;
ll p[N],inv[N];
ll qpow(ll x,ll y) {
    ll res=1;
    for(;y;y>>=1,x=x*x%mod) if(y&1) res=res*x%mod;
    return res;
}
ll C(int n,int m) {
    if(n<m) return 0;
    return p[n]*inv[m]%mod*inv[n-m]%mod;
}
ll f[2][N];
int B,W;
int main() {
    p[0]=1;for(int i=1;i<N;i++) p[i]=p[i-1]*i%mod;
    inv[N-1]=qpow(p[N-1],mod-2);
    for(int i=N-2;~i;i--) inv[i]=inv[i+1]*(i+1)%mod;
    scanf("%d%d",&B,&W);ll now=1;
    for(int i=1;i<B+W;i++) {
        now=now*inv[2]%mod;
        f[0][i]=(f[0][i-1]+C(i-1,B-1)*now)%mod;
        f[1][i]=(f[1][i-1]+C(i-1,W-1)*now)%mod;
    }
    for(int i=0;i<B+W;i++) {
        printf("%lld\n",(1+mod-f[0][i]+f[1][i])*inv[2]%mod);
    }
    return 0;
}


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

#define vi vector<int>
#define ii pair<int, int>
#define vii vector<ii>
#define vvi vector<vi>
#define vb vector<bool>
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define INF int(1e9)

using namespace std;

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

    int a, b, c;

    cin >> a >> b >> c;

    cout << c << " " << a << " " << b << endl;

    return 0;
}

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

void main(void){
    int a,b,c,tmp;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);

    tmp=a;
    a=b;
    b=tmp;
    tmp=a;
    a=c;
    c=tmp;

    printf("%d %d %d",a,b,c);

}

Measured memory_bytes: 1728
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	p := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&p[i])
	}
	if sort.IntsAreSorted(p) {
		fmt.Println("YES")
		return
	}

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			tmp := make([]int, n)
			copy(tmp, p)
			tmp[i], tmp[j] = tmp[j], tmp[i]
			if sort.IntsAreSorted(tmp) {
				fmt.Println("YES")
				return
			}
		}
	}

	fmt.Println("NO")
}


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

int main(void) {
  int H, W;
  while (cin >> H >> W, H || W) {
    vector<vector<char> > tiles(H, vector<char>(W));

    for (auto i = 0; i < H; i++) {
      for (auto j = 0; j < W; j++) {
        cin >> tiles[i][j];
      }
    }

    bool flag = true;
    int nowX = 0, nowY = 0;
    int max_num = H * W + 1;
    while (flag && max_num--) {
      switch(tiles[nowY][nowX]) {
      case '>':
        nowX++;
        break;
      case '<':
        nowX--;
        break;
      case '^':
        nowY--;
        break;
      case 'v':
        nowY++;
        break;
      default:
        flag = false;
        break;
      }
    }

    if (max_num > 0) {
      cout << nowX << " " << nowY << endl;
    } else {
      cout << "LOOP" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define ll long long
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(s) scanf("%s", s)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(s) printf("%s\n", s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<vc> vcc;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim)
{
    uniform_int_distribution<int> uid(0, lim - 1);
    return uid(rang);
}

int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve()
{
    ll i, j, n, m;
    cin >> n >> m;
    vi a(10);
    fo(i, m)
    {
        cin >> j;
        a[j] = 1;
    }
    for (i = n; i <= 100000; i++)
    {
        string s = to_string(i);
        bool k = true;
        fo(j, s.size())
        {
            if (a[s[j] - '0'])
            {
                k = false;
                break;
            }
            else
            {
                continue;
            }
        }
        if (k)
        {
            cout << i << endl;
            return;
        }
        else
        {
            continue;
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }

    return 0;
}

int mpow(int base, int exp)
{
    base %= mod;
    int result = 1;
    while (exp > 0)
    {
        if (exp & 1)
            result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

void ipgraph(int n, int m)
{
    int i, u, v;
    while (m--)
    {
        cin >> u >> v;
        u--, v--;
        g[u].pb(v);
        g[v].pb(u);
    }
}

void dfs(int u, int par)
{
    for (int v : g[u])
    {
        if (v == par)
            continue;
        dfs(v, u);
    }
}


Measured memory_bytes: 10708
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    REP(k,0,a){
        if((c + b * k) % a == 0){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;

}


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

if int(s[0]+s[1])>12 and 0<int(s[2]+s[3])<=12:
  print("YYMM")
  
elif 0<int(s[0]+s[1])<=12 and int(s[2]+s[3])>12:
  print("MMYY")
  
elif 0<int(s[0]+s[1])<=12 and 0<int(s[2]+s[3])<=12:
  print("AMBIGUOUS")
  
elif int(s[0]+s[1])==0 and 0<int(s[2]+s[3])<=12:
  print("YYMM")
  
elif int(s[2]+s[3])==0 and 0<int(s[0]+s[1])<=12:
  print("MMYY")
  
else:
  print("NA")

Measured memory_bytes: 3064