akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                Stack<double> stk = new Stack<double>();

                string[] s = input.Split(' ');
                double a, b;

                for (int i = 0; i < s.Length; i++)
                {
                    switch (s[i])
                    {
                        case "+":
                            a = stk.Pop();
                            b = stk.Pop();
                            stk.Push(b + a);
                            break;
                        case "-":
                            a = stk.Pop();
                            b = stk.Pop();
                            stk.Push(b - a);
                            break;
                        case "*":
                            a = stk.Pop();
                            b = stk.Pop();
                            stk.Push(b * a);
                            break;
                        case "/":
                            a = stk.Pop();
                            b = stk.Pop();
                            stk.Push(b / a);
                            break;
                        default:
                            stk.Push(double.Parse(s[i]));
                            break;
                    }
                }
                sb.AppendLine(stk.Pop().ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 10124
#include<iostream>
#include <vector>
using namespace std;
int main(){
  
  
  int n,m; cin>>n>>m;
  vector<vector<int>> v(n+1);
  
  int H[n+1]{};
  for(int i = 1; i<=n ; i++)cin>>H[i];
  
  for(int i = 0 ; i<m; i++){
    int u,v1; cin>>u>>v1;
    v[u].push_back(v1);
    v[v1].push_back(u);
 	}
  
  int cnt = 0 ; 
  
  for(int i = 1 ; i<=n ; i++){
    int num = H[i];
    bool ok = true;
    for(auto x : v[i]){
      
      if(H[x]>=num)ok = false;
    }
    if(ok)cnt++;
   }
  
  cout << cnt;
 return 0; 
}


Measured memory_bytes: 8752
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

  bool foundA = false;
  int posA;
  int posZ;
  for(int i=0;i<(int)s.size();i++){
    if(!foundA && s[i] == 'A'){
      posA = i;
      foundA = true;
    }
    if(s[i] == 'Z') posZ = i;
  }

  cout << posZ - posA + 1 << endl;
  return 0;
}

Measured memory_bytes: 640
package main

import (
  "fmt"
  "math"
)

func max(M *[]int) (ret int) {
  ret = (*M)[0]
  for _, m := range (*M) {
    if ret < m {
      ret = m
    }
  }
  return
}

func main() {
  var N, C int
  fmt.Scan(&N, &C)
  A := make([]int, N)
  B := make([]int, N)
  p := int64(math.Pow(10, 9) + 7)
  var x int
  for i := 0; i < N; i++ {
    fmt.Scan(&x)
    A[i] = x
  }
  for i := 0; i < N; i++ {
    fmt.Scan(&x)
    B[i] = x
  }
  B_max := max(&B)
  X := make([][]int64, C + 2)
  for i := 0; i < C + 2; i++ {
    X[i] = make([]int64, B_max + 1)
  }
  for j := 1; j < B_max + 1; j++ {
    X[0][j] = 1
  }
  for i := 0; i < C + 1; i++ {
    for j := 1; j < B_max + 1; j++ {
      X[i + 1][j] = (X[i][j] * int64(j)) % p
      X[i][j] = (X[i][j] + X[i][j - 1]) % p
    }
  }
  DP := make([][]int64, N + 1)
  for i := 0; i < N + 1; i++ {
    DP[i] = make([]int64, C + 1)
  }
  DP[0][0] = 1
  var dp int64
  for i := 1; i < N + 1; i++ {
    for j := 0; j < C + 1; j++ {
      for k := 0; k < j + 1; k++ {
        dp = X[k][B[i - 1]] - X[k][A[i - 1] - 1]
        if dp < 0 {
          dp += p
        }
        dp = (dp * DP[i - 1][j - k]) % p
        DP[i][j] += dp
      }
      DP[i][j] %= p
    }
  }
  fmt.Println(DP[N][C])
}

Measured memory_bytes: 3456
def main():

    while True:
        n, x = tuple(map(int, input().split()))
        pattern = 0

        if n == x == 0:
            break
        else:
            for a in range(1, n+1):
                for b in range(1, a):
                    for c in range(1, b):
                        pattern += 1 if a + b + c == x and a > b > c else 0
            print(pattern)
                            

if __name__ == '__main__':
    main()


