akhauriyash/Code-Regression huggingface dataset:
import scala.collection.mutable._
import io.StdIn.readInt
import io.StdIn.readLine

object Main extends App {
  val out = new java.io.PrintWriter(System.out)

  def calculate(q:Array[Int],d:Array[Array[Int]]):Int = {
    val ts = q(0)
    val te = q(1)
    val st = q(2)

    val a = d.filter(_(2) == st)
    val map = new HashMap[Int,Array[Int]]
    val log = ListBuffer.empty[Tuple2[Int,Int]]
    a.foreach(l => {
      if(l(3) == 1) map.put(l(1),l)
      else {
        val e = map.remove(l(1)).get
        log += {( e(0), l(0) )}
        }
    })
    // println(log.mkString)

    val time = Array.ofDim[Boolean](721)
    log.foreach(t => {
      val s = math.max(ts, t._1) -540
      val e = math.min(te, t._2) -540
      (s until e).withFilter(time(_) != true)
        .foreach(time(_) = true)
    })
    time.count(_ == true)
  }

  def solve(s:String):Unit = {
    val Array(n, m) = s.split(" ").map(_.toInt)
    val r = readInt
    val d = Iterator.continually(readLine)
      .take(r)
      .map(_.split(" ").map(_.toInt))
      .toArray
    val q = readInt
    Iterator.continually(readLine)
      .take(q)
      .map(_.split(" ").map(_.toInt))
      .foreach(qd => out.println(calculate(qd,d)))
  }

  Iterator.continually(readLine)
    .takeWhile(_ != "0 0")
    .foreach(solve(_))
  
  out.flush
}


Measured memory_bytes: 58428
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
int main(){
    unsigned long n,k,ans=0;cin>>n>>k;
    string s;cin>>s;
    vector<int> diff;
    For(i,n-1){
        if(s.at(i)!=s.at(i+1)){
            diff.push_back(i+1);
        }
    }
    ans=n-diff.size()-1;
    ans+=min(k*2,diff.size());
    cout<<ans<<endl;
}


Measured memory_bytes: 1020
n, ma, mb = map(int, input().split())
items = []
for i in range(n):
    item = list(map(int, input().split()))
    items.append(item)

# dp[iまでの薬品を使用して][aの重量][bの重量]を達成する最小の予算
dp = [[[float('inf')]*401 for j in range(401)] for i in range(41)]
dp[0][0][0] = 0

for i in range(n):
    a, b, c = items[i]
    for anow in range(400):
        for bnow in range(400):
            # 使わない
            dp[i+1][anow][bnow] = min(dp[i+1][anow][bnow], dp[i][anow][bnow])
            # 使う
            if 0<=anow+a<401 and 0<=bnow+b<401:
                dp[i+1][anow+a][bnow+b] = min(dp[i+1][anow+a][bnow+b], dp[i][anow][bnow]+c)
                

ans = float('inf')
for a in range(1, 401):
    for b in range(1, 401):
        if ma*b==mb*a:
            ans = min(ans, dp[n][a][b])
if ans == float('inf'):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 142264
/*
	##############################
	## Author: Pratyush Gaurav ###
	## College: NIT ROURKELA #####
	##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long/*--------------------*/lli;
typedef long double/*------------------*/ld;
typedef unsigned long long/*-----------*/ulli;
typedef pair<lli, lli >/*--------------*/plli;
typedef vector<plli >/*----------------*/vplli;

#define rep(i,a)/*---------------------*/for(i = 0 ; i < a ; i++)
#define repr(i,a)/*--------------------*/for(i = a ; i >= 0 ; i--)
#define REP(i,a,b)/*-------------------*/for(i = a ; i <= b ; i++)
#define REPR(i,a,b)/*------------------*/for(i = a ; i >= b ; i--)

#define scan(N)/*----------------------*/scanf("%lld",&N)
#define print(N)/*---------------------*/printf("%lld",N)
#define scan2(N1,N2)/*-----------------*/scanf("%lld %lld",&N1,&N2)
#define print2(N1,N2)/*----------------*/printf("%lld %lld",N1,N2)
#define scan3(N1,N2,N3)/*--------------*/scanf("%lld %lld %lld",&N1,&N2,&N3)
#define print3(N1,N2,N3)/*-------------*/printf("%lld %lld %lld",N1,N2,N3)

#define lb/*---------------------------*/lower_bound
#define ub/*---------------------------*/upper_bound
#define pb/*---------------------------*/push_back
#define popb/*-------------------------*/pop_back

#define mem(a,b)/*---------------------*/memset(a,b,sizeof(a))
#define opt/*--------------------------*/ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sz/*---------------------------*/size()

