akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
 
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
constexpr ll MOD = 1000000007;
 
#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
#else
#define print(...)
#endif


int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    ll h,w,k,ans,cnt;

    cnt = 0;
    
    cin >> h >> w >> k;
    vector<vector<ll>> g(h,vector<ll>(w,0));

    for(ll i=0; i<h; i++){
        string s;
        cin >> s;
        for(ll j=0; j<w; j++){
            if(s[j] == '#'){
                g[i][j] = 1;
                cnt++;
            }
        }
    }

    ans = 0;

    for(ll i=0; i<pow(2,h); i++){
        for(ll j=0; j<pow(2,w); j++){
            vector<vector<ll>> g2 = g;
            ll c=cnt;
            ll a=0;
            for(ll y=i; y>0; y>>=1){
                if(y&1==1){
                    for(ll p=0; p<w; p++){
                        if(g2[a][p] == 1){
                            c-=g2[a][p];
                            g2[a][p]=0;
                        }
                    }
                }
                a++;
            }
            a=0;
            for(ll x=j; x>0; x>>=1){
                if(x&1==1){
                    for(ll p=0; p<h; p++){
                        if(g2[p][a] == 1){
                            c-=g2[p][a];
                            g2[p][a]=0;
                        }
                    }
                }
                a++;
            }
            if(c == k)
                ans++;
        }
    }
    
    cout << ans << endl;
 
    return 0;
}



Measured memory_bytes: 4056
#include <iostream>
using namespace std;
int main(){
  int x,y,dx,dy;
  cin>>x>>y>>dx>>dy;
  dx-=x;
  dy-=y;
  x+=dx;
  y+=dy;
  x+=-dy;
  y+=dx;
  cout<<x<<" "<<y<<" ";
  x-=dx;
  y-=dy;
  cout<<x<<" "<<y<<"\n";
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong();
		long X500 = X / 500;
		X -= X500 * 500;
		long X5 = X / 5;
		long H = X500 * 1000 + X5 * 5;
		System.out.println(H);
	}
}


Measured memory_bytes: 21844
#![allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let n: usize = read();
    let h = "hon";
    let p = "pon";
    let b = "bon";
    let word = [p, p, h, b, h, h, p, h, p, h];
    println!("{}", word[n % 10]);
}

Measured memory_bytes: 2128
#include <cstdio>
#include <algorithm>
#include <vector>
static const int MAXN = 2e5 + 4;
static const int LOGN = 20;
template <typename T> inline void upd_max(T &var, const T val) { if (var < val) var = val; }
template <typename T> inline void upd_min(T &var, const T val) { if (var > val) var = val; }

int n, v_max, x[MAXN];
int k, v[LOGN];
int f_lf[1 << LOGN], f_rg[1 << LOGN];
int rg_with_lf[MAXN];

void calc_dp(int *f)
{
    static int next[LOGN][MAXN];
    for (int i = 0; i < k; ++i) {
        for (int p = 0, q; p < n; ) {
            for (q = p + 1; q < n && x[q] - x[q - 1] <= v[i]; ++q) ;
            for (; p < q; ++p) next[i][p] = q;
        }
    }

    for (int i = 0; i < (1 << k); ++i) f[i] = 0;
    std::vector<int> pc[LOGN];
    for (int i = 0; i < (1 << k); ++i) pc[__builtin_popcount(i)].push_back(i);
    for (int i = 0; i < k; ++i) for (int mask : pc[i]) {
        for (int j = 0; j < k; ++j) if (!(mask & (1 << j))) {
            upd_max(f[mask | (1 << j)], next[j][f[mask]]);
        }
    }
}

int main()
{
    scanf("%d%d", &n, &v_max);
    for (int i = 0; i < n; ++i) scanf("%d", &x[i]);
    for (k = 0; v_max > 0; ++k, v_max /= 2) v[k] = v_max;
    v[k++] = 0;

    calc_dp(f_lf);
    std::reverse(x, x + n);
    for (int i = 0; i < n; ++i) x[i] = -x[i];
    calc_dp(f_rg);
    std::reverse(x, x + n);
    for (int i = 0; i < n; ++i) x[i] = -x[i];
    for (int i = 0; i < (1 << k); ++i) f_rg[i] = n - f_rg[i];

    for (int i = 0; i <= n; ++i) rg_with_lf[i] = MAXN;
    for (int i = 0; i < (1 << (k - 1)); ++i) upd_min(rg_with_lf[f_lf[i << 1]], f_rg[(((1 << (k - 1)) - 1) ^ i) << 1]);
    for (int i = n - 1; i >= 0; --i) upd_min(rg_with_lf[i], rg_with_lf[i + 1]);

    for (int i = 0, j; i < n; ) {
        for (j = i + 1; j < n && x[j] - x[j - 1] <= v[0]; ++j) ;
        bool possible = (rg_with_lf[i] <= j);
        for (; i < j; ++i) puts(possible ? "Possible" : "Impossible");
    }

    return 0;
}


Measured memory_bytes: 27564
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
int rnd(int x) { return mrand() % x; }
ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % mod; a = a * a % mod; }return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// head

