akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  while (true) {
    int n; cin >> n;
    if (n == 0) break;
    V<string> s(n);
    V<> d(n, -1);
    for (int i = 0; i < n; ++i) {
      cin >> s[i];
      int m = s[i].size();
      for (int j = m - 1; j >= 0; --j) if (s[i][j] == '.') {
        s[i][j] = '+';
        d[i] = j;
        break;
      }
    }
    for (int j = 0; j < 2000; ++j) {
      V<> a;
      for (int i = 0; i < n; ++i) if (j < s[i].size() and s[i][j] == '+') {
        a.push_back(i);
      }
      int m = a.size();
      for (int x = 0; x < m - 1; ++x) {
        bool f = true;
        for (int i = a[x] + 1; i < a[x + 1]; ++i) if (d[i] < j) {
          f = false;
          break;
        }
        if (!f) continue;
        for (int i = a[x] + 1; i < a[x + 1]; ++i) if (s[i][j] == '.') {
          s[i][j] = '|';
        }
      }
    }
    for (auto&& e : s) {
      for (auto&& c : e) {
        if (c == '.') c = ' ';
      }
      cout << e << '\n';
    }
  }
}


Measured memory_bytes: 3484
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	private static ArrayList<String>divide = new ArrayList<String>(){{
		add("dream");
		add("dreamer");
		add("erase");
		add("eraser");
	}};
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		String str = new StringBuilder(s).reverse().toString();
		divide = Main.divide.stream().map(e -> new StringBuilder(e).reverse().toString())
				.collect(ArrayList<String>::new, ArrayList<String>::add, ArrayList<String>::addAll);
		;

		boolean can = true;
		for (int i = 0; i < str.length();) {
			boolean can2 = false;
			for (int j = 0; j < 4; j++) {
				String d = divide.get(j);
				if ((d.length() - (str.length() - i) <= 0) 
						&& str.substring(i, i + d.length()).equals(d)) {
					can2 = true;
					i += d.length();
				}
			}
			if (!can2) {
				can = false;
				break;
			}
			
		}
		
		String answer = (can) ? "YES" : "NO";
		System.out.println(answer);
		

	}

}

Measured memory_bytes: 33096
S = input()
N = len(S)
ans = [0] * N
n = 0
m = 0

for i in range(N - 1):
    if S[i] == "R" and S[i+1] == "R":
        n += 1
    elif S[i] == "R" and S[i+1] == "L":
        tmp = i
    elif S[i] == "L" and S[i+1] =="L":
        m += 1
    else:
        ans[tmp] = n // 2 + (m - m // 2)+1
        ans[tmp+1] = m // 2 + (n - n // 2)+1
        n = 0
        m = 0

ans[tmp] = n // 2 + (m - m // 2)+1
ans[tmp+1] = m // 2 + (n - n // 2)+1

for i in range(N):
    print(str(ans[i]), end = " ")

Measured memory_bytes: 4864
object Main {
  def main(args: Array[String]): Unit = {
    val num = scala.io.StdIn.readInt
    if( isHarshadNumber( num ) ) println( "Yes" )
    else                         println( "No" )
  }

  def isHarshadNumber( input: Int ): Boolean = {
    var num = input
    var sum = 0
    while( num > 0 ) {
      sum += num%10
      num /= 10
    }

    if( input%sum == 0 ) return true
    else                 return false
  }
}

Measured memory_bytes: 54624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int n, c, k;
    cin >> n >> c >> k;
    vector<int> t(n);
    rep(i, n) cin >> t[i];

    sort(all(t));
    ll nowt = t[0] + k, cou = 1, ans = 1;
    for(int i = 1; i < n; i++) {
        if(t[i] <= nowt) {
            if(c > cou) cou++;
            else {
                ++ans;
                cou = 0;
                nowt = t[i]+k;
                i--;
            }
        }
        else {
            ++ans;
            cou = 0;
            nowt = t[i]+k;
            i--;
        }
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }

int n;
int m;

char res[201];
int c, d;
int pos, rpos;

int findK (int a, int b) {
	if (a < b) swap (a, b);
	re (a + b) / (b + 1);
}

int add (int a, int b, int k) {
//	cout << a << " " << b << " " << k << endl;
	if (a == 0 && b == 0) re 0;
	int last = pos + (a + b) * k;
	while (c + rpos <= d && c + rpos < last) {
		if (((c + rpos) - pos) % (a + b) < a)
			res[rpos++] = 'A';
		else
			res[rpos++] = 'B';	
	}
	pos = last;
	re 0;
}