#define MP/*---------------------------*/make_pair
#define bs/*---------------------------*/binary_search
#define gcd(a, b)/*--------------------*/__gcd(a, b)
#define lcm(a, b)/*--------------------*/((a)*((b)/gcd(a,b)))
#define sqr(x)/*-----------------------*/(x)*(x)
#define all(a)/*-----------------------*/a.begin(),a.end()

#define ff/*---------------------------*/first
#define ss/*---------------------------*/second

#define endl/*-------------------------*/'\n'
#define inf/*--------------------------*/(lli)2000000000000
#define MOD/*--------------------------*/(lli)1000000007
#define MAXN/*-------------------------*/100005

template<class T> bool is_prime(T n)
{
	if((n%2 == 0 and n > 2) or n < 2 )
		return false;
	for(T i = 3; i*i <= n ; i += 2)
	{
		if( n % i == 0)
			return false;
	}
	return true;
}
lli power(lli a,lli b)
{
    lli value;
    if(!b)
    	return 1;
    else if(b%2==0)
    {
        value = power(a,b/2)%MOD;
        return (value * value)%MOD;
    }
    else
    {
        value = power(a,b/2)%MOD;
        return ((a*value)%MOD*(value))%MOD;
    }
}

int main()
{
	opt;
	double a,b,c;
	cin >> a >> b;
	c = (a+b)/2.0;
	c = round(c);
	cout << c << endl;
	return 0;
}










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

int main(){
    int m;
    cin >> m;
    
    int score_of_Taro = 0;
    int score_of_Hanako = 0;
    
    for(int i = 0; i < m; i++){
        string t, h;
        cin >> t >> h;
        
        if(t < h) score_of_Hanako += 3;
        else if(t > h) score_of_Taro += 3;
        else{
            score_of_Taro++;
            score_of_Hanako++;
        }
    }
    cout << score_of_Taro << " " << score_of_Hanako << endl;
    return 0;
}


Measured memory_bytes: 3148
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> using hset = unordered_set<T>;
template<class Key, class T> using hmap = unordered_map<Key, T>;

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

