akhauriyash/Code-Regression huggingface dataset:
/**
 * @author khokharnikunj8
 */

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

using namespace std;

class BCommonRaccoonVsMonster {
public:
    void solve(std::istream &in, std::ostream &out) {
        int h, n;
        in >> h >> n;
        int sum = 0;
        for (int i = 0; i < n; i++) {
            int temp;
            in >> temp;
            sum += temp;
        }
        if (sum >= h) out << "Yes\n";
        else out << "No\n";
    }
};


int main() {
    BCommonRaccoonVsMonster solver;
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#define all(x) x.begin(), x.end()
#define min_e(x) min_element(all(x))
#define max_e(x) max_element(all(x))
#define sum(x, y) accumulate(all(x), y)
using namespace std;
using vl = vector<long>;

int main() {
    int n;
    cin >> n;
    vl a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    cout << *min_e(a) << ' '
        << *max_e(a) << ' '
        << sum(a, 0L) << endl;
}



Measured memory_bytes: 3172
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String op;
      String[] words;
      Tree tree = new Tree();

      for(int i=0,k=0; i<n; i++,k=0){
        words = br.readLine().split(" ");
        op  = words[k++];
        if ( op.equals("insert") ) { 
          tree.insert(Integer.parseInt(words[k++]));
        }
        else {
          tree.dispRoundPath();
        }
      }

    }
    catch(IOException e) {
      System.out.println("IOException!");
    }
  }
}

class Tree {

  static final BTreeNode NIL = new BTreeNode(-1);
  BTreeNode root;
  StringBuilder buf;

  public Tree() {
    root = NIL;
    buf = new StringBuilder();
  }

  public void insert(int val) {
    BTreeNode y = NIL;
    BTreeNode x = root;
    BTreeNode z = new BTreeNode(val);

    while( !x.equals(NIL) ) {
      y = x;
      if( z.key < x.key )
        x = x.left;
      else
        x = x.right;
    }
    z.parent = y;

    if( y.equals(NIL) ){
      root = z;
    }
    else if( z.key < y.key )
      y.left = z;
    else
      y.right = z;
  } 
  void preParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      buf.append(" ").append(u.key);
      preParse(u.left);
      preParse(u.right);
    }
  }
  void inParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      inParse(u.left);
      buf.append(" ").append(u.key);
      inParse(u.right);
    }
  }

  void dispRoundPath() {

    inParse(root);
    buf.append("\n");
    preParse(root);
    buf.append("\n");

    System.out.print(buf);
    buf.setLength(0);
  }
}

class BTreeNode {
  int key;
  BTreeNode parent,left,right;

  public BTreeNode(int key) {
    this.key = key;
    this.parent =
    this.left =
    this.right = Tree.NIL;
  }

  @Override
  public boolean equals(Object o) {
    if(o == this) return true;
    if(o == null) return false;
    if(!(o instanceof BTreeNode)) return false;

    BTreeNode node = (BTreeNode)o;
    if(!(this.key == node.key)) return false;

    return true;
  }
}


Measured memory_bytes: 125540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
using Graph = vector<vector<int>>;

int main(){
	string s; cin >> s;
	int l = s.length();
	int ans = 0;
	rep(i, l / 2) if(s[i] != s[l - i - 1]) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
using namespace std;

typedef unsigned long long ull;
const int N_MAX = 1e6;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    int n;
    cin >> n;
    vector<string> S(n);
    REP(i, n){
        cin >> S[i];
    }
    vector< vector<int> > alphabets;
    REP(i, n){
        vector<int> vec(26, 0);
        alphabets.push_back(vec);
    }
    REP(i, n){
        REP(j, S[i].size()){
            alphabets[i][(int)S[i][j] - 97]++;
        }
    }
    vector<int> res(26);
    REP(j, 26){
        int mini = 100;
        REP(i, n){
            mini = min(alphabets[i][j], mini);
        }
        res[j] = mini;
    }
    REP(j, 26){
        REP(i, res[j]){
            putchar(j+97);
        }
    }
    cout << endl;
    return 0;
}

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

int main() {
    int N; cin >> N;
    vector<int> v(N); 
    ll sum = 0;
    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> v[i];
        if(v[i]<0) cnt++;
        v[i] = abs(v[i]);
        sum += v[i];
    }

    if(cnt%2==0) cout << sum << endl;
    else {
        sort(v.begin(), v.end());
        cout << sum - 2*v[0] << endl;
    }
    

}

Measured memory_bytes: 640
def solve(N, M, ABs):
    ans = 0
    for i in range(M):
        adjMat = [[0 for _ in range(N)] for _ in range(N)]
        for k, (a, b) in enumerate(ABs):
            if k != i:
                adjMat[a - 1][b - 1] = 1
                adjMat[b - 1][a - 1] = 1

        def dps(a, visited):
            n = [i for i, b in enumerate(adjMat[a]) if b == 1]
            for nn in n:
                if nn not in visited:
                    visited.append(nn)
                    dps(nn, visited)
            return visited

        visited = dps(0, [])
        if len(visited) != N:
            ans += 1
    return ans