int t;

int main()
{
	ios::sync_with_stdio(false);
#ifdef RG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main(){
  int n,m,i,j,i2,j2;
  cin>>n>>m;
  string a[n],b[m];
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  for(i=0;i<m;i++){
    cin>>b[i];
  }
  int cnt;
  for(i=0;i<n-m+1;i++){
  	for(j=0;j<n-m+1;j++){
      cnt=0;
      for(i2=0;i2<m;i2++){
      	for(j2=0;j2<m;j2++){
          if(a[i2+i][j2+j]!=b[i2][j2]){
            cnt++;
            break;
          }
        }
        if(cnt!=0)break;
      }
      if(cnt==0){
        cout<<"Yes";
        return 0;
      }
    }
  }
  cout<<"No";
}

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

int main(void){
	std::ios_base::sync_with_stdio(false);
	list<int> l;
	string s;
	int d;
	int n;

	cin >> n;
	for(int i=0; i<n; i++){
		cin >> s;
		if(s == "insert"){
			cin >> d;
			l.push_front(d);
		}else if(s == "delete"){
			cin >> d;
			list<int>::iterator pos;
			pos = find(l.begin(), l.end(), d);
			if(pos != l.end())l.erase(pos);
		}else if(s == "deleteFirst"){
			l.pop_front();
		}else if(s == "deleteLast"){
			l.pop_back();
		}
	}

	list<int>::iterator pos;
	for(pos=l.begin(); pos!=l.end(); pos++){
		if(pos != l.begin()) cout << " ";
		cout << *pos;
	}
	cout << endl;

	return 0;
}

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

using namespace std;

string s;

int main()
{
    while (1)
    {
        cin >> s;
        int sum = 0;
        int len = s.size();
        if (s == "0")
            break;
        for (int i = 0; i < len; i++)
        {
            sum += s[i] - '0';
        }
        cout << sum << endl;
    }

    return 0;
}



Measured memory_bytes: 3220
#include <iostream>

int main(void)
{
    int a, b;
    std::cin >> a >> b;
    if (a == 1) { a += 13; }
    if (b == 1) { b += 13; }
    if (a < b) { std::cout << "Bob"; }
    else if (a > b) { std::cout << "Alice"; }
    else { std::cout << "Draw"; }
    std::cout << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int h,w,kk[10][10],b,num[11]={},i,j,k,ans=0;
  bool t=true;
  scanf("%d%d",&h,&w);
  for (i=0;i<10;i++){
    for (j=0;j<10;j++){
      scanf("%d",&kk[i][j]);
    }
  }
  for (i=0;i<h*w;i++){
    scanf("%d",&b);
    num[b+1]++;
  }
  if (num[0]==h*w||num[2]==h*w){
    printf("0\n");
    return 0;
  }
  while (t){
    t=false;
    for (i=0;i<10;i++){
      for (j=0;j<10;j++){
        for (k=0;k<10;k++){
          if (kk[i][k]>kk[i][j]+kk[j][k]){
            kk[i][k]=kk[i][j]+kk[j][k];
            t=true;
          }
        }
      }
    }
  }
  for (i=1;i<11;i++) ans+=kk[i-1][1]*num[i];
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll

int t, n, m, k, a[300010], q, l, r;


int32_t main(){
INIT
int x;cin>>x;

if((x<600) ){cout<<8;return 0;}
if((x<800) ){cout<<7;return 0;}
if((x<1000) ){cout<<6;return 0;}
if((x<1200) ){cout<<5;return 0;}
if((x<1400) ){cout<<4;return 0;}
if((x<1600) ){cout<<3;return 0;}
if((x<1800) ){cout<<2;return 0;}if((x<2000) ){cout<<1;return 0;}
return 0;
}



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

using namespace std;

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, N) for(int i=0; i<(N); i++)
#define INF 2000200
typedef pair<int, int> P;
using Graph = vector<vector<int>>;

vector<bool> seen;
vector<vector<int>> dist(2100, vector<int>(2100));

int main(){
    int n, x, y;
    cin >> n >> x >> y;
    queue<int> que;
    int ans[n];
    REP(i,n){
        ans[i] = 0;
    }
    Graph G(n);

    REP(i, n-1){
        G[i].push_back(i+1);
        G[i+1].push_back(i);
    }

    x--;
    y--;
    G[x].push_back(y);
    G[y].push_back(x);

    REP(i,n){
        REP(j,n){
            if(i==j) dist[i][j] = 0;
            else dist[i][j] = INF;
        }
    }

    REP(i, n){
        que.push(i);
        dist[i][i] = 0;
        while(que.size()){
            int v = que.front();
            que.pop();
            if(v > i) ans[dist[i][v]-1] += 1;

            for(int nv: G[v]){
                if(dist[i][nv] != INF) continue;
                dist[i][nv] = dist[i][v]+1;
                que.push(nv);
            }
        }
    }

    REP(i,n-1) cout << ans[i] << "\n";

    return 0;
}

Measured memory_bytes: 17792
n = gets.to_i
a = gets.split(' ').map{|i| i.to_i}.sort

