akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
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 long double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int L, R, d;
	cin >> L >> R >> d;
	int ans = 0;
	for(int i=L;i<=R;i++){
		if(i % d == 0) ++ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint h, w;
    cin >> h >> w;
    lint n;
    cin >> n;
    vector<lint> r(n), c(n), a(n);
    vector<lint> nodes(h + w, inf);
    vector<vector<pair<int, lint>>> edges(h + w);
    for (int i = 0; i < n; ++i) {
        cin >> r[i] >> c[i] >> a[i];
        r[i]--, c[i]--;
        edges[r[i]].emplace_back(h + c[i], a[i]);
        edges[h + c[i]].emplace_back(r[i], a[i]);
    }
    for (int i = h; i < h + w; ++i) {
        if (nodes[i] != inf || edges[i].size() == 0)
            continue;
        nodes[i]   = 0;
        lint minir = inf, minic = inf;
        function<void(int, int)> dfs = [&](int c, int p) {
            for (auto &v : edges[c]) {
                if (v.first == p)
                    continue;
                if (nodes[v.first] != inf) {
                    continue;
                }
                nodes[v.first] = v.second - nodes[c];
                dfs(v.first, c);
            }
            if (c < h)
                minir = min(minir, nodes[c]);
            else
                minic = min(minic, nodes[c]);
        };
        dfs(i, -1);
        if (minir + minic < 0) {
            cout << "No"
                 << "\n";
            return 0;
        }
    }
    for (int i = 0; i < n; ++i) {
        if (nodes[r[i]] + nodes[h + c[i]] != a[i]) {
            cout << "No"
                 << "\n";
            return 0;
        }
    }
    cout << "Yes"
         << "\n";
    return 0;
}

Measured memory_bytes: 23424
n=int(input())
a=list(map(int,input().split()))

cnt=True

for i in range(len(a)):
    k=a[i]
    if k%2==0 and (k%3!=0) and (k%5!=0):
            cnt=False
            break

if cnt:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 2940
#include<iostream>
//#include <bits/stdc++.h>
using namespace std;
#include<algorithm>
#include<map>
#include<vector>
#include <iomanip>
#include <set>
#include<cmath>
#define F first
#define S second
#define pii pair<int,int>
#define pb push_back
#define int long long
#define mp make_pair
#define error(x) cout<<#x<<"="<<(x)<<endl;
void sp(double y,int x){cout<<fixed<<setprecision(x)<<y;}
int inf=1e9+10;
int const M=2e5+10;
int const M2=1e6+10;
int const M3=1e3+10;
int mod=1e9+7;
int sa(int x,int y){if(x%y==0)return x/y;return x/y+1;}
int binp(int x,int y){int ans=1;int t=x;while(y!=0){if(y%2==1){ans*=t;ans;}y/=2;t*=t;t;}return ans;}
main(){
	ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
	int n,l,r;
	int ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
        cin>>l>>r,ans+=(r-l+1);
    cout<<ans;
}

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

long long find(long long a[][3],int n)
{
	
	long long dp[n][3];
	dp[0][0]=a[0][0];
	dp[0][1]=a[0][1];
	dp[0][2]=a[0][2];
	for(int i=1;i<n;i++)
	{
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
		dp[i][2]=max(dp[i-1][1],dp[i-1][0])+a[i][2];
		// cout<<dp[i-1][0]<<" "<<dp[i-1][1]<<" "<<dp[i-1][2]<<endl;

	}

	return max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));


}

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

	long long a[n][3];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)
			{cin>>a[i][j];}
	}

	long long ans=find(a,n);
	cout<<ans;

	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
int main(){
  ll n,ans=0;
  cin>>n;
  rep(i,0,n){
    ll l,r;
    cin>>l>>r;
    ans+=r-l+1;
  }
  cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <set>
 
using namespace std;
typedef long long ll;

ll ans,mx,mn=1e10,sum;
int main(){
	ll n;
	cin>>n;
	for(int i=0; i<n; i++){
		ll a,b;
		cin>>a>>b;
		sum+=(b-a)+1;
	}
	cout<<sum<<endl;
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vl = vector<ll>;
using vs = vector<string>;

constexpr int MOD = int(1e9 + 7);
constexpr int INF = int(1e9 + 1);
constexpr ll LLINF = ll(4 * 1e18 + 1);
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
	int n, m;
	cin >> n >> m;
	vector<vector<pii>> p(n);
	for(int i = 0; i < m; ++i){
		int pr, y;
		cin >> pr >> y;
		pr--;
		p[pr].push_back({y, i});
	}
	for(int i = 0; i < n; ++i){
		sort(begin(p[i]), end(p[i]));
	}

	vector<pii> num(m);
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < p[i].size(); ++j){
			num[p[i][j].second] = {i + 1, j + 1};
		}
	}
	
	for(int i = 0; i < m; ++i){
		printf("%06d%06d\n", num[i].first, num[i].second);
	}
	
	
	
	return 0;
}


