akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ch = sc.nextInt();
		double s[][] = new double[n][3];
		for(int i=0; i<n; i++){
			s[i][0] = sc.nextInt();
			s[i][1] = sc.nextInt();
			s[i][2] = sc.nextInt();
		}
		sc.close();

		double[] rec = new double[ch];
		double[] recch = new double[ch];
		int num = 1;

		Arrays.sort(s, new Comparator<double[]>() {
			@Override
			public int compare(double[] a, double[] b) {
				return Double.compare(a[0], b[0]);
			}
		});

		for(int i=0; i<n; i++){
			boolean can = false;

			for(int j=0; j<num; j++){
				if(recch[j] == 0 || recch[j] == s[i][2]){
					if(rec[j] <=s[i][0]){
						rec[j] = s[i][1];
						recch[j] = s[i][2];
						can = true;
						break;
					}
				}else{
					if(rec[j] <s[i][0]-0.5d){
						rec[j] = s[i][1];
						recch[j] = s[i][2];
						can = true;
						break;
					}
				}
			}
			if(!can){
				num++;
				rec[num-1] = s[i][1];
				recch[num-1] = s[i][2];
			}
			
		}
		System.out.println(num);
	}
}

Measured memory_bytes: 101156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


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

    const ll INF=1LL<<60;
    vector<vector<ll>> dp(100010,vector<ll>(3,-1));

    dp[0][0] = 0;
    dp[0][1] = 0;
    dp[0][2] = 0;

    vector<vector<ll>> h(N,vector<ll>(3));
    REP(i,N) cin>>h[i][0]>>h[i][1]>>h[i][2];

    REP(i,N){
        REP(a,3){
            REP(b,3){
                if(a==b) continue;
                chmax(dp[i+1][a], dp[i][b] + h[i][a]);
            }
            //cout << a<<": "<<dp[i+1][a] << endl;
        }
    }

    ll max =0;
    REP(i,3) {
        //cout << dp[N][i] << endl;
        chmax(max, dp[N][i]);
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 11136
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextInt();
            var k = cin.nextInt();

            Console.WriteLine(500 * n >= k? "Yes":"No" );
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N+ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }   

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  for (int i = 0; i < N; i++)
    cin >> v.at(i);
  
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  
  int sumA = 0, sumB = 0;
  
  for (int i = 0; i < N; i += 2)
    sumA += v.at(i);
    
  for (int i = 1; i < N; i += 2)
    sumB += v.at(i);
  
  cout << sumA - sumB << endl;
}

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

using namespace std;

#define ll long long

const int MAX = 1005;
const int mod = 1e9+7;

char s[MAX][MAX];
int dp[MAX][MAX];

int main(){
    //freopen("tree.in","r",stdin);
    //freopen("tree.out","w",stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    //cin.tie(0);

    int h, w;
    cin >> h >> w;

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

    dp[0][0] = 1;

    for(int i = 1; i < h; ++i){
        if(s[i][0] == '.')
            dp[i][0] = dp[i-1][0];
    }

    for(int j = 1; j < w; ++j){
        if(s[0][j] == '.')
            dp[0][j] = dp[0][j-1];
    }

    for(int i = 1; i < h; ++i){
        for(int j = 1; j < w; ++j){
            if(s[i][j] == '.'){
                dp[i][j] = dp[i-1][j] + dp[i][j-1];
                if(dp[i][j] >= mod)
                    dp[i][j] -= mod;
            }
        }
    }

    cout << dp[h-1][w-1] << endl;
}   



Measured memory_bytes: 5248
while True :
	H, W = map(int, input().split())
	if(H == 0 & W == 0) :
		break
	else :
		for i in range(H) :
			for j in range(W) :
				if((i + j) % 2 == 0) :
					print("#", end = "")
				else :
					print(".", end = "")
			print()
		print()


Measured memory_bytes: 7008
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        n: usize,
        mut s: chars,
    }
    let mut cumsum = vec![0; n];
    for i in 0..n {
        if i == 0 {
            cumsum[i] = if s[i] == 'E' { 1 } else { 0 };
        } else {
            cumsum[i] = cumsum[i - 1] + if s[i] == 'E' { 1 } else { 0 }
        }
    }
    let mut diff = vec![0; n];
    for i in 0..n {
        diff[i] = i + cumsum[n - 1] - cumsum[i] - if i == 0 { 0 } else { cumsum[i - 1] }
    }

    println!("{}", diff.iter().min().unwrap());
}


Measured memory_bytes: 14588
N, K = map(int, input().split())
p = sorted([int(input()) for i in range(N)])
ans = 10 ** 9

for i in range(N - K + 1):
    if p[i + K - 1] - p[i] < ans:
        ans = p[i + K - 1] - p[i]
