akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
typedef pair<int, int> p;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9



int main() {
	int n;
	int x, y;
	cin >> n >> x >> y;

	cout << min(x, y) << " ";

	if (n - x - y > 0) cout << 0 << endl;
	else cout << x + y - n << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<ll> v32;
typedef vector<vector<ll> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1e9+7 ;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define vvv64 vector<vv32>
#define vvvv64 vector<vvv32>
 
ll exp(ll n, ll e)
{
    if (e==0)
        return 1;
    ll temp=exp((n*n)%MOD,e/2);
    return e%2==0 ? temp : (temp*n)%MOD;
}
void norm(ll &n)
{
    n%=MOD;
    n+=MOD;
    n%=MOD;
}


void solve()
{
    ll h,a;
    cin>>h>>a;
    ll ans=h/a;
    if (h%a!=0)
        ans++;
    cout<<ans<<endl;
}
 
int main() {
    fast_cin();
    int t=1;
    while (t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define MAX 2000000

void insert(int);
void delete(int);
void deleteFirst(void);
void deleteLast(void);

int top=0, tail=0, L[MAX];

int main(void)
{
	int i, n, x;
	char str[12];
	
	scanf("%d",&n);
	for (i=0; i<n; i++) {
		scanf("%s",str);
		if( strcmp(str, "insert") == 0 ) {
			scanf("%d",&x);
			insert(x);
		} else if( strcmp(str, "delete") == 0 ) {
			scanf("%d",&x);
			delete(x);
		} else if( strcmp(str, "deleteFirst") == 0 ) {
			deleteFirst();
		} else if( strcmp(str, "deleteLast") == 0 ) {
			deleteLast();
		}
	}
	while( L[tail+1] == -1 ) {
		tail++;
	}
	for (i=top; i>tail+1; i--) {
		if(L[i] != -1) printf("%d ",L[i]);
	}
	printf("%d\n",L[tail+1]);
	
	return 0;
}

void insert(int x)
{
	top++;
	L[top] = x;
}

void delete(int x)
{
	int i=top;
	L[tail] = x;
	while(1) {
		if( L[i] == x ) {
			L[i] = -1;
			break;
		}
		i--;
	}
}

void deleteFirst(void)
{
	while(1) {
		if( L[top] == -1) {
			top--;
		} else {
			break;
		}
	}
	top--;
}

void deleteLast(void)
{
	while(1) {
		if( L[tail+1] == -1) {
			tail++;
		} else {
			break;
		}
	}
	tail++;
}

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

using namespace std;

void outputArray(vector<int> array)
{
	for (int i = 0; i != array.size(); ++i)
	{
		cout << array[i];
		if (i + 1 != array.size())
		{
			cout << " ";
		}
	}
	cout << endl;
}

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

	vector<int> array(number);
	for (int i = 0; i != number; ++i)
	{
		cin >> array[i];
	}

	int count = 0;
	for (int i = 0; i != number; ++i)
	{
		int minJ = i;
		for (int j = i+1; j != number; ++j)
		{
			if (array[minJ] > array[j])
			{
				minJ = j;
			}
		}
		if (minJ != i)
		{
			swap(array[minJ], array[i]);
			//outputArray(array);
			++count;
		}
	}
	

	outputArray(array);
	cout << count << endl;

	return 0;
}


Measured memory_bytes: 3140
#include<stdio.h>
#include<math.h>
int main()
{
  int n,p,flag=0,a=0,k,j;
  double q;
  scanf("%d",&n);
  
  for(int i=0; i<n; i++){
    flag=0;
    scanf("%d",&p);
    if(p==2||p==3||p==5||p==7)//値が2の時
      flag=1;
    else if(p<2||p%2==0)//値が２以下もしくは偶数のとき
      flag=2;
    
    if(flag==0){
      q=sqrt(p);
      for(j=3; j<=q; j+=2){
	if(p%j==0){
	  flag=0;
	  break;
	}
	else
	  flag=1;
      }
      
      
    }
    //    printf("n:%d flag:%d\n",p,flag);
    if(flag==1)
      a++;
  }
  
  printf("%d\n",a);
return 0;
}


Measured memory_bytes: 2064
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

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

uf = UnionFind(N)
for i in range(M):
    x,y,z = map(int, input().split())
    uf.union(x-1,y-1)

print(uf.group_count())




Measured memory_bytes: 7856
#include <stdio.h>
#include <stdbool.h>
#include <string.h>

typedef struct
{
	int first;
	int second;
} P;

P max(P a, P b)
{
	if (a.first == b.first)
	{
		if (a.second > b.second)
			return a;
		else
			return b;
	}
	else if (a.first > b.first)
		return a;
	else
		return b;
}

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

int n, m;
int cave[1111][1111];
bool is_prime[1111111];
P memo[1111][1111];
P none;

P dfs(int x, int y)
{
	if (memo[x][y].first != -1 && memo[x][y].second != -1)
	{
		return memo[x][y];
	}
	P res;
	res.first = 0;
	res.second = 0;
	int xx;
	for (xx = x - 1; xx <= x + 1; xx++)
	{
		if (xx >= 0 && xx < 1111 && y + 1 >= 0 && y + 1 < 1111 && cave[xx][y + 1] != 0 && cave[xx][y + 1] <= m)
		{
			res = max(res, dfs(xx, y + 1));
		}
	}
	if (is_prime[cave[x][y]])
	{
		res.first++;
		if (res.second == 0)
		{
			res.second = cave[x][y];
		}
	}
	return memo[x][y] = res;
}

int main(void)
{
	memset(is_prime, 1, sizeof(is_prime));
	is_prime[0] = is_prime[1] = false;
	int i, j;
	for (i = 0; i < 1111111; i++)
	{
		if (is_prime[i])
		{
			int j;
			for (j = i * 2; j < 1111111; j += i)
			{
				is_prime[j] = false;
			}
		}
	}
	int num = 1;
	int x = 1111 / 2;
	int y = 1111 / 2;
	int len = 1;
	int dir = 0;
	none.first = -1;
	none.second = -1;
	while (true)
	{
		for (i = 0; i < 2; i++)
		{
			for (j = 0; j < len; j++)
			{
				cave[x][y] = num++;
				x += dx[dir];
				y += dy[dir];
			}
			dir = (dir + 1) % 4;
		}
		if (num > 1000000)
		{
			break;
		}
		len++;
	}
	while (true)
	{
		scanf("%d %d", &m, &n);
		if (n == 0)
		{
			break;
		}
		int sx, sy;
		for (i = 0; i < 1111; i++)
		{
			for (j = 0; j < 1111; j++)
			{
				if (cave[i][j] == n)
				{
					sx = i;
					sy = j;
				}
			}
		}
		for (i = 0; i < 1111; i++)
		{
			for (j = 0; j < 1111; j++)
			{
				memo[i][j] = none;
			}
		}
		P ans = dfs(sx, sy);
		printf("%d %d\n", ans.first, ans.second);
	}
	return 0;
}


Measured memory_bytes: 16896
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MP make_pair
#define MT make_tuple
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

LL gcd(LL a, LL b){
	LL c;
	while ( a != 0 ) {
	 c = a; a = b%a;  b = c;
	}
	return b;
}

LL lcm( int m, int n ){
	if ((0 == m) || (0 == n)) return 0;
	return ((m / gcd(m, n)) * n);
}

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

	int N;
	cin >> N;

	LL T = 1, A = 1;
	REP(i, N){
		LL t, a;
		cin >> t >> a;

		LL l = 1, r = 1e18 / max(t, a);
		while(l + 1 < r){
			LL mid = (l + r) / 2;
			LL tt, at;
			tt = (mid - 1) * t;
			at = (mid - 1) * a;
			if(T > tt || A > at){
				l = mid;
			}
			else{
				r = mid;
			}
		}
		T = (l + r) / 2 * t;
		A = (l + r) / 2 * a;
		//cout << T << " " << A << endl;
	}

	cout << T + A << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(ll key, ll value){
      this->key = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  cin >> N;
  vll h(N);
  rep(i, 0, N){
    cin >> h[i];
  }

  ll ans = 0;

  bool flag=true;
  while(flag){
    flag = false;
    ll l=-1, r=N;
    for(int i=0; i<N; ++i){
      if(!flag && h[i]>0){
        flag=true;
        l=i;
      }
      if(flag && h[i]==0){
        r=i;
        break;
      }
    }
    if(!flag) break;
    ans++;
    for(int i=l; i<r; ++i){
      h[i]--;
    }
  }

  cout << ans << "\n";

  return 0;
}

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

int main() {
	int N; cin >> N;
	double ans=0;
	for(int i=0; i<N; ++i){
	    double x;
	    string u;
	    cin >> x >> u;
	    if(u=="JPY") ans += x;
	    else ans += x*380000.0;
	}
	cout << setprecision(10) << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n1,n2,n3,n4,n5,n6=map(int,raw_input().split())
act=raw_input()
for i in act:
    if i=="N":
        n11=n1
        n1=n2
        n2=n6
        n6=n5
        n5=n11
    elif i=="S":
        n11=n1
        n1=n5
        n5=n6
        n6=n2
        n2=n11
    elif i=="E":
        n11=n1
        n1=n4
        n4=n6
        n6=n3
        n3=n11
    else :
        n11=n1
        n1=n3
        n3=n6
        n6=n4
        n4=n11
print(n1)

Measured memory_bytes: 6336
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
int main() {

	int n, k; cin >> n >> k;
	vector<int> arr;
	for (int i = 0; i < k; i++) {
		int d; cin >> d;
		arr.pb(d);
	}
	int ans = n;
	while (true) {

		int tmp = ans;
		bool check = true;
		while (check && tmp > 0) {
			int rem = tmp % 10;
			if (find(arr.begin(), arr.end(), rem) != arr.end()) {
				check = false;
			}
			if (check) tmp /= 10;
			else {
				ans += 1;
				break;
			}
		}
		if (check) break;
	}
	cout << ans;
	return 0;
}

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


int main() {
  string a, b, c;
  cin >> a >> b >> c;
    
  cout << 'A' << b[0] << 'C' << endl;  
  return 0;
  
}

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

#define NDEBUG
#ifdef DEBUG
#include "cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

#define INTSPACE 12
char _buf[INTSPACE*1000000 + 3];

int loadint() {
    if (fgets(_buf, INTSPACE+3, stdin)==NULL) return 0;
    return atoi(_buf);
}
int loadvec(vector<int>& v, int N=-1) {
    if (N == -1) {
        N = loadint();
        if (N==0) return 0;
    }
    int bufsize = INTSPACE*N + 3;
    if (fgets(_buf, bufsize, stdin)==NULL) return 0;
    v.resize(N);

    int i=0;
    bool last = false;
    for (char *p=&_buf[0]; ;) {
        char *q = p;
        while (*q > ' ') ++q;
        if (*q == 0x0D || *q == 0x0A) last = true;
        *q = 0;
        v[i++] = atoi(p);
        if (last || i == N) break;
        p = q+1;
    }
    // assert(i <= N);
    return i;
}

ll solve(int N, int K, vi& a) {
    map<int,int> m;
    for(int x:a) ++m[x];
    vector<ii> ml;
    for(auto p:m) ml.pb(ii(p.second,p.first));
    sort(ALL(ml));
    if (ml.size() <= K) return 0;
    
    ll cnt = 0;
    rep(i, ml.size()-K) {
        cnt += ml[i].first;
    }
    return cnt;
}

int main() {
    vi a;
    loadvec(a,2);
    int N=a[0], K=a[1];
    loadvec(a,N);
    cout << solve(N,K,a) << endl;
    return 0;
}


Measured memory_bytes: 13816
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BSmallAndLargeIntegers {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    ll a, b;
	    in >> a >> b;
	    int k;
	    in >> k;

	    set<ll> res;
	    for(int i=a; i<a+k; i++){
	        if(i > b) continue;
            res.insert(i);
	    }
	    for(int i=b-k+1; i<=b; i++){
	        if(i < a) continue;
	        res.insert(i);
	    }

	    for(auto const& e : res){
	        out << e << endl;
	    }
	}
};


int main() {
	BSmallAndLargeIntegers solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main() {
  struct Face {int h, w;};
  vector<Face> face(6);
  for(auto& i: face) cin >> i.h >> i.w;
  for(auto& i: face) if(i.h > i.w) swap(i.h, i.w);
  sort(begin(face), end(face), [](auto lhs, auto rhs) {return lhs.h != rhs.h ? lhs.h < rhs.h : lhs.w < rhs.w;});
  vector<int> length;
  for(auto i: face) length.push_back(i.h);
  for(auto i: face) length.push_back(i.w);
  auto same = [&](int b, int e) {return all_of(begin(length) + b, begin(length) + e + 1, [&](int x) {return x == length[b];});};
  cout << (same(0, 3) && same(4, 7) && same(8, 11) ? "yes" : "no") << endl;
}

Measured memory_bytes: 3132
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;



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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String str = br.readLine();
		
		int n = Integer.parseInt(str);
		
		String[] arr = br.readLine().split(" ");
		
		
		
		
		
		int count = n-1;
		String out="";
		for(int i =0;i<arr.length;i++){
			out += arr[count]+" ";
			count--;
		}
		String result = out.trim();
		
		System.out.println(result);
	}
}

Measured memory_bytes: 24260
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
const int MAXN=1e5+7;
int p[MAXN],dep[MAXN]; 
vector<int> son[MAXN];
void dfs (int cur,int d) {
	dep[cur]=d;
	for (int i=0;i<son[cur].size();i++) {
		dfs (son[cur][i],d+1);
	}
}
int main () {
	int n;
	scanf ("%d",&n);
	memset (p,-1,sizeof(p));
	for (int i=0;i<n;i++) {
		int id,k;
		scanf ("%d%d",&id,&k);
		for (int j=0;j<k;j++) {
			int tmp;
			scanf ("%d",&tmp);
			son[id].push_back(tmp);
			p[tmp]=id;
		}
	}
	for (int i=0;i<n;i++) {
		if (p[i]==-1) {
			dfs (i,0);
			break;
		}
	}
	for (int i=0;i<n;i++) {
		printf ("node %d: parent = %d, depth = %d, ",i,p[i],dep[i]);
		if (p[i]==-1) printf ("root, [");
		else if (son[i].empty()) printf ("leaf, [");
		else printf ("internal node, [");
		for (int j=0;j<son[i].size();j++) {
			if (j>0) printf (", ");
			printf ("%d",son[i][j]);
		}
		printf ("]\n");
	}
    return 0;
}


Measured memory_bytes: 6568
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  int ans = n/3;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from bisect import bisect_right
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ruisekiwa_of_a = [0]
ruisekiwa_of_b = [0]
for a in A:
    ruisekiwa_of_a.append(ruisekiwa_of_a[-1]+a)
for b in B:
    ruisekiwa_of_b.append(ruisekiwa_of_b[-1]+b)
# print(ruisekiwa_of_a)
# print(ruisekiwa_of_b)
ans = 0
for i in range(N+1):
    if ruisekiwa_of_a[i] > K:
        continue
    tmp = i
    tmp += bisect_right(ruisekiwa_of_b, K-ruisekiwa_of_a[i])-1
    ans = max(ans, tmp)
print(ans)


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

using namespace std;
using ll = long long;

int main(void) {
  string s, t;
  cin >> s >> t;
  int ans = t.size();
  for (int i = 0; i <= s.size() - t.size(); i++) {
    int tans = 0;
    for (int j = 0; j < t.size(); j++) {
      if (s[i + j] == t[j]) {
        tans++;
      }
    }
    ans = min(ans, (int)(t.size() - tans));
  }
  cout << ans << endl;
  return 0;
}

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

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long;
using pll = pair<ll, ll>;

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    const auto ans = max(a * c, max(a * d, max(b * c, b * d)));

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
//#include <algorithm>
//#include <vector>
//#include <unordered_map>
//#include <map>
//#include <queue>
//#include <cstring>

//#include <bits/stdc++.h>

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}


