akhauriyash/Code-Regression huggingface dataset:
def powmod(x, n,mod):
  if n == 0:
   return 1
  K = 1
  while n > 1:
   if n % 2 != 0:
    K = K * x%mod
    x = x ** 2%mod
    n = (n - 1) // 2
   else:
    x = x ** 2%mod
    n = n // 2%mod

  return K * x # 指数を割り続け n が 1 に至ったら終了

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 998244353 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
N,M,K=map(int,input().split())
mod=998244353
A=0
for i in range(K+1):
 A+=powmod(M-1, N-1-i,mod)*cmb(N-1,i,mod)
 A%=mod
print((A*M)%mod)

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

ll dp[100005];
int w[105], v[105];

int main() {
  int n, W; cin >> n >> W;
  for (int i = 1; i < 100005; i++) dp[i] = 0x3f3f3f3f3f3f3f3fll;
  for (int i = 0; i < n; i++) {
   	cin >> w[i] >> v[i];
  	for (int j = 100004; j >= v[i]; j--)
      dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
  }
  int ans = 0;
  
  for (int i = 0; i <= 100004; i++) if (dp[i] <= W) ans = i;
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <algorithm>
#define ll long long int
#define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n)

using namespace std;

int main()
{
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    if (e - a <= k)
        cout << "Yay!" << endl;
    else
        cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 256
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int t,x; cin >> t >> x;
    printf("%.10f\n",(double)t/x);
}


Measured memory_bytes: 3724
#include<algorithm>
#include<iostream>
#include<vector>

int main()
{
	int n, m;
	while( std::cin >> n >> m, n | m )
	{
		std::vector<int> v( n );
		for( int i = 0; i != n; ++i )
		{
			int p;
			std::cin >> p;
			v.push_back( p );
		}
		
		std::sort( v.rbegin(), v.rend() );

		int ans = 0;
		for( int i = 0; i != n; ++i )
			if( ( i + 1 ) % m )
				ans += v[i];

		std::cout << ans << std::endl;
	}

	return 0;
}

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

int main()
{
	int A, B, C;
	cin >> A;
	cin >> B;
	cin >> C;
	int ans = min(B / A, C);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <random>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
    int n,x; cin >> n >> x;
    int d[n+1];
    d[0] = 0;
    rep(i,n) {
        int l; cin >> l;
        d[i+1] = d[i] + l;
    }
    int ans = 0;
    rep(i,n+1) if (d[i] <= x) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}
int dp[(int)1e6 + 1] = {0};

int main()
{
        //input->compute->output//
        int N, D;
        cin >> N >> D;

        cout << (N + 2 * D) / (2 * D + 1) << endl;

        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define ull unsigned ll
#define pb push_back
#define popb pop_back
#define mt make_tuple
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define piii pair <pii,int>
#define piiii pair <pii,pii>
#define pll pair <ll,ll>
#define plll pair <pair <ll, ll>, ll>
#define rep0(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<=(ll)n;i++)
#define rep(i,x,y) for(ll i=(ll)x;i<=(ll)y;i++)
#define reprev(i,n) for(ll i=(ll)n;i>=0;i--)
#define all(c) c.begin(),c.end()
#define print(a) rep0(i,a.size()) cout << a[i] << " "
#define hi() cout << "\nHello, I am error. Can you find me? :):):)\n"
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_eppoch().count())
 
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>;

// FOR DEBUGGING
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", ";
	else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifndef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

const int mod = 1e9+7;
const long double pi = acos(-1);
const ll INF = 1e15;

ll power(ll x, ll y){
	x %= mod;
	ll ans = 1;
	while(y){
		if(y&1) ans = (ans*x)%mod;
		y /= 2;
		x = (x*x)%mod;
	}
	return ans;
}

void solve(){

	int n,a,b;
	cin >> n >> a >> b;
	string s;
	cin >> s;

	int ans = 0, cnt = 0;
	rep0(i,n){
		if(s[i]=='c') cout << "No\n";
		if(s[i]=='a'){
			if(ans<a+b){
				ans++;
				cout << "Yes\n";
			}else cout << "No\n";
		}
		if(s[i]=='b'){
			cnt++;
			if(ans<a+b && cnt<=b){
				ans++;
				cout << "Yes\n";
			}else cout << "No\n";
		}
	}

	return;
}

int main(){

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

	int TC = 1,t = 0;
	// cin >> TC;
	while(t++ < TC){
		// cout << "Case #" << t << ": ";
		solve();
		// cout << "\n";
	}

	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

	return 0; 
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

// 入力
int N;
long long a[100010][3]; // a[i], b[i], c[i] をそれぞれまとめて a[i][0], a[i][1], a[i][2] にしてしまう

// DP テーブル
long long dp[100010][3];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];

    // 初期化は既に 0 に初期化される
    // 初期条件も既に 0 で OK

    // ループ
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    // 答え
    long long res = 0;
    for (int j = 0; j < 3; ++j) chmax(res, dp[N][j]);
    cout << res << endl;
}

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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
 ll gcd(ll a,ll b){
 if(b == 0) return a;
 return gcd(b,a%b);
 }

