akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  cout<<(N+1)/2<<endl;
  }


Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
LL T,A,c,d;
int n;
int main() {
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) {
		if(i==1)
			scanf("%lld%lld",&T,&A);
		if(i!=1) {
			scanf("%lld%lld",&c,&d);
			LL a=(c-1+T)/c, b=(d-1+A)/d;
			//   printf("%lld %lld",a,b);
			LL temp=max(a,b);
			T=c*temp, A=d*temp;
			//   printf("::%lld %lld\n\n",T,A);
		}
	}
	printf("%lld",T+A);
}

Measured memory_bytes: 128
h, w  = map(int, input().split())
a = [input() for _ in range(h)]

memo = [[0] * w for _ in range(h)]

i = 0
j = 0
memo[i][j] = 1
while i < h-1 and j < w-1:
    if a[i+1][j] == "#" and a[i][j+1] == "#":
        print("Impossible")
        exit()
    elif a[i+1][j] == "#":
        i += 1
        memo[i][j] = 1
    elif a[i][j+1] == "#":
        j += 1
        memo[i][j] = 1
    else:
        print("Impossible")
        exit()

if i == h-1:
    while j < w-1:
        if a[i][j+1] == ".":
            print("Impossible")
            exit()
        j += 1
        memo[i][j] = 1
else:
    while i < h-1:
        if a[i+1][j] == ".":
            print("Impossible")
            exit()
        i += 1
        memo[i][j] = 1

for i in range(h):
    for j in range(w):
        if a[i][j] == "#" and memo[i][j] == 0:
            print("Impossible")
            exit()

print("Possible")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N,M;
  cin >> N >> M;
  vector<int> L(M);
  vector<int> R(M);
  for(int i=0; i<M; i++){
    cin >> L.at(i);
    cin >> R.at(i);
  }
  int max=0;
  int min=N;
  for(int i=0; i<M; i++){
    if(max<=L.at(i)){
      max=L.at(i);
    }
    if(min>=R.at(i)){
      min=R.at(i);
    }
  }
  if((min-max+1)<=0){
    cout << 0 << endl;
    return 0;
  }
  cout << min-max+1 << endl;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int r;cin>>r;
    cout<<r*r<<endl;
    return 0;
}


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

using namespace std;

