akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long double ld;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

/*
1~i番目までのコインを用いて値段をj以上にするときのコイン枚数の最小値p[i][j]
*/

int p[25][50010];

void solve(){

    int n,m;
    cin >> n >> m;
    int c[30];
    rep(i,m){
        cin >> c[i+1];
    }
    rep(j,n+1){
        p[0][j]=INF;
    }
    rep(i,m+1){
        p[i][0]=0;
    }
    for(int i=1; i<=m; i++){
        for(int j=1; j<=n; j++){
            if(j>=c[i]) p[i][j]=min(p[i-1][j], min(p[i-1][j-c[i]]+1, p[i][j-c[i]]+1));
            else p[i][j]=p[i-1][j];
        }
    }

    cout << p[m][n] << endl;

}

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



Measured memory_bytes: 7328
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE MultiWayIf #-}

import Control.Monad
import Control.Monad.ST
import Control.Monad.State
import Control.Monad.Primitive
import Control.Applicative
import Control.Arrow
import Data.List
import Data.Array
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Data.Maybe
import Data.Bits
import Data.Ord
import Data.Ratio
import Data.Int
import Data.Char
import qualified Data.ByteString.Char8 as BS
import qualified Data.Set as Set
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Data.Tuple
import Data.Function
import Text.Printf
import Debug.Trace
import Numeric

modifyArray arr i f = readArray arr i >>= \x -> writeArray arr i (f x)

listToTuple2 [a,b] = (a,b)
listToTuple3 [a,b,c] = (a,b,c)
listToTuple4 [a,b,c,d] = (a,b,c,d)
listToTuple5 [a,b,c,d,e] = (a,b,c,d,e)

readIntBS = fst . fromJust . BS.readInt

for = flip map

infixr 1 ?
(?) :: Bool -> (a,a) -> a
(?) b t = (if b then fst else snd) t

