akhauriyash/Code-Regression huggingface dataset:
//Let's join Kaede Takagaki Fun Club !!
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 1000000007;//998244353
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}
int n,m,dp[2][105][105];
string f[105];
int main(){
	ios::sync_with_stdio(false);
	
	g(n); g(m);
	rep(i,n) g(f[i]);
	rep(a,2) rep(i,105)rep(j,105) dp[a][i][j] = INF;
	dp[(f[0][0]=='.'?0:1)][0][0] = (f[0][0]=='.'?0:1);
	rep(i,n){
		rep(j,m){
			if(i == 0 && j == 0){
				continue;
			}
			else{
				int a = (f[i][j] == '#');
				rep(b,2){
					if(i) chmin(dp[a][i][j], dp[b][i-1][j]+(a&&!b));
					if(j) chmin(dp[a][i][j], dp[b][i][j-1]+(a&&!b));
				}
			}
		}
	}
	o(min(dp[0][n-1][m-1],dp[1][n-1][m-1]));
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <string>
//#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 9, M = 1e7, OO = 0x3f3f3f3f, eps = 0.001;
#define IO() assert(freopen("in.in", "rt", stdin)), assert(freopen("out.out", "wt", stdout))
#define ll long long int
#define FastIO() ios::sync_with_stdio(false), cin.tie(0);
void printar(int arr[], int n)
{
    for (int i = 0; i < n; i++)
    {
        cout << arr[i] << " ";
    }
    cout << endl;
}
// template <typename... T>
// void debug(T &... args)
// {
//     ((cerr << args << " "), ...);
//     cerr << endl;
// }
// struct COMPARE {
//   bool operator()(pair<string,ll> const& P1, pair<string,ll> const& P2)
//     {

//         return P1.first < P2.second;
//     }
// };
// priority_queue<pair<string,ll>,vector<pair<string,ll>>,COMPARE >pq;
ll cnt = 0, n;
void g(ll org, ll a, ll b, ll c){
    if(org <= n){

        if(a && b && c) cnt++;

        g( org * 10 + 7 , a + 1, b, c);
        g( org * 10 + 5 , a, b + 1, c);
        g( org * 10 + 3 , a, b, c + 1);
    }
}

int main()
{
    // icpctraining
    // IO();
    FastIO();
    cin >> n;
    g(0, 0, 0, 0);
    cout << cnt << endl;    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace Dwacon6th
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var playList = new List<Song>(N);
            for (var i = 0; i < N; i++)
            {
                var st = Console.ReadLine().Split();
                playList.Add(new Song { Title = st[0], Time = int.Parse(st[1]) });
            }
            var X = Console.ReadLine();

            Console.WriteLine(playList.SkipWhile(x => x.Title != X).Skip(1).Sum(x => x.Time));

        }

        struct Song
        {
            public string Title { get; set; }
            public int Time { get; set; }
        }
    }
}


Measured memory_bytes: 13396
def isPrime(n):
    for i in range(2, n):
        if i * i > n:
            return 1
        if n % i == 0:
            return 0
    return 1

ans = 0
n = int(input())
for i in range(n):
    x = int(input())
    ans = ans + isPrime(x)

