akhauriyash/Code-Regression huggingface dataset:
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

using ll = long long;

#define fst first
#define snd second
#define mp make_pair
#define mt make_tuple

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)


/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)

/* ---------- container ---------- */

#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) (LL((v).size()))
#define each(itr,v) for(auto (itr):(v))

#define FIND(v, k) (v).find(k) != (v).end()
#define VFIND(v, k) find(ALL(v), k) != (v).end()

#define gsort(b, e) sort(b, e, greater<decltype(*b)>())

/* ----------- debug ---------- */

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
	os << "[";
	for (auto vv : v)
		os << vv << ",";
	return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
	os << "[";
	for (auto vv : v)
		os << vv << ",";
	return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
	return os << "(" << p.fst << "," << p.snd << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
T sq(T a) {
	return a * a;
}

template <typename T>
T gcd(T a, T b) {
	if (a > b) return gcd(b, a);
	return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
	if (n == 0) return 1;
	if (n == 1) return b /* % MOD */;
	if (n % 2 == 0) {
		return mypow(b * b /* % MOD */, n / 2);
	}
	else {
		return mypow(b, n - 1) * b /* % MOD */;
	}
}

ll pcnt(ll b) {
	return __builtin_popcountll(b);
}



// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N, T;
	cin >> N >> T;
	ll t[N];
	REP(i, N) {
		cin >> t[i];
	}
	ll ans = 0;
	REP(i, N - 1) {
		if (t[i + 1] - t[i] >= T) ans += T;
		else ans += t[i + 1] - t[i];
	}
	ans += T;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
a, b = map(int, input().split())
nums = []

for i in range(3):
    i = i + 1
    ans = a * b * i
    if ans % 2 == 0:
        nums.append('No')
    else:
        nums.append('Yes')

if nums.count('Yes'):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 2940
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
using ll = long long;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

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

//動的計画法で役に立つ関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a/g*b;
}

