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

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define        optimize    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007


int main()
{
    ll i,j,k,l,m,n,x,y;

    cin  >> n;

    ll mn = -1,mx= -1,lmx=-1,lmn=-1;

    vl v1,v2;
    for(i=0; i<n; i++)
    {
        cin  >> x >> y;

        if(mn == -1)mn = x+y;
        else mn = min(mn,x+y);

        if(mx == -1)mx = x+y;
        else mx = max(mx,x+y);

        v1.pb(x-y);
        v2.pb(y-x);
    }

    ll ans = mx-mn;


   // sort(all(v));
    sort(all(v1));
    sort(all(v2));
  //  sort(all(v3));

   // reverse(all(v));
    reverse(all(v1));
    reverse(all(v2));
    //reverse(all(v3));

    ans = max(ans,v1[0]+v2[0]);

    cout << ans << endl;



}


Measured memory_bytes: 6616
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#define Cin(T, x) T x; cin >> x
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cout(x) cout << (x) << "\n"
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) find(Range(c), x) != c.end()
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, vs, n, m) vector<vector<T>> vs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]

using namespace std;
using ll = long long;

int main(void){
    Cin(int, n);
    For(i, n){
        Cin(ll, a);
        Cin(ll, b);
        if(a == b){ Cout(2*a-2); continue; }
        ll x = floor(sqrt(a*b));
        Cout((x*(x+1) < a*b) ? 2*x-1 : (x*x < a*b) ? 2*x-2 : 2*x-3);
    }
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val inputs = readLine()!!.split(" ").map { it.toInt() }

    var ans = 0
    for (i in 0 until n-2) {
        if((inputs[i+1] > inputs[i] && inputs[i + 1] < inputs[i + 2]) || (inputs[i+1] < inputs[i] && inputs[i + 1] > inputs[i + 2])) {
            ans += 1
        }
    }


    println(ans)
}

Measured memory_bytes: 37904
public class Main {
	public static void main(String[] args) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		int[] a = new int[1];
		int[] b = new int[1];
		do {
			int x = sc.nextInt();
			if (x == 0) { break;}
			a[a.length - 1] = x;
			
			b = new int[a.length];
			for (int j = 0;j < a.length;j++){
				b[j] = a[j];
			}
			a = new int[a.length + 1];
			for (int j = 0;j < b.length;j++){
				a[j] = b[j];
			}
		} while (true);
		for (int i = 0;i < b.length;i++) {
			System.out.println("Case " + (i+1) + ": " + b[i]);
		}
	}
}

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

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	ll n, a, b;
	cin >> n >> a >> b;
	
	if((n == 1 && a != b) || a > b){
		cout << 0 << endl;
		return 0;
	}
	
	ll mn = a * (n - 1) + b;
	ll mx = b * (n - 1) + a;
	
	ll ans = mx - mn + 1;
	
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdtr1c++.h>
using namespace std;
#define INP "solve"
#define OUT "solve"
const int QQ = 3e5 + 10;
const int maxN = 3e5 + 10;
const int maxM = 3e5 + 10;
const int oo = 1e9;
const int module = 1e9 + 7;
const long double du = 1e-9;

void doc() {
    freopen(INP ".inp","r",stdin);
    freopen(OUT ".out","w",stdout);
}

void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    if (n >= 3200) cout << s;
    else cout << "red";
}
int main(int argc,char *argv[]) {
    //srand(time(nullptr));
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    //doc();
    solve();
}


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

int main() {
  int a, b;
  cin >> a >> b;
  int west = 0, east = 0,ans;

  int k = 0;
  while (1) {
    k++;
    west += k;
    east = west + (k + 1);
    if ((west - a) == (east - b)) break;
  }

  cout << (west - a) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  long long ans = 0LL;
  vector<long long> name(5);
  for(int i = 0; i < n; i++){
    string s; cin >> s;
    if(s.at(0) == 'M') name[0]++;
    else if(s.at(0) == 'A') name[1]++;
    else if(s.at(0) == 'R') name[2]++;
    else if(s.at(0) == 'C') name[3]++;
    else if(s.at(0) == 'H') name[4]++;
  }
  for(int i = 0; i < 5; i++){
    for(int j = i + 1; j < 5; j++){
      for(int k = j + 1; k < 5; k++){
        ans += name[i] * name[j] * name[k];
      }
    }
  }
  cout << ans;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << "[line : " << __LINE__ <<"]"<< pp(x)
#define dg2(x,y) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y)
#define dg3(x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(w) pp(x) pp(y) pp(z)
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x , y) memset(x , y , sizeof x);
#define sz(x) (int)x.size()

const int Mod = 1e9 + 7;
const int inf = 1e18;

