akhauriyash/Code-Regression huggingface dataset:
H, W = map(int, input().split())
T = [[] for i in range(H)]
for i in range(H):
    s = list(input())
    T[i] = s


R = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]
for i in range(H):
    for j in range(W):
        if T[i][j] == ".":
            rec = 0
            for dx, dy in R:
                nx, ny = i + dx, j + dy
                if 0 <= nx < H and 0 <= ny < W and T[nx][ny] == "#":
                    rec += 1

            T[i][j] = str(rec)

for i in range(H):
    print("".join(T[i]))


Measured memory_bytes: 3188
//created by pyoxiao on 2020/04/19
#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define CL(a, b) memset(a, b, sizeof(a))
using namespace std;
const int mod = 1e9 + 7;
LL fpow(LL a, LL b, LL p = mod){LL ans = 1; a %= p; while(b) {if(b & 1) ans = ans * a % p; b >>= 1; a = a * a % p;} return ans;}
LL gcd(LL a, LL b){return b == 0 ? a : gcd(b, a % b);}
int n, m;
void solve() {
    scanf("%d %d", &n, &m);
    int tot = 0;
    for(int i = 1; i <= m; i ++) {
        int x;
        scanf("%d", &x);
        tot += x;
    }
    if(tot > n) puts("-1");
    else printf("%d\n", n - tot);
}
int main() {
    int T = 1;
    // scanf("%d", &T);
    while(T --) 
        solve();
    return 0;
}

Measured memory_bytes: 3764
n,m=[int(i) for i in input().split()]
arr = [0]*(n+2)
for I in range(m):
    l,r=[int(i) for i in input().split()]
    arr[l]+=1
    arr[r+1]-=1
for i in range(1,n+2):
    arr[i]+=arr[i-1]
print(arr.count(m))


Measured memory_bytes: 6948
#include <bits/stdc++.h>
using namespace std;
const int N=100005;
int read(){
	int x=0;
	char ch=getchar();
	while (!isdigit(ch))
		ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x;
}
int n,m,q;
int a[N],b[N],c[N];
int Tag[N][11];
void push(int x,int y){
	for (int i=10;i>0;i--)
		Tag[y][i-1]=max(Tag[y][i-1],Tag[x][i]);
}
int main(){
	n=read(),m=read();
	for (int i=1;i<=m;i++)
		a[i]=read(),b[i]=read();
	q=read();
	memset(Tag,0,sizeof Tag);
	for (int i=1;i<=q;i++){
		int v=read(),d=read();
		c[i]=read();
		Tag[v][d]=max(Tag[v][d],i);
	}
	for (int kk=10;kk--;)
		for (int i=1;i<=m;i++){
			push(a[i],b[i]);
			push(b[i],a[i]);
		}
	for (int i=1;i<=n;i++){
		int Max=0;
		for (int j=0;j<=10;j++)
			Max=max(Max,Tag[i][j]);
		cout << c[Max] << endl;
	}
	return 0;
}

Measured memory_bytes: 6144
#include<iostream>
using namespace std;
int main(void){
  int n;
  cin>>n;
  long long a(1);
  for(int i(1);i<=n;i++){
    a*=i;
    if(a>1000000007)a%=1000000007;
  }
  cout<<a<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

int main(){
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    
    int int_query;
    int reversed = 0;
    REP(i,Q){
        cin >> int_query;
        if(int_query==1){
            reversed++;

        }else{
            int f;
            char q;
            cin >> f >> q;
            if((reversed + f)%2==1){
                S = q + S;
            }else{
                S += q;
            }
        }
    }

    if(reversed%2 == 1){
        string S_ = "";
        REP(i,(int)S.size()){
            S_+= S[(int)S.size()-1-i];
        }
        S = S_;
    }

    cout << S << endl;
    return 0;
    
}

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

#define IOS cin.tie(0);ios_base::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vs      vector<string>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>
using Graph  =  vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())
#define END cout<<"\n"

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define SRepS(i,n,m)    for(int i=(int)(n);i*i<=(int)(m);i++)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template<class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define VCIN(x) for(auto &item:x) cin>>item

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?" ":"\n"); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);} //最小公倍数
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
template<class T>bool comp(T a,T b){return abs(a)<abs(b);} //比較関数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int NMAX = 200;
const int INF = 1e9;
const int MOD = 1e9+7;
bool flag;

//----------------------Global-------------------------//

