akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

char buf[100][100];
char ans[100][100];

int main(void) {
  int nRow, nCol;
  scanf("%d%d", &nRow, &nCol);
  REP(i, nRow) {
    scanf("%s", buf[i]);
  }
  REP(i, nRow) {
    REP(j, nCol) {
      if(buf[i][j] == '#') {
        ans[i][j] = '#';
        continue;
      }
      int cnt = 0;
      REP(ii, 3) {
        REP(jj, 3) {
          int ni = i-1 + ii;
          int nj = j-1 + jj;
          if(ni >= 0 && nj >= 0 && ni < nRow && nj < nCol) {
            if(buf[ni][nj] == '#') {
              ++cnt;
            }
          }
        }
      }
      ans[i][j] = '0' + cnt;
    }
  }
  REP(i, nRow) {
    puts(ans[i]);
  }
  return 0;
}


Measured memory_bytes: 128
while True:
   try:
      A = input().split()
      B = input().split()
      h = 0
      b = 0
      for i in range(4):
         for j in range(4):
            if A[i] == B[j]:
               if i == j:
                  h += 1
               else:
                  b += 1
            else:
               pass
      print(h, b)
   except EOFError:
      break


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

int main() {
  int N,Y,A=-1,B=-1,C=-1;
  cin>>N>>Y;
  Y/=1000;
  for(int i=0;i<=N;i++){
    for(int j=0;j+i<=N;j++){
      if(i*5+j*10+N-i-j==Y){
        A=j,B=i,C=N-i-j;
      }
    }
  }
  cout<<A<<" "<<B<<" "<<C<<endl;
}

Measured memory_bytes: 3604
import Control.Applicative ((<$>))

main = do
  [k, s] <- fmap read <$> words <$> getLine :: IO [Int]
  putStrLn . show . length $ [[x,y,z] | x <- [0..k], y <- [0..k], z <- [s-x-y], 0 <= z, z <= k]


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
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 mod= 1e9 + 7;

int N, M;  //N頂点M辺
vector<int> visited;
vector<vector<int>> G;
int dp[100100];
int rec(int v) {
    if (dp[v] != -1) return dp[v]; // 既に更新済み

    int res = 0;
    for (auto nv : G[v]) {
        chmax(res, rec(nv) + 1);
    }
    return dp[v] = res; // メモしながらリターン
}

int main() {
    cin >> N >> M;
    G = vector<vector<int>>(N); // サイズを確保する
    visited = vector<int>(N, 0); // 全頂点を「未訪問」に初期化
    for(int i=0; i<M; i++){
        int a, b;
        cin >> a >> b;
        // 頂点番号を 0-indexed とする
        a--;
        b--;
        G[a].push_back(b);
    }
    rep(i,N)dp[i]=-1;
    // 例えば頂点番号 0 からDFSを始める時
    int ans=0;
    rep(i,N)chmax(ans,rec(i));
    cout << ans << endl;
}

Measured memory_bytes: 8576
#C
N = int(input())
S = str(input())
sign = ('.', '#') #w,b
if N == 1:
    print(0)
else:
    c1, c2 = 0, S.count('.')
    ans = c1 + c2
    for i in range(0,N):
        if S[i] == '#':
            c1 += 1
        else:
            c2 -= 1
        tmp = c1 + c2
        ans = min(ans, tmp)
    print(ans)


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

int main() {
  double H, W, A, B;
  cin >> H >> W >> A >> B;
  for (int i=0; i<B; i++){
      for (int j=0; j<A; j++) cout << 0;
      for (int j=A; j<W; j++) cout << 1;
      cout << endl;

  }
  for (int i=B; i<H; i++){
      for (int j=0; j<A; j++) cout << 1;
      for (int j=A; j<W; j++) cout << 0;
      cout << endl;
  }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;

int main() {
  int k, t;
  cin >> k >> t;
  vector<int> a(t);
  for (int i = 0; i < t; i ++) cin >> a[i];
  sort(a.begin(), a.end());
  cout << max(0, a.back() - 1 - (k - a.back())) << endl;
}


Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = [list(map(lambda x: int(x)-1, input().split())) for _ in range(n)]
N = n*(n-1)//2
index = [[0]*(n) for i in range(n)]
ind = 0
from collections import defaultdict
ns = defaultdict(list)
for i in range(n):
    for j in range(i+1,n):
        index[i][j] = ind
        index[j][i] = ind
        ind += 1
for i in range(n):
    for j in range(n-2):
        u = index[i][a[i][j]]
        v = index[i][a[i][j+1]]
        ns[u].append(v)
### サイクル検出 cycle detection
seen = [False] * N
done = [False] * N
vals = [None] * N
def dfs(u):
    s = [u]
    while s:
        u = s.pop()
        if u>=0:
            # 非負の値: 新しい頂点に到達
            seen[u] = True
            s.append(~u)
            for v in ns[u]:
                if done[v]:
                    continue
                elif not seen[v]:
                    s.append(v)
                else:
                    # 閉路発見
                    return True
        else:
            u = ~u
            done[u] = True
            # ここに帰りがけ処理を書く
            val = 0
            for v in ns[u]:
                # uの子はすべて処理が終わっている
                val = max(val, vals[v]+1)
            vals[u] = val
    return False

ans = -float("inf")
for u in range(N):
    if seen[u]:
        continue
    pos = dfs(u)
    if pos:
        print(-1)
        break
else:
    print(max(vals)+1)

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)
const ll MOD = 1e9+7;

