akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MOD 1e9 + 7
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }


int main() {
    int n,co1=0,co2=0;
    cin >> n;
    vector<int> a(n);
    FOR(i,0,n) cin >> a.at(i);
    bool ans = false;

    FOR(i,0,n){
        if(a.at(i) % 2 == 0){
            co1++;
             if(a.at(i) % 3 == 0 || a.at(i) % 5 == 0){
                co2++;
            }
        
    }}
       
    if(co1 == co2){
        cout << "APPROVED"<< endl;

    }else{
        cout << "DENIED" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 5e2 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int n, mat[maxN][maxN], there[maxN][maxN];
int dr[4][2] = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}};

void prt() {
	for(int i = 0; i < n; i++, LOG << '\n')
		for(int j = 0; j < n; j++) LOG << mat[i][j] << ' ';
	LOG << '\n';
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	cin >> n;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			mat[i][j] = min({i + 1, n - i, j + 1, n - j}), there[i][j] = 1;

	prt();
	int ans = 0;
	for(int u = 0; u < n * n; u++) {
		int inp, r, c;
		cin >> inp;
		inp--;
		r = inp / n, c = inp % n;
		mat[r][c]--;
		there[r][c] = 0;
		queue<ii> q;
		q.push(ii(r, c));
		while(q.size()) {
			auto cr = q.front(); q.pop();
			for(int i = 0; i < 4; i++) {
				int x = cr.fi + dr[i][0], y = cr.se + dr[i][1];
				if(min(x, y) < 0 || max(x, y) >= n || mat[x][y] <= mat[cr.fi][cr.se] + there[x][y])
					continue;
				mat[x][y]--;
				q.push(ii(x, y));
			}
		}
		ans += mat[r][c];
		//debug(inp + 1, r, c);
		//prt();
	}
	cout << ans << '\n';
}



Measured memory_bytes: 5608
#include <stdio.h>

long int gcd(long int a, long int b)
{
    long int r=0, t=0;

    if(a<b){
        t=a;
        a=b;
        b=t;
    }
    while(b!=0){
        r=a%b;
        a=b;
        b=r;
    }

    return a;
}        
long int lcm(long int a, long int b)
{
    return (a*b)/gcd(a, b);
}

int main(void)
{
    int n;
    scanf("%d", &n);
    long int t[n], i;
    for(i=0;i<n;i++){
        scanf("%ld", &t[i]);
    }

    for(i=0;i<n-1;i++){
        t[i+1]=t[i]/gcd(t[i], t[i+1])*t[i+1];
    }
    
    printf("%ld\n", t[i]);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1){
            res *= a; if(mod>=1) res %= mod;
        }
        a *= a; if(mod>=1) a %= mod;
        n >>= 1;
    }
    return res;
}
void initialize(){
    
}
int p[LIMIT1]={0},x[LIMIT1]={0};
int tmp(cv *l,cv *r){
  return p[*(int *)l]-p[*(int *)r];
}
int main(void){
  initialize();
  ll n,m,i,j,k,result[LIMIT1]={0},q;
  int a,b,c[LIMIT1]={0};
  char s[LIMIT1];
  int visited[LIMIT1]={0};
  std::vector<ll> ki[LIMIT1];
  std::queue<ll> que;
  scanf("%lld %lld",&n,&q);
  rep(i,n-1){
    scanf("%d %d",&a,&b);
    a--;
    b--;
    ki[a].push_back(b);
    ki[b].push_back(a);
  }
  rep(i,q){
    scanf("%d %d",&p[i],&x[i]);
    p[i]--;
  }
  tmpInit(c,q);
  qsort(c,q,sizeof(int),tmp);
  rep(i,q){
    result[p[c[i]]]+=x[c[i]];
  }
  que.push(0);
  while(!que.empty()){
    i = que.front();
    que.pop();
    if(visited[i]==1) continue;
    visited[i]=1;
    k = ki[i].size()-1;
    //printf("%lld\n",i);
    while(!ki[i].empty()){
	  j = ki[i][k];
      ki[i].pop_back();
      k--;
      if(visited[j]==1) continue;
      que.push(j);
      result[j] += result[i];
    }
  }
  
  rep(i,n) printf("%lld%c",result[i],(i==n-1 ? '\n' : ' '));
  return 0;
}



Measured memory_bytes: 20972
use proconio::input;

fn main() {
  input! {
    n: usize,
    k: usize,    
  }
  
  let mut sweets = vec![false; n];
  
  for i in 0..k {
    input! {
      d: usize,
    }
    for j in 0..d {
      input! {
      	a: usize,
      }
      sweets[a-1] = true;
    }
  }
  
  let ans = sweets.iter().filter(|&x| !x).count();
  println!("{}", ans);

}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;

ll n;
vi a;

struct SegTree{
  typedef int T;
  T e = 0;
  inline T m(const T&a, const T&b){return a + b;}
//###################################################
  typedef int i;i n;vector<T> d;
  T q(i a,i b,i k,i l,i r){return (r<=a||b<=l)?e:(a<=l&&r<=b)?d[k]:m(q(a,b,k*2+1,l,(l+r)/2),q(a,b,k*2+2,(l+r)/2,r));}