if __name__ == "__main__":
    N, M = tuple(map(int, input().split(" ")))
    ABs = [tuple(map(int, input().split(" "))) for _ in range(M)]
    print(solve(N, M, ABs))


Measured memory_bytes: 3064
#include <stdio.h>

int main(){
    int i,j,d1,d2;
    int M,D;
    int cnt = 0;
    scanf("%d %d",&M,&D);
    // d1 = D % 10;
    // d2 = D / 10;
    for(i=4;i<=M;i++){
        for(j=22;j<=D;j++){
            d1 = j % 10;
            d2 = j / 10;
            if(((d1>=2)&&(d2>=2)) && d1*d2==i) cnt++;
        }
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 256
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define foref(i, a, b) for (int i = b - 1, to = a; i >= to; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int x;
  cin >> x;
  if (x >= 30) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }

  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
#define PB push_back
#define MP make_pair
#define st first
#define nd second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<long long>;
using ld = long double;

#define unordered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using unordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif


int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);

  ll n, k;
  cin >> n >> k;

  vi vals(n);
  for (int &x : vals) { cin >> x; }

  vi rep_vals = vals;
  for (int i = 0; i < n; ++i) {
    rep_vals.PB(vals[i]);
  }

  vi jump(n);

  map<int, int> last_occur;
  for (int i = 2 * n - 1; i >= 0; --i) {
    if (i < n) {
      jump[i] = last_occur[rep_vals[i]] - i + 1;
    }
    last_occur[rep_vals[i]] = i;
  }

  debug(jump);

  ll total_len = n * k;

  vector<ll> first_occ(n, -1);
  ll ptr = 0;
  while (true) {
    if (first_occ[ptr % n] != -1) {
      ll cyc_len = ptr - first_occ[ptr % n];
      debug(cyc_len);
      ll rem = total_len - ptr;
      ptr += rem / cyc_len * cyc_len;
    } else {
      first_occ[ptr % n] = ptr;
    }

    ll next_ptr = ptr + jump[ptr % n];
    if (next_ptr > total_len) { break; }
    ptr = next_ptr;
  }

  debug(ptr);

  vi ans;
  set<int> has_num;

  auto Add = [&](int x) {
    if (has_num.count(x)) {
      while (has_num.count(x)) {
        has_num.erase(ans.back());
        ans.pop_back();
      }
    } else {
      ans.PB(x);
      has_num.insert(x);
    }
  };

  for (ll i = ptr; i < total_len; ++i) {
    Add(vals[i % n]);
  }

  for (int x : ans) { cout << x << " "; }
  cout << "\n";
}



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

int main()
{
    int P, Q, R;
    cin >> P >> Q >> R;
    int mnm = P + Q;

    mnm = Q + R < mnm ? Q + R : mnm;
    mnm = P + R < mnm ? P + R : mnm;

    cout << mnm << endl;
    return 0;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())


def main():
    n, m = map(int, input().split())
    a, b = [], []
    for i in range(m):
        A, B = map(int, input().split())
        a.append(A - 1)
        b.append(B - 1)
    
    ans = 0
    for i in range(m):
        uf = UnionFind(n)
        for j in range(m):
            if i == j:
                continue
            uf.union(a[j], b[j])
        if uf.group_count() != 1:
            ans += 1
            
    print(ans)

if __name__ == '__main__':
    main()

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  bool c = 1;
  for(int A : a) {
    if(A % 2 == 0) {
      if(A % 3 != 0 && A % 5 != 0) {
        c = 0;
        break;
      }
    }
  }
  if(c) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}

Measured memory_bytes: 3604
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;                        // 任意長整数
using Real = mp::number<mp::cpp_dec_float<1024>>;// 仮数部が1024bitの浮動小数点数
#include<bits/stdc++.h>

using namespace std;
//using Bint = long long;
using P = pair<int,int>;
inline int ri() {
	int r; cin >> r; return r;
}


int main()
{
	Bint a;
	Bint b, n;
	cin >> a >> b >> n;
	auto func = [&](Bint x) {
		return (a * x / b) - a * (x / b);
	};
	Bint nax = 0;
	cout << max({func(min(n, a)), func(min(n, b)), func(n), func(min(n ,b - 1)), func(min(n, a - 1)), func(n - 1), func(0)}) << endl;
	
}

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