Measured memory_bytes: 7680
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(V) V.begin(), V.end()
using i64 = int_fast64_t;
using P = pair<int,int>;

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

    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N);
    vector<vector<int>> visited(N, vector<int>(3, -1));

    int u, v;
    rep(i, M){
        cin >> u >> v; u--, v--;
        G[u].emplace_back(v);
    }
    int S ,T;
    cin >> S >> T; S--, T--;

    queue<pair<int,int>> que;
    que.emplace(make_pair(S, 0));
    visited[S][0] = 0;
    while(!que.empty() && visited[T][0] == -1){
        int v, dist;
        tie(v, dist) = que.front(); que.pop();
        const int md = dist % 3;
        const int nd = (dist+1) % 3;
        for(int nxt : G[v]){
            if(visited[nxt][nd] != -1) continue;
            visited[nxt][nd] = dist + 1;
            que.emplace(make_pair(nxt, dist+1));
        }
    }

    int ans = visited[T][0];
    if(ans != -1) ans /= 3;
    cout << ans << endl;
}


Measured memory_bytes: 11264
from collections import deque
N = int(input())
g = [set() for i in range(N + 1)]
for i in range(N - 1):
    a, b = map(int, input().split())
    g[a].add(b)
    g[b].add(a)
    
c = list(map(int, input().split()))
c.sort(reverse=True)

print(sum(c) - c[0])

q = deque()
nums = [0] * (N + 1)

q.appendleft(1)

while q:
  d = q.popleft()
  nums[d] = c.pop(0)
  for node in g[d]:
    if nums[node] == 0:
      q.appendleft(node)
print(*nums[1:])


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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
    int a, b;
    cin >> a >> b;

    if ((a + b) % 2)
    {
        cout << "IMPOSSIBLE" << endl;
    }
    else
        cout << (a + b) / 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int a,b,c,d,n;

main(){
  cin>>a>>b>>c>>d>>n;
  int ans=0;

  int aa=a*8,bb=b*4,cc=c*2;
  int r=min(aa,bb);
  r=min(r,cc);
  r=min(r,d);
  ans+=r*(n/2);
  n%=2;
  aa/=2;
  bb/=2;
  cc/=2;
  r=min(aa,bb);
  r=min(r,cc);
  ans+=r*n;

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(long a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
int main(void)
{
  int count=0,i=0,j=0,k=0,N=IN(),L[100];
  while(i<N){L[i++]=IN();}i=0;
  while(i<N-2)
  {
    j=i+1;while(j<N-1)
    {
      k=j+1;while(k<N)
      {
        if(L[i]<L[j]+L[k]&&L[j]<L[k]+L[i]&&L[k]<L[i]+L[j]&&L[i]!=L[j]&&L[j]!=L[k]&&L[k]!=L[i]){count++;}k++;
      }j++;
    }i++;
  }
  return OUT(count),0;
}

Measured memory_bytes: 1492
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var x=input.trim().split(" ").map(Number);
var cnt=0;
for(var a=1;a<=9;a++){
for(var b=1;b<=9;b++){
for(var c=1;c<=9;c++){
for(var d=1;d<=8;d++){
for(var e=1;e<=9;e++){
for(var f=1;f<=9;f++){
var z=((a+c+f+(b+e)*10+d*100)+"").split("").map(Number);
if(z.length!=3)continue;
z=[a,b,c,d,e,f].concat(z);
var flag = z.every(function(v,i){
   return  (x[i] == v || x[i] == -1) && (z.indexOf(i+1)>=0) ;
});
if(flag)cnt++;
}}}}}}
console.log(cnt);

Measured memory_bytes: 58076
/*
17/10/2017
*/
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int occ[1000005]={};
bool ok[1000005]={};
int main()
{
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
occ[a[i]]++;
}
bool fnd=0;
for(int i=2;i<=1000000;i++)
{
if(!ok[i])
{
int w=1;
int cnt=0;
while(w*i<=1000000)
{
ok[w*i]=1;
cnt+=occ[w*i];
w++;
}
if(cnt>1)
{
fnd=1;
break;
}
}
}
if(!fnd)
{
cout<<"pairwise coprime"<<endl;
}
else
{
int gd=0;
for(int i=0;i<n;i++)
{
gd=__gcd(gd,a[i]);
}
if(gd==1)
{
cout<<"setwise coprime"<<endl;
}
else
{
cout<<"not coprime";
}
}
}


Measured memory_bytes: 12380
using System;

public class Hello
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        string str = Console.ReadLine();
        int s = str.Length;

        if(s > n)
        {
            Console.WriteLine(str.Substring(0, n) + "...");
        }
        else
        {
            Console.WriteLine(str);
        }
    }
}

