akhauriyash/Code-Regression huggingface dataset:
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
  N,D = parseMap(split(readline()))
  X = zeros(N)
  Y = zeros(N)
  count=0
  for i in 1:N
    X[i],Y[i] = parseMap(split(readline()))
    if sqrt(X[i]^2+Y[i]^2) <= D
      count += 1
    end
  end
  println("$count")
end
main()


Measured memory_bytes: 205456
#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 <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
#define f first
#define s second

int h[1000001];

main(){
  ll p=108839116800000000LL;
  rep(k,1000001){
    if(k==0)continue;
    if(p%k==0)h[k]=h[k-1]+1;
    else h[k]=h[k-1];
  }
  int m,n;
  while(cin>>m,m){
    cin>>n;
    cout<<h[n]-h[m-1]<<endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int nx[2000009][27];
int p[2000009];
int sz[2000009];
int ind[2000009];
int w[2000009];
int dp[2000009][27];
string s;
int c = 1;
int ad(int x, int i){
    if(i == s.size()) {
        sz[x]++;
        return x;
    }
    int u = s[i] - 'a';
    if(nx[x][u] == 0){
        nx[x][u] = ++c;
        w[c] = u;
        p[c] = x;
    }
    return ad(nx[x][u], i+1);
}
void dfs(int x){
    for(int i= 0 ; i < 26; i++){
        if(!nx[x][i]) continue;
        int y = nx[x][i];
        dfs(y);
        sz[x] += sz[y];

        for(int j = 0;j < 26; j++)
            dp[x][j] += dp[y][j];
    }

    if(x > 1) dp[x][w[x]] = sz[x];
}
string S[2000009];
main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin>> s;
        reverse(s.begin(), s.end());
        S[i] = s;
        ind[i] = ad(1, 0);
    }
    dfs(1);
    long long ans = 0;
    for(int i = 1; i <= n; i++){
        int x = p[ind[i]];
        int u = S[i].back()-'a';
        for(int j = 0; j < 26; j++)
            if(nx[x][j]) ans += dp[nx[x][j]][u];
        ans--;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 363548
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define int long long
signed main() {
	int h, w, x, y; cin >> h >> w >> x >> y;
	h *= w; x += y;
	h %= 2; x %= 2;
	cout << (h&&x ? "No\n" : "Yes\n");
}


Measured memory_bytes: 3084
s = input() + "T"
x, y = map(int, input().split())
X = [[], [0]]
d = 0
t = 0
for i in range(len(s)):
    if s[i] == "F":
        t += 1
    else:
        X[d].append(t)
        d = 1-d
        t = 0
def calc(l):
    if len(l) == 0: return [0] 
    post = [l[0]]
    for i in range(1, len(l)):
        if l[i]:
            pre = sorted(post)
            post = []
            for j in range(len(pre)):
                if j==0 or pre[j] != pre[j-1]:
                    post.append(pre[j]+l[i])
                    post.append(pre[j]-l[i])
            # print(pre, post)
    return post

if x in calc(X[0]) and y in calc(X[1]):
    print("Yes")
else:
    print("No")

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


int main() {

    long K;
    cin >> K;

    long result = 0;

    for(int a = 1; a <= K; a++){
        for(int b = 1; b <= K; b++){
            for(int c = 1; c <= K; c++){
                int tmp = __gcd(a, b);
                result += __gcd(tmp,c);
            }
        }
    }

    cout << result << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll ans[100009];
struct ss
{
    ll v;
    ll pos;
}a[100009];
const bool com(const ss &a,const ss&b)
{
    if(a.v>b.v)return 1;
    else if(a.v==b.v)
    {
        return a.pos<b.pos;
    }
    return 0;
}
 int main()
{
    ll n;
    scanf("%lld",&n);
    for(ll i=1;i<=n;i++)
    {
        //cin>>a[i].v;
        scanf("%lld",&a[i].v);
        a[i].pos=i;
    }
    sort(a+1,a+1+n,com);
    /*for(ll i=1;i<=n;i++)
    {
        cout<<a[i].v<<" "<<a[i].pos<<endl;
    }*/
    a[n+1].v=0;
    ll tmp=1;
    ll num=a[1].pos;
    for(ll i=2;i<=n+1;i++)
    {
        if(a[i].v==a[i-1].v)tmp++;
        else
        {
            ans[num]+=(a[i-1].v-a[i].v)*tmp;
            tmp++;
        }
        if(a[i].pos<num)
        {
            num=a[i].pos;
        }
    }
    for(ll i=1;i<=n;i++)
    {
        printf("%lld\n",ans[i]);
    }
}


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

typedef long long ll;
typedef pair<int,int> ii;

bool ok(pair<int,int> &p, int n, int m) {
	return (p.first<n&&p.second<m);
}

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,m; cin>>n>>m;
	vector<string> grid(n);
	for (int i=0; i<n; i++)
		cin>>grid[i];
	ii cur={0,0};
	while(1) {
		grid[cur.first][cur.second]='.';
		if(cur.first==n-1&&cur.second==m-1)
			break;
		ii right=cur, down=cur; right.second++; down.first++;
		bool update=false;
		if(ok(right,n,m)&&grid[right.first][right.second]=='#')
			cur=right, update=true;
		else if(ok(down,n,m)&&grid[down.first][down.second]=='#')
			cur=down, update=true;
		if(!update)
			break;
	}

	for (int i=0; i<n; i++)
		for (int j=0; j<m; j++)
			if(grid[i][j]=='#') {
				cout << "Impossible" << endl;
				return 0;
			}
	cout << "Possible" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

const int MAX = 91;
bool M[MAX][MAX];
int w,h,ans;
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};


void init(){
  ans = 0;
}

void input(){
  for(int i = 0; i < h; i++)
    for(int j = 0; j < w; j++) cin >> M[i][j];
}

bool isInside(const int x, const int y){ return 0<=x&&x<w&&0<=y&&y<h;}

void dfs(int y, int x, int s){

  for(int i = 0; i < 4; i++){
    int ny = y+dy[i];
    int nx = x+dx[i];
    
    if(!isInside(nx,ny) || !M[ny][nx]) continue;
    
    M[ny][nx] = false;
    dfs(ny,nx,s+1);
    M[ny][nx] = true;
  }

  ans = max(ans,s);
}

void solve(){
  for(int i = 0; i < h; i++)
    for(int j = 0; j < w; j++)
      if(M[i][j]){
	M[i][j] = false;
	dfs(i,j,1);
	M[i][j] = true;
      }

  cout << ans << endl;
}

int main(){
  
  while(cin >> w >> h && w+h){
    init();
    input();
    solve();
  }

  return 0;
}

Measured memory_bytes: 1168
//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
#include <list>
#include <iterator>//std::advance()
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<long long> a(n);
    vector<long long> ans1(n);
    vector<long long> ans2(n);
    long long ans=0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        ans1[i]=i-a[i];
        ans2[i]=a[i]+i;
    }
    sort(ans2.begin(),ans2.end());
    for(int i=0; i<n; i++){
        ans+=upper_bound(ans2.begin(),ans2.end(),ans1[i])-lower_bound(ans2.begin(),ans2.end(),ans1[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 8008
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define loop(i ,a,b) for(int i = a;i<b;i++)
#define rloop(i,a,b) for(int i = a ; i>b;i--)
#define loopll(i,a,b) for( long long int i = a; i<b;i++)
#define rloopll(i,a,b) for(long long int i = a; i>b;i--)
#define eb emplace_back
#define pii pair<int ,int>
#define pll pair<ll ,ll>
#define f first
#define mk make_pair
#define intmin INT_MIN
#define intmax INT_MAX
#define cout(x) cout<<x<<" ";
using namespace std;
void vec(vector<int> & v){

    for(int i = 0;i<v.size() ; i++){
        cout<<v[i]<< " ";
    }
    cout<<endl;
}
void vec_ll(vector<long long int> & v){

    for(int i = 0;i<v.size() ; i++){
        cout<<v[i]<< " ";
    }
    cout<<endl;
}
int parsestring(string temp){
    int num= 0;
    int digs = temp.size() - 1;
    for(int i = 0 ;i<=digs;i++){
        num += pow(10 , digs -i)*(temp[i] - '0');
    }
    return num;
}
bool prime(ll n) {
if (n < 2) return false;
for (ll x = 2; x*x <= n; x++) {
if (n%x == 0) return false;
}
return true;
}

string ter(ll n){
    string t ="";
        while(n>0){
            t += to_string(n%3);
            n /=3;
        }
        return t;
}
ll power(int base ,int exp , int mod){
    ll ans = 1;
    for(int i = 1;i<=exp ; i++){
        ans = ((ans%mod)*(base%mod))%mod;
    }
    return ans%mod;
}
int sumdig(ll num){
    int sum = 0;
    string s = to_string(num);
    loop( i , 0 , s.size()){
        sum += s[i]-'0';
    }
    return sum;
}

vector<vector<int>> adj(2e5 + 100 , vector<int>());
vector<bool> vis(2e5  +100 , false);
int mod = 1e9 + 7;
int dfs(int x){
    int ans = 0;
    stack<int> s;
    s.push(x);
    while(s.size()){
        int t = s.top();
        s.pop();
        vis[t] = true;
        ans++;
        for(int i = 0;i<adj[t].size() ;i++){
            if(!vis[adj[t][i]]){
                s.push(adj[t][i]);
            }
        }
    }
    return ans;
}
int bin(vector<int> &v , int l , int r , int key){
    while(r - l > 1){
        int m = (l+r)/2;
        if(v[m] <=key){
            l= m;
        }
        else{
            r = m;
        }
    }
    return r;
}
int main(){
    int l,r,d;
    cin>>l>>r>>d;
    int ans = 0;
    ans += (r/d);
    ans -= (l-1)/d;
    cout<<ans<<endl;
}


Measured memory_bytes: 7844
def alpha(n):
    if n <= 26:
        return chr(ord('a')-1+n)
    elif n % 26 == 0:
        return alpha(n//26-1)+'z'
    else:
        return alpha(n//26)+chr(ord('a')-1+(n % 26))

n = int(input())
print(alpha(n))

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

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[3];
		a[0] = sc.nextInt();
		a[1] = sc.nextInt();
		a[2] = sc.nextInt();
		sc.close();

		Arrays.parallelSort(a);
		System.out.println(a[0] + a[1]);
	}
}


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

using namespace std; 

int gcd(int x, int y) {
  return !y ? x : gcd(y, x % y); 
}

int main() {
  int a; 
  cin >> a; 
  cout << 360 / gcd(360, a); 
  return 0; 
}

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

using namespace std;

const int INF=1000000000;
int d[101][101];

int selected[101];
int maxSum=0;
int n,m;

void dfs(int num,int cnt,int idx){
  if(cnt==num){
    // for(int i = 0; i < num; i++){
    //   //      cout<<selected[i]<<" ";
    // }
    int sum=0;
    // N[NÌRXgðßé
    for(int i = 0; i < cnt; i++){
      int minc=INF;
      for(int j = 0; j < cnt; j++)
	if(i!=j)minc=min(minc,d[selected[i]][selected[j]]);
      sum+=minc;
    }
    //    cout<<" "<<sum<<endl;
    maxSum=max(maxSum,sum);
  }
  else{
    for(int i = idx; i < n; i++){
      bool ok=true;
      // SyAÔÉ¹ª éÈçÂ­é
      for(int j = 0; j < cnt; j++){
	// ¹ª¶ÝµÈ¢
	if(d[i][selected[j]]==INF){
	  ok=false;
	  break;
	}
      }
      if(ok){
	selected[cnt]=i;
	dfs(num,cnt+1,i+1);
      }
    }
  }
}
 
int main(){
  cin>>n>>m;
  for(int i = 0; i < 101; i++)
    for(int j = 0; j < 101; j++)
      d[i][j]=INF;
  for(int i = 0; i < m; i++){
    int from,to,cost;
    cin>>from>>to>>cost;
    from--;to--;
    d[from][to]=d[to][from]=cost;
  }
  maxSum=0;
  // 1©ç14¸_©çÈéN[NÌÅåRXgðTõ
  for(int i = 2; i <= 14; i++){
    dfs(i,0,0);
  }
  cout<<maxSum<<endl;

  return 0;
}

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

int main() {
  vector<pair<int, int> > data(5);
  for (int i=0; i<5; i++) {
    scanf("%d", &data.at(i).second);
    data.at(i).first = (data.at(i).second%10 == 0 ? 9 : data.at(i).second%10);
  }
  sort(data.begin(), data.end(), greater<pair<int, int> >());
  int ans=0;
  for (int i=0; i<4; i++) {
    ans += (data.at(i).second+9)/10*10;
  }
  ans += data.at(4).second;
  printf("%d\n", ans);
}

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

int main() {
    int n;
    cin >> n;
    string a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    vector<set<char>> st(n);
    rep(i,n) {
        st[i].insert(a[i]);
        st[i].insert(b[i]);
        st[i].insert(c[i]);
    }
    rep(i,n) {
        ans += st[i].size() - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
x = []
tmp = sum(a)
for i in range(1,n,2):
	tmp = tmp - 2*(a[i])
x.append(tmp)
for i in range(n-1):
	x.append(2*(a[i])-x[-1])
print(*x)

Measured memory_bytes: 14092
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

template<uint MD>
struct ModInt {
    uint v;
    ModInt() : v{0} {}
    ModInt(ll v) : v{normS(v%MD+MD)} {}
    explicit operator bool() const {return v != 0;}
    static uint normS(const uint &x) {return (x<MD)?x:x-MD;};
    static ModInt make(const uint &x) {ModInt m; m.v = x; return m;}
    static ModInt inv(const ModInt &x) {return pow(ModInt(x), MD-2);} 
    ModInt operator+(const ModInt &r) const {return make(normS(v+r.v));}
    ModInt operator-(const ModInt &r) const {return make(normS(v+MD-r.v));}
    ModInt operator*(const ModInt &r) const {return make((ull)v*r.v%MD);}
    ModInt operator/(const ModInt &r) const {return *this*inv(r);}
    ModInt& operator+=(const ModInt &r) {return *this=*this+r;}
    ModInt& operator-=(const ModInt &r) {return *this=*this-r;}
    ModInt& operator*=(const ModInt &r) {return *this=*this*r;}
    ModInt& operator/=(const ModInt &r) {return *this=*this/r;}
};
template<uint MD> string to_string(ModInt<MD> m) {return to_string(m.v);}
using Mint = ModInt<TEN(9)+7>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
    int n;
    cin >> n;
    Mint ans = 1;
    int nc = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x; x--;
        nc++;
        if ((nc-1)*2 <= x) continue;
        ans *= Mint(nc);
        nc--;
    }
    while (nc) {
        ans *= nc;
        nc--;
    }
    cout << ans.v << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque
N = int(input())
A = list(map(int,input().split()))
A.sort()
if len(A) == 2:
    print(A[1]-A[0])
    print(A[1],A[0])
    exit()
posi = deque([])
nega = deque([])
for i in A:
    if i < 0:
        nega.append(i)
    else:
        posi.append(i)
ans = []
if len(posi) == 0:
    x = nega.pop()
    y = nega.pop()
    posi.append(x-y)
    ans.append([x,y])
if len(nega) == 0:
    x = posi.popleft()
    y = posi.popleft()
    nega.append(x-y)
    ans.append([x,y])

while len(posi) > 1:
    x = nega.pop()
    y = posi.pop()
    ans.append([x,y])
    nega.append(x-y)
while len(nega) > 0:
    x = posi.pop()
    y = nega.pop()
    ans.append([x,y])
    posi.append(x-y)

print(posi[0])
for i in range(N-1):
    print(' '.join(map(str,ans[i])))


Measured memory_bytes: 97832
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++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(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60


long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

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

    int sum = 0;
    for(int a=1; a<=K; a++)
        for(int b=1; b<=K; b++)
            for(int c=1; c<=K; c++) {
                sum += GCD(GCD(a, b), c);
            }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3612
A = raw_input()
A = int(A)

B = raw_input().split()
B = [int(b) for b in B]

max_v = 0
previous = None
current = 0
for i in B:
    if previous is not None and previous >= i:
        previous = i
        current += 1
    else:
        current =0
        previous = i
    if current > max_v:
        max_v = current
print max_v

Measured memory_bytes: 11852
/**************************
*                         *
*  Nothing Is Impossible  *
*                         *
**************************/
#include <algorithm>
#include <pthread.h>
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <string>
#include <vector>
#include <thread>
#include <math.h>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <set>
#include <map>
#define GetRand(Min, Max) ((rand()%(int)(((Max) + 1)-(Min))) + (Min))
#define Rep(i, min, max) for(int64_t i = min; i < max; ++i)
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef long double ld;
using namespace std;

void solve(){
	int k;	cin >> k;
	string s; cin >> s;
	if(s.size() > k){
		Rep(i,0,k){
			cout << s[i];
		}
		cout << "..." << endl;
	}else{
		cout << s << endl;
	}
}

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

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;
int n,k;
vector<ll>a;
void input();
bool buy[100];
void solve(){
    ll mx=0;

    ll money = 1000;
    for(int i=0;i<n-1;i++){
        if(a[i]<a[i+1]){
            int j = i+1;
            while(j<n-1 && a[j]<=a[j+1]){
                j++;
                continue;
            }
            ll stock = money/a[i];
            money%=a[i];
            money +=stock*a[j];
            //cout<<i<<" "<<j<<"\n";
            i=j;
        }
    }
    cout<<money<<"\n";
}

void Clear(){

}

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

    input();
    solve();
    Clear();
}

void input(){
    cin>>n;
    for(int i=0;i<n;i++){
        ll x;
        cin>>x;
        a.pb(x);
    }
}


Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <algorithm>
using ll=long long;
const int mod=1e9+7;
long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
    int n;
    std::cin>>n;
    std::vector<ll> c(n);
    for(int i=0;i<n;i++)std::cin>>c[i];
    ll ret=0;
    std::sort(c.begin(),c.end());
    for(int i=0;i<n;i++){
        if(n-i-1>0)ret+=c[i]*modpow(2,i*2)%mod*2%mod*modpow(2,2*(n-i-1)-1)%mod*((n-i-1)+2)%mod;
        else ret+=c[i]*modpow(2,i*2)%mod*2%mod;
        ret%=mod;
        //std::cout<<ret<<std::endl;
    }
    std::cout<<ret<<std::endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
	int a, b, c;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	
	if(a <= b){
		if(b <= c){
			printf("%d %d %d\n", a, b, c);
		}
		if(b > c){
			if(a <= c){
				printf("%d %d %d\n", a, c, b);
			}
			if(a > c){
				printf("%d %d %d\n", c, a, b);
			}
		}
	}
	if(a > b){
		if(b > c){
			printf("%d %d %d\n", c, b, a);
		}
		if(b <= c){
			if(a > c){
				printf("%d %d %d\n", b, c, a);
			}
			if(a <= c){
				printf("%d %d %d\n", b, a, c);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <iomanip>

using namespace std;

/********** TEMPLATE STARTS HERE ***********/

#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define gcd __gcd 

typedef unsigned long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vl;
typedef vector <pll> vll;
typedef vector <pii> vii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;

template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

/*********** TEMPLATE ENDS HERE *************/

const int DIM = 60;

bool v[DIM][DIM];

int path[DIM][DIM];

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

queue <pii> Q;

int n, m;

bool isInside(int x, int y)
{
	return (x >= 1 && x <= n && y >= 1 && y <= m);
}

main()
{
	IOS
	
	cin >> n >> m;
	
	int black = 0;
	
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
		{
			char c;
			cin >> c;
			
			if(c == '#')
			{
				v[i][j] = 1;
				black++;
			}
		}
	
	Q.push({1, 1});
	
	path[1][1] = 1;
	
	while(!Q.empty())
	{
		int x = Q.front().F;
		int y = Q.front().S;
		
		Q.pop();
		
		for(int i = 0; i < 4; i++)
		{
			int new_x = x + dx[i];
			int new_y = y + dy[i];
			
			if(isInside(new_x, new_y) && path[new_x][new_y] == 0 && v[new_x][new_y] == 0)
			{
				path[new_x][new_y] = path[x][y] + 1;
				Q.push({new_x, new_y});
			}
		}
	}
	
	if(path[n][m] == 0)
		cout << -1;
	else
		cout << n * m - black - path[n][m];
	
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){

    int s,a;

    a = 0;

    scanf("%d",&s);

    if(s >= 100000){
        a++;
        s = s - 100000;
    }
    

    if(s > 10000){
        a++;
        s = s-10000;
    }
    

    if (s >= 1000){
        a++;
        s = s-1000;
    }
    

    if(s >= 100){
        a++;
        s = s-100;
    }
    

    if(s >= 10){
        a++;
        s = s -10;
    }
    

    if( s>= 1){
        a++;
    }
    
    printf("%d\n",a);

    return 0;



}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

bool fn_is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

bool isOK(int index, int key, vector<ll>& a) {
    if (a[index] >= key) return true;
    else return false;
}

int binary_search(int key, vector<ll>& a) {
    int ng = -1;
    int ok = a.size();

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key, a)) ok = mid;
        else ng = mid;
    }
    return ok;
}

struct UnionFind {
    vector<int> r;

    UnionFind(int N) {
        r = vector<int>(N, -1);
    }

    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }

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

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

ll calc(ll a, ll b, ll p) {
    if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = calc(a, b/2, p);
        return (d * d) % p;
    } else {
        return (a * calc(a, b-1, p)) % p;
    }
}
     
int main()
{
    ll n, m; cin >> n >> m;
    ll ans = 1;
    if (abs(n - m) >= 2) {
        cout << 0 << endl;
        return 0;
    } 
    for (int i = 2; i <= n; i++) {
        ans = (ans * i) % MOD;
        ans %= MOD;
    }
    for (int i = 2; i <= m; i++) {
        ans = (ans * i) % MOD;
        ans %= MOD;
    }
    if (n == m)
        ans *= 2;
    cout << ans % MOD << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template<typename T> T gcd(T a, T b){return (a % b)? gcd(b, a % b) : b;}
template<typename T> T lcm(T a, T b){return a * b / gcd(a, b);}

int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;

    bool flag = false;
    while(k >= 0){
        if(a < b && b < c){
            flag= true;
            break;
        }
        if(a >= b) b *= 2;
        else c *= 2;
        k--;
    }

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
typedef pair<int, int> P;
int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<vector<char>> t(4, vector<char>(n));
	t[0][0] = t[1][0] = 'S';
	t[2][0] = t[3][0] = 'W';
	if (s[0] == 'o')
	{
		t[0][n - 1] = t[0][1] = 'W';
		t[1][n - 1] = t[1][1] = 'S';
		t[2][n - 1] = 'S';
		t[2][1] = 'W';
		t[3][n - 1] = 'W';
		t[3][1] = 'S';
	}
	else if(s[0]=='x')
	{
		t[0][n - 1] = 'W';
		t[0][1] = 'S';
		t[1][n - 1] = 'S';
		t[1][1] = 'W';
		t[2][n - 1] = t[2][1] = 'W';
		t[3][n - 1] = t[3][1] = 'S';
	}
	vector<char> beffirst(4), beflast(4);
	rep(i, 4)
	{
		beffirst[i] = t[i][0];
		beflast[i] = t[i][n - 1];
	}

	FOR(i, 1, n - 1)
	{
		if (s[i] == 'o')
		{
			rep(j, 4)
			{

				if (t[j][i] == 'S')
				{
					t[j][i + 1] = t[j][i - 1];
				}
				else
				{
					if (t[j][i - 1] == 'W')
					{
						t[j][i + 1] = 'S';
					}
					else
					{
						t[j][i + 1] = 'W';
					}
				}
			}
		}
		else if (s[i] == 'x')
		{
			rep(j, 4)
			{

				if (t[j][i] == 'S')
				{
					if (t[j][i - 1] == 'W')
					{
						t[j][i + 1] = 'S';
					}
					else
					{
						t[j][i + 1] = 'W';
					}
				}
				else
				{
					t[j][i + 1] = t[j][i - 1];
				}
			}
		}
	}
	rep(j, 4)
	{
		if (t[j][n - 1] == 'S')
		{
			if (s[n - 1] == 'o')
			{
				 t[j][0]=t[j][n - 2] ;
			}
			else
			{
				if (t[j][n - 2] == 'W')
				{
					t[j][0] = 'S';
				}
				else
				{
					t[j][0] = 'W';
				}
			}
		}
		else if(t[j][n-1]=='W')
		{
			if (s[n - 1] == 'o')
			{

				if (t[j][n - 2] == 'W')
				{
					t[j][0] = 'S';
				}
				else
				{
					t[j][0] = 'W';
				}
			}
			else
			{
				t[j][0] = t[j][n - 2];
			}
		}
	}

	/*rep(j, 4)
	{
		rep(i, n)
		{
			cout << t[j][i];
		}
		cout << endl;
	}*/
	bool ok = false;
	int ite = -1;
	rep(j, 4)
	{
		if (t[j][n - 1] == beflast[j] && t[j][0] == beffirst[j])
		{
			ite = j;
			ok = true;
			break;
		}
	}
	if (ok)
	{
		rep(i, n)
		{
			cout << t[ite][i];
		}
		cout << endl;
	}
	else
	{
		cout << -1 << endl;
	}
}


Measured memory_bytes: 1024
#include<stdio.h>
#define N 100

int main(){
  int i,j,n,cnt=0,tmp;
  int A[N],mini;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  for(i=0;i<n;i++){
    mini=i;
    for(j=i;j<n;j++){
      if(A[j]<A[mini]){
	mini=j;
      }
    }
    if(i!=mini){
      tmp=A[i];
      A[i]=A[mini];
      A[mini]=tmp;
      cnt++;
    }
    
  }
  
  
  for(i=0;i<n;i++){
    if(i>0) printf(" ");
    printf("%d",A[i]);
  }

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

  return 0;
}

Measured memory_bytes: 604
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
int odd=0,even=0,Odd[105],Even[105],ma[105];
int flag[10000010],x[10000010],map[105][105],vis[105];
int prime[10000010],a[105];
int dfs(int u)
{
	for (int v=1;v<=even;v++)
	{
		if (!map[u][v]) continue;
		if (!vis[v])
		{
			vis[v]=1;
			if (ma[v]==-1||dfs(ma[v]))
			{
				ma[v]=u;
				return 1;
			}
		}
	}
	return 0;
}
int main()
{
	int n,cnt=0;
	scanf("%d",&n);
	flag[1]=1;
	for (int i=2;i<=10000001;i++)
	{
		if (!flag[i]) prime[++cnt]=i;
		for (int j=1;j<=cnt;j++)
		{
			if (i*prime[j]>10000001) break;
			flag[i*prime[j]]=1;
			if (i%prime[j]==0) break;
		}
	}
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		x[a[i]]^=1;
	}
	for (int i=1;i<=10000001;i++)
		if (x[i]!=x[i-1])
		{
			if (i&1) Odd[++odd]=i;
			else Even[++even]=i; 
		}
	for (int i=1;i<=odd;i++)
		for (int j=1;j<=even;j++)
			if (!flag[abs(Odd[i]-Even[j])]) map[i][j]=1;
	for (int i=1;i<=even;i++)
		ma[i]=-1;
	int sum=0;
	for (int i=1;i<=odd;i++)
	{
		memset(vis,0,sizeof(vis));
		if (dfs(i)) sum++;
	}
	int ans=sum+(((odd-sum)>>1)<<1)+(((even-sum)>>1)<<1)+(odd-sum)%2*3;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 82560
from collections import deque
H, W = map(int, input().split())
areas = []
blacks = 0
for _ in range(H):
    texts = list(input().rstrip())
    for char in texts:
        if char == '#':
            blacks += 1
    areas.append(texts)

# start は 0,0
# goal はH-1,W-1
# .を#に変更できる
# たくさん変更すればするほどポイントは高い
# 全部のマス - 元から#だった数 - 最短距離

inf = float('inf')


def bfs(start_point, goal_point):
    scores = [[inf for _ in range(W)] for _ in range(H)]
    queue = deque([start_point])
    scores[0][0] = 0
    move_positions = [[-1, 0], [0, -1], [1, 0], [0, 1]]
    while queue:
        now_point = queue.popleft()
        for move_position in move_positions:
            next_point = [now_point[0] + move_position[0],
                          now_point[1] + move_position[1]]
            if 0 <= next_point[0] < H and 0 <= next_point[1] < W:
                if areas[next_point[0]][next_point[1]] == '.':
                    if scores[next_point[0]][next_point[1]] > scores[now_point[0]][now_point[1]] + 1:
                        scores[next_point[0]][next_point[1]
                                              ] = scores[now_point[0]][now_point[1]] + 1
                        queue.append(next_point)
    return scores[H - 1][W - 1]


cost = bfs([0, 0], [H - 1, W - 1]) + 1
if cost == inf:
    print(-1)
else:
    print(H * W - blacks - cost)


Measured memory_bytes: 40432
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}

uintmax_t comb(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}

unsigned GetDigit(unsigned num){
    return log10(num)+1;
}
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}



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

ll x,money = 100;
cin >> x;

for(ll i = 1;i < 4500;i++){
    money = money*1.01;
    if(money >= x){
        cout << i << endl;
        return 0;
    }
}


//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 3668
/**
 * @brief ユーザ定義リテラル
 * @author えびちゃん
 */

#ifndef H_int_literals
#define H_int_literals

#include <cstddef>
#include <cstdint>

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

#endif  /* !defined(H_int_literals) */

/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */

#ifndef H_make_vector
#define H_make_vector

#include <cstddef>
#include <type_traits>
#include <vector>

namespace detail {
  template <typename Tp, size_t N>
  std::vector<Tp> make_vector(
      std::vector<size_t>& sizes,
      typename std::enable_if<(N == 1), Tp const&>::type x
  ) {
    return std::vector<Tp>(sizes[0], x);
  }
  template <typename Tp, size_t N>
  auto make_vector(
      std::vector<size_t>& sizes,
      typename std::enable_if<(N > 1), Tp const&>::type x
  ) {
    size_t size = sizes[N-1];
    sizes.pop_back();
    return std::vector<decltype(make_vector<Tp, N-1>(sizes, x))>(
        size, make_vector<Tp, N-1>(sizes, x)
    );
  }
}  // detail::

template <typename Tp, size_t N>
auto make_vector(size_t const(&sizes)[N], Tp const& x = Tp()) {
  std::vector<size_t> s(N);
  for (size_t i = 0; i < N; ++i) s[i] = sizes[N-i-1];
  return detail::make_vector<Tp, N>(s, x);
}

#endif  /* !defined(H_make_vector) */

#include <cstdio>

int main() {
  size_t n;
  scanf("%zu", &n);

  std::vector<intmax_t> a(n);
  for (auto& ai: a) scanf("%jd", &ai);

  a.insert(a.begin(), 0);
  for (size_t i = 1; i <= n; ++i) a[i] += a[i-1];

  intmax_t const inf = 1e18;
  auto dp = make_vector({n, n+1}, inf);
  for (size_t i = 0; i < n; ++i) dp[i][i+1] = 0;

  for (size_t w = 2; w <= n; ++w) {
    for (size_t i = 0; i+w <= n; ++i) {
      intmax_t cur = a[i+w] - a[i];
      for (size_t  j = i+1; j < i+w; ++j) {
        dp[i][i+w] = std::min(dp[i][i+w], dp[i][j] + dp[j][i+w] + cur);
      }
    }
  }

  printf("%jd\n", dp[0][n]);
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    string s;
    cin >> s;
    string ans[2] = {"First", "Second"};

    int idx = 1;
    int len = s.size();
    while (len > 2) {
        for (int i = 1; i < len - 1; i++) {
            if (s[i - 1] != s[i + 1]) {
                s.erase(i, 1);
                if (idx) {
                    idx = 0;
                } else {
                    idx = 1;
                }
                break;
            }
            if (i == len - 2) {
                cout << ans[idx] << endl;
                return 0;
            }
        }
        len--;
    }

    cout << ans[idx] << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
	int n,f=0;
	cin>>n;
	while(n){
		int x = n%10;
		if(x==7) {
			f=1;
			cout<<"Yes";
			break;
		}
		n = n/10;
	}
	if(f==0) cout<<"No";
	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
  char b;
  cin>>b;
  if(b=='T')
  {
    cout<<'A';
  }
  else if(b=='A')
  {
    cout<<'T';
  }
  else if (b=='G')
  {
    cout<<'C';
  }
  else
  {
    cout<<'G';
  }
}


Measured memory_bytes: 256
// 6/26 解き直し → 6/30
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;
const int INF = 1000000007;

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];

    vector<P> task(N);
    // rep(i, N) task[i] = P(B[i] - A[i], A[i]);  // 締め切り。
    // sort(task.begin(), task.end());

    // int time = 0;
    // bool b = true;
    // rep(i, N) {
    //     if (time <= task[i].first) {
    //         time += task[i].second;
    //     } else {
    //         b = false;
    //         break;
    //     }

    //     printf("time, task, simekiri, A = %d, %d, %d, %d\n", time, i, task[i].first, task[i].second);
    // } 

    // if (b) cout << "Yes" << endl;
    // else cout << "No" << endl;

    rep(i, N) task[i] = P(B[i], A[i]);
    sort(task.begin(), task.end(), greater<P>());
    int time = task[0].first;  // 一番最後の締め切り
    rep(i, N) {
        if (task[i].first < time) time = task[i].first;
        time -= task[i].second;
    }
    if (time < 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 6412
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const double PI  =3.141592653589793238463;
long long mod = 1000000007;
int stringToInteger(string x){
    int gg=0;
    stringstream geek(x);
    geek >> gg;
    return gg;
}

ll powmod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b>0){ if(b%2)
        {ans*=a; ans%=m;}
         b/=2; a=a*a; a=a%m;
        }
        return ans%m;
}
ll gcd(ll a,ll b)
{

    return __gcd(a,b);
}

