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

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

#define endl '\n'
#define ff first
#define ss second
#define int long long
#define pb push_back
#define f(i,l,r) for(ll i=l;i<=r;i++)
#define rf(i,r,l) for(ll i=r;i>=l;i--)
#define Max 5000001
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define d0(a) cout<<a<<' ';
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<' '<<b<<endl;
#define d3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define d4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
#define d5(a,b,c,d,e) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl;
#define d6(a,b,c,d,e,f) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<' '<<f<<endl;

const ll N=2e5+5,mod=1e9+7,bit=61;

ll get(char x)
{
    if(x=='R')
    {
        return 0;
    }
    if(x=='G')
    {
        return 1;
    }
    return 2;
}

signed main()
{
    fast;

    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        string s;
        cin>>s;
        s='#'+s;
        ll suff[n+2][3];
        suff[n+1][0]=suff[n+1][1]=suff[n+1][2]=0;
        rf(i,n,1)
        {
            f(j,0,2)
            {
                suff[i][j]=suff[i+1][j];
            }
            ll id=get(s[i]);
            suff[i][id]++;
        }
        ll ans=0;
        f(i,1,n)
        {
            f(j,i+1,n)
            {
                if(s[i]==s[j])
                {
                    continue;
                }
                ll id1=get(s[i]);
                ll id2=get(s[j]);
                ll id3=3-(id1+id2);
                ll sum=suff[j+1][id3];
                ll diff=j-i;
                if(j+diff<=n and get(s[j+diff])==id3)
                {
                    sum--;
                }
                ans+=sum;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}
















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

int main() {
  int N;cin >> N;
  vector<long long> v(N);
  long long sum = 0;
  for (int i = 0; i < N; ++i) cin >> v[i], sum += v[i];
  
  long long res = 1LL<<60;
  long long cur = 0;
  for (int i = 0; i < N; ++i) {
    res = min(res, abs(cur - (sum-cur)));
    cur += v[i];
  }
  cout << res << endl;
}

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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N;
map< pair<int,int>,double > memo;
int vis [150001];
double node [150001];
vector<int> edge [150001];

double rec(int prev,int curr)
{
	if(memo.count(make_pair(prev,curr))) return memo [make_pair(prev,curr)];
	double res = 0.0;
	if(vis [curr] == 0){
		for(const auto& it : edge [curr]) if(it != prev){
			res += rec(curr,it) + 1.0;
		}
		if(edge [curr].size() > 1){
			res /= edge [curr].size() - 1;
		}
	}
	else{
		if(vis [curr] == 1){
			for(const auto& it : edge [curr]){
				node [curr] += rec(curr,it) + 1.0;
			}
		}
		res = node [curr] - (rec(curr,prev) + 1.0);
		if(edge [curr].size() > 1){
			res /= edge [curr].size() - 1;
		}
	}
	vis [curr]++;
	return memo [make_pair(prev,curr)] = res;
}

int main()
{
	scanf("%d",&N);
	FOR(i,0,N - 1){
		int u,v;
		scanf("%d%d",&u,&v);
		edge [u].push_back(v);
		edge [v].push_back(u);
	}

	FOR(i,1,N + 1){
		double ans = 0.0;
		for(const auto& it : edge [i]){
			ans += rec(i,it) + 1.0;
		}
		ans /= edge [i].size();
		printf("%.10f\n",ans);
	}

	return 0;
}


Measured memory_bytes: 39040
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);


int main() {
  string s;
  cin >> s;
  
  bool ans=true;
  
  int a=s.size();
  
  rep(i,a-a/2) {
    if(s[2*i]=='L') ans = false;
  }
  
  rep(i,a/2) {
    if(s[2*i+1]=='R') ans = false;
  }
  
  
  cout << (ans==true?"Yes":"No") << endl;       
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		for(int t=0;t<T;t++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			int w = sc.nextInt();
			int h = sc.nextInt();
			int n = sc.nextInt();
			int ans = 0;
			for(int i=0;i<n;i++) {
				int xi = sc.nextInt();
				int yi = sc.nextInt();
				if (x <= xi && xi <= x + w) {
					if (y <= yi && yi <= y + h) {
						ans++;
					}
				}
			}
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 24912
#include <iostream>
using namespace std;
int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(a>0)
    {
        c-=b;
        if(c<=0)
        {
            cout << "Yes" << endl;
            return 0;
        }
        a-=d;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  int f = 0;
  int t = 0;
  for(int i = 0;i < n;i++){
    int a = sc.nextInt();
    if(a%4 == 0){
      f++;
    }
    else if(a%2 == 0){
      t++;
    }
  }
  System.out.println(t/2 + f >= n/2 ? "Yes":"No");
}}

Measured memory_bytes: 48748
import heapq
a,b = map(int,input().split())
L = []
for _ in range(a):
    L.append( tuple(map(int,input().split())) )
L = sorted(L)
h = []
c = 0
ans = 0
for i in range(1,b+1):
    while True:
        if c >= len(L): break
        if L[c][0] <= i:
            heapq.heappush(h,-L[c][1])
            c += 1
        else:
            break
    try :
        ans += -heapq.heappop(h)
    except:
        pass
print(ans)


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

int main() {
  int a,b,c,sum;
  cin >> a;
  c = a;
  b = 0;
  sum = 0;

  for (int i = 0 ; i < 10 ; i++ ){
    b = a % 10;
    sum += b;
    if(a > 9) {
      a /= 10;
    } else {
      break;
    }
   }
    if(c % sum == 0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;  
  }    
}



Measured memory_bytes: 3600
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        x: usize, p: [usize],
    }
    let mut app = vec![false; 102];
    for p in p {
        app[p] = true;
    }
    let mut mi = (10000, 0);
    for i in 0..102 {
        let d = (x as i32 - i as i32).abs();
        if !app[i] {
            mi = min(mi, (d, i));
        }
    }
    puts!("{}\n", mi.1);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2220
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define pb push_back
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
ll inf=1e18;
ll p= 1e9+7;
ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if(n > 1)
        result -= result / n;
    return result;
}
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
   while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}