print(ans)

Measured memory_bytes: 8280
#include<stdio.h>
#include<math.h>

#define N 100000

int main(){
  int i,j,a[N],count=0,k,b;

  scanf("%d",&i);

  for(j=0;j<i;j++){
    b=0;
    scanf("%d",&a[j]);
    if(a[j]<4) count++;
    if(a[j]%2==0 || a[j]%3==0) continue;
    if(a[j]>=5){
      for(k=5;k<=sqrt(a[j]);k+=2){
	if(a[j]%k==0){
	  b=1;
	  break;
	}
      }
      if(b==0) count++;
    }
  }
   

  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 2056
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>

using namespace std;


int n;
int table[11][11];
int row_sum;
int col_sum;


int main()
{
	while (cin >> n)
	{
		if (n == 0) break;
		
		for (int i=0; i<n; i++)
		{
			row_sum = 0;
			for (int j=0; j<n; j++)
			{
				cin >> table[i][j];
				row_sum += table[i][j];
			}
			table[i][n] = row_sum;
		}
		
		for (int i=0; i<=n; i++)
		{
			col_sum = 0;
			for (int j=0; j<n; j++)
			{
				col_sum += table[j][i];
			}
			table[n][i] = col_sum;
		}
		
		for (int i=0; i<=n; i++)
		{
			for (int j=0; j<=n; j++)
			{
				printf("%5d", table[i][j]);
			}
			cout << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1192
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        String word = sc.next();

        List<String> sentence = new ArrayList<String>();

        while (!sentence.contains("END_OF_TEXT")) {
            sentence.add(sc.next());
        }

        int count = 0;

        for (int i = 0; i < sentence.size(); i++) {
            if ((sentence.get(i)).equalsIgnoreCase(word)) {
                count++;
            }
        }

        System.out.println(count);

        sc.close();
    }
}


Measured memory_bytes: 26600
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(150) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define pint pair<lli,lli>
#define Lower(v,X) lower_bound(v.begin(),v.end(),X)-v.begin();
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
vector<lli> divisor(lli N){
  vector<lli>res;
  for(lli i=1;i*i<=N;i++){
    if(N%i==0){
      res.push_back(i);
      if(i*i!=N)res.push_back(N/i);
    }
  }
  Sort(res);
  return res;
}
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  auto Xq=divisor(N);
  M=Xq.size();
  if(M==1)Y=Xq[0];
  else if(M%2==1)Y=Xq[M/2];
  else{
	  Y=Xq[M/2];
	  L=Xq[M/2-1];
	  Y=max(L,Y);
  }
  sum=1;
  while(Y>9){
	  Y/=10;
	  sum++;
  }
  Out(sum);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s,t,ans="";
int i,j,r;
int main(){
    cin>>s>>t;
    if(s.size()<t.size()){
        cout<<"UNRESTORABLE";
        return 0;
    }
    for(i=0;i<=s.size()-t.size();i++){
        int k=i;
        string s1=s;
        j=0;
        while(j<t.size()){
            if(s1[k]=='?')
                s1[k]=t[j];
            else if(s[k]!=t[j])
                break;
            k++;
            j++;
        }
        if(j==t.size()){
            for(r=0;r<s1.size();r++){
                if(s1[r]=='?')
                    s1[r]='a';
            }
            if(ans=="")
                ans=s1;
            else ans=min(ans,s1);
        }
    }
    if(ans=="")
        cout<<"UNRESTORABLE"; 
    else cout<<ans;
    return 0;
}

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

int main()
{
  ll n, x;
  cin >> n >> x;

  vector<ll> v;
  ll a;
  for (int i = 0; i < n; i++)
  {
    cin >> a;
    v.push_back(a);
  }

  sort(v.begin(), v.end());
  int res = 0;
  for (int i = 0; i < n; i++)
  {
    if (i == n - 1)
    {
      if (x == v[i])
      {
        res++;
      }
    }
    else if (x >= v[i])
    {
      x -= v[i];
      res++;
    }
    else
    {
      break;
    }
  }

  cout << res << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const double PI = 3.14159265358979;
static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

int main() {
	ll n, h, w; cin >> n >> h >> w;
	ll cnt = 0;
	rep(i, 0, n) {
		ll a, b; cin >> a >> b;
		if (h <= a && w <= b) {
			cnt++;
		}
	}

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
sc = []
for i in range(M):
    sc.append(list(map(int, input().split())))
    
if N == 1:
    start = 0
else:
    start = 10**(N-1)
for i in range(start, 10**N):
    i = str(i)
    flag = True
    for j in range(M):
        if int(i[sc[j][0]-1]) != sc[j][1]:
            flag = False
    if flag:
        print(int(i))
        exit()
        
print(-1)


Measured memory_bytes: 3064
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#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 <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
const int MOD = 1000000007;
typedef pair<long long,long long> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

long long dp[105][10];
 
int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
 
    int H,W,K;cin >> H >> W >> K;
    if(W == 1){
        cout << 1 << endl;
        return 0;
    }
    for(int i = 0;i<105;i++) for(int j = 0;j<10;j++) dp[i][j] = 0;
    dp[0][0] = 1;
    for(int i = 0;i<H;i++){
        for(int j = 0;j<(1<<(W-1));j++){
            bitset<9> BIT(j);
            bool ren = false;
            for(int k = 0;k<W-2;k++){
                if(BIT.test(k) && BIT.test(k+1)){
                    ren = true;
                }
            }
            if(ren) continue;
            for(int k = 0;k<W-1;k++){
                if(BIT.test(k)){
                    dp[i+1][k+1] += dp[i][k];
                    dp[i+1][k] += dp[i][k+1];
                    dp[i+1][k+1] %= MOD;
                    dp[i+1][k] %= MOD;
                    continue;
                }
                else{
                    if(k == 0){
                        dp[i+1][k] += dp[i][k];
                        dp[i+1][k] %= MOD;
                        continue;
                    }
                    if(k != 0 && !BIT.test(k-1)){
                        dp[i+1][k] += dp[i][k];
                        dp[i+1][k] %= MOD;
                    }
                }
                if(k == W-2 && !BIT.test(k)){
                    dp[i+1][W-1] += dp[i][W-1];
                    dp[i+1][W-1] %= MOD;
                }
            }
        }
    }
    cout << dp[H][K-1] << endl;
}

Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;
#define int long long
typedef pair<int, int> P;
map<P, int> M;

signed main() {
  int H, W, N; cin >> H >> W >> N;
  P a[100000];
  for(int i = 0; i < N; ++i) {
    cin >> a[i].first >> a[i].second;
    a[i].first--, a[i].second--;
  }
  sort(a, a + N);
  int sum[10] = {(H-2) * (W-2), 0, 0, 0, 0, 0, 0, 0, 0, 0};
  for(int i = 0; i < N; ++i) {
    for(int j = -2; j <= 0; ++j) {
      for(int k = -2; k <= 0; ++k) {
        int X = a[i].first + j, Y = a[i].second + k;
        if(X < 0 || Y < 0 || X + 2 >= H || Y + 2 >= W) continue;
        if(M[P(X, Y)] == 1) continue;
        int cnt = 0;
        for(int l = 0; l <= 2; l++) {
          for(int m = 0; m <= 2; ++m) {
            int cx = X + l, cy = Y + m;
            int D = lower_bound(a, a + N, P(cx, cy)) - a;
            if(a[D] == P(cx, cy)) cnt++;
          }
        }
        if(cnt >= 1) {
          sum[0]--;
          sum[cnt]++;
          M[P(X, Y)] = 1;
        }
      }
    }
  }
  for(int i = 0; i <= 9; ++i) cout << sum[i] << endl;
  return 0;
}



Measured memory_bytes: 58112
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a)
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;

inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=100005;
//i_am_noob
int n,cnt=0,pow3[maxn],sum[maxn][4],ans=0,x;
string str;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> str;
    n=sz(str);
    rep(n) cnt+=str[i]=='?';
    pow3[0]=1;
    rep(maxn-1) pow3[i+1]=pow3[i]*3%MOD;
    rep(4) sum[0][i]=0;
    rep(n) sum[i+1][0]=sum[i][0]+(str[i]=='A');
    rep(n) sum[i+1][1]=sum[i][1]+(str[i]=='?');
    rep(n) sum[i+1][2]=sum[i][2]+(str[n-1-i]=='C');
    rep(n) sum[i+1][3]=sum[i][3]+(str[n-1-i]=='?');
    rep(n){
        if(str[i]=='B'||str[i]=='?'){
            if(str[i]=='B') x=0;
            else x=1;
            if(cnt>=x) ans=add(ans,sum[i][0]*sum[n-1-i][2]%MOD*pow3[cnt-x]%MOD);
            if(cnt>=x+1) ans=add(ans,sum[i][1]*sum[n-1-i][2]%MOD*pow3[cnt-x-1]%MOD);
            if(cnt>=x+1) ans=add(ans,sum[i][0]*sum[n-1-i][3]%MOD*pow3[cnt-x-1]%MOD);
            if(cnt>=x+2) ans=add(ans,sum[i][1]*sum[n-1-i][3]%MOD*pow3[cnt-x-2]%MOD);
        }
    }
    print1(ans);
	return 0;
}


Measured memory_bytes: 4432
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
  let (H, W): (i64, i64) = {
    let v = read_vec();
    (v[0], v[1])
  };

  let (h, w): (i64, i64) = {
    let v = read_vec();
    (v[0], v[1])
  };

  println!("{}", (H-h)*(W-w));

}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String s1 = sc.next();
		String s2 = sc.next();
		String s3 = sc.next();
		sc.close();
	
		String ans = "" + s1.charAt(0) + s2.charAt(0) + s3.charAt(0);
		ans = ans.toUpperCase();		
		System.out.println(ans);

	}

}

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