struct edge {
  int u , v , w;
};

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N , M;
  cin >> N >> M;
  vector<int> dist(N + 1, -inf);
  vector<edge> Ed;
  for(int i = 0;i < M; i++) {
    int a, b , c;
    cin >> a >> b >> c;
    Ed.push_back({a, b, c});
  }
  dist[1] = 0;
  for(int i = 1; i < N; i++) {
    for(auto j : Ed) {
      if(dist[j.u] != -inf) {
        dist[j.v] = max(dist[j.v] , dist[j.u] + j.w);
      }
    }
  }
  int ans = dist[N];
  for(int i = 1; i < N; i++) {
  for(auto j : Ed) {
    if(dist[j.u] != -inf) {
      dist[j.v] = max(dist[j.v] , dist[j.u] + j.w);
    }
  }
 }
 
 if(ans != dist[N]) {
   cout << "inf" << '\n';
   return 0;
 }
 cout << ans << '\n';

}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define INF 1145141919
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int ny, nx;
typedef long long int ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
////////////////////////////////////////////////////////////////////
int main()
{

    vector<int> lunch(5);
    REP(i,5) cin >> lunch[i];
    int ans=-INF, num;

    REP(i,5){
        int res = (int(lunch[i]/10)+1)*10;
        if(res-lunch[i]>ans and res-lunch[i]!=10){
            ans = res-lunch[i];
            num = i;
        }
    }

    int res=0;

    REP(i,5){
        if(i==num){
            res+=lunch[i];
        }else{
            if(lunch[i]%10!=0) res+=(int(lunch[i]/10)+1)*10;
            else res+=lunch[i];
        }
    }

    cout << res << endl;

    return 0;
}


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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3");
            WillReturn.Add("3 4 6");
            //10
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("5");
            WillReturn.Add("7 46 11 20 11");
            //90
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("7");
            WillReturn.Add("994 518 941 851 647 2 581");
            //4527
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] AArr = InputList[1].Split(' ').Select(X => int.Parse(X)).ToArray();
        Console.WriteLine(AArr.Sum(X => X - 1));
    }
}


Measured memory_bytes: 13424
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);

        int K = s.nextInt();
        int A = s.nextInt();
        int B = s.nextInt();

        if(check(K, A, B))
            System.out.println("OK");
        else
            System.out.println("NG");


    }
    public static boolean check(int K, int A, int B) {
        for(int i=A; i<=B; i++){
            if(i%K==0)
                return true;
        }
        return false;
    }


}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
typedef long long LL;
typedef double db;
typedef pair<int,int> PII;
const double PI=acos(-1.0);
const int INF=1e9;
const double EPS=1e-10;


int main(){
int n,dai;
dai=0;
cin>>n;
vector<int> v(n);
vector<int> c(n);
REP(i,n){
cin>>v[i];
}
REP(i,n){
cin>>c[i];
  if(v[i]>c[i])dai+=(v[i]-c[i]);
}
  

cout<<dai<<endl;
return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
t=[list(map(int,input().split()))for i in range(m)]
ans=[0]*(n+1)
for i in range(m):
    ans[t[i][0]]+=1
    ans[t[i][1]]+=1
for i in range(1,n+1):
    print(ans[i])


Measured memory_bytes: 3060
while str = gets do
  num = str.chomp.to_i
  break if num == 0
  array = []
  num.times do |n|
    array << gets.chomp.split(" ")
  end
  snum = gets.chomp.to_i
  str = ""
  snum.times do |n|
    chr = gets.chomp
    change_str = array.find{|a| a[0] == chr}
    unless change_str.nil?
      chr = change_str[1]
    end
    str << chr
  end
  puts str
end

Measured memory_bytes: 8992
#include <iostream>			//std::cout, std::cin
#include <string>			//std::string,std::to_string(C++11)
#include <vector>			//std::vector
#include <valarray>			//std::valarray
#include <algorithm>		//std::sort
#include <ctime>			//localtime_s
#include <cstdlib>			//abs
#include <cmath>			//abs,std::pow,sqrt,sin,cos,round,floor,ceil
#include <fstream>			//std::ifstream,std::ofstream
#include <iomanip>			//std::setprecision,std::setw,std::setfill
#include <random>			//std::random(C++11)
#include <numeric>			//std::accumulate
#include <functional>		//std::greater
#include <chrono>			//std::chrono(C++11)
#include <bitset>			//std::bitset
#include <queue>			//std::queue

const static double	de_PI	= 3.14159265358979323846;
const static int	de_MOD	= 1000000007;
const static int	de_MAX	= 999999999;

unsigned long long Greatest_Common_Divisor(unsigned long long a, unsigned long long b) {

	while (a != 0 && b != 0) {
		if (a > b) {
			a = a - b;
		}
		else {
			b = b - a;
		}
	}
	return(a + b);
}

int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());
	//std::ofstream ofs("456.csv");
	//std::chrono::system_clock::time_point t_st = std::chrono::system_clock::now();

	unsigned long long a = 0, b = 0;
	std::vector<unsigned long long> GCD,LCM;

	while (std::cin >> a) {
		std::cin >> b;
		GCD.push_back(Greatest_Common_Divisor(a, b));
		LCM.push_back(a*b / GCD.back());
	}

	for (unsigned int i = 0; i < GCD.size(); i++) {
		std::cout << GCD[i] << " " << LCM[i] << std::endl;
	}

	//std::chrono::system_clock::time_point t_ed = std::chrono::system_clock::now();
	//std::cout << std::chrono::duration_cast<std::chrono::milliseconds>(t_ed - t_st).count() << "ms" << std::endl;

}

