akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let H: usize = sc.get();
    let W: usize = sc.get();
    let mut a: Vec<Vec<i64>> = sc.mat(H, W);
    let mut ans = Vec::new();
    for i in 0..H {
        for j in 0..W {
            if a[i][j] % 2 != 0 {
                if j + 1 < W {
                    a[i][j] -= 1;
                    a[i][j+1] -= 1;
                    ans.push(((i+1, j+1), (i+1, j+2)));
                } else if i + 1 < H {
                    a[i][j] -= 1;
                    a[i+1][j] -= 1;
                    ans.push(((i+1, j+1), (i+2, j+1)));
                }
            }
        }
    }
    println!("{}", ans.len());
    for ((i1, j1), (i2, j2)) in ans {
        println!("{} {} {} {}", i1, j1, i2, j2);
    }
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 305;
int n, m, l, r;
int h, w, d;
int a[N][N];
ll psum[N * N];
ii b[N * N];
inline int dist(int to, int from) {
    auto [x1, y1] = b[to];
    auto [x2, y2] = b[from];
    return abs(x1 - x2) + abs(y1 - y2);
}
int main() {
    cin >> h >> w >> d;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> a[i][j];
            b[a[i][j]] = {i, j};
        }
    }
    for (int i = d + 1; i <= h * w; ++i) {
        psum[i] = psum[i - d] + dist(i, i - d);
    }
    cin >> m;
    for (int i = 0; i < m; ++i) {
        cin >> l >> r;
        cout << psum[r] - psum[l] << endl;
    }
    return 0;
}


Measured memory_bytes: 5388
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int n,x,a[N];
bool vis[N];
int main()
{
	scanf("%d%d",&n,&x);
	if (x==1||x==2*n-1) return puts("No"),0;
	a[n-1]=x-1;a[n]=x;a[n+1]=x+1;
	vis[x-1]=vis[x]=vis[x+1]=1;
	int p=1;
	for (int i=1;i<=2*n-1;i++)
	if (!a[i]){
		while (vis[p]) p++;
		a[i]=p++;
	}
	puts("Yes");
	for (int i=1;i<=2*n-1;i++) printf("%d\n",a[i]);
	return 0;
}

Measured memory_bytes: 2304
//2019.8.24 by ljz
//email 573902690@qq.com
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f
#define unl __int128
#define eps 5.6e-8
#define RG register
#define db double
#define pc(x) __builtin_popcount(x)
typedef pair<int,int> Pair;
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define ull unsigned LL
#define gc getchar
//inline char gc() {
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
inline int read() {
    res s=0,ch=gc();
    while(ch<'0'||ch>'9')ch=gc();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s;
}
//inline int read() {
//    res s=0,ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline void write(RG unl x){
//    if(x>10)write(x/10);
//    putchar(int(x%10)+'0');
//}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//clock_t start=clock();
//inline void ck(){
//    if(1.0*(clock()-start)/CLOCKS_PER_SEC>0.1)exit(0);
//}
namespace MAIN{
    int m,d;
    int ans;
    inline void MAIN(){
        m=read(),d=read();
        for(res i=1;i<=m;i++){
            for(res j=1;j<=d;j++){
                if((j%10)*(j/10)==i&&(j%10)>=2&&(j/10)>=2)ans++;
            }
        }
        printf("%d\n",ans);
    }
}
int main(){
//    srand(19260817);
//    freopen("signin.in","r",stdin);
//    freopen("signin.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
// #include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
  int a, b, c;
  vb reach(60, false);
  cin >> a >> b >> c;

  int t = 0;
  int aa = a;
  while(true) {
    if(reach[t % 60]) goto END;
    reach[t % 60] = true;
    REP(i, a){
      t++;
      if(t % 60 == c) goto END;
    }
    t += b;
  }
END:;
  cout << (t % 60 == c ? t : -1) << endl;
}

Measured memory_bytes: 3096
#include <algorithm>
#include <array>
#include <bitset>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
//region cp_helper
using namespace std;
#define _io ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define vi vector<int>
#define vvi vector< vector<int> >
#define vll vector<ll>
#define vii vector<ii>
#define in(n) cin >> n
#define out(n) cout << n
#define outs(n) cout << n << ' '
#define outn(n) cout << n << '\n'
#define vin(a, n) for (int i=0; i<n; i++) in(a[i])
#define viin(a, n) for (int i=0; i<n; i++) in(a[i].first) >> a[i].second;
#define vout(a) for (auto i : a) outs(i)
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qdsort(a) sort(all(a), greater<>())
#define pp(a, b) emplace_back(make_pair(a, b))
const int mod = (int)(1e9) + 7;
//endregion

