akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
{ for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{ cerr << " " << H; debug_out(T...); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    string s;
    cin >> s;
    rep(i, (int)s.size()) {
        if ((i & 1 && s[i] == 'R') || (!(i & 1) && s[i] == 'L')) {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

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



Measured memory_bytes: 3636
N = int(input())
l = []
for i in range(N):
  l.append(list(map(str, input().split())))

for i in range(N):
  l[i][1] = int(l[i][1])
  l[i].append(i+1)
  l[i][1] = 100-l[i][1]
  
l.sort()

for i in range(N):
  print(l[i][2])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,c=0,n,j,p=0;
    string a;
    char x;
    cin>>n;
    cin>>a;
    for(i=0; i<a.size(); i++)
    {
        if(a[i]>='A'&& a[i]<='Z')
        {
            p= a[i]+n;
            if(p>90)
            {
                p=p-26;
            }
            x=p;
            cout<<x;

        }

    }
    cout<<endl;

}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	var s string
	fmt.Scan(&n)
	fmt.Scan(&s)
	if len(s) != n{
		return
	}

	count := 1
	for i := 1; i<len(s); i++{
		if s[i-1] != s[i]{
			count++
		}
	}

	fmt.Println(count)
}

Measured memory_bytes: 2484
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	int y;
	y = pow(2, N);
	int k[10];
	int s[10][10];
	int p[10];
	int D[10000][10];
	for (int i = 0; i < y; i++) {
		for (int m = 0; m < M; m++) {
			D[i][m] = 0;
		}
	}
	for (int i = 0; i < M; i++) {
		cin >> k[i];
		for (int j = 0; j < k[i]; j++) {
			cin >> s[i][j];
		}
	}
	for (int i = 0; i < M; i++) {
		cin >> p[i];
	}
	int x;
	int ans = 0;
	for (int i = 0; i < y; i++) {
		for (int j = 0; j < N; j++) {
			x = pow(2, j);
			for (int m = 0; m < M; m++) {
				if ((i / x) % 2 == 1) {
					{
						for (int l = 0; l < k[m]; l++) {
							if (s[m][l] == j + 1) D[i][m]++;
						}
					}
				}
			}
		}
	}
	for (int i = 0; i < y; i++) {
		for (int m = 0; m < M; m++) {
			if (D[i][m] % 2 != p[m]) {
				ans -= 1;
				break;
			}
		}
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n;
    cin>>n;
    int a[n];
    int ans=0;
    rep(i,n){
        cin>>a[i];
        ans+=a[i];
    }
    int kai=(1+n)*n/2;
    cout<<ans-kai<<endl;
}



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

int main(void){
  int n;
  cin >> n;
  ll tot = 0;
  vector<ll> cnt(100005);
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    cnt[a]++;
    tot += a;
  }
  
  int q;
  cin >> q;
  for(int i = 0; i < q; i++){
    int b, c;
    cin >> b >> c;
    tot += (c-b)*cnt[b];
    cnt[c] += cnt[b];
    cnt[b] = 0;
    cout << tot << endl;
  }
  return 0;
}

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

int main(void) {
  int steps[2], degree, sum_degree = 0, count = 1;
  double x = 0.0, y = 0.0;

  scanf("%d,%d", &steps[0], &sum_degree);
  y += steps[0];
  while (1) {
    scanf("%d,%d", &steps[count % 2], &degree);
    if (steps[count %2] == 0 && degree == 0) break;

    y += steps[count % 2] * sin((-sum_degree + 90) * M_PI / 180);
    x += steps[count % 2] * cos((-sum_degree + 90) * M_PI / 180);

    sum_degree += degree;
    count++;
  }

  printf("%d\n%d\n", (int)x, (int)y);

  return 0;
}

Measured memory_bytes: 604
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>
#include<queue>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))


int main(){
	int x[3],e,d,t,cnt;
	e=d=t=cnt=0;
	for(;;cnt++){
		rep(i,3)scanf("%d",x+i);
		sort(x,x+3);
		if(x[2]>=x[0]+x[1])break;
		rep(i,3)x[i]*=x[i];
		if(x[2]==x[0]+x[1])t++;
		else if(x[2]<x[0]+x[1])e++;
		else d++;
	}
	printf("%d %d %d %d\n",cnt,t,e,d);
	return 0;
}

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

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

    int ans = 0;
    for (int i = 1; i <= N; i++)
    {
        int num = i;
        int count = 0;
        while (num >= 10)
        {
            count++;
            num /= 10;
        }
        if ((count + 1) % 2 == 1)
            ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(int i=0;i<N;i++)
typedef long long ll;
const ll MOD=1000000007;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
	int N;
    cin>>N;
    vector<int>d(N);
    for(int i=0;i<N;i++){
        cin>>d[i];
    }
    sort(ALL(d));
    cout<<d[N/2]-d[N/2-1]<<endl;
}

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

main()
{
  int n;
  cin >> n;
  map< int, int > x;
  for(int i = 0, tmp; i < n; i++) {
    cin >> tmp;
    if(x.end() == x.find(tmp)) {
      x.insert(make_pair(tmp, 1));
    } else {
      x.at(tmp)++;
    }
  }

  string ans;
  if(x.size() > 3) {
    ans = "No";
  } else if(x.find(0) == x.end()) {
    if(x.size() != 3) {
      ans = "No";
    } else {
      int count = 0, first = 0, second = 0;
      ans = "Yes";
      for(const auto &s : x) {
        if(count == 0) {
          count = s.second;
          first = s.first;
        } else if(count != s.second) {
          ans = "No";
          break;
        } else if(second == 0) {
          second = s.first;
        } else if((first ^ second) != s.first) {
          ans = "No";
          break;
        }
      }
    }
  } else {
    if(x.size() == 1) {
      ans = "Yes";
    } else {
      if(x.size() == 2) {
        int tmp = 0;
        for(const auto &s : x) {
          if(tmp == 0) {
            tmp = s.second;
          } else if(s.second / tmp == 2 && s.second % tmp == 0) {
            ans = "Yes";
          } else {
            ans = "No";
          }
        }
      } else {
        ans = "No";
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3840
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#define pii pair<int,int> 
#define mp make_pair
#define fr first
#define sc second
using namespace std;
int n,P,sl,fh,ans,l[512],r[512],dp[512][256];
pii a[512];
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
void upd(int &x,int y) {x+=y; if(x>=P) x-=P;}
int main()
{
	n=rd();P=rd();
	for(int i=0;i<n<<1;++i)
	{
		r[i]=min(2*n-1,(int)floor(sqrt(4*n*n-i*i)));
		if(i<n) l[i]=ceil(sqrt(n*n-i*i)),a[i]=mp(l[i]-1,-i);
		else a[i]=mp(r[i],-i);
	}
	sort(a,a+n*2);for(int i=0;i<n<<1;++i) a[i].sc=-a[i].sc;
	for(int cnt,k=0;k<=n;++k)
	{
		memset(dp,0,sizeof(dp));cnt=0;dp[0][0]=1;
		for(int i=0;i<n<<1;++i)
		{
			if(a[i].sc<n) cnt++;
			for(int j=0,M=min(k,cnt);j<=M;++j)
				if(a[i].sc<n)
				{
					dp[i+1][j]=1ll*dp[i][j]*(r[a[i].sc]+1-(2*n-1-a[i].sc+k-j))%P;
					if(j) dp[i+1][j]=(dp[i+1][j]+1ll*dp[i][j-1]*(a[i].fr+1-(i-(cnt-j))))%P;
				}
				else dp[i+1][j]=1ll*dp[i][j]*(a[i].fr+1-(i-(cnt-j)))%P;
		}
		if(k&1) upd(ans,P-dp[n<<1][k]); else upd(ans,dp[n<<1][k]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(void)
{
  int n,m,p,i,sum,ans;
  while(1){
    scanf("%d %d %d",&n,&m,&p);
    if(!(n+m+p)) break;
    int a[n];
    sum=0;
    for(i=0;i<n;i++){
      scanf("%d",&a[i]);
      sum+=a[i];
    }
    sum*=100;
    sum=sum-((sum*p)/100);
    if(!a[m-1])
      printf("%d\n",0);
    else{
      ans=sum/a[m-1];
      printf("%d\n",ans);
    }
    }
  return 0;
}

Measured memory_bytes: 600
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
using namespace std;
using ll = long long;
using lll = __int128_t;
typedef pair<ll,ll> P;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
const ll longinf=1ll<<60;
const int inf=(1<<30)-1;
const ll mod=1e9+7;

int main(){
      int n;
      cin>>n;
      int a[n][n];
      for(int i=0;i<n-1;i++){
            for(int j=i+1;j<n;j++){
                  int k=0;
                  while(1){
                        if(((i>>k)xor(j>>k))&1){
                              a[i][j]=k+1;
                              break;
                        }
                        k++;
                  }
            }
      }
      for(int i=0;i<n-1;i++){
            for(int j=i+1;j<n;j++){
                  cout<<a[i][j]<<" ";
            }
            cout<<endl;
      }
      return 0;
}

Measured memory_bytes: 1408
#include<iostream>
int main(){
	char x, y;
	std::cin >> x >> y;
	if (x > y) {
		std::cout << ">" << std::endl;
	}
	if (x < y) {
		std::cout << "<" << std::endl;
	}
	if (x == y) {
		std::cout << "=" << std::endl;
	}
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

inline int topbit(unsigned long long x){
    return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
    return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
    return __builtin_parity(x);
}

int N;
int A[111111];

bool check(const vint &v){
    rep(i,N-1){
        if(A[v[i]]==v[i+1])return false;
    }
    return true;
}

int deg[111111];
signed main(){
    cin>>N;
    rep(i,N)cin>>A[i],A[i]--;

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

    set<int>s;
    rep(i,N)s.insert(i);

    rep(i,N)deg[A[i]]++;

    vint vs;
    int pre=-1;
    while(s.size()>3){
        int v=*s.begin();
        s.erase(v);

        if(pre!=-1&&A[pre]==v){
            int vv=*s.begin();
            s.erase(vv);
            s.insert(v);
            v=vv;
        }

        if(s.find(A[v])!=s.end()&&deg[A[v]]==s.size()){
            int vv=A[v];
            s.insert(v);
            s.erase(vv);
            v=vv;
        }
        deg[A[v]]--;

        vs.pb(v);
        pre=v;
    }

    vint rm;
    for(auto v:s)rm.pb(v);

    const int INF=1001001001;
    vint ans(N,INF);

    do{
        vint tmp=vs;
        tmp.insert(tmp.end(),all(rm));
        if(check(tmp))chmin(ans,tmp);
    }while(next_permutation(all(rm)));


    rep(i,ans.size()){
        if(i)cout<<" ";
        cout<<ans[i]+1;
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 7920
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

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

    int A,B,M; cin >> A >> B >> M;
    int a[A],b[B];
    rep(i,A) cin >> a[i];
    rep(i,B) cin >> b[i];
    int ans=INF;
    rep(i,M){
        int t,s,u; cin >> t >> s >> u;
        t--; s--;
        chmin(ans,a[t]+b[s]-u);
    }
    sort(a,a+A); sort(b,b+B);
    chmin(ans,a[0]+b[0]);
    cout << ans << endl;

}

Measured memory_bytes: 1792
# 入力をintにして変数に格納
a, b, c, k = map(int, input().split())

# KとA,Bの大きさに応じて場合分けして最大値計算
if a >= k :
    max = k

elif a+b >= k :
    max = a

elif( a+b <= k ):
    max = a - ( k - a - b )

# 結果を出力
print(max)

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

const int MOD=1000000007;

int cntNum[1010];

void cal(int x){
    for(int i=2;i<=x;i++){
        while(x%i==0){
            cntNum[i]++;
            x/=i;
        }
        if(x==1)break;
    }
}

int main(){
    int N;
    cin>>N;
    for(int i=1;i<=N;i++){
        cal(i);
    }
    long long ans=1;
    for(int i=2;i<=N;i++){
        if(cntNum[i]!=0){
            ans*=cntNum[i]+1;
            ans%=MOD;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
while True:
    n = int(input())
    if n == 0:
        break
    samples = list(map(float,input().split()))
    
    m = 0
    for sample in samples:
        m += sample
    m = m / len(samples)
    
    a2 = 0
    for sample in samples:
        a2 += (sample - m) ** 2 / len(samples)
        
    print(a2 ** 0.5)


Measured memory_bytes: 5728
n = int(input())
S = [*map(int, input().split())]
t = [0]

def merge(A, left, mid, right):
  L = A[left:mid] + [float("inf")]
  R = A[mid:right] + [float("inf")]
  i, j = 0, 0
  for k in range(left, right):
    if L[i] <= R[j]:
      A[k] = L[i]
      i += 1
    else:
      A[k] = R[j]
      t[0] += mid + j - k
      j += 1
  return right - left

def merge_sort(A, left, right):
  count = 0
  if right - left > 1:
    mid = (left + right) // 2
    count += merge_sort(A, left, mid) + merge_sort(A, mid, right)
    count += merge(A, left, mid, right)
  return count

count = merge_sort(S, 0, n)
print(t[0])


Measured memory_bytes: 27476
#include<cstdio>
int l, r;
bool ans = true;
int main()
{
	scanf("%d%d",&l, &r);
	for(register int i = l;i <= r;i++){
		if(i == 0){
			printf("Zero");
			return 0;
		}else if(i < 0){
			ans = !ans;
		}
	}
	if(ans > 0) printf("Positive");
	else printf("Negative");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int> ;
using vl = vector<ll>;

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

    x -= 400;
    x /= 200;
    cout << 8 - x << endl;

    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
 
using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;
 
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")


#define lli long long int 
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define loopb(i,a,b) for (lli i=a;i>=b;i--)
#define pb push_back
#define mod 1000000007
#define fast() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mem(a,b) memset(a,b,sizeof(a))
#define gcd(a,b) (__gcd((a),(b)))
#define lcm(a,b)(((a)*(b))/gcd((a),(b)))
#define bc __builtin_popcountll
#define vi vector<lli>
#define pr pair<lli,lli>
#define vp vector<pr>
#define F  first
#define S   second
#define lld long double 
lli a[100002][3];
lli dp[100002][3];
lli n;
lli solve(lli day,lli act)
{ if(dp[day][act]!=-1)
{return dp[day][act];
}
else
{
if(day==(n-1))
{dp[day][act]=(a[day][act]);
return dp[day][act];
}
else
{
loop(i,0,3)
{if(act!=i)
{dp[day][act]=max(dp[day][act],a[day][act]+solve(day+1,i));
}
}
return dp[day][act];
}
}
}
int main()
{fast();
cin>>n;
loop(i,0,n)
{loop(j,0,3)
{cin>>a[i][j];
dp[i][j]=-1;
}
}
cout<<max({solve(0,0),solve(0,1),solve(0,2)})<<"\n";
}

Measured memory_bytes: 8960
#!/usr/bin/env python3
def main():
    N, M = map(int, input().split())
    A = sorted([int(x) for x in input().split()], reverse=True)

    level = sum(A) / (4 * M)
    if A[M - 1] < level:
        print('No')
    else:
        print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9104
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll long long
#define INF 10005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 10001;

short int nx[MAX_N], prv[MAX_N], d[MAX_N];

inline int Prim(int node_size, short int** G){
    short int V = node_size, mn = INF, mn_id = 0, v = 0, j, a, b;
    int res = 0;
    iota(nx, nx + V, 1), iota(prv, prv + V, -1);
    fill(d, d + V, INF);
    for(int i = 0; i < V-1; i++){
        for(j = nx[0]; j != V; j = nx[j]){
            a = min(v, j), b = max(v, j);
            d[j] = min(d[j], G[a][b-a-1]);
            if(d[j] < mn) mn = d[j], mn_id = j;
        }
        res += mn, v = mn_id;
        d[mn_id] = mn = INF;
        prv[nx[mn_id]] = prv[mn_id], nx[prv[mn_id]] = nx[mn_id];
    }
    return res;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    short int** G = new short int*[n];
    rep(i,n){
        G[i] = new short int[n-i-1];
        fill(G[i], G[i]+n-i-1, INF);
    }
    rep(i,m){
        int a,b,c;
        cin >> a >> b >> c;
        if(a > b) swap(a,b);
        G[a][b-a-1] = c;
    }
    cout << Prim(n, G) << "\n";
    return 0;
}



Measured memory_bytes: 101080
N, K, Q = map(int, input().split())
p = [0]*N
for _ in range(Q):
    #p = list(map(lambda x : x-1, p))
    A = int(input())
    p[A-1] += 1

for ans in p:
    if ans <= Q-K:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 9716
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    size_t N;
    vector<size_t> a;

    cin >> N;
    a.resize(N);
    for(size_t i = 0; i < N; ++i) { cin >> a[i];}

    size_t all;
    all = a[0];
    for(size_t i = 1; i < N; ++i)
    {
        all ^= a[i];    
    }

    vector<size_t> b(N);
    for(size_t i = 0; i < N; ++i)
    {
        b[i] = all ^ a[i];    
    }

    cout << b[0];
    for(size_t i = 1; i < N; ++i)
    {
        cout << " " << b[i];
    }
    cout << endl;


    //cout << 

    return 0;    
}

Measured memory_bytes: 6352
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

// template version 2.0
using namespace std;
#include <bits/stdc++.h>

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define divceil(a, b) ((a) + (b)-1) / (b)
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    string s;cin>>s;
    ll n = sz(s);

    ll ans = 0;
    rep(i, n){
        // if (s[i]=='P'){
        // }
        // if (s[i]=='D' || s[i]=='?'){
        //     ans++;
        //     if (i>0 && s[i]=='P') ans++;
        // }
        if (s[i]=='?') s[i] = 'D';
    }
    cout << s << endl;

    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 3748
import sys
def input():
    return sys.stdin.readline()[:-1]
s=input()
n=len(s)
lst=[0]*(n+1)
lst[1]=1
if s[0]==s[1]:
    lst[2]=1
else:
    lst[2]=2

for i in range(2,n):
    if s[i-1]==s[i]:
        lst[i+1]=lst[i-2]+2
    else:
        lst[i+1]=lst[i]+1

print(lst[-1])

Measured memory_bytes: 75088
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

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


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

bool solve(){
  int d,e;

  scanf("%d%d",&d,&e);

  if(d == 0) return false;

  double ans = 1e9;
  
  for(int i=0;i<=d;i++){
    ans = min(ans, abs(sqrt(i*i + (d-i)*(d-i))-e));
  }

  printf("%.10lf\n",ans);
  
  return true;
}
  

int main(){

  while(solve());
  
  return 0;
}

Measured memory_bytes: 3144
class RMQ
  def initialize(n, inf = (1 << 30) - 1 + (1 << 30))
    @n = n, @l = 1, @inf = inf
    while @l < n
      @l <<= 1
    end
    @data = Array.new(@l * 2, @inf)
  end

  def update(i, x)
    i += @l
    @data[i] = x
    i >>= 1
    while i > 0
      @data[i] = min(@data[i * 2], @data[i * 2 + 1])
      i >>= 1
    end
    true
  end

  # minimum of [l, r)
  def query(l, r)
    _query(l, r, 1, 0, @l)
  end

  def [](k)
    @data[@l + k]
  end

  private

  def _query(l, r, k, sl, sr)
    return @inf if sr <= l || r <= sl
    return @data[k] if l <= sl && sr <= r
    dl = _query(l, r, k * 2, sl, (sl + sr) / 2)
    dr = _query(l, r, k * 2 + 1, (sl + sr) / 2, sr)
    min(dl, dr)
  end

  def min(a, b)
    return (a > b ? b : a)
  end
end


n, q = gets.split.map(&:to_i)
rmq = RMQ.new(n)
ans = []
q.times do
  com, x, y = gets.split.map(&:to_i)
  if com == 0
    rmq.update(x, y)
  else
    ans << rmq.query(x, y + 1)
  end
end
puts ans


Measured memory_bytes: 9456
#include <iostream>
#include <string>
int main(){
	std::string s;
	std::cin>>s;
	int flag=0;
	for(auto i:s){
		if(i=='C'&&flag!=2) flag=1;
		if(i=='F'&&flag==1) flag=2;
	}
	if(flag==2) std::cout<<"Yes"<<std::endl;
	else std::cout<<"No"<<std::endl;
	return 0;
} 

Measured memory_bytes: 256
import sys
N,A,B,C = map(int,input().split())
S = [input() for _ in range(N)]
s = S[0]
if (s == 'AB' and A+B == 0) or (s=='AC' and A+C==0) or (s=='BC' and B+C==0):
  print('No')
  sys.exit()

if A+B+C == 1:
  answer = ['Yes']
  for s in S:
    if (s == 'AB' and A+B == 0) or (s=='AC' and A+C==0) or (s=='BC' and B+C==0):
      print('No')
      sys.exit()
    if 'A' in s:
      if A == 0:
        A+=1
        answer.append('A')
      else:
        A-=1
    if 'B' in s:
      if B == 0:
        B+=1
        answer.append('B')
      else:
        B-=1
    if 'C' in s:
      if C == 0:
        C+=1
        answer.append('C')
      else:
        C-=1
  print('\n'.join(answer))
  sys.exit()

#A+B+C>=2のとき
answer = ['Yes']
for i in range(len(S)):
  s = S[i]
  lastlen = len(answer)
  if 'A' in s and A == 0:
    A+=1
    answer.append('A')
  elif 'B' in s and B == 0:
    B+=1
    answer.append('B')
  elif 'C' in s and C==0:
    C+=1
    answer.append('C')
  if lastlen < len(answer):
    ac = answer[-1]
    if 'A' in s and ac != 'A':
      A-=1
    elif 'B' in s and ac != 'B':
      B-=1
    elif 'C' in s and ac != 'C':
      C-=1
    continue
  
  if i == len(S)-1:
    if 'A' in s: answer.append('A')
    elif 'B' in s: answer.append('B')
    continue
  
  s1 = S[i+1]
  if s != s1:
    if 'A' in s and 'A' in s1:
      answer.append('A')
      A+=1
    elif 'B' in s and 'B' in s1:
      answer.append('B')
      B+=1
    elif 'C' in s and 'C' in s1:
      answer.append('C')
      C+=1
    
    if 'A' in s and answer[-1] != 'A':
      A-=1
    elif 'B' in s and answer[-1] != 'B':
      B-=1
    elif 'C' in s and answer[-1] != 'C':
      C-=1
    continue
  if s == 'AB':
    A,B=A+1,B-1
    answer.append('A')
  elif s =='AC':
    A,C=A+1,C-1
    answer.append('A')
  else:
    B,C=B+1,C-1
    answer.append('B')
print('\n'.join(answer))
    
    

Measured memory_bytes: 17404
s = int(input())

def f(n):
    if n%2 == 0:
        return int(n/2)
    else:
        return 3*n+1
    
memo = {i: 0 for i in range(1, 999999)}

a = s
i = 1
memo[a] = 1

while(True):
    i += 1
    a = f(a)

    if memo[a]:
        break

    memo[a] = 1
    
        
print(i)

Measured memory_bytes: 92680
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::io::*;
use std::str::FromStr;
 
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed parsing")
}
 
use std::cmp::{min, max};
use std::num;
use std::collections::HashMap;
use std::collections::HashSet;

const MOD : u64 = 1_000_000_000 + 7;

fn main() {
    
    let n = read::<usize>();
    let k = read::<u64>();
    
    let a : Vec<u64> = (0..n).map(|_| read::<u64>() ).collect();

    let mut p = 0;
    let mut q = 0;
    
    for i in 0..n-1 {
        for j in i..n {
            if a[i] > a[j] {
                p += 1;
            }
        }
    }
    
    for i in 0..n {
        for j in 0..n {
            if a[i] > a[j] {
                q += 1;
            }
        }
    }
    
    let ans = ((p * k) % MOD + q * ((k * (k-1) / 2) % MOD) % MOD) % MOD;
    
    
    println!("{}",ans);
}


Measured memory_bytes: 4352
#include <stdio.h>
int main(void){
    int a,b,c;
    scanf("%d %d %d\n",&a,&b,&c);
    if(a<b&&b<c){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    
    return 0;
    
}



Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <cmath>
#include <map>
#include <tuple>
#include <queue>
#include <iomanip>

#define MOD (1000000007)
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) {
    ll maxv = max(a,b);
    ll minv = min(a,b);

    if(maxv % minv == 0) return minv;
    else return gcd(maxv - minv, minv);
}

int main() {
    ll N, K;
    cin >> N >> K;

    cout << min(N%K, K- (N%K)) << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
import math
import sys
N,P=[int(x) for x in input().split()]
if N==1:
    print(P)
    sys.exit(0)
now = P
d = defaultdict(int)
 
for i in range(2,int(math.sqrt(P))+1):
    while  now%i==0:
        now /= i
        d[i]+=1
ans=1
for k in d:
    if d[k] // N > 0:
        ans *= (k ** (d[k] // N))
print(ans)

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>
#include <bitset>
#include <cmath>

#define BP 1000000007

using namespace std;

typedef unsigned long long ull;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned int ui;

typedef vector<ull> vull;
typedef vector<ll> vll;
typedef vector<ui> vui;
typedef vector<long> vl;
typedef vector<int> vi;
typedef vector<vl> vvl;
typedef vector<vi> vvi;

typedef pair<ull, ull> pull;
typedef pair<ll, ll> pll;
typedef pair<ui, ui> pui;
typedef pair<long, long> pl;
typedef pair<int, int> pi;

typedef vector<pair<long, long> > vpl;
typedef vector<pair<int, int> > vpi;

typedef queue<long> ql;
typedef queue<int> qi;

template <class T>
void printv(vector<T> vc) {
    for (auto e: vc) cout << e << " ";
    cout << endl;
}

template <class T>
void printvv(vector<T> vvc) { 
    for (auto vc: vvc) {
        for (auto e: vc) cout << e << " ";
        cout << endl;
    }
}

template <class T>
void printvp(vector<pair<T, T> > vp) {
    for (auto pT: vp) cout << pT.first << " " << pT.second << endl;
}

int main() {
    ll n,m;
    cin >> n >> m;

    if (n == 1 && m == 1) cout << 1 << endl;
    else if (n == 1 || m == 1) {
        cout << max(n,m) - 2 << endl;
    } else {
        cout << (n - 2) * (m - 2) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    next_numbers = [int(x) for x in input().split(" ")]
    count = 0
    while True:
        next_numbers = [x/2 for x in next_numbers if x % 2 == 0]
        if len(next_numbers) != N:
            print(count)
            break
        count += 1


if __name__ == '__main__':
    main()


Measured memory_bytes: 63812
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;

const int maxn=1e6+100;
char s[maxn];

int main()
{
    scanf("%s",s);
    int n=strlen(s);
    int ans=n;
    for (int i=1;i<n;i++)
        if (s[i]!=s[i-1])
        {
           // printf("%d %d\n",i,n-i);
            int tmp=max(i,n-i);
            ans=min(ans,tmp);
        }
    printf("%d\n",ans);
    return 0;
}


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

using namespace std;

using ll = long long;

constexpr ll INF = 1ll << 60;

constexpr ll ARRAY[] = {59049, 46656, 7776, 6561, 1296, 729, 216, 81, 36, 9, 6, 1};

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

    std::vector<ll> dp(N + 1, INF);
    dp[0] = 0;

    for (ll i = 0; i <= N; ++i) {
        for (const auto e : ARRAY) {
            if (i >= e) {
                dp[i] = std::min(dp[i], dp[i - e] + 1);
            }
        }
    }

    cout << dp[N] << endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
typedef  long long     ll ;
typedef  unsigned long long ull;
const double EPS= (1e-9);
using namespace std;
int getBit(int num, int idx) {return ((num >> idx) & 1) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(int num, int idx) {return num ^ (1<<idx);}
void SP(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}

int main()
{
    int k,x;
    cin>>k>>x;
    int str= max(-1000000,x-k+1);
    int en= min(1000000,x+k-1);
    for(int i=str;i<=en;i++)
        cout<<i<<" ";
    cout<<endl;
}






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

namespace AtCoderPractice
{
    class Tsundoku
    {
        static void Main(string[] args)
        {
            string[] x = Console.ReadLine().Split();
            long[] A = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long[] B = Console.ReadLine().Split().Select(long.Parse).ToArray();

            long n = long.Parse(x[0]);
            long m = long.Parse(x[1]);
            long k = long.Parse(x[2]);

            long[] a = new long[n + 1];
            long[] b = new long[m + 1];

            long count = 0;

            for(int i = 1; i < n + 1; i++)
            {
                a[i] = a[i - 1] + A[i - 1];
            }
            for (int i = 1; i < m + 1; i++)
            {
                b[i] = b[i - 1] + B[i - 1];
            }

            long j = m;
            for(int i = 0; i < n + 1; i++)
            {
                if (a[i] > k)
                {
                    break;
                }
                while(b[j]>k-a[i])
                {
                    j--;
                }
                count = Math.Max(count, i + j);
            }
            Console.WriteLine(count);
        }
    }
}


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

using namespace std;
 
int main(){
    int n, i, j = 0;
    cin >> n;
    map<string,int> x;
    for(i = 0; i<n; i++){
        string s;
        cin >> s;
        x[s]++;
        int aux = x[s];
        j = max(j,aux);
    }
    for(auto a = x.begin(); a != x.end(); a++){
        if(a->second == j){
            cout << a->first << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 19232
using System;

public class Hello
{
	public static void Main()
	{
		string[] line = Console.ReadLine().Trim().Split(' ');
		var n = int.Parse(line[0]);
		var x = int.Parse(line[1]);
		line = Console.ReadLine().Trim().Split(' ');
		var L = Array.ConvertAll(line, int.Parse);
		var p = 0;
		var a = 0;
		while (p < n)
		{
			a += L[p];
			if (a > x) { Console.WriteLine(p + 1); goto end; }
			p++;
		}
		Console.WriteLine(n + 1);
	end:;
	}
}

Measured memory_bytes: 13140
let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n

let code_a = int_of_char 'a'
let char_of_code code = char_of_int (code_a + code)

let rec loop res = function
  | 0 -> res |> List.map Char.escaped |> String.concat "" |> print_endline
  | n -> let n = n - 1 in loop ((char_of_code (n mod 26)) :: res) (n / 26)

let () = loop [] n


Measured memory_bytes: 3732
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <queue>
using namespace std;

int Q, cl = 200000, cr = 200000; char c[500009];
bool flag = false;

void verse() {
	flag ^= true;
}

void addition(int a, char b) {
	if (a == 1) {
		if (flag == false) { cl--; c[cl] = b; }
		else { c[cr] = b; cr++; }
	}
	if (a == 2) {
		if (flag == true) { cl--; c[cl] = b; }
		else { c[cr] = b; cr++; }
	}
}

int main() {
	string S; cin >> S;
	for (int i = 0; i < S.size(); i++) { c[cr] = S[i]; cr++; }
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int ty; cin >> ty;
		if (ty == 1) {
			verse();
		}
		else {
			int a; char b; cin >> a >> b;
			addition(a, b);
		}
	}

	if (flag == false) {
		for (int i = cl; i < cr; i++) cout << c[i]; cout << endl;
	}
	else {
		for (int i = cr - 1; i >= cl; i--) cout << c[i]; cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
int main(void){
    
    int n, m, x;
    std::cin >> n >> m >> x;
    
    std::vector<int> c(n);
    std::vector<std::vector<int>> a(n, std::vector<int>(m));
    
    for (int i = 0; i < n; i++) {
        std::cin >> c[i];
        for (int j = 0; j < m; j++) {
            std::cin >> a[i][j];
        }
    }
    int ans = -1;
    for (int bit = 0; bit < (1<<n); bit++) {
        int sum = 0;
        std::vector<int> a_check(m, 0);
        for (int i = 0; i < n; i++) {
            if (bit & (1<<i)) {
                sum += c[i];
                for (int k = 0; k < m; k++) {
                    a_check[k] += a[i][k];
                }
            }
        }
        bool flag = true;
        for (int k = 0; k < m; k++) {
            if (a_check[k] < x) {
                flag = false;
                break;
            }
        }
        if (flag) ans = ans == -1 ? sum : std::min(ans, sum);
    }
    
    std::cout << ans << std::endl;
    
}

Measured memory_bytes: 3592
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
#define max 16777216
bool mark[max]={false};

unsigned int find(string b)
{
	unsigned int result = 0;
	unsigned int tmp = 1;
	unsigned int len = b.length();
	for (int i = 0; i < len; ++i) 
	{
		switch (b[i]) 
		{
		case 'A':
			result += tmp * 1; break;
		case 'C':
			result += tmp * 2; break;
		case 'G':
			result += tmp * 3; break;
		case 'T':
			result += tmp * 4; break;
		}
		tmp *= 4;
	}
	return result;
}
int main()
{
	string a="abc";
	int n;
	cin >> n;
	if (!n)return 0;
	while (n--) 
	{
		cin >> a;
		if (a[0] == 'i')
		{
			cin >> a;
			mark[find(a)] = true;
		}
		else 
		{
			cin >> a;
			if (mark[find(a)])cout << "yes" << endl;
			else cout<<"no"<<endl;
		}
	}
    return 0;
}




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

int isIn(int, int *, int);

int main(void)
{
  int n, q, i, count = 0;
  scanf(" %d", &n);
  int *nArray = (int *) malloc(sizeof(int[n]));
  for (i = 0; i < n; i++)
    scanf(" %d", nArray+i);
  scanf(" %d", &q);
  int *qArray = (int *) malloc(sizeof(int[q]));
  for (i = 0; i < q; i++)
    scanf(" %d", qArray+i);
  for (i = 0; i < q; i++)
    if (isIn(qArray[i], nArray, n))
      count++;
  printf("%d\n", count);
  return 0;
}

int isIn(int number, int *array, int length)
{
  int i;
  for (i = 0; i < length; i++)
    if (array[i] == number)
      return 1;
  return 0;
}



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

int main()
{
    long long int i,j,k,n,ans=0;
    cin>>n;
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++)
        {
            for(k=1;k<=n;k++)
            {
                ans+=__gcd(i,__gcd(j,k));
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  switch(n){
    case 1:
    case 2:
    case 3:
    case 5:
    case 6:
    case 9:
    case 10:
    case 13:
    case 17:
      cout<<"No";
      break;
    default:
      cout<<"Yes";
  }
}

Measured memory_bytes: 256
from collections import defaultdict
d = defaultdict(int)
n, *a = map(int,open(0))
for i in a:
  d[i] += 1
l = list(d.keys())
l.sort()
m = l[-1]
if d[m] == 1:
  i = a.index(m)
  [print(m) for j in range(i)]
  print(l[-2])
  [print(m) for j in range(n-i-1)]
else:
  [print(m) for i in range(n)]

Measured memory_bytes: 20816
#include <bits/stdc++.h>
#define em3 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define X real()
#define Y imag()
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define EPS 1e-7
long long mod = 1e9 + 7;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const double pi = acos(-1);
typedef complex <double> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
///         i , j --> ans
ll n , m ,memo[1005][1005];
char s[1005][1005];
bool InRange(int i , int j)
{
    if(i >= 0 && i < n && j >= 0 && j < m)
        return true;
    return false;
}
ll solve(int i , int  j)
{
    if(i == n - 1 && j == m - 1)
        return 1;
    if(s[i][j] == '#')
        return 0;
    if(memo[i][j] != -1)
        return memo[i][j];
    ll ans = 0;
    if(InRange(i + 1 , j))
       ans = (ans + solve(i + 1 , j)) % mod;
    if(InRange(i , j + 1))
        ans = (ans + solve(i , j + 1)) % mod;
    memo[i][j] = ans % mod;
    return memo[i][j];
}

int main()
{
    em3
    memset(memo , -1 , sizeof memo);
    cin >> n >> m;
    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < m ; j++)
            cin >> s[i][j];

    cout << solve(0 , 0) << endl;

    return 0;
}


Measured memory_bytes: 9216
#include <iostream>

using namespace std;
int main(){
    int n,i,max,sum;
    while (cin >> n){
        int sides[n];
        max = 0;
        sum = 0;
        for(i = 0; i < n; i++){
            cin >> sides[i];
            sum += sides[i];
            if(sides[i] > max) max = sides[i];
        }
        if (2*max < sum) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

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

int main (){
  int64_t X;
  cin >> X;
  int64_t sum = 100;
  int64_t y = 0;
  while(sum < X){
    sum *= 1.01;
    y++;
  }
  cout << y << endl;
}

Measured memory_bytes: 3672
// AtCoder Beginner Contest 174
// A - Air Conditioner

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <random>
#include <vector>
#include <chrono>

using namespace std;
//using namespace std::chrono;


int main()
{
	//steady_clock::time_point start = steady_clock::now();
	int X;

	cin >> X;
	// 制約確認
	if (X < -40 || 40 < X)  {
        cout << "Xは条件を満たしていません!\n";
        return 0;
    }

	if (X >=30) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	//計算時間集計
	/*
	steady_clock::time_point end = steady_clock::now();
    steady_clock::duration d = end - start;
	cout << "計算時間は" << duration_cast<milliseconds>(d).count() << "ミリ秒です。\n";
	*/
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
void *wmem;
template<class T1, class T2> void sortA_L(int N, T1 a[], T2 b[], void *mem = wmem){
  int i;
  pair<T1, T2> *arr=(pair<T1, T2> *) mem;
  for(i=0;i<N;i++){
    arr[i].first = a[i];
    arr[i].second = b[i];
  }
  sort(arr, arr+N);
  for(i=0;i<N;i++){
    a[i] = arr[i].first;
    b[i] = arr[i].second;
  }
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
char memarr[96000000];
int N;
int RX[100];
int RY[100];
int BX[100];
int BY[100];
int main(){
  int i, j, res=0;
  multiset<int> s;
  multiset<int>::iterator it;
  wmem = memarr;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(RX[Lj4PdHRW]);
      rd(RY[Lj4PdHRW]);
    }
  }
  {
    int KL2GvlyY;
    for(KL2GvlyY=0;KL2GvlyY<N;KL2GvlyY++){
      rd(BX[KL2GvlyY]);
      rd(BY[KL2GvlyY]);
    }
  }
  sortA_L(N, RX, RY);
  sortA_L(N, BX, BY);
  j = 0;
  for(i=0;i<N;i++){
    while(j < N && RX[j] < BX[i]){
      s.insert(RY[j++]);
    }
    if(s.size()){
      it = s.lower_bound(BY[i]);
      if(it==s.begin()){
        continue;
      }
      res++;
      s.erase(--it);
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int N, RX[100], RY[100], BX[100], BY[100];
// {
//   int i, j;
//   int res = 0;
//   multiset<int> s;
//   multiset<int>::iterator it;
//   
//   rd(N,(RX,RY)(N),(BX,BY)(N));
//   sortA(N, RX, RY);
//   sortA(N, BX, BY);
// 
//   j = 0;
//   rep(i,N){
//     while(j < N && RX[j] < BX[i]) s.insert(RY[j++]);
//     if(s.size()){
//       it = s.lower_bound(BY[i]);
//       if(it==s.begin()) continue;
//       res++;
//       s.erase(--it);
//     }
//   }
// 
//   wt(res);
// }


Measured memory_bytes: 256