akhauriyash/Code-Regression huggingface dataset:
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(s: String);
    let mut s: Vec<char> = s.chars().collect();
    let mut ans:Vec<u64> = vec![0; s.len() + 1];
    
    let mut i = s.len() as isize - 1;
    while i >= 0 {
        if s[i as usize] == '>' {
            let mut k = i - 1;
            let mut cnt = 1;
            ans[i as usize + 1] = 0;
            while k>=0 && s[i as usize] == s[k as usize] {
                ans[k as usize + 1] = cnt;
                cnt += 1;
                k -= 1;
            }
            i = k;
        } else {
            i -= 1;
        }
    }
    let mut i = 0;
    while i < s.len() {
        if s[i as usize] == '<' {
            ans[i + 1] = ans[i] + 1;
            if i + 2 <= s.len() && ans[i + 1] <= ans[i + 2] {
                ans[i + 1] = ans[i + 2] + 1;
            }
        }
        i += 1;
    }
    ans[0] = if s[0] == '>' { ans[1]+1 } else { 0 };
    //println!("{:?}",ans);
    println!("{}", ans.iter().fold(0, |sum, x| sum + x));
}


Measured memory_bytes: 12024
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
#include <queue>

using namespace std;

const char *X, *Y;
int X_length, Y_length;

int table_lcs[1001][1001];

int lcs(int x_begin, int y_begin) {
	int i, j, to;
	int max = 0;
	int v_lcs;
	bool alreadySeenTable[256];
	if (table_lcs[x_begin][y_begin] != -1) {
		return table_lcs[x_begin][y_begin];
	}
	
	for (i = 0; i < 256; i++) {
		alreadySeenTable[i] = false;
	}
	i = x_begin;
	to = Y_length-1;
	while(i <= X_length-1) {
		j = y_begin;
		if (alreadySeenTable[X[i]] == true) {
			i++;
			continue;
		}
		bool found = false;
		while (j <= to) {
			if (X[i] == Y[j]) {
				v_lcs = lcs(i + 1, j + 1) + 1;
				if (v_lcs > max) {
					max = v_lcs;
				}
				found = true;
				break;
			}
			else {
				j++;
			}
		}
		if (found == false) {
			alreadySeenTable[X[i]] = true;
			i++;
		}
		else {
			alreadySeenTable[X[i]] = true;
			i++;
			to = j - 1;
		}
	}
	return table_lcs[x_begin][y_begin] = max;
}

int lcs2(int x_begin, int y_begin) {
	int i, j, to;
	int max = 0;
	int v_lcs;
	if (table_lcs[x_begin][y_begin] != -1) {
		return table_lcs[x_begin][y_begin];
	}

	i = x_begin;
	to = Y_length - 1;
	while (i <= X_length - 1) {
		j = y_begin;
		bool found = false;
		while (j <= to) {
			if (X[i] == Y[j]) {
				v_lcs = lcs2(i + 1, j + 1) + 1;
				if (v_lcs > max) {
					max = v_lcs;
				}
				found = true;
				break;
			}
			else {
				j++;
			}
		}
		if (found == false) {
			i++;
		}
		else {
			i++;
			to = j - 1;
		}
	}
	return table_lcs[x_begin][y_begin] = max;
}

int main() {

	int N;
	cin >> N;
	string stringX, stringY;

	for (int i = 1; i <= N; i++) {
		for (int i = 0; i < 1001; i++) {
			for (int j = 0; j < 1001; j++) {
				table_lcs[i][j] = -1;
			}
		}
		cin >> stringX >> stringY;
		X = stringX.c_str();
		X_length = stringX.size();
		Y = stringY.c_str();
		Y_length = stringY.size();
		printf("%d\n", lcs2(0, 0));
	}
	return 0;
}

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

//https://codeforces.com/blog/entry/12079
#define ll unsigned long long
#define FASTIO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;

const ll maxn = 1e8;
const int MOD = 1e9+7;