print(ans)


Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int l=0;
	for (int i=0;i<s.size();i++){
		if (s[i]=='C') l=1;
		if (s[i]=='F' && l==1){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

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

using ll = long long;

#define mod 1000000007
#define init ios::sync_with_stdio(0);cin.tie(0);

typedef vector<int> vi;
typedef pair<int, int> pi;
#define MS(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define PB push_back
#define MP make_pair






int main()
{
	init;

	int x, n;
	cin >> x >> n;

	int ar[101];


	for (int i = 0; i < n; ++i)
	{
		int tmp;
		cin >> tmp;
		ar[tmp] = 1;
	}
	int i = x;
	while (i > 0)
		if (ar[i] == 1)
			i--;
		else
			break;
	int j = x;
	while (j <= 100)
		if (ar[j] == 1)
			j++;
		else
			break;

	if (x - i <= j - x)
		cout << i << endl;
	else
		cout << j << endl;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	while (true) {
		int x, y;
		cin >> x >> y;

		if (!x && !y) break;

		if (y < x) swap(x, y);
		cout << x << " " << y << endl;
	}
}


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

int main(){
  int n,m;
  cin >>n >>m;
  vector<pair<ll, ll>> p(n);
  rep(i,n){
    cin >>p[i].first >>p[i].second;
  }
  sort(p.begin(), p.end());
  ll ans = 0;
  for(int i = 0; m>=0; i++){
    if(p[i].second>=m) {
      ans += m*p[i].first;
      break;
    }
    else{
      ans += p[i].first*p[i].second;
      m -= p[i].second;
    }
  }
  cout << ans << endl;
  return 0;
}

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

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


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

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 100100;

char S[MAX];
int T[MAX];
int A[MAX];

int nxt(int p2, int p, int t)
{
	if (p) t ^= 1;
	if (t == 0) return p2;
	return p2 ^ 1;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

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

	FOR (i, 0, n)
	{
		if (S[i] == 'o') T[i] = 0;
		else T[i] = 1;
	}

	FOR (i1, 0, 2)
	{
		FOR (i2, 0, 2)
		{
			A[0] = i1;
			A[1] = i2;
			FOR (i, 2, n)
			{
				A[i] = nxt(A[i-2], A[i-1], T[i-1]);
			}

			if (nxt(A[n-2], A[n-1], T[n-1]) != A[0]) continue;
			if (nxt(A[n-1], A[0], T[0]) != A[1]) continue;

			FOR (i, 0, n)
			{
				if (A[i] == 0) printf("S");
				else printf("W");
			}
			printf("\n");
			return 0;
		}
	}

	cout<<-1<<endl;

}


Measured memory_bytes: 1280
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>
#include<stack>
#include <utility>
#include <tuple>
#define INF 1000000000000
const long long MOD = 1000000007;

using namespace std;
typedef long long llong;
#define debug cout << "Hello" << endl;
//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

void dfs(llong node, vector<vector<llong> > &graph, vector<llong> &color, llong c){
    if(color[node]!=-1){
        return;
    }
    color[node] = c;
    for(auto next_node:graph[node]){
        dfs(next_node, graph, color, c);
    }
}

int main(){
    llong N,M;
    cin >> N >> M;
    vector<vector<llong> > graph(N);
    llong a,b;
    vector<llong> color(N, -1);
    llong c;
    for(int i=0; i<M; i++){
        cin >> a >> b;
        graph[a-1].push_back(b-1);
        graph[b-1].push_back(a-1);
    }
    c = 0;
    for(int i=0; i<graph.size(); i++){
        if(color[i]!=-1){
            continue;
        }
        dfs(i, graph, color, c);
        c++;
    }
    cout << c-1 << endl;
    return 0;
}

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

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

int main() {
  int N, a, b;
  cin >> N >> a >> b;
  
  int total = 0;
  for(int i = 0; i <= N; i++) {
    if(a <= Func(i) && Func(i) <= b) total += i;
  }
  
  cout << total << endl;
}  


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

int f(int x) {
    int ret = 0;

    while (x % 10 > 0) {
        ret += (x % 10);
        x /= 10;
    }

    return ret;
}

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

    cout << (n % f(n) == 0 ? "Yes" : "No") << endl;

    return 0;
}


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

using namespace std;

int main()
{
	int a, b, c;
	string str;

	cin >> a >> b >> c;

	if (a <= c && c <= b) {
		str = "Yes";
	}
	else {
		str = "No";
	}

	cout << str << endl;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int A[101][101];
    int b[101][2];
    int c[101][2]={0};
    int i,j;
    int n,m;
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++)
        for(j=0;j<m;j++)
            scanf("%d",&A[i][j]);
    for(j=0;j<m;j++)
        scanf("%d",&b[j][1]);
    for(i=0;i<n;i++)
        for(j=0;j<m;j++)
            c[i][1]+=A[i][j]*b[j][1];
    for(i=0;i<n;i++)
        printf("%d\n",c[i][1]);
    return 0;
}

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

int main(){
int n;
cin>>n;
vector<int> a(n);
vector<int> b(n);
vector<int> ans;
rep(i,n){
  cin>>a[i];
  //cout<<a[i]<<'k'<<endl;
}

int cnt=0;
for (int i=n;i>0;i--){
  //int temp=a[i-1];
  int s=0;int j=i+i;
  while (j<=n){
    s+=b[j-1];
    j+=i;
  }
  s+=a[i-1];
  b[i-1]=s%2;
  cnt+=s%2;
  if (s%2==1){
  ans.emplace_back(i);
}
}
cout<<cnt<<endl;
for (auto i:ans){
  cout<<i<<' ';
}
}


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define Rep(i,n) for(int i=1;i<=(n);++i)
using LL = long long;
using ULL = unsigned long long;

const int INF = 0x3f3f3f3f;

vector<int> g[100123];
int dis[100123], ans[100123];