#define MOD		1000000007
#define ll		long long int
#define pll		pair<ll, ll>
#define pb		push_back
#define endl	"\n"
#define f 		first
#define s 		second
#define fastio 	ios_base::sync_with_stdio(false);cin.tie(NULL)
#define all(v)  (v).begin(), (v).end()
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)

ll power(ll x, ll y) { ll ans = 1; x %= MOD; while (y) {if (y & 1)ans = (x * ans) % MOD; x = (x * x) % MOD; y >>= 1;} return ans;}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};



void solve() {
    int n;
    cin >> n;
    ll ans = 0;
    for(int i = 1; i < n; i++) {
        ans += ((n - 1)/i);
    }
    cout << ans << endl;
}

int main() {
    fastio;
    solve();
}


Measured memory_bytes: 3648
S = input()
YYMM = 0
MMYY = 0
if int(S[2:]) <= 12 and int(S[2:]) > 0:
  YYMM = 1
if int(S[:2]) <= 12 and int(S[:2]) > 0:
  MMYY = 1
  
if YYMM == 1 and MMYY == 1:
  print('AMBIGUOUS')
elif YYMM == 0 and MMYY == 0:
  print('NA')
else:
  if YYMM == 1:
    print('YYMM')
  else:
    print('MMYY')

Measured memory_bytes: 3064
//////////////** SATYAM * SHIVAM * SUNDARAM **////////////
/**
* author: G.Pavan Kumar
**/

