akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) begin(x), end(x)
using namespace std;
typedef long long ll;
typedef pair <int,int> P;

int rgb[3][4005];

int main(){
  int n;
  string s;
  cin>>n>>s;
  rep(i,n){
    rep(j,3) rgb[j][i+1]+=rgb[j][i];
    if(s[i]=='R') rgb[0][i+1]++;
    else if(s[i]=='G') rgb[1][i+1]++;
    else rgb[2][i+1]++;
  }
  ll ans=0;
  string t="RGB";
  rep(i,n) rep(j,i){
    if(s[i]==t[0]&&s[j]==t[1]){
      int k=2*j-i;
      ans+=rgb[2][j];
      if(k>=0&&s[k]==t[2]) ans--;
    }
    if(s[i]==t[0]&&s[j]==t[2]){
      int k=2*j-i;
      ans+=rgb[1][j];
      if(k>=0&&s[k]==t[1]) ans--;
    }
    if(s[i]==t[1]&&s[j]==t[2]){
      int k=2*j-i;
      ans+=rgb[0][j];
      if(k>=0&&s[k]==t[0]) ans--;
    }
    if(s[i]==t[1]&&s[j]==t[0]){
      int k=2*j-i;
      ans+=rgb[2][j];
      if(k>=0&&s[k]==t[2]) ans--;
    }
    if(s[i]==t[2]&&s[j]==t[0]){
      int k=2*j-i;
      ans+=rgb[1][j];
      if(k>=0&&s[k]==t[1]) ans--;
    }
    if(s[i]==t[2]&&s[j]==t[1]){
      int k=2*j-i;
      ans+=rgb[0][j];
      if(k>=0&&s[k]==t[0]) ans--;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3640
line_1 = []
line_2 = []
line_3 = []

line_1 = gets.split.map(&:to_i)
line_2 = gets.split.map(&:to_i)
line_3 = gets.split.map(&:to_i)

line_flag_1 = [false, false, false]
line_flag_2 = [false, false, false]
line_flag_3 = [false, false, false]

i = gets.to_i

i.times do
  b = gets.to_i
  case b
  when line_1[0]
    line_flag_1[0] = true
  when line_1[1]
    line_flag_1[1] = true
  when line_1[2]
    line_flag_1[2] = true
  when line_2[0]
    line_flag_2[0] = true
  when line_2[1]
    line_flag_2[1] = true
  when line_2[2]
    line_flag_2[2] = true
  when line_3[0]
    line_flag_3[0] = true
  when line_3[1]
    line_flag_3[1] = true
  when line_3[2]
    line_flag_3[2] = true
  else
  end
end

if line_flag_1 == [true, true, true]
  puts "Yes"
elsif line_flag_2 == [true, true, true]
  puts "Yes"
elsif line_flag_3 == [true, true, true]
  puts "Yes"
elsif line_flag_1[0] == true && line_flag_2[0] == true && line_flag_3[0] == true
  puts "Yes"
elsif line_flag_1[1] == true && line_flag_2[1] == true && line_flag_3[1] == true
  puts "Yes"
elsif line_flag_1[2] == true && line_flag_2[2] == true && line_flag_3[2] == true
  puts "Yes"
elsif line_flag_1[0] == true && line_flag_2[1] == true && line_flag_3[2] == true
  puts "Yes"
elsif line_flag_1[2] == true && line_flag_2[1] == true && line_flag_3[0] == true
  puts "Yes"
else 
  puts "No"
end


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

int main(){
  int n,m;
  cin >> n >> m;
  int s = 0;
  
  for(int i=0;i<m;i++){
    int a;
    cin >> a;
    s += a;
  }
  if((n-s)>=0){
    cout << n-s << endl;
  }else{
    cout << -1 << endl;
  }
}

Measured memory_bytes: 3580
function Main(input) {
	var data = input.split("\n")
	input = data[0]
	var answer = true;
    for(var i =0; i<data[0].length;i++){
    	if(i%2==1 && data[0][i] == "R"){
    		answer = false;
    	}else if(i%2==0 && data[0][i] == "L"){
    		answer = false;
    	}
    }
    console.log((answer)?"Yes":"No")
}
 
// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
  int N, K;
  cin >> N >> K;
  int a=1;
  
  for(int i=0; i<N; i++) {
    if(a <= K)
      a*=2;
    else
      a+=K;
  }
  cout << a << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for(i = a; i < b; i++)
#define per(i, a, b) for(i = a; i >= b; i--)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define trav(x, it) for(auto it = x.begin(); it != x.end(); it++)
#define pr(x) cout << #x << " = " << x << endl
#define fill(x,y) memset(x,y,sizeof(x))
#define endl "\n"
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector< pii > vpii;
typedef vector< pll > vpll;
const ld eps = 1e-7;
const ll mod = 1000000007;
const ll N = 998244353;

ll binpow(ll b, ll p){ ll ans = 1; while(p > 0){if(p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1;}return ans;}
ll modinv(ll x){return binpow(x, mod - 2);}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n, i, k, sum = 0;
	cin >> n >> k;
	int a[n];
	rep(i, 0, n)
		cin >> a[i];
	sort(a, a + n);
	rep(i, 0, k)
		sum += a[i];
	cout << sum << endl;
}

Measured memory_bytes: 3640
# -*- coding: utf-8 -*-
import sys 
from collections import defaultdict
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
S = readline().decode()

st = ['SS','SW','WS','WW']

# 8通りの分岐を辞書に登録
d = defaultdict(int)
d['SSo'] = 'S'
d['SSx'] = 'W'
d['SWo'] = 'W'
d['SWx'] = 'S'
d['WSo'] = 'W'
d['WSx'] = 'S'
d['WWo'] = 'S'
d['WWx'] = 'W'
 

#答えの候補をansに代入
ans = []
for s in st:
    t = s  
    for i in range(1,N-1):
        tmp = t[-2:]
        ss = tmp + S[i]
        t += d[ss]
    ans.append(t)

# 答えの候補が矛盾しないかのチェック
for a in ans:
    b = a[N-2]+a[N-1]+S[N-1]
    if d[b] != a[0]:
        continue
    b = a[N-1]+a[0]+S[0]
    if d[b] != a[1]:
        continue
    print(a)
    sys.exit()

print(-1)

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

    double ans = 0;
    for(int i=1; i<=n; i++){
        int dice = i;
        double count = 0;
        while(dice<k){
            dice *= 2;
            count++;
        }
        ans += pow(0.5, count);
    }
    ans *= (double)(1.0/n);

    cout << setprecision(9) << ans;

    return 0;
}

Measured memory_bytes: 256
#負の経路の検出
def find_negative_loop(n, es, d):
    #始点はどこでもよい
    check = [0 for _ in range(n)]
    for _ in range(n):
        for p, q, r in es:
            #e: 辺iについて
            if d[p] != float("inf") and d[q] > d[p] + r:
                d[q] = d[p] + r
                check[q] = True
            if check[p]:
                check[q] = True
                # if i == n-1:
                #     return True
    return check

def shortest_path(s, n, es):
    #s -> i　の最短経路
    #s: 始点、n: 頂点数、w:辺の数、es[i]: [辺の始点、辺の終点、辺のコスト]
    d = [float("inf")] * n
    #d[i]: s->iの最短距離
    d[s] = 0
    for _ in range(n):
        update = False
        for p, q, r in es:
            #e: 辺iについて
            if d[p] != float("inf") and d[q] > d[p] + r:
                d[q] = d[p] + r
                update = True
        # print(update)
        if not update:
            break
    return d

n,w = map(int,input().split()) #n:頂点数　w:辺の数
es = [] #es[i]: [辺の始点,辺の終点,辺のコスト]

for _ in range(w):
    x,y,z = map(int,input().split())
    es.append([x-1, y-1, -z])
    # es.append([y,x,z])

# print(shortest_path(0, n, es))
# print(es)

# if find_negative_loop(n,es):

d = shortest_path(0, n, es)

# print(d)

c = find_negative_loop(n, es, d)
# print(c)



if c[-1]:
    print("inf")
else:
    # d = shortest_path(0, n, es)
    print(-d[-1])

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

int main(void){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0 ; i < N ; i++){
        int tmp;
        int cnt = 0;
        cin >> tmp;
        
        while(tmp % 2 == 0){
            tmp /= 2;
            cnt++;
        }
        
        A.at(i) = cnt;
    }
    
    int min = 1000000010;
    for(int i = 0 ; i < N ; i++){
        if(A.at(i) < min){
            min = A.at(i);
        }
    }
    
    cout << min << endl;
    return 0;
    
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N;
  cin >> N;
  long long a = 1;
  int b = 0;
  string ans = "";
  vector<string> li = {"z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y"};
  while(true){
    a = N/26;
    b = N%26;
    if(b==0){
      a -=1;
    }
    ans = li.at(b)+ans;
    if(a == 0){
      break;
    }
    N = a;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
#include <unordered_map>
using namespace std;

unordered_map<string,int> ma;

int main()
{
	int n;
	cin>>n;
	long long ans=0;
	string s;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		sort(s.begin(),s.end());
		ans+=ma[s];
		ma[s]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10660
implicit none
integer(8) :: a,b,c,d
integer(8) :: nc, nd, ncd, m, n, r
read *,a,b,c,d

nc = b/c - (a-1)/c  ! Numbers that can be divided by C
nd = b/d - (a-1)/d  ! Numbers that can be divided by D

! GCD
if (c > d) then
   m = c
   n = d
else
   m = d
   n = c
endif

r = 1
do while (r > 0)
   r = mod(m,n)
   m = n
   n = r
enddo

! LCM
m = c * d / m

ncd = b/m - (a-1)/m   ! Numbers that can be divided by C & D

write(6,'(i0)') b-a+1 - nc - nd + ncd
stop
end

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inclass in = new inclass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AStillTBD solver = new AStillTBD();
        solver.solve(1, in, out);
        out.close();
    }

    static class AStillTBD {
        public void solve(int testNumber, inclass in, PrintWriter out) {
            String str = in.readLine();
            String arr[] = str.split("/");
            String y = arr[0];
            if (Integer.parseInt(y) < 2019) {
                out.println("Heisei");
                return;
            }
            if (Integer.parseInt(arr[1]) <= 4 && Integer.parseInt(y) <= 2019) {
                out.println("Heisei");
                return;
            }
            if (Integer.parseInt(arr[1]) <= 4 && Integer.parseInt(y) <= 2019 && Integer.parseInt(arr[2]) <= 30) {
                out.println("Heisei");
                return;
            }
            out.println("TBD");
            return;
        }

    }

    static class inclass {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public inclass(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        private String readLine0() {
            StringBuilder buf = new StringBuilder();
            int c = read();
            while (c != '\n' && c != -1) {
                if (c != '\r') {
                    buf.appendCodePoint(c);
                }
                c = read();
            }
            return buf.toString();
        }

        public String readLine() {
            String s = readLine0();
            while (s.trim().length() == 0) {
                s = readLine0();
            }
            return s;
        }

    }
}



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


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

	if(a>=3200)
	{
		cout<<s;
	}
	else
	{
		cout<<"red";
	}
    
    
    return 0;
}

Measured memory_bytes: 256
import collections


def solve(string):
    n = len(string)
    i = 0

    while i < n:
        count = collections.Counter(string[i:min(n, i+3)])

        for key, count in count.items():
            if count >= 2:
                return (i, min(n-1, i+2))

        i += 1

    return (-1, -1)


string = input().strip()

left, right = solve(string)

if left == -1 and right == -1:
    print(left, right)
else:
    print(left+1, right+1)


Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main()
{
  int n, l;
  scanf("%d%d", &n, &l);
  std::vector<std::string> v;
  for (int i = 0; i < n; ++i)
  {
    std::string s;
    std::cin >> s;
    v.emplace_back(s);
  }
  std::sort(v.begin(), v.end());
  for (auto &s : v)
  {
    std::cout << s;
  }
  std::cout << std::endl;
  return 0;
}

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

int main(void)
{
    int a, b;
    char op;

    while (1){
        cin >> a >> op >> b;
        
        if (op == '+'){
            cout << a + b << endl;
        }
        else if (op == '-'){
            cout << a - b << endl;
        }
        else if (op == '*'){
            cout << a * b << endl;
        }
        else if (op == '/'){
            cout << a / b << endl;
        }
        else if (op == '?'){
            break;
        }
    }
    
    return (0);
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using ll         = int;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
const long long INF = numeric_limits<long long>::max();
int main() {
    ll N;
    cin >> N;
    ll free = 0;
    vector<ll> rank(8, 0);
    for (ll i = 0; i < N; ++i) {
        ll n;
        cin >> n;
        if (n >= 3200) {
            free++;
        } else {
            rank[n / 400]++;
        }
#ifdef SOURCE_TEST

        cout << n << ":" << n / 400 << endl;
#endif
    }

    ll sum = 0;
    for (ll i = 0; i < rank.size(); ++i) {
        sum += (rank[i] > 0) ? 1 : 0;
    }
    cout << (max(sum, 1)) << " " << sum + free << "\n";
    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

int main()
{
  int N, K;
  cin >> N >> K;
  vector<long long> a(N + 1);
  rep(i, N)
  {
    cin >> a[i + 1];
  }
  rep(i, N)
  {
    a[i + 1] += a[i];
  }
  vector<long long> addA;
  rep(i, N + 1)
  {
    for (int j = i + 1; j < N + 1; j++)
      addA.push_back(a[j] - a[i]);
  }

  long long ans = 0;
  rep(i, 41)
  {
    long long temp = ans + pow(2, 40 - i);
    long long count = 0;
    rep(j, addA.size())
    {
      if ((temp & addA[j]) == temp)
        count++;
    }
    if (count >= K)
      ans = temp;
  }

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

Measured memory_bytes: 7516
def ans(n):
  if n==0:
    return ['0']
  else:
    l=[['0' for i in range(2**n)] for j in range(2**n)]
    ans2=ans(n-1)
    for i in range(2**n):
      for j in range(2**n):
        if i<2**(n-1) and j<2**(n-1):
          l[i][j]=ans2[i][j]
        elif i<2**(n-1) and j>=2**(n-1):
          l[i][j]=str(n)
        elif i>=2**(n-1) and j<2**(n-1):
          l[i][j]='0'
        else:
          l[i][j]=ans2[i-2**(n-1)][j-2**(n-1)]
    return l
import math
n=int(input())
ans=ans(math.ceil(math.log(n,2)))
for i in range(n-1):
  print(' '.join(ans[i][i+1:n]))

Measured memory_bytes: 10680
/*
  "Piece of shit. Stupid piece of shit. I'm a real stupid piece
   of shit. But I know I'm a piece of shit. That at least makes
   me better than all the pieces of shit that don't know they're
   pieces of shit. Or is it worse?"
     - BoJack F. Horseman
*/
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstring>
#include<climits>
#include<numeric>
#include<random>
#include<fstream>
#include<chrono>

#include<deque>
#include<queue>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<unordered_map>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define int          long long
#define ld           long double
#define pii          pair<int,int>
#define vi           vector<int>
#define maxpq        priority_queue<int>
#define minpq        priority_queue<int,vi,greater<int>>
#define pb           push_back
#define mp           make_pair
#define ff           first
#define ss           second
#define endl         '\n'
#define rep(i,s,e)   for(int i=s;i<=e;i++)
#define brep(i,s,e)  for(int i=s;i>=e;i--)
#define all(x)       (x).begin(),(x).end()
#define ball(x)      (x).rbegin(),(x).rend()
#define sz(x)        (int)x.size()
#define mem(x,y)     memset(x,y,sizeof(x))
#define milf(x)      x.reserve(1LL<<14LL); x.max_load_factor(0.25);
#define pbds         tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define VR46         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
mt19937              rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1e9+7;
ld EPS = 1e-12;
const int INF32 = 0x3F3F3F3F;
const int INF = 0x3F3F3F3F3F3F3F3F;
const int crng = rng();

map<int,int> dp;

int REC(int h)
{
    if( h==1 ) return 1;
    if( dp.find(h)!=dp.end() ) return dp[h];
    int re = REC( h/2 );
    dp[h] = 2*re + 1;
    return 2*re + 1;
}

signed main()
{
    VR46 ifstream fin("input.txt"); ofstream fout("output.txt");
    // auto start = chrono::high_resolution_clock::now();

    // GANDU TEST CASE BNAKE TEST KRLE; CHECK BOUNDS;
    // int t; cin>>t; rep(test,1,t)
    {
        int h;
        cin>>h;
        cout<<REC(h)<<endl;
    }

    // auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout<<"Time taken by function: "<<duration.count()<<" milliseconds"<<endl;

    // *( hsh.find_by_order(k) ) kth smallest, from 0
    // hsh.order_of_key(k) num of ele str less than k
    // change less to less_equal for multiset pbds
    // Create struct HASH; Use milf(x) for every hashmap; Use CRNG xor;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

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

  if ( std::abs(a-c) <= d || (std::abs(a-b)<=d && std::abs(b-c)<=d) ) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;

  return 0;
}


Measured memory_bytes: 256
# input
N, M = map(int, input().split())
W = []
V = []
for _ in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)

dp = [[None for __ in range(N*max(V)+1)] for _ in range(N+1)]
dp[0] = [10**9 for _ in range(N*max(V)+1)]
dp[0][0] = 0
for i in range(1, N+1):
    for v in range(N*max(V)+1):
        if V[i-1] >= v:
            dp[i][v] = min(dp[i-1][v], W[i-1])
        else:
            dp[i][v] = min(dp[i-1][v], dp[i-1][v-V[i-1]] + W[i-1])


print(max(i for i, w in enumerate(dp[-1]) if w <= M))


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

#define int long long
#define endl "\n"
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);


main(){
	FIO
	string str;
	cin>>str;
	int i,j,k;
	k = str.length();
	for(i=0;i<k;i++){
		if(str[i]=='?'){
			str[i] = 'D';
		}
	}
	
	cout<<str;
	
}

Measured memory_bytes: 3736
n = int(input())
hs = list(map(int, input().split()))
stack = []
ans = 0

for i, h in enumerate(hs):
    j = -1
    while stack and stack[-1][1] > h:
        j, h2 = stack.pop()
        ans = max(ans, (i - j) * h2)
    if not stack or stack[-1][1] < h:
        stack.append((i if j == -1 else j, h))
ans = max(ans, max((n - j) * h2 for j, h2 in stack))

print(ans)

Measured memory_bytes: 22168
from sys import stdin

data = []
for i in range(5):
    data.append(int(stdin.readline().rstrip()))

k = int(stdin.readline().rstrip())

cnt = 1

for i in range(len(data)):
    for j in range(cnt,5):
        if abs(data[i] - data[j]) > k:
            print(":(")
            exit()
    cnt += 1


print("Yay!")

Measured memory_bytes: 38384
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)

#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
///                →,↑,←,↓,↗,↖,↙,↘
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

static const int N = 100;
static const int White = 0;
static const int Gray = 1;
static const int Black = 2;
int d[N], f[N],tt;
int color[N],n,M[N][N];


void dfs_visit(int u) {
	int v;
	d[u] = ++tt;
	color[u] = Gray;
	rep(v,n){
		if (M[u][v] == 0) continue;
		if (color[v] == White) dfs_visit(v);
	}
	color[u] = Black;
	f[u] = ++tt;
}

void dfs() {
	int u;
	rep(u, n)color[u] = White;
	rep(u, n) {
		if (color[u] == White) dfs_visit(u);
	}
	rep(u, n) {
		cout << u + 1 << ' ' << d[u] << ' ' << f[u] << '\n';
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin >> n;
	int i;
	rep(i, n) {
		int u, k, v;
		cin >> u >> k;
		u--;
		int j;
		rep(j, k) {
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}
	dfs();
	return 0;
}


Measured memory_bytes: 3232
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const n = args[0][0]
	let a = null
	let b = null
	let c = null

	if (n[0] === '1') a = '9'
	else if (n[0] === '9') a = '1'
	else a = n[0]

	if (n[1] === '1') b = '9'
	else if (n[1] === '9') b = '1'
	else b = n[1]

	if (n[2] === '1') c = '9'
	else if (n[2] === '9') c = '1'
	else c = n[2]

	console.log(`${a}${b}${c}`)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    ll ans = 0;
    ll now = 0;
    for (int i = 0; i < n; ++i) {
        if (now < a[i]) now = a[i];
        ans += now - a[i];
    }
    cout << ans << endl;
}

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

#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 2e5 + 5;
ll sum[N];
ll mod = 1e9 + 7;
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        //freopen("VLJUM.INP", "r", stdin);
        //freopen("VLJUM.OUT", "w", stdout);
        ll n, k;
        cin >> n >> k;
        for (int i = 1; i <= (n + 1); i++){
                sum[i] = (sum[i - 1] + (i - 1)) % mod;
        }
        ll ans = 0;
        for (int i = k; i <= (n + 1); i++){
                ans += (sum[n + 1] - sum[n + 1 - i]) - (sum[i] - 1) + mod * mod;
                ans %= mod;
        }
        cout << ans;
}



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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=0;i<=(n);i++)

ll Func(ll a){
	if(a % 2)
		return a * 3 + 1;
	else
		return a / 2;
}

int main(){
	static ll a[1000000] = {};
	cin >> a[0];

	bool f = false;
	for(ll i = 1; i < 1000000; ++i){
		a[i] = Func(a[i - 1]);
		//cout << a[i] << endl;
		//cout << "=>" << i << endl;
		for(ll j = 0; j < i; ++j){
			//cout << "!!!!!!!!!!!" << endl;
			if(a[i] == a[j]){
				cout << ++i << endl;
				f = true;
			}else
				f = false;

			if(f)
				break;
		}
		if(f)
			break;
	}

	return 0;
}


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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;
#define ret() return 0;

bool contain(set<char> &s, char a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

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

    ll neck = INF;
    rep(i, 5) {
        ll a;
        cin >> a;
        cmin(neck, a);
    }

    cout << (n + neck - 1) / neck + 4 << endl;

}


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

#define pan(i,n) for(int i=0;i<n;i++)
#define pans(i,n,a) for(int i=a;i<n;i++)
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define INF 1e9+7
#define PI 3.141592653
#define inf 200007
#define P pair<ll,ll>

using namespace std;

int main(){
    int n;
    cin>>n;
    string s=to_string(n);
    bool flag=false;
    for (size_t i = 0; i < s.size(); i++)
    {
        if(s[i]=='7') {flag=true;
            break;
        }
    }
    if(flag) cout<<"Yes";
    else cout<<"No";
}   

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

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i,3) {
    if (s[i] == t[i]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#abc115c

n,k=map(int,raw_input().split())
h=[]
for i in xrange(n):
 h.append(int(raw_input()))
h.sort()
res=float('inf')
for i in xrange(n-k+1):
 res=min(res,h[i+k-1]-h[i])
print res


Measured memory_bytes: 6208
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}
ll mpower(ll a,ll b,ll c){
  int z;
  if(b==0){
    z=1;
    z%=c;
    return z;
  }
  if(b==1){
    z=a;
    z%=c;
    return z;
  }
  else{
    return (((mpower(a,b/2,c))*(mpower(a,b/2,c))%c)*mpower(a,b%2,c)%c);
  }
}

int main() {
  double a;
  cin>>a;
  cout<<fixed<<setprecision(20);
  cout<<(a/3)*(a/3)*(a/3)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

struct UnionFind {
  vector<int> parent;
  vector<int> rank;

  UnionFind(int size) : parent(size), rank(size, 0) {
    for (int i = 0; i < size; i++) {
      parent[i] = i;
    }
  }

  int find(int x) {
    if (parent[x] == x) {
      return x;
    } else {
      return parent[x] = find(parent[x]);
    }
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (rank[x] < rank[y]) {
      parent[x] = y;
    } else {
      parent[y] = x;
      if (rank[x] == rank[y]) rank[x]++;
    }
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

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

  ll n, m;
  cin >> n >> m;
  UnionFind uf(n+m);
  rep(i, n) {
    ll k;
    cin >> k;
    rep(j, k) {
      ll l;
      cin >> l;
      uf.unite(i, l-1+n);
    }
  }

  bool f = 1;
  rep(i, n) {
    //cerr << uf.parent[i] << endl;
    if (!uf.same(0, i)) f = 0;
  }

  if (f) cout << "YES" << endl;
  else cout << "NO" << endl;
}


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

const long long MOD = 1000000007;

mat mul(mat &A,mat &B){
    mat C(A.size(),vector<long long>(B[0].size(),0));
    for(int i=0;i<A.size();i++){
        for(int j=0;j<B.size();j++){
            for(int k=0;k<B[0].size();k++){
                C[i][k] =(C[i][k] +A[i][j] * B[j][k]) % MOD;
            }
        }
    }
    return C;
}

mat pow(mat A, long long n){
    mat B(A.size(),vector<long long>(A[0].size(),0));
    for(int i=0;i<A.size();i++){
        B[i][i] = 1;
    }
    while(n >0){
        if( n&1){
            B = mul(B,A);
        }
        A = mul(A,A);
        n >>=1;
    } 
    return B;   
}



void solve(long long N, long long K, std::vector<std::vector<long long>> a){
    mat A(N,vector<long long>(N));
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            A[i][j] = a[i][j];
        }
    }
    mat B = pow(A,K);
    long long ans =0;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            ans += B[i][j];
            ans %= MOD;
        }
    }
    cout << ans << endl;

}

