akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1000000007;

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
       char x[3][60];
       scanf("%s",x[1]+1);
       scanf("%s",x[2]+1);
       int i;
       ll dp[60];
       if(x[1][1]==x[2][1])
        {
            dp[1]=3;
           i=2;
       }
       else
       {
           dp[2]=6;
           i=3;
       }

       for(;i<=n;i++)
       {
           if(x[1][i]==x[2][i]&&x[1][i-1]==x[2][i-1])
            {
                dp[i]=dp[i-1]*2%mod;
            }
          else if(x[1][i]==x[2][i]&&x[1][i-1]!=x[2][i-1])
            {
                dp[i]=dp[i-1]%mod;
            }
          else if(x[1][i]!=x[2][i]&&x[1][i-1]==x[2][i-1])
            {
                dp[i]=dp[i-1]*2%mod;
                dp[i+1]=dp[i];
                i++;
            }
          else if(x[1][i]!=x[2][i]&&x[1][i-1]!=x[2][i-1])
            {
                dp[i]=dp[i-1]*3%mod;
                dp[i+1]=dp[i];
                i++;
            }
       }
       printf("%lld\n",dp[n]%mod);

    }





}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    list<int> b;
    for(int i=0; i<n; i++) cin >> a[i];

    for (int i = 0; i < n; i++) {
        if(i % 2 == 0) b.push_back(a[i]);
        else(b.push_front(a[i]));
    }

    if(n % 2 == 1) reverse(b.begin(), b.end());
    for (auto s : b) {
        cout << s << " ";
    }

    cout << endl;
}


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

int main()
{
	int n;
	cin>>n;
	
	int a[n+1];
	for(int i=1;i<=n;i++) cin>>a[i];
	
	int even=0,ok=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]%2==0)
		{
			even++;
			if(a[i]%3==0 || a[i]%5==0)
				ok++;
		}	
	}	
	if(ok==even)
	cout<<"APPROVED"<<endl;
	else
	cout<<"DENIED"<<endl;
} 

Measured memory_bytes: 256
#include <stdio.h>

long long int make_ans_sum(long long int S){
	if(S < 10){
		return S;
	}
	else{
		long long int sum = S, io;
		int i;
		for(i = 0, io = 10; S / io != 0; i++, io *= 10){
			sum += (S / io)<<i;
		}
		io /= 10;
		sum += 2 * make_ans_sum(S % io);
		return sum;
	}
}

int main(){
	long long int S, io = 1;
	scanf("%lld", &S);
	while(S / io >= 10){
		io *= 10;
	}
	printf("%lld\n", make_ans_sum(S) - make_ans_sum(S % io));
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
 
int main(void){
 
  int x[10002],n,i;
 
  x[1]=2;
  for(i=2;i<=10000;i++)
    x[i]=i+x[i-1];
   
  while(scanf("%d",&n)!=EOF){
    printf("%d\n",x[n]);
  }
  return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll 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 rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    int n,W; cin >> n >> W;
    vector<int> v(n),w(n);
    vector<int> dp(W+1,0);
    rep(i,n) cin >> v[i] >> w[i];
    rep(i,n){
        rep(j,W){
            if(j+w[i] > W) break;
            chmax(dp[j+w[i]], dp[j]+v[i]);
        }
    }
    cout << dp[W] << endl;
}


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

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;

    int t = 1900*m + (n-m)*100;

    int y = 1;
    for(int i = 0; i < m; ++i) {
        y *= 2;
    }

    int ans = y * t;

    cout << ans << endl;
    return 0;
}

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

int main()
{
    int a,b,h;
    cin >> a;
    cin >> b;
    cin >> h;
    cout << (a+b)*h/2 <<endl;
}

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

MMYY = "NO"
YYMM = "NO"

first2 = int(S[0:2])
last2 =  int(S[2:4])

if 13 > first2 > 0 and 99 >= last2 >= 0:
    MMYY = "YES"
if 99 >= first2 >= 0 and 13 > last2 > 0:
    YYMM = "YES"

if YYMM == "NO" and MMYY == "NO":
    print("NA")
elif YYMM == "YES" and MMYY == "NO": 
    print("YYMM")
elif YYMM == "NO" and MMYY == "YES":
    print("MMYY")
