akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

ll gcd(ll m, ll n) {
  if (n == 0) return m;
  else return gcd(n, m%n);
}

ll lcm(ll a, ll b) {
  return a/gcd(a, b)*b;
}

int main() {
  int n;
  cin >> n;
  vector<ll> t(n);
  for (int i = 0; i < n; i++) cin >> t[i];
  ll res = t[0];
  for (int i = 1; i < n; i++) res = lcm(res, t[i]);
  dump(res);
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll int64_t 
#define f(i,s,e) for(i=s;i<e;++i)
#define endl << "\n"
#define sp << " "
#define INF INFINITY
#define mset(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define crap ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846264338327950288419716939937510
#define pb(a) push_back(a)
#define pf(a) push_front(a)
using namespace std;

int main()
{
	crap;
	ll i,j,k,n;
	cin >> n >> k;
	vector <ll> arr(n);
	f(i,0,n)
		cin >> arr[i];
	sort(all(arr));
	ll ans = 0;
	f(i,0,k)
		ans += arr[i] ;
		cout << ans endl ;
	return 0;
}

Measured memory_bytes: 3660
#include <string.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
// #include <unordered_map>
// #include <unordered_set>
#include <utility>
#include <vector>

#define pb push_back
#define mp make_pair

#ifdef ONLINE_JUDGE
#define link renamelink
#define next renamenext
#define prev renameprev
#endif

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef long double ld;

inline void EnableFileIO(const string &fileName, bool local = 0) {
  if (fileName.empty()) return;
  if (local) {
    freopen((fileName + ".in").c_str(), "r", stdin);
    freopen((fileName + ".out").c_str(), "w", stdout);
    return;
  }
#ifdef ONLINE_JUDGE
  freopen((fileName + ".in").c_str(), "r", stdin);
  freopen((fileName + ".out").c_str(), "w", stdout);
#endif
}

const int INF = (1 << 30) - 1;
const LL LINF = (1LL << 61) - 1;
const double EPS = 1e-10, PI = acos(-1);
const int N = 2e5 + 100, P = 1e9 + 7;

int n;
int id[N], x[N], v[N];
inline bool compv(const int &i, const int &j) { return v[i] < v[j]; }
int premax[N], sufmin[N];

pii tim[N];
LL f[N], sum[N];

int main() {
  // srand((int)time(0));
  // printf("Hello, world!\n");
  // EnableFileIO("");

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", x + i, v + i);
    id[i] = i;
  }
  sort(id, id + n, compv);
  premax[0] = x[id[0]];
  for (int i = 1; i < n; i++) {
    premax[i] = max(premax[i - 1], x[id[i]]);
  }
  sufmin[n] = INF;
  for (int i = n - 1; i >= 0; i--) {
    sufmin[i] = min(sufmin[i + 1], x[id[i]]);
  }

  for (int i = 0; i < n; i++) {
    int l = -1, r = i;
    while (r - l > 1) {
      int mid = (l + r) >> 1;
      if (premax[mid] >= x[id[i]]) {
        r = mid;
      } else {
        l = mid;
      }
    }
    tim[i + 1].first = r;

    l = i, r = n;
    while (r - l > 1) {
      int mid = (l + r) >> 1;
      if (sufmin[mid] <= x[id[i]]) {
        l = mid;
      } else {
        r = mid;
      }
    }
    tim[i + 1].second = l;
  }
  sort(tim + 1, tim + n + 1);

  int head = 0, pos = 0;
  f[0] = 1, sum[0] = 1;
  tim[0] = mp(-1, -1);
  for (int i = 1; i <= n; i++) {
    while (tim[head].second < tim[i].first - 1) ++head;
    f[i] = (sum[i - 1] - (head ? sum[head - 1] : 0) + P) % P;
    sum[i] = (sum[i - 1] + f[i]) % P;
    if (tim[i].second != n - 1) pos = i;
  }
  printf("%lld\n", ((sum[n] - sum[pos]) % P + P) % P);
  return 0;
}


Measured memory_bytes: 8832
#!/usr/bin/env python

n = int(input())
a = list(map(int, input().split()))

s = []
tmp = 1 
for i in range(1, n): 
    if a[i] == a[i-1]:
        tmp += 1
        if i == n-1:
            s.append(tmp)
    else:
        if tmp != 1:
            s.append(tmp)
        tmp = 1 

ans = 0 
for i in s:
    ans += i//2

print(ans)


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