// 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)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<std::vector<long long>> a(N, std::vector<long long>(N));
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < N ; j++){
            scanf("%lld",&a[i][j]);
        }
    }
    solve(N, K, std::move(a));
    return 0;
}


Measured memory_bytes: 384
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

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

	if (k < a) cout << k;
	else if (k <= a + b) cout << a;
	// else if (k < a + b + c) cout << a;
	else cout << a - (k - (a + b));

	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

ll s[200000],t[200000];
int main(){
	int a,b,q;cin>>a>>b>>q;
	rep(i,a){
		scanf("%lld",&s[i]);
	}
	rep(i,b){
		scanf("%lld",&t[i]);
	}
	rep(i,q){
		ll x;scanf("%lld",&x);
		int id1=lower_bound(s,s+a,x)-s,id2=lower_bound(t,t+b,x)-t;
		ll Min=LLONG_MAX;
		for(int j=id1-1;j<=id1;j++){
			for(int k=id2-1;k<=id2;k++){
				if(j<0||k<0||j>=a||k>=b)continue;
				if(j==id1&&k==id2){
					Min=min(Min,max(s[j],t[k])-x);
				}
				else if(j==id1&&k==id2-1){
					Min=min(Min,s[j]-t[k]+min(s[j]-x,x-t[k]));
				}
				else if(j==id1-1&&k==id2){
					Min=min(Min,t[k]-s[j]+min(t[k]-x,x-s[j]));
				}
				else Min=min(Min,x-min(s[j],t[k]));
			}
		}
		printf("%lld\n",Min);
	}
}