using namespace std;

int n, m, s[100005], c, total, p=0;
int main() { _io
    in(n); in(m);
    vii arr(n);
    viin(arr, n);
    qsort(arr);
    multiset<int> ms;
    for (int i=1; i<=m; i++) {
        while (p<n && arr[p].first <= i) {
            ms.insert(arr[p].second);
            p++;
        }
        if (!ms.empty()) {
            total += *ms.rbegin();
            ms.erase(--ms.end());
        }

    }
    out(total);
}


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


int main() {
    int n;
	cin >> n;
    int w[n];
    int sum=0;
    int nowsum=0;
    int ans=100000;
   fr(i,n){
     cin >> w[i];
     sum+=w[i];
   }
    fr(i,n){
     nowsum+=w[i];
     if(ans>abs(sum-2*nowsum))ans = abs(sum-2*nowsum);
   }
    cout << ans << endl;
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    int X,t;
    cin >> X >> t;
    cout << max(X - t,0) << endl;

    return 0;
}


Measured memory_bytes: 888
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

const int kN = 700 + 5;
int n, m;
bool graph[kN][kN];
int side[kN];
int cnt[2];
std::vector<std::pair<int, int>> vec;
bool dp[kN][kN];

bool dfs(int u) {
  cnt[side[u] - 1] ++;
  for (int v = 0; v < n; ++ v) if (graph[u][v]) {
    if (side[v]) {
      if (side[v] == side[u])
        return false;
    } else {
      side[v] = side[u] ^ 3;
      if (!dfs(v))
        return false;
    }
  }
  return true;
}

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++ i) {
    for (int j = 0; j < n; ++ j)
      graph[i][j] = i != j;
  }
  for (int i = 0; i < m; ++ i) {
    int a, b;
    scanf("%d%d", &a, &b); -- a; -- b;
    graph[a][b] = graph[b][a] = false;
  }
  for (int i = 0; i < n; ++ i) if (side[i] == 0) {
    cnt[0] = cnt[1] = 0;
    side[i] = 1;
    if (!dfs(i))
      return puts("-1"), 0;
    vec.emplace_back(cnt[0], cnt[1]);
  }
  dp[0][0] = true;
  int s = 0;
  for (const auto& pair : vec) {
    int a = pair.first;
    int b = pair.second;
    for (int i = s; i >= 0; -- i) {
      for (int j = s; j >= 0; -- j) if (dp[i][j]) {
        dp[i + a][j + b] = true;
        dp[i + b][j + a] = true;
      }
    }
    s += std::max(a, b);
  }
  int result = 0;
  for (int i = 0; i <= s; ++ i) {
    for (int j = 0; j <= s; ++ j) if (dp[i][j]) {
      result = std::max(result, i * j);
    }
  }
  result = m - (result - (n * (n - 1) / 2 - m));
  printf("%d\n", result);
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
int bit[maxn],n,b[maxn];
int get(int idx){
    int sum=0;
    while(idx>0){
        sum+=(bit[idx]);
        idx-=(idx&(-idx));
    }
    return sum;
}
void update(int idx,int val){
    while(idx<=n){
        bit[idx]+=val;
        idx+=(idx&(-idx));
    }
    return;
}
vector<int> a;


