akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

int cost(vector<int> heights)
{
    int n = heights.size();
    if (n < 2) return 0;

    vector<int> cost(n + 2, numeric_limits<int>::max());
    cost[0] = 0;

    for (int i = 0; i < n; ++i)
    {
        cost[i + 1] = min(cost[i+1], cost[i] + abs(heights[i+1] - heights[i]));
        cost[i + 2] = min(cost[i+2], cost[i] + abs(heights[i+2] - heights[i]));
    }

    return cost[n - 1];
}

int main(void)
{
	int n; cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; ++i) cin >> h[i];
    cout << cost(h) << endl;
  	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

vector<int64_t> fac(1e6);

int64_t modpow(int64_t x, int64_t n){
    int64_t res = 1;
    for(int64_t i = n; i > 0; i >>= 1){
        if(i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

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

    fac[0] = 1;
    for(int64_t i = 0; i + 1 < fac.size(); i++){
        fac[i+1] = fac[i] * (i + 1) % MOD;
    }

    int64_t ans = 0;
    if(n == m){
        ans = modpow(fac[n], 2) * 2 % MOD;
    }else if(abs(n - m) == 1){
        ans = fac[n] * fac[m] % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <stdio.h>
#include <vector>
#include <deque>
#include <algorithm>

using namespace std;
typedef long long  ll;

const long long MOD = 1e9+7;

int main(){

    deque<string> s;
    string first_s;
    int n;
    cin >> first_s >> n;

    s.push_front(first_s);

    bool reverse_flag = true;

    int t, f;
    string c;
    for(int i = 0; i < n; i++){
        cin >> t;
        if(t == 1){ reverse_flag = not reverse_flag;}
        else{
            cin >> f >> c;
            if(reverse_flag){
                if(f == 1){s.push_front(c);} //c + s
                else{s.push_back(c);}//s + c
            } else {
                if(f == 1){s.push_back(c);}
                else{s.push_front(c);}
            }
        }
    }

    string ans;
    for(int i = 0; i<s.size(); i++){
        ans += s[i];
    }

    if(not reverse_flag){reverse(ans.begin(), ans.end());}

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 12128
# -*- coding: utf-8 -*-
"""
Created on Sun Dec  2 21:50:38 2018
ABC114D
@author: maezawa
"""

nmax = int(100)
is_prime = [True]*(nmax+1)

is_prime[0] = False
is_prime[1] = False

for i in range(2, nmax//2):
    if is_prime[i] == True:
        for j in range(2*i,nmax+1,i):
            is_prime[j] = False

prime_numbers = [i for i in range(nmax+1) if is_prime[i]]

n = int(input())

prime_exps = [0]*len(prime_numbers)
for i in range(2,n+1):
    for k, p in enumerate(prime_numbers):
        if i<p:
            break
        while i>=p:
            if i%p == 0:
                i = i // p
                prime_exps[k] += 1
            else:
                break

#print(prime_numbers)
#print(prime_exps)
ans = 0

cnt74 = 0
cnt24 = 0
cnt14 = 0
cnt4 = 0
cnt2 = 0

# searching >=74
for i in prime_exps:
    if i>=74:
        cnt74 += 1
    if i>=24:
        cnt24 += 1
    if i>=14:
        cnt14 += 1
    if i>=4:
        cnt4 += 1
    if i>=2:
        cnt2 += 1

cnt = cnt74
if cnt24 > 0 and cnt2 > 1:
    cnt += cnt24*(cnt2-1)
if cnt14 > 0 and cnt4 > 1:
    cnt += cnt14*(cnt4-1)
if cnt4 > 1 and cnt2 > 2:
    cnt += cnt4*(cnt4-1)//2*(cnt2-2)
    
print(cnt)


Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstdlib>
#include<cstring>
#include<utility>
#ifdef XS
	#include<De>
#endif
using namespace std;
#define MS(m) memset(m,0,sizeof(m))

typedef unsigned U;
typedef pair<int,int > P;
typedef long long ll;
void inp();
int main(){
#ifdef XS
	//freopen(".in","r",stdin);
#endif
	try{
		//while(1)
		//int n;scanf("%d",&n);for(int i=1;i<=n;i++)
		inp();
	}
	catch(... ){
#ifdef XS
		printf("%s","exception");
#endif
	}//for compatibility with cygwin c++ runtime
	return 0;
}
const int N = 1e5 +100;
P A[N];
P B[N];
int p[N];
typedef pair<int, pair<int,int>> pp ;
priority_queue<pp,vector<pp>, greater<pp> > pq;
int find(int a){
	if(p[a]<0)return a;
	return p[a] = find(p[a]);
}
void uni(int a,int b){
	if(p[a]>p[b]) swap(a,b);
	p[a]+=p[b];
	p[b] = a;
}
void inp(){
	int n;
	scanf("%d",&n);
	memset(p, -1 , sizeof(p));
	for(int i = 0;i<n;i++){
		scanf("%d%d", &A[i].first,&B[i].first);
		A[i].second = B[i].second = i+1;
	}
	sort(A,A+n);
	sort(B,B+n);
	for(int i = 1;i<n;i++){
		pq.push(pp(abs(A[i].first - A[i-1].first),P(A[i].second,A[i-1].second)));
		pq.push(pp(abs(B[i].first - B[i-1].first),P(B[i].second,B[i-1].second)));
	}
	ll cost = 0;
	while(!pq.empty()){
		pp p = pq.top();pq.pop();
		int fa = find(p.second.first);
		int fb = find(p.second.second);
		if(fa==fb)continue;
		cost += p.first;
		uni(fa,fb);
	}
	printf("%lld\n", cost);
}
//D.cc by xsthunder at Wed Jul 19 09:27:12 2017


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



void Main(){

  int a,b;
  cin>>a>>b;
  int num;
  if(b==100) num=1000*a+b;
  else if(b>=10) num=100*a+b;
  else num=10*a+b;

  rep(i,1000){
    if(i*i==num){
      cout<< "Yes"<<"\n";
      return;
    }
  }

  cout<< "No"<<"\n";
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct node{
	int a,b;
}x[110],y[110];
long long dist(int x1,int y1,int x2,int y2){
	return abs(x1-x2)+abs(y1-y2);
}
int main(){
	int n,m,i,j;
	cin>>n>>m;
	for(i=1;i<=n;i++){
		cin>>x[i].a>>x[i].b;
	} 
	for(j=1;j<=m;j++){
		cin>>y[j].a>>y[j].b;
	}
	for(i=1;i<=n;i++){
		int dism=dist(x[i].a,x[i].b,y[1].a,y[1].b);
		int id=1;
		for(int j=2;j<=m;j++){
			int disc=dist(x[i].a,x[i].b,y[j].a,y[j].b);
			if(disc<dism){
				dism=disc;
				id=j;
			}
		}
		cout<<id<<endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

vector<vector<int> > getCycle(vector<int> v) {
    v.insert(v.begin(), -1e9);

    int n = v.size();
    vector<int> sorted = v, used(n, 0);
    vector<pair<int, int> > vp(n);
    vector<vector<int> > res;
    map<int, int> mp;

    sort(sorted.begin(), sorted.end());
    for (int i = 1; i < n; i++)
        mp[sorted[i]] = i;
    for (int i = 1; i < n; i++) {
        vp[i].first = v[i];
        vp[i].second = mp[v[i]];
    }

    for (int i = 1; i < n; i++) {
        if (used[i]) continue;
        used[i] = 1;

        vector<int> sub(1, vp[i].first);
        int j = vp[i].second;
        if (j != i) {
            while (!used[j]) {
                used[j] = 1;
                sub.push_back(vp[j].first);
                j = vp[j].second;
            }
        }
        res.push_back(sub);
    }

    return res;
}

int main(void) {
    int n, min_of_all = 1e9, min_of_sub;
    cin >> n;
    vector<int> w(n);
    for (int i = 0; i < n; i++) {
        cin >> w[i];
        min_of_all = min(min_of_all, w[i]);
    }
    
    int sz, sum;
    ll ans = 0;
    vector<vector<int> > v = getCycle(w);
    for (int i = 0; i < v.size(); i++) {
        sz = v[i].size();
        if (sz == 1) continue;
        min_of_sub = 1e9;
        sum = 0;
        for (int j = 0; j < sz; j++) {
            min_of_sub = min(min_of_sub, v[i][j]);
            sum += v[i][j];
        }
        ans += sum + min((sz - 2) * min_of_sub, (sz + 1) * min_of_all + min_of_sub);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3248
#include<stdio.h>
#include<stdlib.h>
#define N 1000000
#define A_IN 1000000000
int cnt=0;
int n;
int*G;
int A[N];
int c=0;
void insertionSort(int A[], int n, int g){
  int i,v,j;
  for(i=g;i<n;i++){
    v=A[i];
    j=i-g;
    while(j>=0 && A[j]>v){
      A[j+g]=A[j];
      j-=g;
      cnt++;
    }
    A[j+g]=v;
  }
}

void shellSort(int A[],int n){
  int i=0,q;
  cnt=0;
  G=(int *)malloc(n * sizeof(int));
 
  for(q=1;;){
    if(q>n) break;
    G[i]=q;
    i++;
    q=3*q+1;
  }
  c=i;
  for(i=c-1;i>=0;i--){
    insertionSort(A,n,G[i]);
  }
}


int main(){
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  
  shellSort(A,n);

  printf("%d\n",c);

  for(i=c-1;i>=0;i--){
    printf("%d",G[i]);
    if(i) printf(" ");
  }
  printf("\n");
  printf("%d\n",cnt);
  for(i=0;i<n;i++)printf("%d\n",A[i]);

  free(G);
  
  return 0;
}



Measured memory_bytes: 5636
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String answer="";
		while(sc.hasNext()){
			String str=sc.next();
			if(str.charAt(str.length()-1)==','||str.charAt(str.length()-1)=='.'){
				str=str.substring(0,str.length()-1);
			}
			if(str.length()>=3&&str.length()<=6){
				answer+=str+" ";
			}
		}
		answer=answer.substring(0,answer.length()-1);
		System.out.println(answer);
	}
}

Measured memory_bytes: 17216
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#define llint long long
#define mod 1000000007
#define inf 1e9

using namespace std;
typedef pair<llint, llint> P;

struct SegTree{
	int size;
	vector<int> seg;

	SegTree(){}
	SegTree(int size){
		this->size = size;
		seg.resize(1<<(size+1));
	}

	void init()
	{
		for(int i = 0; i < (1<<(size+1)); i++) seg[i] = inf;
	}

	void update(int i, int val)
	{
		i += (1 << size);
		seg[i] = val;
		while(i > 1){
			i /= 2;
			seg[i] = min(seg[i*2], seg[i*2+1]);
		}
	}

	int query(int a, int b, int k, int l, int r)
	{
		if(b < l || r < a) return inf;
		if(a <= l && r <= b) return seg[k];
		int lval = query(a, b, k*2, l, (l+r)/2);
		int rval = query(a, b, k*2+1, (l+r)/2+1, r);
		return min(lval, rval);
	}
	int query(int a, int b)
	{
		return query(a, b, 1, 0, (1<<size)-1);
	}
};

int kk, nn;
int Rank[400005];
int tmp[400005];

bool compare_sa(int i, int j)
{
	if(Rank[i] != Rank[j]) return Rank[i] < Rank[j];
	int ri, rj;
	if(i+kk <= nn) ri = Rank[i+kk]; else ri = -1;
	if(j+kk <= nn) rj = Rank[j+kk]; else rj = -1;
	return ri < rj;
}

void makeSA(string s, int sa[]){
	nn = s.size();
	for(int i = 0; i <= nn; i++) sa[i] = i;
	for(int i = 0; i < nn; i++) Rank[i] = s[i];
	s += " ";
	s[nn] = -1;

	for(kk = 1; kk <= nn; kk*=2){
		sort(sa, sa+nn+1, compare_sa);
		int val = 0;
		tmp[sa[0]] = 0;
		for(int i = 1; i <= nn; i++){
			if(compare_sa(sa[i-1], sa[i])) val++;
			tmp[sa[i]] = val;
		}
		for(int i = 0; i <= nn; i++) Rank[i] = tmp[i];
	}
}

void makeLCP(string s, int sa[], int lcp[]){
	nn = s.size();
	for(int i = 0; i <= nn; i++) Rank[sa[i]] = i;

	int h = 0;
	lcp[0] = 0;
	for(int i = 0; i < nn; i++){
		int j = sa[Rank[i]-1];
		while(i+h < nn && j+h < nn && s[i+h] == s[j+h]) h++;
		lcp[Rank[i]-1] = h;
		if(h > 0) h--;
	}
}

string s, t;
int k;
int sa[400005], lcp[400005], sa_inv[400005];
int pred[400005], succ[400005];
int dp[400005];
SegTree seg(19);

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

  cin >> s >> t;
  cin >> k;

  string S = s + "#" + t;
  makeSA(S, sa);
  makeLCP(S, sa, lcp);
  for(int i = 0; i <= S.size(); i++) sa_inv[sa[i]] = i;

  /*for(int i = 0; i <= S.size(); i++){
    cout << i << " " << S.substr(sa[i]) << " " << lcp[i] << endl;
  }*/

  int x = -1;
  for(int i = 0; i <= S.size(); i++){
    pred[i] = x;
    if(sa[i] > s.size()) x = i;
  }
  x = S.size()+1;
  for(int i = S.size(); i >= 0; i--){
    succ[i] = x;
    if(sa[i] > s.size()) x = i;
  }

  seg.init();
  for(int i = 0; i <= S.size(); i++) seg.update(i, lcp[i]);

  int n = s.size();
  s = "#" + s; int sum = 0;
  dp[0] = 1, dp[1] = -1;
  for(int i = 0; i <= n; i++){
    sum += dp[i];
    if(sum == 0) continue;
    int mx = 0, pos = sa_inv[i];
    if(pred[pos] >= 0){
      mx = max(mx, seg.query(pred[pos], pos-1));
    }
    if(succ[pos] <= S.size()){
      mx = max(mx, seg.query(pos, succ[pos]-1));
    }
    //cout << i << " " << pos << " " << pred[pos] << " " << succ[pos] << " " << mx << endl;
    if(mx < k) continue;
    dp[i+k]++, dp[i+mx+1]--;
  }
  if(sum) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}



Measured memory_bytes: 19140
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	int n;
	cin >> n;
	ll L[n + 1];
	L[0] = 2;
	L[1] = 1;
	for(int i = 2; i <= n; i++) L[i] = L[i - 1] + L[i - 2];
	cout << L[n];
}

Measured memory_bytes: 256
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')

N = I()
S = input()
K = I()

c1 = S[K - 1]
for c in S:
    print(c if c == c1 else '*', end='')
print()

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

int main(int argc,char* argv[])
{
    int n,i,bright;
    cin >> n;
    vector<int> btn(n,0);

    for(i=0;i<n;i++) {
        cin >> btn.at(i);
    }
    bright=0;
    for(i=0;i<n;i++) {
        bright = btn.at(bright)-1;
        if(bright==1) {
            cout << i+1;
            return 0;
        }
    }

    cout << -1;

    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

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

   if (a % 2 == 0 || b % 2 == 0)
      cout << "No" << endl;
   else
      cout << "Yes" << endl;

   return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

int main()
{
    int Q;
    cin >> Q;
    rep(i, Q){
        unsigned int a;
        cin >> hex >> a;
        if(a >> 31){
            cout << '-';
            a ^= 1 << 31;
        }
        cout << setprecision(15) << a / double(1 << 7);
        if((a & ((1<<7)-1)) == 0) cout << ".0";
        cout << endl;
    }
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 305;
const int P = 998244353;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
char s[MAXN];
int n, l, m, a[MAXN];
int dp[MAXN][MAXN][MAXN];
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
int main() {
	scanf("\n%s%d", s + 1, &m);
	int last = 0; l = strlen(s + 1), chkmin(m, l);
	for (int i = 1; i <= l + 1; i++)
		if (s[i] != '1') {
			a[++n] = i - last - 1;
			last = i;
		}
	dp[0][0][0] = 1;
	for (int i = 1; i <= n; i++) {
		static int b[MAXN][MAXN], c[MAXN][MAXN];
		memset(b, 0, sizeof(b));
		memset(c, 0, sizeof(c));
		for (int j = 0; j <= l; j++)
		for (int k = 0; k <= m; k++) {
			int tmp = dp[i - 1][j][k];
			if (tmp == 0) continue;
			update(b[j - min(a[i], j)][k], tmp);
			update(b[j + 1][k], P - tmp);
			update(c[j + 1][k + 1], tmp);
		}
		for (int j = 0; j <= l; j++)
		for (int k = 0; k <= m; k++) {
			if (j != 0) update(b[j][k], b[j - 1][k]);
			update(dp[i][j][k], b[j][k]);
		}
		for (int j = 0; j <= l; j++)
		for (int k = 0; k <= m; k++) {
			if (j != 0 && k != 0) update(c[j][k], c[j - 1][k - 1]);
			update(dp[i][j][k], c[j][k]);
		}
	}
	int ans = 0;
	for (int i = 0; i <= m; i++)
		update(ans, dp[n][0][i]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 112328
#include <iostream>
#include <string.h>
using namespace std;
bool vis[55];
int n,a[55],b[55];
long long ans=(1LL<<51)-2;
bool dfs(int a,int b)
{
	if (a==b)
	return 1;
	if (vis[a])
	return 0;
	vis[a]=1;
	bool ret=0;
	for (int i=1;i<=a;i++)
	{
		if (ans&(1LL<<i))
		ret|=dfs(a%i,b);
	}
	return ret;
}
bool check()
{
	for (int i=0;i<n;i++)
	{
		memset(vis,0,sizeof(vis));
		if (!dfs(a[i],b[i]))
		return 0;
	}
	return 1;
}
int main()
{
	scanf("%d",&n);
	for (int i=0;i<n;i++)
	scanf("%d",&a[i]);
	for (int i=0;i<n;i++)
	scanf("%d",&b[i]);
	if (!check())
	{
		printf("-1");
		return 0;
	}
	for (int i=50;i>0;i--)
	{
		ans^=(1LL<<i);
		if (!check())
		ans^=(1LL<<i);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 256
from sys import stdin
def input():
    return stdin.readline()

def main():
    N, S = map(int,input().split())
    A = list(map(int,input().split()))
    mod = 998244353
    dp = [[0 for j in range(S + 1)] for i in range(N + 1)]
    dp[0][0]=1
    for i in range(1,N+1) : 
        for j in range(S + 1) : 
            if(j==0):
                dp[i][j]+=pow(2,i,mod)
            else:
                dp[i][j]+=2*dp[i-1][j]
                dp[i][j]%=mod
                if(j-A[i-1]>=0):
                    dp[i][j]+=dp[i-1][j-A[i-1]]
            dp[i][j]%=mod
    print(dp[N][S]%mod)
if __name__=="__main__":
    main()

Measured memory_bytes: 147176
#include <stdio.h>
int main(void){
   int a[3][3];
   for(int i = 0; i < 3; i++){
       for(int j = 0; j < 3; j++){
           scanf("%d", &a[i][j]);
       }
   } 

   int n;
   scanf("%d", &n);
   int b[n];
   for(int i = 0; i < n; i++){
       scanf("%d", &b[i]);
       for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(a[j][k] == b[i]){
                    a[j][k] = 0;
                }
            }
        }
       
   }

    if(a[0][0] == 0 && a[0][1] == 0 && a[0][2] == 0){
        printf("Yes");
        return 0;
    }else if(a[1][0] == 0 && a[1][1] == 0 && a[1][2] == 0){
        printf("Yes");
        return 0;
    }if(a[2][0] == 0 && a[2][1] == 0 && a[2][2] == 0){
        printf("Yes");
        return 0;
    }if(a[0][0] == 0 && a[1][0] == 0 && a[2][0] == 0){
        printf("Yes");
        return 0;
    }if(a[0][1] == 0 && a[1][1] == 0 && a[2][1] == 0){
        printf("Yes");
        return 0;
    }if(a[0][2] == 0 && a[1][2] == 0 && a[2][2] == 0){
        printf("Yes");
        return 0;
    }if(a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0){
        printf("Yes");
        return 0;
    }if(a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0){
        printf("Yes");
        return 0;
    }

printf("No");
}

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

int main(){
    string j("JPY"), b("BTC"), s;
    long N;
    cin >> N;
    long double rat = 380000, ans = 0, c;
    for(int i = 0; i < N; ++i){
        cin >> c >> s;
        ans += c * (s == j ? 1 : rat);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

using namespace std;

typedef long long ll;

map<int, int> cnt;

int main() {
	int n;
	cin >> n;
	
	vector<int> A(n);
	for (int i = 0; i < n; i++) cin >> A[i];
	
	for (int i = 0; i < n; i++) {
		cnt[A[i] - 1]++;
		cnt[A[i]]++;
		cnt[A[i] + 1]++;
	}
	
	int ans = 0;
	for (auto c : cnt) ans = max(ans, c.second);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll k, x;
	cin >> k >> x;
	if (500 * k >= x) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


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

int main(){
    string a,b,ans;
    cin >> a >> b;
    
    sort(a.begin(),a.end());
    sort(b.begin(),b.end(),greater<int>());

    if(a<b){
        ans = "Yes";
    }else{
        ans = "No";
    }
    cout << ans << endl;
    
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
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;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

int main() {
  //
  int n;
  cin >> n;
  vector<pii> data(n);
  rep(i, n) {
    int x;
    cin >> x;
    data[i] = make_pair(x, i);
  }
  sort(ALL(data));
  vi b(n, -1);
  rep(i, n) {
    pii d = data[i];
    int idx = d.second;
    if (i < n / 2) {
      b[idx] = data[n / 2].first;
    } else {
      b[idx] = data[n / 2 - 1].first;
    }
  }
  rep(i, n) { cout << b[i] << endl; }
  return 0;
}


Measured memory_bytes: 4480
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define ll long long
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define cls(name,x) memset(name,x,sizeof(name))
using namespace std;
const int inf=1<<28;
const int maxn=210;
const int maxm=20010;
const int mod=1e9+7;
const double pi=acos(-1.0);
int n;
int main()
{
    //freopen("in.txt","r",stdin);
    scanf("%d",&n);
    char s[maxn];
    scanf("%s",s);
    int now=0;
    int c1=0,c2=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='(')
            now++;
        else if(s[i]==')')
            now--;
        if(now<0) {c1++;now++;}
    }
    while(now>0) {c2++;now--;}
    for(int i=0;i<c1;i++)
        printf("(");
    printf("%s",s);
    for(int i=0;i<c2;i++)
        printf(")");
    printf("\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define ss second
#define ff first
#define INF 300000000000001
#define ll_max 9000000000000000001
#define mod 998244353
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;
const ll N = 1000001;
const ll M = 1;

struct point {
    ll x, y;
};

ll fast_exp(ll x, ll n)
{
    if(n == 0) return 1;
    else if(n & 1)
        return fast_exp(x, n - 1) * x % mod;
    else
    {
        ll tmp = fast_exp(x, n >> 1);
        return tmp * tmp % mod;
    }
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll n, m = 0, ans = 0, x, y, k, v;
        cin >> n >> k;
        ans = (n * (n - 1) / 2) + (k * (k - 1) >> 1);
        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
import numpy as np
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix

int1 = lambda x: int(x) - 1

N, M = map(int, input().split())
P = tuple(map(int1, input().split()))

edge = np.array([tuple(map(int1, input().split())) for _ in range(M)]).T
matr = csr_matrix((np.ones(M, dtype="int64"), edge), (N, N))

C, labels = connected_components(matr)
lst = [[set(), set()] for _ in range(C)]
for i, x in enumerate(labels):
    lst[x][0].add(i)
    lst[x][1].add(P[i])

for c in range(C):
    lst[c] = lst[c][0] & lst[c][1]
print(sum(len(s) for s in lst))

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

#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int maxm = 1000000000 + 7;

using namespace std;

int in[100007];
long long arr[100007];

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, k;
	cin >> n >> k;
	loop(i, n) {
		cin >> in[i];
	}
	arr[0] = 0;
	arr[1] = abs(in[1] - in[0]);
	for (int j = 2; j < n; j++) {
		arr[j] = numeric_limits<int>::max();
		for (int l = 1; l <= k; l++) {
			if (j - l < 0)
				break;
			arr[j] = min(arr[j - l] + abs(in[j] - in[j - l]), arr[j]);
		}
	}
	cout << arr[n - 1];
}

Measured memory_bytes: 4752
k = gets.to_i
a,b = gets.split.map &:to_i
i = 0

loop do
    k_mul = k * i

    if a <= k_mul && k_mul <= b
        puts "OK"
        break
    elsif b < k_mul
        puts "NG"
        break
    end
    i = i + 1
end

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

template <typename T> inline void print(T val) { cout << val << '\n'; }

template <typename Iterator> inline void print(Iterator begin, Iterator end) {
  for (auto it = begin; it != end; it = next(it)) {
    cout << *it << ' ';
  }
  cout << '\n';
}

template <class T> inline T square(T x) {
  T result;
  result = x * x;
  return result;
};

#ifdef LOCAL
#define DBG_MACRO_NO_WARNING
#include <dbg.h>

#else
#define dbg(...) 0
#endif

const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);

  auto start = chrono::steady_clock::now();
#endif

  vector<ll> x(5);

  for(auto &i:x){cin >> i;}

  ll ans = 10;

  for(auto i= 0;i < 5;++i){
    if(x[i] == 0){
      ans = i+1;
    }
  }

  print(ans);


#ifdef LOCAL
  auto end = chrono::steady_clock::now();
  auto diff = end - start;

  cout << "Duration: " << chrono::duration<double, milli>(diff).count() << " ms"
       << '\n';
#endif

  return 0;
}


Measured memory_bytes: 3556
#include <stdio.h>

int main(void) {
	int a,b,c,n;
	n=0;
	scanf("%d%d%d",&a,&b,&c);
	for(a;a<=b;a++){
		if(c%a == 0) n++;
	}
	printf("%d\n",n);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long ans = 0;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  for (int i = 1; i < n; i++)
  {
    if (a[i] < a[i-1])
    {
      ans += a[i-1]-a[i];
      a[i] = a[i-1];
    }
    
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    int H,W,N,sr,sc;
    string S,T;
    cin >> H >> W >> N;
    cin >> sr >> sc;
    cin >> S;
    cin >> T;
    
    vector<char> ss = {'L','R','D','U'};
    vector<char> tt = {'R','L','U','D'};
    vector<int> a = {sc, sc, sr, sr};
    vector<int> bb = {W, W, H, H};
    vector<int> cc = {1, -1, -1, 1};
    
    for (int j = 0; j < 4; j++) {
         for (int i = 0; i < N; i++) {
             if (S[i] == ss[j]) a[j]-=cc[j];
             if(a[j] < 1 || a[j] > bb[j]){
                 cout << "NO" << endl;
                 return 0;
                 
             }
             if(T[i] == tt[j] && a[j]+cc[j] >= 1 && a[j]+cc[j] <= bb[j]) a[j] += cc[j];
             //cout << a[j] << " ";
         }
        //cout << endl;
    }
    
   
    
    cout << "YES" << endl;
    
    return 0;
}



Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL 
#include "/home/gokul/Codes/lib/prettyprint.hpp"
#else
#define debug(...) 2
#endif

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int k, q;
  cin >> k >> q;

  vector<int> d(k);
  for (int i = 0; i < k; ++i) 
    cin >> d[i];

  while (q--) {
    int n, x, m;
    cin >> n >> x >> m;

    x %= m;
    long long last = x, sum = 0;
    int ans = 0, z = 0;
    vector<int> nw(k);
    for (int i = 0; i < k; ++i) {
      nw[i] = d[i] % m;
      if (i < (n-1)%k) last += nw[i];
      if (i < (n-1)%k && nw[i] == 0)  ans++;
      if (nw[i] == 0) z++;
      sum += nw[i];
    }

    ans += z * ((n-1) / k);
    last += sum * ((n-1) / k);
    debug(last);
    ans += last / m;
    ans = n - 1 - ans;

    cout << ans << '\n';
  }
}






Measured memory_bytes: 384
s, w = [0] * 2

def format_input(filename = None):
	global s, w
	if filename == None:
		s, w = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		s = rng(1, 10**2)
		w = rng(1, 10**2)
		print(s, w)

def get_answer():
	answer = 'unsafe'
	if s > w:
		answer = 'safe'
	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)


Measured memory_bytes: 9196
//Author: Prakhar Asaiya
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(ll i=a;i<b;++i)
#define REPN(i,a,b) for(ll i=a;i<=b;++i)
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define ll long long
const int M=1e9+7;
const int INF=1e9+5;

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

  int n;
  cin>>n;
  set <string> S;
  string s;
  REP(i,0,n)
  {
  	cin>>s;
  	S.insert(s);
  }
  cout<<S.size()<<'\n';
   return 0;
}


Measured memory_bytes: 19260
n,m=map(int,input().split())
dp=[0]*(n+1)
f=[]
dp[0]=1

f=[True]*(n+1)
for _ in range(m):
    f[int(input())]=False

for i in range(1,n+1):
    if f[i]==False:
        continue
    else:
        if dp[i-1] != 0:
            dp[i] += dp[i-1]
        if i > 1:
            if dp[i-2] != 0:
                dp[i] += dp[i-2]

print(dp[-1]%1000000007)

Measured memory_bytes: 463476
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 2;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

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

  int n, m;
  cin >> n >> m;
  int cnt = 0;
  ll sum = 0;
  ll a[1010];
  rep(i, n)
  {
    cin >> a[i];
    sum += a[i];
  }
  rep(i, n)
  {
    if (4 * m * a[i] >= sum)
      cnt++;
  }
  Yes(cnt >= m);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    long long int s = 0;
    long long int c = 0;
    long long int scc = 0;
    scanf("%lld %lld", &s, &c);
    if(s * 2 > c) {
        scc = c/2;
    } else {
        scc = s;
        c = c - s * 2;
        scc += c/4;
    }
    
    printf("%lld\n", scc);
    return 0;
}


Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	fmt.Println(resolve(parseProblem(os.Stdin)))
}

func parseProblem(r io.Reader) int {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	a := scanString(sc)
	b := scanString(sc)
	aI, _ := strconv.Atoi(a)
	bI, _ := strconv.Atoi(strings.Replace(b, ".", "", 1))
	return aI * bI / 100
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


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

using ll=long long;

int main(){
    ll a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    cout<<min({a*x+b*y,2*c*x+b*max(0LL,(y-x)),2*c*y+a*max(0LL,x-y)})<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define each(it,o) for(auto it= (o).begin(); it != (o).end(); ++ it)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define inrep int t;cin>>t; while(t--)
using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii > vpii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll > vpll; 
typedef vector<string> vs;
typedef long double ld;
const ll MOD = 1e9+7;
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {

    for ( unsigned   i=0; i<v.size(); i++ )
        in>>v[i];
    return in;
}
ll k[101][100001];
ll val(ll n,ll w,ll we[],ll va[])
{
	if(k[n][w]!=-1)
	{
		return k[n][w];
	}
	if(n==0||w==0)
	{
		k[n][w]=0;
		return 0;
	}
	if(we[n]>w)
	{
		k[n][w]=val(n-1,w,we,va);
		return val(n-1,w,we,va);
	}
	k[n][w] = max(va[n]+val(n-1,w-we[n],we,va),val(n-1,w,we,va));
	return max(va[n]+val(n-1,w-we[n],we,va),val(n-1,w,we,va));
}
int main()
{
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,w;
    cin>>n>>w;
    ll wa[n+1];ll va[n+1];
    memset(k,-1,sizeof(k));
    for(ll i=1;i<=n;i++)
    {
    	cin>>wa[i]>>va[i];
    }
    ll s = val(n,w,wa,va);
    cout<<s;
    // #ifndef ONLINE_JUDGE
    //     cout<<"\nTime Elapsed : "<< 1.0*clock() / CLOCKS_PER_SEC << " s\n";
    // #endif
    
    return 0;
}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
long long power(long long x, long long y) 
{ 
    long long num= 1; 
    while (y > 0) {       
        if (y%2==1) 
            num= (num * x)%mod;
          y=y/2;
        x = (x * x)%mod;
          } 
    num=num%mod;
    return num;
}
int main() {
  
  long long n,sum=0;
  cin>>n;
  long long a[n],i,count=0,ze=0,on=0,j;
  for(i=0;i<n;i++)
  {
      cin>>a[i];
  }
    for (i=0;i<62;i++)  
    { 
        ze=0;
        on=0; count=0;
        for (j=0;j<n;j++) 
        { 
            if (a[j] % 2 == 0) 
            ze++; 
            else
            on++; 
            a[j]/=2; 
        } 
        count=(((on%mod)*(ze%mod))%mod);  
        count=((count%mod)*(power(2,i)%mod)%mod)%mod;
        sum=(sum%mod+count%mod)%mod;  
    } 
 cout<<sum; 
}

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

int main() {
  string S; cin >> S;
  int k = 15 - S.length();
  int cnt = 0;
  for(int i = 0; i < S.size(); ++i) {
    if(S[i] == 'o') cnt++;
  }
  if(k+cnt>=8) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define MOD 1000000007
#define fi first
#define se second
#define ld double

using namespace std;

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

ll a, b, c, x, y;

int main(){
    // ifstream cin("date.in");
    // ofstream cout("date.out");

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> a >> b >> c >> x >> y;

    int mn = min(x, y);
    ll cost = min(a * mn + b * mn, c * mn * 2);

    x -= mn;
    y -= mn;

    cost += min(a * x + b * y, 2 * c * max(x, y));
    cout << cost;

	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair
//cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;
int gcd(int a, int b) 
{ 
	if(a>b)
	{
		swap(a,b);
	}
	if (a == 0) 
		return b; 
	return gcd(b % a, a); 
} 
int invertBits(int num) 
{  
    int x = log2(num) + 1; 
    for (int i = 0; i < x; i++)  
       num = (num ^ (1 << i));  
   
    return num; 
} 
///////////////////////////////////////////////////////////////////////////////////////////////////////////
string add(string f,string s)
{
    reverse(f.begin(),f.end());
    reverse(s.begin(),s.end());
    
    int i=0,j=0;
    string t="";
    int carry=0;
    while(i<f.size() && j<s.size())
    {
        int k=(f[i]-'0')+(s[j]-'0')+carry;
        carry=k/10;
        int sum=k%10;
        t+=(sum+'0');
        i++;
        j++;
    }
    while(i<f.size())
    {
        int k=(f[i]-'0')+carry;
        carry=k/10;
        int sum=k%10;
        t+=(sum+'0');
        i++;
    }
    
    while(j<s.size())
    {
        int k=(s[j]-'0')+carry;
        carry=k/10;
        int sum=k%10;
        t+=(sum+'0');
        j++;
    }
    
    if(carry)
    {
        t+=(carry+'0');
    }
    reverse(t.begin(),t.end());
    return t;
}
int mulmod(int a, int b, int mod) 
{ 
    int res = 0; // Initialize result 
    a = a % mod; 
    while (b > 0) 
    { 
        // If b is odd, add 'a' to result 
        if (b % 2 == 1) 
            res = (res + a) % mod; 
  
        // Multiply 'a' with 2 
        a = (a * 2) % mod; 
  
        // Divide b by 2 
        b /= 2; 
    } 
  
    // Return result 
    return res % mod; 
} 
int main()
{
	int n;
	cin>>n;
	int a[n+1],i;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	int b[n+1]={0};
	int size=0;
	for(i=n;i>=1;i--)
	{
		int k=2;
		int sum=0;
		while(k*i<=n)
		{
			sum+=b[k*i];
			k++;
		}
		if(a[i]%2==0)
		{
			if(sum%2==0)
			{
				b[i]=0;
			}
			else
			{
				b[i]=1;
				size++;
			}
		}
		else
		{
			if(sum%2==0)
			{
				b[i]=1;
				size++;
			}
			else
			{
				b[i]=0;
			}
		}
	}
	cout<<size<<endl;
	for(i=1;i<=n;i++)
	{
		if(b[i]==1)
		{
			cout<<i<<" "; 
		}
	}
	return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  ll n, k;
  cin >> n >> k;
  ll diff = n - k;
  if (n > k) diff = n % k;
  if (diff < 0) diff *= -1;
  ll tmp;
  while (true) {
    tmp = diff;
    diff -= k;
    if (diff < 0) diff *= -1;
    if (tmp < diff) break;
  }
  cout << tmp << endl;
}

Measured memory_bytes: 256
#!python3.4
# -*- coding: utf-8 -*-
# abc157/abc157_c
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, M = i2nn()
    res = ['0'] * max(N, M)
    s_max = 0
    s_min = M
    s_dict = {}
    for i in range(M):
        s, c = i2nn()
        s -= 1
        # 矛盾する条件
        if (s in s_dict and s_dict[s] != c):
            print(-1)
            return
        # 1桁以外で先頭が0
        if (s == 0 and c == 0 and N > 1):
            print(-1)
            return
        s_dict[s] = c
        s_max = max(s, s_max)
        s_min = min(s, s_min)
        res[s] = str(c)
    # 1桁以外で先頭が0のままなら1にする
    if (N > 1 and res[0] == '0'):
        res[0] = '1'
    # 指定範囲が桁数より大きい
    if (N < s_max+1):
        print(-1)
        return
    res_str = ''.join(res[:N])
    print(res_str)
    return

main()


Measured memory_bytes: 3188
#include<vector>
#include<list>
#include<map>
#include<set>
#include<deque>
#include<stack>
#include<bitset>
#include<algorithm>
#include<functional>
#include<numeric>
#include<utility>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<queue>
using namespace std;
const int INF=0x3f3f3f3f;
char a[1000][1000];
int n,m;
int main()
{
    int n,l;
    while(scanf("%d%d",&n,&l)!=EOF)
    {
        for(int i=1;i<=n;i++)
            scanf("%s",a[i]);
        for(int i=1;i<=n;i++)
        {
            for(int j=i+1;j<=n;j++)
            {
                if(strcmp(a[i],a[j])>0)
                {
                    char s[1000];
                    strcpy(s,a[i]);
                    strcpy(a[i],a[j]);
                    strcpy(a[j],s);
                }
            }
        }
        for(int i=1;i<=n;i++)
        {
            printf("%s",a[i]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 384
n=int(input())
a=list(map(int, input().split()))
kazu=[0]*(10**6+1)
for i in a:
  for j in range(i,10**6+1, i):
    if j > 10**6+1:
      break
    if kazu[i] >= 2:
      break
    kazu[j] += 1

count = 0
for i in a:
  if kazu[i] == 1:
    count += 1
print(count)

Measured memory_bytes: 32160
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

A=many_int()

if sum(A)>=22:
    print("bust")
else:
    print("win")

Measured memory_bytes: 38256
#include <stdio.h>
#include <float.h>

int main(void){
	float max=0, min=FLT_MAX, t;
	while(scanf("%f",&t)==1){
		if(t>max) max=t;
		if(t<min) min=t;
	}
	printf("%.1f",max-min);
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int n, k, a[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> k;
    FOR(i,1,n) cin >> a[i];
    int vt = 0;
    FOR(i,1,n)
        if (a[i] == 1) vt = i;
    int res = 1000000000;
    FOR(i,max(1, vt-k+1), min(n, vt+k-1)) {
        int l = i, r = l + k - 1;
        int lef = l - 1, rig = n - r;
        int now = 1 + lef / (k - 1) + (lef % (k - 1) > 0) + rig / (k - 1) + (rig % (k - 1) > 0);
        res = min(res, now);
    }
    cout << res;
    return 0;
}

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

const int kN = 505;

char grid[kN][kN], ans1[kN][kN], ans2[kN][kN];
int h_max[kN], h_min[kN];

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; ++i) scanf("%s", grid[i] + 1);
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j) {
			ans1[i][j] = ans2[i][j] = grid[i][j];
		}
	for(int j = 1; j <= m; ++j) {
		for(int i = 2; i < n; ++i) {
			if(j % 4 == 2 || j % 4 == 3) ans1[i][j] = '#';
			else ans2[i][j] = '#';
		}
	}
	for(int i = 1; i <= m; ++i) printf("#");
	printf("\n");
	for(int i = 2; i <= n; ++i) printf("%s\n", ans1[i] + 1);
	printf("\n");
	for(int i = 1; i < n; ++i) printf("%s\n", ans2[i] + 1);
	for(int i = 1; i <= m; ++i) printf("#");
	printf("\n");
	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if (a > b) cout << "a > b" << endl;
    else if (a == b) cout << "a == b" << endl;
    else cout << "a < b" << endl;
    
    return 0;
}


Measured memory_bytes: 3092
#include<iostream>

using namespace std;

int main()
{
	int S;
	int h, m, s;
	cin >> S;
	h = S / 3600;
	S -= 3600 * h;
	m = S / 60;
	S -= 60 * m;
	s = S;

	cout << h << ":" << m << ":" << s << "\n";

}

Measured memory_bytes: 3100
# for #!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase


def main():
	# for t in range(int(input())):
		n = input()
		if n.count("7")>0:
			print("Yes")
		else:
			print("No")
		
		


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = "x" in file.mode or "r" not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b"\n") + (not b)
			ptr = self.buffer.tell()
			self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode("ascii"))
		self.read = lambda: self.buffer.read().decode("ascii")
		self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
	main()

Measured memory_bytes: 62716