akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>
#include <sstream> // std::stringstream
#include <bitset>  // std::bitset<N>

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/
const ll MOD=1000000007;

ll min(ll a, ll b){
	if(a>=b){
		return b;
	}
	else{
		return a;
	}
}

void solve(){
	ll ans = 0;
	ll n, x, t;
	cin >> n >> x >> t;
	if(n%x==0){
		ans = t*(n / x);
	}
	else{
		ans = t * (1 + (n / x));
	}
	cout << ans << endl;
}

int main(){
	
	solve();
	
    return 0;
}



Measured memory_bytes: 3596
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
namespace AtCoder_Beginner_Contest_13
{
    class Program
    {
        //配列にする
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        //Listにする
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
        }
        static void Solve()
        {
            var Si = ReadLine();
            var Hi = new long[Si.Length];
            var pre = 0;
            for (var i = 0; i < Si.Length; ++i)
            {
                if (Si[i] == 'R')//連続
                { ++pre; }
                else if (Si[i - 1] == 'R' && Si[i] == 'L')
                {
                    Hi[i - 1] = (pre + 1) / 2;
                    Hi[i] = pre / 2;
                    pre = 0;
                }
            }
            pre = 0;
            for (var i = Si.Length - 1; 0 <= i; --i)
            {
                if (Si[i] == 'L')//連続
                { ++pre; }
                else if (Si[i + 1] == 'L' && Si[i] == 'R')
                {
                    Hi[i + 1] += (pre + 1) / 2;
                    Hi[i] += pre / 2;
                    pre = 0;
                }
            }
            WriteLine(string.Join(" ", Hi));
        }
    }
}


Measured memory_bytes: 13536
N = int(input())
A = [list(map(int,input().split())) for _ in range(2)]
cmax = 0
for i in range(N):
    cnt = 0
    for j in range(i+1):
        cnt += A[0][j]
    for j in range(i,N):
        cnt += A[1][j]
    cmax = max(cmax,cnt)
print(cmax)

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

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

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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

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


ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

ll sub(ll b, ll a, ll ofs=0) {
#ifdef DEBUG
    fprintf(stderr, "sub(%lld, %lld; %lld)\n", b,a,ofs);
#endif
    // b >= a
    ll q = b/a, r = b%a;
    if (r == 0) {
        ll t = q*2-1;
#ifdef DEBUG
        fprintf(stderr, " + %lldx%lld\n", t,a);
        fprintf(stderr, " = %lld\n", ofs + t*a);
#endif
        return ofs + t*a;
    } else {
        ll t = q*2;
#ifdef DEBUG
        fprintf(stderr, " + %lldx%lld\n", t,a);
#endif
        return sub(a, r, ofs + t*a);
    }
}

ll solve(ll N, ll X){
    /// X < N
    if (X == N-X) {
        return X*3;
    }
    else if (X < N-X) { // 2,3
        // X, N-X
        return sub(N-X, X, N); // 3,2,close
    }
    else { // X > N-X // 3,2
        return sub(X, N-X, N); // 3,2,open
    }
}

int main() {
    ll N, X; cin >> N >> X;
    cout << solve(N,X) << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    r, c, k = map(int, input().split())
    item = [[0]*c for _ in range(r)]
    
    for i in range(k):
        a, b, v = map(int, input().split())
        item[a-1][b-1] = v
    
    dp0 = [[0]*(c+1) for _ in range(r+1)]
    dp1 = [[0]*(c+1) for _ in range(r+1)]
    dp2 = [[0]*(c+1) for _ in range(r+1)]
    dp3 = [[0]*(c+1) for _ in range(r+1)]
    
    for i in range(r):
        for j in range(c):
            if item[i][j] == 0:
                dp0[i+1][j+1] = max([dp0[i][j+1], dp0[i+1][j], dp1[i][j+1], dp2[i][j+1], dp3[i][j+1]])
                dp1[i+1][j+1] = dp1[i+1][j]
                dp2[i+1][j+1] = dp2[i+1][j]
                dp3[i+1][j+1] = dp3[i+1][j]
                continue
            dp0[i+1][j+1] = max([dp0[i][j+1], dp0[i+1][j], dp1[i][j+1], dp2[i][j+1], dp3[i][j+1]])
            dp1[i+1][j+1] = max(dp0[i+1][j]+item[i][j], dp1[i+1][j], dp0[i][j+1]+item[i][j], dp1[i][j+1]+item[i][j], dp2[i][j+1]+item[i][j], dp3[i][j+1]+item[i][j])
            dp2[i+1][j+1] = max(dp1[i+1][j]+item[i][j], dp2[i+1][j])
            dp3[i+1][j+1] = max(dp2[i+1][j]+item[i][j], dp3[i+1][j])
    
    ans = max([dp0[r][c], dp1[r][c], dp2[r][c], dp3[r][c]])
    print(ans)
            
    
    
if __name__ == "__main__":
    main()




Measured memory_bytes: 429332
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String number = sc.next();
            if(number.equals("0")){
                break;
            }
            int sum = 0;
            for(int i = 0; i < number.length(); i++){
                sum = sum + (number.charAt(i) - '0');
            }
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 26096
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#include<limits.h>
#define MAX 7
char table[MAX][MAX];
char table_copy[MAX][MAX];
char table_ori[MAX][MAX];
int H,W,K;
int count(){
    int ret = 0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(table[i][j] == '#')
                ret++;
        }
    }
    return ret;
}
int main(){
   int ans=0;
   scanf("%d %d %d",&H,&W,&K);
   for(int i=0;i<H;i++)
       scanf("%s",table[i]);
   memcpy(table_ori,table,sizeof(table));


   for(int bit1=0;bit1<(1<<W);bit1++){
       memcpy(table,table_ori,sizeof(table));
       for(int i=0;i<W;i++){
            if(bit1 & (1<<i)){
                for(int j=0;j<H;j++)
                    table[j][i] = '*';
            }
       }

       memcpy(table_copy,table,sizeof(table));

       for(int bit2=0;bit2<(1<<H);bit2++){
            memcpy(table,table_copy,sizeof(table));
            for(int k=0;k<H;k++){
                if(bit2 & 1<<k){
                    for(int l=0;l<W;l++)
                        table[k][l] = '*';
                }
            }
            if(count() == K) ans++;
        }
    }

   printf("%d",ans);
}


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