main :: IO ()
main = do
  l <- readLn :: IO Int

  let
    r = last $ takeWhile (\i -> 2^i <= l) [1..] :: Int
    es = (concat $  map (\i -> [(i,i+1,0), (i,i+1,2^(i-1))]) [1..r]) ++ aux r (reverse [1..r]) l

  printf "%d %d\n" (r+1) (length es)
  forM_ es $ \(u,v,w) -> do
    printf "%d %d %d\n" u v w

  where
    aux _ [] _ = []
    aux r (t:ts) l = if l-2^(t-1) >= 2^r then (t,r+1,l-2^(t-1)) : aux r ts (l-2^(t-1)) else aux r ts l 


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i, a, b;
    cin>>a>>b;
    for(i=1; i<=1000000; ++i)
    {
        if(int(i*0.08)==a && int(i*0.1)==b)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>
#include <deque>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <unordered_map>
#include <queue>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
const ll SIZE = 1e5 * 2 + 10, INF = 1e9;

vector<ll> vec;
ll sz[SIZE], hv[SIZE];

int main()
{
    fastInp;

    ll n, m;
    cin >> n >> m;

    for (int i = 0; i < n; i++) sz[i] = 1;
    hv[0] = 1;

    while (m--) {
        ll u, v;
        cin >> u >> v;
        u--; v--;
        sz[v]++;
        sz[u]--;
        if (sz[v] >= 1 && hv[u]) hv[v] = 1;
        if (sz[u] == 0) hv[u] = 0;
    }

    ll ans = 0;
    for (int i = 0; i < n; i++) ans += hv[i];

    cout << ans;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;

int main(){
    ll H;
    cin >> H;
    ll W;
    cin >> W;
    vector<vector<char>> a(H, vector<char>(W));
    for(ll i=0;i<H;i++){
     for(ll j=0;j<W;j++){
         cin>>a[i][j];
     ;}
    ;}
    vector<vector<ll>> dp(H, vector<ll>(W,0));
    dp[0][0]=1;
    for(ll i=0;i<H;i++){
     for(ll j=0;j<W;j++){
         if(i-1>=0&&i-1<H&&j>=0&&j<W&&a[i-1][j]=='.'){
             dp[i][j]+=dp[i-1][j];
         }
         if(i>=0&&i<H&&j-1>=0&&j-1<W&&a[i][j-1]=='.'){
             dp[i][j]+=dp[i][j-1];
         }
         dp[i][j]%=MOD;
     ;}
    ;}
    cout<<dp[H-1][W-1]<<endl;




    return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 62;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n, m; cin >> n >> m;
  vector<int> x(m);
  rep(i, m) cin >> x[i];
  if(n >= m) {
    cout << 0 << endl;
    return 0;
  }
  sort(ALL(x));
  vector<int> d;
  rep(i, m-1) d.push_back(x[i+1]-x[i]);
  sort(ALL(d));

  ll ans = 0;
  rep(i, m-n) ans += d[i];
  cout << ans << endl;
}

Measured memory_bytes: 4260
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
using P = pair<long long, long long>;

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

int main() {
  long long a, b;
  cin >> a >> b;
  if(a < b) swap(a, b);
  long long ans = a * b / gcd(a, b);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3648
def dfs(v, p)
  @vis[v] = true
  @ord[v] = @k += 1 # 到達時刻
  @low[v] = @ord[v]

  @lines[v]&.each do |to|
    if !@vis[to]

      dfs(to, v)
# 訪問先が閉路の経路であれば現在点もそれに含まれる
      @low[v] = [@low[v], @low[to]].min
# @lowの値が現在と訪問先で等しい
# →現在〜訪問先の経路は閉路に含まれる。
# そうで無いならばその経路は橋である
      @bridge += 1 if @ord[v] < @low[to]
# 訪問先が直前の頂点でなければ→閉路の発生
    elsif to != p
      @low[v] = [@low[v], @ord[to]].min
    end
  end
end
N, M = gets.split.map(&:to_i)
@lines = {}
M.times do
  s, t = gets.split.map(&:to_i)
  (@lines[s-1] ||= []) << t-1
  (@lines[t-1] ||= []) << s-1
end
@vis = Array.new(N, false)# 訪問したか否か
@ord = Array.new(N, 0)# 各頂点の訪問時刻
@low = Array.new(N)
@k = 0 # 訪問時刻
@bridge = 0 # 橋の数
N.times do |i|
  dfs(i, -1) if !@vis[i]
end
puts @bridge

Measured memory_bytes: 1916
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define pii pair<int, int>
#define vii vector< pair<int,int> >
#define vi vector<int>
#define vvi vector< vector< int> >
#define ss second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace4(x, y, z, d)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#d<<": "<<d<<endl

#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1, 0};int dy[]={0,1,0, -1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
bool compare(const pair<int,int> &a,
             const pair<int,int> &b)
{
    if(a.ff == b.ff) {
        return (b.ss < a.ss);
    }
    return (a.ff<b.ff);
}
bool prime[1000001];
void SieveOfEratosthenes(int n) 
{
    // Create a boolean array "prime[0..n]" and initialize
    // all entries it as true. A value in prime[i] will
    // finally be false if i is Not a prime, else true.

    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
int32_t main()
{
    IOS;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    /********************* From here ***********************/
    
    string s;
    cin >> s ;
    
    int ind[s.length()+1]  = {0};
    rep(i, 1, s.length()+1){
        if(s[i-1]=='A'||s[i-1]=='T'||s[i-1]=='C'||s[i-1]=='G'){
            ind[i] = ind[i-1]+1;
        }
        else{
            ind[i] = 0;
        }
    }
    // rep(i, 1, s.length()+1){
    //     cout << ind[i] << " ";
    // }
    // cout << endl;
    cout << *max_element(ind, ind+s.length()+1);
}



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

using namespace std;

typedef long long in;

int main(){
    string s;
    cin >> s;
    vector<string> v={"dream","dreamer","erase","eraser"};
    for(int i=0;i<s.size();i++){
        if(s[i]=='d'){
            if(s.substr(i,7)==v[1]){
                if(i+5+6<=s.size()&&(s.substr(i+5,6)==v[3])){
                    i+=4;
                    continue;
                }
                if(i+5+5<=s.size()&&s.substr(i+5,5)==v[2]){
                    i+=4;
                    continue;
                }
                i+=6;
                continue;
            }
            if(s.substr(i,5)==v[0]){
                i+=4;
                continue;
            }
            cout << "NO" << endl;
            return 0;
        }
        if(s[i]=='e'){
            if(s.substr(i,6)==v[3]){
                i+=5;
                continue;
            }
            if(s.substr(i,5)==v[2]){
                i+=4;
                continue;
            }
            cout << "NO" << endl;
            return 0;
        }
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    return 0;
}
//dreameraser


Measured memory_bytes: 640
#include<cstdio>
#define mod 1000000007
#define int long long
int n,m,a[610],b[610],nxt[610],sum[610],cnt[610][610],dp[610][610],ans;
signed main(){
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=m;i++)
		scanf("%lld%lld",&a[i],&b[i]),
		nxt[a[i]]=b[i],
		nxt[b[i]]=a[i];
	n*=2;
	sum[0]=1;
	for(int i=2;i<=n;i+=2)
		sum[i]=(sum[i-2]*(i-1))%mod;
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j++)
			cnt[i][j]=cnt[i][j-1]+(!nxt[j]);
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j++){
			bool bo=false;
			for(int k=i;k<=j;k++)
				if(nxt[k]&&(nxt[k]>j||nxt[k]<i))
					bo=true;
			if(bo)continue;
			dp[i][j]=sum[cnt[i][j]];
			for(int k=i+1;k<=j-1;k++)
				dp[i][j]=(dp[i][j]-dp[i][k]*sum[cnt[k+1][j]]%mod+mod)%mod;
		}
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j++)
			(ans+=dp[i][j]*sum[(n/2-m)*2-cnt[i][j]]%mod)%=mod;
	printf("%lld\n",ans);
} 

Measured memory_bytes: 5888
n, m = map(int, input().split())
c = {}
for i in range(n):
    c[i] = 0
ac = [False] * n
acn = 0
for _ in range(m):
    p,s = tuple(input().split())
    p = int(p)
    if s == 'AC' and ac[p-1]==False:
        ac[p-1] = True
        acn+=1
    elif s== 'WA' and ac[p-1]==False:
        c[p-1]+=1
pen = 0
for i,p in c.items():
    if ac[i]: pen+=p
print(acn, pen, sep=' ')

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

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

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

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

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

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

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

signed main() {
    int a, b; cin >> a >> b;
    if(a == b) cout << "Draw" << endl;
    else if(a == 1) cout << "Alice" << endl;
    else if(b == 1) cout << "Bob" << endl;
    else {
        if(a < b) cout << "Bob" << endl;
        else cout << "Alice" << endl;
    }
    return 0;
}

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

signed main(){
	int n,m,x,ans1 = 0,ans2 = 0;
	cin >> n >> m >> x;
	for(int i = 0;i < m;i++){
		int a;
		cin >> a;
		if(a < x) ans1++;
		else ans2++;
	}
	cout << min(ans1,ans2) << endl;
	return 0;
}

Measured memory_bytes: 256
import collections

n = int(input())
v = list(map(int, input().split()))
a = v[::2]
b = v[1::2]
ac = collections.Counter(a)
bc = collections.Counter(b)
ac = sorted(ac.items(), key=lambda x: x[1], reverse=True)
bc = sorted(bc.items(), key=lambda x: x[1], reverse=True)
if ac[0][0] == bc[0][0]:
    if len(ac) == len(bc) and len(ac) == 1:
        print(ac[0][1])
        exit()
    i = 0
    while ac[i][1] == bc[i][1]:
        i += 1
        if i == len(ac) - 1 or i == len(bc) - 1:
            break
    if ac[i][1] > bc[i][1]:
        ac.remove(ac[i])
        bc.remove(bc[0])
    elif ac[i][1] < bc[i][1]:
        ac.remove(ac[0])
        bc.remove(bc[i])
    else:
        ac.remove(ac[0])
        bc.remove(bc[1])
else:
    ac.remove(ac[0])
    bc.remove(bc[0])
ans = 0
for i in range(len(ac)):
    ans += ac[i][1]
for i in range(len(bc)):
    ans += bc[i][1]
print(ans)


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

int main() {
  int n; cin >> n;
  ll a[n],b[n],s[n],t[n]; bool check = true; 
  
  rep(i,0,n) {
    cin >> a[i]; b[i] = a[i];
  }
  s[0] = a[0]; t[0] = s[0];
  
  ll ans1 =0;
  rep(i,0,n) {
    if (i >=1) t[i] = t[i-1] + b[i];
    if (i % 2 ==0) {
      if (t[i] <=0) {
        ans1 += 1 - t[i]; b[i] += 1 - t[i]; t[i] = 1;
      } 
      if (b[i] <=0) {
        ans1 += 1 - b[i]; b[i] = 1;
      }
    }
    if (i % 2 ==1) {
      if (t[i] >=0) {
        ans1 += t[i] + 1; b[i] -= t[i] + 1; t[i] = -1;
      }
      if (b[i] >=0) {
        ans1 += b[i] + 1; b[i] = -1;
      }
    } 
  }

  ll ans2 =0;
  rep(i,0,n) {    
    if (i >=1) s[i] = s[i-1] + a[i];
    if (i % 2 ==1) {
      if (s[i] <=0) {
        ans2 += 1 - s[i]; a[i] += 1 - s[i]; s[i] = 1;}
      if (a[i] <=0) {
        ans2 += 1 - a[i]; a[i] = 1;}  
    }
    if (i % 2 ==0) {
      if (s[i] >=0) {
        ans2 += s[i] + 1; a[i] -= s[i] + 1; s[i] = -1; }
      if (a[i] >=0) {
        ans2 += a[i] + 1; a[i] = -1;}  
    } 
  }
  ll ans = min(ans1,ans2);
  cout << ans << endl;
}

Measured memory_bytes: 6736
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        long n = Long.parseLong(sc.next());
        long[] x = new long[5];
        for(int i = 0; i < 5; i++){
            x[i] = Long.parseLong(sc.next());
        }
        
        long min = x[0];
        int minIndex = 0;
        for(int i = 1; i < 5; i++){
            if(x[i] < min){
                min = x[i];
                minIndex = i;
            }
        }
        
        long time;
        if(n % x[minIndex] == 0){
            time = n / x[minIndex] +4;
        }else{
            time = n / x[minIndex] +5;
        }
        
        System.out.println(time);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector< vector <ll> > mat;

const ll MOD = 1000000007;
int N;
mat mat1[100];
ll bit[100];
//mat E(N, vec(N));

void make_bit(ll a){
    for(int i=1; i<100; i++){
        bit[i] = a%2LL;
        a /= 2LL;
    }
}

mat mult(mat &a, mat &b){
    mat c=a;
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            ll x=0;
            for(int k=0; k<N; k++){
                x += a[i][k]*b[k][j];
                x %= MOD;
            }
            c[i][j]=x;
        }
    }
    return c;
}

