akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

// ^= -> ビットごとの排他的論理和を計算する




signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	int ans = 1;
	char now = s[0];
	for (int i = 1; i < s.size(); i++) {
		if (s[i] == now) {
			i++;
			now = '*';
			if (i >= s.size())break;
		}
		else {
			now = s[i];
		}
		ans++;
	}
	cout << ans << endl;
	return 0;
}

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



int main(void){
    int N;
    scanf("%d",&N);
    int ans=0;
    for(int i=1;i<=N;i+=2){
        int tmp=0;
        for(int j=1;j<=N;j++)if(i%j==0)tmp++;
        if(tmp==8)ans++;
    }
    printf("%d",ans);
    return 0;
}


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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	int H,W,h,w;
	cin >> H >> W >> h >> w;

	H-=h;
	W-=w;
	cout << H*W << endl;

	return 0;
}

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

int bubblesort(int A[], int N) {
	int flag = 1;
	int i = 0;
	int count = 0;
	while (flag) {
		flag = 0;
		for (int j = N - 1; j > i; j--) {
			if (A[j] < A[j - 1]) {
				int tmp = A[j - 1];
				A[j - 1] = A[j];
				A[j] = tmp;
				flag = 1;
				count += 1;
			}
		}
		i += 1;

	}
	for (int i = 0; i < N-1; i++) {
		cout << A[i] << " ";
	}
	cout << A[N - 1] << endl;
	return count;
}

int main() {
	int N, A[100];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	cout << bubblesort(A, N) << endl;
}


Measured memory_bytes: 3120
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(){
  char w[11];
  char t[1001];
  int counter = 0;

  scanf("%s", w);

  while(1){
	scanf("%s", t);
	if(!strcmp(t, "END_OF_TEXT")){break;}

	for(int i = 0; i < strlen(t); i++){
	  t[i] = tolower(t[i]);
	}

	if(!strcmp(w,t)){
	  counter++;
	}
  }

  printf("%d\n", counter);

  return 0;
}


Measured memory_bytes: 2020
#include <algorithm>
#include <bitset>
//#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
// namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
// using ll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main() {
  ll N;
  string S;
  cin>>N;
  cin>>S;
  for(auto& c:S){
    c+=N;
    if(c>'Z'){
      c-=26;
    }
  }
  cout<<S;
  return 0;
}


Measured memory_bytes: 256
function main(input) {
  const args = input.split(' ');
  let A = Number(args[0]);
  let B = Number(args[1]);
  let K = Number(args[2]);
  let Arr = A < B ? [A, B] : [B, A];
  let result = Array.from(Array(Arr[0]), (v, i) => i + 1).reduce((sum, cu) => {
    if (Number.isInteger(Arr[0] / cu) && Number.isInteger(Arr[1] / cu)) {
      sum.push(cu);
      return sum;
    }
    return sum;
  }, []);
  const res = result.reverse();
  console.log(res[K - 1]);
}

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


Measured memory_bytes: 7372
#include <iostream>

using namespace std;

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

  int num = 1;

  for (int i = 0; i < d; i++) {
    num *= 100;
  }

  if (n == 100) {
    num *= 101;
  } else {
    num *= n;
  }

  cout << num << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> v(h+2, vector<int> (w+2, 1));
    queue<pair<int, int>> Q;
    for (int i = 0; i < h; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < w; ++j) {
            v[i+1][j+1] = (s[j] == '#');
            if(v[i+1][j+1]) Q.emplace(i+1, j+1);
        }
    }
    auto visited = v;
    int di[] {1, -1, 0, 0}, dj[]{0, 0, -1, 1};
    int ans = 1;
    while(!Q.empty()){
        int p, q; tie(p, q) = Q.front(); Q.pop();
        for (int i = 0; i < 4; ++i) {
            if(!v[p+di[i]][q+dj[i]]){
                v[p+di[i]][q+dj[i]] = v[p][q]+1;
                ans = max(ans, v[p+di[i]][q+dj[i]]);
                Q.emplace(p+di[i], q+dj[i]);
            }
        }
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            ans = max(ans, v[i+1][j+1]);
        }
    }
    cout << ans-1 << "\n";
    return 0;
}

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

int main(){
  string S;
  cin >> S;
  
  int ans;  
  if(S == "SAT") ans = 1;
  if(S == "FRI") ans = 2;
  if(S == "THU") ans = 3;
  if(S == "WED") ans = 4;
  if(S == "TUE") ans = 5;
  if(S == "MON") ans = 6;
  if(S == "SUN") ans = 7;
  cout << ans << endl;
  return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<vector<int>> to(N), cost(N);

	for (int i = 0; i < N - 1; i++) {
		int a, b, w;
		cin >> a >> b >> w;
		a--;
		b--;
		to[a].push_back(b);
		to[b].push_back(a);
		cost[a].push_back(w);
		cost[b].push_back(w);
	}

	vector<int> ans(N, - 1);
	queue<int> q;

	ans[0] = 0;
	q.push(0);

	while (!q.empty()) {
		int v = q.front();
		q.pop();

		for (int i = 0; i < to[v].size(); i++) {
			int u = to[v][i];
			int w = cost[v][i];
			
			if (ans[u] != -1)
				continue;
			ans[u] = (ans[v] + w) % 2;
			q.push(u);
		}
	}

	for (int x : ans) {
		cout << x << endl;
	}
	
	return 0;

}


