akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

// Optimization

//#pragma GCC optimize("O3")
#define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 1e3 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e18 + 7;
const ll infll = 1e18 + 7;

int n, k, s;
int a[N];

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k >> s;
    if (s == 1){
        ForE(i, 1, k) cout << s << ' ';
        ForE(i, k + 1, n) cout << 2 << ' ';
        return 0;
    }
    ForE(i, 1, k) cout << s << ' ';
    ForE(i, k + 1, n) cout << s - 1 << ' ';
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 1280
def solve(): # Grouping
    while 1:
        x, y = list(map(int, input().split(" ")))
        if x == 2 or y == 2:
            print("No")
            break
        A = [1, 3, 5, 7, 8, 10, 12]
        B = [4, 6, 9, 11]

        if (x in A and y in A) or (x in B and y in B):
            print("Yes")
        else:
            print("No")

        break


solve()

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>
#include<type_traits>

using namespace std;
using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;
constexpr ll LONGINF = 1050000000000000000;


int main() {
	string s; cin >> s;
	int ans = s.size();
	for (int i = 0; i < s.size(); i++) {
		string a = s.substr(i, 1);
		string b = s.substr(i + 1, 1);
		if (a == b) {
			ans--;
			i += 2;
		}
		else {
		}
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 640
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]

minv = 100000
maxv = 1
for lr in LR:
  maxv = max(maxv, lr[0])
  minv = min(minv, lr[1])

print(max(0, minv - maxv + 1))

Measured memory_bytes: 27332
using System;
using System.Linq;

namespace ABC133C
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            long[] lr = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long res = 2020;

            if (lr[1]-lr[0]>=2018)
            {
                Console.WriteLine(0);
                return;
            }

            for (long i = lr[0]; i <= lr[1]; i++)
            {
                for (long j = i+1; j <= lr[1]; j++)
                {
                    long tmp = (i * j) % 2019;
                    res = Math.Min(res, tmp);
                }
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

int main()
{
    ll a, b;
    cin >> a >> b;
    map<ll, ll> da, db;

    int i = 1;
    int tmp = a;
    while(i*i < a){
        i++;
        while(tmp % i == 0){
            da[i]++;
            tmp /= i;
        }
    }
    if(tmp != 1) da[tmp]++;

    i = 1;
    tmp = b;
    while(i*i < b){
        i++;
        while(tmp % i == 0){
            db[i]++;
            tmp /= i;
        }
    }
    if(tmp != 1) db[tmp]++;

    ll mx = max(a,b);
    if(mx < 4){
        cout << a * b << endl;
        return 0;
    }
    for(int i = 2; i<= mx; i++){
        if(da[i] != db[i]){
            if(da[i] > db[i]){
                for(int j = 0; j < da[i]-db[i]; j++){
                    b *= i;
                }
            }else{
                for(int j = 0; j < db[i]-da[i]; j++){
                    a *= i;
                }
            }
        }
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 15996
import math
n = int(input())
lis1 = list(map(int,input().split()))
lis2 = list(map(int,input().split()))
k = 0
c = 0
s = 0
cou = sum(lis2)-sum(lis1)
if cou < 0:
    print("No")
else:
    for i in range(n):
        if lis1[i] < lis2[i]:
            c += math.ceil((lis2[i] - lis1[i]) / 2)
            if (lis2[i] - lis1[i])%2 == 0:
                k += 1
            else:
                s += 1
    if c > cou:
        print("No")
    elif c == cou:
        print("Yes")
    else:
        if k >= 1:
            print("Yes")
        else:
            print("No")

Measured memory_bytes: 4596
#include<cstdio>
#include<utility>
#include<vector>
#include<queue>
#include<climits>
#define MAX_V 1000000
#define INF LLONG_MAX
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
struct edge{ll to,cost;};
ll n;
vector<edge> G[MAX_V];
ll d[MAX_V];
void di(ll s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+n, INF);
    d[s] = 0;
    que.push(P(0, s));
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        ll v = p.second;
        if (d[v] < p.first) {
          continue;
        }
        for (ll i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}
int main(){
  ll u,v,w;
  scanf("%lld",&n);
  for(ll i=0;i<n-1;i++){
    scanf("%lld%lld%lld",&u,&v,&w);
    edge tmp = {v-1,w},tmp2={u-1,w};
    G[u-1].push_back(tmp);
    G[v-1].push_back(tmp2);
  }
  di(0);
  for(ll i=0;i<n;i++){
    if(d[i]%2==0) printf("1\n");
    else printf("0\n");
  }
}


Measured memory_bytes: 31488
use std::io;

fn read_line()-> String {
    let mut s = String::new();
    let _ = io::stdin().read_line(&mut s).unwrap();
    s
}

fn main() {
        let mut c = 0;
        let n = read_line().trim().parse::<i32>().unwrap();
        for i in 1..(n+1) {
                c+=i;
        }
        println!("{}",c);
}

Measured memory_bytes: 4352
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;

int main() {
  ll n, a, b;
  cin >> n;
  a = 1;
  b = n;
  for(ll i = 1; i*i <= n; ++i) {
    if (n % i == 0) {
      a = i;
      b = n / i;
    }
  }

  cout << a+b-2 << endl;


  
  return 0;
}

Measured memory_bytes: 384
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

vector<vector<ll> > table;
vector<P> roads;
vector<P> qs;

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

  string ans = "No";
  if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) ans = "Yes";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
dance = input()
even = "R"
odd = "L"

for i in range(len(dance)):
    if i%2 == 0:
        if dance[i] == "L":
            print("No")
            sys.exit()
    else:
        if dance[i] == "R":
            print("No")
            sys.exit()
print("Yes")

Measured memory_bytes: 38256
import java.util.*;
import java.io.*;

class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		String i1[]=br.readLine().split(" ");
		int V=Integer.parseInt(i1[0]);
		int E=Integer.parseInt(i1[1]);
		String h[]=br.readLine().split(" ");
		int ht[]=new int[V];
		for(int i=0;i<V;i++)
		{
			ht[i]=Integer.parseInt(h[i]);
		}
		ArrayList<ArrayList<Integer>> graph=new ArrayList<>();
		
		for(int i=0;i<V;i++)
		{
			ArrayList<Integer> road=new ArrayList<>();
			graph.add(road);
		}
		
		for(int i=0;i<E;i++)
		{
			String uv[]=br.readLine().split(" ");
			int u=Integer.parseInt(uv[0]);
			int v=Integer.parseInt(uv[1]);
			
			u--;
			v--;
			graph.get(u).add(v);
			graph.get(v).add(u);
		}
		
		//For each from 0 to N;
		int total=0;
		for(int i=0;i<V;i++)
		{
			//here i is our obs;
			ArrayList<Integer> rd=graph.get(i);
			boolean good=true;
			int height=ht[i];
			
			for(Integer r: rd)
			{
				if(ht[r]>=height)
				{
					good=false;
					break;
				}
			}
			if(good)
			{
				total++;
			}
			
		}
		
		System.out.println(total);
		
		
		
	}

}


Measured memory_bytes: 66560
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main() {
	int A, B, ans;
	cin >> A >> B;
	if (A >= 13) {
		ans = B;
	}
	else if (A >= 6 && A <= 12) {
		ans = B / 2;
	}
	else {
		ans = 0;
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
count = 0

for i in range(n):
    if(a[i] - b[i] >= 0):
        a[i] -= b[i]
        count += b[i]
        b[i] = 0
    else:
        b[i] -= a[i]
        count += a[i]
        a[i] = 0
    
    if(a[i+1] - b[i] >= 0):
        a[i+1] -= b[i]
        count += b[i]
    else:
        # b[i] -= a[i+1]
        count += a[i+1]
        a[i+1] = 0

print(count)



Measured memory_bytes: 18476
#include <bits/stdc++.h>
#define len(x) (int) (x.size())
using namespace std;
typedef long long ll;

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

    // i = crane, j = turtle
    string ans = "No";
    for(int i = 0; i <= 100; i++) {
        for(int j = 0; j <= 100; j++) {
            if(i+j == x && 2*i+4*j == y) {
                ans = "Yes";
            }
        }
    }
    cout << ans << '\n';
    
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int x[n];
    double p = 0;
    REP(i, n) {
        cin >> x[i];
        p += x[i];
    }
    p = round(p / n);
    ll sol = 0;
    REP(i, n) {
        sol += pow(x[i] - p, 2);
    }
    cout << sol << endl;
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	int r,g,b,x;
	cin >> r >> g >> b;
	x=10*g+b;
	if(x%4==0){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}

}

Measured memory_bytes: 256
//#pragma GCC target ("avx2,sse2")
//#pragma GCC optimization ("Ofast")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree <pair <ll, int>, null_type, less <pair <ll, int> >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define fi first
#define se second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define endl "\n"

#define left fsdsdfoisf
#define sum dpsdfioppsf
#define assign xcvjlkdjfio
#define trie fksdfkjkfnjuiv
#define next sidlfjsfkl
#define merge sdfksdkfsldf

#define int long long

using namespace std;

void dout() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 3007;
int n;
db p[N], dp[N][N];

void solve(int tc) {
    // check for (int i = 0; i < n; j++)
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
    }
    dp[1][1] = p[1];
    dp[1][0] = (1.0 - p[1]);
    for (int i = 2; i <= n; i++) {
        for (int j = 0; j <= i; j++) {
            dp[i][j] = dp[i - 1][j] * (1.0 - p[i]);
            if (j > 0) {
                dp[i][j] += dp[i - 1][j - 1] * p[i];
            }
        }
    }
    db res = 0;
    for (int i = n / 2 + 1; i <= n; i++) {
        res += dp[n][i];
    }
    cout << setprecision(12) << res;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int tc = 1;
//    cin >> tc;
    for (int i = 0; i < tc; i++) {
        solve(i);
//        cleanup();
    }
}


Measured memory_bytes: 139904
#include<stdio.h>

int p[201];
int gap = -1;
int ans = -1;
int main(){
    int m, n_min, n_max;
    for(;;){
        scanf("%d %d %d\n",&m, &n_min, &n_max);
        if(m == 0 && n_max == 0 && n_min == 0) break;
        for(int i=1; i<=m; i++){
            scanf("%d\n",&p[i]);
        }
        for(int border = n_min; border <= n_max; border++){
            if(gap <= p[border] - p[border+1]){
                gap = p[border] - p[border+1];
                ans = border;
            }
        }
        printf("%d\n",ans);
        ans = -1;
        gap = -1;
    }
    return 0;
}

Measured memory_bytes: 2748
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<map>
using namespace std;
#define f(n) for(int i=0;i<n;++i)
#define ll long long

int main() {
	ll n, ans = 1000000000000001, a;
	vector<ll>v(200005, 0);
	cin >> n;
	ll t;
	cin >> t;
	a = t;
	v[0] = t;
	for(int i = 1; i < n; i++) {
		cin >> t;
		a += t;
		v[i] = v[i - 1] + t;
	}
	f(n-1) {
		ans = min(ans, abs(a - 2 * v[i]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1920
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int N=110;
int n,m,a[N],b[N];
int main()
{
  scanf("%d%d",&n,&m);
  int iodd=0;
  for(int i=1;i<=m;i++)
    scanf("%d",&a[i]),iodd+=(a[i]&1);
  if(m==1)
  {
    if(a[1]==1) printf("%d\n1\n%d\n",1,1);
    else printf("%d\n2\n%d %d\n",a[1],a[1]-1,1);
    return 0;
  }
  if(iodd>2) puts("Impossible");
  else
  {
    for(int i=2;i<=m;i++)
      if(a[i]&1) (a[1]&1)?swap(a[m],a[i]):swap(a[1],a[i]);
    int t=0; if(a[1]>1) b[++t]=a[1]-1;
    for(int i=2;i<m;i++) b[++t]=a[i];
    b[++t]=a[m]+1;
    for(int i=1;i<=m;i++) printf("%d ",a[i]); putchar('\n');
    printf("%d\n",t);
    for(int i=1;i<=t;i++) printf("%d ",b[i]);
  }
}

Measured memory_bytes: 256
n = int(input())
inf = float("inf")
lst = list(map(int, input().split()))

dp = [inf]*(n+2)
dp[0] = 0

for i in range(n):
  dp[i+1] = min(dp[i+1], dp[i] + abs(lst[min(n-1, i+1)] - lst[i]))
  dp[i+2] = min(dp[i+2], dp[i] + abs(lst[min(n-1, i+2)] - lst[i]))

print(dp[n-1])

Measured memory_bytes: 52928
INF = float('inf')

class MinSegTree:
    """
    0-indexed
    query : [L, R)
    """
    def __init__(self, size):
        self.size = 1 << (size.bit_length())  # 完全二分木にする
        self.data = [INF] * (2 * self.size - 1)

    def build(self, rawData):
        self.data[self.size - 1: self.size - 1 + len(rawData)] = rawData
        for i in rawData(self.size - 1)[:: -1]:
            self.data[i] = min(self.data[2 * i + 1], self.data[2 * i + 2])

    def update(self, index, value):
        index += self.size - 1
        self.data[index] = value
        while index >= 0:
            index = (index - 1) // 2
            self.data[index] = min(self.data[2 * index + 1], self.data[2 * index + 2])

    def query(self, left, right):
        L = left + self.size
        R = right + self.size
        ret = INF
        while L < R:
            if R & 1:
                R -= 1
                ret = min(ret, self.data[R - 1])
            if L & 1:
                ret = min(ret, self.data[L - 1])
                L += 1
            L >>= 1
            R >>= 1
        return ret

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

LRC = []
for _ in range(M):
    L, R, C = map(int, input().split())
    L -= 1
    LRC.append((L, R, C))
LRC.sort()

tree = MinSegTree(N)
tree.update(0, 0)
for l, r, c in LRC:
    newDist = tree.query(l, r) + c
    oldDist = tree.query(r - 1, r)
    if newDist < oldDist:
        tree.update(r - 1, newDist)

ans = tree.query(N - 1, N)
print(-1 if ans == INF else ans)

Measured memory_bytes: 131160
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
const int mo=1e9+7;

struct Node
{
	int key,act,t;
	Node(int _key=0,int _act=0,int _t=0):key(_key),act(_act),t(_t){}
};

struct Node_Less
{
	bool operator() (const Node &a,const Node &b) const {return a.act>b.act || (a.act==b.act && a.t>b.t);}
};

tree<Node,null_type,Node_Less,rb_tree_tag,tree_order_statistics_node_update> T;
map<int,string> NS;
map<int,int> tn,ta;
map<string,int> HASH;int HASHcnt;

int Hash(string s)
{
	return HASH[s]?HASH[s]:HASH[s]=++HASHcnt;
}

int n;

void Init()
{
	std::ios::sync_with_stdio(false);
	cin >> n;
	for (int i=1;i<=n;i++)
	{
		string s;
		int x;
		cin >> s;
		cin >> x;
		NS[Hash(s)]=s;
		T.insert(Node(Hash(s),x,i));
		tn[Hash(s)]=i;
		ta[Hash(s)]=x;
	}
}

void Solve()
{
	int m,cnt=n;
	cin >> m;
	for (int t=n+1;t<=n+m;t++)
	{
		char ch;
		string s;
		int x;
		cin >> ch >> s;
		NS[Hash(s)]=s;
		if (ch=='+') cin >> x;
		if (ch=='+')
		{
			tn[Hash(s)]=t;
			ta[Hash(s)]=x;
			if (cnt<=4)
			{
				cnt++;
				T.insert(Node(Hash(s),x,t));
				int tmp=T.order_of_key(Node(Hash(s),x,t));
				if (cnt < 5 || tmp > 0) cout << s << " is not working now." << endl;
				if (cnt == 5) cout << NS[T.find_by_order(0)->key] << " is working hard now." << endl;
			}
			else
			{
				auto tmp=T.find_by_order(cnt/5-1);
				cnt++;
				T.insert(Node(Hash(s),x,t));
				if (cnt%5==0)
				{
					if ((int)T.order_of_key(Node(Hash(s),x,t)) <= cnt/5-1)
					{
						cout << s << " is working hard now." << endl;
					}
					else
					{
						cout << s << " is not working now." << endl;
						cout << NS[T.find_by_order(cnt/5-1)->key] << " is working hard now." << endl;
					}
				}
				else
				{
					if ((int)T.order_of_key(Node(Hash(s),x,t)) <= cnt/5-1)
					{
						cout << s << " is working hard now." << endl;
						cout << NS[tmp->key] << " is not working now." << endl;
					}
					else
					{
						cout << s << " is not working now." << endl;
					}
				}
			}
		}
		else
		{
			auto tmp=T.find_by_order(cnt/5-1);
			string tmps=NS[tmp->key];
			T.erase(Node(Hash(s),ta[Hash(s)],tn[Hash(s)]));
			cnt--;
			if (s==tmps)
			{
				if (cnt%5==4) continue;
				if (cnt>4) cout << NS[T.find_by_order(cnt/5-1)->key] << " is working hard now." << endl;
			}
			else
			{
				if (cnt%5==4)
				{
					if ((int)T.order_of_key(*tmp)>cnt/5-1)
					{
						cout << NS[tmp->key] << " is not working now." << endl;
					}
				}
				else
				{
					if (cnt<5) continue;
					if (T.find_by_order(cnt/5-1)->key == tmp->key) continue;
					cout << NS[T.find_by_order(cnt/5-1)->key] << " is working hard now." << endl;
				}
			}
		}
	}
}

int main()
{
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 22092
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

int main() {
  string s;
  cin >> s;
  int len = s.length();
  string rev = "";
  for (int i = len - 1; i >= 0; i--) {
    rev += s.at(i);
  }
  cout << rev << endl;
}

Measured memory_bytes: 1184
nums = input().split(" ")
a = int(nums[0])
b = int(nums[1])
c = int(nums[2])
d = int(nums[3])

while a > 0 and c > 0:
    c -= b
    if c <= 0:
        break
    a -= d

if a > 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define infin ll (pow(10,9)+7);
int main()
{
    int h,w;
    cin>>h>>w;
    ll ways[h][w] ;//ways[i][j]=no.of ways to reach (h-1,w-1) from i,j 
    char given[h][w];
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            cin>>given[i][j];
        }
    }
    ways[h-1][w-1]=1;
    for(int j=w-2;j>=0;j--)
    {
        if (given[h-1][j]=='#')
            ways[h-1][j]=0;
        else
        {
            //cout<<j<<" "<<ways[h-1][j+1]<<endl;
            ways[h-1][j]=(ways[h-1][j+1]) % infin;
            //cout<<ways[h-1][j]<<endl;
        }
    }
    for(int i=h-2;i>=0;i--)
    {
        if (given[i][w-1]=='#')
            ways[i][w-1]=0;
        else
            ways[i][w-1]=(ways[i+1][w-1]) % infin;
    }
    //cout<<"all good"<<endl;
    // for(int i=0;i<h;i++)//just print
    //    {
    //       for(int j=0;j<w;j++)
    //         cout<<ways[i][j]<<" ";
    //       cout<<endl;
    //     }
    
    for(int i=h-2;i>=0;i--)
    {
        for(int j=w-2;j>=0;j--)
        {
            if (given[i][j]=='#')
                ways[i][j]=0;
            else
                ways[i][j]=(ways[i+1][j]+ways[i][j+1]) % infin;
        }
    }
    // cout<<"\n\n"<<endl;
    // for(int i=0;i<h;i++)
    //    {
    //       for(int j=0;j<w;j++)
    //         cout<<ways[i][j]<<" ";
    //       cout<<endl;
    //     }
    cout<<ways[0][0]<<endl;

}


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

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

  ll n;
  cin >> n;

  for (ll i = sqrt(n); i > 0; --i) {
    if (n % i == 0) {
      cout << (n / i) + i - 2 << endl;
      return (0);
    }
  }

  return (0);
}


Measured memory_bytes: 3644
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define inf 20021225
#define ll long long
#define mdn 1000000007
using namespace std;

struct matrix{int a[3][3],n;};
inline void init(matrix &a)
{
	memset(a.a,0,sizeof(a.a));
}
matrix operator *(matrix a,matrix b)
{
	matrix tmp; init(tmp); tmp.n=a.n;
	//printf("%d\n",tmp.a[2][2]);
	for(int i=1;i<=a.n;i++)
	for(int j=1;j<=a.n;j++)
	for(int k=1;k<=a.n;k++)
	tmp.a[i][j] = ((ll)tmp.a[i][j] +(ll)a.a[i][k]*b.a[k][j]%mdn)%mdn;
	return tmp;
}

matrix ksm(matrix bs,ll mi)
{
	matrix tmp; tmp.n=bs.n; init(tmp);
	for(int i=1;i<=tmp.n;i++)	tmp.a[i][i]=1;
	while(mi)
	{
		if(mi&1)	tmp=tmp*bs;
		bs=bs*bs; mi>>=1;
	}
	return tmp;
}
char mp[1100][1100];
int ud,lr,eud,elr,cnt;
int ksm(int bs,ll mi)
{
	int ans=1;
	while(mi)
	{
		if(mi&1)	ans=(ll)ans*bs%mdn;
		bs=(ll)bs*bs%mdn; mi>>=1;
	}
	return ans;
}
int main()
{
	int h,w;ll k;
	scanf("%d%d%lld",&h,&w,&k);
	if(k<=1){printf("1\n");return 0;}
	for(int i=1;i<=h;i++)
	{
		scanf("%s",mp[i]+1);
		if(mp[i][1] == mp[i][w] && mp[i][1] =='#')	lr++;
		for(int j=2;j<=w;j++)	if(mp[i][j] == mp[i][j-1] && mp[i][j] == '#')	elr++;
	}
	for(int i=2;i<=h;i++)
		for(int j=1;j<=w;j++)	if(mp[i-1][j] == mp[i][j] && mp[i][j] == '#')	eud++;
	for(int i=1;i<=w;i++)	if(mp[1][i] == mp[h][i] && mp[h][i] == '#')	ud++;
	for(int i=1;i<=h;i++)	for(int j=1;j<=w;j++)	cnt+=(mp[i][j]=='#');
	if(lr && ud)
	{
		printf("1\n"); return 0;
	}
	if(!lr && !ud)
	{
		printf("%d\n",ksm(cnt,k-1)); return 0;
	}
	//printf("QAQ");
	if(lr)	swap(lr,ud),swap(elr,eud); // only ud
	matrix ans; ans.n = 2;// printf("%d %d\n",eud,ud);
	ans.a[1][1] = cnt; ans.a[1][2] = 0; ans.a[2][1] = 1; ans.a[2][2] = ud;
	ans = ksm(ans,k-2);
	int fin =(ll)ans.a[1][1]*eud%mdn + (ll)ud*eud%mdn*ans.a[2][1]%mdn;
	fin%=mdn; int mis = ksm(cnt,k-1);// printf("%d\n",mis);
	//printf("%d %d %d %d\n",ans.a[1][1],ans.a[1][2],ans.a[2][1],ans.a[2][2]);
	printf("%d\n",(mis-fin+mdn)%mdn);
	return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <stdlib.h>

int main()
{
     int y,a,b;
    while(~scanf("%d",&y))
    {
        if(y==1)
        {
            printf("Hello World\n");
        }
        else
        {
            scanf("%d%d",&a,&b);
            printf("%d\n",a+b);
        }
    }

    return 0;
}

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

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

set<string> s,init;

int hit(string a,string b){
	int res = 0;
	rep(i,4) if(a[i] == b[i]) res++;
	return res;
}

int blow(string a,string b){
	int res = 0;
	rep(i,4) rep(j,4){
		if(i == j) continue;
		if(a[i] == b[j]){
			res++;
			break;
		}
	}

	return res;
}

int main(void){
	rep(i,10) rep(j,10) rep(k,10) rep(l,10) {
		if(i != j && i != k && i != l && j != k && j != l && k != l){
			string str = "";
			str += '0' + i;
			str += '0' + j;
			str += '0' + k;
			str += '0' + l;
			init.insert(str);
		}
	}

	int n;
	while(cin>>n,n){
		s = init;
		while(n--){
			string str;
			int h,b;
			cin>>str>>h>>b;

			set<string> next;
			for(set<string>::iterator i=s.begin();i!=s.end();i++){
				if(hit(str,*i) == h && blow(str,*i) == b){
					next.insert(*i);
				}
			}

			s = next;
		}

		if(s.empty()){
			cout<<"????\n";
		}
		else if(s.size() == 1){
			cout<<*s.begin()<<endl;
		}
		else{
			bool ansFlg;
			for(set<string>::iterator i=init.begin();i!=init.end();i++){
				string say = *i;
				bool used[5][5];
				memset(used,0,sizeof(used));
				ansFlg = true;

				for(set<string>::iterator j=s.begin();j!=s.end();j++){
					int h = hit(*i,*j);
					int b = blow(*i,*j);
					if(used[h][b]){
						ansFlg = false;
						break;
					}
					used[h][b] = true;
				}

				if(ansFlg){
					cout<<say<<endl;
					break;
				}
			}
			if(!ansFlg) cout<<"????\n";
		}
	}

	return 0;
}

Measured memory_bytes: 1316
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) lower_bound(all(v),k)-v.begin()
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
ll inf=100100100100;
const int mod=1000000007;
int main(){
   int n;cin>>n;
   vi v(n);
   rep(i,n)cin>>v[i];
   vi dp(n);
   dp[0]=0;dp[1]=abs(v[1]-v[0]);
   REP(i,2,n){
      dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
   }
   cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define SFOR(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define INF INT_MAX
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int n,a,b,d[1000];
int main(){
   cin.tie(0);
   ios::sync_with_stdio(false);
   int H,W,h,w;
   cin>>H>>W;
   cin>>h>>w;
   int ans=H*W;
   cout<<ans-h*W-H*w+h*w<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using ul = unsigned long long;
using Bint = mp::cpp_int;
ll mod = 1000000007;

class rolling_hash {
  private:
    vector<ul> hash;
    const ul mask30 = (1ul << 30) - 1;
    const ul mask31 = (1ul << 31) - 1;
    const ul hash_mod = (1ul << 61) - 1;
    const ul mask61 = hash_mod;
    const ul positivizer = hash_mod * ((1ul << 3) - 1);
    ul base;
    vector<ul> pow_memo;
    ul mul(ul a, ul b) {
        ul au = a >> 31;
        ul ad = a & mask31;
        ul bu = b >> 31;
        ul bd = b & mask31;
        ul mid = ad * bu + au * bd;
        ul midu = mid >> 30;
        ul midd = mid & mask30;
        return au * bu * 2 + midu + (midd << 31) + ad * bd;
    }
    ul calc_mod(ul x) {
        ul xu = x >> 61;
        ul xd = x & mask61;
        ul res = xu + xd;
        if (res >= hash_mod) {
            res -= hash_mod;
        }
        return res;
    }

  public:
    rolling_hash(string s) {
        random_device seed_gen;
        mt19937_64 engine(seed_gen());
        base = engine() % mod + 256;

        hash.resize(s.length() + 1, 0);
        pow_memo.resize(s.length() + 1, 0);
        for (ll i = 0; i < s.length(); i++) {
            hash[i + 1] = calc_mod(mul(hash[i], base) + s[i]);
        }
        pow_memo[0] = 1;
        for (ll i = 1; i < pow_memo.size(); i++) {
            pow_memo[i] = calc_mod(mul(pow_memo[i - 1], base));
        }
    }
    ul slice(ll begin, ll length) {
        return calc_mod(hash[begin + length] + positivizer -
                        mul(hash[begin], pow_memo[length]));
    }
    ul get_hash(ll a, ll b) { return slice(a, b - a); }
};

bool solve(rolling_hash &rh, ll len, ll n) {
    bool ans = false;
    rep(i, n - len - 1) {
        ul hash_base = rh.slice(i, len);
        for (ll j = i + len; j + len <= n; j++) {
            ul hash = rh.slice(j, len);
            if (hash_base == hash) {
                ans = true;
                break;
            }
        }
        if (ans) {
            break;
        }
    }
    return ans;
}

int main() {
source:
    ll n;
    cin >> n;
    string s;
    cin >> s;
    rolling_hash rh(s);

    ll l = 0, r = n;
    while (r - l > 1) {
        ll mid = (l + r) / 2;
        if (solve(rh, mid, n)) {
            l = mid;
        } else {
            r = mid;
        }
    }
    cout << l << endl;
    return 0;
}



Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
int DBG = 0;										/* デバッグプリント 提出時は0 */
/* main *************************************************************/
int main()
{
	int		a,b[101],c,i,j,k,n,m,x,y,ans = 0;
	char	str[256];
	
	scanf("%d", &n);
	for(i=1;i<n;i++) scanf("%d", &b[i]);
	b[0] = b[1];
	b[n] = 0x7fffffff;
	if (DBG) {
		for(i=0;i<n;i++) printf("%d ",b[i]);
		ENTER;
	}
	for(i=0;i<n;i++) {
		if (b[i] > b[i+1]) b[i] = b[i+1];
		ans += b[i];
	}
	if (DBG) {
		for(i=0;i<n;i++) printf("%d ",b[i]);
		ENTER;
	}
	printf("%d\n",ans);


	return 0;
}


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

using namespace std;

string s;

int main () {
    cin >> s;
    if (s == "Sunny") {
        cout << "Cloudy";
    }else if (s == "Cloudy") {
        cout << "Rainy";
    }else {
        cout << "Sunny";
    }
}


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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

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

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int h,n;    // 1e4, 1e3
pii magic[1252];

ll dp[25252];

int main(){
    scanf("%d%d",&h,&n);
    REP(i,n){
        scanf("%d%d",&magic[i].first,&magic[i].second);
    }
    fill(dp,dp+25252,1ll<<60);
    dp[0] = 0;
    REP(i,n){
        int a = magic[i].first;
        int b = magic[i].second;
        REP(j,h)CHMIN(dp[j+a], dp[j]+b);
    }
    ll ans = *min_element(dp+h,dp+25252);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
using namespace std;
typedef unsigned long long ll;
// A > B
ll calcGCD(ll A, ll B){
  if(A % B == 0){
    return B;
  } else {
    calcGCD(B, A%B);
  }
}

bool isPrime(ll gcd){
  
}

int main(){
  ll A,B;
  cin >> A >> B;
  ll bigger = A;
  ll smaller = B;
  if(A < B){
    bigger = B;
    smaller = A;
  }
  ll gcd = calcGCD(bigger,smaller);
  if(gcd == 1){
    cout << 1 << endl;
    return 0;
  }
  // gcdを素因数分解
  ll counter = 1;
  ll root = (ll) sqrt(gcd);
  ll gcd_copy = gcd;
  for(ll i = 2; i < gcd_copy; i++){
    bool isDevide = false;
    while(gcd % i == 0){
      if(!isDevide){
	counter++;
	isDevide = true;
      }
      gcd = gcd / i;
    }
    if(i > gcd){
      cout << counter << endl;
      return 0;
    }
    root = sqrt(gcd);
    if(i > root){
      cout << counter + 1 << endl;
      return 0;
    }
  }
  return 0;
}


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

int xp0,yp0,xp1,yp1,x,y;

struct bec{
    int x,y;
};

void judge(int x,int y){
    bec p1,p2;
    p1.x= xp1-xp0; p1.y= yp1-yp0;
    p2.x= x-xp0; p2.y=y-yp0;
    double d1,d2;
    d1=sqrt((double)p1.x*(double)p1.x+(double)p1.y*(double)p1.y);
    d2=sqrt((double)p2.x*(double)p2.x+(double)p2.y*(double)p2.y);
    if((p1.x*p2.y-p1.y*p2.x)>0) cout<<"COUNTER_CLOCKWISE"<<endl;
    else if((p1.x*p2.y-p1.y*p2.x)<0) cout<<"CLOCKWISE"<<endl;
    else{
        double c = ((double)p1.x*(double)p2.x+(double)p1.y*(double)p2.y)/(d1*d2);
        int cc=round(c);
        if(cc==1||d2==0){
            if(d1<d2) cout<<"ONLINE_FRONT"<<endl;
            else cout<<"ON_SEGMENT"<<endl;
        }
        else cout<<"ONLINE_BACK"<<endl;
    }
}

int main(){
    cin>>xp0>>yp0>>xp1>>yp1;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        judge(x,y);
    }
    return 0;
}


Measured memory_bytes: 3160
#include<iostream>
#include<cstdio>
#include<set>
#include<vector>
using namespace std;
#define MAX 100000
vector<int> G[MAX];
int N;
bool visited[MAX];
int prenum[MAX],parent[MAX],lowest[MAX],timer;
void dfs(int current,int prev)
{
    prenum[current]=lowest[current]=timer;
    timer++;
    visited[current]=true;
    int next;
    for(int i=0;i<G[current].size();i++)
    {
        next=G[current][i];
        if(!visited[next])
        {
            parent[next]=current;
            dfs(next,current);
            lowest[current]=min(lowest[current],lowest[next]);
        }
        else if(next!=prev)
        {
            lowest[current]=min(lowest[current],prenum[next]);
        }
    }
}
void art_points()
{
    for(int i=0;i<N;i++)
    visited[i]=false;
    timer=1;
    dfs(0,-1);
    set<int> ap;
    int np=0;
    for(int i=1;i<N;i++)
    {
        int p=parent[i];
        if(p==0) np++;
        else if(prenum[p]<=lowest[i]) ap.insert(p);
    }
    if(np>1) ap.insert(0);
    for(set<int>::iterator it=ap.begin();it!=ap.end();it++)
        cout<< *it<<endl;
}
int main()
{
    int m;
    int s,t;
    scanf("%d %d",&N,&m);
    for(int i=0;i<m;i++)
    {
        scanf("%d %d",&s,&t);
        G[t].push_back(s);
        G[s].push_back(t);
    }
    art_points();
    return 0;
}



Measured memory_bytes: 6912
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <iostream>

using namespace std;

const int MAX_N = 50;

int N, A;
int X[MAX_N + 1];
long long dp[MAX_N + 1][MAX_N + 1][MAX_N * MAX_N + 1];

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

    cin >> N >> A;

    int sum = 0;

    for (int i = 1; i <= N; i++) {
        cin >> X[i];
        sum += X[i];
    }

    for (int i = 0; i <= N; i++) {
        dp[i][0][0] = 1;
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= i; j++) {
            for (int k = 0; k <= sum; k++) {
                if (k >= X[i + 1]) {
                    dp[i + 1][j + 1][k] = dp[i][j][k - X[i + 1]] + dp[i][j + 1][k];
                } else {
                    dp[i + 1][j + 1][k] = dp[i][j + 1][k];
                }
            }
        }
    }

    long long ans = 0;
    for (int j = 1; j <= N; j++) {
        ans += dp[N][j][j * A];
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 28840
def C(n, r, m):
    num, den = 1, 1
    for i in range(1, r + 1):
        num = num * (n - i + 1) % m
        den = den * i % m
    return (num * pow(den, m - 2, m)) % m

n, k = map(int, input().split())
p = 10**9 + 7
ans = [(C(n - k + 1, i, p) * C(k - 1, i - 1, p)) % p for i in range(1, k + 1)]
print(*ans, sep='\n')

Measured memory_bytes: 3444
import java.util.*;


public class Main {
    public static void main(String[] args) {
      
      Scanner sc = new Scanner(System.in);
      String s = sc.next();
      String a = "";
      String b = "";
      int ai = 0;
      int bi = 0;
      for (int i = 0; i < s.length(); i++) {
        if (a == "") {
          a = s.substring(i,i+1);
        } else if (a.equals(s.substring(i,i+1))) {
          ai += 1;
        } else if (b == "") {
          b = s.substring(i,i+1);
        } else if (b.equals(s.substring(i,i+1))) {
          bi += 1;
        }
      }
      if (ai == 1 && bi == 1) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    }
}

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


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

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int a[200000];
int main(){
	int n;
	cin>>n;
	int max=0,maxindex;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]>max)max=a[i],maxindex=i;
	}
	sort(a,a+n);
	for(int i=0;i<n;i++){
		if(i==maxindex)cout<<a[n-2]<<'\n';
		else cout<<max<<'\n';
	}
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
  
using namespace std;
  
typedef long long int64;
  
map< int64, int > data;
  
int64 sum(int64 k)
{
  k += 1e13;
  int ret = 0;
  for(; k > 0; k -= k & -k) {
    if(!data.count(k)) continue;
    ret += data[k];
  }
  return (ret);
}
  
void push(int64 k, int x)
{
  k += 1e13;
  for(; k < 1e14; k += k & -k) data[k] += x;
}
  
int main()
{
  int64 N, A, B;
  vector< pair< int64, int64 > > T[5];
  
  cin >> N >> A >> B;
  for(int i = 0; i < N; i++) {
    int64 a, b, c;
    cin >> a >> b >> c;
    T[--a].emplace_back(b, c);
  }
  
  for(int i = 0; i < 5; i++) {
    T[i].emplace_back(0LL, 0LL);
  }
  
  map< int64, vector< pair< int64, int > > > add;
  map< int64, vector< int64 > > que;
  map< int64, vector< pair< int64, int > > > del;
  
  for(auto &s : T[0]) {
    for(auto &t : T[1]) {
      for(auto &q : T[2]) {
        int64 a = s.first + t.first + q.first;
        int64 b = s.second + t.second + q.second;
        que[a].emplace_back(b);
      }
    }
  }
  
  for(auto &s : T[3]) {
    for(auto &t : T[4]) {
      int64 a = s.first + t.first;
      int64 b = s.second + t.second;
      pair< int64, int64 > latte = {A - a, B - a};
      pair< int64, int64 > malta = {A - b, B - b};
      if(latte.first > latte.second) continue;
      if(malta.first > malta.second) continue;
      add[latte.first].emplace_back(malta.first, +1);
      add[latte.first].emplace_back(malta.second + 1, -1);
      del[latte.second].emplace_back(malta.first, -1);
      del[latte.second].emplace_back(malta.second + 1, +1);
    }
  }
  
  auto ptr = que.begin();
  auto latte = add.begin(), malta = del.begin();
  
  
  while(ptr != que.end()) {
    while(latte != add.end() && latte->first <= ptr->first) {
      for(auto &v : latte->second) {
        push(v.first, v.second);
      }
      ++latte;
    }
    while(malta != del.end() && malta->first < ptr->first) {
      for(auto &v : malta->second) push(v.first, v.second);
      ++malta;
    }
    for(auto &v : ptr->second) {
      if(sum(v) != 0) {
        cout << "Yes" << endl;
        return (0);
      }
    }
    while(malta != del.end() && malta->first <= ptr->first) {
      for(auto &v : malta->second) push(v.first, v.second);
      ++malta;
    }
    ++ptr;
  }
  
  cout << "No" << endl;
}

Measured memory_bytes: 130748
#include <stdio.h>

int main(void){
  long N,A,B;
  scanf("%ld %ld %ld",&N,&A,&B);
  long count = 0;
  if((B-A)%2==0){
    count = (B-A)/2;
  } else {
    if( (N-A)>(B-1) ){
      count = A-1 + 1 + (B-A-1)/2;

    }else{
      count = N-B + 1 + (B-A-1)/2;
    }
  }

  printf("%ld\n",count);

  return 0;
}

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

int R,C;
int f[10][10000];
bool flag[10];
int ans = 0;

int cnt(void) {
  int res = 0;
  for (int i = 0; i < C; i++) {
    int tmp = 0;
    for (int j = 0; j < R; j++) {
      if (!f[j][i] && flag[j] || f[j][i] && !flag[j]) tmp++;
    }
    res += max(tmp, R-tmp);
  }
  return res;
}

void solve(int num) {
  if (num == R) {
    ans = max(cnt(), ans); return;
  }
  flag[num] = false;
  solve(num+1);
  flag[num] = true;
  solve(num+1);
}

int main() {
  while (cin >> R >> C) {
    if (R == 0 || C == 0) break;
    ans = 0;
    for (int r = 0; r < R; r++)
      for (int c = 0; c < C; c++) cin >> f[r][c];
    solve(0);
    cout << ans << endl;
  }
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#include <map> // pair
using namespace std;
int main(){
  string S,T,U;
  int A,B;
  cin>>S>>T;
  cin>>A>>B;
  cin>>U;
  if(S==U)A--;
  else B--;

  cout<<A<<" "<<B<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <math.h> 
using namespace std;
int main(void){
    int N; cin >> N;
    vector<int> x(N);
    vector<int> y(N);
    vector<int> h(N);
    int i = 0;
    int Max = 0;
    long min = 10e9;
    while(i < N){
        cin >> x[i] >> y[i] >> h[i];
        if (h[i] < min) min = h[i];
        if (h[i] > Max) Max = h[i];
        i++;
    }
    i = 0;
    int j = 0; int k = 0;
    int flag = 0;
    while (i <= 100) {
        j = 0;
        while (j <= 100) {
            k = Max;
            while (Max <= k && k <= Max + 200) {
                int l = 0;
                int flag2 = 1;
                while (l < N) {
                    int value = 0;
                    value = max(k - abs(i - x[l]) - abs(j - y[l]),0);
                    if ( value != h[l]) {
                        flag2 = 0;
                        break;
                    } 
                    l++;
                }
                if (flag2) {
                    flag = 1;
                    break;
                }
                k++; 
            }
            if (flag) break;
            j++;
        }
        if (flag) break;
        i++;
    }
    cout << i << " " << j << " " << k << endl;
}


Measured memory_bytes: 3640
#include <iostream>

using namespace std;

const long long MOD = 1000000007;

long long sum_of_large_numbers(long long n, long long k) {
  long long ans = 0;

  for(long long i=k;i<=n+1;i++) {
    long long minimum = ((i-1)*i)/2;
    long long maximum = ((n+n-i+1)*i)/2;
    long long add = maximum - minimum + 1;
    ans = (ans + add) % MOD;
  }
  return ans;
}


int main() {
  long long n, k;
  cin >> n;
  cin >> k;
  cout << sum_of_large_numbers(n, k);
}

Measured memory_bytes: 3568
using System;
using System.Linq;

public class Program
{
	public static void Main()
	{
		var w = Console.ReadLine();
		bool[] isEven = new bool[26];
		for (int i = 0; i < 26; i++)
		{
			isEven[i] = true;
		}
		for (int i = 0; i < w.Length; i++)
		{
			var t = w[i] - 'a';
			isEven[t] = !isEven[t];
		}
		Console.WriteLine(!isEven.Where(i => !i).Any() ? "Yes" : "No");
	}
}

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

using namespace std;
using ll = long long;
using P = pair<int, ll>;

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

int main() {
  int n, k;
  cin >> n >> k;
  int p[n], c[n];
  rep(i, n) cin >> p[i], --p[i];
  rep(i, n) cin >> c[i];

  ll ans = -1e18;
  rep(i, n) {
    int v = i;
    ll loopSum = 0;
    int loopLen = 0;

    while (1) {
      ++loopLen;
      loopSum += c[v];
      v = p[v];
      if (v == i) break;
    }

    ll path = 0;
    int cnt = 0;

    while (1) {
      ++cnt;
      path += c[v];

      if (cnt > k) break;

      int num = (k - cnt) / loopLen;
      ll score = path + max(0ll, loopSum) * num;
      ans = max(ans, score);

      v = p[v];
      if (v == i) break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3676
#include<cstdio>
#include<cmath>

#define MAX_STUDENTS 1000

int main(){

    while(1){

        unsigned int n, i, score, scores_data[MAX_STUDENTS] = {0}, sum = 0;
        double alpha = 0, average;

        scanf("%d", &n);

        if(n == 0) break;

        for( i = 0; i < n; i++ ){
            scanf("%d", &score);
            sum += score;
            scores_data[i] = score;
        }

        average = (double)sum / n;

        for( i = 0; i < n; i++ ){
            alpha += pow(scores_data[i] - average, 2);
        }

        alpha /= n;
        
        printf("%.8lf\n", sqrt(alpha));

    }

    return 0;

}


Measured memory_bytes: 2692
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;

#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define ESIZEOF(A)      (sizeof(A)/sizeof((A)[0]))

int k[4];
int main(){
    string s;
    while(getline(cin, s)){
        int n; char buf[8];
        sscanf(s.c_str(), "%d,%s", &n, buf);
        if(strcmp(buf, "A")  == 0){ k[0]++; }
        if(strcmp(buf, "B")  == 0){ k[1]++; }
        if(strcmp(buf, "AB") == 0){ k[2]++; }
        if(strcmp(buf, "O")  == 0){ k[3]++; }
    }
    REP(i,4) cout << k[i] << endl;
    return 0;
}

Measured memory_bytes: 1240
n,x = (int(i) for i in input().split())
def pc(n,k):
	if n and k==1: return 0
	elif k==1: return 1
	elif k<2**(n+1)-1: return pc(n-1,k-1)
	elif k==2**(n+1)-1: return 2**n
	elif k<2**(n+2)-3: return 2**n+pc(n-1,k-2**(n+1)+1)
	else: return 2**(n+1)-1
print(pc(n,x))

Measured memory_bytes: 3064