typedef pair<ll, ll> pi;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll i,j,x,y,k,t,m,z,a,b,c,d,r;
     
           ll n;
           cin>>n;
           ll temp=n%10;
           if(temp==3)
           cout<<"bon";
           else if(temp==0||temp==1||temp==6||temp==8)
           cout<<"pon";
           else
           cout<<"hon";
   
    return 0;
 
    
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int n;
int S[20000];
int s()
{


    sort(S,S+n);

    int result = 0;

    for (int i = n - 1; i >= 2; --i) {
        int l = 0, r = i - 1;
        while (l < r) {
            if (S[i] < S[l] + S[r]) {  // S[i] < S[l] + S[r] && S[i] > S[r] > S[l]
                result += r - l;  //  直接加上可能的个数
                r--;
            } else {
                l++;
            }
        }
    }

    return result;

}
int main()
{
cin>>n;
for(int i=0;i<n;i++)
    cin>>S[i];
cout<<s();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
typedef long long ll;
using namespace std;

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 long long INF = 1LL << 60;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
ll ma = 1000000000 + 7;


int main() {
	int n;
	cin >> n;
	int r = 0;int b = 0;
	vector<char> s(n);
	string res = "No";
	for (int i = 0;i < n;i++) {
		cin >> s[i];
		if (s[i] == 'R') {
			r++;
		}
		else {
			b++;
		}
	}
	if (r > b) {
		res = "Yes";
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>

using namespace std;

int main(){

    int x, y;
    cin >> x >> y;

    cout << x*y << " " << 2*x+2*y << endl;


    return 0;
}



Measured memory_bytes: 3092
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define endl "\n"
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }

typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    cini(n);
    cinai(a, n);
    cinai(b, n);
    cinai(c, n-1);

    ll ans=0;
    for(int i=0; i<n; i++) {
        ans+=b[a[i]-1];
        if(i>0 && a[i-1]+1==a[i]) {
            ans+=c[a[i-1]-1];
        }
    }

    cout<<ans<<endl;

}



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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int n;
    cin >> n;
    int sum = 0;
    int maxi = 0;
    for(int i = 1; i <= n; i++) {
        int l;
        cin >> l;
        sum += l;
        maxi = max(maxi, l);
    }
    if(sum <= 2 * maxi) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
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 (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll ans=0;
	ans=max(a*c,a*d);
	ans=max(ans,b*c);
	ans=max(ans,b*d);
	cout<<ans<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


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

struct ope {
	int B;
	long long C;
};

bool opesort(const ope& a, const ope& b) {
	return a.C > b.C;
}

bool change_sort(const long long& a, const long long& b) {
	return a > b;
}

int main(void) {
	int N, M;
	cin >> N >> M;
	vector <long long> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];

	vector <ope> O(M);
	for (int i = 0; i < M; i++) {
		cin >> O[i].B >> O[i].C;
	}

	vector <long long> change;
	int csize = 0;

	sort(O.begin(), O.end(), opesort);
	for (int i = 0; (i < M) && (csize < N); i++) {
		for (int j = 0; (j < O[i].B) && (csize < N); j++) {
			change.push_back(O[i].C);
			csize++;
		}
	}

	sort(A.begin(), A.end());
	sort(change.begin(), change.end(), change_sort);

	vector <long long> sum(N);
	sum[0] = A[0];
	for (int i = 1; i < N; i++) {
		sum[i] = sum[i-1]+A[i];
	}


	if (A[0] >= change[0]) {
		cout << sum[N-1] << endl;
		return 0;
	}

	int l = 0;
	int r = csize-1;
	int m = (l+r+1) / 2;

	while (l < r) {
		if (A[m] < change[m]) {
			l = m;
			m = (l+r+1) / 2;
		} else {
			r = m-1;
			m = (l+r+1) / 2;
		}
	}

	long long ans = sum[N-1] - sum[l];
	for (int i = 0; i <= l; i++) {
		ans += change[i];
	}
	cout << ans << endl;
  return 0;
}


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

a = list(map(int, input().split()))
s = [0]*n
for i in range(n):
    s[a[i]-1] += 1
k = 0
for i in range(n):
    if s[i] >= 2:
        k += ((s[i]*(s[i]-1))//2)
for i in range(n):
    if s[a[i]-1] >= 2:
        print(k-(s[a[i]-1]-1))
    else:
        print(k)

Measured memory_bytes: 25716
#include<bits/stdc++.h>
using namespace std;
//#define int long long
typedef long long ll;
#define sqr(x) ((x)*(x))
#define pb push_back
const int N=1000002,M=998244353;
int pw(int x,int y){int z=1;for(;y;y>>=1,x=1ll*x*x%M)if(y&1)z=1ll*z*x%M;return z;}
void inc(int &x,int y){x+=y;if(x>=M)x-=M;}void dec(int &x,int y){x-=y;if(x<0)x+=M;}
void Max(int &x,int y){if(y>x)x=y;}void Min(int &x,int y){if(y<x)x=y;}
//struct node{int to,ne;}e[];
//void add(int x,int y){e[++tot]=(node){y,h[x]},h[x]=tot;}
int n;
char s[N];
signed main(){
	scanf("%d%s",&n,s);
	n=unique(s,s+n)-s;
	printf("%d",n);
}

Measured memory_bytes: 384
n = int(input())
x,y,h = [],[],[]
idx = 0
for i in range(n):
    a,b,c = map(int,input().split())
    x.append(a)
    y.append(b)
    h.append(c)
    if c != 0:
        idx = i

for cx in range(101):
    for cy in range(101):
        # h[idx] = H - abs(x[idx]-cx) - abs(y[idx]-cy)
        H = h[idx] + abs(x[idx]-cx) + abs(y[idx]-cy)

        ok = True
        for i in range(n):
            if h[i] != max(H - abs(x[i]-cx) - abs(y[i]-cy), 0):
                ok = False
        if ok:
            print(cx,cy,H)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long
#define INF INT_MAX
#define mod 1000000007
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll pw(ll a, ll b) {
    if (b == 0) return 1;
    ll t = pw(a, b / 2);
    if (b % 2 == 0) return (t * t)%mod;
    else return ((t * t)%mod * a)%mod;
}
int main()
{
	string s,t;cin>>s>>t;
	int res=0;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]!=t[i])res++;
	}
	cout<<res;
}