int main()
{
    int a,b,c,cou;
    cou = 0;
    cin >> a >> b >> c;
        
        if(a == b)
        cou++;
        if(b == c)
        cou++;
        if(c == a)
        cou++;
        
        if(cou == 1)
        cout << "Yes";
        else
        cout << "No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

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

/*（๑•﹏•๑｀) */

int main() {
    string S;
    getline(cin,S);
    int ans1 = 0;
    int ans2 = 0;
    int N = S.length();

    REP(i,N){
        if (i % 2 == 0){
            if (S[i] == '0') ans1++;
        }else{
            if (S[i] == '1') ans1++;
        }
    }

    REP(i,N){
        if (i % 2 == 1){
            if (S[i] == '0') ans2++;
        }else{
            if (S[i] == '1') ans2++;
        }
    }

    int ans = min(ans1,ans2);
    cout << ans << "\n";

}


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

int main(){

    int x = 0, y = 0;
    for(int i = 0; i < 4; i++){
        int in; cin >> in;
        x += in;
    }
    for(int i = 0; i < 4; i++){
        int in; cin >> in;
        y += in;
    }

    cout << max(x, y) << endl;
    return 0;
}


Measured memory_bytes: 3100
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let h: usize = itr.next().unwrap().parse().unwrap();
    let w: usize = itr.next().unwrap().parse().unwrap();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let sr: usize = itr.next().unwrap().parse().unwrap();
    let sc: usize = itr.next().unwrap().parse().unwrap();
    let s: Vec<char> = itr.next().unwrap().chars().collect();
    let t: Vec<char> = itr.next().unwrap().chars().collect();

    // x軸
    // L
    let mut l = sc;
    let mut r = sc;
    for i in 0..n {
        if s[i] == 'L' {
            l -= 1;
        }
        if s[i] == 'R' {
            r += 1;
        }
        if l == 0 || r == w + 1 {
            println!("NO");
            return;
        }
        if t[i] == 'R' && l < w {
            l += 1;
        }
        if t[i] == 'L' && r > 1 {
            r -= 1;
        }
    }
    let mut u = sr;
    let mut d = sr;

    for i in 0..n {
        if s[i] == 'U' {
            u -= 1;
        }
        if s[i] == 'D' {
            d += 1;
        }
        if u == 0 || d == h + 1 {
            println!("NO");
            return;
        }
        if t[i] == 'D' && u < h {
            u += 1;
        }
        if t[i] == 'U' && d > 1 {
            d -= 1;
        }
    }
    println!("YES");
}


Measured memory_bytes: 6396
fun main() {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val list = readLine()!!.split(" ").map { it.toInt() }
    val result = n - list.sum()
    if (result >= 0) {
        println(result)
    } else {
        println(-1)
    }
}

Measured memory_bytes: 39340
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include<bits/stdc++.h>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>*/

#define sz(s) (int)(s.size())
#define all(s) s.begin(), s.end()
#define rep(a, b, c) for(int a = b; a <= c; ++a)
#define per(a, b, c) for(int a = b; a >= c; --a)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;
//using namespace __gnu_pbds;

typedef unsigned long long ull;
typedef long long ll;
/*typedef tree<pair<int, int>, 
null_type, less<pair<int, int>>, 
rb_tree_tag, tree_order_statistics_node_update>
ordered_set;*/
//find_by_order() order_of_key()

const double eps = 1e-7;
const int mod = 1e9+7, MXN = 5e5+17;
const int dx[] = {0,0,1,-1}, dy[] = {1,-1,0,0};

template<typename T>inline bool updmin(T &a, const T &b) {return a > b ? a = b,1 : 0;}
template<typename T>inline bool updmax(T &a, const T &b) {return a < b ? a = b,1 : 0;}

int32_t main() { _
#ifdef DanQQQQQ
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	string s; cin >> s;
	if(s[0] == s[1]) return cout << 1 << " " << 2 << endl, 0;
	rep(i,0,sz(s)-3) {
		char a = s[i], b = s[i+1], c = s[i+2];
		if(a == b) return cout << i+1 << " " << i+2 << endl, 0;
		if(b == c) return cout << i+2 << " " << i+3 << endl, 0;
		if(a == c) return cout << i+1 << " " << i+3 << endl, 0;
	}
	cout << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 512
import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}

object Main extends App {
  val n = in.readInt
  val a = in.readLine.split(" ").map(_.toInt)

  val max = a.max
  val min = a.min

  val buf = StringBuilder.newBuilder
  if(max == 0 && min == 0) buf.append(0).append('\n')
  else if(min >= 0) {
    buf.append(n-1).append('\n')
    (1 until n).foreach(i => buf.append(i).append(' ').append(i+1).append('\n'))
  }
  else if(max < 0) {
    buf.append(n-1).append('\n')
    (n-1 to 1 by -1).foreach(i => buf.append(i+1).append(' ').append(i).append('\n'))
  } else {
    val m = if(max.abs > min.abs) max else min
    val idx = a.indexWhere(_ == m)
    buf.append(n-1 + n-1).append('\n')
    for(i <- 0 until n if i != idx){
      buf.append(idx+1).append(' ').append(i+1).append('\n')
    }
    val b = a.map(_ + m)
    if(m >= 0)
      (1 until n).foreach(i => buf.append(i).append(' ').append(i+1).append('\n'))
    else
      (n-1 to 1 by -1).foreach(i => buf.append(i+1).append(' ').append(i).append('\n'))
  }