Measured memory_bytes: 3108
import heapq
n = int(input())
a = list(map(int, input().split()))

l_sum = [0 for _ in range(n+1)]
r_sum = [0 for _ in range(n+1)]

que = a[:n]
l_sum[0] = sum(que)
heapq.heapify(que)

for i in range(n):
    l_sum[i+1] = l_sum[i]

    if que[0] < a[n+i]:
        l_sum[i+1] += a[n+i] - que[0]
        heapq.heappop(que)
        heapq.heappush(que, a[n+i])


que = [-a[i] for i in range(2*n, 3*n)]
r_sum[0] = -sum(que)
heapq.heapify(que)

for i in range(n):
    r_sum[i+1] = r_sum[i]
    
    if -que[0] > a[2*n-1-i]:
        r_sum[i+1] += a[2*n-1-i] + que[0]
        heapq.heappop(que)
        heapq.heappush(que, -a[2*n-1-i])


ans = -1e15
for x in range(n+1):
    ans = max(ans, l_sum[x] - r_sum[n-x])

print(ans)

Measured memory_bytes: 37212
#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,w,d;
int nexts=1;

typedef tuple<int,int,int,int,int> rect;

int main(void){
	while(cin >> n >> w >> d){
		if(w==0)
			break;
		nexts=1;
		vector<rect> buff;
		rect init=make_tuple(nexts++,0,0,w,d);
		buff.pb(init);
		rep(i,n){
			sort(buff.begin(),buff.end());
			int p,s;
			cin >> p >> s;
			int xx,yy,ww,hh;
			rect cur=buff[p-1];
			buff.erase(remove(buff.begin(),buff.end(),cur),buff.end());
			tie(ignore,xx,yy,ww,hh)=cur;
			int wid=ww-xx;
			int hei=hh-yy;
			int mod=(wid+hei);
			s%=2*mod;
			bool rev=(s>mod);
			s%=mod;

			rect small,large;
			if(s<wid){
				if(rev) s=wid-s;
				if(s<=wid/2){
					small=make_tuple(nexts++,xx,yy,xx+s,hh);
					large=make_tuple(nexts++,xx+s,yy,ww,hh);
				}else{
					small=make_tuple(nexts++,xx+s,yy,ww,hh);
					large=make_tuple(nexts++,xx,yy,xx+s,hh);
				}
			}else{
				s-=wid;
				if(rev) s=hei-s;
				if(s<=hei/2){
					small=make_tuple(nexts++,xx,yy,ww,yy+s);
					large=make_tuple(nexts++,xx,yy+s,ww,hh);
				}else{
					small=make_tuple(nexts++,xx,yy+s,ww,hh);
					large=make_tuple(nexts++,xx,yy,ww,yy+s);
				}
			}
			buff.pb(small);
			buff.pb(large);
		}
		vi ans;
		rep(i,buff.size()){
			int xx,yy,ww,hh;
			tie(ignore,xx,yy,ww,hh)=buff[i];
			ans.pb((ww-xx)*(hh-yy));
		}
		sort(ans.begin(),ans.end());
		rep(i,ans.size())
			cout << (i?" ":"") << ans[i];
		cout << endl;
	}
	return 0;
}

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

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

  std::vector<int> x(N), y(N);
  rep(i, N) {
    std::cin >> x[i] >> y[i];
  }

  std::vector<std::vector<double>> d(N, std::vector<double>(N));
  for(int i = 0; i < N; ++i) {
    for(int j = i + 1; j < N; ++j) {
      double dx = (double) (x[i] - x[j]);
      double dy = (double) (y[i] - y[j]);
      d[i][j] = std::sqrt(dx * dx + dy * dy);
      d[j][i] = d[i][j];
    }
  }

  double sum = 0;
  std::vector<int> perm(N);
  rep(i, N) {
    perm[i] = i;
  }
  do {
    for(int i = 1; i < N; ++i) {
      sum += d[perm[i - 1]][perm[i]];
    }
  } while(std::next_permutation(perm.begin(), perm.end()));

  double ans = sum;
  for(int i = 2; i <= N; ++i) {
    ans /= i;
  }

  std::cout << std::fixed << std::setprecision(10);
  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) res = res * x % mod;
	return res;
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