ll gcd(ll a, ll b)
{
    return (a % b ? gcd(b, a % b) : b);
}

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

ll N, ans = 1;

int main()
{
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        ll t;
        cin >> t;
        ans = lcm(ans, t);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    primes = get_primes(55555)
    out = []
    num = 0
    for prime in primes:
        if prime%5 == 1:
           out.append(prime)
           num += 1
        if n == num:
            print(*out)
            return

def get_primes(x):
    if x < 2:
        return []
    if x == 2:
        return [2]
    limit = x**0.5 + 1
    nums = list(range(3, x+1, 2))
    divider = 3
    dividers = []
    while limit > divider:
        dividers.append(divider)
        nums = [num for num in nums if num%divider]
        divider = nums[0]
    return dividers+nums
        
if __name__ == "__main__":
    main()

Measured memory_bytes: 4212
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextInt();
		long B = sc.nextInt();
		long C = sc.nextInt();
		long K = sc.nextInt();
		if (A >= K) {
			System.out.println(K);
		} else if (A + B >= K) {
			System.out.println(A);
		} else {
			System.out.println(A - (K - A - B));
		}
	}
}


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

using namespace std;

int a[100010];

int work(int l,int r)
{
    int x=a[r-1];

    int i=l-1;

    for(int j=0;j<r-1;j++)
    {
        if(a[j]<=x)
        {
            swap(a[j],a[++i]);
        }
    }
    swap(a[r-1],a[++i]);

    return i;
}