//最小公倍数
 ll lcm(ll a,ll b){
 ll g = gcd(a,b);
 return a / g * b; // Be careful not to overflow  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 


//  int X[8]={-1, 0, 1, -1, 1, -1, 0, 1};
//  int Y[8]={1, 1, 1, 0, 0, -1, -1, -1};




int main(){
int H, W;
cin >> H >> W;
string s[51];
REP(i, H) cin >> s[i];

 int X[8]={-1, 0, 1, -1, 1, -1, 0, 1};
 int Y[8]={1, 1, 1, 0, 0, -1, -1, -1};

 REP(i, H)REP(j, W){
   if(s[i][j] == '#') continue;
   else{
     int count = 0;
     for(int d = 0; d < 8; d++){
       int ni = i + X[d];
       int nj = j + Y[d];
       if(ni < 0 || ni > H || nj < 0 || nj > W) continue;
       else if(s[ni][nj] == '#') count++;
     }
    s[i][j] = '0' + count;
   }
 }

REP(i, H) print(s[i]);

}

Measured memory_bytes: 256
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 2e5 + 10;
const ll inf = 1e18 + 42;

struct jewel {
	int c; ll val; int type;
	bool operator<(const jewel &o) const {
		return tie(o.val, o.type) < tie(val, type);
	}
};

vector<jewel> all_jewels;
vector<ll> jewels[N];
multiset<ll> used_pairs, used_singles;
multiset<ll, greater<ll>> avail_singles, triplets;
ll res[N];

int main() {
	fast_cin();
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) {
		int c, v;
		cin >> c >> v;
		jewels[c].pb(v);
	}
	for (int c = 1; c <= k; ++c) {
		sort(jewels[c].begin(), jewels[c].end(), greater<int>());
		int t = jewels[c].size();
		if (t >= 3) {
			triplets.insert(jewels[c][0] + jewels[c][1] + jewels[c][2]);
		}
		all_jewels.pb({c, jewels[c][0] + jewels[c][1], 2});
		for (int j = 2; j < t; ++j) {
			all_jewels.pb({c, 2 * jewels[c][j], 1});
		}
	}
	sort(all_jewels.begin(), all_jewels.end());
	avail_singles.insert(-inf);
	triplets.insert(-inf);
	used_pairs.insert(inf);
	used_singles.insert(inf);
	ll sum = 0, x = 0;
	for (auto &j : all_jewels) {
		int c = j.c;
		if (j.type == 2) {
			ll ans = -1;
			ans = max(ans, sum + *avail_singles.begin());
			ans = max(ans, sum - *used_pairs.begin() + *triplets.begin());
			ans = max(ans, sum - *used_singles.begin() + j.val);
			res[x + 1] = ans;
			sum += j.val;
			x += 2;
			int t = jewels[c].size();
			for (int i = 2; i < t; ++i) {
				avail_singles.insert(jewels[c][i]);
			}
			if (t >= 3) {
				triplets.erase(triplets.find(jewels[c][0] + jewels[c][1] + jewels[c][2]));
			}
			used_pairs.insert(j.val);
		} else {
			j.val /= 2;
			sum += j.val;
			++x;
			avail_singles.erase(avail_singles.find(j.val));
			used_singles.insert(j.val);
		}
		res[x] = sum;
	}
	for (int i = 1; i <= n; ++i) {
		cout << res[i] << '\n';
	}
}

Measured memory_bytes: 26228
#include <stdio.h>

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

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

string S;
ll N;
vector<string> vs;