vector<vector<long long> > comb(int n) {
  vector<vector<long long> > v(n + 1,vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

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

    int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;  
    int x_=y1-y2;
    int y_=x2-x1;
    cout << x2+x_ << " " << y2+y_ << " " << x1+x_ << " " << y1+y_<<endl;
  
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stdio.h>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

int main() {
	int n;	cin >> n;
	vector<int>L(n, 0);	rep(i, n) { cin >> L[i]; }
    sort(L.begin(),L.end());
	int ans = 0;
	for (int a = 0; a < n - 2; a++) {
		for (int b = a + 1; b < n-1; b++) {
			for (int c = b + 1; c < n; c++) {
				if ((L[a] < L[b] + L[c]) && (L[b] < L[c] + L[a]) && (L[c] < L[a] + L[b])) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N=int(input())
P=[-1]+[int(i)-1 for i in input().split()]
X=[int(i) for i in input().split()]
Q=[[] for i in range(N)]
for i in range(1,N):
    Q[P[i]].append(i)
dp=[0 for i in range(N)]
INF=10**9+7
def solve(i):
    cur=[INF for j in range(X[i]+1)]
    cur[0]=0
    for j in Q[i]:
        solve(j)
        prv=[k for k in cur]
        cur=[INF for k in range(X[i]+1)]
        for acc in range(len(prv)):
            if prv[acc]<INF:
                if acc+X[j]<=X[i]:
                    cur[acc+X[j]]=min(cur[acc+X[j]],prv[acc]+dp[j])
                if acc+dp[j]<=X[i]:
                    cur[acc+dp[j]]=min(cur[acc+dp[j]],prv[acc]+X[j])
    dp[i]=min(cur)
solve(0)
if dp[0]<INF:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 92508
import itertools
n,d=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]
count=0
for i,j in itertools.product(l,l):
  s = sum([abs(i[k]-j[k])**2 for k in range(d)])
  f = s**0.5 - int(s**0.5)==0
  g =s!=0
  if f and g:
    count+=1
print(int(count/2))

Measured memory_bytes: 3064
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,l = readline() |> split |> parseMap
	k = div(n*(n+1),2)+n*(l-1)
	if l <= -n
		println(k-(l+n-1))
	elseif l < 0
		println(k)
	else
		println(k-l)
	end
end

main()

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

int main() {
  string S;
  cin >> S;
  int n = S.size(), ans = 0;
  for (int i=1; i<n; i++) {
    if (S[i-1] == S[i])
      continue;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N, A, B, PL1, PL2;
  cin >> N >> A >> B;

  PL1=A*N;
  PL2=B;
    
    if(PL1>=PL2){
cout << PL2;
    }else{
    cout << PL1;  
    }
    }


Measured memory_bytes: 256
// 2020-06-22 22:13:49
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  const int INF = 1e9;
  int h, w, k;
  cin >> h >> w >> k;
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  x1--; y1--; x2--; y2--;
  vector<vector<bool> > wall(h, vector<bool>(w, false));
  rep(i, h) {
    string s; cin >> s;
    rep(j, w) {
      if(s[j] == '@') wall[i][j] = true;
    }
  }
  vector<vector<int> > dist(h, vector<int>(w, INF));
  dist[x1][y1] = 0;
  int dx[] = {0, 1, 0, -1};
  int dy[] = {1, 0, -1, 0};
  queue<pair<int, int> > que;
  que.push(make_pair(x1, y1));
  while(!que.empty()) {
    auto a = que.front(); que.pop();
    int cx = a.first;
    int cy = a.second;
    rep(d, 4) REPC(j, 1, k) {
      int nx = cx + dx[d] * j;
      int ny = cy + dy[d] * j;
      int ndist = dist[cx][cy] + 1;
      if(nx < 0 || h <= nx || ny < 0 || w <= ny || wall[nx][ny]) break;
      if(chmin(dist[nx][ny], ndist)) {
        que.push(make_pair(nx, ny));
      } else if(dist[nx][ny] < ndist) {
        break;
      }
    }
  }
  if(dist[x2][y2] == INF) cout << -1 << "\n";
  else cout << dist[x2][y2] << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 11336
n=int(input())
s=list(input())
r=s.count("R")
b=s.count("B")
g=s.count("G")
ans=0
herasu=0
for i in range(n):
  if s[i]=="R":
    ab=s[:i].count("B")
    ag=s[:i].count("G")
    bb=b-ab
    bg=g-ag
    l=ab*bg+ag*bb
    ans+=l
  elif s[i]=="B":
    ar=s[:i].count("R")
    ag=s[:i].count("G")
    br=r-ar
    bg=g-ag
    l=ar*bg+ag*br
    ans+=l
  else:
    ab=s[:i].count("B")
    ar=s[:i].count("R")
    bb=b-ab
    br=r-ar
    l=ab*br+ar*bb
    ans+=l
for i in range(1,n):
  for e in range(i):
    if s[i]!=s[e]:
      if i*2-e<=n-1:
        if s[e]!=s[i*2-e] and s[i]!=s[i*2-e]:
          herasu+=1
print(ans-herasu)

Measured memory_bytes: 69552
import math

MOD = 1000000007

def combination(n, k):
    return math.factorial(n) // math.factorial(k) // math.factorial(n - k)

n, k = map(int, input().split())
for i in range(1, k + 1):
    if i <= n - k + 1:
        print(combination(n - k + 1, i) * combination(k - 1, i - 1) % MOD)
    else:
        print(0)



Measured memory_bytes: 69976
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  long long a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  if (x > y) {
    swap(x, y);
    swap(a, b);
  }
  cout << min({x * a + y * b, 2 * x * c + (y - x) * b, 2 * y * c}) << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

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

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

N =  int(sys.stdin.readline())
list_num = list(map(int, sys.stdin.readline().split()))
cnt_min = 100

for num in list_num:
    num_tmp = num
    cnt_tmp = 0
    # print(num_tmp)
    while(num_tmp % 2 == 0):
        num_tmp = num_tmp // 2
        cnt_tmp += 1
        # print(cnt_tmp)
        #if(num_tmp == 0):
        #    break

    if(cnt_tmp < cnt_min):
        cnt_min = cnt_tmp

    cnt_tmp = 0

print(cnt_min)




Measured memory_bytes: 5076
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

ll x[100010], v[100010], a[100010], b[100010];

int main() {
    ll n, c;
    cin >> n >> c;
    
    x[0] = 0;  v[0] = 0;
    for(int i = 1; i <= n; i++) {
        cin >> x[i] >> v[i];
    } 
    x[n+1] = c;  v[n+1] = 0;
    
    for(int i = 1; i <= n; i++) {
        a[i] = a[i-1] + v[i] - (x[i] - x[i-1]);
    }
    for(int i = 1; i <= n; i++) {
        a[i] = max(a[i], a[i-1]);
    } 
    
    for(int i = n; i >= 1; i--) {
        b[i] = b[i+1] + v[i] - (x[i+1] - x[i]);
    }  
    for(int i = n; i >= 1; i--) {
        b[i] = max(b[i], b[i+1]);
    } 
    
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        ans = max(ans, a[i]);
        ans = max(ans, a[i] - x[i] + b[i+1]);
        ans = max(ans, b[i]);
        ans = max(ans, b[i] - (c - x[i]) + a[i-1]);
    }
    
    cout << ans << endl;
    return 0;
}

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

//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
typedef long long ll;


int main(){
    int L;
    ll K,A,B,x;
    cin >>L;


    vector<vector<ll>> v(L+1,vector<ll> (6,0));
    for(int i=1;i<=L;++i){
        cin >> x;
        v[i][5] = x;

        if (x==0) {
            v[i][0] = v[i-1][0];
            v[i][1] = min(v[i][0], v[i-1][1] + 2);
            v[i][2] = min(v[i][1], v[i-1][2] + 1);
            v[i][3] = min(v[i][2], v[i-1][3] + 2);
            v[i][4] = min(v[i][3], v[i-1][4]);
        }

        else if (x%2==0){
            v[i][0] = v[i-1][0] + x;
            v[i][1] = min(v[i][0] , v[i-1][1]);
            v[i][2] = min(v[i][1] , v[i-1][2] + 1);
            v[i][3] = min(v[i][2] , v[i-1][3]);
            v[i][4] = min(v[i][3] , v[i-1][4] + x);
        }

        else {
            v[i][0] = v[i-1][0] + x;
            v[i][1] = min(v[i][0] , v[i-1][1]+1);
            v[i][2] = min(v[i][1] , v[i-1][2]);
            v[i][3] = min(v[i][2] , v[i-1][3]+1);
            v[i][4] = min(v[i][3] , v[i-1][4] + x);
        }
        
    }

    cout << v[L][4] << endl;
  }


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

using namespace std;
using ll=long long;

#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cint int t;cin>>t;while(t--)
#define rep(i,n) for(ll i=0;i<n;i++)
#define pii pair<int,int>
typedef vector<int> vint;
#define fi first
#define se second

ll mod=1e9+7;

int main(){
    faster;

    ll h;
    cin>>h;

    ll count=0;

    while(h){
        count++;
        h/=2;
    }

    ll ans=0;

    ll tmp=1;

    for(int i=0;i<count;i++){
        ans+=tmp;
        tmp*=2;
    }

    cout<<ans<<endl;
}

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

int DigitSum(int n){
    int sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10; 
    }
    return sum;
}

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    int total = 0;
    rep(i,N+1){
        if(A <= DigitSum(i) && DigitSum(i) <= B){
            total = total + i;
        }
    }
    cout << total << endl; 
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
template <class T>
void chmin(T &a, T b) { a = min(a, b); }
template <class T>
void chmax(T &a, T b) { a = max(a, b); }
void ok() { cerr << "ok" << endl; }
template <class T>
struct Dinic {
    struct edge {
        int to, rev;
        T cap;
        edge(int to, int rev, T cap) : to(to), rev(rev), cap(cap) {}
    };
    int n;
    vector<vector<edge>> G;
    vector<int> lev, itr;
    Dinic(int n) : n(n), G(n), lev(n), itr(n) {}
    void add_edge(int u, int v, T cap) {
        G[u].emplace_back(v, G[v].size(), cap);
        G[v].emplace_back(u, (int)G[u].size() - 1, 0);
    }
    void bfs(int s) {
        lev.assign(n, -1);
        queue<int> q;
        lev[s] = 0;
        q.push(s);
        while (!q.empty()) {
            int i = q.front();
            q.pop();
            for (auto &e : G[i]) {
                if (lev[e.to] == -1 && e.cap > 0) {
                    lev[e.to] = lev[i] + 1;
                    q.push(e.to);
                }
            }
        }
    }
    T dfs(int i, const int &t, T flow) {
        if (i == t) return flow;
        for (; itr[i] < G[i].size(); itr[i]++) {
            edge &e = G[i][itr[i]];
            if (e.cap == 0 || lev[e.to] <= lev[i]) continue;
            int x = dfs(e.to, t, min(flow, e.cap));
            if (x > 0) {
                e.cap -= x;
                G[e.to][e.rev].cap += x;
                return x;
            }
        }
        return 0;
    }
    T maxflow(const int &s, const int &t) {
        T res = 0, inc;
        while (1) {
            bfs(s);
            if (lev[t] == -1) break;
            itr.assign(n, 0);
            while (1) {
                inc = dfs(s, t, INF);
                if (inc == 0) break;
                res += inc;
            }
        }
        return res;
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    Dinic<int> g(n);
    for (int i = 0; i < m; i++) {
        int u, v, c;
        cin >> u >> v >> c;
        g.add_edge(u, v, c);
    }
    cout << g.maxflow(0, n - 1) << '\n';
}



Measured memory_bytes: 3240
#include<iostream>

using namespace std;

int main()
{
	for(;;){
		int h, w;
		int memo[101][101][2][2] = {0};
		
		cin >> w;
		cin >> h;
		
		if(w == 0 && h == 0){
			break;
		}
		
		//0:ツ債カツつゥツづァ  1:ツ可コツつゥツづァ
		//ツつスツづ療ア
		
		memo[0][1][0][0] = 1;
		memo[1][0][1][0] = 1;
		
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				for(int k = 0; k < 2; k++){
					for(int l = 0; l < 2; l++){
						if(k == 0 && l == 0){
							//ツ債カツつゥツづァツ猟按づ陳シツ前ツづ凝按つェツづづづ按つ「
							memo[i+1][j][1][1] += memo[i][j][k][l];		//ツ篠淞湘」ツづ可凝按つェツづゥ
							memo[i][j+1][0][0] += memo[i][j][k][l];		//ツ篠淞右ツづ可陳シツ進
							
							memo[i+1][j][1][1] %= 100000;
							memo[i][j+1][0][0] %= 100000;
						}
						else if(k == 0 && l == 1){
							//ツ債カツつゥツづァツ猟按づ陳シツ前ツづ凝按つェツづづつ「ツづゥ
							memo[i][j+1][0][0] += memo[i][j][k][l];		//ツ右ツづ可陳シツ進
							memo[i][j+1][0][0] %= 100000;
						}
						else if(k == 1 && l == 0){
							//ツ可コツつゥツづァツ猟按づ陳シツ前ツづ凝按つェツづづつ「ツづ按つ「
							memo[i][j+1][0][1] += memo[i][j][k][l];		//ツ右ツづ可凝按つェツづゥ
							memo[i+1][j][1][0] += memo[i][j][k][l];		//ツ湘」ツづ可陳シツ進
							
							memo[i][j+1][0][1] %= 100000;
							memo[i+1][j][1][0] %= 100000;
						}
						else if(k == 1 && l == 1){
							//ツ可コツつゥツづァツ猟按づ陳シツ前ツづ凝按つェツづづつ「ツづゥ
							memo[i+1][j][1][0] += memo[i][j][k][l];		//ツ湘」ツづ可陳シツ進
							memo[i+1][j][1][0] %= 100000;
						}
					}
				}
			}
		}
		int ans = memo[h-1][w-1][0][0] + memo[h-1][w-1][0][1] + memo[h-1][w-1][1][0] + memo[h-1][w-1][1][1];
		
		cout << ans % 100000<< endl;
	}
}

Measured memory_bytes: 0
MOD = 10 ** 9 + 7

L = input()
N = len(L)

dp = [[0] * 2 for _ in range(N + 1)]
dp[0][0] = 1
# dp[idx][未満未定0/未満確定1]

for i, num in enumerate(L, 1):
    if num == '1':
        dp[i][0] = dp[i - 1][0] * 2
        dp[i][0] %= MOD

        dp[i][1] = dp[i - 1][1] * 3 + dp[i - 1][0]
        dp[i][1] %= MOD

    else:
        dp[i][0] = dp[i - 1][0]
        dp[i][0] %= MOD

        dp[i][1] = dp[i - 1][1] * 3
        dp[i][1] %= MOD
ans = (dp[N][0] + dp[N][1]) % MOD
print(ans)


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


priority_queue<pair<ll,ll> >q;



int main()
{

   ll n,i,j,a,b,x,y;

   cin>>n;

   for(i=1;i<=n;i++)
   {
       cin>>a;
       q.push({-a,i});
   }
   ll c=0;


   while(!q.empty())
   {
       a=q.top().second;
       q.pop();
       c++;
       cout<<a;
       if(c!=n)cout<<" ";

   }
   cout<<endl;


  return 0;
}



Measured memory_bytes: 2544
def z_algo(S):
    N = len(S)
    A = [0] * N
    i = 1
    j = 0
    A[0] = l = len(S)
    while i < l:
        while i + j < l and S[j] == S[i + j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l-i > k < j - A[k]:
            A[i + k] = A[k]
            k += 1
        i += k
        j -= k
    return A


def resolve():
    n = int(input())
    s = input()
    ans = 0
    for i in range(n):
        a = z_algo(s[i:])
        for index, j in enumerate(a):
            if j <= index:
                ans = max(ans, j)
    print(ans)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 48732
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
#define rrep(i,n) for(int i = n-1; i >= 0 ; i--)
constexpr auto INF = 2147483647;
typedef long long ll;

  int n, m;
  int DP[20005][256], codebook[16], inp[20005];

int main(){
  while(true){
    cin >> n >> m;
    if(n==0) break;
    rep(i,m) cin >> codebook[i];
    rep(i,n) cin >> inp[i];
    rep(i,n+1)rep(j,256) DP[i][j] = INF;
    DP[0][128] = 0;
    rep(i,n)rep(j,256){
      if(DP[i][j] == INF)continue;
      rep(k,m){
        int next = j+codebook[k];
        next = min(255,max(0,next));
        int diff = (next - inp[i])*(next - inp[i]);
        DP[i+1][next] = min(DP[i+1][next],DP[i][j]+diff);
      }
    }
    int ans = INF;

    rep(i,256) ans = min(ans, DP[n][i]);
    cout << ans << endl;
  }

  return 0;
}


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

int main() {
    int A[10000], i;
    for (i = 0; i < 10000; i++) {
        cin >> A[i];
        if (A[i] == 0) break;
    }
    for (int j = 0; j < i; j++){
        cout << "Case" << " " << j + 1 << ": " << A[j] << endl;
    }
    return 0;
}

Measured memory_bytes: 1200
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        int n = scn.nextInt();
        int m = scn.nextInt();
        int l = scn.nextInt();

        long[][] a = new long[n][m];
        long[][] b = new long[m][l];
        long[][] c = new long[n][l];

        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                a[i][j]=scn.nextInt();
            }
        }

        for(int i=0;i<m;i++){
            for(int j=0;j<l;j++){
                b[i][j]=scn.nextInt();
            }
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<l;j++){
                for(int k=0;k<m;k++){
                    c[i][j]+= (a[i][k] * b[k][j]);
                }
            }
        }
        for(int i=0;i<n;i++){
            System.out.printf("%d",c[i][0]);
            for(int j=1;j<l;j++){
                System.out.printf(" %d",c[i][j]);
            }
            System.out.printf("%n");
        }


        scn.close();


    }


}


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

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

