akhauriyash/Code-Regression huggingface dataset:
#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();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

VVI ans;

void dfs(int l, int r, int lev){
    if(r-l < 2) return;

    int mid = (r+l)/2, n1 = mid-l, n2 = r-mid;
    VI g1(n1); REP(i,n1) g1[i] = l+i;
    VI g2(n2); REP(i,n2) g2[i] = mid+i;

    REP(i,n1)REP(j,n2) ans[g1[i]][g2[j]] = ans[g2[j]][g1[i]] = lev;

    dfs(l,mid,lev+1); dfs(mid,r,lev+1);
    return;
}

void Main(){
    int N; cin >> N; ans.resize(N,VI(N));

    dfs(0,N,1);

    REP(i,N-1){
        FOR(j,i+1,N) cout << ans[i][j] << " ";
        cout << en;
    }
    return;
}

int main(void){
    cin.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t){
        Main();
    }
    return 0;
}

Measured memory_bytes: 1536
N=int(input())
comp=[0 for i in range(N+1)]

for n in range(1,N+1):
    for i in range(2,N+1):
        while n%i==0:
            comp[i]+=1
            n//=i
        if n==1:
            break
MOD=10**9+7
res=1
for c in comp:
    res*=c+1
    res%=MOD
print(res)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include<string>
#include<vector>
#include<stdlib.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;
int N;
bool check(int p[]){
    for(int i=0;i<N-1;i++){
        if(p[i]<=p[i+1]){
            continue;
        }else{
            return false;
        }
    }
    return true;
}
int main(void){
  int i,j;
  cin >> N;
  int A[N+2];
  int tmp;
  for(i=0;i<N+1;i++){
      cin >> A[i+1];
  }
  int B[N+1];
  rep(i,N){
      cin >> B[i+1];
  }
  ll sum = 0;
  for(i=N;i>=1;i--){
      tmp = min(A[i+1],B[i]);
    B[i] -=tmp;
    sum +=tmp;
    //cout << tmp << endl;

    tmp =min(A[i],B[i]);
    //cout << tmp << endl;
    sum += tmp;
    A[i] -=tmp;
  }
  cout << sum;
    return 0;
}


Measured memory_bytes: 1024
inf = float('inf')