  void clear(){memset(&d[0], e, sizeof(d[0]) * sz(d));}
  void resize(i m){n=1<<(32-__builtin_clz(m-1));d.resize(2*n-1);clear();}
  void init(vector<T>&v){resize(sz(v));FOR(j,0,sz(v))d[j+n-1]=v[j];FORR(k,n-2,0)d[k]=m(d[k*2+1],d[k*2+2]);}
  void update(i k,T a){k+=n-1;d[k]=a;while(k>0){k=(k-1)/2;d[k]=m(d[k*2+1],d[k*2+2]);}}
  T query(i a,i b){return q(a,b,0,0,n);}
  T get(i a){return d[n+a-1];}
};
SegTree seg;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    int t;
    cin >> t;
    a.pb(t);
  }
  ll l = 0, r = mod, mid, g = (n*(n+1)/2+1)/2;
  seg.resize(n*2+1);
  while(r-l > 1){
    seg.clear();
    seg.update(n, 1);
    mid = (l + r) / 2;
    int s = 0;
    ll c = 0;
    for(int aa: a){
      s += (aa >= mid) ? 1 : -1;
      c += seg.query(0, s+n+1);
      seg.update(s+n, seg.get(s+n) + 1);
    }
    if (c >= g){
      l = mid;
    }else{
      r = mid;
    }
  }
  cout << l << endl;
  return 0;
}

Measured memory_bytes: 2808
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] edge = new long[N];
		long con = 0;

		for (int i = 0; i < N; i++) {
			edge[i] = sc.nextLong();
		}

		if (N < 3) {
			System.out.println(0);
		}else {
			for (int i = 0; i < N; i++) {
				for (int j = 0; j < N; j++) {
					for (int k = 0; k < N; k++) {
						if (i == j || j == k || k == i) {
							continue;
						}else {
							if (edge[i] + edge[j] > edge[k] && edge[j] + edge[k] > edge[i] && edge[k] + edge[i] > edge[j] && edge[i] < edge[j] && edge[j] < edge[k]) {
								con++;
							}
						}
					}
				}
			}
			System.out.println(con);
		}


	}
}

Measured memory_bytes: 35952
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  multiset<int> st;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    st.insert(a);
  }
  int ans = 0;
  while (st.size()) {
    int cur = *prev(st.end());
    st.erase(prev(st.end()));
    for (int i = 0; i < 31; i++) {
      int t = (1 << i) - cur;
      if (t <= 0) continue;
      if (st.find(t) == st.end()) continue;
      ans++;
      st.erase(st.find(t));
    }
  }
  cout << ans << endl;
  return 0;
}

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

const int N = 5e5+7, RT = 800;
int cnt[N], a[N], out[N], l[N], r[N];
int ans = 0;

void add(int x) {
    if (cnt[x] == 0)    ans++;
    cnt[x]++;
}

void rem(int x) {
    cnt[x]--;
    if (cnt[x] == 0)    ans--;
}


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

    int n, q;
    cin>>n>>q;

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

    vector<int> qq;
    for (int i=1; i<=q; i++) {
        cin>>l[i]>>r[i];
        qq.push_back(i);
    }

    sort(qq.begin(), qq.end(), [](auto a, auto b) {return l[a]/RT != l[b]/RT ? l[a] < l[b] : (r[a] < r[b])^((l[a]/RT)%2);});

    int cl = 1, cr = 0;

    for (int id: qq) {
        while (cr < r[id])  add(a[++cr]);
        while (cl > l[id])  add(a[--cl]);
        while (cr > r[id])  rem(a[cr--]);
        while (cl < l[id])  rem(a[cl++]);

        out[id] = ans;
    }

    for (int i=1; i<=q; i++)    cout<<out[i]<<"\n";
}


Measured memory_bytes: 15528
#include<iostream>
#include<map>
#include<list>
#include<queue>
#include<climits>
using namespace std;
class graph
{
    map<int,list<int>>l;
public:
    void add(int x,int y)
    {
        l[x].push_back(y);
        l[y].push_back(x);
    }
    void bfs(int src,int n)
    {
        map<int,int>visited;
        queue<int>q;
        int c=0;
        for(auto i:l)
        {
            visited[i.first]=INT_MAX;
        }
        q.push(src);
        visited[src]=0;
        while(!q.empty())
        {
            int t=q.front();

            q.pop();
            for(auto i:l[t])
            {
                if(visited[i]==INT_MAX)
                {
                    visited[i]=visited[t]+1;
                    q.push(i);
                }
            }
        }
        for(auto i:visited)
        {
            if(i.second==2&&i.first==n)
            {
                c++;
                cout<<"POSSIBLE"<<endl;
            }
        }
        if(c==0)
        {
            cout<<"IMPOSSIBLE"<<endl;
        }
    }
};
int main()
{
    graph g;
    int n,m,a,b;
    cin>>n>>m;
    while(m--)
    {
        cin>>a>>b;
        g.add(a,b);
    }
    g.bfs(1,n);
    return 0;
}


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

