akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;
const int INF = (1<<21);
int c,n,m,s,d;
int G[100][100];


int dij(){
  int D[100][11];
  bool V[100][11];
  for(int i=0;i<n;i++){
    for(int j=0;j<c+1;j++){
      D[i][j]=INF;
      V[i][j]=false;
    }
  }
    
  D[s][c]=0;
  while(1){
    int minv=INF,u,v;
    for(int i=0;i<n;i++){
      for(int j=0;j<c+1;j++){
	if(!V[i][j] && D[i][j]<minv){
	  minv=D[i][j];
	  u=i;
	  v=j;
	}
      }
    }

    if(minv==INF){
      break;
    }

    V[u][v]=true;
    for(int i=0;i<n;i++){
      if(G[u][i]==INF) continue;
      D[i][v]=min(D[i][v],D[u][v]+G[u][i]);
      if( v ){
	D[i][v-1]=min(D[i][v-1],D[u][v]+(G[u][i]/2));
      } 
    }
  }
    
    int minv=INF;
    for(int i=0;i<c+1;i++){
      minv=min(minv,D[d][i]);
    }
    return minv;
}



int main(){
  
  while(cin>> c>> n>> m>> s>> d,c){
    s--;
    d--;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	G[i][j]=INF;
      }
    }

    for(int i=0;i<m;i++){
      int a,b,f;
      cin>> a>> b>> f;
      G[a-1][b-1]=G[b-1][a-1]=f;
    }

    cout<< dij()<< endl;
  }
}

Measured memory_bytes: 1200
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