Measured memory_bytes: 2944
import java.util.Scanner;
        
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int acCount = 0;
        int waCount = 0;
        int tleCount = 0;
        int reCount = 0;
        
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            if (s.equals("AC")) {
                acCount++;
            } else if (s.equals("WA")) {
                waCount++;
            } else if (s.equals("TLE")) {
                tleCount++;
            } else if (s.equals("RE")) {
                reCount++;
            }
        }
        System.out.println("AC x " + acCount);
        System.out.println("WA x " + waCount);
        System.out.println("TLE x " + tleCount);
        System.out.println("RE x " + reCount);
    }
}

Measured memory_bytes: 58384
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int mod = 200003;
int mult(int a, int b) {
    return (1LL * a * b) % mod;
}
int sum(int a, int b) {
    int s = a + b;
    if (s >= mod) s -= mod;
    return s;
}
const int GEN = 2;
const int maxN = 2e5 + 10;
int val[maxN];
int n;
int bck[maxN];

typedef complex<long double> base;
vector < base > roots = {base(0, 0), base(1, 0)};
int cur_base = 1;
const double PI = acosl(-1.0);
const base ii = base(0, 1);

void fft (vector<base> & a, bool invert) {
    int n = (int) a.size();

    if (invert) {
        for (auto& it : a) {
            it = conj(it);
        }
    }

    if ((1 << cur_base) < n) {
        roots.resize(n);
        while ((1 << cur_base) < n) {
            ld ang = (2 * PI) / (1 << (cur_base + 1));
            for (int i = (1 << (cur_base - 1)); i < (1 << cur_base); i++) {
                roots[i << 1] = roots[i];
                ld ang_i = ang * (2 * i + 1 - (1 << cur_base));
                roots[(i << 1) + 1] = base(cosl(ang_i), sinl(ang_i));
            }
            cur_base++;
        }
    }

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

    for (int len=2; len<=n; len<<=1) {
        for (int i=0; i<n; i+=len) {
            for (int j=0; j<len/2; ++j) {
                base u = a[i+j],  v = a[i+j+len/2] * roots[j + len / 2];
                a[i+j] = u + v;
                a[i+j+len/2] = u - v;
            }
        }
    }
    if (invert)
        for (int i=0; i<n; ++i)
            a[i] /= n;
}