elif YYMM == "YES" and MMYY == "YES":
    print("AMBIGUOUS")



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  char a, b;
  cin >> a >> b;
  if(a>b){
    print('>');
  }
  else if(a==b){
    print('=');
  }
  else{
    print('<');
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int N;
int A[11];
long long rez=0;
int main()
{
    cin>>N;
    for(int i=0;i<N;i++)cin>>A[i];
    for(int conf=0;conf<(1<<N);conf++)
    {
        long long tmp=1;
        bool ok=0;
        for(int i=0;i<N;i++)
        {
            if((conf>>i)&1)
            {
                ok|=(A[i]%2==1);
                tmp*=2;
            }
            else
            {
                ok|=(A[i]%2==0);
            }
        }
        rez+=ok*tmp;
    }
    cout<<rez;
    return 0;
}


Measured memory_bytes: 256
import sys
array_no = list(map(int,input().split()))
for I in array_no:
    if not (1 <= I <= 9): sys.exit()

max_first = array_no.pop(array_no.index(max(array_no)))
max_second = array_no.pop(array_no.index(max(array_no)))
print(int(str(max_first)+str(max_second)) + array_no[0])

Measured memory_bytes: 9164
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
using namespace std;
typedef long long llong;
static const llong max_n = 30;
// vector<vector<llong>> dp(max_n, vector<llong>(10, 0));
// static const int max_n = 110;
// static const llong max_cost = 2000000000000000;
// // vector<vector<llong>> matrix(max_n, vector<llong>(max_n, 0));
// // vector<vector<llong>> adj_matrix(max_n, vector<llong>(max_n, max_cost));
// vector<vector<pair<llong, int>>> adj_list(max_n);
// vector<llong> distance_table(max_n, max_cost);
// set<pair<llong, int>> points_sort_x;
// set<pair<llong, int>> points_sort_y;

// int N;
llong N;

vector<llong> search_division(llong n){
    vector<llong> divisions;
    llong num = 1;
    llong i = 2;
    while(i*i < n){
        if(n % i == 0){
            divisions.push_back(i);
            divisions.push_back(n/i);
        }
        i ++;
    }

    if(i*i == n){
        divisions.push_back(i);
    }
    sort(divisions.begin(), divisions.end());

    return divisions;
}

llong search_division_num(llong n){
    vector<llong> divisions;
    llong num = 1;
    llong i = 2;
    while(i*i < n){
        if(n % i == 0){
            num += 2;
        }
        i++;
    }
    // for(i=2;i*i<n;i++){
    //     if(n%i==0){
    //         num += 2;
    //     }
    // }

    if(i*i == n){
        // divisions.push_back(i);
        num ++;
    }
    // sort(divisions.begin(), divisions.end());

    return num;
}

llong search_division_res(llong n){
    llong num = 1;
    llong i = 2;
    while(i*i < n){
        // printf("i=%lld, i*i=%lld\n", i, i*i);
        if(n % i == 0){
            llong m = n;
            while(m % i == 0){
                m = m / i;
            }
            if(m % i == 1) num ++;
        }
        i ++;
    }

    if(i*i == n){
        num ++;
    }


    return num;
}



int main(){
    // int u, v;
    // bool updated = false;
    llong ans;
    scanf("%lld", &N);

    // ans = search_division(N-1).size();
    if(N==2){
        printf("%d\n", 1);
    }else{
        ans = search_division_num(N-1);
        // printf("N-1 = %lld\n", ans);
        ans += search_division_res(N);

        printf("%lld\n", ans);
    }



    // double limit = 1. / (double)(4 * M);



    return 0;

}

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

stack<int> operand;
void pop(int &a, int &b) {
    a = operand.top();
    operand.pop();
    b = operand.top();
    operand.pop();
}

int main() {
    // stack<int> operand;
    char s[100];
    while (scanf("%s", &s) != EOF) {
        int a, b;
        if (s[0] == '+') {
            // int a = operand.top();
            // operand.pop();
            // int b = operand.top();
            // operand.pop();
            pop(a, b);
            operand.push(b + a);
        } else if (s[0] == '-') {
            // int a = operand.top();
            // operand.pop();
            // int b = operand.top();
            // operand.pop();
            pop(a, b);
            operand.push(b - a);
        } else if (s[0] == '*') {
            // int a = operand.top();
            // operand.pop();
            // int b = operand.top();
            // operand.pop();
            pop(a, b);
            operand.push(b * a);
        } else {
            operand.push(atoi(s));
        }
    }
    printf("%d\n", operand.top());
}


Measured memory_bytes: 3228
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
	string s;
	cin >> s;
	int ans = 0;
	for(int i = 0; i < s.length(); i++){
		if(s[i] == '9') ans = 1;
	}
	if(ans == 0) cout << "No" << endl;
	else  cout << "Yes" << endl;
	return 0;
}

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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int N; cin >> N;
    V<int> a(N+1,0),b(N+1,0);
    for(int i = 1; i <= N; ++i) cin >> a[i];
    for(int i = N; 1 <= i; --i){
        int tmp = 0;
        for(int j = 2*i; j <= N; j += i) (tmp += b[j]) %= 2;
        if(tmp!=a[i]) b[i] += 1;
    }
    cout << accumulate(ALL(b),0) << endl;
    for(int i = 1; i <= N; ++i) if(b[i]) cout << i << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 2432
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#include <sstream>
#include <iterator>

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

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

    i64 twoMax = 0, twoNext = 0;
    i64 fourMax = 0;

    map<int, int> counts;

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

        counts[k]++;

        if (counts[k] == 2)
        {
            if (k > twoMax)
            {
                twoNext = twoMax;
                twoMax = k;
            }
            else if (k > twoNext)
            {
                twoNext = k;
            }
        }
        
        if (counts[k] == 4)
        {
            if (k > fourMax)
                fourMax = k;
        }
    }

    printf("%lld\n", max(twoMax * twoNext, fourMax * fourMax));

    return 0;
}