int main(){
    scanf("%d",&n);
    a.push_back(-1);
    for(int i=1;i<=n;i++){
        scanf("%d",&b[i]);
        a.push_back(b[i]);
    }
    sort(a.begin(),a.end());
    a.erase(unique(a.begin(),a.end()),a.end());
    int ans=0;
    for(int i=1;i<=n;i++){
            int id=lower_bound(a.begin(),a.end(),b[i])-a.begin();
        if(get(id-1)==0){
            ans++;
            update(id,1);
            continue;
        }
        int pos=0,val=0,c=get(id-1);
        for(int i=19;i>=0;i--){
            if(pos+(1<<i)<=n&&val+bit[pos+(1<<i)]<c){
                pos+=(1<<i);
                val+=bit[pos];
            }
        }
        pos++;
        update(pos,-1);
        update(id,1);
    }
    printf("%d\n",ans);
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 1528
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {  
 
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		long stocks = 0;
		long[] a = new long[N];
		for (int i = 0; i < N; i++) a[i] = I.nextLong();
		long price = a[0];
		long max = 0; //Highest local bidder
		long ans = 1000; //Money
		for (int i = 1; i < N; i++) {
			if (a[i]<a[i-1]&&max==0) price=a[i];
			else if (a[i]<a[i-1]&&max!=0) {
				stocks+=ans/price;
				ans%=price;
				ans+=stocks*max;
				stocks=0; //Sold all
				price=a[i];
				max=0;
			}
			else if (a[i]>a[i-1]) {
				max=a[i];
			}
		}
		//O.pln(ans);
		if (max>0) {
			stocks+=ans/price;
			ans%=price;
			ans+=stocks*max;
			stocks=0; //Sold all
			max=0;
		}
		O.pln(ans);
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 25636
#include <iostream>
#include <algorithm>
using namespace std;
int d[1000000];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>d[i];
	}
	sort(d,d+n);
	cout<<(d[n/2]-d[n/2-1]);
}

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

#define ll  long long
#define PII pair<ll,ll>
#define VI  vector<ll>
#define VB  vector<bool>
#define VC vector<char>
#define VVI vector<vector<ll>>
#define VVC vector<vector<char>>
#define VS  vector<string>
#define VP  vector<PII>
#define lf(i,a,b) for(ll i=a;i<=b;i++)
#define lr(i,a,b) for(ll i=a;i>=b;i--)
#define lfl(i,v) for(ll i=0;i<v.size();i++)
#define lrl(i,v) for(ll i=(ll)(v.size())-1;i>=0;i--)
#define chk2(a,b) cout<<"check :  "<<a<<" "<<b<<endl
#define chk3(a,b,c) cout<<"check :  "<<a<<" "<<b<<" "<<c<<endl
#define chk4(a,b,c,d) cout<<"check :  "<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define chk5(a,b,c,d,e) cout<<"check :  "<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl
#define l_b(v,k)  lower_bound(v.begin(),v.end(),k)-v.begin()
#define u_b(v,k)  upper_bound(v.begin(),v.end(),k)-v.begin()
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define p_b push_back
#define p_f push_front
#define m_p make_pair
#define fir first
#define sec second
#define sz size()
ll n,m,k;
ll dp[3005][3005];
VI v;
ll fun(ll str,ll end)
    {   if(str>end)
            return 0;
        if(dp[str][end]!=-1)
            return dp[str][end];
        return dp[str][end]=max(v[str]+min(fun(str+1,end-1),fun(str+2,end)),v[end]+min(fun(str,end-2),fun(str+1,end-1)));
    }
