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


typedef long long ll;
#define DEBUG

class UnionFind{
    private:
    vector<int> par; // 親
    vector<int> rank; // 木の深さ
    int size_;

    public:
    // n要素で初期化
    UnionFind(int n) {
        par = vector<int>(n);
        rank = vector<int>(n);
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
        }
        size_ = n;
    }

    // 木の根を求める
    int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }

    // xとyの属する集合を併合
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
        }
        size_--;
    }

    // xとyが同じ集合に属するか否か
    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(){
        return size_;
    }
};


void solve(long long N, long long M, std::vector<long long> a, std::vector<long long> b){
    // 0-originにする
    for(int i=0; i < M; i++){
        a[i]--;
        b[i]--;
    }

    int cnt = 0;
    for(int i=0; i < M; i++){
        // i橋を落とす
        UnionFind uf(N);
        // i橋をのぞいて橋をかける
        for(int j=0; j < M; j++){
            if(j == i){
                continue;
            }
            uf.unite(a[j], b[j]);
        }
        // 連結成分をかぞえる
        if(uf.size() > 1){
            cnt++;
        }
    }

    cout << cnt << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(M);
    std::vector<long long> b(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    solve(N, M, std::move(a), std::move(b));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    int cnt = 0;;
    for(int i = 1; i <= N; i++) {
        if(i % 2 == 1) {
            int w = 0;
            for(int j = 1; j <= N; j++) {
                if(i % j == 0) ++w;
            }
            if(w == 8) cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int b[25];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++){
			scanf("%d",b+i);
		}
		int rem=32;
		int now=0;
		while(rem){
			rem-=(rem-1)%5;
			printf("%d\n",rem);
			if(rem==0)break;
			rem-=b[now++%a];
			if(rem<0)rem=0;
			printf("%d\n",rem);
		}
	}
}

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

int main() {
  string s, t;
  cin >> s >> t;
  bool a = true;
  for(int i = 0; i < s.size(); i++) {
    if(s.at(i) != t.at(i)) {
      a = false;
    }
  }
  if(a) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/
int n, k;
vi a(100);

bool memo[100001], vis[100001];

bool dfs1(int x){
  if(vis[x]) return memo[x];
  vis[x] = true;

  rep(i, 0, n){
    if(a[i] <= x){
      if(!dfs1(x-a[i])) return memo[x] = true;
    }
  }

  return memo[x] = false;
}

signed main(){
  cin >> n >> k;
  rep(i, 0, n) cin >> a[i];

  if(dfs1(k)) cout << "First" << endl;
  else cout << "Second" << endl;

  return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

int main(){
	vector<int> arr;
	int N;
	cin>>N;
	arr.resize(N);

	REP(i,N)cin>>arr[i];

	int  count = 0;
	REP(i,N){
		if((i+1) == arr[arr[i]-1])count++;
	}

	cout<<(count/2)<<endl;
	return 0;
}



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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

LL dp[1005][20005];

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

    int h, n;
    cin >> h >> n;
    vector< P > v;
    for( int i = 0; i < n; ++i ) {
        int a, b;
        cin >> a >> b;
        v.pb(MP(a, b));

    }

    for( int i = 0; i < 1005; ++i ) {
        for( int j = 0; j < 20005; ++j ) {
            dp[i][j] = INF;
        }
    }
    for( int i = 0; i < n; ++i ) {
        LL t = v[i].F;
        LL m = v[i].S;
        for( int j = 1; j <= 20000; ++j ) {
            if( i == 0 ) {
                if( j == 1 ) {
                    dp[i][j] = m;
                    continue;

                }
                if( t + 1 == j ) {
                    t += v[i].F;
                    m += v[i].S;
                    dp[i][j] = m;

                } else {
                    dp[i][j] = dp[i][j - 1];

                }
                continue;
            }

            if( t + 1 == j ) {
                t += v[i].F;
                m += v[i].S;

                dp[i][j] = min(dp[i][j - v[i].F] + v[i].S, m);
                dp[i][j] = min(dp[i][j], dp[i - 1][j]);
                dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i].F] + v[i].S);

            } else {
                if( j - v[i].F >= 1 ) {
                    dp[i][j] = min(dp[i][j - v[i].F] + v[i].S, m);
                    dp[i][j] = min(dp[i][j], dp[i - 1][j]);
                    dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i].F] + v[i].S);

                } else {
                    dp[i][j] = min(dp[i - 1][j], m);

                }
            }
        }
    }

    LL res = INF;
    for( int i = 0; i < n; ++i ) {
        res = min(res, dp[i][h]);

    }
/*
    for( int i = 0; i < n; ++i ) {
        for( int j = 1; j <= h; ++j ) {
            cout << dp[i][j] << " ";

        }
        cout << endl;
    }
    */
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 157952
#include <iostream>
using namespace std;
int main(){
    long a,b,k;
    cin >> a >> b >> k;
    if(b-k+1<=a+k-1){
        for(int i = 0;i<=b-a;i++){
            cout << a+i << endl;
        }
    }
    else{
        for(int i = 0;i<k;i++){
            cout << a+i << endl;
        }
        for(int i = k-1;i>=0;i--){
            cout << b-i << endl;
        }
    }
}