vector < ll > poly_mult(vector < int >& a, vector < int >& b) {
    if (a.empty() || b.empty()) return {};
    int s = a.size() + b.size() - 1;
    int sz = 1;
    while (sz < s) sz <<= 1;
    vector < base > ff(sz);
    for (int i = 0; i < sz; i++) {
        ld x = (i < a.size() ? a[i] : 0);
        ld y = (i < b.size() ? b[i] : 0);
        ff[i] = base(x, y);
    }
    fft(ff, false);
    vector < base > x(sz);
    for (int i = 0; i < sz; i++) {
        int j = (sz - i) & (sz - 1);
        x[i] = (ld)0.25 * ii * (conj(ff[j] * ff[j]) - ff[i] * ff[i]);
    }
    fft(x, true);
    vector < ll > ans(a.size() + b.size() - 1);
    for (int i = 0; i < ans.size(); i++) {
        ans[i] = llround(x[i].real());
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    int c = 1;
    for (int i = 0; i <= mod - 2; i++) {
        val[c] = i;
        bck[i] = c;
        c = mult(c, GEN);
    }
    ll ans = 0;
    cin >> n;
    vector < int > freq(mod);
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        if (x == 0) continue;
        ans -= mult(x, x);
        freq[val[x]]++;
    }
    auto tt = poly_mult(freq, freq);
    for (int i = 0; i < tt.size(); i++) {
        ans += 1LL * bck[i % (mod - 1)] * tt[i];
    }
    cout << ans / 2;
    return 0;
}