Measured memory_bytes: 27528
#include <bits/stdc++.h>
#define endl '\n'
#define pi 3.1415926535897932384626433832
#define ll long long
using namespace std;
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / __gcd(a, b); }
bool isPrime(int n) {if (n <= 1) return false;
if (n <= 3) return true;
if (n % 2 == 0 || n % 3 == 0) return false;
for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false;
return true;}

void lok(){

}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll t;
	cin>>t;
	map<string,ll> pd;
	string tak;
	for(int i=0;i<t;i++){
		cin>>tak;
		pd[tak]++;
	}
	cout<<"AC x "<<pd["AC"]<<endl;
	cout<<"WA x "<<pd["WA"]<<endl;
	cout<<"TLE x "<<pd["TLE"]<<endl;
	cout<<"RE x "<<pd["RE"]<<endl;
	return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int plane[12][12];
bool used[12][12];
const int dr[] = {-1, 0, 1, 0 };
const int dc[] = { 0, 1, 0,-1 };

void dfs (int r, int c )
{
	used[r][c] = true;
	rep (k, 4 ){
		int nr = r + dr[k];
		int nc = c + dc[k];
		if (nr < 0 || nr >= 12 || nc < 0 || nc >= 12 ) continue;
		if (used[nr][nc] || plane[nr][nc] == 0 ) continue;
		dfs (nr, nc );
	} // end rep
}

void disp_plane (void )
{
	rep (i, 12 ){
		rep (j, 12 ){
			cerr << plane[i][j];
		} // end rep
		cerr << endl;
	} // end rep
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.island", "r", stdin );

	while (true ){
		string str = "";
		memset (plane, 0, sizeof (plane ) );
		rep (i, 12 ){
			cin >> str;
			if (cin.eof() ){
				goto end;
			} // end if
			rep (j, 12 ){
				plane[i][j] = (int)(str[j] - '0' );
			} // end rep
		} // end rep
//		disp_plane ();

		memset (used, false, sizeof (used ) );
		int res = 0;
		rep (row, 12 ){
			rep (col, 12 ){
				if (!used[row][col] && plane[row][col] == 1 ){
					res++;
					dfs (row, col );
				} // end if
			} // end rep
		} // end rep
		printf ("%d\n", res );
	} // end loop
end:;
	return 0;
}