int main(){

	int n, q;
	cin >> n >> q;
	vector< deque<int> > a(n);
	int querynum = 0;
	while (querynum < q) {
		int var1;
		cin >> var1;
		if (var1 == 0) {
			int var2, var3;
			cin >> var2 >> var3;
			a[var2].push_back(var3);
		}
		else if (var1 == 1) {
			int var2;
			cin >> var2;
			if (!a[var2].empty())  cout << a[var2].front() << endl;
		}
		else {
			int var2;
			cin >> var2;
			if (!a[var2].empty()) a[var2].pop_front();
		}
		querynum++;
	}
	
	return 0;
}


Measured memory_bytes: 4292
import std.stdio;
import std.string, std.conv;
import std.format;

void main() {
  int N = readln().chomp().to!int();
  foreach(ds; 1 .. N + 1) {
    int n = readln().chomp().to!int();
    writefln("Case %d:", ds);
    foreach(i; 0 .. 10) {
      n = format("%08d", n * n)[2 .. 6].to!int();
      writeln(n);
    }
  }
}

Measured memory_bytes: 992
kk = int(input())
if kk < 10:
    print(kk)
    exit()


dp = [[0] * 10 for _ in range(15)]
dp[0] = [1] * 10
for i in range(14):
    #dp[i+1][0] += sum(dp[i])
    for j in range(10):
        for k in range(-1, 2):
            if not (0 <= j + k < 10):
                continue
            dp[i + 1][j + k] += dp[i][j]

a = 0
for i in range(15):
    if a+sum(dp[i][1:]) >= kk:
        break
    a += sum(dp[i][1:])

ii = i


for j in range(1, 10):
    if a + dp[i][j] >= kk:
        kk -= a
        break
    a += dp[i][j]

ans = j
for i in reversed(range(ii)):
    a = 0
    for k in range(-1, 2):
        if not (0 <= j + k < 10):
            continue
        if a + dp[i][j + k] >= kk:
            kk -= a
            j = j + k
            ans = ans * 10 + j

            break
        a += dp[i][j + k]


print(ans)


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


int main() {
    li x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    li dx = x2 - x1;
    li dy = y2 - y1;
    cout << x2 - dy << " " << y2 + dx << " "
         << x2 - dy - dx << " " << y2 + dx - dy << endl;
    return 0;
}

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