int main() {
    int m, nmin, nmax, submax, ans;
    vi P;
    while (cin >> m >> nmin >> nmax) {
        if (m == 0) break;

        submax = 0;
        ans = nmin;
        P.resize(m);
        for (int i = 0; i < m; i++) cin >> P[i];

        for (int n = nmin; n <= nmax; n++) {
            if (P[n-1] - P[n] >= submax) {
                submax = P[n-1] - P[n];
                ans = n;
            }
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define test(t) int t ; cin>>t ; while(t--)
int n , k;
int main(){
    cin >> n >> k;
    int arr[n];
    for(int i = 0 ; i < n ; ++i){
        cin >> arr[i];
    }
    sort(arr,arr+n);
    int i = 0 ;
    int temp = arr[0];
    while(i < n && arr[i] == temp){
        i++;
    }
    i--;
    int ans = 0;
    for(; i < n-1 ;){
        for(int j = i ; j < i+k && j < n ; ++j){
            arr[j] = temp;
        }
        ans++;
        i+=k-1;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {

        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        static void SolveA(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[,] g = new int[n, n];
            for(int i=0;i<n;++i)
            {
                string[] szarr = Console.ReadLine().Split(' ');
                //int u = int.Parse(szarr[0]);
                int k = int.Parse(szarr[1]);
                for(int j=0;j<k;++j)
                {
                    int v =int.Parse( szarr[j+ 2]);
                    int idx = v - 1;
                    g[i, idx] = 1;
                }
            }
            for(int i=0;i<n;++i)
            {
                for(int j = 0;j<n;++j)
                {
                    Console.Write(g[i, j]);
                    if( j != n - 1)
                    {
                        Console.Write(' ');
                    }
                }
                Console.WriteLine();
            }
        }
    }

}



Measured memory_bytes: 9332
from collections import Counter
from functools import reduce
from operator import and_

n = int(input())

cs = [Counter(input()) for _ in range(n)]
enable_chars = reduce(and_, (set(c.keys()) for c in cs))

for enable_char in sorted(enable_chars):
    enable_counts = min(c[enable_char] for c in cs)
    print(enable_char * enable_counts, end="")
print()


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n);i++)
#define rep1(i,n) for(int i=1; i<(n); i++)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
const int INF = 1e9;
const LL LLINF = 1e16;
const int mod = 1e9+7;

int main(){
    int x,y,z,k;
    cin >> x >> y >> z >> k;
    vector<LL> a(x), b(y), c(z);
    rep(i, x) cin >> a[i];
    rep(i, y) cin >> b[i];
    rep(i, z) cin >> c[i];

    priority_queue<LL, vector<LL>, greater<LL>> ab;
    repe(i, a)repe(j, b){
        ab.push(i+j);
        if(ab.size() > k) ab.pop();
    }

    priority_queue<LL> ans;
    rep(i, min(x*y, k)){
        repe(j, c){
            ans.push(ab.top()+j);
            //cout << ab.top()+j << endl;
        }
        ab.pop();
    }
    rep(i, k){
        cout << ans.top() << endl;
        ans.pop();
    }

}

Measured memory_bytes: 35080
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort()
B.sort()
C.sort()

ans = 0
import bisect
for b in B:
    ia = bisect.bisect_left(A, b)
    ic = n-bisect.bisect_right(C, b)
    ans += ia*ic
print(ans)


Measured memory_bytes: 105444
#define ffor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;


int main(){
    long long n,m;
    cin >> n >> m;

    if(abs(n-m)>1){
        cout << 0 << endl;
        return 0;
    }

    if(n == m){
        unsigned long long sum = 1;
        for(long long i=1; i <= n; ++i){
            sum *= (i%1000000007);
            sum *= (i%1000000007);
            sum %= 1000000007;
        }
        cout << (sum*2)%1000000007 << endl;
        return 0;
    }

    if(n != m){
        if(n < m) swap(n,m);
        unsigned long long sum = 1;
        for(long long i=1; i <= n; ++i){
            sum *= (i%1000000007);
            if(i!=n){
                sum *= (i%1000000007);
                sum %= 1000000007;
            }
        } 
        cout << sum% 1000000007 << endl;
    }

	return 0;
}

Measured memory_bytes: 256
s = list(raw_input())
for op1 in '+-':
    for op2 in '+-':
        for op3 in '+-':
            exec 'ans=%s%s%s%s%s%s%s' % (s[0], op1, s[1], op2, s[2], op3, s[3])
            if ans == 7:
                print '%s%s%s%s%s%s%s=7' % (s[0], op1, s[1], op2, s[2], op3, s[3])
                exit()

Measured memory_bytes: 2568
#include <iostream>
#include <bits/stdc++.h> 
#include <string>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef priority_queue<int> pqi;
typedef priority_queue<int, vi, greater<int>> mpqi;

#define IOS std::ios::sync_with_stdio(false); cin.tie(0);
#define F0R(i,a) for(int i = 0; i < a; i++)
#define R0F(i,a) for(int i = a - 1; i >= 0; i--)
#define pb push_back
#define mp make_pair
#define ins insert
#define ft front()
#define bk back()
#define f first
#define s second
#define trav(a,x) for(auto& a : x)
#define ALL(x) (x).begin(), (x).end()

const int MOD = 1000000007;
const int MX = 2e5+2;
const ll INF = 1000000000000000000;
const ld PI = 4*atan((ld)1);
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

bool tkmin(int a, int b){ return b < a ? a = b, true : false; }
bool tkmax(int a, int b){ return b > a ? a = b, true : false; }
int rudiv(int a, int b){ return a/b + !(a % b == 0); }

// Output
void op(int ok){ cout << ok << endl; }
void op(string ok){ cout << ok << endl; }
void op(ll ok){ cout << ok << endl; }
void op(char ok){ cout << ok << endl; }
void op(db ok){ cout << fixed << setprecision(7) << ok << endl; }
void op(ld ok){ cout << fixed << setprecision(7) << ok << endl; }
void op(pi ok){ cout << ok.f << " " << ok.s << endl; }
void op(pl ok){ cout << ok.f << " " << ok.s << endl; }
void op(pd ok){ cout << ok.f << " " << ok.s << endl; }

// -----------

ll n, k;

int main(){
    IOS;
    cin >> n >> k;
    op(min(n%k, abs(k - n%k)));
    return 0;
    // You should actually read the notes to self.
}

/* NOTES TO SELF:
    Int overflow? Array bounds?
    Edge cases? (n = 1, n = 0)
    Don't be dumbosity please pace yourself.
*/

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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var sheep = input[0];
            var wolf = input[1];

            Console.WriteLine(wolf >= sheep ? "unsafe" : "safe");
        }
    }
}


Measured memory_bytes: 28304
#include<stdio.h>
int main(void)
{
	int a, b, d, r;
	double f;
	scanf("%d %d", &a, &b);
	d=a/b;
	r=a%b;
	f=(double)a/(double)b;
	printf("%d %d %f\n", d, r, f);
	return 0;
}


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