signed main(){
    CIN(N);LCIN(K);
    map<int,ll> mp;
    rep(i,N){
        CIN(a,b);
        mp[a]+=b;
    }
    ll cur=0;
    RepA(mp){
        cur+=item.second;
        if(cur>=K){
            printf("%d\n",item.first);
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 4224
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
a=ii()
b=ii()
c=ii()
d=ii()
e=ii()
k=ii()

if e-a > k:
    print(':(')
else:
    print('Yay!')


Measured memory_bytes: 3060
// https://codeforces.com/blog/entry/64250?#comment-482534
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 2e5 + 9, M = 3e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

ll dp[M][M], pre[M][M];

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n;
  string str;
  cin >> n >> str;
  str = "$$" + str;
  for (int i = 1; i <= n; ++i) {
    dp[1][i] = 1;
    pre[1][i] += pre[1][i-1] + 1;
    pre[1][i] %= MOD;
  }
  for (int i = 2; i <= n; ++i) {
    for (int j = 1; j <= i; ++j) { // Last element // always remmember that greatest element in (i-1) is i 
// So in > we will increment all elements that was present (elements that greater than or equal to my last element)
      int L, R;
      if(str[i] == '>') {
        L = j, R = i - 1;
      } else {
        L = 1, R = j - 1;
      }
      if(L <= R)
        dp[i][j] = ((dp[i][j] % MOD) + ((((pre[i-1][R] - pre[i-1][L-1]) % MOD) + MOD) % MOD)) % MOD;
//      for(; L <= R; ++L)
//        dp[i][j] += dp[i-1][L];
    }
    for (int j = 1; j <= n; ++j)
      pre[i][j] = ((dp[i][j] % MOD) + (pre[i][j-1] % MOD)) % MOD;
  }
  ll ans = 0;
  for (int i = 1; i <= n; ++i) {
    ans += dp[n][i];
    ans %= MOD;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 141568
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a+b>c+d) cout<<"Left";
    else if(a+b<c+d) cout<<"Right";
    else cout<<"Balanced";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

char input[100];
int n;
vector<string> anss;

void calc(string str, int depth) {
  assert(0 <= depth && depth <= 25);
  if (depth == 0) {
    anss.push_back(str);
    return;
  }
  char pc = 'a' + depth;
  char nc = 'a' + depth - 1;
  // cout << str << " " << pc << " " << nc << endl;
  REP(i, n) {
    if (str[i] == pc) { return; }
    if (str[i] == nc) {
      string nstr = str;
      nstr[i] = pc;
      calc(nstr, depth - 1);
    }
  }
  calc(str, depth - 1);
}

int main() {
  while (scanf("%s", input) > 0 && input[0] != '#') {
    string str = input;
    n = str.size();
    anss.clear();
    calc(str, 25);
    sort(anss.begin(), anss.end());
    anss.erase(unique(anss.begin(), anss.end()), anss.end());
    printf("%d\n", (int)anss.size());
    if (anss.size() <= 10) {
      FORIT(it, anss) {
        cout << *it << endl;
      }
    } else {
      REP(i, 5) {
        cout << anss[i] << endl;
      }
      FOR(i, anss.size() - 5, anss.size()) {
        cout << anss[i] << endl;
      }
    }
  }
}

Measured memory_bytes: 2388
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(RALL(x))
#define SUM(x) accumulate(ALL(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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; }

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 n, m;
  cin >> n >> m;

  vector<pii> key;
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    int s = 0;
    rep(j,b) {
      int c;
      cin >> c;
      c--;
      s |= 1<<c;
    }
    key.eb(s,a);
  }

  vi dp(1<<n,INF);
  dp[0] = 0;
  rep(i,1<<n) {
    rep(j,m) {
      int t = i | key[j].fi;
      dp[t] = min(dp[t], dp[i]+key[j].se);
    }
  }

  int ans = (dp.back()!=INF ? dp.back() : -1);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<queue>

using namespace std;

#define MAX 10000
#define INFINITY 300000

int n;
int color[MAX], d[MAX];

vector< pair<int, int> > adj[MAX];

enum Color {
    WHITE,
    GRAY,
    BLACK
};

void dijkstra() {
    priority_queue<pair<int, int> >PQ;
    for (int i = 0; i < n; ++i) {
        color[i] = WHITE;
        d[i] = INFINITY;
    }
    d[0] = 0;
    PQ.push(make_pair(0,0));

    while (!PQ.empty()) {
        pair<int, int> p = PQ.top();
        PQ.pop();
        int target = p.second;

        color[target] = BLACK;
        if (d[target] < p.first * -1) continue;

        for (int j = 0; j < adj[target].size(); ++j) {
            int v = adj[target][j].first;
            if (color[v] != BLACK) {
                if(adj[target][j].second + d[target] < d[v]) {
                    d[v] = d[target] + adj[target][j].second;
                    color[v] = GRAY;
                    PQ.push(make_pair(d[v] * -1, v));
                }
            }
        }
    }

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

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int id, k;
        scanf("%d %d", &id, &k);
        for (int j = 0; j < k; ++j) {
            int t, c;
            scanf("%d %d", &t, &c);
            adj[id].push_back(make_pair(t,c));
        }
    }
    dijkstra();
    return 0;
}

Measured memory_bytes: 7616
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;


int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int turn = 0;
	while (a > 0 && c > 0) {
		if (turn % 2 == 0) {
			c -= b;
		}
		else {
			a -= d;
		}
		turn++;
	}
	if (a <= 0)cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        List<Integer> list = new ArrayList<Integer>();
        list.add(sc.nextInt());
        list.add(sc.nextInt());
        list.add(sc.nextInt());
        List<Integer> arr = quickSort(list);
        System.out.printf("%d %d %d\n", arr.get(0), arr.get(1), arr.get(2));
    }
    static List<Integer> quickSort(List<Integer> list) {
        if (list.size() < 2) {
            return list;
        }
        int p = list.get(0);
        List<Integer> result = new ArrayList<Integer>();
        List<List<Integer>> divided = divide(p, list.subList(1, list.size()));
        result.addAll(quickSort(divided.get(0)));
        result.add(p);
        result.addAll(quickSort(divided.get(1)));
        return result;
    }
    static List<List<Integer>> divide(int p, List<Integer> list) {
        List<Integer> left = new ArrayList<Integer>();
        List<Integer> right = new ArrayList<Integer>();
        List<List<Integer>> result = new ArrayList<List<Integer>>();
        for(int i=0; i<list.size(); i++){
            if (p > list.get(i)) {
                left.add(list.get(i));
            } else {
                right.add(list.get(i));
            }
        }
        result.add(left);
        result.add(right);
        return result;
    }
}