int main() 
{   cin>>n;
    v=VI(n+1);
    memset(dp,-1,sizeof(dp));
    ll sum=0;
    lf(i,1,n)
    {   cin>>v[i];sum+=v[i];}
    cout<<fun(1,n)-(sum-fun(1,n))<<endl;
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string a, b, c;
  cin >> a >> b >> c;

  if (a.back() == b.front() && b.back() == c.front()) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define TRUE  1
#define FALSE 0

#define SPADE 'S'
#define HEART 'H'
#define CLUB  'C'
#define DIA   'D'

#define PRI_SPADE 0
#define PRI_HEART 1
#define PRI_CLUB  2
#define PRI_DIA   3

#define MAX_RANK 13
#define MAX_TYPE 4
#define MAX_CARD  MAX_RANK * MAX_TYPE

int main(void)
{
        char type;
        int card, rank;
        int card_set[MAX_TYPE][MAX_RANK] = {
                { FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE },
                { FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE },
                { FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE },
                { FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE },
        };

        scanf("%d", &card);

        if(card > MAX_CARD) return -1;

        for(int h=0; h < card; h++)
        {

                scanf(" %c %d", &type, &rank);

                if(rank > MAX_RANK) return -1;

                switch(type)
                {
                        case SPADE:
                                card_set[PRI_SPADE][rank-1] = TRUE;
                                break;
                        case HEART:
                                card_set[PRI_HEART][rank-1] = TRUE;
                                break;
                        case CLUB:
                                card_set[PRI_CLUB][rank-1] = TRUE;
                                break;
                        case DIA:
                                card_set[PRI_DIA][rank-1] = TRUE;
                                break;
                        default:
                                printf("error\n");
                                return -1;
                }
        }


        for(int i=0; i < MAX_TYPE; i++)
        {
                for(int j=0; j < MAX_RANK; j++)
                {
                        if(card_set[i][j] == FALSE)
                        {
                                switch(i)
                                {
                                        case PRI_SPADE:
                                                printf("%c %d\n", SPADE, j + 1);
                                                break;
                                        case PRI_HEART:
                                                printf("%c %d\n", HEART, j + 1);
                                                break;
                                        case PRI_CLUB:
                                                printf("%c %d\n", CLUB,  j + 1);
                                                break;
                                        case PRI_DIA:
                                                printf("%c %d\n", DIA,   j + 1);
                                                break;
                                        default:
                                                break;
                                }
                        }
                }
        }

        return 0;

}


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

using namespace std;

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

	for (int i = 1; i <= 9; ++i){
		int num = i*100 + i*10 + i;
		if(N <= num){
			cout << num << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String str = br.readLine();
    
    StringTokenizer st = new StringTokenizer(str);
    
    int a = Integer.parseInt(st.nextToken());
    int b = Integer.parseInt(st.nextToken());
    int c = Integer.parseInt(st.nextToken());
    
    int max = Integer.max(a, b);
    max = Integer.max(max, c);
    
    System.out.println(a+b+c-max);
  }

}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

void Main() {
    int K;
    ll ans = 0;
    cin >> K;
    rep(i, K){
        rep(j, K){
            ll tmp = gcd(i+1, j+1);
            rep(l, K){
                ans += gcd(tmp, l+1);
            }
        }
    }
    cout << ans << endl;
}


int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3640
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]
LONG = 1900
SHORT = 100
N, M = MAP()

sh = (N-M)*SHORT
lo = M*LONG
prob = 2**M
#print(sh, lo, prob)
print((sh+lo)*prob)

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

ll SUM(vector<ll>&& vec){return accumulate(all(vec),0LL);} // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
bool isPrime(ll n); // 素数か
vector<ll> primes(ll n); // 素因数分解
int ctoi(char c){return c - '0';}

const ll COM_MAX = (ll)(1e6+100); // combinationの最大値
vector<ll> fac(COM_MAX),finv(COM_MAX),inv(COM_MAX);
void comb_init(); // 初期化
ll comb(ll n,ll k); // nCk

// TODO: write
int main() { 
  int n,m;cin>>n>>m;
  vector<string> a(n),b(m);
  rep(i,n)cin>>a[i];rep(i,m)cin>>b[i];
  bool has = false;
  rep(i,n-m+1){
    rep(j,n-m+1){
      rep(k,m){
        if(a[i+k].substr(j,m) == b[k]){
          has = true;
        }else{
          has = false;
          break;
        }
      }
      if(has)break;
    }
    if(has)break;
  }
  print(has?"Yes":"No");
  return 0;
}

void comb_init(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<COM_MAX;++i){
    fac[i]=fac[i-1]*i%INF;
    inv[i]=INF-inv[INF%i]*(INF/i)%INF;
    finv[i]=finv[i-1]*inv[i]%INF;
  }
}

ll comb(ll n,ll k){
  if(n<k)return 0;
  if(n<0||k<0)return 0;
  return fac[n]*(finv[k]*finv[n-k]%INF)%INF;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}
vector<ll> primes(ll n){
  vector<ll> v;
  for (ll i = 2; i*i <= n; ++i) {
    while(n%i==0){
      n/=i;
      v.pb(i);
    }
  }
  if(n != 1)v.pb(n);
  return v;
}


/* 二分探索の時に使う
template<typename T>bool isOk(T key,T value){
  return key <= value;
}
template<typename T>T binary_search(vector<T> a,T key){
  T ok = a.size();
  T ng = -1;
  while(abs(ok - ng) > 1){
    T mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}
*/

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

const int maxn = 500005;
int a[maxn], last[maxn], f[maxn], ans[maxn];

struct Query {
	int l, r, id;
	bool operator<(const Query &Q) const {
		return r < Q.r;
	}
};
Query b[maxn];