  print(buf)
}

Measured memory_bytes: 27320
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int W = sc.nextInt();
  int H = sc.nextInt();
  int N = sc.nextInt();
  int l = 0;int r = W;int u = H;int d = 0;
  int[] x = new int[3*N];
  for(int i = 0;i < 3*N;i += 3){
    x[i] = sc.nextInt();
    x[i+1] = sc.nextInt();
    x[i+2] = sc.nextInt();
    if(x[i+2] == 1){
      if(l <= x[i])l = x[i];
    } 
    else if(x[i+2] == 2){
      if(x[i] <= r)r = x[i];
    }
    else if(x[i+2] == 3){
      if(d <= x[i+1])d = x[i+1];
    }
    else{
      if(x[i+1] <= u)u = x[i+1];
    }
  }
  if(r-l >= 0 && u-d >= 0)System.out.println((r-l)*(u-d));
  else System.out.println("0");
}}


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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	// debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, left, right)  (a).begin()+(left),(a).begin()+(right)	// left to (right-1)


int main() {
	int x;
	cin >> x;
	int kosu = x / 100;
	int hasu = x % 100;
	FOR(i, 0, 100) {
		FOR(j, 0, 50) {
			FOR(k, 0, 34) {
				FOR(m, 0, 25) {
					FOR(n, 0, 20) {
						if (i * 1 + j * 2 + k * 3 + m * 4 + n * 5 == hasu) {
							if (i + j + k + m + n <= kosu) {
								ps(1);
								return 0;
							}
						}
					}
				}
			}
		}
	}
	ps(0)
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  int n, k;
  cin >> n >> k;
  int *a = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  bool *dp = new bool[k + 1];
  for (int i = 0; i < k; i++) {
    dp[i] = false;
  }

  delete[] dp;

  for (int i = 1; i <= k; i++) {
    for (int j = 0; j < n; j++) {
      if (i - a[j] >= 0)
        dp[i] |= !dp[i - a[j]];
    }
  }

  if (dp[k])
    cout << "First" << endl;
  else
    cout << "Second" << endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

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

  int t, a; cin >> t >> a;
  int ans = n + 1;
  double temperature = 20000;

  int h[n];
  for(int i = 1; i <= n; i++){
    cin >> h[i];
  }

  for(int i = 1; i <= n; i++){
    if(abs(t - a - h[i]*0.006) < temperature){
      temperature = abs(t - a - h[i]*0.006);
      ans = i;
    }
    
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main(){
	int n, k;
	cin >> n >> k;
	vector<long long> geko;
	REP(i, n) {
		long long a;
		cin >> a;
		geko.push_back(a);
	}
	sort(geko.begin(), geko.end());
	long long ans = 0;
	REP(i, k) {
		ans += geko[n - 1 - i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll n,c; cin>>n>>c;
	ll dp[n+1][c+1];
	ll w[n],v[n];
	ll ans=0;
	for(ll i=0;i<n;i++) cin>>w[i]>>v[i];
	for(ll i=0;i<=n;i++){
		for(ll j=0;j<=c;j++){
			if(i==0 or j==0)
			dp[i][j]=0;
			else if(j<w[i-1]){
				dp[i][j]=dp[i-1][j];
			}else{
				dp[i][j]=max(v[i-1]+dp[i-1][j-w[i-1]],dp[i-1][j]);
			}
		}
	}
	for(ll i=0;i<=n;i++){
		for(ll j=0;j<=c;j++){
			ans=max(ans,dp[i][j]);
		//	cout<<dp[i][j]<<" ";
		}//cout<<endl;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 79104
n=int(input())
a=list(map(int,input().split()))
b=[i for i in a if i>=0]
c=[i for i in a if i<0]
if len(b)==n:
    b.sort()
    print(-b[0]+sum(b[1:]))
    now=b[0]
    for i in range(1,n-1):
        print(now,b[i])
        now-=b[i]
    print(b[-1],now)
elif len(c)==n:
    c.sort(reverse=1)
    print(c[0]-sum(c[1:]))
    now=c[0]
    for i in range(1,n):
        print(now,c[i])
        now-=c[i]
else:
    print(sum(b)-sum(c))
    for i in range(len(b)-1):
        print(c[0],b[i])
        c[0]-=b[i]
    for i in c:
        print(b[-1],i)
        b[-1]-=i

Measured memory_bytes: 14008
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const int MAX = 100000;
static const int NIL = -1;
using namespace std;

ll absll(ll a){
    if(a > 0) return a;
    else return -1*a;
}
int main() {

    ll x,y; cin >> x >> y;

    if(x == y) cout << 0;
    else if(x == 0 && y > 0) cout << y;
    else if(x == 0 && y < 0) cout << (abs(y)+1);
    else if(x > 0 && y == 0) cout <<x+1;
    else if(x < 0 && y == 0) cout << abs(x);
    else if((x > 0 && y > 0) && y > x) cout << absll(x-y);
    else if((x > 0 && y > 0) && y < x) cout << absll(x-y)+2;
    else if((x < 0 && y < 0) && x > y) cout << (absll(x-y)+2);
    else if((x < 0 && y < 0) && x < y) cout << (absll(x-y));
    else cout << (absll(x+y)+1);
    return 0;
}


Measured memory_bytes: 3536
n=input()
m=input()
x=len(n)

y=len(m)

dp=[[0 for i in range(y+1)] for j in range(x+1)]
#print(len(dp),len(dp[0]))
for i in range(0,x+1):
  for j in range(0,y+1):
    if(i==0 or j==0):
      dp[i][j]=0
    elif n[i-1]==m[j-1]:
      dp[i][j]=1+dp[i-1][j-1]
    else:
      dp[i][j]=max(dp[i-1][j],dp[i][j-1])
j=y
i=x
ans=""
#print(i,j)
while i>0 and j>0:
    if(n[i-1]==m[j-1]):
        #print(n[i-1],m[j-1])
        ans=ans+n[i-1]
        #print(n[i-1],1)
        i=i-1
        j=j-1
    else:
        mx=max(dp[i-1][j],dp[i][j-1])
        if mx==dp[i-1][j]:
            i=i-1
        else:
            j=j-1
print(ans[::-1])


Measured memory_bytes: 119772
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int big,regu,nob,ci,su,t;
    while(cin>>big>>regu>>nob>>ci>>su>>t,big,regu,nob,ci,su,t)
        cout<<100+ci*2+nob*7+regu*63+big*95-(t-su)*3<<endl;
}

Measured memory_bytes: 1156
l, r = [int(i) for i in input().split()]

base = 2019
l_mod = l % base
r_mod = r % base

if r - l >= base:
    print(0)
elif r_mod <= l_mod:
    print(0)
else:
    # print(l_mod * (l_mod + 1))
    ans = base
    for i in range(l, r+1):
        for j in range(i+1, r+1):
            ans = min(ans, (i*j) % base)
    print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef pair<Int,Int> P;

Int D;
vector<Int> C(26);
vector<vector<Int>> S(365, vector<Int>(26));


// 各日における満足度の配列を返す関数
vector<Int> score(vector<int> schedule){
    vector<int> last_day(26, 0); // 各コンテストを最後に行った日

    vector<Int> res(D, 0);

    rep(d,D){
        int type = schedule[d]-1; // その日に行われるコンテスト

        res[d] += S[d][type];
        rep(i,26){
            if(i == type) continue;
            res[d] -= C[i] * (d+1 - last_day[i]);
        }
        last_day[type] = d+1;

        if(d != D-1) res[d+1] += res[d];
    }

    return res;
}

int main(){
    cin >> D;
    rep(i,26) cin >> C[i];
    rep(i,D) rep(j,26) cin >> S[i][j];

    vector<int> t(D);
    rep(i,D){
        cin >> t[i];
    }

    vector<Int> sc = score(t);
    rep(i,D) cout << sc[i] << endl;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
int main(){
	int a,b,c,d;
	a=read(),b=read(),c=read(),d=read();
	if(a+b<c+d) printf("Right\n");
	else if(a+b>c+d) printf("Left\n");
	else printf("Balanced\n");
	return 0;
}

Measured memory_bytes: 256
n = int(input())
d = {}
for i in range(n):
  s = input()
  if s in d:
    d[s] += 1
  else:
    d[s] = 1
max_d = max(d.values())
d = sorted(d.items(), key = lambda x : x[0])
for i in range(len(d)):
  if d[i][1] == max_d:
    print(d[i][0])

Measured memory_bytes: 44764
n,k = map(int, input().split())
a = 0
b = 0
c = 0
kk = k // 2
for i in range(1,n+1):
    d = 2*i
    if k % 2 == 0 and i % k == kk:
        a += 1
    if i % k == 0:
        b += 1
    if (k % 2 == 0 and i % k == kk) and i % k == 0:
        c += 1

print(a**3 + b**3 - c**3)
# print(a,b,c)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    auto c = make_vec<char>(2, 3);
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }
    if (c[0][0] == c[1][2] && c[1][0] == c[0][2] && c[0][1] == c[1][1]) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
}


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

typedef long long ll;

#define mp make_pair
#define pb push_back
#define ff first
#define ss second

int main() {
	ios_base::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	cout << (1 << M) * ((M * 1900) + ((N - M) * 100));
	
	
}



Measured memory_bytes: 256
from operator import itemgetter
n=int(input())
ab=[list(map(int,input().split())) for i in range(n)]
ab.sort(key=itemgetter(1))
now=0
ans="Yes"
for i in ab:
    a,b=i[0],i[1]
    now+=a
    if now>b:
        ans="No"
        break

print(ans)

Measured memory_bytes: 53732
import math
D, G = map(int, input().split())
P, C = [], []
for _ in range(D):
    p, c = map(int, input().split())
    P.append(p)
    C.append(c)

ans = float('inf')
for i in range(2**D):
    score = 0
    cnt = 0
    max_zero = 0
    # print(bin(i))
    # b = bin(i)[2:][::-1]
    # print(b)
    # for j, c in enumerate(b):
    for j in range(D):
        x = (i >> j) & 1
        # x = int(c)
        if x == 1:
            cnt += P[j]
            score += 100 * (j + 1) * P[j] + C[j]
        else:
            max_zero = j
    if G <= score:
        ans = min(ans, cnt)
    else:
        diff = G - score
        base = 100 * (max_zero + 1)
        if P[max_zero] <= math.ceil(diff / base):
            continue
        else:
            cnt += math.ceil(diff / base)
            ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 41456
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
using namespace std;

int main() {
	double a,b;
	cin >> a >> b;
	cout << ceil((a + b) / 2) << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using System.Text;
 
class DandA {
    static void Main(string[] args) {
        int n = ReadLineInt();
        Console.WriteLine((n/2) + (n%2));
    }
 
    static string Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
    static string[] strAry = new string[] {"L", "R", "U", "D"};
    static int[] intArray = new int[10];
    static List<int> intList = new List<int>();
  
    static private string ReadLineStr() {return Console.ReadLine();}
    static private int ReadLineInt() {return int.Parse(Console.ReadLine());}
    static private long ReadLineLong() {return long.Parse(Console.ReadLine());}
    static private double ReadLineDouble() {return double.Parse(Console.ReadLine());}
    static private string[] ReadLineStrArray() {return Console.ReadLine().Trim().Split();}
    static private int[] ReadLineIntArray() {return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToArray();}
    static private long[] ReadLineLongArray() {return Console.ReadLine().Trim().Split().Select(a => long.Parse(a)).ToArray();}
    static private double[] ReadLineDoubleArray() {return Console.ReadLine().Trim().Split().Select(a => double.Parse(a)).ToArray();}
    static private decimal[] ReadLineDecimalArray() {return Console.ReadLine().Trim().Split().Select(a => decimal.Parse(a)).ToArray();}
    static private List<int> ReadLineIntList() {return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToList();}
    static private List<long> ReadLineLongList() {return Console.ReadLine().Trim().Split().Select(a => long.Parse(a)).ToList();}
    static private string[][] ReadMLineStrArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split()).ToArray();}
    static private int[][] ReadMLineIntArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();}
 
    static private bool IsPrime(int num) {
        if (num < 2) return false;
        if (num == 2) return true;
        else if (num % 2 == 0) return false;
        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2) {
            if (num % i == 0) return false;
        }
        return true;
    }
  
    static private string IntToNString(int x, int n) {
        var nstring = "";
        var numbers = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
        int r = 1;
        int q = x;
        while (q > 0) {
            r = q % n;
            nstring += numbers[r];
            q = q / n;
        }
        return string.Join("",nstring.Reverse());
     }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> state;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }
int ceil(int a,int b){
  // a/bの切り上げを考える
  return (a+b-1)/b;
}

int main() {
  char alpha;
  cin >>alpha;
  cout << (('a' <= alpha and alpha <= 'z')?'a':'A') << endl;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int n,mx,mn,a[100005];
int main()
{
	scanf("%d",&n);
	mx=-1e9+7;
	mn=1e9+7;
	for(int i=0;i<n;i++)
	{
		int x;
		scanf("%d",&x);
		a[x]++;
		mx=max(mx,x);
		mn=min(mn,x);
	}
	if(mx-mn>1)puts("No");
	else if(mx==mn)
	{
		if(mx==n-1||n>=2*mx)puts("Yes");else puts("No");
	}
	else
	{
		if(mx>a[mn]&&a[mx]>=2*(mx-a[mn]))puts("Yes");else puts("No");
	}
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define inf 1000000000
#define eb emplace_back
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef map<int,int> mii;
int bp[1000001];
int exhaust(int n)
{
    int i=0;
    while(n%2==0){
        n>>=1;
        i++;
    }
    return i;
}
int main()
{
    int i,j,k;
    int n;
    string str;
    cin>>n>>str;
    bp[0]=0;
    for(i=1;i<n;i++){
        bp[i]=bp[i-1]+exhaust(n-i)-exhaust(i);
    }
    int sum=0;
    for(i=0;i<str.length();i++)
        sum+=(bp[i]==0)*(str[i]-'1');
    if(sum&1){
        printf("1");
        return 0;
    }
    for(i=0;i<str.length();i++){
        if(str[i]=='2'){
            printf("0");
            return 0;
        }
    }
    sum=0;
    for(i=0;i<str.length();i++)
        sum+=(bp[i]==0)*(str[i]-'1')/2;
    if(sum&1)
        printf("2");
    else
        printf("0");

}


Measured memory_bytes: 5252
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct Node{
  int key;
  struct Node *l,*r,*p;
};

void insert(int );
void inorder(struct Node *);
void preorder(struct Node *);

struct Node *root,*NIL;

int main(){
  int n,i,h;
  char x[10];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",x);
    if(0==(strcmp(x,"print"))){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }else if(0==(strcmp(x,"insert"))){
      scanf("%d",&h);
      insert(h);
    }   
     }
    return 0;
  }


void insert(int k){
  struct Node *x=root,*y=NIL,*z;

  z=(struct Node *)malloc(sizeof(struct Node));

  z->key=k;
  z->l=NIL;
  z->r=NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key) x=x->l;
    else    x=x->r;
  }
  z->p=y;
  if(y==NIL) root=z;
  else{
    if(z->key < y->key) y->l=z;
    else  y->r=z;
  }
}

