akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define pii pair<ll, ll> 
#define pb push_back
#define mod (1e9+7)
#define debug(x) cerr<< #x << " is " <<x<<endl;
#define debug2(x) cerr<<#x<< " is\n"; for (auto &i:x) {cout<<i<<' '; } cout<<endl;
#define f first
#define s second
using namespace std;

const ll inf = 1ll<<60;

const int maxn = 1e5+5;

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int n, W; cin>>n>>W;
    vector<ll> dp(maxn, inf);
    dp[0]=0;
    for (int i=0; i<n; i++){
    	ll w, v; cin>>w>>v;
    	vector<ll> ndp(maxn, inf);
    	for (int j=0; j<maxn; j++){
    		if (j>=v) ndp[j]=min(dp[j],dp[j-v]+w);
    		else ndp[j]=dp[j];
    	}
    	dp=ndp;
    }
    for (int i=maxn-1; i>=0; i--){
    	if (dp[i]<=W){
    		cout<<i<<'\n';
    		return 0;
    	}
    }
    cout<<0<<'\n';
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main()
{
    int a;
    cin >> a;
    int step = 0;
    for(int i=1;i<10;i++){
        if(a/i*i==a&&a/i>0&&a/i<10)
        {
            step = 1;
            break;
        }
    }
    if(step == 1)
    cout << "Yes" << endl;
    else
        cout << "No" <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<ll> q;
    
    ll ans = 0;
    rep(i,n){
        ll a;
        cin >> a;
        ans += a;
        q.push(a);
    }
    rep(i,m){
        ll a = q.top();
        ans -= a - a / 2;
        q.pop();
        q.push(a / 2);
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1400
#include<stdio.h>
int main(){
int i,a,b,c,d = 0;
scanf("%d %d %d",&a,&b,&c);
for (i = a; i <= b; i++){
    a=a+1;
    if(c%i==0){

      d = d+1;
    }

}
printf("%d\n",d);
    return 0;
}



Measured memory_bytes: 2056
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let x: Vec<char> = read::<String>().chars().collect();
    let y: Vec<char> = read::<String>().chars().collect();
    let xnum = x[0] as u32;
    let ynum = y[0] as u32;
    if xnum < ynum {
        println!("<")
    } else {
        if xnum == ynum {
            println!("=")
        } else {
            println!(">")
        }
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
int main(){
  int n,m,i,j,en,out,S[10000],max;
  scanf("%d\n%d",&n,&m);
  S[0]=m;
  max=S[0];
  for (i=1;i<=n;i++){

    scanf("%d %d",&en,&out);
    S[i]=S[i-1]+en-out;

    if(max<S[i]){
      max=S[i];
    }
    if(S[i]<0)break;
  }
  if(S[i]<0){
    printf("%d\n",0);
  }else{
    printf("%d\n",max);
  }
  return 0;
}

Measured memory_bytes: 632
from subprocess import*
with open('Main.java','w')as f:f.write(r"""
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		PrintWriter out = new PrintWriter(System.out);
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int c[] = new int[n];
		int s[] = new int[n];
		int f[] = new int[n];
		for (int i = 1; i < n; i++) {
			c[i] = Integer.parseInt(sc.next());
			s[i] = Integer.parseInt(sc.next());
			f[i] = Integer.parseInt(sc.next());
		}
		for (int i = 1; i <= n; i++) {
			int t = 0;
			for (int j = i; j < n; j++) {
				if (t < s[j])
					t = s[j];
				else if ( t % f[j] != 0)
					t += f[j] - t % f[j];
				t += c[j];
			}
			out.println(t);
		}
		out.flush();
	}
}
""")
call(('javac','Main.java'))
call(('java','Main'))

Measured memory_bytes: 104288
#include<bits/stdc++.h>
using namespace std;
#define nl cout<<'\n';
int main()
{
    /*string s;
    cin>>s;
    if((s[0]==s[1]&&s[1]==s[2])||(s[1]==s[2]&&s[2]==s[3]))
      cout<<"Yes";
    else
      cout<<"No";*/
    int a,b;
    cin>>a>>b;
    cout<<ceil((a+b)/2.0);
    nl;
    return 0;
}


Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var L = long.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, long.Parse);
        for (int i = 0; i < n-1; i++)
            if (a[i+1] + a[i ] >= L) { Console.WriteLine("Possible"); putAns(n, i); goto end; }
        Console.WriteLine("Impossible");
        end:;
    }
    public static void putAns (int n, int p)
    {
        for (int i = 0; i <= p - 1; i++) Console.WriteLine(i + 1);
        for (int i = n-1; i >= p+2 ; i--) Console.WriteLine(i) ;
        Console.WriteLine(p + 1);
    }
}

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

