akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];

std::vector<int> factors;
void factorize(int n){
   for (int i = 1; i*i <= n; ++i)
   {
      if(n%i)continue;
      factors.pb(i);
      if(i != n/i){
         factors.pb(n/i);
      }
   }
   sort(factors.begin(), factors.end());
}

int32_t main(){_

   cin>>n;

   factorize(n);

   int ans = 0;
   for (int i = 0; i < sz(factors); ++i)
   {
      int vals = (n / factors[i]) - 1;
      if(vals == 0)continue;
      if (n/vals == n%vals){
         tr(vals);
         ans += vals;
      }
      // assert(n/vals == n%vals);
   }

   cout<<ans;

   return 0;
}

// Common sense: do smth instead of nothing
// Even a single second counts...
// If other's can do it, even I can do it. It wouldn't be that tough. Let me give it a try.
// Mistakes made in past
// -Ques. ask for max-min => think binary_search, DP, greedy
// -not reading question properly / skipping to read & understand all samples properly & wasting time in wrong direction.
// -Using wrong indexing in nested loops something like a[i], when it is supposed to be a[j](WA)
// -value of const int N is not correct (WA/RTE).
// -Did you memset dp to -1 ?
// -check for small edges cases and work on small test cases manually if WA
// -not deallocating memory to pointers can lead to MLE. Use delete :))
// -not reading problem statements of harder problems E,..., thinking it couldn't be solved, but it isn't the case.
// -Avoid using #define int long long as much as possible when it's dp problem and requires high memory say, O(N^2, N=5000) (MLE)
// -Check Bitwise Operator Precedence 
// -Use pragmas to optimize (by constant factor) when necessary..
// -Think before coding & starting to debug. Have patience to look inside code and actually see how it works

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	
	public static void main(String args[]) {
		
		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		double[] p = new double[n];
		
		for(int l=0;l<n;l++) {
			p[l] = in.nextDouble();
		}
		
		double[][] dp = new double[n+1][n+1];
		dp[0][0]=1;
		
		for(int i=1;i<=n;i++) {
			for(int j=0;j<=i;j++) {
				if(j==0) dp[i][j] = dp[i-1][j]*(1-p[i-1]);
				else {
					dp[i][j] = dp[i-1][j-1]*p[i-1] + dp[i-1][j]*(1-p[i-1]);
				}
			}
				
		}
//		print2d(dp);
		double ans=0;
		for(int i=(n+1)/2 ; i<=n;i++) {
			ans+=dp[n][i];
		}
		System.out.println(ans);

	}
		
	private static int ch(int j) {
		if(j==1) return 0;
		if(j==0) return 1;
		return 0;
	}

	public static void print2d(double[][] arr) {
		for(int i=0;i<arr.length;i++) {
			for(int j=0;j<arr[i].length;j++) {
				System.out.print(arr[i][j]+ " ");
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 122800
n, m = map(int, input().split())
h = list(map(int, input().split()))
l = len(h) * [1]
for _ in range(m):
  a, b = map(int, input().split())
  if h[a-1] > h[b-1]:
    l[b-1] = 0
  elif h[b-1] > h[a-1]:
    l[a-1] = 0
  else:
    l[b-1] = 0
    l[a-1] = 0    
#print(l)
#print(h)
print(sum(l))

Measured memory_bytes: 20144
// author: Saman Mahdanian
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
const int N = 2e5 + 10;

int n, m;
vector <int> g[N];
int degA[N], degB[N];
string s;
bool mark[N];
queue <int> to_do;

int32_t main() {
	cin >> n >> m >> s;
	for (int i = 0; i < m; i++) {
		int v, u;
		cin >> v >> u;
		v--; u--;
		g[v].push_back(u);
		g[u].push_back(v);
		if (s[v] == 'A')
			degA[u]++;
		else
			degB[u]++;
		if (s[u] == 'A')
			degA[v]++;
		else
			degB[v]++;
	}

	for (int v = 0; v < n; v++) {
		int all_same = true;
		for (int u: g[v])
			all_same &= s[u] == s[g[v][0]];
		if (all_same)
			to_do.push(v);
	}

	while (!to_do.empty()) {
		int v = to_do.front();
		to_do.pop();
		if (mark[v])
			continue;
		mark[v] = true;
		for (int u: g[v]) {
			if (s[v] == 'A')
				degA[u]--;
			else 
				degB[u]--;
			if (degA[u] == 0 || degB[u] == 0)
				if (!mark[u])
					to_do.push(u);
		}
	}

	for (int i = 0; i < n; i++)
		if (!mark[i]) {
			cout << "Yes" << endl;
			return 0;
		}
	cout << "No" << endl;
}
// SamMHD :: 21/11/2018 14:06:15 :: Another F****** graph...

Measured memory_bytes: 12548
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var k = int.Parse(Console.ReadLine());

        var ans = 1;
        for (int i = 0; i < n; i++)
        {
            if (ans < k)
            {
                ans *= 2;
            }
            else
            {
                ans += k;
            }
        }

        Console.WriteLine(ans);
    }
}


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

using namespace std;

int main()
{
    char a[20];
    scanf("%s",a);
    int n=strlen(a);
    int sum=0,ans=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]=='A'||a[i]=='G'||a[i]=='C'||a[i]=='T')
        {
            sum++;
            ans=max(ans,sum);
        }
        else sum=0;
    }
    printf("%d",ans);
    return 0;
}


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