void inorder(struct Node *u){
  if(u==NIL) return;
  inorder(u->l);
  printf(" %d",u->key);
  inorder(u->r);
}

void preorder(struct Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->l);
  preorder(u->r);
}



Measured memory_bytes: 25140
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <iomanip>
#include <cmath>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>

#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define ll long long 
//#define int long long
#define ld long double
#define vi deque<int>
#define pb push_back
#define ff first
#define ss second
#define ii pair<int,int>
#define iii pair<int,ii>
#define il pair<int,ll>
#define pll pair<ll,ll>
#define _path pair<ll,pair<ll,int> > 
#define vv deque
//#define endl '\n'
//#define mp make_pair

using namespace std;

const int MAXN = 1+5;
const int MOD = 1e9+7;

void solve(){
	int n;
	cin >> n;
	string s1,s2;
	cin >> s1 >> s2;
	ll tot = 1;
	int last = -1;
	FOR(i,n){
		if(last == -1){
			if(s1[i] == s2[i]){
				tot *= 3;
				last = 1; // col
			}else{
				i++;
				tot *= 6;
				last = 2; // row
			}
		}else if(last == 1){
			if(s1[i] == s2[i]){
				tot *= 2;
				tot %= MOD;

			}else{
				i++;
				tot *= 2;
				tot %= MOD;
				last = 2;
			}
		}else{
			if(s1[i] == s2[i]){
				last = 1;
			}else{
				i++;
				tot *=3;
				tot %= MOD;

			}
		}
		tot %= MOD;
	}
	cout << tot%MOD << endl;
}

