akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  int n, m; cin >> n >> m;
  vector<long long> x(n), y(n), z(n);
  vector<pair<long long, int> > v[8];
  long long a[8] = {1, 1, 1, 1, -1, -1, -1, -1};
  long long b[8] = {1, 1, -1, -1, 1, 1, -1, -1};
  long long c[8] = {1, -1, 1, -1, 1, -1, 1, -1};
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> z[i];
    for (int j = 0; j < 8; j++) {
      v[j].push_back(make_pair(x[i]*a[j]+y[i]*b[j]+z[i]*c[j], i));
    }
  }
  long long ans = 0;
  for (int i = 0; i < 8; i++) {
    sort(v[i].rbegin(), v[i].rend());
    long long p = 0; long long q = 0; long long r = 0;
    for (int j = 0; j < m; j++) {
      int k = v[i][j].second;
      p += x[k]; q += y[k]; r += z[k];
    }
    long long tmp = abs(p) + abs(q) + abs(r);
    ans = max(tmp, ans);
    //cout << "\t" << tmp << endl;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
fun main(args: Array<String>) {
    val row1 = mutableListOf<String>()
    val row2 = mutableListOf<String>()
    val row3 = mutableListOf<String>()
    val result1 = MutableList(3) { false }
    val result2 = MutableList(3) { false }
    val result3 = MutableList(3) { false }
    readLine()!!.split(" ").map { row1.add(it) }
    readLine()!!.split(" ").map { row2.add(it) }
    readLine()!!.split(" ").map { row3.add(it) }
    val n = readLine()!!.toInt()
    repeat(n) {
        val s = readLine()!!
        if (row1.contains(s)) result1[row1.indexOf(s)] = true
        if (row2.contains(s)) result2[row2.indexOf(s)] = true
        if (row3.contains(s)) result3[row3.indexOf(s)] = true
    }
    if (result1.all { it }
            || result2.all { it }
            || result3.all { it }
            || (result1[0] and result2[0] and result3[0])
            || (result1[1] and result2[1] and result3[1])
            || (result1[2] and result2[2] and result3[2])
            || (result1[0] and result2[1] and result3[2])
            || (result1[2] and result2[1] and result3[0])
    ) println("Yes")
    else println("No")
}

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

using namespace std;

typedef long long LL;

#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define LEN(a) int((a).size())
#define SORT(a) sort((a).begin(), (a).end())
#define CLR(a) memset((a), 0, sizeof(a))

const double EPS = 1e-10;

int main() {
    LL w, h, x, y;
    cin >> w >> h >> x >> y;

    int b = (w == x * 2 && h == y * 2) ? 1 : 0;
    printf("%.9f %d", w * h / 2.0, b);

    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main(void){
	int p[3],i,k,temp;
	int j[2],sum,ans;

	scanf("%d %d %d",&p[0],&p[1],&p[2]);
	scanf("%d %d",&j[0],&j[1]);
	sum=0; ans=p[0]+j[0];
	for(i=0;i<3;i++){
		for(k=0;k<2;k++){
			sum=p[i]+j[k];
			if(sum<ans){
				temp=sum;
				sum=ans;
				ans=temp;
			}
		}
	}
	printf("%d\n",ans-50);
	return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
struct Point{
    double x,y;
    Point(){}
    Point(double x,double y):x(x),y(y){}
};
typedef Point Vector;
Vector operator + (Vector A,Vector B){
    return Vector(A.x+B.x,A.y+B.y);
}
Vector operator - (Vector A,Vector B){
    return Vector(A.x-B.x,A.y-B.y);
}
Vector operator * (Vector A,double p){
    return Vector(A.x*p,A.y*p);
}
Vector operator / (Vector A,double p){
    return Vector(A.x/p,A.y/p);
}
bool operator < (const Point& a,const Point& b){
    return a.x<b.x||(a.x==b.x&&a.y<b.y);
}
const double eps = 1e-10;
int dcmp(double x){
    if(fabs(x<eps)) return 0; else return (x<0?-1:1);
}
bool operator == (const Point& a,const Point& b){
    return dcmp(a.x-b.x)==0 && dcmp(a.y-b.y)==0;
}
//点积
double Dot(Vector A,Vector B){
    return A.x*B.x+A.y*B.y;
}
double Length(Vector A){
    return sqrt(Dot(A,A));
}
double Angle(Vector A,Vector B){
    return acos(Dot(A,B)/Length(A)/Length(B));
}

//叉积
double Cross(Vector A,Vector B){
    return (A.x*B.y-A.y*B.x);
}
//三角形面积的二倍的叉乘公式
double Area2(Point A,Point B,Point C){
    return Cross(B-A,C-A);
}
//向量旋转,rad是弧度
Vector Rotate(Vector A,double rad){
    return Vector(A.x*cos(rad)-A.y*sin(rad),A.x*sin(rad)+A.y*cos(rad));
}
//计算向量的单位法线,先逆时针旋转90度，然后把长度归一化
Vector Normal(Vector A){
    double Len=Length(A);
    return Vector(-A.y/Len,A.x/Len);
}
//求两直线交点
//调用前请确保P+tv和Q+tw有唯一交点，当且仅当Cross(v,w)非0
Point GetLineIntersection(Point P,Vector v,Point Q,Vector w){
    Vector u=P-Q;
    double t=Cross(w,u)/Cross(v,w);
    return P+v*t;
}
//点到直线的距离
double DistanceToLine(Point P,Point A,Point B){
    Vector v1=B-A,v2=P-A;
    return fabs(Cross(v1,v2))/Length(v1);
}
//点到线段的距离
double DistanceToSegment(Point P,Point A,Point B){
    if(A==B) return Length(P-A);
    Vector v1=B-A,v2=P-A,v3=P-B;
    if(dcmp(Dot(v1,v2))<0) return Length(v2);
    else if(dcmp(Dot(v1,v3))>0) return Length(v3);
    else return fabs(Cross(v1,v2))/Length(v1);
}
//点在直线上的投影
Point GetLineProjection(Point P,Point A,Point B){
    Vector v=B-A;
    return A+v*(Dot(v,P-A)/Dot(v,v));
}
int main(){
    Point A,B;
    cin>>A.x>>A.y>>B.x>>B.y;
    int t;
    cin>>t;
    while(t--){
        Point P;
        cin>>P.x>>P.y;
        cout<<fixed<<setprecision(10)<<GetLineProjection(P,A,B).x<<" "<<GetLineProjection(P,A,B).y<<endl;
    }
    return 0;
}


Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100005
#define INF 1000000005
#define PI 3.1415926535897932386
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000005;
const int MOD = 1000000007;
int Zalgorithm(string s){
    vector<int> Z(s.size());
    Z[0] = s.size();
    int i = 1, j = 0;
    while(i < s.size()){
        while(i + j < s.size() && s[j] == s[i + j]) j++;
        Z[i] = j;
        if(j == 0){
            i++;
            continue;
        }
        int k = 1;
        while(k < j && k + Z[k] < j){
            Z[i + k] = Z[k];
            k++;
        }
        i += k;
        j -= k;
    }
    int m=0;
    REP(i,SZ(s)){
        m=max(m,min(Z[i],i));
    }
    return m;
}
int main(){
    int n;
    string s;
    cin>>n>>s;
    string t="";
    int ans=0;
    REP(i,n){
        t=s[n-i-1]+t;
        ans=max(ans,Zalgorithm(t));
    }
    OUT(ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin>>n;
    if(n%10==2 ||n%10==4 || n%10==5 || n%10==7 || n%10==9 )
        cout<<"hon"<<endl;
    if(n%10==0 ||n%10==1 || n%10==6 || n%10==8)
        cout<<"pon"<<endl;
    if(n%10 == 3)
        cout<<"bon"<<endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
// #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;

#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);i++)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}


int main() {
  int a,b;cin>>a>>b;
  cout<<a*b-(a+b-1)<<endl;
}


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

int main() {
  
  int n, T;
  cin >> n >> T;
  
  int ans = 1001;
  REP(i,n) { 
    int c, t;
    cin >> c >> t;
    if (t <= T) ans = min(ans,c);
  }
 
  if (ans == 1001) cout << "TLE" << endl;
  else cout << ans << endl;
  
}

Measured memory_bytes: 3508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 100000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

int main(){
  int n,cnt=0;
  cin>>n;
  int a[n];
  rep(i,n){
    cin>>a[i];
    a[i]--;
  }
  rep(i,n){
    if(a[i]==cnt&&a[i]<=i){
      cnt++;
    }
  }
  if(cnt==0){
    cout<<-1<<endl;
    return 0;
  }
  cout<<n-cnt<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<complex>
#include<vector>

using namespace std;

typedef complex<double> P;

int x[10],y[10],h[10];
double mg;
int n,w;
double m;

bool inside(double d){
  return mg<=d&&d<=100-mg;
}

vector<P> intersection(P a,double ra,P b,double rb){
  double c=abs(b-a);
  double costheta=-(rb*rb-ra*ra-c*c)/2/ra/c;
  if(-1<=costheta&&costheta<=1){
    double theta=acos(costheta);
    double ang=arg(b-a);
    return {a+polar(ra,ang+theta),a+polar(ra,ang-theta)};
  }else{
    return {};
  }
}

bool check(double px,double py,int u=0){
  for(int i=0;i<n;i++){
    if(u>>i&1)continue;
    if(hypot(px-x[i],py-y[i])<=((h[i]>m)?m:sqrt(m*m-(m-h[i])*(m-h[i]))))return false;
  }
  return true;
}


int main(){
  for(;cin>>n>>w,n|w;){
    for(int i=0;i<n;i++){
      cin>>x[i]>>y[i]>>h[i];
    }
    double lo=0,hi=(w>50)?50:(2500.+w*w)/2/w;
    for(int i=0;i<100;i++){
      m=(lo+hi)/2;
      mg=(m<w)?m:sqrt(m*m-(m-w)*(m-w));
      bool f=false;
      f|=check(mg,mg);
      f|=check(mg,100-mg);
      f|=check(100-mg,mg);
      f|=check(100-mg,100-mg);
      double rs[10];
      for(int i=0;i<n;i++){
	double r=(m<h[i])?m:sqrt(m*m-(m-h[i])*(m-h[i]));
	rs[i]=r;
	double sql=r*r-(x[i]-mg)*(x[i]-mg);
	if(sql>=0){
	  double ly=y[i]-sqrt(sql),hy=y[i]+sqrt(sql);
	  f|=inside(ly)&&check(mg,ly,1<<i);
	  f|=inside(hy)&&check(mg,hy,1<<i);
	}
	double sqb=r*r-(y[i]-mg)*(y[i]-mg);
	if(sqb>=0){
	  double lx=x[i]-sqrt(sqb),hx=x[i]+sqrt(sqb);
	  f|=inside(lx)&&check(lx,mg,1<<i);
	  f|=inside(hx)&&check(hx,mg,1<<i);
	}
	double sqr=r*r-(100-mg-x[i])*(100-mg-x[i]);
	if(sqr>=0){
	  double ly=y[i]-sqrt(sqr),hy=y[i]+sqrt(sqr);
	  f|=inside(ly)&&check(100-mg,ly,1<<i);
	  f|=inside(hy)&&check(100-mg,hy,1<<i);
	}
	double sqt=r*r-(100-mg-y[i])*(100-mg-y[i]);
	if(sqt>=0){
	  double lx=x[i]-sqrt(sqt),hx=x[i]+sqrt(sqt);
	  f|=inside(lx)&&check(lx,100-mg,1<<i);
	  f|=inside(hx)&&check(hx,100-mg,1<<i);
	}
	for(int j=0;j<i;j++){
	  for(auto e:intersection(P(x[i],y[i]),r,P(x[j],y[j]),rs[j])){
	    if(mg<=e.real()&&e.real()<=100-mg&&mg<=e.imag()&&e.imag()<=100-mg){
	      f|=check(e.real(),e.imag(),1<<i|1<<j);
	    }
	  }
	}
      }
      if(f){
	lo=m;
      }else{
	hi=m;
      }
    }
    cout<<fixed<<lo<<endl;
  }
}
	  

Measured memory_bytes: 1392
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn rec(n: i64, nums: &[i64], sum: i64) -> i64 {
    if let Some(&v) = nums.first() {
        rec(v, &nums[1..], n + sum) + rec(n * 10 + v, &nums[1..], sum)
    } else {
        n + sum
    }
}

fn main() {
    let s = scan!()
        .chars()
        .map(|c| i64::from(c.to_digit(10).unwrap()))
        .collect::<Vec<_>>();
    println!("{}", rec(0, &s, 0) / 2);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;
#define int LL

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && (ch != '-')) ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const MAXN = 1e5 + 5;
int a[MAXN], b[MAXN], c[MAXN];
priority_queue <int> q;

signed main() {

#ifdef LOCAL
  FILEIO("a");
#endif

  int x, y, A, B, C;
  read(x), read(y), read(A), read(B), read(C);
  for (RI i = 1; i <= A; ++i) read(a[i]);
  for (RI i = 1; i <= B; ++i) read(b[i]);
  for (RI i = 1; i <= C; ++i) read(c[i]);
  sort(a + 1, a + 1 + A);
  sort(b + 1, b + 1 + B);
  sort(c + 1, c + 1 + C);
  int ans = 0;
  for (RI i = A; i > A - x; --i) ans += a[i], q.push(-a[i]);
  for (RI i = B; i > B - y; --i) ans += b[i], q.push(-b[i]);
  int nowa = A - x + 1, nowb = B - y + 1;
  for (RI i = C; i; --i)
    if (c[i] + q.top() > 0)
      ans += c[i] + q.top(), q.pop();
  cout << ans << endl;

  cerr << (double)(clock()) / CLOCKS_PER_SEC * 1000 << "ms" << endl;

  return 0;
}

// created by Daniel yuan

Measured memory_bytes: 5748
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <limits.h>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
#define INF LLONG_MAX/3
#define inf INT_MAX/3
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int lcm(int a, int b) {
	return a / gcd(a, b)*b;
}
bool prime(int p) {
	for (int i = 2;i <= sqrt(p);i++) {
		if (p%i == 0)return false;
	}
	return true;
}
int modpow(int a, int b) {
	if (b == 0)return 1;
	if (b == 1)return a % MOD;
	if (b % 2)return modpow(a, b - 1)*a%MOD;
	else return modpow(a, b / 2)*modpow(a, b / 2) % MOD;
}
int comb(int a, int b) {
	if (b == 0 || a == b)return 1;
	if (b == 1)return a % MOD;
	return (comb(a - 1, b - 1) + comb(a - 1, b)) % MOD;
}
// Library End !
int c[26];
ll ans = 1;
string s;
int main() {
	cin >> s;
	rep(i, 26)c[i] = 0;
	rep(i, s.size()) {
		ans += i - c[s[i] - 'a'];
		c[s[i] - 'a']++;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int n, a, b;
    string s;
    cin >> n >> a >> b >> s;
    
    int br = 0;
    int w = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'a' and w < a+b) {
            cout << "Yes" << endl;
            w++;
        }
        else if (s[i] == 'b' and w < a+b and br < b) {
            cout << "Yes" << endl;
            w++;
            br++;
        }
        else cout << "No" << endl;
    }
}


Measured memory_bytes: 896
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var d = new long[N];
            for (var i = 0; i < N; i++)
            {
                d[i] = ReadLong();
            }
            return d.Distinct().Count();
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28224
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
typedef long double ld;
using namespace std;

ll gcd(ll a, ll b){
  if(b<a) swap(a, b);
  ll r = a % b;
  if(r==0) return b;
  while(r!=0){
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
ll prime_factor(ll n) {
  ll c = 0;
  for(ll i = 2; i * i <= n; i++) {
    if(n%i==0) c++;
    while(n % i == 0) n /= i;
  }
  c++;
  if(n != 1) c++;
  return c;
}
int main(int argc, char const *argv[]) {
  ll A, B;
  std::cin >> A >> B;
  ll tmp = gcd(A, B);
  vector<ll> ans;
  ll ra = tmp;
  ll c = prime_factor(tmp);
  /*
  for(int i=2;i*i<=tmp;i++){
    if(tmp%i==0){
      ans.push_back(i);
      while(tmp%i==0) tmp/=i;
    }
  }
  */
  std::cout << c << '\n';
  if(tmp>1) ans.push_back(tmp);
  //std::cout << ans.size()+1 << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N,K,count;
  cin >> N >> K ;
 vector<int> height(N);
 
  for (int j=0;j<N;j++){
  cin >> height.at(j) ;
  }

  count = 0;
  for (int i = 0; i < N ; i ++){
  if (height.at(i) >= K){
  count ++;
  }
    
  }
 cout << count << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const ll INF = 1<<30;
const ll MOD = (ll)1e9 + 7;
const ll MAX_N = (ll)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> A(n, INF), B(n - 1, INF);
    for(ll i = 0; i < n - 1; i++) cin >> B[i];
    for(ll i = 0; i < n - 1; i++)
    {
        A[i] = min(A[i], B[i]);
        A[i + 1] = min(A[i + 1], B[i]);
    }
    ll ans = 0;
    for(ll i = 0; i < n; i++) ans += A[i];
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
  
using namespace std;
  
int main(void){
  int a,b,c;
  cin >> a >> b >> c;
  
  if(a<b && b<c){
      cout << "Yes";
  }
  else{
      cout << "No";
  }
  
  cout << endl;
  
  return 0;
  
}


Measured memory_bytes: 3100
import java.util.Scanner;

class Graph{
	int n;
	int[][] A;
	
	Graph(int n){
		this.n=n;
		A=new int[n+1][n+1];
	}
	
	void setAdjList(int u,int v){ A[u][v]=1; }
	int getAdjList(int u,int v){ return A[u][v]; }
	
}
	

class Main{
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		
		int n=scan.nextInt();
		Graph G=new Graph(n);
		
		for(int i=1;i<=n;i++){
			int u=scan.nextInt();
			int m=scan.nextInt();
			for(int j=0;j<m;j++)
				G.setAdjList(u,scan.nextInt());
		}
		
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n-1;j++)
				System.out.print(G.getAdjList(i,j)+" ");
			System.out.println(G.getAdjList(i,n));
		}
		
	}
}


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

using namespace std;
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PI; 
typedef pair<LL,LL> PLL;
typedef unsigned long long ULL;
typedef pair<double,double> PD;

#define FOR(x, b, e) for(int x = b; x<= (e); x++)
#define FORD(x, b, e) for(int x = b; x>= (e); x--)
#define REP(x, n) for(int x = 0; x<(n); ++x)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())

#define PB push_back
#define IN insert
#define ST first
#define ND second
#define INF 2000000011
#define MOD 1000000007

#define MAXS 3010

int n;
LL dp[MAXS][MAXS];
string s;

int main(){
	
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n>>s;
	
	dp[1][1]=1;
	
	FOR(i,2,n){
		
		if(s[i-2]=='>'){
			LL suf=0;
			FORD(j,i,1){
				suf+=dp[i-1][j];
				suf%=MOD;
				dp[i][j]+=suf;
				dp[i][j]%=MOD;
			}
		}
		else{
			LL pref=0;
			FOR(j,1,i){
				pref+=dp[i-1][j-1];
				pref%=MOD;
				dp[i][j]+=pref;
				dp[i][j]%=MOD;
			}
		}
	}
	
	LL wyn=0;
	FOR(i,1,n){
		wyn+=dp[n][i];
		wyn%=MOD;
	}
	
	cout<<wyn;
	
	return 0;
}


Measured memory_bytes: 69248
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int N,K;
  cin>>N>>K;
  if(N==2){
    if(K==0){
      cout<<1<<endl;
      cout<<1<<" "<<2<<endl;
    }else cout<<-1<<endl;
  }else if(K>(N-1)*(N-2)/2){
    cout<<-1<<endl;
  }else if(K==0){
    cout<<N*(N-1)/2<<endl;
    rep(i,N) rep(j,N) if(i<j) cout<<i+1<<" "<<j+1<<endl;
  }else{
    cout<<N-1+(N-1)*(N-2)/2-K<<endl;
    rep(i,N-1) cout<<1<<" "<<i+2<<endl;
    int cnt=0;
    rep(i,N-1){
      rep(j,N-1){
        if(i<j){
          cnt++;
          if(cnt>(N-1)*(N-2)/2-K) break;
          cout<<i+2<<" "<<j+2<<endl;
        }
      }
      if(cnt>=(N-1)*(N-2)/2-K) break;
    }
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (int i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(int n, int k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

int main() {
  int a;
  string s;
  cin>>a>>s;
  if(a>=3200){
    cout<<s<<endl;
    return 0;
  }
  cout<<"red"<<endl;
}

Measured memory_bytes: 3528
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
int main(void){
int a,b;
  cin >> a >> b;
  if(a+b>=24) cout<< a+b-24 <<endl;
  else cout << a+b << endl;
  return 0;
}



Measured memory_bytes: 256
n = int(input())
d,x = map(int,input().split())

a = []

for i in range(n):
	a.append(int(input()))
    
c = 0
choco = []

for i in range(n):
	for j in range(100):
		k = j*a[i] + 1
		c += 1        
		if k > d:        
			choco.append(c-1)
			c = 0
			break	            
            
print(sum(choco) + x) 

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define Vsort(v) sort(All(v))
#define VsortR(v) sort(All(v), std::greater<__typeof(v[0])>())

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    string s;

	cin >> s;

	if (s[0] != 'A') {
		Out("WA");
	} else {
	    int c = 0;
		int ci = 0;
		
		int i, len = s.size() - 1;

		repi(i, len, 2) {
			if (s[i] == 'C') {
				c++;
				ci = i;
			}
		}

		if (c != 1) {
			Out("WA");
		} else {
			len++;
			repi(i, len, 1) {
				if (i == ci) continue;

				if (s[i] < 'a' || 'z' < s[i]) {
					Out("WA");

					return 0;
				}
			}

			Out("AC");
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int X = N;
  int sumX = X % 10;
  while( X / 10 > 0 ){
    X /= 10;
    sumX += X%10;
  }
  if( N % sumX == 0){
    cout << "Yes" << endl;}
  else{
    cout << "No" << endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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 repx(i, x, n) for (int i = int(x); i < int(n); ++i)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define ALL(n) begin(n), end(n)
#define IN(a, x, b) ((a) <= (x) && (x) < (b))
#define OUT(a, x, b) ((x) < (a) || (x) < (b))
typedef long long ll;
typedef long double ld;
const ll INF = 1e18;
const ll MOD = 1000000007;

int main()
{
    int N, T;
    cin >> N >> T;
    ll A[N], m = 1e10, max_b = 0, b, ans = 0;
    vector<ll> min_t;
    rep(i, N)
    {
        cin >> A[i];
        m = min(m, A[i]);
        b = A[i] - m;
        if (max_b == b)
        {
            ans++;
        }
        else if (b > max_b)
        {
            ans = 1;
            max_b = b;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int N; cin >> N;
    int K; cin >> K;
    double ans = 0;
    for(int i = 0 ; i < N ; i++){
        double H = 1;
        while((i+1)*H < K) H *= 2;
        H = 1 / H;
        ans += H;
    }
    printf("%.12f", ans / N);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()
const ll MOD = 1e9 + 7;

ll fact[500001], fact_i[500001];

ll power(int x, int y) {
    if (y == 0) return 0;
    if (y == 1) return x;
    ll p = power(x, y >> 1);
    if (y & 1) return p * p % MOD * x % MOD;
    else return p * p % MOD;
}

ll inv(int n) {
    return power(n, MOD - 2);
}

void init(int n) {
    fact[0] = 1;
    REP(i, n) fact[i + 1] = fact[i] * (i + 1) % MOD;
    fact_i[n] = inv(fact[n]);
    REP(i, n) fact_i[n - i - 1] = fact_i[n - i] * (n - i) % MOD;
}

ll nCr(int n, int r) {
    return fact[n] * fact_i[r] % MOD * fact_i[n - r] % MOD;
}

ll nPr(int n, int r) {
    return fact[n] * fact_i[n - r] % MOD;
}

int main() {
    init(500000);

    int N, M;
    cin >> N >> M;
    ll ans = 0;
    REP(i, N + 1) {
        ll sign = (i % 2 == 0) ? 1 : -1;
        ll tmp = nCr(N, i) * nPr(M - i, N - i) % MOD * nPr(M, N) % MOD;
        ans += MOD + sign * tmp;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11396
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  int n;
  cin>>n;
  vector<vector<int>> a(n, vector<int>(3));
  rep(i,n) rep(j,3) cin>>a[i][j];

  vector<vector<long>> dp(n+1,vector<long>(3,0));
  rep(i,n){
    rep(j,3){
      rep(k,3) if(j!=k) dp[i+1][j] = max(dp[i+1][j], dp[i][k] + a[i][j]);
    }
  }

  cout << *max_element(all(dp[n])) << endl;

  return 0;
}


Measured memory_bytes: 11136
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(true){
			int h = in.nextInt();
			int w = in.nextInt();
			if(h==0 && w==0) break;
			for(int i=0; i<h; i++){
				for(int j=0; j<w; j++){
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 12000
import java.util.*;

public class Main {

  public static void main (String[] args) {

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

    String answer = "No";
    for (int i = 1; i < 10; i++) {
      for (int j = 1; j < 10; j++) {
        if (i * j == N) {
          answer = "Yes";
        }
      }
    }

    System.out.println(answer);

  }

}

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

const ll INF = 1001001001;

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

int main(){
  int a,b;
  cin>>a>>b;
  bool f=false;
  int ans = 0;
  for(int i=0;i<100000;i++){
    if((i*8)/100==a && (i*10)/100==b){
      f=true;
      ans=i;
      break;
    }
  }
  if(f) cout<< ans<<endl;
  else cout<<-1<<endl;
}



Measured memory_bytes: 256
a,b,c = map(int,input().split(" "))
n = 0
if a % 2 == 1:
    print(0)
    exit()
if b % 2 == 1:
    print(0)
    exit()
if c % 2 == 1:
    print(0)
    exit()
if a == b == c:
  print(-1)
  exit()
for i in range(10**9):
  aa = a//2
  bb = b//2
  cc = c//2
  a = bb + cc
  b = aa + cc
  c = aa + bb
  n += 1
  if a % 2 == 1:
    break
  if b % 2 == 1:
    break
  if c % 2 == 1:
    break
print(n)


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

int main(){
  int n;
  cin>>n;
  vector<int> A(n);
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
int ans =0;
int now =1;
for(int i=0;i<n;i++){
  if(A[i]==now) now++;
  else ans++;
}
if(n==ans)cout<<-1<<endl;
else cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
#include<cctype>
using namespace std;


int main(){
    int sum = 0;
    string w, s;
    cin >> w;

    while(true){
        cin >> s;
        if(s == "END_OF_TEXT") break;
        
        transform(s.begin(), s.end(), s.begin(), ::tolower);
        if(s == w) {
            sum++;
        }
    }
    cout << sum << endl;
}


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

using namespace std;

using ll = long long;

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

	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ans = LLONG_MIN;
	ans = max(ans, a * c);
	ans = max(ans, a * d);
	ans = max(ans, b * c);
	ans = max(ans, b * d);
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define INF 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,P> PP;

int n,m;
vector<int> G[100005];
int dp[100005][3][3];

int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		a--;
		b--;
		G[a].push_back(b);
	}
	int s,t;
	scanf("%d%d",&s,&t);
	s--;
	t--;
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				dp[i][j][k]=INF;
			}
		}
	}
	dp[s][0][0]=0;
	priority_queue<PP,vector<PP>,greater<PP> > que;
	que.push(PP(P(0,s),P(0,0)));
	while(que.size()){
		PP p=que.top();
		que.pop();
		int v=p.first.second;
		int step=p.second.first;
		int cost=p.first.first;
		if(cost<dp[v][p.second.first][p.second.second])continue;
		for(int i=0;i<G[v].size();i++){
			int nv=G[v][i];
			if(dp[nv][(step+1)%3][(cost+1)%3]>cost+1){
				dp[nv][(step+1)%3][(cost+1)%3]=cost+1;
				que.push(PP(P(cost+1,nv),P((step+1)%3,(cost+1)%3)));
			}
		}
	}
	int ans=INF;
	for(int i=0;i<3;i++){
		ans=min(ans,dp[t][0][i]);
	}
	if(ans==INF)ans=-3;
	printf("%d\n",ans/3);
	return 0;
}


Measured memory_bytes: 9344
# -*- coding: utf-8 -*-
from collections import deque
def inpl(): return map(int, input().split())
N = int(input())

G = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b, c = inpl()
    G[a].append((b, c))
    G[b].append((a, c))

Q, K = inpl()

def BFS(G, K):
    DQ = deque([K])
    D = [0] * (N+1)
    visited = [False]*(N+1)
    while DQ:
        p = DQ.popleft()
        visited[p] = True
        for q, c in G[p]:
            if not visited[q]:
                D[q] = D[p] + c
                DQ.append(q)
    return D

D = BFS(G, K)
for _ in range(Q):
    x, y = inpl()
    print(D[x] + D[y])

Measured memory_bytes: 43656
ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(map(int, input().split()))

import numpy as np
n,k,q = mi()
a=[int(input()) for i in range(q)]

point = np.array([k-q for i in range(n)])

for i in a:
    point[i-1] += 1

ans = np.where(point>0, 'Yes', 'No')

print('\n'.join(ans))

Measured memory_bytes: 29176
z['   '],i;
main(j){
	for(;++i<2e3;)
		for(j=z[i>>5]&1<<i?1e7:-2*i*~i;j<5e6;j+=i-~i)z[j>>5]|=1<<j;
	for(;scanf("%d",&i),i;)
		for(j=~i/-2;i;)
			z[--j>>5]&1<<j|
			z[j-1>>5]&1<<j-1|
			z[j-3>>5]&1<<j-3|
			z[j-4>>5]&1<<j-4||printf("%d\n",j*2+1,i=0);
}

Measured memory_bytes: 1020
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n: BigInt = BigInt.javaBigInteger2bigInt(sc.nextBigInteger())
    val blue: BigInt = BigInt.javaBigInteger2bigInt(sc.nextBigInteger())
    val red: BigInt = BigInt.javaBigInteger2bigInt(sc.nextBigInteger())

    val sum = blue.+(red)
    val division = n./(sum)
    val reminder = n.%(sum)

    val reminderBlue =
      if (reminder.<(blue)) {
        reminder
      } else {
        blue
      }

    val ans = (division.*(blue)).+(reminderBlue)

    println(ans.toString())
  }
}


Measured memory_bytes: 25528
//ぷえのコード
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

//modしながら塁乗
ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  ll n;cin>>n;
  ll a[n];
  cin>>a[0];
  for(int i=1;i<n;i++){
    ll t;cin>>t;
    a[i] = a[i-1] + t;
  }
  vector<ll> v;
  REP(i,n){
    v.pb(a[i]);
  }
  v.pb(0);
  VSORT(v);
  ll ans = 0;
  int i = 1;
  ll count = 1;
  while(i<=n){

    if(v[i] != v[i-1]){
      ans += count * (count - 1) / 2;
      //cout<<i<<" "<<count * (count - 1) / 2<<endl;
      count = 0;
    }
        count++;
    i++;
  }
  ans += count * (count - 1) / 2;

  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 3956
import sys
readline = sys.stdin.buffer.readline

def main():
    n = int(readline())
    a = [list(map(int, readline().split())) for _ in range(n)]

    dp = [[0] * 3 for _ in range(n)]
    dp[0] = a[0]

    for i in range(n - 1):
        dp[i + 1][0] = a[i + 1][0] + max(dp[i][1], dp[i][2])
        dp[i + 1][1] = a[i + 1][1] + max(dp[i][2], dp[i][0])
        dp[i + 1][2] = a[i + 1][2] + max(dp[i][0], dp[i][1])
    print(max(dp[-1]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 67548
#include<stdio.h>
#include<stdlib.h>
#define N 1000000
int cnt=0,n,l,A[N],*S;
 
void insertionSort(int A[], int n, int m){
int i,v,j;
  for(i=m;i<n;i++){
    v=A[i];
    j=i-m;
    while(j>=0&&A[j]>v){
      A[j+m]=A[j];
      j-=m;
      cnt++;
    }
    A[j+m]=v;
  }
}
 
void Sort(int A[],int n){
  int i=0,a;
 
S=(int *)malloc(n * sizeof(int));
 
for(a=1; ; ){
if(a>n) break;
S[i]=a;
i++;
  a=3*a+1;
}
l=i;
  for(i=l-1;i>=0;i--){
    insertionSort(A,n,S[i]);
  }
}
 
 
 
int main(){
int i;
scanf("%d",&n);
for(i=0;i<n;i++) scanf("%d",&A[i]);
cnt=0;
 
Sort(A,n);
 
printf("%d\n",l);
 
for(i=l-1;i>=0;i--){
printf("%d",S[i]);
if(i) printf(" ");
}
printf("\n");
printf("%d\n",cnt);
for(i=0;i<n;i++)printf("%d\n",A[i]);
 
 free(S);
  return 0;
}



Measured memory_bytes: 5636
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
class Main{


	static final int MOD = 1000000007;


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();


		long dp[][] = new long[n][n];
		for(int i = 0;i < n;i++){
			Arrays.fill(dp[i], Integer.MAX_VALUE);
		}
		
		for(int i = 0;i < m;i++){
			int a = sc.nextInt()-1;
			int b = sc.nextInt()-1;
			int c = sc.nextInt();
			if(c > l){
				dp[a][b] = Integer.MAX_VALUE;
				dp[b][a] = Integer.MAX_VALUE;
			}else{
				dp[a][b] = c;
				dp[b][a] = c;
			}
		}
		
		
		
		for(int k = 0;k < n;k++){
			for(int i = 0;i < n;i++){
				for(int j = 0;j < n;j++){
					dp[i][j] = Math.min(dp[i][j], dp[i][k] + dp[k][j]);
				}
			}
		}
		
		long[][] edge = new long[n][n];
		for(int i = 0;i < n;i++){
			for(int j = 0;j < n;j++){
				if(dp[i][j] <= l){
					edge[i][j] = 1;
				}else{
					edge[i][j] = Integer.MAX_VALUE;
				}
			}
		}
		
		for(int k = 0;k < n;k++){
			for(int i = 0;i < n;i++){
				for(int j = 0;j < n;j++){
					edge[i][j] = Math.min(edge[i][j], edge[i][k] + edge[k][j]);
				}
			}
		}

//		for(int i= 0;i < n;i++){
//			for(int j = 0;j < n;j++){
//				System.out.println("i " + i + " j " + j + " "+edge[i][j]);
//			}
//		}
		
		
		int q = sc.nextInt();
		for(int i = 0;i < q;i++){
			int ans = 0;
			int s = sc.nextInt()-1;
			int t = sc.nextInt()-1;
			if(edge[s][t] >= Integer.MAX_VALUE){
				System.out.println(-1);
			}else{
				System.out.println(edge[s][t] -1);
			}
		}

		
		
	}




	static int upperbond(int k,int min,int[] data){		//kより小さい最大の値をdataの中から探し、返す二分探索
		int max = data.length;
//		if(min == data.length-1){
//			if(data[min] > k){
//				return min;
//			}
//		}

		while(max-min > 1){
			int mid = (max+min)/2;
			if(data[mid] >= k){
				max = mid;
			}else{
				min = mid;
			}
		}

		return max;
	}

	static int lowerbond(int k,int min,int[] data){		//kより大きい最小の値をdataの中から探し、返す二分探索
		int max = data.length;

		while(max-min > 1){
			int mid = (max+min)/2;
			if(data[mid] >= k){
				max = mid;
			}else{
				min = mid;
			}
		}
		return min;
	}



	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}


class Edge extends ArrayList<P>{

}

class P{
	int to;
	long cost;
	P(int to,long cost){
		this.to = to;
		this.cost = cost;
	}
}


class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return   from- otherpair.from;
	}








}






Measured memory_bytes: 93688
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
const int N=2e5+5;
const int MOD=1e9+7;
int a[N];

int cmp(int a,int b)
{
    return a>b;
}
string s;
map<ll,int> mp;
const int minn=-1e9-10;
int b[N];
const int maxx=1e9+10;
int main()
{
    int n,x,t;
    cin>>n>>x>>t;
    if(n%x==0){
        cout<<n/x*t<<endl;
    }
    else cout<<n/x*t+t<<endl;
}






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

int main(){
	int n;
	cin>>n;
	if(n==25){
		cout<<"Christmas";
	}
	else if(n==24){
		cout<<"Christmas Eve";
	}
	else if(n==23){
		cout<<"Christmas Eve Eve";
	}
	else{
		cout<<"Christmas Eve Eve Eve";
	}
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char a;
    cin >> a;
    if(a > 'Z') {
    	cout << "a\n";
    } else {
    	cout << "A\n";
    }
}

Measured memory_bytes: 3632
def memoize(f):
    cache = {}
    def helper(*args):
        if args not in cache:
            cache[args] = f(*args)
        return cache[args]
    return helper

@memoize
def line_num(n):
    if n<=0:
        return 1
    elif n==1:
        return 2
    elif n==2:
        return 3
    else:
        return line_num(n-1) + line_num(n-2)

@memoize
def ans(h,w,k):
    if w==1:
        return 1
    elif h==1: # w>=2
        if k == 1:
            return line_num(w-2)
        elif k == 2:
            return line_num(w-3)
        else:
            return 0
    else:
        if k==1:
            return ans(h-1,w,k)*line_num(w-2) + ans(h-1,w,k+1)*line_num(w-3)
        elif k==w:
            return ans(h-1,w,k)*line_num(w-2) + ans(h-1,w,k-1)*line_num(w-3)
        else:
            a = ans(h-1,w,k)*(line_num(k-2)*line_num(w-k-1))
            b = ans(h-1,w,k-1)*(line_num(k-3)*line_num(w-k-1))
            c = ans(h-1,w,k+1)*(line_num(k-2)*line_num(w-k-2))
            return a+b+c

M = 1000000007

h,w,k = map(int,input().split())

print(ans(h,w,k) % M)

Measured memory_bytes: 3316
const input = require("fs").readFileSync("/dev/stdin", "utf8")
const lines = input.split('\n')

const [N, M] = lines[0].split(' ').map(Number)
const s = []
const c = []

for (let i = 0; i < M; i++) {
  const row = lines[i + 1].split(' ').map(Number)
  s[i] = row[0] - 1
  c[i] = row[1]
}

;(() => {
  const n = Array(N).fill(null)
  for (let i = 0; i < M; i++) {
	if (n[s[i]] && n[s[i]] !== c[i]) {
      console.log(-1)
      return
    }
    n[s[i]] = c[i]
  }
  
  if (n.length > 1 && n[0] === 0) {
    console.log(-1)
    return
  }
  
  for (let i = 0; i < N; i++) {
    if (n[i] === null)  {
      n[i] = (i === 0 && N !== 1) ? 1 : 0
    }
  }
  console.log(n.join(''))
  
})()


Measured memory_bytes: 29792
def main():
    s = list(input())
    n = int(input())

    for i in range(len(s)):
        if s[i]=="a": continue
        if ord("z") - ord(s[i])+1 <= n:
            n -= ord("z")-ord(s[i]) + 1
            s[i] = "a"
    if n>0: s[-1] = chr(ord(s[-1])+n%26)
    print("".join(s))

if __name__=="__main__": main()

Measured memory_bytes: 4152