int main() {
	int n, k;
	cin >> n >> k;
	int ans = 0;
	while (n != 0) {
		ans++;
		n /= k;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtcoderPractice
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            
            //出力
            Console.WriteLine(a / 3);

            // Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
n = int(input())
h = list(map(int, input().split()))

dp = [0] * n
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]),
                dp[i - 2] + abs(h[i] - h[i - 2]))
print(dp[-1])

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void solve(string AtCoder, string s, string Contest) {
  cout << 'A' << s[0] << 'C' << '\n';
}

int main() {
  // cout << fixed << setprecision(5);

  string AtCoder;
  cin >> AtCoder;
  string s;
  cin >> s;
  string Contest;
  cin >> Contest;
  solve(AtCoder, s, Contest);
  return 0;
}


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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;


int main() {
    cin.tie(0);
	ios::sync_with_stdio(false);

    while (true) {
        int H, W;
        cin >> H >> W;
        if (H == 0 and W == 0) {
            break;
        }

        vector<string> field(H);
        FOR(i, 0, H) {
            cin >> field[i];
        }

        vector<vector<int>> dp(H, vector<int>(W, 0));
        FOR(x, 0, W) {

            FOR(y, 0, H) {
                if (y == 0) {
                    dp[y][x] = (field[y][x] == '*' ? 0 : 1);
                }
                else {
                    if (field[y][x] == '*') {
                        dp[y][x] = 0;
                    }
                    else {
                        dp[y][x] = dp[y - 1][x] + 1;
                    }
                }
            }
        }

        int ans = 0;
        FOR(y, 0, H) {
            FOR(x1, 0, W) {
                int max_h = INF;
                FOR(x2, x1, W) {
                    max_h = min(max_h, dp[y][x2]);
                    ans = max(ans, (x2 - x1 + 1) * max_h);
                }
            }
        }

        print(ans);
    }

	return 0;
}


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

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  rep(i, h) {
    cin >> a[i];
  }
  vector<vector<int>> dp(1010, vector<int>(1010));
  dp[0][0] = 1;
  rep(i, h) rep(j, w) {
    if(a[i][j] == '#') continue;
    dp[i + 1][j] += dp[i][j];
    dp[i + 1][j] %= mod;
    dp[i][j + 1] += dp[i][j];
    dp[i][j + 1] %= mod;
  }
  cout << dp[h - 1][w - 1] << endl;
}

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