ll powmod(ll a, ll n){
    ll rez = 1;
    while(n){
        if (n&1)
            rez = rez * a % MOD;
        a = a * a % MOD;
        n /= 2;
    }
    return rez;
}

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

vector<ll> fact;
ll comb(int n, int k){
    return fact[n] * inv(fact[k] * fact[n-k]%MOD) % MOD;
}

ll popcnt(ll i){
    ll rez = 0;
    while(i){
        if (i&1)
            rez++;
        i /=2;
    }
    return rez;
}

ll bf(ll s){
    ll sol = 0;
    FOR(i, s+1){
        sol += powmod(2, popcnt(i));
        sol %= MOD;
    }
    cout << sol << '\n';
}
#include <string.h>
int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\stdout", "w", stdout);
    }

    //bf(12);

    string s;
    cin >> s;
    //bf(131);
    int n = s.length();

    ll sol = 0;
    ll two = 1;
    ll i3 = inv(3);
    ll three = powmod(3, n-1);
    FOR(i, n){
        if (s[i]=='1') {
            sol += two * three % MOD;
            sol %= MOD;
            two = two * 2 % MOD;
        }
        three = three * i3 % MOD;
    }
    sol += two;
    sol %= MOD;
    cout << sol << '\n';

    //if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int l;
    cin>>l;
    int a[20], b[20];
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    int curr = 19;
    while(l>1){
        if(l%2!= 0){
            l--;
            a[curr]=1;
        }
        b[curr] = 2;
        l/=2;
        curr--;
    }
    //cout<<curr<<endl;
    for(int i=1; i<=curr; i++){
        b[i] = 1;
    }
    int sum = 0;
    for(int i=0; i<20; i++){
        sum+=a[i];
        sum+=b[i];
    }
    cout<<"20 "<<sum<<endl;
    ll val = 1e6;
    ll some =1;
    for(int i=19; i>0; i--){
    	//cout<<b[i]<<endl;
    	if(b[i]==2){
    		cout<<i<<" "<<i+1<<" "<<some<<endl;
    		cout<<i<<" "<<i+1<<" "<<0<<endl;
    		some<<=1;
    	}else{
    		cout<<i<<" "<<i+1<<" "<<0<<endl;
    	}
    }
    //int some1 = 2;
    for(int i=1; i<20; i++){
        if(a[i]){
            cout<<1<<" "<<i+1<<" "<<some<<endl;
            some+= (1<<(19-i));
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

string s;
cin >> s;
int len = s.size();
char c1 = 'h', c2 = 'i';
bool tr = false;
if(len%2==1){
cout << "No\n";
return 0;
}

for(int i = 0;i<len;i+=2){
   if(s[i]==c1 && s[i+1]==c2){
     tr = true;
   }
   else{
      break;
   }
}

if(tr)cout << "Yes\n";
else cout << "No\n";
return 0;

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
	public static void main(String[] args) throws IOException {

		//Scanner scan = new Scanner(System.in);

		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);

		String inputData = br.readLine();
		String data[] = inputData.split(" ");
		Deque<String> deque = new ArrayDeque<>();

		Pattern p = Pattern.compile("^[0-9]*$");
		for (int i = 0; i < data.length ; i++) {
			Matcher m = p.matcher(data[i]);
			if(m.find()) {
				deque.push(data[i]);
			}else {
				String b = deque.pop();
				String a = deque.pop();
				String r = "";
				switch(data[i]){
				case "+":
					r = String.valueOf(Integer.parseInt(a) + Integer.parseInt(b));
					break;
				case "-":
					r = String.valueOf(Integer.parseInt(a) - Integer.parseInt(b));
					break;
				case "*":
					r = String.valueOf(Integer.parseInt(a) * Integer.parseInt(b));
					break;
				}
				deque.push(r);
			}
		}
		System.out.println(deque.pop());
	}

}



Measured memory_bytes: 24632
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(){

    double x1,y1,x2,y2,x3,y3,x4,y4;
    while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4)!=EOF){
        if(x1==x2){
            if(y3==y4)puts("YES");
            else puts("NO");
        }
        else if(x3==x4){
            if(y1==y2)puts("YES");
            else puts("NO");
        }
        else{
            double d=(y2-y1)/(x2-x1),d_=(y4-y3)/(x4-x3);
            d_*=-1;
            d_=1/d_;
            if(d-d_<=0.000001&&d-d_>=-0.000001)puts("YES");
            else puts("NO");
        }
    }
    return 0;
}

Measured memory_bytes: 1040
s = input()
end = "ABC"
while True:
  if s == end:
    print("Yes")
    break
  s = s.replace(end, "X")
  if ("X" not in s) or sum((c in s for c in end)) != 2:
    print("No")
    break
  for c in end:
    if c not in s:
      s = s.replace("X", c)
      break