int main () {
    int n, x;
    cin >> n >> x;
    
    while (n != 0 || x != 0) {
        int sum = 0;
        int result = 0;
        for (int i = 1; i <= n-2; i++) {
            for (int j = i+1; j <= n-1; j++) {
                for (int k = j+1; k <= n; k++) {
                    sum = i + j + k;
                    if (sum == x) result++;
                }
            }
        }
        cout << result << endl;
        cin >> n >> x;
    }
    
    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <bits/stdc++.h>

using namespace std;

long long n, s;

int main () {
    cin >> n;
    for ( int i = 1; i <= n; i++) {
        if ( i % 3 != 0 && i % 5 != 0 ) {
            s = s + i;
        }
    }
    cout << s;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;cin>>s;
    if(s=="ABC") cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int M = 505, MOD = 1e9 + 7;
ll dp[M][M], a[M], cb[M][M], pw[M][M];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, m;
    cin >> n >> m;

    for (int i = 0; i < M; i++) {
        cb[i][0] = 1;
    }

    for (int i = 1; i < M; i++) {
        for (int j = 1; j < M; j++) {
            cb[i][j] = (cb[i - 1][j - 1] + cb[i - 1][j]) % MOD;
        }
    }

    for (int i = 0; i < M; i++) {
        pw[i][0] = 1;
        for (int j = 1; j < M; j++) {
            pw[i][j] = pw[i][j - 1] * i % MOD;
        }
    }

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

    dp[0][0] = 1;

    for (int i = m; i > 0; i--) {
        for (int c = m; c >= 0; c--) {
            for (int s = m; s >= 0; s--) {
                if (dp[c][s]) {

                    ll cur = dp[c][s];
                    dp[c][s] = 0;



                    for (int j = 0; s + j * i + c - 1 <= m; j++) {
                        int ns = s + j * i,
                            nc = c + j;

                        dp[nc][ns] = (dp[nc][ns] 
                            + cur * cb[nc][j] % MOD * pw[ns - (i - 1) * nc][a[i]]) % MOD;
                    }
                }
            }
        }
    }

    ll ans = 0;

    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= m; j++) {
            int k = m - j - (i - 1);
            ll cur = dp[i][j] * cb[i + k][k] % MOD;

            if ((m - j) & 1) {
                ans = (ans - cur + MOD) % MOD;
            }
            else {
                ans = (ans + cur) % MOD;
            }
        }
    }

    cout << ans;
    
    return 0;
}

Measured memory_bytes: 6272
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <vector>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if( (A<C && C<B) || (A>C && C>B)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;

const int N = 1e3 + 5;
const int mod = 1e9 + 7;

int n, m, dp[N][N];
char a[N][N];

void add (int &x, int y) {
    x += y;
    if (x >= mod) x -= mod;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> a[i][j];
    dp[1][1] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (i == 1 && j == 1) continue;
            if (a[i][j] == '#') continue;
            add(dp[i][j], dp[i - 1][j]);
            add(dp[i][j], dp[i][j - 1]);
        }
    }
    
    cout << dp[n][m];
    return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
#define pb push_back
#define INF 1e15 + 7
#define MOD 1000000007

struct Edge {
	int s;
	int t;
};
using VE = vector<Edge>;
using VVE = vector<VE>;


int main(int argc, char **argv) {
	string str;
	cin >> str;
	int n = str.size();
	VI a(n);
	for (int i = 0; i < n; ++i) {
		a[i] = str[i] == '?' ? -1 : (str[i] - '0');
	}
	VVL dp(n + 1, VL(13, 0));
	dp[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		if(a[i - 1] < 0) {
			for (int j = 0; j < 13; ++j) {
				for (int k = 0; k < 10; ++k) {
					dp[i][(j * 10 + k) % 13] += dp[i - 1][j];
					dp[i][(j * 10 + k) % 13] %= MOD;
				}
			}
		}else {
			for (int j = 0; j < 13; ++j) {
				dp[i][(j * 10 + a[i - 1]) % 13] = dp[i - 1][j];
			}
		}
	}
//	for (int i = 0; i <= n; ++i) {
//		for (int j = 0; j < 13; ++j) {
//			cout << dp[i][j] << " ";
//		}
//		cout << endl;
//	}
	cout << dp[n][5] << endl;
	return 0;
}