int main(){
  int N,M,s,c,Ans=0;
  cin>>N>>M;
  vector<int> vec(3);
  vec.at(0)=-1;
  vec.at(1)=-1;
  vec.at(2)=-1;
  
  rep(i,M){cin>>s>>c;
         if(vec.at(s-1)==-1||vec.at(s-1)==c){vec.at(s-1)=c;}else{Ans=-1;break;}
        }
  if(Ans==-1){cout<<-1<<endl;}
  else if(N==1){if(vec.at(0)==-1){vec.at(0)=0;}cout<<vec.at(0)<<endl;}
  else if(vec.at(0)==0){cout<<-1<<endl;}
  else{if(vec.at(0)==-1){vec.at(0)=1;}
       if(vec.at(1)==-1){vec.at(1)=0;}
       
       if(N==2){cout<<vec.at(0)*10+vec.at(1)<<endl;}
       else {if(vec.at(2)==-1){vec.at(2)=0;}cout<<vec.at(0)*100+vec.at(1)*10+vec.at(2)<<endl;}
      }
}


Measured memory_bytes: 3600
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

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

//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の扱い
#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)) //最小値

//グローバル変数


//ライブラリ挿入
// 辺を表す構造体
struct edge{
    int from, to;
    long long cost;
};

// v:=頂点数 es:=辺の集合 cost:=始点からの最短経路のコストを格納する配列
// s:=始点(指定しなければ頂点0) g:=終点(指定しなければ頂点v-1)
// 始点から到達可能で、かつ終点へ到達可能な負閉路が検出された場合falseを、それ以外の場合trueを返す
bool bellman_ford(int v, const vector<edge>& es, vector<long long>& cost, int s = 0, int g = -1){
    if(g == -1){
        g = v - 1;
    }

    constexpr long long INF = 1LL << 61;

    cost.assign(v, INF);
    cost[s] = 0;

    for(int i = 0 ; i < v * 2 ; ++i){
        for(auto& e : es){
            if(cost[e.from] < INF && cost[e.from] + e.cost < cost[e.to]){
                if(i >= v - 1 && e.to == g){
                    return false;
                }else if(i >= v - 1){
                    cost[e.to] = -INF;
                }else{
                    cost[e.to] = cost[e.from] + e.cost;
                }
            }
        }
    }

    return true;
}

int main(){
    int N,M;
    ll P;
    cin>>N>>M>>P;
    int a,b;
    ll c;
    vector<edge> e(M);
    REP(i,M){
        cin>>a>>b>>c;
        a--;
        b--;
        c=P-c;
        e[i]={a,b,c};
    }
    vector<ll> dist(N,INF);
    if(bellman_ford(N,e,dist,0,N-1)){
        cout << max((ll)0,-dist[N-1]) << endl;
    }else{
        cout << -1 <<endl;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int a[8];
int dp[10000];
int rec(int idx, int n)
{
    if(idx>=n)
    {
        return 0;         
    }
    if(dp[idx]!=-1)
    {
        return dp[idx];
    }
    
    return dp[idx]=max(rec(idx+1,n), rec(idx+2,n)+a[idx]);
    
    
}





int main()
{
       

    // finally be false if i is Not a prime, else true. 
    int n=1000000;
    int x; cin>>x;
    bool prime[n]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    vector<int>primes;
    for (int p=2; p<=n; p++) 
       {if (prime[p]) 
            primes.push_back(p);
       }
    auto it=lower_bound(primes.begin(),primes.end(),x);
    cout<<*it;











}


Measured memory_bytes: 1916
n=int(input())
l=[input() for i in range(n)]
ac=l.count("AC")
wa=l.count("WA")
tle=l.count("TLE")
re=l.count("RE")
print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re))

Measured memory_bytes: 79144
use std::collections::VecDeque;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        h: usize,
        w: usize,
        maze: [chars; h],
    }
    let s = (0, 0);
    let g = (h - 1, w - 1);
    let mut queue: VecDeque<(usize, usize)> = VecDeque::new();
    let mut d = vec![vec![usize::max_value(); w]; h];

    queue.push_back(s);
    d[s.0][s.1] = 0;

    while let Some((pr, pc)) = queue.pop_front() {
        if (pr, pc) == g {
            break;
        }

        for (nr, nc) in vec![(1isize, 0isize), (0, 1), (-1, 0), (0, -1)]
            .iter()
            .map(|&(dr, dc)| (pr as isize + dr, pc as isize + dc))
            .filter(|&(nr, nc)| 0 <= nr && nr < h as isize && 0 <= nc && nc < w as isize)
            .map(|(nr, nc)| (nr as usize, nc as usize))
        {
            if maze[nr][nc] == '.' && d[nr][nc] == usize::max_value() {
                queue.push_back((nr, nc));
                d[nr][nc] = d[pr][pc] + 1;
            }
        }
    }

    if d[g.0][g.1] == usize::max_value() {
        return println!("-1");
    }

    let white = maze
        .iter()
        .map(|r| r.iter().filter(|&&c| c == '.').count())
        .sum::<usize>();
    println!("{:?}", white - 1 - d[g.0][g.1]);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
string s;
signed main()
{
    cin>>s;
    int l=s.length(),k=0;
    for(int i=0;i<l;i++) if(s[i]=='p') k++;
    printf("%d\n", l/2-k);
    return 0;
}