int main(){
    FASTIO
    
    int n,m;cin >> n >> m;
    vector<bool> wrong(n+1);
    for(int i=0;i<m;i++){
    	int x;cin >> x;
    	wrong[x] = true;
    	if((wrong[x] && wrong[x-1]) || (wrong[x] && wrong[x+1])){
    		cout << 0;
    		return 0;
    	}
    }
    vector<ll> ans(n+1);
    if(!wrong[1]) ans[1] = 1ll;
    if(!wrong[2]){
    	
    	if(!wrong[1]) ans[2] = 2ll;
    	else ans[2] = 1ll;
    }
    for(int i=3;i<=n;i++){
    	
    	if(!wrong[i-1]) ans[i] += ans[i-1];
    	if(!wrong[i-2]) ans[i] += ans[i-2];
    	
    	if(wrong[i-1]) ans[i] = ans[i-2];
    	if(wrong[i-2]) ans[i] = ans[i-1];
    	
    	ans[i] %= MOD;
    }
    cout << ans[n];
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <cstdlib>
#include <math.h>

using namespace std;

typedef long long ll;
#define rep(i, n) for(long (i) = 0; (i) < (long) (n); (i)++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,a,b) for(long i=(a);i<(b);i++)
#define rrep1(i,a,b) for(long i=(a);i<=(b);i++)
#define rrrep(i,a,b) for(long i=(a);i>=(b);i--)
#define define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define X first
#define Y second
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int> >
#define vpl vector<pair<long, long> >
#define vppl vector<pair<long, pair<long, long> > >

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const ll LINF = 1e18;

int printYes() {
    cout << "Yes" << endl;
    return 0;
}

int printNo() {
    cout << "No" << endl;
    return 0;
}

int ans;

int printAns() {
    cout << ans << endl;
    return 0;
}


int pow(int x) {
	if (x == 0) {
		return 1;
	}
	else {
		return pow(x - 1) * 2;
	}
}

int main(int argc, char const *argv[])
{
    int a,b;
    cin >> a >> b;
    int c;
    c = b - a;
    int n = 0;
    rep(i, c){
        n += i;
    }
    cout << n - a;
    return 0;
}


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

ll Pow(ll a, ll b, ll c){
    ll ans = 1;
    a %= c;
    while (b){
        if (b & 1) ans = (ans * a) % c;
        a = (a * a) % c;
        b >>= 1;
    }
    return (ans % c);
}

bool cmp(const int &a, const int &b){
    return a > b;
}

int gcd(int x, int y){
    return x % y == 0 ? y : gcd(y, x % y);
}

const int mod = 1e9 + 7;
 long long c[2005][2005];

int main(){
    int n, k;
    scanf("%d%d", &n, &k);
    c[0][0] = 1;
    for (int i = 1; i <= n; i++){
        c[i][0] = 1;
        for (int j = 1; j <= i; j++)
            c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
    }
    for (int i = 1; i <= k; i++)
        printf("%lld\n", c[n - k + 1][i] * c[k - 1][i - 1] % mod);
    return 0;
}


Measured memory_bytes: 30080
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
using namespace std;
 

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pb push_back
#define forn(i, n) for (int i = 0; i < n; ++i)
#define int long long

 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
 
 
const int MAXN = 1e5 + 5;
const ll MOD = 998244353;
const ll INF = INT64_MAX;


random_device rd;
mt19937 rnd(rd());


ll pw(ll a, ll x) {
	ll res = 1;
	while (x > 0) {
		if (x & 1) {
			res = (res * a) % MOD;
		}
		a = (a * a) % MOD;
		x >>= 1;
	}
	return res;
}


int a[MAXN];
int pref[MAXN];
int n;


int get(int x) {
	int ans = 0;
	forn(i, n) {
		int j = lower_bound(a, a + n, x - a[i]) - a;
		ans += (n - j);
	}
	return ans;
}


signed main() {
	FAST_IO;
	int m;
	cin >> n >> m;
	forn(i, n) {
		cin >> a[i];
	}
	sort(a, a + n);
	forn(i, n) {
		pref[i] = a[i];
		if (i != 0) {
			pref[i] += pref[i - 1];
		}
	}
	int l = 1, r = 2e5 + 1;
	while (l + 1 < r) {
		int mid = (l + r) >> 1;
		if (get(mid) < m) {
			r = mid;
		} else {
			l = mid;
		}
	}
	int ans = 0;
	int l1 = l;
	if (get(l) > m) {
		while (get(l) > m) {
			l++;
		}
		ans += (m - get(l)) * l1;
	}
	forn(i, n) {
		int j = lower_bound(a, a + n, l - a[i]) - a;
		ans += max(0ll, a[i] * (n - j) + pref[n - 1] - (j == 0 ? 0 : pref[j - 1]));
	}
	cout << ans << "\n";
 	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include<string>
using namespace std;
int main(){
    int A,B,C,X;
    cin>>A>>B>>C>>X;
    int count=0;
    for(int i=0; i<=A; i++){
        for(int j=0; j<=B; j++){
            for(int k=0; k<=C; k++){
                if(i*500+j*100+k*50==X){
                    count++;
                }
            }
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

// Round Table
// 2012/12/15
public class Main{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

	int INF=1<<28;
	double EPS=1e-12;

	int n, m;
	int[] a;

	void run(){
		try{
			String[] ss=br.readLine().split(" ");
			n=Integer.parseInt(ss[0]);
			m=Integer.parseInt(ss[1]);
			ss=br.readLine().split(" ");
			a=new int[n];
			for(int i=0; i<n; i++){
				a[i]=Integer.parseInt(ss[i]);
			}
			solve();
		}catch(IOException e){}
	}

	int logM;
	int[] sum;
	int[][] dp;

	void solve(){
		logM=31-Integer.numberOfLeadingZeros(m)+1;
		dp=new int[logM][3*n];
		sum=new int[3*n];
		for(int i=0; i<3*n-1; i++){
			sum[i+1]=sum[i]+a[i%n];
		}
		int left=0, right=(int)1e8;
		for(; right-left>1;){
			int mid=(left+right)/2;
			if(check(mid)){
				right=mid;
			}else{
				left=mid;
			}
		}
		println(right+"");
	}

	boolean check(int t){
		if(t==0){
			return false;
		}
		for(int i=0; i<logM; i++){
			fill(dp[i], -1);
		}
		for(int i=0; i<3*n; i++){
			int index=binarySearch(sum, sum[i]+t);
			if(index<0){
				index=-index-1;
				index--;
			}
			dp[0][i]=index;
		}
		for(int j=1; j<logM; j++){
			for(int i=0; i<3*n; i++){
				dp[j][i]=dp[j-1][dp[j-1][i]];
			}
		}
		for(int i=0; i<n; i++){
			int now=i;
			for(int b=0; b<logM; b++){
				if((m>>b&1)==1){
					now=dp[b][now];
				}
			}
			if(now-i>=n){
				return true;
			}
		}
		return false;
	}

	void println(String s){
		System.out.println(s);
	}

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

Measured memory_bytes: 21000
import java.util.Scanner;

public class Main {

	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		while(in.hasNextInt()==true){
			int n = in.nextInt();
			int m = in.nextInt();
			int l=n;
			int k=m;
			int r=0;
			if(m>n){
				r=n;
				n=m;
				m=r;
			}
			while(m!=0){
				n=n%m;
				r=n;
				n=m;
				m=r;
				}
			System.out.print(n+" ");
			System.out.println(l/n*k);
		}
	}
		
}
				

Measured memory_bytes: 12000
#include<stdio.h>
#include<queue>
int main(){
	std::queue<int>q;
	int w,h,f[484],i,j,d[]={22,0,-1,0,1,0,-22},a,b,t,x,z;
	char p[15];
	for(;scanf("%d%d ",&h,&w),h;){
		for(j=0;j<w+2;j++)f[j]=f[j-~h*22]=-9;
		for(i=1;i<=h;i++){
			for(j=1;j<=w;j++){
				f[x=i*22+j]=-1;
				switch(getchar()){
					case'#':--f[x];break;
					case'A':a=x;break;
					case'B':b=x;break;
				}
			}
			f[i*22]=f[i*22-~w]=-9;
			getchar();
		}
		
		f[a]=t=0;
		q.push(0);
		for(q.push(a);q.size()>1;){
			a=q.front();
			q.pop();
			if(a){
				for(i=0;i<7;i+=2)
					if(f[x=a+d[i]]==-1)
						f[x]=t,q.push(x);}
			else
				++t,q.push(0);
		}
		q.pop();
		scanf("%s",p);
		for(a=t=0;!a;){
			x=b;
			z=0;
			for(i=0;!a&&p[i];i++){
				t++;
				f[j=b+d[p[i]-'2']]>-3?b=j:0;
				f[b]>=0&&t>=f[b]?a=b:0;
				f[b]>=0&&++z;
			}
			!z&!a&!p[i]&b==x&f[b]<0&&--a;
		}
		printf(a<0?"impossible\n":"%d %d %d\n",t,a/22-1,a%22-1);
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int w,h,x,y;
    cin >> w >> h >> x >> y;
    if(x*2 == w && y*2 == h)
        cout << std::setprecision(7) <<float(w)*h/2 << ' '<< 1;
    else
        cout << std::setprecision(7) <<float(w)*h/2<< ' '<< 0;
    return 0;
}

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

int main(){
    // A~Z: 65~90   a~z: 97~122
    bool unko=1;
    int count=0;
    while(unko){
        string s;
        cin >> s;
        if (s=="") {unko=0;}
        else if (1<=count) {cout << " ";}
        for (int i=0; i<s.size(); i++){
            if (65<=s.at(i) && s.at(i)<=90) {s.at(i)+=32;}
            else if (97<=s.at(i) && s.at(i)<=122) {s.at(i)-=32;}
        }
        cout << s;
        count++;
    }
    cout << endl;
}


Measured memory_bytes: 3152
/* 実行時間1s制限の場合10^6 1,000,000 : 余裕をもって間に合う10^7
  10,000,000 : おそらく間に合う10^8 100,000,000 : 非常にシンプルな処理
  でないと厳しい
 */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // Greatest Common Divisor ユークリッドの互除法（aが長辺）
vector<pair<ll,int>> factorize(ll n) {            // a,bの公約数 = GCD(a, b)の約数
    vector<pair<ll,int>> res;
    for (ll i = 2; i*i <= n; i++) { // √nまで探せばよい
        if (n%i) continue;
        res.emplace_back(i, 0);     // 割り切れたら
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1); // この時点で1でなかったら、残りは素数.
    return res;
}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}         // Least Commont Multiple オーバーフローしないように先に割る
ll ceil(ll a, ll b) {return (a+b-1)/b;}

const ll INF = LONG_MAX;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(int argc, char* argv[])
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    // std::ifstream in(argv[1]);
    //std::cin.rdbuf(in.rdbuf());
    //std::ifstream in(string(argv[0]) + ".txt");
    std::ifstream in("in.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

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



    return 0;
}

/*
  - 1e9 : 10^9
  - container一般
    - 合計
      accumulate(a.begin(), a.end(), 0LL)  0LLはオーバーフロー用
  - vector
    vector<int> A(N, 0); // 0で初期化(省略可)
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
      - vector<vector<int>> cnt(h, vector<int>(w))
    - sort(struct)
        struct st_t {
            string name;
            int p;
            bool operator<(const st_t& another) const {
                if (name == another.name)
                {
                    return p > another.p;
                }
                return name < another.name;
            }
        };
        vector<st_t> st(n);
        sort(st.begin(), st.end());
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
    - pair<pair<string,int>,int> p[110];
      std::sort(p,p+a);
        こうすると、first.first -> first.second -> secondの順にソートされる
    - sort
      - sort(a.begin(), cb.end(), greater<pair<int, int>>());
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - priority_queue<int> q;
    - q.top()に最大値が入っている
  - string
    - loop
      for (char& c : s) {}
 */



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

using namespace std;

#define mp make_pair
#define pb push_back
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ULL;
const LL mod=1e9+7;
const int INF=0x3f3f3f3f;
const double PI=acos(-1.0);
const double EPS=1e-10;
inline int readint(){int sum=0;char c=getchar();bool f=0;while(c<'0'||c>'9'){if(c=='-') f=1;c=getchar();}while(c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return f?-sum:sum;}
inline LL readLL(){LL sum=0;char c=getchar();bool f=0;while(c<'0'||c>'9'){if(c=='-') f=1;c=getchar();}while(c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return f?-sum:sum;}

int a[100005];

int main(){//ios_base::sync_with_stdio(0);cin.tie(0);
    int n=readint();
    for(int i=0;i<n;i++){
        int x=readint();a[x]++;
    }
    int ans=0;
    for(int i=1;i<=100000;i++) ans=max(ans,a[i-1]+a[i]+a[i+1]);
    printf("%d\n",ans);
    return 0;
}

//cout.setf(ios::fixed);
//cout<<fixed<<setprecision(10)<<s<<endl;


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    string s,ans = {};
    cin >> s;
    for(int i = 0;i < s.length();i++){
        if(s[i] == '0') ans += '0';
        else if(s[i] == '1') ans += '1';
        else if(ans.length() != 0) ans.erase(ans.end()-1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define inf 1e18
#define mod pow(10,9)+7
#define mii map<int,int>
#define pii pair<int,int>
#define setbits(x) __builtin_popcountll(x)
void c_p_c()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef  ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int32_t main()
{
	c_p_c();
	int s, w;
	cin >> s >> w;
	if (w >= s) cout << "unsafe";
	else cout << "safe";
	return 0;
}

Measured memory_bytes: 3640
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    sc.close();

    if (A <= B * 2) {
      System.out.println(0);
    } else {
      System.out.println(A - (B * 2));
    }

  }

}

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

int main(){
  double a, b, x; cin >> a >> b >> x;
  double h; h = x/pow(a,2.0);
  double ex; ex = b-h;
  double theta, deg;
  if(h >= b/2){
    theta = atan(2*ex/a);
    deg = theta*180/M_PI;
  }else{
    double tmp = 2*x/(a*b);
    theta = atan(tmp/b);
    deg = 90 - theta*180/M_PI;
  }
  cout << setprecision(10) << deg << endl;
  return 0;
}

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

int main(){
  ll R,G,B,N,cnt=0;
  cin>>R>>G>>B>>N;
  for(int i=0;i*R<=N;i++){
    for(int j=0;j*G<=N;j++){
      if(R*i+G*j<=N&&(N-R*i-G*j)%B==0) cnt++;
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;
int T;


const int MAX_ROW = 205; // to be set appropriately
const int MAX_COL = 205; // to be set appropriately
struct BitMatrix {
    int n, m;
    bitset<MAX_COL> val[MAX_ROW];
    BitMatrix(int n_ = 1, int m_ = 1) {n = n_; m = m_;}
    inline bitset<MAX_COL>& operator [] (int i) {return val[i];}
    inline friend ostream& operator << (ostream& s, BitMatrix M) {
        s << endl;
        for (int i = 0; i < M.n; ++i) {
            for (int j = 0; j < M.m; ++j) s << M.val[i][j];
            s << endl;
        }
        return s;
    }
};

int linear_equation(BitMatrix A, vector<int> b) {
    int rank = 0;
    for (int i = 0; i < A.n; ++i) { A[i][A.m] = b[i]; }

    for (int i = 0; i < A.m; ++i) {
        int pivot = -1;
        for (int j = rank; j < A.n; ++j) {
            if (A[j][i]) {
                pivot = j;
                break;
            }
        }
        if (pivot != -1) {
            swap(A[pivot], A[rank]);
            for (int j = 0; j < A.n; ++j) if (j != rank && A[j][i]) A[j] ^= A[rank];
            ++rank;
        }
    }

    for (int i = rank; i < A.n; ++i) if (A[i][A.m]) return -1; // 解なし   
    return rank;
};

void solve(){
    int N;
    ll A_[200];
    string S;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A_[i];
    }
    int cnt = 0;
    cin >> S;
    int a = 0;
    for(char c : S){
        if(c == '0') a++;
    }
    BitMatrix BM(62, a);
    for(int i = 0; i < a; i++){
        for(int j = 0; j < 62; j++){
            BM[j][i] = 0;
        }
    }
    // cout << a << endl;
    for(int i = N-1; i >= 0; i--){
        if(S[i] == '1'){
            vector<int> b(62);
            for(int j = 0; j < 62; j++){
                if(((ll)1<<j)&A_[i]) b[j] = 1;
            }
            if(linear_equation(BM, b) == -1){
                cout << 1 << endl;
                return;
            }
            // cout << linear_equation(BM, b)  << endl;
        }else if(S[i] == '0'){
            // cout << i << endl;
            for(int j = 0; j < 62; j++){
                if(((ll)1<<j)&A_[i]){
                    BM[j][cnt] = 1;
                    // BM[cnt][j] = 1;
                }else{
                    BM[j][cnt] = 0;
                }
            }
            cnt++;
            // cout << i << "=========" << endl;
            // for(int j = 0; j < cnt; j++){
            //     for(int k = 0; k < 62; k++){
            //         cout << BM[k][j];
            //     }
            //     cout << endl;
            // }
        }
    }
    cout << 0 << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> T;
    for(int i = 0; i < T; i++){
        solve();
    }
}

Measured memory_bytes: 3676
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)






int main() {
	int X;
	cin >>X;
	string s = "No";
	if (X % 10 == 9||X/10==9) {
		s = "Yes";
	}
	cout <<s<< endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N,M;cin>>N>>M;
  vector<ll> a(N);
  rep(i,N) cin>>a[i];

  SORT(a);

  ll ans = 0;
  ll left = -1, right = 1e18;
  while(right-left > 1){
    ll middle = (left + right )/ 2;
    //cout<<left<<" "<<right<<" "<<middle<<endl;
    //左手ごとに条件を満たす右手が何個あるか保存する
    vector<ll> cnt(N);
    //左手ごとにjustのものの個数を調べる
    vector<ll> just(N);
    rep(i,N){
      cnt[i] = a.end() - upper_bound(a.begin(), a.end(), middle - a[i]);
      just[i] = POSU(a,middle - a[i]) - POSL(a,middle - a[i]);
    }

    ll count = 0, tmp = 0;
    rep(i,N) count += cnt[i];
    rep(i,N) tmp += just[i];

    //cout<<"count is" <<" "<<count<<endl;

    if(count > M) left = middle;
    else if(count + tmp < M){
      //足りない時
      right = middle;
    }
    else{
      rep(i,N){
        ans += cnt[i]*a[i];
      }
      ans *= 2;
      ans += (M - count) * middle;
      cout<<ans<<endl;
      return 0;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 2652
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

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

using ll = long long;
using P = std::pair<ll, ll>;

ll N;
std::map<std::string, ll> mp;

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

  rep( i, N )
  {
    std::string S;

    std::cin >> S;

    ++mp[S];
  }

  std::cout << mp.size() << std::endl;

  return 0;
}

Measured memory_bytes: 18852
#include <bits/stdc++.h>
// #include <sys/types.h> 
// #include <unistd.h> 
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=50,M=5*1e6;
int dp[N][N];
int fac[M];
int add(int a,int b)
{
      a+=b;
      if(a>=MOD) a-=MOD;
      return a;
}
int sub(int a,int b)
{
      a-=b;
      if(a<0) a+=MOD;
      return a;
}
int mul(int a,int b)
{     
      return ((long long)a*b)%MOD;
}
int rev(int a)
{
  return mpow(a,MOD-2);
}
int b1(int x,int y)
{
  int ans=fac[x+y];
  ans=mul(ans,rev(fac[2*y]));
  ans=mul(ans,rev(fac[x-y]));
  return ans;
}
int b2(int x,int y)
{
  int ans=fac[x+y-1];
  ans=mul(ans,rev(fac[2*y-1]));
  ans=mul(ans,rev(fac[x-y]));
  return ans;
}
int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);

      fac[0]=1;
      for(int i=1;i<M;i++) fac[i]=(fac[i-1]*i)%MOD;
      // cout<<b1(2,1);
      // return 0;
      int x,y;
      cin>>x>>y;
      dp[0][0]=1;
      for(int i=0;i<N;i++)
      {
        for(int j=0;j<N;j++)
        {
          if(i+1<N&&j+2<N) dp[i+1][j+2]+=dp[i][j];
          if(j+1<N&&i+2<N) dp[i+2][j+1]+=dp[i][j];
        }
      }
      // for(int i=0;i<20;i++)
      // {
      //   for(int j=0;j<20;j++)
      //   {
      //     cout<<dp[i][j]<<" ";
      //   }
      //   cout<<"\n";
      // }
      if(x%2==0)
      {
        int yl=x/2+x/2+1+2*(x/2);
        // bool f=false;
        int cnt=0;
        // cout<<yl<<" ";
        // cout<<y<<" ";
        for(int i=x/2;i<yl;i+=3,cnt++)
        {
          // cout<<i<<" ";
          if(i==y)
          {

            // cout<<"*";
            // f=true;
            // assert(false);
            // cout<<"*";
            // cout<<x/2<<" "<<cnt<<" ";
            cout<<b1(x/2,cnt);
            return 0;
          }
        }
        cout<<"0";
        return 0;
      }
      else{
        int yl=x/2+2+x/2+1+2*(x/2);
        // bool f=false;
        int cnt=1;
        for(int i=x/2+2;i<yl;i+=3,cnt++)
        {
          if(i==y)
          {
            // f=true;
            cout<<b2(x/2+1,cnt);
            return 0;
          }
        }
        cout<<"0";
        return 0;
      }
}
// f[n][m]=f[n-1][j-2]+f[n-2][i-1]
// 1 5 9 12
// I never lose. I either win or I learn

Measured memory_bytes: 39424
fun main(args: Array<String>) {
    //val people_count = 7
    //val coordinates = arrayOf(14, 14, 2, 13, 56, 2, 37)
    val people_count = readLine()!!.toInt()
    val coordinates = readLine()!!.split(" ").map { it.toInt() }

    val answer = (coordinates.min()!!..coordinates.max()!!).map { temp_p ->
        coordinates.map { (it - temp_p) * (it - temp_p) }.sum()
    }.min()

    println("$answer")
}


Measured memory_bytes: 36924
import sys
import collections
import itertools
import math
import re
from collections import deque

MOD = 10 ** 9 + 7

# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]

N = int(input())

ma = 0
sum = 0
for i in range(N):
    p = int(input())
    sum += p
    ma = max(ma, p)

print(sum - ma // 2)


Measured memory_bytes: 3700
#include <stdio.h>
#define BLK 1
#define WHI -1
#define GRY 0
#define N 101
 
int A[N][N];
int f[N],d[N];
int n,t=0,k;
int color[N];
 

void DFSV(int u){
  int v;
  
  color[u]=GRY;
  d[u] = ++t;
  
  for(v=1;v<=n;v++){
    if((color[v]==WHI) && (A[u][v]==1)){
      DFSV(v);
    }
  }
  color[u] = BLK;
  f[u]=++t;
}




void DFS(void){
    int u;
     
    for(u=1;u<=n;u++){
        color[u]=WHI;
        t=0;
    }
     
    for(u=1;u<=n;u++){
        if(color[u]==WHI)DFSV(u);
    }
     
}








int main(void){
    int ts,u,i,j;
     
    scanf("%d",&n);
     
    for(i=1;j<=n;i++){
        for(j=1;j<=n;j++){
            A[i][j]=0;
        }
    }
    


 
    for(i=1;i<=n;i++){
      scanf("%d%d",&u,&k);
            for(j=1;j<=k;j++){
                scanf("%d",&ts);
            A[i][ts] =1;
        }
    }




    DFS();
    for(i=1;i<=n;i++){
        printf("%d %d %d\n",i,d[i],f[i]);
    }
    return 0;
}
 

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

int main(){
    int a[3], b[3], c[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> c[i][j];
        }
    }
    a[0]=0;
    for(int j = 0; j < 3; j++){
        b[j] = c[0][j] - a[0];
    }
    for(int i = 1; i < 3; i++){
        a[i] = c[i][0] - b[0];
    }
    bool okay = true;
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            if(a[i]+b[j] != c[i][j]) okay = false;
        }
    }
    cout << (okay ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
s = gets.strip.split('')

tmp = []
cluster = []
s.each do |c|
  if c=='R' && tmp.last=='L'
    cluster << tmp
    tmp=[]
  end
  tmp << c
end
cluster << tmp

result = []
cluster.each do |rl|
  r,l = rl.partition {|e| e=='R'}.map(&:length)
  rcount = [1, 0]
  lcount = [0, 1]

  rcount = [(r+1)/2, r/2] unless r==1
  lcount = [l/2, (l+1)/2] unless l==1
  sum_count = [rcount[0]+lcount[0], rcount[1]+lcount[1]]


  result << [0]*(r-1)
  result << sum_count
  result << [0]*(l-1)
end

puts result.flatten.join(' ')

Measured memory_bytes: 27516
#include <bits/stdc++.h>
using namespace std;
#define ll              long long int
#define int             ll
#define ff              first
#define ss              second
#define pb              emplace_back
#define mpair           make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define sbits(x)      __builtin_popcountll(x)
#define zbits(x)      __builtin_popcountlliltin_ctzll(x)
#define w(t)            int t;cin>>t;while(t--)
#define uset            unordered_set
#define forr(i, a, b)   for(int i =int(a);i<=int(b);i++)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
    template <typename Arg1>
     void __f(const char* name,Arg1&& arg1){
        cout<<name<<" : "<<arg1<<std::endl;
     }
     template <typename Arg1, typename... Args>
     void __f(const char* names,Arg1&& arg1,Args&&... args){
        const char* comma = strchr(names+1 ,',');
        cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
     }
#else
#define trace(...)
#endif
/*     
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
*/
double pi = 2.0*acos(0);
void fast(){ios_base::sync_with_stdio(false);cin.tie(NULL);cout<<fixed<<setprecision(10);}
int max2(int a,int b){ if(a>b) return a;return b;}
int min2(int a,int b){ if(a<b)return a;return b;}
int max3(int a,int b,int c){ return max2(a,max2(b,c));}
int min3(int a,int b,int c){ return min2(a,min2(b,c));}

///////////////////////////////////////////////////////////////////////////////////////////////


void solve(){
     string s,t;
     cin>>s;cin>>t;
     if(s.length()+1 == t.length())
     {
		 for(int  i =0;i<(int)s.length();i++)
		 if(s[i]!=t[i]){
			 cout<<"No"<<endl;
			 return;
		 }
		 cout<<"Yes"<<endl;
	 }
	 else
	 cout<<"No"<<endl;
 }


signed main(void)
{
      fast();
     // w(t)
      solve();

}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

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

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}


int main(){
    int Mf,Ms,Df,Ds;
    cin >> Mf >> Df >> Ms >> Ds;
    if(Mf==Ms)cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}

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

int main(){
	ll N,M,p,res=0;
  	string str;
  	cin>>N>>M;
	set<ll> liste;
	vector<ll>vect(N+1,0);
	for (ll i=0;i<M;i++){
		cin>>p>>str;
		if(str=="AC")liste.insert(p);
		if(liste.find(p)==liste.end()&&str=="WA")vect[p]++;
	}
	for(auto&&i:liste)res+=vect[i];
	cout<<liste.size()<<" "<<res<<endl;
}


Measured memory_bytes: 5760
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
ll Max = 10 + 1e12;
int N = 5 + 1e5;
int main()
{
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	int cnt = 0;
	int ans = 0;
	rep(i, n-1) {
		if (h[i] >= h[i + 1])
			cnt++;
		else
			cnt = 0;
		ans = max(ans, cnt);
	}
	cout << ans;

}

Measured memory_bytes: 3632
#!/mnt/c/Users/moiki/bash/env/bin/python
s = input()
# s = s.replace('B', '1')
# s = s.replace('W', '0')
# s = list(s)
index = 0
sum = 0
for e,c in enumerate(s):
    if c == 'W':
        sum += e - index
        index += 1
        

        
# # print(s)
# cnt = 0
# def bsort(a):
#     global cnt
#     for i in range(len(a)-1):
#         for j in range(i, len(a)):
#             if int(a[j-1]) > int(a[j]):
#                 cnt += 1
#                 a[j-1] = '0'
#                 a[j] = '1'

# bsort(s)
print(sum)
            



Measured memory_bytes: 3500
x1, y1, x2, y2 = list(map(int, input().split()))

a = x2 -x1
b = y2 -y1

b_v = a
a_v = -b
x3 = x2 + a_v
y3 = y2 + b_v

x4 = x3 -a
y4 = y3 -b
print(x3, y3, x4, y4)

Measured memory_bytes: 9184
#include<iostream>
#include<cstdio>

#include<vector>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
const int INF = 1e9+1;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}

int d[50][50];

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    for (int i = 0; i < M; i++) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        d[a[i]][b[i]] = 1;
        d[b[i]][a[i]] = 1;
    }
    
    int res = 0;
    for (int e = 0; e < M; e++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                d[i][j] = INF;
            }
        }
        for (int i = 0; i < M; i++) {
            d[a[i]][b[i]] = 1;
            d[b[i]][a[i]] = 1;
        }

        d[a[e]][b[e]] = INF;
        d[b[e]][a[e]] = INF;
        
        /*for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                cout << d[i][j] << " ";
            }
            cout << endl;
        }*/

        for (int k = 0; k < N; k++) {
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {
                    chmin(d[i][j],d[i][k]+d[k][j]);
                }
            }
        }
        
        bool flag = true;
        for (int i = 0; i < N; i++) {
            for (int j = i+1; j < N; j++) {
                if (d[i][j] >= INF) flag = false;
            }
        }
        if (!flag) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main(){
	int d,t,s;
	cin >> d >> t >> s;
	
	
	if((double)d/s>t)
		cout << "No" <<endl;
	else 
		cout <<"Yes"<<endl;
	
 
	return 0;
}


Measured memory_bytes: 3604
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int x1 = nextInt();
		int y1 = nextInt();
		int x2 = nextInt();
		int y2 = nextInt();

		int x3,y3,x4,y4;
			x3=x2+(y1-y2);
			y3=y2-(x1-x2);
			x4=x1+(y1-y2);
			y4=y1-(x1-x2);

		System.out.println(x3+" "+y3+" "+x4+" "+y4);

	}


	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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

#define ll long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (ll)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 1000005


int a[mxn];
int main(){
sp;
int n;
cin>>n;
ll ans=0;
for(int i=1; i<=n;++i){
    cin>>a[i];
    ans+=max(a[i]-a[i-1],0);
}
cout<<ans;

return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
using namespace std;

const int MAXN = 200000;
const int MOD = 998244353;
int n;
pii arr[MAXN];
int now, ans = 1;
stack <pii> stk;

signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> arr[i].ff >> arr[i].ss;
  sort(arr, arr+n, greater<pii>());
  for (int i = 0; i < n; i++) {
    now = 1;
    while (stk.size() && arr[i].ff + arr[i].ss > stk.top().ff) {
      now = now * stk.top().ss % MOD, stk.pop();
    }
    stk.push(pii(arr[i].ff, now+1));
  }
  while (stk.size())
    ans = ans * stk.top().ss % MOD, stk.pop();
  cout << ans << "\n";
}


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

const int N = 10;

std::queue <std::pair <int, int>> q;
int dp[1 << N][N], n, m, mat[N][N], vis[1 << N][N];

int main(){
	scanf("%d%d", &n, &m);
	for (int i = 0, u, v; i < m; ++ i){
		scanf("%d%d", &u, &v);
		mat[u][v] = mat[v][u] = 1;
	}
	dp[1][1] = 1;
	q.push({1, 1});
	while (!q.empty()){
		int u = q.front().first, v = q.front().second;
		q.pop();
		vis[u][v] = false;
		for (int i = 1; i <= n; ++ i){
			if (!mat[v][i] || (u & 1 << (i - 1))){
				continue;
			}
			std::pair <int, int> p = {u | 1 << (i - 1), i};
			if (!vis[p.first][p.second]){
				q.push(p);
			}
			dp[p.first][p.second] += dp[u][v];
			vis[p.first][p.second] = true;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; ++ i){
		ans += dp[(1 << n) - 1][i];
	}
	return printf("%d\n", ans), 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  string S;
  cin >> S;
  int opt = 0;
  for (int i; i < 3; i++) {
  	if (S.at(i) == 'o') {
    	++opt;
    }
  }
  cout << 700 + opt * 100 << endl;
}

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

int main(){
  int a;
  cin >> a;
  string s;
  cin >> s;

  if(a<3200) {
    cout << "red" << endl;
  } else {
    cout << s << endl;
  }
  return 0;
}


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

int main() {
	int n; cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;++i){
		cin >> a[i];
		--a[i];
	}
	
	int ans = 0;
	
	for(int i=0; i<n; ++i){
		if(a[i] > i && a[a[i]] == i){	
			++ans;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main() {
	int a[5] = { 0,0,0,0 ,0};
	int N;
	for (int i = 1; i<= 6; i++) {
		cin >> N;
		a[N]++;
	}
	for (int j = 1; j <= 4; j++) {
		if (a[j] >= 3) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;

}

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

using namespace std;

int main() {
	char c;
	cin >> c;
	if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')cout << "vowel";
	else cout << "consonant";
	return 0;
}


Measured memory_bytes: 256
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(&mut std::io::stdin(), &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!(usize);
    let mut ss = vec![0; 1001];
    for _ in 0 .. n {
        let s = get!(usize);
        ss[s] += 1;
    }
    
    let mut sum = vec![0; 1002];
    for i in 0 .. 1001 {
        sum[i+1] = sum[i] + ss[i];
    }
    let mut ans = 0_i64;
    for x in 1 .. 1001 {
        if ss[x] == 0 {
            continue;
        }
        if ss[x] >= 2 {
            for y in 1 .. 1001 {
                if y != x && y < x + x {
                    ans += (ss[x] * (ss[x] - 1) / 2) * ss[y];
                }
            }
        }
        if ss[x] >= 3 {
            ans += ss[x] * (ss[x] - 1) * (ss[x] - 2) / 6;
        }
        for y in 1 .. x {
            if ss[y] == 0 {
                continue;
            }
            for z in 1 .. y {
                if y < x + z && x < y + z && z < x + y {
                    ans += ss[x]*ss[y]*ss[z];
                }
            }
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4476
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
typedef long long ll;
using namespace std;
 
int main(){
ll a,b,k; cin >> a >> b >> k;
    if(a>k) printf("%lld %lld",a-k,b);
    else if(a+b>k) printf("0 %lld",b+a-k);
    else printf("0 0");

return 0;
}

Measured memory_bytes: 256
// AOJ 0598
#include<cstdio>
#include<algorithm>
#include<map>
#define rep(i,a) for(int i=0;i<(a);++i)
#define all(a) (a).begin(), (a).end()

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

int M, N;
char fld[1000][1001], emb[2][3];

bool safe( int i, int j )
{ return i >= 0 && i < M && j >= 0 && j < N; }

int main()
{
	scanf( "%d%d", &M, &N );
	rep( i, M )
		scanf( "%s", fld[i] );
	rep( i, 2 )
		scanf( "%s", emb[i] );

	int ans = 0, inc = 0;
	rep( i, M ) rep( j, N )
	{
		std::map<char, int> m;

		rep( t, 4 )
		{
			int cnt = 0;
			char ch = '\0';

			rep( d, 4 ) if( safe( i+dy[t][d], j+dx[t][d] ) )
			{
				cnt += fld[i+dy[t][d]][j+dx[t][d]] == emb[d/2][d&1];

				if( !dx[t][d] && !dy[t][d] && fld[i+dy[t][d]][j+dx[t][d]] != emb[d/2][d&1] )
					ch = emb[d/2][d&1];
			}

			if( !t && cnt == 4 )
				++ans;
			if( cnt == 3 && ch != '\0' )
				++m[ch];
		}

		for( auto it = m.begin(); it != m.end(); ++it )
			inc = std::max( inc, it->second );
	}

	printf( "%d\n", ans+inc );

	return 0;
}

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

int main() {
  string s; cin >> s;
  int n = s.size(), cnt = 0;
  rep(i, n) if (i%2 == s[i] - '0') cnt++;
  cout << min(cnt, n - cnt) << endl;
  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

int main(void){
	int N;
	scanf("%d",&N);
	int num[N];
	int MAX=0;
	int min=0;
	
	for(int i=0;i<N;i++){
		scanf("%d",num+i);
		if(i==0){
			MAX=num[0];
			min=num[0];
		}
		if(MAX<num[i]){
			MAX=num[i];
		}
		if(min>num[i]){
			min=num[i];
		}
	}
	
	printf("%d",MAX-min);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int H, W;
char S[52][52];

bool judge(int i, int j){
    bool flag = true;
    int cnt = 0;
    if(i-1 >= 0 && S[i-1][j] == '#')  cnt += 1;
    if(i+1 < H && S[i+1][j] == '#') cnt += 1;
    if(j-1 >= 0 && S[i][j-1] == '#') cnt += 1;
    if(j+1 < W && S[i][j+1] == '#') cnt += 1;
    
    if(cnt == 0) flag = false;
    return flag;
}

int main(void){
    // Your code here!
    cin >> H >> W;
    for(int i = 0; i < H; i++) for(int j = 0; j < W; j++) cin >> S[i][j];
    
    for(int i = 0; i < H; i++) {
        for(int j= 0; j < W; j++){
            if(S[i][j] == '.') continue;
            if(!judge(i, j)){
                
                cout << "No" << endl;
                return 0;
            }
        }
    }
    
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void) {
  int a, b, c, x, ans;
  cin >> a >> b >> c >> x;
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= b; j++) {
      for (int k = 0; k <= c; k++) {
        if (500 * i + 100 * j + 50 * k == x) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n = int(input())
chk = []
for _ in range(n):
  f = input().split()
  chk.append(int(''.join(f),2))

p = [] 
for _ in range(n):
  P = [int(i) for i in input().split()]
  p.append(P)

import collections
ans = -float('inf')
for i in range(1,2**10):
  que = 0
  for j,cj in enumerate(chk):
    d = format(i & cj,'b')
    c = collections.Counter(d)
    que += p[j][c['1']]
  ans = max(ans,que)
print(ans)

Measured memory_bytes: 3444