while a.length > 1
  a << (a[0] + a[1]) / 2.to_f
  a.delete_at(0)
  a.delete_at(0)
  a.sort!
end

puts a[0].round(5)

Measured memory_bytes: 1788
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return a % 1000000007;
}


int main(){
  ll n,k; cin >> n >> k; vl hatenum(k); ll ans = -1;
  rep(i,k){ ll x; cin >> x; hatenum[i] = x; }

  while(ans == -1){
    ll nd = n; ll ncope = n;
    
    while(nd != 0){
      ll nmod = nd % 10;
      
      for(ll x : hatenum){
        if(x == nmod){
          n++;
          nd = 0;
          break;
        }
      }
      
      nd /= 10;
    }
     
    if(n == ncope) ans = n;
  }
  
  cout << n << endl;
}
      
      

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <utility>
using namespace std;
int N, A[100002], L[100002], R[100002], ans;
int gcd(int a, int b) {
  if(a == 0) return b;
  if(b == 0) return a;
  if(a < b) swap(a, b);
  int r = 1;
  while(r > 0) r = a % b, a = b, b = r;
  return a;
}
int main() {
  scanf("%d", &N);
  for(int i = 1; i <= N; ++i) scanf("%d", &A[i]);
  for(int i = 1; i <= N; ++i) {
    L[i] = gcd(L[i-1], A[i]);
    R[N-i+1] = gcd(R[N-i+2], A[N-i+1]);
  }
  for(int i = 1; i <= N; ++i) {
    ans = max(ans, gcd(L[i-1], R[i+1]));
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 1280
n = int(input())
P = [int(p) for p in input().split()]

ans = 0
for i in range(1,n-1):
    if P[i-1]<P[i] and P[i+1]>=P[i]:
        ans += 1
    elif P[i+1]<P[i] and P[i-1]>=P[i]:
        ans += 1
print(ans)


Measured memory_bytes: 2940
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

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

    int n, x; cin >> n >> x;
    vector<int> l(n); for (int& y : l) cin >> y;
    int d = 0, i = 0;
    while (i < n && d <= x) {
        d += l[i];
        i++;
    }
    if (d <= x) i++;
    cout << i << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<utility>
#include<queue>
#include<algorithm>
using namespace std;
typedef pair<int,int> Point;
const int INF = 100000000;
const int MAX_H = 1200;
const int MAX_W = 1200;
int d[MAX_H][MAX_W];
char data[MAX_H][MAX_W];
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
int solve(Point start, Point goal, int H, int W){
  queue<Point> q;
  q.push(start);
  for(int i = 0 ; i < MAX_H ; i++){
    for(int j = 0 ; j < MAX_W ; j++)
      d[i][j] = INF;
  }
  d[start.first][start.second] = 0;
  while(q.size()){
    Point p = q.front();
    q.pop();
    if(p.first == goal.first && p.second == goal.second)
      return d[p.first][p.second];
    else{
      int i = p.first;
      int j = p.second;
      for(int k = 0 ; k < 4 ; k++){
        int i_ = i + dy[k];
        int j_ = j + dx[k];
        if(i_ >= 0 && i_ < H && j_ >= 0 && j_ < W && data[i_][j_] == '.' && d[i_][j_] == INF){
          q.push(make_pair(i_,j_));
          d[i_][j_] = d[i][j] + 1;
        }
      }
    }
  }
}
int main(){
  int H,W,N;
  scanf("%d %d %d",&H,&W,&N);
  char str[MAX_W];
  Point p[N+1];
  for(int i = 0 ; i < H ; i++){
    scanf("%s",str);
    for(int j = 0 ; j < W ; j++){
      if(str[j] == 'S'){
        p[0] = make_pair(i,j);
        data[i][j] = '.';
      }
      else if(str[j] >= '1' && str[j] <= '9'){
        p[str[j] - '0'] = make_pair(i,j);
        data[i][j] = '.';
      }
      else
        data[i][j] = str[j];
    }
  }
  int ans = 0;
  for(int i = 0 ; i < N ; i++)
    ans += solve(p[i],p[i+1],H,W);
  printf("%d\n",ans);
}



Measured memory_bytes: 9412
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        var hw = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var h = hw[0];
        var w = hw[1];
        var map = Enumerable.Repeat(0, hw[0]).Select(_ => Console.ReadLine().ToArray()).ToArray();
        var res = 0;
        var steps = Enumerable.Range(0, h).Select(_ => Enumerable.Repeat(int.MaxValue, w).ToArray()).ToArray();
        steps[0][0] = map[0][0] == '#' ? 1 : 0;
        for (int i = 0; i < h + w; i++)
        {
            for (int y = 0, x = i; y < h && 0 <= x; y++, x--)
            {
                if (w <= x) continue;
                
                if (y != 0) 
                    steps[y][x] = Min(steps[y][x], steps[y - 1][x] + (map[y - 1][x] != map[y][x] ? 1 : 0));
                
                if (x != 0) 
                    steps[y][x] = Min(steps[y][x], steps[y][x - 1] + (map[y][x - 1] != map[y][x] ? 1 : 0));
            }
        }
        Console.WriteLine((steps.Last().Last() + 1) / 2);
    }
}