Measured memory_bytes: 512
N, M = map(int, input().split())
cy = [1] * N
city = []

for i in range(M):
  p, y = map(int, input().split())
  city.append((y, p, i))
city.sort()

ans = [""] * M

for y, p, i in city:
  ans[i] = ("000000" + str(p))[-6:] + ("000000" + str(cy[p-1]))[-6:]
  cy[p-1] += 1

print(*ans, sep="\n")

Measured memory_bytes: 31368
import sys
input = sys.stdin.readline

def main():
	s = input().strip()
	t = input().strip()
	l = [-1] * 26
	k = [-1] * 26
	a = ord('a')
	for i in range(len(s)):
		if l[ord(s[i]) - a] != -1 or k[ord(t[i]) - a] != -1:
			if l[ord(s[i]) - a] != t[i] or k[ord(t[i]) - a] != s[i]:
				print('No')
				return
		l[ord(s[i]) - a] = t[i]
		k[ord(t[i]) - a] = s[i]
	print('Yes')


if __name__ == '__main__':
	main()


Measured memory_bytes: 41932
#include<iostream>
#include<vector>
#include<bitset>
 
int main(void){
    std::string s;
    std::cin >> s;
    int a, b, c, d;
    a = s[0] - '0';
    b = s[1] - '0';
    c = s[2] - '0';
    d = s[3] - '0';
    std::vector<int> numbers = {b, c, d};
 
    std::vector<char> op = {'-', '-', '-'};
 
    for(int temp = 0; temp < (1<<3); temp++){
        std::bitset<3> s(temp);
        for(int i = 0; i < 3; i++){
            if(s.test(i)){
                op.at(i) = '+';
            }
            else{
                op.at(i) = '-';
            }
        }
 
        int temp_ans = a;
        for(int i = 0; i < 3; i++){
            if(op.at(i) == '+')temp_ans += numbers.at(i);
            else temp_ans -= numbers.at(i);
        }
 
        if(temp_ans == 7){
            std::cout << a << op.at(0) << b << op.at(1) << c << op.at(2) << d << "=7" << std::endl;
            return 0;
        }
    }
}

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

int main() {
  int n;
  cin >> n;
  map<string, int> judge;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    judge[s]++;
  }

  cout << "AC x " << judge["AC"] << '\n';
  cout << "WA x " << judge["WA"] << '\n';
  cout << "TLE x " << judge["TLE"] << '\n';
  cout << "RE x " << judge["RE"] << '\n';
  return 0;
}


Measured memory_bytes: 3628
N = int(input())
S = tuple(map(int, input()))

ans = 0
pins = [0] * 3
for pin in range(1000):
    pins[0] = pin // 100
    pins[1] = (pin % 100) // 10
    pins[2] = pin % 10
    x = 0
    for c in S:
        if c == pins[x]:
            x += 1
            if x == 3:
                ans += 1
                break
print(ans)

Measured memory_bytes: 40944
import sys
def input():
    return sys.stdin.readline()[:-1]
H,W,N=map(int,input().split())
d=[]
for i in range(N):
    a,b=map(int,input().split())
    for j in range(-1,2):
        if not 1<a+j<H:
            continue
        for k in range(-1,2):
            if not 1<b+k<W:
                continue
            t=(a+j,b+k)
            d.append(t)
d.sort()
l=[0]*10
t=0
c=0
for i in d:
    if i==t:
        c+=1
    else:
        l[c]+=1
        t=i
        c=1
l[c]+=1
l[0]=(H-2)*(W-2)-sum(l)+1
print(*l,sep="\n")

Measured memory_bytes: 128072
package main

import (
	"fmt"
	"math"
)

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	var a, b, n int
	fmt.Scan(&a, &b, &n)

	x := min(b-1, n)
	fmt.Println(int(math.Floor(float64(a*x)/float64(b))) - a*int(math.Floor(float64(x)/float64(b))))
}


Measured memory_bytes: 1756
#include <cstdio>
#include <vector>
using namespace std;

struct card {char f; int n, i;};

typedef vector<card> v;
typedef v::iterator vi;

#define gcu getchar_unlocked
static inline int in()
{
	int c, n = 0;
	while ((c = gcu()) >= '0' && c <= '9')
		n = 10 * n + (c - '0');
	return n;
}

#define pcu putchar_unlocked
static inline void out(int n)
{
	static char buf[20];
	char *p = buf;
	if (!n)
		*p++ = '0';
	else
		while (n)
			*p++ = n % 10 + '0', n /= 10;
	while (p != buf)
		pcu(*--p);
}

void qs(vi p, vi r) {
	if (p < r) {
		vi i = p, j = i;
		for (;j != r;j++)
			if ((*j).n <= (*r).n)
				swap(*j, *i++);
		swap(*i, *r);

		qs(p, i - 1);
		qs(i + 1, r);
	}
}