#ifdef LOCAL 
string to_string(char a) { return string(1,a); }
string to_string(bool a) { return a ? "1" : "0"; }
string to_string(const char* a) { return (string)a; }
string to_string(string a) { return a; }
string to_string(vector<bool> v) {
	string s = "["; for(unsigned i=0;i<v.size();i++){ s += ((i>0)?" ":"");
    s += char('0'+v[i]); } 	s += "]"; return s; }
template<class A, class B> string to_string(pair<A,B> p);
template<class T> string to_string(T v) {
	bool b = 1; string s = "["; for (const auto& x: v) {
		if (!b) {s += ", ";} b = 0; s += to_string(x); } s += "]"; return s; }
template<class A, class B> string to_string(pair<A,B> p) {
	return "("+to_string(p.first)+", "+to_string(p.second)+")"; }
void dbgf() { cerr << endl; }
template<class H, class... T> void dbgf(H h, T... t) {
	cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
	dbgf(t...); }
#define dbg(...) cerr << #__VA_ARGS__ << " = ", dbgf(__VA_ARGS__)
#else
#define dbg(...) 0
#endif
#define boolout(x) cout<<(x?"YES":"NO")<<endl;
typedef long long ll;

const int mod = 1e9+7;

ll n;
int mul(ll a, ll b){
    return (ll) a*b%mod;
}
void add_self(int &a, int b){
    a+=b;
    if (a>=mod) {
        a-=mod;
    }
}