int main(){
    cin >> N; ll K; cin >> K;
    mat m0(N, vec(N));
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            int a;
            cin >> a; m0[i][j]=(ll)a;
        }
    }
    //入力もらう
    //
    mat E(N, vec(N));
    for(int i=0; i<N; i++){
        E[i][i]=1LL;
    }
    mat1[0]=E;
    mat1[1]=m0;
    for(int i=1; i<99; i++){
        mat1[i+1] = mult(mat1[i],mat1[i]);
    }
    make_bit(K);
    mat res=E;
    for(int i=0; i<100; i++){
        if(bit[i]){
            res = mult(res,mat1[i]);
        }
    }
    ll ans=0;
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            ans +=res[i][j];
            ans %=MOD;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
 
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999
#define MOD 1000000007
 
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
 
int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};
 
ll n, m;
 
int main(){
	cin >> n >> m;
	if((n + m) % 2){
		cout << "IMPOSSIBLE" << endl;
	}else{
		cout << (n + m) / 2 << endl;
	}
	return 0;
}

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<int,int> p;

int n,m;
int a[200200],b[200200];
map<ll, ll> mp;

int main(){
  cin >> n >> m;
  rep(i,0,m){
    cin >> a[i] >> b[i];
    if(a[i]==1)mp[b[i]]++;
    if(b[i]==n)mp[a[i]]++;
  }
  string ans = "IMPOSSIBLE";
  rep(i,0, mp.size()){
    if(mp[i]>=2)ans="POSSIBLE";
  }
  cout << ans << endl;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << #x << " = " << x << endl;
#define debugV(x,n) for(int i = 0;i < n;i++) cerr << x[i] << " "; cerr<<endl;
#define rep(i,a,b) for(int i = (int)a;i < (int)b;i++)
#define F first
#define S second
#define pb push_back
typedef pair<int,int> ii;
typedef long long int ll;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-5;



int main(){
	ll a,b, gcd;
	cin>>a>>b;
	gcd=__gcd(a,b);
	cout << a*b/gcd <<endl;
	return 0;
}

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

using namespace std;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using D = double;
using uint = unsigned int;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

const int maxn = 100005;
const ll t18 = 1000'000'000'000'000'000;

const int MOD = 998244353;

inline ll mul(ll a, ll b)
{
	return (a * b) % MOD;
}

inline ll add(ll a, ll b)
{
	a += b;
	if (a >= MOD) a -= MOD;
	return a;
}

inline ll sub(ll a, ll b)
{
	a -= b;
	if (a < 0) a += MOD;
	return a;
}

inline ll powmod(ll a, ll b)
{
	ll ans = 1;
	ll tmp = a;
	while (b)
	{
		if (b & 1) ans = mul(ans, tmp);
		tmp = mul(tmp, tmp);
		b >>= 1;
	}
	return ans;
}

inline int inv(ll a)
{
	return powmod(a, MOD - 2);
}

int v[3][maxn];
vector<int> gr[maxn];
int was[maxn];
int p10[3 * maxn];
int kwas;
int n;
ll a[3][2 * maxn];
ll b[2 * maxn];

void transform(ll *from, ll *to) 
{ 
    if(to - from == 1) 
        return; 
    ll *mid = from + (to - from) / 2; 
    transform(from, mid); 
    transform(mid, to); 
    for(int i = 0; i < mid - from; i++) 
    {
        ll a = *(from + i);
        ll b = *(mid + i);
        *(from + i) = add(a, b);
        *(mid + i) = sub(a, b);
    }
} 

int main()
{
	p10[0] = 1;
	for (int i = 1; i < 3 * maxn; i++) p10[i] = mul(p10[i - 1], t18 % MOD);
	scanf("%d", &n);
	int np2 = n;
	while (np2 & (np2 - 1)) np2++;
	//cout << np2 << endl;
	for (int T = 0; T < 3; T++)
	{
		int m;
		scanf("%d", &m);
		for (int i = 0; i < n; i++) gr[i].clear();
		for (int i = 0; i < m; i++)
		{
			int a, b;
			scanf("%d%d", &a, &b);
			a--, b--;
			gr[a].pb(b);
			gr[b].pb(a);
		}
		for (int i = n - 1; i >= 0; i--)
		{
			sort(all(gr[i]));
			kwas++;
			for (auto t : gr[i]) if (t > i) was[v[T][t]] = kwas;
			v[T][i] = 0;
			while (was[v[T][i]] == kwas) v[T][i]++;
		}
		for (int i = 0; i < n; i++) a[T][v[T][i]] = add(a[T][v[T][i]], p10[i + 1]);
		//for (int i = 0; i < np2; i++) cout << a[T][i] << ' ';
		//cout << endl;
		transform(a[T], a[T] + np2);
		//for (int i = 0; i < np2; i++) cout << a[T][i] << ' ';
		//cout << endl;
	}
	
	for (int i = 0; i < np2; i++)
	{
		b[i] = mul(mul(a[0][i], a[1][i]), a[2][i]);
	}
	transform(b, b + np2);
	//for (int i = 0; i < np2; i++) cout << b[i] << ' ';
	//cout << endl;
	ll dby = inv(np2);
	for (int i = 0; i < np2; i++) b[i] = mul(b[i], dby);
	//for (int i = 0; i < np2; i++) cout << b[i] << ' ';
	//cout << endl;
	cout << b[0] << endl;
	
	
	//int answer = 0;
	//for (int i = 0; i < n; i++)
	//{
		//for (int j = 0; j < n; j++)
		//{
			//for (int k = 0; k < n; k++) if ((v[0][i] ^ v[1][j] ^ v[2][k]) == 0)
			//{
				//answer = add(answer, p10[i + j + k + 3]);
			//}
		//}
	//}
	//cout << answer << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}


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


	int N = getint();

	int A[301][301];
	rep1(i, N) {
		rep1(ii, N) {
			A[i][ii] = getint();
		}
	}

	int shouryaku[301][301] = {};
	rep1(k, N) {
		rep1(i, N) {
			if (k == i) continue;
			rep1(j, i - 1) {
				if (k == j) continue;
				if (A[i][j] > A[i][k] + A[k][j]) {
					printf("-1");
					return 0;
				}
				else if (A[i][j] == A[i][k] + A[k][j]) {
					shouryaku[i][j] = 1;
				}
			}
		}
	}

	ll goukei = 0;
	rep1(i, N) {
		rep1(ii, i - 1) {
			if (shouryaku[i][ii] == 0) goukei += A[i][ii];
		}
	}

	printf("%lld", goukei);

	Would you please return 0;
}

Measured memory_bytes: 1024
N = int(input())
T = [int(input()) for i in range(N)]

def gcd(x, y):
    while y > 0:
        x, y = y, x % y
    return x

for i in range(N - 1):
    T[i + 1] = (T[i] * T[i + 1]) // gcd(T[i], T[i + 1])
    
print(T[-1])

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
#include <chrono>

#define _ << " " <<
#define all(v) v.begin(), v.end()
#define sp(n) fixed << setprecision(n)
#define ff first
#define ss second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const ll mod = 1e9 + 7;
const double eps = DBL_EPSILON;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef LOCAL_DEBUG
	freopen("input.txt", "r", stdin);
#endif
	ll h, n, s = 0;
	cin >> h >> n;
	while (n--) {
		int t;
		cin >> t;
		s += t;
	}
	puts(s >= h ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int n, k;

int main() {
    cin >> n >> k;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];
    ll ans = linf;
    for (int bit = 0; bit < (1 << n); bit++) {
        if (__builtin_popcount(bit) == k) {
            ll cur_max = 0, res = 0;
            rep(i, n) {
                if ((bit >> i) & 1) {
                    cur_max = max(v[i], cur_max + 1);
                    res += cur_max - v[i];
                } else {
                    cur_max = max(cur_max, v[i]);
                }
            }
            ans = min(ans, res);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

void solve() {
    int N;
    cin >> N;
    set<int> S;
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            S.insert(i * j);
        }
    }
    if (S.count(N)) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<queue>
using namespace std;
void read(int &x){
    char ch;bool ok;
    for(ok=0,ch=getchar();!isdigit(ch);ch=getchar())if(ch=='-')ok=1;
    for(x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());if(ok)x=-x;
}
#define rg register
const int maxn=2e5+10;
int n,k,a[maxn],s[maxn*4],ss[maxn*4],ans,tot,sum;
void update(int x){s[x]=max(s[x<<1],s[x<<1|1]),ss[x]=min(ss[x<<1],ss[x<<1|1]);}
void change(int x,int l,int r,int a,int b){
    if(l==r)return s[x]=ss[x]=b,void();int mid=(l+r)>>1;
    if(a<=mid)change(x<<1,l,mid,a,b);
    else change(x<<1|1,mid+1,r,a,b);
    update(x);
}
int get(int x,int l,int r,int a,int b,int f){
    if(a<=l&&b>=r)return f?s[x]:ss[x];
    int mid=(l+r)>>1,ans=f?0:1e9;
    if(a<=mid)f?ans=max(get(x<<1,l,mid,a,b,f),ans):ans=min(get(x<<1,l,mid,a,b,f),ans);
    if(b>mid)f?ans=max(get(x<<1|1,mid+1,r,a,b,f),ans):ans=min(get(x<<1|1,mid+1,r,a,b,f),ans);
    return ans;
}
int main(){
    read(n),read(k);
    for(rg int i=1;i<=n;i++)read(a[i]),change(1,1,n,i,a[i]);
    int l=2,r=k+1;ans=1;
    while(r<=n){
	if(get(1,1,n,l,r,1)==a[r]){
	    if(get(1,1,n,l-1,r-1,0)==a[l-1]){l++,r++;continue;}
	}
	l++,r++;ans++;
    }
    for(rg int i=1;i<=n+1;i++){
	if(a[i]>a[i-1])tot++;
	else sum+=tot>=k?1:0,tot=1;
    }
    printf("%d\n",sum?ans-sum+1:ans);
}


Measured memory_bytes: 7168
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int C[15], A[15][15], now[15];

int main() {
	int N, M, X;
	cin >> N >> M >> X;
	for(int i=0; i<N; ++i){
		cin >> C[i];
		for(int j=0; j<M; ++j) cin >> A[i][j];
	}
	int ans=10000000;
	for(int i=0; i<(1<<N); ++i){
		for(int j=0; j<M; ++j) now[j]=0;
		int sum=0;
		for(int d=0; d<N; ++d){
			if(i&(1<<d)){
				sum += C[d];
				for(int j=0; j<M; ++j){
					now[j] += A[d][j];
				}
			}
		}
		bool flag=true;
		for(int j=0; j<M; ++j){
			flag=flag&&(now[j]>=X);
		}
		if(flag){
			ans=min(ans, sum);
		}
	}
	if(ans==10000000) cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int top,stack[200];
int isEmpty(){
  return top==0;
    }
void push(int x){
  stack[++top]=x;
}
int pop(){
  if(isEmpty())exit(1);
  else
  top--;
  return stack[top+1];
}
int main(){
  int a,b,x;
  char p;
  top=0;
  while((scanf("%c",&p))!=EOF&&p!='\n'){
     if(p=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }
    else if(p=='-'){
      a=pop();
      b=pop();
      push(b-a);
    }
    else if(p=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }
    else if(p<='9'&&'0'<=p){
      x=atoi(&p);
      while(scanf("%c",&p)!=EOF&&p!=' '){
	x*=10;
	x=x+atoi(&p);
      }
      push(x);
    }
  }
  printf("%d\n",pop());
  return 0;
}
      	



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

#define IL inline 
#define int long long
IL int read() {
	char ch = getchar(); int u = 0, f = 1;
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { u = (u << 1) + (u << 3) + ch - 48; ch = getchar(); }
	return u * f; 
}
const int maxn = 2e5 + 10;
int n, k;
int a[maxn];
int DisR[maxn], DisL[maxn];
signed main() {
	n = read(), k = read();
	for (int i = 1; i <= n; ++i) a[i] = read();
	int p = 0;
	memset(DisR, 0x3f, sizeof DisR); memset(DisL, 0x3f, sizeof DisL);
	for (int i = 1; i <= n; ++i) if (a[i] >= 0) {
		p++;
		DisR[p] = a[i];
	}
	p = 0;
	for (int i = n; i >= 1; --i) if (a[i] <= 0) {
		p++;
		DisL[p] = -a[i];
	}	
	int ans = DisL[k];
	ans = min(ans, DisR[k]);
	for (int i = 1; i < k; ++i) {
		if (DisL[i] != 0x3f3f3f3f3f3f3f3f && DisR[k - i] != 0x3f3f3f3f3f3f3f3f) 
			ans = min(ans, DisL[i] * 2ll + DisR[k - i]);
		if (DisL[k - i] != 0x3f3f3f3f3f3f3f3f && DisR[i] != 0x3f3f3f3f3f3f3f3f) 
			ans = min(ans, DisL[k - i] + DisR[i] * 2ll);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4352
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
      	InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
    	Scanner sc = new Scanner(inputStream);
      	PrintWriter out = new PrintWriter(outputStream);
      	Minesweeper ms = new Minesweeper();
      	ms.solve(sc, out);
      	out.close();
    }
  	
  	static class Minesweeper {
    	public void solve(Scanner sc, PrintWriter out) {
        	int X = Integer.parseInt(sc.next());
            int Y = Integer.parseInt(sc.next());
            char S[][] = new char[50][50];

            for(int x = 0; x < X;  x++){
                String s = sc.next();
                for(int y = 0; y < Y; y++){
                    S[x][y] = s.charAt(y);
                }
            }
          //out.println(Arrays.deepToString(S));
          int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
          int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};

          for(int i = 0; i < X;  i++){
                for(int j = 0; j < Y; j++){
                    if(S[i][j] == '.'){
                        int count = 0;
                        for(int k = 0; k < 8; k++){
                            int x = i + dx[k];
                            int y = j + dy[k];
                            if(0 <= x && x < X && 0 <= y && y < Y && S[x][y] == '#'){
                                count++;
                            }
                          S[i][j] = (char)('0' + count);
                        }
                    }
                }
          }
            for(int i = 0; i < X; i++){
                for(int j = 0; j < Y; j++){
                    out.print(S[i][j]);
                }
              out.println();
            }
        }
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 1000000007
#define int long long
#define ll long long
#define EPS 0.00000000000001
#define ld long double
#define inf 20000000
#define N 1000001

vector<int> isPrime(N,1);
vector<int> primes;
void preprocess()
{
    isPrime[1] = 0;
    for(int i = 2;i < N;i++)
    {
        if(isPrime[i])
        {
            for(int j = 2*i;j < N;j+=i)
            {
                isPrime[j] = 0;
            }
            primes.push_back(i);    
        }
    }
}


int32_t main()
{
    IOS;

    preprocess();
    map<int,int> m;
    int a,b;
    cin >> a >> b;
    for(auto it : primes)
    {
        if(a % it == 0)
        {
            m[it]++;
            while(a % it == 0)
                a /= it;
        }
    }
    if(a > 1)
        m[a]++;
    for(auto it : primes)
    {
        if(b % it == 0)
        {
            m[it]++;
            while(b % it == 0)
                b /= it;
        }
    }
    if(b > 1)
        m[b]++;
    int ans = 1;
    for(auto& it : m)
    {
        if(it.second == 2)
            ans++;
    }
    cout << ans;
    return 0;
}
 
 

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// テーブルを作る前処理
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    vector<ll> X(N + 2, 0), Y(N, 0);
    REP(i, N) cin >> X[i + 1] >> Y[i];
    X[N + 1] = C;

    vector<ll> h_X(N + 1, 0), t_X(N + 1, 0);
    REP(i, N) {
        h_X[i + 1] = h_X[i] + Y[i];
        t_X[N - i - 1] = t_X[N - i] + Y[N - i - 1];
    }

    ll ans = 0;
    
    vector<ll> ga(N + 1, 0);
    ll fa = 0;
    for(int i = 0; i <= N; i++) {
        chmax(fa, h_X[i] - X[i]);
        ga[i] = fa;
    }
    for(int i = N; i >= 0; i--) chmax(ans, t_X[i] - (C - X[i + 1]) * 2 + ga[i]);

    vector<ll> gb(N + 1, 0);
    ll fb = 0;
    for(int i = N; i >= 0; i--) {
        chmax(fb, t_X[i] - (C - X[i + 1]));
        gb[i] = fb;
    }
    for(int i = 0; i <= N; i++) chmax(ans, h_X[i] - X[i] * 2 + gb[i]);

    pl(ans)

    return 0;
}


Measured memory_bytes: 4992
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] arg) {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			int M = sc.nextInt();
			int[] v = new int[N];
			for (int i = 0; i < N; ++i) {
				int D = sc.nextInt();
				int P = sc.nextInt();
				v[i] = (P << 16) + D;
			}
			Arrays.sort(v);
			int ans = 0;
			for (int i = N - 1; i >= 0; --i) {
				int D = v[i] & 0xFFFF;
				int P = v[i] >> 16;
				if (M >= D) {
					M -= D;
				} else {
					ans += (D - M) * P;
					M = 0;
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 94080
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10



int main() {
	int K, X; cin >> K >> X;
	vector<int > ans;
	for (int i = X - K + 1; i <= X + K - 1; i++) {
		ans.push_back(i);
	}
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i] << " ";
	}
	cout << endl;



	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb emplace_back
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define deb(x) cout << #x << " - " << x << endl;

using namespace std;

int main()
{
	IOS;
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	ll n,d, k,ans; cin >> n >> k;
	if (n % k == 0) cout << "0";
	else {
	    d = n % k;
		//deb(abs(k - d));
		ans=min(d,abs(k-d));
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int main(void){
    int n,ans=0;
    scanf("%d",&n);
    int p[n];
    for (int i=0; i<n; i++){
        scanf("%d",&p[i]);
    }
    for (int i=0; i<n; i++){
        if (p[i]==i+1){
            ans++;
            int tmp;
            tmp=p[i];
            p[i]=p[i+1];
            p[i+1]=tmp;
        }
    }
    printf("%d\n",ans);
	return 0 ;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)

int main() {
    long long n;
    long long t[5];
    cin >> n;
    long long m = 1e16;
    rep(i, 5) {
        cin >> t[i];
        m = min(m, t[i]);
    }
    long long ans = 4;
    ans += (n+m-1) / m;
    cout << ans << endl;
}

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

#define rep(i, ss, ee) for (int i = ss; i < ee; ++i)
using namespace std;

int d(int n) {
  int cnt = 0;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      cnt++;
      if (i * i != n) cnt++;
    }
  }
  return cnt;
}

int N;
void input() { cin >> N; }

void solve() {
  int ans = 0;
  rep(i, 1, N) { ans += d(N - i); }
  cout << ans << endl;
}

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

Measured memory_bytes: 3668
fun main(args: Array<String>) {
    var tmpLine = readLine()
    var tmps = tmpLine!!.split("\\s+".toRegex())
    var x = tmps[0].toInt() 
    var n = tmps[1].toInt() 

    tmpLine = readLine()
    if (n == 0) {
        println(x) 
        return 
    }

    tmps = tmpLine!!.split("\\s+".toRegex())
    var parray = tmps.map {x - it.toInt()}
    var setP = parray.toSet()
    for (i in 0..100) {
        if (!setP.contains(i)) {
            println("${x - i}")
            return 
        }
        if (!setP.contains(-i)) {
            println("${x + i}")
            return 
        }

    }
}

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

int main(){
  int a;
  cin >> a;
  int count=0;
  if(a/100==1){
    count++;
  }
  if(a%100==10||a%100==11){
      count++;
  }
  if(a%10==1){
    count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

#define int long long

struct Ban {
    int l;
    int r;
    int val;

    Ban() {}

    Ban(int l_, int r_, int val_) {
        l = l_;
        r = r_;
        val = val_;
    }
};

namespace Sp {
    const int LIM = 20; 
    const int N = 2e5 + 7;

    int mn[LIM][N];
    int pw[N];

    void init(vector<int> a) {
        int n = (int)a.size();
        for (int i = 0; i < n; i++) {
            mn[0][i] = a[i]; 
        }
        for (int i = 0; i + 1 < LIM; i++) {
            for (int j = 0; j + (1 << (i + 1)) <= n; j++) {
                mn[i + 1][j] = max(mn[i][j], mn[i][j + (1 << i)]);
            }
        }
        pw[1] = 0;
        for (int i = 2; i < N; i++) {
            pw[i] = pw[i / 2] + 1;
        }
    } 

    int get(int l, int r) {
        r++;
        int p = pw[r - l];
        return min(mn[p][l], mn[p][r - (1 << p)]);
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &t : a) {
        cin >> t;
    }
    vector<int> dl(n);
    for (int i = 0; i < n; i++) {
        if (a[i] > i) {
            cout << -1 << endl;
            return 0;
        }
        dl[i] = i - a[i];
    }
    // for (auto t : dl) {
    //     cerr << t << ' ';
    // }
    // cerr << endl;
    int ans = 0;
    vector<Ban> bans;
    for (int i = 0; i < n; i++) {
        int r = i;
        while (r + 1 < n && a[r] + 1 == a[r + 1]) {
            r++;
        }
        ans += a[r];
        i = r;
        bans.push_back(Ban(r - a[r], r, r - a[r]));
    }
    Sp::init(dl);
    for (auto t : bans) {
        // cerr << t.l + 1 << ' ' << t.r + 1 << ' ' << t.val << endl;
        if (Sp::get(t.l, t.r) > t.val) {
            cout << - 1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}   

Measured memory_bytes: 41068
import java.util.*;

public class Main{

    public static void main(String args[]){

        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        int b = 1;

        for(int i = 0; i < s.length(); i++){
            if(i % 2 == 0){
                if(s.charAt(i) == 'L'){
                    b = 0;
                    break;
                }
            }else{
                if(s.charAt(i) == 'R'){
                    b = 0;
                    break;
                }
            }
        }

        if(b == 1) System.out.println("Yes");
        else System.out.println("No");

    }

}


Measured memory_bytes: 23636
H,W=map(int,input().split())
L = [input() for _ in range(H)]

def grid(x,y):
  field = 0
  for dy in range(-1,2):
    for dx in range(-1,2):
      nx = x + dx
      ny = y + dy
      if 0 <= nx and nx < W and 0 <= ny and ny < H and L[ny][nx] == '#':
        field += 1
  return str(field)
    

for y in range(H):
  ans = ''
  for x in range(W):
    if L[y][x] != '#':
      ans += grid(x,y)
    else:
      ans += '#'
  print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int same[][4] = {
	{1, 2, 4, 3},
	{5, 2, 0, 3},
	{1, 5, 4, 0},
	{1, 0, 4, 5},
	{0, 2, 5, 3},
	{1, 3, 4, 2},
};

int s2i(string s) {
	if(s == "Red")
		return 0;
	if(s == "Yellow")
		return 1;
	if(s == "Blue")
		return 2;
	if(s == "Magenta")
		return 3;
	if(s == "Green")
		return 4;
	if(s == "Cyan")
		return 5;
	return -1;
}

bool eq(vector<int> a, vector<int> b) {
	int indx0, indx1;
	for(int i = 0; i < 6; i++) {
		if(a[i] == 0)
			indx0 = i;
		if(b[i] == 0)
			indx1 = i;
	}

	for(int i = 0; i < 4; i++) {
		bool flg = true;
		for(int j = 0; j < 4; j++) {
			flg &= a[same[indx0][j]] == b[same[indx1][(j + i) % 4]];
		}
		if(flg)
			return true;
	}

	return false;
}

int main() {
	int n;
	while(cin >> n, n) {
		vector<vector<int> > v;
		for(int i = 0; i < n; i++) {
			vector<int> tmp;
			for(int j = 0; j < 6; j++) {
				string s;
				cin >> s;
				tmp.push_back(s2i(s));
			}
			bool flg = true;
			for(int j = 0; j < v.size(); j++) {
				if(eq(v[j], tmp)) {
					flg = false;
				}
			}
			if(flg)
				v.push_back(tmp);
		}

		cout << n - v.size() << endl;
	}
}

Measured memory_bytes: 1244
#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 INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll N, M;
  cin >> N >> M;
  ll A[N];
  REP(i, N) cin >> A[i];
  ll sum = 0;
  map<ll, ll> mp;
  mp[sum]++;
  REP(i, N) {
    sum += A[i];
    mp[sum % M]++;
  }
  ll ans = 0;

  for (auto x : mp) {
    ans += x.second * (x.second - 1) / 2;
  }

  cout << ans;
  return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <typeinfo>
#include <climits>
using namespace std;
#define INIT cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)

int main()
{
    INIT;

    int x, y;
    cin >> x >> y;

    int N[12] = {0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};
    if(N[x - 1] == N[y - 1]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256