int main () {
	scanf ("%d", &n);
	for (int i = 0; i < n; i++) {
		int a, b;
		scanf ("%d%d%d%d", &a, &b, &c, &d); c--; d--;
		int len = d - c + 1;
		rpos = 0;
		int k = findK (a, b);
		pos = 0;
		while (a > 0 && b > 0) {
			int ca = 0, cb = 0;
			{
				int l = max ((ll)0, a - (ll)b * k);
				int r = min (min (a, k), a - (b + k - 1) / k + 1);
				ca = r;
			}
			{
				int l = max ((ll)1, b - (ll)(a - ca) * k);
				int r = min (min (b, k), b - (a - ca + k - 1) / k + 1);
				cb = l;
			}
			if (ca > 0 && cb > 0) {
				int l = 1, r = 1e9;
				while (r - l > 1) {
					int s = (l + r) / 2;
					if ((ll)ca * s <= a && (ll)cb * s <= b) {
						int aa = a - ca * s;
						int bb = b - cb * s;
						if (bb <= (ll)aa * k && aa <= (ll)(bb + 1) * k)
							l = s;
						else
							r = s;	
					} else r = s;
				}
				add (ca, cb, l);
				a -= ca * l;
				b -= cb * l;
			} else {
				add (ca, cb, 1);
				a -= ca;
				b -= cb;
			}
		}
		if (a > 0) add (a, 0, 1);
		if (b > 0) add (0, b, 1);
		for (int i = 0; i < len; i++) printf ("%c", res[i]);
		printf ("\n");
	}
	return 0;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc042/tasks/abc042_b

"""
import sys
from sys import stdin
input = stdin.readline


def solve(data):
    data.sort()
    return data


def main(args):
    N, L = map(int, input().split())
    data = [input().strip() for _ in range(N)]
    ans = solve(data)
    print(*ans, sep='')


if __name__ == '__main__':
    main(sys.argv[1:])
    


Measured memory_bytes: 3064
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

 main()

{
    fast
    int n,a,b,tmp;
    cin>>n>>a>>b;
    int x=0;
    f(i,3,n)
    {
        cin>>tmp;
        x=x^tmp;
    }
    int s=(a+b);
    int d=(s-x)/2;
    int gap=s-x;
    if(gap<0 || (gap&1) || d>a || (d&x))
    {
        cout<<"-1"<<endl;
        return 0;
    }
    for(int i=(1LL<<61);i;i>>=1)
    {
        if((i&x) && d+i<=a)
        {
            d+=i;
        }
    }
    if(d==0)cout<<"-1"<<endl;
    else cout<<a-d<<endl;
    return 0;

}





































Measured memory_bytes: 3648
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    a, b, c = LI()
    d = defaultdict(int)
    d[(a, b, c)] = 1
    ans = 0
    while 1:
        if a & 1 or b & 1 or c & 1: break
        a, b, c = (b + c) // 2, (a + c) // 2, (a + b) // 2
        ans += 1
        if d[(a, b, c)]:
            print(-1)
            return
        d[(a, b, c)] = 1
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 38640
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>

int main(){
  long long int N, K, tmp;
  std::vector<long long int> h;
  
  scanf("%lld%lld", &N, &K);
  for(long long int i = 0; i < N; i++){
    scanf("%lld", &tmp);
    h.push_back(tmp);
  }
  
  long long int ans = 0;
  for(long long int i = 0; i < N; i++){
    if(h[i] >= K){
      ans++;
    }
  }
  
  std::cout << ans << std::endl;
  
  return 0;
}


Measured memory_bytes: 1400
#include<cstdio>
using namespace std;
int main(void)
{
  int a,b,c,d,e,x;
  scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
  if(a<0 && b<=0)	{
    x=(b-a)*c;
  }
  else if(a<0 && b>0)	{
    x=(0-a)*c+d+b*e;
  }
  else {
    x=(b-a)*e;
  }
  printf("%d\n",x);
  return 0;
}


Measured memory_bytes: 2720
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#include <assert.h>
#include <bitset>
#define Endl endl
#define mp make_pair
#define ll long long 
#define ull unsinged long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
template <typename T1,typename T2> inline void chmin(T1 &x,T2 b) {if(b<x) x=b;}
template <typename T1,typename T2> inline void chmax(T1 &x,T2 b) {if(b>x) x=b;}
const int inf=1039074182;
const ll llinf=1LL*inf*inf;
using namespace std;
int n;
int h[5005];
int p[5005];
int dp[5005];

bool compare(pii &a,pii &b)
{
	return a.first+a.second<b.first+b.second;
}

void upd(int &a,int b)
{
	if(a==-1) a=b;else chmin(a,b);
}

int main()
{
//	freopen("input.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin>>n;
	vector <pii> vSort;
	for(int i=0;i<n;i++)
	{
		cin>>h[i]>>p[i];
		vSort.push_back(mp(h[i],p[i]));
	}
	sort(all(vSort),compare);
	for(int i=0;i<n;i++)
	{
		h[i]=vSort[i].first;
		p[i]=vSort[i].second;
	}
	memset(dp,-1,sizeof(dp));
	dp[0]=0;
	for(int i=0;i<n;i++)
	{
		for(int j=n;j>=0;j--)
		{
			if(dp[j]==-1) continue;
			if(dp[j]<=h[i]) upd(dp[j+1],dp[j]+p[i]);
		}
	}
	for(int j=n;j>=0;j--)
	{
		if(dp[j]!=-1) over(j);
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
ll MOD = 1000000007;
ll INF =1<<30;

int main(){
    int n;
    cin >>n;
    vector<pair<string,int>>x(n),y(n);
    rep(i,n) cin>>x[i].first>>x[i].second;
    y=x;
    sort(x.begin(),x.end());
    vector<int> c;
    rep(i,n){
        string s = x[i].first;
        priority_queue<int>q;
        while(i<n&&x[i].first==s){
            q.push(x[i].second);
            i++;
        }
        while(!q.empty()){
            int ans = q.top();
            q.pop();
            rep(i,n){
                if(ans==y[i].second){
                  cout << i+1<<endl;
                }
            }
        }
        i--;
    }
    
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 500005;

int n, i, x[N], l[N], maxx, res, kol[N], w;

bool cmp(int a, int b) {
	return x[a] < x[b];
}

int main() {
scanf("%d", &n);
for (i=0;i<n;i++) {
	scanf("%d %d", &x[i], &l[i]);
	kol[i] = i;
}
sort(kol, kol + n, cmp);
maxx = -INF;
for (i=0;i<n;i++) {
	w = kol[i];
	if (x[w] - l[w] >= maxx) {
		res++;
		maxx = x[w] + l[w];
	} else maxx = min(maxx, x[w] + l[w]);
}
printf("%d\n", res);
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

int N,A,B;

int main() {
  cin >> N >> A >> B;
  int diff = abs(A-B);
  puts(!(diff&1)?"Alice":"Borys");
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int n, a[200];

bool Solve(int m, int x, int indx) {

	if (x == m)return true;
	if (indx == n)return false;

	if (Solve(m, x, indx + 1) == true)return true;
	if (Solve(m, x + a[indx + 1], indx + 1) == true)return true;

	return false;

}


int main() {

	int m, q;

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

	cin >> q;

	for (int i = 0; i<q; i++) {

		cin >> m;

		if (Solve(m, a[0], 0) || Solve(m, 0, 0))cout << "yes" << endl;
		else cout << "no" << endl;

	}


	return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL (1LL<<62) // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

struct Edge{
    // 始点, 終点, 重み, 最大量
    long long src, dst, weight, capacity;
    Edge(): src(0), dst(0), weight(0), capacity(0) {}
    Edge(long long s, long long d, long long w): src(s), dst(d), weight(w) {}
    Edge(long long s, long long d, long long w, long long c): src(s), dst(d), weight(w), capacity(c) {}
};

class Graph{
public:
    long long size;
    vector<vector<Edge>> node;
    Graph(long long n): size(n), node(n) {}
    // 有向辺の追加
    void addArc(long long s, long long d, long long w = 1){
        node[s].emplace_back(s, d, w);
    }
};

// TopologicalSort; トポロジカルソート
// ：有向非巡回グラフ（DAG）の全ての辺が右向きになるように整列する。[O(E+V)]
vector<long long> TopologicalSort(const Graph &g){
    vector<long long> indegree(g.size), sorted;
    for(long long v=0; v<g.size; v++) for(auto &edge: g.node[v]) indegree[edge.dst]++;
    queue<long long> que;
    for(long long i=0; i<g.size; i++) if(indegree[i] == 0) que.push(i);
    while(!que.empty()){
        long long v = que.front();
        que.pop();
        sorted.emplace_back(v);
        for(auto &edge: g.node[v]) if (--indegree[edge.dst] == 0) que.push(edge.dst);
    }
    return *max_element(indegree.begin(), indegree.end()) == 0LL ? sorted : vector<long long>();
}

int main(){
    Init();
    ll n, m;
    cin >> n >> m;
    Graph g(n);
    rep(i, n-1+m){
        ll a, b;
        cin >> a >> b;
        a--, b--;
        g.addArc(a, b);
    }

    vi ans(n, -INFLL);
    auto ts = TopologicalSort(g);
    map<ll, ll> t;
    for(ll i=0; i<ts.size(); i++) t[ts[i]] = i;
    ans[ts[0]] = 0;

    for(ll i=0; i<ts.size(); i++){
        for(auto &edge : g.node[ts[i]]){
            if(t[ans[edge.dst]-1] <= t[edge.src]){
                ans[edge.dst] = edge.src + 1;
            }
        }
    }
    for(ll i=0; i<n; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 18136
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {

	long A;
	long B;
	long M;
	cin >> A;
	cin >> B;
	cin >> M;

	vector<long> av(A, 0);
	for (long i = 0; i < A; i++) {
		cin >> av[i];
	}

	vector<long> bv(B, 0);
	for (long i = 0; i < B; i++) {
		cin >> bv[i];
	}

	long x;
	long y;
	long c;
	long val;
	long minval = *min_element(av.begin(), av.end()) + *min_element(bv.begin(), bv.end());

	for (long i = 0; i < M; i++) {
		cin >> x;
		cin >> y;
		cin >> c;
		val = av[x - 1] + bv[y - 1] - c;
		if (val < minval) {
			minval = val;
		}
	}

	cout << minval << endl;

	return 0;
}

Measured memory_bytes: 1792
from itertools import combinations_with_replacement


def main():
    N, M, Q = list(map(int, input().split(' ')))
    constraint_list = list()
    for _ in range(Q):
        constraint_list.append(list(map(int, input().split(' '))))
    ans = 0
    for A in combinations_with_replacement(range(1, M + 1), N):
        score = 0
        for constraint in constraint_list:
            a, b, c, d = constraint
            if A[b - 1] - A[a - 1] == c:
                score += d
        ans = max([ans, score])
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9224
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
typedef long long ll;
typedef unsigned long long ull;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()ss		
#define debug system("pause")				//デバッグ用


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

	int n,k;

	cin >>n >> k;

	string s;
	cin >> s;

	for (int i = 0; i < n; i++)
	{
		if (i + 1 == k)
		{
			char tmp;
			tmp = 'a' + s[i] - 'A';
			cout << tmp;
		}
		else
		{
			cout << s[i];
		}
	}

	cout << endl;

}

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

int main()
{
  int n, k;
  cin >> n >> k;

  int toConnect = (n - 1) * (n - 2) / 2 - k;
  if (toConnect < 0)
  {
    cout << -1 << endl;
    return 0;
  }

  vector < pair<int, int> > ans;
  for (int i = 1; i < n; i++)
    ans.push_back({i, n});

  for (int i = 1; i < n; i++)
    for (int j = i + 1; j < n; j++)
      if (toConnect > 0)
      {
        ans.push_back({i, j});
        toConnect--;
      }

  cout << ans.size() << endl;
  for (auto e : ans)
    cout << e.first << ' ' << e.second << endl;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long[] a = sc.LongArray();

        Dictionary<long, long> dic = new Dictionary<long, long>();

        foreach (var num in a)
        {
            if (dic.ContainsKey(num))
            {
                dic[num]++;
            }
            else
            {
                dic.Add(num, 1);
            }
        }

        long eat = 0;

        long even = 0;

        foreach (var item in dic)
        {
            var count = item.Value;
            if (item.Value >= 2)
            {
                var num = (count - 1) / 2;
                eat += num;
                count -= num * 2;
                if (count == 2)
                {
                    even++;
                }
            }
        }

        eat += (even + 1) / 2;

        long answer = n - eat * 2;

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 41388
#include<bits//stdc++.h>
using namespace std;
int main(){
  int n,sum =0;cin >> n;vector<int> a(n);
  for(int i = 0; i < n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());int f = a[0];
  for(int i = 1; i < n;i++){
    sum += abs(a[i] - f);
    f = a[i];
  }
  cout << sum << endl;
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	int a, b; char op; scanf("%d %c %d", &a, &op, &b);
	if (op == '+') printf("%d", a+b);
	else printf("%d", a-b);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
     
int main() {
  double ans=0, sum=0;
  int n, count=0;
  cin >> n;
  vector<pair<int, int>> vec(n, pair<int, int>());
  rep (i, n) {
    int x, y;
    cin >> x >> y;
    vec[i] = make_pair(x, y);
  }

  vector<int> num(n);
  rep (i, n) num[i] = i;

  do {
    for (int i=0; i<n-1; ++i) {
      pair<int, int> p, q;
      p = vec[num[i]];
      q = vec[num[i+1]];
      sum += sqrt(pow((p.first - q.first), 2) + pow((p.second - q.second), 2));
    }
    ++count;
  } while (next_permutation(num.begin(), num.end()));

  ans = sum / count;
  cout << fixed << setprecision(10);
  cout << ans << endl;
}

Measured memory_bytes: 256
from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math

N = int(stdin.readline().rstrip())
d = [int(s) for s in stdin.readline().rstrip().split()]
count = 0
sumF = d[0]
sumB = d[len(d) - 1]
count = 0
countF = 0
countB = len(d) - 1
while count < len(d):
    if sumF < sumB:
        sumF += d[countF+1]
        countF += 1
        count += 1
    elif sumB < sumF:
        sumB += d[countB-1]
        countB -= 1
        count += 1
    else:
        sumF += d[countF+1]
        countF += 1
        sumB += d[countB-1]
        countB -= 1
        count += 2
print(abs(sum(d[0:countF])-sum(d[countF:len(d)])))


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

using namespace std;

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(NULL);
    
    int n,k,i,j;
    cin >> n >> k;
    int arr[n];
    long int dp[n+1][k+1];
    //memset(dp,0,sizeof(dp));
    for(i=0;i<n;i++){
        cin >> arr[i];
        dp[i+1][0] = 1;
    }
    //sort(arr,arr+n);
    for(i=1;i<=k;i++){
        if(arr[0] >= i)
        dp[1][i]=1;
        else
        dp[1][i]=0;
    }
    
    for(i=2;i<=n;i++){
        for(j=1;j<=k;j++){
            if(j <= arr[i-1])
            dp[i][j] = (dp[i][j-1] + dp[i-1][j])%1000000007;
            else{
                dp[i][j] = (dp[i][j-1] + dp[i-1][j] - dp[i-1][j-arr[i-1]-1] + 1000000007) % 1000000007;
            }
        }
    }
   /* for(i=0;i<=n;i++){
        for(j=0;j<=k;j++){
            cout << dp[i][j] << " ";
        }
        cout << "\n";
    }*/
    cout << dp[n][k];
    return 0;
}

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

int main()
{
  //int n;
  int a[10000];
  for(int i = 0; i < 10000 ; i++ )
  {
    cin >> a[i];
    if (a[i] == 0)
    {
        break;   
    }
    else cout <<"Case "<<i + 1 <<": "<< a[i] <<endl;
  }
  return 0;
}



Measured memory_bytes: 3048
n=int(input())
s=[]
h=[]
c=[]
d=[]
for i in range(n):
    a,b=map(str,input().split())
    if a=="S":
        s.append(int(b))
    if a=="H":
        h.append(int(b))
    if a=="C":
        c.append(int(b))
    if a=="D":
        d.append(int(b))
for i in range(1,14):
    if i in s:
        pass
    else:
        print("S",i)
for i in range(1,14):
    if i in h:
        pass
    else:
        print("H",i)
for i in range(1,14):
    if i in c:
        pass
    else:
        print("C",i)
for i in range(1,14):
    if i in d:
        pass
    else:
        print("D",i)



Measured memory_bytes: 5604
import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))

from collections import deque

edges = []

def solve(u, v=-1):
  global edges
  que = deque([u])
  if v != -1:
    que.append(v)
  used = set([u, v])
  D = {u: 0, v: 0}
  E = {}
  if v != -1:
    E[0] = max(len(edges[v]), len(edges[u])) - 1
  else:
    E[0] = len(edges[u])
  x = v
  while que:
    v = que.popleft()
    d = D[v]
    for w in edges[v]:
      if w in used:
        continue
      D[w] = d + 1
      que.append(w)
      used.add(w)
      E[d+1] = max(E.get(d+1, 0), len(edges[w])-1)
  res = 2 if x != -1 else 1
  for v in E.values():
    if v:
      res *= v
  return res


def main():
  global edges
  n = int(input())
  edges = [[] for _ in range(n)]
  for _ in range(n-1):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

  # calc diameter
  que = deque([0])
  dist = {0: 0}
  prev = {0: 0}
  while que:
    u = que.popleft()
    d = dist[u]
    for w in edges[u]:
      if w in dist:
        continue
      dist[w] = d + 1
      prev[w] = u
      que.append(w)
  w = u  # 最遠点
  que = deque([w])
  dist = {w: 0}
  prev = {w: -1}
  while que:
    u = que.popleft()
    d = dist[u]
    for w in edges[u]:
      if w in dist:
        continue
      dist[w] = d + 1
      prev[w] = u
      que.append(w)
  w = u
  D = []
  while w != -1:
    D.append(w)
    w = prev[w]

  L = len(D)  # 直径
  col = (L + 1) // 2
  if L % 2 == 1:
    ans = 10**18
    v = D[L//2]  # 中心
    for w in edges[v]:  # 中心から繋がってる部分について
      ans = min(ans, solve(v, w))
    ans = min(ans, solve(v))
  else:
    # 直径が偶数の時は中心が2個
    v = D[L//2-1]
    w = D[L//2]
    ans = solve(v, w)
  print(col, ans)


if __name__ == '__main__':
  main()


Measured memory_bytes: 40688
import sys
inputs = input().rstrip().split(' ')

n = int(inputs[0])
a = int(inputs[1])
b = int(inputs[2])

def isNum(Num):
    tmp = Num % 10 + (int(Num/10) % 10) + (int(Num/100) % 10) + (int(Num/1000)  % 10) + (int(Num/10000) % 10)
    if (a<= tmp and tmp <=b):
        return Num
    else:
        return 0
count = 0

for i in range(1,n+1,1):
    count = count + isNum(i)
print(count)


Measured memory_bytes: 3064
import sys

input=sys.stdin.buffer.readline

N, M, S = map(int,input().split())
SMAX = 50 * (N-1)
S = min(S,SMAX)

INF=10**18
dp = [[INF]*2501 for _ in range(N)]
way=[[]for _ in range(N)]

for _ in range(M):
    u,v,a,b=map(int,input().split())
    way[u-1].append((v-1,a,b))
    way[v-1].append((u-1,a,b))

CD = [tuple(map(int,input().split())) for _ in range(N)]

from heapq import heappush,heappop

q=[(0,0,S)]

while q:
    t, u, s = heappop(q)
    for nxt, a, b in way[u]:
        if s >= a:

            if dp[nxt][s-a] > t + b:
                dp[nxt][s-a] = t + b
                heappush(q,(t + b, nxt, s-a))
                
    c, d = CD[u]
    nc = min(SMAX, c + s)
    nt= t + d

    if nt < dp[u][nc]:
        dp[u][nc] = nt
        heappush(q, (nt, u, nc))

for i in range(1,N):
    print(min(dp[i]))

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

int	main(void)
{
  int pay, one_coin;
  cin >> pay >> one_coin;
  
  while (pay >= 500)
    pay -= 500;
  if (pay == 0)
    cout << "Yes" << endl;
  else if (pay <= one_coin)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  vector<int> T(N), L(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &T[i]);
    T[i] *= 2;
    if (i > 0) { T[i] += T[i - 1]; }
  }
  for (int i = 0; i < N; ++i) {
    scanf("%d", &L[i]);
  }

  int M = T[N - 1];
  vector<double> V1(M + 5, 0.0);
  double lim = L[0];
  for (int t = 1, ix = 0; t <= M; ++t) {
    if (t > T[ix]) {
      lim = L[++ix];
    }
    V1[t] = min(V1[t - 1] + 0.5, lim);
  }

  vector<double> V2(M + 5, 0.0);
  lim = L[N - 1];
  for (int t = M - 1, ix = N - 1; t >= 0; --t) {
    if (ix > 0 and t < T[ix - 1]) {
      lim = L[--ix];
    }
    V2[t] = min(V2[t + 1] + 0.5, lim);
  }

  vector<double> V(M + 5);
  for (int t = 0; t <= M; ++t) {
    V[t] = min(V1[t], V2[t]);
  }

  double ans = 0;
  for (int t = 1; t <= M; ++t) {
    ans += (V[t - 1] + V[t]) / 2.0;
  }
  ans /= 2.0;
  printf("%.9f\n", ans);
  return 0;
}


Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    static class A500YenCoins
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(' ');
            var k = int.Parse(inputs[0]);
            var x = int.Parse(inputs[1]);
            
            Console.WriteLine(500 * k >= x ? "Yes" : "No");
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 11092
#include <cstdio>

using namespace std;

const int mod = 998244353;
int n;
char s[200001];
long long a[200001];

long long calc(int c) {
    int i, j;
    long long ans = 0;
    
    for (i = 0; i < c; i++) {
        ans *= 2;
        if (ans >= mod) ans -= mod;
        
        if (s[i] == '1') {
            ans++;
            if (ans >= mod) ans -= mod;
        }
    }
    
    for (i = 0; i < n / c; i++) {
        for (j = 0; j < c; j++) {
            int x, y;
            
            if (i % 2 == 0) {
                x = s[i * c + j] - '0';
                y = s[j] - '0';
            } else {
                x = s[i * c + j] - '0';
                y = 1 - (s[j] - '0');
            }
            
            if (x > y) {
                return ans + 1;
            } else if (x < y) {
                return ans;
            }
        }
    }
    
    return ans + 1;
}

int main() {
    int i, j;
    long long ans = 0;
    
    scanf("%d", &n);
    scanf("%s", s);
    
    for (i = 1; i <= n; i++) {
        if (n % i == 0 && n / i % 2 == 1) {
            a[i] += calc(i);
            if (a[i] >= mod) a[i] -= mod;
            
            ans += a[i] * i * 2 % mod;
            
            for (j = i * 2; j <= n; j += i) {
                a[j] -= a[i];
                if (a[j] < 0) a[j] += mod;
            }
        }
    }
    
    printf("%lld\n", ans % mod);
    
    return 0;
}


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

struct team {
    char name;
    int win, lose;
};

void mysort(team t[], int n) {
    for (int i = 0; i < n; i++) {
        for (int j = i; j > 0; j--) {
            if (t[j - 1].win < t[j].win || t[j - 1].win == t[j].win 
                && t[j - 1].lose > t[j].lose) {
                team temp = t[j - 1];
                t[j - 1] = t[j];
                t[j] = temp;
            }
        }
    }
}

int main() {
    while (true) {
        int n;
        cin >> n;
        if (!n) return 0;
        
        team t[n];
        for (int i = 0; i < n; i++) {
            t[i].win = 0;
            t[i].lose = 0;
        }

        for (int i = 0; i < n; i++) {
            cin >> t[i].name;
            for (int j = 0; j < n - 1; j++) {
                int r;
                cin >> r;
                if (r == 0) t[i].win++;
                else if (r == 1) t[i].lose++;
            }
        }
        mysort(t, n);
        for (int i = 0; i < n; i++) {
            cout << t[i].name << endl;
        }
    }
}

Measured memory_bytes: 3044
N = int(input())

count = 0
count_a = 0
count_b = 0
count_all = 0
for i in range(N):
    s = input()
    for j in range(1,len(s)):
        if s[j] == 'B' and s[j-1] == 'A':
            count += 1
    if s[0] == 'B' and s[-1] == 'A':
        count_all += 1
        continue
    if s[0] == 'B':
        count_b += 1
    if s[-1] == 'A':
        count_a += 1

mx = max(count_a, count_b)
mn = min(count_a, count_b)
ans = count + mn
if count_all != 0:
    if count_a != 0 and count_b != 0:
        ans = count + (count_all-1+2) + (mn-1)
    if count_a == 0 and count_b == 0:
        ans = count + count_all - 1
    if count_a == 0 and count_b != 0:
        ans = count + count_all - 1 + 1
    if count_a != 0 and count_b == 0:
        ans = count + count_all -1 + 1

print(ans)


Measured memory_bytes: 50008
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, ans;
string str;

int main(){
	cin >> str;
	
	n = str.size();
	ans = n;
	for(ll i = 0; i < n-1; i++){
		if(str[i] != str[i+1]){
			ans = min(max(i+1, n-i-1), ans);
		}
	}
	
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int r;
  cin>>r;
  cout<<r*r<<'\n';
  return 0;
}


Measured memory_bytes: 256
A, B, Q = map(int, input().split())
s = [int(input()) for _ in range(A)]
t = [int(input()) for _ in range(B)]
x = [int(input()) for _ in range(Q)]


def bsearch(n, arr):
    l = 0
    r = len(arr)
    m = (l + r) // 2
    while l != m:
        if n <= arr[m]:
            r = m
        else:
            l = m
        m = (l + r) // 2
    if r < len(arr) and abs(arr[l] - n) > abs(arr[r] - n):
        return r
    else:
        return l


def bsearch_l(n, arr):
    l = 0
    r = len(arr)
    m = (l + r) // 2
    while l != m:
        if n <= arr[m]:
            r = m
        else:
            l = m
        m = (l + r) // 2
    return l


def calc_distance(x, l, c, near_idx):
    ret = abs(x - l)
    if c == 's':
        next_l = t[near_idx]
    else:
        next_l = s[near_idx]
    ret += abs(next_l - l)
    return ret


st = []
for i, s_i in enumerate(s):
    t_i = bsearch(s_i, t)
    st.append((s_i, 's', t_i))

for i, t_i in enumerate(t):
    s_i = bsearch(t_i, s)
    st.append((t_i, 't', s_i))

st = sorted(st)
starr = sorted(s + t)

ans_list = []
for i, x_i in enumerate(x):
    st_i = bsearch_l(x_i, starr)
    l, c, near_idx = st[st_i]
    ans = calc_distance(x_i, l, c, near_idx)
    if st_i < len(st) - 1:
        l, c, near_idx = st[st_i + 1]
        ans = min(ans, calc_distance(x_i, l, c, near_idx))
    ans_list.append(ans)

for i, ans in enumerate(ans_list):
    print(ans)

Measured memory_bytes: 45392
#include <iostream>
#include <algorithm>
using namespace std;
 
int main()
{
    int N;
    string S;
    cin >> N;
    cin >> S;
    long long ans = 0, r, g, b; r=g=b=0;
    for (int i = 0; i < S.size(); ++i) {
        if (S[i] == 'R') r++; 
        if (S[i] == 'G') g++; 
        if (S[i] == 'B') b++; 
    }
    ans = r*g*b;
    // cout << ans << endl;
    for (int i = 1; i <= (S.size()-1)/2; ++i) {
        for (int j = 0; j < S.size(); ++j) {
            int x = j, y = x + i, z = y + i;
            if (y >= S.size() || z >= S.size()) break;
            if (S[x] != S[y] && S[x] != S[z] && S[y] != S[z]) ans--;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    vector<int> G[101];
    int N; cin >> N;
    for(int i = 0; i < N; i++) {
        int u, k; cin >> u >> k;
        while(k > 0) {
          int v; cin >> v; 
          G[u].push_back(v);
          k--;
        }
    }

    vector<int> dist(N+1, -1);
    queue<int> Q;
    Q.push(1);
    dist[1] = 0;

    while(!Q.empty()) {
        int u = Q.front(); Q.pop();
        for(int i = 0; i < (int)G[u].size(); i++) {
            int v = G[u][i];
            if(dist[v] != -1) continue;
            dist[v] = dist[u] + 1;
            Q.push(v);
        }
    }
    for(int i = 1; i < N+1; i++) cout << i << ' ' << dist[i] << endl;
}


Measured memory_bytes: 3172
use proconio::input;
use proconio::marker::*;
use std::cmp;
use std::cmp::Ordering;
use std::cmp::Reverse;
use std::collections::BinaryHeap;

const MAX_V: usize = 50;
const MAX_S: i64 = MAX_V as i64 * 50 + 5;
const INF: i64 = 1e18 as i64;

#[derive(Clone, Copy)]
struct Edge {
    to: usize,
    fee: i64,
    time: i64,
}

#[derive(Eq)]
struct Data {
    v: usize,
    s: i64,
    time: i64,
}

impl Ord for Data {
    fn cmp(&self, other: &Self) -> Ordering {
        self.time.cmp(&other.time)
    }
}

impl PartialOrd for Data {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

impl PartialEq for Data {
    fn eq(&self, other: &Self) -> bool {
        self.time == other.time
    }
}

fn main() {
    input! {
        n: usize,
        m: usize,
        s: i64,
        rails: [(Usize1, Usize1, i64, i64); m],
        exchanges: [(i64, i64); n],
    }

    let mut g = vec![vec![]; MAX_V];
    for (from, to, fee, time) in rails {
        g[from].push(Edge { to, fee, time });
        g[to].push(Edge {
            to: from,
            fee,
            time,
        });
    }

    let dp = vec![vec![INF; MAX_S as usize + 5]; MAX_V];

    let mut solve = Solve {
        dp,
        n,
        m,
        g,
        s,
        exchanges,
        q: BinaryHeap::new(),
    };
    solve.solve();
}

struct Solve {
    n: usize,
    m: usize,
    s: i64,
    g: Vec<Vec<Edge>>,
    dp: Vec<Vec<i64>>,
    exchanges: Vec<(i64, i64)>,
    q: BinaryHeap<Reverse<Data>>,
}

impl Solve {
    fn solve(&mut self) {
        let s = cmp::min(self.s, MAX_S);
        let g = self.g.clone();

        self.push(0, s, 0);

        while let Some(Reverse(data)) = self.q.pop() {
            let Data { v, s, time } = data;
            if self.dp[v][s as usize] != time {
                continue;
            }

            let (c, d) = self.exchanges[v];
            let ns = cmp::min(s + c, MAX_S);
            self.push(v, ns, time + d);

            for e in g[v].iter().copied() {
                self.push(e.to, s - e.fee, time + e.time);
            }
        }

        for i in 1..self.n {
            let mut ans = INF;
            for j in 0..(MAX_S + 5) {
                ans = cmp::min(ans, self.dp[i][j as usize]);
            }
            println!("{}", ans);
        }
    }

    fn push(&mut self, v: usize, s: i64, time: i64) {
        let data = Data { v, s, time };
        if s < 0 {
            return;
        }
        if self.dp[v][s as usize] <= time {
            return;
        }
        self.dp[v][s as usize] = time;
        self.q.push(Reverse(data));
    }
}


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

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

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

    cout << ans << endl;
}


Measured memory_bytes: 256
a,b,k = map(int, input().split())
if k > a and k >= a+b:
  print( 0 , 0 )
elif k < a :
  print(a-k , b)
elif k == a:
  print(0 , b)
elif k>a and k < a+b:
  print(0 , b-(k-a))



Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
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; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    vector<int> a(3); rep(i, 3) cin >> a[i];
    sort(ALL(a));
    int ans = abs(a[0] - a[1]) + abs(a[1] - a[2]);
    cout << ans << endl;
}

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

typedef long long ll;
typedef long long LL;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#ifdef DEBUG
    #define cek(x) cout<<x
#else
    #define cek(x) if(false){}
#endif // DEBUG

#define fi first
#define se second
#define INF 1000000000
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define PI acos(-1.0)
#define pb push_back
#define TC() while(tc--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=0;i<=n;i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define REPN(i,a,b) for(int i=a;i<=b;i++)
#define reset(a,b) memset(a,b,sizeof(a))
#define sc(x) scanf("%d",&x)

int main(void){
    #ifdef ccsnoopy
        freopen("D:/Code/in.txt","r",stdin);
    #endif

    ll n,x;
    scanf("%lld %lld", &n,&x);
    ll total = n;

    if(x*2 > n)x = n-x;
    n = n-x;

    while(x){
        ll brp = n/x;

        if(n%x){
            total += 2*brp*x;
            ll temp = n%x;
            n = x;
            x = temp;
        }else{
            total += (brp * 2 - 1) * x;
            break;
        }


    }

    cout<<total<<endl;



    return 0;
}





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

int main() {
    long int X, Y, x, y;
    cin >> X >> Y >> x >> y;
    if(2*x == X && 2*y == Y){
        cout << 1.0*X*Y/2 << " " << 1;
    }
    else{
        cout << 1.0*X*Y/2.0 << " " << 0;
    }
}

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

int main(){
  int n,l;
  cin >> n >> l;
  vector<string> vec(n);
  for(int i=0; i<n; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  for(int i=0; i<n; i++){
    cout << vec.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int n = sc.nextInt();
		int[] a = new int[200000];
		for(int i = 0; i < n; i++){
			a[i] = sc.nextInt();
		}
		sc.close();

		int max = 0;
		for(int i = 0; i < n; i++) {
			int d;
			if(i == n - 1) {
				d = k + a[0] - a[i];
			}else {
				d = a[i + 1] - a[i];
			}
			max = Math.max(max, d);
		}


		System.out.print(k - max);
	}
}


Measured memory_bytes: 73892
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, a[200009], b[200009];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(b, b + n);
	for (int i = 0; i < n; i++) {
		if (a[i] == b[n - 1]) {
			cout << b[n - 2] << E;
		}
		else {
			cout << b[n - 1] << E;
		}
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <algorithm>
int main() {
	string s;

	cin >> s;

	for (int i = 0; i < s.size(); i++) {
		if (s[i] != 'x') {
			s[i] = 'x';
		}
	}

	cout << s <<endl;
}

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

int main(){
    string a;
    cin >> a;
    
    for(int j = 0; j < a.size(); j++){
        a.at(j) = 'x';
    }
    cout << a << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int N = sc.nextInt();
			sc.nextLine();
			Long A[] = new Long[N];
			Long B[] = new Long[N];
			for (int i = 0; i < N; i++) {
				A[i] = sc.nextLong();
				B[i] = sc.nextLong();
			}
			long cnt = 0;
			for (int i = N - 1; i >= 0; i--) {
				long cur = A[i] + cnt;
				if (cur % B[i] != 0) {
					cnt = cnt + B[i] - (cur % B[i]);
				}
			}
			System.out.println(cnt);
		}
	}
}


Measured memory_bytes: 83824