void test(int x){
	x += MOD*2;
	while(x > 1){
		FORE(i,2,x){
			if(x%i == 0){
				cout << i <<  " " ;
				x /= i;
				break;
			}
		}
		cout << endl;
	}
}



/*
void solve3(){
	int n;
	cin >> n;
	int arr[3*n];
	FOR(i,3*n)cin >> arr[i];
	ll pref[3*n];
	ll suf[3*n];
	// phase1;
	ll sum = 0;
	set<int> s;
	FOR(i,3*n){
		s.insert(arr[i]);
		s += arr[i];
		if(s.size() > n){
			s -= *(s.begin());
			s.erase(s.begin());
		}
		if(s.size() == n){
			pref[i] = sum;
		}else{
			pref[i] = 0;
		}
	}
	// pahse 2;
	sum = 0;
	s.clear();
	for(int i = 3*n-1;i>=0;i--){
		s.insert(-arr[i]);
		s += arr[i];
		if(s.size() > n){
			s += *(s.begin());
			s.erase(s.begin());
		}
		if(s.size() == n){
			pref[i] = sum;
		}else{
			pref[i] = 0;
		}
	}

}*/

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	test(958681902);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	return 0;
}

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

#ifdef LOCAL
#define dbg(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define dbg(...) 17;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) { return os << "(" << p.first << ", " << p.second << ")"; }
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) { bool f = true; os << "{"; for (const auto &x : c) { if (!f) os << ", "; f = false; os << x; } return os << "}"; }
template<typename T> void debug(string s, T x) { cerr << s << " = " << x << "\n"; }
template<typename T, typename... Args> void debug(string s, T x, Args... args) { cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...); }