Measured memory_bytes: 11904
n = gets.to_i
restrans = {}
n.times do |i|
  restrans[i + 1] = gets.split.map(&:chomp)
end

restrans.sort { |a, b|
  (a[1][0] <=> b[1][0]) != 0 ? a[1][0] <=> b[1][0] : -a[1][1].to_i <=> -b[1][1].to_i
}.each { |x| puts x[0] }


Measured memory_bytes: 1788
use std::io::prelude::*;

fn main() {
    let mut input_str = String::new();
    std::io::stdin().read_to_string(&mut input_str).unwrap();

    let input_parts = input_str.split_whitespace().collect::<Vec<_>>();
    let mut input_parts_it = input_parts.iter().cloned();

    let n: u32 = input_parts_it.next().unwrap().parse().unwrap();
    let x: u32 = input_parts_it.next().unwrap().parse().unwrap();

    let mut d = 0;

    let mut i = 0;
    while i < n {
        let l: u32 = input_parts_it.next().unwrap().parse().unwrap();

        if d + l > x {
            break;
        }
        d += l;

        i += 1;
    }

    println!("{}", i + 1);
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;

namespace c
{
    class Program
    {
        public static readonly long INF = 999999999999;
        public static readonly long MOD = 1000000007;

        static void Main(string[] args)
        {
            var n = Scanner.IntScan()[0];
            var xy = new List<List<int[]>>();

            for(var i = 0; i < n; i++)
            {
                var a = Scanner.IntScan()[0];
                var z = new List<int[]>();
                for(var j = 0; j < a; j++)
                {
                    z.Add(Scanner.IntScan());
                }
                xy.Add(z);
            }
            var res = 0;
            for(var bit = 0; bit < (1 << n); bit++)
            {
                var sum = 0;
                var ok = true;
                for (var i = 0; i < n; i++)
                {
                    if(((bit >> i)&1) == 1)
                    {
                        sum++;
                        foreach(var a in xy[i])
                        {
                            if(((bit >> (a[0]-1))&1) == a[1])
                            {
                            }
                            else
                            {
                                ok = false;
                            }
                        }
                    }
                }
                if (ok)
                {
                    if (res < sum) res = sum;
                }
            }
            Console.WriteLine(res);
        }
    }

    public class Scanner
    {
        public static string[] Scan() => Console.ReadLine().Split(' ');
        public static int[] IntScan() => Array.ConvertAll(Scan(), int.Parse);
        public static long[] LongScan() => Array.ConvertAll(Scan(), long.Parse);
        public static string[][] Scan(int n) => Enumerable.Repeat(0, n).Select(_ => Scan()).ToArray();
        public static int[][] IntScan(int n) => Enumerable.Repeat(0, n).Select(_ => IntScan()).ToArray();
        public static long[][] LongScan(int n) => Enumerable.Repeat(0, n).Select(_ => LongScan()).ToArray();

    }

    public class Ex
    {
        public static bool Chmin(ref int a, int b) { if (a > b) { a = b; return true; } return false; }
        public static bool Chmin(ref long a, long b) { if (a > b) { a = b; return true; } return false; }
        public static bool Chmax(ref int a, int b) { if (a < b) { a = b; return true; } return false; }
        public static bool Chmax(ref long a, long b) { if (a < b) { a = b; return true; } return false; }
        public static int[] SubArr(int[] arr, int begin, int n) { int[] a = new int[arr.Length]; Array.Copy(arr, begin, a, 0, n); return a; }
    }
}


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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    double result{0};
    lol n; cin >> n;
    double a = (double)n/3;
    result = pow(a, 3);

    cout << fixed << setprecision(7) << result << endl;
    return 0;
}

Measured memory_bytes: 4088
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);
  int n, q;
  cin >> n >> q;
  priority_queue<int> que[1000];
  rep(qi, q)
  {
    int type;
    cin >> type;
    if (type == 0)
    {
      int t, x;
      cin >> t >> x;
      que[t].push(x);
    }
    else if (type == 1)
    {
      int t;
      cin >> t;
      if (!que[t].empty())
        cout << que[t].top() << endl;
    }
    else
    {
      int t;
      cin >> t;
      if (!que[t].empty())
        que[t].pop();
    }
  }

  return 0;
}



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