int main() {
  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int smax = a.front() + k - a.back();
  for (int i = 0; i < n - 1; i++) {
    smax = max(smax, a[i + 1] - a[i]);
  }
  const int ans = k - smax;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>                                                             
                                                                                
int main(void) {                                                                
  int N, i;                                                                     
  std::cin >> N;                                                                
  std::cin >> i;                                                                
  std::cout << N - i + 1 << std::endl;                                          
  return 0;                                                                     
}       

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> roads(n);
  REP(i, m) {
    int a, b;
    cin >> a >> b;
    roads[a - 1]++;
    roads[b - 1]++;
  }
  REP(i, n) {
    cout << roads[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define sl(c) (('a')<=(c)&&(c)<=('z'))
#define ll(c) (('A')<=(c)&&(c)<=('Z'))
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define PI 3.141592653589793
#define cout (cout<<fixed<<setprecision(15))
#define makeupper(t) (transform(all(t),t.begin(),::toupper))
#define makelower(t) (transform(all(t),t.begin(),::tolower))
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define NEXT_LINE string junk; getline(cin, junk);
#define output(v) do{rep(i,v.size())cout<<(i?" ":"")<<v[i];cout<<"\n";}while(0)
#define output2(v) rep(i,v.size()){rep(j,v[i].size()){cout<<(j?" ":"")<<v[i][j];}cout<<"\n";}
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
vector<lint> operator+(const vector<lint>& v1,const vector<lint>& v2){
    vector<lint> v(v1.size()+v2.size(),0);
    rep(i,v1.size())v[i]=v1[i];
    rep(i,v2.size())v[i+v1.size()]=v2[i];
    return v;
}
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
inline lint max(vector<lint> num){
    lint M=num[0];
    rep(i,num.size())M=max(M,num[i]);
    return M;
}
inline lint min(vector<lint> num){
    lint M=num[0];
    rep(i,num.size())M=min(M,num[i]);
    return M;
}
int main(){
    input(b,n);
    vec ans;
    rep(j,b.size()){
        if(j+1==b[j])ans.push_back(b[j]);
        else if(j+1<b[j]){
            cout<<-1;
            return 0;
        }else{
            ans.insert(ans.begin()+b[j]-1,b[j]);
        }
    }
    rep(i,ans.size()){
        cout<<ans[i]<<"\n";
    }
}

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

int main(){
  int N;
  cin >> N;
  vector<tuple<string,int,int>> A(N);
  for(int i=0; i<N; i++){
    string s;
    int p;
    cin >> s >> p;
    A.at(i) = make_tuple(s,-p,i+1);
  }
  sort(A.begin(),A.end());
  for(int i=0; i<N; i++){
    cout << get<2>(A.at(i)) << endl;;
  }
  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
vector<string> split(string s, char p){vector<string>v;stringstream m(s);string b;while(getline(m,b,p))v.push_back(b);return v;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

int main(){
    ll N, K;
    cin >> N >> K;
    ll ans = 1;
    REP(i, N) {
        if (ans < K) ans *= 2;
        else ans += K;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 500
#define M 50
using namespace std;

int main(){
  int n,m;
  double sx[N],sy[N],sz[N],tx[M],ty[M],tz[M],r[M];
  bool ans[N];
  while(1){
    cin>>n;
    if(!n) break;
    for(int i=0;i<n;i++) cin>>sx[i]>>sy[i]>>sz[i],ans[i]=false;
    cin>>m;
    for(int i=0;i<m;i++) cin>>tx[i]>>ty[i]>>tz[i]>>r[i];
    for(int i=0;i<m;i++){
      for(int j=0;j<n;j++){
	double d1=sqrt(sx[j]*sx[j]+sy[j]*sy[j]+sz[j]*sz[j]);
	double X=sqrt(tx[i]*tx[i]+ty[i]*ty[i]+tz[i]*tz[i]);
	double t=(tx[i]*sx[j]+ty[i]*sy[j]+tz[i]*sz[j])/(X*d1);
	if(acos(t)<=r[i]) ans[j]=true;
      }
    }
    int cnt=0;
    for(int i=0;i<n;i++)
      if(ans[i]) cnt++;
    cout<<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 1312
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ld long double
const ld pi=3.1415926535897932384626433;


int main()
{
	int n;
	cin >> n;
	if(n==1)
	{
		cout << '1' << endl;
		cout << '0' << endl;
	}
	else if(n==2)
	{
		cout << '2' << endl;
		cout << '0' << endl;
		cout << "11" << endl;
	}
	else
	{
		cout << n-1 << endl;
		rep(i, n-1)
		{
			cout << '0';
			rep(j, i) cout << '1';
			cout << '0';
			cout << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3104
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(n)]
a = sorted(a,key=lambda x:x[0])
ans = 0
for i,j in a:
  if m > j:
    ans += i*j
    m -= j
  else:
    ans += i*m
    break
print(ans)

Measured memory_bytes: 29836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp(a, b) make_pair(a, b)
#define ls (rt << 1)
#define rs (rt << 1 | 1) 
typedef pair<int, int> pii; 
const ll mod = 1e9 + 7;
template <class T> T lowbit(T x){return ((x)&(-(x)));}
const int maxn = 1e3 + 10;
int n, m, k, ans = 1e9;
char a[15][maxn];
int c[15], pos[15];
void solve(int s)
{
	memset(c, 0, sizeof c);
	int tot = 0, ret = 0;
	for(int j = 0; j < n; ++j)
	{
		pos[j] = tot;
		if(s & (1 << j))
			++tot;
	}
	for(int i = 1; i <= m; ++i)
	{
		for(int j = 0; j < n; ++j)
			c[pos[j]] += (a[j][i] - '0');
		bool flag = 0;
		for(int j = 0; j <= tot; ++j)
			if(c[j] > k)
				flag = 1;
		if(flag)
		{
			++ret;
			memset(c, 0, sizeof c);
			for(int j = 0; j < n; ++j)
				c[pos[j]] += (a[j][i] - '0');
			for(int j = 0; j <= tot; ++j)
				if(c[j] > k)
					return;
		}
	}
	ret += tot;
	ans = min(ans, ret);
}
int main()
{
	scanf("%d%d%d", &n, &m, &k);
	for(int i = 0; i < n; ++i) 
		scanf("%s", a[i] + 1);
	int s = 1 << (n - 1);
	for(int i = 0; i < s; ++i)
		solve(i);
	printf("%d\n", ans);
	return 0;
}

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

namespace program{
  class Program{
    static void Main(){
      int[] input = Input.ScanIntArray();
      int H = input[0];
      int W = input[1];
      int[,] Mat = new int[H,W];
      
      string row = Input.ScanStr();
      for(int k=0;k<W;k++)
      {
        if(row[k]=='.') 
          Mat[0,k] = 1;
        else 
          break;
      }
      
      for(int i=1;i<H;i++){
        row = Input.ScanStr();
        if(row[0]=='.') Mat[i,0] = Mat[i-1,0];
        for(int k=1;k<W;k++)
        {
          if(row[k]=='.') Mat[i,k] = (Mat[i-1,k] + Mat[i,k-1]) % 1000000007;
        }
      }
      
      Console.WriteLine($"{Mat[H-1,W-1]}");
    }
  }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }
}


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

int main(){
  int N;
  cin >> N;
  vector<char> S(N),T(N),A(N+N);
  int i;
  for(i=0;i<N;i++){
    cin >> S.at(i);
  }
  
  for(i=0;i<N;i++){
    cin >> T.at(i);
  }
    
  for(i=0;i<N;i++){
    A.at(2*i)=S.at(i);
    A.at(2*i+1)=T.at(i);
  }
  
  for(i=0;i<2*N;i++){
    cout << A.at(i);
  }
  cout << endl;
}

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

#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll a,b,c,d; cin >> a >> b >> c >> d;
    ll ans1 = b*1LL*d;
    ll ans2 = b*1LL*c;
    ll ans3 = a*1LL*d;
    ll ans4 = a*1LL*c;
    ll ans = max(max(ans1, ans2), max(ans3, ans4));
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3644
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int n = str.length();
        char c[] = str.toCharArray();
        
        long answer = 0;
        int count = 0;
        char now = '<';
        int left = 0;
        int right = 0;
        
        for (int i = 0; i < n; i++) {
            if (now == '<') {
                if (c[i] == '<') {
                    left++;
                } else {
                    now = '>';
                    right = 1;
                }
            } else {
                if (c[i] == '<') {
                    if (left > right) {
                        right--;
                    } else {
                        left--;
                    }
                    
                    while (left > 0) {
                        answer += left;
                        left--;
                    }
                    while (right > 0) {
                        answer += right;
                        right--;
                    }
                    now = '<';
                    left = 1;
                } else {
                    right++;
                }
            }
        }
        
        
        
        if (left > right) {
            right--;
        } else {
            left--;
        }
        
        while (left > 0) {
            answer += left;
            left--;
        }
        while (right > 0) {
            answer += right;
            right--;
        }
        
        System.out.println(answer);
    }
}


Measured memory_bytes: 28704
function main(){
  var i = 0;
  while(true){
    var fieldInfo = input[i].split(' ');
    var width = fieldInfo[0] - 0;//toInt
    var height = fieldInfo[1] - 0;//toInt

    // 0 0が入力された
    if(!width && !height){
      break;
    }

    var start;
    var goal;
    var elem = [[],[],[],[],[]];
    for(var ei = 0;ei < 5; ei++){
      elem[ei].length = 0;
    }
    
    for(var y = 0; y < height; y++){
      i++;//1行進める
      for(var x = 0; x < width; x++){
        var c = input[i][x];

        switch(c){
        case 'S':
          start = new Pos(x, y);
          break;
        case 'G':
          goal = new Pos(x, y);
          break;
        case '.':
          break;
        default : // 入力値が正しいので、絶対に属性
          elem[c-1][elem[c-1].length] = new Pos(x, y);
          break;
        }
      }
    }

    
    var bestElement = -1;
    var distance = Infinity;
    
    // 属性ごとにループ
    for (var startElem = 0; startElem < 5; startElem++) {
      // DPの初期化 DP[属性][同じ属性内の連番]
      var dp = [[],[],[],[],[]];
      for(var h = 0; h < 5; h++){
        var hLength = elem[h].length;
        dp[h].length = hLength;
        for(var hidx = 0; hidx < hLength; hidx++){
          dp[h][hidx] = Infinity;
        }
      }
      
      // 最初に選んだパチモンから次に捕まえられる属性番号
      var first = (startElem + 1) % 5;

      var firstLength = elem[first].length;
      for (var j = 0; j < firstLength; j++) {
        // s→e1を計算
        dp[first][j] = dist(start, elem[first][j]);
      }
      
      // s->1->2->3->4->g
      // なので、ループは間の-> * 3分まわす
      for (var e = 0; e < 3; e++) {
        // ex->e(x+1)
        var now = (first + e) % 5;
        var next = (now + 1) % 5;
        var nowLength = elem[now].length;
        var nextLength = elem[next].length;
        for (var j = 0; j < nowLength; j++) {
          for (var k = 0; k < nextLength; k++) {
            dp[next][k] = min(
              dp[next][k],
              dp[now][j] + 
                  dist(elem[now][j], elem[next][k]));
          }
        }
      }
      
      var last = (first + 3) % 5;
      var lastLength = elem[last].length;
      for (var j = 0; j < lastLength; j++) {
        // e4->g
        var d = dp[last][j] + 
                    dist(elem[last][j], goal);
        
        if (d < distance) {
          distance = d;
          bestElement = startElem + 1;
        }
        
      }
      
    }
    
    if (distance == Infinity) {
      console.log("NA");
    } else {
      console.log(bestElement + " " + distance);
    }

    i++;
  }
  

}

function dist(from, to){
  return Math.abs(from.x - to.x) + Math.abs(from.y - to.y)
}

function min(a1, a2){
  return a1 < a2 ? a1 : a2;
}

function Pos(a, b){
  this.x = a;
  this.y = b;
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 63488
N = int(input())
a = [0]+list(map(int, input().split()))
b = [0 for _ in range(N+1)]

for i in reversed(range(1, N+1)):
    tmp = 0
    for j in range(i, N+1, i):
        tmp += b[j]
            
    if(tmp%2 == a[i]):
        b[i] = 0
    else:
        b[i] = 1


ans = []
for i, j in enumerate(b):
    if(j == 1):
        ans.append(i)
print(len(ans))
if(len(ans)):
    print(*ans)

Measured memory_bytes: 17780
#include <bits/stdc++.h>
#define int long long
#define debug(x) cerr << "\n" \
                      << #x << ": " << x << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define INF (1LL << 30)
#define pii pair<int, int>
#define MOD 1000000007
#define print(x) cout<<(x)<<endl
using namespace std;


signed main()
{
    int N,M;
    cin>>N>>M;
    vector<pii> c(M);
    int l,r;
    rep(i,M){cin>>l>>r;--l;--r;c[i]=make_pair(l,r);}

    vector<int> lis(M);
    int mxl=-INF;int mnr=INF;
    for (auto x: c){
       mxl = max(mxl,x.first);
       mnr = min(mnr,x.second);
    }

    int ans = 0;
    if (mnr < mxl) ans = 0;
    else ans =(mnr-mxl+1);
    print(ans);

    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	LL Q,H,S,D,N;
	cin >> Q >> H >> S >> D >> N;
	LL ans = 0;
	if(S*2 > D && H*4 > D && Q*8 > D){
		ans += N/2 * D;
		N -= (N/2) * 2;
	}
	if(H*2 > S && Q*4 > S){
		ans += N * S;
		N = 0;
	}
	if(Q*2 > H){
		ans += N * 2 * H;
		N = 0;
	}
	ans += N * 4 * Q;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
def main():
    N, K = (int(i) for i in input().split())
    R, S, P = (int(i) for i in input().split())
    T = input()
    dp = [[0 for _ in range(N+1)] for _ in range(3)]
    pre = []
    for i, t in enumerate(T):
        if t == "r":
            dp[0][i+1] = max(dp[0][i], dp[1][i], dp[2][i])
            dp[1][i+1] = max(dp[0][i], dp[1][i], dp[2][i])
            dp[2][i+1] = max(dp[0][i], dp[1][i], dp[2][i]) + P
        elif t == "s":
            dp[0][i+1] = max(dp[0][i], dp[1][i], dp[2][i]) + R
            dp[1][i+1] = max(dp[0][i], dp[1][i], dp[2][i])
            dp[2][i+1] = max(dp[0][i], dp[1][i], dp[2][i])
        elif t == "p":
            dp[0][i+1] = max(dp[0][i], dp[1][i], dp[2][i])
            dp[1][i+1] = max(dp[0][i], dp[1][i], dp[2][i]) + S
            dp[2][i+1] = max(dp[0][i], dp[1][i], dp[2][i])

        if dp[0][i+1] == max(dp[0][i+1], dp[1][i+1], dp[2][i+1]):
            pre.append(0)
        elif dp[1][i+1] == max(dp[0][i+1], dp[1][i+1], dp[2][i+1]):
            pre.append(1)
        else:
            pre.append(2)

        if K <= i:
            if pre[-(K+1)] == pre[-1]:
                dp[pre[-1]][i+1] = 0
                pre[-1] = -1
    print(max(dp[0][N], dp[1][N], dp[2][N]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 59632
using System;

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            var array = Converter(Console.ReadLine());
            Console.WriteLine(Calc(array));
            Console.ReadLine();
        }

        static int[] Converter(string str)
        {
            var array = str.Split(' ');
            return Array.ConvertAll(array, int.Parse);
        }

        static string Calc(int[] array)
        {
            int W = array[0]; int H = array[1]; int x = array[2]; int y = array[3]; int r = array[4];
            return (x - r) < 0 || (x + r) > W || (y - r) < 0 || (y + r) > H ? "No" : "Yes";
        }
    }
}



Measured memory_bytes: 9000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

// 互除法で2正数x,yのgcdを返す関数
ll gcd (ll x, ll y) {
    ll p = x % y;
    while(p){
        x = y;
        y = p;
        p = x % y;
    }
    return y;
}

int main() {
    int Q;
    cin >> Q;
    vector<int>ans(Q);
    for (int i = 0; i < Q; ++i) {
        ll A, B, C, D;
        cin >> A >> B >> C >> D;
        if(A < B || B > D) {
            ans[i] = 0;
            continue;
        }
        if(C >= B){
            ans[i] = 1;
            continue;
        }
        if(A > C) {
            A = A - B * ((A - (C + 1)) / B);
        } else{
            A += D;
            if(D != B) A = A + (D - B) * ((C - A) / (D - B) + 1);
        }
        ll gcd_B_D = gcd(B, D);
        A = A - gcd_B_D * ((A - (C + 1)) / gcd_B_D);
        if(A >= B){
            ans[i] = 1;
        } else{
            ans[i] = 0;
        }
    }
    for (int i = 0; i < Q; ++i) {
        if(ans[i]){
            cout << "Yes" << "\n";
        } else{
            cout << "No" << "\n";
        }
    }
    return 0;
}

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

int main(){
  int n;
  cin >> n; 
  
  int count = 0;
  int* h = new int[n];
  
  for(int i = 0; i < n; i++){
    int tmp;
    cin >> tmp;
    h[i] = tmp;
    bool b = true;
    for(int j=0;j<i;j++){
      b = b && h[i] >= h[j] ;
    }
    if(b || i == 0)count++;
  }
  
  
  cout << count;
  return 0;
}




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

using namespace std;

int main() {
    char b;
    cin >> b;

    vector<pair<char, char> > bases = {
                                    make_pair('A', 'T'), 
                                    make_pair('C', 'G'), 
                                    make_pair('G', 'C'), 
                                    make_pair('T', 'A')
                            };
    for (int i = 0; i < 4; i++) {
        if (b == bases[i].first) {
            cout << bases[i].second << endl;
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define NFOR(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); --i)
#define rep(i, a) for (ll i = 0; i < a; i++)
#define endl "\n"
#define fi first
#define se second
#define MOD 1000000007
#define inf 1e12
#define pb push_back
#define Case cout<<"Case #"<<++cas<<": ";
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) v.begin(),v.end()

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;

#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}

void solve() {
	int n;
	cin >> n;
	vvl a(n, vl(3));
	rep(i, n) cin >> a[i][0] >> a[i][1] >> a[i][2];

	vvl dp(n, vl(3, 0));
	rep(i, 3) dp[0][i] = a[0][i]; 

	FOR(i, 1, n - 1)
		rep(j, 3)
			rep(k, 3)
				if (k != j)
					dp[i][j] = max(dp[i][j], dp[i-1][k] + a[i][j]);

	cout << *max_element(dp[n-1].begin(), dp[n-1].end()) << endl;
}

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


Measured memory_bytes: 11264
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		int a,b;

	    try (Scanner sc = new Scanner(System.in)) {
	    	a = sc.nextInt();
	    	b = sc.nextInt();
	    }

	    if(a<b) {
	    	System.out.println("a < b");
	    }
	    else if(a==b) {
	    	System.out.println("a == b");
	    }
	    else {
	    	System.out.println("a > b");
	    }
	}

}



Measured memory_bytes: 26176
#include <stdio.h>
 
int sum,point;
 
void rec(int ,int, int ans[]);
int ruijou(int );
 
 
int ruijou(int a){
  int i, sum=1;
 
  for(i=0;i<a;i++){
    sum*=2;
  }
  return sum;
}
 
 
void rec(int p, int n, int ans[]){
   
  if( ruijou(p) > n ){
    return;
  }
  if(point==1) return ;
   
 
  ans[p]=1;
  sum+= ruijou(p);
  if(sum>n){
    ans[p]=0;
    sum-=ruijou(p);
    return;
  }
  rec(p+1,n,ans);
  if(sum == n){
    point=1;
    return;
  }
  ans[p]=0;
  sum-=ruijou(p);
  rec(p+1,n,ans);
}
 
 
main(){
  int n;
  int i,max;
  int ans[10];
 
  while(1){
    sum=0;
    point=0;
    if(scanf("%d", &n)==EOF) break;
 
    for(i=0;i<10;i++){
      ans[i]=0;
    }
 
    rec(0,n,ans);
 
    max=-1;
    for(i=0;i<10;i++){
      if(ans[i]==1){
    if(max<i){
      max=i;
    }
      }
    }
 
    for(i=0;i<10;i++){
      if(ans[i]==1 && i!=max){
    printf("%d ", ruijou(i));
      }
      else if(ans[i]==1 && max==i){
    printf("%d\n", ruijou(i));
      }
    }
  }
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
  string s; cin >>s;
  if(s[0]=='R'&&s[1]=='R'){
    if(s[2]=='R') cout <<3;
    else cout <<2;
  }
  else if(s[0]=='R') cout <<1;
  else if(s[1]=='R'&&s[2]=='R') cout <<2;
  else if(s[1]=='R'||s[2]=='R') cout <<1;
  else cout <<0;
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  solve();
return 0;}

Measured memory_bytes: 3644
#include <stdio.h>

int main(void) {
  int n, max = 0, i, j, k;
  scanf("%d", &n);
  int a[2][n];
  for(i = 0; i < 2; ++i) for(j = 0; j < n; ++j) scanf("%d", &a[i][j]);
  for(i = 0; i <= n; ++i) {
    int temp = 0;
    for(j = 0; j < n; ++j) {
      if(j < i) {
        temp += a[0][j];
      } else if(j == i) {
        temp += a[0][j] + a[1][j];
      } else {
        temp += a[1][j];
      }
    }
    if(max < temp) max = temp;
  }
  printf("%d", max);
  return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



long long n, m, v, p;
long long a[100000];


bool f(int idx) {
	if (idx < p)return true;
	if (a[p - 1] - a[idx] > m)return false;
	long long cnt = p * m;

	for (int i = p - 1; i < n; i++) {
		if (i == idx)continue;
		cnt += min(a[idx] + m - a[i], m );
	}
	return cnt >= m * v;
}


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

	cin >> n >> m >> v >> p;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	reverse(a, a + n);

	int lb = 0, ub = n;
	while (ub-lb > 1) {
		int mid = (lb + ub) / 2;
		if (f(mid))lb = mid;
		else ub = mid;
	}

	cout << lb + 1 << endl;



	return 0;
}

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

using namespace std;
int main()
{
	int N, sum = 0;
	cin >> N;
	vector<int> L(N);
	for (int i = 0; i < N; i++) {
		cin >> L[i];
		sum += L[i];
	}
	for (int i = 0; i < N; i++) {
		if (sum <= L[i] * 2) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
s=input()
li=[]
seq=1
for i in range(1,len(s)):
    if s[i-1]==s[i]:
        seq+=1
    else:
        li.append(seq)
        seq=1
        
li.append(seq)
length=len(li)
ans=sum(li)-length

for i in range(k):
    if length>=3:
        length+=-2
        ans+=2
    elif length==2:
        ans+=1
        length+=-1
    else:
        break


print(ans)


Measured memory_bytes: 3956
# -*- coding: utf-8 -*-
import sys
from operator import itemgetter
from fractions import gcd
from math import ceil, floor, sqrt
from copy import deepcopy
from collections import Counter, deque, defaultdict
import heapq
from functools import reduce
sys.setrecursionlimit(200000)
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
def debug(*args, sep=" ", end="\n"): print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg): print(*arg); sys.exit()
# template

def divisor(n):
    ret = list()
    for i in range(1, int(sqrt(n)) + 1):
        if n % i == 0:
            ret.append(i)
            # ret.append(n // i) if i * i != n else None
    return sorted(ret)


def main():
    S = ii()
    X1, Y1 = 0, 0
    if (S <= 10 ** 9):
        print(0, 0, S, 0, 0, 1)
        sys.exit()
    for i in range(floor(sqrt(S)) - 3, floor(sqrt(S)) + 100):
        if i * i >= S:
            n = i
            break
    print(0, 0, n, 1, n ** 2 - S, n)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5164
#include<iostream>
#include<algorithm>
using namespace std;
int b[1010][1010], w[1010][1010];
int main() {
	int n, k; cin >> n >> k;
	for (int i = 0; i < n; i++) {
		long long x, y; char c; cin >> x >> y >> c;
		x %= 2 * k; y %= 2 * k;
		if (x >= k) {
			x -= k;
			if (c == 'B')c = 'W';
			else c = 'B';
		}
		if (y >= k) {
			y -= k;
			if (c == 'B')c = 'W';
			else c = 'B';
		}
		if (c == 'B')b[x][y]++;
		else w[x][y]++;
	}
	for (int i = 0; i < k; i++) {
		for (int j = 0; j < k; j++) {
			if (i == 0 && j == 0);
			else if (i == 0)b[i][j] += b[i][j - 1];
			else if (j == 0)b[i][j] += b[i - 1][j];
			else b[i][j] += b[i - 1][j] + b[i][j - 1] - b[i - 1][j - 1];
		}
	}
	for (int i = 0; i < k; i++) {
		for (int j = 0; j < k; j++) {
			if (i == 0 && j == 0);
			else if (i == 0)w[i][j] += w[i][j - 1];
			else if (j == 0)w[i][j] += w[i - 1][j];
			else w[i][j] += w[i - 1][j] + w[i][j - 1] - w[i - 1][j - 1];
		}
	}
	int ans = 0;
	for (int i = 0; i < k; i++) {
		for (int j = 0; j < k; j++) {
			if (i == 0 && j == 0)ans = max(b[k - 1][k - 1], w[k - 1][k - 1]);
			else if (i == 0)ans = max(ans, max(b[k - 1][k - 1] - b[k - 1][j - 1] + w[k - 1][j - 1], w[k - 1][k - 1] - w[k - 1][j - 1] + b[k - 1][j - 1]));
			else if (j == 0)ans = max(ans, max(b[k - 1][k - 1] - b[i - 1][k - 1] + w[i - 1][k - 1], w[k - 1][k - 1] - w[i - 1][k - 1] + b[i - 1][k - 1]));
			else ans = max(ans, max(b[k - 1][k - 1] - b[i - 1][k - 1] - b[k - 1][j - 1] + 2 * b[i - 1][j - 1] + w[i - 1][k - 1] + w[k - 1][j - 1] - 2 * w[i - 1][j - 1], w[k - 1][k - 1] - w[i - 1][k - 1] - w[k - 1][j - 1] + 2 * w[i - 1][j - 1] + b[i - 1][k - 1] + b[k - 1][j - 1] - 2 * b[i - 1][j - 1]));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8192
pow a b
	| b == 0 = 1
    | otherwise = a * pow a (b-1)
main = do
	[a,b,c,k] <- map read . words <$> getLine
	if abs (a-b) > pow 10 18 then putStrLn "Unfair" else if mod k 2 == 0 then print (a-b) else print (b-a)

Measured memory_bytes: 508
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
int dp[101][76];
void solve() {
	int N; cin >> N;
	map<int, int> divide_prime;
	for (int i = 2; i <= N; ++i) {
		int n = i;
		for (int j = 2; j <= n; ++j) {
			while (n % j == 0) {
				divide_prime[j]++;
				n /= j;
			}
		}
	}
	vector<int> nums;
	for (auto z : divide_prime) nums.push_back(z.second);
	int lens = nums.size();
	vector<int> num_75 = {1, 3, 5, 15, 25, 75};
	dp[0][1] = 1;
	for (int i = 0; i < lens; ++i) {
		for (auto d1 : num_75) {
			for (auto d2 : num_75) {
				if (d1 * d2 <= 75 && nums[i]+1 >= d2) {
					dp[i + 1][d1 * d2] += dp[i][d1];
				}
			}
		}
	}
	cout << dp[lens][75] << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
int main(){
  int n, l[2000];
  std::cin >> n;
  for(int i = 0; i < n; i++) std::cin >> l[i];

  std::sort(l, l+n, std::greater<int>());

  int ret = 0;
  for(int i = 0; i < n-2; i++){
    if(l[i] < l[i+1]+l[i+2]){
      for(int j = i+1; j < n-1; j++){
        for(int k = j+1; k < n; k++){
          if(l[i] < l[j]+l[k] && l[j] < l[i]+l[k] && l[k] < l[i]+l[j]){
            ret++;
          }
        }
      }
    }
  }

  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(){
    int x,y;
    int b,p;
    int ans=0;
    int calc;
    if(scanf("%d",&x)==1);

    y=(int)sqrt((double)x);

    for(b=1;b<=y;b++){
        for(p=2;p<10;p++){
            calc=(int)pow((double)b,(double)p);
            if(x<calc)break;
            if(ans<calc)ans=calc;
        }
    }
    printf("%d\n",ans);
} 

Measured memory_bytes: 128
main :: IO ()
main = do
  [a,b,c,x,y] <- map read.words <$> getLine :: IO [Integer]
  let f cnt minPrice = min minPrice $ cnt*c*2 + a*max 0 (x-cnt) + b*max 0 (y-cnt)
  print $ foldr f (a*x+b*y) [0..max x y]


Measured memory_bytes: 7164
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func strSprit(str string) []string {
	cols := strings.Split(str, " ")
	return cols
}

func parseInt(str string) int {
	n, _ := strconv.Atoi(str)
	return n
}

func intSprit(str string) []int {
	strs := strSprit(str)
	cols := make([]int, len(strs))
	for i, v := range strs {
		cols[i] = parseInt(v)
	}
	return cols
}

func bitCount(n uint) int {

	x := uint64(n)

	const m = 1<<64 - 1
	const m0 = 0x5555555555555555
	const m1 = 0x3333333333333333
	const m2 = 0x0f0f0f0f0f0f0f0f

	x = x>>1&(m0&m) + x&(m0&m)
	x = x>>2&(m1&m) + x&(m1&m)
	x = (x>>4 + x) & (m2 & m)
	x += x >> 8
	x += x >> 16
	x += x >> 32

	return int(x) & (1<<7 - 1)
}

func bitExist(n, i int) bool {
	return ((n >> uint(i)) & 1) == 1
}

func setBit(d, n int) int {
	t := 1 << uint(n)
	return d | t
}

func intAbs(n int) int {
	return int(math.Abs(float64(n)))
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////
type Pair struct {
	A, B int64
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}
func (p Pairs) Less(i, j int) bool {
	if p[i].A == p[j].A {
		return p[i].B < p[j].B
	} else {
		return p[i].A < p[j].A
	}
}

func main() {
	line := nextLine()
	spl := intSprit(line)

	N := spl[0]
	M := int64(spl[1])

	p := make([]Pair, N)

	for i := 0; i < N; i++ {
		s := intSprit(nextLine())
		p[i].A = int64(s[0])
		p[i].B = int64(s[1])
	}

	sort.Sort(Pairs(p))

	m := int64(0)
	res := int64(0)
	for i := 0; i < N; i++ {
		if m+p[i].B > M {
			res += (M - m) * p[i].A
			break
		} else if m+p[i].B == M {
			res += p[i].B * p[i].A
			break
		} else {
			m += p[i].B
			res += p[i].A * p[i].B
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    double R1,R2;
  	cin >> R1 >> R2;
    cout << fixed << setprecision(10);
    cout << 1/(1/R1+1/R2) << endl;
}


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

#define ul unsigned long int
#define ull unsigned long long
#define li long long int

int main()
{
  int r, c;
  cin >> r >> c;
  int m[101][101];
  fill(m[0], m[0] + 101 * 101, 0);
  long int sum = 0;

  for (int i = 0; i < r; i++)
  {
    for (int j = 0; j < c; j++)
    {
      cin >> m[i][j];
      m[i][c] += m[i][j];
      m[r][j] += m[i][j];
    }
    sum += m[i][c];
  }
  m[r][c] = sum;

  for (int i = 0; i <= r; i++)
  {
    for (int j = 0; j < c; j++)
    {
      cout << m[i][j]<<" ";
    }
    cout << m[i][c]<<endl;
  }

  return 0;
}



Measured memory_bytes: 3132
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
import copy
import numpy as np
import sys
INF = float('inf')
mod = 10**9+7


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


def main():
    s = list(S())
    t = list(S())
    lst = []
    ans = []
    for i in range(len(s) - len(t)+1):
        lst.append(s[i: i + len(t)])
    for l in lst:
        cnt = 0
        for i in range(len(t)):
            if l[i] == t[i]:
                cnt += 1
            ans.append(len(t) - cnt)
    print(min(ans))


if __name__ == "__main__":
    main()


Measured memory_bytes: 34512
a= int(input())
result = 0
for i in range(10):
    if a >= 10 ** (i-1) and a < 10 ** i :
        rank = i 
        break

for i in range(rank+1):
    
    if i == 1 and rank is not i:
        result += 10 ** i -1
    elif i == 3 and rank is not i:
        result += 10 ** i  - 10** (i-1)
    elif i == 5 and rank is not i:
        result += 10 ** i  - 10** (i-1)
    elif i == rank and i %2 is not 0:
        result += a - 10 ** (i-1) + 1
    
        
        
print(result)

Measured memory_bytes: 3064
#include<iostream>

using namespace std;
int main(){
	int a,b;
	cin >>a;
	cin >>b;
	if(a==b){
		cout<<"a == b"<<endl;
	}else if(a<b){
		cout << "a < b"<<endl;
	}else{
		cout <<"a > b"<<endl;
	}
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    scanf("%d", &i);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    scanf("%lld", &i);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

constexpr char BR = '\n';


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

int main()
{
    int a;
    io >> a;
    int ans = a + a*a + a*a*a;
    io << ans << BR;
}

Measured memory_bytes: 3828
inputs = readlines

n = inputs[0].to_i
h = inputs[1].split.map!(&:to_i)

max = h[0]
count = 1

for i in 2..n do
    if max < h[i-1]
        max = h[i-1] 
        count += 1
    elsif max == h[i-1]
        count += 1
    end
end

p count

Measured memory_bytes: 1788
n = int(input())
mod = 10 ** 9 + 7
dp = [{} for i in range(n + 1)]

def check(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i - 1], t[i] = t[i], t[i - 1]
        if ''.join(t).count('AGC') >= 1:
            return 0
    return 1

for c1 in 'ACGT':
    for c2 in 'ACGT':
        for c3 in 'ACGT':
            if not c1 + c2 + c3 in {'AGC', 'GAC', 'ACG'}:
                dp[3][c1 + c2 + c3] = 1
for i in range(n - 3):
    for last3 in dp[3 + i]:
        for c in 'ACGT':
            if check(last3 + c):
                if last3[1:] + c in dp[4 + i]:
                    dp[4 + i][last3[1:] + c] += dp[3 + i][last3]
                else:
                    dp[4 + i][last3[1:] + c] = dp[3 + i][last3]
    for key, value in dp[4 + i].items():
        dp[4 + i][key] = value % mod
print(sum(dp[n].values()) % mod)

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

int main() {
  int n;cin>>n;
  
  cout<<3*n*n;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		//In
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		//Process Out
		if(a>9 || b>9) {
			System.out.println(-1);
		}else {
			System.out.println(a*b);
		}
		
	}

}


Measured memory_bytes: 23380