Measured memory_bytes: 5580
// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>

const int INF = 1e15 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

const int N = 2e3 + 5;
int ans[N];
vector <int> adj[N];
int lvl[N], vis[N];

void bfs(int root) {
    queue <int> q;
    q.push(root);
    vis[root] = 1;
    while(!q.empty()) {
        root = q.front();
        ans[lvl[root]]++;
        q.pop();
        for(auto i : adj[root]) {
            if(!vis[i]) {
                lvl[i] = lvl[root] + 1;
                q.push(i);
                vis[i] = 1;
            }
        }
    }
}

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

    // #ifndef ONLINE_JUDGE
    //   freopen("input.txt", "r", stdin);
    //  // freopen("output.txt", "w", stdout);
    // #endif
    int n, x, y;
    cin >> n >> x >> y;
    if((abs(x-y)) != 1) {
        adj[x].pb(y); adj[y].pb(x);
    }
    for(int i = 2; i <= n; i++) {
        adj[i].pb(i-1); adj[i-1].pb(i);
    }
    for(int i = 1; i <= n; i++) {
        memset(lvl,0,sizeof(lvl));
        memset(vis,0,sizeof(vis));
        bfs(i);
    }
    for(int i = 1; i < n; i++) {
       cout << ans[i]/2 << '\n';
    }
  
}



Measured memory_bytes: 384
n, m = list(map(int, input().split()))
a = []
for i in range(n):
  a.append([int(j) for j in input().split()])
b = []
for i in range(m):
  b.append(int(input()))
for i in range(n):
  s = 0
  for j in range(m):
    s += a[i][j] * b[j]
  print(s)


Measured memory_bytes: 6008
#include <bits/stdc++.h>
    using namespace std ;
     
    #define pb(n) push_back(n)
    #define fi first
    #define se second
    #define all(r) begin(r),end(r)
    #define vmax(ary) *max_element(all(ary))
    #define vmin(ary) *min_element(all(ary))
    #define debug(x) cout<<#x<<": "<<x<<endl
    #define fcout(n) cout<<fixed<<setprecision((n))
    #define scout(n) cout<<setw(n)
    #define vary(type,name,size,init) vector< type> name(size,init)
    #define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
    #define mp(a,b) make_pair(a,b)
     
    #define rep(i,n) for(int i = 0; i < (int)(n);++i)
    #define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
    #define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
    #define repa(n,array) for(auto &n :(array))
     
    using ll = long long;
    using pii = pair<int,int> ;
    using pll = pair<ll,ll> ;
     
    template<typename T>
    void O(T t){
      cout << t << endl;
    }
     
    const ll mod = 1e9+7;
    constexpr ll inf = ((1<<30)-1)*2+1 ;
    constexpr double PI = acos(-1.0) ;
    double eps = 1e-10 ;
    const int dy[] = {-1,0,1,0,1,-1,1,-1};
    const int dx[] = {0,-1,0,1,1,-1,-1,1};
     
    inline bool value(int x,int y,int w,int h){
      return (x >= 0 && x < w && y >= 0 && y < h);
    }
     
    int main(){
      cin.tie(0);
      ios::sync_with_stdio(false);
      ll n;
      string s,t;
      cin >> s;
      ll c = inf;
      if(s.size()==1) c =0;
      else{
      rep(i,s.size()){
        ll tmp = 0;
        t = s;
        rep(_,100){
          set<char> m;
          string k;
          rep(j,t.size()-1){
            if(t[j] == s[i] || t[j+1] == s[i]){
              k+= s[i];
            }
            else{
              k+=t[j];
            }
          }
          rep(j,k.size()){
            m.insert(k[j]);
          }
          if(m.size() == 1) break;
          ++tmp;
          t = k;
        }
        c = min(c,tmp);
      }
}
      if(c != 0) ++c;
      std::cout << c << std::endl;
     
      return 0;
    }

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int x[26]={'X','Y','Z','A','B','C','D','E','F','G','H','I','J','K',
  'L','M','N','O','P','Q','R','S','T','U','V','W'};
  char input[1001];
  int i;
  scanf("%s",input);
  char c=input[0];
  for(i=0; (c!='\0'); i++){
  printf("%c", x[(c-65)]);
  c = input[i+1];
  }
putchar('\n');     
return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
int main(){

    int t;
    cin>>t;

    string str;
    cin>>str;

    if(t%2!=0)cout<<"No"<<endl;
    else{
        string str1="",str2="";
        for(int i=0;i<t/2;i++){
            str1+=str[i];
        }
        for(int i=t/2;i<t;i++){
            str2+=str[i];
        }
        if(str1==str2){
            cout<<"Yes"<<endl;
        }
        else cout<<"No"<<endl;
    }

}


Measured memory_bytes: 256
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()

