akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int n;
    cin>>n;
    string s;
    cin>>s;
    int pre[n + 2], post[n + 2];
    memset(pre, 0, sizeof(pre));
    memset(post, 0, sizeof(post));
    f(i, n) {
        if(i) pre[i] = pre[i - 1];
        if(s[i] == 'W') pre[i]++;
    }
    for(int i = n - 1; i >= 0; i--) {
        if(i != n - 1) post[i] = post[i + 1];
        if(s[i] == 'R') post[i]++;
    }
    if(pre[ n - 1] == 0) {
        cout<<0;
        return 0;
    }
    int ans = INT_MAX;
    for(int i = 0; i < n - 1; i++) {
        int w = pre[i], r = post[i + 1];
        if(w == 0) continue;
        if(w <= r) {
            ans = min(ans, max(r, w));
        }
    }
    if(ans == INT_MAX) ans = 0;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 6864
#include <stdio.h>
#include <vector>
#define mod 1000000007
using namespace std;

typedef long long ll;

vector<ll> v[1000];
ll s[1000], n;

ll dfs(int a) {
  ll d = 1, i;
  if(s[a] % 3 == 1) d = 0;
  for(i = 0; i < v[a].size(); ++i) {
    ll tmp = dfs(v[a][i]);
    if(s[a] % 3 == 0) {
      d *= tmp;
    } else if(s[a] % 3 == 1) {
     d += tmp;
    } else {
     d *= (tmp + 1);
    }
    d %= mod;
  }
  if(s[a] % 3 == 2) --d;
  if(s[a] / 3) ++d;
  return d;
}

int main(void) {
  ll i, j, k;
  scanf("%lld", &n);
  for(i = 0; i < n; ++i) {
    char c[5];
    scanf("%s", c);
    if(c[0] == 'E') s[i] = 0;
    else if(c[0] == 'A') s[i] = 1;
    else s[i] = 2;
    if(c[1]) s[i] += 3;
  }
  for(i = 1; i < n; ++i) {
    ll ss, t;
    scanf("%lld%lld", &ss, &t);
    ss--, t--;
    v[ss].push_back(t);
  }
  printf("%lld\n", dfs(0));
  return 0;
}


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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
// ll mod_pow(ll x, ll n, ll mod){//x^n % mod
//     if (n == 0)
//         return 1;
//     ll res = mod_pow(x * x % mod, n / 2, mod);
//     if (n & 1)
//         res = res * x % mod;
//     return res;
// }
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int N; cin >> N;
    cout << 180* N - 360 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define IO ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define ll long long int
int main()
{
//	IO;
	int n,sum=0;
	cin>>n;
	int a[n+1];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	int tc;
	cin>>tc;
	while(tc--)
	{
		int p,q;
		cin>>p>>q;
		cout<<(sum-a[p-1])+q<<"\n";	
	}	
}

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

