akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=100000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u];i;i=sq[i].nxt)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 998244353
#define eps 1e-8
int n,m;
ll bin[100100],f[100100],g[100100];
char s[100100];

int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	bin[0]=1;
	rep(i,1,n) bin[i]=bin[i-1]<<1;
	rep(i,1,n)
	{
		g[i]=g[i-1]*10+bin[i-1]*(s[i]-'0');
		if (i==n) f[i]=f[i-1]+g[i];
		else f[i]=f[i-1]*2+g[i];
	}
	printf("%lld",f[n]);
	return 0;
}

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

int main(){
  int N; cin>>N;
  vector<ll> sum(N+1,0);
  rep(i,N){
    ll A;cin>>A;
    sum[i+1]=sum[i]+A;
  }
  ll ans=1e15;
  int l1=1,l2=3;
  for(int i=2;i<=N-2;i++){
    while(sum[l1]<sum[i]-sum[l1]) l1++;
    while(sum[l2]-sum[i]<sum[N]-sum[l2]) l2++;
    for(int j=-2;j<=2;j++) for(int k=-2;k<=2;k++){
      int L1=l1+j, L2=l2+k;
      if(L1<1||L1>i-1||L2<i+1||L2>N-1) continue;
      ll P=sum[L1],Q=sum[i]-sum[L1],R=sum[L2]-sum[i],S=sum[N]-sum[L2];
      ans=min(ans,max({P,Q,R,S})-min({P,Q,R,S}));
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
/*
AizuOnline A2340
Title Carpenter
*/
#include <stdio.h>
//Global data section
int q;
int p,n;
char c;
long long s;
//
main()
{
  int i;

  scanf("%d ",&q);
  s=0;
  for(i=0;i<q;i++)
    {
      scanf("%d %c %d",&p,&c,&n);
      if(c=='(')
	s += n;
      else
	s -= n;
      printf("%s\n",(s==0)?"Yes":"No");
    }
return(0);
}

Measured memory_bytes: 584
#include <cstdio>
#include <utility>
#include <string>
#include <queue>
#include <set>

using namespace std;

static int
validate (
  const char * s
  )
{
  while ( *( ++s ) != '\0' )
  {
    if ( s[ -1 ] != s[ 0 ] )  return ( 0 );
  }

  return ( 1 );
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    typedef pair<string,int> Point;
    queue<Point> lis;
    set<string> h;
    char si[ 11 ];

    scanf ( " %s", si );
    if ( *si == '0' ) break ;

    lis.push ( make_pair ( si, 0 ) );
    h.insert ( si );
    while ( !lis.empty ( ) )
    {
      const Point s = lis.front ( );
      lis.pop ( );

      if ( validate ( s.first.c_str ( ) ) )
      {
        printf ( "%d\n", s.second );
        goto ESC;
      }

      for ( i = 1; i < s.first.size ( ); ++i )
      {
        if ( s.first[ i - 1 ] != s.first[ i ] )
        {
          string g = s.first;

          if ( ( g[ i - 1 ] == 'r' && g[ i ] == 'g' )
            || ( g[ i - 1 ] == 'g' && g[ i ] == 'r' ) )
          {
            g.replace ( i - 1, 2, "bb" );
          }
          if ( ( g[ i - 1 ] == 'g' && g[ i ] == 'b' )
            || ( g[ i - 1 ] == 'b' && g[ i ] == 'g' ) )
          {
            g.replace ( i - 1, 2, "rr" );
          }
          if ( ( g[ i - 1 ] == 'b' && g[ i ] == 'r' )
            || ( g[ i - 1 ] == 'r' && g[ i ] == 'b' ) )
          {
            g.replace ( i - 1, 2, "gg" );
          }

          if ( h.find ( g ) == h.end ( ) )
          {
            lis.push ( make_pair ( g, s.second + 1 ) );
            h.insert ( g );
          }
        }
      }
    }
    puts ( "NA" );

ESC: ;
  }

  return ( 0 );
}

Measured memory_bytes: 1660
import java.util.*;
public class Main{

     public static void main(String []args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int mx = 0;
        for(int i=0;i<n;i++){ a[i] = sc.nextInt(); mx = Math.max(mx,a[i]);}
        int[] dp = new int[mx+1];
        for(int i=0;i<n;i++){
            dp[a[i]]++;
        }
        long ans = 0;
        for(int i=1;i<=mx;i++){
            long x = dp[i];
            x *= (x-1);
            x/=2;
            ans +=x;
        }
        for(int i=0;i<n;i++){
            int y = dp[a[i]];
            System.out.println(ans-y+1);
        }
     }
}

Measured memory_bytes: 90996
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<ll,ll> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int h[200000];

int main() {
  int N,D,A;
  while(input(N,D,A)) {
    priority_queue<pii,vector<pii>,greater<pii>> Q;
    REP(i,N) {
      int x;
      input(x,h[i]);
      Q.push(pii(x,-h[i]));
    }
    ll ans = 0;
    ll sum = 0;
    while(!Q.empty()) {
      auto p = Q.top(); Q.pop();
      if (p.second >= 0) {
        sum -= p.second;
      } else {
        int h = -p.second;
        ll cnt = (max(0LL, h - sum) + A - 1) / A;
        ans += cnt;
        sum += cnt * A;
        Q.push(pii(p.first + (ll)2 * D, cnt * A));
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 6384
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){return "";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var T = one[1];
  var list = nextIntArray();
  var output = 0;
  for(var i = 1; i < N; i++){
    if(list[i] - list[i-1] > T){
      output += T;
    }else{
      output += list[i] - list[i-1];
    }
  }
  output += T;
  myout(output);
}

Measured memory_bytes: 34200
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007LL

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

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

	vector<ll> popcount(222222);
	for(ll i = 1;i < 222222;i++){
		ll cou = 0;
		REP(j, 30)if((i >> j) & 1)cou++;
		popcount[i] = popcount[i % cou] + 1;
	}

	ll n;cin >> n;
	string str;cin >> str;

	ll cou = -1;
	REP(i, str.size())if(str[i] == '1')cou++;

	vector<ll> now(3);
	vector<ll> kake(3, 1);
	REV(i, str.size()){
		REP(j, 3){
			if(cou + j == 0)continue;
			if(str[i] != '1')continue;
			now[j] = (now[j] + kake[j]) % (cou + j);
		}
		REP(j, 3){
			if(cou + j == 0)continue;
			kake[j] = kake[j] * 2 % (cou + j);
		}
	}

	//cout << "cou: " << cou << endl;

	REP(i, 3)kake[i] = 1;
	vector<ll> ans(n);

	REV(i, str.size()){
		ll tmp;
		ll pla;
		if(str[i] == '0') {
			//cout << i << " " << 0 << " " << now[2] << " " << kake[2] << endl;
			tmp = (now[2] + kake[2]) % (cou + 2);
			pla = 1;
		}
		else {
			//cout << i << " " << 1 << " " << now[0] << " " << kake[0] << endl;
			if(cou == 0){
				tmp = 0;
				pla = 0;
			}
			else {
				tmp = (now[0] - kake[0] + (cou)) % cou;
				pla = 1;
			}
		}

		//cout << "i: " << i << " tmp: " << tmp << endl;
		ans[i] = popcount[tmp] + pla;


		REP(j, 3){
			if(cou + j == 0)continue;
			kake[j] = kake[j] * 2 % (cou + j);
		}
	}

	REP(i, n)cout << ans[i] << endl;

	return 0;
}


Measured memory_bytes: 6928
//abc090_a.cpp
//Sun Mar 11 20:54:53 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
using namespace std;

int main(){
	string x;
	string y;
	string z;
	cin >> x;
	cin >> y;
	cin >> z;


	cout << x[0] << y[1] << z[2] << endl;
}

Measured memory_bytes: 256
# Your code here!
num = gets
arr = gets.chop.split.map(&:to_i).sort
min, max = arr[0], arr[-1]
point = (max - min) / 2
ans = 10**10
min.upto(max) do |point|
    tmp = 0
    arr.each do |num|
        tmp += (num - point)**2
    end
    ans = tmp < ans ? tmp : ans
end
p ans

Measured memory_bytes: 1788
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A =sc.nextInt();
		int B =sc.nextInt();
		int K =sc.nextInt();
		int count =0;
		if(A<B){
			for(int i=A;i>=1;i--) {
				if(A%i==0&&B%i==0) {
					count++;
					if(count==K){
						System.out.println(i);
					}
				}
			}
		}
		else if(A>B){
			for(int i=B;i>=1;i--) {
				if(A%i==0&&B%i==0) {
					count++;
					if(count==K){
						System.out.println(i);
					}
				}
			}
		}
		else if(A==B){
			for(int i=A;i>=1;i--) {
				if(A%i==0&&B%i==0) {
					count++;
					if(count==K){
						System.out.println(i);
					}
				}
			}
		}
	}
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void){

    int N; cin>>N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin>>A[i];
    }
    int max = *max_element(A.begin(), A.end());
    int min = *min_element(A.begin(), A.end());
    cout<<max-min<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define forn(i, n) for(int i=0;i<n;i++)
#define lli long long int
#define pii pair<int,int>
#define fi first
#define se second
#define psi pair<int,pii>
#define pb push_back
#define vi vector<int>
#define vii vector< vi >

using namespace std;

const int MAXN = 1000001;

lli num[MAXN];

// чтение и перевод это будет пустой тратой времени
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	forn(i, n) cin>>num[i];

	lli ans = 2ll, ans2 = 2ll;
	num[n] = 2ll;

	for(int i=n-1;i>=0;i--) {
		lli cur = num[i]; 

		lli x = ans / num[i];
		if(x * num[i] < ans) x++;
		cur *= x;

		if(cur > ans2) {
			cout<<-1<<endl;
			return 0;
		}

		ans = cur;
		ans2 = num[i] * (ans2 / num[i]) + num[i] - 1;
	}

	cout<<ans<<" "<<ans2<<endl;
	return 0;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  cin >> N;
  vector<PII> xs(N);
  cin >> xs;

  VVI ends(32);
  for(auto p: xs)
	ends[p.FF].PB(p.SS);

  int ans = 0;
  priority_queue<int,VI,greater<int>> pq;
  FOR(t,1,32){
	for(int e: ends[t])
	  pq.push(e);
	while(!pq.empty() && pq.top() < t)
	  pq.pop();

	if(!pq.empty()){
	  ans += 100;
	  pq.pop();
	}
	else{
	  ans += 50;
	}
  }
  
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3160
// 2011/09/22 Tazoe

#include <iostream>
using namespace std;

int DFS(int S[92][92], const int n, const int m, int i, int j, int d)
{
	if(S[i][j]==0)
		return d;

	S[i][j] = 0;

	int d1 = DFS(S, n, m, i-1, j, d+1);
	int d2 = DFS(S, n, m, i+1, j, d+1);
	int d3 = DFS(S, n, m, i, j-1, d+1);
	int d4 = DFS(S, n, m, i, j+1, d+1);

	S[i][j] = 1;

	if(d1>=d2&&d1>=d3&&d1>=d4)
		return d1;
	else if(d2>=d1&&d2>=d3&&d2>=d4)
		return d2;
	else if(d3>=d1&&d3>=d2&&d3>=d4)
		return d3;
	else
		return d4;
}

int main()
{
	while(true){
		int m;
		cin >> m;
		int n;
		cin >> n;
		if(m==0&&n==0)
			break;

		int S[92][92];
		for(int i=0; i<=n+1; i++)
			for(int j=0; j<=m+1; j++)
				S[i][j] = 0;

		for(int i=1; i<=n; i++)
			for(int j=1; j<=m; j++)
				cin >> S[i][j];

		int max = -1;

		for(int i=1; i<=n; i++)
			for(int j=1; j<=m; j++)
				if(S[i][j]==1){
					int tmp = DFS(S, n, m, i, j, 0);
					if(tmp>max)
						max = tmp;
				}

		cout << max << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
#define X first
#define Y second
typedef long long ll; 
int n, ans, w[105][105], from[105], a[105], b[105], c[105], d[105];
bool vis[105]; 
int dfs(int u)
{
	for (int v = 0; v < n; v++)
	{
		if (!w[u][v] || vis[v])
			continue; 
		vis[v] = true; 
		if (from[v] == -1 || dfs(from[v]))
		{
			from[v] = u; 
			return true; 
		}
	}
	return false; 
}
int main()
{
	// freopen("ARC092-C.in", "r", stdin); 
	scanf("%d", &n); 
	for (int i = 0; i < n; i++)
		scanf("%d%d", a + i, b + i); 
	for (int i = 0; i < n; i++)
		scanf("%d%d", c + i, d + i); 
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (a[i] < c[j] && b[i] < d[j])
				w[i][j] = 1; 
		}
	}
	memset(from, -1, sizeof(from)); 
	for (int i = 0; i < n; i++)
	{
		memset(vis, false, sizeof(vis)); 
		ans += dfs(i); 
	}
	printf("%d\n", ans);
	return 0; 
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

int to[68][200200];

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,k; cin >> n >> k;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        to[0][i+1]=a[i];
    }
    for(int i=0;i<65;i++){
        for(int j=1;j<=n;j++){
            to[i+1][j]=to[i][to[i][j]];
        }
    }
    int now=1;
    for(int i=62;i>=0;i--){
        if(k&(1LL<<i)){
            now=to[i][now];
        }
    }
    printf("%d\n",now);
}

Measured memory_bytes: 55732
#include<cstdio>

long long x, k, d;

template<class I>
inline I abs(I a) {
	return a > 0 ? a : -a;
}

template<class I>
inline I min(I a, I b) {
	return a < b ? a : b;
}

int main(void) {
	scanf("%lld%lld%lld", & x, & k, & d);
	if (x == 0)
		printf("%lld\n", (k & 1) ? abs(d) : 0);
	else if (x > 0) {
		long long tk = x / d;
		x -= d * min(k, tk),
		k -= min(k, tk);
		if (k & 1)
			printf("%lld\n", abs(x - d));
		else printf("%lld\n", abs(x));
	} else {
		long long tk = -x / d;
		x += d * min(k, tk),
		k -= min(k, tk);
		if (k & 1)
			printf("%lld\n", abs(x + d));
		else printf("%lld\n", abs(x));
	}
	return 0;
}

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

int main(){
  ll N,M;
  ll mod = 1e9+7;
  cin >> N >> M;
  vector<ll> hole(N+10,0);
  for(ll i=0;i<M;++i){
    ll a;
    cin >> a;
    hole[a]=1;
  }
  ll dp[N+10];
  fill(dp,dp+N+10,0);
  dp[0]=1;
	for(ll i=0; i<N+5; i++){
		for(ll j=1;j<=2;++j){
      if(hole[i+j]) continue;
      else {
        dp[i+j] = dp[i+j] + dp[i];
        dp[i+j]%=mod;
      }
    }
	}
  cout << dp[N] << endl;
}

Measured memory_bytes: 1792
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<int>v(N + 3);
	v[N + 1] = N + 1;
	v[N + 2] = N + 2;
	for (int i = 1; i <= N; i++) {
		cin >> v[i];
	}
	L = -1;
	vector<pair<int, int>>p;
	for (int i = 0; i <= N + 2; i++){
		if (L == -1) {
			if (v[i] != i) {
				L = i;
				R = i;
			}
		}
		else {
			if (v[i] == i) {
				if (i - L == 2) {
					cout << "No\n";
					return 0;
				}
				if ((i - L) % 2 == 0) {
					p.emplace_back(L, R);
					L = -1;
				}
			}
			if (v[i] != i) {
				if ((i - L) % 2) {
					p.emplace_back(L, R);
					L = i;
				}
				R = i;
			}
		}
	}
	for (auto i : p) {
		L = i.first;
		R = i.second;
		vector<int>w;
		for (int j = L; j <= R; j += 2) {
			w.push_back(v[j]);
		}
		auto u = w;
		sort(u.begin(), u.end());
		M = w[0];
		if (L + 2 < N + 3) {
			for (int j = L + 2; j <= R; j += 2) {
				if (v[j] > j) {
					if (M > v[j]) {
						cout << "No\n";
						return 0;
					}
					M = v[j];
				}
			}
		}
		M = w.back();
		if (R - 2 >= 0) {
			for (int j = R - 2; j >= L; j -= 2) {
				if (v[j] < j) {
					if (M < v[j]) {
						cout << "No\n";
						return 0;
					}
					M = v[j];
				}
			}
			for (int j = R; j >= L; j -= 2) {
				v[j] = u.back();
				u.pop_back();
			}
		}
	}
	for (int i = 1; i <= N; i++) {
		if (v[i] != i) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 7536
def gcd(a, b):
    r = a % b
    if r == 0:
        return b
    else:
	    return gcd(b, r)
def lcm(a,b):
    return a * b // gcd(a, b)
a,b = tuple(map(int,input().rstrip().split()))
print(lcm(a, b))

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<ll> Size;
    bool checked[300050];
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n + 1); rank.resize(n + 1); Size.resize(n + 1);
        for (int i = 0; i <= n; ++i) par[i] = i, rank[i] = 0, Size[i] = 0, checked[i] = false;
    }

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

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        Size[x] += Size[y];
        return true;
    }

    ll size(int x){
        return Size[root(x)];
    }

    ll add(int x) {
        Size[root(x)]++;
    }
};


