akhauriyash/Code-Regression huggingface dataset:
#define _DEBUG
//ヘッダー
#include<bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

//型定義
typedef long long ll;

//定数
const ll INF=1e+18;
const int MOD=998244353;

//デバッグ
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug1(x1) cout<<#x1<<": "<<x1<<endl
#define debug2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug5,debug4,debug3,debug2,debug1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
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...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//省略
using vi  = vector<int>;
using vii = vector<vector<int>>;
using vl  = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

// UnionFind
struct UnionFind {
    vector< int > data;
    
    UnionFind(int sz) {
        data.assign(sz, -1);
    }
 
    bool unite(int x, int y) {//要素xとyの各々の木を併合（もともと同じ木ならfalse）
        x = find(x), y = find(y);
        if(x == y) return (false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }
    
    int find(int k) {//要素kが属する木の根を得る
        if(data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }
    
    int size(int k) {//要素kが属する木の要素数
        return (-data[find(k)]);
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = find(x);
        int ry = find(y);
        return rx == ry;
    }

};

int main(){
    ll N,M;
    cin>>N>>M;
    UnionFind tree(N);
    REP(i,M){
        ll a,b;
        cin>>a>>b;
        a--;
        b--;
        tree.unite(a,b);
    }
    set<ll> si;
    REP(i,N){
        si.insert(tree.find(i));
    }
    ll ans=si.size()-1;
    cout<<ans<<endl;
}

Measured memory_bytes: 7716
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
int A[200000];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  deque<int> deq;
  bool reversed = false;
  rep(i, N) {
    int a;
    cin >> a;
    if (reversed) deq.push_front(a);
    else deq.push_back(a);
    reversed ^= true;
  }
  if (reversed) {
    rep(i, N) {
      cout << deq.back() << " ";
      deq.pop_back();
    }
  }
  else {
    rep(i, N) {
      cout << deq.front() << " ";
      deq.pop_front();
    }
  }
  cout << "\n";
  return 0;
}


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

int main()
{
    int n,m;
    cin >> n >> m;
    int ans = 1900*m+100*(n-m);
    int i;
    for(i = 1;i <= m;++i){
        ans *= 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a,b,c;
char op;
while(1){
scanf("%d %c %d",&a,&op,&b);
if(op=='?') break;
if(op=='+') c = a + b;
if(op=='-') c = a - b;
if(op=='*') c = a * b;
if(op=='/') c = a / b;
printf("%d\n",c);
}
return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
int main(void){
	int a[10001],n,i,min,max;
	long sum = 0;
	scanf("%d",&n);
	for(i = 0;i < n;i++){
		scanf("%d",&a[i]);
		if(i == 0){
			min = a[i];
			max = a[i];
		}
		else{
			if(min>a[i]){
				min = a[i];
			}
			else if(max<a[i]){
				max = a[i];
			}
		}
		sum += (long)a[i];
	}
	printf("%d %d %ld\n",min,max,sum);
	return 0;
}

Measured memory_bytes: 640
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
ans = 0
for _ in range(n):
  a = map(int, input().split())
  d = 0
  for i, j in zip(a, b):
    d += i * j
  if d + c > 0:
    ans += 1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <bitset>
#include <string>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <list>
#include <deque>
using namespace std;
#define INF 10000000
#define LLINF 100000000000000
typedef pair<int, int> P;
typedef long long ll;
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define VSORT(v) sort(v.begin(), v.end());
#define fi first
#define se second
#define out(x) cout << x << endl;
int dx[] = { 1, 0, -1, 0 }, dy[] = { 0,1,0,-1 };
ll MOD = 1000000007;
ll t[100005] = { 0 };
int main() {
	ll n, k;
	cin >> n >> k;
	rep(i, n) cin >> t[i];
	ll sum = 0;
	vector<ll>v;
	for (int i = 1; i < n; i++) {
		sum += t[i] - (t[i - 1] + 1);
		v.pb(t[i] - (t[i - 1] + 1));
	}
	VSORT(v);
	reverse(all(v));
	rep(i, k - 1) {
		sum -= v[i];
	}
	out(n + sum);
	return 0;
}


Measured memory_bytes: 4740
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] list = new int[5];
    
    for(int i = 0; i < 5; i++){
      list[i] = sc.nextInt();
      if(list[i] == 0){
        System.out.println(i+1);
        return;
      }
    }
    
    
  }  
}

Measured memory_bytes: 35684
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;

typedef complex<double> P;

struct L : public vector<P>{//??´???
  L(const P &a, const P &b){
    push_back(a);push_back(b);
  }
};

struct C{//???
  P c; double r;
  C(const P &c,double r): c(c),r(r){}
};