int main()
{
    int n,m; cin>>n>>m; set<int>s;
    for(int i=0;i<m;i++) {
        int a; cin>>a;
        s.insert(a);
    }
    int dp[n+1]={0}; dp[0]=1;
    for(int i=1;i<=n;i++)
    {   if(s.find(i)!=s.end()) continue;
        
        if(i-1>=0&&s.find(i-1)==s.end())
        dp[i]=(dp[i-1])%mod;
        if(i-2>=0&&s.find(i-2)==s.end())
        dp[i]=(dp[i]+dp[i-2])%mod;
        
    }
    cout<<dp[n];
    
}








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

const int MAX=101;
const int INF=(1<<21);

int main(){
  int n,m;
  int s,g1,g2;
  int pipe[MAX][MAX];

  while(1){
    cin >> n >> m >> s >> g1 >> g2;

  if(n==0 && m==0 && s==0 && g1==0 && g2==0) break;

  for( int i=0;i<=n;i++ ) {
    for( int j=0;j<=n;j++ ) {
      pipe[i][j]=INF;
    }
    pipe[i][i]=0;
  }

  for( int i=0;i<m;i++ ) {
    int b1,b2,c; 
    cin >> b1 >> b2 >> c;
    pipe[b1][b2]=c;
  }

  for( int i=1;i<=n;i++ ) {
    for( int j=1;j<=n;j++ ) {
      for( int k=1;k<=n;k++ ) {
	pipe[j][k]=min(pipe[j][k],pipe[j][i]+pipe[i][k]);
      }
    }
  }
  int ans=INF;
  for( int i=1;i<=n;i++ ){
    ans=min(ans,pipe[s][i]+pipe[i][g1]+pipe[i][g2]);
  }
  cout << ans << endl;
  }
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
#define INF 100005
using namespace std;
typedef long long ll;
int n,k;

int check(ll x){
  int res=1;
  while(1){
    if(x<=1)return res;
    if(res>n)return INF;
    x--;
    x=x-x/k;
    res++;
  }
}

ll bynary_search(){
  ll l=0,r=(ll)(1e18)+1;
  while(l<r){
    ll m=(l+r)/2;
    if(check(m)<n)l=m+1;
    else r=m;
  }
  return max(0LL,l-1);
}

int main(){
  cin>>n>>k;
  cout<<bynary_search()<<endl;
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp(i, s, e) for (int i = (s); i < (e); i++)
#define all(x) x.begin(), x.end()

#define endl "\n"

void use_cio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[";
  for (auto x : V) os << x << ", ";
  return os << "]";
}
//--------------------------------------------------//
int n, k;
ll dp[110][100010];
ll cnt[100010];
const int MOD = 1e9 + 7;
inline ll mul(ll a, ll b) { return (a * b) % MOD; }
inline ll add(ll a, ll b) { return (a + b) % MOD; }
int main() {
  use_cio();
  cin >> n >> k;
  int sq;
  for (sq = 0; sq * sq <= n; sq++)
    ;
  sq--;
  int m = sq + n / (sq + 1);
  repp(i, 1, m + 1) dp[1][i] = 1;
  repp(i, 1, sq + 1) cnt[i] = 1;
  for (int i = m; i > sq; i--) cnt[i] = (n / (m - i + 1)) - (n / (m - i + 2));
  repp(i, 2, k + 2) {
    dp[i][m] = dp[i - 1][1];
    for (int j = m - 1; j > 0; j--)
      dp[i][j] = add(dp[i][j + 1], mul(dp[i - 1][m - j + 1], cnt[m - j + 1]));
  }
  cout << dp[k + 1][1] << endl;
}


Measured memory_bytes: 81152
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
using namespace std;

int n, k;
bool dp[2002][10001];
bool good[2002][10001];
string s[2002];

vector <int> which;
vector <int> pos;

vector <int> next_which;
vector <int> next_pos;


char getBest()
{
	char ret = 'z';
	for(int i = 0; i < which.size(); i++)
	{
		ret = min(ret, s[which[i]][pos[i]]);
	}
	return ret;
}

void updateNext(char c, int remain)
{
	next_which.clear();
	next_pos.clear();
	int firstFinish = n+1;
	int rate = which.size() / 10000;
	for(int i = 0; i < which.size(); i += (rate + 1))
		if(s[which[i]][pos[i]] == c)
		{
			if(pos[i] == s[which[i]].length()-1)
				firstFinish = min(firstFinish, which[i]);
			else
			{
				next_which.push_back(which[i]);
				next_pos.push_back(pos[i]+1);
			}
		}
	for(int i = firstFinish + 1; i <= n; i++)
		if(good[i][remain])
		{
			next_which.push_back(i);
			next_pos.push_back(0);
		}
	which = next_which;
	pos = next_pos;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	cin >> n >> k;
	for(int i = 1; i <= n; i++)
		cin >> s[i];
	memset(dp, 0, sizeof(dp));
	dp[n+1][0] = true;
	for(int i = n; i >= 1; i--)
		for(int j = 0; j <= k; j++)
		{
			if(dp[i+1][j] == true)
				dp[i][j] = true;
			if(j - (int)s[i].length() >= 0 && dp[i+1][j-(int)s[i].length()])
				dp[i][j] = true;
		}
	memset(good, false, sizeof(good));
	for(int i = 1; i <= n; i++)
		for(int j = 0; j <= k; j++)
			if(s[i].length() <= j && dp[i+1][j - (int)s[i].length()])
				good[i][j] = true;

	int remain = k;
	for(int i = 1; i <= n; i++)
		if(good[i][remain])
		{
			which.push_back(i);
			pos.push_back(0);
		}
	string ret;
	for(int i = 1; i <= k; i++)
	{
		char c = getBest();
		remain --;
		updateNext(c, remain);
		ret += c;
	}
	cout << ret << endl;
	return 0;
}


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

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

    int n;
    cin >> n;
    map<int, int> cnt;
    for (int i = 0; i < n; i++) {

        int a;
        cin >> a;
        if (cnt[a]) cnt[a]--;
        else cnt[a]++;
    }
    int ans = 0;
    for (auto& p : cnt) {
        if (p.second) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 8332
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
ll dp[3001][3001][4];
ll m[3001][3001];

void solve()
{
    int r, c, k;
    cin >> r >> c >> k;

    for(int i = 0; i<k; i++)
    {
        int x, y, z;
        cin >> x >> y >> z;
        --x; --y;
        m[x][y] = z;
    }

    dp[0][0][0] = 0;

    for(int i = 0; i<r; i++)
    {
        for(int j = 0; j<c; j++)
        {
            if(m[i][j]>0)
            {
                for(int s = 2; s>=0; s--)
                {
                    dp[i][j][s+1] = max(dp[i][j][s+1], dp[i][j][s] + m[i][j]);
                }
            }
            for(int s = 0; s<4; s++)
            {
                dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][s]);
                dp[i][j + 1][s] = max(dp[i][j + 1][s], dp[i][j][s]);
            }
        }
    }

    ll ans = 0;
    for(int i = 0; i<4; i++)
    {
        ans = max(dp[r-1][c-1][i], ans);
    }
    cout << ans << endl;
}


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


Measured memory_bytes: 355324
#include<iostream>
using namespace std;
int main()
{
  int l,c=0;
  cin>>l;
  string s;
  cin>>s;
  for(int i=0;i<l;i++)
  {
  	if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
  	c++;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

A = sorted(A)

wa = A[0]  # i - 1 までの和
cnt = 1  # i 番目の生き物の 2 倍より小さかったのに、i 番目の生き物を食べれるやつの数
for i in range(1, N):
    if 2 * wa >= A[i]:
        cnt += 1
    else:
        cnt = 1
    wa += A[i]
print(cnt)


Measured memory_bytes: 20464
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int L = A + B;
  int R = C + D;

  if (L == R) {
    cout << "Balanced" << endl;
  }
  else if(L > R){
    cout << "Left" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Peaks.
 */
public class Main {
    public static void main(String[] args) {
        var scanner = new Scanner(System.in);
        var n = Integer.parseInt(scanner.next());
        var m = Integer.parseInt(scanner.next());
        var heights = new int[n];
        for (int i = 0; i < n; i++) {
            heights[i] = Integer.parseInt(scanner.next());
        }

        var maxHeight = new int[n];
        for (int i = 0; i < m; i++) {
            var a = Integer.parseInt(scanner.next());
            var b = Integer.parseInt(scanner.next());
            maxHeight[a - 1] = Math.max(maxHeight[a - 1], heights[b - 1]);
            maxHeight[b - 1] = Math.max(maxHeight[b - 1], heights[a - 1]);
        }
        var count = 0;
        for (int i = 0; i < n; i++) {
            if (heights[i] > maxHeight[i]) {
                count++;
            }
        }
        var writer = new PrintWriter(System.out);
        writer.println(count);
        writer.flush();
    }
}


Measured memory_bytes: 59968