int main()
{
	v A(in());

	int i = 0;
	for (card &x : A) {
		x.f = gcu(), gcu();
		x.n = in();
		x.i = i++;
	}

	vi b = A.begin(), e = A.end();
	qs(b, e - 1);

	bool s = true;
	for (vi i = b + 1; i < e; i++, b++)
		if ((*b).n == (*i).n && (*b).i > (*i).i) {
			s = false;
			break;
		}
	puts(s ? "Stable" : "Not stable");

	for (card &x : A)
		pcu(x.f), pcu(' '), out(x.n), pcu('\n');
}


Measured memory_bytes: 3304
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
    ll N, T, result = 0;
    cin >> N >> T;
    vector<int> t(N);
    REP(i, N) {
        cin >> t[i];
    }
    REP(i, N) {
        result += T;
        if (i != 0 && t[i] - t[i-1] < T) {
            result -= (T - t[i] + t[i-1]);
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 1024
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        m: usize,
        a:[usize;n]
    }

    let mut pr_queue: BinaryHeap<usize> = BinaryHeap::new();

    for p in &a {
        pr_queue.push(*p);
    }

    for i in 0..m {
        let max = pr_queue.pop().unwrap();
        pr_queue.push(max / 2);
    }

    //println!("{:?}", pr_queue);

    let mut ans = 0;

    while pr_queue.len() > 0 {
        let num = pr_queue.pop().unwrap();
        ans += num;
    }

    println!("{}", ans);
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 10620
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N, K;
  cin >> N >> K;
  map<ll, ll> A;
  REP(i, 0, N) {
    ll a;
    cin >> a;
    if (A.find(a) != A.end()) {
      A[a]++;
    } else {
      A.emplace(a, 1);
    }
  }

  if (A.size() <= K) {
    cout << 0 << endl;
    return 0;
  }

  vector<pll> P;
  for (const auto& a : A) {
    P.emplace_back(a.first, a.second);
  }
  sort(P.begin(), P.end(), [](const auto& a, const auto& b) {
    return a.second > b.second;
  });

  ll ans = 0;
  ll k = 0;
  REP(i, 0, P.size()) {
    if (k < K) {
      // nop
    } else {
      ans += P[i].second;
    }
    k++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 18544
#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 INF 1e10
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef unsigned long long ll;

int main(){
    int n, w, h;
    cin >> w>> h >>n;
    int x, y, a;

    pair<int, int> bottom = {0, 0};
    pair<int, int> top = {w, h};

    bool gone = false;

    REP(i, n){
        cin >> x>> y >> a;
        if (a==1){
            if (bottom.first < x) bottom.first = x;
        }
        else if (a == 2){
            if (top.first > x) top.first = x;
        }
        else if (a == 3){
            if (bottom.second < y) bottom.second= y;
        }
        else{
            if (top.second > y) top.second = y;
        }
    }
    if(top.first - bottom.first< 0 || top.second - bottom.second < 0)cout << 0;
    else cout << (top.first - bottom.first)*(top.second - bottom.second )<<endl;
    
    return 0;
}   
        


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int MOD=1e9+7;
const double pi=acos(-1);


int main(){
  int n;
  cin >> n;
  vector<string>ans;
  queue<string>que;
  que.emplace("a");
  while(!que.empty()){
    string t=que.front();
    que.pop();
    int m=t.size();
    if(m==n){
      ans.push_back(t);
    }
    else{
      char c=*max_element(t.begin(),t.end());
      c++;
      for(auto d='a';d<=c;d++){
        string s=t+d;
        que.emplace(s);
      }
    }
  }
  sort(ans.begin(),ans.end());
  ans.erase(unique(ans.begin(),ans.end()),ans.end());
  rep(i,ans.size()){
    cout << ans[i] << endl;
  }
  
}


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

int main() {
  int r,D,i;
  vector<int> x(11);
  cin >> r >> D >> x.at(0);
  
  for(i=0; i<10; i++) {
    x.at(i+1) = r*x.at(i)-D;
    cout << x.at(i+1) << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,m;
  cin >> n >> m;
  long scc=0;
  if(m<=n*2)scc=m/2;
  else{
    scc=n;
    m-=2*n;
    scc+=m/4;
  }
  cout << scc;
}

Measured memory_bytes: 256
// Nguyen Anh Tu
#include <bits/stdc++.h>
#define FOR(x,a,b) for(int x=a;x<=b;x++)
#define FORD(x,a,b) for(int x=a;x>=b;x--)
#define maxn 100005
#define maxc 1000000007
#define MOD 1000000007
#define reset(x, y) memset(x,y,sizeof(x))
#define task ""
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define pii pair<int,int>
#define ll long long
#define bit(p,x) ((x>>p) & 1)
#define remain(a,b) (a+b >= MOD) ? (a+b - MOD) : (a+b)
using namespace std;
int main()
{
    ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
    if(fopen(task".inp", "r"))
    {
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }
    string s;
  	cin >> s;
  	if(s == "ABC") cout << "ARC";
  else cout << "ABC";
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    int x,y,z; cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
    return 0;
}

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

vector<int>v;
int maxn=-1;

int judge(int n)
{
    //cout<<"  "<<n<<endl;
    if(n<10)
        return 1;

    int t=n%10;
    n/=10;
    while(1)
    {

        //cout<< n%10 <<" "<< t <<endl;
        if(n==0)break;
        if(n%10+1!=t) return 0;


        t=n%10;
        n/=10;
    }


    return 1;
}

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int t;
        cin>>t;
        v.push_back(t);
    }
    for(int i=0;i<v.size();i++)
        for(int j=0;j<v.size();j++)
    {
        if(i!=j)
        {
            if(judge(v[i]*v[j]))
            {
                //cout<<judge(v[i]*v[j])<<endl;
                maxn=max(maxn,v[i]*v[j]);
            }
        }
    }
    cout<<maxn<<endl;
    return 0;
}

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

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

    string S;
    cin >> S;
    int N;
    cin >> N;

    int ans = 0;

    REP(i, N)
    {
        string input;
        cin >> input;

        input += input;

        if(input.find(S) != string::npos)
        {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3200
import Control.Monad

main :: IO ()
main = do
  n <- (read :: String -> Int) <$> getLine
  inputs <- replicateM n getInts
  let ans = solve inputs
  print $ uncurry (+) ans
  
getInts :: IO [Int]
getInts = map read . words <$> getLine

solve :: [[Int]] -> (Int, Int)
solve = foldl (\(a, b) [x, y] ->
                 let v = max ((a + x - 1)`div`x) ((b + y - 1)`div`y) in
                 (v * x, v * y)) (1, 1)


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll gcd(ll a, ll b);
ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

int main(void){
  string s;
  cin >> s;
  int m = 1000;
  for (int i = 0; i < s.size() - 2; i++){
    m = min(m, abs((s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0') - 753));
  }


  cout << m << endl;

  return 0;
}

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

ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


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

#define IOS ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
 
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vp vector<pii>
#define vs vector<string>
#define all(v) v.begin(),v.end()

#define lb  lower_bound
#define ub  upper_bound
#define bs  binary_search
#define ff  first
#define ss  second
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
 
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
     
#define pi 3.14159265358979323846264338327950L
#define MOD 1000000007

 
int32_t main(){

    
     IOS
	int h,n,ans=0;
	cin>>h>>n;
	vi a(n,0);
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int x:a)
		ans+=x;
	if(ans>=h)
		cout<<"Yes";
	else
		cout<<"No";

	return 0;
}




Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();

		int[] a = { 1, 3, 5, 7, 8, 10, 12 };
		int[] b = { 4, 6, 9, 11 };

		if (x == 2 && y == 2 || Arrays.binarySearch(a, x) >= 0 && Arrays.binarySearch(a, y) >= 0
				|| Arrays.binarySearch(b, x) >= 0 && Arrays.binarySearch(b, y) >= 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


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

using namespace std;


#define ff				first
#define ss				second
#define int				long long
#define pb				push_back
#define mp				make_pair
#define pii				pair<int,int>
#define vi				vector<int>
#define mii 			map<int,int>
#define	pqb				priority_queue<int>
#define pqs				priority_queue<int,vi,greater<int> >
#define setbits(x)		__builtin_popcountll(x)
#define zrobits(x)		__builtin_ctzll(x)
#define mod				1000000007
#define inf 			1e18
#define ps(x,y)			fixed<<setprecision(y)<<x
#define mk(arr,n,type)	type *arr = new type[n]
#define w(x)			int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl			'\n'

void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}


bool isPrime(int n)
{
	if (n <= 1)
		return false;
	if (n <= 3)
		return true;
	if (n % 2 == 0 || n % 3 == 0)
		return false;
	for (int i = 5; i * i <= n; i += 6)
	{
		if (n % i == 0 || n % (i + 2) == 0)
			return false;

	}
	return true;
}

vector<int> Sieve(int n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));
	for (int i = 2; i * i <= n; i++)
	{
		if (prime[i])
		{
			for (int j = i * i; j <= n; j += i)
			{
				prime[j] = false;
			}
		}
	}
	vector<int> primes;

	for (int i = 2; i <= n; i++)
	{
		if (prime[i])
			primes.pb(i);
	}
	return primes;
}
map<int, int> primeFactors(int  n)
{
	mii factors;
	while (n % 2 == 0)
	{
		n /= 2;
		factors[2]++;

	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		// int count = 0;
		while (n % i == 0)
		{
			factors[i]++;
			n /= i;
		}
	}
	if (n > 2)
		factors[n]++;
	return factors;
}
int func(int h)
{
	if (h == 1)
		return 1;

	return 2 * func(h / 2) + 1;
}

// Graph------------------------------------------------------------------------

int32_t main()
{
	FIO;
	// c_p_c();
// --------------------------------------------------
// Never GIVE UP !!!!
	int ans = 0; int h;
	cin >> h;

	cout << func(h) << endl;


}

Measured memory_bytes: 3700
fun main(args: Array<String>) {
    val (H, W) = listOfInt()
    val A = Array(H) { listOfInt() }.flatMap { it }.toIntArray()
    fun yx(v: Int) = "${(v / W) + 1} ${(v % W) + 1}"
    val wh = W * H
    val wh0 = W * (H - 1)
    var N = 0
    val ans = StringBuilder()
    for (n in 0 until wh) {
        if (A[n] % 2 != 0) {
            var a = -1
            if (n < wh0) {
                a = n + W
            } else if (n < wh - 1) {
                a = n + 1
            }
            if (a > 0) {
                A[n] -= 1
                A[a] += 1
                ans.append("\n${yx(n)} ${yx(a)}")
                N += 1
            }
        }
    }
    println("${N}${ans.toString()}")
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }


Measured memory_bytes: 86056
#-*- coding: utf-8
#  -*-
"""
oj dl https://atcoder.jp/contests/abc116/tasks/abc116_d -d test-d
oj test -d test-d -c "python abc116d.py"
oj test -d test-d -c "python abc116d.py" test-d/sample-3.in
"""
from collections import defaultdict
import sys
import math
from datetime import datetime

def sol2(n, S):
    dp = defaultdict(int)
    pre_x = None
    pre_y = None
    for i, (x, y) in enumerate(S):
        #print(x, y, pre_x, pre_y)
        if i == 0:
            pre_x, pre_y = x, y
        else:
            dp[(x - pre_x, y - pre_y)] +=1
            pre_x, pre_y = x, y
    #print(dp)
    return n - max(dp.values())


def rec(S, pre, diff, n):
    if S == None or len(S) == 0 or len(S)==n: return 0

    tugi = (pre[0]+diff[0], pre[1]+diff[1])
    print("pre:%s, diff:%s, so tugi:%s while S:%s" % (str(pre), str(diff), str(tugi), S))
    if tugi in S:
        print("hit:%s" % str(tugi))
        S.remove(tugi)
        return 1 + rec(S, tugi, diff)
    else:
        print("end")
        return 0


def sol_botsu2(n, S):
    dp = defaultdict(int)
    if n == 1:
        return 1
    # n >= 2
    mx = 0
    tugi = S[1]
    for s in S:
        if tugi == s: continue
        tmp = rec(S[1:], s, (tugi[0]-s[0], tugi[1]-s[1]))
        mx = max(tmp, mx)

    return n - mx



def sol(n, S):
    PQ = []
    for s1 in S:
        for s2 in S:
            if s1 == s2: continue
            PQ.append((s2[0] - s1[0], s2[1] - s1[1]))
    mx = 0
    for p, q in set(PQ):
        tmp = 0
        for s1 in S:
            for s2 in S:
                if s1 == s2: continue
                if (s2[0] - s1[0], s2[1] - s1[1]) == (p, q):
                    tmp += 1
        mx = max(tmp, mx)

    return n - mx

do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    #print(parsed_lines)
    n = int(parsed_lines[0][0])
    #W = [int(x) for x in parsed_lines[1]]
    S = []
    for i in range(1, n+1):
        x = int(parsed_lines[i][0])
        y = int(parsed_lines[i][1])
        S.append((x, y))
    # k = int(parsed_lines[0][1])
    # S = parsed_lines[1][0]
    # return n, k, S
    return n, S


if not do_submit:
    n, S = input_parse("""
    2
    1 1
    2 2
    """)
    #print(sol(n, S))

    n, S = input_parse("""
    3
    1 4
    4 6
    7 8
    """)
    #print(sol(n, S))

    n, S = input_parse("""
    4
    1 1
    1 2
    2 1
    2 2
    """)
    print(sol(n, S))


else:
    n = int(input())
    S = []
    for i in range(n):
        x ,y = list(map(int, input().split()))
        S.append((x, y))
    # print(sol(n, k, S))
    #S = input().strip()
    # S = input().strip()
    print(sol(n, S))



Measured memory_bytes: 4080
#include <stdio.h>

int main(){
    int A,B,res;
    
    scanf("%d %d",&A,&B);
    
    if(A<B){
        printf("0\n");
    }
    else{
        res= A-(B*2);
        if(res<=0){
            printf("0\n");
        }
        else{
            printf("%d\n",res);
        }
    }
    
    
    return 0;
}

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

int N, nums[100];

void insertionSort(int nums[100]){
  for(int k = 0; k < N; k++){
    cout << nums[k];
    if(k < N - 1) cout << ' ';
    else cout << endl;
  }
  for(int i = 1; i < N; i++){
    int v = nums[i];
    int j = i - 1;
    while(j >= 0 && nums[j] > v){
      nums[j + 1] = nums[j];
      j--;
      nums[j+1] = v;
    }
    for(int k = 0; k < N; k++){
      cout << nums[k];
      if(k < N - 1) cout << ' ';
      else cout << endl;
    }
  }
}

int main(){
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> nums[i];
  }
  insertionSort(nums);
  return 0;
}

Measured memory_bytes: 3100
import java.util.*;
import java.lang.*;


class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int input = sc.nextInt();
    
    if (input%2 == 0 ) {
      System.out.println(input/2);
    } else {
      System.out.println(input/2 + 1 );
    }
  }
  
}