flag = 0
hidari = sc
migi = sc
ue = sr
shita = sr
for i in range(N):
  if S[i] == 'L':
    hidari -= 1
  if S[i] == 'R':
    migi += 1
  if S[i] == 'U':
    ue -= 1
  if S[i] == 'D':
    shita += 1
  if hidari == 0 or migi == W+1 or ue == 0 or shita == H+1 :
    flag = 1
  
  if T[i] == 'R' and hidari != W:
    hidari += 1
  if T[i] == 'L' and migi != 1:
    migi -= 1
  if T[i] == 'D' and ue != H:
    ue += 1
  if T[i] == 'U' and shita != 1:
    shita -= 1

if flag :
  print("NO")
else :
  print("YES")
  

Measured memory_bytes: 3788
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
std::pair<int64_t, int64_t> pos[200000];

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    in >> N;
    for (size_t i = 0; i < N; i++)
    {
        in >> pos[i].first >> pos[i].second;
    }
    std::sort(pos, pos + N);
    auto nowleft = pos[0].first + pos[0].second;
    int error = 0;
    for (size_t i = 1; i < N; i++)
    {
        auto right = pos[i].first - pos[i].second;
        if (right < nowleft) {
            ++error;
            auto tmp = pos[i].first + pos[i].second;
            nowleft = std::min(tmp, nowleft);
        }
        else{
            nowleft = pos[i].first + pos[i].second;
        }
    }
    out << N - error << endl;
    return 0;
}
#endif


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

int main(){
    int n;
    cin >> n;
    char s;
    int p=0, w=0, g=0, y=0;
    for(int i=0; i<n; i++){
        cin >> s;
        if(s=='P'){
            p++;
        }
        else if(s=='W'){
            w++;
        }
        else if(s=='G'){
            g++;
        }
        else{
            y++;
        }
    }

    if(p!=0&&w!=0&&g!=0&&y!=0){
        cout << "Four" << endl;
    }
    else{
        cout << "Three" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    int maxv=100000;
    vector<int> vec;
    vec.push_back(1);
    int d=6;
    while(d<=maxv){
        vec.push_back(d);
        d*=6;
    }
    d=9;
    while(d<=maxv){
        vec.push_back(d);
        d*=9;
    }
    sort(all(vec));
    debug(vec.size());
    INT(n);
    int ans=0,index;
    vector<int> dp(n+1,100000000);
    dp[0]=0;
    for(int i=1;i<=n;i++){
        rep(j,12){
            if(i-vec[j]>=0)dp[i]=min(dp[i],dp[i-vec[j]]+1);
        }
    }
    out(dp[n]);
}

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

int n;
int arr[100005][3];
int dp[100005][3];

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin>>arr[i][j];
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j =0;j<3;j++)
		{
			dp[i][0] = max(dp[i-1][1],dp[i-1][2])+arr[i][0];
			dp[i][1] = max(dp[i-1][0],dp[i-1][2])+arr[i][1];
			dp[i][2] = max(dp[i-1][0],dp[i-1][1])+arr[i][2];
		}
	}
	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
}

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

int main() {
    map<string, int> m;
    m["MON"] = 1;
    m["TUE"] = 2;
    m["WED"] = 3;
    m["THU"] = 4;
    m["FRI"] = 5;
    m["SAT"] = 6;
    m["SUN"] = 7;

    string s;
    cin >> s;

    int ans = m["SUN"] - m[s];
    if(ans == 0) ans = 7;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int n, i, j, score, min = 10000000;
  int a[n];
  
  scanf("%d", &n);
  for( i = 0; i < n; i++ ){
    scanf("%d", &a[i]);
  }
  
  for( i = 1; i < 100; i++ ){
    score = 0;
    for( j = 0; j < n; j++ ){
      score += (a[j] - i) * (a[j] - i);
    }
    if( min > score ){
      min = score;
    }
    
  }
  
  printf("%d\n", min);
  
  return 0;
}

Measured memory_bytes: 128
#define DEBUG(...) cerr << __VA_ARGS__ << endl;

#ifndef CDEBUG
#undef DEBUG
#define DEBUG(...) ((void)0);
#define NDEBUG
#endif

#define ran(i, a, b) for (auto i = (a); i < (b); i++)

#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
const int mod = 1e9 + 7;
#ifndef M_PI
const double M_PI = acos(-1.0);
#endif