void main_()
{
    ll N;
    vector<ll> as;
    cin >> N;
    copy_n(istream_iterator<ll>(cin), N, back_inserter(as));

    set<int> colors;
    ll over3200_num = 0;
    for (auto&& a : as) {
        if (a < 3200) {
            colors.insert(a / 400);
        } else {
            over3200_num++;
        }
    }

    cout << max(colors.size(), 1UL) << " " << colors.size() + over3200_num << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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; }

using namespace std;
using ll = long long;
using P = pair<int, int>;

constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

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

  int a, b; cin >> a >> b;
  int ans;
  if (b%a==0) {
    ans = a+b;
  } else {
    ans = b-a;
  }
  cout << ans << endl;
}

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


def main():
    s = input().strip()
    q = int(input().strip())

    rev_count = 0
    s_prev = ""
    s_suffix = ""
    for i in range(q):
        query = input().strip()
        if query[0] == "1":
            rev_count += 1
        else:
            _, f, c = query.split()
            if (f == "1" and rev_count % 2 == 0) or (f == "2" and rev_count % 2 == 1):
                s_prev += c
            else:
                s_suffix += c

    if rev_count % 2 == 0:
        print(s_prev[::-1] + s + s_suffix)
    else:
        print(s_suffix[::-1] + s[::-1] + s_prev)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4408
#include <bits/stdc++.h>
#define ii pair < int , int >
#define fi first
#define se second

using namespace std;
const int N=3e3+33;
int dp[N][N];
ii p[N][N];
string a,b;

int bt(int i , int j)
{
	if(i==(int)a.size()||j==(int)b.size())
		return 0;
	int &ret=dp[i][j];
	if(ret!=-1)
		return ret;
	ret=bt(i,j+1);
	p[i][j]={i,j+1};
	int x=bt(i+1,j);
	if(x>ret)
	{
		p[i][j]={i+1,j};
		ret=x;
	}
	if(a[i]==b[j])
	{
		x=bt(i+1,j+1)+1;
		if(x>ret)
		{
			p[i][j]={i+1,j+1};
			ret=x;
		}
	}
	return ret;
}