Measured memory_bytes: 58140
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#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>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<vector<int> > p(n, vector<int>(n));
    vector<vector<int> > sum(n, vector<int>(n+1));
    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            cin >> p[i][j];
            sum[i][j+1] = sum[i][j] + p[i][j];
        }
    }

    int ans = INT_MIN / 2;
    for(int x1=0; x1<n; ++x1){
        for(int x2=x1; x2<n; ++x2){
            int a = INT_MIN / 2;
            for(int y=0; y<n; ++y){
                int b = sum[y][x2+1] - sum[y][x1];
                ans = max({ans, b, a + b});

                if(x1 == x2)
                    a = max(b, a + p[y][x1]);
                else
                    a = max(b, a + p[y][x1] + p[y][x2]);
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1788
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  string s,t;
  cin >> s >> t;
  if(s == t.substr(0,t.size()-1)) cout << "Yes" << endl;
  else cout << "No" << endl; 
  return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
/*
struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<ll> A(N);
    for (auto &it : A)
        cin >> it;

    deque<ll> backMax;
    for (int i = 0; i < N; i++)
    {
        if (i == 0)
        {
            backMax.push_back(A[i]);
            continue;
        }
        int idx = lower_bound(backMax.begin(), backMax.end(), A[i]) - backMax.begin();
        if (idx == 0)
            backMax.push_front(A[i]);
        else
            backMax[idx - 1] = A[i];
    }
    cout << backMax.size() << endl;
    return 0;
}


Measured memory_bytes: 4756
// Lec08-C Counting Characters
#include<iostream>
#include<string>
#include<cstdio>
int main(){
  int cnt[26]={};
  std::string str;
  while(std::getline(std::cin, str)){
    for(int i=0; i<str.length(); i++){
      if(str[i] >= 'A' && str[i] <= 'z'){
        str[i] < 'a' ? cnt[str[i]-65]++ : cnt[str[i]-65-32]++;
      }
    }
  }
  for(char c='a'; c<='z'; c++){
    std::cout << c << " : " << cnt[c-65-32] << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3164
import math,heapq,collections,sys,numpy
sys.setrecursionlimit(10**7)

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

N,K = LI()
p = []
for i in range(N):
    a,b = LI()
    p.append((a,b,i))
sx = sorted(p)
ans = 10**50
for x,y,i in sx:
    for x2,y2,i2 in sx:
        if x2 <= x:
            continue
        points = sx.index((x2,y2,i2)) - sx.index((x,y,i)) + 1
        if points >= K:
            sy2 = sorted(sx[sx.index((x,y,i)):sx.index((x2,y2,i2))+1],key=lambda sx: sx[1])
            for j in range(len(sy2)-K+1):
                if sy2[j][1] <= y and sy2[j+K-1][1] >= y2:          
                    ans = min(ans, (x2 - x) * (sy2[j+K-1][1]-sy2[j][1])) 
print(ans)

Measured memory_bytes: 14472
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))

s = input()

if (s == "Sunny"):
    print("Cloudy")
elif (s == "Cloudy"):
    print("Rainy")
else:
    print("Sunny")


Measured memory_bytes: 9016
fn main() {
  let n: isize = get::val();
  let k: isize = get::val();
  
  let mut ans = 1;
  for _ in 0..n {
    if ans < k {ans*=2} else {ans+=k}
  }
  println!("{}", ans);
}

#[allow(dead_code)]
mod get {
  use std::io::*;
  use std::str::*;

  pub fn val<T: FromStr>() -> T {
    let mut buf = String::new();
    stdin().read_line(&mut buf).ok();
    buf.trim().parse::<T>().ok().unwrap()
  }

  pub fn vals<T: FromStr>(n: usize) -> Vec<T> {
    let mut vec: Vec<T> = vec![];
    for _ in 0 .. n {
      vec.push(val());
    }
    vec
  }

  pub fn tuple<T1: FromStr, T2: FromStr>() -> (T1, T2) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).ok();
    let mut it = buf.trim().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    (x, y)
  }

  pub fn tuples<T1: FromStr, T2: FromStr>(n: usize) -> Vec<(T1, T2)> {
    let mut vec: Vec<(T1, T2)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple());
    }
    vec
  }

  pub fn tuple3<T1: FromStr, T2: FromStr, T3: FromStr>() -> (T1, T2, T3) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).ok();
    let mut it = buf.trim().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    let z = it.next().unwrap().parse::<T3>().ok().unwrap();
    (x, y, z)
  }

  pub fn tuple3s<T1: FromStr, T2: FromStr, T3: FromStr>(n: usize) -> Vec<(T1, T2, T3)> {
    let mut vec: Vec<(T1, T2, T3)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple3());
    }
    vec
  }

  pub fn list<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
  }

  pub fn lists<T: FromStr>(h: usize) -> Vec<Vec<T>> {
    let mut mat: Vec<Vec<T>> = vec![];
    for _ in 0 .. h {
      mat.push(list());
    }
    mat
  }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main() {
 int N;
 cin>>N;
 vector<string>S(N);
 for(int i=0;i<N;i++){
   cin>>S.at(i);}
 
  sort(S.begin(),S.end());
  
  int count=1;
 for(int i=0;i<N;i++){
   if(i>0&&S.at(i-1)!=S.at(i)){count++;}
 }
  cout<<count<<endl;
 return 0;
}

Measured memory_bytes: 9600
#include "iostream"
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  int a,b,c;
  std::cin >> a >> b >> c;
  int min=a+b;
  if(min>b+c) min=b+c;
  if(min>c+a) min=c+a;
  std::cout << min << '\n';
  return 0;
}


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

typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

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

const int MAXN = 300001;
ll N;
ll A[MAXN];



int main(){
    cin >> N ;
    ll maxi = 0;
    rep(i,N){
      cin >> A[i];
      maxi = max(A[i], maxi);
    }
    ll maxbit = 0;
    while(1) {
      maxi = (maxi >> 1);
      maxbit++;
      if(maxi==0)break;
    }
    ll ans = 0;
    ll tmp_bit = 1;
    for(int bit=0;bit<maxbit;bit++) {
      ll zero = 0;
      ll one = 0;
      rep(i,N) {
        if((A[i]>>bit) & 1){
          one++;
        }
        else zero++;
      }
      tmp_bit %= mod;
      ll tmp = (tmp_bit * min(one, zero)) %mod;
      tmp = (tmp * max(zero,one)) % mod;
      ans += tmp;
      ans %= mod;
      tmp_bit *= 2;
      tmp_bit %= mod;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5948
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass

n = i()
print(n//2 if n%2==0 else n//2+1)

Measured memory_bytes: 3064