Measured memory_bytes: 14080
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(obj) rbegin(obj), rend(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1LL << 60);
const int INf = 1e9;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
    fill((T*)array, (T*)(array + N), val);
}
int main() {
    ll d, g,cnt,ans = INf; cin >> d >> g; vector<ll> p(d), c(d);
    rep(i, d) cin >> p[i] >> c[i];
    rep(i, (1 << d)) {
        ll sum = 0; cnt = 0;
        rep(j, d) {
            if (i & (1 << j)) {
                sum += c[j] + p[j] * (j + 1) * 100;
                cnt += p[j];
            }
        }
        if (sum >= g) {
            ans = min(ans, cnt);
            continue;
        }
        rrep(j, d) {
            bool f = false;
            if (!(i & (1 << j))) {
                req(k, p[j] - 1) {
                    cnt++; sum += (j + 1) * 100;
                    if (sum >= g) {
                        ans = min(ans, cnt);
                        f = true;
                        break;
                    }
                }
            }
            if (f) break;
        }
    }cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long dp[200][200005];
int main()
{
    int n, w;
    cin >> n >> w;  
    int a[n], b[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    
    }
    for (int i = 0; i < n; i++)  { 
        for (int j = 0; j <= w; j++)  { 
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            if(j + a[i] <= w) {
                dp[i + 1][j + a[i]] = max(dp[i][j] + b[i], dp[i][j + a[i]]);
            }
        }
    }
    cout << dp[n][w];

}

Measured memory_bytes: 156416
#include<iostream>
using namespace std;
int main()
{
    long long n, p = 1;
    cin >> n;
    long long a[n];
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        if(a[i] == 0)
        {
            cout << 0;
            return 0;
        }
    }
    for(int i = 0; i < n; i++)
    {
        if(a[i] <= 1000000000000000000 / p)
        {
            p = p * a[i];
        }
        else
        {
            cout << -1;
            return 0;
        }
    }
    cout << p;
    return 0;
}

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < D; j++) {
            cin >> X[i][j];
        }
    }

    int cnt = 0;

    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            bool flag = false;
            ll sum = 0;
            for (int k = 0; k < D; k++) {
                sum += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
            }
            for (ll k = 0; k < 10000; k++) {
                if (k * k == sum) {
                    flag = true;
                    break;
                }
            }
            if (flag) {
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 256
#include<cstdio>
int main(){
    int a[4],b[4];
    while(~scanf("%d",&a[0])){
        bool e[10];
        for(int i=0;i<10;i++){
            e[i]=false;
        }
        int hi=0,bl=0;
        e[a[0]]=true;
        for(int i=1;i<4;i++){
            scanf("%d",&a[i]);
            e[a[i]]=true;
        }
        for(int i=0;i<4;i++){
            scanf("%d",&b[i]);
            if(a[i]==b[i]) hi++;
            else if(e[b[i]]) bl++;
        }
        printf("%d %d\n",hi,bl);
    }
}

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

namespace AtCoder0822
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            //int N = int.Parse(Console.ReadLine());
            long[] NXT = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            long N = NXT[0];
            long X = NXT[1];
            long T = NXT[2];
            if (N % X == 0)
            {
                Console.WriteLine((N / X ) * T);
            }
            else
            {
                Console.WriteLine((N / X + 1) * T);
            }
        }
    }
}


Measured memory_bytes: 28212
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <iterator>
#include <cmath>
#include <stack>
#include <functional>
using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> tri(3);

  while(n > 0) {
    cin >> tri[0] >> tri[1] >> tri[2];
    sort(tri.begin(), tri.end());
    if(pow(tri[0], 2) + pow(tri[1], 2) == pow(tri[2], 2))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
    n--;
  }
  return 0;
}

Measured memory_bytes: 1204
use std::io;

fn main() -> io::Result::<()>{
    // read the input from console
    let n : u128 = {
	let stdin = io::stdin();
	let mut buf = String::new();
	stdin.read_line(&mut buf)?;
	buf.retain(|c| c!='\n');
	buf.parse().unwrap()
    };

    // head of convertion
    let res = convert(&n);
    println!("{}", res);
    Ok(())
}


fn convert(n : &u128) -> String {
    const NUM_OF_ALPHABET : u128 = 26;
    let mut n = *n;
    let mut res = Vec::new();                      

    while n > 0{
	n -= 1;
        let tmp = n % NUM_OF_ALPHABET;
        n /= NUM_OF_ALPHABET;   // updating n
	res.push((tmp) as u8 + 0x61);
    }
    res.reverse();
    String::from_utf8(res).unwrap()
}


Measured memory_bytes: 2156
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;
 