int main()
{
	memset(dp , -1,sizeof dp);
	cin>>a>>b;
	int x,y,i,j;
	x=y=0;
	bt(0,0);
	while(x!=(int)a.size()&&y!=(int)b.size())
	{
		i=x;
		j=y;
		x=p[i][j].fi;
		y=p[i][j].se;
		if(x>i&&y>j)
			cout<<a[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 108416
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
ll N, C;
ll x[100010];
ll v[100010];

ll sfd[100010], sbd[100010];
ll td;

/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>N>>C;
    REP(i,0,N){
        cin>>x[i+1]>>v[i+1];
    }

    //出発点からのiまでの最大得点
    td = 0LL;
    REP(i,1,N+1){
        td += v[i];
        sfd[i] = max({sfd[i-1], sfd[i], td-x[i]});
    }

    td = 0LL;
    REP(i,1,N+1){
        ll ii = N - i + 1;
        td += v[ii];
        sbd[i] = max({sbd[i-1], sbd[i], td-(C-x[ii])});
    }

    //時計回り開始
    ll ans = 0;
    td = 0LL;
    REP(start,0,N+1){
        if(start > 0) td += v[start];

        ll sum1 = td ;
        if(start > 0) sum1 -= x[start];
        if(start < N){
            ll rmx1 = sbd[N-start] - x[start];  //TODO: startで止まるとは限らない!!!（"先に計算した最適なインデックス < start" の場合がある）=> 固定する側で事前計算の値は使えない.
            if(rmx1 > 0){
                sum1 += rmx1;
            }
        }

        ans = max(ans, sum1);
    }

    //反時計回り開始
    td = 0LL;
    REP(start,0,N+1){
        ll s = N-start+1;
        if(start > 0) td += v[s];

        ll sum2 = td;
        if(start > 0) sum2 -= (C-x[s]);
        if(start < N){
            ll rmx2 = sfd[N-start] - (C - x[s]);
            if(rmx2 > 0){
                sum2 += rmx2;
            }
        }

        ans = max(ans, sum2);
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3456
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <limits>
#include <iomanip>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

ll GCD(ll a, ll b) { if(b==0) return a; else return GCD(b, a%b); }
ll LCM(ll a, ll b) { return a/GCD(a,b)*b; }

class AABC333 {
public:
	void solve(std::istream& in, std::ostream& out) {
        int a,b;in>>a>>b;
        out<<((a%2==0 || b%2==0) ? "No" : "Yes")<<endl;
	}
};


int main() {
	AABC333 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

const ll INF = LLONG_MAX;
const ll MOD = 1e9+7;

struct StringQuery {
    string orgS;
    string beforeS;
    string afterS;
    bool mode;
    StringQuery (string s) {
        mode = true;
        orgS = s;
        beforeS = "";
        afterS = "";
    }
    void chageMode() {mode = !mode;};
    void add (string c, bool f) {
        if ((mode && !f) || (!mode && f)) beforeS = c + beforeS;
        else afterS = afterS + c;
    }
    string output() {
        orgS = beforeS + orgS + afterS;
        if (mode) return orgS;
        else {
            reverse(orgS.begin(), orgS.end());
            return orgS;
        }
    }
};

int main() {
    // input, ready
    string S;
    int Q;
    cin >> S >> Q;

    // resolve
    StringQuery sq(S);
    for (int i=0; i<Q; i++) {
        int query;
        cin >> query;
        if (query == 1) sq.chageMode();
        else {
            int query2;
            string c;
            cin >> query2 >> c;
            sq.add(c, query2-1);
        }
    }

    // output
    cout << sq.output() << endl;

    return 0;
}


Measured memory_bytes: 1692
sx, sy, tx, ty = map(int, input().split())

yu = "U" * (ty - sy)
xr = "R" * (tx - sx)
yd = "D" * (ty - sy)
xl = "L" * (tx - sx)

print(yu + xr + yd + xl + "L" + yu + "U" + xr + "R" + "D" + "R" + yd + "D" + xl + "L" + "U")


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    // 整数の入力
  int N, K;
  cin >> N;
  vector<int> arange(N);
  int count=0;
  for(int i = 0; i<N; i++){
    int a;
    cin >> a;
    arange[a-1] = i+1;
  }
  for(int i=0; i<N; i++){
	  cout << arange[i] << " ";
  }
    
  return 0;
}

Measured memory_bytes: 1152
#include<cstdio>
#include<cstring>
//#include<Hatsune_Miku>
long long h[50]={2};
int n;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
    	h[i]=h[i-1]*2+2;
    }
    printf("%lld\n",h[n]);
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n= ii()
res=n
for i in range(n+1):
    cc=0
    t=i
    while t>0:
        cc+=t%6
        t//=6
    t=n-i
    while t>0:
        cc+=t%9
        t//=9
    if res>cc:
        res=cc
print(res)


Measured memory_bytes: 66408
X = int(input())
A = 0
while True:
    if A**5 -(A-1)**5 > X:
        break
    A += 1
B = A
while True:
    Y = A ** 5 - B ** 5
    if Y == X:
        break
    elif Y < X:
        B -= 1
    elif Y > X:
        A -= 1
        B = A
print(A, B)


Measured memory_bytes: 9180
N=int(input())
a = list(map(int,input().split()))
# N = 10**5
# a = [i for i in range(N)]

result = True
for i in range(1,N)[::-1]:
    if a[i-1]<=a[i]:
        pass
    elif a[i-1]-1==a[i]:
        a[i-1] -= 1
    else:
        result = False
        break

print("Yes" if result else "No")


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

typedef long long ll;

int n,m;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	int ans = max(n+m,n-m);
	ans = max(ans,n*m);
	cout << ans << endl;
	return 0;
}

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using ll = long long;
using ull = unsigned long long;


int main(void)
{
    IOS
    constexpr int M = 2019;
    int l,r;
    cin >> l >> r;

    int ans = 0;
    if (r - l >= M) {
        ans = 0;
    } else {
        int lm = l % M;
        int rm = r % M;
        if (lm >= rm) {
            ans = 0;
        } else {
            ans = M;
            FOR(i,lm,rm) {
                FOR(j,lm+1,rm+1) {
                    int tmp = i * j % M;
                    //cerr << tmp << endl;
                    if (ans > tmp) ans = tmp;
                }
            }
        }
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import math
import heapq
import sys
from collections import Counter
import datetime
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

#N,K=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
#x=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
#s = [input() for i in range(3)]

x=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき

A=x[0]
B=x[1]
K=x[2]

if A+B-K<=0:
    print('0 0')
elif A-K<=0:
    print('0 {0}'.format(B-(K-A)))
else:
    print('{0} {1}'.format(A-K,B))

Measured memory_bytes: 5252
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9;
const ll MOD = 1000000007;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  int N;
  cin >> N;
  vector<P> D(N);
  vector<ll> X(N), Y(N);
  ll ans = 0;
  REP(i, N) {
    ll x, y;
    cin >> x >> y;
    D[i].first = x - y, D[i].second = x + y;
    X[i] = x - y, Y[i] = x + y;
  }
  /*ll _D = D.size() - 1;
  sort(D.begin(), D.end());
  ans = chmax(ans,
              max(abs(D[_D].first - D[0].first), (D[_D].second - D[0].second)));
  REP(i, _D + 1) swap(D[i].first, D[i].second);
  sort(D.begin(), D.end());
  ans = chmax(ans,
              max(abs(D[_D].first - D[0].first), (D[_D].second -
  D[0].second)));*/
  sort(X.begin(), X.end());
  sort(Y.begin(), Y.end());
  ans = max(Y[Y.size() - 1] - Y[0], X[X.size() - 1] - X[0]);
  cout << ans << endl;
}

Measured memory_bytes: 9512
#!python3.4.3

import math

h = int(input())
if h > 1:
    x = math.floor(h/2)
    n = 2
    count = n
    while x > 1:
        x = math.floor(x/2)
        n = n*2
        count += n
        
    print(count+1)
else:
    print(1)


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

int main()
{

    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;

    vector<int> l(Q), r(Q);
    for (int i = 0; i < Q; ++i){
        cin >> l[i] >> r[i];
    }

    vector<int> sum(N + 1, 0);

    for (int i = 1; i < N;++i){
        if(S[i-1] == 'A' and S[i] == 'C'){
            sum[i + 1] = sum[i] + 1;
        }
        else
            sum[i + 1] = sum[i];
    }

    for (int i = 0; i < Q; i++){
        int ans = sum[r[i]] - sum[l[i]];
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 2176
N, X, T = map(int, input().split())
count = 1
check = X
if X > 1:
    while True:
        value = int(N / X)
        re = N % X
        if re == 0:
            count = value
            TotalTime = T * count
            break
        else:
            count += value
            TotalTime = T * count
            break
else:
    TotalTime = T * N
print(TotalTime)


Measured memory_bytes: 9152
//Zory-2018
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
#include<stack>
using namespace std;

namespace mine
{
	const int MAX_N=310000;
	typedef long long ll;
	int mymin(int x,int y) {return x<y?x:y;}
	int myabs(int x) {return x>0?x:-x;}

	int a[MAX_N],b[MAX_N];
	bool check(int l,int r)
	{
		int left=0,right=0;
		for(int i=l;i<=r;i++)
		{
			if(a[i]<l or a[i]>r) return 0;
			if(a[i]<i)//left
			{
				if(left>a[i]) return 0;
				left=a[i];
			}
			else if(a[i]>i)
			{
				if(right>a[i]) return 0;
				right=a[i];
			}
		}
		return 1;
	}
	#define GG {puts("No");return;}
	void main()
	{
		int n;scanf("%d",&n);
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&a[i]);
//			if((a[i]-i)%2) GG//奇偶性
			b[i]=(a[i]==i);
			if(i>=3 and !b[i-2] and !b[i-1] and !b[i]) GG//连续三个动点
		}

		for(int l=1;l<=n;l++) if(b[l]==0)//动点
		{
			int now=1;//交替
			int r=l;while(r+1<=n and b[r+1]==now) now^=1,r++;
			if(!check(l,r)) GG
			l=r;
		}
		puts("Yes");
	}
};

int main()
{
	mine::main();
}

Measured memory_bytes: 2560
/*
 * 2364.cc: Lucky Dip
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_W = 1000;
const int MAX_H = 1000;

const int INF = 1 << 30;

const int dxs[] = {1, 0, -1, 0}, dys[] = {0, -1, 0, 1};

/* typedef */

struct Stat {
  int d, x, y;
  Stat() {}
  Stat(int _d, int _x, int _y): d(_d), x(_x), y(_y) {}
  bool operator<(const Stat &s) const { return d > s.d; }
};

/* global variables */

int flds[MAX_H][MAX_W], dists[MAX_H][MAX_W];

/* subroutines */

/* main */

int main() {
  int w, h;
  cin >> w >> h;

  int gx, gy;

  for (int y = 0; y < h; y++) {
    string s;
    cin >> s;
    for (int x = 0; x < w; x++) {
      switch(s[x]) {
      case '.': flds[y][x] = 0; break;
      case '#': flds[y][x] = INF; break;
      case 't': flds[y][x] = 0; gx = x; gy = y; break;
      }
      dists[y][x] = INF;
    }
  }

  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    if (flds[y][x]) flds[y][x] = i;
  }

  dists[0][0] = 0;

  priority_queue<Stat> q;
  q.push(Stat(0, 0, 0));

  while (! q.empty()) {
    Stat u = q.top(); q.pop();
    if (dists[u.y][u.x] != u.d) continue;
    if (u.x == gx && u.y == gy) break;

    for (int di = 0; di < 4; di++) {
      int vx = u.x + dxs[di], vy = u.y + dys[di];
      if (vx >= 0 && vx < w && vy >= 0 && vy < h && flds[vy][vx] < INF) {
	int vd = max(u.d, flds[vy][vx]);
	if (dists[vy][vx] > vd) {
	  dists[vy][vx] = vd;
	  q.push(Stat(vd, vx, vy));
	}
      }
    }
  }

  printf("%d\n", (dists[gy][gx] < INF) ? dists[gy][gx] : -1);
  return 0;
}

Measured memory_bytes: 16112
import java.util.Scanner;
import java.util.ArrayList;
public class Main {
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
      	int a = scanner.nextInt();
        String arare[] = new String[a];
		for(int x = 0;x<a;x++) {
			arare[x] = scanner.next();
        }
        int n = 0;
        boolean i = false;
        String str = "Y";
        for(n = 0;n < a;n++){
         	if(str.equals(arare[n]))i = true;
        }
      
        if(i){
            System.out.println("Four");
        }else{
          System.out.println("Three");
        }
    }
}

Measured memory_bytes: 21844
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int n;
int main()
{
  cin>>n;
  int a[10002],ans=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    while(a[i]%2==0){
      ans++;
      a[i]/=2;
    }
  }
  cout<<ans;
  return 0;
}

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