Measured memory_bytes: 3856
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <map>
#include <vector>
//#include <unordered_map>
//#include <unordered_set>
#include <stack>
#include <set>
#include <queue>
#include <list>

using namespace std;
//bool ju[100005];
/*struct node
{
    int x,i;
    friend bool operator <(node a,node b)
    {
        return a.x<b.x;
    }
};*/
int ha[100005];
int main()
{
    int n,f=0;
    long long su=0;
    scanf("%d",&n);
    for(int i=0;i<n;++i)
    {
        scanf("%d",&ha[i]);
        //ha[i].i=i;
    }
    sort(ha,ha+n);
    for(int i=0;i<n;++i)
    {
        if(su*2<ha[i])
            f=i;
        su+=ha[i];
    }
    printf("%d\n",n-f);
    return 0;
}


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

int main() {
  int N,A,B;
  cin>>N>>A>>B;
  int p1=A*N,p2=B;
  if(p1>=p2){
  cout<<p2<<endl;
  }
  else {
  cout<<p1<<endl;
  }
}

Measured memory_bytes: 256
#coding: utf-8

while True:
    m, f, r = map(int, input().split())
    s = m + f
    if s + r == -3:
        break
    elif m == -1 or f == -1:
        print('F')
    elif s >= 80:
        print('A')
    elif s >= 65:
        print('B')
    elif s >= 50:
        print('C')
    elif s >= 30 and r >= 50:
        print('C')
    elif s >= 30:
        print('D')
    else:
        print('F')