ll dp[333][101010];
int main(){
    int n,m,k;
    cin>>n>>m>>k;
    ll a[n];
    rep(i,n)cin>>a[i];
    rep(i,k)dp[i+1][0]=-longinf;
    rep(i,k){
        deque<pair<int,ll>> dq;
        rep(j,n){
            while(dq.size()&&dq.back().second<=dp[i][j])dq.pop_back();
            dq.emplace_back(j,dp[i][j]);
            while(dq.size()&&j+1-dq.front().first>m)dq.pop_front();
            dp[i+1][j+1]=dq.front().second+a[j]*(i+1);
        }
    }
    ll ans=0;
    rep(i,n)ans=max(dp[k][i+1],ans);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 237824
#include <iostream>
#include <algorithm>
#include <unordered_map>

using namespace std;

int main() {
    int n;
    long m;
    cin >> n >> m;
    unordered_map<long, long> mods;
    long rui = 0, sum = 0;
    mods[0] = 1;
    for (int i=0; i<n; i++) {
        long a;
        cin >> a;
        rui = (rui+a) % m;
        sum += mods[rui];
        mods[rui]++;
    }
    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 3596
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;

struct Card
{
  char pic;
  int num;
};

int partition(Card a[], int p, int r)
{
  int x = a[r].num;
  int i = p - 1;
  for (int j = p; j < r; j++)
    if (a[j].num <= x)
    {
      i++;
      swap(a[i], a[j]);
    }
  swap(a[i + 1], a[r]);
  return i + 1;
}

void quickSort(Card a[], int p, int r)
{
  if (p < r)
  {
    int q = partition(a, p, r);
    quickSort(a, p, q - 1);
    quickSort(a, q + 1, r);
  }
}

void merge(Card a[], int left, int mid, int right)
{
  int n1 = mid - left;
  int n2 = right - mid;
  Card l[n1 + 1], r[n2 + 1];
  for (int i = 0; i < n1; i++)
    l[i] = a[left + i];
  for (int i = 0; i < n2; i++)
    r[i] = a[mid + i];
  l[n1] = {'J', 1000000001};
  r[n2] = {'J', 1000000001};

  int i = 0, j = 0;
  for (int k = left; k < right; k++)
    if (l[i].num <= r[j].num)
    {
      a[k] = l[i];
      i++;
    }
    else
    {
      a[k] = r[j];
      j++;
    }
}

void mergeSort(Card a[], int left, int right)
{
  if (left + 1 < right)
  {
    int mid = (left + right) / 2;
    mergeSort(a, left, mid);
    mergeSort(a, mid, right);
    merge(a, left, mid, right);
  }
}

int main()
{
  int n, x;
  char p;
  scanf("%d\n", &n);

  Card a[n], ms[n];
  for (int i = 0; i < n; i++)
  {
    scanf("%c%d\n", &p, &x);
    a[i] = {p, x};
    ms[i] = {p, x};
  }

  quickSort(a, 0, n - 1);
  mergeSort(ms, 0, n);

  bool isStable = true;
  for (int i = 0; i < n; i++)
    if (a[i].num != ms[i].num || a[i].pic != ms[i].pic)
    {
      printf("Not stable\n");
      isStable = false;
      break;
    }

  if (isStable)
    printf("Stable\n");

  for (int i = 0; i < n; i++)
    printf("%c %d\n", a[i].pic, a[i].num);

  return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll x, y;
  cin >> x >> y;
  if (abs(x - y) <= 1) cout << "Brown" << endl;
  else cout << "Alice" << endl;
}

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

int main(void){
	vector<int> d;
	for (int i = 0; i < 3; i++){
		int num;
		cin >> num;
		d.push_back(num);

	}
	sort(d.begin(), d.end());
	cout << d[0] << " " << d[1] << " " << d[2] << endl;
	return 0;
}


Measured memory_bytes: 3164
#include <stdio.h>

int main(void)
{
  int a, b;
  scanf("%d %d", &a, &b);
  int max;
  if (a + b > a - b){
    if (a + b > a * b) max = a + b;
    else if (a * b > a - b) max = a * b;
  }else{
    if (a - b > a * b) max = a - b;
    else max = a * b;
  }
  printf("%d\n", max);
  return 0;
}

Measured memory_bytes: 128
/*
３つの整数a, b, cを読み込み、それらが a < b < cの条件を満たすならば"Yes"を、満たさないならば"No"を出力するプログラムを作成して下さい。
*/

#include <stdio.h>

int main(void) {
    int a, b, c;
    
    fscanf(stdin, "%d %d %d", &a, &b, &c);
    
    if (a < b && b < c) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    
    return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	char c; cin >> c;
	cout << (char)(c + 1) << '\n';
	return 0;
}

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

ans=0
n=len(s)
for i in range(n):
    if ((i%2==0) & ((s[i]=="R") | (s[i]=="U") | (s[i]=="D"))) | ((i%2==1) & ((s[i]=="L") | (s[i]=="U") | (s[i]=="D"))):
        ans=ans+0
    else:
        ans=ans+1

if ans==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38256
from collections import deque
N = int(input())
G = [[] for i in range(N)]
D = [0]*N
for i in range(N-1):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
    D[a-1] += 1
    D[b-1] += 1
*C, = map(int, input().split())
C.sort()

U = [1]*N
que = deque()
for i in range(N):
    if D[i] <= 1:
        que.append(i)
        U[i] = 0
it = iter(C).__next__
ans = [0]*N
R = 0
while que:
    v = que.popleft()
    ans[v] = r = it()
    R += r
    for w in G[v]:
        if U[w] == 0:
            continue
        D[w] -= 1
        if D[w] <= 1:
            U[w] = 0
            que.append(w)
print(R - C[-1])
print(*ans)

Measured memory_bytes: 6512
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

k = inp()
q = deque([i+1 for i in range(9)])
while k > 0:
    now = q.popleft()
    tail = int(str(now)[-1])
    for i in range(-1,2):
        if 0 <= tail + i <= 9:
            q.append(int(str(now) + str(tail+i)))
    k -= 1
print(now)


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define INF 2000000000000000000LL
#define EPS 1e-9
#define debug(a) cerr<<#a<<"="<<(a)<<"\n"
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL);

typedef long long ll;
typedef unsigned long long ull;
typedef complex<double> cd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll mod = 998244353 ;
const double PI = acos(-1);

int n,i,j,k,t;
double p[3002];
double dp[3002][3002];

int main(){
    scanf("%d", &n);
    for(i=1;i<=n;++i)
        scanf("%lf", p+i);
    int val = n - (n-1)/2;
    for(j=0;j<=n;++j)
        dp[0][j] = 0;
    dp[0][0] = 1;
    for(i=1;i<=n;++i){
        for(j=0;j<=n;++j)
            dp[i][j] = 0;
        for(j=0;j<i;++j){
            dp[i][j+1] += p[i]*dp[i-1][j];
            dp[i][j] += (1-p[i])*dp[i-1][j];
        }
    }
    double ans = 0;
    for(i=val;i<=n;++i)
        ans += dp[n][i];
    printf("%.12lf\n", ans);
}

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

int main(){
    int n;
    cin >> n;
    int arr[n];
    for(int i=0;i<n;i++) cin>>arr[i];
    vector <int> v(arr,arr+n);
    make_heap(v.begin(),v.end());
    
    for (unsigned i=0; i<v.size(); i++)
        cout << ' ' << v[i];
        
    cout << '\n';
}


Measured memory_bytes: 6760
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <fstream>
#include <ctime>
#include <time.h>
#include <queue>
#include <memory.h>
#include <vector>
#include <algorithm>
#include <numeric>
#define PI 3.1415927

using namespace std;
const int maxn=1e5+5;
int a[maxn];
int g[105][105];

int main()
{
    int h,w;
    while(scanf("%d%d",&h,&w)!=EOF)
    {
        int n;
        scanf("%d",&n);
        for(int i=1;i<=n;++i)
            scanf("%d",&a[i]);
        int cnt=1;
        for(int i=1;i<=h;++i)
        {
            if(i&1)
            {
                for(int j=1;j<=w;++j)
                {
                   if(a[cnt]>0) {g[i][j]=cnt;--a[cnt];}
                   else if(a[cnt]==0) {++cnt;g[i][j]=cnt;--a[cnt];}
                }
            }else
            {
                for(int j=w;j>=1;--j)
                {
                    if(a[cnt]>0) {g[i][j]=cnt;--a[cnt];}
                    else if(a[cnt]==0) {++cnt;g[i][j]=cnt;--a[cnt];}
                }
            }
        }
        for(int i=1;i<=h;++i)
        {
            for(int j=1;j<=w;++j)
            {
                if(j!=w) printf("%d ",g[i][j]);
                else printf("%d\n",g[i][j]);
            }
        }
    }
}

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

/*
2人の持つ番号の差の絶対値が、2人の身長の和に等しい
0番から左の人だけを見て行くと、差は必ずpositiveになる
よって身長の和だけが分かれば良い
A[i] + A[j] == j - iになればよいので、A[i] + i == j - A[j]になればよい
よってA[i] + iを保存しつつ見ていけば良さそう
*/

int	main(void)
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	map<int, int> mp;
	long long ans = 0;
	for (int i = 0; i < n; i++)
	{
		ans += mp[i - a[i]];
		mp[a[i] + i]++;
	}
	cout << ans << endl;
	return (0);
}