int main(){
  long A,B,K;
  cin>>A>>B>>K;
  if(A>K)
    cout<<A-K<<" "<<B<<endl;
  else if(B>K-A)
    cout<<0<<" "<<B+A-K<<endl;
  else
    cout<<0<<" "<<0<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
using namespace std;

static inline void p(int x) { printf("%d\n", x); }

int main()
{

	int n, cnt = 0;
	scanf("%d", &n);

	vector<int> A(n), G;
	for (int &x: A)
		scanf("%d", &x);

	for (int i = 1, x = 1; x <= n; x = (pow(3, ++i) - 1) / 2)
		G.push_back(x);
	reverse(G.begin(), G.end());

	for (int g: G)
		for (auto i = A.begin() + g; i != A.end(); i++) {
			int v = *i;
			auto j = i - g;
			for(; j >= A.begin() && *j > v; j -= g)
				*(j + g) = *j, cnt++;
			*(j + g) = v;
		}

	p(G.size());
	for (int &x: G)
		printf("%s%d", (&x == &G[0] ? "" : " "), x);
	puts("");
	p(cnt);
	for (int x: A)
		p(x);
}


Measured memory_bytes: 6252
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>

#define MAX_SIZE 100000000
typedef unsigned long long ull;
using namespace std;

int main() {
  int N; cin >> N;
  vector<string> w_vec(N);
  for(auto& w : w_vec) {
    cin >> w;
  }

  set<string> memo;
  memo.insert(w_vec[0]);
  string end_str = w_vec[0].substr(w_vec[0].size() - 1, 1);
  for(int i = 1; i < N; i++) {
    if(memo.find(w_vec[i]) != memo.end()) {
      cout << "No" << endl;
      return 0;
    }
    memo.insert(w_vec[i]);

    string start_str = w_vec[i].substr(0, 1);
    if(end_str != start_str) {
      cout << "No" << endl;
      return 0;
    }
    end_str = w_vec[i].substr(w_vec[i].size() - 1, 1);
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
 
#include <stdio.h>
#include <bits/stdc++.h>
 
using namespace std;
 
#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  
#define pb push_back
#define mp make_pair
#define in insert
#define f first
#define s second
#define ll long long
#define dd double
  
const int mod = 1e9 + 7;
const int N = 2e5 + 7;
const int inf = 2e9;
const ll INF = 1e18;

double dp[303][303][303];
int cnt[303];

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	// freopen("*.in", "r", stdin);freopen("*.out", "w", stdout);
	double n;
	cin >> n;
	for(int i = 0; i < n; i++) {
		int a;
		cin >> a;
		cnt[a]++;
	}
	for(int k = 0; k <= n; k++) {
		for(int j = 0; j <= n; j++) {
			for(int i = 0; i <= n; i++) {
				if(i + j + k == 0 || i + j + k > n) continue;
				dp[i][j][k] = 1;
				if(i) dp[i][j][k] += dp[i - 1][j][k] * i / n;   
				if(j) dp[i][j][k] += dp[i + 1][j - 1][k] * j / n;    
				if(k) dp[i][j][k] += dp[i][j + 1][k - 1] * k / n;   
				dp[i][j][k] *= n / (i + j + k);
			}
		}
	}
	printf("%0.11lf", dp[cnt[1]][cnt[2]][cnt[3]]);
}

Measured memory_bytes: 217472
#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) x&(-x)
int n,a[100010][5],b[100010],bit[100010],f0,f1,g0,g1;
void add(int x,int v)
{
	for (;x<=n;x+=lowbit(x))
	{
		bit[x]+=v;
	}
}
int ask(int x)
{
	int res=0;
	for (;x;x-=lowbit(x))
	{
		res+=bit[x];
	}
	return res;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=3;i++)
	{
		for (int j=1;j<=n;j++)
		{
			scanf("%d",&a[j][i]);
		}
	}
	for (int i=1;i<=n;i++)
	{
		int x,y,z;
		x=a[i][1];
		y=a[i][2];
		z=a[i][3];
		if (!((x+1==y && z-1==y) || (x-1==y && z+1==y)))
		{
			puts("No");
			return 0;
		}
		b[i]=y/3+1;
		if ((b[i]-i)&1)
		{
			puts("No");
			return 0;
		}
	}
	for (int i=1;i<=n;i+=2)
	{
		if (a[i][1]/3==b[i])
		{
			g1++;
		}
		f1=(f1+i/2-ask(b[i]))%2;
		add(b[i],1);
	}
	memset(bit,0,sizeof(bit));
	for (int i=2;i<=n;i+=2)
	{
		if (a[i][1]/3==b[i])
		{
			g0++;
		}
		f0=(f0+i/2-1-ask(b[i]))%2;
		add(b[i],1);
	}
	g0%=2;
	g1%=2;
	if (f0==g1 && f1==g0)
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}
	return 0;
}
//人生如逆旅，我亦是行人。
//——苏轼《临江仙·送钱穆父》