void upd(int id, int val) {
	while(id < maxn) f[id] += val, id += id&-id;
}
int sum(int id) {
	int res = 0;
	while(id > 0) res += f[id], id -= id&-id;
	return res;
}

signed main() {
	
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int n, q;
	cin >> n >> q;
	
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	
	for(int i = 0; i < q; i++) {
		cin >> b[i].l >> b[i].r;
		b[i].id = i;
	}
	
	sort(b, b + q);
		
	for(int i = 0; i < maxn; i++) {
		last[i] = -1;
	}
	
	int idx = 0;
	for(int i = 1; i <= n; i++) {
		
		if(last[a[i]] != -1)
			upd(last[a[i]], -1);
		
		last[a[i]] = i;
		upd(i, 1);
		
		while(idx < q && b[idx].r == i) {
			ans[b[idx].id] = sum(b[idx].r) - sum(b[idx].l - 1);
			idx++;
		}
	}
	
	for(int i = 0; i < q; i++) {
		cout << ans[i] << "\n";
	}
}


Measured memory_bytes: 17460
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll K, N;
  cin >> K >> N;
  vl A(N);
  rep(i, N) cin >> A[i];

  vl dif(N);
  rep(i, N - 1){
    dif[i] = A[i + 1] - A[i];
  }
  dif[N - 1] = A[0] + (K - A[N - 1]);

  stable_sort(dif.begin(), dif.end());

  cout << K - dif[N - 1] << endl;
  
  return 0;
}

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

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

    int ans = 0;
    rep(i, 101) {
        if (i >= a && i < b && i >= c && i < d) ans++;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a * b;
        int length = 2 * a + 2 * b;
        System.out.println(area + " " + length);
        sc.close();
    }
}


Measured memory_bytes: 26144
fun main(args: Array<String>) {
    val (H, W) = listOfInt()
    val S = Array(H) { next() }
    val HH = Array(H) { IntArray(W) }
    val WW = Array(H) { IntArray(W) }
    val DOT = '.'
    for (h in 0 until H) {
        var w = 0
        while (w < W) {
            if (S[h][w] == DOT) {
                var c = w
                while (c < W && S[h][c] == DOT) c++
                val sum = c - w
                while (w < c) WW[h][w++] = sum
            } else w++
        }
    }
    for (w in 0 until W) {
        var h = 0
        while (h < H) {
            if (S[h][w] == DOT) {
                var c = h
                while (c < H && S[c][w] == DOT) c++
                val sum = c - h
                while (h < c) HH[h++][w] = sum
            } else h++
        }
    }
  //WW.print()
  //HH.print()
    var ans = 0
    for (h in 0 until H)
        for (w in 0 until W)
            ans = Math.max(ans, WW[h][w] + HH[h][w] - 1)
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun Array<IntArray>.print(title: String = "") {
    System.err.println(if (title.length > 0) title else this)
    for ((index, array) in this.withIndex()) {
        System.err.print("[${index}] ")
        System.err.println(array.joinToString(separator = ", "))
    }
}

Measured memory_bytes: 85392
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/

int n;
signed main() {
	cin >> n;
	int sum = 0;
	rep(i, n) {
		int a; cin >> a;
		sum ^= a;
	}
	if (!sum)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>

int main()
{
	int i,num,ans[50]={};
	scanf("%d",&num);

	ans[1]=1;
	ans[2]=2;

	for(i=1;i<num;i++){
		ans[i+2]=ans[i+1]+ans[i];
	}

	printf("%d\n",ans[num]);
}




Measured memory_bytes: 2104
def main():
    import sys
    input = sys.stdin.readline
    import numpy as np
    from collections import Counter
    N = int(input())
    A = np.array(list(map(int, input().split())))

    count = 0

    tmp = np.arange(N)
    X = A-tmp
    Y = A+tmp

    # print(X)
    # print(Y)
    XX = Counter(list(X))
    YY = Counter(list(Y))

    count = 0
    # print(XX)
    # print(YY)
    for number, c in XX.items():
        count += YY[-number] * c
        # count +=
    print(count)


if __name__ == "__main__":
    main()


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

using namespace std;


#define PI 3.14159265
#define int long long



main(){


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

	x--, y--;

	vector < vector <int> > d(n, vector <int>(n));

	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			d[i][j] = abs(j - i);
		}
	}

	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			d[i][j] = min(d[i][j], d[i][x] + 1 + d[y][j]);
			d[i][j] = min(d[i][j], d[i][y] + 1 + d[x][j]);
		}
	}

	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			d[i][j] = min(d[i][j], d[i][x] + 1 + d[y][j]);
			d[i][j] = min(d[i][j], d[i][y] + 1 + d[x][j]);
		}
	}

	map <int, int> cnt;

	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n; j++){
			cnt[d[i][j]]++;
		}
	}


	for(int i = 1; i < n; i++){
		cout << cnt[i] << endl;
	}



	
	
	
	return 0;
}