int main() {
    map<int, int> counter;
    int N;
    cin >> N;
    int a[100050];
    int b[100050];
    UnionFind uni(300000);
    vector<int> c;
    int outer = 0;
    for(int i = 1; i <= N; i++) {
        cin >> a[i];
        c.push_back(a[i]);
        //uni.add(a[i]);
        counter[a[i]]++;
        outer ^= a[i];
    }
    a[N + 1] = outer;
    c.push_back(outer);
    sort(c.begin(), c.end());
    c.erase(unique(c.begin(), c.end()), c.end());
    //uni.add(outer);
    counter[outer]++;
    int outer_b = 0;
    for(int i = 1; i <= N; i++) {
        cin >> b[i];
        if(counter[b[i]] == 0) {
            cout << -1 << endl;
            return 0;
        }
        /*
        if(a[i] != b[i]) {
            uni.merge(a[i], b[i]);
            uni.add(b[i]);
        }
        */
        counter[b[i]]--;
        outer_b ^= b[i];
    }
    for(int i = 1; i <= N; i++) {
        a[i] = distance(c.begin(), lower_bound(c.begin(), c.end(), a[i]));
        b[i] = distance(c.begin(), lower_bound(c.begin(), c.end(), b[i]));
    }
    outer = distance(c.begin(), lower_bound(c.begin(), c.end(), outer));
    outer_b = distance(c.begin(), lower_bound(c.begin(), c.end(), outer_b));
    for(int i = 1; i <= N; i++) {
        if(a[i] != b[i]) {
            uni.merge(a[i], b[i]);
            uni.add(b[i]);
        }
    }
    uni.merge(outer, outer_b);
    uni.add(outer_b);
    for(int i = 0; i <= 5; i++) {
        //cout << i << " " << uni.root(i) << " " << uni.size(i) << endl;
    }
    int ans = 0;
    for(int i = 0; i <= 250000; i++) {
        if(uni.checked[uni.root(i)]) continue;
        uni.checked[uni.root(i)] = true;
        if(uni.size(i) <= 1) continue;
        if(uni.issame(i, outer)) ans += uni.size(i) - 1;
        else ans += uni.size(i) + 1;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int n,d;
  int i=0,j=0,k=0;
  double l;
  double du,dif;
  int ans=0;
  int one = 1;

  cin >> n >> d;;

  double x[n][d];

  while(cin >> l) {
    x[i][j] = l;
    j++;
    if(j==d) {j=0;i++;}
  }

  for(i=0;i<n;i++) {
    for(j=i+1;j<n;j++) {
      for(k=0;k<d;k++) {
        du = abs(x[i][k] - x[j][k]) * abs(x[i][k] - x[j][k]);
        dif += du;
      }
      dif = sqrt(dif);
      if(fmod(dif,1) == 0) {ans++;}
      dif = 0;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
w, h, n = map(int, input().split())

x1 = 0
y1 = 0
x2 = w
y2 = h

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        x1 = max(x1, x)
    elif a == 2:
        x2 = min(x2, x)
    elif a == 3:
        y1 = max(y1, y)
    elif a == 4:
        y2 = min(y2, y)

if x1 < x2 and y1 < y2:
    print((x2 - x1) * (y2 - y1))
else:
    print(0)


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

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main() {
    int N;
    long long P;
    cin >> N >> P;
    auto fac = prime_factorize(P);
    long long res = 1;
    for (auto p : fac) {
        for (int j = 0; j < p.second/N; ++j) res *= p.first;
    }
    cout << res << endl;
}

Measured memory_bytes: 384
s = str(input())
len_s = len(s)

p = "0"
ans_1 = 0
for i in range(len_s):
    if s[i] != p:
        ans_1 += 1
    if p == "0":
        p = "1"
    else:
        p = "0"
        
q = "1"
ans_2 = 0
for j in range(len_s):
    if s[j] != q:
        ans_2 += 1
    if q == "0":
        q = "1"
    else:
        q = "0"

ans = min(ans_1, ans_2)
print(ans)

Measured memory_bytes: 3188
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------


int main() {
    int A,B,C;
    cin >> A >> B >> C;

    if (!(A & 1) || !(B & 1) || !(C & 1)) printf("0\n");
    else {
        if (A > B) swap(A,B);
        if (B > C) swap(B,C);
        if (A > B) swap(A,B);
        printf("%lld\n",(LLI) A*B);
    }

    return 0;
}



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

int main(void) {
    int64_t H,W;
    int64_t N;
    int64_t x=0,y=0;
    int64_t a;
    cin >> H >> W;
    cin >> N;

    vector<vector<int64_t>> hw(H,vector<int64_t>(W,0));
    for(int i=0;i<N;i++) {
        cin >> a;
        while(a){
            if(y % 2) {
                while(a){
                    hw[y][x--] = i+1;
                    a--;
                    if(x < 0){
                        x++;
                        y++;
                        break;
                    }
                }
            } else {
                while(a){
                    hw[y][x++] = i+1;
                    a--;
                    if(x == W){
                        x--;
                        y++;
                        break;
                    }
                }
            }
        }
    }

    for(int i=0;i<H;i++) {
        cout << hw[i][0];
        for(int j=1;j<W;j++) {
            cout << " " << hw[i][j];
        }

        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int array[15][15];
	int n, i, j, x, y;
	
	while (scanf("%d", &n), n != 0){
		for (i = 0; i < n; i++){
			for (j = 0; j < n; j++){
				array[i][j] = 0;
			}
		}
		
		x = n / 2 + 1 + (n * 5);
		y = n / 2 + (n * 5);
		
		for (i = 1; i <= n * n; i++){
			while (array[x % n][y % n] != 0){
				x++;
				y--;
			}
			
			array[x % n][y % n] = i;
			x++;
			y++;
		}
		
		for (i = 0; i < n; i++){
			for (j = 0; j < n; j++){
				printf("%4d", array[i][j]);
			}
			puts("");
		}
	}
	
	return (0);
}

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

int main() {
    string S;
    cin >> S;
    if (S[0] == S[1] && S[1] == S[2])
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
#define INF (1LL<<62)
using namespace std;

int N;
int A[100005], B[100005], C[100005];
long long dp[3][100005];

void solve() {
  for (int i = 0; i < N; i++) {
    dp[0][i] = dp[1][i] = dp[2][i] = 0;
  }
  dp[0][0] = A[0];
  dp[1][0] = B[0];
  dp[2][0] = C[0];
  for (int i = 1; i < N; i++) {
    dp[0][i] = max(dp[1][i-1], dp[2][i-1]) + A[i];
    dp[1][i] = max(dp[2][i-1], dp[0][i-1]) + B[i];
    dp[2][i] = max(dp[0][i-1], dp[1][i-1]) + C[i];
  }
  printf("%lld\n", max(dp[0][N-1], max(dp[1][N-1], dp[2][N-1])));
}

int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d%d%d", A+i, B+i, C+i);
  }
  solve();
}


Measured memory_bytes: 5164
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.TreeSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BTrickOrTreat solver = new BTrickOrTreat();
        solver.solve(1, in, out);
        out.close();
    }

    static class BTrickOrTreat {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int n = s.nextInt(), k = s.nextInt();
            int ans = 0;
            TreeSet<Integer> t = new TreeSet<>();
            for (int i = 0; i < k; i++) {
                int di = s.nextInt();
                while (di-- > 0) t.add(s.nextInt());
            }
            w.println(n - t.size());
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 26148
n, q = map(int, input().split())
p = []
for i in range(n):
    p_tmp = input().split()
    p.append([p_tmp[0], int(p_tmp[1])])
# print(n, q)
# for i in range(n):
#     print(i, p[i])
time = 0
while len(p) != 0:
    process_time = q
    # print(time)
    # print(process_time)
    # print(p)
    if p[0][1] > q:
        p_tmp = p.pop(0)
        p.append([p_tmp[0], p_tmp[1]-q])
        time += process_time
        process_time = 0
    else:
        process_time -= p[0][1]
        time += p[0][1]
        print(p[0][0], time)
        p.pop(0)



Measured memory_bytes: 13016
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
typedef long long ll;

int main(){
   string S;
   cin >> S;
   int size = S.size();
   long long ans = 0;
   int cnt = 0;
   for(int i = size-1;i>=0;i--){
      if(S[i]=='W'){
         cnt++;
      }
      else{
         ans += cnt;
      }
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 3724
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <string>
#define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);

using namespace std;
typedef long long ll;
const int MAX = 0x7ffffff;
int n , m;
void slove()
{
	cin >> n >> m;
	ll sum = 0;
	int x = 0;
	for(int i = 0;i < m ;i ++)
	{
		cin >> x;
		sum += x;
	}
	if(n - sum >= 0)cout << n - sum << endl;
	else cout << -1 << endl;
}
int main()
{
	SIS;
	slove();
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
int n,k,x,y,u,l;
  cin>>n>>k>>x>>y;
  u=min(n,k);
  if(k>n) l=0;
  else l=n-k;
  cout<<(u*x)+(l*y)<<endl;

  return 0;
}







Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>


#define reps(i,s,n) for((i) = (s); (i) < (n);(i)++)
#define rep(i,n)  reps(i,0,n)
using ll = long long;
using namespace std;


int main(){
    ll n,a,b,ans;
    cin >> n >> a >> b;
   // cout <<  b* n-b+a<<"," << a*n-a+b<<endl;
    ans = (b*n-b+a)-(a*n - a + b)+1;
    if(ans < 0) ans = 0;
    cout << ans << endl; 


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int Area(int x,int y)
{
	int area;
	area=x*y;
	return area;
}
int main()
{
	int a,b,c,d;
	int area1,area2;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	area1=Area(a,b);
	area2=Area(c,d);
	if(area1>=area2)
	{
		printf("%d",area1);
	}
	else
	{
		printf("%d",area2);
	}
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>

using namespace std;

#define ll long long
#define el '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)
#define vi vector<int>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define mp make_pair
#ifdef LOCAL
#define debug(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define check(...) assert(__VA_ARGS__)
#else
#define debug(fmt, ...)
#define check(...)
#endif

#define INF 1000000

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

    int A, B, M;
    cin >> A >> B >> M;
    int a[A], b[B], x[M], y[M], c[M];
    int min_a = INF;
    rep(i, 0, A) {
        cin >> a[i];
        min_a = min(min_a, a[i]);
    }
    int min_b = INF;
    rep(i, 0, B) {
        cin >> b[i];
        min_b = min(min_b, b[i]);
    }
    int ans = min_a + min_b;
    // debug("here");
    rep(i, 0, M) {
        cin >> x[i] >> y[i] >> c[i];
        x[i]--;
        y[i]--;
        int this_one = a[x[i]] + b[y[i]] - c[i];
        ans = min(ans, this_one);
    }
    cout << ans;
}


Measured memory_bytes: 2176
#include<iostream>
#include<vector>
using namespace std;
int main () {
  int N, M;
  cin >> N >> M;
  vector<vector<int>>swi(N, vector<int>(M + 13));
  vector<int>si(N, 0);
  //swi[i][j] = iのスイッチがつながっているj番目の電球
  for (int i = 0; i < M; i ++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j ++) {
      int a;
      cin >> a;
      a --;
      swi[a][si[a]] = i;
      si[a] ++;
    }
  }
  vector<int>jud(M);
  for (int i = 0; i < M; i ++) cin >> jud[i];
  int ans = 0;
  int bi[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024};
  for (int i_ = 0; i_ < bi[N]; i_ ++) {
    int i = i_;
    vector<int>num(M, 0);
    for (int j = 0; j < N; j ++) {
      if (i % 2) {
        for (int k = 0; k < si[j]; k ++) num[swi[j][k]] ++;
      }
      i /= 2;
    }
    bool ok = true;
    for (int j = 0; j < M; j ++) {
      if (num[j] % 2 != jud[j]) ok = false;
    }
    if (ok) ans ++;
  }
  cout << ans << endl;
}



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

vector <pair <int ,bool>> mlist[100001];
bool open[100001];


void open_connection(int x) {
	for (unsigned int i = 0; i < mlist[x].size(); i++) {
		int connect = mlist[x].at(i).first;
		if (!open[connect]) {
			open[connect] = true;
			open_connection(connect);
		}
	}
}

int main(void) {
	int N, M;
	cin >> N >> M;

	for (int i = 1; i <= N; i++) {
		open[i] = false;
		mlist[i].clear();
	}

	for (int i = 0; i < M; i++) {
		int x, y, z;
		cin >> x >> y >> z;
		// evenはデータとして要らない？
		bool even = (z%2==0?true:false);
		mlist[x].push_back(make_pair(y, even));
		mlist[y].push_back(make_pair(x, even));
	}

	int cost = 0;
	
	for (int i = 1; i <= N; i++) {
		if (!open[i]) {
			cost++;
			open[i] = true;
			open_connection(i);
		}
	}
	cout << cost << endl;
	return 0;
}


Measured memory_bytes: 8960
#include<bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define MOD (int)1e9+(int)7
#define INF 2147483647
typedef long long ll;
typedef unsigned long long ull;
//dark power
//#define int ll
//define Error、大抵は、セミコロン忘れとか、Defineは関係ない
//komennto C+udekaijo
template < typename T > string to_string( const T& n )
    {
        ostringstream stm ;
        stm << n ;
        return stm.str() ;
    }
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n=0,m=0;cin>>n>>m;
	vector<int> a={2,5,5,4,5,6,3,7,6};
	vector<int> b(m);
	rep(i,m)cin>>b[i];
	vector<pair<int,int> > c(m);
	rep(i,m){
		c[i].first=b[i];
		c[i].second=a[b[i]-1];
	}

	vector<string> dp(n+1);
	rep(i,n+1)dp[i]="INF";
	dp[0]="";
	int num=0;

	rep(i,1,n+1){
		rep(j,m){
			if((i-c[j].second)<0)continue;
			if(dp[i-c[j].second]!="INF"){
				if(((dp[i]=="INF")?0:int(dp[i].length()))-1<int(dp[i-c[j].second].length())){
					//ketagaookiinara kousin
					dp[i]=dp[i-c[j].second]+to_string(c[j].first);
					num=c[j].first;
				}
				if(((dp[i]=="INF")?0:int(dp[i].length()))-1==int(dp[i-c[j].second].length())){
					//ketagaonajinara ookiihounisuru
					if(num<c[j].first){
					dp[i]=dp[i-c[j].second]+to_string(c[j].first);
					num=c[j].first;
					}
				}
			}
		}
		num=0;
	}
	sort(all(dp[n]),[](auto a,auto b){return (ctoi(a))>(ctoi(b));});
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 32384
#include<bits/stdc++.h>
using namespace std;
#define ll long long;
#define ld long double
#define pb push_back
const int mod=1e9+7;
const int mxN=2e6+3;

int main(){
    long long n;
    cin>>n;
    long long ten=1,nine=1,eight=1;
    for(int i=0;i<n;i++){
        ten*=10;nine*=9;eight*=8;
        ten%=mod;nine%=mod;eight%=mod;
    }
    long long ans=ten-2*nine+eight;
    while(ans<0)ans+=mod;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
int main(){
	int n;
	scanf("%d",&n);
	if(n/100==1) n+=800;
	else n-=800;
	if((n/10)%10==1) n+=80;
	else n-=80;
	if(n%10==1) n+=8;
	else n-=8;
	printf("%d",n);
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
int read()
{
	int k=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) k=k*10+c-'0';return k*f;
}
int n,m,mx,a[200055];
int main()
{
	n=read();m=read();
	for(int i=1;i<=n;i++)
		a[i]=read(),mx=max(mx,a[i]);
	int mid,l=1,r=mx,res=mx;
	while(r>=l)
	{
		mid=l+r>>1;ll sum=0;
		for(int i=1;i<=n;i++)
		{
			if(a[i]>mid)
			{
				sum+=(a[i]-1)/mid;
			}
		}
		if(sum>m) l=mid+1;
		else res=mid,r=mid-1;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 3924
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    int r,l;
    REP(i,s.length()){
        if(s[i]=='A'){
            l = i;
            break;
        }
    }
    FORR(i,s.length()-1,0){
        if(s[i]=='Z'){
            r = i;
            break;
        }
    }
    cout << r-l+1 << endl;
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })


vvl graph;
vl paths;
vb worked;


void recurse(ll cur){
  worked[cur] = true;

  FOR(i, 0, graph[cur].size()){
    ll val = graph[cur][i];
    if(!worked[val]){
      recurse(val);
    }

    paths[cur] = max(paths[cur], paths[val]+1);
  }
}


int main(){
  ios_base::sync_with_stdio (false);
  cin.tie(NULL);

  ll N, M;

  cin >> N >> M;

  graph = vvl(N, vl());
  paths = vl(N, 0);
  worked = vb(N, false);
  FOR(i, 0, M){
    ll x, y;
    cin >> x >> y;
    graph[x-1].pb(y-1);
  }

  FOR(i, 0, N){
    if(!worked[i]){
      recurse(i);
    }
  }

  // comment
  ll maximum = 0;
  FOR(i, 0, N){
    maximum = max(maximum, paths[i]);
  }

  cout << maximum << endl;
}


Measured memory_bytes: 8576
#include<stdio.h>

int linearSearch(int n, int key, int *S){
  
  int i=0;
  
  S[n]=key;
  if(S[0]==key){
    return 1;
  }
    
  while(S[i]!=key){
    i++;
  }
    if(i==n){
      return 0;
    }

  return 1;
}

    
int main(){

  int i,n,q,key,count=0;
  int S[100001];

  scanf("%d",&n);

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

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(linearSearch(n,key,S)){
      count++;
    }
  }

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

  return 0;
}
 

Measured memory_bytes: 644
#include<iostream>
using namespace std;
int main(){
	int n,m,temp,x=0;
		char a[101];
int b[100]={0};
	cin>> n;
	if((n>=1)&&(n<=100))

for(int i=0;i<n;i++){
	
		cin>> a[i];
		if (a[i]=='I'){
		++x;
		b[i]=x;}
		
		else
		 if(a[i]=='D'){
	     --x;
	     	b[i]=x;}
		else 
		m=x;
	}
	for(int c=0; c<n-1;c++){
	
	if(b[c]>b[c+1]){
			temp=b[c];
			b[c]=b[c+1];
			b[c+1]=temp;
		}}
if(b[n-1]>0)
	cout<<b[n-1];
	else
	cout<<"0";
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import datetime

def input():
    return sys.stdin.readline()


def resolve():
    h1, m1, h2, m2, k = map(int, input().split())

    dt1 = datetime.datetime(2020, 5, 30, h1, m1)
    dt2 = datetime.datetime(2020, 5, 30, h2, m2)

    mean_t = dt2 - dt1

    k_second = k * 60

    ans_second = mean_t.seconds - k_second

    if ans_second <= 0:
        print(0)
    else:
        print(int(ans_second / 60))

if __name__ == "__main__":
    resolve()



Measured memory_bytes: 63760
n = int(input())
a = list(map(int, input().split()))
cnt = 0
check = 0

while True:
    for i in range(n):
        if a[i] % 2 != 0:
            check = 1
    if check == 0:
        a = list(map(lambda a: a / 2, a))
        cnt += 1
    else:
        break
print(cnt)

# 合計をただ割ると n = 2 a = 6, 6 の時と n = 3 a = 4, 4, 4 の時の答えが同じになっちゃう
# lambdaでlist割り算

Measured memory_bytes: 3060
n, c, k = map(int, input().split())
l = sorted([int(input()) for i in range(n)])
count = 1
pas = 0
now = l[0]
for i in range(len(l)):
    check = now + k
    if pas < c and l[i] <= check:
        pas += 1
    else:
        now = l[i]
        pas = 1
        count += 1
print(count)

Measured memory_bytes: 8276
use proconio::{fastout, input};
use std::io::*;
use std::str::FromStr;

use std::cmp::{max, min};

fn main() {
    input! {
        n: usize,
        d: usize,
    }
    println!("{}", n / (2 * d + 1) + min(1, n % (2 * d + 1)))
}


Measured memory_bytes: 2160
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

ll func(ll b,ll n){
	if(n<b)return n;
	return func(b,n/b)+n%b;
}

int main(){
	ll n,s;
	cin>>n>>s;
	if(n==s){
		cout<<n+1<<endl;
		return 0;
	}
	else if(n<s){
		cout<<-1<<endl;
		return 0;
	}
	else{
		for(ll i=2;i<=sqrt(n);++i){
			if(func(i,n)==s){
				cout<<i<<endl;
				return 0;
			}
		}ll minb=numeric_limits<ll>::max();
		bool ok=false;
		for(ll p=1;p<sqrt(n);++p){
			ll b=(n-s)/p+1;
			if(b==1)continue;
			if(func(b,n)==s){
				ok=true;
			//ここで終了しない（最小値なのでこの全探索は全部やる）
			minb=min(minb,b);
			}
		}
		if(ok){
			cout<<minb<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
}

Measured memory_bytes: 256