akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <queue>
#include <stack>
#include <set>

using namespace std;

#define ALL(co) co.begin(), co.end()
#define tpl(...) make_tuple(__VA_ARGS__)

typedef long long LL;
typedef pair<int, int> P; typedef pair<int, P> IP; typedef pair<P, P> PP;
typedef vector<int> Array; typedef vector<vector<int> > Array2;
typedef vector<LL> LArray; typedef vector<P> PArray; typedef vector<string> SArray;

const int INF = 1 << 29;
const LL LINF = 1LL << 60;

inline int getInt() { int itiv; return (cin >> itiv, itiv); }
template <typename T> void readAll(vector<T>& vec) { for (int i = 0, size = vec.size(); i < size; i++) cin >> vec[i]; }
template <typename T, typename U> void readAll(vector<pair<T, U> >& vec) { char c;for (int i = 0, size = vec.size(); i < size; i++) cin >> vec[i].first >> c >> vec[i].second; }
template < typename T > inline string toString( const T &a ){ ostringstream oss; oss << a; return oss.str(); };
inline bool between(int min, int max, int n) { return min <= n && n <= max; }
inline bool inRange(int begin, int end, int n) { return begin <= n && n < end; }
inline bool inRange(int size, int n) { return 0 <= n && n < size; }

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

int w, n;

// index, weight
int dp[1010][1010];
PArray treasure;

int main(void)
{
	ios::sync_with_stdio(false);
	int count = 1;
	while(cin >> w && w)
	{
		n = getInt();
		for (int i = 0; i <= n; i++)
		{
			memset(dp[i], 0, sizeof(dp[i]));
		}
		treasure.resize(n);
		readAll(treasure);
		P ans = P(-1, INF);
		for (int i = 0; i < n; i++)
		{
			int price = treasure[i].first, weight = treasure[i].second;
			for (int j = 0; j <= w; j++)
			{
				int nw = j + weight;
				if(nw <= w)
					dp[i + 1][nw] = max(dp[i][nw], max(dp[i + 1][nw - 1], max(dp[i + 1][nw], dp[i][j] + price)));
				if(j != 0) dp[i + 1][j] = max(dp[i + 1][j], max(dp[i + 1][j - 1], dp[i][j]));
				if(ans.first == dp[i + 1][j] && ans.second > j)
					ans = P(dp[i + 1][j], j);
				else if(ans.first < dp[i + 1][j]) ans = P(dp[i + 1][j], j);
			}
		}

		cout << "Case " << count << ':' << endl;
		cout << ans.first << endl << ans.second << endl;
		count++;
	}
	return 0;
}

Measured memory_bytes: 5168
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define F first
#define S second
#define def(x) cerr << #x << " is " << x << endl;
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(ll i=a;i<n;i++)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(a) a.begin(),a.end()
const int NUM = 2e5 + 5;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
int main(){
    ios
    int num_tests=1; 
    //cin>>num_tests;
    while(num_tests-->0){
        ll ang; cin>>ang;
        ll ans=1;
        while(ang%360!=0){
            ans++;
            ang = (ang/(ans-1))*ans;
        }
        cout<<ans;
    }   
}


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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  static const double pi = 3.141592653589793;
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double hh = 2 * pi * (60 * h + m) / (60 * 12);
  double mm = 2 * pi * m / 60;
  double diff = max(hh, mm) - min(hh, mm);
  double rad = min(diff, 2 * pi - diff);
  cout << fixed << setprecision(10);
  cout << sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(rad)) << endl;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


VV G;
V color;

bool dfs(int u, int x=0) {
  if (color[u] == x) return true;
  if (color[u] == (x^1)) return false;
  color[u] = x;
  for (auto v : G[u]) {
    if (!dfs(v, x^1)) return false;
  }
  return true;
}