Measured memory_bytes: 31744
#include <iostream>
#include <vector>
using namespace std;
int main(void){
     
    // 正解した問題の数を「　positiveNumber　」と置く
    int positiveNumber;
    cin >> positiveNumber;
     
    // 各、問題の得点を「　score　」と配列で置く
    vector<int> score( positiveNumber );
     
    // 各、問題の得点を入力する
    for(int i = 0; i < positiveNumber; i++) cin >> score[i];
     
    // 得点の最大値を「　maxScore = 1　」と置く。
    // 何故：maxScore = 1　を代入したか　maxScore は 答えが 1 ～ positiveNumber の間にあるから
    int maxScore = positiveNumber;
     
    // 今回のスコア算出の計算と条件
    while(1){
         
        // 正解が A 問以上の個数を「 count 」と置く
        int count = 0;
         
        // 得点が A 以上である個数を求める
        for(int i = 0; i < positiveNumber; i++){
            if(maxScore <= score[i]) count++;
        }
         
        // 問題の条件：得点が A 以上であるものが A 問以上あることを満たすような最大の A そのチームのスコア
        if(maxScore <= count){
            cout << maxScore << endl;
            break;
        }
         
        // 次の最大値 maxScore になるように　+1する
        maxScore--;
    }
     
}


Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <math.h>
using namespace std;
int main()
{
    int a, b, counter=0;
    cin >> a >> b;
    for(int i = a; i <= b; ++i){
        if( (i/10000 == i%10)  && ((i/1000)%10 == i/10%10 )) counter++;
    }
    cout << counter;
    return 0;
}


Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
ll dp[2][4];
int now = 0;
int t[3];
ll p2[32];
bool use[100010];
void Sequence() {

	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b) {
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;
}
int main() {
	Sequence();
	return 0;
}



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

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N);
    rep(i, 0, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
    }
    vector<int> ans(N + 1);
    function<void(int)> bfs = [&](int x) {
        queue<int> Q; Q.push(x);
        vector<int> parent(N, -1);
        vector<int> depth(N);
        while(!Q.empty()) {
            int cur = Q.front(); Q.pop();
            for(auto &to : G[cur]) {
                if(parent[to] != -1) continue;
                Q.push(to);
                parent[to] = cur;
                depth[to] = depth[cur] + 1;
                if(to == x) {
                    vector<int> tmp;
                    int i = to;
                    rep(j, 0, depth[to]) {
                        tmp.push_back(i);
                        i = parent[i];
                    }
                    if(ans.size() > tmp.size()) {
                        ans = tmp;
                        return;
                    }
                }
            }
        }
    };
    rep(i, 0, N) bfs(i);
    if(ans.size() == N + 1) cout << -1 << '\n';
    else {
        cout << ans.size() << '\n';
        for(auto a : ans) cout << a + 1 << '\n';
    }
    return 0;
}


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