#include<bits/stdc++.h>
using namespace std;

#define eps 10e-9
#define mod 1000000007
#define ump unordered_map // operations take less time compared to map
#define pb push_back
#define mp make_pair
#define B begin()
#define E end()
#define F first
#define S second
#define ins insert
#define pof pop_front()
#define pob pop_back()
#define cnt(x) count(x)
#define ety empty()
#define mae *max_element
#define mie *min_element
#define acc accumulate
#define bs binary_search
#define rep(i,l,h) for(int i=l;i<h;i++)
#define ds1(i,x) for(auto i=x.begin();i!=x.end();i++)
#define ds2(i,x) for(auto i:x) // easy method to iterate through a ds
#define sq(a) (a)*(a)
#define fib(n) ceil(pow((1+sqrt(5),n)-pow((1-sqrt(5),n)/(float)(pow(2,n)*sqrt(5)
#define FIO {ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define dig(n) (int)(log10(n)+1)
#define ss(x,k) substr(x,k)  // x is the start pos and k is the length of substr.
#define f(x) find(x)


typedef long long ll;
typedef long l;
typedef string str;
typedef vector<int> vi;
typedef vector<pair<int,int> > vpii;
typedef pair<int,int> pii;
typedef pair<str,int> psi;
typedef pair<ll,int> pli;
typedef ump<int,int> umpii;