namespace std{//??????????????????
  bool operator < (const P& a,const P& b){
    return real(a)!= real(b) ? real(a) < real(b) : imag(a) < imag(b);
    //return imag(a) != imag(b) ? imag(a) < imag(b) : real(a) < real(b)
  }
  bool operator == (const P& a,const P& b){
    return a.real()==b.real()&&a.imag()==b.imag();
  }
}

double dot(P a,P b){
  return real(conj(a)*b);
}

double cross(P a,P b){
  return imag(conj(a)*b);
}

int ccw(P a, P b, P c){
  b-=a;c-=a;
  if(cross(b,c)>0)   return +1;// counter clockwise 
  if(cross(b,c)<0)   return -1;// clockwise 
  if(dot(b,c)<0)     return +2;// c-a-b on line
  if(norm(b)<norm(c))return -2;// a-b-c on line
  return 0;                    // a-c-b on lone
}

P projection(P p1, P p2, P p){//p???p1p2???????°???±
  P t=dot(p2-p1,p-p1)/norm(p2-p1)*(p2-p1);
  return p1+t;
}

int main()
{
  double xp1,yp1,xp2,yp2;
  int q;
  int i,j;

  cin>>xp1>>yp1>>xp2>>yp2;
  cin>>q;

  P p1(xp1,yp1),p2(xp2,yp2);

  rep(i,q){
    double xp,yp;
    cin>>xp>>yp;
    P p(xp,yp);
    P ans=projection(p1,p2,p);
    printf("%.10f %.10f\n",ans.real(),ans.imag());
  }

}

Measured memory_bytes: 3264
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;typedef vector<ll> vll;
#define fill(a) memset(a, 0, sizeof (a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int maxn = 2000100;

int main(){
        _ios;
            ll n;cin>>n;
            string s;cin>>s;
            ll r=0,g=0,b=0;
            for(ll i=0;i<n;i++){
                if(s[i]=='R')r++;
                else if(s[i]=='G')g++;
                else b++;
            }
            ll ans=r*g*b;
            for(ll i=0;i<n;i++){
                for(ll j=i+1;j<n;j++){
                    if(s[i]==s[j])continue;
                    ll k=j+(j-i);
                    if(k>=n)continue;
                    if(s[k]==s[i] || s[k]==s[j])continue;
                    ans--;
                }
            }
            cout<<ans<<endl;

return 0;
}



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

class DisjointSet {
public:
    vector<int> p, rank;

    DisjointSet(int n) {
        p.resize(n, 0);
        iota(p.begin(), p.end(), 0);
        rank.resize(n, 0);
    }

    int findSet(int x) {
        if (p[x] == x) return x;
        return findSet(p[x]);
    }

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

    void unite(int x, int y) {
        int xroot = findSet(x), yroot = findSet(y);
        if (rank[xroot] < rank[yroot]) {
            p[xroot] = yroot;
        } else {
            p[yroot] = xroot;
            if (rank[xroot] == rank[yroot]) rank[xroot] ++;
        }
    }
};

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

    int n, q;
    cin >> n >> q;

    DisjointSet obj(n);
    int com, x, y;
    while (q --) {
        cin >> com >> x >> y;
        if (com == 0) {
            obj.unite(x, y);
        } else {
            cout << (int)obj.same(x, y) << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1288
N = int(input())
Q = [0]*N
H=0
for j in range(N):
    Q[j] = [ int(i) for i in input().split()]

for x in range(101):
    for y in range(101):
        h_kouho = {-1}
        for i in range(N):
            if  Q[i][2] != 0:
                H1 = Q[i][2] + abs(Q[i][0]- x) + abs(Q[i][1] - y)
                if h_kouho =={-1}:
                    h_kouho = {H1}
                else:
                    h_kouho = h_kouho & {H1}
            else:
                continue
        if h_kouho != set() :
            u = 0
            for i in range(N):
                if Q[i][2] != max({0,max(h_kouho)- abs(Q[i][0]- x) - abs(Q[i][1] - y)}):
                    u = 1
            if u == 0:
                print(x,y,max(h_kouho))
                break
                break
            else:
                continue
        else:
            continue    

Measured memory_bytes: 3064
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
  var a = one[0];
  var b = one[1];
  //b - aを行うことで、aの塔の雪なしでの高さがわかる
  var tmp = b - a - 1;
  var A = (tmp * (tmp + 1)) / 2;
  myout(A - a);
}

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n,k;
    int ans=0;
    cin >> n >> k;
    vector<int>x(n);
    rep(i,n) cin >> x[i];
    
    rep(i,n){
        if(x[i] < k - x[i]) ans += x[i]*2;
        else ans += (k-x[i])*2;
    }
    cout << ans << endl;
}

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