from math import floor
# 約数全列挙(ソート済み)
# n = 24 -> [1,2,3,4,6,8,12,24]
def divisor(n):
    left = [1]
    right = [n]
    sup = floor(pow(n,1/2))
    for p in range(2,sup+1):
        if n % p == 0:
            if p == n//p:
                left.append(p)
                continue
            left.append(p)
            right.append(n//p)
    res = left + right[::-1]
    return res

def accmulate(array):
    global cs
    cs = [0]*(len(array)+1)
    for i in range(len(array)):
        cs[i+1] = cs[i] + array[i]

def query(l,r):
    return cs[r] - cs[l]

N,K = map(int,input().split())
A = list(map(int,input().split()))
sA = sorted(A)

S = sum(A)
for d in divisor(S)[::-1]:
    nA = sorted([a % d for a in A])
    accmulate(nA)
    cnt = inf
    for i in range(N+1):
        minus = -query(0,i)
        plus = d*(N-i) - query(i,N)
        if minus + plus == 0:
            cnt = min(cnt, plus)
    if cnt <= K:
        print(d)
        exit()

Measured memory_bytes: 3188
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

printList [a] = print a
printList (a:as) = putStr ( show a ) >> putChar ' ' >> printList as

main = readInt >>= putStrLn . which "Yes" "No" . ( 30 <= )

Measured memory_bytes: 3848
n = int(input())
s = input()
rui = [[0] * (n) for i in range(3)]

if s[0] == "R":
    rui[0][0] = 1
elif s[0] == "G":
    rui[1][0] = 1
else:
    rui[2][0] = 1

for i in range(n-1):
    for j in range(3):
        rui[j][i+1] = rui[j][i]
    
    if s[i+1] == "R":
        rui[0][i+1] += 1
    elif s[i+1] == "G":
        rui[1][i+1] += 1
    else:
        rui[2][i+1] += 1

mi = 0
an = 0
for i in range(1,n-1):
    if s[i] == "R":
        x = min(i,n-1-i)
        for j in range(1,x+1):
            if (s[i+j] == "G" and s[i-j] == "B") or (s[i+j] == "B" and s[i-j] == "G"):
                mi += 1
        an += (rui[1][i-1] * (rui[2][n-1] - rui[2][i]))
        an += (rui[2][i-1] * (rui[1][n-1] - rui[1][i]))
                
    elif s[i] == "G":
        x = min(i,n-1-i)
        for j in range(1,x+1):
            if (s[i+j] == "R" and s[i-j] == "B") or (s[i+j] == "B" and s[i-j] == "R"):
                mi += 1
        an += (rui[0][i-1] * (rui[2][n-1] - rui[2][i]))
        an += (rui[2][i-1] * (rui[0][n-1] - rui[0][i]))
                
    elif s[i] == "B":
        x = min(i,n-1-i)
        for j in range(1,x+1):
            if (s[i+j] == "R" and s[i-j] == "G") or (s[i+j] == "G" and s[i-j] == "R"):
                mi += 1
        
        an += (rui[0][i-1] * (rui[1][n-1] - rui[1][i]))
        an += (rui[1][i-1] * (rui[0][n-1] - rui[0][i]))
        
print(an-mi)

Measured memory_bytes: 74440
object Main extends App {
  import scala.io.StdIn._
  solve
  def solve: Unit = {
    val Array(n, m, t) = readLine.trim.split(' ').map(_.toInt)
    val time: Array[Int] = readLine.trim.split(' ').map(_.toInt)
    var sumDiff = time(0) - m + (if (t - time(n - 1) > m) t - time(n - 1) - m else 0)
    for (i ← 1 until n){
      if (time(i) - time(i - 1) >= 2 * m) sumDiff += time(i) - time(i - 1) - 2 * m
    }
    println(sumDiff)
  }
  implicit class ScopeFunc[T](private val value: T) {
    def let[A](func:T ⇒ A): A = func(value)
    def also(func:T ⇒ Unit): T = {
      func(value)
      value
    }
  }
}




Measured memory_bytes: 44144
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include<bitset>
#include <iomanip>

using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;



#define ll long long




/*
class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d, e, H, W, L;
long long A[200005] = {};
long long B[5005][5] = {};
long long C[205][205] = {};
long long x[200005] = {};
long long y[200005] = {};
bool f, ff;
string S[2];
set <long long>sll;
pl bufpl;
vector <long long>vl[3];
vector <pl>vpl;
vector <string> vs;
set<ll> llset;

/*struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}


ll minn, maxx;

int main() {

	cin >> N>>a;
	b = 0;
	c = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		b += A[i];
		if (b <= a) {
			c++;
		}
	}

	cout << c+1 << endl;

	return 0;

}


Measured memory_bytes: 2304
N, M = map(int, input().split())

A = list(map(int, input().split())) 


def votenum(A):
  m = 0
  for i in range(0, len(A)):
    m = m + A[i]
  return m

#上位番目
Mlast = sorted(A)[-M]


S = Mlast / votenum(A) 


if S < 0.25 / M:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 3060
n,q=map(int,input().split())
s=input()
list_ac=[0]
number=0
for i in range(0,n):
    if s[i:i+2]=='AC':
        number=number+1
        list_ac.append(number)
    else:
        list_ac.append(number)
for i in range(0,q):
    l,r=map(int,input().split())
    print(list_ac[r-1]-list_ac[l-1])


Measured memory_bytes: 6100
#include<bits/stdc++.h>
using namespace std;
#define MAX 1000000

int a[MAX];

int f(int n){
    if(n%2 == 0){
        return n/2;
    }
    else{
        return 3*n+1;
    }
}

int main(){
    string str;
    cin >> str;
    int n = str.size()-2;
    int ans = 1e9;
    for(int i=0;i<n;i++){
        int x = (str[i]-'0')*100+(str[i+1]-'0')*10+(str[i+2]-'0');
        ans = min(ans,abs(x-753));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <stdlib.h>
long long k;
int compare_int(const void *a, const void *b)
{
    k = *(long long*)a - *(long long*)b;
    if (k > 0)
        k = 1;
    if (k < 0)
        k = -1;
    return k;
}
int main() {
    int n, i,j;
    long long a[200001], sum[200002],ans=0, count;
    scanf("%d", &n);
    for (i = 1; i <= n; i++)
        scanf("%lld", &a[i]);
    sum[0] = 0;
    for (i = 1; i <= n; i++)
            sum[i] = sum[i - 1] + a[i];
    qsort(sum, n+1, sizeof(long long), compare_int);
    count = 1;
    long long memory=sum[0];
    for (i = 1; i <= n; i++) {
        if (sum[i] == memory)
            count++;
        else {
                ans += count * (count - 1) / 2;
            count = 1;
            memory = sum[i];
        }
    }
    if (count > 1)
        ans += count * (count - 1) / 2;
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 4860
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
int main() {
	int n; std::cin >> n;
	std::vector<int> sticks(n); for (auto& s : sticks) std::cin >> s;
	std::sort(sticks.begin(), sticks.end());
	int count = 0;
	for (auto i = 0; i < n; ++i) for (auto j = i + 1; j < n; ++j) for (auto k = j + 1; k < n; ++k) {
		if (i < j && sticks[i] + sticks[j] > sticks[k]) {
			++count;
		}
	}
	std::cout << count << std::endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;

int main(){
  ll n,m; cin>>n>>m;
  vector<ll> v;
  for(int i=0;i<n;i++)v.push_back(i+m);
  ll sum=0; for(int i=0;i<n;i++)sum+=v[i];
  ll ans=1e17;
  for(int i=0;i<n;i++){
    ll cur=sum-v[i];
    if(abs(cur-sum)<abs(ans-sum))ans=cur;
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int main()
{
  while(1){
    int n,m;
    cin>>n;
    cin>>m;

    if(n == 0 && m == 0){
      break;
    }

    vector<int> thing;
    for(int i = 0;i < n;++i){
      int much;
      cin>>much;

      thing.push_back(much);
    }

    sort(thing.begin(),thing.end(),greater<int>());
 
    int i = 0;
    int j = 0;
    int sum = 0;

    for(int e : thing){
      for(int f : thing){
        if(e + f <= m && i != j && sum < e + f){
          sum = e + f;
        }
        ++j;
      }
      j = 0;
      ++i;
    }
    if(sum != 0){
      cout<<sum<<endl;
    }
    else{
      cout<<"NONE"<<endl;
    }
  }

  return 0;
}


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

  int main(){
    int N,K;
    cin >> N >> K;
    int a[N];
    for (int i=0;i<N;i++){
      cin >> a[i];
    }
    sort(a,a+N);
    int s=0;
    for (int i=0;i<K;i++){
      s+=a[N-1-i];
    }
    cout << s << endl;
  }


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * o.cc: O - Matching
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 21;
const int NBITS = 1 << MAX_N;
const int H = 12;
const int HBITS = 1 << H;
const int MOD = 1000000007;

/* typedef */

typedef long long ll;
typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

/* global variables */

int bnums[HBITS], ms[MAX_N][MAX_N], dp[NBITS];

/* subroutines */

inline void addmod(int &a, int b) { a = (a + b) % MOD; }

inline int bitnum(int bits) {
  return bnums[bits & (HBITS - 1)] + bnums[bits >> H];
}

/* main */

int main() {
  bnums[0] = 0;
  for (int bits = 1, msb = 1; bits < HBITS; bits++) {
    if ((msb << 1) <= bits) msb <<= 1;
    bnums[bits] = bnums[bits ^ msb] + 1;
  }

  int n;
  scanf("%d", &n);

  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) scanf("%d", &ms[i][j]);

  int nbits = 1 << n;
  dp[0] = 1;

  for (int bits = 0; bits < nbits; bits++) {
    int i = bitnum(bits);
    for (int j = 0, bj = 1; j < n; j++, bj <<= 1)
      if (! (bits & bj) && ms[i][j])
	addmod(dp[bits | bj], dp[bits]);
  }

  printf("%d\n", dp[nbits - 1]);
  return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> V;

#define _ cin.tie(0);ios::sync_with_stdio(false);
llong n,m;
int main(){ _;
  cin>>n>>m;
  V a(51);
  REP(i,m){
    int x,y;
    cin>>x>>y;
    a[x-1]++;a[y-1]++;
  }
  REP(i,n)
    cout<<a[i]<<endl;
    

  return 0;
}


Measured memory_bytes: 256
h,w = map(int,input().split())
s = [list(input()) for i in range(h)]
ans = [[0]*w for i in range(h)]
for i in range(h):
         for j in range(w):
                  if s[i][j] == "#":
                           for k in range(max(0,i-1),min(h,(i+1)+1)):
                                    for l in range(max(0,j-1),min(w,(j+1)+1)):
                                             ans[k][l] += 1
for i in range(h):
         for j in range(w):
                  if s[i][j] == "#":
                           ans [i][j] = "#"
for i in range(h):
         answer = list(map(str,ans[i]))
         answer=''.join(answer)
         print(answer)



Measured memory_bytes: 3064
r,g,b,n = [int(x) for x in input().strip().split(" ")]
counter = 0
for i in range(n//r+1):
#    print(i)
    for j in range((n-i*r)//g+1):
        if (n-i*r-j*g)%b == 0:
#            print(i,j,(n-i*r-j*g)/b)
            counter += 1
print(counter)




Measured memory_bytes: 40460
#include<algorithm>
#include<cmath>
#include<climits>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
	int H, W, K;
	cin >> H >> W >> K;

	vector<string> s(H);
	rep(i, H) cin >> s[i];

	vector<vector<int>> a(H, vector<int>(W));
	vector<vector<int>> pos(H, vector<int>());

	int num = 0;

	//イチゴに色付け
	rep(i, H)
	{
		rep(j, W)
		{
			if (s[i][j] == '#')
			{
				num++;
				a[i][j] = num;
				pos[i].push_back(j);
			}
		}
	}

	bool flg = false;

	rep(i, H)
	{
		if (pos[i].size() > 0)
		{
			//苺がある行
			flg = true;

			rep(j, W)
			{
				if (a[i][j] != 0) continue;

				auto itr = lower_bound(all(pos[i]), j);

				//自分の右側の苺と同じ色
				if (itr != pos[i].end())
				{
					a[i][j] = a[i][*itr];
				}
				else
				{
					a[i][j] = a[i][pos[i].back()];
				}
			}
		}
		else if(flg)
		{
			//苺がない行
			//1行前と同じ
			rep(j, W)
			{
				a[i][j] = a[i - 1][j];
			}
		}
		
	}

	//最終行は絶対に色がついている
	revrep(i, H - 1)
	{
		if (a[i][0] != 0) continue;

		rep(j, W)
		{
			a[i][j] = a[i + 1][j];
		}
	}


	rep(i, H)
	{
		rep(j, W)
		{
			cout << a[i][j] << " ";
		}

		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <cmath>
#include <tuple>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long ll;

int main(int argc, char *argv[])
{
	ll limit;
	ll h;
	ll answer;
	cin >> h;
	for (limit = 1;; limit *= 2) {
		if (h < limit) {
			answer = limit - 1;
			break;
		}
	}
	cout << answer << endl;
			
	return 0;
}


Measured memory_bytes: 256
import math
def main():
    A, B, H, M = map(int, input().split())
    x = abs(30 * H - 6 * M + 0.5 * M)
    x = math.radians(x)
    if x == 1:
        return A + B
    x = min(x, 2*math.pi - x)
    C = A**2 + B**2 - 2 * A * B * math.cos(x)
    return math.sqrt(C)
print(main())


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

using ll = long long;
#define D1(a) cerr<<#a<<":"<<a<<endl
#define D2(a,b) cerr<<#a<<":"<<a<<","<<#b<<":"<<b<<endl
#define D3(a,b,c) cerr<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cerr<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl
#define DH(c) do{rep(__i, c.size())cerr<<c[__i]<<(__i==c.size()-1?'\n':' ');}while(0)

int main()
{
    ll K; cin >> K;
    vector<ll> A(K); for (auto& a : A) cin >> a;

    ll l = 2, r = 2;
    for (int i = K-1; i >= 0; i--) {
        if (r/A[i] - (l-1)/A[i] == 0) {
            l = -1;
            break;
        }
        l = A[i] * ((l+A[i]-1)/A[i]);
        r = A[i] * (r/A[i]) + A[i] - 1;
        // D2(l, r);
    }

    if (l == -1) {
        cout << -1 << endl;
    } else {
        cout << l << " " << r << endl;
    }
}


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

F = [list(map(int,input().split())) for _ in range(N)]
P = [list(map(int,input().split())) for _ in range(N)]

#%%
INF = 1<<60
ans = -INF
for st in range(1,1<<10):
    t = st
    state = [0]*10
    for i in range(10):
        state[i] = t%2
        t >>= 1
    
    cur = 0
    for k in range(N):
        tmp = 0
        for i in range(10):
            if F[k][i] == 1 and state[i] == 1:
                tmp += 1
        cur += P[k][tmp]
    
    ans = max(ans,cur)

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
int maxnum(int x,int y);
int minnum(int x,int y);
int main(){
    int stu[30] = {0};
    int forg[2];
    int n;
    for(int i = 0;i < 28;i++){
        cin >> n;
        stu[n-1] = 1;
    }
    n = 0;
    for(int i = 0;i < 30;i++){
        if(stu[i] == 0){
            forg[n] = i+1;
            n++;
        }
    }
    sort(forg,forg+2);
    for(int i = 0;i < 2;i++){
        cout << forg[i] << endl;
    }
    return 0;
}

int maxnum(int x,int y){
    if(x >= y){
        return x;
    }
    else{
        return y;
    }
}

int minnum(int x,int y){
    if(x <= y){
        return x;
    }
    else{
        return y;
    }
}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  const int m = 2019;
  string s; cin >> s;
  int n = s.size();
  vi num(n+1);
  reverse(all(s));
  int x = 1;
  rep(i,n){
    num[i+1] = (s[i]-'0')*x;
    x *= 10;
    x %= m;
  }
  rep(i,n){
    num[i+1] += num[i];
    num[i+1] %= m;
  }
  int ans = 0;
  vi cnt(m);
  rep(i,n+1) ans += cnt[num[i]]++;
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 4360
import sys
import itertools
input = sys.stdin.readline


def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def main():
    n = I()
    mylist = ("M", "A", "R", "C", "H")
    mylist2 = [0 for i in range(5)]
    for i in range(n):
        word = input().rstrip()[0]
        for i, k in enumerate(mylist):
            if word == k:
                mylist2[i] += 1
    mylist2 = [i for i in mylist2 if i != 0]
    
    
    if len(mylist2) <= 2:
        print(0)
        sys.exit()
    result = 0
    for a, b, c in itertools.combinations(mylist2, 3):
        result += a * b * c
    print(result)
    
main()

Measured memory_bytes: 3064
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE FlexibleContexts #-}
-- {-# LANGUAGE PartialTypeSignatures #-}
-- {-# OPTIONS_GHC -Wno-partial-type-signatures #-}
import Control.Monad
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS
import Data.Array.ST
import Control.Monad.ST
import Data.STRef

asSTUArray :: ST s (STUArray s i a) -> ST s (STUArray s i a)
asSTUArray = id

main = do
  [h,w] <- map (read . BS.unpack) . BS.words <$> BS.getLine
  -- 1 <= h <= 1000, 1 <= w <= 1000
  initialState <- V.replicateM h BS.getLine
  -- for all (i, j), ((a ! i) `BS.index` j) `elem` "#."
  let initCells :: U.Vector (Int,Int) -- [(Int,Int)]
      initCells = U.fromList [(i,j) | i <- [0..h-1], j <- [0..w-1], (initialState V.! i) `BS.index` j == '#']
  let answer :: Int
      answer = runST $ do
        arr <- asSTUArray $ newArray ((0,0),(h-1,w-1)) False
        U.forM_ initCells $ \p ->
          writeArray arr p True
        let -- loop :: Int -> U.Vector (Int,Int) -> _ Int
            loop !k xs = do
              lenRef <- UM.replicate 1 0
              vec <- UM.new (4 * U.length xs)
              let -- push :: (Int,Int) -> _ ()
                  push value = do
                    len <- UM.read lenRef 0
                    UM.write vec len value
                    UM.write lenRef 0 (len + 1)
              let doCell !i !j
                    | 0 <= i && i < h && 0 <= j && j < w = do
                        b <- readArray arr (i,j)
                        when (not b) $ do
                          writeArray arr (i,j) True
                          push (i,j)
                    | otherwise = return ()
              U.forM_ xs $ \(i,j) -> do
                doCell (i-1) j
                doCell (i+1) j
                doCell i (j-1)
                doCell i (j+1)
              len <- UM.read lenRef 0
              if len == 0
                then return k
                else do ys <- U.take len <$> U.unsafeFreeze vec
                        loop (k+1) ys
        loop 0 initCells
  print answer


Measured memory_bytes: 97020
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
    
        
        System.out.printf("%d %d\n",a*b,2*(a+b));
        
        
        
    }
}




Measured memory_bytes: 26256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// make new Scanner.
		Scanner sc = new Scanner(System.in);
//		int n = Integer.parseInt(sc.next());

		List<Integer> list = new ArrayList<Integer>();
		
		list = inList(sc,3);
		
		Collections.sort(list, Comparator.reverseOrder());
		
		int a = list.get(0) - list.get(1) + list.get(1) - list.get(2);
		
		System.out.println(a);
		

		// close Scanner
		sc.close();

	}

	
	/**
	 *  入力した数字を配列に格納するメソッド.
	 * @param sc
	 * @param n
	 * @return
	 */
	public static List<Integer> inList(Scanner sc, int n) {
		List<Integer> list = new ArrayList<Integer>();
		for (int a=0;a<n;a++) {
			list.add(sc.nextInt());
		}
		return list;
	}
	
	/**
	 *  入力した数字を配列に格納するメソッド.
	 * @param sc
	 * @param n
	 * @return
	 */
	public static List<Long> inLongList(Scanner sc, int n) {
		List<Long> list = new ArrayList<Long>();
		for (int a=0;a<n;a++) {
			list.add(sc.nextLong());
		}
		return list;
	}
	
	
	/**
	 *   リストの数字の美しさを求める.
	 */
	public static int beautyList(List<Integer> list, int d) {
		int a=0;
		for (int b=0;b<= list.size(); b++) {
			if (Math.abs(list.get(b) - list.get(b+1)) ==d) {
				a++;
			}
		}
		return a;
	}
	
	public static String judge(List<Long> list) {
		Long a =list.get(0);
		Long b =list.get(1);
		Long c =list.get(2);
		Long d =list.get(3);
		
		if (a < b
				|| b > d)
				{
			return "No";
		}
		if (a-b < b) {
			if (a-b > c) {
				return "No";
			} else if (b ==d) {
				return "Yes";
			}
		}
		if (b % 2 == 0) {
			if (b*2 <= c+d) {
				return "Yes";
			} else {
				return "No";
			}
		} else {
			if (b*2 < c+d) {
				return "Yes";
			} else {
				return "No";
			}
		}
	}

}


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

int main() {

	int count = 0, num;

	cin >> num;
	
	if (num/100 == 1) {
		count++;
	}
	if ((num%100)/10 == 1) {
		count++;
	}
	if (num%10 == 1) {
		count++;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n;  cin >> n;
    int *a = new int[n];

    bool flag = true;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] % 2 == 0) {
            if (a[i]%3 && a[i]%5)
                flag = false;
        }
    }

    if (flag)
        cout << "APPROVED" << endl;
    else 
        cout << "DENIED" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	cin >> n;
	long long dp[1000000];
	for(int i=0;i<=n;i++){
		dp[i]=1e9;
	}
	dp[0]=0;
	for(int i=0;i<n;i++){
		dp[i+1]=min(dp[i+1],dp[i]+1);
		for(int j=6;j<=n;j*=6){
			dp[i+j]=min(dp[i+j],dp[i]+1);
		}
		for(int j=9;j<=n;j*=9){
			dp[i+j]=min(dp[i+j],dp[i]+1);
		}
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 3200
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(intl i=0;i<(intl)(n);i++)
#define Rep1(i,n) for(intl i=1;i<(intl)(n)+1;i++)
#define vec vector
#define fi first
#define se second
#define pushb push_back
#define popb pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
using intl = int64_t;
using vi = vec<intl>;
using vvi = vec<vi>;
vec<intl> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<intl> dy = {1, 0, -1, 0, 1, -1, 1, -1};

intl pow(intl a,intl n){
  intl ans=1;
  Rep(i,n) ans *=a;
  return ans;
}

int main(){
  int N,X,Y;
  cin >>N>>X>>Y;
  vi distance(N,0);
  Rep1(i,N){
    for(int j=i+1;j<=N;j++){
      distance[min({j-i , abs(X-i)+abs(Y-j)+1 ,abs(Y-i)+abs(X-j)+1})] ++;
    }
  }
  Rep1(i,N-1)cout << distance[i]<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    a = list(map(int, input().split()))
    l = [0]*(10**5 + 10)


    for i in a:
        l[i] += 1
        l[i + 1] += 1
        if i != 0:
            l[i - 1] += 1
    print(max(l))

main()

Measured memory_bytes: 14040
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    int X=(A+D-1)/D, Y=(C+B-1)/B;
    cout<<(X>=Y?"Yes":"No")<<"\n";
}


Measured memory_bytes: 3608
while True:
    m,f,r=map(int, raw_input().split())
    s=m+f
    if m==-1 and f==-1 and r==-1:
        break
    elif m==-1 or f==-1 or s <30:
        print 'F'
    elif s <50 and r <50:
        print 'D'
    elif s <65:
        print 'C'
    elif s <80:
        print 'B'
    else:
        print 'A'

Measured memory_bytes: 6360
export default solve;

// main
function main(lines) {
  console.log(solve(lines));
}

// solver
function solve(lines: string[]): string {
  const { N, destinations } = parseLines(lines);
  return (3 * N * N).toString();
}

// helpers
function parseLines(lines: string[]) {
  const N = +lines[0];
  const destinations = lines.slice(1, 1 + N).map(line => line.split(' ').map(s => +s));
  const obj = { N, destinations };
  debug(obj);
  return obj;
}

// general helpers
function debug(message?: any, ...optionalParams: any[]) {
  if (!!process.env.LOCAL_DEBUG) console.log(message, ...optionalParams);
}

// reader
if (!process.env.LOCAL_DEBUG) {
  const { stdin: input, stdout: output } = process;
  input.resume();
  input.setEncoding('utf8');
  const lines = [];
  require('readline')
    .createInterface({ input, output })
    .on('line', line => lines.push(line))
    .on('close', () => main(lines));
}


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

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



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

    if(a==1){
        a += 20;
    }
    if(b==1){
        b += 20;
    }

    if(a==b){
        cout << "Draw" << endl;
    }else if(a > b){
        cout << "Alice" << endl;
    }else{
        cout << "Bob" << endl;
    }

    return 0;
}  

Measured memory_bytes: 256
n,k=map(int,input().strip().split())
if n%2==0:
    val=int(n/2)
    if k<=val:
        print("YES")
    else:
        print("NO")
else:#even
    val=int(n/2)+1
    if k<=val:
        print("YES")
    else:
        print("NO")
    
    


Measured memory_bytes: 2940
while True :
    m, f, r = (int(x) for x in input().split())
    sum = m + f

    if (m == -1 and f == -1 and r == -1):
        break

    elif (m == -1 or f == -1):
        print("F")

    elif (sum >= 80):
        print("A")

    elif (sum >= 65 and sum < 80):
        print("B")

    elif (sum >= 50 and sum < 65):
        print("C")

    elif (sum >= 30 and sum < 50):
        if (r >= 50):
            print("C")
        elif (r < 50):
            print("D")

    elif (sum < 30):
        print("F")



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

#define ll long long

const int maxn = 26,mod = 1e9+7;
int cnt[26];
ll memo[maxn][2];

ll go(int pos,int par){
    if(pos==26) return 1;
    if(memo[pos][par]!=-1) return memo[pos][par];
    int ans;
    if(cnt[pos]){
        ans=(cnt[pos]*go(pos+1,1)+go(pos+1,0))%mod;;
    }
    else{
        ans=go(pos+1,par);
    }
    return memo[pos][par]=ans%mod;
}

int main(){


    int n;
    cin>>n;
    memset(cnt,0,sizeof(cnt));
    memset(memo,-1,sizeof(memo));
    string s;
    cin>>s;
    for(auto it:s){
        cnt[it-'a']++;
    }
    cout<<go(0,0)-1;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<map>
#include<string>
#include<string.h>
#include<utility>
#include<algorithm>
#include<vector>
#include<queue>
#include<iostream>
#include<math.h>
#include<stack>
#include<set>
#define INF 2147483647
#define n 300000
#define loop(i, a, b) for(int i=a; i<=b; i++)
#define mem(arr) memset(arr, 0, sizeof(arr));
using namespace std;
typedef long long lli;
typedef double llf;
typedef pair<int, int> P;
struct edge{
	int to, weight;
};
void solve();
int main()
{
	int times = 1;
//	cin >> times;
	loop(i, 1, times)
	{
		solve();
		cout << '\n';
	}
	return 0;
}
vector<edge> V[n + 50];
llf a, b, c, d, e, f;
int arr[n + 50], arr1[n + 50], arr2[n + 50];
string str, str1, str2;

void solve()
{
	cin >> a;
	double temp = a / 1.08;
	int one = temp, two = ceil(temp);
	if(one * 1.08 - a >= 0.0 && one * 1.08 - a < 1) cout << one;
	else if(two * 1.08 - a >= 0.0 && two * 1.08 - a < 1) cout << two;
	else cout << ":(";
}

Measured memory_bytes: 8704
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
using namespace std;
const int MAXN = 202;
const int INF = INT_MAX/2;
int64_t g[MAXN][MAXN];
int main(){
  int n,m,r;
  vector<int> rs;
  fill(*g, g[MAXN], INF);
  cin >> n >> m >> r;
  for(int i = 0; i < r; i++){
    int rtmp;
    cin >> rtmp;
    rs.push_back(rtmp - 1);
  }

  for(int i = 0; i < m; ++i){
    int a,b,c;
    cin >> a >> b >> c;
    a--;
    b--;
    g[a][b] = g[b][a] = c;
  }
  for(int i = 0; i < n; ++i){
    g[i][i] = 0;
  }
  for(int k = 0; k < n; ++k){
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < n; ++j){
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
  int ans = INF;
  sort(rs.begin(), rs.end());
  do{
    int sum = 0;
    for(size_t i = 0; i < rs.size()- 1; ++i){
      sum += g[rs[i]][rs[i + 1]];
    }
    ans = min(sum, ans);
  } while(next_permutation(rs.begin(), rs.end()));
  cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 2003, MOD = 1e9 + 7;
int n, a, b, c, d, dp[N][N], C[N][N];
int fact[N][N], rev[N][N];

void add(int & x, int y) {
	x += y;
	if (x >= MOD) x -= MOD;
}

int bp(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1)
			res = (ll)res * x % MOD;
		x = (ll)x * x % MOD;
		y /= 2;
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	for (int i = 0; i < N; i++) fact[0][i] = 1;
	for (int i = 1; i < N; i++) {
		fact[i][0] = 1;
		int F = (ll)fact[i - 1][1] * i % MOD;
		for (int j = 1; j < N; j++) {
			fact[i][j] = (ll)fact[i][j - 1] * F % MOD;
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			rev[i][j] = bp(fact[i][j], MOD - 2);
		}
	}
	C[0][0] = 1;
	for (int i = 1; i < N; i++) {
		C[i][0] = 1;
		for (int j = 1; j < N; j++) {
			C[i][j] = C[i - 1][j];
			add(C[i][j], C[i - 1][j - 1]);
		}
	}
	cin >> n >> a >> b >> c >> d;
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			dp[i][j] = dp[i - 1][j];
			if (a <= i && i <= b) {
				for (int k = c; k <= d; k++) {
					if (j - k * i < 0) break;
					int t = (ll)dp[i - 1][j - k * i] * C[n - j + k * i][k * i] % MOD;
					t = (ll)t * rev[k][1] % MOD;
					add(dp[i][j], ((ll)t * fact[k * i][1] % MOD) * rev[i][k] % MOD);
				}
			}
		}
	}
	cout << dp[n][n];
}


Measured memory_bytes: 58484
using System;

public class Program{
    public static void Main(){
        char[] S=Console.ReadLine().ToCharArray();
        int N=S.Length;
        int[] H=new int[N];
        int store=1;
        char last='R';
        int lastL=-1;
        for(int k=0;k<N;k++){
            H[k]=0;
        }
        for(int i=1;i<N;i++){
            if(S[i]!=last){
                int l=store/2;
                if(last=='R'){
                    H[i-1]+=store%2==0?l:l+1;
                    H[i]+=l;
                    store=0;
                    lastL=i;
                    last='L';
                }else{
                    H[lastL-1]+=l;
                    H[lastL]+=store%2==0?l:l+1;
                    store=0;
                    last='R';
                }
            }
            store++;
        }
        H[lastL-1]+=store/2;
        H[lastL]+=store%2==0?store/2:store/2+1;
        Console.Write(H[0]);
        for(int j=1;j<N;j++){
            Console.Write(" "+H[j]);
        }
    }
}


Measured memory_bytes: 16096
n = int(input())
a = list(map(int, input().split()))

flag = True
for i in range(n):
    if a[i+1] != 0:
        flag = False
        break

if n != 0 and a[0] != 0:
    print(-1)
    exit()
elif n == 0 and a[0] == 1:
    print(1)
    exit()

nleaf = 1
ans = 0
v = list()

for i in range(n):
    nleaf -= a[i]
    v.append(nleaf)
    nleaf *= 2

if nleaf < a[n]:
    print(-1)
    exit()

nleaf = a[n]
ans += a[n]
for i in range(n-1, -1, -1):
    if v[i]*2 < nleaf:
        print(-1)
        exit()
    if v[i] > nleaf:
        v[i] = nleaf
    nleaf = v[i] + a[i]
    ans += nleaf
print(ans)

Measured memory_bytes: 668748
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

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

    int fac0=0, fac2=0;
    REP(i,n){
        int a;
        cin >> a;
        int sum_of_2=0;
        while(a%2==0){
            sum_of_2++;
            a/=2;
        }
        if(sum_of_2>=2) fac2++;
        if(sum_of_2<1) fac0++;
        
    }

    if(fac2>=fac0) cout << "Yes" << endl;
    else if(fac2+1==fac0){
        if(fac2+fac0==n) cout << "Yes" << endl;
        else cout << "No" << endl;
    }else cout << "No" << endl;
    return 0;   
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
#include<queue>
using namespace std;



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

  if(a>=3200) cout<<s<<endl;
  else cout<<"red"<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int x = scan.nextInt();
    
    if(x == 2){
      System.out.println(x);
      System.exit(0);
    }
    
    boolean s = false;
    
    while(s == false){
      
      
      for(int i = 2; i < x; i ++){
        if(x % i == 0){
          s = false;
          break;
        }
        s = true;
      }
      
      
      
      x += 1;
    }
    
    System.out.println(x-1);
    
  }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define PI acos(-1)