int main(void){
    int n, d;
    cin >> n >> d;
    int x[n+1][d+1];
    for(int i = 0; i < n; i++)
        for(int j = 0; j < d; j++)
            cin >> x[i][j];
    for(int j = 0; j < d; j++)
        x[n][j]=x[0][j];
    double dis;
    int count = 0;
    for(int i = 0; i < n-1; i++){
        for(int j = i+1; j < n; j++){
            dis = 0;
            for(int k = 0; k < d; k++){
                dis += abs(x[i][k]-x[j][k])*abs(x[i][k]-x[j][k]);
            }
                  dis = sqrt(dis);
        if(ceil(dis) == floor(dis))
            count++;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <complex>
#include <cassert>
#include <random>
#include <cstring>
#include <numeric>
#define ll long long
#define ld long double
#define null NULL
#define all(a) a.begin(), a.end()
#define forn(i, n) for (int i = 0; i < n; ++i)
#define sz(a) (int)a.size()
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
template<class T> int gmax(T &a, T b) { if (b > a) { a = b; return 1; } return 0; }
template<class T> int gmin(T &a, T b) { if (b < a) { a = b; return 1; } return 0; }
using namespace std;
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
    int n;
    while(cin >> n) {
        ll ans = 1;
        for(int i = 0; i < 3; ++i) {
            ans *= n;
        } 
        cout << ans << endl;
    }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++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 DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int used[114514], ans[114514];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, p[114514], y[114514];
	pair<int, pii> yp[114514];
	cin>>n>>m;
	REP(i, m){
		cin>>p[i]>>y[i];
		yp[i]=make_pair(y[i], pii(p[i], i));
	}
	sort(yp, yp+m);
	REP(i, m){
		ans[yp[i].second.second]=++used[yp[i].second.first];
	}
	REP(i, m){
		int tmp=p[i], cnt=0;
		while(tmp>0){
			tmp/=10;
			++cnt;
		}
		REP(j, 6-cnt){
			cout<<0;
		}
		cout<<p[i];
		tmp=ans[i];
		cnt=0;
		while(tmp>0){
			tmp/=10;
			++cnt;
		}
		REP(j, 6-cnt){
			cout<<0;
		}
		cout<<ans[i]<<'\n';
	}
	return 0;
}


Measured memory_bytes: 4608
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
signed main(){
    
    
    int n,x[111111*2],a[111111*2];
    cin>>n;
    
    rep(i,n){
        cin>>x[i];
        a[i]=x[i];
    }
    sort(a,a+n);
    rep(i,n){
        if(a[(n+1)/2]>x[i])cout<<a[(n+1)/2]<<endl;
        else cout<<a[(n+1)/2-1]<<endl;
    }
    
    
	

}

Measured memory_bytes: 5504
import math
from bisect import  bisect_right

X = int(input())

s = list([1])

for i in range(2,math.ceil(1000**0.5)):
    for j in range(2,9):
        if i**j > 1000:
            break
        else:
            s.append(i**j)

s.sort()
print(s[bisect_right(s,X) -1]) 

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int func(int a){
  int sum = 0;
  while(a){
    int dig = a%10;
    sum+=dig;
    a/=10;
  }
  return sum;
}
    
int main(){
  int N,A,B;
  cin>>N>>A>>B;
  long long ans = 0;
  for(int i=1;i<=N;i++){
    int p = func(i);
    if(A<=p && p<=B){
      ans+=i;
    }
  }
  cout<<ans<<endl;
  return 0;
}
  

Measured memory_bytes: 256
N,K=map(int,input().split())
#L=[tuple(map(int,input().split())) for i in range(N)]
L = []
for i in range(N):
    li = list(map(int,input().split()))
    L.append(li)
    
#print(L)

L.sort()

#print(L)

ans=10**37
for i in range(N):
    for j in range(i+1,N):
        t=L[j][0]-L[i][0]
        S=sorted(x[1] for x in L[i:j+1])
        for k in range(len(S)-K+1):
            u=S[K+k-1]-S[k]
            ans=min(ans,u*t)
print(ans)

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
        int b = sc.nextInt();
		int ans = 0;
        for(int i = 1;i <= b - a; i++){
          ans = ans + i;
        }
        ans = ans - b;
        
        System.out.println(ans);

 
      	
 
    }
}

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

using namespace std;