Measured memory_bytes: 13652
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;

	cout << N * (N - 1) / 2 + M * (M - 1) / 2 << "\n";

	return 0;
}

Measured memory_bytes: 256
H, W, K = gets.split.map(&:to_i)
MOD = 10 ** 9 + 7
dp = Array.new(H + 1) { Array.new(W, 0) }
dp[0][0] = 1
H.times do |h|
  (0...(1 << (W - 1))).each do |bit|
    #check
    flag = false
    (1...W).each do |i|
      if bit[i] == 1 && bit[i - 1] == 1
        flag = true
      end
    end
    next if flag
    W.times do |w|
      # fiber
      if w != W - 1 && bit[w] == 1
        target = w + 1
      elsif w != 0 && bit[w - 1] == 1
        target = w - 1
      else
        target = w
      end
      dp[h + 1][target] = (dp[h + 1][target] + dp[h][w]) % MOD
    end
  end
end
puts dp[H][K - 1]


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll x;
    vector<ll>cnt(n+1,0);
    for(ll i=2;i<=n;i++)
    {
        cin>>x;
        cnt[x]++;
    }
    for(ll i=1;i<=n;i++)
    {
        cout<<cnt[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 4788
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;

    FOR(i,1,n+1) if (i % 3 == 0 || to_string(i).find('3') != string::npos) cout << " " << i;
    cout << endl;

    return 0;
}


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

prime = [True] * (2*n + 1)
prime[0] = False
prime[1] = False
for i in range(2, int(n**0.5) + 1):
	if not prime[i]:
		continue
	for j in range(i * 2, 2*n + 1, i):
		prime[j] = False
for i in range(2*n+1) :
	if prime[i]:
		if i>=n:
			print(i)
			break


Measured memory_bytes: 4596
a,b,c,d,e,f=map(int,input().split())
d2={1:a,2:b,3:c,4:d,5:e,6:f}
d1={a:1,b:2,c:3,d:4,e:5,f:6}
a,b,c,d,e,f=1,2,3,4,5,6
ans=[[b,c,e,d,b],[a,d,f,c,a],[a,b,f,e,a],[a,e,f,b,a],[a,c,f,d,a],[b,d,e,c,b]]
for _ in range(int(input())):
    top,front=map(int,input().split())
    top,front=d1[top],d1[front]
    top-=1
    for i in range(len(ans[top])):
        if front==ans[top][i]:
            print(d2[ans[top][i+1]])
            break
    


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;  typedef pair<ll,ll> pii;
typedef vector<int> VI; typedef vector<ll> VL;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main(){
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI a(n);
	rep(i, n) cin >>a[i];
	
	sort(all(a));
	
	
	int rg=0, ans =0;
	rep(lf, n){
		for(; rg<n && a[rg] - a[lf] <=2 ;rg++){
			ans = max(ans, rg +1 - lf);
		}
	}
	cout << ans <<"\n";
	return 0;
}


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


void solve(long long N, std::vector<long long> a){
    sort(a.begin(), a.end());
    cout << abs(a[a.size()-1] - a[0]) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e8;
const ll INF=1e16;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	string s,t;
	cin>>s>>t;
	vi co1(s.size()+1);
	vi co2(t.size()+1);
	rep(i,s.size())if(s[i]=='A')co1[i+1]=1;
	rep(i,t.size())if(t[i]=='A')co2[i+1]=1;
	rep(i,s.size())co1[i+1]+=co1[i];
	rep(i,t.size())co2[i+1]+=co2[i];
	int q;
	cin>>q;
	while(q--){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		a--;c--;
		int co1a=co1[b]-co1[a],co1b=b-a-co1a;
		int co2a=co2[d]-co2[c],co2b=d-c-co2a;
		if(co1a>co2a){
			swap(co1a,co2a);
			swap(co1b,co2b);
		}
		int t=co2a-co1a;
		co2b+=t*2;
		if(abs(co2b-co1b)%3==0)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

/*#define MOD 1000000007
// a^b mod MOD
ll powmod(ll a,ll b){
	ll out=1;
	ll p=a%MOD;
	while(b){
		if(b&1)out=out*p%MOD;
		p=p*p%MOD;
		b>>=1;
	}
	return out;
}
int main(){
	int n,m;
	cin>>n>>m;
	vi a(n);
	rep(i,n)cin>>a[i];
	vi b(m);
	rep(i,m)cin>>b[i];
	ll s=(a[n-1]-a[0])%MOD,t=(b[m-1]-b[0])%MOD;
	ll out=s*t%MOD;
	(out*=(n-1)*(m-1)%MOD)%=MOD;
//	(out*=powmod(2,n-2))%=MOD;
//	(out*=powmod(2,m-2))%=MOD;
	cout<<out<<endl;
}*/








Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
    int n,k;
    int c = 0,mymin = mod;
    int a[100000];

    cin >> n >> k;
    FOR(i,0,n){
        cin >> a[i];
        if(a[i] < mymin)mymin = a[i];
    }
    FOR(i,0,n){
        if(a[i] == mymin)c++;
    }

    cout << (n-c)/(k-1) + min(1,(n-c)%(k-1));

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--) 
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
typedef pair<int, int> pii;
#define x first
#define y second
const int N = 410, M = 1e5 + 10;
int f[N][N], a[M], b[M];
int n, m;
bool t[N];
bool work(int f[], int x) {
	f[x] = m + 1; 
	dep(i,m,1) {
		if (f[a[i]] && f[b[i]]) return false;
		else if (f[a[i]]) f[b[i]] = i;
		else if (f[b[i]]) f[a[i]] = i;
	}
	return true;
}

int main() {
	scanf("%d%d",&n,&m);
	rep(i,1,m) scanf("%d%d",a + i, b + i);
	rep(i,1,n) t[i] = work(f[i], i);
	int ans = 0;
	rep(i,1,n) rep(j,i + 1,n) if (t[i] && t[j]) {
		int tmp = 1;
		rep(k,1,n) if (f[i][k] && f[j][k] && f[i][k] != f[j][k]) tmp = 0;
		ans += tmp;
	}
	printf("%d\n",ans);
	return 0;
}


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

int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    long long A, B, N;
    cin >> A >> B >> N;

    long long z = min(B-1, N);
    long long maximum = (A*z)/B;
    cout << maximum << endl;
    return 0;
}

Measured memory_bytes: 3640
X,N = map(int,input().split())
try:
    li = list(map(int,input().split()))
except:
    li = []
flg=0
d=1
if X not in li:
    print(X)
    flg=1
while flg==0:
    if X+d in li and X-d in li:
        d+=1
    elif X+d not in li and X-d not in li:
        print(X-d)
        flg=1
    elif X+d not in li:
        print(X+d)
        flg=1
    else:
        print(X-d)
        flg=1


Measured memory_bytes: 9204
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
	for(int n,m;cin>>n>>m,n|m;){
		vector<vector<double> > g(n,vector<double>(n));
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				cin>>g[i][j];
		
		vector<vector<double> > dp(m,vector<double>(n,0));
		dp[0].assign(n,1);
		for(int i=1;i<m;i++){
			for(int j=0;j<n;j++)
				for(int k=0;k<n;k++)
					dp[i][j]=max(dp[i][j],dp[i-1][k]*g[k][j]);
		}
		
		cout<<fixed<<setprecision(2)<<*max_element(dp[m-1].begin(),dp[m-1].end())<<endl;
	}
	return 0;
}