int main() {
  cin.sync_with_stdio(false);
  string s;
  cin>>s;
  for(int i=0; i<s.size(); ++i){
    if(s[i] == '?')
      s[i] = 'D';
  }
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 3784
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

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

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

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

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1<<25;
// const ll INF = 1LL<<50;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------


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

  int A, B, C, D;
  cin >> A >> B >> C >> D;
  cout << max(A * B, C * D) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const ll mod=(1e9)+7;
int n,a,b;
ll ans;
ll ksm(ll x,ll y) {
	ll res=1;
	while (y) {
		if (y&1) res=res*x%mod;
		x=x*x%mod; y>>=1;
	} return res;
}
ll C(ll x,ll y) {
	ll res=1;
	for (int i=x;i>=x-y+1;i--)
		res=res*i%mod;
	for (int i=1;i<=y;i++)
		res=res*ksm(i,mod-2)%mod;
	return res;
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(a); read(b);
	ans=ksm(2,n)-1-C(n,a)-C(n,b);
	printf("%lld\n",(ans%mod+mod)%mod);
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
  int n,q;
 
  while(1) {
  cin >> n >> q;
  if(n == 0 && q == 0) break;
    int a[101]={};
  for(int i=0;i<n;i++){
    int m;
    cin >> m;
    for(int j=0;j<m;j++){
      int d;
      cin >> d;
      a[d]++;
    }
  }
  int ans=0;
  int cnt = 0;
  for(int i=0;i<101;i++){
    if(a[i] > cnt && a[i] >= q) ans = i,cnt = a[i];
    }
  cout << ans <<endl;
  }
 
  return 0;
}

Measured memory_bytes: 3092
N=int(input())
S=input()
R=S.count('R')
G=S.count('G')
B=S.count('B')
ans=R*G*B
for d in range(N):
    if 2*d>=N:
        break
    for i in range(N):
        if i+2*d>=N:
            break
        if S[i]!=S[i+d] and S[i+d]!=S[i+2*d] and S[i]!=S[i+2*d]:
            ans-=1
print(ans)

Measured memory_bytes: 68040
import java.util.*;

public class Main {
	public static void main(String[] $$) throws Exception {
		Scanner $ = new Scanner(System.in);
		int N = $.nextInt(), pmax = 100;
		String[] P = new String [N];
		for (int i = 0; i < N; i++){
			P[i] = $.next() + "_" + (pmax * 11 - $.nextInt()) + "_" + (i + 1);
		}
		Arrays.sort(P);
		for (int i = 0; i < N; i++){
			System.out.println(P[i].split("_")[2]);
		}
		/*
		6 khabarovsk 20 moscow 10 kazan 50 kazan 35 moscow 60 khabarovsk 40 -> 3 4 6 1 5 2
		10 yakutsk 10 yakutsk 20 yakutsk 30 yakutsk 40 yakutsk 50 yakutsk 60 yakutsk 70 yakutsk 80 yakutsk 90 yakutsk 100 -> 10 9 8 7 6 5 4 3 2 1
		*/
	}
}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, par[N], sz[N];
struct  poi{
    int x, y, idx;
}   p[N];
struct  edge    {
    int x, y, w;
}   e;
vector<edge>    E, MST;
int ans = 0;
bool cmp1(poi A,poi B)  {
    return A.x < B.x;
}
bool cmp2(poi A,poi B)  {
    return A.y < B.y;
}
bool cmp(edge e1,edge e2)   {
    return  e1.w < e2.w;
}
int findSet(int x)  {
    return  par[x] == x ? x : par[x] = findSet(par[x]);
}
void unionSet(int x,int y) {
    int a = findSet(x);
    int b = findSet(y);
    if(a == b)  return;
    if(sz[a] < sz[b])   swap(a,b);
    par[b] = a; sz[a] += sz[b];
}
int main()  {
    cin >> n;
    for(int i = 1 ; i <= n ; ++i)   {
        cin >> p[i].x >> p[i].y;
        p[i].idx = i;
        par[i] = i;
        sz[i] = 1;
    }
    sort(p + 1,p + 1 + n,cmp1);
    for(int i = 1 ; i < n ; ++i)   {
        e.x = p[i].idx;
        e.y = p[i + 1].idx;
        e.w = p[i + 1].x - p[i].x;
        E.push_back(e);
    }
    sort(p + 1,p + 1 + n,cmp2);
    for(int i = 1 ; i < n ; ++i)   {
        e.x = p[i].idx;
        e.y = p[i + 1].idx;
        e.w = p[i + 1].y - p[i].y;
        E.push_back(e);
    }
    sort(E.begin(),E.end(),cmp);
    int i = 0;
    while(MST.size() < n - 1)   {
        int x = E[i].x, y = E[i].y, W = E[i].w;
        ++i;
        if(findSet(x) == findSet(y))    continue;
        ans += W;   MST.push_back(E[i - 1]);
        unionSet(x,y);
    }
    cout << ans << endl;
}


Measured memory_bytes: 7920
S = list(input())
N = int(input())
normalFlag = True
front = []
back = []
for _ in range(N):
    q = list(map(str,input().split()))
    if q[0] == '1':
        normalFlag = not normalFlag
    else:
        if q[1] == '1':
            if normalFlag:
                front.append(q[2])
            else:
                back.append(q[2])
        else:
            if normalFlag:
                back.append(q[2])
            else:
                front.append(q[2])

if normalFlag:
    front.reverse()
    ans = front+S+back
else:
    back.reverse()
    S.reverse()
    ans = back+S+front
print(''.join(map(str,ans)))

Measured memory_bytes: 134152
#!/usr/bin/env python3
import sys


def solve(N: int):
    a = 0
    for x in range(1,N+1):
        if (x % 3 != 0)&(x % 5 != 0):
            a += x
    print(a)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9188
#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>;

int ans = 0;

void permutation(vector<unordered_set<int>>& adj, vector<int>& perm, vector<bool>& used, int level)
{
    if (level == perm.size()) {
        if (perm[0] != 0) return;
        int u = 0;
        for (int i = 1; i < perm.size(); i++) {
            if (!adj[u].count(perm[i])) return;
            u = perm[i];
        }
        ans++;
        return;
    }

    for (int i = 0; i < used.size(); i++) {
        if (used[i] == false) {
            used[i] = true;
            perm[level] = i;
            permutation(adj, perm, used, level + 1);
            used[i] = false;
        }
    }
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<unordered_set<int>> adj;
    adj.assign(n, unordered_set<int>());
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        adj[a - 1].insert(b - 1);
        adj[b - 1].insert(a - 1);
    }

    vector<int> perm(n, 0);
    vector<bool> choice(n, false);
    permutation(adj, perm, choice, 0);
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while (sc.hasNext()) {
      int[] pai = new int[10];
      boolean[] agarihai = new boolean[10];
      String str = sc.next();
      for (int i = 0; i < 13; i++) {
        pai[(int)(str.charAt(i)-'0')]++;
      }
      for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
          int[] temp = new int[10];
          for (int k = 0; k < 10; k++) {
            temp[k] = pai[k];
          }
          temp[i]++;
          if (temp[i] > 4) {
            break;
          }
          else if (temp[j] < 2) {
            continue;
          }
          else {
            int counter = 0;
            temp[j] -= 2;
            for (int k = 1; k < 10; ) {
              if (temp[k] >= 3) {
                temp[k] -= 3;
                counter++;
                continue;
              }
              else if (k < 8 && temp[k] > 0 && temp[k+1] > 0 && temp[k+2] > 0) {
                temp[k]--;
                temp[k+1]--;
                temp[k+2]--;
                counter++;
                continue;
              }
              k++;
            }
            if (counter == 4) {
              agarihai[i] = true;
              break;
            }
          }
        }
      }
      str = "";
      for (int i = 1; i < 10; i++) {
        if (agarihai[i]) {
          str += i + " ";
        }
      }
      System.out.println(str.equals("") ? 0 : str.trim());
    }
  }
}