int main()
{
	int n, m;
	cin >> n >> m;
	int u, v;
	rep(i, m) {
		scanf("%d%d", &u, &v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	Rep(i, n) dis[i] = INF;
	dis[1] = 0;
	queue<int> q;
	q.push(1);
	while(!q.empty()) {
		u = q.front(); q.pop();
		for(int w: g[u]) {
			if(dis[w] == INF) {
				dis[w] = dis[u] + 1;
				q.push(w);
				ans[w] = u;
			}
		}
	}
	Rep(i, n) if(dis[i] == INF) {
		puts("No");
		return 0;
	}
	puts("Yes");
	for(int i = 2; i <= n; ++i) printf("%d\n", ans[i]);
	return 0;
}


Measured memory_bytes: 11064
#include <iostream>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <vector>
#include <queue>

using namespace std;

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

Measured memory_bytes: 3596
n,x,y=map(int,input().split())
x-=1
y-=1

ans=[0 for i in range(n-1)]

a=[[0 for i in range(n)]for j in range(n)]
for i in range(n-1):
  for j in range(n):
    a[i][j]=j-i
    
l=y-x+1
l//=2
l-=1

for i in range(n-1):
  for j in range(i+1,n):
    a[i][j]=min(a[i][j],abs(x-i)+1+abs(y-j))

for i in range(n-1):
  for j in range(i+1,n):
    ans[a[i][j]-1]+=1

#for i in range(n):
#  for j in range(n):
#    print(a[i][j],end=" ")
#  print()
    
for k in range(n-1):
  print(ans[k])
  
  

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

using namespace std;

typedef long long LL;
#define N 1600

const int mod=998244353;
int n,sz,num,sum,ans,f[N][N],g[N][N];
bool vis[N];
char s[N];

void upd(int x,int y,char ch){
	if (x>y) swap(x,y);
	if (ch=='?') return;
	if (ch=='o'){
		if (f[x][y]==0){puts("0"); exit(0);}
		f[x][y]=1;
	}
	if (ch=='x'){
		if (f[x][y]==1){puts("0"); exit(0);}
		f[x][y]=0;
	}
}

void dfs(int u,int n){
	vis[u]=1; ++sz;
	for (int i=0;i<u;++i)
		if (g[i][u]==-1){
			++num;
			if (!vis[i]) dfs(i,n);
		}
		else sum^=g[i][u];
	for (int i=u+1;i<=n;++i)
		if (g[u][i]==-1){
			++num;
			if (!vis[i]) dfs(i,n);
		}
		else sum^=g[u][i];
}

int solve(int n){
	int ret=1;
	if (n&1){
		for (int i=0;i<=n;++i)
			for (int j=i+1;j<=n;++j)
				if (g[i][j]==-1) ret=ret*2%mod;
	}
	else{
		memset(vis,0,sizeof vis);
		for (int i=0;i<=n;++i)
			if (!vis[i]){
				sz=0; sum=0; num=0; dfs(i,n);
				if (sum){puts("0"); exit(0);}
				for (num/=2,num-=sz-1;num;--num) ret=ret*2%mod;
			}
	}
	return ret;
}

int main(){
	scanf("%d",&n);
	memset(f,-1,sizeof f);
	for (int i=1;i<n;++i){
		scanf("%s",s+1);
		for (int j=1;j<n;++j){
			int x=min(i+j,n*2-i-j),y=abs(i-j);
			upd(x,y,s[j]);
		}
	}
	memset(g,-1,sizeof g);
	for (int i=0;i<=n;i+=2)
		for (int j=i+2;j<=n;j+=2) g[i/2][j/2]=f[i][j];
	ans=solve((n-(n&1))/2);
	memset(g,-1,sizeof g);
	for (int i=1;i<=n;i+=2)
		for (int j=i+2;j<=n;j+=2) g[i/2][j/2]=f[i][j];
	ans=(LL)ans*solve((n-!(n&1))/2)%mod;
	printf("%d\n",ans);
	
	return 0;
}
			

Measured memory_bytes: 20352
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  long long int ans=0;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    ans=ans^a[i];
  }
  for(int i=0;i<n;i++)
    a[i]=ans^a[i];
  for(int i=0;i<n;i++)
    cout<<a[i]<<" ";
  return 0;
}

Measured memory_bytes: 4376
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cinttypes>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

bool IsPrime(int N) {
  for (int i = 2; 1LL * i * i <= N; ++i) {
    if (N % i == 0) {
      return false;
    }
  }
  
  return true;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int N;
  cin >> N;
  
  int number = 2;
  while (N > 0) {
    if (number % 5 != 1 || !IsPrime(number)) {
      ++number;
      continue;
    }
    
    cout << number << ' ';
    --N;
    ++number;
  }
  
  cout << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <functional> 
#include <vector>
#include <numeric>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <cstdlib>
typedef long long ll;
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
 
using namespace std;
 
int main(){
 
    int n,c,k;
    cin >> n >> c >> k;

    int cap = 1;
    int ans = 1,bus;
    vector<int> t(n);
    for(int i=0;i<n;i++) cin >> t[i];
    SORT(t);
    bus = t[0];
    for(int i=1;i<n;i++){
        if(cap < c && t[i] <= bus + k) cap++;
        else {
            ans++;
          	cap = 1;
            bus = t[i];
        }
    }
    cout << ans;

    return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int> (m));
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int &x : a[i]) cin >> x;
    }
    int ans = 1e9;
    for (int mask = 1; mask < (1 << n); mask++) {
        vector<int> curr(m);
        int price = 0;
        for (int i = 0; i < n; i++) {
            if (mask & (1 << i)) {
                price += c[i];
                for (int j = 0; j < m; j++) {
                    curr[j] += a[i][j];
                }
            }
        }
        bool ok = true;
        for (int now : curr) {
            if (now < x) ok = false; 
        }
        if (ok) {
            ans = min(ans, price);
        }
    }
    if (ans == 1e9) {
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;
}

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

using namespace std;

struct T;
#define null ((T*)NULL)

typedef long long ll;

struct T {
  ll v;
  ll m;
  int c;
  T *l,*r;
  bool lz;
  ll lazy;
  T(){}
  T(ll v):v(v),m(v),c(1),l(null),r(null),lz(false),lazy(0){}
};

int hogeS=0;
#define SSS 2222222
T hoge[SSS];
inline T* New(int v){
  if(hogeS >= SSS) exit(-1);
  hoge[hogeS]=T(v);
  return &hoge[hogeS++];
}
inline int count(T* t){ return t?t->c:0; }
inline void push(T* t)
{
  if( !t ) return;
  if( t->lz ) {
    t->v += t->lazy;
    t->m += t->lazy;
    t->lz = false;
    if( t->r ) {
      t->r->lz |= true;
      t->r->lazy += t->lazy;
    }
    if( t->l ) {
      t->l->lz |= true;
      t->l->lazy += t->lazy;
    }
    t->lazy = 0;
  }
}
inline ll mini(T* t){ push(t); return t?t->m:LLONG_MAX; }