Measured memory_bytes: 1192
($H,$W,$D)=glob<>;
for$y(1..$H){
	@_[glob<>]=map[$y,$_],1..$W
}
for($D+1..$H*$W){
	$s[$_]=
		$s[$_-$D]+
		abs(@{$_[$_]}[0]-@{$_[$_-$D]}[0])+
		abs(@{$_[$_]}[1]-@{$_[$_-$D]}[1])
}
<>;/ /,print$s[$']-$s[$`],$/for<>


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

int main(void)
{
  char s[128];

  scanf("%s",s);
  if(strcmp("keyence",s)==0){
    puts("YES");
    return 0;
  }

  int len=strlen(s);

  for(int i=0;i<len;i++){
    for(int j=i;j<len;j++){
      char tmp[128]="\0";
      int st=0;
      for(int k=0;k<len;k++){
        if(i>k||k>j){
          tmp[st]=s[k];
          st++;
        }
      }
      // printf("%s\n",tmp);
      if(strcmp(tmp,"keyence")==0){
        puts("YES");
        return 0;
      }
    }
  }
  puts("NO");

  return 0;
}


Measured memory_bytes: 1628
import collections

N, K = map(int,input().split())
sunuke = [0]*N# for _ in range(N)]
for i in range(K):
    _ = input()
    n = map(int,input().split())
    for j in n:
        sunuke[j-1] +=1
sunuke = collections.Counter(sunuke)
#print(sunuke)
print(sunuke[0])

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

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

  cin >> hex;
  cout << hex;

  while(N--) {
    unsigned d[9];
    for(int i = 0; i < 9; i++) {
      cin >> d[i];
    }
    unsigned ret = 0;
    for(unsigned i = 0; i < 32; i++) {
      unsigned curr = 0;
      for(int j = 0; j < 8; j++) curr += d[j];
      if(((curr >> i) & 1) != ((d[8] >> i) & 1)) {
        ret |= 1u << i;
        for(int j = 0; j < 8; j++) d[j] ^= 1u << i;
      }
    }
    cout << ret << endl;
  }
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    long long h, n;
    cin >> h >> n;
    vector<int>an(n);
    long long sum = 0;
    for (int i = 0; i < n; i++){
        cin >> an.at(i);
        sum += an.at(i);
    }
    if(sum >= h){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    solve();
    return 0;
}



Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<limits.h>

int main() {
    int N, A;
    scanf("%d",&N);

    int Cj[N+1], Dk[N+1];
    memset(Cj, 0, sizeof(int)*(N+1));
    memset(Dk, 0, sizeof(int)*(N+1));
    
    int i;
    for (i=0; i<N; i++) {
        scanf("%d", &A);
        Cj[A]++;
    }

    int DkSum1=0, DkSum2=0;
    for (i=1; i<=N; i++) {
        Dk[Cj[i]]++;
        DkSum2++;
    }
    DkSum1 = 0;
    DkSum2 -= Dk[0];

    int X, k, FX[N+1];
    FX[0] = INT_MAX;
    for (X=1; X<=N; X++) {
        DkSum1 += X*Dk[X];
        DkSum2 = DkSum2 - Dk[X];
        FX[X] = DkSum1/X + DkSum2;
    }

    int K;
    X = N;
    for (K=1; K<=N; K++) {
        while (K > FX[X])  X--;
        printf("%d\n", X);
    }

    return 0;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int N;
LL fact[1145141];
LL revf[1145141];

LL mypow(LL base, LL exp) {
  if (exp == 0) return 1;
  LL res = mypow(base*base%MOD, exp/2);
  if (exp%2) res = res*base % MOD;
  return res;
}

int main() {
  scanf("%d", &N);
  fact[0] = 1;
  revf[0] = 1;
  reps(i, 1, N+10) {
    fact[i] = fact[i-1] * i % MOD;
    revf[i] = revf[i-1] * mypow(i, MOD-2) % MOD;
  }

  LL ans = 0;
  LL prev = 0;
  rep(k, N) {
    if (2*k < N) continue;
    LL cnt = fact[k] * fact[k-1] % MOD * revf[2*k-N] % MOD;
    LL num = (cnt + MOD - prev) % MOD;
    ans = (ans + k*num) % MOD;
    prev = cnt;
  }
  printf("%lld\n", ans);
}


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

int selectionSort(int a[],int n){
	int i,j,sw=0,minj;
	for(i=0;i<n-1;++i){
		minj=i;
		for(j=i;j<n;++j)
			if(a[j]<a[minj]) minj=j;
		swap(a[i],a[minj]);
		if(i!=minj) ++sw;
	}
	return sw;
}

int main(){
	int n,a[100],i,sw;
	cin>>n;
	for(i=0;i<n;++i) cin>>a[i];
	sw=selectionSort(a,n);
	for(i=0;i<n;++i){
		if(i>0) cout<<" ";
		cout<<a[i];
	}
	cout<<endl<<sw<<endl;
	return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define ll long long
#define pii pair<ll,ll>
#define piii pair<ll, pii>
#define MOD 1000000007
#define M 100005
#define inf 1000000001
using namespace std;

int main(){
    //ll t; cin>> t; while(t--){
        ll n, w;
        cin>> n >> w;
        ll dp[n][w], grid[n][w];
        char a;
        memset(dp, 0, sizeof(dp));
        memset(grid, 0, sizeof(grid));
        for(ll i =0;i<n;i++){ // no of item
            for(ll j =0;j<w;j++){ // weight
                cin>> a;
                if(a=='.') grid[i][j] = 1;
            }
        }
        for(ll i =0;i<n;i++){ // no of item
            for(ll j =0;j<w;j++){ // weight
                if(grid[i][j]){
                    if(i==0 && j==0) {dp[i][j] = 1;}
                    else if(j==0) dp[i][j] = dp[i-1][j];
                    else if(i==0) dp[i][j] = dp[i][j-1];
                    else {
                        dp[i][j] = (dp[i-1][j]+ dp[i][j-1])%MOD;
                    }
                }
                //cout<< dp[i][j]<< " ";

            }//cout << endl;
        }
        cout << dp[n-1][w-1] << endl;

}


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

int main(){
	string a;
	int c = 0;
	int d;
	cin >> a;
	d = a.length() - 1;
	for(int i = 0; i < a.length();++i){
		if(a[i] == 'A')
			break;
		++c;
	}
	for(int i = a.length() - 1; i >= 0;--i){
		if(a[i] == 'Z')
			break;
		--d;
	}

	cout << d - c + 1 <<endl;

	return 0;
}

Measured memory_bytes: 640
h,w=map(int,input().split())
slis=[]
a=["."]*(w+2)
slis.append(a)
for i in range(h):
	s=list("."+input()+".")
	slis.append(s)
slis.append(a)
for i in range(1,h+1):
	for j in range(1,w+1):
		a=slis[i-1][j-1:j+2]+slis[i][j-1:j+2]+slis[i+1][j-1:j+2]
		if slis[i][j] != "#":
			slis[i][j]=a.count("#")
for i in range(1,h+1):
	print(*slis[i][1:w+1],sep="")

Measured memory_bytes: 3444
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout << fixed << setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	ll n = in();
	vector<ll>inp(n); REP(i, n)inp[i] = in();
	map<ll, ll>div;
	REP(i, n) {
		ll s = sqrt(inp[i]);
		REP1(j, s) {
			if (inp[i] % j == 0) {
				div[j]++;
				if (j != inp[i] / j)div[inp[i] / j]++;
			}
		}
	}
	REPC(i, div) {
		if (i.second == n) {
			cout << i.first << endl;
		}
	}
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  int a,d=0,e=0,f=0;
  cin>>a;
  vector<int> b(a),c(a,0);
  fo(i,a)
    cin>>b[i];
  fo(i,a){
    while(b[i]%2==0&&c[i]<=2){
      c[i]++;
      b[i]/=2;
    }
  }
  fo(i,a){
    if(c[i]==0)
      d++;
    else if(c[i]==1)
      e++;
    else
      f++;
  }
  if(e==0){
    if(f+1<d)
      cout<<"No"<<endl;
    else
      cout<<"Yes"<<endl;
  }
  else{
    if(f<d)
      cout<<"No"<<endl;
    else
      cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 1792
from collections import defaultdict, deque

N, M = map(int, input().split())
edge = defaultdict(set)
for _ in range(M):
    a, b = map(int, input().split())
    edge[a].add(b)
    edge[b].add(a)

done = {1}
ans = [None] * (N + 1)
queue = deque()
queue.append(1)
while queue and len(done) < N:
    v1 = queue.popleft()
    for v2 in edge[v1]:
        if v2 not in done:
            done.add(v2)
            ans[v2] = v1
            queue.append(v2)
print('Yes')
for i in range(2, N + 1):
    print(ans[i])

Measured memory_bytes: 73472
n=int(input())
task=[]
for i in range(n):
    a,b=map(int,input().split())
    task.append([b,a])
task.sort()
time=0

for i in range(n):
    time+=task[i][1]
    if time>task[i][0]:
        print("No")
        exit()

print("Yes")




Measured memory_bytes: 36972
import java.util.Scanner;

public class Main {

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

		long X = scan.nextLong() ;
		long Y = scan.nextLong() ;

		if ( X % Y == 0) {
			System.out.println(-1);
			return;
		}
		System.out.println(X);

	}
}

Measured memory_bytes: 23252
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = s()
if N[0] == N[2]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9884
#include<bits/stdc++.h>
using namespace std;
const int nmax = 8;
bool graph[nmax][nmax];
int dfs(int v, int N, bool visited[nmax]){
  bool all_visited = true;
  for(int i = 0; i < N; i++){
    if(visited[i] == false) all_visited = false;
  }
  if(all_visited) return 1;
  int ret = 0;
  for(int i = 0; i < N; i++){
    if(graph[v][i] == false) continue;
    if(visited[i]) continue;
    visited[i] = true;
    ret += dfs(i, N, visited);
    visited[i] = false;
  }
  return ret;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    int A, B;
    cin >> A >> B;
    graph[A-1][B-1] = graph[B-1][A-1] = true;
  }
  bool visited[nmax];
  for(int i = 0; i < N; i++){
    visited[i] = false;
  }
  visited[0] = true;
  cout << dfs(0, N, visited) << endl;
  return 0;
}

Measured memory_bytes: 256
# 英小文字からなる文字列 S が与えられます。
# S に含まれる文字がすべて異なるか判定してください。

s = gets.chomp

diff = true

s.length.times do |i|
  (s.length - i - 1).times do |j|
    if s[i + j + 1] == nil
      break
    end
    
    if s[i] == s[i + j + 1]
      diff = false
      break
    end
  end
  
  unless diff
    break
  end
end

if diff
  puts "yes"
else
  puts "no"
end

Measured memory_bytes: 1788
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# strlist = "abcdefghijklmnopqrstuvwxyz"
H = int(input())

ans = 0
exp = 0
while H >0:
    H = H//2
    ans += pow(2,exp)
    exp += 1

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

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

int main() {
  ll k;
  cin>>k;
  if(k%2==0 or k%5==0){
    cout<<-1<<endl;
    return 0;
  }
  ll memo[k+1];
  memo[0]=1;
  for(int i=1;i<=k;i++){
    memo[i]=mod(memo[i-1]*10,k);
  }
  ll sum=0;
  for(int i=1;i<=k;i++){
    sum+=mod(memo[i-1]*7,k);
    if(sum%k==0){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 11400
//
//  main.cpp
//  AOJ1179
//
//  Created by aki33524 on 2014/07/08.
//  Copyright (c) 2014年 aki33524. All rights reserved.
//

#include <iostream>
using namespace std;

int Y, M, D;

int cal(int ey, int em, int ed){
    int cnt = 0;
    for(int y=1; y<=ey; y++){
        for(int m=1 ; m<=10; m++){
            int mc;
            if(y%3 == 0)
                mc = 20;
            else{
                if(m%2 == 1)
                    mc = 20;
                else
                    mc = 19;
            }
            for(int d=1; d<=mc; d++){
                cnt++;
                if(ey == y && em == m && ed == d)
                    return cnt;
            }
        }
    }
    return 0;
}

void solve(){
    cout << cal(1000, 1, 1) - cal(Y, M, D) << endl;
    
}

int main(int argc, const char * argv[])
{
    int N;
    cin >> N;
    for(int i=0; i<N; i++){
        cin>>Y>>M>>D;
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 1160
N=int(input())
h=len(str(N))
if h%2==1:
  a=N-(10**(h-1))+1
  a=a+((100**((h-1)//2))-1)//11
  print(a)
elif h%2==0:
  a=((100**(h//2))-1)//11
  print(a)
   
  

Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>
#define MIN(a, b) ((a) < (b) ? (a) : (b))

int main(void) {
  char s[100001], flag;
  int len, k, start, end, i;
  scanf("%s", s);
  len = strlen(s);
  k = (len+1) / 2;

  if (len % 2 == 0) {
    k = len / 2;
    if (s[k-1] == s[k]) {
      flag = s[k];
      for (start = k-1; flag == s[start-1]; start--);
      for (end = k; flag == s[end+1]; end++);
      k = MIN(len - start, end + 1);
    }
  } else {
    k = (len + 1) / 2;
    if (s[k-2] == s[k-1] && s[k-1] == s[k]) {
      flag = s[k];
      for (start = k-2; flag == s[start-1]; start--);
      for (end = k; flag == s[end+1]; end++);
      k = MIN(len - start, end + 1);
    }
  }
  printf("%d\n", k);

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int A = sc.nextInt();
		String op = sc.next();
		int B = sc.nextInt();
		int ans = 0;

		if (op.equals("+")) {
			ans = A + B;
		} else if (op.equals("-")) {
			ans = A - B;
		}
		System.out.println( ans );
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;  
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define Rep(i, a, b) for(ll i = a; i <= b; i++)
#define repr(i, a, b) for(ll i = b-1; i >= a; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
// const ll INF = 1LL << 60;
const ll INF = 100000000000;
#define pp pair<ll, pair<ll, ll>> 
// #define fi first
// #define se second
 
/*--------------------------------------------------------------------------------

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


int main(){
    ll h, w, d; cin >> h >> w >> d;
    vector<pair<ll, ll>> pos(h*w+1);
    Rep(i, 1, h) Rep(j, 1, w){
        ll a; cin >> a;
        pos[a] = {i, j};
    }
    ll q; cin >> q;
    // d が予め与えられている　→　距離の個数はせいぜい300*300個　→　前処理
    Vl dist(h*w+1, 0);
    Rep(i, 1, d){
        for(ll j = i+d; j <= h*w; j += d){
            ll dis = abs(pos[j].first-pos[j-d].first)+abs(pos[j].second-pos[j-d].second);
            dist[j] = dist[j-d] + dis;
        }
    }
    while(q--){
        ll ans = 0;
        ll l, r; cin >> l >> r;
        co(dist[r]-dist[l]);
    }
    // rep(i, 1, sz(dist)) cout << dist[i] << " ";
    // coel;
    // Rep(i, 1, h*w) cout << i << " : " << pos[i].first << " , " << pos[i].second << endl;

    return 0;
}


Measured memory_bytes: 5368
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
signed main()
{
    fast;
    int n,m,l;
    cin>>n>>m>>l;
    int dp[n+1][n+1];
    int stops[n+1][n+1];
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
        {
            dp[i][j] = 1e18;
            stops[i][j] = 1e18;
        }
    for(int i=1;i<=m;i++)
    {
        int u,v,c;
        cin>>u>>v>>c;
        dp[u][v] = c;
        dp[v][u] = c;
    }
    for(int k=1;k<=n;k++)
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
                dp[i][j] = min(dp[i][j],dp[i][k]+dp[k][j]);
    for(int k=1;k<=n;k++)
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
            {
                if(dp[i][j]<=l)
                    stops[i][j] = 0;
                else
                    stops[i][j] = min(stops[i][j],1+stops[i][k]+stops[k][j]);
            }
    int q;
    cin>>q;
    while(q--)
    {
        int u,v;
        cin>>u>>v;
        if(stops[u][v] == 1e18)
            cout<<-1<<"\n";
        else cout<<stops[u][v]<<"\n";
    }
}

Measured memory_bytes: 1920
A,B,C,X,Y = list(map(int,input().split()))

if A+B <= 2*C:
  #only buy A and B
  print(X*A+Y*B)

else:
  if X >= Y and A < 2*C:
    #print("A")
    select = A
  elif X < Y and B < 2*C:
    #print("B")
    select = B
  else:
    #print("C")
    select = 2*C
    
  print((min(X,Y)*2*C)+ (abs(X-Y)*select))

Measured memory_bytes: 61928
#include <stdio.h>

int isPrime(int n){
    int i,j=0;
    for(i=1;1;i++){
        if(i%2){
            j=(i/2)*7+6;
        }else{
            j=(i/2)*7+1;
        }
        if(j>=n)break;
        if(n%j==0)return 0;
    }
    return 1;
}

int main(void){
    int n;
    while(scanf("%d",&n),n!=1){
        printf("%d:",n);
        int i=1,j=0;
        while(j<n){
            if(i%2){
                j=(i/2)*7+6;
            }else{
                j=(i/2)*7+1;
            }
            if(n%j==0&&isPrime(j)){
                printf(" %d",j);
            }
            i++;
        }
        printf("\n");
    }
    
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <map>
#include <set>
using namespace std;

map<string, set<string> > group;
set<string> check_group;

set<string> f(string g) {
	if(check_group.count(g)) return group[g];
	check_group.insert(g);
	set<string> s;
	for(string m : group[g]) {
		if(group.count(m)) {
			set<string> res = f(m);
			s.insert(res.begin(), res.end());
		}
		else {
			s.insert(m);
		}
	}
	group[g] = s;
	return s;
}


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

	int n;
	while(cin >> n, n) {
		group.clear();
		check_group.clear();
		string fst;
		for(int i = 0; i < n; i++) {
			string s, g, m;
			cin >> s;
			int j = 0;
			while(s[j] != ':') g += s[j++];
			j++;
			set<string> member;
			while(j < s.size()) {
				m = "";
				while(s[j] != ',' && s[j] != '.') m += s[j++];
				j++;
				member.insert(m);
			}
			group[g] = member;
			if(i == 0) fst = g;
		}

		set<string> res = f(fst);
		cout << res.size() << endl;
	}
}

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

int coords[100000]={0};
int main()
{
    int i=0,N,M,distance=0;

    cin>>N>>M;
    for(i=0;i<M;i++)
    {
        cin>>coords[i];
    }
    if(N>=M)
    {
        cout<<0<<endl;
        return 0;
    }

    sort(coords, coords+M);

    distance = coords[M-1]-coords[0];
    for(i=M-1;i>0;i--)
    {
        coords[i] = coords[i]-coords[i-1];
    }
    coords[0]=0;

    sort(coords, coords+M);

    for(i=M-1;i>M-1-(N-1);i--)
    {
        distance -= coords[i];
    }
    cout<<distance<<endl;
    return 0;
}


Measured memory_bytes: 640
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef int64_t LL;
typedef uint64_t ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
template<class T, class... U> void DEBUG(const T &head, const U &... tail) { 
#ifdef HOME
    _W('#'); _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...);
#endif
}
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int N,A,B;R(N,A,B);
    while(1){
        if(A+1!=B){
            A++;
        }
        else if(A==1){
            W("Borys");
            return 0;
        }
        else A--;
        if(B-1!=A)B--;
        else if(B==N){
            W("Alice");
            return 0;
        }
        else B++;
    }
    return 0;
}


Measured memory_bytes: 256
M = 10**9 + 7
N, *AS = $stdin.read.split.map(&:to_i)
as = if N.odd?
       [0] + 2.step(N-1, 2).to_a * 2
     else
       1.step(N-1, 2).to_a * 2
     end
if AS.sort == as.sort
  p 2**(N/2) % M
else
  p 0
end


Measured memory_bytes: 12392
'use strict';

function Main(INPUT) {
    const input = INPUT.split("\n")[0];
    if ((input[0] == input[1] && input[1] == input[2]) || (input[1] == input[2] && input[2] == input[3])) {
        console.log("Yes");
    } else {
        console.log("No");
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7624
import sys
input = sys.stdin.readline

from bisect import bisect_left, bisect_right

S = list(input().rstrip())
T = list(input().rstrip())
Q = int(input())
Query = [list(map(int, input().split())) for _ in range(Q)]

Sa = []
Sb = []
for i, s in enumerate(S):
    if s == 'A':
        Sa.append(i)
    else:
        Sb.append(i)

Ta = []
Tb = []
for i, t in enumerate(T):
    if t == 'A':
        Ta.append(i)
    else:
        Tb.append(i)

def kind(La, Lb, l, r):
    ca = bisect_right(La, r) - bisect_left(La, l)
    cb = bisect_right(Lb, r) - bisect_left(Lb, l)
    return (ca + cb*2)%3 

for a, b, c, d in Query:
    if kind(Sa, Sb, a-1, b-1) == kind(Ta, Tb, c-1, d-1):
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 44092
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt(), x = sc.nextInt();
		String ans[] = {"Yes", "No"};
		int an = 0;
		sc.close();
		int tmp = 500 * k;
		if(tmp < x)an = 1;
		System.out.println(ans[an]);
	}
}


Measured memory_bytes: 22740
import java.util.Scanner;

/**
 * https://abc047.contest.atcoder.jp/tasks/arc063_a
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		sc.close();
		
		int ans = 0;
		for(int i=1; i<s.length; i++){
			if(s[i]!=s[i-1])
				ans++;
		}
		
		System.out.println(ans);	

	}

}

Measured memory_bytes: 25964
#include <stdio.h>
int main ()
{
	int a,b,c,d,e;
	scanf("%d %d",&a,&b);
	c=a+b;
	d=a-b;
	e=a*b;
	if(c>=d&&c>=e)
	printf("%d\n",c);
    else if(d>=c&&d>=e)
 	printf("%d\n",d);
 	else if(e>=c&&e>=d)
 	printf("%d\n",e);
	
	return 0;

}
	
	

Measured memory_bytes: 1732
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

    double X = (double)N / 1.08;
    int x = (int)X;
    //cout << X << endl;
    //cout << x << endl;

    for(int i = 1; i <= N; i++){
        double x = (double)i * 1.08;
        int y = (int)x;
        if(y == N){
            cout << i << endl;
            return 0;
        }
    }

    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <complex>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>

using namespace std;

//conversion
//------------------------------------------
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();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EPS 1.0e-9

int main(){
	int n,m;
	while(cin>>n>>m, n){
		vector<PII> dp(n);
		int ex=0;
		REP(i,n){
			int x,y;
			cin>>x>>y;
			dp[i] = MP(y,x);
			ex+=x*y;
		}
		int idx = 0;
		sort(ALL(dp), greater<PII>());
		while(m){
			int tmp = min(dp[idx].second, m);
			ex-=tmp*dp[idx].first;
			m-=tmp;
			idx++;
			if(idx==n)break;
		}
		cout << ex << endl;
	}
	return 0;
}

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

typedef long long ll;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const int MOD = 1e9 + 7 ;
const double PI = 2 * acos(0.0);

int main()
{
  ll h, a ;
  cin >> h >> a ;
  if(h % a == 0)  cout << (h / a) << endl ;
  else  cout << ((h / a) + 1) << endl ;
}


Measured memory_bytes: 256
#include <iostream>
//#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <boost/tokenizer.hpp>
#include <boost/lexical_cast.hpp>

int solve(	int k, std::list<int>& dv )
{
	int count = 1;

	int len = 0;
	for( auto l : dv ) {
		len += l;
	}
	
	if( k == 1 ) {
		return len;
	}

	while ( count < k ) {
		if( len == 0 ) break;
		len -= (*dv.begin());
		dv.pop_front();
		count++;
	}

	return len;
}

int main(int argc, char* argv[])
{
	// std::ifstream ifs;
	//ifs.open(argv[1]);

	typedef boost::char_separator<char> char_separator;
    typedef boost::tokenizer<char_separator> tokenizer;
    char_separator sep(" ", "", boost::keep_empty_tokens);	

	int N;
	std::string line;
	std::getline(std::cin, line);
	{
		tokenizer tokens(line, sep);
		tokenizer::iterator tok_iter = tokens.begin();
		N = boost::lexical_cast<int>(*tok_iter);
	}

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

		int n, k;
		std::getline(std::cin, line);
		{
			tokenizer tokens(line, sep);			
			tokenizer::iterator tok_iter = tokens.begin();
			n = boost::lexical_cast<int>(*tok_iter++);
			k = boost::lexical_cast<int>(*tok_iter);
		}

		std::vector<int> pv;
		std::getline(std::cin, line);
		{
			tokenizer tokens(line, sep);
			for( auto sp : tokens ) {
				pv.push_back(boost::lexical_cast<int>(sp));
			}
		}

		std::list<int> dv;
		int pp = -1;
		for( auto p : pv ) {
			int d = p - pp;
			if( pp != -1 ) {
				dv.push_back(d);
			}
			pp = p;
		}

		dv.sort(std::greater<int>());
		std::cout << solve(k, dv) << std::endl;
	}
	
	return 0;
}

Measured memory_bytes: 7312
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
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(); }

// for loop
#define REP(i, n) for ((i) = 0;(i) < (ll)(n);(i)++)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

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

	ll N;
	cin >> N;

	vector<ll> As(N);
	for (ll i = 0; i < N; ++i) {
		cin >> As[i];
	}

	map<ll, ll> map1;
	map<ll, ll> map2;
	for (ll i = 0; i < N; ++i) {
		if (map1.count(i + As[i]) == 0) {
			map1[i + As[i]] = 0;
		}
		++map1[i + As[i]];
		if (map2.count(i - As[i]) == 0) {
			map2[i - As[i]] = 0;
		}
		++map2[i - As[i]];
	}

	ll res = 0;

	for (auto iter = map1.begin(); iter != map1.end(); ++iter) {
		if (map2.count(iter->first) == 0) continue;
		res += iter->second * map2[iter->first];
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 27916
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>
#include <cstdio>

using namespace std;

int main() {

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

	string s;
	cin >> s;
	int ans = INT_MAX;
	for (int i = 2; i < s.size(); i++) {
		string ss = s.substr(i-2,3);
		int tmp = atoi(ss.c_str());
		ans = min(ans, abs(tmp - 753));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256