int main()
{
    int n;

    while(scanf("%d",&n)!=EOF)
    {
        for(int i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
        }

        int idx=work(0,n);

        for(int i=0;i<idx;i++)
        {
            if(i)
            {
                printf(" ");
            }
            printf("%d",a[i]);
        }
        printf(" [%d]",a[idx]);

        for(int i=idx+1;i<n;i++)
        {
            if(i)
            {
                printf(" ");
            }
            printf("%d",a[i]);
        }

        printf("\n");
    }


    return 0;
}



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

typedef struct{

  int k;
  int pk;
  int lk;
  int rk;
  int h;

}Node;
  
int main(){
  int h,i,s;

  Node *node;
  
  scanf("%d",&h);

  node = (Node *)malloc(sizeof(Node) * h);
  
  for(i = 0 ; i < h ; i++) scanf("%d",&node[i].k);
  
  for(i = 0 ; i < h ; i++){
    node[i].h = i+1;
  }
  
  for(i = 0 ; i < h ; i++){
    if(i == 0){
      s = node[i].h;
      
      node[i].pk = 0;
      node[i].lk = node[2 * s - 1].k;
      node[i].rk = node[2 * s].k;
    }
    else if(i <= (h / 2)){
      s = node[i].h;
      
      node[i].pk = node[(s/2) - 1].k;
      node[i].lk = node[2 * s - 1].k;
      node[i].rk = node[2 * s].k;
    }

    else{
      s = node[i].h;
      
      node[i].pk = node[(s/2) -1].k;
      
    }
  }


  for(i = 0 ; i < h ; i++){
    s = node[i].h;
    
    printf("node %d: key = %d, ",i+1,node[i].k);
    if(i != 0) printf("parent key = %d, ",node[i].pk);
    
    if((2 * s) < h+1 ) printf("left key = %d, ",node[i].lk);
    if((2 * s + 1) < h+1) printf("right key = %d, ",node[i].rk);
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<string>

using namespace std;

	struct day{
		
		long long a,b,c;
		
	} Vacation[100090];
	long long DP[100090][3];

int main(){
	
	int n; cin >> n;
	for(int i = 0; i < n; i++) cin >> Vacation[i].a >> Vacation[i].b >> Vacation[i].c;
	
	DP[0][0] = Vacation[0].a;
	DP[0][1] = Vacation[0].b;
	DP[0][2] = Vacation[0].c;
	
	for(int i = 1; i < n; i++){
		
		DP[i][0] = max(DP[i-1][1],DP[i-1][2]) + Vacation[i].a;
		DP[i][1] = max(DP[i-1][0],DP[i-1][2]) + Vacation[i].b;
		DP[i][2] = max(DP[i-1][0],DP[i-1][1]) + Vacation[i].c;
		
	} cout << max(DP[n-1][0],max(DP[n-1][1],DP[n-1][2]));





	return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std ;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define rep(i,a,b) for(int i=a; i<=b; i++)
#define per(i,b,a) for(int i=b; i>=a; i--)
#define sz(v) (int)v.size()
#define len(s) (int)s.length()
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
typedef pair<int, int> pi ;
typedef vector<pair<int,int> > vpi ;
typedef vector<int> vi ;
typedef long long ll ;
typedef double db ;
typedef long double ldb ;
const int mod = 1e9 + 7;
const int cmod = 998244353 ;
const ll inf = 1e18 + 5;
const db cpi = 3.14159265358 ;
ll powmod(ll a, ll b) { ll ret = 1 ; while(b) { if(b&1) ret = (ret*a)%mod ;  a = (a*a)%mod ; b >>= 1 ; }  return ret ; }
const int maxn = 2e5 + 5 ;
int n ;
int a[maxn] ;
int pos[maxn] ;
int main()
{
    ios::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    cin >> n ;
    int left[maxn], right[maxn] ;
    rep(i,0,n-1)
    {
        cin >> a[i] ;
        pos[a[i]] = i ;
        left[i] = -1 ;
        right[i] = n ;
    }
    stack<pi> alive ;
    alive.push({a[0],0}) ;
    left[0] = -1 ;
    rep(i,1,n-1)
    {
        int x = a[i] ;
        while(!alive.empty() && alive.top().fi > x)
        {
            right[alive.top().se] = i ;
            alive.pop() ;
        }
        if(!alive.empty())
        {
            left[i] = alive.top().second ;
        }
        alive.push({a[i], i}) ;
    }
    ll res = 0 ;
    rep(i,1,n)
    {
        int x = pos[i] ;
        int l = left[x] ;
        int r = right[x] ;
        ll y = (x - l)*1LL*(r - x) ;
        res += y*i ;
    }
    cout << res << "\n" ;
    return 0 ;
}


Measured memory_bytes: 4992
using System ;

namespace Program{
 class Program{
  static void Main(string []args){
   string []buff = Console.ReadLine().Split(' ');
   int N = int.Parse(buff[0]);
   int K = int.Parse(buff[1]);
    
   string S =  Console.ReadLine();
   
   for(int i = 0 ;i < S.Length ;i++){
     if( i == K -1 ){
       Console.Write(  (char)(S[i] + ('a' - 'A') ) );
     }else{
       Console.Write( S[i] ) ; 
     }
   }
  }
 }
}

Measured memory_bytes: 13140
//AUTHOR:- Avinash//
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long int
#define lll long long
#define fo(i,n) for(int i=0;i<n;i++)
#define take(a,i,n) for(int i=0;i<n;i++) cin>>a[i]
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ld long long double
#define d1(x) cout<<(x)<<endl
#define T int t;cin>>t;while(t--)
#define hell 1000000007
#define ex endl;
#define F first
#define maxn 200001
#define pi 3.14159265
#define S second
#define P pair<int,int>
#define PP pair<int,pair<int,int>>
#define pb push_back
#define in insert
#define vec vector<ll>
#define vec2 vector<vector<int>>
#define s(a,n) sort(a,a+n);
#define sv(a) sort(a.begin(),a.end());
#define MAX 1000
//Author:-Avinash//
ll power(ll x, ll y, ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m;
    return (y%2 == 0)? p : (x * p) % m;
}
ll modInverse(ll a, ll m)
{
    return power(a, m-2, m);
}
int main(){
 FAST
 int64_t a,b,x;
 cin>>a>>b>>x;
if(a % x == 0) {
    cout << b / x - a / x + 1 << endl;
  }
  else {
    cout << b / x - a / x << endl;
  }
 //cout<<count<<endl;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REP2(i,x,n) for(ll i=x; i<(n); i++)
#define REP3(i,x,n) for(ll i=x; i>(n); i--)
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    ll N,M,p_input,sum_pena =0,sum_ac=0;
    cin >> N >> M;
    vector<ll>p(N,0);
    vector<bool>AC_first(N,false);
    string S;
    REP(i,M){
        cin >> p_input;
        p[p_input-1]++;
        cin >> S;
        if(S=="AC"){
            if(AC_first[p_input-1]==false){
                p[p_input-1]--;
                sum_pena += p[p_input-1];
                sum_ac++;
                AC_first[p_input-1]=true;
            }
        }
    }
    cout << sum_ac << " " << sum_pena << endl;
    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:

int p,r,t;
int l[310];
int need[310][310];
int proc[200010],res[200010];

bool avoid(int t){
	int cl[310],cur[310][310];
	bool term[310];
	
	rep(i,p)rep(j,r) cur[i][j]=0;
	rep(j,r) cl[j]=l[j];

	rep(i,t){
		cur[proc[i]][res[i]]++,cl[res[i]]--;
		term[proc[i]]=true;
		rep(j,r) if(cur[proc[i]][j]!=need[proc[i]][j]) term[proc[i]]=false;
		if(term[proc[i]]) rep(j,r) cl[j]+=need[proc[i]][j],cur[proc[i]][j]=0;
	}

	/*
	cout << need[0][0]-cur[0][0] << " " << need[0][1]-cur[0][1] << endl;
	cout << need[1][0]-cur[1][0] << " " << need[1][1]-cur[1][1] << endl;
	cout << cl[0] << " " << cl[1]  << endl;
	*/

	rep(loop,p){
		bool can=false;

		rep(i,p){
			if(term[i]) continue;
			bool ok=true;
			rep(j,r) if(need[i][j]-cur[i][j]>cl[j]) ok=false;
			
			if(ok==false) continue;
			can=true,term[i]=true;
			rep(j,r) cl[j]+=cur[i][j],cur[i][j]=0;
		}

		if(can==false) break;
	}

	rep(i,p) if(term[i]==false) return false;
	return true;
}

int main(void){
	cin >> p >> r >> t;
	rep(i,r) cin >> l[i];
	rep(i,p)rep(j,r) cin >> need[i][j];
	rep(i,t) cin >> proc[i] >> res[i],proc[i]--,res[i]--;

	int lb=0,ub=t+1;
	while(abs(ub-lb)>1){
		const int mid=(lb+ub)/2;
		if(avoid(mid))
			lb=mid;
		else
			ub=mid;
	}

	//rep(i,1,t+1) cout << i << " : " << (avoid(i)?"Avoid":"Unavoid") << endl;
	cout << (ub==t+1?-1:ub) << endl;
	return 0;
}

Measured memory_bytes: 5380
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li		int32_t
#define lli		long long
#define ulli unsigned long long

#define pn			 printf("\n")
#define nl			 cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define elif		else if
#define mset(a,b)	memset(a,b,sizeof(a))

#define pb		push_back
#define pob		pop_back
#define itr		iterator
#define sz()	size()
#define szof    sizeof
#define lb		lower_bound
#define ub		upper_bound
#define mp		make_pair
#define vlli    vector<lli>
#define plli	pair<lli,lli>
#define vplli	vector<plli >
#define F   	first
#define S		second
#define Dup     erase(unique(V.begin(),V.end()),V.end())

#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound

#define ALL(V)  V.begin(),V.end()

#define MX1     100000
#define MX2     1000000
#define MX3     1000
#define Inf     1000000000000000
#define mod		1000000007
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    opt;
    
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/
    
    lli T,t=1;
    T=1;
    
    while(T--)
    {
        lli N,i;
        cin>>N;
        
        vlli V;
        V.pb(0);
        rep(i,0,N)
        {
            lli x;
            cin>>x;
            
            V.pb(x);
        }
        V.pb(0);
        
        stack<lli>S1;
        lli dp1[N+2];
        
        S1.push(0);
        rep(i,1,N+1)
        {
            while(!S1.empty() and V[S1.top()]>V[i])
            {
                S1.pop();
            }
            
            dp1[i]=S1.top();
            S1.push(i);
        }
        
        stack<lli>S2;
        lli dp2[N+2];
        
        S2.push(N+1);
        repr(i,N,0)
        {
            while(!S2.empty() and V[S2.top()]>V[i])
            {
                S2.pop();
            }
            
            dp2[i]=S2.top();
            S2.push(i);
        }
        
        lli Sum=0;
        rep(i,1,N+1)
        {
            lli x=dp2[i]-dp1[i]-1;
            x=(x*(x+1))/2;
            lli y=i-dp1[i]-1,z=dp2[i]-i-1;
            
            y=(y*(y+1))/2;
            z=(z*(z+1))/2;   
            x-=y+z;   
                    
            Sum+=V[i]*x;
        }
        
        cout<<Sum;
        nl;
    }
    
    



 return 0;
}


Measured memory_bytes: 6640
#include<iostream>
#include<string>

using namespace std;

typedef long long ll;

int main(){
    ll n,R_cnt=0,G_cnt=0,B_cnt=0,All_cnt=0,Sub_cnt=0;
    string s;
    cin>>n>>s;

    for(int i=0; i<s.size(); i++){
        if(s[i]=='R'){
            R_cnt++;
        }
        if(s[i]=='G'){
            G_cnt++;
        }
        if(s[i]=='B'){
            B_cnt++;
        }
    }

    All_cnt=R_cnt*G_cnt*B_cnt;

    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            int k=2*j-i;
            if(s[i]==s[j])  continue;
            if(k>=n || s[i]==s[k] || s[j]==s[k]) continue;
            Sub_cnt++;
        }
    }

    cout<<All_cnt-Sub_cnt<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

vector<int> E(vector<int> a){
    return {a[3], a[1], a[0], a[5], a[4], a[2]};
}
vector<int> W(vector<int> a){
    return E(E(E(a)));
}
vector<int> S(vector<int> a){
    return {a[4], a[0], a[2], a[3], a[5], a[1]};
}
vector<int> N(vector<int> a){
    return S(S(S(a)));
}
random_device rnd;
int main() {
    vector<int> cu(6);
    char co;
    for (int i = 0; i < 6; i++){
        cin >> cu[i];
    }

    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int a, b;
        cin >> a >> b;

        while (1) {
            int k = rnd() % 2;
            if (k % 2) {
                cu = E(cu);
            } else {
                cu = S(cu);
            }
            if (cu[0] == a && cu[1] == b) {
                cout << cu[2] << endl;
                break;
            }
        }
    }
}



Measured memory_bytes: 3216
#pragma region Template
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RNG(i, a, b) for(int i = a; i < b; i++)
#define RBF(i, v) for(auto& i : v)
#define ALL(x) x.begin(), x.end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;
template<typename T> using VP = vector<pair<T, T>>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }
#pragma endregion