#define eq(x,y) (fabs((x)-(y)) < eps)
#define debug(x) cerr<<x<<endl;
#define endl "\n"
#define pb push_back
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const int nmax=1e5+10;
const int eps=1e-8;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.precision(10);
    //cout<<fixed;
    //cout.tie(NULL);
    ll n,m;
    cin>>n>>m;

    ll ans=n*m;

    if(n==1 && m==1)
        cout<<ans<<endl;
    else if(n==1 || m==1)
        cout<<ans-2<<endl;
    else{
        ans-= 2*n + 2*(m-2);
        cout<<ans<<endl;
    }




    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

    int N;
    int x;

    scanf("%d",&N);

    if(N%1000==0){
        x=N/1000;
    }else{
        x=N/1000+1;
    }

    printf("%d\n",x*1000-N);

    return 0;
}

Measured memory_bytes: 2108
input()
A = list(map(int, input().split()))

sum_list = sum(A)
sum_of_product = 0

for i in A:
    sum_list -= i
    sum_of_product = ((sum_list * i) % (10 ** 9 + 7) + sum_of_product) % (10 ** 9 + 7)

print(sum_of_product)

Measured memory_bytes: 31348
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>

using namespace std;
#define REP(i,a,n) for(int i = a; i < (int)n; ++i)
#define REPM(i,n,a) for(int i = n - 1; i >= a; --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;