int main(){
    int n;
    while(true){
        cin >> n;
        if(n==0)return 0;
        double s[1000];
        double ave=0;
        double h=0;
        for(int i=0;i<n;i++){
            cin >> s[i];
            ave+=s[i]/n;
        }
        for(int i=0;i<n;i++){
            h+=(s[i]-ave)*(s[i]-ave)/n;
        }
        printf("%.6f\n",sqrt(h));
    }
}


Measured memory_bytes: 3168
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>

using namespace std;

typedef long long ll;

int main() {
	int m[26] = {0};
	char c;
	while ( scanf("%c", &c) != EOF ) {
		if ('a' <= c && c <= 'z') m[c-'a']++;
		else if ('A' <= c && c <= 'Z') m[c-'A']++;
	}
	for (int i = 0; i < 26; ++i) {
		printf("%c : %d\n", (char)(i+'a'), m[i]);
	}
}

Measured memory_bytes: 1136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int w, a, b;
	cin >> w >> a >> b;
	cout << max(max(0, (a - (b + w))), max(0, b - (a + w)));
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

//LIS verified ABC038-D
#define MAX_S 100000
template<typename T> int longest_increasing_subsequence(T s){
	vector<int> dp(MAX_S,INF);
	rep(i,s.size()) *lower_bound(all(dp),s[i]) = s[i];
	
	return lower_bound(all(dp),INF)-dp.begin();
}


int main(){
	int n;
	cin>>n;
	vector<int> v(n);
	rep(i,n)cin>>v[i];
	
	int res = longest_increasing_subsequence(v);
	cout<<res<<endl;
}

Measured memory_bytes: 3936
#include<cstdio>
#include<algorithm>
#include<cmath>

using namespace std;

int main(){
        while(true){
                int pa = 0, pb = 0;      
                int a, b, n, i;
                scanf("%d", &n);
                if(!n) break;
                for(i = 0; i < n; i++){
                        scanf("%d%d", &a, &b);
                        if(a > b)
                                pa += a + b;
                        else if(b > a)
                                pb += a + b;
                        else if(a == b){
                                pa += a;
                                pb += b;
                        }
                }
                printf("%d %d\n", pa, pb);
        }
        return 0;
}

Measured memory_bytes: 1028
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
 
class Program {
    static int[] SumWest;
    static int[] SumEast;
    static void Main(string[] args) {
        var N = int.Parse(Console.ReadLine());
        var S = Console.ReadLine();
        SumWest = new int[N];
        SumEast = new int[N]; 
        
        //東と西の累積和を取る
        SumOfWest(S);
        SumOfEast(S);
        
        var min = N;
        for(int i = 0;i < N;i++){
            //変えなくてはいけない人の人数
            var comp = SumWest[i]+SumEast[i];
            //Console.WriteLine(SumWest[i]+" "+SumEast[i]);
            if(min > comp){
                //Console.WriteLine(i+" "+comp);
                
                min = comp;
            }
        }
        Console.WriteLine(min);
    }
    
    static void SumOfWest(string S){
        for(int i = 0;i < S.Length-1; i++){
            if(S[i] == 'W'){
                SumWest[i+1] = SumWest[i]+1;
            }else{
                SumWest[i+1] = SumWest[i];
            }
        }
    }
    
    static void SumOfEast(string S){
        for(int i = S.Length-1;i > 0; i--){
            if(S[i] == 'E'){
                SumEast[i-1] = SumEast[i]+1;
            }else{
                SumEast[i-1] = SumEast[i];
            }
        }
    }    
}