inline T* update(T* t)
{
  if(!t)return t;
  push(t);
  t->c = count(t->l)+count(t->r)+1;
  t->m = min(t->v,min(mini(t->l),mini(t->r)));
  return t;
}

T* merge(T* a,T* b)
{
  push(a);
  push(b);
  if(!a || !b)return a?a:b;
  if(rand()%(count(a)+count(b))<count(a)){
    a->r = merge(a->r,b);
    return update(a);
  } else {
    b->l = merge(a,b->l);
    return update(b);
  }
}

pair<T*,T*> split(T* a,int k)
{
  push(a);
  if(!a)return make_pair(null,null);
  if(k<=count(a->l)){
    pair<T*,T*> s=split(a->l,k);
    a->l = s.second;
    return make_pair(s.first,update(a));
  } else {
    pair<T*,T*> s=split(a->r,k-count(a->l)-1);
    a->r = s.first;
    return make_pair(update(a),s.second);
  }
}

inline T* insert(T* t,int k,int v)
{
  push(t);
  pair<T*,T*> a=split(t,k);
  return merge(merge(a.first,New(v)),a.second);
}

inline T* add(T* t,int l,int r,int k)
{
  push(t);
  pair<T*,T*> u = split(t,r);
  pair<T*,T*> v = split(u.first,l);
  T* w = v.second;
  w->lz = true;
  w->lazy += k;
  return merge(merge(v.first,update(w)),u.second);
}

int n,m;
char s[333333];

void print(T* t)
{
  if(t==null)return;
  push(t);
  print(t->l);
  printf("%2lld,%2lld|",t->v,t->m);
  print(t->r);
}

int main(void)
{
  T *root = null;
  int n,q;
  set<int> toji;
  scanf("%d%d",&n,&q);
  scanf("%s",s);
  for( int i = 0; i < n; i++ ) {
    root = insert(root,i,0);
  }
  for( int i = 0; i < n; i++ ) {
    root = add(root,i,n,s[i]=='('?1:-1);
    if( s[i] == ')' ) toji.insert(i);
  }
  int k;
  for( int ii = 0; ii < q; ii++ ) {
    scanf("%d",&k);
    if( s[k-1] == '(' ) {
      s[k-1] = ')';
      toji.insert(k-1);
      root = add(root,k-1,n,-2);
      int me = *(toji.begin());
      printf("%d\n",me+1);
      s[me] = '(';
      toji.erase(me);
      root = add(root,me,n,2);
    } else {
      toji.erase(k-1);
      s[k-1] = '(';
      root = add(root,k-1,n,2);
      int l=0,r=n;
      while( l < r ) {
        int mb = (l+r)/2;
        auto t = split(root,mb);
        if( mini(t.second) >= 2 ) {
          r = mb;
        } else {
          l = mb+1;
        }
        root = merge(t.first,t.second);
      }
      printf("%d\n",l+1);
      s[l] = ')';
      toji.insert(l);
      root = add(root,l,n,-2);
    }
  }
  return 0;
}

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

using namespace std;

template <typename A, typename B>string to_string(pair<A, B> p);

template <typename A, typename B, typename C> string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D> string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {return '"' + s + '"';}

string to_string(const char* s) {return to_string((string) s);}

string to_string(bool b) {return (b ? "true" : "false");}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