struct mat{
    vector<vector<int>> c;
    mat() {
        c.resize(n, vector<int>(n));
    }

    mat operator* (const mat& b){
        mat res = mat();
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                for (int k = 0; k < n; ++k) {
                    add_self(res.c[i][j], mul(c[i][k], b.c[k][j]));
                }
            }
        }
        return res;
    }
};

void solve()
{
    ll k;
    cin >> n >> k;
    mat a;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> a.c[i][j];
        }
    }
    mat id;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            id.c[i][j] = i==j;
        }
    }
    while (k) {
        if (k%2) {
            id = id * a;
        }
        a = a * a;
        k /= 2;
    }
    int sum=0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            add_self(sum, id.c[i][j]);
        }
    }
    cout << sum << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t; // read t. cin knows that t is an int, so it reads it as such.
    for (int i = 1; i <= t; ++i) {
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
import scala.io.StdIn
import scala.annotation.tailrec

object Main{
  def main(args: Array[String]){
    val in = new java.util.Scanner(System.in)
    val a = in.nextInt
    val line = Array.fill(a)(in.nextInt).toList

    val res = sSort(List(), line, 0)
    println(res._1.mkString(" ") + "\n" + res._2)
  }

  @tailrec
  def sSort(sorted: List[Int], unsorted: List[Int], n: Int):(List[Int], Int)={
    if(unsorted.sorted == unsorted) ((sorted ::: unsorted), n)
    else if(unsorted.indexWhere(_ == unsorted.min) == 0) sSort(sorted :+ unsorted.head, unsorted.tail, n)
    else {
      val pos = unsorted.indexWhere(_ == unsorted.min)
      val swapped = unsorted.updated(0, unsorted(pos)).updated(pos, unsorted.head)

      sSort(sorted :+ unsorted.min, swapped.tail, n+1)
    }
  }
}

Measured memory_bytes: 46832
n,k = map(int,input().split())
asum = 0
for i in range(1,n+1):
    a = i
    if a < k:
        for j in range(1,21):
            if a < k:
                a *= 2
            if a >= k:
                break
        asum += (1/n)*((1/2)**j)
    else:
        asum += (1/n)
print(asum)

Measured memory_bytes: 9388
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'

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

    string str, cur = "", prev = "";
    cin >> str;
    int Count = 1;
    prev += str[0];
    for (int i = 1; i < str.size(); i++) {
        cur += str[i];
        if (cur == prev) {
            if (i + 1 == str.size())
                break;
            cur += str[++i];
        }
        prev = cur, cur = "";
        Count++;
    }
    cout << Count << endl;
}