void dp(ll i = 0, string S = "") {
    if (S.length() == N) {
        vs.push_back(S);
        return;}
    S = S + to_string(i);

    ll max_n = -1;
    REP(i, S.length()) {
        if ((int)S[i]-'0' >= max_n) {
            max_n = (int)S[i] - '0' + 1;
        }
    }
    REP(i, max_n + 1) { dp(i, S); }
}

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

    dp();
    UNIQUE(vs)
    REP(j, vs.size()){
        REP(i, N){
            cout << char((int)(vs[j][i]-'0')+'a') ;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 39912
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int gcd(int a, int b)
{
  if (a%b==0){
    return(b);
  }
  else{
    return(gcd(b,a%b));
  }
}




int main(){
  int N,K;
  cin >> N >> K;
  int ans = 0;
  rep(i,N){
    int h;
    cin >> h;
    if(h >= K) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
//codeforces
#include <algorithm>
#include <vector>
#include <string>
#include <ctype.h>
#include <set>
#include <map>
#include<cstdio>
#include<queue>
#include<cstdlib>
#include<time.h>
#include<string>
#include<stack>
#include<cmath>
#include<iostream>
#include<cstring>
#include<complex>
#include<bitset>
#include <climits>
#include<tr1/unordered_set>
#include<tr1/unordered_map>


#define FOR(i,j,k) for(int i=j;i<k;i++)
#define FORD(i,j,k) for(int i=j;i>=k;i--)
#define ll long long
//Make sure no overflow problems
//#define int long long
#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define VAR(i,n) __typeof(n) i = (n)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();i++)
#define FORDEACH(i,c) for( VAR(i,(c).rbegin()),i!=(c).rend();i++)
#define REP(i,n) FOR(i,0,n)
#define ld long double
const int INF = 1e9+7;
const long long INFLL = (ll)INF * (ll)INF;
const ld EPS = 10e-9;

using namespace std;

class TrieNode{
    public:
    bool isword;
    char c;
    map<char,TrieNode*> m;
    string word;
    public:
    TrieNode(){}
    TrieNode(char ch){
        c=ch;
        isword=false;
    }
};

void insert(TrieNode* root,string word){
    TrieNode* temp=root;
    for(char c:word){
        if(temp->m.find(c)==temp->m.end())
            temp->m[c]=new TrieNode(c);
        temp=temp->m[c];
    }
    temp->isword=true;
    temp->word=word;
}

#pragma GCC optimize ("Ofast")
static auto _ = [] { std::ios::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0); std::cerr.tie(0); return 0; } ();

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

    int sum=0;

    vector<int> v(n),w(n);
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
        sum+=v[i];
    }

    vector<long long> dp(sum+1,INF);
    dp[0]=0;

    for(int i=0;i<n;i++){
        for(int j=sum-v[i];j>=0;j--){
            dp[j+v[i]]=min(dp[j+v[i]],dp[j]+w[i]);
        }
    }

    long long ans=0;
    for(long long i=0;i<=sum;i++){
        if(dp[i]<=W)
            ans=max(ans,i);
    }

    cout<<ans;

    // cout<<*min_element(dp.begin(),dp.end());


    return 0;
}


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

typedef long long LL;

int main() {
  LL N, M;
  cin >> N >> M;
  LL A[N];
  priority_queue<LL> pque;
  for (LL i = 0; i < N; i++) {
    cin >> A[i];
    pque.push(A[i]);
  }
  
  for (LL i = 0; i < M; i++) {
    LL p = pque.top();
    pque.pop();
    pque.push(p / 2);
  }
  
  LL ans = 0;
  
  while(!pque.empty()) {
    ans = ans + pque.top();
    pque.pop();
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1912
import math

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

test_case = []
for i in range(n):
    x1, y1 = xy[i]
    test_case.append((y1, -x1))
    test_case.append((-y1, x1))

ret = 0
for x1, y1 in test_case:
    sx, sy, tx, ty = 0, 0, 0, 0
    for j in range(n):
        x2, y2 = xy[j]
        if x1 * x2 + y1 * y2 > 0 or (x1 * x2 + y1 * y2 == 0 and -y1 * x2 + x1 * y2 >= 0):
            sx += x2
            sy += y2
    ret = max(ret, math.hypot(sx, sy), math.hypot(tx, ty))
print(ret)

Measured memory_bytes: 39408
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

A = LIST()
A.sort()

if A[2]%2:
	print(A[0]*A[1])
else:
	print(0)

Measured memory_bytes: 5148
#include <algorithm>
#include <iostream>

using namespace std;
typedef long long ll;

#define RPT(i, n) for (int i = 1; i <= n; i++)

int N, K, x[100001];

int main()
{
    cin >> N >> K;
    RPT(i, N) cin >> x[i];

    ll ans = __LONG_LONG_MAX__;
    RPT(i, N - K + 1)
    {
        int L = i;
        int R = i + K - 1;
        ll tmp =
            min(abs(x[L]) + abs(x[R] - x[L]), abs(x[R]) + abs(x[L] - x[R]));
        ans = min(ans, tmp);
    }

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


Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <stack>
#include <vector>
#include <utility>
using namespace std;
int search(int a[], int n, int key)
{
    a[n] = key;
    int i = 0;
    while (key != a[i])
        i++;
    return i != n;
}
int main()
{
    int count = 0;
    int n;
    cin >> n;
    int S[n + 1];
    for (int i = 0; i < n; i++)
        cin >> S[i];
    int q;
    cin >> q;
    int T;
    for (int i = 0; i < q; i++)
    {
        cin >> T;
        if (search(S, n, T))
            count++;
    }
        cout << count << "\n";
}


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

int main()
{
	int iRow, iCol;			// 元の表の行数、列数
	int iInputNum;			// 入力された1要素
	int iSumRow;			// 各行の合計値
	int* aiSumCol;			// 各列の合計値
	int iSumTable = 0;		// 表の全要素の合計値
	int iCountA, iCountB;	// ループカウンタ

	// 入力：元の表の行数、列数
	scanf("%d %d", &iRow, &iCol);

	// 列の合計値を格納する配列を確保する
	aiSumCol = (int*)malloc(sizeof(int) * iCol);
	for (iCountA = 0; iCountA < iCol; iCountA++)
	{
		aiSumCol[iCountA] = 0;
	}

	// 入力と同時に合計値を求め、各行の合計を出力する
	for (iCountA = 0; iCountA < iRow; iCountA++)
	{
		iSumRow = 0;
		for (iCountB = 0; iCountB < iCol; iCountB++)
		{
			// 入力：1要素分の値
			scanf("%d", &iInputNum);

			// 出力：1要素分の値
			printf("%d ", iInputNum);

			// 行合計、列合計、全要素合計に加算する
			iSumRow += iInputNum;
			aiSumCol[iCountB] += iInputNum;
			iSumTable += iInputNum;
		}
		// 出力：行合計
		printf("%d\n", iSumRow);
	}

	// 出力：各列の合計、表全体の合計
	for (iCountA = 0; iCountA < iCol; iCountA++)
	{
		printf("%d ", aiSumCol[iCountA]);
	}
	printf("%d\n", iSumTable);

	free(aiSumCol);
	return 0;
}


Measured memory_bytes: 2104
#include<iostream>

int main (){
    std::cin.tie(0); 
	std::ios::sync_with_stdio(false);
    long long X,K,D;std::cin >> X >> K >> D;
    long long ans=0;

    X = std::abs(X);

    long long devide= X / D;
    long long mod = X % D;

    if (devide >= K) {
        ans = X - D * K;
    } else {
        if ((K - devide) % 2 ==0) {
            ans = mod;
        } else {
            ans = D - mod;
        }
    }

    std::cout << ans;
    return 0 ;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll h,w;
  string s[300];
  cin >> h >> w;
  rep(i,h)cin >> s[i];
  rep(i,w+2)printf("#");
  printf("\n");
  rep(i,h){
    printf("#");
    cout << s[i];
    printf("#\n");
  }
  rep(i,w+2)printf("#");
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <cstdlib>
#include <stack>
#include <queue>
#include <list>
#include <set>

#define llong long long int

using namespace std;

int main(int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, sum = 0;
    cin >> n;
    int max = 1;
    for (int i = 0; i < n; ++i) {
        int tmp;
        cin >> tmp;
        sum += tmp;
        if (tmp >= max) max = tmp;
    }

    cout << sum - max + (int)(max/2) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mx 500010
#define pb push_back

ll arr[mx];
ll brr[mx];


int main()
{
ios_base::sync_with_stdio(false);

int n,m;
cin>>n>>m;
cout<<n-(m-1)<<endl;

//cout << fixed << showpoint;
//cout << setprecision(12);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000000;

signed main(){
  int N;
  cin >> N;
  
  vector<int> H(N+10);
  for( int i = 0; i < N; i++ ) cin >> H.at(i);
  
  vector<int> dp(N+10, INF);
  dp.at(0) = 0;
  for( int i = 0; i < N; i++ ){
    dp.at(i+1) = min(dp.at(i+1), dp.at(i)+abs(H.at(i)-H.at(i+1)));
    dp.at(i+2) = min(dp.at(i+2), dp.at(i)+abs(H.at(i)-H.at(i+2)));
  }
   
  cout << dp.at(N-1) << endl;
}

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

// Shortcut

#define int long long
#define endl '\n'
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) for (int i = 0; i < a.size(); i++) cout << a[i] << ' ';
#define PrintVl(a) for (int i = 0; i < a.size(); i++) cout << a[i] << endl;
#define PrintA(a, n) for (int i = 0; i < n; i++) cout << a[i] << ' ';
#define PrintAl(a, n) for (int i = 0; i < n; i++) cout << a[i] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

#define bend(a) a.begin(), a.end()
#define mset(a) memset(a, 0, sizeof(a));
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 2e5 + 5, mod = 1e9 + 7, inf = 1e9 + 7;


signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, x, y, ans = 0;
    cin >> n;
    int a[n], b[n];
    For(i, 0, n) cin >> a[i];
    For(i, 0, n) cin >> b[i];
    For(i, 0, n){
        if (b[i] < a[i]) ans += a[i] - b[i];
    }
    cout << ans;
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 256
/// Bismillah Hir Rahmanir Rahim

/**
    Practice like Cristiano Ronaldo
        Play Like Leo Messi..
**/

#include <bits/stdc++.h>

using namespace std;

#define PI                    acos(-1.0)
#define Pi                    3.141592653589793
#define ff                    first
#define ss                    second
#define pb                    push_back
#define space                 " "
#define all(x)                (x).begin(), (x).end()
#define clr(ar)               memset(ar, 0, sizeof(ar))
#define eprintf(...)          fprintf(stderr, __VA_ARGS__)

/*
template <class T> T gcd(T a,T b){ if(b == 0) return a; return gcd( b,a % b ); }
template <class T> T lcm(T a, T b ){ return ( a * b ) / gcd( a,b ); }
template<class T> string ToString(const T &x){ stringstream s; s << x; return s.str(); }
template<class T> int ToInteger(const T &x){ stringstream s; s << x; int r; s >> r; return r; }
*/

typedef  long long int            ll;
typedef  map<string,int>          msi;
typedef  map<int,int>	          mii;
typedef  map<char,int>            mci;
typedef  map<int,string>	      mis;
typedef  pair<int,int> 	          ii;
typedef  pair<string, int>        psi;
typedef  vector<int> 	          vi;
typedef  vector<string> 	      vs;
typedef  vector< ii >             vii;

template<class T1> void deb(T1 e1)
{
    cout << e1 << endl;
}
template<class T1,class T2> void deb(T1 e1, T2 e2)
{
    cout << e1 << space << e2 << endl;
}
template<class T1,class T2,class T3> void deb(T1 e1, T2 e2, T3 e3)
{
    cout << e1 << space << e2 << space << e3 << endl;
}

#define sf                    scanf
#define pf                    printf

#define sf1(a)                scanf("%d", &a)
#define sf2(a,b)              scanf("%d %d",&a, &b)
#define sf3(a,b,c)            scanf("%d %d %d", &a, &b, &c)
#define sf4(a,b,c,d)          scanf("%d %d %d %d", &a, &b, &c, &d)

#define sf1ll(a)              scanf("%I64d", &a)
#define sf2ll(a,b)            scanf("%I64d %I64d", &a, &b)
#define sf3ll(a,b,c)          scanf("%I64d %I64d %I64d", &a, &b, &c)
#define sf4ll(a,b,c,d)        scanf("%I64d %I64d %I64d %I64d", &a, &b, &c, &d)

#define READ                  freopen("in.txt", "r", stdin);
#define WRITE                 freopen("out.txt", "w", stdout);
/// The End.

void check_time()
{
#ifdef the_badcoder
    eprintf("%.5lf\n", (double)clock() / CLOCKS_PER_SEC);
#endif
}

const int res = 1e5 + 10;
const ll mod = 1e9 + 7;


int main()
{
    int n, sum = 0, maxi = -1;
    string s;

    cin >> s;

    if( s[0] == s[1] and s[1] == s[2] ) deb("Yes");
    else if( s[1] == s[2] and s[2] == s[3] ) deb("Yes");
    else deb("No");

    return 0;
}


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

long long dp[110][100010];
pair<int, int> p[110];

int main()
{
  long long n, w; cin >> n >> w;
  int total = 0;
  for (int i = 1; i <= n; i++)
  {
    int a, b; cin >> a >> b;
    p[i] = make_pair(a, b);
    total += b;
  }
  for (int i = 0; i <= n; i++)
  {
    for (int j = 0; j <= total; j++)
    {
      dp[i][j] = 1e18 + 7;
    }
  }
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++)
  {
    for (int j = 0; j <= total; j++)
    {
      if (j - p[i].second >= 0) dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - p[i].second] + p[i].first);
      else dp[i][j] = dp[i - 1][j];
    }
  }
  int ans = 0;
  for (int i = 0; i <= total; i++)
  {
    if (dp[n][i] <= w) ans = i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 80128
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int a[55]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}; 
int main(){
	int k;
	cin>>k;
	cout<<a[k-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#encoding=utf-8
 
import sys
num = []
ans = []
def prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1


for i in sys.stdin:
    inp = map(int , i.split())
    if prime(inp[0]):
        num.append(inp)
num.sort()

for i in xrange(1, len(num)):
    if num[i - 1] != num[i]:
        ans.append(num[i][0])
print len(ans) + 1

Measured memory_bytes: 6452
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
    ll N;
    cin >> N;
    ll length=1;
    ll sum = 26;
    vector<ll> each(101);
    each.at(0)=0;
    each.at(1)=26;
    while(N>sum){
        length++;
        ll a=pow(26,length);
        each.at(length)=a;
        sum += a;
    }
    N = N - (sum-each.at(length));
    vector<char> ans(101);
    for(ll i=length-2; i>=0; i--){
        ll c = (N-1)/each.at(i+1);
        N = N-c*each.at(i+1);
		ans.at(i)=char('a'+c);
    }
    ans.at(100)=char('a'+N-1);
    for(ll i=length-2; i>=0; i--){
        cout << ans.at(i);
    }
  	cout << ans.at(100);
    return 0;
}

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


int main() {
    int D;
    cin >> D;
    if (D == 25){
        cout << "Christmas" << endl;
    }
    else if (D == 24){
        cout << "Christmas Eve" << endl;
    }
    else if (D == 23){
        cout << "Christmas Eve Eve" << endl;
    }
    else if (D == 22){
        cout << "Christmas Eve Eve Eve" << endl;
    }
    return 0;
}


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

int main(){long long a,b,ma=999999999;cin>>a>>b;vector<long long> n(a);
           for(long long i=0;i<a;i++){
             cin>>n[i];
           }
           
           sort(n.begin(),n.end());
           
           for(long long i=0;i<a-b+1;i++){
                 if(n[i+b-1]-n[i]<ma){
               ma=n[i+b-1]-n[i];
             }
           }
           cout<<ma;
          }


Measured memory_bytes: 1024
def main():
    n, m = map(int, input().split())

    ab = [tuple(map(int, input().split())) for _ in range(n)]
    ab.sort()
    ans = 0

    for i, j in ab:
        if m < j:
            ans += i*m
            break
        m -= j
        ans += i*j
        

    print(ans)

main()

Measured memory_bytes: 16980
S = input()
N=len(S)

S2 = S[0]
count = 0
for i in range(1,N):
    S2 += S[i]
    while len(S2) > 1 and S2[len(S2)-1] != S2[len(S2)-2] :
        S2 = S2[:len(S2)-2]
        count += 2
        
print(count)

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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

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

const int maxN = 3e3 + 1;
const int maxM = 3e3 + 1;

int n, m;
char s[maxN], t[maxM];

int dp[maxN][maxM];

string res;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> (s + 1) >> (t + 1);
    n = strlen(s + 1);
    m = strlen(t + 1);
    memset(dp, 0, sizeof(dp));
    for1(i, n)
    {
        for1(j, m)
        {
            if (s[i] == t[j])
            {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
            else
            {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }
    int i = n, j = m;
    while (i && j)
    {
        if (s[i] == t[j])
        {
            res += s[i];
            --i;
            --j;
        }
        else if (dp[i - 1][j] > dp[i][j - 1])
        {
            --i;
        }
        else
        {
            --j;
        }
    }
    reverse(res.begin(), res.end());
    cout << res;
    return 0;
}


Measured memory_bytes: 35456
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>

#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define FOR(i, A, N) for(int (i) = (A); (i) < (N); (i)++)
#define REP(i, N) for(int (i) = 0; (i) < (N); (i)++)

using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

int n,m;
int A[111111];
int main() {
	scanf("%d", &n);
	REP(i, n) scanf("%d", A+i);
	sort(A, A+n);
	int found = 0;
	ll X, Y;
	for(int i = n-1; i > 0; i--) {
		if(A[i-1] == A[i]) {
			found += 2;
			if(found > 2)
				Y = A[i];
			else
				X = A[i];
			i--;
		}
		if(found == 4)
			break;
	}
	if(found == 4) {
		printf("%lld\n", X*Y);
	}
	else 
		printf("0");
	return 0;
}


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

int main() {
  int n,x,y=0;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++)
    cin>>a[i];
  for(int i=0;i<n;i++){
    x=a[i];
    for(int j=i+1;j<n;j++){
      if(a[j]==x)
        a[j]=0;
    }
    if(a[i]!=0)
      a[i]=1;
  }
  for(int i=0;i<n;i++)
    y+=a[i];
  cout<<y<<endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        HashSet<Integer> set = new HashSet<Integer>();
        int N = sc.nextInt();
        while(sc.hasNext()){
            set.add(sc.nextInt());
        }
        System.out.println(set.size());
    }
}

Measured memory_bytes: 21588
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

void pok() {
  cout << "Yes" << endl;
}
void png() {
  cout << "No" << endl;
}

void prime_factorization(int n, std::map<int,  int>& primes) {
  if (n % 2 == 0) {
    primes.insert(std::make_pair(2, 0));
    while (n % 2 == 0) {
      primes[2]++;
      n /= 2;
    }
  }

  int factor = 3;
  while(n > 1) {
    if (n % factor == 0)
      primes.insert(std::make_pair(factor, 0));

    while (n % factor == 0) {
      primes[factor]++;
      n /= factor;
    }
    factor += 2;
  }
}

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

  int cnt = 0;
  for (int a = 3; a <= n; a+=2) {
    std::map<int, int> primes;
    prime_factorization(a, primes);

    int yakusu  = 1;
    for (auto it : primes) {
      yakusu *= it.second + 1;
    }

    if (yakusu == 8) cnt++;
  }
  std::cout << cnt << std::endl;
}

Measured memory_bytes: 256
N=int(input())

#https://qiita.com/LorseKudos/items/9eb560494862c8b4eb56
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

count=0
for i in range(1, N+1):
  if i%2==1 and len(make_divisors(i))==8:
    count+=1
print(count)

Measured memory_bytes: 9128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int l[2222];

int main(void){
	int n,i,j,k;
	ll ans = 0ll;
	scanf("%d",&n);
	for(i=0; i<n; ++i){
		scanf("%d",&l[i]);
	}
	sort(l,l+n);
	for(i=0; i<n; ++i){
		for(j=0; j<i; ++j){
			for(k=0; k<j; ++k){
				if(l[i]<l[j]+l[k]){
					++ans;
				}
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int k;
  cin >> k;
  --k;
  vector<long long> a;
  string s;
  auto dfs = [&](auto&& self) -> void {
    if (not s.empty()) {
      a.push_back(stoll(s));
    }
    if (s.size() == 10) {
      return;
    }
    if (s.empty()) {
      for (char c = '1'; c <= '9'; ++c) {
        s += c;
        self(self);
        s.pop_back();
      }
    } else {
      for (char c = '0'; c <= '9'; ++c) {
        if (abs(c - s.back()) <= 1) {
          s += c;
          self(self);
          s.pop_back();
        }
      }
    }
  };
  dfs(dfs);
  sort(begin(a), end(a));
  cout << a[k] << '\n';
}


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

int main() {
    int N;
    cin >> N;
    string s = "No";
    for(int i = 0; 4*i <= N; i++) {
        int j = (N - 4*i) %  7;
        if(j == 0) {
            s = "Yes";
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 1;
		int min = sc.nextInt();
		for (int i = 1; i < n; i++) {
			int x = sc.nextInt();
			if (min >= x) {
				count++;
				min = x;
			}
		}
		sc.close();
		System.out.println(count);

	}
}


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

  int b[26]={};

int main(void)
{

    char s;
    while (scanf("%c", &s), s<='z' && s >= 'a'){
        if (b[s - 'a']){
            printf("no\n");
            return 0;
        }
        b[s - 'a'] = 1;
    }
    printf("yes\n");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <map>
#include <vector>
//#include <unordered_map>
//#include <unordered_set>
#include <stack>
#include <set>
#include <queue>
#include <list>

using namespace std;

int main()
{
    int n;
    cin>>n;
    double f=sqrt(n*2);
    int k=f;
    if(k*(k+1)>=2*n)
        cout<<k<<endl;
    else cout<<k+1<<endl;
    return 0;
}


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

void solve(long long N, std::vector<long long> a){
    sort(a.begin(), a.end(), greater<long long>());

    long long sumA = 0;
    long long sumB = 0;
    REP(i, a.size()) {
        if (i % 2) sumB += a[i];
        else sumA += a[i];
    }

    cout << sumA - sumB << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

using P = pair<int, int>;
int n, m;
vector<P> ps[155];
int dp[155][80][1010];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    while (cin >> n >> m, n) {
        REP (i, 155) ps[i].clear();
        REP (i, n) {
            int k;
            cin >> k;
            REP(j, k) {
                int x, d;
                cin >> x >> d;
                x--;
                ps[i + 1].emplace_back(x, d);
            }
        }
        REP(i, 1010) ps[0].emplace_back(i, 0);
        REP(i, 1010) ps[n + 1].emplace_back(i, 0);
        const int INF = 1LL << 60;
        fill_n((int*)dp, 155 * 80 * 1010, INF);
        REP (i, 1010) dp[0][0][i] = 0;
        REP (i, n + 1) REP (j, m + 1) {
            for (P p1 : ps[i]) {
                if (dp[i][j][p1.first] == INF) continue;
                if (i + 1 <= n + 1) {
                    for (P p2 : ps[i + 1]) {
                        dp[i + 1][j][p2.first] = min(dp[i + 1][j][p2.first], dp[i][j][p1.first] + (p1.second + p2.second) * abs(p1.first - p2.first));
                    }
                }
                if (i + 2 <= n + 1 && j + 1 <= m) {
                    for (P p2 : ps[i + 2]) {
                        dp[i + 2][j + 1][p2.first] = min(dp[i + 2][j + 1][p2.first], dp[i][j][p1.first] + (p1.second + p2.second) * abs(p1.first - p2.first));
                    }
                }
            }
        }
        int ans = INF;
        REP (i, m + 1) REP (j, 1010) ans = min(ans, dp[n + 1][i][j]);
        cout << ans << endl;
    }
}


Measured memory_bytes: 101156
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define sll            set<ll int>
#define msll        multiset<ll int>
#define io    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,h[100005];
ll dp[100005];
ll go(ll i){
    if(i==n-1) return 0;
    ll ans=1e17;
    if(dp[i]!=-1) return dp[i];
    for(ll j=i+1;j<=i+2 and j<n;j++) ans=min(ans,go(j)+abs(h[i]-h[j]));
    return dp[i]=ans;
}

int main()
{
    io
    ll i,j;
    memset(dp,-1,sizeof dp);
    cin>>n;
    for(i=0;i<n;i++) cin>>h[i];
    cout<<go(0);

    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include<stdio.h>
using namespace std;
int main() {
    int cnt=0,maxl=0;
    string s;
    cin>>s;
    for(char c:s)
        if(c=='R') cnt++;
        else
        {
            maxl=max(maxl,cnt);
            cnt=0;
        }
    cout<<max(maxl,cnt)<<endl;
}


Measured memory_bytes: 3620
n=input()
if int(n[0])>int(n[1]):
  out=int(n[0])
elif int(n[0])==int(n[1]):
  if int(n[1])>=int(n[2]):
    out=int(n[0])
  else:
    out=int(n[0])+1
else:
    out=int(n[0])+1
print(str(out)*3)

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

int main(){
	//freopen("i.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	int p = 0;
	for(int i = 0;i < n;i++){
		int x; cin >> x;
		p *= 10;
		p += x;
	}
	int q = 0;
	for(int i = 0;i < n;i++){
		int x; cin >> x;
		q *= 10;
		q += x;
	}
	
	int x, y;
	int cnt = 0;
	string s; for(char i = '1';i < '1'+n;i++) s += i;
	do{
		int ss = stoi(s);
		if(ss == p) x = cnt;
		if(ss == q) y = cnt;
		cnt++;
	}while(next_permutation(s.begin(),s.end()));
	cout << abs(x-y) << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    char b;
    cin >> b;
    if (b == 'A') cout << 'T' << endl;
    else if (b == 'C') cout << 'G' << endl;
    else if (b == 'G') cout << 'C' << endl;
    else if (b == 'T') cout << 'A' << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
const ll MOD=1e9+7;
int n, q;
string s, t, d;
bool check(int p, int i){
	for(int j=0; j<q; j++){
		if(s[i]==t[j]){
			if(d[j]=='L') i--;
			else i++;
		}
		if(i<0){
			if(p==0) return false;
			else return true;
		}
		if(i>=n){
			if(p==1) return false;
			else return true;
		}
	}
	return true;
}
int main()
{
    cin>>n>>q;
	cin>>s;
	for(int i=0; i<q; i++){
		char t0, d0; cin>>t0>>d0;
		t+=t0, d+=d0;
	}
	int l1=0, l2=n;
	while(l1!=l2){
		int l=(l1+l2)/2;
		if(check(0, l)) l2=l;
		else l1=l+1;
	}
	int r1=-1, r2=n-1;
	while(r1!=r2){
		int r=(r1+r2+1)/2;
		if(check(1, r)) r1=r;
		else r2=r-1;
	}
	cout<<max(0, r1-l1+1)<<endl;
    return 0;
}

Measured memory_bytes: 1068