// aのn乗のMOD
ll modpow(ll a,ll n){
    ll res = 1;
    while(n>0){
        // &１つはビット積
        if(n&1) res = res * a%MOD;
        a = a*a%MOD;
        n>>=1;
    }
    return res;
}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll N;
	cin >> N;
    vector<ll> C(N);
	rep(i,N){
		cin>>C[i];
	}
	sort(C.begin(),C.end(),greater<ll>());
	ll ans =0;
	ll s = modpow(2,2*N-2);
	
	rep(i,N){
		ans =(ans+ (((s*C[i])%MOD)*(i+2)))%MOD;
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 1792
def submit():
    h1, m1, h2, m2, k = map(int, input().split())
    
    time1 = h1 * 60 + m1
    time2 = h2 * 60 + m2

    if time1 > time2:
        time2 += 24 * 60

    print(time2 - time1 - k)


submit()

Measured memory_bytes: 9156
//package A;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		FastScanner in = new FastScanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		System.out.println(a * b);
	}

}
///////////////////////////////////TEMPLATE///////////////////////////////////
class FastScanner {
	BufferedReader br;
	StringTokenizer st;

	FastScanner(InputStream stream) {
		try {
			br = new BufferedReader(new InputStreamReader(stream));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	FastScanner(File input) {
		try {
			br = new BufferedReader(new FileReader(input));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	String nextLine() {
		String s = "";
		try {
			s = br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return s;
	}

	String next() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(next());
	}

	long nextLong() {
		return Long.parseLong(next());
	}

	double nextDouble() {
		return Double.parseDouble(next());
	}
}


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

typedef long long int llint;

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

  sort(a.begin(), a.end());

  int mx= 0;
  int l = -1, r = -1;

  vector<int>::iterator it;

  int tar = a[n - 1] / 2;
  
  it = lower_bound(a.begin(), a.end(), tar);
  
  int e = 0;
  if(*it - tar  <= tar - *(it - 1)) {
    if(a[n - 1] != *it) e = *it;
    else                e = *(it - 1);
  } else {
    if(a[n - 1] != *(it - 1)) e = *(it - 1);
    else                      e = *it;
  }
  
  cout<< a[n - 1] << ' ' << e <<endl;

  return 0;
}


Measured memory_bytes: 892
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];





int main(){
	long long a;
    cin>>a;
    vector<long long> vec(a);
    rep(i,a){
        cin>>vec.at(i);
    }
    long long ret=0;
    long long cou=1;
    rep(i,a){
        if(vec.at(i)!=cou){
            ret++;
        }
        else{
            cou++;
        }
    }
    if(cou==1&&ret==vec.size()){
        cout<<-1<<endl;
    }
    else{
        cout<<ret<<endl;
    }
}



Measured memory_bytes: 1792
//ΔAGC029E
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 222222;
int n,f[N],e[N],c[N],s[N],g[N],a[N];
vector<int> v[N];
void dfs1(int u,int fa){
	f[u]=fa;
	if(fa>e[fa])
		e[u]=fa,c[u]=e[fa];
	else{
		e[u]=e[fa];
		c[u]=max(fa,c[fa]);
	}
	int i=v[u].size(),x;
	while(i--){
		x=v[u][i];
		if(x==fa)
			continue;
		dfs1(x,u);
	}
}
void dfs2(int u){
	int i=v[u].size(),x;
	while(i--){
		x=v[u][i];
		if(x==f[u])
			continue;
		a[u]=x;
		dfs2(x);
	}
	x=a[e[u]];
	if(u<e[u]){
		s[u]++;
		s[x]--;
		if(u<e[f[x]]&&c[u]==e[f[x]])
			s[x]++,s[f[x]]--;
	}
	s[f[u]]+=s[u];
}
void dfs3(int u){
	g[u]+=g[f[u]];
	int i=v[u].size(),x;
	while(i--){
		x=v[u][i];
		if(x==f[u])
			continue;
		dfs3(x);
	}
}
int main()
{
	int i,x,y;
	scanf("%d",&n);
	for(i=1;i<n;i=i+1){
		scanf("%d%d",&x,&y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs1(1,0);
	dfs2(1);
	for(x=1;x<=n;x=x+1){
		//cout<<x<<':'<<s[x]<<endl;
		g[x]=1-s[x];
		for(i=v[x].size();i--;){
			y=v[x][i];
			if(y!=f[x])
				g[x]+=s[y];
		}
	}
	dfs3(1);
	for(i=2;i<=n;i=i+1)
		cout<<g[i]-1<<' ';
	return 0;
}

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

#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second
#define sf scanf

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

const int N = (int) 1e5;
const int INF = (int) 1e9 + 7;

const double pi = 3.14159265358979323846;

int main(int argc, char *argv[])
{
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);

	int r;
	cin >> r;
	cout << 2 * pi * r;

	return 0;
}


Measured memory_bytes: 3776
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

void no () { writeln (-1); }

void main() {
  int n;
  readf (" %d", &n);
  auto b = new int[n+1];
  foreach (i; 1 .. n + 1) {
    readf (" %d", &b[i]);
  }
  int[] x;
  foreach_reverse (i; 1 .. n + 1) {
    int bi;
    foreach_reverse (j; 1 .. i + 1) {
      if (b[j] == j) {
        bi = j;
        break;
      }
    }
    if (!bi) {
      no ();
      return;
    }
    x ~= bi;
    foreach (k; bi .. i) {
      b[k] = b[k+1];
    }
    debug stderr.writeln (bi, ' ', b[1 .. i]);
  }
  foreach_reverse (i; x) {
    writeln (i);
  }
  /*
  foreach_reverse (i; 1 .. n + 1) {
    int bi;
    foreach (j; 1 .. i + 1) {
      if (b[i] > i) {
        no ();
        return;
      }
      if (b[i] == i) {
        if (bi) {
          no ();
          return;
        }
        bi = i;
      }
      if (!bi) {
        no ();
        return;
      }
    }
  }
  */
}



Measured memory_bytes: 256
(defun solve (b)
  (cond
    ((string-equal b "A") "T")
    ((string-equal b "T") "A")
    ((string-equal b "G") "C")
    ((string-equal b "C") "G")))

(defun main ()
  (let ((b (read)))
    (format t "~A~%" (solve b))))

(main)


Measured memory_bytes: 10216
import numpy as np
n,d = map(int,input().split())
l = np.array([list(map(int,input().split())) for _ in range(n)])
#print(l)
c = 0
ans = []
for i in range(len(l)-1):
  for j in range(i+1,len(l)):
    u = l[i] - l[j]
    #print(u)
    ans.append(np.linalg.norm(u))
#print(ans)
for k in ans:
  if k % 1 == 0:
    c += 1
print(c)

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

// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion

int N;

vector<int> sieve_of_eratosthenes(int n) {
  vector<int> primes(n);
  for (int i = 2; i < n; ++i)
    primes[i] = i;
  for (int i = 2; i*i < n; ++i)
    if (primes[i])
      for (int j = i*i; j < n; j+=i)
        primes[j] = 0;
  return primes;
}

int main()
{
    cin >> N;
    vi arr = sieve_of_eratosthenes(1000);
    vi primes;
    rep(i, arr.size()) {
        if(arr[i]!=0) primes.push_back(i);
    }
    ll cnt = 0;
    ll ans = 1;
    for(int i = 0; i < primes.size(); i++){
        int cur = primes[i];
        int total = 0;
        while(cur <= N){
            total += (N/cur);
            cur = cur*primes[i];
        }
        if(total!=0) ans *= (total+1);
        ans %= MOD;
    }
    P(ans%MOD);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <string.h>
#include <bitset>
#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define allr(x) x.begin(),x.end(),greater<int>()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

int main(){
	ll a,b,x;
	cin >> a >> b >> x;
	ll ans;
	if(a == 0) ans = b/x + 1;
	else ans = b/x - (a-1)/x;
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << '\n'

typedef int64_t Int;
const double pi = M_PI;

using namespace std;

int main() {
    int a[3][3], N;
    for (int i = 0; i < 3; i++) {
        for (int k = 0; k < 3; k++) {
            cin >> a[i][k];
        }
    }
    cin >> N;
    int b[N];
    for (int i = 0; i < N; i++) {
        cin >> b[i];
    }

    bool c[3][3] = {{}}, ans = false;
    for (int i = 0; i < 3; i++) {
        for (int k = 0; k < 3; k++) {
            for (int l = 0; l < N; l++) {
                if (a[i][k] == b[l]) {
                    c[i][k] = true;
                }
            }
        }
    }

    for (int i = 0; i < 3; i++) {
        if (c[i][0] && c[i][1] && c[i][2]) {
            ans = true;
        }
        if (c[0][i] && c[1][i] && c[2][i]) {
            ans = true;
        }
    }
    if (c[0][0] && c[1][1] && c[2][2] || c[0][2] && c[1][1] && c[2][0]) {
        ans = true;
    }

    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
import java.util.HashSet;
import java.lang.Integer;
import java.lang.StringBuilder;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        long max = 1000000007;

        long power = 1;
        for (int i = 1; i <= N; i++) {
            power *= i;
            power %= max;
        }

        System.out.println(power);
    }
}

Measured memory_bytes: 22996
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    auto ns = stdin.byLine().map!(to!int).array();
    auto m = ns.reduce!max()+1;
    auto p = new bool[m];
    auto c = new int[m];
    foreach(i;2..m)
    {
        c[i]=c[i-1];
        if(!p[i])
        {
            ++c[i];
            foreach(j;2..((m+i-1)/i))
                p[i*j]=true;
        }
    }
    ns.map!(n=>c[n].to!string()).join("\n").writeln();
}

Measured memory_bytes: 6660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

#define MAX_N 100005
bool is_prime[MAX_N+1]; //is_prime[i]==true->iはprime

void sieve(int n) {
    rep(i,n+1) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    rep2(i,n+1) {
        if(is_prime[i]) {
            for(int j = 2 * i; j<= n; j+= i) is_prime[j] = false;
        }
    }
    return ;
}

int main(){
    sieve(100005);
    vei S(100005, 0);
    rep(i,MAX_N) if(is_prime[i] and is_prime[(i+1)/2]) S[i]++;
    rep1(i,MAX_N) S[i] += S[i-1];
    int Q; cin >> Q;
    rep(i,Q) {
        int r, l; cin >> l >> r;
        cout << S[r] - S[l-1] << endl;
    }
    return 0;
}

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

int main() {
  int c[10], sum = 0;
  for (int i = 0; i < 9; i++) {
    cin >> c[i];
    sum += c[i];
  }

  if (3 * (c[0] + c[4] + c[8]) == sum) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
open Batteries

let read_two () = Scanf.sscanf (read_line ()) "%d %d" (fun a b -> (a, b))

let read_three () =
  Scanf.sscanf (read_line ()) "%d %d %d" (fun a b c -> (a, b, c))

let read_four () =
  Scanf.sscanf (read_line ()) "%d %d %d" (fun a b c d -> (a, b, c, d))

let read_list () =
  read_line () |> String.split_on_char ' '
  |> List.map (fun s -> int_of_string s)

(* a**x *)
let pow a x =
  let rec aux acc = function 0 -> acc | n -> aux (acc * a) (n - 1) in
  aux 1 x

let rec pow2 n = if n mod 2 = 0 then 1 + pow2 (n / 2) else 0

let rec f n =
  if n = 1 then (1, 0)
  else
    let pn = pow2 n and nm, pnm = f (n - 1) in
    if pn > pnm then (n, pn) else (nm, pnm)

let () =
  let n = read_int () in
  let ans, _ = f n in
  print_int ans;
  print_newline ()


Measured memory_bytes: 3072
N = int(input())

def make_div(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

ans = N//make_div(N)[-1] + make_div(N)[-1] - 2

print(ans)

Measured memory_bytes: 3268
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()
#define all(a)  a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mod 1000000007
#define _for(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)

using namespace std;

int N;
int a[100005];

int main(){
   cin >> N;
   long long res = 0;
   for(int n = 0; n < N; ++n){
      scanf("%d", &a[n]);
   }
   int _min = 1;
   for(int n = 0; n < N; ++n){
      if(a[n] > _min){
         res += (a[n] - 1) / _min;
         a[n] = max(1, _min - 1);
      }
      if(a[n] == _min){
         ++_min;
      }
   }
   cout << res << endl;
   return 0;
}

Measured memory_bytes: 640
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    for i in range(H):
        for j in range(W):
            if i==0 or i==H-1 or j==0 or j==W-1:
                print('#',end='')
            else:
                print('.',end='')
        print()
    print()    


Measured memory_bytes: 7000
N, H = gets.split.map(&:to_i)
a, b = N.times.map { gets.split.map(&:to_i) }.transpose
amax = a.max
boveramax = b.select { |i| i > amax }.sort.reverse
bsum = 0
cnt = 0
boveramax.each do |i|
  bsum += i
  cnt += 1
  break if H <= bsum
end
p(cnt + ([(H - bsum), 0].max/amax.to_f).ceil)


Measured memory_bytes: 15376
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#define endl "\n"
typedef long long ll;
using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isPrime(ll n){
	if (n == 2 || n == 3 || n == 5)
		return true;
	else if (n % 2 == 0 || n % 3 == 0 || n % 5 == 0 || n == 1)
		return false;
	else {
		for (int i = 5; i <= sqrt(n); i += 2){
			if (n%i == 0)
				return false;
		}
		return true;
	}
}

char arr[107][107];
int main(){
	Lancer();
	ll r, c, t;
	cin >> r >> c;
	for (int i = 0; i < r; i++)
		for (int j = 0; j < c; j++)
			cin >> arr[i][j];
	for (int i = 0; i < r; i++){
		t = 0;
		for (int j = 0; j < c; j++){
			if (arr[i][j] == '.')
				t++;
		}
		if (t == c){
			for (int j = 0; j < c; j++){
				arr[i][j] = 'w';
			}
		}
	}
	
	
	for (int i = 0; i < c; i++){
		t = 0;
		for (int j = 0; j < r; j++){
			if (arr[j][i] == '.' || arr[j][i] == 'w')
				t++;
		}
		if (t == r){
			for (int j = 0; j < r; j++)
				arr[j][i] = 'w';
		}
	}
	for (int i = 0; i < r; i++){
		bool ch = false;
		for (int j = 0; j < c; j++){
			if (arr[i][j] != 'w'){
				cout << arr[i][j];
				ch = true;
			}
		}
		if(ch) cout << endl;
	}
	//cout << endl;
	return 0;
}


Measured memory_bytes: 3688
#include<stdio.h>

int main(void)
{
	int a, b, c;

	scanf("%d %d %d", &a, &b, &c);

	if (a < b && b < c)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 580
import java.util.*;
import java.io.*;

public class Main{

    static int INFTY = Integer.MAX_VALUE;
    public static void main (String args[]){
        //初期処理
        Scanner sc=new Scanner(System.in);
        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // try{
            // int n = Integer.parseInt(br.readLine());
        int n= sc.nextInt();
        int x = sc.nextInt();
        int ans=1;
        int d=0;
        for(int i=0;i<n;i++){
            d+=sc.nextInt();
            if(d<=x){
                ans++;
            }else{
                break;
            }
        }
        System.out.println(ans);

    }


}

Measured memory_bytes: 22736
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define bitget(a, b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vsort(x) sort(x.begin(), x.end())

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;

using namespace std;

int main() {
	int n, k;
	scanf("%d", &n);
	scanf("%d", &k);
	int x[200];
	rep(i, 0, n)
		scanf("%d", &x[i]);
	int64 ans = 0;
	rep(i, 0, n){
		if (x[i] > abs(k - x[i])){
			ans += abs(k - x[i]);
		}
		else{
			ans += x[i];
		}
	}
	ans <<= 1;
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int a,b,k;
 cin>>k;
 cin>>a>>b;
 if(a/k==b/k && a%k!=0 && b%k!=0)
 cout<<"NG"<<endl;
 else
 cout<<"OK"<<endl;
 return 0;
}


Measured memory_bytes: 3604
n,m,*abc=map(int,open(0).read().split())
a=abc[:n]
a.sort()
bc=[[x,y] for x,y in zip(abc[n::2],abc[n+1::2])]
bc.sort(key=lambda x:x[1],reverse=True)
ai = 0
for b,c in bc:
    cc = b
    while ai<n and cc >0:
        if a[ai] < c:
            a[ai] = c
            cc -= 1
        ai +=1
    if ai ==n:
        break
print(sum(a))
        


Measured memory_bytes: 35420
#include <iostream>
#include <array>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;
using std::array;
using std::sort;
using std::begin;
using std::end;

int main()
{
  int nums[3];

  cin >> nums[0] >> nums[1] >> nums[2];

  sort(begin(nums), end(nums));

  if(nums[0] == 5 && nums[1] == 5 && nums[2] == 7) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
N=int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
ans=0
for i in range(1,N+1):
    if i%2==1:
        if len(make_divisors(i))==8:
            ans+=1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
template<typename T>
inline void read(T &x)
{
	x=0;
	int f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') f=-1;
		ch=getchar();
}
	while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
	x*=f;
	return;
}	
template<typename T>
void write(T x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
	return;
}
int main()
{
    int n,r;
    cin>>r>>n;
    if(r<10) cout<<n+100*(10-r)<<endl;
    else cout<<n<<endl;
	return 0;
}


Measured memory_bytes: 256
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */
 
    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(ll i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(ll i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    #define te  ll ti;   cin >> ti;  while(ti--) solve();  
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 200100;

    void solve(){
        ll a, b, c;
        cin >> a >> b >> c;
        ll ans = max(0ll, c - abs(a-b));
        cout << ans << endl;
    }
 
    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
     /*
      #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
      #endif
     */
      //te
      solve();
      return 0;
    } 

Measured memory_bytes: 256
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N, K = nl()
import sys

if K > (N - 2) * (N - 1) // 2:
    print('-1')
    sys.exit()

add = (N - 2) * (N - 1) // 2 - K
M = N - 1 + add
print(M)

for i in range(2, N+1):
    print(1, i)

for i in range(2, N):
    for j in range(i+1, N+1):
        if add == 0:
            break
        print(i, j)
        add -= 1
    if add == 0:
        break


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


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

    int ans = 0;

    rep2(i,a,b+1){
        string s = to_string(i);
        if(s[0]==s[4] && s[1]==s[3]) ++ans;
    }
    
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

  // vector<vector<vector<int> > > DP =  vector<vector<vector<int> > >(100001,vector<vector<int> >(2,vector<int>(2,0)));
void solve(void)
{
  int N,K;
  cin>>N>>K;
  if((N-1)*(N-2)/2 <K)
  {
    cout<<-1<<endl;
    return;
  }
  int X = (N-1)*(N-2)/2 - K;
  int M =N-1 + X;
  cout<<M<<endl;;
  for (int i = 0; i < N-1; i++)
  {
    cout<<1 <<" "<<i+2<<endl;
  }
  vector<pair<int,int> > data;
  for (int i = 2; i < N; i++)
  {
    for (int j = i+1; j < N+1; j++)
    {
      pair<int,int> p;
      p.first = i; p.second = j;
      data.push_back(p);
    }
    
  }
  for (int i = 0; i < X; i++)
  {
    cout<<data[i].first <<" "<<data[i].second<<endl;
  }
  
  
    return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <queue>
#include <assert.h>
#include <cmath>
#include <deque>
#include <set>
#include <unordered_map>
#include <complex>
#include <fstream>
using namespace std;
using ll = long long;
using ld = long double;
const int mxn = 110;
const int inf = 1e5+5;
int b[mxn];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int ans = 0;

	int n; cin>>n;
	for(int i=0; i<n-1; i++) cin>>b[i];
	b[n-1] = inf;

	ans+=b[0];
	for(int i=1; i<n; i++) ans+=min(b[i-1], b[i]);
	cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <string>

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

int main() {
	int a, b;
	cin >> a >> b;
	if ((a + b) % 2 == 0) {
		cout << (a + b) / 2 << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
	return 0;
}


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

const int MP = 999983;
int sv[MP+1] = {}, ac[MP+1] = {};

int main() {
	sv[0] = sv[1] = 1;
	for (int i=2; i*i<=MP; ++i) {
		if ( ! sv[i]) {
			for (int j=i*i; j<=MP; j+=i) {
				sv[j] = 1;
			}
		}
	}
	for (int i=1; i<=MP; ++i) {
		ac[i] = ac[i-1] + 1 - sv[i];
	}
	int n, p, m;
	while (cin >> n, n) {
		int ret = 0, X;
		for (int i=0; i<n; ++i) {
			cin >> p >> m;
			ret += ac[min(MP, p+m)] - ac[max(0, p-m-1)] - 1;
		}
		cout << ret << endl;
	}
	return 0;
}

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int a, b;
	cin >> a >> b;
	if ((a * b) % 2 == 0) {
		cout << "Even" << '\n';
	} else {
		cout << "Odd" << '\n';
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100001;
pair <int, int> edge_color[N];
vector <int> tree[N];
int maxc=0;
void dfs(pair <int,int> now){
  int next_color=1;
  for (auto i:tree[now.first]){
  if (edge_color[i].second) continue;
  if (next_color==now.second) next_color++;
  maxc=max(maxc, next_color);
  edge_color[i].second=next_color;
  dfs(edge_color[i]);
  next_color++;

}
}
int main(){
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin>>n;
  for (int i=0; i<n-1; i++){
    int a,b;
    cin>>a>>b;
    if (a>b)swap(a,b);
    tree[a].push_back(i);
    edge_color[i]={b,0};
  }
  dfs ({1,0});
  cout<<maxc<<endl;
  for (int i=0; i<n-1; i++){
    cout<<edge_color[i].second<<endl;
  }
  }


Measured memory_bytes: 7680
a = []
ans = 0
mmin = 10
for i in range(5):
    a.append(int(input()))
for i in range(5):
    m = a[i] % 10
    if m > 0:
        mmin = min(mmin, m)
    for j in range(1, 14):
        if a[i] <= 10 * j:
            ans += 10 * j
            break

ans -= 10
ans += mmin
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;

const int maxn=105;

int n,times[maxn];

queue<int> q;

struct trie {
	int son[maxn][26];
	int fail[maxn];
	int l;
	int root;
	int num[maxn];
	int last[maxn];
	inline int index(char c) {
		return c-'A';
	}
	void insert(char *str) {
		int len=strlen(str),cur=0;
		for (register int i=0;i<len;++i) {
			int id=index(str[i]);
			if (!son[cur][id]) {
				son[cur][id]=++l;
			}
			cur=son[cur][id];
		}
		++num[cur];
		return;
	}
	void build(void) {
		for (register int i=0;i<26;++i) {
			if (son[0][i]) {
				fail[son[0][i]]=0;
				q.push(son[0][i]);
			}
		}
		while (!q.empty()) {
			int cur=q.front();
			q.pop();
			for (register int i=0;i<26;++i) {
				if (son[cur][i]) {
					fail[son[cur][i]]=son[fail[cur]][i];
					q.push(son[cur][i]);
				}
				else {
					son[cur][i]=son[fail[cur]][i];
				}
			}
		}
		return;
	}
	int query(char *str) {
		int len=strlen(str),cur=0,ans=0;
		for (register int i=0;i<len;++i) {
			cur=son[cur][index(str[i])];
			for (register int t=cur;t&&~num[t];t=fail[t]) {
				ans+=num[t];
				num[t]=-1;
			}
		}
		return ans;
	}
}ac;

char str[maxn];

int main() {
	str[0]='A';
	str[1]='C';
	ac.insert(str);
	ac.build();
	scanf("%s",str);
	puts(ac.query(str)?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#define MOD 1000000007
#define md 998244353
#define INF LLONG_MAX
#define F first
#define S second
#define sz(x) (long long)x.size()
#define vi vector<int>
#define vll vector<long long>
#define vpl vector<pair<long long,long long> >
#define vpi vector<pair<int,int> >
#define pb push_back
#define debug(x) cerr<<#x<<"= "<<x<<endl
#define all(v) v.begin(),v.end()
#define TT ll test;cin>>test; while(test--)
#define rep(i,a,n) for(ll i=a;i<(long long)n;++i)
#define repr(i,n,a) for(ll i=n;i>(long long)a;--i)
#define endl '\n'
#define MAXN 100005
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll res=0,pos1=0,pos2=n-1;
    while(pos1<pos2){
        if(s[pos1]=='W' && s[pos2]=='R'){
            ++res;++pos1;--pos2;
        }
        if(s[pos1]=='R')++pos1;
        if(s[pos2]=='W')--pos2;
    }
    cout<<res;
    return 0;
}

Measured memory_bytes: 3744
a, v = gets.chomp.split(" ").map(&:to_i)
b, w = gets.chomp.split(" ").map(&:to_i)
t = gets.chomp.to_i

if v - w <= 0 || a == b
  puts "NO"
  return
end

if (a - b).abs <= t * (v - w)
  puts "YES"
else
  puts "NO"
end


Measured memory_bytes: 14360
#include <cstdio>

void printFrame(int h, int w)
{
    for(int y = 0; y < h; ++y){
        for(int x = 0; x < w; ++x){
            if(y == 0 || y == h-1 || x == 0 || x == w-1){
                printf("#");
            }else{
                printf(".");
            }
        }
        printf("\n");
    }
    printf("\n");
}
int main()
{
    while(true){
        int h, w;
        scanf("%d %d", &h, &w);
        if(h == 0 && w == 0){
            break;
        }
        printFrame(h, w);
    }
    return 0;
}

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

ll f(vector<P> p) {
  int n = p.size();
  rep(i,n) p[i].first = min(p[i].first, n);
  vector<vector<int>> s(n+1);
  rep(i,n) s[p[i].first].push_back(p[i].second);

  ll res = 0;
  priority_queue<int> q;
  for (int i = n; i >= 1; --i) {
    for (int x : s[i]) q.push(x);
    if (q.size() > 0) {
      res += q.top();
      q.pop();
    }
  }
  return res;
}

void solve() {
  int n;
  cin >> n;
  vector<P> pl, pr;
  ll ans = 0;
  rep(i,n) {
    int k, l, r;
    cin >> k >> l >> r;
    int m = min(l,r);
    ans += m;
    l -= m; r -= m;
    if (l > 0) pl.emplace_back(k,l);
    else pr.emplace_back(n-k,r);
  }
  ans += f(pl);
  ans += f(pr);
  cout << ans << endl;
}

int main() {
  int ts;
  cin >> ts;
  rep(ti,ts) solve();
  return 0;
}

Measured memory_bytes: 10532
import numpy as np
A = [list(map(int, input().split())) for _ in range(3)]
c = np.zeros_like(A, dtype=bool)
N = int(input())
for _ in range(N):
    b = int(input())
    for i, line in enumerate(A):
        for j, a in enumerate(line):
            if a == b:
                c[i][j] = True
ans = False
for i in range(3):
    if np.all(c[i]):
        ans = True
    elif np.all(c[:,i]):
        ans = True
for k in range(3):
    if not c[k, k]:
        break
else:
    ans = True
for k in range(3):
    if not c[k, 2 -k]:
        break
else:
    ans = True
print('Yes' if ans else 'No')


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

using namespace std;

#define mod 1000000007
#define int int64_t
#define fio ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"

void solve()
{
    int d,t,s;
    cin>>d>>t>>s;
    cout<<( s*t >= d ? "Yes" : "No")<<endl;
}

int32_t main()
{
    fio;
    int t;
    // cin>>t;
    t=1;
    while(t--)
        solve();
}

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

int x, a, b;

int main() {
	cin >> x >> a >> b;
	if (b - a <= 0) {
		cout << "delicious" << endl;
	}
	else if (b - a > x) {
		cout << "dangerous" << endl;
	}
	else {
		cout << "safe" << endl;
	}
	return 0;
}

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

// ref : http://kyopro.hateblo.jp/entry/2018/12/25/174720

using ll = long long;
/*
dp[d][smaller][leadingZero][num]
numは3, 5, 7を少なくとも1回選んだかどうかのフラグとする
具体的には3bit(つまり0 ~ 7)のうち各bitで管理する
leadingZero = 0 はまだ0が続いている状態
*/
ll dp[11][2][2][8];

int main(){
    std::string S;
    std::cin >> S;

    memset(dp, sizeof dp, 0);
    dp[0][0][0][0] = 1;
    for(int d = 0; d < S.size(); d++){
        for(int smaller = 0; smaller < 2; smaller++){
            for(int leadingZero = 0; leadingZero < 2; leadingZero++){
                for(int num = 0; num < 8; num++){
                    // 未計算は使わないので飛ばす
                    // if(dp[d][smaller][leadingZero][num] == -1) continue;

                    int val; // 次に入れられる数字の最大値
                    if(smaller == 1){
                        val = 9;
                        if(leadingZero == 0){
                            // まだ0が続いている状態
                            // 必ず小さいのでsmallerは1
                            dp[d + 1][1][leadingZero][0] += dp[d][smaller][leadingZero][num];
                        }
                    }else{
                        val = S[d] - '0';
                        if(leadingZero == 0){
                            // まだ0が続いている状態
                            // 必ず小さいのでsmallerは1
                            dp[d + 1][1][leadingZero][0] += dp[d][smaller][leadingZero][num];
                        }
                    }

                    // valの値に応じてsmallerを切り替えて計算
                    if(val == 3) dp[d + 1][0][1][num | 1] += dp[d][smaller][leadingZero][num];
                    if(val > 3) dp[d + 1][1][1][num | 1] += dp[d][smaller][leadingZero][num];
                    if(val == 5) dp[d + 1][0][1][num | 2] += dp[d][smaller][leadingZero][num];
                    if(val > 5) dp[d + 1][1][1][num | 2] += dp[d][smaller][leadingZero][num];;
                    if(val == 7) dp[d + 1][0][1][num | 4] += dp[d][smaller][leadingZero][num];;
                    if(val > 7) dp[d + 1][1][1][num | 4] += dp[d][smaller][leadingZero][num];
                }
            }
        }
    }

    std::cout << dp[S.size()][0][1][7] + dp[S.size()][1][1][7] << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)

typedef long long ll;
typedef long long int lli;

int main() {
	int N;
	cin >> N;
	for (int i = 0; i <= 25; i++) {
		for (int j = 0; j <= 15; j++) {
			if (4 * i + 7 * j == N) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	
	cout << "No" << endl;
	return 0;
}




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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

struct N {
  ll x, l;
};

bool operator<(const N &l, const N &r) {
  return l.x + l.l < r.x + r.l;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<N> ns(n);
  for (int i = 0; i < n; i++) cin >> ns[i].x >> ns[i].l;
  sort(ns.begin(), ns.end());
  ll ans = 0;
  ll now = -10000000000;
  for (int i = 0; i < n; i++) {
    if (ns[i].x - ns[i].l >= now) {
      now = ns[i].x + ns[i].l;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  int cnt = 0;
  bool ans = false;
  for (int i = 0; i < n; i++) {
    int d1, d2;
    cin >> d1 >> d2;
    if (d1 == d2)
      cnt++;
    else
      cnt = 0;
    if (cnt >= 3) ans = true;
  }
  cout << (ans == true ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
long long a,b,c,d;
long long n;
int main(){
    cin>>a>>b>>c>>d;
    cin>>n;
    long long ans = 0;
    ans = min((n*4)*a , (n*2)*b);
    ans = min(ans,n*c);
    if(n%2 == 0){
        ans = min(ans,(int)n/2 * d);
    }
    else{
        ans = min(ans,(int)n/2 * d + min(a*4,min(b*2,c)));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main()
{
    ft
    int t,i,j,k,h,w,n,m,l,r,a,x,y,p,q;
    cin>>h>>w>>n;
    x=0,y=0,p=h,q=w;
    for(i=0; i<n; i++)
    {
        cin>>l>>r>>a;
        if(a==1)
        {
            x=max(x,l);
        }
        else if(a==2)
        {
            p=min(p,l);
        }
        else if(a==3)
        {
            y=max(y,r);
        }
        else
        {
            q=min(q,r);
        }
    }
    if(x>=p || y>=q)
    {
        cout<<"0\n";
    }
    else
    {
        cout<<(p-x)*(q-y)<<"\n";
    }
    return 0;
}

Measured memory_bytes: 256
from __future__ import print_function
import numpy as np
import sys
import math,string,itertools,fractions,heapq,collections,re,array,bisect,copy,functools
# from itertools import accumulate
# from collections import deque
from itertools import permutations
import random

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

l=[3,5,7]
# eprint(type(l))
# for xxx in itertools.permutations(l,9):
#     print(xxx)
nnn=10
cnt=0
inputx=int(input())
endflag=0
for n in range(3,nnn):
    for xxx in itertools.product(l,repeat=n):
        num = int("".join([str(e) for e in xxx]))
        if num>inputx:
            endflag=1
            break
        else:
            res=sorted(set(xxx))
            # print(res)
            if res==[3,5,7]:
                # print(xxx)
                cnt+=1
            else:
                continue
    if endflag==1:
        print(cnt)
        break
if endflag==0:
    print(cnt)

    # eprint(str(n)+": "+str(cnt))

# for xxx in itertools.product(l,repeat=8):
#     res=sorted(set(xxx))
#     if res==[3,5,7]:
#         print(xxx)
#         cnt+=1
#     else:
#         continue
    


Measured memory_bytes: 13456