Measured memory_bytes: 26332
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f(z) for(int i=1;i<=z;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define vi vector<int>
#define pb push_back
#define si set<int>
#define mod  1000000007
#define cl(n,m) (n-1)/m  + 1 ;
#define T() int TT; cin>>TT; while(TT--)
#define P pair<int,int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int  N = 2e6 + 5;
int a[N] ;
signed main(){
	int n , k , ans = LLONG_MAX , x =0 ;
	cin >> n>> k;
	f(n) cin >>  a[i] ;
	for( int i = 1 ;i+k-1 <=n ; i++)
	{
		int l = i , r = i+k-1 ;
		int rt = abs( a[l] - a[r]) ;
		int y = min (abs( x - a[l]) + rt , abs(x - a[r]) + rt ) ;
		ans = min ( ans , y) ;
	}
	cout << ans ;
}

Measured memory_bytes: 1024
this_prime_num = [0 for i in range(300001)]

for i in range(300001):
    if i % 7 == 1 or i % 7 == 6:
        this_prime_num[i] = 1
for i in range(2, 300001):
    j = i * 2
    while this_prime_num[i] == 1 and  j < len(this_prime_num):
        #print(j)
        this_prime_num[j] = 0
        j += i


this_primenum_list = []
for i in range(2, len(this_prime_num)):
    if this_prime_num[i]:
        this_primenum_list.append(i)
#print(this_primenum_list[:30])
ans_list = []
while True:
    n = int(input())
    if n == 1:
        break
    i = 0
    ans = [n]
    while this_primenum_list[i] <= n:
        #print(i)
        if n % this_primenum_list[i] == 0:
            ans.append(this_primenum_list[i])
        i += 1
        if i >= len(this_primenum_list):
            break
    ans_list.append(ans)

for i in ans_list:
    print(str(i[0]) + ":", end = "")
    for j in i[1:]:
        print("", end = " ")
        print(j, end = "")
    print()


Measured memory_bytes: 10052
x, y = gets.split.map(&:to_i)

res = 1 << 60

if (x <= y)
  res = [res, y - x].min
end

if (-x <= y)
  res = [res, y + x + 1].min
end

if (x <= -y)
  res = [res, -y - x + 1].min
end

if (-x <= -y)
  res = [res, -y + x + 2].min
end

puts res


Measured memory_bytes: 1788
{-# LANGUAGE
    BangPatterns, MultiWayIf, TupleSections, TypeApplications #-}
{-# OPTIONS_GHC -O2 #-}


import Control.Arrow
import Control.Concurrent
import Control.Monad
import qualified Data.ByteString.Builder as B
import qualified Data.ByteString.Char8 as C
import Data.Complex
import Data.Char
import qualified Data.Heap as H
import Data.Function
import Data.Function.HT
import qualified Data.IntMap.Strict as IM
import qualified Data.IntSet as IS
import Data.List
import Data.Monoid
import Data.Ord
import qualified Data.Sequence as Sq
import Data.Vector.Algorithms.Search
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import Debug.Trace
import System.IO

------------------
-- #   Read   # --
------------------

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine


d :: Int -> Int -> Double
d x y = fromIntegral x / fromIntegral y

data Log = L {oriLen :: Int, seps :: Int} deriving (Eq, Show)

instance Ord Log where
    compare (L o s) (L u t) = (flip compare) (d o s) (d u t) 

addL (L a b) = L a (b+1)
main :: IO ()
main = do
    [n,k] <- r'
    as <- r'
    let s = sum as
    let lenPerSplit = d s k 
    -- print lenPerSplit
    let aas = map (floor.(/ lenPerSplit).fromIntegral) as
    let ini = H.fromList $ map (addL.uncurry L) $ zip as aas
    -- print ini
    -- print $ k - sum aas

    -- print 0

    putStrLn $ show $ toIntL $ H.minimum (solve ini (k - sum aas))

solve h 0 = h
solve h k = let (L a b) = H.minimum h
            in solve (H.insert (L a (b+1)) $ H.deleteMin h) (k-1)

toIntL :: Log -> Int
toIntL (L a b) = ceiling (d a b)

Measured memory_bytes: 72564
S=input()
n=len(S)
if  S== ''.join(list(reversed(S))) and S[0:int((n-1)/2)]== ''.join(list(reversed(S[0:int((n-1)/2)]))) and S[int((n+1)/2):n]==''.join(list(reversed(S[int((n+1)/2):(n)]))):
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <bits/stdc++.h>
#include <map>
#define pb push_back
#define ll long long
using namespace std;
int d;
int n;//lungimea lui k
string k;
const int mod = 1e9+7;
ll a[410];
ll dp[10010][110][3];
int main()
{
    ll num;
    ifstream fin("z.in");
    ofstream fout("z.out");
    cin>>k;
    cin>>d;
    n=k.length();
    dp[0][0][1]=1;
    int zero='0';
    for(int i=0;i<=n-1;i++)
    {
        for(int j=0;j<=9;j++)
        {
            for(int p=0;p<=d-1;p++)
            {
                num=(((p-j)%d)+d)%d;
                dp[i+1][num][0]+=dp[i][p][0];
                if(j<k[i]-'0')
                {
                    dp[i+1][num][0]+=dp[i][p][1];
                }
                else if(j==k[i]-'0')
                {
                    dp[i+1][num][1]+=dp[i][p][1];
                }
                dp[i+1][num][0]%=mod;
                dp[i+1][num][1]%=mod;
            }
        }
    }
    cout<<(dp[n][0][0]+dp[n][0][1]+mod-1)%mod<<endl;
    fin.close();
    fout.close();
    return 0;
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	ll n;
	cin >>  n;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	SORT(a);
	vector<ll> check(1000005,0);
	int flag = 1;
	int nflag = 1;
	vector<ll> done(1000005,0);
	rep(i,n){
		//pairwise じゃないならflag を 0にする
		// a[i]の素因数の倍数を表から消す
		ll now = a[i];
		if(check[now] >= 1) flag = 0;
		for(int j = 2; j * j < now; j++){
			// ルートnまでが素因数かどうか
			if(now % j == 0){
				if(done[j]){
					break;
				} else {
					now /= j;
					done[j] = 1;
					for(int k = j; k < 1000005; k += j){
						check[k] ++;
					}
				}
			}
		}
		// now が1じゃなければ同じことをやる
		if(now != 1){
			if(done[now]) continue;
			else {
				for(int j = now; j < 1000005; j += now){
					check[j] ++;
				}
			}
		}
	}
	// 全部のgcdが1か見ればいい
	ll G = 0;
	rep(i,n){
		G = __gcd(G,a[i]);
	}
	if(flag == 1){
		cout << "pairwise coprime" << endl;
	} else if(G == 1){
		cout << "setwise coprime" << endl;
	} else {
		cout << "not coprime" << endl;
	}
}


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

#define int long long int
#define fi first
#define so second
#define ps push_back
#define ld long double
#define mod 1000000007

signed main()
{
    int l,i,r;
    cin>>l>>r;
    vector<int> v;
    if((r/2019)-(l/2019)>=1) {cout<<0;
    return 0;}
    for(i=l;i<=r;i++) v.ps(i%2019);
    sort(v.begin(),v.end());
    int j,m=INT_MAX;
    for(i=0;i<v.size();i++)
    {
        for(j=i+1;j<v.size();j++)
        {
            m=min(m,((v[i])*(v[j]))%2019);
        }
    }
    cout<<m;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()

int com(int x, int y, int z){
    if(x<y) swap(x,y);
    while(y!=0){
        int r=x%y;
        x=y;
        y=r;
    }
    if(x<z) swap(x,z);
    while(z!=0){
        int r=x%z;
        x=z;
        z=r;
    }
    return x;
}

int main() {
    int n;
    cin >> n;
    long long sum = 0;
    
    for(int i = 1; i<=n; i++){
        for(int j=i; j<=n; j++){
            for(int k=j; k<=n; k++){
                if(i==j&&j==k) sum+=i;
                else if(i!=j && j!=k && k!=i) sum += 6*com(i,j,k);
                else sum += 3*com(i,j,k);
            }
        }
    }
    
    dunk(sum);
    
    return 0;
}



Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <algorithm>
//#define DEBUG
using namespace std;

struct WORD
{
	char s[128];
	int num;
};

bool cmp(const WORD A, const WORD B)
{
	if (A.s[0] < B.s[0]){
		return (1);
	}
	if (A.s[0] > B.s[0]){
		return (0);
	}
	if (A.num < B.num){
		return (0);
	}
	if (A.num > B.num){
		return (1);
	}
	if (strcmp(A.s, B.s) < 0){
		return (1);
	}
	return (0);
}

int main()
{
	WORD word[2048];
	
	int n;
	while (scanf("%d%*c", &n), n){
		int num = 0;
		
		for (int i = 0; i < n; i++){
			char str_line[2048];
			char str_word[2048];
			fgets(str_line, 2048, stdin);
			int p = 0;
			while (sscanf(&str_line[p], "%s", str_word), str_line[p] != '\0'){
				int j;
				for (j = 0; j < num; j++){
					if (strcmp(str_word, word[j].s) == 0){
						word[j].num++;
						break;
					}
				}
				if (j == num){
					strcpy(word[j].s, str_word);
					word[j].num = 1;
					num++;
				}
				
				p += strlen(str_word) + 1;
			}
		}
		
		sort(word, word + num, cmp);
		
		#ifdef DEBUG
		for (int i = 0; i < num; i++){
			printf("%s\n", word[i].s);
		}
		#endif
		
		char k;
		scanf(" %c", &k);
		int f = 0;
		for (int i = 0; i < num && f < 5; i++){
			if (word[i].s[0] == k){
				if (f > 0){
					printf(" ");
				}
				printf("%s", word[i].s);
				f++;
			}
		}
		if (f == 0){
			printf("NA");
		}
		puts("");
	}
	
	return 0;
}

Measured memory_bytes: 1112
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
#define ll long long
#define RG register
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)

inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!('0'<=ch && ch<='9') && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while('0'<=ch && ch<='9')s=s*10+ch-'0',ch=getchar();
	return s*f;
}

const int maxn=1e5+20;

#define int ll

int n,fa[maxn],m;int w[maxn];//x[fa[x]]-x[i]的距离

void init()
{
	n=read();REP(i,1,n)fa[i]=i,w[i]=0;m=read();
}

int fin(int x)
{
	int p=fa[x];
	if(x==fa[x])return x;
	fa[x]=fin(fa[x]);
	w[x]+=w[p];
	return fa[x];
}

void doing()
{
	REP(i,1,m)
	{
		int u=read(),v=read(),W=read();
		int x=fin(u),y=fin(v);
		if(x==y)
		{
			if(w[u]-w[v]!=W){printf("No\n");return;}
		}else
		{
			fa[x]=y;
			w[x]=W-w[u]+w[v];
		}
	}
	puts("Yes");
}
#undef int
int main()
{
	init();
	doing();
	return 0;
}


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

int main() {
  int64_t n,a,b;
  cin >> n >> a >> b;
  
  int64_t group = n / (a + b);
  int64_t x = n % (a + b);
  
  if (x > a) {
   cout << group * a + a;
  }
  else {
   cout << group * a + x;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int t,n,s,f,i;
	while(1)
	{
		scanf("%d", &t);
		if(t==0)
		break;
		scanf("%d", &n);
		for(i=0; i<n; i++)
		{
			scanf("%d %d", &s, &f);
			t-=f-s;
		}
		if(t<=0)
		printf("OK\n");
		else
		printf("%d\n", t);
	}
	
	return 0;
}


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

using namespace std;

int main() {

	int a,b,k;
	cin >> a >> b >> k;

	for (int i = a; i <= b; i++) {
		if (i <= a + k - 1 || i >= b - k + 1) {
			cout << i << " " << (i == b ? "\n" : " ");
		}
	}
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 262144
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int move = a * b + b * c + a * c;
	if (move % 2 == 0) {
		cout << "Tem" << endl;
	}
	else {
		cout << "Hom" << endl;
	}
}


Measured memory_bytes: 3084
# -*- coding: utf-8 -*-


def main():
    n, m = map(int, input().split())
    is_included_1 = set()
    is_included_n = set()

    for i in range(m):
        ai, bi = map(int, input().split())

        if ai == 1:
            is_included_1.add(bi)
        elif bi == 1:
            is_included_1.add(ai)

        if ai == n:
            is_included_n.add(bi)
        elif bi == n:
            is_included_n.add(ai)

    if len(is_included_1 & is_included_n) > 0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')


if __name__ == '__main__':
    main()


Measured memory_bytes: 18956
/*
 * Watch.cpp
 *
 *  Created on: 2014/07/21
 *      Author: WanWan1985
 */
#include <iostream>
#include <math.h> // for fmod
using namespace std;

int main(void) {

	// 入力
	double dTotalSecond;	// 通算秒
	cin >> dTotalSecond;

	// 時
	int iHour = (int)(dTotalSecond / 3600);

	// 分
	double dmod = fmod(dTotalSecond, 3600);
	int iMinute = (int)(dmod / 60);

	// 秒
	int iSecond = (int)fmod(dmod, 60);

	// 出力
	cout << iHour << ":" << iMinute << ":" << iSecond << endl;

	return 0;
}

Measured memory_bytes: 1224
using System;

class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');

		int animalNum = int.Parse(input[0]);
		int footNum = int.Parse(input[1]);
		bool isYes = false;

		for (int x = 0; x <= 25; x++)
		{
			if (isYes) break;
			for(int y = 0;y <= 50; y++) { 
				if (x + y == animalNum 
					&& (x * 4 + y * 2) == footNum)
                {
					Console.WriteLine("Yes");
					isYes = true;
				}
			}
		}

        if (!isYes)
        {
			Console.WriteLine("No");
		}
    }
}

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

#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()

const int INF = 100000000;


int n;
int a[20];
int x[20][20];
int y[20][20];

int kaijo(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}


double dist(int x1, int x2, int y1, int y2){
    return sqrt(pow(x1-x2,2)+pow(y1-y2,2));
}

int main(){
    
    int n;
    cin >> n;
    vector<int> x(n+1),y(n+1);
    for(int i=1; i<=n; i++){
        cin >> x.at(i) >> y.at(i);
    }

    vector<int> order(n);
    for(int i=0; i<n; i++) order.at(i)=i+1;

    double sum=0.0;
    do{
        for(int i=0; i<n-1; i++){
            sum+=dist(x[order[i]],x[order[i+1]],y[order[i]],y[order[i+1]]);
        }
    }while(next_permutation(all(order)));
 
    cout  << fixed << setprecision(10)<< sum/(double)kaijo(n) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<cstdlib>
#include<ctime>

using namespace std;

#define MODULE 1
#define RAND(min,max) (rand()%(max-min+1)+min)
#define LOG(log) cout<<#log<<" : "<<log<<endl;
#define DEBUG() {cout<<"DEBUG "<<num_debug<<endl; num_debug++;}
int num_debug = 0;

int compare_int(void* a, void* b);
class Math {
public :
	template<typename T> static T P(int n, int r) {
		T ans = 1;
		for (int i = 0; i < r; i++) {
			ans *= n - i;
		}
		return ans;
	}
public:
	template<typename T>static T C(int n, int r) {
		T nmr = 1;
		T dnm = 1;
		if (n - r < r)
			r = n - r;
		for (int i = 0; i < r; i++) {
			nmr *= n - i;
			dnm *= r - i;
		}
		return nmr / dnm;
	}
};

int main(void) {
	srand((unsigned)time(NULL));
	
	char c;
	string S, T;
	cin >> S;
	//LOG(S.length());

	cin >> T;

	int dif = 0;
	for (int k = 0; k < S.length(); k++) {
		if (S[k] != T[k]) {
			dif++;
		}
	}
	//DEBUG();

	cout << dif;

	return 0;
}

int compare_int(void* a, void* b) {
	return *(int*)a;
}


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

int main(){
  int a,b,c,d;
  cin >> a >>b>>c>>d;
  if (a+b > c+d)
    cout << "Left" << endl;
  else if (a+b == c+d)
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include<bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(void){
    int n;
    cin >> n;
    bool flag = true;

    if(n%2==0){
        string s1;
        cin >> s1;

        rep(i,n/2){
            if(s1[i]!=s1[i+n/2]){
                flag = false;
            }
        }
    }else{
        flag = false;
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <climits>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

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

	int n;
	n = s[s.size()-1] - '0';

	if(n == 3){
		cout << "bon";
	}else if(n == 0 || n == 1 || n == 6 || n == 8){
		cout << "pon";
	}else{
		cout << "hon";
	}
}


Measured memory_bytes: 3628
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const ceil=(a)=>{return Math.ceil(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};const gcd=(x,y)=>{while(y){[x,y]=[y,x%y]}return x};const sum=(arr)=>{return arr.reduce((a,b)=>a+b);};
const main=()=>{
  let [a,b]=tss(2)
  to(b+a)
}
main()


Measured memory_bytes: 7372
#include <iostream>
#include <cmath>
#include <cstdio>
constexpr double PI = 3.14159265359;
using namespace std;

int main(){
  ios::sync_with_stdio(false);
  double a, b, C;
  cin >> a; cin >> b; cin >> C;
  double h = b * sin(PI * C / 180);
  double S = 0.5 * a * h;
  double hoge = a - b * cos(C * PI / 180);
  double L = a + b + sqrt(h * h + hoge * hoge);
  printf("%1.6f\n" , S);
  printf("%1.6f\n" , L);
  printf("%1.6f\n" , h);
  return 0;
}

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

ll x = 1e9 + 7; 
const int INF = 1001001001;

int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    int ans = INF;
    for (int i = 1; i <= 100; i++) {
        int sum = 0;
        rep(j,n) sum += (x[j]-i)*(x[j]-i);
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
using namespace std;
const int N=1e5+10;
int a[N],n;
int main(){
	cin>>n;
	int su=0;
	for(int i=0;i<n;i++) cin>>a[i],su+=a[i];
	int ans=su,f=0;
	for(int i=0;i<n;i++){
		f+=a[i];
		if(abs(su-2*f)<ans) ans=abs(su-2*f);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int N;
    int a[50];
    int a_max = -2000000;
    int a_min = 2000000;
    int min_index, max_index;
    int count_neg = 0;
    int count_pos = 0;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        
        if(a[i] < a_min){
            a_min = a[i];
            min_index = i;
        }
        if(a[i] > a_max){
            a_max = a[i];
            max_index = i;
        }
        if(a[i] > 0) count_pos++;
        if(a[i] < 0) count_neg++;
    }
    if(a_min < 0 && a_max > 0){
        if(abs(a_max) > abs(a_min)){
            cout << count_neg+N-1 << endl;
            for(int i = 0; i < N ;i++){
                if(a[i] < 0){
                    a[i] = a[i] + a_max;
                    cout << max_index+1 << ' ' << i+1 << endl;
                }
            }
            for(int i = 1; i < N ;i++){
                cout << i << ' ' << i+1 << endl;
            }
        }else{
            cout << count_pos+N-1 << endl;
            for(int i = 0; i < N ;i++){
                if(a[i] > 0){
                    a[i] = a[i] + a_min;
                    cout << min_index+1 << ' ' << i+1 << endl;
                }
            }
            for(int i = N-1; i > 0 ;i--){
                cout << i+1 << ' ' << i << endl;
            }
        }
    }else if(a_max > 0){
        cout << N-1 << endl;
        for(int i = 1; i < N ;i++){
            cout << i << ' ' << i+1 << endl;
        }
    }else{
        cout << N-1 << endl;
        for(int i = N-1; i > 0 ;i--){
            cout << i+1 << ' ' << i << endl;
        }
    }
}

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

int main(void){
  int d,n;cin >> d >> n;
  if(n != 100){
    if(d == 0)cout << n<< endl;
    else if(d == 1)cout << n*100 << endl;
    else if(d == 2)cout << n*10000 << endl;
  } else {
    if(d == 0)cout << 101 << endl;
    else if(d == 1)cout << 100*101 << endl;
    else if(d == 2)cout << 10000*101 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *                # alpha = ascii_lowercase
from random import *                # l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *                # d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter        # d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l,k):
	n = len(l)
	l = sorted(l)
	if(k != 0):
		l = l[:-k]
	# print(l)
	ans = sum(l)
	return ans
	

N,K = map(int, stdin.readline().rstrip().split())
l = list(map(int, stdin.readline().rstrip().split()))
ans = solve(l,K)
print(ans)


Measured memory_bytes: 28424
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#define INF (long)1e9
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<int> vec(n + 1, 0);
	int a, b;
	for(int i = 0; i < m; i++)
	{
		cin >> a >> b;
		vec[a]++;
		vec[b]++;
	}
	for(int i = 1;i <= n; i++)
	{
		cout << vec[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
// template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



int main() {
    string s[] = {"maerd", "remaerd", "esare", "resare"};
    
    string t;
    cin >> t;
    
    for (int i = sz(t) - 1; i >= 0; --i) {
        
        rep(j, 4) {
            int flg = 0;
            rep(k, sz(s[j])) {
                if (s[j][k] != t[i - k]) {
                    flg = 1;
                    break;
                }
                
            }
            
            if (flg == 0) {
                
                i -= sz(s[j]) - 1;
                if (i == 0) {
                    cout << "YES" << endl;
                    return 0;
                }
                break;
                
            }
            if (j == 3) {
                cout << "NO" << endl;
                return 0;
            }
        }
       
    }
    
}


Measured memory_bytes: 512
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;

//素数判定(素数ならtrue)
bool Prime(int prime)
{
	//偶数除く
	if (prime == 2) {
		return true;
	}
	else if (prime % 2 == 0 || prime < 2) {
		return false;
	}

	float Asqrt = sqrtf((float)prime);

	for (int i = 3; i <= Asqrt; i += 2) {
		if (prime%i == 0) {
			return false;
		}
	}

	return true;
}

//1からnまでのnと互いに素の個数
int Euler(int n)
{
	//最初のnを記録  素因数被り防止
	int newprime = 0;
	double ans = (double)n;

	//少数第一位四捨五入
	auto Rounding = [](double ans) {
		if (fmod(ans, 1) >= 0.5) {
			return ans + 0.5F;
		}
		return ans;
	};

	for (int prime = 2;; prime++) {

		if (Prime(n)) {
			//素因数被りでない
			if (newprime != n) {			
				ans *= (1.0 - (1.0 / n));
				newprime = n;
			}
			//値を返す
			return Rounding(ans);
		}

		while (true)
		{
			//素数 かつ 素因数の場合
			if (Prime(prime) && n%prime == 0) {
				n /= prime;

				if (n == 1) {
					//素因数被りでない
					if (newprime != prime) {
						ans *= (1.0 - (1.0 / prime));
						newprime = prime;
					}		
					//値を返す
					return Rounding(ans);
				}

				//素因数被りでない
				if (newprime != prime) {
					ans *= (1.0 - (1.0 / prime));
					newprime = prime;
				}

				//分解可能なら続ける
				continue;
			}			

			//分解不可でbreak;
			break;
		}
	}
}

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

	cout << Euler(n) << endl;

	return 0;
}


Measured memory_bytes: 3216
#include <stack>
#include <string>
#include <iostream>

using namespace std;

bool solve(string S)
{
	stack<char> s;

	for (int i = 0; i < S.size(); i++)
	{
		if (S[i] == '(' || S[i] == '[')
		{
			s.push(S[i]);
		}

		if (S[i] == ')' || S[i] == ']')
		{
			if (s.empty()) { return false; }

			if (s.top() != (S[i] == ')' ? '(' : '['))
			{
				return false;
			}
			
			s.pop();
		}
	}

	return s.empty();
}

int main()
{
	string S;

	while (true)
	{
		S = "";

		while (S == "")
		{
			getline(cin, S);
		}

		if (S == ".") { break; }

		cout << (solve(S) ? "yes" : "no") << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3164
#include<stdio.h>
int main (){
    int K;
    int S[32] = {1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
    scanf("%d",&K);
    printf("%d",S[K-1]);
  return 0;
}


Measured memory_bytes: 128
inp = input().split(" ")
a = int(inp[0])
b = int(inp[1])
 
c = (a - b) % 2 
if c == 0:
  abs_a = abs(a)
  abs_b = abs(b)
 
  m = (max(abs_a, abs_b) - min(abs_a, abs_b)) /2
  ans = max(abs_a, abs_b) - m
  print(int(ans))
else:
  print("IMPOSSIBLE")


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

int main(){
int N,M;
cin>>N>>M;
vector<int>l(M);
vector<int>r(M);
int maxx=0;
int minn=1000000;
for(int i=0;i<M;i++){
   cin>>l[i]>>r[i];
   maxx=max(maxx,l[i]);
   minn=min(minn,r[i]);
}
int a=0;
for(int i=1;i<=N;i++){
   if(maxx<=i&&i<=minn){
      a++;
   }
}
cout<<a<<endl;


return 0;
}


Measured memory_bytes: 4032
// Math = ♥️

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define ordered_set                            \
    tree<ll, null_type, less<ll>, rb_tree_tag, \
         tree_order_statistics_node_update>
#define MAX (ll)(103)
#define INF (ll)(1e18)

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll h, w;
    cin >> h >> w;

    char mat[h][w];
    ll dp[h][w];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> mat[i][j];
            dp[i][j] = INF;
        }
    }

    if (mat[0][0] == '.') {
        dp[0][0] = 0;
    } else {
        dp[0][0] = 1;
    }

    for (int j = 0; j < w; j++) {
        for (int i = 0; i < h; i++) {
            if (i != h - 1) {
                ll add = 0;
                if (mat[i][j] != mat[i + 1][j]) {
                    add++;
                }

                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + add);
            }

            if (j != w - 1) {
                ll add = 0;
                if (mat[i][j] != mat[i][j + 1]) {
                    add++;
                }

                dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + add);
            }
        }
    }

    ll ans = dp[h - 1][w - 1];
    if (ans & 1) {
        ans++;
    }

    ans /= 2;
    cout << ans << "\n";
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

long long mod = 1e9 + 7;

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	long long n, k;
	cin >> n >> k;

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

	int internal_inversions = 0;
	for (int i = 0; i < n - 1; ++i) {
		for (int j = i + 1; j < n; ++j) {
			if (a[i] > a[j]) {
				++internal_inversions;
			}
		}
	}

	int external_inversions = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (a[i] > a[j]) {
				++external_inversions;
			}
		}
	}

	long long x = (k * internal_inversions) % mod;
	long long y = (k * (k - 1) / 2) % mod;
	y = (y * external_inversions) % mod;

	cout << (x + y) % mod << "\n";

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    vector<int> A(S.size());
    A[0] = S[0] - '0';
    int r = 1;
    int m = 2019;
    for (int i = 1; i < S.size(); i++) {
        r = (r*10) % m;
        A[i] = A[i-1] + r*(S[i]-'0');
        A[i] %= m;
    }
    map<int, long long> mp;
    for (int i = 0; i < S.size(); i++) {
        mp[A[i]]++;
    }
    long long ans = mp[0];
    for (auto x: mp) {
        ans += x.second*(x.second-1)/2;
    }
    cout << ans << endl;
}

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

int main(){
    int A, B, K;
    cin >> A >> B >> K;
    vector<int> V;
    for (int i = 1; i <= min(A, B); i++)
    {
        if(A % i == 0 && B % i == 0) V.push_back(i);
    }
    for (int i = 0; i < K - 1; i++) V.pop_back();
    cout << V.back() << "\n";
    return 0;
}

Measured memory_bytes: 256
import sys
n = [int(i) for i in sys.stdin.readline().rstrip()[::-1]]
ans = 0
i = 0
p = [n[i],10 - n[i]]
now = [0,0]
i += 1
ans = min(p[0], p[1] + 1)
for i in range(1,len(n)):
  now[0] = min(p[0] + n[i]%10, p[1] + n[i]%10 + 1)
  now[1] = min(p[0] + 10 - n[i]%10, p[1] + 9 - n[i]%10)
  ans = min(now[0], now[1] + 1)
  p[0],p[1] = now[0],now[1]
print(ans)


Measured memory_bytes: 115280