Measured memory_bytes: 15516
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let input = stdin();
    let input = input.lock();
    let token: String = input
            .bytes()
            .map(|c| c.expect("failure") as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
    token.parse().ok().expect("error")
}

// 桁和関数の実装
fn digit_sum(n: i64, b: i64) -> i64 {
    if n < b {
        n
    } else {
        digit_sum((n as f64/b as f64).floor() as i64, b) + (n % b)
    }
}

fn main() {
    let n: i64 = read();
    let s: i64 = read();
    let mut ans: i64 = -1;

    if n == 1 {
        if s == 1 {
            ans = 2;
        }
    } else {

        let sqrtn = (n as f64).sqrt().ceil() as i64;

        // sqrt(n)+1から1までを先頭桁として全探索
        for p in (1..sqrtn+1).rev() {
            if (n-s+p) % p == 0 {
                let b: i64 = (n-s+p) / p;
                if b > 1 {
                    if digit_sum(n,b) == s {
                        ans = b;
                        break;
                    }
                }
            }
        }

        // 2からsqrt(n)まで全探索
        for b in 2..(sqrtn + 1) {
            if digit_sum(n, b) == s {
                ans = b;
                break;
            }
        }

        // n == s なら自分自身+1の時が常に最小
        if n == s {
            ans = n + 1;
        }
    }

    println!("{}",ans);
}


Measured memory_bytes: 4476
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 1e5 + 5;

int main() {
    abdelrahman010
    ll n , k;
    cin >> n >> k;
    cout << min(n % k , abs(n % k - k));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>



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

using namespace std;
int a;

int main(){
  cin >> a;
  if(a>=1000) cout << "ABD" << endl;

  else cout << "ABC" << endl;

  
  return 0;
}



Measured memory_bytes: 256
MD = [int(i) for i in input().split()]

c = 0
for m in range(1, MD[0] + 1):
    for d in range(1, MD[1] + 1):
        
        d1  = d % 10
        d10 = (d - d1) /10
        if d1 < 2 or d10 <2:
            continue

        if m == d1 * d10:
            #print("d-> %d,m -> %d, d1 - > %d, d10 -> %d"%(d, m,d1,d10))
            c+=1

print(c  )

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<set>
#include<random>
#include<stdio.h>
#include<map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 11451419198109311;
const long double pi = 3.1415926535897932384626433;
typedef pair<int, int> P;
struct edge { int to, cost; };
vector<edge>G[114514];

int a[114514], b[114514];
int d[114514];
vector<P>V;
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n)cin >> b[i];
	rep(i, n) {
		V.push_back(P(a[i], i));
	}
	sort(V.begin(), V.end());
	rep(i, V.size()-1) {
		if (V[i].second != V[i + 1].second) {
			G[V[i].second].push_back({ V[i + 1].second,V[i+1].first-V[i].first });
			G[V[i + 1].second].push_back({ V[i].second,V[i + 1].first - V[i].first });
		}
	}
	V.clear();
	rep(i, n)V.push_back(P(b[i], i));
	sort(V.begin(), V.end());
	rep(i, V.size() - 1) {
		if (V[i].second != V[i + 1].second) {
			G[V[i].second].push_back({ V[i + 1].second,V[i + 1].first - V[i].first });
			G[V[i + 1].second].push_back({ V[i].second,V[i + 1].first - V[i].first });
		}
	}
	priority_queue<P, vector<P>, greater<P>>Q;
	fill(d, d + 114000, inf);
	d[0] = 0;
	Q.push(P(0, 0));

	while (Q.size()) {
		P p = Q.top();
		Q.pop();
		int v = p.second;
		if (d[v] < p.first)continue;
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				Q.push(P(d[e.to], e.to));
			}
		}
	}
	rep(i, n)cout << d[i] << endl;
}


Measured memory_bytes: 20556
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n,x,m;cin >> n >> x >> m;
    vector<int> a = {x};
    vector<int> vis(m+1);
    int val = 0;
    while(1){
        int tmp = (a.back()*a.back())%m;
        // trace(tmp);
        if(vis[tmp]){
            val = tmp;
            break;
        }
        a.push_back(tmp);
        vis[tmp] = 1;
    }
    int T= 0;
    for(;a[T] != val;T++);
    // trace(T,(int)a.size()-T);    
    T = (int)a.size() -T;
    // trace(a);
    int ret = 0;
    int i;
    for(i = 0;i < (int)a.size();i++){
        int x = a[i];
        if(x == val)break;
        // trace(x);
        int tmp = x;
        ret += tmp;
    }
    n-= i;
    // trace(n);
    int cnt = 0;
    for(;i < (int)a.size();i++){
        int x = a[i];
        // trace(x);
        int tmp = (n/T)*x;
        ret += tmp;
        cnt+= n/T;
    }
    n -= cnt;
    // trace(n);
    // trace(a);
    // trace(a.size());
    for(i = 0;i < a.size() && a[i] != val;i++);
    for(int j = i;j < min(i+n,(int)a.size());j++){
        ret += a[j];
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 4644
# include <bits/stdc++.h>
/// my holy template
# define F first    
# define S second
# define mp make_pair
# define pii pair<int,int>         
/// eveything goes according to plan
# define long long long  
# define pb push_back
# define sz(a) (int)(a.size())
/// countdown BEGAN. 10 , 9 , 8 ...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right     

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const long MXLL = 9223372036854775807;
const int Sz = 1110111;

using namespace std;

inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm("rdtsc" : "=A"(seed));
  srand(seed);
}
int sum;     
                              