Measured memory_bytes: 23124
#include<stdio.h>
#define N 10000

main(){

  int n,m,i,j,a[N],b[N],c=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  scanf("%d",&m);

  for(j=0;j<m;j++){
    scanf("%d",&b[j]);
  }


 for(i=0;i<m;i++){ 
   for(j=0;j<n;j++){

     if(b[i]==a[j]){ c++;
     break;
     }
   }
 }

 printf("%d\n",c);
 return 0;
}

Measured memory_bytes: 648
n,m,_=gets.split.map &:to_i
C=gets.split.map &:to_i
r=0
n.times.map{
	c,w=gets.split.map &:to_i
	[c-1,w]
}.sort_by{|c,w|
	-w
}.each{|c,w|
	if m>0&&C[c]>0
		r+=w
		m-=1
		C[c]-=1
	end
}
p r


Measured memory_bytes: 17312
program main
  implicit none
  integer :: a(3)
  read *, a
  call quicksort(a)
  print "(i0)", a(1) * a(2) / 2

  contains
  recursive subroutine quicksort(a)
    integer, intent(inout) :: a(:)
    integer :: pivot, i, j, k, tmp, n
    real(4) :: r
    n = size(a)
    if (n <= 1) return
    i = 1
    j = n
    call random_number(r)
    k = 1 + floor(r * n)
    k = max(1, min(k, n))
    pivot = a(k)
    do
      do while (.not. pivot <= a(i))
        i = i + 1
      end do
      do while (.not. a(j) <= pivot)
        j = j - 1
      end do
      if (i >= j) exit
      tmp = a(i)
      a(i) = a(j)
      a(j) = tmp
      i = i + 1
      j = j - 1
    end do
    call quicksort(a(1:i - 1))
    call quicksort(a(j + 1:n))
  end subroutine quicksort