template <typename A, typename B, typename C>string to_string(tuple<A, B, C> p) {return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";}

template <typename A, typename B, typename C, typename D>string to_string(tuple<A, B, C, D> p) {return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";}

void debug_out() { cout << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}

#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

const unsigned long long Mod = 1000000000 + 7;
typedef unsigned long long ull;


int main(){	
	ios::sync_with_stdio(false);
	cin.tie(0);
	ull n;
	cin >> n;
	vector <ull>  v(n);
	for (auto &x : v){
		cin >> x;
	}
	vector <ull> f(n);
	f[0] = v[0];
	for (int i = 1; i < n; i++){
		f[i] = f[i-1] + v[i];
	}
	ull ans = 0;
	for (int i = 0; i < n - 1; i++){
		ans = (ans%Mod + ((f[n-1] - f[i])%Mod * v[i]%Mod)%Mod)%Mod;
	}
	cout << ans;
    return 0;
}












Measured memory_bytes: 6356
#include<stdio.h>
int abs(int n)
{
	if (n < 0)
		n *= -1;
	return n;
}
int main()
{
	int x, n;
	scanf("%d %d", &x, &n);
	int i;
	int p;
	int u[102];
	for (i = 0; i < 102; i++)
		u[i] = 0;
	for (i = 0; i < n; i++)
	{
		scanf("%d", &p);
		u[p]++;
	}
	int ans = -1;
	for (i = 0; i < 102; i++)
		if (u[i] == 0)
			if (abs(x - i) < abs(x - ans))
				ans = i;
	printf("%d\n", ans);
	return 0;
}

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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

class UnionFind {
public:
    vector <int> par;
    vector <int> siz;

    UnionFind(int sz_): par(sz_), siz(sz_, 1LL) {
        for (int i = 0; i < sz_; ++i) par[i] = i;
    }

    void init(int sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (int i = 0; i < sz_; ++i) par[i] = i;
    }

    int root(int x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }

    bool merge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;

        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

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

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

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

    vector<pair<int, int>> e;
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        e.push_back(make_pair(a, b));
    }

    int ans = 0;
    REP(i, M) {
        UnionFind uf(N);

        REP(j, M) {
            if (i == j) continue;

            uf.merge(e[j].first, e[j].second);
        }

        bool ok = false;
        REP(j, N) {
            if (uf.issame(0, j) == false) {
                ok = true;
                break;
            }
        }

        if (ok) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

typedef vector< vector<char> > field_t;
typedef pair<int, int> point_t;

point_t operator+(const point_t &lhs, const point_t &rhs){
    point_t p = { lhs.first + rhs.first, lhs.second + rhs.second };
    return p;
}

bool operator==(const point_t &lhs, const point_t &rhs){
    return (lhs.first == rhs.first) && (lhs.second == rhs.second);
}

bool is_in_field(int col, int row, const point_t &point){
    const int c = point.second;
    const int r = point.first;
    return (0 <= c && c < col) && (0 <= r && r < row);
}

int solve(int col, int row, field_t &field, const point_t &start, const point_t &goal){
    // 2. 各マスの訪問履歴(memo)を作成する
    //    memoにはスタートからそのマスまでの歩数を格納する(初期値は0)
    vector< vector<int> > memo;
    for(int i = 0; i < row; ++i) {
        vector<int> v(col, 0);
        memo.push_back(v);//vector<int>を追加していくことで二次元配列を作成
    }

    // 移動方向(上下左右)
    const point_t points[] = {
        { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 },
    };

    // 3. スタートのマスをキューに格納する
    queue<point_t> q;
    q.push(start);

    // 11. 4から10をキューが空になるまで繰り返す
    while( !q.empty() ) {
        // 4. キューの先頭から一マス取得する
        point_t cur = q.front(); q.pop();

        // 5. 取り出したマスがゴールなら終了
        if(cur == goal) {
            return memo[cur.first][cur.second];
        }

        for(const auto &point : points) {
            // 6. 手順4で取り出したマス(cur)から上下左右の何れかに移動する
            point_t next = cur + point;
            // 7. 移動先のマス(next)が迷路外でないことを確認する(迷路外の場合は手順6に戻る)
            if( is_in_field(col, row, next) ) {
                const char s = field[next.first][next.second];
                // 8. 移動先のマス(next)が道またはゴールであることを確認する(道でもゴールでもない場合は手順6に戻る)
                if(s == '.') {
                    // 9. 移動先のマス(next)が未訪問であることを確認する(訪問済みの場合は手順6に戻る)
                    if(memo[next.first][next.second] == 0) {
                        // 10. 移動先のマス(next)をキューに格納し、訪問履歴を更新する
                        q.push(next);
                        memo[next.first][next.second] = memo[cur.first][cur.second] + 1;
                    }
                }
            }
        }
    }
    return -1;
}

int main()
{
    int col, row, count=0;//colは列、rowは行
    cin >> row >> col;

    point_t start, goal;
    field_t field;

    start.first = 0;
    start.second = 0;
    goal.first = row-1;
    goal.second = col-1;
    // 1. 迷路(field)を作成する
    for(int i = 0; i < row; ++i) {
        vector<char> v;
        for(int j = 0; j < col; ++j) {
            char c;
            cin >> c;
            if(c=='.')count++;
            v.push_back(c);
            // スタート地点とゴール地点は別途覚えておく
        }
        field.push_back(v);
    }

    // 最短歩数はsolveで計算する
    if(solve(col, row, field, start, goal)!=-1){
      cout << count-1-solve(col, row, field, start, goal) << endl;
    }
    else cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>

using namespace std;

int calc_digit(int x)
{
	 int i;
	 for(i = 1;;i++){
		 if(int(x / pow(10,i)) == 0)
			 return i;
	 }
}

int main(){
	int a[200],b[200];
	int i,j;
	i = 0;
	while(cin >> a[i] >> b[i]){
	    if(a[i] < 0 || 1000000 < a[i])
			break;
		if(b[i] < 0 || 1000000 < b[i])
			break;
		if(i >= 200)
			break;
		i++;
	}
	for(j = 0; j < i;j++)
		cout << calc_digit(a[j] + b[j]) << endl;
}
	

Measured memory_bytes: 1204
int bt(int x){
	int q=(x+1)/3;
	int r=(x+1)%3;
	int d=0;
	if(q)d+=bt(q);
	putchar("-0+"[r]);
	return d+1;
}
int main(){
	int x;
	scanf("%d",&x);
	int d=bt(x);
	puts("");
	//printf("%d\n",d);
	return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
#define up(j,k,i) for(ll i=j;i<k;i++)
#define down(j,k,i) for(ll i=j;i>k;i--)
#define M 1000000007
#define pp(n) printf("%lld\n",ll(n))
#define ps(n) printf("%lld ",ll(n))
#define pd(x,y) printf("%lld %lld\n",ll(x),ll(y))
#define is(n) scanf("%lld",&n)
#define inf 1e15
#define id(n,m) scanf("%lld%lld",&n,&m)
#define it(n,m,k) scanf("%lld%lld%lld",&n,&m,&k)
#define ss(s) scanf("%s",s)
#define cool 0
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pll pair<ll,ll> 
#define db cout<<"######\n"
#define null(a) memset(a,0,sizeof(a))
#define neg(a) memset(a,255,sizeof(a))
typedef long double ld;
typedef long long int ll;
using namespace std;
ll i,j,k,z,t,n,m,sum,ans,x,y,maxm=0,minm=inf; bool flag;
ll dist[805][805];
vector<pll> reach;
char a[805][805];
inline ll ceil(ll x,ll y)
{
if(x%y) return x/y+1;
else return x/y;
}
bool check(ll x, ll y)
{
if(x<1||x>n||y<1||y>m)
return false;
else
if(a[x][y]=='#')
return false;
else return true;
}
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
void bfs(ll x,ll y)
{
	dist[x][y]=0;
	
	priority_queue<pair<ll,pll>,vector<pair<ll,pll>>, greater<pair<ll,pll> >> Q;
	
	Q.push({0,{x,y}});
	
	while(!Q.empty())
	{
		auto c=Q.top(); Q.pop();
		
		z=c.F; x=c.S.F; y=c.S.S;
		
		if(z>k)
		continue;
		else
		reach.pb({x,y});
		
		up(0,4,i)
		if(check(x+dx[i],y+dy[i]))
		if(dist[x+dx[i]][y+dy[i]]>z+1)
		dist[x+dx[i]][y+dy[i]]=z+1,Q.push({z+1,{x+dx[i],y+dy[i]}});
		
	}
}
int main()
{
	it(n,m,k);
	
	up(1,n+1,i)
	up(1,m+1,j)
	{
		
		cin>>a[i][j];
		
		if(a[i][j]=='S')
		x=i,y=j;
		
		dist[i][j]=inf;
	}
	
	if(x==1 or y==1)
	{
		pp(0);
		return 0;
	}
	
	bfs(x,y);
	
	ans=inf;
	
	for(auto c:reach)
	{
		ans=min(ans,min(min(ceil(n-c.F,k),ceil(c.F-1,k)),min(ceil(m-c.S,k),ceil(c.S-1,k)))+1);
	}
	
	pp(ans);	
}	


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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int M1,D1,M2,D2; cin >> M1 >> D1 >> M2 >> D2;
    if(D2==1){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    lint X;
    cin >> X;
    for(lint i=-4000;i<=4000;i++) for(lint j=-4000;j<=4000;j++){
        if((i*i*i*i*i)-(j*j*j*j*j)==X){
            cout << i << " " << j << endl;
            return 0;
        }
    }
    return -1;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int gcd(int a, int b){if(b==0) return a; else return gcd(b,a%b);}
int main() {
    int n, X; cin >> n >> X;
    int c; cin >> c;
    int g = abs(X-c);
    rep(i, n-1) {
        int x; cin >> x;
        g = gcd(g, abs(X-x));
    }
    cout << g;
}


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

//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)

#define All(a) (a).begin(),(a).end()

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

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

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数
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 (a > b) { a = b; return 1; }
	return 0;
}


int main()
{
	string s;
	cin >> s;

	REP(i, s.length()) {
		if (s[i] == 'U' || s[i] == 'D')continue;
		if (i % 2 == 0) {
			if (s[i] == 'R')continue;
			cout << "No" << endl;
			return 0;
		}
		else {
			if (s[i] == 'L')continue;
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

long long MOD = 1000000000+7;

using ll = long long int;
ll RepeatSquaring(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2);
        return t*t % MOD;
    }
    return N * RepeatSquaring(N, P-1);
}

int main() {
  long n;
  cin >> n;
  vector<int>data(n,0);
  for(long i = 0;i < n;i++){
    long a;
    cin >> a;
    data[a]++;
  }
  if(n%2 == 0){
    for(long i = 1;i < n;i += 2){
      if(data[i] != 2){
        cout << 0 << endl;
        return 0;
      }
    }
  }
  else{
    for(long i = 0;i < n;i += 2){
      if(i == 0){
        if(data[i] != 1){
          cout << 0 << endl;
          return 0;
        }
      }
      else if(data[i] != 2){
        cout << 0 << endl;
        return 0;
      }
    }
  }
  ll ans = RepeatSquaring(2,n/2);
  cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int a[m];
	int sum=0;
	for(int i=0;i<m;i++){
		

		cin>>a[i];
		sum+=a[i];
	}
	if(sum>n){
		cout<<"-1"<<endl;
	}else {
		cout<<n-sum<<endl;
	}
	
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repp(i, m, n) for(int i = m; i < (int)n; i++)
#define reps(i, n) for(int i = 1; i <= (int)n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;



int main()
{
	int n, m;
	while(cin >> n  && n!=0)
	{
		cin >> m;
		ll h[1510]={}, w[1510]={};
		ll a[2000010]={}, b[2000010]={};
		reps(i, n) cin >> h[i];
		reps(i, n) h[i]+=h[i-1];
		reps(i, m) cin >> w[i];
		reps(i, m) w[i]+=w[i-1];
		
		
		rep(i, n+1)rep(j, n+1) a[(int)abs(h[i]-h[j])]+=1;
		
		rep(i, m+1)rep(j, m+1) b[(int)abs(w[i]-w[j])]+=1;
		
		
		
		ll ans=0;
		reps(i, 2000000) ans+=a[i]*b[i]/4;
		
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 34368
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different 
Yours Faithfully
Shobhit Yadav */

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

int A,B;
/*ll freq[200005];*/
void solve(){
	 /*memset(freq,0,sizeof(freq));*/
	cin>>A>>B;

	if(2*B >= A)
		cout<<0<<'\n';

	else
		cout<<A-2*B<<'\n';
}



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

	return 0;
}

Measured memory_bytes: 3612
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	A, B, C, K := ReadInt(), ReadInt(), ReadInt(), ReadInt()
	for k := 0; k < K; k++ {
		if A >= B {
			B *= 2
			continue
		}
		if B >= C {
			C *= 2
			continue
		}
		C *= 2
	}
	if A < B && B < C {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
$n=<>;$t=<>;
for(2..$n){
    $u=<>;
    $t=$t/&gcd($t,$u)*$u;
}
print $t;
sub gcd{
    my($a,$b)=@_;
    ($a,$b)=($b,$a) if($a>$b);
    ($a,$b)=($b%$a,$a)while($a);
    return$b;
}

Measured memory_bytes: 640
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;
const char ENDL = '\n';

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int n,a,b;
    cin >> n >> a >> b;
    VI t(n);
    REP(i,n){
        cin >> t[i];
    }

    int ans = 0;
    REP(i,n){
        if(t[i]<a || b<=t[i]){
            ans++;
        }
    }

    cout << ans << ENDL;
    
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
using namespace std;
const int MOD = 1e9 + 7;
int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string K;
	int D, N, **dp, p[10001];
	cin >> K >> D;
	N = K.size();
	dp = new int*[N];
	for(int k = 0; k < N; ++k) {
		dp[k] = new int[D];
		memset(dp[k], 0, D * sizeof(int));
	}
	p[0] = K[0] - '0';
	for(int k = 1; k < N; ++k) 
		p[k] = (p[k - 1] + K[k] - '0') % D;
	for(int k = 0; k <= K[0] - '0'; ++k) 
		++dp[0][k % D];
	for(int k = 1; k < N; ++k) {
		int d = K[k] - '0';
		for(int i = 0; i <= 9; ++i)
			for(int j = 0; j < D; ++j)
				dp[k][(i + j) % D] = (dp[k][(i + j) % D] + dp[k - 1][j]) % MOD;
		for(int i = d + 1; i <= 9; ++i)
			dp[k][(i + p[k - 1]) % D] = (MOD - 1LL + dp[k][(i + p[k - 1]) % D]) % MOD; 
	}
	cout << (dp[N - 1][0] + MOD - 1) % MOD << '\n';
	return 0;
}

Measured memory_bytes: 4480
#include <iostream>

using namespace std;

int n;

void solve() {
    for(int i = 1; i <= n; i++) {
        int x = i;
        if(x % 3 == 0) cout << " " << i;
        else {
            do {
                if(x % 10 == 3) {
                    cout << " " << i;
                    break;
                }
            }while(x /= 10);
        }
    }
    cout << endl;
}

int main() {
    cin >> n;
    solve();
}


Measured memory_bytes: 3076
N = int(input())
A = [int(i) for i in input().split()]

if 0 in A:
    print(0)
else:
    A.sort()
    A.reverse()

    i = 1
    res = A[0]
    while (res <= (10 ** 18)) and (i < len(A)):
        res = res * A[i]
        i += 1
    if res <= (10 ** 18):
        print(res)
    else:
        print("-1")


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

#define pb push_back
#define F first
#define S second

#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define int long long
#define ll long long

const int M = 1e9 + 7;
	
void solve(){
	int n, k;
	cin >> n >> k;
	// dp[i] so far we have used i candies to distribute among children
	int dp[k + 1] = {1}, a[n];	
	for(int i = 0 ; i < n ; i++){
		int pre[k + 1] = {};
		cin >> a[i];
		for(int j = 0 ; j <= k ; j++){
			int left = j + 1;
			int right = j + min(a[i], k - j);
			if(right >= left){
				pre[left] = (pre[left] + dp[j]) % M;
				if(right <= k)
					pre[right + 1] = (pre[right + 1] - dp[j] + M) % M; 
			}
		}
		for(int i = 1 ; i <= k ; i++){
			pre[i] = (pre[i] + pre[i - 1]) % M;
			dp[i] = (dp[i] + pre[i]) % M;
		}
	}
	cout << dp[k];
}

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

Measured memory_bytes: 1792
class Node():
	def __init__(self, key):
		self.parent = None
		self.left = None
		self.right = None
		self.key = key

class Tree():
	def __init__(self):
		self.root = None
	def insert(self, key):
		z = Node(key)
		y = None
		x = self.root
		while x:
			y = x
			if z.key < x.key:
				x = x.left
			else:
				x = x.right
		z.parent = y
		if y == None:
			self.root = z;
		elif z.key < y.key:
			y.left = z
		else:
			y.right = z
	def pre_order(self, node):
		print(" {}".format(node.key), end = "")
		if node.left:
			self.pre_order(node.left)
		if node.right:
			self.pre_order(node.right)
	def in_order(self, node):
		if node.left:
			self.in_order(node.left)
		print(" {}".format(node.key), end = "")
		if node.right:
			self.in_order(node.right)
	def out(self):
		self.in_order(self.root)
		print("")
		self.pre_order(self.root)
		print("")

tree = Tree()
n = int(input())
for i in range(n):
	c = input().split()
	if c[0] == "insert":
		tree.insert(int(c[1]))
	else:
		tree.out()

Measured memory_bytes: 153696
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
	int r, c;
	cin >> r >> c;

	int mat[101][101] = {};
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			int n;
			cin >> n;
			mat[i][j] = n;
			mat[i][c] += n;
			mat[r][j] += n;
			mat[r][c] += n;
		}
	}

	for (int i = 0; i < r + 1; i++) {
		for (int j = 0; j < c + 1; j++) {
			cout << mat[i][j];
			if (j < c) cout << " ";
		}
		cout << endl;
	}

	return 0;
}



Measured memory_bytes: 3120
#include <tuple>
#include <vector>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
using ll	= long long;
using ull	= unsigned long long;
using ld	= long double;
using pii	= pair<int,int>;
using pll	= pair<ll,ll>;
using vi	= vector<int>;
using vb	= vector<bool>;
using vc	= vector<char>;
using vvi	= vector<vi>;
using vvb	= vector<vb>;
using vpii	= vector<pii>;
using vpll	= vector<pll>;
using vll	= vector<ll>;
using vull	= vector<ull>;
using vvll	= vector<vll>;
#define ever (;;)
#define f first
#define s second
#define pb emplace_back
#define sz size()
#define graph vector<vertex>
#define deg(X) (int)G[X].e.size()
#define INF 1234567890
#define INFll 2000000000000000000
#define maxe(X, Y) if((Y) > (X)) (X) = (Y)
#define mine(X, Y) if((Y) < (X)) (X) = (Y)
#define rep(i, begin, end) for(__typeof(end) i = (begin); i < (end); ++i)
#define repr(i, begin, end) for(__typeof(end) i = (begin)-1; i >= (end); --i)
#define bend(X) X.begin(), X.end()
pii operator+(const pii& A, const pii& B) { return {A.f+B.f, A.s+B.s}; }
pii operator-(const pii& A, const pii& B) { return {A.f-B.f, A.s-B.s}; }
pii operator-(const pii& A) { return {-A.f, -A.s}; }

//
// END OF DEFINES
//

constexpr ll mod = 1e9+7;

struct matrix {
	int n;
	vvll T;
	void resize(int N) {
		n = N;
		T.resize(n, vll(N));
	}
	matrix operator*(const matrix& o) {
		matrix R;
		R.resize(n);
		rep(i, 0, n)
			rep(j, 0, n)
				rep(l, 0, n)
					R.T[i][j] = (R.T[i][j] + T[i][l]*o.T[l][j])%mod;
		return R;
	}
};

int n;
ll k;
matrix G;

bool in() {
	scanf("%d %lld", &n, &k);
	G.resize(n);
	rep(i, 0, n)
		rep(j, 0, n)
			scanf("%lld", &G.T[i][j]);
	
	return true;
}

matrix pw(matrix x, ll p) {
	if(p == 1)
		return x;
	if(p%2 == 1)
		return x*pw(x, p-1);
	matrix A = pw(x, p/2);
	return A*A;
}

ll solve() {
	matrix X = pw(G, k);
	
	ll R = 0;
	rep(i, 0, n)
		rep(j, 0, n)
			R = (R+X.T[i][j])%mod;
	return R;
	
	return -INF;
}

int main() {
	int noOfTests = 1;
	//scanf("%d", &noOfTests);
	
	while(noOfTests --> 0) {
		if(!in()) {
			printf("popsute wejscie\n");
			continue;
		}
		ll result = solve();
		if(result == ll(-'t'))
			printf("TAK\n");
		else if(result == ll(-'n'))
			printf("NIE\n");
		else if(result != -INF)
			printf("%lld\n", result);
	}
	
	return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

int main(){
  int n, count,j;
  int limit;
  vector<int> nl;
  while(cin >> n){
    nl.push_back(n);
  }

  for(int i=0; i<nl.size(); i++){
    n = nl[i];
    int prime[n+1];
    for(j=2; j<=n; j++){
      prime[j] = 1;
    }
    count = 0;
    limit = (int)sqrt(n);
    for(j=2; j<=limit; j++){
      if(prime[j] == 1){
        for(int k=j*2; k<=n; k+=j){
          prime[k] = 0;
        }
      } 
    }

    for(j=2; j<=n; j++){
      if(prime[j]==1){
        count++;
      }
    }
    cout << count << endl;
  }

  return 0;
}

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

const int N = 2e5;
int p[N + 7];
int dp[N + 7];
int n;

int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> p[i];
  
  int wyn = 0;
  for (int i = 1; i <= n; ++i) {
    dp[p[i]] = max(1, 1 + dp[p[i] - 1]);
    wyn = max(wyn, dp[p[i]]);
  }
  
  cout << n - wyn << endl;
  return 0;
} 

Measured memory_bytes: 1792
#include<cstdio>
#define neko 100010
#define qwq return printf("Yes\n"),0
#define orz return printf("No\n"),0
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~i))
int n,minx=1e9,maxn,a[neko],cnt;
int cmin(int a,int b){return a<b?a:b;}
int cmax(int a,int b){return a>b?a:b;}
int main()
{
	scanf("%d",&n);
	f(i,1,n)scanf("%d",&a[i]),minx=cmin(minx,a[i]),maxn=cmax(maxn,a[i]);
	if(minx==maxn)
	{
		if(minx==n-1)qwq;
		else if(2*minx>n)orz;
		else qwq;
	}
	else if(minx<maxn-1)orz;
	else
	{
		f(i,1,n)if(minx==a[i])++cnt;
		if(maxn-cnt<=0)orz;
		else if(2*(maxn-cnt)>(n-cnt))orz;
		else qwq;
	}
}

Measured memory_bytes: 512