Measured memory_bytes: 20960
// Author: 23forever
#include <bits/stdc++.h>
#define pii pair<int, int>
#define mp make_pair
#define fi first
#define se second
typedef long long LL;
const int MAXN = 200000;
using namespace std;

inline int read() {
  int x = 0, w = 1;
  char c = ' ';

  while (c < '0' || c > '9') {
    c = getchar();
    if (c == '-') w = -1;
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }

  return x * w;
}

int n, a[MAXN + 5], b[MAXN + 5], c[MAXN + 5];
int dp[MAXN + 5][3];

void init() {
  n = read();
  for (int i= 1; i <= n; ++i) {
    a[i] = read();
    b[i] = read();
    c[i] = read();
  }
}

int main() {
#ifdef forever23
  freopen("test.in", "r", stdin);
  //freopen("test.out", "w", stdout);
#endif
  init();

  dp[1][0] = a[1];
  dp[1][1] = b[1];
  dp[1][2] = c[1];
  for (int i = 2; i <= n; ++i) {
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
    dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
  }

  printf("%d\n", max(dp[n][0], max(dp[n][1], dp[n][2])));
  return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <map>
#include <string.h>

using namespace std;

int main(int argc, char const* argv[])
{
    int table_count=0;
    map<char, char> map;
    char key,value;
    for (int i = 3; i < 26 ; i++) 
    {
        key = 'A' + i;
        value = 'A' + i - 3;
        map[key] = value;
        //
        //cout << key << " " << value << endl;
    }
    map['A'] = 'X';
    map['B'] = 'Y';
    map['C'] = 'Z';
    
    char input; 
    char ch;
    //while (( ch = getchar() ) != EOF) {
    //    cout << map[ch];
    //}
    string readline;
    cin >> readline;
    ///basic_string<char>::iterator ite = s.begin();
    basic_string<char>::iterator ite = readline.begin();

    for (ite = readline.begin(); ite < readline.end(); ite++) 
    {
        cout << map[*ite];
    }
    //
    //    cout << map[ch];


    cout << endl;
    return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
#define def(i,x,y)for(int i=x;i>=y;--i)
#define y1 Y1
typedef long long LL;
const int mod=1e9+7;
const int N=2000000;
int ft[N+1],Ft[N+1];
void inc(int&a,int b){ a+=b;if(a>=mod)a-=mod; }
void dec(int&a,int b){ a-=b;if(a<0)a+=mod; }
int mul(int a,int b){ return(LL)a*b%mod; }
int mi(int a,int b){
	int s=1;
	for(;b;b>>=1,a=mul(a,a))
		if(b&1)s=mul(s,a);
	return s;
}
int calc(int a,int b){
	a+=b;
	if(a<0||b<0||b>a)return 0;
	return mul(ft[a],mul(Ft[b],Ft[a-b]));
}
int solve(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4){
	int res=0,s=0;
	res=s=mul(calc(x2-x1,y2-y1),calc(x4-x2,y4-y2));
	int px1=x2,py1=y2,px2=x2,py2=y2;
	ref(i,x2+y2+1,x3+y3){
		int qx1=px1,qy1=py1;if(qy1<y3)qy1++;else qx1++;
		int qx2=px2,qy2=py2;if(qx2<x3)qx2++;else qy2++;
		if(py1<qy1)inc(s,mul(calc(qx1-1-x1,qy1-y1),calc(x4-qx1,y4-qy1)));
		else dec(s,mul(calc(px1-x1,py1-y1),calc(x4-px1,y4-(py1+1))));
		if(px2<qx2)inc(s,mul(calc(qx2-x1,qy2-1-y1),calc(x4-qx2,y4-qy2)));
		else dec(s,mul(calc(px2-x1,py2-y1),calc(x4-(px2+1),y4-py2)));
		inc(res,s);
		px1=qx1;py1=qy1;px2=qx2;py2=qy2;
	}
	//cout<<res<<endl;
	return res;
}
int x1,x2,x3,x4,x5,x6;
int y1,y2,y3,y4,y5,y6;
int ans;
int main(){
	ft[0]=1;
	ref(i,1,N)ft[i]=mul(ft[i-1],i);
	Ft[N]=mi(ft[N],mod-2);
	def(i,N,1)Ft[i-1]=mul(Ft[i],i);
	cin>>x1>>x2>>x3>>x4>>x5>>x6;
	cin>>y1>>y2>>y3>>y4>>y5>>y6;
	ref(a,0,1)ref(b,0,1)ref(c,0,1)ref(d,0,1){
		int s=solve(a?x2:(x1-1),b?y2:(y1-1),x3,y3,x4,y4,c?x5:(x6+1),d?y5:(y6+1));
		if(a^b^c^d)dec(ans,s);else inc(ans,s);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<int> cnt(N);
    REPF(i, 1, N) {
        cnt[i] += cnt[i - 1];
        if (S[i - 1] == 'A' && S[i] == 'C') {
            cnt[i]++;
        }
    }
    while (Q--) {
        int l, r;
        cin >> l >> r;
        l--, r--;
        if (S[l] == 'C') l++;
        if (S[r] == 'A') r--;
        cout << cnt[r] - (l > 0 ? cnt[l - 1] : 0) << endl;
    }
    return (0^_^0);
}



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

const int INF = (int)1e9;

int main() {
	int N;
    cin >> N;
    vector<string> S(N);
    for(int i=0; i<N; i++) cin >> S[i];

    map<char,int> m, ms[55];
    for(int i=0; i<N; i++){
        for(int j=0; j<S[i].length(); j++){
            m[S[i][j]]++;
            ms[i][S[i][j]]++;
        }
    }
    vector<char> chs;
    for(auto itr=m.begin(); itr!=m.end(); itr++){
        if((itr->second != 1) || (N==1)) chs.push_back(itr->first);
    }
    map<char,int> ansm;
    for(int k=0; k<chs.size(); k++) ansm[chs[k]]=INF;
    for(int i=0; i<N; i++){
        for(int k=0; k<chs.size(); k++){
            ansm[chs[k]] = min(ansm[chs[k]],ms[i][chs[k]]);
        }
    }

    for(auto itr=ansm.begin(); itr!=ansm.end(); itr++){
        //cout << itr->first <<" "<< itr->second << endl;
        for(int i=0; i<itr->second; i++){
            cout << itr->first;
        }
    }
    cout << endl;

}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
A = LIST(N)

if A[0] != 0:
    print(-1)
    exit()

ans = 0
for i in range(N-1):
    if A[i] + 1 < A[i+1]:
        print(-1)
        exit()
    elif A[i] + 1 == A[i+1]:
        ans += 1
    else:
        ans += A[i+1]
print(ans)


Measured memory_bytes: 11048
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#pragma comment(linker, "/STACK:400000000")

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(it=X.begin();it!=X.end();it++)
#define iss istringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sst stringstream
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

enum { Ba,L,F,R,T,Bo };

int n,t,f;
int x[][4]={{T,F,Bo,Ba},{T,R,Bo,L},{T,Ba,Bo,F},{T,L,Bo,R},{F,R,Ba,L}};
int top[211][211],dep[211][211],dy[]={-1,0,1,0},dx[]={0,-1,0,1};

// 0
//1 3
// 2

void rot(vi& dice,int dir){
	int temp=dice[x[dir][0]];
	rep(i,3)dice[x[dir][i]]=dice[x[dir][i+1]];
	dice[x[dir][3]]=temp;
}

int ok(vi dice){
	vi D(6);
	D[T]=1;D[Bo]=6;D[L]=2;D[R]=5;D[F]=3;D[Ba]=4;
	rep(i,2){
		rep(j,4){
			rep(k,4){
				if(D==dice)return 1;
				rot(D,0);
			}
			rot(D,1);
		}
		rot(D,4);
	}
	return 0;
}

int main(){
	while(cin>>n && n){
		memset(top,0,sizeof(top));
		memset(dep,0,sizeof(dep));
		rep(h,n){
			cin>>t>>f;
			vi v(6);
			v[T]=t;
			v[Bo]=7-t;
			v[F]=f;
			v[Ba]=7-f;
			rep(i,7){
				v[L]=i;
				v[R]=7-i;
				if(ok(v))break;
			}
			int y=100,x=100;
			while(1){
				int dir=-1,maxnum=-1;
				rep(i,4){
					if(v[i]>3 && v[i]>maxnum
					&& dep[y][x] > dep[y+dy[i]][x+dx[i]]){
						dir=i;
						maxnum=v[i];
					}
				}
				if(dir==-1)break;
				rot(v,dir);
				y+=dy[dir];
				x+=dx[dir];
			}
			top[y][x]=v[T];
			dep[y][x]++;
		}
		vi ans(7);
		rep(i,200)rep(j,200)ans[top[i][j]]++;
		rep2(i,1,7)cout<<ans[i]<<(i==6?"\n":" ");
	}
}

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

int main()
{
	int n,c,i;
	int pre[12],now[12],cnt[12];
	while(cin >> n,n)
	{
		map<int,int> m;
		for(i=0; i<n; i++)
		{
			cin >> pre[i];
			m[pre[i]] = i+1;
		}
		for(i=0; i<n; i++)
			now[i] = m[pre[i]];	

		for(c=0; ; c++)
		{
			for(i=0; i<n; i++)
				cnt[i] = 0;

			for(i=0; i<n; i++)
				cnt[now[i]-1]++;		

			for(i=0; i<n; i++)
				now[i] = cnt[now[i]-1];

			for(i=0; i<n; i++)
				if(now[i]!=pre[i])
					break;

			if(i==n) break;

			for(i=0; i<n; i++)
				pre[i] = now[i];
		}

		cout << c << endl << now[0];
		for(i=1; i<n; i++)
			cout << " " << now[i];
		cout << endl;


	}
	return 0;
}

Measured memory_bytes: 820
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    string S; cin >> S;
    int mask = 0;
    for (auto c : S) {
        if (c == 'N') mask |= 1;
        if (c == 'S') mask |= 2;
        if (c == 'W') mask |= 4;
        if (c == 'E') mask |= 8;
    }
    const char *YesNo[] = {"No", "Yes"};
    cout << YesNo[mask == 3 || mask == 12 || mask == 15] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const ll INF = 10e16;
const int maxN = 600010;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 1000000007;

pii a[maxN];
char s[maxN];
int main()
{
	scanf("%s",s+200000);
	int top = 200000;
	int tail = 200000+strlen(s+200000);
	int Q;
	scanf("%d",&Q);
	int cnt = 0;
	for(int i=1;i<=Q;i++)
	{
		int t;
		scanf("%d",&t);
		if(t == 1)
		{
			a[i] = pii(0,1);
			cnt++;
		}
		else
		{
			int f;
			char c;
			scanf("%d %c",&f,&c);
			if(cnt%2 == 1)
			{
				f = 3-f;
			}
			if(f == 1)
			{
				top--;
				s[top] = c;
			}
			else
			{
				s[tail] = c;
				tail++;
			}
		}
	}
	if(cnt%2 == 1)
	{
		reverse(s+top,s+tail);
	}
	for(int i=top;i<tail;i++)
	{
		cout<<s[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 4352
function Main(input){
  const arr = input.split('\n');
  let nums, a, b;

  for (let i = 0; i < arr.length; i++){
    nums = arr[i].split(' ').map(Number);
    a = nums[0];
    b = nums[1];
    if (a === 0 && b === 0){
      break;
    } else if (a > b) {
      console.log(b, a);
    } else {
      console.log(a, b);
    }    
      }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 20988
#include<iostream>
#include <cstring>
using namespace std;
int main()
{
	string a,str,b;
	cin >> str ;
	a=str.substr(0,1);
	b=str.substr(str.length()-1,str.length());
	cout << a;
	cout << str.length()-2;
	cout << b;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000
#define MAX 200001

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 998244353;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

int main(){
    ll N;
    cin >> N;
    bool flag = true;
    ll ans = 0;
    vector<vector<ll>> A(N, vector<ll>(N,0));
    vector<vector<bool>> f(N, vector<bool>(N,true));
    rep(i,N)rep(j,N){
        cin >> A[i][j];
        ans += A[i][j];
    }
    rep(k,N)rep(i,N)rep(j,N){
        if(A[i][j] > A[i][k] + A[k][j]) flag = false;
        else if(A[i][j] == A[i][k] + A[k][j]){
            if(k == i or k == j) continue;
            f[i][j] = false;
        }
    }
    rep(i,N)rep(j,N){
        if(!f[i][j]) ans -= A[i][j];
    }
    if(flag) cout << ans / 2 << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 4348
n,m = map(int,input().split())

ok = True
num = [-1]*n
for i in range(m):
    s,c = map(int,input().split())
    s -= 1
    if n >= 2 and s == 0 and c == 0:
        ok = False
        break
    elif num[s] == -1:
        num[s] = c
    elif num[s] != c:
        ok = False
        break
if ok == False:
    print(-1)
    exit()
for i in range(n):
    if n >= 2 and i == 0:
        if num[i] == -1:
            num[i] = 1
    else:
        if num[i] == -1:
            num[i] = 0
ans = [str(num[i]) for i in range(n)]
print("".join(ans))

Measured memory_bytes: 61996
import java.util.Scanner;

class Dice{
	int[] dice = new int[7];
	int[] dice2 = new int[7];
	
	void Setdice(int[] box)
	{
		dice[0] = 0;
		dice2[0] = 0;
	}
	
	void diceroll(char[] roll)
	{
		for(int i = 0;i < roll.length;i++)
		{
			int temp =0;
			if(roll[i] == 'N'){
				temp = dice[1];
				dice[1] = dice[2];
				dice[2] = dice[6];
				dice[6] = dice[5];
				dice[5] = temp;
			}else if(roll[i] == 'E'){
				temp = dice[1];
				dice[1] = dice[4];
				dice[4] = dice[6];
				dice[6] = dice[3];
				dice[3] = temp;
			}else if(roll[i] == 'S'){
				temp = dice[1];
				dice[1] = dice[5];
				dice[5] = dice[6];
				dice[6] = dice[2];
				dice[2] = temp;
			}else if(roll[i] == 'W'){
				temp = dice[1];
				dice[1] = dice[3];
				dice[3] = dice[6];
				dice[6] = dice[4];
				dice[4] = temp;
			}else if(roll[i] == 'R'){
				temp = dice[2];
				dice[2] = dice[3];
				dice[3] = dice[5];
				dice[5] = dice[4];
				dice[4] = temp;
			}else if(roll[i] == 'L'){
				temp = dice[2];
				dice[2] = dice[4];
				dice[4] = dice[5];
				dice[5] = dice[3];
				dice[3] = temp;
			}
		}
	}
	
	int Getdice(int num)
	{
		return dice[num];
	}
}

public class Main {
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		Dice dice = new Dice();
		for(int i = 1;i < 7;i++)
		{
			dice.dice[i] = scan.nextInt();
		}
		for(int i = 1;i < 7;i++)
		{
			dice.dice2[i] = scan.nextInt();
		}
		
		int count;
		boolean ansflg = false;
		String str = "";
		for(int i = 0;i < 4;i++){
			for(int j = 0;j < 4;j++){
				for(int k = 0;k < 4;k++){
					count = 0;
					for(int l = 1;l < dice.dice.length;l++)
					{
						if(dice.dice[l] == dice.dice2[l])
						{
							count++;
							
						}
						if(count == 6)
						{
							ansflg = true;
						}
					}
					str = "R";
					dice.diceroll(str.toCharArray());
				}
				str = "S";
				dice.diceroll(str.toCharArray());
			}
			str = "E";
			dice.diceroll(str.toCharArray());
		}
		if(ansflg == true)
		{
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 17336
N, M = map(int, input().split())
candidates = []
for p in range(1, max(int(M ** 0.5) + 1, N + 1)):
    if M % p == 0:
        if M // p >= N:
            # p * (M // p = a1+a2+.. >= N) = M
            candidates.append(p)
        if p >= N:
            # (M // p) * (p = a1+a2+.. >= N) = M
            candidates.append(M // p)
print(max(candidates))

Measured memory_bytes: 3060
import fractions

def lcm(a, b):
    return int(a * b / fractions.gcd(a, b))


N, M = [int(i) for i in input().split()]
s = input()
t = input()

L = lcm(N, M)
l_to_s = {}
for i in range(N):
    l_to_s[1 + i * (L // N)] = i
l_to_t = {}
for i in range(M):
    l_to_t[1 + i * (L // M)] = i

ans = L
for k, v in l_to_s.items():
    if k in l_to_t:
        if s[v] != t[l_to_t[k]]:
            ans = -1
            break

print(ans)

Measured memory_bytes: 28984
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size)scanf("%d",&(name)[i])

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    GI3(N,A,B);
    int c=0;
    for(int i=1;i<=N;++i){
        int t=0;
        int x=i;
        while(x>0){
            t+=x%10;
            x/=10;
        }
        if(A<=t&&t<=B)c+=i;
    }
    print(c);
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class ABC
{
    public static void Main()
    {
        int[] ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int a = ab[0];
        int b = ab[1];
        int output = 0;
        if (a >= 13) output = b;
        else if (a <= 5) output = 0;
        else output = b / 2;
        Console.WriteLine(output);

    }


}

Measured memory_bytes: 11220
import re
def nchars(s, n):
    """文字列 s に、同じ文字が n 個以上連続している部分文字列を見つける
    """
    assert n > 0
    reg = re.compile("(.)\\1{%d,}" % (n - 1))  # カンマを取ると n 個ちょうどになる
    while True:
        m = reg.search(s)
        if not m:
            break
        yield m.group(0)
        s = s[m.end():]

S = input()
a = list(nchars(S,2))
if len(a)==0:
    print("Good")
else:
    print("Bad")

Measured memory_bytes: 3316
// Problem : B - Count ABC
// Contest : AtCoder - AtCoder Beginner Contest 150
// URL : https://atcoder.jp/contests/abc150/tasks/abc150_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    int n;
    string s;
    cin>>n>>s;
    int ans = 0;
    for(int i=0;i<n-2;i++){
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ans++, i+=2;
    }
    cout<<ans;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
    ll n, k, x, y;

    cin >> n >> k;

//    x = n % k;
//    y = k - x;

    cout << min(n % k, k - (n % k)) << endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long X = Math.abs(sc.nextLong());
		long K = sc.nextLong();
		long D = sc.nextLong();
		long ans = X;
		if(K <= (double) X / D)
			ans = X - K * D;
		else {
			K -= X / D;
			X %= D;
			if(K % 2 == 1)
				ans = Math.abs(X - D);
			else
				ans = X;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 35676
// Aizu 1124: When Can We Meet?
// 2017.9.15 bal4u@uu

#include <stdio.h>
#include <string.h>

int f[102];

int main()
{
	int n, q, m, i, d, max, ans;

	while (scanf("%d%d", &n, &q) && n) {
		memset(f, 0, sizeof(f)), max = 0;
		while (n-- > 0) {
			scanf("%d", &m);
			while (m-- > 0) { scanf("%d", &d), f[d]++; if (d > max) max = d; }
		}
		for (ans = 0, i = 1; i <= max; i++) if (f[i] >= q && f[i] > f[ans]) ans = i;
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1760
#include <stdio.h>

int search(int A[], int n, int key) {
  int i = 0;  A[n] = key;
  while(A[i] != key) i++;
  return i != n;
}

int main(void) {
  int i, n, A[10000+1], q, key, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d", &A[i]);
  scanf("%d",&q);
  for(i=0; i<q; i++) {
    scanf("%d", &key);
    if(search(A, n, key)) sum++;
  }
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int h, w;
vector<vector<char>> maze(21, vector<char>(21));
vector<vector<int>> current;
int cur_big = 0;
void dfs(int y, int x, int py = -1, int px = -1, int d = 0)
{
    if (current[y][x] != -1)
    {
        if (d >= current[y][x])
        {
            return;
        }
        current[y][x] = min(d, current[y][x]);
    }
    else
    {
        current[y][x] = d;
    }
    cur_big = max(current[y][x], cur_big);
    if (y > 0 && maze[y - 1][x] == '.' && y - 1 != py)
    {
        dfs(y - 1, x, y, x, d + 1);
    }
    if (y < h - 1 && maze[y + 1][x] == '.' && y + 1 != py)
    {
        dfs(y + 1, x, y, x, d + 1);
    }
    if (x > 0 && maze[y][x - 1] == '.' && x - 1 != px)
    {
        dfs(y, x - 1, y, x, d + 1);
    }
    if (x < w - 1 && maze[y][x + 1] == '.' && x + 1 != px)
    {
        dfs(y, x + 1, y, x, d + 1);
    }
}

int main()
{
    cin >> h >> w;
    rep(y, h)
    {
        rep(x, w)
        {
            cin >> maze[y][x];
        }
    }

    int big = 0;
    rep(y, h) rep(x, w)
    {
        if (maze[y][x] == '.')
        {
            int cur_big = 0;
            current = vector<vector<int>>(h, vector<int>(w, -1));
            dfs(y, x);
            for (auto &row : current)
            {
                for (auto &c : row)
                {
                    cur_big = max(cur_big, c);
                }
            }
            big = max(cur_big, big);
        }
    }

    cout << big << endl;

    return 0;
}

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

#pragma warning(disable:4996)
using namespace std;


int main() {
	int N,M;cin>>N>>M;
	vector<long long int>a,b;
	for (int i = 0; i < N; ++i) {
		int k;cin>>k;
		a.push_back(k);
	}
	for (int i = 0; i < M; ++i) {
		int k;cin>>k;
		b.push_back(k);
	}
	long long int answer=accumulate(a.begin(),a.end(),0ll)*accumulate(b.begin(),b.end(),0ll);
	cout<<answer<<endl;
	return 0;
}



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

class Problem {
    public static void Main() {
        var rc = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var list = new int[rc[0] + 1, rc[1] + 1];
        for (var i = 0; i < rc[0]; i++) {
            var data = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (var j = 0; j < data.Length; j++) {
                list[i, j] = data[j];
                list[rc[0], j] += data[j];
            }
            var sum = data.Sum();
            list[i, rc[1]] = sum;
            list[rc[0], rc[1]] += sum;
        }
        for (var i = 0; i < list.GetLength(0); i++)
            for (var j = 0; j < list.GetLength(1); Console.Write(++j != rc[1] + 1 ? " " : "\n"))
                Console.Write(list[i, j]);
    }
}


Measured memory_bytes: 9780
//Think simple yet elegant.
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll  long long
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
const ll maxn=2e5+10;
const ll mod=1e9+7;


int main() {
  	fast;
  	ll x;
  	cin>>x;
  	ll ans=0;
  	ll money = 100;
  	while(money<x){
  		money = (money/100) + money;
  		++ans;
  	}
  	cout<<ans;
}

Measured memory_bytes: 3644
package main

import "fmt"

func main() {
	var n, cnt int
	var isTriple bool
	fmt.Scan(&n)
	d1 := make([]int, n)
	d2 := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&d1[i], &d2[i])
		if d1[i] == d2[i] {
			cnt++
		} else {
			cnt = 0
		}
		if cnt >= 3 {
			isTriple = true
		}
	}

	if isTriple {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1840
use std::io::*;
use std::str::FromStr;

fn isprime<T>(n: T) -> bool
where
    T: Copy
        + std::ops::Rem<Output = T>
        + std::ops::Mul<Output = T>
        + std::cmp::Ord
        + std::convert::From<u32>,
{
    if n <= T::from(1u32) {
        return false;
    }

    for i in (2u32).. {
        let x = T::from(i);
        if x * x > n {
            break;
        }

        if n % x == T::from(0u32) {
            return false;
        }
    }
    true
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: u32 = sc.next();
    let mut cnt: u32 = 0;
    for _ in 0..n {
        let x: u32 = sc.next();
        if isprime(x) {
            cnt += 1;
        }
    }

    println!("{}", cnt);
}

/* ========== Scanner ========== */

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn next<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next()).collect()
    }

    fn char(&mut self) -> char {
        self.next::<String>().chars().next().unwrap()
    }
}



Measured memory_bytes: 5040
n=int(input())
for i in range(n):
    points = input().split()
    p = list(map(float,points))
    if (p[3]-p[0])**2 + (p[4]-p[1])**2 < (p[2]-p[5])**2:
        if p[5]>p[2]:
            print(-2)
        else:
            print(2)
    elif (p[0]-p[3])**2 + (p[1]-p[4])**2 >= (p[2]-p[5])**2 and (p[0]-p[3])**2 + (p[1]-p[4])**2 <= (p[2]+p[5])**2:
        print(1)
    else:
        print(0)

Measured memory_bytes: 5620
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::Ordering;

fn main() {
    let n = read();
    let mut v = Vec::new();
    for i in 0..n {
        v.push((read::<String>(), read::<i32>(), i + 1));
    }
    v.sort_by(|a, b| {
        let result = a.0.cmp(&b.0);
        if result != Ordering::Equal {
            return result;
        }
        else if a.1 > b.1 {
            return Ordering::Less;
        }
        Ordering::Greater
    });
    for a in v {
        println!("{}", a.2);
    }
}


Measured memory_bytes: 4352
public class Main {
	public static void main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
			scan.useDelimiter("//n");
			char[] arr = new char[1200];
			String str2 ="abcdefghijklmnopqrstuvwxyz";
			char[] arr2 = str2.toCharArray();
			int[] line = new int[26];

			do{
				String str = scan.nextLine();
				arr = str.toCharArray();

				for(int i = 0;i <arr.length;i++){
					if(Character.isUpperCase(arr[i])){
						arr[i] = Character.toLowerCase(arr[i]);
					}
					for(int j = 0; j< 26;j++){
						if(arr[i] == arr2[j]){
							line[j]++;
						}
					}
				}
			}while(scan.hasNext());
		for(int i = 0;i < 26;i++){
			System.out.println(arr2[i] + " : " +line[i]);
		}
	}

}

Measured memory_bytes: 26320
#include <stdio.h>

int main(void)
{
	int a[3][101],n,m,ans=0,x,y,z;
	for(x=0;x<3;x++)
	{
		for(z=0;z<101;z++)
		{
			a[x][z]=0;
		}
	}
	scanf("%d",&n);
	for(x=0;x<3;x++)
	{
		scanf("%d",&y);
		for(z=0;z<y;z++)
		{
			scanf("%d",&m);
			a[x][m]=1;
		}
	}
	for(x=0;x<101;x++)
	{
		if(a[0][x]==0&&a[2][x]==1)
		ans++;
		else if(a[1][x]==1&&a[2][x]==1)
		ans++;
	}
	printf("%d\n",ans);
	return 0;
}

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

namespace Atc_0032
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            int index = 0;
            int count = 0;

            while (index < N)
            {
                var s = Console.ReadLine();

                if (s.Split(' ')[0] == s.Split(' ')[1])
                {
                    count++;
                }
                else
                {
                    count = 0;
                }

                if (3 <= count)
                {
                    break;
                }

                index++;
            }

            if (3 <= count)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

ll L;

inline ll read(){
    ll s = 0, w = 1;
    char ch = getchar();
    for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
    for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
    return s * w;
}

inline void work(){
    L = read();                             //è¾“å…¥æ€»é•¿åº¦L
    printf("%.12f\n", pow(L * 1.0 / 3, 3)); //è§åˆ†æž
}

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

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

ll H, W;
signed main(){
    cin >> H >> W;
    if(H == 1 || W == 1) cout << 1 << endl;
    else cout << (H*W+1LL)/2LL << endl;
}

Measured memory_bytes: 256
N,M = list(map(int,input().split()))

S = list(map(int,input().split()))
T = list(map(int,input().split()))

DP = [[0]*(N+1) for i in range(M+1)]

for i in range(N+1):
    DP[0][i]=1


for i in range(M+1):
    DP[i][0]=1

mod=10**9 + 7
for i in range(M):
    for j in range(N):
        if T[i]==S[j]:
            DP[i+1][j+1]=(DP[i+1][j]+DP[i][j+1])%mod
        else:
            DP[i+1][j+1]=(DP[i+1][j]+DP[i][j+1]-DP[i][j])%mod

print(DP[M][N])

Measured memory_bytes: 72540
fun main(args:Array<String>) {
	val s= readLine()!!.toList().map {it.toString().toInt()}
	val n=s.size
	if(n==1){
		println(s[0])
		return
	}
	val bit = (1..n-1).fold(1){acc, o ->acc*2} -1
	(0..bit).map{
		val plus = Integer.toBinaryString(it).padStart(n-1,'0').map {it=='1'}
		val sb = StringBuilder()
		for(i in 0..plus.lastIndex){
			sb.append(s[i])
			if(plus[i]) sb.append("+")
		}
		sb.append(s.last())
		return@map sb.split("+").map {it.toLong()}.sum()
	}.sum().let {println(it)}
}

Measured memory_bytes: 40616
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll N, K;
  cin >> N >> K;
  
  vector<ll> A(N, 0);
  rep(i, N) cin >> A[i];
  ll high = 1e9, low = 1, mid = (high + low) / 2;
  while (high > low){
    ll cnt = 0;
    rep(i, N){
      ll a = A[i]-1;
      cnt += a / mid;
    }
    if (cnt > K)
      low = mid + 1;
    else
      high = mid;
    mid = (high + low) / 2;
//cout << "high:"<< high << "low:"<< low << "cnt:"<< cnt << endl;    
  }
  //check
  ll cnt = 0;
  rep(i, N){
    ll a = A[i]-1;
    cnt += a / low;
  }
  if (cnt > K)
    low++;
  cout << low << endl;
}


Measured memory_bytes: 4772
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int main() {
	int N;
	cin >> N;
	vi a(N);
	rep(i, N)
		cin >> a[i];
	int ans = 0;
	int numtmp = 1;
	rep(i, N) {
		if (a[i] == numtmp)
			numtmp++;
		else
			ans++;
	}
	if (ans == N)
		ans = -1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String args[]){
		Scanner cin = new Scanner(System.in);
		String text = cin.next();
		cin.close();

		for(int i=0;i<19;i++){
			if(i==5||i==13){
				System.out.print(" ");
			}else{
				System.out.print(text.charAt(i));
			}
		}
		System.out.println("");
	}
}


Measured memory_bytes: 21588