end program main



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
map<int, int> factor(int m) {
	map<int, int>res;
	for (int i = 2; i*i <= m; i++) {
		while (m%i == 0) {
			res[i]++;
			m /= i;
		}
	}
	if (m != 1)res[m]++;
	return res;
}

/*--------Library Zone!--------*/

int n, k, a[20], ans = inf, ma[20];
signed main() {
	cin >> n >> k;
	rep(i, n) {
		cin >> a[i];
		if (i)ma[i] = max(ma[i - 1], a[i - 1]);
	}
	rep(i, (1 << n)) {
		int cnt = 0;
		rep(j, n) {
			if ((i >> j) & 1)cnt++;
		}
		if (cnt < k)continue;
		vector<int>vec;
		int b[20];
		rep(j, n)b[j] = a[j];
		rep(j, n) {
			if ((i >> j) & 1)vec.push_back(j);
		}
		cnt = 0;
		for (int j = 1; j < vec.size(); j++) {
			if (b[vec[j]] <= ma[vec[j]] || b[vec[j]] <= b[vec[j - 1]]) {
				cnt += max(ma[vec[j]], b[vec[j - 1]]) - b[vec[j]] + 1;
				b[vec[j]] = max(ma[vec[j]], b[vec[j - 1]]) + 1;
			}
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	endre;
}

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

using namespace std;

int main() {
	int r, d, x;
	
	scanf("%d %d %d", &r, &d, &x);
	
	for (int i=0; i<10; ++i) {
		printf("%d\n", r*x-d);
		x = r*x-d;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		String str[][] = new String[][]{{"A", "10"}, {"B", "11"}, {"C", "12"},
										{"D", "13"}, {"D", "13"}, {"E", "14"}, 
										{"F", "15"}};
		
				Scanner sn = new Scanner(System.in);
		String x = sn.next();
		String y = sn.next();
		sn.close();
		
		int numX = 0;
		int numY = 0;
		for(int i = 0; i < str.length; i++){
			if(x.equals(str[i][0])){
				numX = Integer.parseInt(str[i][1]);
			}
			if(y.equals(str[i][0])){
				numY = Integer.parseInt(str[i][1]);
			}
		}
		
		if(numX > numY){
			System.out.println(">");
		}else if(numX < numY){
			System.out.println("<");
		}else{
			System.out.println("=");
		}	
	}
}

Measured memory_bytes: 22608