Measured memory_bytes: 5596
using System;
using System.Collections.Generic;


class Program
{
    static void Main(string[] args)
    {
        string ABC = Console.ReadLine();
        string[] split = ABC.Split();

        int A = int.Parse(split[0]);
        int B = int.Parse(split[1]);
        int C = int.Parse(split[2]);

        if (A == B || A == C || B == C)
        {
            if (A == B && B == C)
            {
                Console.WriteLine("No");
                return;
            }
            Console.WriteLine("Yes");
            return;
        }
        Console.WriteLine("No");
    }

}



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

using namespace std;

typedef long long ll;

int digsum(int x){
	int ret = 0;
	while(x > 0){
		ret += x % 10;
		x /= 10;
	}

	return ret;
}

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

	int n;
	cin >> n;

	int dsum = digsum(n);
	if(n % dsum == 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

}


Measured memory_bytes: 256
import itertools

N, M, Q = map(int, input().split())
qs = [list(map(int, input().split())) for _ in range(Q)]

ans = 0
for A in itertools.combinations_with_replacement(range(1, M + 1), N):
    ans = max(sum([d for (a, b, c, d) in qs if A[b - 1] - A[a - 1] == c]), ans)

print(ans)


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N), L(N), R(N);
  for (int i = 0, a; cin >> a; i++) A.at(i) = a, L.at(i) = (!i) ? a : __gcd(L.at(i - 1), A.at(i));
  for (int i = N - 1; i >= 0; i--) R.at(i) = (i == N - 1) ? A.at(N - 1) : __gcd(R.at(i + 1), A.at(i));
  int ans = max(R.at(1), L.at(N - 2));
  for (int i = 1; i < N - 1; i++) ans = max(ans, __gcd(L.at(i - 1), R.at(i + 1)));
  cout << ans << "\n";
}

Measured memory_bytes: 1408
class Main{

	public static void main (String[] args) {

		Main main = new Main();

		java.util.Scanner sc = new java.util.Scanner(System.in);

		int K = sc.nextInt();
		int now = 0;
		boolean flag = true;
		for (int index=0; index<K; index++) {
			now=(10*now+7);
			now%=K;
			if(now==0) {
				System.out.println(index+1);
				flag = false;
				break;
			}
		}
		if (flag) {
			System.out.println("-1");
		}
		sc.close();
	}
}

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

int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a >> b >> c;
    cout << (c%gcd(a,b)==0?"YES":"NO") << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
import math

ans = [0]*N

def g(x,y,z):
    return x**2+y**2+z**2+x*y+y*z+z*x


for x in range(1,int(math.sqrt(N))+10):
    for y in range(1,int(math.sqrt(N))+10):
        for z in range(1,int(math.sqrt(N))+10):
            if g(x,y,z) <= N:
                ans[g(x,y,z)-1] += 1

for p in range(N):
    print(ans[p])



Measured memory_bytes: 9400
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
using namespace std;