Measured memory_bytes: 5600
/*
 *  author : Atul Anand   
 *  created on : Wed Apr 01 2020
 */

import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        char c = in.next().charAt(0);
        print((char) ((int) c + 1));
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

Measured memory_bytes: 22992
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n= scan.nextInt();
		double sum=0;
		for(int i=0;i<n;i++) {
			sum+=(double)1/scan.nextInt();
		}

		scan.close();
		System.out.println((double)1/sum);
	}

}


Measured memory_bytes: 21844
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
typedef long long int lli;
typedef unsigned long long int uli;
using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  uli h,kai=0;
  uli i=0;
  cin>>h;
  while(h>0){
    kai+=pow(2,i);
    ++i;
    h/=2;
  }
  ou(kai);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
#include <numeric>
#define ll long long
#define INF INT_MAX 
using namespace std;
int main(){
	int a,b;
	cin >> a >> b;
	if(a+b>=10){
		cout << "error" << endl;
	}else{
		cout << a+b << endl;
	}
}

Measured memory_bytes: 256
n,m=map(int,input().split())
A=[0]*n
ac,wa=0,0
for i in range(m):
  p,s=map(str,input().split())
  p=int(p)
  if s=="AC" and A[p-1]!=-1:
    ac+=1
    wa+=A[p-1]
    A[p-1]=-1
  elif s=="WA" and A[p-1]!=-1:
    A[p-1]+=1
print(ac,wa)


Measured memory_bytes: 3828
#include<iostream>
#include <cstdlib>
#include<string>
using namespace std;
int main(){
  string s;cin>>s;
  string o=s.substr(0,4),p=s.substr(5,2),q=s.substr(8,2);
  int a=atoi(o.c_str()),b=atoi(p.c_str()),c=atoi(q.c_str());
  if(a<=2019&&b<=4&&c<=30)cout<<"Heisei";
  else cout<<"TBD";
}

Measured memory_bytes: 256
//In The Name Of God
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<string> vs;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<double, double> dd;
typedef pair<dd, double> ddd;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<dd> vdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ii> vii;
typedef vector<vii> vvii;

mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define forn(i, n) for (int i = 0; i < n; i++)
#define forr(i, n) for (int i = n; i >= 0; i--)
#define forne(i, x, n) for (int i = x; i < n; i++)
#define forre(i, x, n) for (int i = n; i >= x; i--)
#define all(a) (a).begin(), (a).end()
#define inf 1000000000
#define eps 1e-9

const int maxn = 55;

ll n = 3, MOD = 1e9 + 7; // change n and MOD to meet your requirements

vvi matMul(vvi &a, vvi &b) {
    vvi c(n, vi(n, 0));
    int k;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            for (k = 0; k < n; k++) {
                c[i][j] += (a[i][k] % MOD) * (b[k][j] % MOD);
                c[i][j] %= MOD;
            }
    return c;
}

vvi matPow(vvi base, ll p) {
    vvi ans(n, vi(n, 0)); int i, j;
    for (i = 0; i < n; i++)
        for (j = 0; j < n; j++)
            ans[i][j] = (i == j);
    while (p) {
        if (p & 1)
            ans = matMul(ans, base);
        base = matMul(base, base);
        p >>= 1;
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(0);
    ll k; cin >> n >> k;
    vvi adj(n, vi(n));
    forn(i, n) forn(j, n) cin >> adj[i][j];
    vvi res = matPow(adj, k);
    ll ans = 0;
    forn(i, n) forn(j, n) (ans += res[i][j]) %= MOD;
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 384
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main() {
    let s = input_line_str().to_charvec();
    for i in 0..s.len() {
        print!("x");
    }
    println!("");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001
//0=48,A=65,a=97

int main() {
    string s;cin >> s;
    ll k;cin >> k;
    ll one=0;
    char x;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] != '1'){
            x=s[i];
            break;
        }
        else one++;
        
    }

    if(k<=one) cout << 1 << endl;
    else cout << x << endl;
    

    return 0;
}

