akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)
inline int getint(){
	int x=0,p=1;char c=getchar();
	while (c<=32)c=getchar();
	if(c==45)p=-p,c=getchar();
	while (c>32)x=x*10+c-48,c=getchar();
	return x*p;
}
using namespace std;
//ruogu_alter
const int N=1e5+5;
vector<pii >a,b;
vector<ll>c;
ll e[N];
int n,k,f[N];
//
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=getint();k=2;
	rep(i,n){
		int l=getint(),r=getint();
		a.push_back(mp(l,r));
	}
	sort(a.begin(),a.end());
	rep(i,n){ 
		while(b.size()&&b.back().second>=a[i].second){
			c.push_back(b.back().second-b.back().first+1);
			b.pop_back();
		}
		if(b.empty()||b.back().first<a[i].first)b.push_back(a[i]);
		else c.push_back(a[i].second-a[i].first+1);
	}
	sort(c.begin(),c.end());
	reverse(c.begin(),c.end());
	for(int i=1;i<c.size();i++)c[i]+=c[i-1];
	rep(i,b.size()-1)f[i+1]=b[i+1].second-b[i].first+1;
	rep(i,b.size())e[b.size()]+=b[i].second-b[i].first+1;
	ll res=0;
	priority_queue<int>pq;
	rep(i,n)pq.push(a[i].second-a[i].first+1);
	while(pq.size()>n-k+1)res+=pq.top(),pq.pop();
	sort(f+1,f+b.size());
	for(int i=1;i<b.size();i++)e[b.size()-i]=e[b.size()-i+1]-f[i];
	for(int i=1;i<=b.size()&&i<=k;i++){
		if(k-i<=c.size())res=max(res,e[i]+(k-i-1<0?0ll:c[k-i-1]));
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 3860
import kotlin.math.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints

private fun readLong() = readLn().toLong()
private fun readLongs() = readStrings().map{it.toLong()} 

fun main(){
    val (a, v) = readLongs()
    val (b, w) = readLongs()
    val t = readLong()

    if(a < b){
        val demon = a + (v * t)
        val child = b + (w * t)
        if (demon - child >= 0){
            println("YES")
        }
        else{
            println("NO")
        }
    }
    else{
        val demon = a - (v * t)
        val child = b - (w * t)
        if(demon - child <= 0){
            println("YES")
        }
        else{
            println("NO")
        }
    }
}

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

using namespace std;

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();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#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 range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int n;
ll field[110][110];
int l[50],t[50],r[50],b[50];

int di[4]={1,0,-1,0};
int dj[4]={0,1,0,-1};
bool visited[110][110];

void dfs(int ci,int cj){
	if(visited[ci][cj]) return;
	visited[ci][cj]=true;
	rep(i,4){
		int ni=ci+di[i];
		int nj=cj+dj[i];
		if(ni<0||110<=ni||nj<0||110<=nj) continue;
		if(field[ni][nj]==field[ci][cj]) dfs(ni,nj);
	}
	return ;
}

int main(void){
	while(cin >> n,n){
		clr(field,0);
		clr(visited,false);
		rep(i,n) cin >> l[i] >> t[i] >> r[i] >> b[i];
		int x[110],y[110];
		rep(i,n) x[2*i]=l[i],x[2*i+1]=r[i],y[2*i]=t[i],y[2*i+1]=b[i];
		sort(x,x+2*n);
		sort(y,y+2*n);
		int xnum=unique(x,x+2*n)-x;
		int ynum=unique(y,y+2*n)-y;
		rep(i,n){
			int lindex=lower_bound(x,x+xnum,l[i])-x;
			int rindex=lower_bound(x,x+xnum,r[i])-x;
			int tindex=lower_bound(y,y+ynum,t[i])-y;
			int bindex=lower_bound(y,y+ynum,b[i])-y;
			field[lindex][bindex]+=(1LL<<i);
			field[rindex][bindex]-=(1LL<<i);
			field[lindex][tindex]-=(1LL<<i);
			field[rindex][tindex]+=(1LL<<i);
		}
		rep(i,105) rep(j,105) field[i][j+1]+=field[i][j];
		rep(i,105) rep(j,105) field[i+1][j]+=field[i][j];

		ll ans=1LL;
		rep(i,105) if(field[i][0]==0&&!visited[i][0]) dfs(i,0);
		rep(i,105) if(field[0][i]==0&&!visited[0][i]) dfs(0,i);
		rep(i,105) if(field[i][105]==0&&!visited[i][105]) dfs(i,105);
		rep(i,105) if(field[105][i]==0&&!visited[105][i]) dfs(105,i);

		rep(i,105)rep(j,105) if(!visited[i][j]) ans++,dfs(i,j);
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;

const int MOD = 1e9+7;

struct matrix{
	int N;
	vector<vector<long long>> mat;

	matrix(int sz){
		N = sz;
		mat.resize(N, vector<long long>(N, 0));
	}

	matrix(int sz, const vector<vector<long long>>& in){
		N = sz;
		mat = in;
	}
};

matrix mult(matrix a, matrix b){
	matrix res(a.N);

	for(int i=0; i<a.N; i++)
		for(int j=0; j<a.N; j++)
			for(int k=0; k<a.N; k++)
				res.mat[i][j] = (res.mat[i][j] + a.mat[i][k]*b.mat[k][j]) % MOD;
	return res;
}

matrix fastexp(matrix base, long long exp){
	if(exp == 1)
		return base;

	auto res = fastexp(base, exp/2);

	if(exp % 2)
		return mult(base, mult(res, res));
	else
		return mult(res, res);
}

int main(){
	cin.tie(0);
	cin.sync_with_stdio(0);
	long long N, K;

	cin >> N >> K;
	vector<vector<long long>> v(N, vector<long long>(N));
	for(auto &i : v) for(auto &j : i)
		cin >> j;

	matrix m(N, v);
	matrix walk = fastexp(m, K);
/*
	for(auto i :  walk.mat){
		for(auto j : i) cout << j <<  " ";
		cout << "\n";
	}
*/
	int ans = 0;
	for(auto i : walk.mat) for(auto j : i)
		ans = (j + ans) % MOD;
	cout << ans;
}


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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

const ll MOD = 1e9 + 7;

ll fastPow(ll b, ll expn) {
    ll ans = 1LL;

    while(expn) {
        if(expn & 1) {
            ans = (ans * b) % MOD;
        }
        expn >>= 1LL;

        b = (b * b) % MOD;
    }

    return ans;
}

int main(){
    fIO
//    freopen("", "r", stdin);
//    freopen("", "w", stdout);


    ll n, k;
    cin >> n >> k;

    ll ans = 0;
    ll gcd[k + 1] = {};
    for(ll i = k; i > 0; i--) {
        ll cnt = k / i;

        gcd[i] = fastPow(cnt, n);

        for(ll j = 2LL * i; j <= k; j += i) {
            gcd[i] = (gcd[i] - gcd[j] + MOD) % MOD;
        }
        ans += gcd[i] * i;
        ans %= MOD;
    }

    cout << ans;
}








Measured memory_bytes: 4392
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.util.OptionalInt;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int[] a = in.nextIntArray(3);
            int k = in.nextInt();

            int max = IntStream.of(a).max().getAsInt();
            int sum = IntStream.of(a).sum();

            long t = (long) Math.pow(2, k) * max;

            out.println(sum - max + t);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 28628
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		HashSet<String> set = new HashSet<>();
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		for(int i = 0; i < n; i++)
		{
			String s = sc.next();
			set.add(s);
		}
		System.out.println(set.size());
	}

}


Measured memory_bytes: 66576
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
int mp[1000][1000];
void fill(int N,int s,int x,int y){
  int n=N;
  if(s<=3){
    if(s==1){
      for(int j=0;j<=1;j++)
        mp[x+j][y]=n;
    }
    if(s==2){
      for(int j=0;j<=2;j++){
        for(int k=0;k<s;k++){
          mp[x+j][y+k]=n++;
        }
        n--;
        if(j==2)mp[x+j][y+s-1]=N;
      }
    }
    if(s==3){
      for(int j=0;j<=2;j++){
        for(int k=0;k<s;k++){
          mp[x+j][y+k]=n++;
        }
        n--;
        if(j==2)mp[x+j][y+s-1]=N;
      }
      for(int k=0;k<s;k++)
        mp[x+3][y+k]=N+1+2*k;
    }
    return;
  }
  for(int j=0;j<=2;j++){
    for(int k=0;k<s;k++){
      mp[x+j][y+k]=n++;
    }
    n--;
    if(j==2)mp[x+j][y+s-1]=N;
  }
  for(int j=3;j<=s;j++){
    for(int k=0;k<3;k++)
      mp[x+j][y+k]=(N+1)+k*(s-1)+j-3;
  }
  return fill(n,s-3,x+3,y+3);
}
int main(){
  int N;
  cin>>N;
  if(N==2){
    printf("No\n");
    return 0;
  }
  int s=sqrt(N*2);
  if(s*(s+1)==N*2);
  else if(s*(s-1)==N*2)s--;
  else if((s+1)*(s+2)==N*2)s++;
  else if((s-1)*(s-2)==N*2)s-=2;
  else{
    cout<<"No"<<endl;
    return 0;
  }
  fill(1,s,0,0);
  cout<<"Yes"<<endl<<s+1<<endl;
  for(int j=0;j<s+1;j++){
    cout<<s;
    for(int k=0;k<s;k++)
      cout<<' '<<mp[j][k];
    cout<<endl;
  }
}


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

#define N 100000
#define INF 1000000

typedef struct{
  int a; 
  int b; 
  int c; 
}Date;

int n, d[N];
Date a[500000];

void root(int);

int main(){
  int i, j;
  int k, e, cnt = 0;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++)
  {
    scanf("%d%d",&e,&k);
    for(j = 0 ; j < k ; j++)
    {
      a[cnt].b = e;
      scanf("%d%d",&a[cnt].a,&a[cnt].c);
      cnt++;
    }
  }

  root(cnt);

  for(i = 0 ; i < n ; i++)
  {
    printf("%d %d\n",i,d[i]);
  }

  return 0;
}