int main(void)
{
	string tmp; cin >> tmp;
	vector<int> A(4); 
	rep(i, 0, 4)A[i] = tmp[i] - '0';
	//rep(i, 0, 4)cout << A[i] << endl;

	for (int bit = 0; bit < (1 << 3); bit++) {//1:+, 0:-
		int sum = A[0];
		rep(i, 1, 4) {
			if (bit&(1 << (3-i)))sum += A[i];
			else sum -= A[i];
			//cout << sum << endl;
		}
		if (sum == 7) {
			cout << A[0];
			rep(i, 1, 4) {
				if (bit&(1 << (3 - i)))cout << "+" << A[i];
				else cout << "-" << A[i];
			}
			cout << "=7" << endl;
			break;
		}
	}

	return 0;
}


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

using ll = long long;
const int mod = 1e9 + 7;

ll cnt[200001];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        cnt[A[i]]++;
    }
    ll sum = 0;
    for (int i = 1; i <= N; i++) {
        sum += cnt[i] * (cnt[i] - 1) / 2;
    }
    for (int i = 0; i < N; i++) {
        ll ans = sum;
        ans -= cnt[A[i]] * (cnt[A[i]] - 1) / 2;
        ans += (cnt[A[i]] - 1) * (cnt[A[i]] - 2) / 2;
        cout << ans << endl;
    }
}

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

template<long long mod>
class modint{
private:
  long long a;
public:
  constexpr modint(const long long x = 0) noexcept : a(x%mod) {}
  constexpr long long& value() noexcept { return a; }
  constexpr const long long& value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint& operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if(a >= mod) a -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if(a < rhs.a) a += mod;
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint rhs) noexcept {
    a = a*rhs.a%mod;
    return *this;
  }
  constexpr modint& operator/=(modint rhs) noexcept {
    long long k = mod-2;
    while(k > 0){
      if(k&1){
        *this *= rhs;
      }
      rhs *= rhs;
      k /= 2;
    }
    return *this;
  }
  friend ostream& operator<<(ostream &os, const modint &X){
    return os << X.a;
  }
  friend istream& operator>>(istream &is, modint &X){
    is >> X.a;
    X.a %= mod;
    if(X.a < 0) X.a += mod;
    return is;
  }
};

using mint = modint<(int)1e9+7>;