Measured memory_bytes: 12000
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    int ans = (a + b) % 24;
    cout << ans << endl;

    return 0;
}


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

int main() {
  int N,M,l=0;
  cin >> N >> M;
  vector<vector<int>>h(N,vector<int>(2));
  for(int i=0;i<N;i++)
    cin >> h.at(i).at(0);
  for(int i=0;i<M;i++){
    int A, B;
    cin >> A >> B;
    h.at(B-1).at(1)=max(h.at(A-1).at(0),h.at(B-1).at(1));
    h.at(A-1).at(1)=max(h.at(B-1).at(0),h.at(A-1).at(1));
  }
  for(int i=0;i<N;i++){
    if(h.at(i).at(0)>h.at(i).at(1))
      l++;
  }
  cout << l << endl;
}

Measured memory_bytes: 8792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int n = NK[0];
            var dislike = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int ans = 0;

            for (int i = n; i < 100000; i++)
            {
                for (int j = 0; j < i.ToString().Length; j++)
                {
                    if (dislike.Contains(int.Parse(i.ToString()[j].ToString()))) break;
                    else if (j == i.ToString().Length - 1) ans = i;
                }
                if (ans > 0) break;
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 17348
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  int k;
  cin >> k;
  sort(a, a+3);
  while (k--) {
    a[2] *= 2;
  }
  dump(a[0]+a[1]+a[2]);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int N, K, R, S, P; cin >> N >> K >> R >> S >> P;
    string T; cin >> T;
    long long ans = 0;
    for(int i = 0; i < N; i++){
        int prev = i - K;
        if(prev >= 0){
            if(T[prev] == T[i]) {
                T[i] = 'a';
                continue;
            }
        }
        if(T[i] == 'r') ans += P;
        else if(T[i] == 's') ans += R;
        else if(T[i] == 'p') ans += S;
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
// alt + tab to switch tab


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 


using namespace __gnu_pbds;
using namespace std ;


typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

#define ll long long
#define int long long
#define pb push_back
#define p1da(a,n) for(int i=0;i<(n);i++) cout << *( (a) + (i)) << " "; cout<<endl;
#define g1da(a,n) for(int i=0;i<(n);i++) cin >> *( (a) + (i)) ;
#define fi first
#define se second
#define f(i,n) for(int (i)=0;(i)<(n) ; (i)++ )
#define fr(i,s,e) for(int (i)=s;(i)<=(e) ; (i)++ )
#define pii pair <int,int>
#define p2da(a,row,col) f(i,row){f(j,col) cout << a[(i)][(j)]  <<" "; cout<<endl; }
#define g2da(a,row,col) f(i,row) f(j,col) cin >> a[(i)][(j)] ;
#define p1dv(v) f(i,v.size())cout<<v[(i)]<<" "; cout << endl ;
#define g1dv(v) f(i,v.size()) cin>>v[i] ;
#define debug(...)       dbg (#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void dbg(const char* n, Arg1&& arg1) {cerr << n << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void dbg(const char* n, Arg1&& arg1, Args&&... args) {const char*c = strchr(n + 1, ','); cerr.write(n, c - n) << " : " << arg1 << " || "; dbg(c + 1, args...);}
clock_t startTime ; void mainstart(); void mainEnd() ;
#define mod  998244353
#define N 50001



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


  int tt = 1 ;
  //cin >> tt ;
  //   https://www.guru99.com/node-js-tutorial.html

// int tc = 1 ;

  while (tt--)
  {
   // cout << "ok\n";
    int n ;
    cin >> n  ;
    int a[n] ;
    fr(i, 0, n - 2)cin >> a[i];
    vector <int> c(n + 1, 0);
    fr(i, 0, n - 2) c[a[i]]++ ;
    fr(i, 1, n) cout << c[i] << endl ;

  }

  mainEnd() ;
  return 0 ;
}

void mainstart()
{
#ifndef ONLINE_JUDGE
  freopen("Input.txt", "r", stdin) ;
  freopen("Output.txt", "w", stdout) ;
#endif
  startTime = clock() ;
}
void mainEnd()
{
  fclose (stdout);
  fclose (stdin);
  clock_t endTime = clock() ;
  cerr << "Run Time is : " << (float)( endTime - startTime ) / CLOCKS_PER_SEC << endl ;
}

Measured memory_bytes: 6424
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll h,w,n;
  cin>>h>>w>>n;
  vll a(n),b(n);
  rep(i,n){
    cin>>a[i]>>b[i];
  }
  map<pll,ll> p;
  rep(z,n){
    for(int i=a[z]-1;i<a[z]+2;i++){
      for(int j=b[z]-1;j<b[z]+2;j++){
        if(i>1&&i<h&&j>1&&j<w){
          p[pll(i,j)]++;
        }
      }
    }
  }
  vll aa(10,0);
  for(auto pp:p){
    aa[pp.S]++;
  }
  COUT((h-2)*(w-2)-sz(p));
  for(int i=1;i<=9;i++){
    COUT(aa[i]);
  }
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio (false);
	cout << fixed;
	cout.precision(10);
	if(fopen("joke.in", "r")){
		freopen ("joke.in","r",stdin);
		freopen ("joke.out","w",stdout);
	}

	int n, m;
	cin >> n >> m;

	vector<pair<int, int>> v(n);

	for(int i = 0; i < n; ++i){
		int a, b;
		cin >> a >> b;
		v[i] = {a, b};
	}
	sort(v.begin(), v.end());

	priority_queue<int, vector<int>, less<int>> pq;
	int ptr = 0;
	int res = 0;
	for(int i = 1; i <= m; ++i){
		while(ptr < n && v[ptr].first <= i){
			pq.push(v[ptr].second);
			ptr++;
		}
		if(!pq.empty()){
			res += pq.top();
			pq.pop();
		}
	}

	cout << res;
    return 0;
}


Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
int h,w,x1,y11,x2,y2,d[1001][1001];
string s[1001];
deque<pair<int,int> > q; 
bool vis[1001][1001];
int main(){
	cin>>h>>w;
	cin>>x1>>y11;
	cin>>x2>>y2;
	for(int i=0;i<h;i++){
		cin>>s[i];
	}
	for (int i=0;i<h;i++){
        fill(vis[i],vis[i]+w,false);
        fill(d[i],d[i]+w,1000000);
    }
	q.push_front(make_pair(x1-1,y11-1));
	vis[x1-1][y11-1]=true;
	d[x1-1][y11-1]=0;
	while(!q.empty()){
		pair<int,int> node=q.front();
		q.pop_front();
		int x=node.first;
		int y=node.second;
		if(x==x2-1 && y==y2-1){
			cout<<d[x][y]<<endl;
			return 0;
		}
		for(int i=-2;i<=2;i++)
			for(int j=-2;j<=2;j++){
				if(x+i<h && y+j<w && x+i>=0 && y+j>=0 && !vis[x+i][y+j] && s[x+i][y+j]=='.'){
					if(abs(i)+abs(j)<2){
							q.push_front(make_pair(x+i,y+j));
							vis[x+i][y+j]=true;
							d[x+i][y+j]=d[x][y];
					}
					else{
						if(d[x+i][y+j]>d[x][y]+1){
							q.push_back(make_pair(x+i,y+j));
							d[x+i][y+j]=d[x][y]+1;
						}
					}
				}
			}
	}
	cout<<-1<<endl;
	return 0;
} 