Measured memory_bytes: 256
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = List.range n `To m
let (++^) n m = if n < m then List.range n `To (pred m) else []

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

let scan_list sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list sep conv);
  arr

let rec powerset e =
  match Enum.get e with
  | None -> Enum.singleton @@ Enum.empty ()
  | Some v ->
    let f = powerset e in
    let g = Enum.clone f in
    EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)
    |>  Enum.append g

let permutations l =
  let rec aux l =
    let rec interleave x = function
      | [] -> [[x]]
      | (hd::tl) as lst ->
        (x::lst) ::
        (ListL.map ~f:(List.cons hd)  @@ interleave x tl)
    in
    match l with
    | [] -> [[]]
    | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in
  let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in
  List.enum % ListL.map ~f:List.enum @@ l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let x = scan "%d" id

exception Found of int

let () =
  try
    ListL.fold_left ~init:100
      ~f:(fun acc i  ->
          let w = Int.of_float @@ 1.01 *. Float.of_int acc in
          if w >= x then raise @@ Found i
          else w) (1++4000) |> ignore
  with
  | Found i -> Printf.printf "%d\n" i


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

int main()
{
  int n,m,flag = 1;
  cin>>n>>m;
  int arr[n];
  for(int i=0;i<m;i++)
    cin>>arr[i];

  for(int i=0;i<m;i++)
  {
    if(n-arr[i] < 0)
    {
      flag = 0;
      break;
    }
    else
      n -= arr[i];
  }
  if(flag)
    cout<<n;
  else
    cout<<"-1";
  return 0;
}


Measured memory_bytes: 3664
import sys
input = sys.stdin.readline
#N, K = (int(i) for i in input().split())
#B = [int(x) for x in input().split()]
#A = [[int(i) for i in input().split()] for i in range(N)]
A, B, C = (int(i) for i in input().split())
K = int(input())

while K > 0:
    if A < B and B < C:
        print("Yes")
        exit()
    elif A < B:
        C = C*2
    else:
        B = B*2
    K -= 1

if A < B and B < C:
        print("Yes")
        exit()
print("No")


Measured memory_bytes: 61680
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
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; }
const int INF = 1<<30;
const int mod = 1000000007;

ll beki(ll x, ll n, const ll &p) {
    ll ret = 1;
    while(n > 0) {
        if(n & 1) (ret *= x) %= p;
        (x *= x) %= p;
        n >>= 1;
    }
    return ret;
}

ll fact(ll n){
    if(n == 1) return 1;
    return n * fact(n-1) % mod;
}

ll F[700010];
ll Finv[700010];

void init_combination(){
    const int MAX = 700000;
    F[0] = 1;
    for(int i = 1; i <= MAX; i++){
        F[i] = F[i - 1] * i % mod;
    }
    Finv[MAX] = beki(F[MAX], mod - 2, mod);
    for(ll i = MAX - 1; i >= 0; i--) {
        Finv[i] = Finv[i+1] * (i+1) % mod;
    }
    return;
}


int main(){
    int x, y;
    cin >> x >> y;
    init_combination();
    if((x+y) % 3 != 0 || x > 2 * y || y > 2 * x){
        cout << 0 << endl;
        return 0;
    }
    int t = - (y - 2 * x) / 3, s = x - 2 * t;
    cout << F[s+t] * Finv[s] % mod * Finv[t] % mod << endl;
    return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N,M; cin>>N>>M;
    vector<ll> A(N);
    vector<ll> B(M);
    rep(i,N) cin>>A[i];
    rep(i,M) cin>>B[i];
    sort(ALL(A),greater<ll>());
    sort(ALL(B),greater<ll>());
    ll ans=1;
    ll act=0,bct=0;
    A.emplace_back(-1);
    B.emplace_back(-1);
    repr(i,N*M,1){
        if(A[act]==i){
            ++act;
            if(B[bct]==i){
                ++bct;
            }
            else{
                ans=ans*bct%MOD;
            }
        }
        else{
            if(B[bct]==i){
                ++bct;
                ans=ans*act%MOD;
            }
            else{
                ans=ans*(act*bct-((N*M)-i))%MOD;
            }
        }
    }
    if(act!=N or bct!=M) ans=0;

    cout<< ans <<"\n";
}
    
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 256
#include <stdio.h>

int road[50] = {0};