int main() 
{
  Read_rap ();    
  int n;
  cin >> n;

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

  return 0;
} 










// Coded by Z...

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define pb push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/
 
int N,A,B;
vector<ll> v;
 
class C{
    public:
#define MAX_N 64
#define MAX_M 64
        long long comb[64][64];
        C(){
            for(int i=0;i<MAX_N;i++) for(int j=0;j<MAX_N;j++) comb[i][j] = 0;
 
            for(int i=0;i<MAX_N;i++){
                comb[i][0]=1;
                for(int j=1;j<=i;j++){
                    comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
                }
            }
 
        }
 
        long long get(int i,int j){return comb[i][j];}
};
 
int main(){
    cin >> N >> A >> B;
    v.resize(N);
    rep(i,N) cin>>v[i];
    sort(all(v));
    reverse(all(v));
 
    C cmb;
 
    map<ll,ll> tbl;
    for(int i=0;i<N;i++) tbl[v[i]]++;
 
    long double ans1=0;
    for(int cnt=A;cnt<=B;++cnt){
        ll sum=0;
        //for(int i=N-cnt;i<N;i++) sum+=v[i];
        for(int i=0;i<cnt;i++) sum+=v[i];
        ans1 = max(ans1,(long double)sum/(long double)cnt);
    }
 
    ll ans2=0;
    for(int cnt=A;cnt<=B;++cnt){
        ll sum=0;
        ll po=1;
        map<ll,ll> mp;
        for(int i=0;i<cnt;i++){
            sum+=v[i];
            mp[v[i]]++;
        }
        bool f=false;
        for(auto m : mp){
            ll vv = m.first;
            ll cn = m.second;
            po *= cmb.get(tbl[vv],cn);
            f=true;
        }
        long double t = (long double)sum/(long double)cnt;
        if(fabs(ans1-t)<(1e-18)){
            ans2+=po;
            assert(po>0);
        }
    }
    cout << Double(ans1) << endl;
    cout << ans2 << endl;
}


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

#define pb push_back
#define mp make_pair

#define fi first
#define se second

typedef long long ll;

using namespace std;

const int MAXN = 1e5+5;
const int INF = 1e7;

vector <int> adj[MAXN];

int L[MAXN], R[MAXN];

int ans[MAXN];

int n, k;

void bye() {
    printf("No\n");
    exit(0);
}

void dfs(int v, int pr) {
    for (int to : adj[v]) {
        if (to == pr) {
            continue;
        }

        dfs(to, v);

        L[v] = max(L[v], L[to] - 1);
        R[v] = min(R[v], R[to] + 1);
    }
}

void dfs2(int v, int pr) {
    for (int to : adj[v]) {
        if (to == pr) {
            continue;
        }

        L[to] = max(L[to], L[v] - 1);
        R[to] = min(R[to], R[v] + 1);

        dfs2(to, v);
    }
}

void rec(int v, int pr) {
    if (L[v] > R[v]) {
        bye();
    }

    for (int to : adj[v]) {
        if (to == pr) {
            continue;
        }

        if (ans[to] == -INF) {
            if (L[to] <= ans[v] - 1 && ans[v] - 1 <= R[to]) {
                ans[to] = ans[v] - 1;
            }
            else {
                ans[to] = ans[v] + 1;
            }
        }

        if (abs(ans[v] - ans[to]) != 1) {
            bye();
        }

        rec(to, v);
    }
}

void solve() {
    scanf("%d", &n);

    for (int i = 1, l, r; i < n; ++i) {
        scanf("%d %d", &l, &r);

        adj[l].pb(r);
        adj[r].pb(l);
    }

    for (int i = 1; i <= n; ++i) {
        ans[i] = -INF;
        L[i] = -INF;
        R[i] = INF;
    }

    int root = 1;

    scanf("%d", &k);

    for (int i = 1, ps, x; i <= k; ++i) {
        scanf("%d %d", &ps, &x);
        L[ps] = R[ps] = ans[ps] = x;
        root = ps;
    }

    dfs(root, -1);
    dfs2(root, -1);
    rec(root, -1);

    printf("Yes\n");

    for (int i = 1; i <= n; ++i) {
        printf("%d\n", ans[i]);
    }
}