int main(){
    string s;
    string t;
    int count = 0;
    cin >> s >> t;
    int size = s.size();
    for(int i = 0; i < size; i++){
        if(s.at(i) != t.at(i)){
        count += 1;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3920
import sys
input = sys.stdin.readline
import itertools

N, M = map(int, input().split(' '))
path_map = {i:[] for i in range(1, N+1)}
for _ in range(M):
    a, b = map(int, input().split(' '))
    path_map[a].append(b)
    path_map[b].append(a)

ans = 0
for path in itertools.permutations(list(range(1, N+1))):
    if path[0] != 1:
        continue
    exist = True
    for i in range(N-1):
        if not path[i+1] in path_map[path[i]]:
            exist = False
            break
    if exist:
        ans += 1
print(ans)

Measured memory_bytes: 3064
from collections import deque

n = int(input())
abl = []
suml = []
for _ in range(n):
    a,b = map(int, input().split())
    abl.append((a,b))
    suml.append((a+b,a,b))

suml.sort(reverse=True)
q = deque(suml)

asum = 0
bsum = 0
a_turn = True
while q:
    if a_turn:
        _, poped, _ = q.popleft()
        asum += poped
    else:
        _, _, poped = q.popleft()
        bsum += poped
    a_turn = not a_turn

print(asum-bsum)

Measured memory_bytes: 99132
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    int s;
    cin >> s;

    set<int> ss;
    ss.insert(s);
    vector<int> a(1e6 + 10);
    a[1] = s;
    int i = 2;
    while(true){
        if(a[i-1] % 2){
            a[i] = (a[i-1] * 3 + 1);
        }else{
            a[i] = (a[i-1] / 2);
        }
        if(ss.find(a[i]) != ss.end()){
            cout << i << endl;
            return 0;
        }
        ss.insert(a[i]);
        i++;
    }

    return 0;
}


Measured memory_bytes: 8696
#include <iostream>

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

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

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

    ll sum = 0;
    // 3つ同じ
    repe(val, 1, n) {
        // printf("(%d, %d, %d) : %d", val, val, val, val);
        sum += val;
    }

    // 2つ同じ
    ll tsum = 0;
    repe(val1, 1, n) {
        repe(val2, val1 + 1, n) { tsum += gcd(val1, val2); }
    }

    sum += 6 * tsum;

    // 全部違う
    tsum = 0;
    repe(val1, 1, n) {
        repe(val2, val1 + 1, n) {
            repe(val3, val2 + 1, n) { tsum += gcd(gcd(val1, val2), val3); }
        }
    }
    sum += 6 * tsum;

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,s=0;
  cin>>n;
  m=n;
  while(m>0){
    s+=m%10;
    m/=10;
  }
  if(n%s==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3580
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define pb push_back
#define mp make_pair
#define all(a)  (a).begin(),(a).end()
#define dwn(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	int h, w;
	cin >> h >> w;
	string s;
	for (int y = 0; y < h; y++) {
		for (int x = 0; x < w; x++) {
			cin >> s;
			if (s == "snuke") {
				cout << (char)('A' + x) << y + 1 << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <math.h>
#include <bitset>
#include <random>
#include <regex>

using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,f,n) for(int i=f;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1};
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class A, class B> inline A updiv(const A a,const B b){ return (a + b - 1) / b; }
template <class A, class B> inline A gcd(const A a,const B b){ return b ? gcd(b,a % b) : a; }
template <class A, class B> inline A lcm(const A a,const B b){ return a / gcd(a,b) * b; }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;


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

    int a, b, c, k;
    cin >> a >> b >> c >> k;

    if(k < a){
        cout << k << '\n';
    }else if(k <= a + b){
        cout << a << '\n';
    }else{
        cout << a - (k - a - b) << '\n';
    }

    return 0;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

int n, x;
int a[100];
int main(){
	scanf("%d%d", &n, &x);
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	std::sort(a, a+n);
	int sum = 0;
	for(int i = 0; i < n; i++){
		sum += a[i];
		if(sum > x){
			printf("%d\n", i);
			return 0;
		}
	}
	if(sum == x){
		printf("%d\n", n);
	}else{
		printf("%d\n", n-1);
	}
	return 0;
}


Measured memory_bytes: 764
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  string s;
  std::cin >> s;
  int cnt=0;
  if(s[0]=='1') cnt++;
  if(s[1]=='1') cnt++;
  if(s[2]=='1') cnt++;
  std::cout << cnt << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 100010, mod = 1000000007;
int n;
char s[2][N];
int main()
{
	scanf("%d%s%s", &n, s[0] + 1, s[1] + 1);
	bool flag = false;
	long long ans = 1;
	for(int i = 1; i <= n; ++i)
	{
		if(s[0][i] == s[1][i]) 
		{
			if(i == 1) ans = 3;
			else ans = ans * (2ll - (s[0][i - 1] != s[1][i - 1])) % mod; 
		}
		else 
		{
			if(flag) 
			{
				flag = false;
				continue;
			}
			else
			{
				flag = true;
				if(i == 1) ans = 6;
				else if(s[0][i - 1] == s[1][i - 1]) ans = ans * 2ll % mod;
				else ans = ans * 3ll % mod;
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
} 

Measured memory_bytes: 256
#include <cstdio>
const int Mod = 1e9 + 7;
int f[1 << 15], n, m, u[110], v[110], P[110], s[15], d[1 << 15], to[1 << 15];
int main()
{
	scanf("%d %d", &n, &m);
	P[0] = 1; for(int i = 1; i <= m; ++i) P[i] = (P[i - 1] << 1) % Mod;
	for(int i = 1; i <= m; ++i) scanf("%d %d", &u[i], &v[i]);
	int Full = 1 << n;
	for(int i = 1; i < Full; ++i) d[i] = d[i - (-i & i)] + 1;
	for(int i = 1; i <= m; ++i) to[u[i] - 1] |= 1 << v[i] - 1;
	for(int i = 0; i < Full; ++i)
	{
		if(i & 1 ^ i >> 1 & 1);
		else f[i] = 1;
		int t = (i - 1) & i;
		while(t)
		{
			if(i - t & 1 ^ i - t >> 1 & 1 || !f[i - t]);
			else
			{
				int c1 = 0, c2 = 0, tmp = 0;
				for(int j = 0; j < n; ++j) if(i - t >> j & 1) s[j] = 0;
				for(int j = 0; j < n; ++j) 
					if(i - t >> j & 1) s[j] += d[to[j] & t];
					else if(t >> j & 1) c2 += d[to[j] & i - t];
				int g = 1ll * P[c2] * f[i - t] % Mod;
				for(int j = 0; j < n; ++j) if(i - t >> j & 1)
				{
					if(s[j]){ g = 1ll * g * (P[s[j]] - 1) % Mod; }
					else { g = 0; break; }
				}
				f[i] = (f[i] + g) % Mod;
			}
			t = (t - 1) & i;
		}
	}
	printf("%d\n", (P[m] - f[Full - 1] + Mod) % Mod);
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#pragma warning( disable:4996 )
int main() {
	int k, a, b;
	scanf("%d %d %d", &k, &a, &b);
	if (b - a > 2) {
		long long int count = 1;
		if (a < k) {
			count += a - 1;
			k -= a - 1;
		}
		else {
			printf("%d\n", k + 1);
			return 0;
		}
		count += (long long int)k / 2 * (long long int)(b - a);
		if (k % 2) {
			count++;
		}
		printf("%lld\n", count);
	}
	else {
		printf("%d\n", k + 1);
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#define rep(a,b) for(int a=0;a<b;++a)
#define REP(a,b,c,d) for(int a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	int X; cin >> X;
	for (int i = 1; i <= X; ++i) {
		if (i*(i + 1) / 2 >= X) {
			cout << i << endl;
			break;
		}
	}
	cin >> X;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  cout << (s[0] != s[2] ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int a, p;
  cin >> a >> p;
  cout << (3*a+p)/2 << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main(){
   int n;
   scanf("%d", &n);
   vector<double>dp(n+1);
   dp[0]=1;
   double p_h;
   for(int c =0 ;c<n; c++){
       scanf("%lf", &p_h);
       for(int i =  c+1; i>=0; i--){
           dp[i] =  (i == 0? 0:dp[i-1]*p_h) + dp[i] * (1-p_h);
       }
   }
   
   double ans =0, tails; 
   for(int heads =0; heads<=n; heads++){
       tails = n - heads;
       if(heads > tails){
           ans += dp[heads];
       }
   }
    printf("%.10lf", ans);
}


Measured memory_bytes: 256
#include "iostream"
#include "vector"
#include "algorithm"


using namespace std;

int n;

int main() {

    cin >> n;

    vector <int > a(n);

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

    sort(a.begin(), a.end());

    int max = a[n - 1];
    int pair = 0;
    for (int i = 0; i < n - 1; i++) {
        if (abs(max / 2 - a[i]) <= abs(max / 2 - pair)) {
            pair = a[i];
        }
    }
    cout << max << " " << pair << endl;
}

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

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

  std::vector<std::vector<char>> graph(N, std::vector<char>(N, '.'));
  std::vector<std::pair<int, int>> row_white_count(N);
  for (int i = 0; i < N; ++i) {
    int white_num = 0;
    for (int j = 0; j < N; ++j) {
      std::cin >> graph[i][j];
      if (graph[i][j] == '.') {
        white_num += 1;
      }
    }
    row_white_count[i] = std::make_pair(white_num, i);
  }

  std::vector<int> col_white_count(N, 0);
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      if (graph[i][j] == '.') {
        col_white_count[j] += 1;
      }
    }
  }

  std::sort(row_white_count.begin(), row_white_count.end());

  int ans = 0;

  bool candidate_found = false;
  std::vector<int> plus_alpha(N, N + 1);
  for (int i  = 0; i < N; ++i) {
    const auto& current = row_white_count[i];
    // 白がないケース
    if (current.first == 0) {
      candidate_found = true;
      plus_alpha[i] = 0;
      break;
    }
    // 白を黒にできる列があるケース
    if (col_white_count[current.second] != N) {
      plus_alpha[i] = current.first;
      candidate_found = true;
      break;
    } else if (current.first != N) {
      // 白があって，黒にできる列もないが，自分の行を対象の列に1回変換すると行ける
      plus_alpha[i] = current.first + 1;
      candidate_found = true;
      // 次のloopでこのケースよりいい場合が見つかるかもしれないためbreakしない
    }
  }
  if (!candidate_found) {
    std::cout << "-1" << std::endl;
    return 0;
  }
  ans += *std::min_element(plus_alpha.begin(), plus_alpha.end());

  for (int i = 0; i < N; ++i) {
    if (col_white_count[i] != 0) {
      ans += 1;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<iostream>
#define K 100001
using namespace std;
int main()
{
  int n,ans;
  int a[K];
  int b[K]={0};
  ans=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++)
    {
      scanf("%d",&a[i]);
      if(a[i]>n)
	{
	  ans++;
	}
      else
	{
	  b[a[i]]++;
	}
    }
  for(int i=1;i<(n+1);i++)
    {
      if(b[i]<i)
	{
	  ans+=b[i];
	}
      else if(b[i]>i)
	{
	  ans+=b[i]-i;
	}
    }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
    int n, ans;
    
    scanf("%d", &n);

    if(n < 10){
        ans = n;
    } else if(n<100) { 
        ans = 9;
    } else if(n < 1000){
        ans = 9 + (n - 99);
    } else if(n < 10000){
        ans = 9 + (999 - 99);
    } else if(n < 100000){
        ans = 9 + (999 - 99) + (n - 9999);
    } else if(n == 100000){
        ans = 9 + (999 - 99) + (99999 - 9999);
    }

    printf("%d", ans);
}

Measured memory_bytes: 128
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#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;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


void solve(long long N, std::vector<long long> a){
    SORT(a);
    reverse(ALL(a));
    LL ans=0;
    for(int i=0; i <N; i++){
        ans+=a[(i+1)*2-1];
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(3*N);
    for(int i = 0 ; i < 3*N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 2560
while True:
    h, w = [int(num) for num in input().split()]
    if h == w == 0:
        break
    else:
        for i in range(h):
            for j in range(w):
                if i % 2 == 0:
                    if j % 2 == 0:
                        print("#", end="")
                    else:
                        print(".", end="")
                else:
                    if j % 2 == 0:
                        print(".", end="")
                    else:
                        print("#", end="")
            print("")
        print("")



Measured memory_bytes: 7020
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int a = parseInt(sc.next());
		sc.close();
		out.println(n*n-a);
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=200000 +117;
const int MM= +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.cpp.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int m,n;
int a[NN]={};
bool chk(int x){
	for(int i=2*x+1;i<=2*n;++i){
		if(a[2*n+1+2*x-i]+a[i]<m)return false;
	}
	return true;
}
int main(){
	//open();
	n=read();
	m=read();
	for(int i=1;i<=2*n;++i){
		a[i]=read();
	}
	sort(a+1,a+1+2*n);
	int l=0,r=n;
	while(l!=r){
		int mid=(l+r)>>1;
		if(chk(mid)){
			r=mid;
		}
		else l=mid+1;
	}
	int ans=0;
	for(int i=1;i<=l;++i){
		ans=max(ans,a[i]+a[2*l+1-i]);
	}
	for(int i=2*l+1;i<=2*n;++i){
		ans=max(ans,a[2*n+1+2*l-i]+a[i]-m);
	}
	printf("%d\n",ans);
	close();
	return 0;
}

Measured memory_bytes: 1024
import sys


#torf = [[None for _ in range(m)]for _ in range(n)]
#print(torf)
#print(torf[0][0])
#print(torf[1][0])

s = input()
ans =""
if len(s)==1:
    if s[0]=="?":
        print("D")
        sys.exit()
    else:
        print(s[0])
        sys.exit()

if s[0]=="?":
    if s[1]=="D" or s[1]=="?":
        ans = ans+"P"
    else:
        ans = ans + "D"
else :
    ans = ans + s[0]

for i in range(1,len(s)):
    if s[i]=="?":
        if ans[i-1]=="P":
            ans = ans + "D"
        elif ans[i-1]=="D":
            if i<len(s)-1:
                if s[i+1]=="P":
                    ans = ans + "D"
                else:
                    ans= ans + "P"
            else:
                ans = ans + "D"
        else:
            ans = ans + "P"    
    else:
        ans = ans + s[i]
    

print(ans)


Measured memory_bytes: 9588
n = int(input())

limit = 10 ** 18

l = sorted([int(i) for i in input().split()])

flg = True
if l[0] == 0:
    flg = False
    print(0)
else:
    ans = 1
    for i in l:
        if ans > limit:
            print(-1)
            flg = False
            break
        else:
            ans *= i
            
if flg:
    print(ans if ans <= limit else -1)



Measured memory_bytes: 21760
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

map<pair<int, int>, int> solve(const string& s, int& i)
{
    map<pair<int, int>, int> ans;

    if(s[i] == '_'){
        i += 2;
        auto m1 = solve(s, i);
        ++ i;
        auto m2 = solve(s, i);
        ++ i;

        for(const auto a : m1){
            pair<int, int> p(0, a.first.second);
            if(ans.find(p) == ans.end() || a.second < ans[p])
                ans[p] = a.second;
        }
        for(const auto a : m1){
            for(const auto b : m2){
                pair<int, int> p;
                p.first = min(a.first.first, b.first.first);
                p.second = min(a.first.second, b.first.second);
                if(ans.find(p) == ans.end() || b.second < ans[p])
                    ans[p] = b.second;
            }
        }
    }
    else if(s[i] == '^'){
        i += 2;
        auto m1 = solve(s, i);
        ++ i;
        auto m2 = solve(s, i);
        ++ i;

        for(const auto a : m1){
            pair<int, int> p(a.first.first, 99);
            if(ans.find(p) == ans.end() || a.second < ans[p])
                ans[p] = a.second;
        }
        for(const auto a : m1){
            for(const auto b : m2){
                pair<int, int> p;
                p.first = max(a.first.first, b.first.first);
                p.second = max(a.first.second, b.first.second);
                if(ans.find(p) == ans.end() || b.second < ans[p])
                    ans[p] = b.second;
            }
        }
    }
    else{
        int a = s[i] - '0';
        if(a == 0){
            ans[make_pair(0, 0)] = i;
            ++ i;
        }
        else{
            ans[make_pair(a, a * 10 + 9)] = i;
            ++ i;
            if(isdigit(s[i])){
                a *= 10;
                a += s[i] - '0';
                ans[make_pair(a, a)] = i;
                ++ i;
            }
            else{
                ans[make_pair(a, a)] = i;
            }
        }
    }

    return ans;
}

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

    while(--q >= 0){
        string s;
        cin >> s;

        int i = 0;
        auto m = solve(s, i);
        for(auto a : m){
            if(a.first.first == a.first.second){
                cout << a.first.first << ' ' << (a.second + 1) << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, ans;
    cin >> n;
    ans = 0;
    vll a(n+1, 0);
    FOR(i, 1, n) cin >> a[i];
    FOR(i, 1, n){
        if(a[a[i]] == i) ans ++;
    }
    cout << ans/2 <<"\n";
	return 0;
}


Measured memory_bytes: 1024
N, B = map(int,input().split())
R = N-B
T = 1000000007

def generating_combination(n):
	T = 1000000007
	C = C = [[0 for i in range(n+1)] for j in range(n+1)]
	C[0][0] = 1
	C[1][0] = 1
	C[1][1] = 1
	for i in range(2,n+1):
		C[i][0] = 1
		C[i][i] = 1
		for j in range(1,i):
			C[i][j] = (C[i-1][j-1] + C[i-1][j])%T
	return(C)

D = generating_combination(2000)
for i in range(1,B+1):
	print((D[B-1][i-1]*D[R+1][i])%T)

Measured memory_bytes: 99268
//
#include<bits/stdc++.h>
using namespace std;
int h,w;
string s[20];
int dy[4]={-1,0,1,0};
int dx[4]={0,1,0,-1};
int dfs(int sy,int sx)
{
	typedef pair<int,int>P;
	queue<P>q;
	int dist[20][20]; 
	int i,j;
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			dist[i][j]=-1;
		}
	}
	dist[sy][sx]=0;
	q.push(P(sy,sx));
	while(!q.empty())
	{
		P now=q.front();
		q.pop();
		int y=now.first;
		int x=now.second;
		for(int i=0;i<4;i++)
		{
			int ny=y+dy[i];
			int nx=x+dx[i];
			if(ny<0||ny>=h||nx<0||nx>=w)continue;
			if(s[ny][nx]=='#')continue;
			if(dist[ny][nx]==-1)
			{
				q.push(P(ny,nx));
				dist[ny][nx]=dist[y][x]+1;
			}
		}
	}
	int ret=0;
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			ret=max(ret,dist[i][j]);
		}
	}
	return ret;
}
int main()
{
	int i,j;
	cin>>h>>w;
	for(int i=0;i<h;i++)cin>>s[i];
	int ans=0;
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			if(s[i][j]=='#')continue;
			int res=dfs(i,j);
			ans=max(ans,res);
		}
	}
	cout<<ans;
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  map<string, vector<int>> name;
  vector<int> value(N);
  int ti;
  string ts;
  for(int i = 0; i < N; i++){
    cin >> ts >> ti;
    name[ts].push_back(i);
    value.at(i) = ti;
  }

  for(auto itr = name.begin(); itr != name.end(); ++itr){
    int result;
    int check = 101;
    int count = 0;
    vector<int> t_v = itr->second;
    while(true){
      int temp = -1;
      for(int i = 0; i < t_v.size(); i++){
        if(temp < value.at(t_v.at(i)) && check > value.at(t_v.at(i))){
          temp = value.at(t_v.at(i));
          result = t_v.at(i);
        }
      }
        check = temp;
        count++;
        cout << result + 1 << endl;
        if(count == t_v.size()) break;
      }
    }
  }

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define MOD 1000000007

int main(){
    string S;
    cin >> S;
    int N = S.size();
    long long dp1[111111], dp2[111111], dp3[111111];
    for(int i=0; i<N; i++){
        dp1[i] = dp2[i] = dp3[i] = 0;
    }
    if(S[0] == 'A' || S[0] == '?')
        dp1[0] = 1;
    long long fac = 1;
    if(S[0] == '?') fac = 3;

    for(int i=1; i<N; i++){
        if(S[i] == 'A'){
            dp1[i] = (dp1[i-1] + fac) % MOD;
            dp2[i] = dp2[i-1];
            dp3[i] = dp3[i-1];
        }else if(S[i] == 'B'){
            dp1[i] = dp1[i-1];
            dp2[i] = (dp2[i-1] + dp1[i-1]) % MOD;
            dp3[i] = dp3[i-1];
        }else if(S[i] == 'C'){
            dp1[i] = dp1[i-1];
            dp2[i] = dp2[i-1];
            dp3[i] = (dp3[i-1] + dp2[i-1]) % MOD;
        }else{
            dp1[i] = ((3 * dp1[i-1])%MOD + fac)%MOD;
            dp2[i] = ((3 * dp2[i-1])%MOD + dp1[i-1])%MOD;
            dp3[i] = ((3 * dp3[i-1])%MOD + dp2[i-1])%MOD;
            fac *= 3;
	    fac %= MOD;
        }
    }

    cout << dp3[N-1] << endl;
    return 0;
}


Measured memory_bytes: 2944
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {//233
	int n;
	cin>>n;
	vi arr(n);
	for(int &i:arr)cin>>i;
	sort(arr.begin(),arr.end());
	ll sum = 0;
	REP(i,0,n-2)sum+=arr[i];
	if(sum>arr[n-1])cout<<"Yes";
	else cout<<"No";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3656
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define SUM(x)              accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

vector<int> prime_list;
void prime_factorization(int n) {
  while (n % 2 == 0) {
    n /= 2;
    prime_list.push_back(2);
  }
  for (int i = 3; i < (int)(sqrt((double)n)) + 2; i += 2)
    if (n % i == 0)
      while (n % i == 0) {
        n /= i;
        prime_list.push_back(i);
      }
  if (n != 1) prime_list.push_back(n);
}

class CFactorsOfFactorial {
public:
  static void solve(istream &cin, ostream &cout) {
    int N;
    cin >> N;
    int ans = 1;
    vector<int> check(N + 1);
    REP(i, 1, N + 1) {
      prime_list = {};
      prime_factorization(i);
      FOR(i, prime_list) {
        check[i]++;
      }
    }
    FOR(i, check) {
      ans *= (i + 1);
      ans %= MOD;
    }
    cout << mod(ans, MOD) << endl;
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  CFactorsOfFactorial solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}

	return d;
}

int arr[10] = {};

int main(void) {

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

	for (int i = 0; i < n; i++)
		arr[i] = -1;

	for (int i = 0; i < m; i++) {
		int s, c;
		cin >> s >> c;

		if (arr[s - 1] != -1 && arr[s - 1] != c) {
			cout << -1 << endl;
			return 0;
		}
		arr[s - 1] = c;
	}


	string s;

	bool f = n == 1;
	for (int i = 0; i < n; i++) {
		if (arr[i] == -1) {
			if (f)
				s += "0";
			else {
				s += "1";
				f = true;
			}
		}
		else {
			if (arr[i] == 0 && !f) {
				cout << -1 << endl;
				return 0;
			}
			s += (char)('0' + arr[i]);
			f = true;
		}
	}


	cout << s << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
v = [int(i) for i in input().split()]
dp = [0 for _ in range(n)]
dp[0] = 0
dp[1] = abs(v[1]-v[0])
for i in range(2,n):
    dp[i] = min(dp[i-2]+abs(v[i]-v[i-2]),dp[i-1]+abs(v[i]-v[i-1]))
print(dp[n-1])

Measured memory_bytes: 13928
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <numeric>
#include <complex>
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
using namespace std;
typedef long long ll;

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    if(a>b){
        cout << 0 << endl;
        return 0;
    }
    else{
        if(n == 1 && a < b){
            cout << 0 << endl;
            return 0;
        }
        else{
            cout << (n-2)*(b-a)+1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node {int p,l,r;};
struct Node T[MAX];
int n;

void preParse(int);
void inParse(int);
void postParse(int);

int main(){

  int i,v,l,r,root;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=NIL;}
  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;
    if(l!=NIL)T[l].p=v;
    if(r!=NIL)T[r].p=v;}

  for(i=0;i<n;i++)
    if(T[i].p==NIL)root=i;
  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");
  return 0;}

void preParse(int u){
  if(u==NIL)return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);}

void inParse(int u){
  if(u==NIL)return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);}

void postParse(int u){
  if(u==NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);}



Measured memory_bytes: 2688
package main

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

func main() {
	N := ReadInt()
	ans := 0
	for i := 0; i < N; i++ {
		a := ReadInt()
		for a&1 == 0 {
			ans++
			a >>= 1
		}
	}
	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


Measured memory_bytes: 2108
import sys
import itertools
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N=int(input())
P=nl()
Q=nl()

N_l=list(itertools.permutations(list(range(1,N+1))))
N_l=N_l[::-1]

P_inds=N_l.index(tuple(P))
Q_inds=N_l.index(tuple(Q))

print(abs(P_inds-Q_inds))

Measured memory_bytes: 8308
n,m=gets.split.map(&:to_i)
if n.odd?
  m.times do |i|
    puts "#{i+1} #{n-i}"
  end
else
  m.times do |i|
    if i+1<=n/4
      puts "#{i+1} #{n-i}"
    else
      puts "#{i+1} #{n-i-1}"
    end
  end
end


Measured memory_bytes: 14388
#include<stdio.h>

int main(void){
  int N;
  int l, r, a;
  int k;
  
  scanf("%d", &N);
  for(k = 1; k <= N; k++){
    scanf("%d %d", &l, &r);
    a += r - l + 1;
  }
  
  printf("%d", a);
  
  return 0;
}


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

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define fff ff
#define sss ss.ff
#define ttt ss.ss
#define INF (1 << 30)
#define LLF (1ll << 60)
#define PRIME (1000000007)
#define FASTIO                      \
  std::ios::sync_with_stdio(false); \
  cin.tie(0)
#ifdef DEBUG
#define debug(x) cerr << #x << " = " << x << endl
#else
#define debug(x)
#endif
#define rep(i, begin, end)                            \
  for (__typeof(end) i = (begin) - ((begin) > (end)); \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define FILE_INPUT                  \
  freopen("input.txt", "r", stdin); \
  freopen("output.txt", "w", stdout)

#define all(x) x.begin(), x.end()

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<string> vs;

/*-----------------END TEMPLATE-----------------*/

int main() {
  FASTIO;
  int n;
  cin >> n;
  string s;
  cin >> s;
  if (s.size() % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  string t1 = s.substr(0, n / 2);
  string t2 = s.substr(n / 2);
  if (t1 == t2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#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 ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    double x,t;
    cin >> t >> x;
    printf("%.4f\n",t/x);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;




int main(){

	int N,num_query;
	int head_loc = 1;

	scanf("%d %d",&N,&num_query);

	int command,loc,tmp;

	for(int loop = 0; loop < num_query; loop++){

		scanf("%d %d",&command,&loc);

		if(command == 0){

			tmp = (head_loc+(loc-1))%N;
			if(tmp == 0){
				tmp = N;
			}
			printf("%d\n",tmp);

		}else{

			tmp = (head_loc+loc)%N;
			if(tmp == 0){
				tmp = N;
			}
			head_loc = tmp;
		}
	}

	return 0;
}



Measured memory_bytes: 3240
import sys
# gcd
# from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


N = ii()
S = li()
intS = [0] * N
for i in range(N):
    if S[i] == '#':
        intS[i] = 1
# print(intS)
acuS = list(accumulate(intS))
# print(acuS)
minS = 10 ** 9
for i in range(N):
    minS = min(minS, acuS[i] + (N-1-i) - (acuS[N - 1] - acuS[i]))
# print(minS)
print(min(minS, N - acuS[N-1]))


Measured memory_bytes: 14368
#include<iostream>
#include<string>

using namespace std;

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

	int cnt = 0;

	for (int i = 1; i <= N; i++)
	{
		string t = to_string(i);
		if (t.size() % 2 == 1) {
			cnt++;
		}
	}

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
/*
    Author: Shivam Shukla
    Title : DP_G_Modified.cpp
    Date : 27/08/2020   >> 00:54:32
*/

#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pair<ll,ll> > vpll;
 
const int MOD=1e9+7;
const int MAX=1e5+5;
const double PI= acos(-1.0);
const long double EPS=1e-10;
const int64_t INF=1e18+10;
 
#define fastio() ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0)
#define trace(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vi vector<int>
#define vl vector<ll>
#define vs vector<str>
#define vc(x) vector<x>
#define mapll map<ll,ll>
#define mapib map<int,bool>
#define mapiv map<int,vector>
#define mapsi map<string,int>
#define rep(i,j,k) for(ll i=j;i<k;i++)
#define down(i,j,k) for(ll i=j;i>=k;i--)
#define repa(i,n) for(ll i=0;i<n;i++)
#define dowa(i,n) for(ll i=n;i>=0;i--)
#define reps(i,j,k,s) for(ll i=j;i<k;i+=s)
#define downs(i,j,k,s) for(ll i=j;i>=k;i-=s)
#define trv(i,x) for(auto i:x)
#define pb push_back
#define eb emplace_back
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define str string 
#define dub double
#define pqmax priority_queue<ll>
#define pqmin priority_queue<ll,vl,greater<ll> >
#define INF(x) numeric_limits<x>::max()
 
template<typename t> t lcm(t a, t b) {return (a*b)/__gcd(a,b);}
template<typename t> t gcd(t a, t b) {return __gcd(a,b);}
template<typename t> t mul_mod(t a, t b, t m){t res=((a%m)*(b%m)%m); return res;}
template<typename t> t add_mod(t a, t b, t m){t res=((a%m)+(b%m))%m; return res;}
template<typename t> t pow_mod(t a,t b,t m) {t res=1;while(b){if(b&1) res=mul_mod(res,a,m);a=mul_mod(a,a,m), b>>=1;} return res%m;}
template<typename t> vc(t) num_vec(t num) {t res; while (num) res.pb(num%10), num/=10; return res;}
template<typename t> t vec_num(t vec) {t res=0; ll mul=1; repa(i,sz(vec)) res=vec[i]*mul, mul*=10; return res;}

int32_t dfs(int v, vc(vl)& g, vc(int)& dp) {
    if (dp[v] != -1)
        return dp[v];

    int mx = 0;
    trv(i, g[v]) 
        mx = max(mx, 1 + dfs(i, g, dp));
    dp[v] = mx;
    return dp[v];        
}

int32_t longestPath(vc(vl)& g) {
    int n = sz(g), mx = -INF(int);
    vc(int) dp(n, -1); 
    repa(i, n) 
        mx = max(mx, dfs(i, g, dp));
    return mx;    
}  

int32_t main(int argc,char** argv){
    fastio();
    auto tstart= clock();
 
    #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
      freopen("error.txt","w",stderr);
    #endif   

    int n, m; cin >> n >> m;
    vc(vl) g(n); repa(i, m) {
        int s, d; cin >> s >> d;
        s--, d--;
        g[s].emplace_back(d);
    }

    cout << longestPath(g) << endl;

    cerr << setprecision(2) << fixed<<"Time elapsed: " << (double)(clock() - tstart)/CLOCKS_PER_SEC << endl; 
    return 0; 
}

Measured memory_bytes: 11900
#include <iostream>
#include <string>

using namespace std;

int main(){
    //input
    string s;

    cin >> s;
    //judge
    bool isgood = true;
    if (s[0] == s[1]) isgood = false;
    if (s[1] == s[2]) isgood = false;
    if (s[2] == s[3]) isgood = false;

    //output
    if (isgood) {
        cout << "Good" << endl;
    }
    else {
        cout << "Bad" << endl;
    }

    return 0;

}

Measured memory_bytes: 256