int main() 
{
  int A, B, sum = 0;
  cin >> A >> B;
  sum = max(A, B);
  if (A > B)
    A--;
  else 
    B--;
  sum += max(A, B);
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>                                                      
using namespace std;
int main()
{
  int N;
  cin >> N;
  int count=0;
  int ans=0;
  for(int i=0; i<=N; i++){
    int j=i;
    while(j!=0){
      j/=10;
      count++;
    }
    if(count%2!=0){
      ans++;
    }
    count=0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

Int Ceil(Int a, Int b) {
    if (a % b == 0) {
        return a / b;
    } else {
        return Floor(a, b) + 1;
    }
}

Int digits(Int n) {
    return (Int)to_string(n).size();
}

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

    int n;
    Ld d;
    cin >> n >> d;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        Ld x, y;
        cin >> x >> y;

        if (hypot(x, y) <= d) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
  int N, Y, check;
  cin >> N >> Y;
  int c = Y/1000;
  check = 0;
  for(int i=0; i<=N; i++){
    for(int j=0; j<=N-i; j++){
      int k = N-i-j;
      if(c == 10*i+5*j+k*1){
        cout << i << " " <<  j << " " << k << endl;
        check += 1;
        break;
      }
    }
    if(check == 1){
      break;
    }
  }
  if(check==0){
    cout << -1 << " " <<  -1 << " " << -1 << endl;
  }
}

Measured memory_bytes: 256
using System;

namespace AtCoderAbc160
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var x = int.Parse(s);

            var p = new Problem2();
            Console.WriteLine(p.GetAnswer(x));
        }
    }


    public class Problem2
    {
        public long GetAnswer(int total)
        {
            var count500 = total / 500;
            total -= count500 * 500;
            var count5 = total / 5;
            return count500 * 1000L + count5 * 5L;
        }
    }
}


Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//??\???????????????
		int X = sc.nextInt();
		//X???3???
		int XX = X * X * X;
		
		//int XX = X^3;
		//??¨???
		System.out.println(XX);
	}
}

Measured memory_bytes: 26108
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define print(x) cout<<(x)<<endl
#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


int main(){
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end(), greater<int>());
	if (s < t)print("Yes");
	else print("No");





	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