int main() {
    const ll INF = 1e16;
    int n; cin >> n;
    vector<ll> a(n + 1);
    for (int i = 0; i <= n; i++) {
        cin >> a[i];
    }
    auto fail = [&]() {
        cout << -1 << '\n';
        exit(0);
    };
    vector<ll> post(n + 1);
    for (int i = n; i >= 0; i--) {
        if (i == n) post[i] = a[i];
        else post[i] = post[i + 1] + a[i];
    }
    ll ans = 0;
    ll level = 1;
    for (int i = 0; i <= n; i++) {
        level = min(level, post[i]);
        ans += level;
        level -= a[i];
        if (level < 0) {
            fail();
        }
        level *= 2;
        level = min(level, INF);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 5000
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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 INF=1e10;
int MOD=1e9+7;
signed main(){
  int a;
  cin>>a;
  string b;
  cin>>b;
  int c=0,d=0,e=0;
  rep(i,a){
  if(b[i]=='R')
    c++;
  else if(b[i]=='G')
    d++;
  else
    e++;
  }int m=0;
  for(int i=1;i<=(a-1)/2;i++){
    for(int j=0;j<=a-1-2*i;j++){
      if(b[j]!=b[i+j]&&b[i+j]!=b[2*i+j]&&b[2*i+j]!=b[j])
         m++;
    }
    }
    cout<<c*d*e-m<<endl;
}


Measured memory_bytes: 3596
# C - All Green

D, G = map(int, input().split())
P = [tuple(map(int, input().split())) for _ in range(D)]

ans = 10**18
for i in range(1<<D):
    tmp = 0
    cnt = 0
    for j in range(D):
        if (i>>j)&1:
            p, c = P[j]
            tmp += p * (j+1) * 100 + c
            cnt += p
    if tmp >= G:
        ans = min(ans, cnt)
    else:
        xor_i = i^((1<<D)-1)
        for k in range(D)[::-1]:
            if (xor_i)>>k&1:
                p, c = P[k]
                for _ in range(p):
                    tmp += (k+1) * 100
                    cnt += 1
                    if tmp >= G:
                        ans = min(ans, cnt)
                        break
                else:
                    break
                break

print(ans)


Measured memory_bytes: 9268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)

int main(){
  int h,w;
  cin>>h>>w;
  char a[110][110];
  bool b[110]={},c[110]={},f=0;
  fr(i,h) fr(j,w) cin>>a[i][j];
  fr(i,h) fr(j,w) if(a[i][j]=='#') b[i]=1;
  fr(j,w) fr(i,h) if(a[i][j]=='#') c[j]=1;
  fr(i,h){
    if(!b[i]) continue;
    fr(j,w){
      if(c[j]) cout<<a[i][j];
    }
    cout<<endl;
  }
}

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

#define var auto
#define ll long long
//#define APPLY(a, f) f(a.begin(), a.end())
#define APPLY(a, f, ...) f(a.begin(), a.end(), __VA_ARGS__)
#define FUN1(x, f) [&](auto& x){return f;}
#define FUN2(x, y, f) [&](auto& x){return f;}
using namespace std;

string s;

set<int> solve(int& ind){
    vector<set<int>> num{};
    vector<char> op{};
    int curnum = -1;
    while (true){
        var c = s[ind];
        if (c == '+' || c == '-' || c == '*' || c == '/'){
            if (curnum != -1) { num.push_back(set<int>{curnum}); curnum = -1; }
            op.push_back(c);
            goto end;
        }
        if ('0' <= c && c <= '9'){
            if (curnum == -1) curnum = 0;
            curnum = curnum * 10 + (c - '0');
            goto end;
        }
        if (c == '('){
            ind++;
            num.push_back(solve(ind));//かっこをよしなに
            goto end;
        }
        if (c == ')'){
            if (curnum != -1) { num.push_back(set<int>{curnum}); curnum = -1; }
            //ここでマージ処理
            vector<vector<set<int>>> dp(num.size(), vector<set<int>>(num.size(), set<int>{}));
            for (int i = 0; i < num.size(); i++){
                dp[i][i] = num[i];
            }
            for (int sz = 2; sz <= num.size(); sz++){
                for (int i = 0; i <= num.size() - sz; i++){
                    for (int j = i; j < i + sz - 1; j++){
                        for (auto&& elem1 : dp[i][j]){
                            for (auto&& elem2 : dp[j + 1][i + sz - 1]){
                                bool flag = false;
                                int opres;
                                switch (op[j]){
                                    case '+':
                                        opres = elem1 + elem2;
                                        break;
                                    case '-':
                                        opres = elem1 - elem2;
                                        break;
                                    case '*':
                                        opres = elem1 * elem2;
                                        break;
                                    case '/':
                                        if (elem2 == 0) { flag = true;
                                            break; }
                                        opres = elem1 / elem2;
                                        break;
                                }
                                if (flag) continue;
                                dp[i][i + sz - 1].insert(opres);
                            }
                        }
                    }
                }
            }
            return dp[0][num.size() - 1];
        }
        end:;
        ind++;
    }
}



int main() {
    while (true){
        cin >> s;
        if (s == "#") return 0;
        s = s + ")";
        int ind = 0;
        cout << solve(ind).size() << endl;
    }
}


Measured memory_bytes: 3320
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int maxDiff = Integer.MIN_VALUE;
        int min = sc.nextInt();
        for (int i = 1; i < n; i++) {
            int r = sc.nextInt();
            maxDiff = Math.max(maxDiff, r - min);
            min = Math.min(min, r);
        }

        System.out.println(maxDiff);
    }
}