Measured memory_bytes: 1088
// 200219.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

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

    if (N >= 10) {
        cout << R << endl;
    }
    else {
        cout << R + 100 * (10 - N) << endl;
    }
    return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int P = 998244353;
const int L = 4001;
int n;
using Bit = bitset<L>;
typedef pair<Bit,int> num;
num X , A[6];
char s[10000];
void output(num x){
    per(i,0,10) putchar(x.fi[i]+'0');puts("");
}
void read(num&b){
    scanf("%s",s);
    b.fi.reset();
    int len = strlen(s);
    rep(i,0,len) b.fi[i]=s[len-1-i]-'0';
    b.se=len-1;
}
num gcd(num x,num y){
    if(x.se<y.se) swap(x,y);
    if(y.se==-1) return x;
    num z(x.fi^(y.fi<<(x.se-y.se)),x.se);
    while(z.se>=0&&z.fi[z.se]==0) z.se--;
    return gcd(z,y);
}

int main(){
    scanf("%d",&n);
    read(X);
    rep(i,0,n) read(A[i]);
    rep(i,1,n) A[0]=gcd(A[0],A[i]);
    int ans = 0;
    for(int i=X.se;i>=A[0].se;--i){
        ans = (ans + ans) % P;
        if(X.fi[i] == 1) ans = (ans + 1) % P;
    }
    num Y = X;
    rep(i,0,A[0].se) Y.fi[i]=0;
    for(int i=Y.se;i>=A[0].se;--i)if(Y.fi[i]){
        Y.fi ^= A[0].fi << (i - A[0].se);
    }
    bool ok = true;
    for(int i=A[0].se-1;i>=0;--i) if(X.fi[i]!=Y.fi[i]){
        if(X.fi[i]<Y.fi[i]) ok=false;
        break;
    }
    ans = (ans + ok) % P;
    printf("%d\n",ans);
    return 0;
}


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

long long maxx = 1e18;
void Solve(){
    int n;
    cin>>n;
    vector<long long> v(n);
    for(int i = 0; i < n; i++)
        cin>>v[i];
    sort(v.begin(), v.end());
    //for(auto x: v) cout<<x<<endl;
    if(v[0] == 0){
        cout<<0<<'\n';
        return;
    }
    long long res = 1;
    for(int i = 0; i < n; i++){
        long long remain = maxx / res + 1;
        if(v[i] >= remain){
            cout<<-1<<'\n';
            return;
        }
        res *= v[i];
    }
    cout<<res<<'\n';
} 
int main() 
{ 
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    Solve();
}

  

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