ll dp[100005];
int main()
{
    int n;
    cin >> n;
    ll a = 6;
    vector<int> v;
    v.push_back(1);
    rep(i,10){
        v.push_back(a);
        a *= 6;
    }
    a = 9;
    rep(i,9){
        v.push_back(a);
        a *= 9;
    }
    fill(dp, dp + 100005, INF);
    sort(v.rbegin(), v.rend());
    dp[0] = 0;
    rep(i,v.size()){
        rep(j,100005){
            if(dp[j]==INF)
                continue;
            if(j+v[i]<=n){
                dp[j + v[i]] = min(dp[j + v[i]], dp[j] + 1);
            }
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
  int R[MAX], n;

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

  int maxv = -2000000000;
  int minv = R[0];

  for(int i = 1; i < n; i++){
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }

  cout << maxv << endl;
  return 0;
}



Measured memory_bytes: 3860
import java.util.Scanner;

public class Main {
private static int[][]daoyu;
private static int count;
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        while (true) {
            int x = input.nextInt();
            int y = input.nextInt();
            if (x == 0 && y == 0) {
            	break;
            	}
            daoyu = new int [y+2][x+2];
            for(int i = 1;i<=y;i++) {
            	for(int j = 1;j<=x;j++) {
            		daoyu[i][j]=input.nextInt();
            		}
            }
            for (int i=0; i<y+2; i++){
            	daoyu[i][0] = daoyu[i][x+1] = 0;
         
            for (int j=0; j<x+2; j++){
            	daoyu[0][j] = daoyu[y+1][j] = 0;
 
            count = 1;
            }
        }
        for (int i = 1; i <= y; i++) {
            for (int j = 1; j <=x; j++) {
                if (daoyu[i][j] == 1) {
                    count++;
                    lj(i, j);
                }
            }
        } 
        System.out.println(count-1);
        daoyu=null;
    }
    }
    private static void lj(int i, int j) {
    	 daoyu[i][j] = count;
         for(int a=-1; a<=1; a++) {
             for (int b=-1; b<=1; b++) {
                 if (daoyu[i+a][j+b] == 1) lj(i+a, j+b);
             }
         }
     }
 
}


Measured memory_bytes: 45200
n = gets.to_i
stones = gets.chomp.split('')

answer = 0

change_r = 0
change_w = 0

if stones.any? { |stone| stone == 'W' }
  red = stones.count { |stone| stone == 'R' }
  stones.each.with_index(1) do |stone, i|
    if i <= red
      change_r += 1 if stone == 'W'
    else
      change_w += 1 if stone == 'R'
    end
  end

  answer = change_r + change_w - [change_r, change_w].min
end

puts answer


Measured memory_bytes: 30564
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const double eps = 1e-7;
#define endl '\n'
#define pb(a) push_back(a)
#define al(x) x.begin(), x.end()
#define sz(x) int(x.size())
#define IOS ios::sync_with_stdio(0);

int main() {
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int solve(string s)
{
	int res = 0, p = 0;

	vector<char> st;
	st.clear();

	s = s + "n";

	for(int i = 0; i < (int)s.size(); i++)
	{
		if( s[i] == 'J' )
		{
			if( i > 0 && s[i-1] != 'J' )
			{
				p = 0;
				st.clear();
			}

			if( p == 0 )
				st.push_back('J');
			else
			{
				st.clear();
				p = 0;
			}
				
		}
		else if( s[i] == 'O' )
		{
			if( !st.empty() )
			{
				st.pop_back();
				p++;
			}
			else
			{
				st.clear();
				p = 0;
			}
		}
		else if( s[i] == 'I' && p != 0)
		{
			if(i+p >= (int)s.size())
				break;

			string x = string(s.begin()+i, s.begin()+i+p);
			string y = string(p, 'I');

			if( x == y )
			{
				res = max(res, p);
				i += p-1;
				p = 0;
				st.clear();
			}
			else
			{
				st.clear();
				p = 0;
			}
		}
		else
		{
			st.clear();
			p = 0;
		}
	}
	
	return res;
}

int main()
{
	string s;

	while( cin >> s, !cin.eof())
	{
		cout << solve(s) << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 3584
#include  <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

vector<pii> ans;

int main(){
	  while(1){
	  
			int N,M; cin >> N >> M;
			if(!N) break;
			ans.clear();
			for(int i=0; i<N; i++){
				  int d,p; cin >> d >> p;
				  ans.push_back(pii(p,d));
			}
			sort(ans.begin(),ans.end());
			long long sum=0;
			while(M > 0 and ans.size()){
				  int id = ans.size()-1;
				  if( M > ans[id].second ){
						M -= ans[id].second;
						ans.pop_back();
				  }
				  else if(M > 0){
						ans[id].second -= M;
						M = 0;
				  }
			}

			for(auto x : ans){
				  sum += x.first * x.second;
			}
			cout << sum << endl;
	  
	  
	  }
}

Measured memory_bytes: 3188
a, b, c = map(int, input().split())
if a <= b and b <= c:
    print(a, b, c)
elif a <= c and c <= b:
    print(a, c, b)
elif b <= a and a <= c:
    print(b, a, c)
elif b <= c and c <= a:
    print(b, c, a)
elif c <= a and a <= b:
    print(c, a, b)
else:
    print(c, b, a)
    


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[202020];

ll hoge(ll a) {
	ll tot=0;
	int i;
	FOR(i,N) tot+=abs(A[i]-(a+i));
	return tot;
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>A[i];
	
	ll L=-1LL<<40,R=1LL<<40;
	while(R-L>=4) {
		ll m1=(2*L+R)/3;
		ll m2=(L+2*R)/3;
		
		ll v1=hoge(m1);
		ll v2=hoge(m2);
		if(v1==v2) L=m1,R=m2;
		else if(v1<v2) R=m2;
		else L=m1;
	}
	
	ll ret=1LL<<60;
	for(ll a=L;a<=R;a++) ret=min(ret,hoge(a));
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
	int H, W, i, j;
	
	while(1){
		cin >> H >> W;
		if(H == 0 && W == 0){
			break;
		}
		for(i = 0; i < H; i++){
			for(j = 0; j < W; j++){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;	
}

Measured memory_bytes: 3104
n = gets().chomp.split('')

cnt = 1
n.each_with_index do |chr, i|
  next if i == 0
  if chr == n[i - 1]
    cnt += 1
    break if cnt >= 3
  else
    cnt = 1
  end
end

puts cnt >= 3 ? 'Yes' : 'No'

Measured memory_bytes: 14396
#include <stdio.h>
#include <stdlib.h>

#define MAX 2147483647

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

int main(){
    int n,i,k,j;
    int h[100100];
    int dp[100100] = {0};

    scanf("%d %d",&n,&k);

    for(i = 1; i <= n ; i++){
        scanf("%d",&h[i]);
        dp[i] = MAX;
    }
    dp[1] = 0;
    dp[2] = abs(h[1] - h[2]);
    for(i = 3 ; i <= n ; i++){
        dp[i] = min(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
        for(j = 2; j <= k ; j++){
            if(i - j >= 1){
            dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
            }
        }
    }
    printf("%d\n",dp[n]);
    return 0;


}

Measured memory_bytes: 896