int main() {
    int n, m;
    int a, b;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; i++){
        scanf("%d %d", &a, &b);
        road[a-1]++;
        road[b-1]++;
    }
    for (int i = 0; i < n; i++) {
        printf("%d\n", road[i]);
    }

    return 0;


};

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
              Scanner scn =  new Scanner(System.in);
              String s = scn.next();
             
              scn.nextLine();
              int q = scn.nextInt();
                 StringBuilder sb1 = new StringBuilder();
                 StringBuilder sb2=new StringBuilder();
                 
              boolean f = false;
              while(q-->0){
            	  int t= scn.nextInt();
            	 if(t==1){
            		 if(f){
            			 f=false;
            		 }else{
            			 f=true;
            		 }
            	 }else{
            		 int n =scn.nextInt();
            		 char ch = scn.next().charAt(0);
            		 if(f==true){
            			 if(n==1){
            				 sb2.append(ch);
            			 }else{
            				 sb1.append(ch);
            			 }
            		 }else{
            			 if(n==1){
            				 sb1.append(ch);
            			 }else{
            				 sb2.append(ch);
            			 }
            		 }
            	 }
              }
              if(f==true){
            	  for(int i=sb2.length()-1;i>=0;i--){
            		  System.out.print(sb2.charAt(i));
            	  }
            	  for(int i=s.length()-1;i>=0;i--){
            		  System.out.print(s.charAt(i));
            	  }
            	  for(int i=0;i<sb1.length();i++){
            		  System.out.print(sb1.charAt(i));
            	  }
              }else{
            	  for(int i=sb1.length()-1;i>=0;i--){
            		  System.out.print(sb1.charAt(i));
            	  }
            	  for(int i=0;i<s.length();i++){
            		  System.out.print(s.charAt(i));
            	  }
            	  for(int i=0;i<sb2.length();i++){
            		  System.out.print(sb2.charAt(i));
            	  }
            	  
              }
         
	}

}

Measured memory_bytes: 147344
#include<bits/stdc++.h>
#define reg register
#define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i)
#define dep(i, a, b) for (reg int i = (a), i##end = (b); i >= i##end; --i)
using namespace std;
using ll = long long;

signed main() {
	ll n;
	cin>>n;
	vector<ll> p(n);
	rep(i, 0, n-1) {
		cin>>p[i];
	}
	ll sum=0, m=p[0];
	rep(i, 0, n-1) {
		sum += p[i];
		m = max(m, p[i]);
	}
	cout<<sum-m/2<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong a, b, c;

int main() {
    cin >> a >> b >> c;

    llong sum = 0;

    for (int i = 0; i < 10000; i++) {
        if (sum % b == c) {
            cout << "YES" << endl;
            return 0;
        }
        sum += a;
    }

    cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, q int
	var s string
	fmt.Scan(&n, &s, &q)

	bs := make([]BIT, 26)
	for i := 0; i < 26; i++ {
		bs[i] = newBIT(n + 2)
	}

	ss := make([]int, n)
	for i := 0; i < n; i++ {
		c := int(s[i] - 'a')
		ss[i] = c
		bs[c].add(i+1, 1)
	}

	var iq, lq, rq int
	var cq string
	for i := 0; i < q; i++ {
		fmt.Scan(&iq)

		switch iq {
		case 1:
			fmt.Scan(&iq, &cq)
			cur := int(cq[0] - 'a')
			pre := ss[iq-1]
			bs[pre].add(iq, -1)
			bs[cur].add(iq, 1)
			ss[iq-1] = cur
		case 2:
			fmt.Scan(&lq, &rq)
			ans := 0
			for i := 0; i < 26; i++ {
				cnt := bs[i].sum(rq) - bs[i].sum(lq-1)
				if cnt > 0 {
					ans++
				}
			}
			fmt.Println(ans)
		}
	}
}

// BIT .
type BIT struct {
	n   int
	bit []int
}

func newBIT(n int) BIT {
	b := BIT{n: n}

	n2 := 1
	for n2 <= n {
		n2 *= 2
	}

	b.bit = make([]int, n2)
	return b
}

func (b *BIT) sum(i int) int {
	s := 0
	for i > 0 {
		s += b.bit[i]
		i -= i & -i
	}
	return s
}

func (b *BIT) add(i, x int) {
	for i <= b.n {
		b.bit[i] += x
		i += i & -i
	}
}


Measured memory_bytes: 115060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	Main m = new Main();
	m.answer();
    }

    private Scanner scan = new Scanner(System.in);
    private int N;
    private int Y;

    public Main() {
	N = Integer.parseInt(scan.next());
	Y = Integer.parseInt(scan.next());

	scan.close();
    }

    public final void answer() {

	boolean notexist = true;

	outside: for (int x = 0; x <= N; x++) {
	    for (int y = 0; y <=  N-x; y++) {
		int z = N - x - y;
		if(exist(x, y, z)) {
		    System.out.println(x + " " + y + " " + z);
		    notexist = false;
		    break outside;
		}
	    }
	}

	if(notexist) System.out.println("-1 -1 -1");
    }

    private boolean exist(int x, int y, int z) {
	return x*10000 + y*5000 + z*1000 == Y;
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

int N, K;
vector<vector<int>> G(101010);
int ans=0;

int dfs(int v, int p){
  int ma=0;
  for(int u:G[v]) if(u!=p){
    ma=max(ma,dfs(u,v));
  }
  if(ma+1==K){
    if(p!=0) ans++;
    return 0;
  }else return (ma+1);
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  
  cin>>N>>K;
  rep(i,N){
    int a; cin>>a; a--;
    if(i) G[a].push_back(i);
    else if(a!=0) ans++;
  }
  dfs(0,0);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 10496
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    map<long long,long long> a;
    int n,ans=0,b;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>b;
        if(a[b]!=1){
            a[b]=1;
            ans++;
        }
        else{
            a[b]=0;
            ans--;
        }
    }
    cout<<ans<<endl;
    return(0);
}