void root(int x){
  int i, flag = 1;

  for(i = 0 ; i < n ; i++) d[i] = INF;
  d[0] = 0;

  while(flag != 0)
  {
    flag = 0;
    for(i = 0 ; i < x ; i++)
    {
      if(a[i].c + d[a[i].b] < d[a[i].a])
      {
        d[a[i].a] = a[i].c + d[a[i].b];
        flag = 1;
      }
    }
  }
}




Measured memory_bytes: 7588
import java.util.*;

//
class Main {
	Scanner sc = new Scanner(System.in);

	public void run() {
		ArrayList<Integer> primes=new ArrayList<Integer>();
		for(int i=2;i<120000;i++){
			boolean isprime=true;
			for(int prime:primes){
				if(i%prime==0){
					isprime=false;
					break;
				}
				if( prime*prime>i){
					break;
				}
			}
			if(isprime){
				primes.add(i);
			}
		}

		while(true){
			int n=sc.nextInt();
			if(n==0)break;

			int sum=0;
			for(int i=0;i<n;i++){
				sum+=primes.get(i);
			}
			ln(sum);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 13000
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i< (int)(n);i++)
using namespace std;
int main(){
  int n,a=0,b=0,c=0,d=0;
  cin >>n;
  rep(i,n){
    string s;
    cin >> s;
    if(s=="AC") a++;
    else if(s=="WA") b++;
    else if(s=="TLE") c++;
    else d++;
  }
cout << "AC" << " " << "x" << " "<< a << endl;
cout << "WA" << " " << "x" << " "<< b << endl;
  cout << "TLE" << " " << "x" << " "<< c << endl;
  cout << "RE" << " " << "x" << " "<< d << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1000000000000000
#define mod 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}

signed main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	a--;
	int x = b / c - a / c, y = b / d - a / d;
	int z = b / lcm(c, d) - a / lcm(c, d);
	cout << b - a - (x + y - z) << endl;
	
	return 0;
}


Measured memory_bytes: 256
X, Y, Z, K = map(int, input().split())
*A, = map(int, input().split())
*B, = map(int, input().split())
*C, = map(int, input().split())
AB = [a+b for a in A for b in B]
AB.sort(reverse=True)
AB = AB[:K]
ABC = [ab+c for c in C for ab in AB]
ABC.sort(reverse=True)
ABC = ABC[:K]
for abc in ABC:
    print(abc)


Measured memory_bytes: 167728
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main(){
  int64_t N;
  cin >> N;
  vector<int64_t> a(N);
  rep(i, N){
    cin >> a.at(i);
  }
  int64_t cnt = 0;
  int64_t num = 1;
  rep(i, N){
    if(a.at(i) != num){
      cnt++;
    }
    else{
      num++;
    }
  }
  if(cnt == N){
    cout << -1 << endl;
  }
  else{
    cout << cnt << endl;
  }
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
  int N;
  cin >> N;
  int H[N];
  int res=0;
  for(int i=0; i<N; ++i){
    cin >> H[i];
    if(i==0){
      ++res;
      continue;
    }
    for(int j=0; j<i; ++j){
      if((H[j]>H[i])&&(i!=0)){
        break;
      }
      else if((j==(i-1))||(i==0)){
        ++res;
      }
    }
  }
  cout<<res;
}

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

int main(){
  int N, K ;
  long int ans = 0 ;
  cin >> N >> K ;
  long int A[N] ;
  for(int i=0;i<N;i++){
    cin >> A[i] ;
  }  
  sort(A,A+N) ;
  for(int i=0;i<(N-K);i++){
    ans += A[i] ;
  }  
  cout << ans << endl ;
  return 0 ;
}

Measured memory_bytes: 1792
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    string S;cin>>S;ll N=S.size();
    ll cnt0=0,cnt1=0;
    REP(i,N){
        if(S[i]=='0')cnt0++;
        else cnt1++;
    }
    cout<<min(cnt0,cnt1)*2<<"\n";
}

Measured memory_bytes: 512
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

a = int(input())
b = int(input())
h = int(input())
print((a + b) * h // 2)

Measured memory_bytes: 9452
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
from operator import itemgetter
from collections import defaultdict
import sys
import math
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# a/b の切り上げ


def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def floor(a, b):
    """floor(a/b) 整数値を返す"""
    c = (a - a % b)/b
    return int(c)


def main():
    a, b, n = wi()
    if n >= b-1:
        print(floor(a*(b-1), b) - a*floor((b-1), b))
    else:
        print(floor(a*n, b) - a*floor(n, b))


if __name__ == '__main__':
    main()


Measured memory_bytes: 67560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;


int main(){
    string s;   cin >> s;
    stack<char> st;
    int n=s.size();
    for(int i=0; i<n; i++){
        if(s[i]=='S') st.push('S');
        else if(st.size()>0 && st.top()=='S') st.pop();
        else st.push('T');
    }
    cout << st.size() << endl;
}



Measured memory_bytes: 644
#include <iostream>
#include <stdio.h>
using namespace std;
 
 int mem[256][256][4],i,j,k,n,an; 
 int main() {
  char da[256][256];
  while(cin >> n) {
  if (n==0) break;
  for (i=0;i<n;i++) cin >> da[i];
  for (i=0;i<n;i++) for (j=0;j<n;j++) for (k=0;k<4;k++) mem[i][j][k]=0;
  an=0;
  for (i=0;i<n;i++) for (j=0;j<n;j++) {
	  if (da[i][j]=='0') continue;
	  for (k=0;k<4;k++) {
		  mem[i][j][k]++;
		  if (k==0 && j>0) mem[i][j][k]+=mem[i][j-1][k];
		  if (k==1 && j>0 && i>0) mem[i][j][k]+=mem[i-1][j-1][k];
		  if (k==2 && i>0) mem[i][j][k]+=mem[i-1][j][k];
		  if (k==3 && i>0 && j<n-1) mem[i][j][k]+=mem[i-1][j+1][k];
		  if (an<mem[i][j][k]) an=mem[i][j][k];
	  }
  }
  cout << an << endl;
  }
 return 0;
 }

Measured memory_bytes: 2248
import java.io.*;
import java.util.Scanner;
 
public class Main {
    public static String compare(int a, int b) {
        if (a > b) return "a > b";
        if (a == b) return "a == b";
        return "a < b";
    }
 
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(compare(a, b));
    }
}


Measured memory_bytes: 26316
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

ll dp[51][51][2525];
int main() {
    int n, a;
    cin >> n >> a;
    int card[51];
    rep(i,0,n) cin >> card[i];
    rep(i,0,2501) {
            if(i == 0) dp[0][0][i] = 1;
            else dp[0][0][i] = 0;
    }

    rep(i,1,n+1) {
        rep(j,0,n+1) {
            rep(k,0,2525) {
                // i-1番目のカードを足した時と足さなかった時の足し算
                if(j == 0 || k < card[i-1]) dp[i][j][k] = dp[i-1][j][k];
                else dp[i][j][k] = dp[i-1][j-1][k-card[i-1]] + dp[i-1][j][k];
            }
        }
    }

    // dp[i][j][k] := {x_1, ..., x_i} から j個選んで和が k になる場合の数 O(N^3 X)
    // i = 0 → dp[0][0][0] = 1;
    // i > 0 → dp[i][j][k] = dp[i-1][j-1][k-x_i] + dp[i-1][j][k];
    // 答えは、\sigma dp[N][t][At]
    // O(N^2 X)に落とすこともできる(考えてみよう)
    ll ans = 0;
    rep(i,1,n+1) {
        // cout << dp[n][i][a * i] << endl;
        ans += dp[n][i][a * i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 50560
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);

    int a, b;
    cin >> a >> b;
    if (a < b) {
        int tmp = a;
        a = b;
        b = tmp;
    }

    int dif = a - b;
    if (dif % 2 == 0) {
        cout << (b + a) / 2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  vector<int64_t>vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  int64_t sum=0,p=0;
  for(int i=0;i<n-1;i++){
    p=(p+vec.at(n-1-i))%1000000007;
    sum+=(vec.at(n-2-i)*p)%1000000007;
    }
  
  cout<<sum%1000000007<<endl;
}

Measured memory_bytes: 4756
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;


    
    
    int main(){
        int a,b,c;cin>>a>>b>>c;
        cout<<(a+b+c>21 ? "bust":"win");
    }
    


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

using ll = long long int;

constexpr int MAX = 1e5 + 10;

std::map<int, ll> map;

int main()
{

    int n, m;

    std::cin >> n >> m;

    int mod = 0;

    for (int i = 0; i < n; ++i)
    {
        int a;
        std::cin >> a;
        mod = (mod + a) % m;
        ++map[mod];
    }

    ll ans = 0;

    for (auto p : map)
    {

        ans += p.second * (p.second - 1) / 2;
    }

    std::cout << ans + map[0] << std::endl;

    return 0;
}

Measured memory_bytes: 4224
import sys


def is_a(m: int, f: int) -> bool:
    if 80 <= m + f:
        return True
    return False


def is_b(m: int, f: int) -> bool:
    if 65 <= m + f < 80:
        return True
    return False


def is_c(m: int, f: int, r: int) -> bool:
    if 50 <= r:
        return True
    if 50 <= m + f < 65:
        return True
    return False


def is_d(m: int, f: int, r: int) -> bool:
    if 30 <= m + f < 50:
        if 50 <= r:
            return False
        return True
    return False


def rank(m: int, f: int, r: int) -> str:
    if -1 in [m, f]:
        return 'F'

    if m < 0:
        m = 0
    if f < 0:
        f = 0
    if r < 0:
        r = 0

    if is_d(m, f, r):
        return 'D'
    if is_c(m, f, r):
        return 'C'
    if is_b(m, f):
        return 'B'
    if is_a(m, f):
        return 'A'
    return 'F'


def resolve():
    for line in sys.stdin:
        m, f, r = map(int, line.split())

        if m == f == r == -1:
            break

        print(rank(m, f, r))


resolve()



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

using CP = complex<long double>;
#define X real()
#define Y imag()

long long n;
vector<CP> v;

long double solve();

int main() {
  cout << fixed << setprecision(10);
  cin >> n;
  for(int i = 0; i < n; ++i) {
    long long x, y;
    cin >> x >> y;
    v.push_back(CP(x, y));
  }
  cout << solve() << endl;
  return 0;
}

long double solve() {
  vector<int> p;
  long double ans = 0;
  long long cnt = 0;
  for(int i = 0; i < n; ++i) p.push_back(i);
  do {
    for(int i = 1; i < n; ++i)
      ans += abs(v[p[i]] - v[p[i - 1]]);
    ++cnt;
  } while(next_permutation(p.begin(), p.end()));
  return ans / cnt;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX 111111
int n,A[MAX+1],L[MAX];
int lis(){
  L[0]=A[0];
  int length=1;
  for(int i=1;i<n;i++){
    if(L[length-1]<A[i]){
      L[length++]=A[i];
    }else{
      *lower_bound(L,L+length,A[i])=A[i];
    }
  }
  return length;
}
int main(){
  cin>>n;
  for(int i=0;i<n;i++) cin>>A[i];
  cout<<lis()<<endl;
  return 0;
}

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

ll cnt[202020],A[202020];

int main(){
  int N; cin>>N;
  rep(i,N){
    cin>>A[i];
    cnt[A[i]]++;
  }
  ll sum=0;
  for(int i=1;i<=N;i++){
    sum+=max(0LL,cnt[i]*(cnt[i]-1)/2);
  }
  rep(i,N){
    ll tmp=sum;
    if(cnt[A[i]]>1){
      ll x=cnt[A[i]];
      tmp-=x*(x-1)/2;
      tmp+=max(0LL,(x-1)*(x-2)/2);
    }
    cout<<tmp<<endl;
  }
  return 0;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 200009
#define mod 998244353
ll n,q,i,j,k,t,arr[sz],brr[sz],crr[sz],a,b,c,d;
int main()
{
    scanf("%lld %lld",&n,&q);
    if(n>q)
        printf("safe");
    else
        printf("unsafe");
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    
    if (s[0] == 'A') {
        string t = s.substr(2, s.length()-3);
        int count = 0;
        for (int i = 0; i < t.length(); i++) {
            if (t[i] == 'C') {
                count ++;
            }
        }
        if (count == 1) {
            for (int i = 0; i < s.length(); i++) {
                if (s[i]!='A' && s[i]!='C') {
                    if ('a'<=s[i] && s[i]<='z') {}
                    else {
                        cout << "WA" << endl;
                        return 0;
                    }
                }
            }
            cout << "AC" << endl;
        }
        else
            cout << "WA" << endl;
    }
    else
        cout << "WA" << endl;
}

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

int main() {
    int x, n;
    cin >> x >> n;
    vector<int> d(102);
    rep(i, n) {
        int p;
        cin >> p;
        d[p] = 1;
    }
    P ans(99999, -1);
    for(int i = 0; i <= 101; i++) {
        if(d[i] == 1) continue;
        int dif = abs(x-i);
        ans = min(ans, P(dif, i));
    }
    cout << ans.second << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

#define _GLIBCXX_DEBAC
using namespace std;
	

int main() {
	int n;
	cin >> n;
	int x = 0;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < n-2; i++) {
		for (int j = i+1;  j < n - 1; j++) {
			for (int k = j + 1; k < n; k++) {
				if (a[i] >= a[j] + a[k]){
					break;
				}
				else if(a[j] >= a[i] + a[k]) {
					break;
				}
				else if (a[k] >= a[i] + a[j]) {
					break;
				}
				else {
					x += 1;
				}
				
			}
		}
	}
	cout << x;
		return 0;
}









Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int gcd( int m, int n )
{
	int a=max(m,n),b=min(m,n);
	if(m==0) return n;if(n==0) return m;
	if(a%b==0) return b;
	return gcd(b,a-b*(a/b));
}
int main()
{
	int n,out=0,a;
	cin>>n;
	rep(i,n){
		cin>>a;out=gcd(out,a);
	}
	cout<<out<<endl;
}


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

int main(){
	int sum = 0;
	int a;
	cin >> a;
	for(int i =0 ;i < a;i++){
		char b;
		cin >> b;
		if(b=='R'){
			sum += 1;
		}
		else{
			sum -= 1;
		}
	}
	if(sum > 0){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
	return 0;
} 

Measured memory_bytes: 256
//????????¢?????¢?????¨??¨??????????????????
#include<iostream>
using namespace std;

int main()
{
	int a=0, b=0;
	
	cin >> a >> b;
	
	cout << a*b << " " << 2*a+2*b << "\n";
	
	return 0;
	
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m, total = 0;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int a;
        cin >> a;
        total += a;
    }
    if (n - total < 0) cout << -1 << '\n';
    else cout << n - total << '\n';
    return 0;
}


Measured memory_bytes: 3652
fn main() {
    proconio::input! {
        n: usize,
        c: proconio::marker::Bytes,
    }
    let mut k=0;
    for &c in &c {
        if c==b'R' {
            k+=1;
        }
    }
    for &c in &c[0..k] {
        if c==b'R' {
            k-=1;
        }
    }
    println!("{}",k);
}

Measured memory_bytes: 2336
#include<bits/stdc++.h>
#define mp make_pair
#define pr pair<ll,ll>
#define MAX 1000000
using namespace std;
typedef long long int ll;
#define mod 998244353
void sync(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}

int main(){
	sync();
	ll t;
	t=1;
	string x;
	for(ll testcase=1;testcase<=t;testcase++){
		cin>>x;
		int n=x.length();
		if(x[2]==x[3]&&x[4]==x[5])
		cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	int f=0,s=0,t=0,num,tmp;
	
	for(int i=0;i<10;i++){
		cin>>num;
		if(num>t){
			t=num;
		}
		if(t>s){
			tmp=s;
			s=t;
			t=tmp;
		}
		if(s>f){
			tmp=f;
			f=s;
			s=tmp;
		}
		
	}
	cout << f << endl << s << endl << t << endl;
	
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    constexpr int bigScore = 1000;

    int n;
    cin >> n;

    vector<int> scores(n);
    
    for(int i = 0; i < n; ++i) cin >> scores[i];

    int minScore {bigScore}, sum {};

    for(auto s : scores) {
        sum += s;
        if(s < minScore && s % 10 != 0) {
            minScore = s;
        }
    }

    if(sum % 10 == 0) sum = (minScore != bigScore ? sum - minScore : 0);

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
vector<int> ans;

void dfs(int i,int now){
ans.push_back(i);
if (i*now<=1e3) dfs(i*now,now);
}

void pre(){
for (int i=2;i*i<=1e3;++i) dfs(i*i,i);
}

int main(){
pre();
ans.push_back(1);
sort(ans.begin(),ans.end());
int n=read();
write(*--upper_bound(ans.begin(),ans.end(),n));
}

Measured memory_bytes: 256
h,w = map(int,input().split())
a = [list(map(str,input())) for _ in range(h)]
cnt = h
for i in range(h):
    if '#' not in a[i]:
        a[i].clear()
        cnt -= 1
if cnt != h:
    a = [_ for _ in a if _]
i = 0
while i < w:
    for j in range(cnt):
        if a[j][i] == '#':
            break
    else:
        for j in range(cnt):
            a[j].pop(i)
        w -= 1
        i -= 1
    i += 1
for i in range(cnt):
    print(''.join(map(str,a[i])))

Measured memory_bytes: 3188
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *

N, Q = map(int, input().split())
es = [[] for i in range(N+1)]
for i in range(N-1):
    a, b = map(int, input().split())
    es[a].append(b)
cnt = [0] * (N+1)
for i in range(Q):
    p, x = map(int, input().split())
    cnt[p] += x
def EulerTour(v, p, c):
    for u in es[v]:
        if u != p:
            EulerTour(u, v, c+cnt[v])
    cnt[v] += c
EulerTour(1, 0, 0)
print(*cnt[1:])


Measured memory_bytes: 226804
s=input()

def check(s):
    n=len(s)
    if n<7:
        print("NO")
    elif n==7:
        if s[0:7]=="keyence":
            print("YES")
        else:
            print("NO")
    
    elif s[0]=="k" and s[n-1]=="e":
        count=0
        for i in range(6):
            if s[0:i+1]+s[n-(7-i-1):n]=="keyence":
                count=1
                
        if count==1:
            print("YES")
        else:
            print("NO")
            
    elif s[0]=="k":
        if s[0:7]=="keyence":
            print("YES")
        else:
            print("NO")
            
    elif s[n-1]=="e":
        if s[n-7:n]=="keyence":
            print("YES")
        else:
            print("NO")
        
    else:
        print("NO")

check(s)




Measured memory_bytes: 38256
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#define REL
#endif
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <random>
#include <set>
#include <vector>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <array>
#include <forward_list>
#include <chrono>
#include <iomanip>
#include <utility>
#include <assert.h>

//#pragma GCC optimize("Ofast")
//#pragma target("sse", "sse1")

#define mp make_pair
#define pb push_back

#define endl '\n'

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

mt19937 gen(34);
//mt19937_64 gen(41);

int gcd(int a, int b) {
	while (b) {
		a %= b;
		swap(a, b);
	}
	return a;
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("rps2.in", "r", stdin);
	//freopen("rps2.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//----------------------------------------------//
	int n;
	cin >> n;
	int res = 0;
	for (int i = 1; i <= n; i++) {

		for (int j = 1; j <= n; j++) {
			int g = gcd(i, j);
			for (int k = 1; k <= n; k++) {
				res += gcd(g, k);
			}
		}
	}
	cout << res;
	//----------------------------------------------//

	return 0;
}




Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
#define endl "\n"
#define ll long long
 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll int a,b,c,d,x,y,z,w,ans;
	cin >> a >> b >> c >> d;
	x=a*c;
	y=a*d;
	z=b*c;
	w=b*d;
	ans=max(x,w);
	ans=max(ans,y);
	ans=max(ans,z);
	
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

const int N = 3e3 + 10;
const int Mod = 1e9 + 7;
const int inv2 = (Mod + 1) / 2;

int add(int a, int b) {
  return (a += b) >= Mod ? a - Mod : a;
}

int sub(int a, int b) {
  return (a -= b) < 0 ? a + Mod : a;
}

int mul(int a, int b) {
  return 1ll * a * b % Mod;
}

int n, q, a[N], x[N], y[N];
int f[N][N];

int main() {
  cin >> n >> q;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= q; i++) cin >> x[i] >> y[i];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      f[i][j] = (a[i] > a[j]);
    }
  }
  for (int i = 1; i <= q; i++) {
    if (x[i] == y[i]) continue;
    for (int j = 1; j <= n; j++) if (j != x[i] && j != y[i]) {
      f[x[i]][j] = f[y[i]][j] = mul(inv2, add(f[x[i]][j], f[y[i]][j]));
      f[j][x[i]] = f[j][y[i]] = mul(inv2, add(f[j][x[i]], f[j][y[i]]));
    }
    f[x[i]][y[i]] = f[y[i]][x[i]] = mul(inv2, add(f[x[i]][y[i]], f[y[i]][x[i]]));
    for (int j = 1; j <= n; j++) if (j != y[i]) {
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      ans = add(ans, f[i][j]);
    }
  }
  for (int i = 1; i <= q; i++) {
    ans = mul(ans, 2);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 35584
n = list(input())
a = n[0] + n[1]
b = n[2] + n[3]
num = ('01','02','03','04','05','06','07','08','09','10','11','12')
if a in num and b in num:
    print('AMBIGUOUS')
elif b in num:
    print('YYMM')
elif a in num:
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 3064
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int t, n, s, f, sum, i;

    for(;;){
      t = sc.nextInt();
      if(t == 0)break;

      n = sc.nextInt();
      sum = 0;
      for(i = 0;i < n;i++){
        s = sc.nextInt(); f = sc.nextInt();
        sum += f - s;
      }

      if(sum >= t)out.println("OK");
      else out.println(t - sum);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 23528
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b

signed main(){
	int h,w,a,b;  cin>>h>>w>>a>>b;
  int ans[h][w];
  rep(i,0,h){
    rep(j,0,w){
      if(i<b && j<a)ans[i][j]=0;
      else if(i<b || j<a)ans[i][j]=1;
      else ans[i][j]=0;
    }
  }
  rep(i,0,h){
    rep(j,0,w){
      cout<<ans[i][j];
    }
    cout<<endl;
  }

      
      
 
  
	
	
	return 0;
}

Measured memory_bytes: 7536
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    string n;
    cin>>n;
    long long g = 0;
    for(long i= 0;i<n.length();i++){
    	char c = n[i];
		int  f = c - '0';
        g += f;
    }
    if(g%9==0) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#define llt long long int

using namespace std;
int main()
{
    string s;
    cin >> s;

    for (int i = 0; i < 3; i++)
    {
        if (s[i] == s[i + 1])
        {
            cout << "Bad" << endl;
            return 0;
        }
    }

    cout << "Good" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;


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

	vector<ll> A(N);
	
	rep(i, N) {
		cin >> A[i];
	}

	sort(A.begin(), A.end(), greater<>());

	ll L = 0, count = 0, ans = 1, key = 0;

	rep(i, N) {
		if (L == A[i]) {
			count++;
		}
		else {
			L = A[i];
			count = 1;
		}

		if (count == 2) {
			ans *= L;
			count = 0;
			key++;
		}

		if (key == 2) {
			break;
		}
	}

	if (key == 2) {
		cout << ans;
	}
	else {
		cout << 0;
	}


	return 0;

}


Measured memory_bytes: 3868
line = gets.split(' ').map(&:to_i)

X = line[0]
K = line[1]
D = line[2]

def abs(x)
  if x > 0 then
    return x
  else
    return -x
  end
end
  
def min(x,y)
  if x > y then
    return y
  else
    return x
  end
end
 
X2 = abs(X)
num_to_min = X2 / D
  
if num_to_min >= K then
    puts abs(X2 - K * D)
else
  cand1 = abs(X2 - num_to_min * D)
  cand2 = abs(X2 - (num_to_min + 1) * D)
  if (K - num_to_min) % 2 == 0 then
    puts cand1
  else
    puts cand2
  end
end

Measured memory_bytes: 14388
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int gcd(int a,int b){
    int temp;
    while(b>0){
        temp=a;
        a=b;
        b=temp%b;
    }
    return a;
}

int main(){
    int n,ans; cin>>n;
    cin>>ans;
    rep(i,n-1){
        int a; cin>>a;
        ans=gcd(ans,a);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3568
import std.stdio, std.ascii, std.array, std.string;

alias int function(int, int) Op;

enum Type {LParen, RParen, Plus, Minus, Multi, Div, Number, Equal}

struct Token {
  Type type;
  union V {
    int number;
    Op op;
  }
  V variant;
}

Token[char] table;
Token[] state;

static this() {
  table =
    ['+': Token(Type.Plus),
     '-': Token(Type.Minus),
     '*': Token(Type.Multi),
     '/': Token(Type.Div),
     '(': Token(Type.LParen),
     ')': Token(Type.RParen),
     '=': Token(Type.Equal)];
  
  table['+'].variant.op = (x, y) => x + y;
  table['-'].variant.op = (x, y) => x - y;
  table['*'].variant.op = (x, y) => x * y;
  table['/'].variant.op = (x, y) => x / y;
}

Token[] tokenize(string str) {
  Token[] tokens;
  int i = 0;
  while(str.length > i) {
    if (isDigit(str[i])) {
      Token token;
      int number = 0;
      do {
        number = 10 * number + (str[i] - '0');
      } while(isDigit(str[++i]));
      token.type = Type.Number;
      token.variant.number = number;
      tokens ~= token;
    }
    else {
      tokens ~= table[str[i++]];
    }    
  }
  return tokens;
}

Token[] expect(Token[] tokens, Type type) {  
  if (tokens[0].type != type) throw new Exception("unexpected token.");
  else
    return tokens[1..$];
}

void operate(Token token) {
  Token a = state.back; state.popBack;
  Token b = state.back; state.popBack;
  assert(a.type == Type.Number && b.type == Type.Number);
  Token t;
  t.type = Type.Number;
  t.variant.number = token.variant.op(b.variant.number, a.variant.number);
  state ~= t;
}

Token[] factor(Token[] tokens) {
  switch(tokens[0].type) {
  case Type.Number:
    state ~= tokens.front;
    tokens.popFront;
    break;
  case Type.LParen:
    tokens.popFront;
    tokens = expect(expression(tokens), Type.RParen);
    break;
  default:
    throw new Exception("error occured");
    break;
  }
  return tokens;
}

Token[] term(Token[] tokens) {
  tokens = factor(tokens);
  while(tokens[0].type == Type.Multi ||
        tokens[0].type == Type.Div) {
    Token front = tokens.front;
    tokens.popFront;
    tokens = factor(tokens);
    operate(front);
  }
  return tokens;
}

Token[] expression(Token[] tokens) {
  tokens = term(tokens);
  while(tokens[0].type == Type.Plus ||
        tokens[0].type == Type.Minus) {
    Token front = tokens.front;
    tokens.popFront;
    tokens = term(tokens);
    operate(front);
  }
  return tokens;
}

alias expression parse;

int eval(string line) {
  state = [];
  parse(line.tokenize);
  return state[0].variant.number;
}

void main() {
  int times;
  readf("%d\n", &times);
  foreach(t; 0..times) {
    readln.chomp.eval.writeln;
  }
}

Measured memory_bytes: 1084