int main() {
  ll n, m; cin >> n >> m;
  
  G.assign(n, V());
  color.assign(n, -1);

  rep(i, m) {
    int a, b; cin >> a >> b;
    --a; --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  bool bi = true;
  if (!dfs(0)) bi = false;

  if (bi) {
    Vll cnt(2);
    rep(i, n) ++cnt[color[i]];
    cout << (cnt[0]*cnt[1]-m) << endl;
  }
  else cout << (n*(n-1)/2 - m) << endl;
  return 0;
}


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

#define int long long

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

int N;

signed main() {
    cin >> N;
    int T_abs = 1, A_abs = 1;
    for (int i = 0; i < N; i++) {
        int T, A;
        cin >> T >> A;
        int bi = max(T_abs / T + (T_abs % T == 0 ? 0 : 1), A_abs / A + (A_abs % A == 0 ? 0 : 1));
        T_abs = T * bi, A_abs = A * bi;
    }
    cout << T_abs + A_abs << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1000000000100000000;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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(){
	vector<int> v(3); rep(i, 3) cin >> v[i];
  	sort(all(v));
    cout << v[0] + v[1] << ln;
}

Measured memory_bytes: 3496
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 998244353, MAX = 1e18, larg = 1e5, INF = -1e18;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;

ll arr[3];
int main() {
	cin >> arr[0] >> arr[1] >> arr[2];
	ll maxv = max(arr[0], max(arr[1], arr[2]));
	ll sum = arr[0] + arr[1] + arr[2];
	if ((maxv * 3 - sum) % 2 == 0) {
		cout << (maxv * 3 - sum) / 2;
	}else{
		cout << ((maxv + 1) * 3 - sum) / 2;
	}
}


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

using namespace std;

#define deb(x) cout << #x << " " << x << endl;

template <typename... T>
void read(T &... args)
{
    ((cin >> args), ...);
}

template <typename... T>
void write(T &&... args)
{
    ((cout << args << " "), ...);
    cout << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);

    char alpha;
    cin >> alpha;

    if (alpha >= 'A' && alpha <= 'Z')
        cout << 'A' << endl;

    if (alpha >= 'a' && alpha <= 'z')
        cout << 'a' << endl;

    return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>

int main(){
  char number[1001];

  while(1){
	scanf("%s", number);
	if(number[0] == '0'){break;}

	int i = 0;
	int sum = 0;

	while(number[i]){
	  sum += number[i] - '0';
	  i ++ ;
	}

	printf("%d\n", sum);
  }

  return 0;
}



Measured memory_bytes: 1980
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long LL;

const int maxn=2e5+5;

int n,a,b,N,er[30],c[maxn];

int lowbit(int x) {return x&(-x);}

bool bz[30];
void dfs(int k,int a,int b)
{
	if (k==1)
	{
		printf("%d %d ",a,b);
		return;
	}
	fo(i,0,n-1) if (((a>>i)&1)^((b>>i)&1))
	{
		bz[i]=1;
		int mid=a;
		fo(j,0,n-1) if (!bz[j])
		{
			mid^=er[j];
			break;
		}
		dfs(k-1,a,mid);
		dfs(k-1,mid^er[i],b);
		bz[i]=0;
		break;
	}
}

int main()
{
	scanf("%d %d %d",&n,&a,&b);
	N=(1<<n)-1;
	
	fo(i,0,N)
		for(int x=i; x; x-=lowbit(x)) c[i]++;
	fo(i,0,n-1) er[i]=1<<i;
	
	if ((c[a]&1)==(c[b]&1)) puts("NO"); else
	{
		puts("YES");
		dfs(n,a,b);
	}
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
using namespace std;

int main(void)
{
	string s, t;
	cin >> s >> t;

	char *sc = new char[s.length() + 1];
	char *tc = new char[t.length() + 1];

	for (int i = 0; i < s.length(); ++i) {
		sc[i] = s[i];
	}
	sc[s.length()] = '\0';
	for (int i = 0; i < t.length(); ++i) {
		tc[i] = t[i];
	}
	tc[t.length()] = '\0';

	sort(sc, sc + s.length());
	sort(tc, tc + t.length(), greater<char>());

	if (strcmp(sc, tc) < 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}

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

int main() {
    int a, b, c; cin >> a >> b >> c;
    int ans = 0;
    for (int divisor = a; divisor <= b; ++divisor) {
        if (c % divisor == 0) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int mod = 1000000007;
//const int mod = 998244353;
const int INF = 1001001001;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

struct mint {
  ll x;
  mint(ll 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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main()
{
    string s, t;
    cin >> s >> t;
    int size = s.size();
    s += s;
    rep(i, 0, size){
        bool flag = true;
        rep(j, 0, t.size()){
            if(s[i+j] != t[j]) flag = false;
        }
        if(flag){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void){
	int way[32];
	int n;
	way[1] = 1;
	way[2] = 2;
	way[3] = 4;
	for(int i=4;i<=30;i++){
		way[i] = way[i-1]+way[i-2]+way[i-3];
	}

	while(cin>>n&&n){
		cout << ceil((double)way[n]/3650) << endl;
	}
}

Measured memory_bytes: 0
import numpy as np
k, n = map(int, input().split())
a = np.array(list(map(int, input().strip().split())))
d = np.zeros(n,dtype=np.int64)
d[1:] = a[1:] - a[:-1]
d[0] = a[0] + (k-a[-1])

#print(d)
m = 10**9
q = d[0:-1].sum()
for i in range(n):
    if i == 0:
        q = d[1:].sum()
    else:
        q = q + d[i-1] - d[i]

    if q < m:
        m = q

print(m)

Measured memory_bytes: 43180
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
//#define fastio; ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vi;

int main()
{
    int h1,s1,h2,s2;
    cin>>h1>>s1>>h2>>s2;

    int str1,str2;
    if(h1%s2==0) str1=h1/s2;
    else str1=h1/s2+1;

    if(h2%s1==0) str2=h2/s1;
    else str2=h2/s1+1;

    if(str1>=str2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3636
//
//  main.cpp
//  upgranet
//
//  Created by Dong Truong on 7/5/19.
//  Copyright Â© 2019 Dong Truong. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <fstream>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;
#define maxn 1000005
#define gh 1005
#define long long long

const long cm=1e9+7;
long n,k,a[maxn];
void nhap()
{
    cin>>n>>k;
    long sl=0,kq=0;
    for (int i=1;i<=n;++i)
    {
        cin>>a[i];
        for (int j=1;j<i;++j)
            if (a[i]<a[j]) sl=(sl+1)%cm;
    }
    kq=(sl*k)%cm;
    for (int i=1;i<=n;++i)
        for (int j=1;j<=n;++j)
            if (a[j]<a[i])
            {
                long o=(k*(k-1)/2)%cm;
                kq=kq+o;
                kq=kq%cm;
            }
    cout<<kq;
}
int main(int argc, const char * argv[]) {
   // freopen("a.inp","r",stdin);
    nhap();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

template <typename T> inline string toString(const T &a){ostringstream oss; oss<<a; return oss.str();};

int main(){
    string s; cin>>s;
    int n=s.size();

    if(n%2==0){
        if(s[0]==s[n-1]) cout << "First" << endl;
        else cout << "Second" << endl;
    }
    else{
        if(s[0]==s[n-1]) cout << "Second" << endl;
        else cout << "First" << endl;
    }
}

Measured memory_bytes: 512
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
	Scanner reader=new Scanner(System.in);
	int A= reader.nextInt();
	int B= reader.nextInt();
	int C= reader.nextInt();
	int tab[]= {A,B,C};
	Arrays.sort(tab);
	if ((tab[0]==5  && tab[1]==5 && tab[2]==7)) {
		System.out.print("YES");}
		else {
			System.out.print("NO");}
	
	}

}


Measured memory_bytes: 24020
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CTriangularRelationship solver = new CTriangularRelationship();
        solver.solve(1, in, out);
        out.close();
    }

    static class CTriangularRelationship {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            long n = sc.nextInt();
            long k = sc.nextInt();
            long ans = 0;
            for (int a = 1; a <= n; a++) {
                if (((a % k) * 2) % k == 0) {
                    long nb = (n / k);
                    if (a % k != 0 && n % k >= a % k) {
                        nb++;
                    }
                    ans += nb * nb;
                }
            }
            out.println(ans);
        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e12;

int main() {
    long long h, w; cin >> h >> w;
    long long res = INF;
    for (int i = 1; i < w; i++)
    {
        long long s1, s2, s3;
        long long wh = (w - i + 1) / 2, hh = (h + 1) / 2;
        s1 = h * i;
        s2 = h * wh;
        s3 = h * w - s1 - s2;
        res = min(res, max({s1, s2, s3}) - min({s1, s2, s3}));
        s2 = hh * (w - i);
        s3 = h * w - s1 - s2;
        res = min(res, max({s1, s2, s3}) - min({s1, s2, s3}));
    }
    swap(h, w);
    for (int i = 1; i < w; i++)
    {
        long long s1, s2, s3;
        long long wh = (w - i + 1) / 2, hh = (h + 1) / 2;
        s1 = h * i;
        s2 = h * wh;
        s3 = h * w - s1 - s2;
        res = min(res, max({s1, s2, s3}) - min({s1, s2, s3}));
        s2 = hh * (w - i);
        s3 = h * w - s1 - s2;
        res = min(res, max({s1, s2, s3}) - min({s1, s2, s3}));
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3604
#include"bits/stdc++.h"
using namespace std;
#define rep(i, N) for(int i=0; i<N; ++i)
using ul = unsigned long;
using ll = long long;

int main() {
    string s;
    cin >> s;
    int m = s.size()/2;
    int cnt = 0;
    rep(i, m) {
        if (s[i] != s[s.size()-i-1]) cnt++;
    }

    cout << cnt << endl;
}


Measured memory_bytes: 256
//
// B - 3人でカードゲームイージー / Card Game for Three (ABC Edit)
//

#include <iostream>

using namespace std;

int main() {

    string S['c' + 1];
    int L['c' + 1];
    int P['c' + 1] = {0};

    for (int i = 'a'; i <= 'c'; i++) {
        cin >> S[i];
        L[i] = (int) S[i].length();
    }

    char prev = 'a';

    while (true) {
        if (P[prev] == L[prev]) break;
        char next = S[prev][P[prev]];
        P[prev]++;
        prev = next;
    }

    cout << (char) (prev - 32) << endl;
}

Measured memory_bytes: 256
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

int main(void) {
    int N;
    cin>>N;
    vector<int>a(N);
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end(),greater<int>());
    int cnt=0;

    for(int i=0;i<N;i++){
        if(i%2==0){
            cnt+=a[i];
        }
        else{
            cnt-=a[i];
        }
    }
    cout<<cnt<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int const MAX=1000*100+10;
vector<int>adj[MAX];
bool mark[MAX];
int dp[MAX];
int depth[MAX];
int cnt=0;
int ans[MAX];
bool mark2[MAX];
void dfs(int v,int de){
    mark[v]=1;
    depth[v]=de;
    dp[v]=depth[v];
    int maxx=0;
    for(int i=0;i<adj[v].size();i++){
        int u=adj[v][i];
        if(!mark[u]){
            dfs(u,de+1);
           dp[v]=min(dp[u],dp[v]);
            maxx=max(dp[u],maxx);
        }
        else
            dp[v]=min(dp[v],depth[u]);
    }
    if(dp[v]==de-1)
        dp[v]=de;
    if(maxx>de && v!=0)
        ans[cnt++]=v;
}
void dfs2(int v){
    mark2[v]=1;
    for(int i=0;i<adj[v].size();i++){
        if(!mark2[adj[v][i]])
            dfs2(adj[v][i]);
    }
}
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int a,b;
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    dfs(0,1);
    mark2[0]=1;
    dfs2(1);
    bool k=true;
    for(int i=0;i<n;i++){
        if(!mark2[i])
            k=false;
    }
    if(!k)
        ans[cnt++]=0;
    sort(ans,ans+cnt);
    for(int i=0;i<cnt;i++)
        cout<<ans[i]<<endl;
}

Measured memory_bytes: 6916
import java.util.Scanner;

public class Main {

    public static void main(String[] args)throws Exception {

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        char[] ch = line.toCharArray();
        for (int i = 0; i < ch.length; i++) {
            if(Character.isUpperCase(ch[i])){
                ch[i] = Character.toLowerCase(ch[i]);
            }else if(Character.isLowerCase(ch[i])){
                ch[i] = Character.toUpperCase(ch[i]);
            }
        }
        for (char c : ch) {
            System.out.print(c);
        }
        System.out.println();
        sc.close();
    }
}

Measured memory_bytes: 17272
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <set>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

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

}



int main() {
	ll N;

	cin >> N;
	vector<ll> A(N + 1), T(N + 1);
	rep(i, N) {
		cin >> A[i];
		T[A[i]] = i + 1;
	}

	set<ll> S, M;
	ll sum = 0;
	S.insert(0), S.insert(N + 1);
	M.insert(0), M.insert(-(N + 1));
	for (int i = N; i >= 1; i--) {

		auto it = S.lower_bound(T[i]);
		auto it2 = S.lower_bound(*it);
		if (*it != N + 1)
			it2 = S.upper_bound(*it);
	
			

		auto it3 = M.lower_bound(-T[i]);
		auto it4 = M.lower_bound(*it3);
		if (*it3 != 0)
			it4 = M.upper_bound(*it3);
		
			


		sum += i * (*it2 - *it) * (T[i] + *it3) + i * (*it - T[i])*(*it4 - *it3);
		S.insert(T[i]);
		M.insert(-T[i]);
	}


	cout << sum << endl;

	return 0;
}

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

#define MAXN 200005

using namespace std;

int info[200000][2];
int main() {
#ifdef orange
    freopen("input.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string temp;
		cin >> temp;
		int cnt = 0;
		if (temp.find(".") != string::npos) {
			int save = temp.find(".");
			cnt = temp.length() - save - 1;
			temp = temp.substr(0, save) + temp.substr(save + 1);
		}
		//	cout << temp << endl;
		long long a = stoll(temp);
		int cnt2 = -cnt;
		int cnt5 = -cnt;
		while (a % 2 == 0) {
			a /= 2;
			cnt2++;
		}
		while (a % 5 == 0) {
			a /= 5;
			cnt5++;
		}
		info[i][0] = cnt2;
		info[i][1] = cnt5;
		//cout << cnt2 << " " << cnt5 << endl;
	}
	long long prev[90][50] { };
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		long long sum = 0;
		for (int j = -info[i][0]; j < 45; j++) {
			for (int k = -info[i][1]; k < 25; k++) {
				sum += prev[j + 45][k + 25];
			}
		}
		prev[info[i][0] + 45][info[i][1] + 25]++;
		ans += sum;
	}
	cout << ans << endl;
}


Measured memory_bytes: 5212
#include <cstdio>
#include <algorithm>

using namespace std;

int a[100000];

int main() {
    int n, i;
    long long ans1 = 0, ans2 = 0, sum1 = 0, sum2 = 0;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    
    for (i = 0; i < n; i++) {
        sum1 += a[i];
        sum2 += a[i];
        
        if (i % 2 == 0) {
            if (sum1 <= 0) {
                ans1 += -sum1 + 1;
                sum1 = 1;
            }
            
            if (sum2 >= 0) {
                ans2 += sum2 + 1;
                sum2 = -1;
            }
        } else {
            if (sum1 >= 0) {
                ans1 += sum1 + 1;
                sum1 = -1;
            }
            
            if (sum2 <= 0) {
                ans2 += -sum2 + 1;
                sum2 = 1;
            }
        }
    }
    
    printf("%lld\n", min(ans1, ans2));
    
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if (a * b < c)
    {
        printf("%d\n", a * b);
    }
    else
    {
        printf("%d\n", c);
    }
    return 0;
}

Measured memory_bytes: 128
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define db double
#define inf 20021225
#define N 100010
using namespace std;
int n,m,to[N],stk[N]; ll k,a[N],x[N],nw[N],ans[N]; bool vis[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)	scanf("%lld",&x[i]),nw[i]=x[i]-x[i-1],to[i]=i;
	scanf("%d%lld",&m,&k);
	for(int i=1;i<=m;i++)	scanf("%lld",&a[i]),swap(to[a[i]],to[a[i]+1]);
	for(int i=1;i<=n;i++)	if(!vis[i])
	{
		int cnt=0;
		for(int j=i;!vis[j];j=to[j])
			vis[j]=1,stk[++cnt]=j;
		for(int j=1;j<=cnt;j++)
			ans[stk[j]]=nw[stk[(j+k-1)%cnt+1]];
	}
	for(int i=1;i<=n;i++)
		ans[i]+=ans[i-1],printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 5120
//#pragma region ALL(include define etc)
#include <iostream>   // swap(a, b)
#include <string>
#include <cmath>      // abs(絶対値) sin cos tan(角度 / 180.0 * 3.141592)
#include <vector>     // vec.push_back(a) vec.pop_back()
#include <algorithm>  // max(a, b) min(a, b) reverse() sort()
#include <functional> // sort(a, a + N, greater<型>());
#include <limits>
#include <math.h>
#include <iomanip>
#define int long long
//#define int unsigned long long
#define ll long long
#define double long double
using namespace std;
//#pragma endregion

signed main()
{
	// 10^18 = 1000000000000000000

	//int h1, h2, m1, m2, k;
	//int box, box1,box2;

	//int N;
	int n;
	//char n;
	//int a, b, c;
	//int m;
	int h, w, x;
	int k;
	int d;
	int t;
	//string s;
	//string t;
	//int m1, m2;
	//int a, b, c, k;
	//int x, y;

	//string s[111111];
	//string s[100000];
	//string c[7];
	//int a[100000];
	//int b[200000];
	//int a[2000000] = { 0 };
	//int b[2000000] = { 0 };
	//int a[20000] = { 0 };
	//int b[20000] = { 0 };
	//vector<int>a(2000000);
	//vector<int>b(2000000);

	//int aaa = 0;
	//int bbb = 0;

	int box[20000] = { 0 };
	//int box = 0;
	//int box[7][7] = { 0 };
	//int box2;
	//int p[1111];
	//int x[2000], y[2000];
	//int l[100];


	//long double aaa;

	int count = 0;
	//int k, d;
	//int a = 0;
	int all = 0;
	//double all;
	//double a, b;
	//double h, m;
	//int a[30000] = { 0 };
	//double c, d, e;

	//double mbox, hbox;
	//double box, box2;

	bool flag = true;
	//bool flag = false;

	//string str;

	//cin >> h1 >> m1 >> h2 >> m2 >> k;
	//cin >> n;
	//cin >> a >> b >> c;
	//cin >> s;
	//cin >> h >> w >> k;
	cin >> n >> x >> t;
	/*for (int i = 0; i < n; i++)
	{
		cin >> l[i];
	}*/
	count = n / x;
	if (n % x == 0)
	{
		all = t * count;
	}
	else if (n % x != 0)
	{
		all = t * (count + 1);
	}
	else
	{
		
	}

	//n = s.length();

	//sort(p, p + n);
	//n = n - 'Z';

	//box = n % 26;

	//for (int i = 0; i < k; i++)
	//{
	//	all += p[i];
	//}

	//all = n + (n * n) + (n * n * n);

	/*if (n > 0)
	{
		cout << "a\n";
	}
	else
	{
		cout << "A\n";
	}*/
	//n = t.length();

	/*cout << "AC x " << ac << "\n";
	cout << "WA x " << wa << "\n";
	cout << "TLE x " << tle << "\n";
	cout << "RE x " << re << "\n";*/

	//cout << x << "\n";
	cout << all << "\n";
	//cout << box << "\n";
	//cout << a << b << c << "\n";

	/*if (flag == true)
	{
		cout << "Yes\n";
	}
	else
	{
		cout << "No\n";
	}*/

	//cout << fixed << setprecision(111) << all;
	//return 0;
}


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

const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()

#define cout cout << setprecision(12)

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void dbg(T a) { cout << a << ' ' << endl; }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main() {
    cin >> n >> m >> k;
	ll a, b = n;
	if ((k-m)%2==0) {
    	a = (k-m)/2;
    } else {
		a = min(n-m,k-1);
    	if (m-1 < n-k) {
        	b = m-1;
        	k -= b-1;
        	b += (k-1) / 2;
        } else {
        	b = n-k;
        	m += b-1;
        	b += (n-m) / 2;
        }
    }
	cout << min(a,b) << endl;
}


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

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

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

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

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

    int N, M;
    std::cin >> N >> M;

    vector<vector<int>> work(M);
    REP(i, N) {
        int a, b;
        std::cin >> a >> b;
        if(M < a) continue;
        work[a - 1].push_back(b);
    }

    ll ans = 0;
    priority_queue<int> pq;
    for(int i = 0; i < M; i++) {
        if(0 < work[i].size()) {
            for(const auto& v : work[i]) {
                pq.emplace(v);
            }
        }

        if(0 < pq.size()) {
            auto top = pq.top();
            pq.pop();
            ans += top;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 5632
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int A[100010], B[100010];

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int sumA = 0;
    int sumB = 0;
    rep(i, N) {
        cin >> A[i];
        sumA += A[i];
    }
    rep(i, N) {
        cin >> B[i];
        sumB += B[i];
    }
    vector<int> lack;
    vector<int> many;
    rep(i, N) {
        if (B[i] > A[i]) lack.push_back(B[i] - A[i]);
        else if (B[i] < A[i]) many.push_back(A[i] - B[i]);
    }
    if (sumA < sumB) {
        cout << -1 << endl;
        return 0;
    }
    sort(many.begin(), many.end(), greater<int>());
    int i = 0, j = 0;
    int ans = lack.size();
    while(i < lack.size()) {
        if (i == 0 && j== 0) ans++;
        if (many[j] == 0) {
            j++;
            ans++;
        }
        int less = min(lack[i], many[j]);
        lack[i] -= less;
        many[j] -= less;
        if (lack[i] == 0) i++;
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 2936
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

class DisjointSet{
    public:
        vector<int> rank, p, num;

        DisjointSet(){}
        DisjointSet(int size){
            rank.resize(size, 0);
            p.resize(size, 0);
            num.resize(size, 0);
            for(int i = 0; i < size; i++) makeSet(i);
        }

        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
            num[x] = 1;
        }//グループを作る

        bool same(int x, int y){
            return findSet(x) == findSet(y); //x,yが同じグループに属しているか判定
        }

        void unite(int x, int y){
            link(findSet(x), findSet(y));
            
        }//xとyの属するsetを結合する

        void link(int x, int y){
            if(rank[x] > rank[y]){
                p[y] = x;
                num[x] += num[y];
                num[y] = 0;
            }else{
                p[x] = y;
                if( rank[x] == rank[y]){
                    rank[y]++;
                }
                num[y] += num[x];
                num[x] = 0;
            }
        }//rankが大きい方の下にrankが小さいものをくっつける

        int findSet(int x){
            if(x != p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }//再帰的にxの親を見つけている

        int size(int x){
            return num[findSet(x)];
        }// xの属する集合の大きさを返す
};//size分の0~n-1の数、setが生成されていることに注意(読み込む時に全て-1するのが良い)

//long long dp[100];
/*void factorial(){
    for(int i = 0; i<100; i++){
        if(i == 0) dp[i] = 0;
        else dp[i] = dp[i-1] * i;
    }
}*/

int main(){
    int n, m;
    cin >> n >> m;
    int a[m], b[m];
    vector<ll> v;
    //factorial();
    DisjointSet ds = DisjointSet(n);
    for(int i = 0; i < m; i++){
        cin >> a[m - i - 1] >> b[m - i - 1];
        a[m - i - 1]--;
        b[m-i-1]--;
    }
    v.push_back(0);
    ll sum = 0;
    for(int i = 0; i < m; i++){
        if(ds.same(a[i],b[i]) != true){
            ll p = ds.size(a[i]), q = ds.size(b[i]);
            sum += p * q;
            ds.unite(a[i], b[i]);
        }
        v.push_back(sum);
    }
    ll max = (long)n * (n - 1) / 2;
    for(int i = v.size() - 2; i >= 0; i--){
        cout << max - v[i] << endl;
    }
}

Measured memory_bytes: 4212
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <cassert>
#include <functional>

using namespace std;
typedef long long ll;


#define SIZE 26
#define INF 1000000000
#define LLINF 1000000000000000000LL

ll dp[5][5001];

bool solve(){
  int n;
  
  if(scanf("%d", &n) == EOF) return false;
  
  printf("%lld\n", dp[4][n]);
  
  return true;
}

int main(){

  dp[0][0] = 1;

  for(int i=0;i<4;i++){
    for(int j=0;j<=i*1000;j++){
      for(int k=0;k<=1000;k++){
        dp[i+1][j+k] += dp[i][j]; 
      }
    }
  }
  
  while(solve());
  
  return 0;
}



Measured memory_bytes: 3312
#include<cstdio>
#include<map>
#include<queue>
#include<iostream>

using namespace std;

int n;
long long a[55];

int main()
{
	cin >> n;
	long long ans=0;
	for(int i = 1;i <= n;i++)
		cin >> a[i];
	bool flag=1;
	while(1)
	{
		flag=0;
		for(int i = 1;i <= n;i++)
			if(a[i]>=n)flag=1;
		if(!flag)break;
		for(int i = 1;i <= n;i++)
			if(a[i]>=n)
			{
				long long cnt=a[i];
				cnt/=n;
				a[i]-=cnt*n;
				ans+=cnt;
				for(int j = 1;j <= n;j++)
					if(i!=j)a[j]+=cnt;
			}
	}
	/*flag=1;
	while(1)
	{
		int ii=1;
		for(int i = 1;i <= n;i++)
			if(a[i]>a[ii])ii=i;
		ans++;
		a[ii]-=n;
		for(int i = 1;i <= n;i++)
			if(i!=ii)a[i]++;
		flag=0;
		for(int i = 1;i <= n;i++)
			if(a[i]>=n)flag=1;
	}*/
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a,b,k;
    scanf("%d %d %d",&a,&b,&k);
    
    int i;
    for(i=0;i<k;i++){
        if((i%2==0&&a==0)||(i%2==1&&b==0)){
            break;
        }
        if(i%2==0&&a%2==1&&a!=0){
            a=a-1;
            a=a/2;
            b+=a;
        }else if(i%2==0){
            a=a/2;
            b+=a;
        }
        if(i%2==1&&b%2==1&&b!=0){
            b=b-1;
            b=b/2;
            a+=b;
        }else if(i%2==1){
            b=b/2;
            a+=b;
        }
    }
    printf("%d %d\n ",a,b);
    return 0;
}

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

int main () {
  double r;
  double pi = 3.141592653589;
  double sq, l;
  cin >> r;
  sq = r*r*pi;
  l = 2*pi*r;
  cout.precision(6);
  cout << fixed << sq << " "
       << l << endl;
  return 0;
}

Measured memory_bytes: 1288
# include <bits/stdc++.h>
# define ll long long
using namespace std;
int main()
{
    ll k, s;
    cin>>k>>s;
    ll count=0;
    for(int i=0;i<=k;i++)
    {
        for(int j=0;j<=k;j++)
        {
            ll yea=s-i-j;
            if(yea>=0 && yea<=k)
            {
                count++;
                //cout<<i<<" "<<j<<" "<<yea<<endl;
            }
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
use whiteread::parse_line;

fn main() {
    let n: usize = parse_line().unwrap();
    let (d, x): (u32, u32) = parse_line().unwrap();
    let mut cnt: u32 = 0;
    for _ in 0..n {
        let ci: u32;
        let ai: u32 = parse_line().unwrap();
        if d % ai == 0 {
            ci = d / ai;
        } else {
            ci = (d / ai) + 1;
        }
        cnt += ci;
    }
    println!("{}", cnt + x);
}


Measured memory_bytes: 2144
#include<bits/stdc++.h>
#define mp make_pair
#define pr pair<ll,ll>
#define MAX 1000000
using namespace std;
typedef long long int ll;
#define mod 998244353
void sync(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}

int main(){
	sync();
	ll t;
	t=1;
	ll n;
	for(ll testcase=1;testcase<=t;testcase++){
	cin>>n;
	ll ans=0;
	ans=(n/500)*1000;
	n=n-(n/500)*500;
	ans+=(n/5)*5;
	cout<<ans<<endl;
	}
}

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

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

    while (1) {
        long i = n / 100;
        long j = n / 10 % 10;
        long k = n % 10;
        if (i == j && j == k) {
            cout << n << endl;
            return 0;
        }
        n++;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin>>a.at(i);

  int j=0,cnt=0;
  while(j<n-1)
  {
    if(a.at(j+1)==a.at(j))
    {
      cnt++;
      j=j+2;
    }

    else j++;
  }

  cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <numeric>
#include <algorithm>
using namespace std;

unsigned long long lcm(unsigned long long a,unsigned long long b){
  unsigned long long x = a * b;

  if(a<b){
    unsigned long long tmp = a;
    a = b;
    b = tmp;
  }

  unsigned long long r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return x/b;
	
}


int main() {
	unsigned long long A, B, C, D;

	cin >> A >> B >> C >> D;

	--A;

	unsigned long long lcm_cd = lcm(C, D);
	unsigned long long total = B-A;
	unsigned long long div_c  = B/C - A/C;
	unsigned long long div_d  = B/D - A/D;
	unsigned long long div_cd = B/lcm_cd - A/lcm_cd;

	cout << total - (div_c + div_d - div_cd);

}

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

int main()
{
  int n;
  int i;
  int l;
  int r;
  int amount;
  
  cin >> n;
  i = 0;
  while (i < n)
  {
    cin >> l >> r;
    amount += r - l + 1;
    i++;
  }
  
  cout << amount << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <bits/stdc++.h>
using namespace std;

int main(){
    int X, A;
    cin >> X >> A;
    int ans;
    if(X < A){
        ans=0;
    }else{
        ans=10;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import math
input()
vx = [int(i) for i in input().split()]
vy = [int(i) for i in input().split()]

Dxy = []
for p in range(1,4):
    Dxy.append(sum([abs(vx[i] - vy[i]) ** p for i in range(len(vx))]) ** (1 / p))

Dxy.append(max([abs(vx[i] - vy[i]) for i in range(len(vx))]))
for res in Dxy:
    print('{0:.5f}'.format(res))

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

int main() {
  long long int X,s;
  cin >> X;
  s = 100; 
  for (int i = 0; i < 100000000; i++) {
    s *= 1.01;
    if (s >= X) {
      cout << i + 1 << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3536
#include<bits/stdc++.h>
#define fast ios::base_sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define M 1000000000+7
using namespace std;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long int n,i,j;
	cin>>n;
	long int a[n][3];
	for(i=0;i<n;i++)
	{
		for(j=0;j<3;j++)
		cin>>a[i][j];
	}
	long int dp[n][3];
	dp[0][0]=a[0][0];
	dp[0][1]=a[0][1];
	dp[0][2]=a[0][2];
	for(i=1;i<n;i++)
	{
		for(j=0;j<3;j++)
		{
			if(j==0)
			dp[i][j]=a[i][j]+max(dp[i-1][1],dp[i-1][2]);
			if(j==1)
			dp[i][j]=a[i][j]+max(dp[i-1][0],dp[i-1][2]);
			if(j==2)
			dp[i][j]=a[i][j]+max(dp[i-1][0],dp[i-1][1]);
		}
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

Measured memory_bytes: 4992
package main

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

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a % b)
}

func main() {
	var n int
	fmt.Scan(&n)
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	a := make([]int, n)
	for i := range a {
		s.Scan()
		a[i], _ = strconv.Atoi(s.Text())
	}
	L := make([]int, n+1)
	R := make([]int, n+1)
	for i := 0; i < n; i++ {
		L[i+1] = gcd(L[i], a[i])
	}
	for i := n - 1; i >= 0; i-- {
		R[i] = gcd(R[i+1], a[i])
	}
	ans := 1
	for i := 0; i < n; i++ {
		ans = max(ans, gcd(L[i], R[i+1]))
	}
	fmt.Println(ans)
}


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

using namespace std;

long long gcd(long long x,long long y) {
  return y?gcd(y,x%y):x;
}

long long lcm(long long x,long long y){
  return x/gcd(x,y)*y;
}

int main(){
  int n; cin >> n;
  vector<long long> p(n);
  long long maxi=1;
  for(auto& a:p) cin >> a;
  sort(p.begin(),p.end());
  p.erase(unique(p.begin(),p.end()),p.end());
  n=p.size();
  set<long long> st;
  for(int i=1;i<(1<<n);++i) {
    long long tmp=1;
    for(int j=0;j<n;++j)
      if(i & (1<<j)) tmp=lcm(tmp,p[j]);    
    st.insert(tmp);
  }
  cout << st.size() << endl;
  
  return 0;
}


Measured memory_bytes: 4076
a, b = map(int, input().split())
a -= 1
d = 1
ans = 0

while d <= 10**12:
    d2 = d * 2
    asum = a//d2 * d + max(0, a % d2 + 1 - d)
    bsum = b//d2 * d + max(0, b % d2 + 1 - d)
    ans += (bsum - asum) % 2 * d
    d *= 2

print(ans)


Measured memory_bytes: 2940
#include <stdio.h>
int main(){
     int a,b,c;
     scanf("%d %d%d",&a,&b,&c);
     int k=1;
     while(1){
        if(k*a%b==c) {
            printf("YES");
            break;
        }
        if(k*a%b==0){
            printf("NO");
            break;
        }
        k++;
     }
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<stdbool.h>


int a[10], b[10], c[10];
bool result;


bool Ball(int A, int B, int C){


  if(A==10){
    return true;
  }

  if(a[A]<b[B] && a[A]<c[C]){
    return false;
  }


  if(a[A]>b[B-1]){
    b[B]=a[A];
    result = result || Ball(A+1, B+1, C);
    b[B]=0;
  }
  
  if(C==0 || a[A]>c[C-1]){
    c[C]=a[A];
    result = result || Ball(A+1, B, C+1);
    c[C]=0;
  }


  return result;

}



int main(void){

  int A, B, C;
  int i, n;


  scanf("%d", &n);
  while(n>0){
    for(i=0; i<10; i++){
      scanf("%d", &a[i]);
      b[i]=c[i]=0;
    }
    
    A=B=C=0;
    result = false;
    b[B]=a[A];
    result=Ball(A+1, B+1, C);

    if(result==true){
      printf("YES\n");
    }
    else{
      printf("NO\n");
    }
    
    n--;
  }



  return(0);
}



Measured memory_bytes: 2056
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)


int main() {
	string s;
	cin>>s;
	int t=s.size(),ac=1,c=0;
	if(s[0]!='A')cout<<"WA";
	else if(tolower(s[1])!=s[1]||tolower(s[t-1])!=s[t-1])cout<<"WA";
	else{
	    for(int i=2;i<t-1;i++){
	        if(tolower(s[i])!=s[i]){
	            if(s[i]=='C')c++;
	            else ac=0;
	        }
	    }
	    if(c==1&&ac==1)cout<<"AC";
	    else cout<<"WA";
	}
	return 0;
}


Measured memory_bytes: 256
n, q = map(int, raw_input().split())
s = [0]*n
mx,mxa = 0, 0
for i in range(q):
	a,v = map(int, raw_input().split())
	s[a-1] += v
	if v > 0:
		if s[a-1] > mx:
			mx = s[a-1]
			mxa = a-1
		elif s[a-1] == mx:
			if a-1 < mxa:
				mxa = a-1
	elif v < 0:
		if a-1 == mxa:
			mx = max(s)
			mxa = s.index(mx)
	print mxa+1,mx

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

using namespace std;

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


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), x = sc.nextInt();
		int l[] = new int[n];
		int d = 0;
		int ans = 1;
		for(int i = 0; i < n; ++i) {
			l[i] = sc.nextInt();
			d += l[i];
			if(d <= x)ans++;
		}
		sc.close();
		System.out.println(ans);
	}
}


Measured memory_bytes: 22740
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> xs(M, 0);
  for(int i = 0; i < M; ++i) {
    cin >> xs[i];
  }
  sort(xs.begin(), xs.end());

  if(N >= M) {
    cout << 0 << endl;
    return 0;
  }
  vector<ll> ls;
  for(int i = 1; i < xs.size(); ++i) {
    ls.push_back(xs[i] - xs[i - 1]);
  }
  sort(ls.begin(), ls.end(), greater<ll>());
  ll total = 0;
  for(int i = 0; i < N - 1; ++i) {
    // cout << ls[i] << endl;
    total += ls[i];
  }
  ll ans = (xs.back() - xs.front()) - total;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2168