akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const int MOD = 1e9 +7;

int par1[200010];
int ra1[200010];

void init1(int n){
    rep(i,n){
        par1[i]=i;
        ra1[i]=0;
    }
}

int find1(int x){
    if(par1[x]==x)
    return x;
    else return par1[x] =find1(par1[x]);
}

void unite1(int x,int y){
    x=find1(x);
    y=find1(y);
    if(x==y) return;
    if(ra1[x] <ra1[y]){
        par1[x] =y;
    }
    else{
        par1[y] =x;
        if(ra1[x] ==ra1[y]) ra1[x]++;
    }
}
bool same1(int x,int y){
    return find1(x) ==find1(y);
}

int par2[200010];
int ra2[200010];

void init2(int n){
    rep(i,n){
        par2[i]=i;
        ra2[i]=0;
    }
}

int find2(int x){
    if(par2[x]==x)
    return x;
    else return par2[x] =find2(par2[x]);
}

void unite2(int x,int y){
    x=find2(x);
    y=find2(y);
    if(x==y) return;
    if(ra2[x] <ra2[y]){
        par2[x] =y;
    }
    else{
        par2[y] =x;
        if(ra2[x] ==ra2[y]) ra2[x]++;
    }
}
bool same2(int x,int y){
    return find2(x) ==find2(y);
}
int main(){
   int N,K,L;
   cin >>N>>K>>L;
   init1(N);
   init2(N);
   int p[100010],q[100010],r[100010],s[100010];
   int ans[200010]={};
   rep(i,K){
       cin >>p[i] >>q[i];
       unite1(p[i],q[i]);
   }
   rep(i,L){
       cin>>r[i] >>s[i];
       unite2(r[i],s[i]);
   }
   map<pii,int> mp;
   for(int i=1;i<=N;i++){
       mp[make_pair(find1(i),find2(i))]++;
   }
   for(int i=1;i<=N;i++){
       cout <<mp[make_pair(find1(i),find2(i))]<<endl;;
   } 
    return 0;
}

Measured memory_bytes: 16640
#include <stdio.h>
#define N 100000

int partition(int,int);

int A[N];

int main(){
  int i,j,n;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  j = partition(0,n-1);
  for(i=0;i<n;i++){
    if(i==j)  printf("[%d]",A[i]);
    else printf("%d",A[i]);
    if(i!=n-1) printf(" ");
    else   printf("\n");
  }
  return 0;
}

int partition(int p,int r){
  int x,v,i,j;
  x =A[r];
  i = p - 1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i+=1;
      v = A[i];
      A[i]=A[j];
      A[j]=v;
    }
  }
  v = A[i+1];
  A[i+1]=A[r];
  A[r] = v;
  return i+1;
}

Measured memory_bytes: 992
#include <iostream>
#include<string.h>
#include<algorithm>
#include<string.h>
#include<stdio.h>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<cmath>
#define ll long long
#define eps 1e-8
using namespace std;
int main()
{
    int n,tmp;
    set<int>s;
    cin>>n;
    while(n--)
    {
        scanf("%d",&tmp);
        if(!s.count(tmp))s.insert(tmp);
        else s.erase(tmp);

    }cout<<s.size();
}


Measured memory_bytes: 4864
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long x = sc.nextLong();
    long cash = 100;
    int res = 0;
    while (cash < x) {
      cash *= 1.01;
      res++;
    }
    System.out.println(res);
    sc.close();
  }
}