int main() {
    int n, a[105]{}, ans=1, l=1;
    cin >> n;
    REP(i,n) cin >> a[i+1];
    REP(i,n+1){
        if(a[i+1]==1){
            l++;
        }
        else{
            ans = max(ans, l);
            l=1;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3100
import itertools
from math import sqrt, pow

N = int(input())
lst = []
for _ in range(N):
    lst.append([int(x) for x in input().split()])

ret_lst = []
for l in itertools.permutations(lst):
    ret = 0
    for idx, (x1, y1) in enumerate(l[:-1]):
        x2 = l[idx + 1][0]
        y2 = l[idx + 1][1]
        ret += sqrt(pow((x1 - x2), 2) + pow((y1 - y2), 2))
    ret_lst.append(ret)

print(sum(ret_lst) / len(ret_lst))


Measured memory_bytes: 4440
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

struct Group
{
	std::string name;
	std::vector<std::string> members;
	Group(std::string& s) {
		int l=0;int r=0;
		for(char i:s) {
			if(i==':') {
				name = s.substr(l,r-l);
				l=r;
			}
			if(i==',' || i=='.') {
				members.emplace_back(s.substr(l+1,r-l-1));
				l=r;
			}
			r++;
		}
	}
};

void dfs(std::vector<Group>& groups, std::set<std::string>& members, int group, std::vector<int>& went) {
	if(went[group]) return;
	went[group] = 1;
	for(std::string m:groups[group].members) {
		bool found = false;
		rep(i,groups.size()) {
			if(groups[i].name==m) {
				found = true;
				dfs(groups,members,i,went);
			}
		}
		if(!found) members.emplace(m);
	}
}

signed main() {
	while(true) {
		int n;
		std::cin >> n;
		if(n==0) break;
		std::vector<Group> groups;
		groups.reserve(n);
		rep(i,n) {
			std::string s;
			std::cin >> s;
			groups.emplace_back(s);
		}
		std::set<std::string> members;
		std::vector<int> went(n,0);
		dfs(groups, members,0,went);
		print(members.size());
	}
	return 0;
}



Measured memory_bytes: 3280
#include<stdio.h>
#include<string.h>
#define N 8
int board[N][N];
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_13_A -- backtracking
//chech previous part but there are fixed point before that
//so check all of them
bool safe(int row, int col){
	//chec the column
	if(board[row][col]==1) return true;
	for(int i = 0; i<N; i++){
		if(board[row][i] == 1) return false;
	}
	//check the row
	for(int i = 0; i<N; i++){
		if(board[i][col] == 1) return false;
	}
	//check the diagional
	int i = row, j = col;
	while(i>=0 && j>=0){
		if(board[i][j]==1) return false;
		i--; j--;
	}
	i = row, j = col;
	while(i<N && j<N){
		if(board[i][j]==1) return false;
		i++; j++;
	}
	i = row, j = col;
	while(i>=0 && j<N){
		if(board[i][j]==1) return false;
		i--; j++;
	}
	i = row, j = col;
	while(i<N && j>=0){
		if(board[i][j]==1) return false;
		i++; j--;
	}
	//printf("check\n");
	return true;
}

//for each row([0,7]),check the column
bool solve_board(int col){
	//all chess placed
	if(col>=N) return true;
	for(int i = 0; i<N; i++){
		if(board[i][col]==1){
			if(solve_board(col+1)) return true;
		}
		else {
		if(safe(i,col)){
			//printf("%d %d\n",i,col);
			board[i][col] = 1;
			//recur--key points
			if(solve_board(col+1)) return true; 
			board[i][col] = 0;
		}}
		
	}
	return false;
}

int main(){
	int n = 0;
	memset(board,0,sizeof(board));
	scanf("%d",&n);
	for(int i = 0; i<n; i++){
		int a, b;
		scanf("%d %d",&a,&b);
		board[a][b] = 1;
	}
	//for each column, check the row
	solve_board(0);
	for(int i = 0; i<N; i++){
		for(int j = 0; j< N; j++){
			if(board[i][j]==0) printf(".");
			else printf("Q");
		}
		printf("\n");
	}
}


Measured memory_bytes: 2692
from collections import deque

def solve():
    N, M = [int(_) for _ in raw_input().split()]
    to = [ [] for i in range(N) ]
    for i in range(M):
        Xi, Yi, Zi = [int(_) for _ in raw_input().split()]
        Xi -= 1
        Yi -= 1
        to[Xi].append(Yi)
        to[Yi].append(Xi)
    union = [None] * N
    que = deque()
    union_cnt = 0
    for i in range(N):
        if union[i] is not None:
            continue
        union_cnt += 1
        # BFS
        que.append(i)
        while len(que) > 0:
            vi = que.popleft()
            union[vi] = union_cnt
            for j in range(len(to[vi])):
                fri = to[vi][j]
                if union[fri] is not None:
                    continue
                union[fri] = union_cnt
                que.append(fri)
    print str(union_cnt)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 50332
#include <bits/stdc++.h>
#include <set>
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
//setprecision(10);
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

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

const int inf=100000000;

long long modpow(long long a, long long n, long long mod) //a^n
{
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

llong gcd(llong a, llong b) {
        return b != 0 ? gcd(b, a % b) : a;
    }

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    llong a,b,c,d;
    cin>>a>>b>>c>>d;
    a--;
    if(a>b) swap(a,b);
    if(c>d) swap(c,d);
    llong cnt=c*d/gcd(c,d);
    llong cnta=a/cnt;
    llong va=a%cnt;
    llong cntb=b/cnt;
    llong vb=b%cnt;

    llong ab=0;
    ab=cnt/d+cnt/c-1;
    llong vbb=vb/d+vb/c;
    llong vaa=va/d+va/c;

    llong vans=cntb*ab+vbb-cnta*ab-vaa;
    cout<<b-a-vans<<endl;

    return  0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <stack>
#include <map>
#include <queue>
#include <math.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    long long x, y;
    cin>>x>>y;

    long long a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a, a+n);
    reverse(a, a+n);

    long long s=0;
    long long low=0, high=(a[0]+y-1)/y;
    long long mid;
//    int left[n];
    long long mini = (1<<30);
//    memset(left, 0, sizeof(left));
    long long br=0;

//        cout<<low<<" "<<mid<<" "<<high<<endl;
    while(low<=high)
    {
        mid = (low+high)/2;
//        cout<<low<<" "<<mid<<" "<<high<<endl;
//        bool f=false;
        br =0;

        for(int i=0; i<n; i++)
        {
            int pomm = a[i] - (mid*y);
            
            if(pomm>0)
            br+=(pomm+((x-y)-1))/(x-y);
        }

        if(br<=mid)
        {
            mini = min(mini, mid);
            high = mid-1;
        }
        else
        {
//            mini = min(mini, low);
            low = mid+1;
        }
    }

    cout<<mini<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll n, m ;
  cin>> n>>m;
  for (ll i=0; i< m; i++){
  	ll a;
  	cin>>a;
    n = n-a;
  }
  if (n<0){
  	cout<< -1<<endl;
  }else{
    cout<< n<<endl;
  }
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
// #include <string>
// #include <map>
// #include <set>
// #include <cmath>

#define MOD 1000000007

using namespace std;
typedef unsigned long long ull;

void p() {
    cout << "\n";
}
template<class Head, class... Body>
void p(Head head, Body... body) {
    cout << head << ",";
    p(body...);
}

bool get_third(bool first, bool second, char remark) {
    return (second && ((remark == 'o' && first) || (remark == 'x' && !first))) ||
            (!second && ((remark == 'o' && !first) || (remark == 'x' && first)));
}

int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    string s;
    cin >> s;

    vector<bool> is_sheep(N);

    bool found = false;
    for (int flag = 0; flag < 4; ++flag) {
        is_sheep[0] = (flag >> 0) & 1;
        is_sheep[1] = (flag >> 1) & 1;
        for (int i = 2; i < N; ++i) {
            is_sheep[i] = get_third(is_sheep[i-2], is_sheep[i-1], s[i-1]);
        }
        if (is_sheep[N-1] == get_third(is_sheep[1], is_sheep[0], s[0]) &&
            is_sheep[0] == get_third(is_sheep[N-2], is_sheep[N-1], s[N-1])) {
            found = true;
            break;
        }
    }

    if (!found) {
        cout << -1 << endl;
    } else {
        string ans;
        for (int i = 0; i < N; ++i) {
            if (is_sheep[i]) {
                ans += "S";
            } else {
                ans += "W";
            }
        }
        cout << ans << endl;
    }

    return 0;
}


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

vector<int>g[300200];
int mod = 1e9 + 7;
int p[300200];
int colored[300200];
int res = 1;
int k;
void dfs(int v, int pr = -1)
{
    p[v] = pr;
    int closed = p[v] != -1 ? colored[p[v]] + (p[p[v]] != -1) : 0;
    colored[v]++;
    if (p[v] != -1)
        colored[p[v]]++;
    res *= (k - closed);
    res %= mod;
    for(int i = 0; i < g[v].size(); ++i)
    {
        int to = g[v][i];
        if (to == pr)
            continue;
        dfs(to, v);
    }
}


using namespace std;
signed main()
{
    int n;
    cin >> n >> k;
    for(int i = 1; i < n; ++i)
    {
        int a, b;
        cin >> a >> b;
        g[--a].push_back(--b);
        g[b].push_back(a);
    }
    dfs(0);
    cout << res;
    return 0;
}


Measured memory_bytes: 17408
package main

import (
    "fmt"
)

func hoge(n int) int {
    if n == 0 {
        return 0
    }
    for i := 0;true;i++ {
        if ((n >> uint(i)) & 1 == 1){
            return i
        }
    }
    return 0
}

func main() {
    var n int
    fmt.Scan(&n)
    count := 0
    for i := 0; i < n; i++ {
        var ai int
        fmt.Scan(&ai)
        count += hoge(ai)
    }
    fmt.Println(count)
}

Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

typedef pair<ll,ll> Pair;

int main(){

string S,T;
ll ans = 0;

cin >> S >> T;

for(ll i = 0;i < S.size();++i){
    if(S[i] != T[i]){
        ans++;
    }
}

cout << ans << endl;

return 0;

}


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

bool d[81][81][12900];

int main()
{
    int h, w;
    cin >> h >> w;
    int a[81][81], b[81][81];
    int c[81][81];
    for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) cin >> a[i][j];
    for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) cin >> b[i][j];
    for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) c[i][j] = abs(a[i][j] - b[i][j]);
    d[0][0][c[0][0]] = true;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            for(int k = 0; k < 12800; k++){
                if(d[i][j][k]){
                    if(i < h - 1){
                        d[i + 1][j][k + c[i + 1][j]] = true;
                        d[i + 1][j][abs(k - c[i + 1][j])] = true;
                    }
                    if(j < w - 1){
                        d[i][j + 1][k + c[i][j + 1]] = true;
                        d[i][j + 1][abs(k - c[i][j + 1])] = true;
                    }
                }
            }
        }
    }
    for(int i = 0; i < 12800; i++){
        if(d[h - 1][w - 1][i]){
            cout << i << endl;
            return 0;
        }
    }
}

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