int main(){
	FIO
	
	int a,b,c;cin>>a>>b>>c;
	int c5=0,c7=0;
	if(a==5)c5++;if(b==5)c5++;if(c==5)c5++;
	if(a==7)c7++;if(b==7)c7++;if(c==7)c7++;
	
	if(c5==2 && c7==1)cout<<"YES";
	else cout<<"NO";
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     ll t,n,k,i,j,x,y,c=0,m=0;
     ll a[102];
     ll w[102];
     cin>>n>>k;
     for(i=0;i<n;i++)
     {

         cin>>w[i]>>a[i];
         m+=a[i];
     }
     //vector<pair<double,int> >r;
     ll res[m+1];
     for(i=1;i<m+1;i++)
     {
         res[i]=INT_MAX;
     }
     res[0]=0;
     //memset(res,INT_MAX,sizeof(res));

     for(i=0;i<n;i++)
     {
         for(j=m;j>=a[i];j--)
         {
             res[j]=min(res[j],res[j-a[i]]+w[i]);
         }
     }
     for(i=m;i>=0;i--)
     {
         //cout<<res[i]<<" "<<"\n";
         if(res[i]<=k)
         {
             cout<<i<<"\n";
             break;
         }
     }
    // cout<<c<<"\n";
    return 0;
}


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

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> sn(n);
    for(int i=0;i<k;i++){
        int d;
        cin>>d;
        int a;
        for(int j=0;j<d;j++){
            cin>>a;
            sn[a-1]++;
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(sn[i]==0)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
using namespace std;
int main (){
    int n, key, s;
    cin >> n ;
    int a[n];
    for ( int t = 0; t < n; t ++){
        cin >> a[t];
    }
    for (int t = 0; t < n; t++){
        if (t != 0) cout << " " << a[t];
        else  cout << a[t];
    }
    cout << endl;
    for (int i = 1; i < n; i ++ ){
        s = i ;
        key = a[i];
        while (key < a[i - 1] && i >= 1){
            a[i] = a[i - 1];
            a[i - 1] = key;
            i -= 1;
        }
        i = s;
        for (int k = 0; k < n; k++){
            if (k != 0) cout << " " << a[k];                
            else  cout << a[k];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
#include <cstdlib>
#include <map>
using ll = long long int;
using namespace std;

int main()
{
    vector<vector<int>> C(3);
    for (int i = 0; i < 3; i++)
    {
        vector<int> c(3);
        for (int j = 0; j < 3; j++)
        {
            cin >> c[j];
        }
        C[i] = c;
    }
    vector<int> Atotal(3, 0);
    for (int i = 0; i < 3; i++)
    {
        Atotal[i] += (C[0][i] + C[1][i] - 2 * C[2][i]);
    }
    bool Aflag = false, Bflag = false;
    for (int i = -100; i <= 100; i++)
    {
        for (int j = -100; j <= 100; j++)
        {
            for (int k = -100; k <= 100; k++)
            {
                int tmp = i + j - 2 * k;
                if ((tmp == Atotal[0]) && (tmp == Atotal[1]) && (tmp == Atotal[2]))
                {
                    Aflag = true;
                    break;
                }
            }
            if (Aflag)
            {
                break;
            }
        }
        if (Aflag)
        {
            break;
        }
    }
    vector<int> Btotal(3, 0);
    for (int i = 0; i < 3; i++)
    {
        Btotal[i] += (C[i][0] + C[i][1] - 2 * C[i][2]);
    }
    for (int i = -100; i <= 100; i++)
    {
        for (int j = -100; j <= 100; j++)
        {
            for (int k = -100; k <= 100; k++)
            {
                int tmp = i + j - 2 * k;
                if ((tmp == Btotal[0]) && (tmp == Btotal[1]) && (tmp == Btotal[2]))
                {
                    Bflag = true;
                    break;
                }
            }
            if (Bflag)
            {
                break;
            }
        }
        if (Bflag)
        {
            break;
        }
    }
    if (Aflag && Bflag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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

	int n;
	int ans = INF;
	cin >> n;

	for (int a = 1; a < n;a++) {
		int b = n - a;
		int sum = 0;
		string s = to_string(a);
		string t = to_string(b);
		for (char c : s) sum += c - '0';
		for (char c : t) sum += c - '0';
		ans = min(ans, sum);
	}
	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<string>
#include<iostream>
using namespace std;

vector<vector<int> >g;
int n,m,q,s,t;

vector<bool>visited;
vector<int>color;
void dfs(int s){
    for(int i=0;i<g[s].size();i++){
        if(color[g[s][i]]==-1){
            color[g[s][i]]=color[s];
            dfs(g[s][i]);
        }
    }
}
bool dfs2(int s,int t){
    if(s==t)return true;
    visited[s]=true;
    for(int i=0;i<g[s].size();i++){
        if(!visited[g[s][i]]){
            if(dfs2(g[s][i],t)){
                return true;
            }
        }
    }
    return false;
}
int main() {
    scanf("%d %d",&n,&m);
    g.resize(n);
    color.resize(n,-1);
    for(int i=0;i<m;i++){
        scanf("%d %d",&s,&t);
        g[s].push_back(t);
        g[t].push_back(s);
    }
    for(int i=0;i<n;i++){
        if(color[i]==-1){
            color[i]=i;
            dfs(i);
        }
    }
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        scanf("%d %d",&s,&t);
        visited.resize(n,false);
        string s1=(dfs2(s,t)?"yes":"no");
        string s2=(color[s]==color[t]?"yes":"no");
        if(s1!=s2&&s1=="yes")return 1;
        cout<<s2<<endl;
    }
    return 0;
}

Measured memory_bytes: 11776
#include<bits/stdc++.h>
using namespace std;
vector<int>uf;

int find(int a){
	if(uf.at(a)==-1)return a;
	return uf.at(a)=find(uf.at(a));
}

bool same(int a,int b){
	return find(a)==find(b);
}

void unite(int a,int b){
	a=find(a),b=find(b);
	if(a==b)return;
	uf.at(a)=b;
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m; cin>>n>>m;
	vector<pair<int,int>>path(m);
	for(auto&&i:path)cin>>i.first>>i.second,--i.first,--i.second;
	int ans=0;
	for(int i=0;i<m;++i){
		uf.resize(n); for(auto&&j:uf)j=-1;
		for(int j=0;j<m;++j){
			if(i==j)continue;
			unite(path.at(j).first,path.at(j).second);
		}
		if(!same(path.at(i).first,path.at(i).second))++ans;
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 3632
#!/usr/bin
# -*- coding="utf-8" -*-
c1 = []
c2 = []
q = input().split()
n = [input().split() for i in range(int(q[1]))]
 
for m in n:
  if m[0] == "1":
    c1.append(m[1])
  if m[1] == q[0]:
    c2.append(m[0])
if set(c1) & set(c2):
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 68324
#include <iostream>
#include <vector>
#include <set>
#include <unordered_map>
//#include "../cxx-prettyprint/prettyprint.hpp"

int timer = 0;
std::unordered_map<int, std::vector<int>> Adj;
std::set<int> nodes_unvisited;
std::unordered_map<int, int> discovered_time;
std::unordered_map<int, int> finished_time;

int dfs(int u) {
    nodes_unvisited.erase(u);
    discovered_time[u] = ++timer;
    for (int v : Adj[u]) {
        if (nodes_unvisited.find(v) != nodes_unvisited.end()) {
            dfs(v);
        }
    }
    finished_time[u] = ++timer;
}

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

    for (int i = 0; i < n; i ++) {
        int u, k;
        std::cin >> u >> k;
        std::vector<int> V(k);
        for (auto& v : V) {
            std::cin >> v;
        }
        Adj[u] = V;
    }

    for (int i = 1; i <= n; i ++) {
        nodes_unvisited.insert(i);
    }

    while (!nodes_unvisited.empty()) {
        int u = *nodes_unvisited.begin();
        dfs(u);
    }

    for (int i = 1; i <= n; i ++) {
        std::cout << i << " " << discovered_time[i]
            << " " << finished_time[i] << std::endl;
    }
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
 
using namespace std;
const long long INF = 1LL <<60;  
 
int main(void){
  long long res=0;
  long long i,j,k;
  long long l,m,h;
  string s;
  long long n_r=0,n_g=0,n_b=0;
  long long n_max=4010;
  long long n;
  long r[n_max]={},g[n_max]={},b[n_max]={};
 
  cin>>n;
  cin>>s;
  for(i=0;i<n;i++){
    if(s[i]=='R'){
      r[n_r]=i;
      n_r++;
    }
    else if(s[i]=='G'){
      g[n_g]=i;
      n_g++;
    }
    else{
      b[n_b]=i;
      n_b++;
    }
  }
  res=n_r*n_g*n_b;
  //cout<<n_r<<" "<<n_g<<" "<<n_b<<endl;
  
  for(i=0;i<n_r;i++){
    for(j=0;j<n_g;j++){
      h=max(r[i],g[j]);
      l=min(r[i],g[j]);
      if(2*l-h>=0 && s[2*l-h]=='B'){
        res--;
      }
      if(2*h-l<n && s[2*h-l]=='B'){
        res--;
      }
      if((h+l)%2==0 && s[(h+l)/2]=='B'){
        res--;
      }
    }
  }
    
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 3736
#include <stdio.h>

// https://atcoder.jp/contests/abc136/tasks/abc136_a

int main(int argc, char *argv[]) {
    int a, b, c, ans;

    scanf("%d %d %d", &a, &b, &c);

    ans = c - (a - b);
    if (ans < 0) {
        ans = 0;
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 128
import itertools
 
def resolve():
    N, M, Q = map(int, input().split())
    a_list = []
    b_list = []
    c_list = []
    d_list = []
 
    for i in range(Q):
        a, b, c, d = map(int, input().split())
        a_list.append(a)
        b_list.append(b)
        c_list.append(c)
        d_list.append(d)

    ans = 0    
    for A in itertools.combinations_with_replacement(range(1,M+1),N):
        score = 0
        for i in range(Q):
            if A[b_list[i]-1] - A[a_list[i]-1] == c_list[i]:
                score += d_list[i]
        ans = max(score, ans)
    print(ans)

 
if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9204
public class Main {
    public static void main(String[] args){
        java.util.Scanner scan = new java.util.Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int sum = 0;
 
        for(int i = a; i <= b; i++){
            if(c % i ==0){
                sum++;
            }
        }
        System.out.println(sum);
    }
 
}

Measured memory_bytes: 26300
import java.util.*;
    public class Main {
    	public static void main(String[] args){
    		Scanner sc = new Scanner(System.in);
    		// 整数の入力
    		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();

		long ans;

		if (a+b+1 > c){
		    ans = c;
		}else{
		    ans = a+b+1;
		}

		ans += b;

    		// 出力
		System.out.println(ans); 
    	}
    }


Measured memory_bytes: 22608
#include <bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) int((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl '\n'
#define ff first
#define ss second
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

template<typename T>   T add(T x, T y, T m) { return ((x % m)  + (y % m)) % m;}
template<typename T>   T mul(T x, T y, T m) { return ((x % m) * (long long)(y % m)) % m;}
template<typename T>   T sub(T x, T y, T m) { return add(x, -y + m);}
template<typename T>   T gcd(T a, T b) { return b ? gcd(b, a % b) : a;}
template<typename T>   T lcm(T a, T b) { return a / gcd(a, b) * b;}

int lg2(long long x)   {   return 64 - __builtin_clzll(x) - 1;	}
int lg2(int x)   {   return 32 - __builtin_clzll(x) - 1;	}

struct pair_hash{
	template<class T1, class T2>
	size_t operator() (const pair<T1, T2> &p) const {
		auto h1 = hash<T1>{}(p.first);
		auto h2 = hash<T2>{}(p.second);
		return h1 ^ h2;
	}
};




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

	int a, b, c;
	cin >> a >> b >> c;
	cout << c << ' ' << a << ' ' << b << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(a%2==1){
            cout<<"first"<<endl;
            return 0;
        }
    }
    cout<<"second"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer n;
  for(n=nil->next; n != nil; n = n->next){
    if(n->key == key ) return n;
  }
  return NULL;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}


void deleteNode(NodePointer t){
  t->next->prev =t->prev;
  t->prev->next=t->next;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if(t == nil)return;
  deleteNode(t);
}

void delete(int key){
  NodePointer t;
 if((t = listSearch(key))!=NULL){
   deleteNode(t);
  }
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev=x;
    nil->next=x;
    x->prev=nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) {deleteFirst();}
	else if ( com[6] == 'L' ) {deleteLast();}
      } else {
	delete(key); nd++; 
      }
      size--;
    }// else if
  }//for
  printList();
  return 0;
}

Measured memory_bytes: 31788
#include <iostream>


int main() {
    int a, b, c;
    std::cin >> a >> b >> c;

    if (a==b && b==c)
    {
        std::cout << "1" << std::endl;
    }
    else if (a==b || b==c || a==c)
    {
        std::cout << "2" << std::endl;
    }
    else
    {
        std::cout << "3" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 99999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    llong n,a[30],b[30],c[30],ans=0;
    cin >> n;
    for(int i=1;i<=n;i++) cin >> a[i];
    for(int i=1;i<=n;i++){
        cin >> b[i];
        ans += b[i];
    }
    for(int i=1;i<n;i++) cin >> c[i];
    
    for(int i=1;i<n;i++){
        if(a[i+1] == a[i]+1){
            ans += c[a[i]];
        }
    };
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<ll> f(n + 1, 0), a(m + 1, 0);
    for (int i = 0; i < m; i++)
    {
        cin >> a[i];
    }
    f[0] = 1;
    int j = 0;
    for (int i = 1; i <= n; i++)
    {
        if (a[j] == i)
        {
            f[i] = 0;
            j++;
        }
        else
            f[i] = f[i - 1] + ((i > 1) ? f[i - 2] : 0);
        f[i] %= MOD;
    }
    cout << f[n] << endl;
}


Measured memory_bytes: 1792
import sys
from collections import *
import heapq
import math
from math import gcd
import bisect
import copy
from itertools import permutations,accumulate,combinations,product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
s=input()
dic={"R":[],"G":[],"B":[]}
for i in range(n):
    if not s[i] in dic:
        dic[s[i]]=[i]
    else:
        dic[s[i]].append(i)
# print(dic)
se=set(dic["B"])
# print(se)
ans=len(dic["R"])*len(dic["G"])*len(dic["B"])
for i in range(len(dic["R"])):
    for j in range(len(dic["G"])):
        l,r=min(dic["R"][i],dic["G"][j]),max(dic["R"][i],dic["G"][j])
        if r+(r-l) in se:
            ans-=1
        if l-(r-l) in se:
            ans-=1
        if (r-l)%2==0 and l+(r-l)//2 in se:
            ans-=1
print(ans)

Measured memory_bytes: 69888
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;
const ll INFll = 1E+18;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b, k;
    cin >> a >> b >> k;
    rep(i, k) {
        if (i%2==1) swap(a, b);
        a = a/2*2;
        b += a/2;
        a = a/2;
        if (i%2==1) swap(a, b);
    }
    cout << a << " " << b << endl;
    
    return 0;
}


Measured memory_bytes: 3652
#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 pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#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 in(x, a, b) ((a) <= (x) && (x) < (b))
#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 solve(vi &used, map<char, int> &calc, vector<char> &mojis, set<char> &notzero, int keta, int sum)
{
    if (keta == mojis.size() && !sum) return 1;
    else if (keta == mojis.size()) return 0;

    int ret = 0;
    rep(i, 10) {
        if (!i && notzero.find(mojis[keta]) != notzero.end()) continue;
        if (!used[i]) {
            used[i] = 1;
            ret += solve(used, calc, mojis, notzero, keta+1, sum + calc[mojis[keta]] * i);
            used[i] = 0;
        }
    }
    return ret;
}

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

    int n;
    while (cin >> n, n) {
        vector<string> input(n);
        vector<char> mojis;
        set<char> notzero;
        map<char, int> calc;
        rep(i, n) {
            cin >> input[i];
            rep(j, input[i].size()) {
                mojis.eb(input[i][j]);
            }
            if (input[i].size() != 1) notzero.insert(input[i][0]);
            if (i+1 == n) {
                rep(j, input[i].size()) {
                    calc[input[i][j]] -= pow(10, (input[i].size() - j - 1));
                }
            } else {
                rep(j, input[i].size()) {
                    calc[input[i][j]] += pow(10, (input[i].size() - j - 1));
                }
            }
        }
        sort(all(mojis));
        auto tmp = unique(all(mojis));
        mojis.erase(tmp, mojis.end());

        vi used(10, 0);
        cout << solve(used, calc, mojis, notzero, 0, 0) << endl;
    }

    return 0;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string n;
    cin >> n;
    ll res = 0;
    rep(i,n.size()){
        if(n.at(i)=='2') res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

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

    ll X[N];
    ll Y[N];
    REP(i, N) {
        cin >> X[i];
        Y[i] = X[i];
    }

    sort(Y, Y+N);
    ll left = Y[N/2-1];
    ll right = Y[N/2];
    
    REP(i, N) {
        cout << (X[i] <= left ? right : left) << endl;
    }

    return 0;
}

Measured memory_bytes: 5248
#include "bits/stdc++.h"
using namespace std;

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, -1)
#define RREP(i, n, k) for(auto i = n; i != k; i--)

#define debug(x) cerr << #x << " " << x << endl
#define print(x) cout << x;
#define println(x) cout << x << endl;
#define spc << " " <<

#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define eb emplace_back
#define np next_permutation

using ll = long long;
using Pii = pair<int, int>;
using Tiii = tuple<int, int, int>;
template<typename T>using V = vector<T>;
template<typename T>using VV = vector<vector<T>>;
using Vi = vector<int>;
using VVi = vector<vector<int>>;

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

    int N, Q; cin >> N >> Q;
    string S; cin >> S;
    Vi dp(S.length(), 0);

    rep(i, S.size()) {
        if (i != 0) dp[i] = dp[i-1];

        if (S[i] == 'A' && i != S.size()-1 && S[i+1] == 'C') {
            dp[i+1] = dp[i] + 1;
            ++i;
        }
    }

    rep(q, Q) {
        int l, r; cin >> l >> r;
        cout << dp[r-1] - dp[l-1] << endl;
    }

//    rep(i, S.size()) {
//        cout << dp[i] << " ";
//    } cout << endl;

    return 0;
}


Measured memory_bytes: 1488