#if 1
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;
#endif

int X, A, B;

int main() {
	cin >> X >> A >> B;
	int s = B - A;
	if (s <= 0) cout << "delicious" << endl;
	else if (s <= X)cout << "safe" << endl;
	else  cout << "dangerous" << endl;
	return 0;
}


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

int dp[100000];

signed main()
{
  int N;
  cin >> N;
  vector<int> h(N);
  for(int i=0; i<N; i++) cin >> h[i];

  dp[0] = 0;
  dp[1] = labs(h[1]-h[0]);

  for(int i=2; i<N; i++) dp[i] = min(dp[i-1]+labs(h[i]-h[i-1]), dp[i-2]+labs(h[i]-h[i-2]));

  cout << dp[N-1] << endl;

  return 0;
}

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

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

    if (abs(a - c) <= d) { // direct
        cout << "Yes" << endl;
    } else { // indirect
        if (abs(a - b) <= d && abs(b - c) <= d) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <tuple>
#include <cassert>
#include <memory>
using namespace std;
typedef long long ll;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

const int INF = 1e9;

struct Node
{
    int len;
    vector<int> arr;

    Node (): len(0), arr(vector<int>(200010, INF)) {}
};

int N;
vector<int> a;
vector<int> G[200010];
vector<int> ans;
bool used[200010];

void dfs(Node &node, int v) {
    if (used[v]) return;
    used[v] = true;
    auto p = lower_bound(node.arr.begin(),node.arr.end(),a[v]);
    auto tt = *(p);
    auto lt = node.len;
    *(p) = a[v];
    for (int i = node.len; i < node.arr.size(); i++) {
        if (node.arr[i] == INF) {
            node.len = i;
            break;
        }
    }
    ans[v] = node.len;
    for (int i = 0; i < G[v].size(); i++) {
        dfs(node, G[v][i]);
    }
    node.len = lt;
    *(p) = tt;
    node.arr[node.len] = INF;
    node.arr[node.len + 1] = INF;
    node.arr[node.len + 2] = INF;
}

int main ()
{
    cin >> N;
    a.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < N - 1; i++) {
        int u,v;
        cin >> u >> v;
        u--,v--;
        G[v].push_back(u);
        G[u].push_back(v);
    }

    Node fn;
    ans.resize(N);
    dfs(fn, 0);

    for (auto x: ans) {
        cout << x << endl;
    }

    return 0;
}