int main() {
    #ifdef BThero
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // BThero

    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 13824
#include <iostream>

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

  int color_arr[3][30] = {};
  int d_arr[30][30] = {};

  for(int i = 0; i < C; i++){
    for(int j = 0; j < C; j++){
      std::cin >> d_arr[i][j];
    }
  }
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      int tmp;
      std::cin >> tmp;
      color_arr[(i+j)%3][tmp-1] += 1;
    }
  }

  long long diff_min = 999999999999;
  for(int c1 = 0; c1 < C; c1++){
    for(int c2 = 0; c2 < C; c2++){
      if(c2 == c1) continue;
      for(int c3 = 0; c3 < C; c3++){
        if(c3 == c2 || c3 == c1) continue;
        long long diff = 0;
        for(int c = 0; c < C; c++){
          diff += color_arr[0][c]*d_arr[c][c1];
          diff += color_arr[1][c]*d_arr[c][c2];
          diff += color_arr[2][c]*d_arr[c][c3];
        }
        diff_min = (diff_min<diff)?diff_min:diff;
      }
    }
  }

  std::cout << diff_min << std::endl;

  return 0;
}



Measured memory_bytes: 256
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

from itertools import combinations

N,M,Q = LI()
a,b,c,d = LIR(Q,4)

X = list(combinations(range(N+M-1),M-1))

ans = 0
for x in X:
    s = 0
    L = []
    for x0 in x:
        L.append(x0-s)
        s = x0+1
    L.append(N+M-1-s)
    now = []
    for i in range(len(L)):
        now.extend([i+1]*L[i])
    val = 0
    for i in range(Q):
        if now[b[i]-1]-now[a[i]-1] == c[i]:
            val += d[i]
    if val > ans:
        ans = val

print(ans)

Measured memory_bytes: 85148
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
typedef long long ll;
#define INF 1e9