typedef long long ll;
using namespace std;

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

	string w[7] = {"thu","fri","sat","sun","mon","tue","wed"};

	int x; cin >> x;
	cout << w[x%7] << endl;	

	return 0;

}




Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

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

    int n;
    cin >> n;
    vector<llong> A;
    A.push_back(0);
    rep(i, n) {
        llong a;
        cin >> a;
        A.push_back(A[i] + a);
    }
    sort(A.begin(), A.end());

    map<llong, llong> M;
    rep(i, n + 1) {
        ++M[A[i]];
    }

    llong ans = 0;
    for (auto itr = M.begin(); itr != M.end(); ++itr) {
        ans += itr->second * (itr->second - 1) / 2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 14320
#include<stdio.h>
#include<math.h>
int main ()
{
	int n;
	while(scanf("%d",&n)!=EOF)
	{
		int i=0;
		while(n/2)
		{
			n/=2;i++;
		}
		i=pow(2,i);
		printf("%d\n",i);
	}
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
#define spln(i,n) (i==n?'\n':' ')
using namespace std;
int n,m,i,j,a[250005],lim[505];
queue<int> tp;
struct ii
{
	int x,id;
}b[505];
bool cmp(ii x,ii y)
{
	return x.x<y.x;
}
int main()
{
	scanf("%d",&n);
	fz1(i,n){
		b[i].id=i;
		scanf("%d",&b[i].x);
		lim[i]=b[i].x;
	}
	sort(b+1,b+n+1,cmp);
	fz1(i,n){
		if(a[b[i].x]){
			puts("No");
			return 0;
		}
		int c=b[i].id-1;
		fz1(j,b[i].x-1){
			if(c&&!a[j]){
				a[j]=b[i].id;
				c--;
			}
		}
		if(c){
			puts("No");
			return 0;
		}
		a[b[i].x]=b[i].id;
		fz1(j,n-b[i].id)tp.push(b[i].id);
	}
	fz1(i,n*n)if(a[i]==0){
		a[i]=tp.front();tp.pop();
		if(i<lim[a[i]]){
			puts("No");
			return 0;
		}
	}
	cout<<"Yes\n";
	fz1(i,n*n)cout<<a[i]<<' ';
	return 0;
}

Measured memory_bytes: 2688
#include<stdio.h>
int main()
{
  int n1,n2,d;
  scanf("%d%d%d",&n1,&n2,&d);
  int sum=0;
  for(int i=n1;i<=n2;i++)
  {
    if(i%d==0)
      sum++;
  }
  printf("%d",sum);
  return 0;
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
ll dp[150000];
ll h[150000];
int main()
{
    int n;
    cin >> n;
    rep(i,n)
    {
        cin >> h[i];
    }
    dp[1] = abs(h[1]-h[0]);
    rep(i,n)
    {
        dp[i] = LINF;
    }
    dp[0] = 0;
    for (int i = 0; i < n; i++)
    {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>
#include <cmath>
#include <map>
#include <cstring>
#include <stack>
#include <cstdio>
#include <complex>
#include <iomanip>
#include <cctype>
#include <cassert>
#include <numeric>
#define rep(i,n) for(int i=0;i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define show(x) cout << #x << " = " << x << endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int>a(n),b(n),c(n);
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        cin >> b[i];
    }
    rep(i,n){
        cin >> c[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll ans = 0;
    rep(i,n){
        int man = b[i];
        ll res = 1;
        res *=(ll) (lower_bound(a.begin(),a.end(),man) -a.begin());
        res *=(ll)(c.end() - upper_bound(c.begin(),c.end(),man));
        ans += res;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1536
from collections import deque

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

tree = dict(zip([i for i in range(1, N+1)], [[] for _ in range(N)]))
for i in range(N-1):
  a, b = map(int, input().split())
  tree[a].append(b)
  tree[b].append(a)

counter = [0] * (N+1)
for i in range(Q):
  p, x = map(int, input().split())
  counter[p] += x

d = deque([[1, 0]])
while d:
  node, parent = d.popleft()
  counter[node] += counter[parent]
  children = tree[node]
  for child in children:
    if child == parent:
      continue
      
    d.append([child, node])
    
  
print(' '.join(map(str, counter[1:])))

Measured memory_bytes: 84172
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  if (s.back() == 's')
    s += "es";
  else
    s += 's';
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <numeric>
#include "math.h"
#include <string>
#include <vector>
#include <iomanip>

#define pai 3.14159265358979323846264338327950288
using namespace std;



// Can't Wait for Holiday
int main() {
	string week[7]{"SAT","FRI","THU","WED","TUE","MON","SUN"};
	string today;

	cin >> today;

	for (int i = 0; i < 7; i++) {
		if (week[i] == today) {
			cout << i + 1 << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;


#define NUM 150000

int main(){
	int table[NUM],limit;

	for(int i=0; i < NUM;i++)table[i] = 1;
	table[0] = 0;
	table[1] = 0;

	limit = sqrt(NUM);

	for(int i=2;i<=limit;i++){
		if(table[i] == 1){
			for(int k=2*i;k < NUM; k += i){
				table[k] = 0;
			}
		}
	}

	int prime_table[NUM],index = 0;

	for(int i = 2; i < NUM; i++){
		if(table[i] == 1){
			prime_table[index++] = i;
		}
	}


	int N,P,work[30],calc[465],count;

	while(true){
		scanf("%d %d",&N,&P);
		if(N == -1 && P == -1)break;

		count = 0;

		for(int i = 0; i < index; i++){
			if(prime_table[i] > N){
				work[count] = prime_table[i];
				count++;
				if(count == 30)break;
			}
		}

		count = 0;

		for(int i = 0; i <= 29; i++){
			for(int k = i; k <= 29; k++){
				calc[count++] = work[i] + work[k];
			}
		}

		for(int i = 1; i <= 464; i++){
			for(int k = 464; k >= i; k--){
				if(calc[k] < calc[k-1])swap(calc[k],calc[k-1]);
			}
		}

		printf("%d\n",calc[P-1]);

	}
	return 0;
}

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

int main(){
  int N,M,C;
  cin >> N >> M >> C;
  vector<int>B(M);
  for(int i=0;i<M;i++){
    cin >> B[i];
  }
  vector<vector<int>>A(N, vector<int>(M,0));
  int count=0;
  int ans=0;
  for(int i=0;i<N;i++){
    count=0;
    for(int j=0;j<M;j++){
      cin >> A[i][j];
      count+=A[i][j]*B[j];
    }
    count+=C;
    if(count>0){
      ans++;
    }
  }
  cout << ans << endl;
}

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

typedef unsigned long long ll;
typedef std::pair<int, int> P;

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define All(i, x) for(typeof(x.begin()) i = x.begin(); i != x.end(); i++)
#define ReAll(i, x) for(typeof(x.end()) i = x.end(); i != x.begin(); i--)
#define pb push_back

const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int MAX = 100000;
const int INF = 1e9;
const int MOD = 1000000007;
const string END = "\n";

void solve(){
	int n; cin >> n;
	if(n == 1){
		cout << "Hello World" << END;
	}else if(n == 2){
		int a, b; cin >> a >> b;
		cout << a + b << END;
	}
}

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


Measured memory_bytes: 256
#include <stdio.h>

int divisors(int a, int div) {
    int count = 0;
    for (int i = 1; i <= a; i++) {
        if (div % i == 0) {
            count++;
        }
    }
    return count;
}

int main(int argc, char const *argv[]) {

    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    printf("%d\n", divisors(b, c) - divisors(a-1, c));

    return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)

using namespace std;
int main(void) {
  lld a, b, c, k;
  cin >> a >> b >> c >> k;
  cout << (min(a, k) - max(k - a - b, 0ll)) << "\n";
}

Measured memory_bytes: 3672
#patthisie D
n,m=map(int,input().split())
lists=[[] for i in range(8)]
for j in range(n):
    a,b,c=map(int,input().split())
    lists[0].append(a+b+c)
    lists[1].append(a+b-c)
    lists[2].append(a-b+c)
    lists[3].append(a-b-c)
    lists[4].append(-a+b+c)
    lists[5].append(-a+b-c)
    lists[6].append(-a-b+c)
    lists[7].append(-a-b-c)
for k in range(8):
    lists[k]=sorted(lists[k],reverse=True)

ans=[]
for j in range(8):
    ans.append(sum(lists[j][:m]))
M=max(ans)
print(M)

Measured memory_bytes: 3316
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mat vector<vector<int>>
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
#define INF (int)1e18


auto max(auto a){auto ans=a[0];for(auto i:a)if(i>ans)ans=i;return ans;}
auto min(auto a){auto ans=a[0];for(auto i:a)if(i<ans)ans=i;return ans;}
void print(auto a){for(auto i:a)cerr<<i<<' ';cerr<<'\n';}


signed main()
{
	fio
	string s;
	cin>>s;
	int n=s.size()+1;
	int b[n]={0};	//1-valley , 2-peak , 3-inc , 4-dec
	if(s[0]=='<')
		b[0]=1;
	else
		b[0]=2;
	fo(i,n-2)
	{
		if(s[i]=='>' && s[i+1]=='<')
			b[i+1]=1;
		else if(s[i]=='<' && s[i+1]=='>')
			b[i+1]=2;
		else if(s[i]=='<' && s[i+1]=='<')
			b[i+1]=3;
		else
			b[i+1]=4;
	}
	if(s[n-2]=='<')
		b[n-1]=2;
	else
		b[n-1]=1;
	// fo(i,n)
		// cout<<b[i]<<' ';
	// cout<<'\n';
	int ans[n]={0};
	fo(i,n)
	{
		if(b[i]==1)
			ans[i]=0;
		else if((b[i]==3 || b[i]==2) && i)
			ans[i]=ans[i-1]+1;
	}
	for(int i=n-1;i>=0;i--)
	{
		if(b[i]==4)
			ans[i]=ans[i+1]+1;
		else if(b[i]==2 && i!=n-1)
			ans[i]=max(ans[i],ans[i+1]+1);
	}
	// fo(i,n)
		// cout<<ans[i]<<' ';
	// cout<<'\n';
	int fans=0;
	fo(i,n)
		fans+=ans[i];
	cout<<fans<<'\n';
	printclock;
}

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

#define REP(i,n) for(int i=0;i<n;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 pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 999999999999

using namespace std;

#define int double

int32_t main(){
	int n, c, k;
	vector<int> t;
	
	cin >> n >> c >> k;
	REP(i, n){
		int x;
		cin >> x;
		t.pb(x);
	}
	SORT(t);

	int ans=1;
	int cnt=1, time=t[0];
	FOR(i, 1, n){
		if((time+k>=t[i]) && cnt<c){
			cnt++;
		}
		else{
			ans++;
			cnt=1;
			time=t[i];
		}
	}
	
	cout << ans << endl;
}

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

int main() {
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int ans = 0;
  rep(i,n) {
    if (i < n && a[i] == a[i+1]) {
      while (i < n && a[i] == a[i+1]) i++;
    }

    if (i < n && a[i] < a[i+1]) {
      while (i < n && a[i] <= a[i+1]) i++;
    } else if (i < n && a[i] > a[i+1]) {
      while (i < n && a[i] >= a[i+1]) i++;
    }
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <climits>
#include <cmath>

using namespace std;

int main() {
  string line;
  cin >> line;

  int n = atoi(line.c_str());
  int sqrtN = sqrt(static_cast<double>(n));

  cout << sqrtN*sqrtN << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a[5],i,j,k,num,l;
    for(i=0;i<5;i++){
        scanf("%d",&a[i]);
    }
    scanf("%d",&k);
    for(i=0;i<4;i++){
        for(j=i+1;j<5;j++){
            num=a[j]-a[i];
            if(l<num){
                l=num;
            }
        }
    }
    if(l<=k){
        printf("Yay!\n");
    }else{
        printf(":(\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;

void call(int n);
void call2(int n);

int main(void) {
    int n;
    
    cin >> n;
    call2(n);
    
    return 0;
}





void call2(int n) {
    for(int i=1; i<=n; i++) {
        if( (i % 3 == 0) || (i % 10 == 3) ) { //3????????° or 1?????????3
            cout << " " << i;
        } else {
            int x = i/10; //????¨????????????????????????°10??§?????£????¬???????????????§??????
            while(x) { //10??§?????£?????????0????????????x???10???????°????????????????????????§??°????????? => ??¨???????????§?????????????????¨?????????
                if( x % 10 == 3 ) {
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }
    }
    
    cout << endl;
}

Measured memory_bytes: 3076
#include<stdio.h>

int main(){

   int a,i,max,min,b[100];

   scanf("%d",&a);
   for(i=0;i<a;i++){
      scanf("%d",&b[i]);
   }
   max=b[0];
   min=b[0];

   for(i=0;i<a;i++){
      if(max<b[i]) max=b[i];
      else if (min>b[i]) min=b[i];
   }
   printf("%d",max-min);
   return 0;
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)

max_num, *p = A

node_num = N-1

q = [(2*i <= node_num) + (2*i+1 <= node_num) for i in range(1, node_num+1)]

# print(q)
# print(max_1, max_2, sum(p_i*q_i for p_i, q_i in zip(p, q)))
r = max_num + sum(p_i*q_i for p_i, q_i in zip(p, q))
print(r)

Measured memory_bytes: 31408
#include <cstdio>
#include <algorithm>
using namespace std;
int N, C, tx, d[31][100001], ans;
int main() {
  scanf("%d %d", &N, &C);
  for(int i = 1, s, t, c; i <= N; ++i) {
    scanf("%d %d %d", &s, &t, &c);
    d[c][s]++, d[c][t]--, tx = max(tx, t);
  }
  for(int c = 1; c <= C; ++c) {
    for(int t = 2; t <= tx; ++t) {
      if(d[c][t] > 0) d[c][t-1]++, d[c][t]--;
    }
  }
  for(int t = 1; t <= tx; ++t) {
    d[0][t] = d[0][t-1];
    for(int c = 1; c <= C; ++c) d[0][t] += d[c][t];
    ans = max(ans, d[0][t]);
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 12288
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::iter::Iterator;
use std::collections::*;
use std::cmp::*;
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }
  
  #[allow(unused_macros)]
  macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
    s:Chars
    }

    let mut num =0;
    for i in 0..s.len() {
       num += s[i] as i32 - 48;
    }

    if num % 9 == 0 {
      println!("Yes");

    }else{
      println!("No");

    }

}


Measured memory_bytes: 3028
#include <cstdio>
#include <algorithm>

using namespace std;

const int MAX_N=100000;

int N;
int ill[MAX_N];

int line[MAX_N],line2[MAX_N];

int main(){
	scanf("%d",&N);
	int i;
	for (i=0;i<N;i++){
		scanf("%d",ill+i);
	}
	int ma=1;
	line[0]=1;
	for (i=1;i<N;i++){
		if (ill[i-1]!=ill[i]){
			line[i]=line[i-1]+1;
			ma=max(ma,line[i]);
		}
		else{
			line[i]=1;
		}
	}
	line2[N-1]=1;
	for (i=N-2;i>=0;i--){
		if (ill[i+1]!=ill[i]){
			line2[i]=line2[i+1]+1;
		}
		else{
			line2[i]=1;
		}
	}
	int s=0,t=0;
	while (s<N){
		//s,tを大きくしていく
		while (t<N-1 && ill[t]!=ill[t+1]){
			t++;
		}
		ma=max(ma,t-s+1+(s>0 ? line[s-1] : 0)+(t<N-1 ? line2[t+1] : 0));
		s=t+1;
		t=s;
	}
	printf("%d\n",ma);
	return 0;
}

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

int main()
{
    int N, max = 0, maxNum = 1;
    cin >> N;
    for (int i = 1; i <= N; i++)
    {
        int cnt = 0;
        int num = i;
        while (num % 2 == 0)
        {
            cnt++;
            num /= 2;
        }
        if (max < cnt)
        {
            max = cnt;
            maxNum = i;
        }
    }
    cout << maxNum << endl;
}

Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[100001];
bool a[27];
bool none;
char omg;
int main()
{
	scanf("%s",s);
	int str=strlen(s);
	for(int i=0;i<str;i++)
	{
		a[s[i]-'a']=1;
	}
	for(int i=0;i<26;i++){
		if(a[i]==0)
		{
			none=1;
			omg=i+'a';break;
		}
		
	}
	if(none==0)cout<<"None"<<endl;
	else cout<<omg<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef pair <int, int> pii;

const int INF = 0x3f3f3f3f;
int n, e, t1, t2, timer, st[100005], nd[100005], low[100005];
vector <int> v[100005];
vector <pii> b;

void dfs(int node, int p) {
	st[node] = timer++;
	low[node] = st[node];
	for (int i : v[node]) {
		if (i == p) continue;
		if (st[i] == INF) {
			dfs(i, node);
			low[node] = min(low[node], low[i]);
			if (low[i] > st[node]) {
				b.push_back(make_pair(i, node));
			}
		}
		else if (nd[i] == INF) {
			low[node] = min(low[node], low[i]);
		}
	}
	nd[node] = timer;
}

int main() {
	cin >> n >> e;
	for (int i = 0; i < n; i++) st[i] = INF, nd[i] = INF;
	for (int i = 0; i < e; i++) {
		cin >> t1 >> t2;
		v[t1].push_back(t2);
		v[t2].push_back(t1);
	}
	dfs(0, -1);
//	for (int i = 0; i < n; i++) {
//		cout << st[i] << ' ' << nd[i] << ' ' << low[i] << endl;
//	}
	for (int i = 0; i < b.size(); i++) if (b[i].fi > b[i].se) swap(b[i].fi, b[i].se);
	sort(b.begin(), b.end());
	for (int i = 0; i < b.size(); i++) cout << b[i].fi << ' ' << b[i].se << endl;
	return 0;
}




Measured memory_bytes: 7196
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))+[0]

ans=0
ans+=b[a[0]-1]
for i in range(1,n):
  ans+=b[a[i]-1]
  if a[i]-a[i-1]==1:
    ans+=c[a[i-1]-1]
    
  
  
print(ans)
    

Measured memory_bytes: 3064
N = int(input())
S = input()
 
cnt = 0
for i in range(1000):
  c = str(i).zfill(3)
  if c[0] in S:
        index1 = S.index(c[0])
        if c[1] in S[index1+1:]:
            index2 = index1 + 1 + S[index1+1:].index(c[1])
            if c[2] in S[index2+1:]:
                cnt+=1
print(cnt)

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

typedef long long ll;

int n,x[15],y[15],p[15],D[15],d[15];
ll ans[16];

int main(){

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

    cin>>n;
    for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>p[i];
    memset(ans,0x3f,sizeof(ans));
    ans[0]=0;
    for(int i=0;i<n;i++){
        D[i]=min(abs(x[i]),abs(y[i]));
        ans[0]+=(ll)p[i]*D[i];
    }
    for(int s=0;s<1<<n;s++){
        for(int t=s;;t=(t-1)&s) {
            memcpy(d,D,sizeof(d));
            for(int i=0;i<n;i++){
                if(s>>i&1){
                    if(t>>i&1){
                        for(int j=0;j<n;j++){
                            d[j]=min(d[j],abs(x[i]-x[j]));
                        }
                    }else{
                        for(int j=0;j<n;j++){
                            d[j]=min(d[j],abs(y[i]-y[j]));
                        }
                    }
                }
            }
            ll cur=0;
            for(int i=0;i<n;i++){
                cur+=(ll)d[i]*p[i];
            }
            ans[__builtin_popcount(s)]=min(ans[__builtin_popcount(s)],cur);
            if (!t) {
            	break;
			}
        }
    }
    for(int i=0;i<=n;i++)
		cout<<ans[i]<<endl;

    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct UnionFind {
    UnionFind(int n) : p(n, -1) {}
    int root(int u) {
        return p[u] < 0 ? u : p[u] = root(p[u]);
    }
    int size(int u) {
        return -p[root(u)];
    }
    bool same(int u, int v) {
        return root(u) == root(v);
    }
    void unite(int u, int v) {
        u = root(u);
        v = root(v);
        if (u == v) return;
        if (p[u] > p[v]) swap(u, v);
        p[u] += p[v];
        p[v] = u;
    }
    vector<int> p;
};

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

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

    UnionFind uf(n);

    vector<int> r(n, 1);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;

        uf.unite(a, b);
        r[a]++, r[b]++;
    }

    for (int i = 0; i < k; i++) {
        int c, d;
        cin >> c >> d;
        c--; d--;

        if (uf.same(c, d)) r[c]++, r[d]++;
    }

    for (int i = 0; i < n; i++) {
        cout << uf.size(i) - r[i] << " \n"[i == n - 1];
    }

    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

vector<int> a(4);
string table = "+-*";
string f;

int calc(int a, int b, int op){
	if (op == 0)return a + b;
	else if (op == 1)return a - b;
	else return a*b;
}

int main(){
	while (1){
		bool flag = 0;
		REP(i, 4)cin >> a[i];
		if (!(a[0] || a[1] || a[2] || a[3]))break;
		sort(ALL(a));
		do{
			REP(i, 3){
				REP(j, 3){
					REP(k, 3){
						//cout << "(((" << a[0] << table[i] << a[1] << ")" << table[j]
						//	<< a[2] << ")" << table[k] << a[3] << ")" << endl;
						if (calc(calc(a[0], a[1], i), calc(a[2], a[3], j), k) == 10){
							cout << "((" << a[0] << table[i] << a[1] << ")" << table[k]
								<< "(" << a[2] << table[j] << a[3] << "))" << endl;
							flag = 1;
						}
						else if (calc(calc(calc(a[0], a[1], i), a[2], j), a[3], k) == 10){
							cout << "(((" << a[0] << table[i] << a[1] << ")" << table[j]
								<< a[2] << ")" << table[k] << a[3] << ")" << endl;
							flag = 1;
						}
						if (flag)break;
					}
					if (flag)break;
				}
				if (flag)break;
			}
			if (flag)break;
			//REP(i, 4){
			//	cout << a[i] << " ";
			//}
			//cout << endl;
		} while (next_permutation(ALL(a)));
		if (!flag)cout << 0 << endl;
	}
}

Measured memory_bytes: 3100
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #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;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
const int d=21;
const int nax=(1<<d);
using pii=pair<int,int>;

int n, k;

char wcz[nax];
vector <int> tab[d];

struct S
{
	int m;
	vector <int> trz[d];
	int licz()
	{
		int ret=0;
		for (int i=0; i<=m; i++)
			for (int j=0; j<(1<<i); j++)
				ret+=trz[i][j];
		return ret;
	}
};

pii wyn;

void rek(pii v, S &zbior)
{
	if (zbior.licz()<k)
		return;
	debug() << v;
	if (v.first>wyn.first || (v.first==wyn.first && v.second<wyn.second))
		wyn=v;
	if (!zbior.m)
		return;
	S now[2];
	int mam=zbior.m;
	for (int i=0; i<2; i++)
	{
		now[i].m=mam-1;
		for (int j=0; j<=mam-1; j++)
			now[i].trz[j].resize(1<<j, 0);
	}
	for (int i=0; i<2; i++)
	{
		for (int j=0; j<=zbior.m; j++)
		{
			for (int l=0; l<(1<<j); l++)
			{
				int d=j;
				int w=l;
				while(d>=0)
				{
					if ((w&1)==i)
					{
						w/=2;
						d--;
						break;
					}
					d--;
					w/=2;
				}
				if (d>=0)
					now[i].trz[d][w]+=zbior.trz[j][l];
			}
		}
	}
	for (int h=0; h<2; h++)
		rek({v.first+1, v.second*2+h}, now[h]);
}

int rev(int v, int d)
{
	int ret=0;
	while(d--)
	{
		ret=(ret*2+(v&1));
		v>>=1;
	}
	return ret;
}

int main()
{
	scanf("%d%d", &n, &k);
	for (int i=0; i<=n; i++)
	{
		scanf("%s", wcz);
		for (int j=0; j<(1<<i); j++)
			tab[i].push_back(wcz[rev(j, i)]-'0');
	}
	S start;
	start.m=n;
	for (int i=0; i<=n; i++)
		start.trz[i]=tab[i];
	rek({0, 0}, start);
	debug() << wyn;
	for (int i=0; i<wyn.first; i++)
		printf("%d", (wyn.second&(1<<(wyn.first-1-i)))>0);
	printf("\n");
	return 0;
}


Measured memory_bytes: 36080
#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;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define lli long long int
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define se second;
#define fi first;
#define endl '\n';
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define REP(i,n) for (int i = 1; i <= n; i++)
template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
typedef long long ll;
typedef vector<vector<ll> > matrix;
const ll MOD = 1000000007;
const int K = 9;
const lli mod = 1e9 + 7;
const lli INF = 1e9 + 7;
const lli N=2*1e5;
lli visit[400001];
map<lli,vector<lli> >g;
map<string,lli>pi,m1,m2;
lli var1,var2,var3,var4,var5,var6;
vector<lli>v,v1,v2,v3,v4;
lli X[10][10];
string a,b;
lli n,m,l,t,r,q,p,k,x,y;
lli ans=0,ans1=0,ans2=0,ans3=0;
lli dp[N],cp[N][5];
int main(){
  _
  cin>>n;
  for(lli i=0;i<n;i++){
    cin>>x;
    v.pb(x);
  }
  dp[1]=abs(v[0]-v[1]);
  for(lli i=2;i<n;i++){
    dp[i]=min(dp[i-2]+abs(v[i]-v[i-2]),dp[i-1]+abs(v[i]-v[i-1]));
  }
  cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 5236
#include <stdio.h>
#include <math.h>

#define maxn 10000

int primejudge(int t){
	int c;
	int k = (int)sqrt(t);
	if(t==1)return 0;
	for(c=2;c<=k;c++)if(t%c==0)return 0;
	return 1;
}

int main(void){
	int n,c;
	int t[maxn];
	int res=0;
	scanf("%d",&n);
	for(c=0;c<n;c++){
		scanf("%d",&t[c]);
	}
	for(c=0;c<n;c++){
		if((primejudge(t[c]))==1)res++;
	}
	printf("%d\n",res);
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, i;
    cin >> n;
    vector<int> a(n);
    map<int, long long> cnt;
    for (i=0; i<n; i++)
	{
	   cin>>a[i];
	   cnt[a[i]]++;
	}
	long long ret = 0;
    map<int,long long>::iterator p;
    for(p=cnt.begin(); p!=cnt.end(); p++)
       ret+=(p->second - 1)*p->second / 2;
	for(int k=0; k<n; ++k) 
	{
        long long n=cnt[a[k]];
        long long tmp=ret-(n-1)*n/2+(n-2)*(n-1)/2;
        cout<<tmp<<"\n";
    }
    return 0;
}

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

int main() {
  string f, s;
  cin >> f >> s;
  
  bool ok = true;
  for(int i = 0; i < 3; i++){
    if(f.at(i) != s.at(2-i)) ok = false;
  }
  
  if(ok) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3632