Measured memory_bytes: 27880
#include <iostream>
#include <string>
using namespace std;
int main(){
	int m = 700;
	string S;
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'o') {
			m += 100;
		}
		else {
			m += 0;
		}
	}
	cout << m << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;

int main() {
  int a,b;
  scanf("%d %d",&a,&b);
  if(a%2==1 && b%2==1) printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
#define tl 1'000'000'007
int mmax;
void erasuru(vector<ll> &A){
    A[0] = 0; // 0は素数ではない
    A[1] = 0; // 1は素数ではない
    
    for(size_t i=2; i*i<=mmax; ++i) // 0からsqrt(max)まで調べる
        if(A[i]) // iが素数ならば
            for(size_t j=2; i*j<=mmax; ++j) // (max以下の)iの倍数は
                A[i*j] = 0;      // 素数ではない
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    mmax= n;
    vector<ll>A(n+1,1);
    erasuru(A);
    ll ans= 1;
    
    REP(i,n+1){
        if(A[i]){
            ll cc= 0;
            ll x;
            for(ll j=2; j<=n; j++){ 
                x= j;
                while(x%i==0){
                    cc++;
                    x/=i;
                }
            }
            // cout << cc << endl;
            ans*= cc+1;
            ans%= tl;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int i,s=0,in[500][2],tate,yoko;
	for(i=0;i<500;i++){
		scanf("%d %d",&in[i][0],&in[i][1]);
		if(in[i][0]==0&&in[i][1]==0)
			break;
		s++;
	}
	for(i=0;i<s;i++){
		for(tate=0;tate<in[i][0];tate++){
			for(yoko=0;yoko<in[i][1];yoko++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}


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

int main(void){
 
  string a,b,c;
  cin >> a >> b >> c;
  
  cout << (char)(a[0] + ('A' - 'a')) << (char)(b[0] + ('A' - 'a')) << (char)(c[0] + ('A' - 'a'))<<endl;
}

Measured memory_bytes: 3616
package main

import "fmt"

func main() {
	var X int
	fmt.Scan(&X)

	v5 := make(map[int]int)

	A := 0
	for {
		A5 := A * A * A * A * A
		v5[A5] = A
		B5 := A5 - X
		if B5 > 0 {
			if B, ok := v5[B5]; ok {
				fmt.Println(A, B)
				return
			}
		} else {
			if B, ok := v5[-B5]; ok {
				fmt.Println(A, -B)
				return
			}
		}
		A++
	}
}


Measured memory_bytes: 1844
program kadai
    implicit none
integer  ::  n
integer,allocatable  ::  h(:)
integer  ::  i,ans,j

read(*,*) n
allocate(h(n))
read(*,*) h

ans=0
j=0
do i=1,n-1
    if (h(i)<h(i+1)) then
        ans=max(ans,j)
        j=0
    else
        j=j+1
    end if
end do
ans=max(ans,j)
write(*,*) ans

stop
contains



end program kadai

Measured memory_bytes: 1152