akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<double,double> point;
const ll MAX = 30000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k;
    cin >> k;
    ll s = 7%k;
    rep(i,k+1){
        if (s == 0){
            PRINT(i+1);
            return 0;
        }
        s = (s*10+7)%k;
    }
    PRINT(-1);
}


Measured memory_bytes: 3644
#include <iostream>
#include <deque>

using namespace std;

deque<int> linize(const string &s)
{
    deque<int> line;
    char prev = s[0];
    int count = 0;
    for (auto c: s)
    {
        if (c != prev)
        {
            line.push_back(count);
            count = 0;
        }

        count++;
        prev = c;
    }

    line.push_back(count);
    return line;
}

int main()
{
    int n, k;
    string str;

    cin >> n >> k;
    cin >> str;

    auto line = linize(str);
    
    int s = 0;
    for (auto e: line)
    {
        s += e;
    }
    int happiness = s - line.size();

    int size = line.size();
    for (;k > 0; k--)
    {
        if (size >= 3)
        {
            happiness += 2;
            size -= 2;
        }
        else if (size > 1)
        {
            happiness += 1;
            size -= 1;
        }
    }
    
    cout << happiness << endl;
    return 0;
}


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

int main() {
  int a,b,k;
  cin >> a >> b >> k;
  int r;
  for(int i=b;i>0;i--){
       if(a%i==0 && b%i==0){
	        k--;
			if(k==0) r=i;
	   }
  }
  cout << r << endl;
}


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