Measured memory_bytes: 720
//author:emre yazicioglu
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fori(a,b,c) for(ll a = b;a < ll(c);a++)
#define pb push_back
const int N = 2e5 + 7;
ll n,m,ans,a[N],b[N],arr[N];
ll dp[N][13];
ll mod = 1e9 + 7;
int main(){
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);

	string str;
	cin >> str;
	n = str.size();
	dp[0][0] = 1;
	fori(i,0,n){
		fori(k,0,13){
			ll a = ((str[i] == '?') ? 0 : str[i] - '0');
			ll b = ((str[i] == '?') ? 9 : str[i] - '0');	
			fori(j,a,b+1)
					dp[i+1][(k*10 + j) % 13] = (dp[i+1][(k*10 + j) % 13] + dp[i][k]) % mod;     
		}
	}
	cout << dp[n][5];
}

Measured memory_bytes: 10752
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
f = [int("".join(ls()), 2) for _ in range(n)]      
p = [list(li()) for _ in range(n)]

# bit全探索
ans = -float("inf")
for bit in range(1, 1<<10):
    profit = 0
    
    for i,fi in enumerate(f):
        both = 0
        
        for mask in range(10):
            if bit&(1<<mask) and fi&(1<<mask):
                both += 1
        
        profit += p[i][both]
    
    ans = max(ans, profit)
    