Measured memory_bytes: 4992
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9+7
resi = dict()
for i in range(100000+1):
    resi[i] = 0
resi[0] = 3

cnt = 1
for i in range(N):
    if A[i] == 0:
        cnt *= resi[0]
        cnt %= MOD
        resi[0] -= 1
        resi[1] += 1
    else:
        cnt *= resi[A[i]]
        cnt %= MOD
        resi[A[i]] -= 1
        resi[A[i]+1] += 1
    if resi[A[i]+1] > 3 or resi[A[i]] < 0:
        print(0)
        exit()

print(cnt)

Measured memory_bytes: 62220
<?php
$N = trim(fgets(STDIN));
$T = explode(' ', trim(fgets(STDIN)));
if($N != count($T)) die("input error\n");

$M = trim(fgets(STDIN));
$D = array();
for($i = 0; $i < $M; $i++){
	$D[$i] = explode(' ', trim(fgets(STDIN)));
}

for($i = 0; $i < $M; $i++){
	$ans = 0;
	for($j = 0; $j < count($T); $j++){
		if($j != ($D[$i][0] - 1)) $ans += $T[$j];
		else $ans += $D[$i][1];
	}
	echo $ans.PHP_EOL;
	unset($ans);
}
?>

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

priority_queue<double ,vector<double> > p;

int main(){
  long N, M;
  cin >> N >> M;
  for(int i=0; i<N; i++){
    int A; cin >> A;
    p.push(A);
  }
  long rem = M;
  long mai = 1;
  if(N==1){
    cout << (long long)(p.top()/pow(2,M)) << endl;
    return 0;
  }
  for(int i=0; i<M; i++){
    long tmp = p.top();
    p.pop();
    p.push(tmp/2);
  }
  long long cost=0;
  for(long i=0; i<N; i++){
    cost+=(long)p.top();
    p.pop();
  }
  cout << cost << endl;
  return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> neg, pos;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x == 0) {
            k--;
        } else {
            (x < 0 ? neg : pos).push_back(abs(x));
        }
    }

    reverse(begin(neg), end(neg));
    neg.insert(begin(neg), 0);
    pos.insert(begin(pos), 0);

    int ans = 1e9;
    for (int i = min((int) neg.size() - 1, k); k - i <= min((int) pos.size() - 1, k); i--) {
        ans = min({ans, neg[i] * 2 + pos[k-i], neg[i] + pos[k-i] * 2});
    }

    cout << ans << endl;
}


Measured memory_bytes: 1020
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;

inline int read()
{
	int X=0; bool flag=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
	while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
	if(flag) return X;
	return ~(X-1);
}

int a,b,c;