int main() {
  string str;
  int max = 0;
  int cnt = 0;
  cin >> str;
  
  for(int i = 0; i < str.size(); i++){
    if(str.at(i) == 'A' || str.at(i) == 'C' || str.at(i) == 'G' || str.at(i) == 'T'){
      cnt++;
    }else{
      if(max < cnt) max = cnt;
      cnt = 0;
    }
  }
  if(max < cnt) max = cnt;
  
  cout << max;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000007;

int main() {

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

	Int N;
	cin >> N;

	vector<vector<Int>> F(N, vector<Int>(10, 0));
	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j < 10; j++) {
			cin >> F[i][j];
		}
	}

	vector<vector<Int>> P(N, vector<Int>(11, 0));
	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j < 11; j++) {
			cin >> P[i][j];
		}
	}

	Int ans = -INF;
	Int temp;
	Int count;
	for (Int bit = 1; bit < (1LL<<10); bit++) {
		temp = 0;
		for (Int i = 0; i < N; i++) {
			count = 0;
			for (Int j = 0; j < 10; j++) {
				if ((bit >> j & 1) && F[i][j]) {
					count++;
				}
			}
			temp += P[i][count];
		}
		ans = max(ans, temp);
	}

	cout << ans << endl;
}

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

int n, m;
int a[1000];