print(ans)

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

#define ll long long
#define fi first
#define sec second

ll n,m,k,a,b,x,x2,y,y2,sol=0,cnt,sad,koliko;
char c;
string s;
vector <ll> V;
ll dp[200010][3][2];

int main()
{
    cin >> n;
    for (int i=0;i<n;i++){
        cin >> x;
        V.push_back(x);
    }

    dp[0][0][0]=-LLONG_MAX;
    dp[0][1][0]=0;
    dp[0][2][0]=-LLONG_MAX;
    dp[0][0][1]=V[0];
    dp[0][1][1]=-LLONG_MAX;
    dp[0][2][1]=-LLONG_MAX;

    for (int i=1;i<n;i++){
        x=V[i];

        dp[i][0][0]=dp[i-1][0][1];
        dp[i][1][0]=max(dp[i-1][1][1],dp[i-1][0][0]);
        dp[i][2][0]=max(dp[i-1][2][1],dp[i-1][1][0]);
        dp[i][0][1]=dp[i-1][0][0]+x;
        dp[i][1][1]=dp[i-1][1][0]+x;
        dp[i][2][1]=dp[i-1][2][0]+x;
    }

    if (n%2==0){
        cout << max(dp[n-1][0][0], dp[n-1][1][1]);
    }
    else{
        cout << max(dp[n-1][1][0], dp[n-1][2][1]);
    }
}