int main() {
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	a=read();
	b=read();
	c=read();

	if(a>b*c) puts("No");
	else puts("Yes");


    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<queue>
#include <string>
#include <sstream>
#include <complex>
#include <cmath>
#include <algorithm>
using namespace std;



int main()
{
  long n;
  // string s;
  cin  >> n;

  vector<long> a(n);
  vector<long> b(n);


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

  vector<long> a_r(n);
  vector<long> b_r(n);

  a_r[n - 1] = a[n - 1];
  b_r[n - 1] = b[n - 1];

  for (int i = n - 2; i >= 0; i--) {
    a_r[i] = a_r[i + 1] + a[i];
  }
  for (int i = n - 2; i >= 0; i--) {
    b_r[i] = b_r[i + 1] + b[i];
  }


  vector<long> a_l(n);
  vector<long> b_l(n);
  a_l[0] = a[0];
  b_l[0] = b[0];
  for (int i = 1; i < n; ++i) {
    a_l[i] = a_l[i - 1] + a[i];
  }
  for (int i = 1; i < n; ++i) {
    b_l[i] = b_l[i - 1] + b[i];
  }


  long ans = 0;
  for (int i = 0; i < n; ++i) {
    // cerr << a_l[i]  <<"  ";
    // cerr << b_r[i]  <<"  " <<endl;
    if (ans < a_l[i] + b_r[i]) {
      ans = a_l[i] + b_r[i];
    }
  }

  cout << ans << endl;



  return 0;
}

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

using namespace std;

int N;
int Member[20];

unsigned long long int getGcd(unsigned long long int a, int b) {

	if (b == 0) {
		return a;
	}
	return getGcd(b, a%b);
}

unsigned long long int getLcm(unsigned long long int a, int b) {
	unsigned long long int gcd;

	gcd = getGcd(a, b);
	return a / gcd * b;
}

int solve() {
	int limit, cnt;
	unsigned long long int curLcm;
	bool flag;

	cnt = 0;
	limit = 1 << N;
	for (int i = 1; i < limit; ++i) {
		curLcm = 1;
		for (int j = 0; j < N; ++j) {
			if (((i >> j) & 1) == 1) {
				curLcm = getLcm(curLcm, Member[j]);
			}
		}
		flag = true;
		for (int j = 0; j < N; ++j) {
			if (((i >> j) & 1) == 0) {
				if (curLcm % Member[j] == 0) {
					flag = false;
					break;
				}
			}
		}
		if (flag) {
			++cnt;
		}
	}

	return cnt;
}

int main() {

	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> Member[i];
	}
	cout << solve() << endl;

	return 0;
}


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

lst = [0 for i in range(N)]

for m in range(M):
    a,b = map(int, input().split())
    a-=1
    b-=1
    if H[a] > H[b]:
        lst[b]-=1
    elif H[a] < H[b]:
        lst[a]-=1
    else:
        lst[a]-=1
        lst[b]-=1

print(lst.count(0))

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

using namespace std;