int main(){
    
    string s; cin >> s;
    
    string console;
    
    for(auto i : s){
        if(i == '0') console += "0";
        if(i == '1') console += "1";
        if(i == 'B') {
            if(console.empty()) continue;
            console.erase(console.end()-1);
        }
    }
    cout << console << endl;
    
    
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int n,Mod;
int a[55];
int cnt1,cnt2;
long long ans;
long long C(int x,int y){
	if (x==y){
		return 1;
	}
	if (y==0){
		return 1;
	}
	return C(x-1,y-1)+C(x-1,y);
}
int main(){
	cin>>n>>Mod;
	for (int i=1;i<=n;i++){
		cin>>a[i];
		if (a[i]%2==0){
			cnt1++;
		}
		else{
			cnt2++;
		}
	}
	if (Mod==0){
	    //ans+=2^cnt1;
	    long long t1=1;
	    for (int i=1;i<=cnt1;i++){
	    	t1*=2;
	    }
	    long long t2=0;
	    for (int i=0;i<=cnt2;i+=2){
	    	t2+=C(cnt2,i);
	    }
	    cout<<t1*t2<<endl;
	}
	else{
		long long t1=1;
		for (int i=1;i<=cnt1;i++){
			t1*=2;	
		}
	//	cout<<t1<<endl;
		long long t2=0;
		for (int i=1;i<=cnt2;i+=2){
			t2+=C(cnt2,i);
		}
	//	cout<<t2<<endl;
		cout<<t1*t2<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
namespace IO
{
    const int __S=(1<<20)+5;char __buf[__S],*__H,*__T;
    inline char getc()
    {
        if(__H==__T) __T=(__H=__buf)+fread(__buf,1,__S,stdin);
        if(__H==__T) return -1;return *__H++;
    }
    template <class __I>inline void read(__I &__x)
    {
        __x=0;int __fg=1;char __c=getc();
        while(!isdigit(__c)&&__c!='-') __c=getc();
        if(__c=='-') __fg=-1,__c=getc();
        while(isdigit(__c)) __x=__x*10+__c-'0',__c=getc();
        __x*=__fg;
    }
    inline void readd(double &__x)
    {
        __x=0;double __fg=1.0;char __c=getc();
        while(!isdigit(__c)&&__c!='-') __c=getc();
        if(__c=='-') __fg=-1.0,__c=getc();
        while(isdigit(__c)) __x=__x*10.0+__c-'0',__c=getc();
        if(__c!='.'){__x=__x*__fg;return;}else while(!isdigit(__c)) __c=getc();
        double __t=1e-1;while(isdigit(__c)) __x=__x+1.0*(__c-'0')*__t,__t=__t*0.1,__c=getc();
        __x=__x*__fg;
    }
    inline void reads(char *__s,int __x)
    {
        char __c=getc();int __tot=__x-1;
        while(__c<'!'||__c>'~') __c=getc();
        while(__c>='!'&&__c<='~') __s[++__tot]=__c,__c=getc();
        __s[++__tot]='\0';
    }
    char __obuf[__S],*__oS=__obuf,*__oT=__oS+__S-1,__c,__qu[55];int __qr;
    inline void flush(){fwrite(__obuf,1,__oS-__obuf,stdout);__oS=__obuf;}
    inline void putc(char __x){*__oS++ =__x;if(__oS==__oT) flush();}
    template <class __I>inline void print(__I __x)
    {
        if(!__x) putc('0');
        if(__x<0) putc('-'),__x=-__x;
        while(__x) __qu[++__qr]=__x%10+'0',__x/=10;
        while(__qr) putc(__qu[__qr--]);
    }
    inline void prints(const char *__s,const int __x)
    {
        int __len=strlen(__s+__x);
        for(int __i=__x;__i<__len+__x;__i++) putc(__s[__i]);
    }
    inline void printd(double __x,int __d)
    {
        long long __t=(long long)floor(__x);print(__t);putc('.');__x-=(double)__t;
        while(__d--)
        {
            double __y=__x*10.0;__x*=10.0;
            int __c=(int)floor(__y);
            putc(__c+'0');__x-=floor(__y);
        }
    }
    inline void el(){putc('\n');}inline void sp(){putc(' ');}
}using namespace IO;
#define ld long double
const ld pi=acos(-1);ld ans;int a1,a2,b1,b2,f1,f2,n,m,s[200005];
struct P{int x,y;friend bool operator<(P a,P b){return a.x<b.x;}}a[200005];
int main()
{
	read(a1);read(b1);read(a2);read(b2);if(a1>a2) f1=-1;else f1=1;if(b1>b2) f2=-1;else f2=1;
	a1*=f1;a2*=f1;b1*=f2;b2*=f2;read(n);
	for(int i=1;i<=n;i++)
	{
		read(a[i].x);read(a[i].y);a[i].x*=f1;a[i].y*=f2;
		if(a[i].x<a1||a[i].x>a2||a[i].y<b1||a[i].y>b2) i--,n--;
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	{
		if(!m||s[m]<a[i].y) s[++m]=a[i].y;
		else s[lower_bound(s+1,s+m+1,a[i].y)-s]=a[i].y;
	}
	ans=100.0*(a2-a1+b2-b1);ans-=(20.0-5.0*pi)*m;ans+=5.0*pi*(m==min(a2-a1+1,b2-b1+1));
	printf("%.15lf\n",(double)ans);
}

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

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

int main(){
  int n,k;
  cin >> n >> k;
  int i = 0;
  while (pow(k,i) <= n) {
    i++;
  }
  cout << i << endl;
}


Measured memory_bytes: 4064
#include <bits/stdc++.h>
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
using namespace std;

int main()
{
    int n,sum=0;
    cin>>n;
    vector<int>s(n);
    REP(i,n){cin>>s[i];sum+=s[i];}
    sort(s.begin(),s.end());
    int j=0;
    while(sum%10==0)
    {
        if(j==n&&sum%10==0){sum=0;break;}
        if(s.at(j)%10==0){j++;continue;}
        
        sum-=s.at(j);
        j++;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
from Queue import Queue

while True:
    q = Queue()
    w, h = map(int, raw_input().split())
    tile = [[0 for i in range(w)] for j in range(h)]
    if w == 0: break
    for i in range(h):
        tile[i] = raw_input()
        for j in range(w):
            if tile[i][j] == '@':
                q.put([i,j])
    #searching
    count = 0
    while q.empty() == False:
        node = q.get()
        y = node[0]
        x = node[1]
        count += 1
        for i,j in zip([1,-1,0,0],[0,0,1,-1]):
            if (0 <= y+i < h and 0 <= x+j < w) == False: continue
            if tile[y+i][x+j] == '.':
                tilist = list(tile[y+i])
                tilist[x+j] = '@'
                tile[y+i] = "".join(tilist)
                q.put([y+i,x+j])
    print count

Measured memory_bytes: 6832
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args)throws Exception {
        BufferedReader inut = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(inut.readLine());

        for (int i = 0; i <= 25; i++) {
            for (int j = 0; j <= 25; j++) {
                if ((i*4) + (j*7) == n) {
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 22996
# coding: utf-8
# Your code here!

N, K = map(int, input().rstrip().split(' '))
S = input()

x = [[0, 0]]
current_s = S[0]
count_zero = 0
count_one = 0
for i, s in enumerate(S):
    if s == current_s:
        if s == '0':
            count_zero += 1
        else:
            count_one += 1
    else:
        if current_s == '0':
            x.append([count_one, count_zero])
            count_one = 1
            count_zero = 0
        else:
            count_zero = 1
        current_s = s
x.append([count_one, count_zero])    

if x[-1][-1] != 0:
    x.append([0,0])
num_white = len(x)
        
cum_x = []
current_sum = 0
for i in range(len(x)):
    current_sum += sum(x[i])
    cum_x.append(current_sum)

if num_white <= (K + 1):
    print(N)
else:
    max_value = 0
    for i in range(K, num_white-1):
        max_value = max(max_value, cum_x[i] - cum_x[i - K] + x[i + 1][0])
    print(max_value)

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

int main(int argc, char *argv[])
{
  int N, M;

  while (cin >> N >> M, N) {
    int d, v;
    vector<int> Dv, Vv;
    for (int i = 0; i < N; i++) {
      cin >> d >> v;
      Dv.push_back(d);
      Vv.push_back(v);
    }
    int sum = 0;
    
    for (int i = 1; i < M+1; i++) {
      int best = 0;
      for (int j = 0; j < N; j++) {
	if (Dv[j]==i) {
	  if (best < Vv[j]) {
	    best = Vv[j];
	  }
	}
      }
      sum += best;
      //cout << sum << endl;
    }
    cout << sum << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3156
#include<stdio.h>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

int main(){
	int n,i,j;
	char s[10000][11];
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%s",s[i]);
	int ans=0,ge[10000],ha=0,ow=0,hajio=0;
	for(i=0;i<n;i++){
		for(j=0;s[i][j+1]!=0;j++){
			if(s[i][j]=='A'&&s[i][j+1]=='B')ans++;
		}
		ge[i]=j;
	}
	for(i=0;i<n;i++){
		if(s[i][0]=='B'&&s[i][ge[i]]=='A')hajio++;
		else if(s[i][0]=='B')ha++;
		else if(s[i][ge[i]]=='A')ow++;
	}
	if(hajio>0){
	if(ha>0&&ow>0){
		ans+=hajio+1;
		ha--;
		ow--;
		ans+=min(ha,ow);
	}
	else if(ha>0){
		ans+=hajio;
		ha--;
	}
	else if(ow>0){
		ans+=hajio;
		ow--;
	}
	else ans+=hajio-1;
	}
	else ans+=min(ha,ow);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
/**
 *    author:  math2do
 *    created: 12.04.2020 22:47:18
**/

#include <bits/stdc++.h>

using namespace std;

template <typename T>
class graph {
 public:
  struct edge {
    int from;
    int to;
    T cost;
  };
 
  vector<edge> edges;
  vector<vector<int>> g;
  int n;
 
  graph(int _n) : n(_n) {
    g.resize(n);
  }
 
  virtual int add(int from, int to, T cost) = 0;
};

template <typename T>
class undigraph : public graph<T> {
 public:
  using graph<T>::edges;
  using graph<T>::g;
  using graph<T>::n;
 
  undigraph(int _n) : graph<T>(_n) {
  }
 
  int add(int from, int to, T cost = 1) {
    assert(0 <= from && from < n && 0 <= to && to < n);
    int id = (int) edges.size();
    g[from].push_back(id);
    g[to].push_back(id);
    edges.push_back({from, to, cost});
    return id;
  }
};

template <typename T>
vector <int> bridge(const undigraph <T> &g) {
  vector <bool> seen(g.n, false);
  vector <int> low(g.n, 0);
  vector <int> dis(g.n, 0);
  vector <int> pv(g.n, -1);
  int timer = 0;
  vector <int> ans;
  function <void(int)> dfs = [&](int u) {
    seen[u] = true;
    dis[u] = low[u] = ++timer;
    for (int id : g.g[u]) {
      int v = g.edges[id].from ^ g.edges[id].to ^ u;
      if (!seen[v]) {
        pv[v] = u;
        dfs(v);
        low[u] = min(low[u], low[v]);
        if (low[v] > dis[u]) {
          ans.push_back(id);
        }
      } else if (v != pv[u]) {
        low[u] = min(low[u], dis[v]);
      }
    }
  };
  dfs(0);
  return ans;
  // return edge id's of bridges
} 

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  undigraph <int> g(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    g.add(x, y);
  }

  vector <int> bri = bridge(g);
  vector <pair <int, int> > ans;
  for (int id : bri) {
    auto &e = g.edges[id];
    int x = min(e.from, e.to);
    int y = max(e.from, e.to);
    ans.emplace_back(x, y);
  }
  sort(ans.begin(), ans.end());
  for (auto &P : ans) {
    cout << P.first << " " << P.second << '\n';
  } 
  return 0;
}



Measured memory_bytes: 5108
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define nl cout<<endl

#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()

#define pb push_back
#define ff first
#define ss second
#define hell 1000000007

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;
#define N 300009

ll power(ll a,ll b,ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}
int main()
{	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
        
	rep(i,1,6)
	{
		ll x;cin>>x;
		if(x==0)
		{
			cout<<i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
int main(){
  ll n,a[100000],s=0;
  cin>>n;
  for(ll i=0;i<n;i++)cin>>a[i],s+=a[i];
  if(s%(n*(n+1)/2))cout<<"NO"<<endl;
  else{
    s/=n*(n+1)/2;
    ll ans=1,ss=0;
    for(ll i=0;i<n;i++){
      ss+=(-a[(i+1)%n]+a[i]+s)/n;
    }
    if(ss==s)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    if (a!=b&&b!=c&&a!=c) {
        cout<<3<<endl;
    } else if ( (a==b&&a!=c)||(b==c&&a!=b)||(a==c&&a!=b) ) {
        cout<<2<<endl;
    } else {
        cout<<1<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits.h>

using namespace std;

int main(){
  int n, max=0, min=INT_MAX;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<a.size();i++){
    cin >> a[i];
    if(max<a[i]){max=a[i];}
    if(min>a[i]){min=a[i];}
  }
  cout << max - min << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ffast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define filoop(n) for(ll i=0;i<(n);i++)
#define fjloop(n) for(ll j=0;j<(n);j++)

int main()
{
    ffast;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);


//    int t;
//    cin>>t;
//    while(t--)
//    {
        int n,a[101];
        cin>>n;

        filoop(n) cin>>a[i];
        bool possible = true;
        filoop(n)
        {
            if(a[i]%2==0)
            {
                if(a[i]%3!=0 && a[i]%5!=0)
                {//cout<<a[i]<<endl;
                possible = false;
                break;
                }
            }

        }
        if(possible)
                cout<<"APPROVED\n";
            else cout<<"DENIED\n";

//    }

    return 0;
}





Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
q = input()
m = list(map(int, input().split()))

def com(i, b):
    if b == 0:
        return True
    if i == n or b < 0:
        return False
    if b - sum(a[i:]) > 0:
        return False
    ans = com(i+1, b) or com(i+1, b-a[i])
    return ans

for j in m:
    if com(0, j):
        print('yes')
    else:
        print('no')


Measured memory_bytes: 5628
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const int N = 200005;

LL a[N], b[N];
int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        b[a[i]]++;
    }
    LL sum = 0;
    for (int i = 1; i <= n; i++) {
        sum += b[i] * (b[i] - 1) / 2;
    }
    for (int i = 0; i < n; i++) {
        LL ans = sum - b[a[i]] * (b[a[i]] - 1) / 2 + (b[a[i]] - 1) * (b[a[i]] - 2) / 2;
        cout << ans << endl;
    }
    return 0;
}


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

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

	for (int i = 1; i <= 1000; i++) {
		int aa = (double)i * 0.08;
		int bb = (double)i * 0.10;
		if (aa==a && bb==b) {
			cout << i << endl;
			return 0;
		}
	}

	cout << -1 << endl;
}

Measured memory_bytes: 3636
#define  _CRT_SECURE_NO_WARNINGS

#include <set>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <fstream>
#include <deque>
#include <climits>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

#define mp make_pair
#define FOR(i, k, n) for (int i = (k); i < (n); i++)
#define pb push_back
#define fi(n) for(ll i = 0; i < n; i++)
#define fr(n) for(ll i = n; i >= 0; i--)
#define fj(n) for(int j = 0; j < n; j++)
#define fk(n) for(int k = 0; k < n; k++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ifstream in;
ofstream out;

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

const ll lINF = LLONG_MAX;
const int INF = INT_MAX;

int main()
{
	int n;
	cin >> n;
	vector<int> v(n);
	fi(n)
		scanf("%d", &v[i]);
	sort(rall(v));
	ll f = -1, s = 0;
	fi(n - 1)
	{
		if (f == -1)
		{
			if (v[i] == v[i + 1])
			{
				f = v[i];
				i++;
			}
		}
		else
		{
			if (v[i] == v[i + 1])
			{
				s = v[i];
				break;
			}
		}
	}
	cout << s * f << endl;
	return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

ll gcd(ll a,ll b){
	if(a<b){
		swap(a,b);
	}

	while(ll r=(a%b)){
		a = b;
		b = r;
	}
	return b;
}

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

	int N=in();
	vector<int> X(N);
	REP(i,N){
		X[i]=in();
	}
	int v = gcd(X[0],X[1]);
	for(int i=2;i<N;i++){
		v = gcd(v,X[i]);
	}
	
	cout << v << endl;
	return 0;
}


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

class Main{
    final static long MOD = 1000000007;
    FastScanner sc = new FastScanner();

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

    void solve(){

        int n = sc.nextInt();
        String s = sc.next();
        String t = sc.next();

        for(int i = 0; i < n; i++){
            System.out.print(s.charAt(i));
            System.out.print(t.charAt(i));
        }

        System.out.println();

    }

    long gcd(long a, long b){ // return aとbの最大公約数
        if(b == 0){
          return a;
        }
        return gcd(b, a % b);
    }

    long pow_mod(long a, long r){ // return a^r (mod MOD)
        long sum = 1;
        while(r > 0){
            if((r & 1) == 1){
                sum *= a;
                sum %= MOD;
            }
            a *= a;
            a %= MOD;
            r >>= 1;
        }
        return sum;
    }

}



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: 21204
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, T;
    cin >> N >> T;
    ll ans = INT_MAX;
    for (ll i = 0; i < N; i++) {
        ll c, t;
        cin >> c >> t;
        if (t <= T) {
            ans = min(ans, c);
        }
    }

    if (ans == INT_MAX) {
        cout << "TLE" << endl;
    } else {
        cout << ans << endl;
    }
}

Measured memory_bytes: 256