Measured memory_bytes: 14252
#include <cstdio>
#define MAXN 100005
char s[MAXN];
int a[27];
int main() {
	scanf("%s", s);
	for(int i = 0; s[i] != '\0'; i++) 
		a[s[i]-'a'] ++;
	for(int i = 0; i < 26; i++) 
		if(!a[i]) {
			printf("%c", i + 'a');
			return 0;
		}
	
	printf("None\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <iomanip>
#include <math.h>

using namespace std;

long long mod = 1000000007;

long long binpow(long long x, long long k)
{
    if (k == 0)
    {
        return 1LL;
    }
    long long temp = binpow(x, k / 2);
    if (k % 2 == 1)
    {
        return (((temp * temp) % mod) * x) % mod;
    }
    else
    {
        return (temp * temp) % mod;
    }
}

long long modular_inverse(long long x)
{
    return binpow(x, mod - 2);
}

long long binomial(long long n, long long k)
{
    long long rez = 1;
    for (long long i = n - k + 1; i <= n; i++)
    {
        rez *= i;
        rez %= mod;
    }
    long long temp = 1;
    for (long long i = 1; i <= k; i++)
    {
        temp *= i;
        temp %= mod;
    }
    rez *= modular_inverse(temp);
    rez %= mod;
    return rez;
}

int main()
{
    long long n, k, rez = 0;
    cin >> n >> k;
    long long c = 1, h = 1;
    for (int i = 0; i <= min(n, k); i++)
    {
        rez += c * h;
        c *= (n - i);
        c %= mod;
        c *= modular_inverse(i + 1);
        c %= mod;
        h *= (n - i - 1);
        h %= mod;
        h *= modular_inverse(i + 1);
        h %= mod;
        // rez += binomial(n, i) * binomial(n - 1, n - i - 1);
        rez %= mod;
    }
    cout << (rez + mod) % mod << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) FOR(i, 0, n)
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define FILLINF(a) memset(a, 0x3f, sizeof(a))
#define POW(n) (1LL << (n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i, a, b) ((a) <= (i) && (i) <= (b))
using namespace std;
template <typename T> inline bool CHMIN(T& a, T b) { if(a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a, T b) { if(a < b) { a = b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(begin(a), end(a)); }
template <typename T> inline void REV(T& a) { reverse(begin(a), end(a)); }
template <typename T> inline void UNI(T& a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }
template <typename S, typename T> inline T LB(S& v, T a) { return *lower_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int LBP(S& v, T a) { return lower_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> inline T UB(S& v, T a) { return *upper_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int UBP(S& v, T a) { return upper_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> ostream& operator << (ostream& os, const pair<S, T>& p) { os << p.first << " " << p.second; return os; }
template <typename S, typename T> istream& operator >> (istream& is, pair<S, T>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator >> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<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 double PI = 3.14159265358979323846;
const double EPS = 1e-10;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const lint MOD = 1000000007;

void _main() {
    int A, B, N;
    cin >> A >> B >> N;
    cout << (A * min(N, (B - 1))) / B << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("in.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("out.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>  
using namespace std;  
typedef long long ll; 
typedef long double ld; 
const int INF = 0x3f3f3f3f;  
const int N = 200000 + 5;

int main()
{
	int n;
	cin >> n;
	ll sum = 0;
	for(int i = 1; i <= n; i++){
		if(i % 3 != 0 && i % 5 != 0)
			sum += i;
	}
	cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    S = input()
    k = input_int()
    one = 0
    for s in S:
        if s == "1":
            one += 1
        else:
            tmp = s
            break
    if k <= one:
        print(1)
    else:
        print(tmp)

    return


if __name__ == "__main__":
    main()


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

const unsigned LIMIT = 50050;

int main(){
	bool table[ LIMIT ] = { false };
	table[ 2 ] = true;
	for ( int i = 3; i < LIMIT; i += 2 ){
		table[ i ] = true;
	}
	for ( int i = 3; i < LIMIT; i += 2 ){
		if ( !table[ i ] ) continue;
		for ( int j = i + i; j < LIMIT; j += i ){
			table[ j ] = false;
		}
	}

	int n;
	while ( cin >> n ){
		for ( int i = n-1; i > 1; --i ){
			if ( table[ i ] ){
				cout << i;
				break;
			}
		}
		cout << " ";
		for ( int i = n+1; i < LIMIT; ++i ){
			if ( table[ i ] ){
				cout << i;
				break;
			}
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int n;

int main() {
  while (cin >> n, n) {
    int id;
    double diff = double(1<<30);
    for (int i = 0; i < n; ++i) {
      int _id, h, w;
      cin >> _id >> h >> w;
      double height = h / 100.0;
      double bmi = w / height / height;
      if (diff > abs(22.0 - bmi)) {
        id = _id;
        diff = abs(22.0 - bmi);
      }
    }
    cout << id << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>

using namespace std;

int main(){
    int n,m,i,j;
    int array[100][100];
    int vec[100],output=0;

    cin>>n>>m;
    for(i=0; i<n; i++){
        for(j=0; j<m; j++){
            cin>>array[i][j];
        }
    }
    for(i=0; i<m; i++){
        cin>>vec[i];
    }
    for(i=0; i<n; i++){
        for(j=0; j<m; j++){
            output+=array[i][j]*vec[j];
        }
        cout<<output<<endl;
        output=0;
    }
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
int n,a[(int)1e5+5],ans = 0;
int main(){
	cin>>n;
	for(int i =0;i<n;i++){
		cin>>a[i];
	}
	int temp = 0;
	for(int i = 0;i<n;i++){
		if(a[i]==i+1){
//			cout<<a[i]<<" sama "<<ans<<" "<<temp<<"\n";
			temp++;
		}else{
//			cout<<a[i]<<" tidak sama "<<ans<<" "<<temp<<"\n";
			// ini rumus nya didapat dari observasi 1 2 3 4 5 -> 3 swap (1,2) (3,4) (4,5)
			// / 2 dan % 2
			if(temp) ans += max(1,temp/2 + (temp%2));
			temp = 0;
		}
	}
	if(temp) ans += max(1,temp/2 + (temp%2));
	cout<<ans<<"\n";
	return 0;
}

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

int solve(int n, vector<int> & dims){
    int dp[100][101] = {{0}};
    for (int span = 2; span != n + 1; ++span){
        for (int first = 0; first + span != n + 1; ++first){
            for (int last = first + span; last != n + 1; ++last){
                int record = 2000000000;
                for (int mid = first + 1; mid != last; ++mid){
                    record = min(record, dp[first][mid] + dp[mid][last] + dims[first] * dims[last] * dims[mid]);
                }
                dp[first][last] = record;
            }
        }
    }
    return dp[0][n];
}


int main()
{
    int n = 0;
    cin >> n;
    vector<int> dims(n + 1);
    int r = 0;
    int c = 0;
    for (int i = 0; i != n; ++i){
        cin >> r >> c;
        dims[i] = r;
    }
    dims[n] = c;
    cout << solve(n, dims) << endl;
    return 0;
}

Measured memory_bytes: 3152
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var AB = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var sum = AB.Sum();
            Console.WriteLine(sum >= 10 ? "error" : sum.ToString());
        }
    }
}


Measured memory_bytes: 28088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
struct p{
    ll x, y;
    p(){}
    p(ll x, ll y):x(x), y(y){}
};

ll dist(p a, p b){
    return max(abs(a.x - b.x), abs(a.y - b.y));
}

int main() {
    ll N;
    cin >> N;
    vc<p> P(N);
    rep(i, N) cin >> P[i].x >> P[i].y;

    vc<p> Q(N);
    rep(i, N) Q[i].x = P[i].x - P[i].y, Q[i].y = P[i].x + P[i].y;

    ll ans = 0;

    sort(all(Q), [](p a, p b) { return a.x < b.x; });

    p xmin = Q.front(), xmax = Q.back();
    chmax(ans, dist(xmax, xmin));

    sort(all(Q), [](p a, p b) { return a.y < b.y; });

    p ymin = Q.front(), ymax = Q.back();
    chmax(ans, dist(ymax, ymin));

    cout << ans << endl;
}

Measured memory_bytes: 9540
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	int N;
	cin >> N;
	for (int i = 1; i < 55000; i++)
	{
		if (floor(i * 1.08) == N)
		{
			cout << i << endl;
			return (0);
		}
	}
	puts(":(");
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int S;
  cin>>S;
  int ans1=S/100;
  int ans2=S%100;
  if(1<=ans1&&ans1<=12){
    if(1<=ans2&&ans2<=12) cout<<"AMBIGUOUS"<<endl;
    else cout<<"MMYY"<<endl;
  }else{
    if(1<=ans2&&ans2<=12) cout<<"YYMM"<<endl;
    else cout<<"NA"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <iomanip>
#include <utility>
#include <bitset>
#include <set>
#include <map>
#include <ios>
#include <cstdlib>
using namespace std;
int main() {
    int N; cin >> N;
    vector<int> W(N);
    int S=0;
    for(int i = 0; i < N; i++) {
        cin >> W[i];
        S+=W[i];
    }
    int S1 = 0;
    int ans = 1000000;
    for (int i=0;i<N;i++){
        S1 += W[i];
        ans = min(abs(S1-(S-S1)),ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean[][] a = new boolean[4][13];
		
		for(int im = 0; im < 4; im++) {
			for(int in = 0; in < 13; in++) {
				a[im][in] = true;
			}
		}
		
		for(int i = 0; i < n; i++){
			String mark = sc.next();
			int num = sc.nextInt() - 1;
			int mar;
			
			if(mark.equals("S")) {
				mar = 0;
			}else if(mark.equals("H")) {
				mar = 1;
			}else if(mark.equals("C")) {
				mar = 2;
			}else {
				mar = 3;
			}
			
			a[mar][num] = false;
		}
		
		for(int im = 0; im < 4; im++) {
			for(int in = 0; in < 13; in++) {
				if(a[im][in]) {
					if(im == 0) {
						System.out.print("S");
					}else if(im == 1) {
						System.out.print("H");
					}else if(im == 2) {
						System.out.print("C");
					}else {
						System.out.print("D");
					}
					
					System.out.println(" " + (in+1));
				}
			}
		}
		
	}
}



Measured memory_bytes: 26248
#include<stdio.h>
int main()
{
  int i,j,n,u,k,v;
  int A[1000][1000];
  scanf("%d",&n);
  for(i=1;i<=n;i++)
    {
      for(j=1;j<=n;j++)
	{
	  A[i][j]=0;
	}
    }
  for(i=1;i<=n;i++)
    {
      scanf("%d%d",&u,&k);
      for(j=1;j<=k;j++)
	{
	  scanf("%d",&v);
	  A[u][v]=1;
	}
    }
  
  for(i=1;i<=n;i++)
    {
      for(j=1;j<=n;j++)
	{
	  if(j!=1)
	    {
	    printf(" ");
	    }
	  printf("%d",A[i][j]);
	}
      printf("\n");
    }
    
  return 0;
}



Measured memory_bytes: 2128
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=1000005,mod=998244353;
int c[N],f[N],inv[N],n,a[N],lim=1000000,ans;

inline int fix(int x){
	return x>=mod?x-mod:x;
}

int main(){
	read(n);
	rep(i,1,n){
		read(a[i]);
		c[a[i]]=fix(c[a[i]]+a[i]);
	}
	inv[1]=1;
	rep(i,2,lim)inv[i]=(ll)(mod-mod/i)*inv[mod%i]%mod;
	per(i,lim,1){
		f[i]=0;
		for(int j=i;j<=lim;j+=i)
			f[i]=fix(f[i]+c[j]);
		f[i]=(ll)f[i]*f[i]%mod;
		for(int j=i+i;j<=lim;j+=i)
			f[i]=fix(f[i]+mod-f[j]);
		//if(f[i])printf("%d %d\n",i,f[i]);
		ans=(ans+(ll)f[i]*inv[i])%mod;
	}
	rep(i,1,n)ans=fix(ans+mod-a[i]);
	ans=(ll)ans*inv[2]%mod;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 14592
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/STACK: 20000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vec vector
#define all(x) x.begin(), x.end()
#define deb(x) cerr<<#x<<" = "<<x<<endl
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){IOS;
    ll r,g;cin>>r>>g;
    ll a,b,c;cin>>a>>b>>c;
    vec<ll> aa(a); for(auto&it:aa)cin>>it; sort(all(aa)); reverse(all(aa)); while(aa.size()!=r) aa.pop_back();
    vec<ll> bb(b); for(auto&it:bb)cin>>it; sort(all(bb)); reverse(all(bb)); while(bb.size()!=g) bb.pop_back();
    vec<ll> x;
    for(auto&it:aa) x.push_back(it); for(auto&it:bb)x.push_back(it); sort(all(x));


    vec<ll> y(c); for(auto&it:y)cin>>it; sort(all(y)); reverse(all(y));
    for(int i=0;i<min(x.size(),y.size());i++){
        if(x[i]<y[i]) x[i]=y[i];
    }
    ll res = 0;
    for(auto&it:x)res+=it;
    cout<<res<<endl;
}

Measured memory_bytes: 4080