Measured memory_bytes: 68952
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f
#define pi 3.1415926535898
using namespace std;
const int N=2e5+10;
const int mod=1e9+7;
map<ll,ll> mp;
int main()
{
    ll sum=0;
    ll ans=0;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        ans+=x;
        if(ans==0)
        {
            sum+=mp[ans]+1;
        }
        else
        {
            sum+=mp[ans];
        }
        mp[ans]++;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 16068
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
bool sortbysec(const pair<ll,ll> &a, 
              const pair<ll,ll> &b) 
{ 
    return (abs(a.first-a.second) >abs(b.first- b.second)); 
} 
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();
//ll t;cin>>t;while(t--)
{
    ll n,atotal=0,btotal=0,f=1;
    cin>>n;
    ll a[n],b[n];
    for(int i=0;i<n;i++)
    {
      cin>>a[i];
      atotal+=a[i];
    }
    vector<pair<ll,ll> >v,vv;
    for(int i=0;i<n;i++)
    {
      cin>>b[i];
      if(a[i]!=b[i])
        f=0;
      if(a[i]>b[i])
        v.pb(mp(a[i],b[i]));
      if(a[i]<b[i])
        vv.pb(mp(a[i],b[i]));



      btotal+=b[i];
    }
    if(f)
      cout<<0<<endl;
    else if(atotal<btotal)
      cout<<-1<<endl;
    else
    {ll ans=0;
      sort(v.begin(), v.end(), sortbysec);
      sort(vv.begin(), vv.end(), sortbysec); 

     // for(auto t:v)cerr<<t.fi<<" "<<t.se<<endl;
        //for(auto t:vv)cout<<t.fi<<" "<<t.se<<endl;
          auto t=v.begin();
        auto tt=vv.begin();
        ll cur=0;
        while(tt!=vv.end())
        {
          cur+=t->fi-t->se;
         ans++;
         //cout<<"Cur = "<<cur<<endl;
         while(cur>0&&tt!=vv.end())
         {

           ll req=tt->se-tt->fi;
           ans++;
           if(req>cur)
           {
            while(cur<req)
            {
              t++;
              cur+=t->fi-t->se;
              ans++;
            }
           }
           cur-=req;
           tt++;
         }

       }

cout<<ans<<endl;

      }
}
return 0;
}

Measured memory_bytes: 3828
using System;
using System.Collections.Generic;
using System.Linq;

namespace ALDS1_4C{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            var N = sr.Next<int>();
            var Q = sr.Next<string>(N, 2).Select(a => new {Command = a[0], Str = a[1]});

            var hs = new HashSet<string>();
            foreach(var q in Q){
                if(q.Command == "insert"){
                    hs.Add(q.Str);
                }
                else if(q.Command == "find"){
                    Console.WriteLine(hs.Contains(q.Str) ? "yes" : "no");
                }
            }
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = Console.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var ret = new T[x];
            for(var i = 0; i < x; ++i) ret[i] = Next<T>();
            return ret;
        }

        public T[][] Next<T>(int y, int x){
            var ret = new T[y][];
            for(var i = 0; i < y; ++i) ret[i] = Next<T>(x);
            return ret;
        }
    }
}

Measured memory_bytes: 203432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    ll n;   cin >> n;
    if(!(n%1000)) cout << 0 << endl;
    else cout << 1000-n%1000 << endl;
}


Measured memory_bytes: 3620