Measured memory_bytes: 9860
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(), v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 1;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n;
        cin >> n;
        int a[n];
        for(int &it : a){
            cin >> it;
        }
        int ans = INF;
        for(int i = -100; i <= 100; i++){
            int curr = 0;
            for(int &j : a){
                curr += (i - j) * (i - j);
            }
            ans = min(ans, curr);
        }
        cout << ans << '\n';
    }
}

Measured memory_bytes: 34596
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
 
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
 
const int oo = 1e9 + 7;
const int mod = 1e9 + 7, maxn = 1000010;
const long double PI = acos(-1);


int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, aux, ans=0;

    cin >> n;

    vector<int> v(maxn, 0);

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

    if (v[1] == 1){
        cout << 1 << endl;
    }
    else if(v[1] > 1){
        cout << 0 << endl;
    }
    else{
        for (int i=2; i<maxn; i++){
            if (v[i]){
                if (v[i] == 1) ans++;
                for (int j=i+i; j<maxn; j+=i){
                    v[j] = 0;
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 7164
int main()
{
  int n, k;
  scanf("%d %d", &n, &k);
  int a[k][n], d, cnt[n], i, m;
  for (i = 0; i < n; i++)
    cnt[i] = 0;
  for (i = 0; i < k; i++)
  {
    scanf("%d", &d);
    for (m = 0; m < d; m++)
    {
      scanf("%d", &a[i][m]);
      cnt[a[i][m] - 1] = 1;
    }
  }
  
  int ans = 0;
  for (i = 0; i < n; i++)
  {
    if (cnt[i] == 0)
    {
      ans++;
    }
  }
  printf("%d", ans);
}


Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
typedef struct data{
	string s;
	long long p;
	long long vt;
};
bool cmp(data a,data b){
	if(a.s<b.s||(a.s==b.s&&a.p>b.p)) return true;
	return false;
}
int main(){
	data a[1000];
	long long n;
	cin>>n;
	for(long long i = 1;i<=n;i++){
		cin>>a[i].s>>a[i].p;
		a[i].vt = i;
	} 
	sort(a+1,a+1+n,cmp);
	for(long long i = 1;i<=n;i++) cout<<a[i].vt<<endl;
}

Measured memory_bytes: 764
#include <iostream>
using namespace std;
int main(void){
    int A,B,C;
    int cnt=0,sum=0;
    
    cin>>A;
    cin>>B;
    cin>>C;
    
    while(sum<C){
        cnt++;
        sum+=A;
        if(cnt!=0 && cnt%7==0){
            sum+=B;
        }
    }
    
    cout<<cnt<<"\n";
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define ll long long
#define inf 1000000000ll
using namespace std;

ll ans,n;
ll c[100],w[100];
ll dp[100003][102];

ll solve(ll cur, ll i){
    if(cur<0)return -inf;
    if(dp[cur][i]==-1){
        if(cur==0 || i==n) return 0;
        return dp[cur][i]=max(solve(cur-c[i],i+1) + w[i], solve(cur,i+1));
    }
    return dp[cur][i];
}

int main(){
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);
    ll ww;
    cin>>n>>ww;
    ll a,b;
    for(ll x=0; x<n; x++){
        cin>>c[x]>>w[x];
    }
    for(ll x=0; x<=ww; x++){
        for(ll y=0; y<=n; y++){
            dp[x][y]=-1;
        }
    }
    cout<<solve(ww,0);
    return 0;
}

Measured memory_bytes: 80000
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int main(){
   string s;
   cin >> s;
   int len = s.size();
   rep(i,len){
      s.erase(s.size()-1);
      if (s.size()%2 == 1) continue;
      bool can = true;
      for (int i = 0;i < s.size()/2;i++){
         if (s[i] != s[s.size()/2+i]) {
            can = false;
            break;
         }
      }
      if (can) {
         cout << s.size() << endl;
         return 0;
      }
   }
   
   return 0;
   
}



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

ll gcd(ll a, ll b){
    if(a < b){
        swap(a, b);
    }
    int r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main() {

    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll lcm = C*D/gcd(C,D);
	ll c_c = B / C - (A-1) / C;
    ll d_c = B / D - (A-1) / D;
    ll l_c = B / lcm - (A-1) / lcm;
    cout << B - A + 1 - (c_c + d_c - l_c);

}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

using namespace std;

std::vector<std::vector<std::pair<int, int>>> graph;

void dfs(std::vector<bool> &color, std::vector<bool> &visited, int current,
         bool c) {
    if (visited[current]) return;

    visited[current] = true;
    color[current] = c;

    for (const auto &v : graph[current]) {
        if (v.second % 2 == 0) {
            dfs(color, visited, v.first, c);
        } else {
            dfs(color, visited, v.first, !c);
        }
    }
}

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

    graph.resize(N);

    REP(i, N - 1) {
        int u, v, w;
        cin >> u >> v >> w;

        u--;
        v--;

        graph[u].emplace_back(v, w);
        graph[v].emplace_back(u, w);
    }

    std::vector<bool> color(N, false);
    std::vector<bool> visited(N, false);

    dfs(color, visited, 0, false);

    REP(i, N) { cout << (color[i] ? 0 : 1) << endl; }

    return 0;
}



Measured memory_bytes: 8704
def bb094():
    n,m,x = list(map(int, input().split()))
    am = list(map(int, input().split()))

    toz = 0
    for i in range(x, 0, -1):
        if am.count(i) == 1:
            toz += 1

    ton = 0
    for i in range(x, n, 1):
        if am.count(i) == 1:
            ton += 1

    print(min([toz, ton]))

bb094()


Measured memory_bytes: 3060
package main

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

var sc *bufio.Scanner

func init() {
	// 100MB
	bufsize := 100 * 1024 * 1024
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, bufio.MaxScanTokenSize), bufsize)
	sc.Split(bufio.ScanWords)
}
func readInt() int              { return readIntArray(1)[0] }
func readInt2() (int, int)      { a := readIntArray(2); return a[0], a[1] }
func readInt3() (int, int, int) { a := readIntArray(3); return a[0], a[1], a[2] }
func readIntArray(n int) []int {
	s := readStringArray(n)
	a := make([]int, n)
	for i := range a {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}
func readString() string            { return readStringArray(1)[0] }
func readString2() (string, string) { a := readStringArray(2); return a[0], a[1] }
func readStringArray(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i] = sc.Text()
	}
	return a
}
func max(ns ...int) int {
	max := ns[0]
	for _, n := range ns {
		if n > max {
			max = n
		}
	}
	return max
}
func min(ns ...int) int {
	min := ns[0]
	for _, n := range ns {
		if n < min {
			min = n
		}
	}
	return min
}
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	H, N := readInt2()
	A := readIntArray(N)
	var total int
	for _, a := range A {
		total += a
	}
	if total >= H {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 3712
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>

int main()
{
	std::string x;
	int digitsSum;
	while (1)
	{
		std::cin >> x;
		if (!strcmp(x.c_str(), "0"))
		{
			break;
		}
		digitsSum = 0;
		for (int i = 0; i < x.size(); i++)
		{
			digitsSum += x[i] - '0';
		}
		printf("%d\n", digitsSum);
	}
	return 0;
}

Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
int main(){
	int r,w,c,r1,ans;
while(1){
	cin>>r>>w>>c>>r1;
	if(r==0 && w==0 && c==0 && r1==0)break;
	if(r/w>=c)ans=0;
	else if((c*w-r)%r1==0)ans=(c*w-r)/r1;
	else if((c*w-r)%r1!=0)ans=(c*w-r)/r1+1;
cout<<ans<<endl;
}
return 0;
}


Measured memory_bytes: 3076
s = raw_input()
l = len(s)
dif = True
for i in range(l):
    for j in range(i+1,l):
        if s[i] == s[j]:
            dif = False
            break
    if not dif:
        break
if dif:
    print 'yes'
else:
    print 'no'


Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;


int main(){

int n;
cin >> n;
ll p =1;
for(int i =1 ;i <=n;i++){p=p*i;
p = p%MOD;}
cout << p<< endl;
return 0;

}


Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
dp=[0]*n
def dis(a,b):
    return abs(h[a]-h[b])
dp[1]=dis(1,0)
for i in range(2,n):
    dp[i]=min(dp[i-1]+dis(i,i-1),dp[i-2]+dis(i,i-2))
print(dp[-1])

Measured memory_bytes: 13800
#include<bits/stdc++.h>
using namespace std ;
int main() {
int a,b,c ;
cin>>a>>b>>c ;
if(a==5&&b==5&&c==7||a==7&&b==5&&c==5||b==7&&a==5&&c==5) {
    cout<<"YES" ;
}
else{
    cout<<"NO" ;
}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args ){
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int n1, n2, n3;
        if(a <= b && a <= c){
            if(b <= c)
                System.out.println(a + " " + b + " " + c);
            else
                System.out.println(a + " " + c + " " + b);
        }
        else if(b <= a && b <= c){
            if(a <= c)
                System.out.println(b + " " + a + " " + c);
            else
                System.out.println(b + " " + c + " " + a);
        }
        else{
            if(b <= a)
                System.out.println(c + " " + b + " " + a);
            else
                System.out.println(c + " " + a + " " + b);
        }
    }
}



Measured memory_bytes: 26344
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <algorithm>
#include <stack>
#include <functional>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007

using namespace std;

lli combination(lli n,lli k){
    lli a=1,b=1,i;
    rep(i,0,n){
        a*=i+1;
    }
    rep(i,0,k){
        b*=i+1;
    }
    return n/k;
}

int main(){
    lli n,ans=0;
    string s;
    vector<char> v;
    map<char,lli> map;
    lli i,j,k;
    cin>>n;
    rep(i,0,n){
        cin>>s;
        switch(s[0]){
            case 'M':map['M']++;break;
            case 'A':map['A']++;break;
            case 'R':map['R']++;break;
            case 'C':map['C']++;break;
            case 'H':map['H']++;break;
        }
    }
    for(auto itr=map.begin();itr!=map.end();itr++){
        v.push_back(itr->first);
    }
    if(map.size()>=3){
        rep(i,0,v.size()-2){
            rep(j,i+1,v.size()-1){
                rep(k,j+1,v.size()){
//                    cout<<v[i]<<"から始まる人と"<<v[j]<<"から始まる人と"<<v[k]<<"から始まる人の組み合わせは"<<endl;
//                    cout<<map[v[i]]<<"x"<<map[v[j]]<<"x"<<map[v[k]]<<"="<<map[v[i]]*map[v[j]]*map[v[k]]<<endl;
                    ans+=map[v[i]]*map[v[j]]*map[v[k]];
                }
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int n=scanner.nextInt();
		int max=-1;
		int ans=0;
		for(int i=0;i<n;i++){
			int h=scanner.nextInt();
			if(max<=h){
				ans++;
			}
			max=Math.max(max, h);
		}
		System.out.println(ans);
	}
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 23252
#include <iostream>
#include <stack>

using ll = long long;
using namespace std;

/* initialize */
int color[100], nt[100], d[100], f[100], tt;
int A[100][100];
int n;

int next(int u){
    for (int v = nt[u]; v < n; ++v) {
        nt[u] = v + 1;
        if( A[u][v]) return v;
    }
    return -1;
}

void dfs_visit(int r){
    for (int i = 0; i < n; ++i) nt[i] = 0;
    stack<int> S;
    S.push(r);
    color[r] = 1;
    d[r] += ++tt;

    while (!S.empty()){
        int u = S.top();
        int v = next(u);
        if (v != -1){
            if (color[v] == 0){
                color[v] = 1;
                d[v] = ++tt;
                S.push(v);
            }
        } else{
            S.pop();
            color[u] = 2;
            f[u] = ++tt;
        }
    }
}
void dfs(){
    for (int i = 0; i < n; ++i) {
        color[i] = 0;
    }
    tt = 0;

    for (int u = 0; u < n; ++u) {
        if (color[u] == 0) dfs_visit(u);
    }
    for (int i = 0; i < n; ++i) {
        cout << i+1 << " " << d[i] << " " << f[i] << "\n";
    }
}
/* main */
int main() {
    int u, k, v;
    cin >> n;
    for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) A[i][j] = 0;
    for (int i = 0; i < n; ++i) {
        cin >> u >> k;
        for (int j = 0; j < k; ++j) {
            cin >> v;
            A[u-1][v-1] = 1;
        }
    }

    dfs();
    return 0;
}


Measured memory_bytes: 3108
object Main extends App {
  import scala.io.StdIn._



  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val toys = Array.tabulate(n){_ ⇒ readLine.trim.toInt}.let(i ⇒ (1 to m).map(a ⇒ i.map(t ⇒ if (t == a) 1 else 0).also(ar ⇒ for (idx ← 1 until ar.length) ar(idx) += ar(idx - 1)))).toArray
  println(
    minMove(toys, (1 << m) - 1)
  )
  def minMove(toys: Array[Array[Int]], usage: Int, rest: Int = 0)(implicit memo: Array[Option[Long]] = Array.tabulate(1 << toys.length){_ ⇒ None}): Long = {
    memo(usage) match {
      case Some(r) ⇒ r
      case None if usage == 0 ⇒ 0
      case None ⇒ {
        usage.asIterable.map{t ⇒
          minMove(toys, usage ^ (1 << t), rest + toys(t).last) + toys(t).last - toys(t)(rest + toys(t).last - 1) + (if (rest != 0) toys(t)(rest - 1) else 0)
        }.min.also(r ⇒ memo(usage) = Some(r))
      }
    }
  }
  implicit class AsFlag(val value: Int){
    def asIterable: Iterable[Int] = {
      var i = 0
      var v = value
      var res = Nil: List[Int]
      while (v != 0){
        if (v % 2 == 1){
          res ::= i
        }
        i += 1
        v /= 2
      }
      res
    }
  }
  implicit class ScopeFunc[T](val value: T){
    def let[A](func: T ⇒ A): A = func(value)
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
  }
}


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

#define ll long long
#define fo(i,a,n) for(ll i=a;i<n;i++)
#define rfo(i,n,a) for(ll i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll t,n,i,j;
    ll a[6],ans;
    fo(i,1,6){
    cin>>a[i];
    if(!a[i])
        ans=i;
    }
    cout<<ans<<endl;
}


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

int main() {

  char S;

  cin >>S;
  int A;
  A=S;
  

if(A>92){
   cout << "a"<< endl;
}
  else{
    cout << "A"<< endl;
  }
 return 0;
}


Measured memory_bytes: 3560
my $n =<STDIN>;my $counter = 0;my $place;my @place=();
while($n>$counter){$place =<STDIN>;chomp $place; push(@place,$place);$counter++;}
my $a=1;my $nn=1;
while($n !=$a){$nn = $nn*($n-$a);$a++;}
my $c =0;my @x1;my @x2;my$sum=0;
while ($c <$n){@x1= split(/ /,$place[$c]);@removed = splice(@place,$c,1);foreach(@place){@x2= split(/ /,$_);$sum += sqrt(($x1[0]-$x2[0])**2+($x1[1]-$x2[1])**2)*$nn;}splice(@place,$c,0,@removed),$c++;}
print $sum/($nn*$n);

Measured memory_bytes: 512
using System;


namespace ConsoleApplication18
{
    class Program
    {
        static void Main(string[] args)
        {
            String s = Console.ReadLine();
            string[] ss = s.Split(' ');
            double r = double.Parse(ss[0]);
            double R = r * r * Math.PI;
            double A = 2 * r * Math.PI;




            Console.WriteLine("{0:f6} {1:f6}", R, A);

        }
    }
}

Measured memory_bytes: 9148
#include<iostream>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n; i++)
#define MAX 1001

void solve(int c, int a, int n){
  bool T[MAX][MAX]; // CAN, CCA

  rep(i, MAX) rep(j, MAX) {
    T[i][j] = (i+2*j <= c && i+j <= a && i <= n);
  }

  int maxp = 0;

  rep(i, MAX) rep(j, MAX) {
    if ( !T[i][j] ) continue;
    maxp = max(maxp, i+j+ (c - (i+2*j))/3);
  }

  cout << maxp << endl;

}

main(){
  int c, a, n, q;
  cin >> q;
  for ( int i = 0; i < q; i++ ){
    cin >> c >> a >> n;
    solve(c, a, n);
  }
}

Measured memory_bytes: 2140
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
const double EPS = 1e-8;
#define Scan(a) int a;scanf("%d", &a);
#define ScanS(a) char a[500];scanf("%s", a);
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
class Graph {
public:
	int vn;
	int sumcost = 0;
	vector<vector<pii>> g;

	Graph(int n) {
		vn = n;
		g.resize(n);
	}
	virtual void con(int a, int b, int w) = 0;
	int getWeight(int f, int t) {
		auto itr = lower_bound(ALL(g[f]), make_pair(t, INT_MIN));
		if (itr != g[f].end())
			return itr->second;
		return INT_MIN;
	}
	int Costsum() {
		return sumcost;
	}
	void scan(int edcount, bool oindexed, bool w) {
		REP(i, edcount) {
			int a, b, c = 1;
			scanf("%d %d", &a, &b);
			if (w)scanf("%d", &c);
			con(a - oindexed, b - oindexed, c);
		}
	}
};
class BiDGraph : public Graph {//無向
public:
	BiDGraph(int n) : Graph(n) {}

	void con(int a, int b, int w = 1) {
		g[a].push_back({ b,w });
		g[b].push_back({ a, w });
		sumcost++;
	}
};
signed main() {
	int n;
	cin >> n;
	int a,b;
	int ans = 0;
	REP(i, n) {
		cin >> a >> b;
		ans += b - a + 1;
	}
	cout << ans << endl;
	return 0;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3
#define B 1000000007

string s,t;
int n1,n2;
map<ull,bool> aru;
ull p[33];

int main(){
  cin>>s>>t;
  n1=s.size();
  n2=t.size();
  p[0]=1;
  rep(i,30)p[i+1]=p[i]*B;
  int res=0;
  repl(len,1,min(n1,n2)+1){
    aru.clear();
    ull h=0;
    for(int i=0;i<n1;i++){
      ull c=s[i]-'a';
      if(i-len>=0){
        ull prec=s[i-len]-'a';
        h-=p[prec];
      }
      h+=p[c];
      if(i>=len-1)aru[h]=true;
    }
    h=0;
    for(int i=0;i<n2;i++){
      ull c=t[i]-'a';
      if(i-len>=0){
        ull prec=t[i-len]-'a';
        h-=p[prec];
      }
      h+=p[c];
      if(i>=len-1&&aru[h])maxch(res,len);
    }
  }
  cout<<res<<endl;
  return 0;
}



Measured memory_bytes: 3672
#include <stdio.h>
void printArray(int *A, int n){
  int i;
  for(i=0; i<n; ++i){
	printf("%d", A[i]);
	if(i!=n-1)
	  printf(" ");
  }
  printf("\n");
}
void insertionSort(int *A, int N){
  int i, j;
  int tmp;
  for(i=1; i<N; ++i){
	tmp=A[i];
	j=i-1;
	while((j>=0)&&(A[j]>tmp)){
	  A[j+1]=A[j];
	  --j;
	}
	A[j+1]=tmp;
	printArray(A, N);
  }
}
int main(){
  int length;
  int A[105];
  int i;
  scanf("%d", &length);
  for(i=0; i<length; ++i){
	scanf("%d", &A[i]);
  }
  printArray(A, length);
  insertionSort(A, length); 
  
}



Measured memory_bytes: 2040
#include <iostream>
#include <limits>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

#define EPS (numeric_limits<double>::epsilon())
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point {
public:
    double x, y;

    Point(double x = 0, double y = 0) : x(x), y(y) {}

    Point operator+(const Point &p) const
    {
        return Point(x + p.x, y + p.y);
    }

    Point operator-(const Point &p) const
    {
        return Point(x - p.x, y - p.y);
    }

    Point operator*(const double &a) const
    {
        return Point(a * x, a * y);
    }

    Point operator/(const double &a) const
    {
        return Point(x / a, y / a);
    }

    double abs()
    {
        return sqrt(norm());
    }

    double norm()
    {
        return x * x + y * y;
    }

    bool operator<(const Point &p) const
    {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator==(const Point &p) const
    {
        return equals(x, p.x) && equals(y, p.y);
    }
};

typedef Point Vector;

struct Segment {
    Point p1, p2;
};
typedef Segment Line;


static const int BOTTOM = 0;
static const int LEFT = 1;
static const int RIGHT = 2;
static const int TOP = 3;

class EndPoint {
public:
    Point p;
    int seg_id;
    int type;

    EndPoint() {}

    EndPoint(Point p, int seg_id, int type) : p(p), seg_id(seg_id), type(type) {}

    bool operator<(const EndPoint &ep) const
    {
        return p.y == ep.p.y ? type < ep.type : p.y < ep.p.y;
    }
};

int manhattanIntersection(vector<Segment> S)
{
    int n = S.size();
    vector<EndPoint> EP;

    for (int i = 0; i < n; i++)
    {
        if (S[i].p1.y == S[i].p2.y)
        {
            if (S[i].p1.x > S[i].p2.x)
                swap(S[i].p1, S[i].p2);
        } else
        {
            if (S[i].p1.y > S[i].p2.y)
                swap(S[i].p1, S[i].p2);
        }

        if(S[i].p1.y == S[i].p2.y)
        {
            EP.emplace_back(S[i].p1, i, LEFT);
            EP.emplace_back(S[i].p2, i, RIGHT);
        } else
        {
            EP.emplace_back(S[i].p1, i, BOTTOM);
            EP.emplace_back(S[i].p2, i, TOP);
        }
    }

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

    set<int> BinaryTree;
    int count = 0;

    for(EndPoint endPoint : EP)
    {
        if(endPoint.type == TOP)
            BinaryTree.erase(endPoint.p.x);
        else if(endPoint.type == BOTTOM)
            BinaryTree.insert(endPoint.p.x);
        else if(endPoint.type == LEFT)
        {
            auto begin = BinaryTree.lower_bound(S[endPoint.seg_id].p1.x);
            auto end = BinaryTree.upper_bound(S[endPoint.seg_id].p2.x);
            count += distance(begin, end);
        }
    }
    return count;
}

int main()
{
    int n;
    cin >> n;
    vector<Segment> S;
    S.reserve(n);
    int x1, y1, x2, y2;
    for(int i = 0; i < n; i++)
    {
        cin >> x1 >> y1 >> x2 >> y2;
        S.push_back(Segment{Point(x1, y1), Point(x2, y2)});
    }

    cout << manhattanIntersection(S) << endl;
}


Measured memory_bytes: 16168
#include<iostream>
#include<vector>
#include<map>
#include<string>
using namespace std;
int main()
{
  string word,frequent,longest;
  map<string,int> table;
  size_t N=0;
  while(cin >> word){
    table[word] += 1;
    N =table[word] < N ? N : table[word];
    frequent = table[word] < N ? frequent : word;
    longest = word.size() < longest.size() ? longest : word;
  }
  cout << frequent << " " << longest << endl;
}

Measured memory_bytes: 1196
var
	n,a,i,s,m:Longint;
	v:array[0..100000]of Longint;
begin
	read(n);
	for i:=1 to n do begin
		read(a);
		inc(v[a]);
	end;
	for i:=1 to 99999 do begin
		m:=v[i-1]+v[i]+v[i+1];
		if s<m then s:=m;
	end;
	writeln(s);
end.


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

int main(){
  int n, z, w;
  cin >> n >> z >> w;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  int a1 = abs(a.back() - w);
  int a2 = 0;
  if(n > 1) a2 = abs(a.at(a.size()-2) - a.back());
  int ans = max(a1, a2);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3640