Measured memory_bytes: 10512
using System;
using System.Linq;
class Program
{
	public static void Main()
	{
		long data_num = long.Parse(Console.ReadLine());
		string[] line = Console.ReadLine().Split(' ');
		long[] data = new long[data_num];
		for (int i = 0; i < data_num; i++) data[i] = long.Parse(line[i]);
		
		Console.WriteLine("{0} {1} {2}", data.Min(), data.Max(), data.Sum());
	}
}


Measured memory_bytes: 18312
#include<iostream>
#include<list>
#include<climits>
#include<queue>
#include<unordered_map>
#include<vector>
using namespace std;

vector<int> dp(100005,-1);
class Graph
{
	unordered_map<int,list<int> > l;

public:
	Graph()
	{

	}

	void addEdge(int x,int y)
	{
		l[x].push_back(y);
	}

	int solve(int src)
	{
		if(dp[src]!=(-1))
			return dp[src];

		int ans=0,leaf=1;
		for(auto nbr:l[src])
		{
			leaf=0;
			ans=max(ans,solve(nbr));
		}
		
		if(leaf==1)
			ans=-1;

		return dp[src]=ans+1;
	}
};

int main()
{
	Graph g;

	int n,m;
	cin>>n>>m;
		
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;

		g.addEdge(x,y);
	}

	int ans=0;
	for(int i=1;i<=n;i++)
		ans=max(ans,g.solve(i));

	cout<<ans;
	return 0;
}