Measured memory_bytes: 3604
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<map>
using namespace std;
const int N=10010,M=100010;
int p[N][2];
int ma[N];
struct node{
	int u,v,nxt;
}edge[M];
int head[N],mcnt;
bool vis[N];
void add(int u,int v){
	mcnt++;
	edge[mcnt].v=v;
	edge[mcnt].u=u;
	edge[mcnt].nxt=head[u];
	head[u]=mcnt;
}
bool dfs(int u){
	for(int i=head[u];i;i=edge[i].nxt){
		int v=edge[i].v;
		if(vis[v])
			continue;
		vis[v]=1;
		if(!ma[v]||dfs(ma[v])){
			ma[v]=u;
			return true;
		}
	}
	return false;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
		scanf("%d%d",&p[i][0],&p[i][1]);
	int x,y;
	int ans=0;
	for(int i=1;i<=n;i++){
		scanf("%d%d",&x,&y);
		for(int j=1;j<=n;j++)
			if(p[j][0]<x&&p[j][1]<y)
				add(j,i);
	}
	for(int i=1;i<=n;i++){
		memset(vis,0,sizeof vis);
        ans+=dfs(i);
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 256
N, M = list(map(int, input().split(' ')))
H = list(map(int, input().split(' ')))

route = [[] for i in range(N+1)]

for i in range(M):
  A, B = list(map(int, input().split(' ')))
  route[A].append(B)
  route[B].append(A)

count = 0
for i in range(1, N+1):
  route1 = route[i]
  flag = True
  for route2 in route1:
    if H[i-1] <= H[route2-1]:
      flag = False
  if flag:
    count += 1
#print(route)
print(count)

Measured memory_bytes: 95304
#include <cstdio>
#include <algorithm>
typedef long long LL;
typedef unsigned long long ULL;
const int MAXN = 100005;
const int P = 998244353;
const int INF = 1000000007;
const double eps = 1e-6;
using namespace std;
inline int getint() {
    int r = 0; bool b = true; char c = getchar();
    while (c < '0' || c > '9') { if (c == '-') b = false; c = getchar(); }
    while (c >= '0' && c <= '9') { r = (r<<1)+(r<<3) + c - '0'; c = getchar(); }
    return b ? r : -r;
}
int K, N;
int C[4005][4005];
int p2[4005];
int Bi(int n, int m) {
    if (n < 0) return 0;
    return C[n][m];
}
int Cou(int cnt, int n) {
    return Bi(cnt + n - 1, cnt  - 1);
}
int main() {
    C[0][0] = 1;
    p2[0] = 1;
    for (int i = 1; i <= 4000; ++i)
        p2[i] = (p2[i-1] << 1) % P;
    for (int i = 1; i <= 4000; ++i) {
        C[i][0] = 1;
        for (int j = 1; j <= 4000; ++j)
            C[i][j] = (C[i-1][j] + C[i-1][j-1]) % P;
    }
    K = getint(); N = getint();
    int ans, p, q;
    for (int i = 2; i <= (K<<1); ++i) {
        ans = 0;
        p = 0;
        for (int j = 1, k = i - 1; j < k; ++j, --k) if (k <= K) ++p;
        if (i & 1) {
            for (q = 0; q <= p; ++q)
                (ans += (LL) Bi(p,q) * p2[q] % P * Cou(K - p - p + q, N - q) % P) %= P;
        }
        else {
            for (q = 0; q <= p; ++q)
                (ans += (LL) Bi(p,q) * p2[q] % P * ((Cou(K - p - p + q - 1, N - q - 1) + Cou(K - p - p + q - 1, N - q)) % P) % P) %= P;
        }
        printf("%d\n", ans);
    }
}


Measured memory_bytes: 62848
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class DRecording {
        public void solve(int testNumber, Scanner in, PrintWriter out) {


            // つまり[l,r]で録画機を占有するが、同じチャンネルに関して言えば
            // [l,r] , [r ,rr]も録画が可能になる
            // 各チャンネルについて、O(NC)であるかどうかを確認する
            // 累積和に落とし込む
            // まず各チャンネルについての累積和を組む
            // そしたら最後のカウントに関しては累積和じゃなくてシミュレートをしていけばいい。

            // 累積和について、まず
            // (s,t,c) について, s->+1, t+1 -> -1する

            int n = in.nextInt();
            int c = in.nextInt();
            int[][] accChan = new int[c][100002];
            int[] cnt = new int[100002];
            int max = 0;
            for (int i = 0; i < n; i++) {
                int s = in.nextInt();
                int t = in.nextInt();
                int chan = in.nextInt() - 1;
                accChan[chan][s]++;
                accChan[chan][t + 1]--;
            }


            for (int i = 0; i < c; i++) {
                for (int j = 1; j < accChan[i].length; j++) {
                    accChan[i][j] = accChan[i][j - 1] + accChan[i][j];
                }
            }

            for (int i = 0; i < c; i++) {
                for (int j = 0; j < accChan[i].length; j++) {
                    if (accChan[i][j] == 1) {
                        cnt[j]++;
                    }
                }
            }


            for (int value : cnt) {
                max = Math.max(max, value);
            }

            out.println(max);

        }

    }
}



Measured memory_bytes: 109056
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    map<int, ll> L, R;
    REP(i, N) {
        L[i + A[i]]++;
        R[i - A[i]]++;
    }
    ll res = 0;
    for (auto &p : L) { res += p.second * R[p.first]; }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 38272
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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

int main(void){
    int n;

    cin >> n;
    vector<int> a(n);
    FOR(i,0,n-1){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    cout << a[n - 1] - a[0] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int d[8] = {-5, -4, -3, 1, 5, 4, 3, -1};

bool check(int i, int d, int n)
{
  if (i + d >= n) {return false;}
  if (i + d < 0) {return false;}
  if (i % 4 == 0 && (d == -5 || d == -1 || d == 3)) {return false;}
  if (i % 4 == 3 && (d == -3 || d == 1 || d == 5)) {return false;}

  return true;
}

int search(vector<int> table, int n)
{
  //  printf("%d\n", n);
  int ans = n;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 8; j++) {
      if (check(i, d[j], n) && table[i] == table[i + d[j]]) {

	vector<int> _table = table;
	if (d[j] > 0) {
	  for (int k = i + 1; k < i + d[j]; k++) {
	    _table[k - 1] = _table[k]; 
	  }
	  for (int k = i + d[j] + 1; k < n; k++) {
	    _table[k - 2] = _table[k]; 
	  }
	} else {
	  for (int k = i + d[j] + 1; k < i; k++) {
	    _table[k - 1] = _table[k]; 
	  }
	  for (int k = i + 1; k < n; k++) {
	    _table[k - 2] = _table[k]; 
	  }	  
	}
	int _ans = search(_table, n - 2);
	if (_ans == 0) {
	  return 0;
	}
	ans = min(ans, _ans);
      }
    }
  }
  return ans;
}

int main()
{
  int numberOfInput;
  scanf("%d", &numberOfInput);
  
  vector<int> table(20, 0);
  for (int index = 0; index < numberOfInput; index++) {
    for (int i = 0; i < 20; i++) {
      scanf("%d ", &table[i]);
    }
    cout << search(table, 20) << endl;
  }
}

Measured memory_bytes: 928
// Author : Chi
// created : 2020-05-24 Sunday

//header files
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

//macros
#define ll 		    long long
#define ss          second
#define ff          first
#define vi          vector<int>
#define vll         vector<long long>
#define pb          push_back
#define TEST  	    int TesT;cin>>TesT;while(TesT--)solve();
#define TEST1       solve();
#define mod         998244353
#define r0n(i,n)    for(ll i = 0; i < n; ++i)
#define r1n(i,n)    for(ll i = 1; i <= n; ++i)
#define CHI         ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
//namespaces
using    namespace __gnu_pbds;
using    namespace std;

typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;
map<int,vector<int>>m;
int dp[100001];
int dfs(int s,int h){
    if(dp[s]!=-1)
        return dp[s];
    if(m[s].size()==0)
        return dp[s]=0;
    int hi=h;
    for(auto i:m[s])
        hi=max(hi,h+1+dfs(i,0));
    return dp[s]=h+hi;
}
void solve(){
    int V,E;
    memset(dp,-1,sizeof dp);
    cin>>V>>E;
    for(int i=0;i<E;i++){
        int u,v;
        cin>>u>>v;
        m[u].pb(v);
    }
    int ans=0;
    for(int i=1;i<=V;i++){
        ans=max(ans,dfs(i,0));
    }
    cout<<ans;
}
// Driver Code
int main(){
    TEST1
    return 0;
}
/*
adsfasdfas
adfasdfsadgnf
afdsafda
*/


Measured memory_bytes: 15616
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class A
{
	public static void Main()
	{
		int r = GetInt();
		int g = GetInt();
		int b = GetInt();
		Console.WriteLine((10 * g + b) % 4 == 0 ? "YES" : "NO");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 11092
import java.util.*;


public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int a[] = new int [N-1];
        
        
        for(int i=0;i<N-1;i++){
            a[i] = sc.nextInt();
        }
        
        int count = a[0] + a[N-2];
        
        
        for(int i=0;i<N-2;i++){
        
            count += Math.min(a[i],a[i+1]);
        
        }
        
        System.out.println(count);
        
        
    }
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;
li a[200100];

int main() {
    li n, x;
    cin >> n >> x;
    if (x == 1 || x == n * 2 - 1) {
        puts("No");
        return 0;
    }
    puts("Yes");
    if (n == 2) {
        puts("1 2 3");
        return 0;
    }
    rep(i, n * 2) {
        a[i] = i;
    }
    // xを中央に
    swap(a[x], a[n]);
    if (x == 2) {
        // 2n-2を右隣に
        swap(a[n * 2 - 2], a[n - 1]);
        // 1を左隣に
        swap(a[1], a[n + 1]);
        // 2n-1をその左隣に
        swap(a[n * 2 - 1], a[n + 2]);
    } else {
        // 1を右隣に
        swap(a[1], a[n - 1]);
        // 2n-1を左隣に
        swap(a[2 * n - 1], a[n + 1]);
        // 2をその左隣に
        swap(a[2], a[n + 2]);
    }

    repp(i, 1, n * 2)cout << a[i] << endl;

    return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	string s;
	cin >> s;

	vector<int> dp(n + 1, 1000000);
	dp[n] = 0;
	queue<int> q;
	q.push(0);
	for (int i = n - 1; i >= 0; --i) {
		while (1) {
			if (q.size() == 0) {
				puts("-1");
				return 0;
			}
			if (q.front() != 1000000 && q.size() <= m) break;
			q.pop();
		}
		if (s[i] == '0') dp[i] = q.front() + 1;
		q.push(dp[i]);
	}

	if (dp[0] == 1000000) {
		cout << -1 << endl;
		return 0;
	}

	int count = 0;
	int prev = dp[0];
	for (auto& i : dp) {
		if (i == 1000000) {
			++count;
			continue;
		}
		if (prev != i) {
			cout << count << " ";
			count = 0;
		}
		prev = i;
		++count;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PA;
typedef priority_queue<int, vector<int>, greater<int> > PQG;
#define REP(i, a, n) for(ll i = (ll) a;i < (ll) n;i++)
#define fi first
#define se second
#define pb push_back
#define INF 1000000009
#define MOD 1000000007
#define MAXN 103
#define MAXC 100000000000014
#define MAXV 1000000009

ll n, m, ans;

int main()
{
    cin >> n >> m;
    if(n == 2 || m == 2){
        cout << "0" << endl;
    }
    else if(n == 1 || m == 1){
        if(n == 1 && m == 1){
            cout  << "1" << endl;
            return 0;
        }
        cout << n + m - 1 - 2 << endl;
    }
    else{
        ans = (n - 2) * (m - 2);
        cout << ans << endl;
    }



    return 0;
}
















Measured memory_bytes: 256
fn main() {
    let (n, m, x): (usize, usize, usize) = (read::<usize>(), read::<usize>(), read::<usize>());
    let mut books = vec![];
    for _ in 0..n {
        let a: Vec<usize> = (0..(m + 1)).map(|_| read::<usize>()).collect();
        books.push(a);
    }
    let mut ans = std::usize::MAX;
    for b in 0..(1 << n) {
        let mut tmp_vs = vec![0; m];
        let mut tmp: usize = 0;
        let mut ok = true;
        for i in 0..n {
            if 1 & b >> i == 1 {
                for j in 1..m + 1 {
                    tmp_vs[j - 1] += books[i][j];
                }
                tmp += books[i][0];
            }
        }
        for j in 0..m {
            if tmp_vs[j] < x {
                ok = false;
                break;
            }
        }
        if ok {
            ans = min(tmp, ans);
        }
    }
    match ans {
        std::usize::MAX => println!("-1"),
        _ => println!("{}", ans),
    }
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 2152
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) ((a) < (b) ? (b) : (a))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

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



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

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



int main() {
	int i, j, k;
	//ll N, M, K;
	int N, M, K;
	int A[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	cin >> N;
	cout << A[N-1];
	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

#define ll long long

vector<ll> a;

int main()
{
    int n;
    int aa;
    cin >> n;
    int min = __INT_MAX__;
    bool b_m = false;
    for(int i=0;i<n;i++)
    {
        cin >> aa;
        int ab = (aa > 0 ? aa : -aa);
        a.push_back(ab);
        if (min > ab)
            min = ab;
        if(aa < 0)
        {
            b_m = b_m ? false : true;
        }
    }
    ll sum = 0;
    for(int i=0;i<a.size();i++)
    {
        sum += a[i];
    }
    if(b_m)
        sum -= 2*min;

    cout << sum << endl;
}

Measured memory_bytes: 1400
#include <iostream>

using namespace std;
int main(void){
    
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    
    a=max(a,c);
    b=min(b,d);
    int ans = max(0,b-a);
    cout<<ans;
    
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        boolean[] data = new boolean[2019];
        int[] x = new int[101];
        for (int i = 0; i < n; ++i) {
            x[i] = scanner.nextInt() - 1;
            data[x[i]] = true;
        }
        int m = scanner.nextInt();
        for (int i = 0; i < m; ++i) {
            int a = scanner.nextInt() - 1;
            if (x[a] != 2018 && !data[x[a] + 1]) {
                data[x[a]] = false;
                data[x[a] + 1] = true;
                ++x[a];
            }
        }

        for (int i = 0; i < n; ++i) {
            System.out.println(x[i] + 1);
        }

    }
}



Measured memory_bytes: 26408
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int a, b;
  cin >> a >> b;
  if (a+b >= 10) dump("error");
  else dump(a+b);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define NewNode (ListNode *)malloc(sizeof(ListNode))
#define Mem(a,b) memset(a,b,sizeof(a))
const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-10;
const unsigned long long mod = 998244353;
const double II = 3.1415926535;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> piil;
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    ll a,b,c,k,sum = 0;
    cin >> a >> b >> c >> k;
    while(k)
    {
        if(a)
        {
            if(k >= a)
                sum += a,k -= a,a = 0;
            else
                sum += k,k = 0;
        }
        else if(b)
        {
            if(k >= b)
                k -= b,b = 0;
            else
                k = 0;
        }
        else
        {
            sum -= k;
            k = 0;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3564
import heapq
n,m=map(int,input().split())
a=[-int(i)for i in input().split()]
heapq.heapify(a)
for i in range(m):
 p=heapq.heappop(a)
 p*=-1
 p//=2
 heapq.heappush(a,-p)
print(-sum(a))

Measured memory_bytes: 14180
/*input
2 2 2
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int main()
{
	IOS;
	int n;
	cin>>n;
	string s;
	cin>>s;
	int cnt=0;
	REP(i,SZ(s))
		if(s[i]=='R') cnt++;
		else cnt--;
	if(cnt>0) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define MAX_N 3000

int main() {
    i64 R, G, B, N; cin >> R >> G >> B >> N;

    i64 cnt = 0;
    REP(r, MAX_N + 1) {
        REP(g, MAX_N + 1) {
            i64 rem = N - r * R - g * G;
            if (rem < 0) continue;
            if (rem % B > 0) continue;
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <string>
#include <iostream>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
string a,b;
int main() {
	cin>>a>>b;
	if (a==b) cout<<"EQUAL"<<endl;
	else if (a.size()!=b.size()) cout<<(a.size() < b.size() ? "LESS" : "GREATER") << endl;
 	else cout << (a < b ? "LESS" : "GREATER") << endl;
   	return 0;
    }


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

using namespace std;
typedef long long ll;

int N, M;

vector<int> G[600];
double dp[600];
double dp1[600];

void copy(){
    for(int i = 0; i < N; i++) dp1[i] = dp[i];
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    
    cin >> N >> M;
    dp[N-1] = 0;
    for(int i = 0; i < M; i++){
        int s, t;
        cin >> s >> t;
        s--; t--;
        G[s].push_back(t);
    }
    for(int i = N-2; i >= 0; i--){
        double tmp = 0;
        for(int j = 0; j < G[i].size(); j++){
            tmp += (dp[G[i][j]]+1);
        }
        dp[i] = tmp/(double)G[i].size();
    }
    double ans = dp[0];
    for(int i = N-2; i >= 0; i--){
        if(G[i].size() == 1) continue;
        copy();
        double m = -1.0;
        double tmp = 0.0;
        for(int j = 0; j < G[i].size(); j++){
            tmp += (dp[G[i][j]]+1);
            m = max(m, dp[G[i][j]]+1);
        }
        dp1[i] = (tmp-m)/(double)(G[i].size()-1);
        for(int k = i-1; k >= 0; k--){
            double tmp = 0;
            for(int l = 0; l < G[k].size(); l++){
                tmp += (dp1[G[k][l]]+1);
            }
            dp1[k] = tmp/(double)G[k].size();
        }
        ans = min(ans, dp1[0]);
        //cout << ans << endl;
    }
    cout << ans << endl;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int main() {
	int n = ri(), m1 = ri(), m2 = ri();
	int dp[401][401];
	for (auto &i : dp) for (auto &j : i) j = 1000000000;
	dp[0][0] = 0;
	for (int i = 0; i < n; i++) {
		int a = ri(), b = ri(), c = ri();
		for (int j = 400 - a; j >= 0; j--) for (int k = 400 - b; k >= 0; k--)
			dp[j + a][k + b] = std::min(dp[j + a][k + b], dp[j][k] + c);
	}
	int res = 1000000000;
	for (int i = 1; m1 * i <= 400 && m2 * i <= 400; i++) res = std::min(res, dp[m1 * i][m2 * i]);
	printf("%d\n", res == 1000000000 ? -1 : res);
	return 0;
}


Measured memory_bytes: 896
#include <map>
#include <algorithm>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <string>
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define DEBUG(X) cerr<<"  "<<#X<<" = "<<X<<endl;
#define DUMP(A, n) for (auto x=begin(A); x!=begin(A)+n;x++){cout <<*x<< ' ';} cout<<endl;
#define DUMPP(A, n, m) for (auto x=begin(A); x != begin(A)+n;x++) {for (auto y=begin(*x); y != begin(*x)+m;)cout <<*y++<< ' '; cout<<endl;};
#define DUMPM(M) for (auto itr=mp.begin(); itr!=mp.end(); itr++) {cout<<itr->first<<" -> "<<itr->second<<endl;}
#define FOR(i,x,y) for(int i=(x);i<(int)(y);i++)
#define FORP(i,x,y) for(int i=(x);i<=(int)(y);i++)
#define REP(i,y) for(int i=0;i<(int)(y);i++)
#define REPP(i,y) for(int i=1;i<=(int)(y);i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)

int n,m;
vector<int> G[500];
vector<pair<int,int>> vertex;
int color[500];

int dfs(int s, int u, int v) {
  int cnt=0;
  if (color[s]==0) {
    cnt++, color[s]=1;
  }
  for (int i=0; i<G[s].size(); i++) {
    if ((G[s][i]==u && s==v) || (s==u && G[s][i]==v)) continue;
    if (color[G[s][i]] == 0)
      cnt += dfs(G[s][i], u, v);
  }
  return cnt;
}

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  cin >> n >> m;
  REP(i,m) {
    int u,v; cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
    vertex.push_back({u,v});
  }
  int cnt=0;
  for (auto p : vertex) {
    fill(color, color+500, 0);
    cnt+= (dfs(1, p.first, p.second)!=n);
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int N,K;
  cin >> N >> K;
  int A[N];
  for(int i = 0;i < N;i++){
    cin >> A[i];
  }
  for(int i = 0;i < N - K;i++){
    if(A[i] >= A[K + i])
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
  }
}

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

#ifdef INPUT
#include <sstream>
stringstream input(R"(
1
24 30
)");
#define cin input
#endif

int main()
{
	int n, l, r;
	cin >> n;
	int sum=0;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
vector<int>g[maxn];
int vis[maxn];
int deg[maxn];
int fa[maxn];
void dfs(int root,int f)
{
	fa[root]=f;
	vis[root]=1;
	for(int i=0;i<g[root].size();i++)
		deg[g[root][i]]--;
	for(int i=0;i<g[root].size();i++)
	{
		if(!vis[g[root][i]] && !deg[g[root][i]])
			dfs(g[root][i],root);
	}
} 
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n+m-1;i++)
	{
		int u,v;
		cin>>u>>v;
		g[u].push_back(v);
		vis[v]=1;
		deg[v]++;
	}
	int root=0;
	for(int i=1;i<=n;i++)
		if(!vis[i])
			root=i;
	memset(vis,0,sizeof(vis));
	dfs(root,0);
	for(int i=1;i<=n;i++)
		cout<<fa[i]<<"\n";
	return 0;
} 

Measured memory_bytes: 12160
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long A;
    long b1,b2;
    scanf("%ld %ld.%ld",&A,&b1,&b2);
    //printf("%ld %ld %ld\n",A,b1,b2);
    long C;
    
    C = A*(b1*100+b2);
    
    printf("%ld\n", C/100);
}


Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef pair<ll, ll> pll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define foro(i, n) for(i=0; i<n; i++)
#define forl(i, n) for(i=1; i<=n; i++)
#define x first
#define y second
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 1e18 + 1;


int main()
{
	int i, j, k, l, tmp;
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	char asf[4100];
	scanf("%d", &n);
	scanf(" %s", asf);
	vector<ll> count(3);
	foro(i, n){
		switch(asf[i]){
			case 'R':	count[0]++;	break;
			case 'G': 	count[1]++;	break;
			case 'B':	count[2]++;	break;
		}
	}
	ll ans=0;
	for(i=1; i<n-1; i++)
		for(j=1; j<n; j++){
			if(i-j<0 || j+i>=n)	break;
			if(!(asf[i-j]==asf[i+j] || asf[i]==asf[i-j] || asf[i]==asf[i+j]))
				ans++;
			}
		
	printf("%lld\n", count[0]*count[1]*count[2] - ans);
	//printf("a");
	//printf("a\n");
}



Measured memory_bytes: 3816
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(){
	char s1[11],s2[11],s3[11];
	char a,b,c;
	scanf (" %s %s %s",s1,s2,s3);
	a=toupper(s1[0]),b=toupper(s2[0]),c=toupper(s3[0]);
	printf ("%c%c%c",a,b,c);
   return 0;}


Measured memory_bytes: 128
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
#include <cassert>
using namespace std;
using ll = long long;
using plong = pair<ll,ll>;
ll MOD=998244353;

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(){
    ll A,B,C,D;
    cin>>A>>B>>C>>D;
    float taka = ceil((float)(C)/(float)B);
    float ao = ceil((float)A/(float)D);
    // cout<<taka<<":"<<ao<<endl;
    if(taka<=ao){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

}


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

using ll = long long;
const ll MOD = 998244353;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N + 1, 1e9 + 1), B(N + 1, 1e9 + 2), C(N + 1, 1e9 + 3);
    vector<ll> s(N + 1, 0), t(N + 1, 0);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N) cin >> C[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    ll i = 0;
    rep(j, N) {
        while (A[i] < B[j]) i++;
        s[j + 1] = i;
    }
    i = 0;
    ll k = 0;
    rep(j, N) {
        while (B[i] < C[j]) {
            i++;
            k += s[i];
        }
        t[j + 1] = t[j] + k;
    }
    cout << t[N] << endl;
    /*
    rep(i, N + 1) {
        cout << s[i] << " " << t[i] << endl;
    }
    rep(i, N + 1) {
        cout << A[i] << " " << B[i] << " " << C[i] << endl;
    }
    */
}

Measured memory_bytes: 4224