Measured memory_bytes: 2944
#include<iostream>
using namespace std;
int ans[500];
int a,b,c,N;
int r[1000],x[1000],y[1000],z[1000];
void init(){
  for(int i=0;i<500;i++)ans[i]=2;
}
int main(){
  while(cin>>a>>b>>c&&a&&b&&c){
    init();
    cin>>N;
    for(int i=0;i<N;i++){
      cin>>x[i]>>y[i]>>z[i]>>r[i];
      if(r[i]==1)ans[x[i]]=1,ans[y[i]]=1,ans[z[i]]=1;
    }
    for(int i=0;i<N;i++){
      if(r[i]==1)continue;
      if(ans[x[i]]==1&&ans[y[i]]==1)ans[z[i]]=0;
      if(ans[y[i]]==1&&ans[z[i]]==1)ans[x[i]]=0;
      if(ans[z[i]]==1&&ans[x[i]]==1)ans[y[i]]=0;
    }
    for(int i=1;i<=a+b+c;i++){
      cout<<ans[i]<<endl;
    }
    
  }
  return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define inchar			getchar
#define outchar(x)		putchar(x)
#define ll long long int
#define all(v) v.begin(), v.end()
#define SP outchar(' ')
#define LN outchar('\n')
using namespace std;

template<typename T> void inpos(T &x){x=0;register T c=inchar();while(((c<48)||(c>57))&&(c!='-'))c=inchar();bool neg=0; if(c=='-')neg=1;for(;c<48||c>57;c=inchar());for(;c>47&&c<58;c=inchar())x=(x<<3)+(x<<1)+(c&15);if(neg)x=-x;}
template<typename T> void outpos(T n){if(n<0){outchar('-');n*=-1;}char snum[65];int i=0;do{snum[i++]=n%10+'0';n/=10;}while(n);i=i-1;while(i>=0)outchar(snum[i--]);}
inline void instr(char *str){register char c=0;register int i=0;while(c<33)c=inchar();while(c!='\n'&&c!=' '&&c!=EOF){str[i]=c;c=inchar();++i;}str[i]='\0';}

// DP for weights
// ith value ke liye minimum weight kya hai



int main ( ){
	int n;
	int w;
	inpos(n); inpos(w);
	int val[n]; int Wt[n];
	ll sum = 0;
	for (int i = 0; i<n;i++) {
		inpos(Wt[i]);
		inpos(val[i]);
		sum += val[i];
	}
	vector <ll> dp(sum+1, INT_MAX); // 
	dp[0] = 0;

	for (int i = 0; i<n;i++) { // iterate kar rahe ha items me
		
		for (int j = sum - val[i] ; j >=0 ; j--) {
			 dp[j + val[i]] = min (dp[j + val[i]] , dp[j] + Wt[i]) ;
		} 

	}
	// outpos(dp[w]);LN;
	// Reverse chal 
	for (int i = sum; i>=0;i--) {
		// outpos(dp[i]);
		if (dp[i] <=w) { // iske corrsepondin
			outpos(i);break;
		}
	}


}

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

class Main{
   public static void main(String args[]){
     int[][] adj;
     int i,j,k=0,n,num,ans;
     Scanner scan = new Scanner(System.in);
     n = scan.nextInt();
     adj = new int[n*n][3];
     @SuppressWarnings("unchecked")
     List<Edge>[] edges = new List[n*n];

       for(i=0;i<n;i++){
         for(j=0;j<n;j++){
           num = scan.nextInt();
           if(num!=-1){
             adj[k][0] = i;
             adj[k][1] = j;
             adj[k][2] = num;
             k++;
           }
         }
       }

        for(i=0;i<k;i++) {
            edges[i] = new ArrayList<Edge>();
        }

        for(i=0;i<k;i++) {
            edges[adj[i][0]].add(new Edge(adj[i][0], adj[i][1], adj[i][2]));
            edges[adj[i][1]].add(new Edge(adj[i][1], adj[i][0], adj[i][2]));
        }
        ans = prim(n, edges);
        System.out.println(ans);
  }

    static int prim(int n, List<Edge>[] edges) {
        boolean[] done = new boolean[n];

        Queue<Edge> q = new PriorityQueue<Edge>();
        q.add(new Edge(0, 0, 0));

        int totalCost = 0;
        while (!q.isEmpty()) {
            Edge e = q.poll();
            if (done[e.target]) {
                continue;
            }

            done[e.target] = true;
            totalCost += e.cost;
            q.addAll(edges[e.target]);
        }

        return totalCost;
    }

  static class Edge implements Comparable<Edge> {
          public int source = 0;
          public int target = 0;
          public int cost = 0;

          public Edge(int source, int target, int cost) {
              this.source = source;
              this.target = target;
              this.cost = cost;
          }

          public int compareTo(Edge o) {
              return this.cost - o.cost;
          }
      }
}



Measured memory_bytes: 42508
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=1e9+7;
#define N 1055050

main(){
    int n=in();
    double m=380000.0;
    double ans=0.0;
    rep(i,n){
        double x;cin>>x;
        string s;cin>>s;
        if(s[0]=='J')ans+=x;
        else ans+=x*m;
    }
    printf("%.10f",ans);
    return 0;
}

Measured memory_bytes: 256
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))

from collections import Counter
cd = Counter(d)
ct = Counter(t)

for tt in ct.items():
    if tt[1] > cd[tt[0]]:
        print("NO")
        break
else:
    print("YES")

Measured memory_bytes: 127572
# -*- coding: utf-8 -*-
p = [0]*4

for _ in range(3):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    p[a] += 1
    p[b] += 1

odd = 0
even = 0
for x in p:
    if x%2==1:
        odd += 1
    else:
        even += 1

if even==4:
    print("YES")
elif odd==2:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3060
-- Try AtCoder
-- author: Leonardone @ NEETSDKASU
 
import qualified Data.Map as Map
import Data.List (find)
import Data.Array (listArray, (!))

main = putStrLn . solve =<< getLine

solve xs = ans where
    a = listArray (1, length xs) xs
    h = Map.singleton (a ! 1) 1
    mn k = k - 1
    g i j m =
        let
            l = j - i + 1
            mx = maximum $ Map.elems m
        in
            if l <= mx * 2 then
                (i, j, m)
            else
                let
                    x = Map.adjust mn (a ! i) m
                in
                    g (i + 1) j x
    f _ j _ | j > length xs = "-1 -1"
    f i j m =
        let
            x = Map.insertWith (+) (a ! j) 1 m
            mx = maximum $ Map.elems x
            l = j - i + 1
        in
            if l < mx * 2 then
                show i ++ " " ++ show j
            else
                let (ii, jj, xx) = g i j x
                in f ii (jj + 1) xx
    ans = f 1 2 h
    

Measured memory_bytes: 7164
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int p,q,r; cin >> p >> q >> r;
    vector<int> a(3);
    a[0] = p;
    a[1] = q;
    a[2] = r;
    sort(a.begin(),a.end());
    cout << a[0] + a[1] << endl;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 998244353;