Measured memory_bytes: 14892
import sys

n, *aaa = map(int, sys.stdin.buffer.read().split())

ans = aaa[0] - 1
min_p = 2
for a in aaa[1:]:
    if a == min_p:
        min_p += 1
        continue
    d, m = divmod(a, min_p)
    if m == 0:
        d -= 1
    ans += d
print(ans)


Measured memory_bytes: 12840
// Problem : C - Sequence
// Contest : AtCoder - AtCoder Beginner Contest 059
// URL : https://atcoder.jp/contests/abc059/tasks/arc072_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

#define spc ' '
#define endl '\n'

using namespace std;


int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, curr1 = 0, curr2 = 0;
	long long t1 = 0ll, t2 = 0ll;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i <n ; ++i){
	    cin >> a[i];
	    curr1 += a[i];
	    if(i%2==0 && curr1>=0){
	        t1+=curr1+1;
	        curr1=-1;
	    }
	    else if(i%2==1 && curr1<=0){
	        t1+=-curr1+1;
	        curr1 = 1;
	    }
	    curr2+=a[i];
	    if(i%2==0 && curr2<=0){
	        t2+=-curr2+1;
	        curr2=1;
	    }
	    else if(i%2==1 && curr2>=0){
	        t2+=curr2+1;
	        curr2 = -1;
	    }
	}
	cout << min(t1,t2);
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#define STACK_SIZE 100
#define MAX_LEN 1000

int stack[STACK_SIZE];
int stack_size = 0;

int pop()
{
  if (stack_size <= 0) return 0;
	return stack[--stack_size];
}
int push(int a)
{
	stack[stack_size++] = a;
}
int is_digit(char *s)
{
	if (*s == '+' || *s =='-') {
		s++;
		if (*s >= '0' && *s <= '9') return 1;
		return 0;
	}
	if (*s >= '0' && *s <= '9') return 1;
	return 0;
}
int get_number(char *s)
{
	int sign = 0, n = 0;	
	if (*s == '+') {
		s++;
	} else if (*s == '-') {
		sign = 1;
		s++;
	}
	while (*s >= '0' && *s <= '9') {
		n = n * 10 + (*s - '0');
		s++;
	}
	if (sign) return -n;
	return n;
}
int calc_rpn(char *s)
{
	int a, b, n;
	while (*s) {      
		if (is_digit(s)) {
			n = get_number(s);
			push(n);
			while (*s == '-' || *s == '+') {
				s++;
			}
			while (n) {
				n /= 10;
				s++;
			}       
		} else {
			switch (*s) {
			case '+':
				a = pop();
				b = pop();
				push(b+a);
				break;
			case '-':
				a = pop();
				b = pop();
				push(b-a);
				break;
			case '*':
				a = pop();
				b = pop();
				push(b*a);
				break;
			case '/':
				a = pop();
				b = pop();
				if (a == 0) break;
				push(b/a);
				break;
			case '%':
				a = pop();
				b = pop();
				if (a == 0) break;
				push(b%a);
			}
			s++;
		}
	}
	return pop();
}
int main()
{
	char s[MAX_LEN];

	scanf("%[^\n]*s", s);
	printf("%d\n",calc_rpn(s));
	return 0;
}



Measured memory_bytes: 2128
use std::io;
fn main() {
    let n: i32 = get_line().parse().unwrap();
    let mut res = 0;
    for _ in 0..n {
        let ac : Vec<u32> = get_line().split(' ')
        .map(|x| x.trim().parse().unwrap()).collect();
        res += ac[1] - ac[0] + 1;
    }
    println!("{}", res);
}

fn get_line() -> String {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    return String::from(line.trim())
}


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

int a[12] = {1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
int main() {
    int x, y;
    cin >> x >> y;
    cout << (a[x-1] == a[y-1] ? "Yes" : "No") << endl;
    return 0;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  IN(N);
  map<string, ll> mp;
  vector<string> S(N);
  ll ans = 0;
  REP(i,N){
    IN(S[i]);
    sort(ALL(S[i]));
    mp[S[i]]++;
  }

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

  OUT(ans);


  return 0;
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main(){
    double n,k;
    cin>>n>>k;
    double psum=0;
    for(int i=1;i<=n;i++){
        int a=i;
        double p = 1/n;
        while (a<k){
             a *=2;
             p *=0.5;
        }
        psum +=p;
    }
    printf("%.12f"  , psum);
}

Measured memory_bytes: 256