int main()
{
    int number;
    cin >> number;
    
    int flag{0};
    while(number) {
        int x = number % 10;
        if(x == 7){
            flag = 1;
            break;
        }
        
        number = number / 10;
    }
    
    if(flag == 1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3592
# coding: utf-8
def II(): return int(input())
def ILI(): return list(map(int, input().split()))


def read():
    N = II()
    S_1 = str(input())
    S_2 = str(input())
    return N, S_1, S_2


def solve(N, S_1, S_2):
    ind = 0
    l_sum = []
    while ind <= N - 1:
        if ind == N - 1:
            l_sum.append("a")
            ind += 1
            continue
        now = S_1[ind]
        next = S_1[ind + 1]
        if now == next:
            l_sum.append("b")
            ind += 2
        else:
            l_sum.append("a")
            ind += 1

    if l_sum[0] == "a":    
        ans = 3
    else:
        ans = 6
    for i in range(1, len(l_sum)):
        pre = l_sum[i - 1]
        now = l_sum[i]
        if pre == "a":
            ans *= 2
        else:
            if now == "b":
                ans *= 3

    return ans % (10 ** 9 + 7)


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<(k) ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=(k) ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef jayinnn
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
const ll MAXN = 100005;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/********** Good Luck :) **********/
int main () {
    TIME(main);
    IOS();
    string a;
    cin >> a;

    for(int i=0;i<(int)a.size();i++){
        cout << "x";
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>

int color[600][600];
int N;

void calccolor(int D,int s){
  int scale=1;
  while(D%4==0){
    scale*=2;
    D/=4;
  }
  if(D%2==0){
    for(int i=0;i<N*2;i++){
      for(int j=0;j<N*2;j++){
	color[i][j]|=(((i/scale)&1)<<s);
      }
    }
  }else{
    for(int i=0;i<N*2;i++){
      for(int j=0;j<N*2;j++){
	color[i][j]|=((((i/scale)^(j/scale))&1)<<s);
      }
    }
  }
}

std::vector<std::pair<int,int> > points[4];

int main(){
  int D1,D2;
  scanf("%d %d %d",&N,&D1,&D2);
  calccolor(D1,0);
  calccolor(D2,1);
  for(int i=0;i<N*2;i++){
    for(int j=0;j<N*2;j++){
      int d=i*i+j*j;
      points[color[i][j]].emplace_back(i,j);
      //printf("%d",color[i][j]);
    }
    //printf("\n");
  }
  for(int i=0;i<4;i++){
    if(points[i].size()>=N*N){
      std::swap(points[i],points[0]);
      break;
    }
  }
  for(int i=0;i<N*N;i++){
    printf("%d %d\n",points[0][i].first,points[0][i].second);
  }
  return 0;
}


Measured memory_bytes: 6120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main() {
    int n,m;
    std::cin >> n>>m;
    std::vector<int> k(m);
    int s[10][10];
    int ans=0;
    std::vector<int>p(m) ;
   for (int i = 0; i < m; i++) {
      std::cin >> k[i];
      rep(j,k[i])std::cin >> s[i][j];
    }
    rep(i,m)std::cin >> p[i];
    // {0, 1, ..., n-1} の部分集合の全探索
    
    for (int bit = 0; bit < (1<<n); ++bit) {
      vector<int> S;
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { 
                S.push_back(i+1);
            }
        }
        bool han=true;
        for (int i = 0; i < m; i++) {
          int counter=0;
          rep(j,S.size()){
            rep(h,k[i]){
           
              if(S[j]==s[i][h])counter++;
            }
          }
          counter=k[i]-counter;
          
          if(counter%2!=p[i])han=false;
        }
        if(han)ans++;
    }
    std::cout << ans << std::endl;
}

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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    int ans = 0;
    rep(i,n) cin >> h.at(i);
    rep(i,n)if(h.at(i) >= k)ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
string S;
int main(){
	cin>>S;
	cout<<(S.substr(0,4)=="YAKI" ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

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

    ll sum = 0;

    for(ll i=1; i<=N; i++){
        if(i % 3==0 || i%5 ==0){
            continue;
        }
        else{
            sum += i;
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

vec d;
mat graph;

ll dfs (ll v, ll from) {
    ll tmp = 0;
    // cout << v << "\n";
    if (d[v] != -1) return d[v];
    if (graph[v].size() == 0) return d[v] = 0;
    for (ll nv : graph[v]) {
        if (nv == from) continue;
        chmax(tmp, dfs(nv, v));
    }
    return d[v] = tmp + 1;
}

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

    ll N, M;
    cin >> N >> M;
    graph.assign(N, vec());
    while (M--) {
        ll x, y;
        cin >> x >> y;
        x--; y--;
        graph[x].push_back(y);
    }

    d.assign(N, -1);

    Rep (i, N) {
        if (d[i] == -1) dfs(i, -1);
    }

    ll ans = 0;
    Rep (i, N) chmax(ans, d[i]);

    cout << ans << endl;
}

Measured memory_bytes: 9216
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx")
#include <bits/stdc++.h>

constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int N, M;
	cin >> N >> M;
	vector<pair<int, int>> ab(N);
	for (int i = 0; i < N; i++)cin >> ab[i].first >> ab[i].second;
	sort(ab.begin(), ab.end());
	ll ans = 0;
	vector<int> ind(100001, 0);
	for (int i = 0; i < N; i++) {
		ind[ab[i].first] = i+1;
	}
	for (int i = 0; i <= M; i++) {
		if (ind[i + 1] == 0)ind[i + 1] = ind[i];
	}

	priority_queue<int> q;
	for (int i = 1; i <= M; i++) {
		for (int j = ind[i-1]; j < ind[i]; j++) {
			q.push(ab[j].second);
		}
		if (!q.empty()) {
			ans += q.top(); q.pop();
		}

	}

	cout << ans << endl;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()

typedef long long lint;
typedef double Double;
typedef pair< int, int > pii;

typedef vector< int > Array;
typedef vector< Array > Matrix;
typedef vector< Double > DArray;
typedef vector< DArray > DMatirx;
typedef vector< string > SArray;
typedef vector< pii > PArray;

inline int POPCNT(int _x) { return __builtin_popcount(_x); }
inline int POPCNT(lint _x) { return __builtin_popcountll(_x); }

const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
const Double EPS = 1e-9;

inline void maxUpdate(int& _a, int _b) { _a = max(_a, _b); }
inline void maxUpdate(lint& _a, lint _b) { _a = max(_a, _b); }

int t;

int p, q;
int n[11], m[11];

Double v[11][110]; // dice[i][j] dice i no j banme no atai
Double r[11][110];

Double POW(Double _d, int _k) {
	Double res = 1.0;
	
	while (_k > 0) {
		if (_k & 1) res *= _d;
		_d *= _d;
		_k >>= 1;
	}
	
	return res;
}

Double calc_exp(int i) {
	Double res = 0;
	
	for_(j,0,m[i]) {
		Double rr = 0.0;
		
		for_(_k,0,1001) rr += POW(r[i][ m[i] ], _k) * r[i][j];
		
		res += rr * v[i][j];
	}
	
	return res;
}

void solve() {
	Double mine = 0;
	for_(i,0,t) mine = max(mine, calc_exp(i));
	
	Double poyo = calc_exp(10);
	
	if (poyo + EPS < mine) cout << "YES" << endl;
	else cout << "NO" << endl;
}

int main() {
	cin >> t;
	
	for_(i,0,t) {
		cin >> n[i] >> m[i];
		
		Double sum = 0;
		for_(j,0,m[i]) {
			cin >> v[i][j] >> r[i][j];
			sum += r[i][j];
		}
		r[i][m[i]] = 1.0 - sum;
	}
	
	cin >> n[10] >> m[10];
	
	Double sum = 0;
	for_(i,0,m[10]) {
		cin >> v[10][i] >> r[10][i];
		sum += r[10][i];
	}
	r[10][m[10]] = 1.0 - sum;
	
	solve();
	return 0;
}

Measured memory_bytes: 1244
# coding: utf-8
import sys
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, Q = lr()
S = sr()
ac = [0] * (N-1)
for i, x in enumerate(zip(S[:], S[1:])):
    if x[0] == 'A' and x[1] == 'C':
        ac[i] = 1

cum = list(itertools.accumulate(ac))
for _ in range(Q):
    l, r = lr()
    result = cum[r-2]
    if l > 1:
        result -= cum[l-2]
    print(result)


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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+123;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};       ///first 4 for adjacent
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};
ll dx8[]= {+1, +1, -1, -1, +2, +2, -2, -2};    ///knights move
ll dy8[]= {+2, -2, +2, -2, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#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 sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ a%=MOD;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=MOD;--b;}a*=a;a%=MOD;b/=2;}return pr;}
ll modinverse(ll a){return powmod(a,MOD-2);}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///



void _case()
{
    ll n,i,ans=0;
    cin>>n;
    ll a[n];
    forn(i,n) cin>>a[i];
    sort(a,a+n);
    if(a[n/2]==a[n/2-1]) cout<<0 el;
    else{
        ll x=a[n/2];
        while(x!=a[n/2-1]) x--,ans++;
        cout<<ans el;
    }
}

main()
{
    fastio();
    _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 4412
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  string S; cin >> S;
  int N = sz(S);
  rep(i,N) cout << "x";
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int N;
    int A;
    bool flag = false;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A;
        if(A % 2 == 0){
            if(A % 3 != 0 && A % 5 != 0){
                cout << "DENIED" << endl;
                return 0;
            }
        } 
    }
    cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int selectionSort(int A[],int N)
{
    int i,j,t,sw = 0,minj;
    for(i = 0 ;i<N-1;i++)
    {
        minj =i;
        for(j = i;j<N;j++)
        {
            if(A[j]<A[minj])minj = j;
        }
        t = A[i];A[i]=A[minj];A[minj]=t;
        if(i !=minj)sw++;
    }
    return sw;
}
int main()
{
    int A[100],N,i,sw;
    scanf("%d",&N);
    for(i = 0 ;i <N;i++) scanf("%d",&A[i]);
    sw = selectionSort(A,N);
    for(i = 0 ;i<N;i++)
    {
        if(i>0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
    printf("%d\n",sw);
    return 0;
}


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

int main() {
	int n;
	while(cin >> n and n!=0) {
		int cnt = 0;
		int left = 0, right = 1, sum = 0;
		while(1) {
			if(right > n) break;
			if(sum == n) {
				// cout << left << " " << right << " " << sum << endl;
				if(right-left >= 1) {
					cnt++;
				}
				sum += right;
				right++;
			}else if(sum < n) {
				sum += right;
				right++;
			}else {
				sum -= left;
				left++;
			}
		}
		cout << cnt << endl;
	}
}


Measured memory_bytes: 3076
package main

import (
	"fmt"
)

func main() {
	var n int

	fmt.Scanf("%d", &n)

	nums := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
	}
	m := make(map[int]struct{})
	newList := make([]int, 0)

	for _, e := range nums {
		if _, ok := m[e]; !ok {
			m[e] = struct{}{}
			newList = append(newList, e)
		}
	}

	fmt.Println(len(newList))
}


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

int main() {
  int N;
  cin >> N;
  
  if (N<10)
    cout << N << endl;
  else if (N<100)
    cout << 9 << endl;
  else if (N<1000) 
    cout << 9 + ((N/100)-1)*100 + N%100 + 1 << endl;
  else if (N<10000)
    cout << 909 << endl;
  else if (N<100000)
    cout << 909 + ((N/10000)-1)*10000 + N%10000 + 1 << endl;
  else if (N==100000)
    cout << 90909 << endl;
    

}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#define rep(i, s, g) for (i = s; i <= g; i++)
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

int main(void)
{
    int N, M;
    int p;
    string S;
    int i, j;
    vector<pair<bool, int>> judge(100010, make_pair(false, 0));
    int ac = 0, wa = 0;

    cin >> N >> M;

    rep(i, 1, M)
    {
        cin >> p >> S;

        if (judge[p].first == false)
        {
            if (S == "AC")
            {
                ac++;
                judge[p].first = true;
            }
            else
            {
                wa++;
                judge[p].second++;
            }
        }
    }

    rep(i, 1, N)
    {
        if (judge[i].first == false)
        {
            wa -= judge[i].second;
        }
    }

    cout << ac << " " << wa << endl;
}

Measured memory_bytes: 1024
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

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

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}

	std::string S;
	std::cin >> S;
	for (int i = 0; i < S.size() - 1; ++i) {
		if (S[i] == S[i+1]) {
			std::cout << "Bad\n";
			return 0;
		}
	}
	std::cout << "Good\n";
}


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

using namespace std;

typedef pair<int,int> P;
const int dx[] = {-1,0,0,1};
const int dy[] = {0,-1,1,0};

int main(){
  int Tc,M,N;

  cin >> Tc;
  while(Tc--){
    vector<P> vec;
    for(int i = 0 ; i < 4 ; i++){
      vec.push_back(P(dx[i],dy[i]));
    }
    cin >> M >> N;
    vec.push_back(P(M,N));
    vec.push_back(P(-N,M));
    vec.push_back(P(-M,-N));
    vec.push_back(P(N,-M));
    int cnt = 0;

    for(int m = 0 ; m <= 100 ; m++){
      for(int n = 0 ; n <= 100 ; n++){
        if(m == n && m == 0) continue;
        int X = m*m + n*n;
        if(!((m*M+n*N) % X == 0 && (m*N-n*M)%X == 0)) continue;
        int Y = (m*M+n*N)/X;
        int Z = (m*N-n*M)/X;
        if((M*M+N*N)/X == Y*Y+Z*Z){
          bool ok = true;
          for(int i = 0 ; i < 8 ; i++){
            if(vec[i].first == m && vec[i].second == n){
              ok = false;
              break;
            }
          }
          if(ok) cnt++;
        }
      }
    }
   
    if(cnt == 0) cout << "P" << endl;
    else cout << "C" << endl;
  }

  return 0;
}

Measured memory_bytes: 1188
#include<iostream>
using namespace std;
const int nmax=(int) 1e5+1;

int main(){
    int N;
    cin >> N;
    int a[nmax]={};
    int tmp,ans;
    for(int i=0; i<N; i++){
        cin >> tmp;
        a[tmp]++;
    }

    ans=0;
    for(int i=0; i<nmax-2; i++){
        tmp=a[i]+a[i+1]+a[i+2];
        ans=max(tmp,ans);
    }    

    cout << ans << endl;

    return 0;
}

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

int main(){
  long long n,k,ans=0;
  cin >> n >> k;
  long long v[n];
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  for(int l=0;l<=min(k,n);l++){
    for(int r=0;r<=min(k-l, n-l);r++){
      long long sum=0;
      vector<long long> getv;
      for(int i=0;i<l;i++){
        sum+=v[i];
        getv.push_back(v[i]);
      }
      for(int i=0;i<r;i++){
        sum+=v[n-i-1];
        getv.push_back(v[n-i-1]);
      }
      sort(getv.begin(), getv.end());
      for(int i=0;i<min(k-l-r, ll(getv.size()));i++){
        if(getv[i]<0){
          sum-=getv[i];
        }else break;
      }
      ans=max(ans, sum);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int N,k,i,x,ans=0;
	scanf("%d %d",&N,&k);
	ans = (N-1)/(k-1);
	if( (N-1)%(k-1)>0){
		ans++;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
import math

k = 1.0/math.sqrt(2.0)
while True:
    n = int(input())
    if n == -1:
        break
    nx = 1.0
    ny = 0.0
    for i in range(n-1):
        dx = -ny
        dy = nx
        d = 1.0/math.sqrt(dx**2 + dy**2)
        nx = nx + d*dx
        ny = ny + d*dy
    print(nx)
    print(ny)




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

#define ft first
#define sd second
#define sz(x) ((int)x.size())

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;






int a[3], b[2];


int main() {
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	b[0] = a[2] - a[0], b[1] = a[2] - a[1];
	if ((b[0] & 1) && (b[1] & 1))
		return cout << (((b[0] + b[1] - 2) >> 1) + 1), 0;
	if (!(b[0] & 1) && !(b[1] & 1))
		return cout << ((b[0] + b[1]) >> 1), 0;
	cout << (((b[0] + b[1] + 1) >> 1) + 1);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<queue>
#include<string>
#include<algorithm>
using namespace std;
typedef queue<pair<string, int> > cc;
typedef pair<string, int> c;
int n,q,a,cnt,ans=0,con;
string s;
cc si;
c temp;
int main()
{
    scanf("%d %d",&n,&q);
    while(n--)
    {
        cin>>s>>a;
        temp=make_pair(s,a);
        si.push(temp);
    }
    while(!si.empty())
    {
        temp=si.front();
        si.pop();
        con=min(temp.second,q);
        cnt=temp.second-con;
        ans+=con;
        if(!cnt)
           cout<<temp.first<<" "<<ans<<endl;
        else
        {
             s=temp.first;
             a=cnt;
             temp=make_pair(s,a);
             si.push(temp);
        }
       // cout<<temp.first<<endl;
    }
    return 0;
}



Measured memory_bytes: 6368
<?php
$q = (int)trim(fgets(STDIN));

$query=[];
for ($i=1; $i <= $q; $i++) { 
	$input = explode(' ', trim(fgets(STDIN)));
	$query[$i]=[
		'l' => (int)$input[0] - 2,
		'r' => (int)$input[1],
	];
}

$primes = [2];
$odds   = [];
for ($i=3; $i <= 100000 ; $i+=2) { 
	$odds[] = $i;
}

$o_length = count($odds);
$array = $odds;
$start = 3;
$max = ceil(sqrt(100000));
for ($j=0; $start < $max ; $j++) { 
	if (in_array($start, $array)) {
		$array = era($array, $start);
	}
	$start += 2;
}
$primes = array_merge($primes, $array);

$accum = [];
$prev = 0;
for ($k=0; $k < $o_length; $k++) { 
	$tmp_odd = $odds[$k];
	if (in_array($tmp_odd, $primes) && in_array(($tmp_odd+1)/2, $primes)) {
		$accum[$tmp_odd] = $prev+1;
	}else{
		$accum[$tmp_odd] = $prev;
	}
	$prev = $accum[$tmp_odd];
}
$result = [];
for ($i=1; $i <= $q; $i++) { 
	$tmp_l = $query[$i]['l'];
	$tmp_r = $query[$i]['r'];
	$result[] = $accum[$tmp_r] - $accum[$tmp_l];
}
echo implode(PHP_EOL, $result);


function era($array, $start){
	$new_array = [];
	foreach ($array as $num) {
		if ($num > $start && $num % $start === 0) {
			continue;
		}
		$new_array[] = $num;
	}
	return $new_array;
}

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

int main() {
	int n, h, w,cnt=0;
	cin >> n >> h >> w;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		if (a >= h && b >= w) {
			cnt++;
		}
	}
	cout << cnt << endl;
	getchar();
	getchar();
	return 0;
}

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

# targ = []
# # targ.append(abs(X - x[0]))
# for i in range(N - 1):
#     targ.append(abs(x[i + 1] - x[i]))

def mygcd(a, b):
    # print("#", a, b)
    if a < b: return mygcd(b, a)
    elif b == 0: return a
    else: return mygcd(b, a % b)

ans = abs(X - x[0])
for i in range(N - 1):
    ans = mygcd(ans, abs(x[i + 1] - x[i]))

print(ans)

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

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

    int t = 0;
    int s = 1;
    while (t < n) {
        t += s;
        s++;
    }
    for (int i = 1; i < s; i++) {
        if (i != t - n) {
            cout << i << endl;
        }
    }
}

Measured memory_bytes: 256
#coding:utf-8

N, M = map(int, input().split())

fuga = [0]*M
for i in range(N):
    tmp = [int(j) for j in input().split()]
    k = tmp[0]
    s = tmp[1:]
    for i in range(k):
        fuga[s[i]-1] += 1

print(fuga.count(N))


Measured memory_bytes: 2940