signed main() {
    string tmp;
    cin >> tmp;
    vector<int> abcd(4);
    for (int i = 0; i < 4; i++) abcd[i] = tmp[i] - '0';

    string ans;
    for (unsigned i = 0; i < 8; i++) {
        bitset<3> bits(i);
        int sum = abcd[0];
        for (int i = 1; i < 4; i++) {
            if (bits[i - 1]) sum += abcd[i];
            else sum -= abcd[i];
        }
        if (sum == 7) {
            ans = to_string(abcd[0]);
            for (int i = 1; i < 4; i++) {
                if (bits[i - 1]) ans += '+';
                else ans += '-';
                ans += to_string(abcd[i]);
            }
            ans += "=7\n";
            break;
        }
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 3700
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	void main() {
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = a - b;
		int[] aa = new int[n];
		for (int i = 0; i < n; i++)
			aa[i] = sc.nextInt();
		int lower = 0, upper = 1000000000;
		while (upper - lower > 1) {
			int k = (lower + upper) / 2;
			long x = 0;
			for (int i = 0; i < n; i++) {
				long d = aa[i] - (long) b * k;
				if (d > 0)
					x += (d + c - 1) / c;
			}
			if (x <= k)
				upper = k;
			else
				lower = k;
		}
		println(upper);
	}
}


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

int main(void){
    ll ans = 0;
    ll N;
    cin >> N;
    vector<ll> f(N + 1, 0);
    for(ll i = 1; i <= N; i++){
        for(ll j = 1; i * j <= N; j++) f[i * j]++;
    }
    for(ll i = 1; i <= N; i++) ans += i * f[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 81396
import java.util.Scanner;

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

        // rgb読み取り
        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();

        int rgb = Integer.valueOf("" + r + g + b);

        if (rgb % 4 == 0) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 20820
n = input()
op_cnt = len(n) - 1
ans = 0
for i in range(2 ** op_cnt):
    op = [""] * op_cnt
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"

    formula = ""
    for p_n, p_o in zip(n, op + [""]):
        formula += (p_n + p_o)
    ans += eval(formula)

print(ans)

Measured memory_bytes: 3060
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

alias Edge = Tuple!(int, "u", int, "v");

void main() {
    int N, M;
    scan(N, M);

    auto es = new Edge[](M);

    foreach (i ; 0 .. M) {
        int ai, bi;
        scan(ai, bi);
        ai--, bi--;
        es[i] = Edge(ai, bi);
    }

    int ans;

    foreach (i ; 0 .. M) {
        auto uf = UnionFind(N);

        foreach (j ; 0 .. M) {
            if (j == i) continue;
            uf.unite(es[j].u, es[j].v);
        }

        bool is_bridge = 0;

        foreach (j ; 0 .. N) {
            if (!uf.same(0, j)) is_bridge = 1;
        }

        if (is_bridge) ans++;
    }

    writeln(ans);
}

struct UnionFind {
    private {
        int N;
        int[] p;
        int[] rank;
    }

    this (int n) {
        N = n;
        p = iota(N).array;
        rank = new int[](N);
    }

    int find_root(int x) {
        if (p[x] != x) {
            p[x] = find_root(p[x]);
        }

        return p[x];
    }

    bool same(int x, int y) {
        return find_root(x) == find_root(y);
    }

    void unite(int x, int y) {
        int u = find_root(x), v = find_root(y);

        if (u == v) return;

        if (rank[u] < rank[v]) {
            p[u] = v;
        }
        else {
            p[v] = u;

            if (rank[u] == rank[v]) {
                rank[u]++;
            }
        }
    }
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template<typename T>
struct BinarySearchTree {
	struct Node {
		T key;
		Node *l, *r, *p;
		Node() {}
		Node(T key) :key(key) {}
		Node(T key, Node *l, Node *r) :key(key), l(l), r(r) {}
		bool operator<(Node &other) {
			return key < other.key;
		}
		bool operator>(Node &other) {
			return key > other.key;
		}
	};
	Node *root = nullptr, *NIL = nullptr;
	void insert(T key) {
		Node *x = root, *y = NIL;
		while (x != NIL) {
			y = x;
			if (key < x->key)x = x->l;
			else x = x->r;
		}
		dump(y);
		Node *z = (Node*)malloc(sizeof(Node));
		z->l = z->r = NIL;
		z->key = key;
		z->p = y;
		if (y == NIL)root = z;
		else {
			if (key < y->key)y->l = z;
			else y->r = z;
		}
	}
	void inorder() {
		inorder(root);
		puts("");
	}
	void inorder(Node *u) {
		if (u == NIL)return;
		inorder(u->l);
		printf(" %d", u->key);
		inorder(u->r);
	}
	void preorder() {
		preorder(root);
		puts("");
	}
	void preorder(Node *u) {
		if (u == NIL)return;
		printf(" %d", u->key);
		preorder(u->l);
		preorder(u->r);
	}
};
signed main() {
	int n; scanf("%d", &n);
	BinarySearchTree<int>bst;
	rep(i, 0, n) {
		string com;
		cin >> com;
		if (com == "insert") {
			int x; scanf("%d", &x);
			bst.insert(x);
		}
		else if (com == "print") {
			bst.inorder();
			bst.preorder();
		}
	}
	return 0;
}

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

#define endl "\n"

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;

void solve()
{
	ll a;
	cin >> a;
	cout << a + (a * a) + (a * a * a);
}

int main()
{

	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int t = 1;
	// cin >> t;

	while (t--)
	{
		solve();
	}

	return 0;
}




Measured memory_bytes: 3648
#include<stdio.h>

typedef long long ll;

int GCD(ll a, ll b){
    ll r;
    while( (r=a%b)!=0 ){      /*ユークリッドの互除法*/
        a=b;
        b=r;    
    }
    return b;
}

ll LCM(ll a, ll b){
    return (a*b) / GCD(a,b);
}

int main(void)
{
    ll a, b;

    scanf("%lld %lld", &a, &b);


    printf("%lld", LCM(a, b));
 
    return 0;
}

Measured memory_bytes: 128
from sys import stdin
import itertools

def main():

    input = stdin.readline

    N,M,X = map(int,input().split())
    
    C = []

    for _ in range(N):
       C.append(list(map(int,input().split())))

    ans_num = -1

    buy_list = [0] * (M+1)

    for i in range(1,N+1):
        for j in itertools.combinations(C, i):
            # 全部足す
            for k in j:
                buy_list = [x + y for (x, y) in zip(buy_list, k)]
            
            # 判定
            judge_list =  buy_list[1:]

            for l in judge_list:
                if l < X:
                    break
            else:
                if(ans_num == -1):
                    ans_num = buy_list[0]
                else:
                    ans_num = min(ans_num,buy_list[0])
            
            buy_list = [0] * (M+1)


    print(ans_num)

if __name__ == "__main__":
    main()

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

const int N = 1005;

int main() {

	FAST;

	int a, b;
	cin >> a >> b;
	for (int i = 1; i <= 1250; i ++) {
		if (int(double(i * 0.08)) == a && int(double(i * 0.1)) == b) {
			cout << i << '\n';
			return 0;
		}
	}
	cout << -1 << '\n';
	return 0;
}

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

int main() {
  int N;
  int a[2][101];
  std::cin >> N;
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < N; ++j)
      std::cin >> a[i][j];

  int max = 0;
  for (int i = 0; i < N; ++i) {
    int sum = 0;
    for (int j = 0; j < N; ++j) {
      if (j <= i)
        sum += a[0][j];
      if (j >= i)
        sum += a[1][j];
    }
    max = std::max(sum, max);
  }

  std::cout << max << std::endl;
}


Measured memory_bytes: 256