int main() {
    int N;
    cin >> N;
    vector<long long> A(N + 1);
    for (int i = 0; i <= N; ++i) {
        cin >> A[i];
    }
    vector<long long> L(N + 1), U(N + 1);
    L[N] = U[N] = A[N];
    for (int i = N - 1; i >= 0; --i) {
        L[i] = (L[i + 1] + 1) / 2 + A[i];
        U[i] = U[i + 1] + A[i];
    }
    if (L[0] > 1) {
        cout << -1 << endl;
        return 0;
    }
    U[0] = 1;
    for (int i = 1; i <= N; ++i) {
        U[i] = min(U[i], (U[i - 1] - A[i - 1]) * 2);
    }
    long long res = 0;
    for (long long p : U) res += p;
    cout << res << endl;
    return 0;
}

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

int main() {
  int n,a,b,c;
  cin>>n;
  vector<int> timer(n);
  map<int, int> work{};
  for(int i=0;i<n;i++){
    cin>>a>>b;
    //cout<<work[b]<<b<<a<<endl;
    if(work[b] > 0){
      c=work[b];
      //cout<<c<<endl;
      work.erase(b);
      //work.insert(make_pair(b,a+c));
      work[b]=a+c;
      continue;
    }
    //work.insert(make_pair(b,a));
    work[b]=a;
    //cout<<work[b]<<b<<a<<endl;
    timer[i]=b;
  }
  sort(timer.begin(),timer.end());
  int savetime=0;
  for(int i=0;i<n;i++){
    savetime += work[timer[i]];
    //savetime += 334;
    //cout<<savetime<<endl;
    //work.erase(timer[i]);
    if(savetime>timer[i]){
      cout<<"No";
      //cout<<work[1000]<<endl;
      exit(0);
    }
  }
  //cout<<work[1000]<<endl;
  cout<<"Yes";
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
int N, M;

int main() {
    cin >> N >> M;
    vector<int> a(N + 1, 1);
    int c;
    for (int j = 0; j < M; j++) {
        cin >> c;
        a.at(c) = 0;
    }
    if (N == 1) {
        cout << 1 << endl;
        return 0;
    }
    for (int j = N - 2; j >= 0; j--){
        if (a.at(j) == 1)
            a.at(j) = (a.at(j + 1) + a.at(j + 2)) % 1000000007;
    }

    cout << a[0] << endl;
}

Measured memory_bytes: 640
object Main extends App {
  val Array(a, b, c, x) = Iterator.continually(io.StdIn.readLine.toInt)
    .take(4).toArray

  val ans = {
    for {
      i <- 0 to a
      c500 = 500*i
      if c500 <= x
      j <- 0 to b
      c100 = 100*j
      if c500 + c100 <= x
      k <- 0 to c
      if c500 + c100 + 50*k == x
    } yield true
  }.size

  println(ans)
}

Measured memory_bytes: 25900
n = int(raw_input())
ts=0 #taro score
hs=0 #hanako score
for x in xrange(n):
    #tc:taro card/hc:hanako card
    tc,hc = raw_input().split()
    if tc > hc:
        ts += 3
    elif tc < hc:
        hs += 3
    else:
        ts += 1
        hs += 1
print "%d %d"%(ts,hs)

Measured memory_bytes: 6428
#include<stdio.h>
int main(){
  int x[5],y[5],n,ax,ay,bx,by,i,j;
  scanf("%d",&n);
  while(n--){
    for(i=0;i<5;i++)scanf("%d %d",&x[i],&y[i]);
    int f[2]={0};
    for(i=0;i<2;i++){
      for(j=0;j<3;j++){
	ax=x[(j+1)%3]-x[j];
	ay=y[(j+1)%3]-y[j];
	bx=x[i+3]-x[j];
	by=y[i+3]-y[j];
	if(ax*by>ay*bx)f[i]++;
      }
      f[i]%=3;
    }
    if(f[0]+f[1]==0||f[0]*f[1])printf("NG\n");
    else printf("OK\n");
  }
  return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<cstring>
using namespace std;
char s[200001];
int main(){
	cin>>s;
	char *start,*end;
	end=strrchr(s,'Z');
	start=strchr(s,'A');
//	if(end==NULL||start==NULL){
//		cout<<"-1"<<endl;
//	}
//	else{
		cout<<end-start+1<<endl;
//	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
#define Matrix vector< vector < long long > >
long long MOD=1000000007;
void Resize_Matrix(long long n, long long m, Matrix &M)
{
    M.clear();
    for(int j=0; j<n; j++)
    {
        M.push_back( vector< long long >() );
        M[j].clear();
        M[j].resize(m);
        for(int i=0; i<m; i++)
            M[j][i]=0;
    }
}
Matrix Matrix_Multiplication(Matrix A, Matrix B)
{
    Matrix Ans;
    long long n, m;
    Resize_Matrix(n=A.size(), m=A[0].size(), Ans);
    for(long long j=0; j<n; j++)
    {
        for(long long i=0; i<m; i++)
        {
            Ans[j][i]=0;
            for(long long k=0; k<m; k++)
            {
                Ans[j][i]+= A[j][k]*B[k][i];
                Ans[j][i]%=MOD;
            }
        }
    }
    return Ans;
}
Matrix Matrix_Exponentiation(Matrix M, long long power)
{
    if(power==1)
        return M;
    Matrix ret=Matrix_Exponentiation(M, power/2);
    ret=Matrix_Multiplication(ret, ret);
    if(power%2)
        ret=Matrix_Multiplication(ret, M);
    return ret;
}
int main()
{
    ll n, k;
    while(cin>>n>>k)
    {
        ll ans=0;
        Matrix m, b;
        Resize_Matrix(n,n,m);
        Resize_Matrix(n,1,b);
        for(int i=0; i<n; ++i){
            b[i][0]=1;
            for(int j=0; j<n; ++j){
                scanf("%lld",&m[i][j]);
            }
        }
        Matrix s=Matrix_Exponentiation(m, k);
        Matrix ss=Matrix_Multiplication(s, b);
        for(int i=0; i<n; ++i){
            ans+=ss[i][0];
            ans%=MOD;
        }
        cout<<ans<<endl;
    }
    return 0;
}




Measured memory_bytes: 1664
(ns Atcoder.ABC081-B)

(require '[clojure.string :as str])
(str/split (read-line) #" ")                                ; N
(def A (map read-string (str/split (read-line) #" ")))      ; A

(loop [vals A result 0]                                     ; vals = A, result = 0の状態からループ
  (def odd_count (count (filter odd? vals)))
  (if (= odd_count 0)                                       ; odd_count == 0であれば
    (recur (map (fn [x] (/ x 2)) vals) (inc result))        ; valsの要素に関して２で割り resultをインクリメント
    (println (str result))
    )
  )

Measured memory_bytes: 67660
#include<bits/stdc++.h>
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

void solve(){
    int a;
    cin>>a;
    cout<<(a + a*a + a*a*a);
}

int main(){
    FAST
    // int t;
    // cin>>t;
    // while(t--)
    // {
    //     solve();
    // }
    solve();
return 0;

}

Measured memory_bytes: 3588
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k <= a+b) {
        cout << min(k, a) << endl;
        return 0;
    }
    cout << a - (k-a-b) << endl;

    return 0;
}

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

#define ll long long
//~ #define endl '\n'

const int maxn = 500010;
vector< int > v(maxn), bit(maxn, 0);

struct event{
	int l, r, idx;
};

bool compare(event a, event b){
	return a.r < b.r;
}

void update(int idx, int val){
	for(; idx < maxn; idx += idx & -idx) bit[idx] += val;
}

int sum(int idx){
	int sum = 0;
	for(; idx > 0; idx -= idx & -idx) sum += bit[idx];
	return sum;
}

void solve(){
	int n, q; cin>>n>>q;
	for(int i = 0; i<n; i++){
		cin>>v[i];
	}
	event queries[q];
	for(int i = 0; i<q; i++){
		int x, y; cin>>x>>y; x--, y--;
		queries[i].l = x;
		queries[i].r = y;
		queries[i].idx = i;
	}
	sort(queries, queries + q, compare);
	int cnt = 0;
	vector< int > ans(maxn), last_visit(maxn, -1);
	for(int i = 0; i<n; i++){
		if(last_visit[v[i]] != -1){
			update(last_visit[v[i]] + 1, -1);
		}
		last_visit[v[i]] = i;
		update(i + 1, 1);
		while(cnt < q && queries[cnt].r == i){
			ans[queries[cnt].idx] = sum(queries[cnt].r + 1) - sum(queries[cnt].l);
			cnt++;
		}
	}
	for(int i = 0; i<q; i++){
		cout<<ans[i]<<endl;
	}
}

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


Measured memory_bytes: 17444
S = input()
T = input()

N = len(S)
M = len(T)

if N < M:
    print('UNRESTORABLE')
    exit()

ans = 'UNRESTORABLE'
for i in range(N-M+1):
    anss = S[:i] + T + S[i+M:]
    make = 1
    anss = list(anss)
    for j in range(N):
        if anss[j] == '?':
            if S[j] == '?':
                anss[j] = 'a'
            else:
                anss[j] = S[j]
        else:
            if anss[j] != S[j] and S[j] != '?':
                make = 0
                break
    if make:
        ans = ''.join(anss)
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<cstdlib>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#include<string>
#include<bitset>
#define lmid l,mid,rt<<1
#define rmid mid+1,r,rt<<1|1
#define ll long long
using namespace std;
int main() {
     int n;
     int c[500], s[500], f[500];
     scanf("%d", &n);
     for (int i = 0; i < n - 1; i++) {
          scanf("%d%d%d", &c[i], &s[i], &f[i]);
     }
     for (int i = 0; i < n; i++) {
          int sum = 0;
          for (int j = i; j < n - 1; j++) {
               if (sum < s[j])
                    sum = s[j];
               if (sum % f[j] != 0) {
                    sum += f[j] - (sum % f[j]);
               }
               sum += c[j];
          }
          printf("%d\n", sum);
     }
     return 0;
}


Measured memory_bytes: 256
a = [int(input()) for _ in range(int(input()))]

dp = [[0] * 5 for _ in range(len(a) + 1)]

for i, x in enumerate(a):
    m = x % 2
    y = m + (x == 0) * 2
    z = 1 - m
    
    dp[i+1][0] = dp[i][0] + x
    dp[i+1][1] = min(dp[i][:2]) + y
    dp[i+1][2] = min(dp[i][:3]) + z
    dp[i+1][3] = min(dp[i][:4]) + y
    dp[i+1][4] = min(dp[i]) + x

print(min(dp[-1]))

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


def main():
    ans = []

    for i in range(M):
        p, x = map(int, input().split())
        ans.append(sum(t)-t[p-1]+x)

    print('\n'.join(map(str, ans)))


if __name__ == '__main__':
    N = int(input())
    t = list(map(int, input().split()))
    M = int(input())

    main()

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

int lcd(int a, int b) {
  if (a < b) {
    swap(a, b);
  }
  if (b == 0) {
    return a;
  } else {
    return lcd(b, a % b);
  }
}

vector<int> O;

int b_search(int s, int e, int t) {
  int m = e / 2;
  if (O[m] == t) {
    return m;
  } else if (t < O[m]) {
    return b_search(s, m, t);
  } else {
    return b_search(m, e, t);
  }
}

int main() {
  int N;
  cin >> N;
  vector<int> dp1(N), dp2(N), A(N);
  
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    if (i == 0) {
      dp1[i] = A[i];
    } else {
      dp1[i] = lcd(A[i], dp1[i - 1]);
    }
  }
  
  int result = 1;
  for (int i = N - 1; 0 <= i; --i) {
    if (i == N - 1) {
      dp2[i] = A.at(i);
    } else if (i == 0) {
      ;
    } else {
      dp2[i] = lcd(A.at(i), dp2.at(i + 1));
    }
    
    if (i == 0) {
      result = max(result, dp2[i + 1]);
    } else if (i == N - 1) {
      result = max(result, dp1[i - 1]);
    } else {
      result = max(result, lcd(dp1[i - 1], dp2[i + 1]));
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   #ifndef ONLINE_JUDGE
      // freopen("input.txt", "r", stdin);
      // freopen("output.txt", "w", stdout);
   #endif
   int x;
   set<int> s;
   f(i,0,3){
      cin >> x;
      s.insert(x);
   }
   if(s.size() == 2){
      cout << "Yes\n";
   }else{
      cout << "No\n";
   }
   return 0;
}

Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<cmath>
#include <numeric>
using namespace std;
int main() {
	int n, h[100000], max;
	cin >> n;
	for (int a = 0; a < n; a++) {
		cin >> h[a];
	}
	max = h[0] - 1;
	for (int i = 1; i < n; i++) {
		if (max > h[i]) {
			cout << "No" << endl;
			return 0;
		}
		else if (h[i] - 1 > max) {
			max = h[i] - 1;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int dp[50];

int fib(int n){
  if(n==0 || n==1) return dp[n]=1;
  if(dp[n]!=-1) return dp[n];

  return dp[n] = fib(n-1)+fib(n-2);
}

int main(){

  int  i,n;

  for(i=0;i<50;i++) dp[i]=-1;

  scanf("%d",&n);
  printf("%d\n",fib(n));

  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> mvec(size_t a){return vector<T>(a);}template<class T, class... Ts>auto mvec(size_t a, Ts... ts){return vector<decltype(mvec<T>(ts...))>(a, mvec<T>(ts...));}/* 多次元デック */template<class T>deque<T> mdeq(size_t a){return deque<T>(a);}template<class T, class... Ts>auto mdeq(size_t a, Ts... ts){return deque<decltype(mdeq<T>(ts...))>(a, mdeq<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

int main(){
  fastio;
  ll A, B;
  cin >> A >> B;
  cout << (A-1)*(B-1) << rt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz = 1<<18;

vector <int> sdp[sz];

int main()
{
   int n;
   cin >> n;
   int emsk = 1<<n;
   for(int i=0; i<emsk; i++) {
      int x;
      scanf("%d", &x);
      sdp[i].push_back(x);
   }

   for(int i=0; i<n; i++) {
      for(int j=0; j<emsk; j++) {
         if(j & (1<<i)) {
            int k = j ^ (1<<i);
            for(int x : sdp[k]) sdp[j].push_back(x);
            sort(sdp[j].begin(), sdp[j].end(), greater<int>());
            while(sdp[j].size() > 2) sdp[j].pop_back();
         }
      }
   }
   int ans = 0;
   for(int i=1; i<emsk; i++) {
      ans = max(ans, sdp[i][0] + sdp[i][1]);
      printf("%d\n", ans);
   }
}


Measured memory_bytes: 17408
n = int(input())
l = list(map(int, input().split()))
# 昇順ソート 
l.sort()
# バイセクションサーチ（二分探索法）のライブラリbisect 
from bisect import bisect_left
# 満たされるべき条件は、a<b<c  a+b>c 
ans = 0
for i in range(n):
  for j in range(i+1, n):
    # ソートした最初の2つの数を足す
    t = l[i]+l[j]
    # bisect_left(対象リスト, 探したい値, lo=左側のインデックス, hi=右側のインデックス)
    # 2つの数の和と同じ数が、リストの何番目に入るかが求められる
    idx = bisect_left(l, t)
    # idxは、a+b=cになる境目
    # idx-(j+1)は a+b>c の条件をみたす、数がいくつあるかを計算している。
    ans += max(0, idx-j-1)
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <queue>
using namespace std;
int a[250010],d[250001],mp[250001];
int dd[4];
queue<pair<int,int>> que0,que1;
void bfs(int s,int n){
    for(int i=0;i<4;i++){
        int nw = s + dd[i];
        if(nw<0 || nw>=n*n) continue;
        que0.push({d[s],nw});
    }
    while(que0.size() || que1.size()){
        while(que0.size()){
            auto p = que0.front(); que0.pop();
            int pos = p.second,dist = p.first;
            if(d[pos]<=dist) continue;
            d[pos] = dist;
            for(int i=0;i<4;i++){
                int nw = pos + dd[i];
                if(nw<0 || nw>=n*n) continue;
                if(mp[pos]==1) que1.push({dist + 1,nw});
                else que0.push({dist,nw});
            }
        }
        if(que1.size()){
            auto p = que1.front(); que1.pop();
            int pos = p.second,dist = p.first;
            if(d[pos]<=dist) continue;
            d[pos] = dist;
            for(int i=0;i<4;i++){
                int nw = pos + dd[i];
                if(nw<0 || nw>=n*n) continue;
                if(mp[pos]==1) que1.push({dist + 1,nw});
                else que0.push({dist,nw});
            }
        }
    }
}
int main(){
    int i,j,n;
    cin >> n;
    for(i=0;i<n*n;i++){
        cin >> a[i]; a[i]--;
    }
    dd[0] = -1; dd[1] = -n; dd[2] = 1; dd[3] = n;
    for(i=0;i<n*n;i++){
        d[i] = 0; mp[i] = 1;
    }
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            int x = min(i,n - 1 - i);
            int y = min(j,n - 1 - j);
            d[i*n + j] = min(x,y);
        }
    }
    int ans = 0;
    for(i=0;i<n*n;i++){
        ans += d[a[i]];
        mp[a[i]] = 0;
        bfs(a[i],n);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6888
#include <iostream>
#include <vector>
using namespace std;
int main(){
	constexpr int INF = 1e8;
	while(1) {
		int n;
		cin>>n;
		if(!n) break;
		vector<vector<int>> d(10,vector<int>(10,INF));
		for (int i = 0; i < 10; i++)
			d[i][i] = 0;
		for (int i = 0; i < n; i++) {
			int a,b,c;
			cin>>a>>b>>c;
			d[a][b] = d[b][a] = c;
		}
		int maxTown = 0;
		for (maxTown = 0; maxTown < 10; maxTown++) {
			bool exist = false;
			for (int j = 0; j < 10; j++)
				if(d[maxTown][j] != INF && d[maxTown][j]) exist = true;
			if(!exist) break;
		}
		for (int k = 0; k < maxTown; k++)
			for (int i = 0; i < maxTown; i++)
				for (int j = 0; j < maxTown; j++)
					d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
		int minsum = INF,minidx = -1;
		for (int i = 0; i < maxTown; i++) {
			int sum = 0;
			for (int j = 0; j < maxTown; j++)
				sum += d[i][j];
			if(minsum > sum) {
				minsum = sum;
				minidx = i;
			}
		}
		cout << minidx << ' ' << minsum << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
#define vsort_r(v) sort(v.begin(), v.end(), greater<ll>())
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

#define MAX_N 50
int N, A, B;

ll C[51][51];

void comb(int N) {
	rep(i, 0, N + 1) rep(j, 0, i + 1) {
		if(j == 0 || i == j) C[i][j] = 1LL;
		else C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> A >> B;
	vector<ll> v;
	rep(i, 0, N) {
		ll tmp;
		cin >> tmp;
		v.push_back(tmp);
	}

	comb(N);

	vsort_r(v);

	double rsl = 0.0;
	rep(i, 0, A) rsl += v[i];
	rsl /= A;
	cout.precision(20);
	cout << fixed << rsl << endl;

	int x = 0, y = 0;
	rep(i, 0, N) {
		if(v[A - 1] == v[i]) {
			if(i < A) y++;
			x++;
		}
	}

	if(y != A) {
		cout << C[x][y] << endl;
		return 0;
	} else {
		ll ans = 0LL;
		rep(i, A, B + 1) {
			ans += C[x][i];
		}
		cout << ans << endl;
		return 0;
	}

}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int main() {
  int n;
  scanf("%d", &n);
  int mi = 1000;
  int ma = 0;
  int b;
  rep (i, n) {
    scanf("%d", &b);
    mi = min(mi, b);
    ma = max(ma, b);
  }
  printf("%d\n", ma - mi);

  return 0;
}


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


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

  if(a < b){
    cout << "a < b" << endl;
  }else if(a == b){
    cout << "a == b" << endl;
  }else if(a > b){
    cout << "a > b" << endl;
  }
}

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

int main() {
  ll n;
  cin >> n;
  vector<ll> t(n);
  vector<ll> a(n);
  for(ll i=0;i<n;i++) {
    cin >> t[i] >> a[i];
  }
  ll f1=1,f2=1;
  for(ll i=0;i<n;i++) {
    ll temp=max((f1+t[i]-1)/t[i],(f2+a[i]-1)/a[i]);
    f1=temp*t[i];
    f2=temp*a[i];
  }
  cout << f1 + f2 << endl;
}

Measured memory_bytes: 256
// Last Change: 03/21/2019 23:24:43.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  vector<int> ipt(3);
  vector<int> evenInfo;
  vector<int> oddInfo;

  for (int i = 0; i < 3; ++i) {
    cin >> ipt.at(i);
    if (ipt.at(i) % 2 == 0) {
      evenInfo.push_back(i);
    } else {
      oddInfo.push_back(i);
    }
  }

  int ans = 0;
  //偶奇揃え
  if (evenInfo.size() == 2) {
    ++ipt.at(evenInfo.at(0));
    ++ipt.at(evenInfo.at(1));
    ans = 1;
  } else if (oddInfo.size() == 2) {
    ++ipt.at(oddInfo.at(0));
    ++ipt.at(oddInfo.at(1));
    ans = 1;
  }

  sort(ipt.begin(), ipt.end());
  ans += (ipt[2] - ipt[0]) / 2;
  ans += (ipt[2] - ipt[1]) / 2;

  cout << ans << endl;

  //NS::LoopUntilZeroInpput();
}


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

using namespace std;

int main(){
	int n;
	cin >> n;
	char S[n];
	cin >> S;
	char T[n];
	cin >> T;
	for(int i=0;i<n;i++){
		printf("%c",S[i]);
		printf("%c",T[i]);
	}
}

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)++)
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    int A[3][3] = {0};
    bool B[3][3] = {false};
    for (int i = 0; i < 3; ++i)
    {
        int a, b, c;

        cin >> a >> b >> c;
        A[i][0] = a;
        A[i][1] = b;
        A[i][2] = c;
    }

    int N;
    cin >> N;
    for (int i = 0; i < N; ++i)
    {
        int temp;
        cin >> temp;
        for (int j = 0; j < 3; ++j)
        {
            for (int k = 0; k < 3; ++k)
            {

                if (A[j][k] == temp)
                {
                    B[j][k] = true;
                }
            }
        }
    }
    for (int i = 0; i < 3; i++)
    {
        if (B[i][0] && B[i][1] && B[i][2])
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    for (int i = 0; i < 3; i++)
    {
        if (B[0][i] && B[1][i] && B[2][i])
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    if (B[0][0] && B[1][1] && B[2][2])
    {
        cout << "Yes" << endl;
        return 0;
    }
    if (B[2][0] && B[1][1] && B[0][2])
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
gra=[[] for _ in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  gra[a-1].append(b-1)
  gra[b-1].append(a-1)
from collections import deque
d=deque()
d.append(0)
visited=[False]*n
visited[0]=True
dep=[0]*n
while d:
  g=d.popleft()
  for i in gra[g]:
    if visited[i]:
      continue
    d.append(i)
    visited[i]=True
    dep[i]=dep[g]+1
route=[0]*(n-1)
for i in range(1,n):
  for t in gra[i]:
    if dep[t]==dep[i]-1:
      route[i-1]=t+1
      break
print('Yes')
print(*route)

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

using namespace std;

int dp[1 << 26];
#define INF (INT_MAX/2)

int main(void)
{
    string s;
    cin >> s;
    int n = s.length();

    for(int i = 0; i < (1 << 26); i++) dp[i] = INF;

    int b = 0;
    dp[0] = 0;
    for(int i = 0; i < n; i++)
    {
        b ^= (1 << (s[i] - 'a'));
        int t = dp[b];

        for(int j = 0; j < 26; j++)
        {
            t = min(t, dp[b ^ (1 << j)]);
        }
        dp[b] = min(dp[b], t + 1);
    }
    cout << (dp[b] == 0 ? 1 : dp[b]) << "\n";
    return 0;
}


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

int main(){
	string S;
	cin >> S;
	rep(i, S.size()) {
		if (i % 2 == 0 && S.at(i) == 'L' || i % 2 != 0 && S.at(i) == 'R') {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, h, w;
    cin >> n >> h >> w;
    int a = n - h;
    int b = n - w;
    int ans = (a + 1) * (b + 1);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

int main()
{
    int a, b, i;
    for(i=1; i<=3000; i++)
    {
      cin >> a >> b;
      if(a > b)
       { 
         a=a+b;
         b=a-b;
         a=a-b;
       }
    
     if(a==0,b==0)
     break;
       
    cout << a << " " << b << endl;
    }
}


Measured memory_bytes: 3064
char_dict = {'a':0,'b':0,'c':0,'d':0,'e':0,
             'f':0,'g':0,'h':0,'i':0,'j':0,
             'k':0,'l':0,'m':0,'n':0,'o':0,
             'p':0,'q':0,'r':0,'s':0,'t':0,
             'u':0,'v':0,'w':0,'x':0,'y':0,
             'z':0,}
char_array = ['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','z']
while 1:
    try:
        string = input().lower()
    except:
        break
    l = list(string)

    for i in range(len(l)):
        if l[i] in char_dict:
            char_dict[l[i]] += 1
            
for i in range(26):
    print(f'{char_array[i]} : {char_dict[char_array[i]]}')


Measured memory_bytes: 5580
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                    \
    sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
    {
sim > struct rge
{
    c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
    ~debug()
    {
        cerr << endl;
    }
    eni(!=) cerr << boolalpha << i;
    ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
    sim dor(const c &)
    {
        ris;
    }
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 10;
ll n;
vector<ll> v1(100005),v2(100005),v3(100005);
ll dp[100005][4];
//ll ans=0;
ll dfs( int x,int lastChoice)
{
if(x==n)
return 0;
if(dp[x][lastChoice]!=-1)
return dp[x][lastChoice];
//debug()<<imie(ans);
ll ans=0;
if(lastChoice!=1)
{
ans=max(ans,dfs(x+1,1)+v1[x]);
}
if(lastChoice!=2)
{
ans=max(ans,dfs(x+1,2)+v2[x]);
}
if(lastChoice!=3)
{
ans=max(ans,dfs(x+1,3)+v3[x]);
}

return dp[x][lastChoice]=ans;
}
int main()
{

    fastio
    memset(dp,-1,sizeof dp);
  cin>>n;
  for( int i=0;i<n;i++)
  {
    cin>>v1[i]>>v2[i]>>v3[i];
  }
  cout<<dfs(0,0)<<endl;;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int N; cin >> N;
	vector<ll> A(N);
	ll S = 0;
	for(int i = 0; i < N; i++) {
		cin >> A[i];
		S += A[i];
	}
	vector<ll> M(N);
	M[0] = S;
	for(int i = 0; i < N; i++) {
		if(i == 0) {
			for(int j = 1; j < N; j += 2) M[0] -= 2 * A[j];
			cout << M[0] << " ";
		}
		else if(i != N - 1) {
			M[i] = 2 * A[i - 1] - M[i - 1];
			cout << M[i] << " ";
		}
		else {
			M[N - 1] = 2 * A[N - 2] - M[N - 2];
			cout << M[N - 1] << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 4784
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define scan(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define scan1(a,n) for(int i=0;i<n;i++){  int z; cin>>z; a.pb(z);}
#define print(a) for(int i=0;i<a.size();i++){    cout<<a[i]<<" " ;}
#define for1(i,n) for(int i=0;i<n;i++)
#define pi 6.28318530717958623200
int main() 
{
    int n;
    cin>>n;
    int a[n+1],b[n+1]={};
    for(int i=2;i<=n;i++)
      {
      	cin>>a[i];
      	b[a[i]]++;
	  }
	  for(int i=1;i<=n;i++)
	  {
	  	cout<<b[i]<<endl;
	  }
 	return 0;
} 

Measured memory_bytes: 5188
n, k = map(int, input().split())
MOD = pow(10,9)+7
dp = [[0]*(n+1) for _ in range(k+1)]
dp[0][0] = 1
for i in range(1,k+1):
    for j in range(n+1):
        if j-i >= 0:
            dp[i][j] = (dp[i-1][j] + dp[i][j-i]) % MOD
        else:
            dp[i][j] = dp[i-1][j]
print(dp[k][n])


Measured memory_bytes: 29356
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll a,b,k;
    cin >> a >> b >> k;
    if(a >= k){
        a-=k;
    }
    else{
        k -= a;
        a = 0;
        b = max((ll)0,b-k);
    }
    cout << a <<" " << b;



    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int n,l,r,ans=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>l>>r;
    ans+=(r-l+1);
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
	int i;
	double h,max=0,min;
	while(scanf("%lf",&h)!=EOF){
		//if(h==0) break;
		i++;
		if(i==1) min=h;
		if(min>h) min=h;
		if(max<h) max=h;
	}
	//cout<<max<<endl;
	//cout<<min<<endl;
	cout<<max-min<<endl;
}

Measured memory_bytes: 1284
#!/usr/bin/env python
# -*- coding:utf-8 -*-
#from __future__ import print_function
import time
import sys
import io
import re
import math
#i = 0
N=int(raw_input())
l=map(int, raw_input().split())
print ' '.join(map(str, l))
for j in range(1,len(l)):
    key=l[j]
    i=j-1
    while i>=0 and l[i] > key:
       l[i+1]=l[i]
       i-=1
    l[i+1]=key
    print ' '.join(map(str, l))

Measured memory_bytes: 4568