akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

struct team{
	string name;
	int point;
};

team teams[50];

int main(){
	
	int n;
	
	cin >> n;
	
	while(true){
		if(n == 0){
			break;
		}
		
		int a, b, c;
		for(int i = 0; i < n; i++){
			cin >> teams[i].name;
			cin >> a >> b >> c;
			teams[i].point = a * 3 + c;
		}
		
		for(int i = 0; i < n; i++){
			for(int j = n - 1; j > 0; j--){
				if(teams[j - 1].point < teams[j].point){
					swap(teams[j - 1], teams[j]);
				}
			}
		}
		
		for(int i = 0; i < n; i++){
			cout << teams[i].name << "," << teams[i].point << endl;
		}
		cin >> n;
		if(n != 0){
			cout << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using hset = unordered_set<T>;
template<class Key, class T> using hmap = unordered_map<Key, T>;

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

int main() {
    vi v(1000, 0);
    for (int i = 1; i < 1000; i++) v[i] = v[i-1] + i;

    int N, cnt;
    while (cin >> N) {
        if (N == 0) break;
        cnt = 0;
        for (int i = 0; i < v.size(); i++) {
            for (int j = i + 2; j < v.size(); j++) {
                if (v[j] - v[i] < N) continue;
                if (v[j] - v[i] == N) cnt++;
                break;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 3016
# https://atcoder.jp/contests/abc117/tasks/abc117_d
=begin
3 7
1 6 3

14

4 9
7 4 0 3

46

1 0
1000000000000

1000000000000
=end
N, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

upper_bit = K.to_s(2)
upper_bit_length = upper_bit.length
max_bit_length = A.max.to_s(2).length

zero_str = (0..40).to_a.each_with_object([]) { |i, obj| obj << '0' * i}.reverse.freeze
zero_fill_strA = A.map { |i| "#{zero_str[i.to_s(2).size]}#{i.to_s(2)}" }

zero_fill_upper_bit =  "#{zero_str[upper_bit.size]}#{upper_bit}"

one = '1'
zero = '0'
mask = ''
already_min = false
0.step(39) do |digest|
  if zero_fill_strA.count { |str| str[digest] == one } * 2 >= N
    already_min = true if zero_fill_upper_bit[digest] == one
    mask << zero
  else
    if already_min || zero_fill_upper_bit[digest] == one
      mask << one
    else
      mask << zero
    end
  end
end
mask = mask.to_i(2)
ans = 0
A.each { |i| ans += (i ^ mask) }
p ans

Measured memory_bytes: 30476
#include <stdio.h>
#include <string.h>

int main()
{
    int n;
    char s[101],t[101];

    int i,j;

    scanf("%d %s %s",&n,s,t);

    for (i = 0; i < n; i++)
    {
        if(s[i] == t[0])
        {
            for (j = i; j < n; j++)
            {
                if(s[j] != t[j - i])break;
            }
            if(j == n)break;
        }
    }
    
    printf("%d",n + i);
}



Measured memory_bytes: 128
import sys
from collections import deque
H,W = map(int,sys.stdin.readline().rstrip().split())
map = [[i for i in map(str,sys.stdin.readline().rstrip())] for _ in range(H)]
dist = [[-1]*W for _ in range(H)]
q = deque()
for i in range(H):
  for j in range(W):
    if map[i][j] == '#':
      q.append((i,j))
      dist[i][j] = 0

def bfs():
  while q:
    x,y = q.popleft()
    dx = [0,1,0,-1]
    dy = [1,0,-1,0]
    for i in range(4):
      nx = x + dx[i]
      ny = y + dy[i]
      if 0<= nx < H and 0 <= ny < W and map[nx][ny] == '.' and dist[nx][ny] == -1:
        dist[nx][ny] = dist[x][y] + 1
        q.append((nx,ny))
bfs()
ans = 0
for i in range(H):
  ans = max(max(dist[i][:]),ans)
print(ans)

Measured memory_bytes: 122332
#include <stdio.h>

int main(){
  int n, x;
  scanf("%d", &n);

  for(int i = 1; i <= n; i++){
        if(i % 3 == 0){
          printf(" %d", i);
          continue;
        }

        x = i;
        while(x){
          if(x % 10 == 3){
                printf(" %d", i);
                break;
          }
          x /= 10;
        }
  }

  printf("\n");
  return 0;
}


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

int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int main ()
{
  int n, sum=0;
  cin >> n;
  for(int i=1; i <= n; i++){
    for(int j=1; j <= n; j++){
      for(int k=1; k <= n; k++){
        sum += gcd(gcd(i, j), k);
      }
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3628
// JOI2015Pre Swapping Bibs
#include <iostream>

using namespace std;

int main(){

  int N,M;
  cin >> N >> M;
  
  int A[1001];  
  for(int i=1;i<=N;i++)
    cin >> A[i];
  
  for(int k=1;k<=M;k++)
    for(int i=1;i<N;i++)
      if(A[i]%k > A[i+1]%k) swap(A[i],A[i+1]);

  for(int i=1;i<=N;i++)
    cout << A[i] <<endl;

  return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  int n; cin >>n;
  string s; cin >>s;
  int res = 1001001001;
  vector<int> blacks(n+1);
  rep(i, n) if (s[i] == '#') blacks[i+1]++;
  rep(i, n) blacks[i+1] += blacks[i];
  for (int i=0; i<=n; i++){
    // [i, n) が黒であるようにする
    // [0, i) は白にする
    int tmp = blacks[i];
    int tmp2 = blacks[n] - blacks[i];
    tmp += n-i - tmp2;
    chmin(res, tmp);
  }
  cout <<res <<endl;
}

Measured memory_bytes: 1412
#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 main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int x; cin >> x;
  int ans = 0;
  ans += (x/500 * 1000);
  x%=500;
  ans += (x/5 * 5);
  cout << ans;
}


Measured memory_bytes: 256
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    vector<ll> v(5);
    rep(i,5) cin>>v[i];
    REP(i,1,10){
        rep(j,5){
            if(v[j]%10==i){
                sum+=v[j];
                v.erase(v.begin()+j);
                f=1;
                break;
            }
        }
        if(f==1) break;
    }
    rep(i,v.size()){
        if(v[i]%10!=0) sum+=10;
        sum+=v[i]/10*10;
    }
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n'; cout << fixed << setprecision(10);

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int b = 1;
	int c = 0;
	while (b <= n) {
		int l = to_string(b).size();
		if (l % 2 != 0) ++c;
		++b;
	}
	cout << c;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

//#define DEBUG

#ifdef DEBUG
constexpr int K = 5;
#else
constexpr int K = 9;
#endif

template <class F>
int lower_bound(int i0, int i1, F f) {
    while (i0 < i1) {
        int i = (i0 + i1) / 2;
        if (f(i)) i1 = i; else i0 = i + 1;
    }
    return i0;
}

constexpr int64_t pow10(int k) {
    int64_t r = 1;
    for (int i = 0; i < k; i++) r *= 10;
    return r;
}

bool query(int64_t n) {
    if (n > pow10(K * 2)) throw;
    cout << "? " << n << endl;
#ifdef DEBUG
    constexpr int64_t N = 1234;
    return !((n <= N) ^ (to_string(n) <= to_string(N)));
#else
    char a;
    cin >> a;
    return a == 'Y';
#endif
}

int main() {
    int64_t r = 0, t = 10;

    for (int j = 0; j < K; j++) {
        r *= 10;
        int i = lower_bound(1, 10, [&](int i) {
            // n>Nなのでstr(n)>str(N)が返る ただしj==0&&i==0&&N==10^Kのときは両方逆になって上手くいく
            return query((r + i) * pow10(K)); // iが大きくなるほど満たされやすくなる条件
        });
        if (j == 0 && i == 1) {
            // 辞書順で10^Kのほうが大きいということは、10冪だった
            t = 3;
            r = 0;
            break;
        }
        r += i - 1; // 求めやすいようにupper_bound
    }
    // lower_boundに直す
    r += 1;

    while (r % 10 == 0) r /= 10;
    while (t <= r) t *= 10;

    for (int i = 0; i < K; i++) {
        // 10冪のとき、str(n)>str(N)なのでn>Nが返る
        // ちがうとき、str(n)<str(N)なのでn<=Nが返る
        if ((t % 3 != 0) ^ query(t)) break;

        t *= 10;
        r *= 10;
    }

    cout << "! " << r << endl;

    return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n; cin>>n; 
    vector<bool> seat(100010, false);
    for(int i=0; i<n; i++){
        int l, r; cin>>l>>r;
        for(int j=l; j<=r; j++){
            seat[j]=true;
        }
    }

    int ans=0;
    for(int i=1; i<=100000; i++){
        if(seat[i]) ans++;
    }
    cout << ans << endl;
}

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

typedef long long ll;
typedef long double ld;

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

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    string S;

    cin >> S;

    cout << (S[0] != S[1] && S[1] != S[2] && S[2] != S[3] ? "Good" : "Bad") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

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

    // ll ans = 0;
    REP(i, 0, T.size()) {
        if (T[i] == 'D') {
            // ans++;
        } else if (T[i] == 'P') {
            if (i < T.size() - 1) {
                if (T[i + 1] == 'D') {
                    // ans++;
                }
                if (T[i + 1] == '?') {
                    T[i + 1] = 'D';
                    // ans++;
                }
            }
        } else {
            T[i] = 'D';
            // ans++;
        }
    }
    // cout << ans << endl;
    cout << T << endl;
    return 0;
}

Measured memory_bytes: 3756
#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;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    ll h, w;
    cin >> h >> w;
    if (h % 3 == 0 || w % 3 == 0) {
        cout << 0;
        return 0;
    }
    ll best = 1e18;
    best = min(best, min(h, w));
    for (int it = 0; it < 2; it++) {
        for (int sz = 0; sz <= h; sz++) {
            ll ar = sz * w;
            ll other_ar = (h - sz) * (w / 2);
            ll other_ar2 = (h - sz) * ((w + 1) / 2);
            best = min(best, max({abs(other_ar - other_ar2), abs(ar - other_ar), abs(ar - other_ar2)}));
        }
        swap(h, w);
    }
    cout << best;
    return 0;
}

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

int main(){
	string s;
	cin >> s;
	if(s.size() < 4){
		cout << "No" << endl;
		return 0;
	}
	bool f = true;
	for(int i = 0; i < 4; i++){
		f &= s[i] == "YAKI"[i];
	}
	cout << (f ? "Yes" : "No") << endl;
	return 0;
}

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

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<ll, ll> pii;
typedef vector< ll > vl;
typedef vector< pii > vpii;

#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;



//DONT WASTE YOUR TIME......i said don't waste -_- 
//prove yourself remember....fuck ps&&as hard....show them your are better then them
//Be confident.....dont lose hope.......You can do it.....
//dimaag  khoob h tere meh ....bas concentration ki kami h
//CONCENTRATE
//A,B,C dimaag nhi ...observation h .....zyaada mat sochna unme.....bas observe karna dhyaan se aur implement kar daal jitni jaldi ho sake

//capture it

// fortunately or unfortunately tu sabse badaah chodu h ....ek number ka chutiyaa -_-

const ll N= 1e6+55,mod = 1e9+7;

ll gg[N];
int main() {
 	//freopen("task.in","r",stdin);freopen("task.out","w",stdout);
	ll n,m,i,j,k,a,b,c,x,y,z;
	sc(n);sc(m);sc(x);
	for(i=1;i<=m;i++){
		sc(j);
		gg[j]++;
	}
	for(i=1;i<=n;i++){
		gg[i]+=gg[i-1];
	}
	a=min(gg[n]-gg[x],gg[x]);
	pr(a);
}

Measured memory_bytes: 256
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)


  val N = in.next().toInt
  var b = new Array[Int](N+1)
  for(i <- 1 to N)
    b(i) = in.next().toInt


  //
  var ans = List[Int]()

  for(i <- 1 to N) {
    breakable{
      for(k <- (1 to (N-i+1)).reverse) {
        if(b(k) == k) {
          //println(k, b(k))
          ans = b(k) :: ans
          b = b.take(k) ++ b.drop(k+1)
          break
        }
      }
    }
  }


  if(ans.length != N)
    println(-1)
  else {
    for (e <- ans)
      pw.println(e)
    pw.flush()
  }
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}



Measured memory_bytes: 27456
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, Z, W;
  cin >> N >> Z >> W;
  vector<int> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  if (N == 1){
    cout << abs(W - a[N - 1]) << endl;
  } else {
    cout << max(abs(W - a[N - 1]), abs(a[N - 2] - a[N - 1])) << endl;
  }
}

Measured memory_bytes: 3580
import sys
arr = [0]*5
for i in range(5):
    arr[i] = int(input())
k = int(input())

for j in range(5):
    for n in range(j+1, 5):
        if (arr[n] - arr[j]) > k:
            print(':(')
            sys.exit()
print('Yay!')


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

int main(){
  int n, m, l;
  long long A[100][100], B[100][100], C[100][100];

  cin >> n >> m >> l;
  for(int i = 0; i < n; i++)
    for(int j = 0; j < m; j++) cin >> A[i][j];
  for(int i = 0; i < m; i++)
    for(int j = 0; j < l; j++) cin >> B[i][j];

  for(int i = 0; i < n; i++){
    for(int j = 0; j < l; j++){
      C[i][j] = 0;
      for(int k = 0; k < m; k++){
        C[i][j] += A[i][k]*B[k][j];
      }
    }
  }

  for(int i = 0; i < n; i++){
    for(int j = 0; j < l; j++){
      if(j) cout << " ";
      cout << C[i][j];
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3280
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define RFOR(i, a, b) for(int i = a; i >= b; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
const int INF = 1e9;
typedef long long ll;
using namespace std;
int main() {
    int n;
    cin >> n;
    int v[n], c[n];
    int x = 0;
    int y = 0;
    int ans = 0;
    REP(i, n) cin >> v[i];
    REP(i, n) cin >> c[i];
    REP(bit, 1<<n) {
        x = 0;
        y = 0;
        REP(i, n) {
            if(bit & 1<<i) {
                x += v[i];
                y += c[i];
            }
        }
        ans = max(ans, x-y);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
import numpy as np
N, K = map(int, input().split())
L = np.array(list(map(int, input().split())))

L = np.sort(L)
pos = L[0<L]
neg = L[0>L]
zero = len(L[L==0])

def f(x):
  tmp = 0
  if x>=0:
    tmp += zero*N
  tmp += np.searchsorted(L, x//pos, side='right').sum()
  tmp += (N - np.searchsorted(L, -(-x//neg), side='left')).sum()
  tmp -= np.count_nonzero(L*L<=x)
  return tmp//2

l, r = -10**18, 10**18
while l<r-1:
  m = (l+r)//2
  count = f(m)
  if count >= K:
    r = m
  else:
    l = m

print(r)

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

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    int num;
    long long sum=0;
    cin >> num;

    for(int i=1; i<=num; i++){
        if((i%3!=0)&&(i%5!=0)) sum=sum+i;
    }
    cout << sum;

}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
typedef long long ll;
typedef pair<ll,ll> P;
//#define rep(i,a,b) for(int i=a ; i<b ; i++)
const int max_n = 1e5;
const ll mod = 1e9+7;
int main(){
  int n,k; cin >> n >> k;
  string s; cin >> s;
  vector<int> v;
  if(s[0]=='0') v.pb(0);
  for(int i=0; i<n;){
    int j = i;
    while(s[i]==s[j] && j<n){
      j++;
    }
    v.pb(j-i);
    i = j;
  }
  if(s.back()=='0') v.pb(0);
  vector<int> sums((int)v.size()+1, 0);
  for(int i=0;i<v.size();i++){
    sums[i+1] = sums[i] + v[i];
  }
  int res = 0;
  for(int left=0 ; left<sums.size() ; left+=2) {
    int right = left+2*k+1;
    if(right>=sums.size()) right = (int)sums.size()-1;
    res = max(res, sums[right]-sums[left]);
  }
  cout << res << endl;
  return 0;
}


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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }
    ll now=a.at(0);
    ll ans=0;
    for(int i=1; i<n; i++){
        now=max(now, a.at(i));
        ans += now-a.at(i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4784
use strict;
my $n=<>;
my $y;
my $x;
my $a=0;
my $b=0;
my $c=0;
my $d=0;
for($x=0;$x<$n;$x++){
$y=<>;
chomp $y;
if($y eq 'AC'){$a=$a+1;}
elsif($y eq 'WA'){$b=$b+1;}
elsif($y eq 'TLE'){$c=$c+1;}
else{$d=$d+1}
}
print"AC x $a\nWA x $b\nTLE x $c\nRE x $d";

Measured memory_bytes: 4848
N=int(input())
T,A=map(int,input().split())
H=list(map(int,input().split()))
ans=0
t=10**18
for i,h in enumerate(H):
  x=T-h*0.006
  if abs(x-A)<t:
    t=abs(x-A)
    ans=i
print(ans+1)

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
int n,cnt[SZ],m=100000;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int a;
		scanf("%d",&a);
		cnt[a]++;
	}
	int N=n,myy=0;
	for(int i=1;i<=m;i++)
	{
		if(!cnt[i]) continue;
		myy+=cnt[i]-1;
	}
	N-=myy;
	if(myy%2==1) --N;
	cout<<N<<"\n";
}


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

int main()
{
    while(1)
    {
        int n,x;
        cin >> n >> x;
        
        if(n == 0 &&x == 0) break;
        
        int cnt = 0;
        
        for(int a = 1;a <= n;a++)
        {
            for(int b = a+1;b <= n;b++)
            {
                for(int c = b+1;c <= n;c++)
                {
                    if(a+b+c == x)cnt++;
                }
            }
        }
        cout << cnt << endl;
    }
    return 0;
}


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

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

  string s;
  cin >> s;

  int ans = 0;
  for (auto c : s) ans += (c == '-' ? -1 : 1);

  cout << ans << '\n';

  return (0);
}


Measured memory_bytes: 3620
#include <stdio.h>
#include <algorithm>
using namespace std;
#define N (80)
int x[N], y[N], sx[N], sy[N];
int n, kk;
#define ord(a,b,c) (a<=b&&b<=c||a>=b&&b>=c)
int main(){
    long long ans = 4e18;
    scanf("%d%d", &n, &kk);
    for (int i = 1; i <= n; ++i){
        scanf("%d%d", x+i, y+i);
        sx[i] = x[i];
        sy[i] = y[i];
    }
    sort(sx+1,sx+n+1);
    sort(sy+1,sy+n+1);
    for (int i = 1; i <= n; i++){
        for (int j = i + 1; j <= n; ++j){
            for (int k = 1; k <= n; ++k){
                for (int l = k + 1; l <= n; ++l){
                    int cnt = 0;
                    for (int p = 1; p <= n; ++p){
                        if (ord(sx[i], x[p], sx[j]) && ord(sy[k], y[p], sy[l])){
                            cnt++;
                        }
                    }
                    if (cnt >= kk){
                        ans = min(ans, 1ll * (sx[j] - sx[i]) * (sy[l] - sy[k]));
                    }
                }
            }
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 128
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
from bisect import bisect_left as bl

def main():
    n, m = MII()
    py = [tuple(MII()) for _ in range(m)]
    py_dict = dict(zip(range(10**5+1), [[0] for _ in range(10**5+1)]))
    for p, y in py: py_dict[p].append(y)
    for p, yy in py_dict.items():
        if yy != [0]: yy.sort()
    for p, y in py:
        idx = bl(py_dict[p], y)
        print(str(p).zfill(6)+str(idx).zfill(6))

if __name__ == '__main__':
    main()


Measured memory_bytes: 39292
#include <stdio.h>

int main(void)
{
	int num;
	int i;
	
	int cnt[26];
	char ch;
	
	for(i = 0; i < 26; i++)
	{
		cnt[i] = 0;
	}
	
	while(scanf("%c", &ch) != EOF)
	{
		if(ch >= 'A' && ch <= 'Z')
		{
			num = ch + 32 - 'a';
			cnt[num]++;
		}
		else if(ch >= 'a' && ch <= 'z')
		{
			num = ch - 'a';
			cnt[num]++;
		}
	}
	for(i = 0; i < 26; i++)
	{
		printf("%c : %d\n", 'a' + i, cnt[i]);
	}
	return 0;
}

Measured memory_bytes: 540
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " <<
#define outdicimal out << fixed << setprecision(10)//TODO 小数点以下の桁数の変更
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;


class CWhenIHitMyPocket {
public:
	void solve(std::istream& in, std::ostream& out) {
	  int k,a,b;
	  in >> k >> a >> b;
	  int ans = 0;
	  if(a + 1 < b){
	    int t = max((k - (a + 1)) / 2, 0ll);
	    ans += (b - a) * t;
	    ans += max(k - (a + 1) - 2 * t, 0ll);
	    if(k < a + 1) ans += k + 1;
	    else ans += b;
	  }
	  else{
      ans += k + 1;
	  }
	  out << ans << endl;
	}
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
	CWhenIHitMyPocket solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
from itertools import permutations


N, M, *ab = map(int, open(0).read().split())
g = [[] for _ in range(N)]
for a, b in zip(*[iter(ab)] * 2):
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

ans = 0
for path in permutations(range(1, N)):
    v = 0
    for nv in path:
        if nv not in g[v]:
            break
        v = nv
    else:
        ans += 1
print(ans)



Measured memory_bytes: 9208
n = int(input())

def dfs(num):  
  if(int(num) > n):
    return 0
  res = 1 if(all(num.count(c) > 0 for c in "753")) else 0
  for i in "753":
    res += dfs(num + i)

  return res

print(dfs("0"))  


Measured memory_bytes: 2940
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


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

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

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

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

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};



int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b;

	cin >> a;
	cin >> b;

	ll ans = 0;

	if (a == 1 && b == 1)ans = 1;

	if (a == 1 && b > 2)ans = b - 2;

	if (b == 1 && a > 2)ans = a - 2;

	if (a > 2 && b > 2)ans = (a - 2) * (b - 2);
	
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define mymalloc(p,n) {p = malloc((n)*sizeof(*p));if ((p)==NULL) {printf("not enough memory?\n"); exit(1);};}

void print(int fact, int flag){
	if(flag==0){
		printf("%d\n",fact);
	}else{
		printf("%d ",fact);
	}
}

int divide(int root,int *A,int *B,int p,int q,int flag){
	int i;
	if(q-p==0){
		print(B[q],flag);
		return root;
	}
	for(i=p;i<=q;i++){
		if(B[i]==A[root]){
			if(i>p){root=divide(root+1,A,B,p,i-1,1);}
			if(i<q){root=divide(root+1,A,B,i+1,q,1);}
			print(B[i],flag);
			return root;
		}
	}
}

main(){
	int i,n;
	int *A,*B;
	scanf("%d",&n);
	mymalloc(A,n);
	mymalloc(B,n);
	for(i=0;i<n;i++){
		scanf(" %d",&A[i]);
	}
	for(i=0;i<n;i++){
		scanf(" %d",&B[i]);
	}
	divide(0,A,B,0,n-1,0);
	free(A);free(B);
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
char board[55][55];
int main()
{
    int n,m;
    cin>> n>>m;
    for(int i = 1;i <= n;i++)
    {
        for(int j = 1;j <= m;j++)
            cin >> board[i][j];
    }
    for(int i = 1;i <= n;i++)
    {
        for(int j = 1;j <= m;j++)
        {
            if(board[i][j] == '#')
            {
                if(board[i+1][j] != '#' && board[i-1][j] != '#' && board[i][j+1] != '#' && board[i][j-1] != '#')
                {
                    cout << "No";
                    return 0;
                }
            }
        }
    }
    cout << "Yes";
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, a[200];

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    bool ok = true;
    for (int i = 0; i < n; i++) {
        if (a[i] % 2 == 0) {
            if (a[i] % 3 && a[i] % 5) {
                ok = false;
                break;
            }
        }
    }
    if (ok) cout << "APPROVED" << E;
    else cout << "DENIED" << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
from itertools import product
n = int(input())
s = input()

ans = 0
for x, y, z in product(range(10), repeat=3):
    index_1 = s.find(str(x))
    index_2 = s.find(str(y), index_1+1)
    index_3 = s.find(str(z), index_2+1)
    if index_1 != -1 and index_2 != -1 and index_3 != -1:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#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 ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const bool debug = 0;
//------------------------------//

int N, M, X;
vector<pii> g[11234];
int t[11234];
int dp[11234][420];

int main() {
	cin >> N >> M >> X;
	REP(i, N) scanf("%d", t + i);
	REP(i, M) {
		int a, b, d;
		scanf("%d %d %d", &a, &b, &d);
		a--; b--;
		g[a].push_back(pii(b, d));
		g[b].push_back(pii(a, d));
	}
	
	priority_queue<pip, vector<pip>, greater<pip> > pq; // time, (pos, past)
	fill(dp[0], dp[N], INF);
	if (t[0] != 2) pq.push(pip(0, pii(0, 0))); dp[0][0] = 0;
	if (t[0] != 0) pq.push(pip(0, pii(0, 210))); dp[0][210] = 0;
	
	while (!pq.empty()) {
		int cost = pq.top().fi, u = pq.top().se.fi, p = pq.top().se.se;
		pq.pop();
		
		if (dp[u][p] < cost) continue;
		
		REP(i, g[u].size()) {
			int v = g[u][i].fi;
			int nextc = cost + g[u][i].se;
			int nextp = -1;
			
			if (t[v] == 0) {
				if (p <= 200) nextp = 0;
				if (t[u] == 1 && p + g[u][i].se >= 210 + X) nextp = 0;
				if (t[u] == 2 && g[u][i].se >= X) nextp = 0;
			}
			else if (t[v] == 1) {
				int ma = p <= 200 ? X : 210 + X;
				nextp = min(ma, p + g[u][i].se);
			}
			else {
				if (p >= 210) nextp = 210;
				if (t[u] == 1 && p <= 200 && p + g[u][i].se >= X) nextp = 210;
				if (t[u] == 0 && g[u][i].se >= X) nextp = 210;
			}
			
			if (nextp == -1) continue;
			if (chmin(dp[v][nextp], nextc)) pq.push(pip(nextc, pii(v, nextp)));
		}
	}
	
	int ans = INF;
	REP(i, 411) chmin(ans, dp[N - 1][i]);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 20640
#include<iostream>
#include<numeric>

using namespace std;

int main(){
    long long a, b, c, d,cd, tmp;
    long long cn, dn, cdn;
    cin>>a>>b>>c>>d;
    cd = c * d;
    if(c<d){
        tmp = c;
        c = d;
        d = tmp;
    }
    cn = b / c - (a-1) / c;
    dn = b / d - (a-1) / d;

    long long r = c % d;
    while(r != 0){
        c = d;
        d = r;
        r = c % d;
    }
    cd = cd / d;

    cdn = b / cd - (a-1) / cd;


    cout<<b - a + 1 - cn - dn + cdn<<endl;
}

Measured memory_bytes: 256
from collections import Counter


def main():
    n = int(input())
    a = []
    for i in range(n):
        a.append(int(input()))
    counter = Counter(a)
    ans = 0
    for key, value in counter.items():
        if value % 2 == 1:
            ans += 1
    print(ans)


main()


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int n, sum= 0;
    cin>> n;

    int in[n+1], a[n+1], b[n+1];

    for(int i=1; i<=n; i++)
        cin>> in[i];

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

    for(int i=1; i<n; i++)
        cin>> b[i];

    for(int i=1; i<n; i++)
        {
            if(in [i]+1 == in[i+1])
                sum += b[ in[i]];
        }


    cout<< sum << '\n';

    return 0;
}




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

  int ans;
  if(N % 1000 == 0){
    ans = 0;
  }else{
    ans = (N / 1000 + 1) * 1000 - N;
  }
  cout << ans << endl;
}

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

#define pb push_back

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll INF = (ll)1<<62;
const ll MOD = 1e9+7;

vector<int> adj[100005];
int par[100005];
int dist[100005];

void bfs(int src){
	par[src] = 0;
	dist[src] = 0;
	queue<int> q;
	bool vis[100005];
	memset(vis, 0, sizeof vis);
	memset(par, -1, sizeof par);
	q.push(src);
	while(!q.empty()){
		int u = q.front();
		q.pop();
		for(int i=0;i<adj[u].size();i++){
			int v = adj[u][i];
			if(!vis[v]){
				vis[v] = 1;
				par[v] = u;
				dist[v] = dist[u]+1;
				q.push(v);
			}
		}
	}
}

int main(){
	int n, m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a, b;
		cin>>a>>b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	bfs(1);
	for(int i=2;i<=n;i++){
		if(par[i] == 0){
			cout<<"No\n";
			return 0;
		}
	}
	cout<<"Yes\n";
	for(int i=2;i<=n;i++)
		cout<<par[i]<<"\n";
	return 0;
}

Measured memory_bytes: 11000
N = int(input())
C = [0]*4

for n in range(N):
    data = input()
    if "AC" == data:
        C[0] += 1
    elif "WA" == data:
        C[1] += 1
    elif "TLE" == data:
        C[2] += 1
    elif "RE" == data:
        C[3] += 1

print("AC x ", C[0])
print("WA x ", C[1])
print("TLE x ", C[2])
print("RE x ", C[3])

Measured memory_bytes: 9220
using System;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		if(s[1]==1||s[1]==s[0]*2-1){Console.WriteLine("No");}
		else{
			Console.WriteLine("Yes");
			int[] a=new int[s[0]*2];
			for(int i=1;i<s[0]*2;i++){a[i]=i;}
			if(s[0]==2){}
			else if(s[1]==2){
				a[2]=s[0]-1;a[s[0]-1]=2;
				a[1]=s[0];a[s[0]]=1;
			}
			else{
				a[s[1]]=s[0];a[s[0]]=s[1];
				a[s[0]*2-1]=a[s[0]-1];
				a[s[0]-1]=s[0]*2-1;
				a[1]=a[s[0]+1];a[s[0]+1]=1;
				if(a[2]==2){a[2]=a[s[0]-2];a[s[0]-2]=2;}
			}
			for(int i=1;i<s[0]*2;i++){Console.WriteLine("{0}",a[i]);}
		}
	}
}

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

int main(){
    int n, c[20], v[20], x, y, ans;
    
    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        cin >> c[i];
    }
    for ( int i = 0; i < n; i++ ) {
        cin >> v[i];
    }
     
    ans = 0;
    for ( int i = 0; i < (1<<n); i++ ) {
        x = y = 0;
        for ( int j = 0; j < n; j++ ) {
            if ( i & (1<<j) ) {
                x += c[j];
                y += v[j];
            }
        }
        ans = max(ans, x-y);
    }
     
    cout << ans << endl;
     
    return (0);
}


Measured memory_bytes: 3516
import sys

N=int(sys.stdin.readline())
A=list(map(int,sys.stdin.readline().split()))
B=list(map(int,sys.stdin.readline().split()))

ANS=""
for i in range(1,30):
    k=2**i
    XA=sorted([a%k for a in A],reverse=True)
    XB=sorted([b%k for b in B])
    XB.append(k*2)

    b0=0
    b1=0
    b2=0
    count=0

    for xa in XA:
        for j in range(b0,N+1):
            if k//2<=xa+XB[j]:
                b0=j
                break

        if b1<b0:
            b1=b0

        
        for j in range(b1,N+1):
            if xa+XB[j]>=k:
                b1=j
                break

        if b2<b1:
            b2=b1

        for j in range(b2,N+1):
            if k*3//2<=xa+XB[j]:
                b2=j
                break

        count+=(b1-b0+N-b2)

    ANS+=str(count%2)

print(int(ANS[::-1],2))

Measured memory_bytes: 144844
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
#define all(a) a.begin(),a.end()
using namespace std;
int main(void){
	int t;
	cin>>t;
	if(t>=30)cout<<"Yes";
	else cout<<"No";
	return 0;
} 

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template <typename T>
struct SegmentTree {
    int n;
    vector<T> node;
    T calc(T a, T b) {
        return min(a, b);
    }
    T e = LINF;
    SegmentTree(vector<T> v) {
        int sz = v.size();
        n = 1;
        while (n < sz) {
            n *= 2;
        }
        node.resize(2 * n - 1, e);
        for (int i = 0; i < sz; i++) {
            node[i + n - 1] = v[i];
        }
        for (int i = n - 2; i >= 0; i--) {
            node[i] = calc(node[2 * i + 1], node[2 * i + 2]);
        }
    }
    SegmentTree(T sz) {
        n = 1;
        while (n < sz) {
            n *= 2;
        }
        node.resize(2 * n - 1, e);
    }
    void update(int x, T val) {
        x = n + x - 1;
        node[x] = val;
        while (x > 0) {
            x = (x - 1) / 2;
            node[x] = calc(node[2 * x + 1], node[2 * x + 2]);
        }
    }
    void add(int x, T val) {
        x = n + x - 1;
        node[x] += val;
        while (x > 0) {
            x = (x - 1) / 2;
            node[x] = calc(node[2 * x + 1], node[2 * x + 2]);
        }
    }
    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return e;
        if (a <= l && r <= b) return node[k];
        T vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        T vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return calc(vl, vr);
    }
    T at(int x) {
        return node[n + x - 1];
    }
};
int main() {
    int n, q;
    cin >> n >> q;
    vector<ll> v(n, (1LL << 31) - 1);
    SegmentTree<ll> segt(v);
    while (q--) {
        int com;
        cin >> com;
        if (com) {
            int x, y;
            cin >> x >> y;
            cout << segt.query(x, y + 1) << endl;
        } else {
            int x;
            ll y;
            ;
            cin >> x >> y;
            segt.update(x, y);
        }
    }
}



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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int expo(int base,int exponent,int mod){
    int ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
int n,k,a[100005],ans;
void solve(){
	cin>>n>>k;
	for(int i=k;i>=1;i--){
		a[i]=k/i;
		a[i]=expo(a[i],n,hell);
		for(int j=2*i;j<=k;j+=i){
			a[i]=(a[i]-a[j]+hell)%hell;
		}
		ans=(ans+a[i]*i)%hell;
	}
	cout<<ans<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 4388
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<int> >a(h,vector<int>(w));
  int i,j;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      cin >> a[i][j];
    }
  }
  vector<pair<pair<int,int>,pair<int,int> > >p;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(a[i][j]%2==1){
        if(j!=w-1){
          a[i][j+1]++;
          p.push_back(make_pair(make_pair(i+1,j+1),make_pair(i+1,j+2)));
        }else if(i!=h-1){
          a[i+1][j]++;
          p.push_back(make_pair(make_pair(i+1,j+1),make_pair(i+2,j+1)));
        }
      }
    }
  }
  cout<<p.size()<<endl;
  for(i=0;i<p.size();i++){
    cout<<p[i].first.first<<" "<<p[i].first.second<<" "<<p[i].second.first<<" "<<p[i].second.second<<endl;
  }
}


Measured memory_bytes: 5232
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x;
        int i = 0;

        while ((x = scanner.nextInt()) != 0) {
            System.out.println("Case " +(++i)+": " +x);
        }
    }
}


Measured memory_bytes: 43324
import math
def A():
    temp = [int(i) for i in input().split()]
    print(int(math.ceil(temp[0]/temp[1])))

def B():
    temp = [int(i) for i in input().split()]
    H = temp[0]
    N = temp[1]
    A = [int(i) for i in input().split()]
    if H <= sum(A):
        print('Yes')
    else:
        print('No')

def C():
    temp = [int(i) for i in input().split()]
    N = temp[0]
    K = temp[1]
    H = [int(i) for i in input().split()]
    if N <= K:
        print(0)
        return
    H.sort(reverse=True)
    print(sum(H[K:]))

def D():
    H = int(input())
    factor = 0
    ans = 0
    while True:
        ans += 2**factor
        if H == 1:
            break
        H = math.floor(H/2)
        factor += 1
    print(ans)
D()

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

#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;

using namespace std;



void one_case() {
    int h, w;
    cin >> h >> w;
    vector<string> g(h);
    for (auto& line : g) {
        cin >> line;
    }
    int cnt = 0;
    for (auto& line : g) {
        for (auto el : line) {
            cnt += el == '.';
        }
    }
    map<pair<int, int>, int> dist;
    queue<pair<int, int>> nodes;
    nodes.emplace(0, 0);
    vector<pair<int, int>> edges = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};
    dist[make_pair(0 ,0)] = 0;
    while (!nodes.empty()) {
        auto cur = nodes.front();
        nodes.pop();
        auto x = cur.first;
        auto y = cur.second;
        for (auto p : edges) {
            auto a = x + p.first;
            auto b = y + p.second;
            if (0 > a || 0 > b || a >= h || b >= w) {
                continue;
            }
            if (g[a][b] == '#') {
                continue;
            }
            if (dist.count(make_pair(a, b))) {
                continue;
            }
            dist[make_pair(a, b)] = 1 + dist[cur];
            nodes.emplace(a, b);
        }

    }



    if (dist.count(make_pair(h - 1, w - 1)) == 0) {
        cout << "-1\n";

    } else {
        auto path = dist[make_pair(h - 1, w - 1)];
        cout << cnt - path - 1 << "\n";
    }


}


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


    int t = 1;
//    cin >> t;
    while (t--) {
        one_case();
    }

    return 0;
}


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

using namespace std;
const int IINF = INT_MAX;
using ll = long long;
using P = pair<int,int>;
#define INF 100000000

const double pai = 3.141592653589793238;
int main(){
    int n; cin >> n;
    int d[n]; 

    rep(i,n) cin >> d[i];
    int ans = 0;
    for(int i = 0; i < n; i++){
    	for(int j = i+1; j < n; j++){
    		ans+=d[i]*d[j];
    	}
    }
     cout << ans << endl;
    return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); if (n == 0) cout << endl; REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    ll n, m;
    cin >> n >> m;
    cout << (1900 * m + 100 * (n - m)) * (ll)pow(2, m) << endl;
}


Measured memory_bytes: 3888