#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--)

typedef long long ll;
typedef unsigned long long ull;

const int INF = 999999999;

int main(){
   int a,b,c;
   cin >> a >> b >> c;
   cout << a+b+c-max({a,b,c});
   return 0;
}

Measured memory_bytes: 256
N = int(input())
a = [None]
b = list(map(int,input().split()))
a.extend(b)
ball = [0]*(N+1)

for i in range(1,N+1)[::-1]:
    s = 0
    now = 0
    k = 2

    while True:
        now = i*k
        if now > N:
            break
        s += ball[now]
        k += 1

    if s%2 == a[i]:
        ball[i] = 0
    else:
        ball[i] = 1

print(sum(ball))

for i in range(N+1):
    if ball[i] == 1:
        print(i,end=" ")

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

int main() {
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i,n) cin >> v[i];
    sort(v.begin(),v.end());
    ll ans=0;
    for(int i=0;i<n;i++)for(int j=i+1;j<n;j++)for(int k=j+1;k<n;k++){
        if(v[i]+v[j]>v[k])if(v[i]!=v[j]&&v[j]!=v[k]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
using System;

namespace C_sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine();
            var S = int.Parse(line);

            var h = S / 3600;
            var m = S % 3600 / 60;
            var s = S % 60;

            Console.WriteLine($"{h}:{m}:{s}");
        }
    }
}