set<string> ok;
void f(string S){
    if(ok.count(S) == 1) return;
    ok.insert(S);
    for(int i = 0; i + 1< S.size(); i++){
        if(S[i] == S[i + 1]) continue;
        char checker = 'a';
        while((S[i] == checker) || (S[i + 1] == checker)) checker++;
        string copy = S;
        //for(int j = 0; j < 3; j++) copy[j] = S[j];
        copy[i] = checker;
        copy[i + 1] = checker;
        f(copy);
    }
}
ll dp[210000][3][3][2];

int main() {
    //cout.precision(10);
    string S;
    cin >> S;
    bool checker = true;
    bool checker2 = false;
    int Hash = 0;
    for(int i = 0; i < S.size(); i++){
        Hash += (int)(S[i] - 'a');
        Hash = Hash % 3;
    }
    for(int i = 1; i < S.size(); i++){
        if(S[i - 1] != S[i]) checker = false;
        if(S[i - 1] == S[i]) checker2 = true;
    }
    if(checker){
        cout << 1 << endl;
        return 0;
    }
    if(S.size() == 3){
        f(S);
        cout << ok.size() << endl;
        return 0;
    }
    for(int i = 0; i < 3; i++){
        for(int k = 0; k <= 200500; k++){
            for(int l = 0; l < 3; l++){
               dp[k][i][l][0] = 0;
               dp[k][i][l][1] = 0;
            }
        }
        dp[1][i][i][0] = 1;
        dp[1][i][i][1] = 0;
    }
    for(int moji = 1; moji < S.size(); moji++){
        for(int last = 0; last < 3; last++){
            for(int next = 0; next < 3; next++){
                for(int hash = 0; hash < 3; hash++){
                    int check = (hash + next) % 3;
                    dp[moji + 1][check][next][1] = (dp[moji + 1][check][next][1] + dp[moji][hash][last][1]) % mod;
                    int index = 0;
                    if(last == next) index++;
                    dp[moji + 1][check][next][index] = (dp[moji + 1][check][next][index] + dp[moji][hash][last][0]) % mod;
                }
            }
        }
    }
    int n = S.size();
    /*for(int i = 0; i <= 2; i++){
        cout << dp[n][i][1] << " " << dp[n][i][0] << endl;
    }
    cout << endl;*/
    //ll sum = dp[S.size()][0][1] % mod;
    ll sum = 0;
    for(int i = 0; i < 3; i++){
        sum = (sum + dp[n][Hash][i][1]) % mod;
    }
    if(!checker2) sum = (sum + 1) % mod;
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 29188
from numba import njit


@njit
def solve(N):
    for b in range(1, 3500 + 1):
        for c in range(1, 3500 + 1):
            num = N * b * c
            den = 4 * b * c - N * b - N * c
            if den > 0 and num % den == 0:
                return num // den, b, c


N = int(input())
print(*solve(N))


Measured memory_bytes: 109520
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
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, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
  int n;
  ull ans=1;
  cin >> n;
  rep(i,1,n+1){
    ans *= i;
    ans %= 1000000007;
  }
  cout << ans << endl;
}


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