int n, k;
int p[1010];
int main()
{
	cin >> n >> k;
	for(int i = 1; i <= n; i++)
	{
		cin >> p[i];
	}
	sort(p+1, p+n+1);
	int ans = 0;
	for(int i = 1; i <= k; i++)
	{
		ans += p[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3596
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    H, W, D = Scanner.map_int()
    A = Scanner.int_list_list(H)
    Q = Scanner.int()
    query = Scanner.int_list_list(Q)
    M = [0] * (H*W + 1)
    for h in range(H):
        for w in range(W):
            M[A[h][w]] = (w, h)
    S = [0] * (H * W + 1)
    for i in reversed(range(1, H*W+1)):
        if i + D >= H*W+1:
            S[i] = 0
        else:
            S[i] = S[i+D] + abs(M[i][0] - M[i+D][0]) + abs(M[i][1] - M[i+D][1])
    for q in query:
        print(S[q[0]] - S[q[1]])


if __name__ == "__main__":
    main()


Measured memory_bytes: 69980
A = []
A.append(list(map(int,input().split())))
A.append(list(map(int,input().split())))
A.append(list(map(int,input().split())))
N = int(input())

B = [[False for i in range(0,3,1)]for i in range(0,3,1)]
for i in range(0,N):
    n = int(input())
    for j in range(0,3):
        for k in range(0,3):
            if n == A[j][k]:
                B[j][k]=True

if (B[0][0]and B[0][1]and B[0][2])or(B[1][0]and B[1][1]and B[1][2])or(B[2][0]and B[2][1]and B[2][2])or(B[0][0]and B[1][0]and B[2][0])or(B[0][1]and B[1][1]and B[2][1])or(B[0][2]and B[1][2]and B[2][2])or(B[0][0]and B[1][1]and B[2][2])or(B[2][0]and B[1][1]and B[0][2]):
    print("Yes")
else:
    print("No")
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" <<; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;
ll mod = 1000000007;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<ll> memnum;

    UnionFind(ll N) { //最初は全てが根であるとして初期化
        init(N);
    }

    void init(ll N) {
        par.resize(N); memnum.resize(N);
        for (ll i = 0; i < N; i++) { par[i] = i; memnum[i] = 1; }
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }


    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        //
        memnum[ry] += memnum[rx];
    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }

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

    bool is_root(ll x) {
        return par[x] == x;
    }

    ll num(ll x) {
        return memnum[root(x)];
    }
};

ll combi(ll n, ll k) {
    if (n == k || k == 0)
        return 1;
    else {
        return combi(n - 1, k - 1) + combi(n - 1, k);
    }
}
int main()
{
    // 入力
    ll N, M;
    cin >> N >> M;
    vec A(M), B(M);
    UnionFind tree(N);
    REP(i, M) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }

    vec ans(M, 0);
    ans[M - 1] = N * (N - 1) / 2;
    IFOR(i, M, 1) {
        if (!tree.same(A[i], B[i])) {
            ans[i - 1] = ans[i] - tree.num(A[i]) * tree.num(B[i]);
        }
        else ans[i - 1] = ans[i];
        // debug(tree.num(A[i], N));
        tree.unite(A[i], B[i]);
    }

    REP(i, M) {
        cout << ans[i] << endl;
    }



    return 0;
}

Measured memory_bytes: 5248
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o C.exe C.cpp 
Execute: ./C
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

// Check if x is in an array p of length n
bool check_if_in_list(int x, int* p, int n) {
	for(int i = 0; i < n; i++) {
		if(p[i] == x) {
			return true;
		}
	}
	return false; 
}

int main() { 	
	int x, n, p[100];
	int min_distance = INT_MAX, minimizer = -100; 
	
	// Input 
	cin >> x >> n; 
	for(int i = 0; i < n; i++) {
		cin >> p[i]; 
	}
	
	// Edge case: n = 0
	if(n == 0) { 
		cout << x << endl; 
		return 0; 
	} 
	
	// Loop through possible values 
	for(int i = 0; i <= 101; i++) {
		if(abs(i-x) < min_distance && !check_if_in_list(i,p,n)) { 
			// guarantees you pick smallest minimizer
			minimizer = i; 
			min_distance = abs(i-x); 
		}
	}
	
	cout << minimizer << endl; 
	
	return 0; 
} 


Measured memory_bytes: 3620
n = gets.to_i
s = []
n.times do
  s << gets.chomp
end

m = gets.to_i
t = []
m.times do
  t << gets.chomp
end

s_uniq = s.uniq 
s_words_count = s_uniq.map do |word|
  [word, s.count(word)]
end.to_h

s_words_count_contained_t = s_uniq.map do |word|
  [word, t.count(word)]
end.to_h

money = s_words_count.map do |word, cnt|
  cnt - (s_words_count_contained_t[word] ||= 0)
end

puts [money.max, 0].max