int main() {
	int i, j;
	
	cin >> n >> m;
	for (i = 0; i < n; i++) cin >> a[i];
	
	int ans = 0;
	for (i = 0; ; i++) {
		int maxi = -84101;
		int mini =  84101;
		for (j = (i * m) % n; j != (i * m + m) % n; j = (j + 1) % n) {
			maxi = max(maxi, a[j]);
			mini = min(mini, a[j]);
		}
		ans += maxi - mini;
		if (j == 0) break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3044
# B
import math

N = int(input())
A_list = list(map(int, input().split()))

A_dict = dict()
for a in A_list:
    if a in A_dict.keys():
        A_dict[a] += 1
    else:
        A_dict[a] = 1

res = 0
A_list_ = list(reversed(sorted(A_list)))
for a in A_list_:
    # partner
    r = 2**math.ceil(math.log2(a))
    if a == r:
        res += A_dict[a] // 2
        A_dict[a] = 0
    else:
        b = r - a
        if A_dict[a] > 0 and A_dict.get(b, 0) > 0:
            A_dict[a] -= 1
            A_dict[b] -= 1
            res += 1
print(res)

Measured memory_bytes: 33040
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#define reg(i,x) for(int i=last[x];i;i=e[i].next)
using namespace std;
inline ll read(){
    ll f=1,x=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//******head by yjjr******
int n,a,b;
void wri(int a,int b,int v){
    if(a==b){printf("%d ",a);return;}
    int x=(a^b)&(-(a^b));
    v^=x;
    int y=v&(-v);
    wri(a,a^y,v);
    wri(a^y^x,b,v);
}
int main(){
    n=read(),a=read(),b=read();
    if(__builtin_popcount(a^b)&1)puts("YES"),wri(a,b,(1<<n)-1);
    else puts("NO");
    return 0;
}

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

using namespace std;

int main(void)
{
	string str;
	int num = 0;
	int count;
	int start = -1;
	bool flag = false;

	cin>>str;

	count = str.size();
	for(int i = 0;i < count;i++)
	{
		if(str[i] == 'C')
		{
			start = i;
			break;
		}		
	}

	if(start != -1)
		for(int j = start+1;j < count;j++)
			if(str[j] == 'F') {
				flag = true;
				break;
			}

	if(flag == true)
		cout<<"Yes"<<endl;

	else
		cout<<"No"<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll POW3(ll x,ll n,ll m){
  x%=m;
  if(n==0)return 1;
  if(n%2==0)return POW3(x*x,n/2,m)%m;
  return x*POW3(x,n-1,m)%m;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}

ll lcm(ll u, ll v) {
  return u*v/gcd(u,v);
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)//xのm進数でのx^nの位の値
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)//xのn進数での桁数
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)//x!のnで割り切れる回数
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)//xのnで割り切れる回数
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

ll SGS(ll x,ll y, ll m)//1+x+…+x^(y-1)をmで割った余り
{
  if(y==0)return 0;
  if(y%2==0){
    return (1+POW3(x,y/2,m))*SGS(x,y/2,m)%m;
  }
  return (1+x*SGS(x,y-1,m))%m;
}

ll SSGS(ll x,ll y,ll m)//Σ[k=1→y](1+x+…+x^(k-1))をmで割った余り
{
  if(y==0)return 0;
  if(y==1)return 1;
  if(y%2==0){
    return (SSGS(x,y/2,m)*(POW3(x,y/2,m)+1)%m+SGS(x,y/2,m)*y/2%m)%m;
  }
  return (SSGS(x,y-1,m)*x%m+y)%m;
}

int main()
{
  ll n,x,l[200],c=0,m=0;
  cin >> n >> x;
  rep(i,n)cin >> l[i];
  rep(i,n){
    m+=l[i];
    if(m>x)break;
    c++;
  }
  printf("%lld",c+1);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ll long long

int main(){
  int n,m;
  scanf("%d%d",&n,&m);
  int ans=0;
  int a[n];
  int sum=0;
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    sum+=a[i];}
  double sikii = sum*1.0/4/m;
  for(int i=0;i<n;i++){
    if(sikii<=a[i]) ans++;}

  if(ans>=m) printf("Yes\n");
  else printf("No\n");



  return 0;
}


Measured memory_bytes: 128
n, k, q = map(int, input().split())

score = [0] * n

for _ in range(q):
    a = int(input())
    score[a-1] +=1
    
s = sum(score)
for i in range(n):
    if k - (s-score[i]) <= 0:
        print("No")
    else :
        print("Yes")

Measured memory_bytes: 4680
const input = require('fs').readFileSync('/dev/stdin', 'utf8');

const nenn = Number(input.split('').slice(0, 4).join(''));

const month = Number(input.split('').slice(5, 7).join(''));

const hi = Number(input.split('').slice(8, 10).join(''));

if (nenn < 2019) {
  console.log('Heisei');
} else if(month < 5) {
  console.log('Heisei');
} else {
  console.log('TBD');
}

Measured memory_bytes: 21956
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, a[110];
	cin >> n;
	for(int i=1; i<=n; i++)
		cin >> a[i];
	for(int i=n; i>1; i--)
		cout << a[i] << " ";
	cout << a[1] << endl;
	return 0;
}