int main()
{
    int n;
    string s;
    cin >> n;
    cin >> s;

    int shift = n % 26;
    for (int i = 0; i < s.size(); i++)
    {
        for (int j = 0; j < shift; j++)
        {
            s[i]++;
            if (s[i] > 'Z') s[i] = 'A';
        }
    }

    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define PI 3.14159265
#define seive_len 1000001

typedef long long int lli;

bool seive[seive_len];
const int MOD = 1000000007;
lli primeSeive[seive_len];

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

lli lcm(lli a, lli b) {
  lli gcd_ = gcd(a, b);
  lli lcm_ = (a*b)/gcd_;
  return lcm_;
}

lli ncr(lli n, lli r) {
  lli res = 1;
  if(r > n-r)
    r = n-r;
  
  for(lli i=0;i<r;i++) {
    res *= (n-i);
    res /= (i+1);
  }
  return res;
}

lli ncrMODp(lli n, lli r) {
  if(r > n-r)
    r = n-r;
  lli prow[r+1];
  memset(prow, 0, sizeof(prow));
  prow[0] = 1;
  for(lli i=1;i<=n;i++) {
    for(lli j=min(i, r);j>0;j--) {
      prow[j] = (prow[j]+prow[j-1])%MOD;
    }
  }
  return prow[r];
}

lli fastPower(lli a, lli b) {
  lli res=1;
  while(b > 0) {
    if(b&1)
      res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}

lli fastPowerMODp(lli a, lli b) {
  a %= MOD;
  lli res = 1;
  while(b) {
    if(b%2 == 1)
      res = (res*a)%MOD;
    a = (a*a)%MOD;
    b >>= 1;
  }
  return res;
}

void multiply(lli a[][2], lli b[][2]) {
  lli res[2][2];
  memset(res, 0, sizeof(res));
  for(lli i=0;i<2;i++) {
    for(lli j=0;j<2;j++) {
      for(lli k=0;k<2;k++) {
        res[i][j] += a[i][k]*b[k][j]%MOD;
      }
    }
  }
  for(lli i=0;i<2;i++)
    for(lli j=0;j<2;j++)
      a[i][j] = res[i][j];
}

void matrixExpo(lli a[][2], lli n) {
  if(n == 0 || n == 1)
    return;
  lli b[][2] = {{1,1}, {1,0}};
  matrixExpo(a, n/2);
  multiply(a, a);
  if(n%2)
    multiply(a, b);
}

void makeSeive() {
  for(lli i=2;i*i<=seive_len;i++) {
    if(seive[i]) {
      for(lli j=i*i;j<=seive_len;j+=i)
        seive[j] = false;
    }
  }
}

void makePrimeSeive() {
  for(lli i=1;i<seive_len;i++)
    primeSeive[i] = i;
  for(lli i=4;i<seive_len;i+=2)
    primeSeive[i] = 2;
  for(lli i=3;i*i<seive_len;i++) {
    if(primeSeive[i] == i) {
      for(lli j=i*i;j<seive_len;j+=i) {
        if(primeSeive[j] == j)
          primeSeive[j] = i;
      }
    }
  }
}

bool isPrime(lli n) {
  for(lli i=2;i<=sqrt(n);i++) {
    if(n%i == 0)
      return false;
  }
  return true;
}

void getInput(vector<lli>& a, lli n) {
  lli x;
  for(lli i=0;i<n;i++) {
    cin >> x;
    a.push_back(x);
  }
}

void testCase() {
  lli i, a, n, count = 0, res = 1, prev = -1, sum = 0;
  cin >> n;
  for(i=1;i<n;i++) {
    a = n-i;
    res = 1;
    count = 0;
    if(a == 1) {
      sum++;
      continue;
    }
    prev = primeSeive[a];
    while(a != 1) {
      if(primeSeive[a] == prev)
        count++;
      else {
        prev = primeSeive[a];
        res *= (count+1);
        count = 1;
      }
      a /= primeSeive[a];
    }
    res *= (count+1);
    sum += res;
  }
  cout << sum;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
	lli t=1;
	// cin >> t;
  makePrimeSeive();
  // FILE* fp;
  // fp = fopen("out.txt", "w");
	for(lli i=1;i<=t;i++) {
    // fprintf(fp, "Case #%d:\n", i);
    // cout << "Case #" << i << ":" << ' ';
		testCase();
    cout << '\n';
	}
	return 0;
}

Measured memory_bytes: 11504
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []
eps = 1.0 / 10 ** 10; 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:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def s_list(): return list(input())
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def num__grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]#NumberGrid
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def grid(n): return [s_list() for _ in range(n)]

n = i()
h = wi()
h[0] -= 1

for i in range(1, n):
    if h[i - 1] < h[i]:
        h[i] -= 1

for i in range(1, n):
    if h[i - 1] > h[i]:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 17424
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int s,a[25],b[100],n,k,i; 
int main()
{

  int j,m,t,x,y;	 
cin>>a[0]>>a[1]>>a[2];
sort(a,a+3);
cout<<a[0]+a[1]<<endl;
 return 0;     
} 

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int q = sc.nextInt();
		int[][] field = new int[n + 1][n + 1];
		int[][] sums = new int[n + 1][n + 1];
		for (int i = 0; i < m; i++) {
			field[sc.nextInt()][sc.nextInt()]++;
		}
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				sums[i][j] = field[i][j] + sums[i - 1][j] + sums[i][j - 1] - sums[i - 1][j - 1];
			}
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < q; i++) {
			int pl = sc.nextInt();
			int pr = sc.nextInt();
			int ans = sums[pr][pr] - sums[pl - 1][pr] - sums[pr][pl - 1] + sums[pl - 1][pl - 1];
			sb.append(ans).append("\n");
		}
		System.out.print(sb);
	}
}


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

#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)

typedef long long ll;

int main(){
  int N, cnt = 0;
  cin >> N;
  vector<int> h(N);
  REP(i,N){
    cin >> h[i];
  }

  int mini = 1000;
  REP(i,N){
    mini = min(mini, h[i]);
  }

  cnt += mini;
  REP(i,N){
    h[i] -= mini;
  }

  bool update = true;
  while(update){
    update = false;
    bool flag = false;
    REP(i, N){
      if(h[i] != 0){
        h[i]--;
        update = true;
        flag = true;
      }
      else{
        if(flag){
          cnt++;
          flag = false;
        }
      }
    }
    if(flag)
      cnt++;
  }

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

Measured memory_bytes: 256