Measured memory_bytes: 35732
#include<bits/stdc++.h>
using namespace std;
const int N(111111);
int a[N];
int main() {
	int k, t;
	cin >> k >> t;
	for(int i(0); i < t; i++) {
		cin >> a[i];
		if(a[i] > k - a[i] + 1) {
			printf("%d\n", a[i] - (k - a[i] + 1));
			return 0;
		}
	}
	printf("0\n");
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;

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

int main() {
  int a[3][3];
  rep(i, 3) rep(j, 3) cin >> a[i][j];

  int n;
  cin >> n;
  rep(i, n) {
    int b;
    cin >> b;
    rep(i, 3) rep(j, 3) {
      if (a[i][j] == b) a[i][j] = -1;
    }
  }

  bool ans = false;
  if (a[0][0] + a[0][1] + a[0][2] == -3) ans = true;
  if (a[1][0] + a[1][1] + a[1][2] == -3) ans = true;
  if (a[2][0] + a[2][1] + a[2][2] == -3) ans = true;

  if (a[0][0] + a[1][0] + a[2][0] == -3) ans = true;
  if (a[0][1] + a[1][1] + a[2][1] == -3) ans = true;
  if (a[0][2] + a[1][2] + a[2][2] == -3) ans = true;

  if (a[0][0] + a[1][1] + a[2][2] == -3) ans = true;
  if (a[0][2] + a[1][1] + a[2][0] == -3) ans = true;

  cout << (ans ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>


/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
*/


#define int long long
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound


#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()


using namespace std;
typedef long long ll;
typedef char ch;
typedef string str;
typedef vector <long long> vl;
typedef vector <int> vi;
typedef vector<vector<long long>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<pair<ll, ll>>> vvpll;
typedef vector<vector<pair<int, int>>> vvpii;
typedef vector<char> vch;
typedef vector<vector<char>> vvch;
typedef vector<string> vs;
typedef map<ll, ll> mll;
typedef map<int, int> mii;
typedef map<int, ch> mich;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef unsigned long long ull;


string to_string(long long x) {
    string s;
    bool neg = x < 0;
    x = abs(x);
    do {
        s += char('0' + x % 10);
        x /= 10;
    } while (x != 0);
    if (neg)
        s += '-';
    reverse(s.begin(), s.end());
    return s;
}

ll powmod(ll a, ll b, ll mod) {
    if (b == 0 || a == 1)
        return mod == 1 ? 0 : 1;

    ll k = powmod(a, b / 2, mod);
    k = k * k % mod;
    if (b & 1)
        k = k * a % mod;
    return k;
}

ll pow10(ll a, ll b) {
    if (b == 0 || a == 1)
        return 1;
    ll k = pow10(a, b / 2);
    k *= k;
    if (b & 1)
        k *= a;
    return k;
}

ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

bool is_prime(ll n) {
    ll bound = sqrt(n);
    ll d = 2;
    while (d <= bound && n % d != 0)
        ++d;
    return d * d > n;
}


const int MOD = 1000000007;
const int MOD2 = 1000000009;
const int BASE = 257;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 100010;
const double EPS = 1e-9;
const int DI[]{1, -1, 0, 0};
const int DJ[]{0, 0, 1, -1};


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


int32_t main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    str s;
    cin >> s;
    bool good = false;
    fx(x, s) {
        good |= x == '7';
    }
    cout << (good? "Yes\n": "No\n");

}


Measured memory_bytes: 3676
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

#define rep(i, n) REP(i, 0, n)
#define REP(i, a, n) for(int i = a ; i < (int)n ; i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back
#define mp make_pair
#define eps 1e-14
#define INF 1e9
#define m0(x) memset(x, 0, sizeof(x))

using namespace std;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

signed main(){
  int N;
  int cnt[13] = {0};
  int a;
  cin >> N;
  
  rep(i, N){
    cin >> a;
    cnt[a/400]++;
  }

  int c1 = 0;
  rep(i, 8){
    c1 += (cnt[i] > 0?1:0);
  }
  int c2 = 0;
  REP(i, 8, 13){
    c2 += cnt[i];
  }
  
  cout << (c1==0?1:c1) << " " << c1 + c2 << endl;
}


Measured memory_bytes: 256
using System;

namespace abc059_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            for (int i = 0; i < 3; i++)
            {
                Console.Write(s[i][0].ToString().ToUpper());
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 13140
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#include<assert.h>
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())
#define INF 0x3f3f3f3f
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=998244353;
const double PI = acos(-1.0);
const double epsilon = PI / 180.0;//角度转弧度 
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;}
const int N = 2e5+10, M = 1e6+10;
map<ll, int> _hash;
int main() {
	ll n, x, m;
	cin>>n>>x>>m;
	ll ans = 0;
	vector<ll> v;
	v.pb(0);
	for(int i = 1;i <= n;i++) {
		if(_hash[x]) {
			int l = _hash[x], r = i - 1;
			ll tmp = v[r] - v[l - 1];
			ans += (n - r) / (r - l + 1) * tmp;
			int t = (n - r) % (r - l + 1);
			ans += v[(t + l - 1)] - v[l - 1];
			break;
		}
		v.pb(x);
		v[SZ(v) - 1] += v[SZ(v) - 2];
		_hash[x] = i;
		ans += x;
		x = x * x % m;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 6732
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#include <math.h>
typedef char Bool;
#define true 39
#define false 0
typedef long long int64;
typedef unsigned long long uint64;
typedef int int32;
typedef unsigned int uint32;
typedef unsigned char byte;
#define OVER 1000000000000000000‬

Bool primeche(int value) 
{
	Bool flag = false;
	for (int i = 2; i < value; ++i) {
		if (value % i == 0) {
			flag = true;
			break;
		}
	}
	return flag;
}

int64 exponentiation(int64 value, int32 index) 
{
	int64 j = 1;
	for (int i = 0; i != index; i++) 
	{
		j *= value;
	}
	return 0;
}

int main()
{
	uint64 n;
	uint64* a;

	uint64 b = 1;

	scanf("%llu", &n);
	a = (uint64*)malloc(sizeof(uint64) * n);
	for (int i = 0; i != n; i++)
	{
		scanf("%llu", &a[i]);
	}
  
  Bool B=false;
  
  for(int i=0;i!=n;i++)
  {
    if(a[i]==0){
     B=true; 
    }
  }

  if(B)
  {
    printf("0");
    return 0;
  }
	for (int i = 0; i != n; i++)
	{
      if(a[i]<=1000000000000000000/b){
		b *= a[i];
      }
      else{
      printf("-1");
      return 0;
      }
		/*if (b > OVER) 
		{
			break;
		}*/
	}
		printf("%lld", b);
	
	return 0;
}


Measured memory_bytes: 2496
#include <iostream>
#include <queue>

using namespace std;

#define ll long long

int main(){
  ll n, qq;
  cin >> n >> qq;
  queue< pair<string,ll> > q;
  for(ll i = 0; i < n; i++){
    string s;
    ll time;
    cin >> s >> time;
    q.push(make_pair(s,time));
  }

  ll time = 0;
  while(!q.empty()){
    if(q.front().second > qq){
      time += qq;
      q.front().second -= qq;
      q.push(q.front());
      q.pop();
    }else{
      time += q.front().second;
      cout << q.front().first << ' ' <<  time << endl;
      q.pop();
    }
  }
  

}

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

typedef pair<int, int> tl;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main()
{
	int n, m;
	cin >> n >> m;
	vector<tl> t(m);
	rep(i, m)  cin >> t[i].second >> t[i].first;
	sort(t.begin(), t.end());

	int ans = 0;
	ll tsum = 1;
	rep(i, m) {
		if (tsum <= t[i].second) {
			ans++;
			tsum = t[i].first;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
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("filed 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 n:u32 = read();
    let t:u32 = read();
    let mut min: u32 = 1001;
    for _ in 0..n {
        let c:u32 = read();
        let v:u32 = read();
        if t >= v && c < min {
            min = c;
        }
    }
    if min == 1001 {
        println!("TLE");
    } else {
        println!("{}", min);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL<<60;
typedef pair<ll, ll> P;

int main() {
    cin>>H>>W;
    vector<string> g(H);
    rep(i,H) cin>>g[i];
    mat cost(H, vec(W, INF));
    cost[0][0] = g[0][0] == '#';
    rep(i,H){
        rep(j, W){
            if(i != 0) cost[i][j] = min(cost[i][j], cost[i-1][j] + (g[i-1][j] == '.' && g[i][j] == '#'));
            if(j != 0) cost[i][j] = min(cost[i][j], cost[i][j-1] + (g[i][j-1] == '.' && g[i][j] == '#'));
        }
    }
    cout<<cost[H - 1][W - 1]<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

ll N, K;
int A[212345];
int dp[63][212345];

int main() {
	cin >> N >> K;
	REP(i, N) cin >> A[i], --A[i];
	
	REP(i, N) dp[0][i] = A[i];
	FOR(i, 1, 63) REP(j, N) dp[i][j] = dp[i - 1][dp[i - 1][j]];
	
	int ans = 0;
	for (int i = 62; i >= 0; --i) if (K >> i & 1) {
		ans = dp[i][ans];
	}
	
	cout << ans + 1 << endl;
	
	return 0;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INF = 2147483647;
const long long LINF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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(void){
    int N,M; cin >> N >> M;
    VI A(N); REP(i,N) cin >> A[i];
    SORT(A); REVERSE(A);
    int sum = 0; REP(i,N) sum += A[i];
    int c = 0;
    REP(i,N){
        if(4*M*A[i] >= sum) c++;
    }
    cout << (c<M ? "No" : "Yes") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int a, b, k;
    int i = 1, j = 0, g[100];
    scanf("%d%d%d", &a, &b, &k);
    while (i <= a && i <= b)
    {
        if (a % i == 0 && b % i == 0)
        {
            g[j] = i;
            j++;
        }
        i++;
    }
    printf("%d\n", g[j - k]);
    return 0;
}

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    string s; cin >> s;
    int n = s.size();

    REP(i, n) {
        if (i == 4) cout << ' ';
        cout << s[i];
    }
    cout << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long

signed main() {
  int n, m;
  cin >> n >> m;
  if (n == 1 && m == 1) {
    cout << 1 << endl;
  } else if (n == 1) {
    cout << m - 2 << endl;
  } else if (m == 1) {
    cout << n - 2 << endl;
  } else if (n == 2 || m == 2) {
    cout << 0 << endl;
  } else {
    cout << (n - 2) * (m - 2) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int a[110];
int b[110];

int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		char c;
		int d;
		scanf(" %c%d",&c,&d);
		b[i]=a[i]=c*10+d;
	}

	for(int i=0;i<n;i++){
		int idx=i;
		for(int j=i+1;j<n;j++)if(a[j]%10<a[idx]%10)idx=j;
		int t=a[i];
		a[i]=a[idx];
		a[idx]=t;
	}
	
	for(int i=n-1;i>=0;i--)for(int j=0;j<i;j++)if(b[j]%10>b[j+1]%10){
		int t=b[j];
		b[j]=b[j+1];
		b[j+1]=t;
	}
	for(int i=0;i<n;i++)printf("%c%d%c",b[i]/10,b[i]%10,i==n-1?10:32);
	puts("Stable");
	int flag=1;
	for(int i=0;i<n;i++)printf("%c%d%c",a[i]/10,a[i]%10,i==n-1?10:32),flag&=a[i]==b[i];
	puts(flag?"Stable":"Not stable");
}


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

#define mp make_pair
typedef pair<int,int>pii;
typedef long long ll;
const int N = 2000;
ll dp[N+10][N+10];
pii a[N+10];

ll solve(int l,int r,int pos)
{
	//printf("%d %d %d\n",l,r,pos);
	if(r-l==1){
		return 0;
	}
	if(dp[l][r]!=0){
		return dp[l][r];
	}
	ll t1 = 1ll*a[pos].first*(abs(l+1-a[pos].second));
	ll t2 = 1ll*a[pos].first*(abs(r-1-a[pos].second));
	ll mx = 0;
	mx = max(mx,t1+solve(l+1,r,pos+1));
	mx = max(mx,t2+solve(l,r-1,pos+1));
	return dp[l][r] = mx;
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i].first);;
		a[i].second = i;
	}
	sort(a+1,a+n+1,greater<pii>());
	printf("%lld\n",solve(0,n+1,1));
}


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

int main() 
{
    ll n;
    cin>>n;
    ll x,y;
    ll cnt=0;
    ll cnt1=0;
    for(ll i=0;i<n;i++)
    {
        cin>>x>>y;
        if(x==y)
        {
            cnt++;
            if(cnt>=3)
            {
                cout<<"Yes";
                return 0;
            }
        }
        else
        {
            cnt=0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <queue>
#include <cmath>
#include <limits>

using namespace std;

int x[1002], y[1002], r[1002];
double cost[1002][1002];
double d[1002];

double norm(double x1, double x2)
{
    double d = x1 - x2;
    return d * d;
}

int main()
{
    scanf("%d%d%d%d", &x[0], &y[0], &x[1], &y[1]);
    r[0] = r[1] = 0;

    int N;
    scanf("%d", &N);
    N += 2;
    for (int i = 2; i < N; i++) {
        scanf("%d%d%d", &x[i], &y[i], &r[i]);
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cost[i][j] = max(sqrt(norm(x[i], x[j]) +  norm(y[i], y[j])) - r[i] - r[j], 0.0);
        }
    }

    d[0] = 0;
    for (int i = 1; i < N; i++)
        d[i] = numeric_limits<double>::max();

    priority_queue<pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>>> pq;
    pq.push(make_pair(d[0], 0));

    while (!pq.empty()) {
        auto p = pq.top();
        pq.pop();
        int v = p.second;
        if (d[v] < p.first)
            continue;
        for (int i = 0; i < N; i++) {
            if (d[i] > d[v] + cost[v][i]) {
                d[i] = d[v] + cost[v][i];
                pq.push(make_pair(d[i], i));
            }
        }
    }

    printf("%.10f\n", d[1]);
}


Measured memory_bytes: 12400
import java.util.*;

class Main{       
   public static void main(String[] args){

      Scanner sc = new Scanner(System.in);                                            
      
      int N = sc.nextInt();
      
      int K = sc.nextInt();
      String a[] = new String[K];
      
      for(int i = 0;i < K;i++){
          a[i] = sc.next();
      }
     
     for(int i = N;;i++){
       String val = String.valueOf(i);
       boolean flag = true;
       for(int j = 0;j< K;j++){
         if(val.contains(a[j])){
             flag = false;
         }
       }
       if(flag){
         System.out.println(i);   
         return;
       }         
     }
      
      
      
   }
}

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

int main()
{
    int before[60],after[60];
    int n,r;
    while(cin >> n >> r)
    {
        if(n==0 && r==0)break;
        for(int i=0;i<n+1;i++)
        {
            before[n-i]=i+1;
            after[n-i]=i+1;
        }
        
        int p,c,temp;
        for(int i=0;i<r;i++)
        {
            cin>>p>>c;
            for(int j=0;j<c;j++)
            {
                after[j+1]=before[p+j];
            }
            for(int j=0;j<p-1;j++)
            {
                after[c+j+1]=before[j+1];
            }
            for(int j=0;j<55;j++)
            {
                before[j]=after[j];
            }
        }
        cout << after[1]<< endl;
    }

    return 0;
}

Measured memory_bytes: 0
def main():
    X, N = map(int, input().split())
    p = list(map(int, input().split()))

    if len(p) == 0:
        print(X)
        return

    i = 0
    while True:
        if X - i not in p:
            print(X - i)
            return
        elif X + i not in p:
            print(X + i)
            return
        else:
            i += 1

if __name__ == "__main__":
    main()


Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    vector<int> x(5);
    REP(i, 5) cin >> x[i];
    REP(i, 5) {
        if(x[i] == 0) {
            cout << (i+1) << endl;
            return 0;
        }
    }

}

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

constexpr int si = 101 * 1002, si_log = 8 + 10 + 1, mod = static_cast<int>(1e9) + 7;
constexpr int shi = 101 * 1000;
int n, m, ar[222];

int main() {
   ios_base::sync_with_stdio(0); cin.tie(0);
   
   for (int i = 0; i < 4; i++) cin >> ar[i];
   int ans = 0, p1=-1, p2=-1;
   for (int i = 0; i < 1234; i++)
   {
      auto q = ar[0] <= i && i <= ar[1];
      auto w = ar[2] <= i && i <= ar[3];
      auto t = q && w;
      if (t)
      {
         if (-1 == p1)
            p1 = i;
         p2 = i;
      }
      ans += t;
   }
   auto di = p2 - p1;
   cout << di << '\n'; 
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define all(v) v.begin(),v.end()
#define PI acos(-1)
#define EPS 1e-15


 
int main(){
	int n;
	cin >> n;
	int cnt = 0;
	for(int i = 0; i < n; i++){
		int l, r;
		cin >> l >> r;
		cnt += r-l+1;
	}
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 256
x, y, a, b, c = map(int, input().split())

p = sorted(list(map(int, input().split())), reverse=True)[:x]
q = sorted(list(map(int, input().split())), reverse=True)[:y]
r = sorted(list(map(int, input().split())))


print(sum(sorted(p + q + r, reverse=True)[:x+y]))

Measured memory_bytes: 22504
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const ll inf=1e9;
const int MAX = 510000;
const ll MOD = 998244353;

inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}

int main(){
  ll n;cin>>n;
  vll a(n),b(n);
  ll aa=0,bb=0;
  rep(i,0,n)cin>>a[i];
  rep(i,0,n)cin>>b[i];
  rep(i,0,n){
    if(a[i]<b[i]){
      aa+=(b[i]-a[i])/2;
    }
    else{
      bb+=a[i]-b[i];
    }
  }
  if(aa>=bb){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}







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

ll solve() {
    ll N, M;
    cin >> N >> M;
    vector<pair<ll,ll>> w;
    ll a, b;
    for ( int i = 0; i < N; i++ ) {
        cin >> a >> b;
        w.emplace_back(a,-b);
    }
    sort(w.begin(), w.end());

    priority_queue<ll> q;
    int k = 0;
    ll ans = 0;
    for ( int i = 0; i <= M; i++ ) {
        while ( k < N && w[k].first <= i ) {
            q.push(-w[k].second);
            k++;
        }
        if ( !q.empty() ) {
            ans += q.top();
            q.pop();
        }
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3568
def gcd(x, y):
    a, b = x, y
    r = a % b
    while r != 0:
        a, b = b, r
        r = a % b
    return b

def divisors(x):
    D = []
    for i in range(1, int(x**0.5) + 1):
        if x % i == 0:
            D.append(i)
            if i != x**0.5:
                D.append(x // i)
    D.sort()
    return D

def isprime(x):
    t = 1
    for i in range(2, int(x**0.5) + 1):
        if x % i == 0:
            t = 0
            break
    if t == 1 and x != 1:
        return True
    else:
        return False


a, b = map(int, input().split())

CD = divisors(gcd(a, b))

ans = 1
for cd in CD:
    if isprime(cd):
        ans += 1

print(ans)


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

const long long N = 1e3 + 17;
ll a[N], b[N], cnt, ans, lnt, n, m, r1, r0, l1, l0, sum, mx, h, c[N], t[N], mn = N, x, y, k;
pair<ll,ll>pr[N];
vector<ll>v,v2;
map<ll,ll>mp;
bool used[N];
char ch[1005];
ll prime[N] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n;
    for(ll i = 0; i < n; i ++)
    {
        cin >> a[i];
    }
    for(ll i = 0; i < n; i ++)
    {
        cin >> b[i];
    }
    for(ll i = 0; i < n; i ++)
    {
        if(a[i] > b[i])
        {
            cnt += a[i];
            lnt += b[i];
        }
    }
    cout << cnt - lnt;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
long long N, A[100100], rct, rct2;
 
int main() {
	
    cin >> N;
    for(int i=1; i<=N; i++) {
        cin >> A[i];
    }
    
    sort(A+1, A+N+1);
 
    for (int i=N; i>=2; i--){
        if(A[i]==A[i-1]){
            rct=i;
            break;
        }
    }
    
    for (int i=rct-2; i>=2; i--){
        if(A[i]==A[i-1]){
            rct2=i;
            break;
        }
    }
    cout << A[rct]*A[rct2] << endl;
 
    
}

Measured memory_bytes: 4340
#include "bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;
const int INF = 1 << 30;
const long long LINF = 1LL << 60;
const long long MOD = 1000000000 + 7;
const double PI = acos(-1);

int main() {
	rep(i, 5) {
		int x;
		cin >> x;
		if (x == 0) {
			cout << i + 1;
			break;
		}
	}
}

Measured memory_bytes: 3564
def partition(A: list, p: int = 0, r: int = None):
    if r is None:
        r = len(A) - 1
    x = A[r]
    i = p - 1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i + 1], A[r] = A[r], A[i + 1]
    return i + 1


N = int(input())
A = list(map(int, input().split()))
r = partition(A)
A = ["[{}]".format(a) if i == r else str(a) for i, a in enumerate(A)]
print(*A)



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

typedef long long int ll;



int main(){
  ll n,m;
  cin>>n>>m;
  vector <ll> h(n+1);
  vector <ll> visit(n+1);
  vector <ll> flag(n+1);
  ll i;
  for(i=1;i<=n;i++){
    ll x;
    cin>>x;
    h[i]=x;
  }
  for(i=1;i<=n;i++){
    flag[i]=1;
  }
  for(i=1;i<=m;i++){
    ll x,y;
    cin>>x>>y;
    if(h[x]>h[y]){
      if(flag[y]==1){
        flag[y]=0;
      }

    }
    else if(h[y]>h[x]){
      if(flag[x]==1){
        flag[x]=0;
      }
    }
    else if(h[y]==h[x]){
      flag[x]=0;
      flag[y]=0;
    }
    visit[x]=1;
    visit[y]=1;

  }
  ll ans=0;
  for(i=1;i<=n;i++){
    if(flag[i]==1||visit[i]==0){
      ans++;
    }
  }
  cout<<ans<<endl;
return 0;
}


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

int cub[10];
int main(){
    int n,l,x;
    scanf("%d%d", &n, &l);
    for(int i=0; i<l; i++){
        scanf("%d", &x);
        cub[x]=1;
    }
    int aux, mod, c, c2, found=0;
    for(int i=n; i<=100000; i++){
        aux=i;
        c=0, c2=0;
        while(aux>0){
            mod=aux%10;
            aux/=10;
            c2++;
            if(cub[mod]==1)
                break;
            else
                c++;
        }
        if(c==c2){
            found=i;
            break;
        }
    }
    printf("%d", found);
return 0;
}


Measured memory_bytes: 256
def hoge():

    n, p = [int(c) for c in input().split()]
    s = input()    

    if p in (2,5):
        a = tuple(int(c)%p for c in s)
        out = 0
        for i,x in enumerate(a):
            if x==0:
                out += (i + 1)
    else:
        a = [0]*n
        tmp = 0
        for i in reversed(range(n)):
            tmp = (tmp + pow(10, n-i-1, p) * int(s[i])) % p
    #         tmp = (tmp + 10**(n-i-1) * int(s[i])) % p
            a[i] = tmp
        d = {i: 0 for i in range(p)}
        d[0] = 1
        out = 0
        for x in a[::-1]:
            out += d[x]
            d[x] += 1
    print(out)
hoge()

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

int W,H,D;
int field[25][25];
int *A[25*25];
int buf[25*25][25*25+1];

int cos90[] = {+1, 0,-1, 0};
int sin90[] = { 0,+1, 0,-1};

inline int vec2int(int x, int y) { return y*W+x; }

void setA(int cx, int cy)
{
	int myidx=vec2int(cx,cy);
	for(int d=0; d<D; d++)
	{
		int dx=  d;
		int dy=D-d;
		for(int t=0; t<4; t++)
		{
			// sinツづosツづ嘉アツ転ツつウツつケツづ全ツ陛サツ古シツ催ャツづゥ
			int nx = cx + dx*cos90[t] - dy*sin90[t]; 
			int ny = cy + dx*sin90[t] + dy*cos90[t];

			if(0<=nx && nx<W && 0<=ny && ny<H)
			{
				A[myidx][vec2int(nx,ny)] = 1;
			}
		}
	}
	A[myidx][myidx] = 1	;
	A[myidx][W*H]   = field[cy][cx];
}

bool sweepout()
{
	for(int t=0; t<W*H; t++)
	{
		// 1ツづーツ探ツつキ
		for(int y=t; y<W*H; y++)
		{
			if(A[y][t])
			{
				swap(A[t],A[y]);
				break;
			}
		}
		if(!A[t][t]) continue;

		for(int y=t+1; y<W*H; y++)
		{
			if(A[y][t])
			for(int x=t; x<W*H+1; x++)
			{
				A[y][x] = (A[y][x]+A[t][x])%2; 
			}
		}
	}

	for(int t=W*H-1; t>=0; t--)
	{
		if(A[t][t])
		for(int y=0; y<t; y++)
		{
			if(A[y][t])
			{
				A[y][t]   = 0;
				A[y][W*H] = (A[y][W*H]+A[t][W*H])%2; 
			}
		}
	}
	

	for(int t=0; t<W*H; t++)
	{
		if((!A[t][t]) && A[t][W*H])
		{
			return false;
		}
	}
	return true;
}

int main()
{
	for(int i=0; i<25*25; i++)
	{
		A[i] = buf[i];
	}

	while(cin >> W >> H >> D, W||H||D)
	{
		for(int y=0; y<H; y++)
		for(int x=0; x<W; x++)
		{
			cin >> field[y][x];
		}

		memset(buf,0,sizeof(buf));
		for(int y=0; y<H; y++)
		for(int x=0; x<W; x++)
		{
			setA(x,y);	
		}

		cout << (sweepout()?1:0) << endl;
	}
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

string bitst(int a)
{
    string st;
    if (!a) return "0";
    while (a) {
        st.pb((a % 2) + '0');
        a /= 2;
    }
    reverse(all(st));
    return st;
}

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

    Int(n); int3(x, y, z);
    int toshino = (1 << (x - 1));
    toshino = (toshino << y) + (1 << (y - 1));
    toshino = (toshino << z) + (1 << (z - 1));
    int mask = (1 << (x + y + z)) - 1;

    vvi funami(n+1, vi(1 << 17, 0));
    funami[0][0] = 1;

    rep(i, n) {
        rep(j, 1 << (x + y + z)) {
            Rep(k, 11) {
                int tmp = ((j << k) + (1 << (k-1))) & mask;
                if ((tmp & toshino) != toshino) {
                    funami[i+1][tmp] = 
                        (funami[i+1][tmp] + funami[i][j]) % MOD;
                }
            }
        }
    }

    int ans = 1;
    rep(i, n) 
        ans = (ans * 10) % MOD;
    rep(i, funami[n].size())
        if (i != toshino) ans = (ans - funami[n][i] + MOD) % MOD;

    cout << ans << endl;

    return 0;
}



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

int N;
int X[8], Y[8];

double dist(int i, int j)
{
	return ( sqrt(pow(X[i] - X[j], 2) + pow(Y[i] - Y[j], 2)) );
}

int main()
{
	cin >> N;
	double sum = 0.0;

	for ( int i = 0; i < N; i++ ) cin >> X[i] >> Y[i];
	
	for ( int i = 0; i < N; i++ ) {
		for ( int j = 0; j < N; j++ ) {
			sum += dist(i, j);
		}
	}

	cout << fixed << setprecision(10) << sum / N  << endl;

	return ( 0 );
}


Measured memory_bytes: 256
## coding: UTF-8


N, M, Q = map(int,input().split())
lq = []
for i in range(Q):
    lq.append(list(map(int,input().split())))
#print(lq)

dfs = []
for i in range(1, M+1):
    dfs.append([i])
#print(dfs)

def add(l):
    ret = []
    for i in range(len(l)):
        last = l[i][-1]
        for j in range(last, M+1):
            ret.append(l[i] + [j])
    return ret

for i in range(N-1):
    dfs = add(dfs)
#print(dfs)


m = -1
for i in range(len(dfs)):
    A = dfs[i]
    tmp = 0
    for j in range(len(lq)):
        aj = lq[j][0]
        bj = lq[j][1]
        cj = lq[j][2]
        dj = lq[j][3]
        #print('i:{}, j:{}, A:{}, [aj, bj, cj, dj]:{}'.format(i, j, A, lq[j]))
        #print('A[bj-1]:{}, A[aj-1]:{}, A[bj-1]-A[aj-1]:{}, cj:{}, ==?:{}, dj:{}'.format(A[bj-1], A[aj-1], A[bj-1]-A[aj-1], cj,   A[bj-1]-A[aj-1]==cj  , dj))
        #print('i:{}, j:{}, A:{}, lq[j]:{}'.format(i, j, A, lq[j]))
        #print('A[lq[j][i]-1]:{}, A[lq[j][0] - 1]:{}'.format(A[lq[j][i]-1], A[lq[j][0] - 1]))
        #if(A[lq[j][i]-1] - A[lq[j][0] - 1] == lq[2]):
            #tmp += lq[3]
        if(A[bj-1]-A[aj-1] == cj):
            tmp += dj
    #print('i:{}, A:{}, tmp:{}'.format(i, A, tmp))
    if(tmp > m):
        m = tmp    
print(m)

Measured memory_bytes: 30308
import sys
input = sys.stdin.readline
c=[list(map(int,input().split())) for i in range(3)]
for i in range(2):
    for j in range(2):
        if c[i][j]-c[i][j+1] != c[i+1][j]-c[i+1][j+1]:
            print("No")
            exit()
        if c[i][j]-c[i+1][j] != c[i][j+1]-c[i+1][j+1]:
            print("No")
            exit()
print("Yes")


Measured memory_bytes: 38384
from collections import Counter

N = int(input())
As = list(map(int, input().split()))

rlt = 0
dic = Counter(As)

for k in dic:
  if dic[k] < k:
    rlt += dic[k]
  elif dic[k] > k:
    rlt += dic[k] - k
    
print(rlt)


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  map<pair<int,int>,int> mp;
  int x,y,w;
  rep(i,n){
    cin >> x >> y >> w;
    mp[{x,y}]+=w;
    mp[{x+1,y}]+=w;
    mp[{x,y+1}]+=w;
    mp[{x+1 ,y+1}]+=w;
  }
  int ans=0;
  for(auto &p:mp) ans=max(ans,p.second);
  cout << ans << " / 1" << endl;
  return 0;
}



Measured memory_bytes: 28088
/*
 *
 * Copyright(c) 2017 Taikai Takeda <297.1951@gmail.com> All rights reserved.
 *
 */
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))


//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n;

    cin >> n;

    ll ans = 0;

    ans += 2 * (n / 11);

    n %= 11;

    if (n >= 6){
        ans += 1;
        n -= 6;
    }

    if(n > 0)
        ans += 1;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define ll long long
#define pb push_back
#define mp make_pair
const ll inf = 1e9;
const ll zero = 0;
using namespace std;
 
int main(){
	ll n;
	cin>>n;
	ll v[100001]={};
	ll a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		v[a[i]]++;
	}
	ll ans(0),e(0);
	for(int i=1;i<=100000;i++){
	    if(v[i] == 0) 
		continue;
	    ans++;
	    if(v[i] % 2 == 0){
	      e++;
	    }
	}
	if (e%2==0){
		cout << ans;
	} else
		cout << ans - 1;
}

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

using namespace std;

int main(void){
    long long N, K;
    cin >> N >> K;
    vector<long long> A(N);
    long long imin;
    for(int i=0;i<N;i++){
        cin >> A[i];
        if(A[i] == 1) imin = i;
    }

    long long ans = 1000000000;
    for(long long k=0;k<K;k++){
        long long l = max(imin-k, 0ll);
        long long r = max((N-imin-1)-(K-k-1), 0ll);
        long long x = ceil((float)l/(K-1))+ceil((float)r/(K-1))+1;
        ans = min(ans, x);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define maxn 100005
using namespace std;
map<int,int> ma;

int main()
{
  int n;
  scanf("%d", &n);
  int ans = 0;
  for(int i=0;i<n;i++){
    int x;
    scanf("%d", &x);
    ma[x] ++;
    ma[x - 1] ++;
    ma[x + 1] ++;
    ans = max(ans, ma[x]);
    ans = max(ans, ma[x - 1]);
    ans = max(ans, ma[x + 1]);
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
  int N, K;
  long S,C=1;
  cin >> N >> K >> S;
  if(S!=1e9){
    C=1e9;
  }else{
    if(N!=K) C=S/(N-K)-1;
  }
  for(int i=0; i<K; i++){
    cout << S << " ";
  }
  for(int i=K; i<N; i++){
    cout << C << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
vector<int >v[55];
int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int N,M;
    cin>>N>>M;
    int a,b;
    for(int i=1;i<=M;++i)
    {
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for(int i=1;i<=N;i++)
    {
        cout <<v[i].size()<<endl;
    }
    return 0;
}



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

int main() {
  int N, M;
  cin >> N >> M;
  char A[50][50], B[50][50];
  
  for (int y = 0; y < N; ++y) {
    for (int x = 0; x < N; ++x) {
      cin >> A[y][x];
    }
  }
  for (int y = 0; y < M; ++y) {
    for (int x = 0; x < M; ++x) {
      cin >> B[y][x];
    }
  }
  
  bool exist = false;
  
  for (int ly = 0; ly < N; ++ly) {
    for (int lx = 0; lx < N; ++lx) {
      if (ly+M-1 >= N || lx+M-1 >= N) continue;
      
      bool match = true;
      for (int y = 0; y < M; ++y) {
        for (int x = 0; x < M; ++x) {
          if (A[ly+y][lx+x] != B[y][x]) match = false;
        }
      }
      if (match) exist = true;
    }
  }
  
  if (exist) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

  

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

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	ll a, b, n; cin >> a >> b >> n;
	if(b > n) cout << a * n / b << endl;
	else{
		ll p = n / b;
		ll ans = (p * b - 1)*a/b - ((p * b -1)/b) * a;
		ans = max(ans, a * n / b - a * (n / b));
		cout << ans << endl;
	}
} 

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

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()

void boost(){
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int N=5e5+5;
ll tree[N];

ll read(int idx) {
  ll sum = 0;
  while (idx > 0) {
    sum += tree[idx];
    idx -= (idx & -idx);
  }
  return sum;
}

void update(int idx, ll val) {
  while (idx <N) {
    tree[idx] += val;
    idx += (idx & -idx);
  }
}


void solve(){
  int n,q;
  cin>>n>>q;
  int x;
  fr(i,1,n+1){
    cin>>x;
    update(i,x);
  }
  int t,l,r;
  while(q--){
    cin>>t>>l>>r;
    if(t==0){
      update(l+1,r);
    }
    else{
      cout<<read(r)-read(l)<<endl;
    }
  }
  return;
}

int main()
{
  boost();
  
  int tc=1;
  //cin>>tc;
  while(tc--)
    solve();
  return 0;
}

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

int main(int, char**) {
  int a[20], n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  
  int ans = 1;
  int maxh = a[0];
  for (int i = 1; i < n; i++) {
    if (a[i] >= maxh) {
      maxh = a[i];
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int MAX = 100005;
const int NIL = -1;

struct Node {
    int p, l, r;
};

Node T[MAX];
int n, D[MAX];

void print(int u) {
    int i, c;
    cout << "node " << u <<": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";

    if (T[u].p == NIL) {
        cout << "root, ";
    }
    else if (T[u].l == NIL) {
        cout << "leaf, ";
    }
    else {
        cout << "internal node, ";
    }

    cout << "[";

    for (i = 0, c = T[u].l; c != NIL; i++, c = T[c].r) {
        if (i) {
            cout << ", ";
        }
        cout << c;
    }
    cout << "]" << endl;
}

int rec(int u, int p) {
    D[u] = p;
    if (T[u].r != NIL) {
        rec(T[u].r, p);
    }
    if (T[u].l != NIL) {
        rec(T[u].l, p + 1);
    }
}

int main() {
    int i, j, d, v, c, l, r;
    cin >> n;

    for (i = 0; i < n; i++) {
        T[i].p = T[i].l = T[i].r = NIL;
    }

    for (i = 0; i < n; i++) {
        cin >> v >> d;
        for (j = 0; j < d; j++) {
            cin >> c;
            if (j == 0) {
                T[v].l = c;
            }
            else {
                T[l].r = c;
            }
            l = c;
            T[c].p = v;
        }
    }
    
    for (i = 0; i < n; i++) {
        if (T[i].p == NIL) {
            r = i;
        }
    }

    rec(r, 0);

    for (int i = 0; i < n; i++) {
        print(i);
    }

    return 0;
}

Measured memory_bytes: 7748
#include <bits/stdc++.h>
#define ll long long
#define inf (1LL<<57)
#define PII pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define endl "\n"
const long long mod = 1e9 + 7;
typedef unsigned long long ull;
using namespace std;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
#define DBG cerr << "debug here" << endl;
#define DBGV(vari) cerr << #vari<< " = "<< (vari) <<endl;
/*============================================================================
rk
Deependra Chourasia
IIT(ISM) DHANBAD
16je001916

============================================================================
*/


int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    ll n,ans=0;
    cin>>n;
    string s;cin>>s;
    
    for(int i=0;i<n-2;i++)
    {
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')ans++;
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class C
{
	public static void Main()
	{
		int N = Int32.Parse(Console.ReadLine());

		int ans = 0;
		string[] args = Console.ReadLine().Split(' ');
		for(int i = 0; i < N; i++)
			ans += Int32.Parse(args[i]);
		ans -= N;
		
		Console.WriteLine(ans);
	}	
}





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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int cnt[102] = {};
    rep(i, B) if (A <= i) cnt[i]++;
    rep(i, D) if (C <= i) cnt[i]++;
    int ans = 0;
    rep(i, 102) if (cnt[i] == 2) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256