using namespace std;

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

  int n, m, a, b;
  cin >> n >> m >> a >> b;

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cout << ((i <= b) ^ (j <= a));
    }
    cout << "\n";
  }

  return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main()
{
    int n;
    cin >> n;
    set<int> dou;
    vector<int> can;
    int a;
    rep(i, n)
    {
        cin >> a;
        if (dou.find(a) != dou.end())
        {
            can.push_back(a);
            dou.erase(dou.find(a));
        }
        else
        {
            dou.insert(a);
        }
    }

    if (can.size() < 2)
    {
        cout << 0 << endl;
    }
    else
    {
        sort(can.begin(), can.end());
        cout << (long long)(can[can.size() - 1]) * can[can.size() - 2] << endl;
    }
    return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<string>
using namespace std;
int main(){
	int solved[50];
	int time[50][10];
	int team[50];
	int m,t,p,r;
	while(true){
	cin>>m>>t>>p>>r;
	if(m==0&&t==0&&p==0&&r==0)
		break;
	for(int i=0;i<t;i++){
		solved[i]=0;
		for(int j=0;j<p;j++)
			time[i][j]=0;
		team[i]=i+1;
	}
	for(int i=0;i<r;i++){
		int a[4];
		for(int j=0;j<4;j++)
			cin>>a[j];
		if(a[3]==0)
			solved[a[1]-1]+=50000-time[a[1]-1][a[2]-1]-a[0];
		else
			time[a[1]-1][a[2]-1]+=20;
	}
	for(int i=0;i<t-1;i++){
		for(int j=t-1;j>i;j--){
			if(solved[j]>solved[j-1]||(solved[j]==solved[j-1]&&team[j]>team[j-1])){
				int tmp=solved[j];
				solved[j]=solved[j-1];
				solved[j-1]=tmp;
				tmp=team[j];
				team[j]=team[j-1];
				team[j-1]=tmp;
			}
		}
	}
	cout<<team[0];
	for(int i=1;i<t;i++){
		if(solved[i]==solved[i-1])
			cout<<"=";
		else
			cout<<",";
		cout<<team[i];
	}
	cout<<endl;
	}
	return 0;
}

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

using namespace std;

#define ll long long
#define endl '\n'

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m, sum = 0, cnt = 0;
    cin >> n >> m;
    int v[n];
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        sum += v[i];
    }
    for (int i = 0; i < n; ++i) {
        if (v[i] * m * 4 >= sum) {
            cnt++;
            if (cnt == m) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

using namespace std;

const long long num[8][3] = {{1,1,1},{1,1,-1},{1,-1,1},{1,-1,-1},{-1,1,1},{-1,1,-1},{-1,-1,1},{-1,-1,-1}};

class cake{
private:
	long long x,y,z;
public:
	int i;
	long long X(){
		return x * num[i][0];
	}
	long long Y(){
		return y * num[i][1];
	}
	long long Z(){
		return z * num[i][2];
	}
	long long sum(){
		long long sum = x * num[i][0]+y * num[i][1]+z * num[i][2];
		return sum;
	}
	cake(){
	}
	cake(long long x,long long y,long long z){
		this->x = x;
		this->y = y;
		this->z = z;
	}
};


bool cmp(cake a,cake b){
	return (a.sum() > b.sum());
}

int main(){
	int n,m;
	cin >> n >> m;
	vector<cake> c;
	for(int i = 0;i < n;i++){
		long long x,y,z;
		cin >> x >> y >> z;
		c.push_back(*(new cake(x,y,z)));
	}
	long long ans = 0;
	for(int i = 0;i < 8;i++){
		for(int j = 0;j < n;j++){
			c[j].i = i;
		}
		sort(c.begin(),c.end(),cmp);
		long long sum = 0;
		for(int k = 0;k < m;k++){
			sum += c[k].sum(); 
		}
		ans = max(sum,ans);
	}
	cout << ans << endl;
	return 0;
}

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

unsigned euclidean_gcd(unsigned a, unsigned b)
{
    if (a < b)
        return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

int main()
{
    long long a, b;
    cin >> a >> b;
    long c = a * b;
    long d = euclidean_gcd(a, b);
    cout << c / d << endl;
    return 0;
}

Measured memory_bytes: 256
#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()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,t,m,n,a)vector<vector<t> > name(m,vector<t> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
int main(){
  int n;
  std::cin >> n;
  std::vector<double>x(n),y(x) ;
  rep(i,n)std::cin >> x[i]>>y[i];
  std::vector<int> a;
  rep(i,n)a.pb(i);
  int kazu=1;
  rep(i,n)kazu*=(i+1);
  double kyo=0;
  do {
    rep(i,n-1){
      kyo+=sqrt((x[a[i+1]]-x[a[i]])*(x[a[i+1]]-x[a[i]])+(y[a[i+1]]-y[a[i]])*(y[a[i+1]]-y[a[i]]));
    }
  } while (std::next_permutation(a.begin(), a.end()));
  kyo/=kazu;
  std::cout << keta(8)<<kyo << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for (int(i) = (int)(a); (i) < (int)(b); ++(i))
#define rFor(i, a, b) for (int(i) = (int)(a)-1; (i) >= (int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T div_floor(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a >= 0 ? a / b : (a + 1) / b - 1;
}
template <class T>
T div_ceil(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a > 0 ? (a - 1) / b + 1 : a / b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    int ans = mod;
    for (int i = 0; i + m <= n; ++i) {
        int tmp = 0;
        rep(j, m) tmp += (t[j] != s[i + j]);
        chmin(ans, tmp);
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (auto i=(a); i<(b); ++i)
#define iter(it,c) for (auto it = (c).begin(); it != (c).end(); ++it)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long long ll;
const int INF = 2147483647;

int arr[110];

int main() {
    int n;
    cin >> n;
    rep(i,0,n) {
        cin >> arr[i];
    }

    int at = -1;
    ll l = 0, r = 0;
    rep(i,0,n) r += arr[i];

    ll mn = INF;
    for (int t = 0; t < n; t++) {
        mn = min(mn, abs(l-r));

        // cout << t << " " << l << " " << r << endl;

        if (at+1 < n) {
            l += arr[t];
            r -= arr[t];
        }
    }
    cout << mn << endl;

    return 0;
}



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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<ll, ll>;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
struct edge {
  ll to, cost;
};

int main() {
  int N; cin >> N;
  string ans = "No"; int cnt = 0;
  REP(i, N) {
    int a, b; cin >> a >> b;
    if(a  == b) {
      cnt++;
    } else {
      cnt = 0;
    }
    if(cnt == 3) ans = "Yes";
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
string s1,s2;
int main(){
	cin>>s1;//getline(cin,s1);
	s2=s1;
	reverse(s2.begin(),s2.end());
	for(int i=0;i<s2.size();++i)
		s2[i]=='b'?s2[i]='d':s2[i]=='d'?s2[i]='b':s2[i]=='p'?s2[i]='q':s2[i]='p';
	if(s1==s2)	puts("Yes");
	else	puts("No");
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char first = s.charAt(0);
        char last = s.charAt(s.length() - 1);
        System.out.println(String.valueOf(first) + (s.length() - 2) +String.valueOf( last));

    }

}

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

int main() {
  int a, b;
  cin >> a >> b;
  int diff = (a+b) % 2;
  int avg = (a+b) / 2;
  
  if(diff > 0) {
    cout << avg + 1 << endl;
  } else {
    cout << avg << endl;  
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int N; cin >> N;
    vector<ll> D(N); rep(i,N) cin >> D[i];
    map<ll,ll> mp;
    rep(i,N){
        mp[D[i]]++;
    }

    int M; cin >> M;
    rep(i,M){
        ll t; cin >> t;
        if(mp[t]>0){
            mp[t]--;
        }else{
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 14336
n = int(input())
ans = 0
a = [int(i) for i in input().split()]

flag = True
while flag:
    flag = False
    for j in range(n - 1, 0, -1):
        if a[j] < a[j - 1]:
            a[j], a[j - 1] = a[j - 1], a[j]
            flag = True
            ans += 1
for i in range(n):
    if i:
        print(" ", end = "")
    print(a[i], end = "")
print()
print(ans)


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

typedef long long ll;


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

    vector<vector<int>> vec(M);
    int p[M];

    rep(i,M){
      int k;
      cin>>k;

      rep(j,k){
        int s;
        cin>>s;
        vec[i].push_back(s);
      }
    }
    rep(i,M) cin>>p[i];

    ll ans =0;

    for(ll bit=0; bit<(1<<N); bit++){
      bool flg = true;
      rep(i,M){
        int counter = 0;
        for(auto e: vec[i]){
          if(bit & (1<<(e-1))){
            counter++;
          }
        }
        if(counter %2 != p[i]) flg = false;
      }
      if(flg) ans++;
    }
    cout<<ans;
}


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

int main() {
  int N; cin >> N;
  double sum;
  vector<double> x(N);
  vector<string> u(N);

  for(int i=0; i<N; i++) {
    cin >> x.at(i) >> u.at(i);
    if(u.at(i)=="JPY") sum +=x.at(i);
    else sum+= x.at(i)*380000.0;
  }
  cout << fixed << setprecision(4) << sum << endl;
}

Measured memory_bytes: 3688
#include <iostream>

using namespace std;

struct Node {
    int key;
    Node *left;
    Node *right;
};

Node *root, *NIL;

Node* newNode(int key) {
    Node *node = new Node();
    node->key = key;
    node->left = NIL;
    node->right = NIL;
    return node;
}

void insert(int key) {
    Node *x = root, *y = NIL;
    while (x != NIL) {
        y = x;
        if (key < x->key)
            x = x->left;
        else
            x = x->right;
    }
    Node *z = newNode(key);
    if (y == NIL)
        root = z;
    else if (key < y->key)
        y->left = z;
    else
        y->right = z;
}

bool find(int key) {
    Node *x = root;
    while (x != NIL) {
        if (key == x->key)
            return true;
        else if (key < x->key)
            x = x->left;
        else
            x = x->right;
    }
    return false;
}

void inorder(Node *t) {
    if (t == NIL)
        return;
    inorder(t->left);
    cout << " " << t->key;
    inorder(t->right);
}

void preorder(Node *t) {
    if (t == NIL)
        return;
    cout << " " << t->key;
    preorder(t->left);
    preorder(t->right);
}

int main() {
    int n, v;
    string s;
    root = NIL;
    cin >> n;
    while (n--) {
        cin >> s;
        if (s == "insert") {
            cin >> v;
            insert(v);
        }
        if (s == "find") {
            cin >> v;
            if (find(v))
                cout << "yes" << endl;
            else
                cout << "no" << endl;
        }
        if (s == "print") {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 15520
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll multbig(ll a,ll b,ll mod){
    if(a==0 or b==0) return 0;
    if(a==1 or b==1) return (a*b)%mod;
    ll cur=multbig(a,b/2,mod);
    cur=(2*cur)%mod;
    if(b%2) cur=(cur+a)%mod;
    return cur;
}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
void solve(){
	string s;
	cin>>s;int f =0;
	rep(i,1,sz(s)) if(s[i]!='9') {f=1;break;}
	int mul = sz(s)-1;
	int ans = 9*mul;
	if(s[0] != 1) ans+= s[0] -'0'-1;
	if(!f)cout<<ans+1<<endl;
	else cout<<ans<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
  t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n,ans=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%2==0)
            if(a[i]%3!=0&&a[i]%5!=0)
                ans=1;
    }
    if(ans==0)
        cout<<"APPROVED\n";
    else
        cout<<"DENIED\n"; 
}

Measured memory_bytes: 256
N = int(input())
L = [0 for i in range(5)]
for i in range(5):
    L[i] = int(input())
    
time = [0 for i in range(5)]
time[0] = (N-1)//L[0] + 1
for i in range(4):
    if L[i] <= L[i+1]:
        time[i+1] = time[i]
    else:
        time[i+1] = (N-1)//L[i+1] + 1
        
ans = max(time) + 4
        
print(ans)

Measured memory_bytes: 3188
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])
ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 47600
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
namespace io{
    #define ll long long
    #define inf 0x3f3f3f3f
    #define il inline 
    #define in1(a) read(a)
    #define in2(a,b) in1(a),in1(b)
    #define in3(a,b,c) in2(a,b),in1(c)
    #define in4(a,b,c,d) in2(a,b),in2(c,d)
    il void readl(ll &x){
        x=0;ll f=1;char c=getchar();
        while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
        x*=f;
    }
    il void read(int &x){
        x=0;int f=1;char c=getchar();
        while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
        x*=f;
    }
}using namespace io;
char s[5];
int main(){
	int n;
	long double x,sum=0;
	read(n);
	for(int i=1;i<=n;i++){
		scanf("%Lf %s",&x,s);
		if(s[0]=='J') sum+=x;
		else sum+=x*380000.0;
	}
	printf("%Lf",sum);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
using namespace std;
using ll = long long;
int main() {
	int N; cin >> N;
	int T[105];
	for (int i = 0; i < N; i++)
		cin >> T[i];
	int total = 0;
	for (int i = 0; i < N; i++)
		total += T[i];
	int M; cin >> M;
	int P[105];
	int X[105];
	for (int i = 0; i < M; i++)
		cin >> P[i] >> X[i];
	for (int i = 0; i < M; i++) {
		int time = total - T[P[i]-1] + X[i];
		cout << time << endl;
	}
	//system("pause");
	return 0;
}


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

clist=[]
tlist=[]
for i in range(N):
    c,t = map(int, input().split())
    clist.append(c)
    tlist.append(t)

valid_costs=[]
for path in range(N):
    if tlist[path] <= T:
        valid_costs.append(clist[path])
if valid_costs == []:
    print('TLE')
else:
    cheapest = valid_costs[0]
    for i in valid_costs:
        if i < cheapest:
            cheapest = i
    print(cheapest)

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

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

fn main() {
  let x = read::<u8>();
  let a = read::<u8>();

  match x < a {
    true => println!("0"),
    false => println!("10"),
  }
}


Measured memory_bytes: 4352
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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 main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> L(N),R(N);
    rep(i,N) cin >> L[i] >> R[i];

    int k = min_element(all(R)) - R.begin();
    set<pii> left,right;
    rep(i,N) {
        if (i == k) continue;
        left.emplace(L[i],i);
        right.emplace(R[i],i);
    }
    int l = L[k], r = R[k];
    int ans = r - l + max(-1,right.begin()->first - left.rbegin()->first) + 2;
    int maxl = 0;
    while (left.size() > 1) {
        int val,num;
        tie(val,num) = *left.begin();
        left.erase(left.begin());
        right.erase({R[num],num});
        chmax(l,val);
        chmax(ans,max(-1,r-l) + max(-1,right.begin()->first - left.rbegin()->first) + 2);
        chmax(maxl,R[num]-L[num]);
    }
    chmax(l,left.begin()->first);
    chmax(ans,max(-1,r-l) + maxl + 2);

    cout << ans << endl;
}


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

int main() {
  
  long long N;
  cin >> N;
  
  long long sum=0;
  
  for(int i=1;i<=N;i++){
    if(i%3!=0 && i%5!=0) sum += i;
  }
  
  cout << sum << endl;
    
  
}


Measured memory_bytes: 3652
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>

int readint()
{
	char c;
	while(c=getchar(),(c<'0'||c>'9')&&c!='-');
	bool flag=(c=='-');
	if(flag)c=getchar();
	int x=0;
	while(c>='0'&&c<='9')
	{
		x=x*10+c-48;
		c=getchar();
	}
	return flag?-x:x;
}

//ans[k]=C[n+1][k]-C[x+y][k-1]
//C[a][b]=a!*(b!^-1)*((a-b)!^-1)

const int maxn=100005;
const int mod=1e9+7;
int n;
int a[maxn],ans[maxn],inverse[maxn],fac_pos[maxn],fac_neg[maxn],cnt[maxn],v[maxn];
int x=-1,y=-1,special;

int get_inverse(int x){
	int power=mod-2,res=1;
	while(power){
		if(power&1)res=(ll)res*(ll)x%mod;
		x=(ll)x*(ll)x%mod;
		power>>=1;
	}
	return res;
}

void factorial(int fac[],int val[],int n){
	fac[0]=1;
	REP(i,n)fac[i]=(ll)fac[i-1]*(ll)val[i]%mod;
}

int main(){
	scanf("%d",&n);
	rep(i,n+1){
		scanf("%d",&a[i]);
		cnt[a[i]]++;
		if(cnt[a[i]]==2)special=a[i];
		v[i+1]=i+1;
	} 
	rep(i,n+1)if(a[i]==special){
		if(x==-1)x=i;
		else y=n-i; 
	} 
	REP(i,n+1)inverse[i]=get_inverse(i);
	REP(i,n+1)if((ll)inverse[i]*(ll)i%mod!=1)cout<<"wrong!";
	factorial(fac_neg,inverse,n+1);
	factorial(fac_pos,v,n+1);
//	cout<<6*fac_neg[2]%mod*fac_neg[1]%mod<<endl;
	REP(i,n+1){
		ans[i]=(ll)fac_pos[n+1]*(ll)fac_neg[i]%mod*(ll)fac_neg[n+1-i]%mod;
		if(x+y>=i-1)
		ans[i]=(ans[i]-(ll)fac_pos[x+y]*(ll)fac_neg[i-1]%mod*(ll)fac_neg[x+y-i+1]%mod+mod)%mod;
		printf("%d\n",ans[i]);
	}
	return 0;
}


Measured memory_bytes: 3968
public class Main {
	public static void main(String[] args) {
		java.util.Scanner s = new java.util.Scanner(System.in);
		int n = s.nextInt();
		int d = s.nextInt();
		int cal = n/(2*d+1)+(n%(2*d+1)==0?0:1);
		System.out.println(cal);

	}
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll K, A, B; cin >> K >> A >> B;
    string ans = "NG";
    for (ll i = A; i <= B; ++i) {
        if(i%K==0) ans = "OK";
    }
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 3628
#include <cstdio>
#include <string>
#include <iostream>

using namespace std;

signed main()
{
    int num, a = 0, b = 0, ab = 0, o = 0;
    string type;
    while( cin >> num >> type )
    {
        if( type == ",A" )
        {
            a++;
        }
        if( type == ",B" )
        {
            b++;
        }
        if( type == ",AB" )
        {
            ab++;
        }
        if( type == ",O" )
        {
            o++;
        }
    }
    printf( "%d\n%d\n%d\n%d\n", a, b, ab, o );
    return 0;
}


Measured memory_bytes: 3208
#include <cstdio>

int main(int argc, char const *argv[]) {
  int N;
  scanf("%d", &N);
  int a[N];
  int sum = 0;
  for (int i = 0; i < N; i++) {
    scanf("%d", &a[i]);
    sum += a[i];
  }
  float y = (float)sum / N;
  sum /= N;
  int r = 0;
  if (y - sum <= 0.5) {
    for (int i = 0; i < N; i++) {
      r += (a[i] - sum)*(a[i] - sum);
    }
  } else {
    sum += 1;
    for (int i = 0; i < N; i++) {
      r += (a[i] - sum)*(a[i] - sum);
    }
  }
  printf("%d\n", r);
  return 0;
}


Measured memory_bytes: 128
s = int(input())
def f(n):
    if n%2 == 0:
        return n // 2
    else:
        return 3*n + 1
    
ans = 1
used = set()
while True:
    if s in used:
        break
    used.add(s)
    ans += 1
    s = f(s)
    
print(ans)

Measured memory_bytes: 3060
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var abhm = lines[0].split(' ');
 var a = Number(abhm[0]);
 var b = Number(abhm[1]);
 var h = Number(abhm[2]);
 var m = Number(abhm[3]);

 var hkaku = h * 30 + m * 0.5;
 var mkaku = m * 6;
 var kaku = Math.abs(hkaku-mkaku);
 var kaku2 = 360 - Math.abs(hkaku-mkaku);
 kaku = Math.min(kaku2,kaku);
 kaku = Math.cos(kaku*(Math.PI/180));

 var ans = (a*a) + (b*b) - (2*a*b*kaku);
 console.log(Math.sqrt(ans));
});

Measured memory_bytes: 30560
import sys
input = sys.stdin.readline
def solve():
  n = int(input())
  p = list(int(i) for i in input().split())
  now = n+1
  times = 0
  for i in range(n):
    value = p[i]
    if now >= value:
      times += 1
    now = min(value,now)
  print(times)
    
solve()

Measured memory_bytes: 70480
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define LLINF 1<<63-1
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define MOD 1000000007
void swap(int* x,int* y){
  int tmp=*x;*x=*y;*y=tmp;
}

int main(){
  int N,K,i,k=0,ans=0;
  scanf("%d%d",&N,&K);
  char S[N+1];
  int A[N],B[N];
  scanf("%s",S);
  if(S[0]=='0'){A[0]=0;B[0]=0;k=1;}
  for(i=k;i<N;i++){
    if(S[i]=='1'){
      A[k]=i;
      while(S[i]=='1')if(S[++i]!='1')B[k++]=i-1;
    }
    if(i==N-1&&S[i]=='0'){A[k]=i;B[k++]=i;}
  }
  if(k<=K)ans=N;
  else for(i=0;i<k-K;i++)if(ans<B[i+K]-A[i]+1)ans=B[i+K]-A[i]+1;

  printf("%d\n",ans);
  return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<int> d(n);
	rep(i, n) cin >> d.at(i);

	int sum = 0;
	for(int i = 0; i < n-1; i++){
		for(int j = i+1; j < n; j++){
			sum += d.at(i)*d.at(j);
		}
	}
	
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main()
{
	char a,b,c;
	scanf("%c %c", &a, &b);
	if(a=='H'){
		printf("%c", b);
	}	
	if(a=='D'){
		if(b=='H'){
			printf("D");
		}
		else {
			printf("H");
		}
	}
	
	
	
}



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

unsigned euclidean_gcd(unsigned , unsigned );
int main()
{
    long n, x,tmp=0;
    cin >> n >> x;
    vector<long> a(n);
    vector<long> t(n);
    vector<long> u(n);
    for (long i = 0; i < n;i++){
        cin >> a.at(i);
        t.at(i) = abs(a.at(i) - x);
    }

    if(n==1){
        cout << t.at(0) << endl;
        return 0;
    }
    else{
        tmp = t.at(0);
        for (long i = 1; i < n; i++)
        {
            tmp = euclidean_gcd(tmp, t.at(i));

        }
    }
    cout << tmp << endl;
}

unsigned euclidean_gcd(unsigned a, unsigned b)
{
    if (a < b)
        return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

Measured memory_bytes: 2560
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInt2() (int, int) {
	return nextInt(), nextInt()
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func f(n int) int {
	switch n % 4 {
	case 0:
		return n
	case 1:
		return 1
	case 2:
		return 1 ^ n
	}
	return 0
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	a, b := nextInt2()

	var ans int
	if a == 0 {
		ans = f(b)
	} else {
		ans = f(b) ^ f(a-1)
	}

	puts(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define D(a) cout<<#a<<": ";for(auto i:a)cout<<i<<' ';cout<<endl;
using namespace std;
int f(int a)
{
    int ans = 0;
    while (a) ans += a % 10, a /= 10;
    return ans;
}
int main()
{
    int N; cin >> N;
    int ans = numeric_limits<int>::max();
    for (int A = 1; A <= N / 2; A++) {
        int B = N - A;
        ans = min(ans, f(A) + f(B));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>

void printRect(int w, int h) {
    for (int y=0; y<h; y++) {
        
        for (int x=0; x<w; x++) {
            if((x+y)%2==0) printf("#");
            else printf(".");
        }
        printf("\n");
    }
    printf("\n") ;
}

int main(int argc, const char * argv[]) {
    
    while (1) {
        int h, w;
        std::cin >> h >> w ;
        if(h==0&&w==0) break ;
        printRect(w, h);
    }
    
    return 0 ;
}


Measured memory_bytes: 3088
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

string s;

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  int n;
  cin >> n;
  int ans = 0;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      for(int k=1;k<=n;k++){
        int gc = __gcd(i,j);
        gc = __gcd(gc,k);
        ans+=gc;
      }
    }
  }
  cout << ans << endl;


return 0;
}
///....


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, M, K;
    cin >> N >> M >> K;
    repi(i, N) {
        repi(j, M) {
            ll temp = i * (M - j) + j * (N - i);
            if(temp == K) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void solve() {
    LL n,d;
    cin >> n >> d;
    LL x,y;
    int cnt = 0;
    REP(i,0,n) {
        cin >> x >> y;
        if (x * x + y * y <= d * d) ++cnt;
    }
    cout << cnt << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 3632
ans = N = int(input())
for i in range(N+1):
  a_,n6,n9 = 0,i,N-i
  while (n6>0): a_ += n6%6; n6 = n6//6
  while (n9>0): a_ += n9%9; n9 = n9//9
  ans = min(ans, a_)
print(ans)


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

using namespace std;

int binarySearch(vector<int>& A, int N, int key) {
  int left = 0;
  int right = N;
  int mid;

  while (left < right) {
    mid = (left + right) / 2;
    if (key == A[mid]) {
      return 1;
    } else if (key > A[mid]) {
      left = mid + 1;
    } else if (key < A[mid]) {
      right = mid;
    }
  }
  return 0;
}

int main() {
  vector<int> A;
  A.reserve(100000);

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

  int M;
  int key;
  int sum = 0;

  cin >> M;
  for (int i = 0; i < M; i++) {
    cin >> key;
    if(binarySearch(A, N, key)) {
      sum++;
    }
  }
  cout<< sum << endl;

  return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
  int n ;
  cin >> n ;
  vector<int> A(n) ;
  rep(i,n) cin >> A[i] ;
  int ans=0 ;
  int k= 1 ;
  rep(i,n){
    ans+=(A[i]*k) ;
    k*= -1 ;
   }
  cout << ans<<endl ;
  rep(i,n-1){
    ans = -ans+2*A[i] ;
    cout<< ans << endl ;
  }
  
   return 0;
}

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();

        System.out.println(solve(A, B, C, X, Y));

        sc.close();
    }

    static int solve(int A, int B, int C, int X, int Y) {
        return Math.min(A + B, C * 2) * Math.min(X, Y) + Math.min(A, C * 2) * Math.max(0, X - Math.min(X, Y))
                + Math.min(B, C * 2) * Math.max(0, Y - Math.min(X, Y));
    }
}

Measured memory_bytes: 23764
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef vector<long long int> VLLI;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

int main() {
    int n;
    cin >> n;
    vector<long long int> a(n); 
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    ll prefix = 0;
    ll ans = LLONG_MAX;
    for (int i = 0; i < n; i++) {
        ans = min(ans, abs(sum - 2*prefix));
        prefix += a[i];
    }
    cout << ans << "\n";
}



Measured memory_bytes: 1792
while 1:
	s = raw_input()
	if s == "#":
		break
	length = len(s)
	l = list()
	num = -1
	i = 0
	while i < length :
		if s[i:i+4] == "west":
			l.append("w")
			i += 4
		else:
			l.append("n")
			i += 5
		num += 1
	l = l[::-1]
	direction = 90 * (2**num) if l[0] == "w" else 0
	for i in range(1,num+1):
		if l[i] == "w":
			direction += 90 * 2**(num-i)
		else :
			direction -= 90 * 2**(num-i)
	while num > 0 and direction % 2 == 0:
		direction /= 2
		num -= 1
	print direction if num == 0 else str(direction)+"/"+str(2**num)
			

Measured memory_bytes: 4252
package main
import "fmt"
func main() {
  var a,b,c int
  fmt.Scan(&a,&b,&c)
  if a%2 == 1 || b%2 == 1 || c%2 == 1 {
    fmt.Println(0)
  } else {
    a,b,c = abs(a-b),abs(b-c),abs(c-a)
    fmt.Println(min(ord(a),ord(b),ord(c)))
  }
}
func abs(n int) int {
  if n < 0 { return -n }
  return n
}
func min(n... int) int {
  var m int = n[0]
  for i:=1;i<len(n);i++ {
    if m < n[i] { m = n[i] }
  }
  if m < 0 { return -1 }
  for i:=0;i<len(n);i++ {
    if m > n[i] && n[i] > 0 { m = n[i] }
  }
  return m
}
func ord(n int) int {
  if n == 0 { return -1 }
  var k int = 0
  for {
    if n%2 != 0 { break }
    n = n/2
    k++
  }
  return k
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main() {
	int n;
	string str;
	cin >> n;
	cin >> str;
	int leng = 1;
	char old_char = str[0];
	REP(i, n-1) {
		if (old_char != str[i + 1]) {
			leng++;
		}
		old_char = str[i + 1];
	}
	cout << leng << endl;
	return 0;
}


Measured memory_bytes: 512
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  s=S()
  k=I()

  l=[]
  for i in range(len(s)):
    for j in range(1,6):
      l.append(s[i:i+j])

  l=list(set(l))
  l.sort()

  return l[k-1]

print(main())


Measured memory_bytes: 7340
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

int main()
{
	ll k; cin >> k;
	string ans = "";
	rep(i, k) {
		ans += "ACL";
	}
	cout << ans << endl;
	//cout << fixed << setprecision(10) << ans << endl;
	system("pause");
}


Measured memory_bytes: 3644
n,m = map(int,input().split())
xyl = [list(map(int,input().split())) for nesya in range(m)]
red = [0]*n
ball = [1]*n
red[0] = 1
for xy in xyl:
  x = xy[0]-1
  y = xy[1]-1
  if red[x] > 0:
    red[y] = 1
    if ball[x] == 1:
      red[x] = 0
  ball[x] -= 1
  ball[y] += 1
print(sum(red))

Measured memory_bytes: 28964
N, T = [int(elem) for elem in input().split()]
min_cost = None
min_cost_time = None
for i in range(0, N):
  c, t = [int(elem) for elem in input().split()]
  if t <= T:
    if min_cost is None:
      min_cost = c
      min_cost_time = t
    else:
      if c < min_cost:
        min_cost = c
        min_cost_time = t
if min_cost is None:
  print('TLE')
else:
  print(min_cost)

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

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define endl "\n"
#define pb push_back
#define ll long long

int main()
{
	
	IOS;

	ll i,n;
	cin>>n;

	vector<ll> a(n);

	for(i=0;i<n;i++)
		cin>>a[i];

	ll cnt = 0;
	ll ans = 0;

	for(i=0;i<n;i++){
		if(a[i] == (cnt+1)){
			cnt++;
		}
		else
			ans++;
	}

	if(cnt == 0){
		cout<<"-1"<<endl;
	}
	else
		cout<<ans<<endl;

return 0;
}

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

int main()
{
  char S[11];
  bool res=true;
  cin >> S;

  int len = strlen(S);

  if(S[0]!='A') res=false;
  bool hasC=false;
  int idxC=0;
  for(int i=2; i<len-1;i++){
    if(S[i]=='C') {
      hasC=true;
      idxC=i;
    }
  }
  if(!hasC) res=false;
  rep(i,len){
    if(S[i]<91 && i!=0 && i!=idxC) {
      res=false;
    }
  }

  if(res) cout << "AC" << endl;
  else cout << "WA" << endl;
}


Measured memory_bytes: 256