Measured memory_bytes: 3112
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

static const int MOD = 1e9 + 7;

int main() {

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

    for (int i = 0; i < S.size(); i++) {
        int x = int(S[i] - 'A' + N) % 26;
        cout << char('A' + x);
    }
}

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

using namespace std;

int main(){
	int w, n, p = 1;
	while(cin >> w, w){
		cin >> n;
		vector<pair<int, int> > t(n);
		for(int i=0; i< n; i++) scanf("%d,%d", &t[i].first, &t[i].second);
		long long dp[1010][1010];
		for(int i=0; i < 1010; i++) for(int j=0; j< 1010; j++) dp[i][j] = 0;
		for(int i=n-1; 0 <= i; i--){
			for(int j=0; j <= w; j++){
				if(j < t[i].second) dp[i][j] = dp[i+1][j];
				else dp[i][j] = max(dp[i+1][j], dp[i+1][j-t[i].second] + t[i].first);
			}
		}
		cout << "Case " << p++ << ":" << endl;
		cout << dp[0][w] << endl;
		for(int i = w; ; i--){
			if(dp[0][i] != dp[0][w]){cout << i+1 << endl; break;}
		}
	}
}

Measured memory_bytes: 9224
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <cctype>
#include <fstream>
#include <cstring>

using namespace std;

#define ll long long
#define MOD 1000000007
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define du(x) cout<<#x<<'='<<x<<endl
#define du2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define du3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());

int V;
vector<int>G[100009]; // グラフの隣接リスト表現
vector<int> rG[100009];//辺の向きを逆にしたグラフ
vector<int> vs;//帰りがけ順の並び
bool used[100009];//既に調べたか
int cmp[100009];//属する強連結成分のトポロジカル順序

void add_edge(int from, int to) {
    G[from].push_back(to);
    rG[to].push_back(from);
}

void dfs(int v) {
    used[v] = true;
    rep(i, G[v].size()) {
        if (!used[G[v][i]])dfs(G[v][i]);
    }
    vs.push_back(v);
}

void rdfs(int v, int k) {
    used[v] = true;
    cmp[v] = k;
    rep(i, rG[v].size()) {
        if (!used[rG[v][i]])rdfs(rG[v][i], k);
    }
}

int scc() {
    memset(used, 0, sizeof(used));
    vs.clear();
    rep(v, V) {
        if (!used[v])dfs(v);
    }
    memset(used, 0, sizeof(used));
    int k = 0;
    for (int i = vs.size() - 1; i >= 0; i--) {
        if (!used[vs[i]]) rdfs(vs[i], k++);
    }
    return k;
}
//頂点数Vを再定義しないように

int main() {
    int E;
    cin >> V >> E;
    rep(i, E) {
        int s, t;
        cin >> s >> t;
        add_edge(s, t);
    }

    scc();

    int Q;
    cin >> Q;
    rep(i, Q) {
        int u, v;
        cin >> u >> v;
        printf("%d\n", (cmp[u] == cmp[v]) ? 1 : 0);
    }
}


Measured memory_bytes: 9308
//
// Created by Harshit on 20-08-2020.
//

#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    string st1,st2,res;
    res="";
    cin>>st1>>st2;
    n=st1.size();
    m=st2.size();
    vector <vector <int> > dp(n+1,vector <int> (m+1,0));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(st1[i-1]==st2[j-1])
                dp[i][j]=1+dp[i-1][j-1];
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    int i=n,j=m;
    while(i>0 && j>0){
        if(st1[i-1]==st2[j-1]){
            res=res+st1[i-1];
            i--;
            j--;
        }
        else{
            if(dp[i-1][j]>dp[i][j-1]){
                i--;
            }
            else
                j--;
        }
    }
    reverse(res.begin(),res.end());
    cout<<res<<endl;
}

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