int main(){
  int N;
  cin >> N;
  vector<int> X(N);
  for(int i = 0; i < N; ++i) cin >> X[i];
  mint ans = 0;
  vector<mint> F(N+1);
  F[0] = 1;
  for(int i = 1; i <= N; ++i) F[i] = F[i-1]*i;
  vector<mint> C(N);
  C[0] = F[N-1];
  for(int i = 1; i < N; ++i){
    int d = X[i] - X[i-1];
    C[i] = C[i-1] + F[N-1]/(i+1);
    ans += C[i-1]*d;
    // cerr << i << " " << C[i-1]*F[N-i] << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 2176
N = int(input())
A = list(map(int, input().split()))

cntA, sumA = 0, 0
for i in range(N):
    sumA += A[i]
    if i % 2 == 0:
        if sumA <= 0:
            cntA += abs(sumA) + 1
            sumA += abs(sumA) + 1
    else:
        if sumA >= 0:
            cntA += abs(sumA) + 1
            sumA -= abs(sumA) + 1
    
cntB, sumB = 0, 0
for i in range(N):
    sumB += A[i]
    if i % 2 != 0:
        if sumB <= 0:
            cntB += abs(sumB) + 1
            sumB += abs(sumB) + 1
    else:
        if sumB >= 0:
            cntB += abs(sumB) + 1
            sumB -= abs(sumB) + 1

print(min(cntA, cntB))

Measured memory_bytes: 20004
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int R;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.R = sc.nextInt();
    }
    
    //解答処理
    private String solve() {
        String answer = "ABC";
        
        if (1200 <= R && R < 2800) {
        	answer = "ARC";
        } else if (2800 <= R) {
        	answer = "AGC";
        }
        
        return answer;
    }
    
    //出力
    public void show(String answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 35640
#include <iostream>
#include <algorithm>

using namespace std;

int n, a[100];

int main() {
	int sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	int av1 = sum / n, av2 = sum/n+1;
	int ans = 0, ans2 = 0;
	for (int i = 0; i < n; i++) {
		ans += (int)pow(a[i] - av1, 2);
		ans2 += (int)pow(a[i] - av2, 2);
	}

	cout << min(ans, ans2) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int Search(int key, int S[], int n){
  int i;
  for(i = 0; i < n; i++){
    if(S[i] == key) return 1;
  }
  return 0;
}
 
int main(){
  int n, S[10000], q, key, count = 0;
  int i;
 
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &S[i]);
  }

  scanf("%d", &q);
  for(i = 0; i < q; i++){
    scanf("%d", &key);
    if(Search(key, S, n)) count++;
  }

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

  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int N;cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    vector<LL> AB(N);
    rep(i,N)cin >> A[i] >> B[i];
    rep(i,N)AB[i] = A[i] + B[i];
    LL ans = 0;
    rep(i,N)ans -= B[i];
    sort(rall(AB));

    rep(i,N){
        if(i % 2 == 0)ans += AB[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main(){
   int k;
   cin>>k;
   long long mod=7%k;
   long long cou=0;
   bool ans=true;
   for(long long i=0;i<k;i++){
       cou++;
       if(mod==0){
           cout<<cou;
           ans=false;
           break;
       }
       mod*=10;
       mod+=7;
       mod=mod%k;
   }
   if(ans) cout<<"-1";
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define FOR(i, s, g) for(int i = s; i < g; i++)
#define FORR(i, s, g) for(int i = s - 1; i >= g; i--)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define DMP(a) std::cerr << "[Debug] : " << #a << " = " << a << "\n"
using namespace std;
typedef long long ll;
struct aaa{
    aaa(){
        std::cin.tie(0); std::ios::sync_with_stdio(0); std::cout<<std::fixed<<std::setprecision(20);
    };
}aaaaaaa;

int main() {
    int a, p;
    cin >> a >> p;
    cout << ((a * 3 + p) / 2) << "\n";

    return 0;
}


Measured memory_bytes: 256
N, A, B, C, D = map(int, open(0).read().split())
m = B-A
M = B-A
j = N-1
for i in range(N-1):
  if m<=C*j<=M or m<=D*j<=M:
    print('YES')
    break
  m += C
  M += D
  j -= 1
else:
  print('NO')

Measured memory_bytes: 3060
/*
 *    author:  Gary Shih
 *    created: 2020-05-04 16:23:39
 */
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.setf(ios::fixed), cout.precision(9);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];

  vector<bool> dp(k + 1);
  for (int i = *min_element(a.begin(), a.end()); i <= k; ++i) {
    bool win = false;
    for (int j = 0; j < n; ++j) {
      if (i - a[j] < 0) continue;
      if (dp[i - a[j]] == false) {
        win = true;
        break;
      }
    }
    dp[i] = win;
  }
  cout << (dp[k] ? "First" : "Second") << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
const int N = 505050;
ll fac[N];
ll finv[N];
ll inv[N];
void modinv(int max) {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < max; 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 r) {
	if (n < r) return 0;
	if (n < 0 || r < 0) return 0;
	return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}
ll perm(int n, int r) {
	return fac[n] * finv[n - r] % MOD;
}
int main() { // フレンズさんの図を見て理解できた,集合の重なっている個数を数えるというテクニックを知った
	modinv(N);
	int n, m;
	cin >> n >> m;

	// 包除原理を使う,具体的にはまずai=biを無視する
	// なぜこれを無視するかと思ったら二番目の条件は数え上げが楽だから
	// 数字の選び方は(mCn*n!)^2なのでmPn^2
	// 選び方のうち、ai=biの個数が奇数ならば-,偶数ならば+される(包除原理の図を描いてみる)
	// これの個数はO(1)で求まる

	ll ans = perm(m, n) * perm(m, n) % MOD; // 考えられる全ての集合
	rep1(i, n) { // 重なる領域の数をそれぞれ調べ上げる

		ll select = comb(n, i); // ai=biとなるi⊂（1～n）な集合の選び方の個数、nCi通り
		ll same = perm(m, i); // ai=biをどの数字にするか、順番も考慮するのでmPi通り
		ll other = perm(m - i, n - i) * perm(m - i, n - i); // ai!=biをどんな数字にするか、aiとbiは異なるのでm-iPn-iの2乗

		ll tmp = select * same % MOD; // modintつかったほうがいいのかも？
		other %= MOD; tmp *= other; tmp %= MOD;

		if (i % 2 != 0) tmp *= -1; // 重なる領域の数が奇数ならば-1倍する
		ans += tmp;
		if (ans < 0) ans += MOD;
		if (ans >= MOD) ans -= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 15448
import scala.io.StdIn.readLine

object Main extends App {
  var l = readLine.split(",").map(_.toDouble);
  var e = 0D;var n = 0D;var angle = 90D

  while(l(0)!=0 || l(0)!=0) {
    e += l(0)*Math.cos(Math.toRadians(angle))
    n += l(0)*Math.sin(Math.toRadians(angle))
    angle = angle - l(1)
    l = readLine.split(",").map(_.toDouble);
  }

  println(e.toInt)
  println(n.toInt)
}

Measured memory_bytes: 43656
#include<bits/stdc++.h>
using namespace std;
char s[1009];

int main()
{
	char c;
	int l=0;
	while(cin>>c)
	{
		if(c=='B')
		{
			if(l>0) l--;
		} 
		else s[++l]=c;
	}
	for(int i=1;i<=l;i++) printf("%c",s[i]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e7 + 10;
long long n,ans;
map<long long ,long long> a;
int main() {
	scanf("%lld",&n);
	for (int i = 1,x;i <= n;i++) {
		scanf("%lld",&x);
		a[i+x]++;
		ans += a[i-x];
	}
	printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 26476
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main()
{
   
    int h, n;
    cin >> h >> n;
    vector<int>p(n);
    for (int i = 0; i < n; i++)cin >> p[i];
    long long int d = 0;
    d = p[0];
    for (int i = 1; i < n; i++) {
       // if (p[i] == p[i - 1])continue;
        d += p[i];
    }
    if (d >= h)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;

}


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

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

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const int int_inf = 100000000;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n, m, x;
    cin >> n >> m >> x;

    vector<ll> c(n);
    vector<vector<ll>> a(n, vector<ll>(m, 0));
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    ll ans = inf;

    for (int bit = 0; bit < (1<<n); bit++) {
        vector<ll> tmp(m, 0);
        ll sum = 0;
        for (int i = 0; i < n; i++) {
            if (bit & (1<<i)) {
                for (int j = 0; j < m; j++) {
                    tmp[j] += a[i][j];
                }
                sum += c[i];
            }
        }
        // cout << sum << endl;
        bool ok = true;
        for (int i = 0; i < m; i++) {
            if (tmp[i] < x) ok = false;
        }
        if (ok) chmin(ans, sum);
    }

    if (ans == inf) cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3660
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    N = int(input())
    A = [int(i) for i in input().split()]

    num_ev = 0
    num_od = 0

    for a in A:
        if a % 2 == 0:
            num_ev += 1
        else:
            num_od += 1

    if num_od % 2 == 1:
        print('NO')
        return None
    else:
        num_ev += num_od // 2

        if num_ev >= 1:
            print('YES')
        else:
            print('NO')

if __name__ == '__main__':
    solve()

Measured memory_bytes: 14108
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    
    vector<int> vec(N);
    
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }

    int max = *std::max_element(vec.begin(), vec.end());
    int sum = std::accumulate(vec.begin(), vec.end(), 0);
    if (max < sum - max) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

N = int(input())
X = list(map(int, input().split()))
Y = sorted(X)

for x in X:
    if x <= Y[N//2-1]:
        print(Y[N//2])
    else:
        print(Y[N//2-1])

Measured memory_bytes: 34132
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.TreeMap;
import java.util.*;

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());
    }
}

public class Main {
    static int[] w = new int[100010];
    static int[] v = new int[100010];
    static int[][] dp = new int[110][100010];
    static int k;

    static int chmin(int a, int b) {
        if (a > b) {
            a = b;
            return a;
        }
        return a;
    }

    static int chmax(int a, int b) {
        if (a < b) {
            a = b;
            return a;
        }
        return a;
    }

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        int count = 0;
        for (int i = 0; i < n; i++) {
            count += Math.abs(fs.nextInt() - fs.nextInt()) + 1;
        }

        System.out.println(count);
    }

}


Measured memory_bytes: 80468
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

N, X = map(int, input().split())
V = list(map(int, input().split()))
V.append(X)
V.sort()
vD = {V[i+1]-V[i] for i in range(len(V)-1)}

res = min(vD)
for d in vD:
    res = gcd(res, d)
    if res <= 1:
        break
print(res)

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

int main() {
  int h,w;
  cin>>h>>w;
  vector<string> s(h);
  for(int i=0;i<h;i++){
    cin>>s.at(i);
    cout<<s.at(i)<<endl<<s.at(i)<<endl;
  }
  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.println((a * b) % 2 == 0 ? "Even" : "Odd");

    }
}


Measured memory_bytes: 22996
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)
bool a[500][500] = {};
char c[500][500];
bool search(int x,int w,int h,int y) {
	if (x < 0 || x >= w || y < 0 || y >= h) {
		return false;

	}
	else if (c[y][x] == '#') {
		return false;
	}
	if (a[y][x] == true) {
		return false;
	}
	if (c[y][x] == 'g') {
		return true;
	}
	a[y][x] = true;
	if (search(x + 1, w, h, y) || search(x - 1, w, h, y) || search(x, w, h, y + 1) || search(x, w, h, y - 1)) {
		return true;
	}
	else {
		return false;
	}

}

//小文字=大文字+32
int main() {
	ll N;
	cin >> N;
	vector<ll>L(N);
	rep(i, N) {
		cin >> L[i];
	}
	ll m;
	ll sum;
	ll ans = 0;
	sort(L.begin(), L.end());
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			for (int k = j + 1; k < N; k++) {
				if (L[i] != L[j] && L[j] != L[k]) {
					if (L[k] < L[i] + L[j] && L[j] < L[i] + L[k] && L[i] < L[j] + L[k]) {


						ans++;
					}


				}
				
			}
		}
	}
	cout << ans;

}
	



Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
    private static Long[][][] dp;
    private static long calculate(int player, int left, int right, int[] arr){
        if(left > right) return 0;
        if(dp[player][left][right] != null) return dp[player][left][right];
        if(player == 0){
            long x = arr[left] + calculate(1, left + 1, right, arr);
            long y = arr[right] + calculate(1, left, right - 1, arr);
            dp[player][left][right] = Math.max(x, y);
            return Math.max(x, y);
        }else {
            long x = -arr[left] + calculate(0, left + 1, right, arr);
            long y = -arr[right] + calculate(0, left, right - 1, arr);
            dp[player][left][right] = Math.min(x, y);
            return Math.min(x, y);
        }
    }
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        // code goes here
        int n = nextInt(br);
        int[] arr = nextIntArray(br, n);
        dp = new Long[2][n][n];
        sb.append(calculate(0, 0, n - 1, arr));
        System.out.print(sb.toString());
    }

    private static int nextInt(BufferedReader br) throws IOException{
        return Integer.parseInt(br.readLine());
    }

    private static int[] nextIntArray(BufferedReader br, int n) throws IOException{
        StringTokenizer st = new StringTokenizer(br.readLine());
        int[] arr = new int[n];
        for(int i = 0; i < n; i++){
            arr[i] = Integer.parseInt(st.nextToken());
        }
        return arr;
    }

    static class Pair<A, B>{
        A first;
        B second;
        public Pair(A first, B second){
            this.first = first;
            this.second = second;
        }
    }
}


Measured memory_bytes: 287888
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define re(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int
struct Union{
  vector<int> par;
  Union(int a){
  par=vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(int a,int b){
    return (find(a)==find(b));
  }
  int size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    int c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
int main(void){
    string s;
    cin >> s;
    if(s=="AAA"||s=="BBB")cout << "No";
    else cout << "Yes";
}


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

namespace arc080_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int nottwo = 0; int two = 0; int four = 0;
            for (int i = 0; i < n; i++)
            {
                if (x[i] % 2 != 0) nottwo++;
                else if (x[i] % 4 != 0) two++;
                else four++;
            }
            two %= 2;
            Console.WriteLine(four - two >= nottwo - 1 ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 19680
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int a,b,c,d;

int main()
{
    cin >> a >> b >> c >> d;
    cout << max(a * b, c * d) << endl;
}

Measured memory_bytes: 256