Measured memory_bytes: 1788
{
  const main = (input: string): void | string | number => {
    const r = _reader(input)
    const [n, m] = r.nn()

    if (Math.abs(m - n) >= 2) {
      return 0
    }
    let res = _product(m, _mod, _product(n, _mod, 1))

    if (m === n) {
      res *= 2
    }
    return res % _mod
  }
  const _mod = 10 ** 9 + 7
  const _range = (n: number) => Array.from(Array(n).keys())
  const _product = (n: number, mod, start: number) =>
    _range(n).reduce((p, c) => (p * (c + 1)) % mod, start)

  const _reader = (str: string, i = 0) => {
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')
    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map(v => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  const _getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')
  const _res = main(_getInput())

  if (typeof _res === 'number' || typeof _res === 'string') console.log(_res)
}


Measured memory_bytes: 25272
import math
N, D = map(int, input().split())

X = [[] for _ in range(N)]
for i in range(N):
    X[i] = list(map(int, input().split()))

ans = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        dist = 0
        for d in range(D):
            dist = dist + (X[i][d] - X[j][d]) ** 2
        dist = math.sqrt(dist)
        if dist.is_integer():
            ans += 1

print(ans)


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

int main()
{
	int x2, y2, x = 0, y = 0, n;
	cin >> x2 >> y2 >> n;
	while (n--)
	{
		int a, b, c;
		cin >> a >> b >> c;
		if (c == 1) x = max(x, a);
		if (c == 2) x2 = min(x2, a);
		if (c == 3) y = max(y, b);
		if (c == 4) y2 = min(y2, b); 
	}
	if (x2 <= x || y2 <= y) puts("0");
	else cout << (x2-x)*(y2-y) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
       public static void main(String[] args){
              int nui[] = new int[10];
              Scanner docaonui = new Scanner(System.in);
              for (int i = 0; i < 10; i++){
                  nui[i] = docaonui.nextInt();
              }
              Arrays.sort(nui);
              System.out.println(nui[9]);
              System.out.println(nui[8]);
              System.out.println(nui[7]);        
       }
}

Measured memory_bytes: 26360
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 300010;
bool ok[maxn];
int n, k;
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> k;
	for (int i = 0;i < k;++i) {
		int len, id;
		cin >> len;
		while (len--) {
			cin >> id;
			ok[id] = true;
		}
	}
	int cnt = 0;
	for (int i = 1;i <= n;++i) if (!ok[i])
		++cnt;
	cout << cnt << '\n';
}



Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <sstream>

using namespace std;
typedef long long ll;

int main() {
	cin.sync_with_stdio(0); cin.tie(0); cout.tie(NULL);
	

	int n; cin >> n;
	cout << n + n * n + n * n * n << '\n';




}

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

// --------------------------------------------------------------------------------
#define FASTIO	ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define frepi(a,b) for(int i=a;i<=b;++i)
#define int long long
// --------------------------------------------------------------------------------

const int mod = 1e9+7;
void test_case(int tc)
{
	int n;cin>>n;
	ll arr[n+1];
	mset(arr,0);
	ll ans = 0;
	frepi(1,n)
	{
		cin>>arr[i];
		arr[i]=(arr[i]+arr[i-1]);
	}
	for(int i=1;i<n;++i){
		ll a = arr[i]-arr[i-1];
		ans+=(a*((arr[n]-arr[i]+mod)%mod))%mod;
		ans=ans%mod;
	}
	cout<<ans%mod;
}

int32_t main()
{
	FASTIO;
	#ifndef ONLINE_JUDGE
		freopen("/home/suryakant/input.txt","r",stdin);
		freopen("/home/suryakant/output.txt","w",stdout);
	#endif
	
    int tc=1;
    //cin>>tc;
    for(int i=1;i<=tc;++i)test_case(tc);
}

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

int main() {
    int n, t, input;
    std::cin >> n >> t;
    std::vector<int> tv(n);
    size_t time = t;
    for (int i = 0; i < n; i++) {
        std::cin >> tv[i];
    }
    for (int i = 1; i < n; i++) {
        int d = tv[i] - tv[i-1];
        if(d > t) {
            time += t;
        } else {
            time += d;
        }
    }
    std::cout << time << std::endl;
}

Measured memory_bytes: 1024
import java.util.*

class Scanner(`in`: java.io.InputStream) {
    private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))
    private var tokenizer: StringTokenizer? = null

    fun next(): String {
        if (tokenizer?.hasMoreTokens() != true) {
            tokenizer = StringTokenizer(reader.readLine())
        }
        return tokenizer!!.nextToken()
    }

    fun nextLine(): String {
        return if (tokenizer?.hasMoreTokens() != true) {
            reader.readLine()
        } else tokenizer!!.nextToken("\n")
    }
}

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

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

object Problem {
    data class ABCD(val a: Int, val b: Int, val c: Int, val d: Int)

    lateinit var dfs: (Array<Int>) -> Unit
    var ans = 0

    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val M = sc.next().toInt()
        val Q = Array(sc.next().toInt()) {
            ABCD(
                sc.next().toInt() - 1,
                sc.next().toInt() - 1,
                sc.next().toInt(),
                sc.next().toInt()
            )
        }

        dfs = { a ->
            if (a.count() < N + 1) {
                val next = (a.map { it } + a[a.count() - 1]).toTypedArray()
                while (next[next.count() - 1] <= M) {
                    dfs(next)
                    next[next.count() - 1]++
                }
            } else {
                var tmp = 0
                for (q in Q) {
                    if (a[q.b] - a[q.a] == q.c) tmp += q.d
                }
                ans = Math.max(ans, tmp)
            }
        }
        dfs(arrayOf(1))
        pw.println(ans)
    }
}


Measured memory_bytes: 53556
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount

int ar[200005];
int pre[200005];

int32_t main(){
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>ar[i];
		pre[i]=pre[i-1]+ar[i];
	}
	int mx = 0;
	for(int i=k;i<=n;i++){
		mx = max(mx,pre[i]-pre[i-k]);
	}
	mx += k;
	cout<<mx/2;
	if(mx&1){
		cout<<".5";
	}
}


Measured memory_bytes: 3328