Measured memory_bytes: 17916
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/2/
Solved on 2019/2/
@author: shinjisu
"""


# ABC 111 C /\/\/\/
def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def getIntLines(n): return [int(input()) for i in range(n)]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def zeros2(n, m): return [zeros(m)]*n


def dmp(x):
    global debug
    if debug:
        print(x)
    return x


def probC():
    N = getInt()
    V = getIntList()
    dmp((N, V))
    odd = {}
    even = {}
    for i in range(N):
        if i % 2 == 0:
            if V[i] in even:
                even[V[i]] += 1
            else:
                even[V[i]] = 1
        else:
            if V[i] in odd:
                odd[V[i]] += 1
            else:
                odd[V[i]] = 1
    dmp(('even',even))
    dmp(('odd',odd))
    evenList = [[even[k], k] for k in even]
    evenList.sort()
    evenList.reverse()
    dmp(evenList)
    oddList = [[odd[k], k] for k in odd]
    oddList.sort()
    oddList.reverse()
    dmp(oddList)
    if evenList[0][1] == oddList[0][1]:  # 度数最大の値が同一の場合
        if len(evenList) == 1 and len(oddList) == 1:
            evenMaxCount = evenList[0][0]
            oddMaxCount = 0
        elif len(evenList) > 1 and len(oddList) > 1:
            evenMaxCount = evenList[0][0]
            oddMaxCount = max(evenList[1][0], oddList[1][0])
        elif len(evenList) > 1:
            evenMaxCount = evenList[1][0]
            oddMaxCount = oddList[0][0]
        else:
            evenMaxCount = evenList[0][0]
            oddMaxCount = oddList[1][0]
    else:
        evenMaxCount = evenList[0][0]
        oddMaxCount = oddList[0][0]
    dmp(oddMaxCount)
    dmp(evenMaxCount)
    return N - evenMaxCount - oddMaxCount


debug = False  # True False
print(probC())


Measured memory_bytes: 23464
N = gets.to_i
A = gets.split.map(&:to_i)
h = {}

N.times do |i|
  h[i] = A[i]
end

# 値順にソート
sh = h.sort_by{ | k, v | v }

sh.each do |a|
  print "#{a[0]+1} "
end
puts ""

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

int main() {
  int N, A;
  cin >> N;
  
  for(int i = 0; i < N; i++){
    string S;
    cin >> S;
    if(S == "Y"){
      cout << "Four" << endl;
      break;
    }
    else if(i+1 == N){
      cout << "Three" << endl;
    }
  }
}


Measured memory_bytes: 256