int main(){
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    if ((x1*y1)>(x2*y2)){
        cout<<x1*y1<<endl;
    } else {
        cout<<x2*y2<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int main(int argc, char *argv[]) {
    int d, n;
    scanf("%d%d", &d, &n);
    if (d == 0) {
        if (n < 100) {
            printf("%d\n", n);
        }
        else {
        	printf("101\n");
        }
    }
    else if (d == 1) {
        if (n < 100) {
            printf("%d00\n", n);
        }
        else {
        	printf("10100\n");
        }
    }
    else {
    	if (n < 100) {
    	    printf("%d0000\n", n);
    	}
    	else {
    		printf("1010000\n"); 
    	}
    }
    return 0;
}

Measured memory_bytes: 128
/***from dust i have come, dust i will be***/

#include<bits/stdc++.h>

typedef long long int ll;
typedef unsigned long long int ull;

#define dbg printf("in\n")
#define nl printf("\n");
#define N 210101
#define inf 1e9

#define sf(n) scanf("%d", &n)
#define sff(n,m) scanf("%d%d",&n,&m)
#define sfl(n) scanf("%I64d", &n)
#define sffl(n,m) scanf("%I64d%I64d",&n,&m)

#define pf(n) printf("%d",n)
#define pff(n,m) printf("%d %d",n,m)
#define pffl(n,m) printf("%I64d %I64d",n,m)
#define pfl(n) printf("%I64d",n)
#define pfs(s) printf("%s",s)

#define pb push_back
#define pp pair<int, int>

using namespace std;

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

    int i, j, k;
    int n, m, t;
    ll a, b, K;

    cin >> a >> b >> K;

    ll x = min(a, K);

    a -= x;
    K -= x;

    x = min(b, K);
    b -= x;

    cout << a << " " << b;

    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int lim = 1e6;
    vector<char> prime(lim + 1, true);
    prime[0] = prime[1] = false;
    for(int i = 2; i <= lim; i++){
        if(prime[i]){
            for(int j = i + i; j <= lim; j += i){
                prime[j] = false;
            }
        }
    }
    vector<int> accs(lim + 1);
    for(int i = 1; i <= lim; i++){
        accs[i] = accs[i - 1] + (i & 1 && prime[i] && prime[(i + 1) / 2]);
    }
    int q; cin >> q;
    for(int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        cout << accs[r] - accs[l - 1] << '\n';
    }
}


Measured memory_bytes: 5504
type ABC(stream:System.IO.TextReader) =
  member this.Scan1 f = stream.ReadLine() |> f
  member this.Scan2 f1 f2 = stream.ReadLine().Split() |> (fun a -> (f1 a.[0], f2 a.[1]))
  member this.Scan3 f1 f2 f3 = stream.ReadLine().Split() |> (fun a -> (f1 a.[0], f2 a.[1], f3 a.[2]))
  member this.Scan4 f1 f2 f3 f4 = stream.ReadLine().Split() |> (fun a -> (f1 a.[0], f2 a.[1], f3 a.[2], f4 a.[3]))
  member this.ScanVecH f = stream.ReadLine().Split() |> Array.map f
  member this.ScanVecV n f = [| for i in 1..n -> stream.ReadLine() |> f |]
  member this.ScanMatrix n f  = [ for i in 1..n do yield stream.ReadLine().Split() |> Array.map f ]
  member this.ScanCharMatrix n = [ for i in 1..n -> stream.ReadLine().ToCharArray() ]
  member this.Close () = stream.Close()

let util = ABC(stdin)

let N,M = util.Scan2 int int
let As = util.ScanVecV M int |> set

let mutable x1 = 1
let mutable x2 = if Set.contains 1 As then 0 else 1
for n in 2..N do
  if Set.contains n As
  then
    x1 <- x2
    x2 <- 0
  else 
    let x = (x1 + x2) % 1000000007
    x1 <- x2
    x2 <- x

printfn "%d" x2

Measured memory_bytes: 22096
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl

#define pb emplace_back
#define fi first
#define se second
     
using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ ll x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

int n, l;

int a[100010];

int main(){

  n = in();
  l = in();
  REP( i , n ){
    a[i] = in();
  }

  int p = -1;
  REP( i , n-1 ){
    if( a[i] + a[i+1] >= l ){
      p = i;
      break;
    }
  }

  if( p == -1 ){
    puts( "Impossible" );
    return 0;
  }

  puts( "Possible" );
  REP( i , p ){
    printf( "%d\n" , i+1 );
  }
  for( int i = n-2; i > p; i-- ){
    printf( "%d\n" , i+1 );
  }
  printf( "%d\n" , p+1 );
  
  return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // 値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)  // 直後の要素をパディング
#define space_pad(num) setfill(' ') << std::right << setw(num)  // 直後の要素をパディング


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

    // input
    int N;
    cin >> N;
    vector<int> vec(N);
    REP(i, N) cin >> vec.at(i);
    
    int res = INT_MAX, tmp, tmp_count;
    bool flag = false;
    REP(i, N) {
        tmp = vec.at(i);
        tmp_count = 0;
        if (tmp%2 == 0) {
            while (tmp%2 == 0) {
                tmp /= 2;
                tmp_count++;
            }
            res = min(res, tmp_count);
        } else {
            flag = true;
            break;
        }
    }
    
    if (flag) {
        cout << 0 << "\n";
    } else {
        cout << res << "\n";
    }
    
    
    
    return 0;
}


Measured memory_bytes: 256
eval"N,K,*A="+`dd`.split*?,
t=[];N.times{|i|s=0;A[i,N].map{|x|t<<s+=x}}
40.times{|i|u=t.select{|x|x[39-i]>0};u.size<K||t=u}
p t.reduce:&

Measured memory_bytes: 13184
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var abcd = ReadInts();
            var left = abcd[0] + abcd[1];
            var right = abcd[2] + abcd[3];
            if (left == right)
            {
                WriteLine("Balanced");
            }
            else if (left > right)
            {
                WriteLine("Left");
            }
            else
            {
                WriteLine("Right");
            }
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
r, c = gets.split(" ").map(&:to_i)
hyou = Array.new(r){
  arr = gets.split(" ").map(&:to_i)
  arr << arr.inject(&:+)
}
arr = []
(c + 1).times do |i|
  arr << hyou.inject(0){|sum, item|
    sum + item[i]
  }
  end
hyou.each{|item|puts item.join(" ")}
puts arr.join(" ")


Measured memory_bytes: 7064
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <queue>

using namespace std;

long long A[100000];

int main()
{
    int N, i;
    long long P, c;

    scanf("%d", &N);
    for(i = 0; i < N; ++i)
        scanf("%lld", &A[i]);
    sort(A, A + N);

    if(A[0] == 0)
        printf("0");
    else{
        P = 1;
        for(i = 0; i < N; ++i){
            c = 1000000000000000000LL / P;
            if(A[i] > c){
                P = -1;
                break;
            }
            else
                P *= A[i];
        }
        printf("%lld", P);
    }

    return 0;
}


Measured memory_bytes: 2460
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 1e9 + 7;

ll n;
ll a[3005], dp[3005][3005];

ll fn(ll i, ll j)
{
	if(dp[i][j] != -1)
		return dp[i][j];
	if(i == j)
		return a[i];
	if(i+1 == j)
		return max(a[i], a[j]);
	ll x1 = a[i] + min(fn(i+2, j), fn(i+1, j-1));
	ll x2 = a[j] + min(fn(i+1, j-1), fn(i, j-2));
	dp[i][j] = max(x1, x2);
	return dp[i][j];
}

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

	cin >> n;
	ll s = 0;
	for(ll i=0; i<n; i++)
	{
		cin >> a[i];
		s += a[i];
	}
	memset(dp, -1, sizeof dp);
	ll y =  s - fn(0, n-1);
	cout << fn(0, n-1) - y << "\n";

	return 0;
}