int main() {
  string a;
  cin>>a;
  
  int d=a.size();
  int g=0;
  int k=0;
  
  for(int i=0;i<d;i++){
    if(a.at(i)=='C'){
      k=i;
      g++;
      break;
    }
  }

  if(g==0){
    cout<<"No"<<endl;
    return 0;
  }
  else{
    for(int i=k;i<d;i++){
      if(a.at(i)=='F'){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
    cout<<"No"<<endl;
  }
    
}

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


void solve(){
  int n,k;
  cin >> n >> k;
  int h[n+10];
  rep(i,n){
    cin >> h[i];
  }
  int count = 0;
  rep(i,n){
    if(h[i]>=k) count++;
  }
  cout << count << endl;
}

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

Measured memory_bytes: 640
n = int(input())
b_list = list(map(int, input().split()))

a_list = [1e6] * n

for i, b in enumerate(b_list):
    a_list[i] = min(b, a_list[i])
    a_list[i + 1] = min(b, a_list[i + 1])

print(sum(a_list))


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <tuple>
#include <utility>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <map>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};



int main(){
  
  int n;
  cin>>n;
  vector<double>a(n);
  rep(i,n)cin>>a[i];

  double x=1;
  rep(i,n)x*=a[i];

  double y=0;
  rep(i,n){
      y+=x/a[i];
  }

  cout << setprecision(15)<< x/y <<endl;

    return 0;
}


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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    double n,m,t,p;
    cin>>n;
    vector<ll>arr(100001,0);
    arr[100]=1;
    arr[101]=1;
    arr[102]=1;
    arr[103]=1;
    arr[104]=1;
    arr[105]=1;
    for(int i=100;i<100001;i++){
        if(arr[i]){
            arr[i+100]=1;
            arr[i+101]=1;
            arr[i+102]=1;
            arr[i+103]=1;
            arr[i+104]=1;
            arr[i+105]=1;
        }
    }
    cout<<arr[n];
    return 0;
}


Measured memory_bytes: 1024
# vim: ft=ruby

class Solver
  def prepare
    @d = gets.to_i
    @cs = gets.split(" ").map(&:to_i)
    @mans = []  # mans[date][contest]

    @last = [0] * 26

    @d.times do
      @mans << gets.split(" ").map(&:to_i)
    end
  end

  # ----------- #

  def score(contest_id, date)
    @mans[date][contest_id]
  end

  def decrease_per_contest(contest_id, date)
    @cs[contest_id] * (date - @last[contest_id])
  end

  def decrease_all(date)
    (0..25).map do |contest_id|
      decrease_per_contest(contest_id, date)
    end.sum
  end


  # TOOLS

  def evaluate(ts)
    res = 0
    ts.each.with_index do |t, d|  # d = date
      t -= 1
      res += score(t, d)
      @last[t] = d+1
      res -= decrease_all(d+1)
    end
    res
  end

  def random_pattern
    @d.times.map do
      (0..25).to_a.sample
    end
  end

  def print_result(pattern)
    pattern.each do |p|
      puts p+1
    end
  end

  # TOOLS END


  def solve
    pattern = random_pattern

    print_result(pattern)
  end

end

solver = Solver.new
solver.prepare
solver.solve


Measured memory_bytes: 14360
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#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 pb(a) push_back(a)
using namespace std;
typedef long long ll;

int main()
{
    int L, R;
    cin >> L >> R;

    if ((R - L) >= 2019 || R % 2019 == 0 || L % 2019 == 0)
    {
        cout << 0 << endl;
    }
    else
    {
        int m = L / 2019;
        m = (m + 1) * 2019;
        if ((L <= m) && (m <= R))
        {
            cout << 0 << endl;
        }
        else
        {
            int ans = 2019;
            for (int l = L % 2019; l < R % 2019; l++)
            {
                for (int r = l + 1; r <= R % 2019; r++)
                {
                    ans = min(ans, (l * r) % 2019);
                }
            }
            cout << ans;
        }
    }
}

Measured memory_bytes: 256
//13_C 15パズル問題   15 Puzzle

#include<cstdio>
#include<iostream>
#include<cmath>
#include<map>
#include<queue>

using namespace std;
#define N 4
#define N2 16

static const int dx[4]={0,-1,0,1};
static const int dy[4]={1,0,-1,0};
static const char dir[4]={'r','u','l','d'};
int MTD[N2][N2];

struct Puzzle{
  int f[N2],space,MD;
  int cost;

  bool operator < (const Puzzle &p) const{
    for(int i=0;i<N2;i++){
      if(f[i]==p.f[i]) continue;
      return f[i]<p.f[i];
    }
    return false;
  }
};

struct State{
  Puzzle puzzle;
  int estimated;
  bool operator < (const State &s) const {
    return estimated > s.estimated;
  }
};

int getALLMD(Puzzle pz){
  int sum=0;
  for(int i=0;i<N2;i++){
    if(pz.f[i] ==N2) continue;
    sum += MTD[i][pz.f[i]-1];
  }
  return sum;
}

int astar(Puzzle s){
  priority_queue<State> PQ;
  s.MD=getALLMD(s);
  s.cost=0;
  map<Puzzle,bool> V;
  Puzzle u,v;
  State initial;
  initial.puzzle = s;
  initial.estimated = getALLMD(s);
  PQ.push(initial);
 
  while(!PQ.empty()){
    State st = PQ.top();
    PQ.pop();
    u=st.puzzle;
    
     if(u.MD==0) return u.cost;
     V[u]=true;
     
    int sx = u.space/N;
    int sy = u.space%N;
    
    for(int r=0;r<4;r++){
      int tx = sx+dx[r];
      int ty = sy+dy[r];
      if(tx<0 || ty<0 || tx>=N || ty >=N ) continue;
      v=u;
      v.MD -= MTD[tx*N+ty][v.f[tx*N+ty]-1];
      v.MD += MTD[sx*N+sy][v.f[tx*N+ty]-1];
      
      swap(v.f[sx*N+sy],v.f[tx*N+ty]);
      v.space = tx *N +ty;
      if(!V[v]){
	v.cost++;
	State news;
	news.puzzle=v;
	news.estimated=v.cost+v.MD;
	PQ.push(news);
      }
    }
  }

  return -1;
}

int main(){
  for(int i=0;i<N2;i++)
    for(int j=0;j<N2;j++)
      MTD[i][j]=abs(i/N-j/N)+abs(i%N-j%N);
  
  Puzzle in;

  for(int i=0;i<N2;i++){
    cin >> in.f[i];
    if(in.f[i]==0){
      in.f[i]=N2;
      in.space=i;
    }
  }

  cout << astar(in) << endl;
  return 0;
}



Measured memory_bytes: 257656
#include <iostream>
#include <vector>
using namespace std;
#define MAX 7368791+2

int main(){
	while(1){
		int m,n;
		cin >> m >> n;
		if(n==0) break;
		
		vector<bool> year(MAX, false);
		for(int i=m,count=0; count<n ; i++){
			if(!year[i]){
				count++;
				for(int j=1; i*j<MAX; j++){
					year[i*j]=true;
				}
			}
		}
		for(int i=m; i<MAX; i++){
			if(!year[i]){
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3928
# AOJ 1111: Cyber Guardian
# Python3 2018.7.15 bal4u

import re

while True:
	n, m = map(int, input().split())
	if (n|m) == 0: break
	rule, ans = [], []
	for i in range(n):
		g, s, d = input().split()
		rule.append((g[0] == 'p', s.replace("?", "[0-9]"), d.replace("?", "[0-9]")))
	for i in range(m):
		s, d, m = input().split()
		for G, S, D in rule[::-1]:
			if re.match(S, s) and re.match(D, d):
				if G: ans.append((s, d, m))
				break
	print(len(ans))
	for a in ans: print(*a)



Measured memory_bytes: 7344
def main():
    n = int(input())
    num_m = 0
    num_a = 0
    num_r = 0
    num_c = 0
    num_h = 0
    inlis = set()
    for i in range(n):
        s = input()
        if s in inlis:
            pass
        else:
            inlis.add(s)
            if s[0] == "M":
                num_m += 1        
            if s[0] == "A":
                num_a += 1
            if s[0] == "R":
                num_r += 1
            if s[0] == "C":
                num_c += 1
            if s[0] == "H":
                num_h += 1
    numlis = [num_m, num_a, num_r, num_c, num_h]
    ans = 0
    if sum(numlis) < 3:
        print(0)
    else:
        for i in range(5):
            for j in range(5):
                for k in range(5):
                    if i == j or i == k or j == k:
                        pass
                    else:
                        ans += numlis[i] * numlis[j] * numlis[k]
        print(int(ans/6))
                    


if __name__ == "__main__":
    main()


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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N, D;
    cin >> N >> D;
    cout << (N + 2 * D) / (2 * D + 1) << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

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

  int anser=0;
  for(int i=0;i<S.length();i++){
      if(S[i]!=T[i]){
        anser++;
      }
  }

  cout << anser << endl;
  return 0;
}


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

using namespace std;

int n,m,ans;

int main(){
	scanf("%d%d",&n,&m); n-=m;
	for (int i=1;i<=n;i++) ans+=100;
	for (int i=1;i<=m;i++) ans+=1900;
	printf("%d\n",ans<<m);
	
	return 0;
}
			

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    long X[N];
    long upper[N];
    long lower[N];
    for (int i = 0; i < N; i++)
    {
        long A, B;
        cin >> lower[i] >> upper[i];
    }
    sort(lower, lower + N);
    sort(upper, upper + N, greater<>());
    int ans = 0;
    if (N % 2 == 1)
    {
        cout << (upper[(N - 1) / 2] - lower[(N - 1) / 2] + 1) << endl;
    }
    else
    {
        long a = lower[N / 2 - 1];
        long b = upper[N / 2];
        long c = lower[N / 2];
        long d = upper[N / 2 - 1];
        cout << ((b + d) - (a + c) + 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 6764
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/

/////////////////////////////////

#define MAX_N 1000000//調節！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
int par[MAX_N],dep[MAX_N];//depはrankのこと
//n要素で初期化
void init(int n){
    for(int i=0;i<=n-1;i++){
        par[i]=i;
        dep[i]=0;
    }
}
//木の根を求める
int find(int x){
    return par[x]==x?x:par[x]=find(par[x]);
}
//xとyの属する集合を併合
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;
    if(dep[x]<dep[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(dep[x]==dep[y])dep[x]++;
    }
}
//xとyが同じ集合に属するか否か
bool same(int x,int y){
    return find(x)==find(y);
}
//////////////////////////////////////
struct edge{int u,v,cost;};
bool comp(const edge& e1,const edge& e2){
    return e1.cost<e2.cost;
}
#define MAX_E 1000000//調節！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
edge es[MAX_E];
int v,e;//頂点数vと辺数e

int kruskal(){
    sort(es,es+e,comp);
    init(v);
    int res=0;
    for(int i=0;i<e;i++){
        edge e=es[i];
        if(!same(e.u,e.v)){
            unite(e.u,e.v);
            res+=e.cost;
        }
    }
    return res;
}
///////////////////////////////////////////

struct P{
    int num,x,y;
};

bool ascx(const P &l,const P &r){
    return l.x<r.x;
}
bool ascy(const P &l,const P &r){
    return l.y<r.y;
}
bool asce(const edge &l,const edge &r){
    return l.cost<r.cost;
}


int main(){
    int n;cin>>n;
    P p[n];
    edge e[2*n-2];
    for(int i=0;i<=n-1;i++){
        cin>>p[i].x>>p[i].y;
        p[i].num=i;
    }
    sort(p,p+n,ascx);
    for(int i=1;i<=n-1;i++){
        e[i-1]=edge{p[i-1].num,p[i].num,abs(p[i].x-p[i-1].x)};
    }
    sort(p,p+n,ascy);
    for(int i=1;i<=n-1;i++){
        e[n+i-2]=edge{p[i-1].num,p[i].num,abs(p[i].y-p[i-1].y)};
    }
    sort(e,e+2*n-2,asce);
    init(n);
    ll ans=0;
    for(auto aaa:e){
        if(!same(aaa.u,aaa.v)){
            ans+=aaa.cost;
            unite(aaa.u,aaa.v);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 7936
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i,  r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define X real()
#define Y imag()
#define maxN 100005
#define oo 2000000007

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int n, pos[maxN];
ii a[maxN];

int main () {
    scanf("%d", &n);
    fto(i, 1, n) {
        scanf("%d", &a[i].ff);
        a[i].ss = i;
    }
    sort(a+1, a+n+1);

    fto(i, 1, n) pos[a[i].ss] = i;

    int ans = 0;
    fto(i, 1, n) {
        if ((i%2)^(pos[i]%2)) ++ans;
    }

    printf("%d", ans/2);

    return 0;
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
long long Sum(long long A) {
	return A * (A + 1) / 2;
}
int main() {
	long long N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		if (Sum(i + 1) >= N) {
			cout << i + 1 << endl;
			return 0;
		}
	}
}


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

using namespace std;

typedef long long ll;

ll n, k;

int main() {
  cin >> n >> k;
  k *= 5, k %= 11;
  cerr << k << '\n';
  ll lo = 8, hi = 7 * (n - 1);
  if (lo > hi or k > hi) {
    cout << "0\n";
    return 0;
  }
  ll tot = (hi - k) / 11 - (max(0LL, lo - k) + 10) / 11 + 1;
  cerr << tot << '\n';
  ll lt = (56 * k + 22) % 77, rt = 56 * k % 77;
  if (lt <= hi) tot -= (hi - lt) / 77 - (max(0LL, lo - lt) + 76) / 77 + 1;
  if (rt <= hi) tot -= (hi - rt) / 77 - (max(0LL, lo - rt) + 76) / 77 + 1;
  cout << tot << '\n';
  return 0;
}



Measured memory_bytes: 3608
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

int main(int argc, const char * argv[]) {
      
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n; cin >> n;
    vector<int64_t> a(n + 1);
    vector<int64_t> b(n);
    for (int i = 0; i < n + 1; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    
    int64_t ans = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (a[i] + a[i + 1] <= b[i]) {
            ans += a[i] + a[i + 1];
            a[i] = 0;
        } else if (a[i + 1] < b[i]) {
            ans += b[i];
            a[i] = a[i] - (b[i] - a[i + 1]);
        } else {
            ans += b[i];
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1792
require 'set'
a = Set.new
n = gets.chomp.to_i
n.times do
    inst, s = gets.chomp.split(" ")
    if inst[0] == "f"
        if a.include?(s)
            puts "yes"
        else
            puts "no"
        end
    else
        a.add(s)
    end
end

Measured memory_bytes: 168708
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <iostream>
#include <string>

int main()
{

    int n;
    scanf("%d", &n);

    int max;

    for (int i = 1; i <= n; ++i)
    {
        int square = i * i;

        if (square > n)
        {
            break;
        }

        max = square;
    }

    std::cout << max << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	string str;
	cin >> str;
	long long ans = 0;

	for (int i = 0; i <= str.length() - 1; i++) {
		long long count = 0;
		int j = i;
		while (1) {
			if (j <= str.length() - 3 && str[j] == 'A' && str[j + 1] == 'B' && str[j + 2] == 'C') {
				count++;
				ans += count;
				j = j + 3;
			}
			else if (j <= str.length() - 2 && str[j] == 'B' && str[j + 1] == 'C') {
				ans += count;
				j = j + 2;
			}
			else if (j <= str.length() - 1 && str[j] == 'A') {
				count++;
				j = j + 1;
			}
			else {
				j++;
				break;
			}
		}
		i = j - 1;
	}

	cout << ans << endl;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N;


int main(void){
    
    scanf("%d", &N);
    printf("%s\n", (N < 1000) ? "ABC" : "ABD");
    
    return 0;
}


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

int main(){
  int N;
  cin>>N;
  if (N>2000){
    cout<<"1"<<endl;
    return 0;
  }
  for(int i=0;i<21;i++){
      for(int j=0;j<21;j++){
          for(int k=0;k<21;k++){
              for(int l=0;l<21;l++){
                  for(int m=0;m<21;m++){
                      for(int n=0;n<21;n++){
                        if(N==i*105+j*104+k*103+l*102+m*101+n*100){
                          cout<<"1"<<endl;
                          return 0;
                        }
                      }
                  }
              }
          }
      }
  }
  cout<<"0"<<endl;
  return 0;
}


    

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

inline bool isOK(vector<int>& sum) {
  rep(i, 20) {
    if (sum[i] >= 2) return false;
  }
  return true;
}

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) { cin >> A[i]; }

  int right = 0;
  int sum = 0;
  int64_t answer = 0;
  rep(left, N) {
    while (right < N && (sum ^ A[right]) == (sum + A[right])) {
      sum += A[right];
      ++right;
    }
    answer += (int64_t)(right - left);
    sum -= A[left];
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 4028
#include <iostream>

using namespace std;

int main()
{
    char vremenat;
    cin>>vremenat;
    if(vremenat=='S'||vremenat=='s'){
        cout<<"Cloudy";

    }
        if(vremenat=='C'||vremenat=='c'){
        cout<<"Rainy";

    }
    if(vremenat=='r'||vremenat=='R'){
        cout<<"Sunny";

    }
    return 0;
}


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

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

int main(){
  int n,a,b,sum=0;
  cin >>n>>a>>b;
  for(int i=1;i<=n;i++){
    if(keta(i)>=a && keta (i)<=b){
      sum=sum+i;
    }
  }
  cout <<sum;
}


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

const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

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

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main()
{
    string s;
    cin >> s;
    int a = 0;
    REP(i, s.length())
    {
        a += (int)(s[i] - '0');
        a %= 9;
    }
    if (a == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

int main(){
    int b[21]={0}, c[20]={0}, order[20]={0}, n;
    int satisfaction=0;
    std::cin>>n;
    for (int i = 0; i < n; i++)
    {
        int ip;
        std::cin>>order[i];
    }
    for (int i = 0; i < n; i++)
    {
        int ip;
        std::cin>>b[i];
    }
    for (int i = 0; i < n-1; i++)
    {
        std::cin>>c[i];
    }
    int iprev=0;
    for (int i = 0; i < n; i++)
    {
        satisfaction+=b[order[i]-1];
        if(i){
            if(order[i-1]==order[i]-1)
                satisfaction+=c[order[i]-2];
        }
    }
    std::cout<<satisfaction<<"\n";
    return 0; 
}

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

long long gcd(long long a,long long b){
	if(a==0 || b==0) return max(a,b);	
	else if(a==1 || b==1) return 1;
	else if(a%b == 0 || b%a==0) return min(a,b);
	long long q;
	bool pro =true;
	while(pro){
		q=a%b;
		a=b;
		b=q;
		if(a%b==0){
			return q;
		pro=false;
		}
	}
}

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}

int can_div(int p){
	int count =0;
	while(p%2==0){
		p/=2;
		count++;
	}
	return count;
}


signed main(){
	int N,M;
	cin>>N>>M;
	int a,b,l;
	cin>>l;
	int div=can_div(l);
	l/=2;
	bool pro =true;
	int ans;
	for(int i=0;i<N-1;i++){
		cin>>a;
		if(can_div(a)!=div){
			pro=false;
			ans=0;
			break;
		}
		
		a/=2;
		l=lcm(l,a);
		if(l>M){
			pro=false;
			ans=0;
			break;
		}
		
	}
	if(pro){
		int p=M/l;
		if(p%2==1){
			ans=(p-1)/2+1;
		}
		else{
			ans=p/2;
		}
	}
	// cout<<l<<endl;
	cout<<ans<<endl;
	return 0;
		
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int h, w, n;
    cin >> h >> w >> n;
    map<int, map<int, int>> grid;
    vector<ll> ans(10, 0);
    
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        
        rep(ii, 3) {
            rep(iii, 3) {
                if (
                    ((a - ii) < 0) || ((a - ii) > (h - 3)) ||
                    ((b - iii) < 0) || ((b - iii) > (w - 3))
                ) {
                    continue;
                }
                
                grid[a - ii][b - iii]++;
            }
        }
    }
    
    ans[0] = (ll)(h - 2) * (w - 2);
    
    reps(i, 1, 10) {
        for(auto x : grid) {
            for(auto y : x.second) {
                if (y.second == i) {
                    ans[i]++;
                    ans[0]--;
                }
            }
        }
    }
    
    rep(i, 10) {
        printf("%lld\n", ans[i]);
    }
    
    return 0;
}


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

typedef long long ll;

int main () {

    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;

    for(int i=0; i<tx-sx; i++) {
	cout << "R";
    }
    for(int i=0; i<ty-sy; i++) {
	cout << "U";
    }
    cout << "R";
    for(int i=0; i<ty-sy+1; i++) {
	cout << "D";
    }
    for(int i=0; i<tx-sx+1; i++) {
	cout << "L";
    }
    cout << "U";

    for(int i=0; i<ty-sy; i++) {
	cout << "U";
    }
    for(int i=0; i<tx-sx; i++) {
	cout << "R";
    }
    cout << "U";
    for(int i=0; i<tx-sx+1; i++) {
	cout << "L";
    }
    for(int i=0; i<ty-sy+1; i++) {
	cout << "D";
    }
    cout << "R";
    cout << endl;

    
    
    return 0;
}


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

using namespace std;

long long int a, b, c, d, answer;

int main() {
	
	answer = -9223372036854775808;
	
	cin >> a >> b >> c >> d;

	long long int fa = max(a, b);
	long long int fb = min(a, b);
	long long int ba = max(c, d);
	long long int bb = min(c, d);
	
	answer = max(answer, fa * ba);
	answer = max(answer, fa * bb);
	answer = max(answer, fb * ba);
	answer = max(answer, fb * bb);
	
	cout << answer;
	
	
	return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main()
{
    multimap<string ,int> m;
    multimap<string ,int>:: iterator it;
    int n,l;
    cin>>n>>l;
    string s;
    for(int i=0;i<n;++i)
    {
        cin>>s;
        m.insert({s,i});
    }
    for(it=m.begin();it!=m.end();++it)
        cout<<it->first;
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3640
def selectionSort(numlist):
    n = len(numlist)
    swaptime = 0
    for i in range(n):
        min_index = i
        for j in range(i + 1, n):
            if numlist[j] < numlist[min_index]:
                min_index = j
        if min_index != i:
            numlist[i], numlist[min_index] = numlist[min_index], numlist[i]
            swaptime += 1
    return swaptime

def print_numlist(numlist):
    if len(numlist) == 1:
        print(numlist[0])
    else:
        for i in range(0, len(numlist) - 1):
            print(numlist[i], end = ' ')
        print(numlist[-1])

if __name__ == '__main__':
    n = int(input())
    numlist = [int(i) for i in input().replace('\n', '').split(' ')]
    swapnum =  selectionSort(numlist)

    print_numlist(numlist)
    print(swapnum)


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

int main(void){
    int n, k, x, mx, gcd;
    scanf("%d%d", &n, &k);
    scanf("%d", &x);
    mx = x;
    gcd = x;
    for(int i = 1; i < n; i++){
        scanf("%d", &x);
        gcd = __gcd(gcd, x);
        mx = max(mx, x);
    }
    if(k % gcd == 0 && mx >= k) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

ll ans = 0;
string s;
int n;
void rec (int i, ll sum) {
    // cout << i << " " << sum << "\n";
    if (i == n) ans += sum;
    rep (j, i + 1, n + 1) {
        string sij = s.substr (i, j - i);
        ll sum2 = stoll (sij);
        rec (j, sum + sum2);
    }
}

int main() {
    cin >> s;
    n = s.size();
    rec (0, 0);
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void)
{
  int s;
  int keta[6];
  int flg1,flg2,flg3;
  
  flg1=flg2=flg3=0;
  cin>>s;
  for(int i=1;i<=4;i++){
    keta[i-1]=s%10;
    s/=10;
  }
  keta[4]=keta[1]*10+keta[0];
  keta[5]=keta[3]*10+keta[2];
  //printf("%d %d\n",keta[4],keta[5]);
  if(keta[4]>=1&&keta[4]<=12){
    if(keta[5]>=0&&keta[5]<=99){
      flg1=1;
    }
  }
  if(keta[4]>=00&&keta[4]<=99){
    if(keta[5]>=1&&keta[5]<=12){
      flg2=1;
    }
  }
  if(flg1==1&&flg2==1){
    cout<<"AMBIGUOUS"<<endl;
  }
  else if(flg2==1){
    cout<<"MMYY"<<endl;
  }
  else if(flg1==1){
    cout<<"YYMM"<<endl;
  }
  else{
    cout<<"NA"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;


int main()
{


	string a, b;
	cin >> a >> b;
	ll m = a.length();
	ll n = b.length();

	ll arr[m + 1][n + 1];
	for (ll i = 0; i <= n; i++)
	{
		arr [0][i] = 0;
	}
	for (ll i = 0; i <= m; i++)
	{
		arr [i][0] = 0;
	}

	for (ll i = 1; i <= m; i++)
	{
		for (ll j = 1; j <= n; j++)
		{
			if (a[i - 1] == b[j - 1])
			{
				arr[i][j] = arr[i - 1][j - 1] + 1;
			}
			else
			{
				arr[i][j] = max(arr[i - 1][j], arr[i][j - 1]);
			}
		}
	}

	string ans = "";
	ll len = arr[m][n];
	ll i =  m;
	ll j = n;

	while (len)
	{
		if (a[i - 1] == b[j - 1])
		{
			ans = a[i - 1] + ans;
			i--;
			j--;
			len = arr[i][j];
		}
		else
		{
			if (arr[i - 1][j] > arr[i][j - 1])
			{
				i--;
				len = arr[i][j];
			}
			else if (arr[i - 1][j] < arr[i][j - 1])
			{
				j--;
				len = arr[i][j];
			}
			else
			{
				i--;
				len = arr[i][j];
			}
		}
	}

	cout << ans << endl;

}

Measured memory_bytes: 70656
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class Program
	{
		static void Main(string[] args)
		{

			int[] vs = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
			int n = vs[0];
			int[] abc = new int[3];
			abc[0] = vs[1];
			abc[1] = vs[2];
			abc[2] = vs[3];
			int[] l = new int[n];
			int pattern = 1;
			for (int i = 0; i < n; i++) {
				l[i] = int.Parse(Console.ReadLine());
				pattern *= 4;
			}
			int ans = int.MaxValue;

          	for (int i = 0; i < pattern; i++) {
				int mp = 0;
				int[] len = new int[4];
				int tmp = 1;

				for (int j = 0; j < n; j++) {
					int no = i / tmp % 4;
					if (no != 3 && len[no] != 0) {
						mp += 10;
					}
					len[no] += l[j];
					tmp *= 4;
				}
				if (len[0] != 0 && len[1] != 0 && len[2] != 0) {
					mp += Math.Abs(abc[0] - len[0]) + Math.Abs(abc[1] - len[1]) + Math.Abs(abc[2] - len[2]);
					ans = Math.Min(ans, mp);
				}
			}
			Console.WriteLine(ans);

		}
	}
}


Measured memory_bytes: 15444
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    N,K = map(int, input().split())
    res = 0
    for i in range(1,N+1):
        cnt = 0
        while i<K:
            cnt += 1
            i *= 2
        res += (1-0.5**cnt)/N
    print(1-res)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
n=int(input())
a=list(map(int,input().split()))
ansm=max(a)
a.remove(ansm)
h=ansm//2
absmin=10**9


ans=a[0]
for x in a:
    if abs(x-h)<absmin:
        ans,absmin=x,abs(x-h)
print(ansm,ans)




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

long long N, K;
vector<long long> sumV(100001);

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;

  int a, b, h;
  cin >> a >> b >> h;
  cout << (a + b) * h / 2 <<endl;
}


Measured memory_bytes: 1024
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  vi h(n);
  rep(i, n) cin >> h[i];
  sort(h.begin(), h.end());
  int ans = h[n - 1] - h[0];
  rep(i, n - k + 1){
    ans = min(h[i + k - 1] - h[i], ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 640