Measured memory_bytes: 70912
H,W,M=map(int,input().split())
h=[0]*(H+1)
w=[0]*(W+1)
hw=[0]*M
for i in range(M):
  y,x=map(int,input().split())
  hw[i]=(y,x)
  h[y]+=1
  w[x]+=1
cnt=0
mxh=max(h)
mxw=max(w)
for hi,wi in hw:
  if h[hi]==mxh and w[wi]==mxw:
    cnt+=1
if h.count(mxh)*w.count(mxw)==cnt:
  print(mxh+mxw-1)
else:
  print(mxh+mxw)

Measured memory_bytes: 53952
package main

import "fmt"

func gcd(a, b int) int {
	if b > a {
		a, b = b, a
	}
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	L := make([]int, n+1)
	L[0] = 0
	for i := 0; i < n; i++ {
		L[i+1] = gcd(L[i], a[i])
	}
	R := make([]int, n+1)
	R[n] = 0
	for i := n; i > 0; i-- {
		R[i-1] = gcd(R[i], a[i-1])
	}
	ans := 1
	for i := 0; i < n; i++ {
		ans = max(ans, gcd(L[i], R[i+1]))
	}
	fmt.Println(ans)
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}


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

using namespace std;
#define taskname "A"
#define pb	push_back
#define mp 	make_pair

typedef long double ld;
typedef long long ll;
typedef pair<int,int> ii;
const int maxn = 2e5 + 5;

int n , q;
int update[maxn];
int val[maxn];

vector<int> adj[maxn];

void dfs(int u , int par){
    for(int c : adj[u]){
        if(par != c){
            update[c] += update[u];
            dfs(c , u);
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    cin >> n >> q;
    for(int i = 1 ; i < n ; ++i){
        int u , v;cin >> u >> v;
        adj[u].pb(v);adj[v].pb(u);
    }
    for(int i = 1 ; i <= q ; ++i){
        int x , u;cin >> u >> x;
        update[u] += x;
    }
    dfs(1 , 0);
    for(int i = 1 ; i <= n ; ++i)cout << update[i] << " ";
}


Measured memory_bytes: 24320