akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>  
using namespace std;  
// Important header files   
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
#include <iostream>  
using namespace __gnu_pbds;  
using namespace std;  
  
// Declaring ordered_set 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update>  
    ordered_set; 
#define rep(i,n) for(li i=0;i<n;i++)
#define li long long int
#define ll long long int
#define pb push_back
#define all(v) sort(v.begin(),v.end())
const int N = 40043;
const ll mod = 1e9 + 7;
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f first
#define s2 second
const ll INF=(1LL<<60)-1;


li gcd(li a,li b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
li lcm(li a,li b)
{
    return (a*b)/gcd(a,b);
}
li power(li a,li b)
{
    li res=1;
    while(b)
    {
        if(b&1)
        res=(res*a);
        a=((a)*(a));
        b>>=1;
    }
    return res;
}
 
li xx,yy,dd;
void equation(li a,li b)
{
    if(b==0)
    {
        xx=1;
        yy=0;
        dd=a;
    }
    else
    {
        equation(b,a%b);
        li temp=xx;
        xx=yy;
        yy=temp-(a/b)*yy;
    }
}
li inverse(li a,li m)
{
    equation(a,m);
    return(xx%m+m)%m;
}
bool compare(const pair<li,li> &i, pair<li,li> &j)
{
    if(i.f==j.f)
    return i.s2 > j.s2;
    else
    return i.f<j.f;
    
}

void solve()
{
  int n;
  cin>>n;
  map<li,li>mp;
  li val=0,ans=0;
  while(1)
  {
      val=val*10+7;
      val%=n;
      if(val==0)
      {
          cout<<ans+1;
          return;
      }
      if(mp[val]==1)
      break;
      mp[val]=1;
      ans++;
  }
  cout<<-1;
}
signed main()
{
   //seive();
   //cout<<prime.size();
   FAST_IO;
   int t;
   t=1;
   while(t--)
   {
       solve();
       
   }
}

Measured memory_bytes: 66096
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> sai1(n);
  	vector<int> sai2(n);
    for (int i = 0; i < n; i++) {
      cin >> sai1.at(i);
      cin >> sai2.at(i);
    }
  	int count = 0;
      for(int i = 0;i < n;i++) {
        if (sai1.at(i) == sai2.at(i)) {
          count++;
          if (count >= 3 ) {
            cout << "Yes" << endl;
      		return 0;
          }
        } else {
          count = 0;
        }
      }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
N,Q = map(int, input().split())
S = input()

cnt = 0
SS = [0]
for i in range(N-1):
    if S[i:i+2] == 'AC':
        cnt += 1
    SS.append(cnt)

for i in range(Q):
    l,r = map(int,input().split())

    ans = SS[r-1] - SS[l-1]
    print(ans)


Measured memory_bytes: 6104
S = input()
N = len(S)

ans = 0
for i in range(2 ** (N - 1)):
    tmp = 0
    prev = 0
    for j in range(N - 1):
        if i & (1 << j):
            tmp += int(S[prev : j + 1])
            prev = j + 1
    tmp += int(S[prev:])
    ans += tmp

print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long int
#define ff first
#define ss second
#define S size()
#define mod (ll)(1000000009)
#define mset(a,k) memset(a,k,sizeof(a));
#define fr(i, x, y) for ( ll i = x; i < y;i++)
#define dr(i, x, y) for ( ll i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define pqueue priority_queue<ll>
#define piqueue priority_queue<ll,vll ,greater<ll>>
#define mapcl map<char,ll>
#define mapll map<ll,ll>
#define mapsl map<string,ll>
#define vi vector<ll>
#define vs vector<string>
#define vb vector<bool>
#define psi pair<string,ll>
#define pii pair<ll,ll>
#define piii pair<ll,pii>
#define vii vector<pii>
#define vvi vector<vi>
using namespace std;
void fast() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}
//----------------------------------------FUNCTIONS-------------------------------------
ll gcd(ll x, ll y )						{if (y == 0) return x; return gcd(y, x % y);}
ll lcm(ll a, ll b)						{return (a * b) / gcd(a, b);}
ll logx(ll base, ll num)				{int cnt = 0; while (num != 1) {num /= base; ++cnt;} return cnt;}
vi vin(ll n)							{vi a(n); fr(i, 0, n) cin >> a[i]; return a;}
void in(ll *a, ll n)        			{for (ll i = 0; i < n; i++)cin >> a[i];}
void out(ll *a, ll n)					{fr(i, 0, n) {cout << a[i] << " ";} cout << '\n';}
void vout(vi v)							{fr(i, 0, (ll)v.S) {cout << v[i] << " ";} cout << endl;}
//----------------------------------------START-------------------------------------------
const ll maxN = (ll)(1 * 1e5 + 5 );


void solve()
{
	ll a, b, c, k;
	cin >> a >> b >> c;
	cin >> k;

	while (b <= a && k)
	{
		b *= 2;
		k--;
	}
	while (c <= b && k)
	{
		c *= 2;
		k--;
	}
//cout << k << '\n';
//cout << a << " " << b << " " << c << '\n';
	if (a < b && b < c)cout << "Yes\n";
	else cout << "No\n";

}
int main()
{
	fast();
#ifndef ONLINE_JUDGE
	freopen ("inp1.txt", "r", stdin);
	freopen ("out1.txt", "w", stdout);
#endif
	ll t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}



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

int main() {
    string s, t;
    cin >> s >> t;
    string ans = "Yes";
    if(t.substr(0,s.size()) != s) ans = "No";
    cout << ans <<endl;

}

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

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  ll d = c - a - b;
  if (d <= 0) {
    cout << "No" << endl;
    return 0;
  } 
  ll dd = d * d, ab = 4 * a * b;
  if (ab < dd) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{

  int x,y,r,a;

  scanf("%d %d",&x,&y);

  if(x < y){
    a = x;
    x = y;
    y = a; 
  }

  while((r = x % y) > 0){
      x = y;
      y = r;
    }

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

    return 0;
  }

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,m;
  while(cin>>n>>m,n||m){
    int s[n],d[m];
    for(int i=0;i<n;i++) cin>>s[i];
    for(int i=0;i<m;i++) cin>>d[i];
    int wa[1<<n],dp[1<<n],inf=1LL<<55LL;
    fill_n(dp,1<<n,inf);
    wa[0]=dp[0]=0;
    for(int i=0;i<(1<<n);i++){
      for(int j=0;j<n;j++){
	if((i>>j)&1) continue;
	wa[i+(1<<j)]=wa[i]+s[j];
	int tmp=0;
	for(int k=0;k<m;k++){
	  if(wa[i]<=d[k]&&d[k]<=wa[i+(1<<j)])
	    tmp+=min(d[k]-wa[i],wa[i+(1<<j)]-d[k]);
	}
	dp[i+(1<<j)]=min(dp[i+(1<<j)],dp[i]+tmp);
      }
    }
    int ans=dp[(1<<n)-1];
    for(int i=0;i<m;i++){
      if(d[i]>=wa[(1<<n)-1])
	ans+=d[i]-wa[(1<<n)-1];
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

int main(){
	int N, i;
	scanf("%d", &N);
	vector<int> H(N);
	for(i = 0; i < N; i++){
		scanf("%d", &H[i]);
	}
	int ans = 0, now = 0;
	for(i = 0; i < N; i++){
		if(i == 0 || H[i] > H[i - 1]){
			now = 0;
		}
		else{
			now++;
		}
		ans = max(ans, now);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<map>  
#include<set>
#include<iterator>
#include<list>
#include<utility>
#include<cstdlib>
#include<queue>
#include<stack>
#include<bitset>
//#include<bits/stdc++.h>
#define PI  2*acos(0.0)
#define pb push_back

       
using namespace std;
using ll = long long;
using lli = long long int;
using ld = long double;



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

ll n;

cin>>n;

if(n%2==0 || n%5==0) cout<<"-1"<<endl;
else
{
	ll sum = 0;
	ll ans;
    for (ans = 1; ans <= n; ans++) {
      sum = (sum * 10 + 7) % n;
      if (sum == 0) break;
    }
    cout << ans << endl;
		
}

	
	
	return 0;
	
	
	       /***Israil Hosen
	            Computer Science & Engineering
	         University Of Rajshahi.
	         ***/
	
	
	
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define rep2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define sz size()
#define pb push_back
#define bg begin()
#define ed end()
#define fi first()
#define se second()
using namespace std;
using ll = long long;
using vint = vector<int>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template <typename T>
T sq(T x) {
  return x * x;
}
ll mod = 1e9 + 7;
ll gcd(ll a, ll b) {
  if (a % b == 0) {
    return b;
  } else {
    return gcd(b, a % b);
  }
}
// cでもc++でも
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

signed main() {
  ll n;
  cin >> n;
  vector<ll> t(n);
  ll ans = 0;
  rep(i, n) {
    cin >> t.at(i);
    if (i == 0) {
      ans = t.at(0);
    } else {
      ans = lcm(ans, t.at(i));
    }
  }
  cout << ans << endl;

  return 0;
}



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

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);   cout.tie(nullptr);
    if (ifstream("test.inp"))
    {
        freopen("test.inp", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            freopen("test.out", "w", stdout);
        #endif //CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }

    int n;  cin >> n;
    int vmin = LLONG_MAX, vmax = LLONG_MIN;
    for (int i = 1; i <= n; ++i)
    {
        int x;  cin >> x;
        vmin = min(vmin, x);
        vmax = max(vmax, x);
    }
    cout << vmax - vmin;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<vector>
#define ll long long
#define maxn 201
#define inf 2147483647
#define mod 10
#define eps 1e-6
#define pi acos(-1.0)
#define de(x) ((x)*(x))
using namespace std;
inline int read(){
	int x=0,f=1; char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
	return x*f;
}
int main(){
    int n,t,x,y;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d%d%d",&t,&x,&y);
        if(x+y>t)//不用绕，使出吃奶的劲儿都到不了
            return printf("No\n"),0;
        if((x+y)%2==0&&t%2==1)//如果最优路径与时间的积偶不一，一定到不了
    		return printf("No\n"),0;
        if((x+y)%2==1&&t%2==0)//同理
	        return printf("No\n"),0;
    }
    printf("Yes\n");//因为如果No就都return 0了，所以剩下一定是Yes。
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()

	n := readInt()
	m := readInt()
	x := make([]int, m)
	for i := range x {
		x[i] = readInt()
	}
	if m <= n {
		println(0)
		return
	}

	sort.Ints(x)
	y := make([]int, m-1)
	for i := range y {
		y[i] = x[i+1] - x[i]
	}

	sort.Ints(y)
	var ans int64
	for i := 0; i+n < m; i++ {
		ans += int64(y[i])
	}

	println(ans)

}

// -----------------------------------------------------------------------------


Measured memory_bytes: 2944
n = int(input())
stack = list(map(int,input().split()))
cnt = 1000
p = stack[0]
g = stack[0]
f = 0
for i in range(len(stack)):
    if stack[i] > g:
        g = stack[i]
        f = 1
        continue

    if stack[i] < g:
        itp = cnt // p
        cnt = cnt - (itp * p)
        cnt = cnt + (itp * g)
        p = stack[i]
        g = stack[i]
        f = 0

itp = cnt // p
cnt = cnt - (itp * p)
cnt = cnt + (itp * g)
print(cnt)

Measured memory_bytes: 9216
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    rep(i,n)v[i]--;
    
    static vector<vector<int>> r(m,vector<int>(n+1,0));
    vector<int> num(20,0);
    rep(i,v.size()){
        num[v[i]]++;
        r[v[i]][i+1] = 1;
    }
    rep(i,m){
        rep(j,n){
            r[i][j+1] += r[i][j];
        }
    }
    
    static int dp[1<<20];
    static int len[1<<20];
    rep(i,1<<20)dp[i] = INF;
    rep(i,1<<20)len[i] = INF;
    dp[0] = 0;
    len[0] = 0;
    
    rep(bit,1<<m){
        rep(piv,m){
            if( (bit&(1<<piv))==0 ){
                int left = len[bit], right = left + num[piv];
                
                int add = num[piv] - (r[piv][right] - r[piv][left]);
                
                dp[bit|(1<<piv)] = min(dp[bit|(1<<piv)], dp[bit] + add);
                len[bit|(1<<piv)] = len[bit] + num[piv];
            }
        }
    }
    cout<<dp[(1<<m)-1]<<endl;
}



Measured memory_bytes: 19232
#include<stdio.h>

int main(){

	int A,B,C;
	int Flag = 0;

	scanf("%d %d %d",&A,&B,&C);

	for(int i=1; i<100; i++){
		if( (A*(100+i)) % B == C ){
			printf("YES");
			Flag = 1;
			break;
		}else{
			/*何もしない*/
		}
	}
	
	if(Flag == 0){
		printf("NO");
	}

	return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <cstdint>

using namespace std;

int main() {
    int base[3];
    for (int i = 0; i < 3; ++i) {
        scanf("%d", &base[i]);
    }

    int b_array[base[1]];
    for (int j = 0; j < base[1]; ++j) {
        scanf("%d", &b_array[j]);
    }

    int ans = 0;
    for (int k = 0; k < base[0]; ++k) {
        int sum = 0;

        int a_array[base[1]];
        for (int j = 0; j < base[1]; ++j) {
            scanf("%d", &a_array[j]);
        }

        for (int i = 0; i < base[1]; ++i) {
            sum += a_array[i] * b_array[i];
        }
        sum += base[2];
        if (sum > 0) {
            ans++;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

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

  int X,Y,Z;
  cin >> X >> Y >> Z;
  cout << Z << " "  << X << " " << Y << endl;

  return 0;
}

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, m;
    cin >> n >> m;
    vector<P> shops(n);
    rep(i,n) {
        cin >> shops[i].first >> shops[i].second;
    }
    sort(shops.begin(), shops.end());
    int cnt = 0;
    int shop_no = 0;
    int64_t ans = 0;
    while (cnt < m) {
        ans += (int64_t)shops[shop_no].first * min(shops[shop_no].second, m - cnt);
        cnt += min(shops[shop_no].second, m - cnt);
        shop_no++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

s = STR()
if s == 'ABC':
    print('ARC')
else:
    print('ABC')

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, m, x;
	cin>>n>>m>>x;
	int a[n][m], c[n];
	for(int i = 0; i < n; i++){
		cin>>c[i];
		for(int j = 0; j < m; j++){
			cin>>a[i][j];
		}
	}
	int ans = -1;
	for(int mask = 0; mask < (1<<n); mask++){
		vector<int> kn(m, 0);
		int cost = 0;
		for(int i = 0; i < n; i++){
			if(mask&(1<<i)){
				for(int j = 0; j < m; j++){
					kn[j] += a[i][j];
				}
				cost += c[i];
			}
		}
		sort(kn.begin(), kn.end());
		if(kn[0] >= x && (ans == -1 || ans > cost))ans = cost;
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3680
#include <cstdio>

int main()
{
  int n,k;
  scanf("%d%d",&n,&k);
  if(k<=(n+1)/2){
    int s=(n+1)/2;
    for(int i=0;i<s;i++){
      printf("%d %d %d\n",k+i,k+2*n-s+i,k+2*n+2*i);
    }
    for(int i=0;i<n-s;i++){
      printf("%d %d %d\n",k+s+i,k+n+i,k+2*n+2*i+1);
    }
  }
  else{
    puts("-1");
  }
  return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
const int dx[] = { -1 , -1 , -1 , 0 , 0 , 0 , 1 , 1 , 1 };
const int dy[] = { -1 , 0 , 1 , -1 , 0 , 1 , -1 , 0 , 1 };
#define NN 8010000
#define TC int t;cin>>t;for(int T=1;T<=t;T++)
#define mod 1000000007
#define PI acos(-1)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define mem(a,n) memset(a,n,sizeof(a))
void AIA() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
//cout<<fixed<<setprecision(20);
// freopen("stand.in","r",stdin);
// freopen("stand.out","w",stdout);
bool isprime(ll n) {
	for (ll i = 2; i * i <= n; i++) {
		if (n % i == 0)return 0;
	}
	return (n!=1);
}
ll gcd(ll x, ll y)
{
	return (y == 0 ? x : gcd(y, x % y));
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll rem(int x, int N){
	return (x % N + N) % N;
}

int main()
{
	//cout<<fixed<<setprecision(20);
	//freopen("Input.txt.txt", "r", stdin);
	//freopen("Output.txt.txt", "w", stdout);
	AIA();
	int n, c = 0;
	cin>>n;
	for(int a=1;a <= n;a++){
		c += (n / a);
		if(n % a == 0)c--;
	}
	cout<<c;
	return 0;
}

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

int main(){
    long N, M;
    long a[100002];
    long long ans[100002];
    const long long mod = 1000000007;

    cin >> N >> M;
    for(long i=0;i<=N;i++) a[i] = 1;
    for(long i=0;i<M;i++){
        long a_idx;
        cin >> a_idx;
        a[a_idx] = 0;
    }

    ans[0] = 1;
    ans[1] = (a[1] == 1);
    for(long i=2;i<=N;i++){
        if(a[i]){
            if(a[i-1]){
                if(a[i-2]){
                    ans[i] = (ans[i-2] + ans[i-1]) % mod;
                }
                else{
                    ans[i] = ans[i-1];
                }
            }
            else{
                if(a[i-2]){
                    ans[i] = ans[i-2];
                }
                else{
                    cout << 0 << endl;
                    return 0;
                }
            }
        }
        else{
            if(!a[i-1]){
                cout << 0 << endl;
                return 0;
            }
            else{
                a[i] = 0;
            }
        }
    }
    cout << ans[N] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	int a,b;
	cin >> a >> b;
	if(a == 0 && b == 0) break;
	int ans[3] = {0};
	int m = b-a;
	ans[2] = m / 1000;
	m %= 1000;
	ans[1] = m / 500;
	m %= 500;
	ans[0] = m / 100;
	m %= 500;
	printf("%d %d %d\n",ans[0],ans[1],ans[2]);
    }
    return 0;
}

Measured memory_bytes: 1144
#include <stdio.h>

int h,w,x,y,z;
char masu[100][100];

int main(){



    scanf ( " %d %d " , &h , &w );

    for ( x = 1 ; x < h ; x++ ) scanf ( " %s " , &masu[x] );


    for ( x = 1 ; x <= h ; x++ ) {
        for ( y = 1 ; y <= w ; y++ ) {
            if ( masu[x][y] != '#' ) masu[x][y] = 0;
        }
    }


    for ( x = 1 ; x <= h ; x++ ) {
        for ( y = 1 ; y <= w ; y++ ) {
            if ( masu[x][y] == '#' ){
                if( masu[x-1][y] == 0 && masu[x][y-1] == 0 && masu[x+1][y] == 0 && masu[x][y+1] == 0 ) {
                    printf("No\n");
                    return 0;
                }
            }
        }
    }


    printf("Yes\n");



    return 0;
}


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

const long double PI = acos(-1);
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main(){
    int n;
    cin >> n;
    int pret = 0, prex = 0, prey = 0;
    bool no = false;
    for(int i = 0; i < n; i++){
        int t, x, y;
        cin >> t >> x >> y;
        if(t - pret < abs(x - prex + y - prey)){
            no = true;
        }else if((t - pret) % 2 != (abs(x - prex) + abs(y - prey)) % 2){
            no = true;
        }

        pret = t, prex = x, prey = y;
    }

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

Measured memory_bytes: 256
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let s = a.iter().fold(0, |acc, ai| acc ^ ai);
    let ans: Vec<_> = a.into_iter().map(|ai| (s ^ ai).to_string()).collect();
    println!("{}", ans.join(" "));
}


Measured memory_bytes: 17760
import sys
sys.setrecursionlimit(10 ** 5 + 10)


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


def resolve():

    n, m, x = map(int, input().split())
    l = [list(map(int, input().split())) for _ in range(n)]

    ans = 10**10

    for i in range(2 ** n):
        skill = [0]*m
        cost = 0
        for j in range(n):  # このループが一番のポイント
            if ((i >> j) & 1):
                cost += l[j][0]
                for k in range(m):
                    skill[k] += l[j][k+1]
        if all(skill[i] >= x for i in range(m)):
            ans = min(ans, cost)

    print(ans if ans != 10**10 else -1)


resolve()

Measured memory_bytes: 74440
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000001;
const int MAX_N = 100000;
const int MAX_S = 317;
int n, s, j, skip, nextskip, lis, idx, nextidx;
int a[MAX_N], sz[MAX_S * 2], top[MAX_S * 2], p[MAX_S], nextp[MAX_S];
// vector<int> a, sz, top, p, nextp;

int PatienceSorting(int nexti){
    int r = -1;
    int l = -1;
    if(p[0] == -1) r = 0;
    for(int i = 0; i < 2 * s; i++){
        top[i] = INF;
        sz[i] = 0;
    }
    for(int i = 0; i < n; i++){
        // filtering out irrelevant elements
        if(i < skip) continue;
        // else if(r + 1 < p.size() && a[i] == p[r + 1]){
        else if(r + 1 < idx && a[i] == p[r + 1]){
            r++;
            continue;
        }else if(r == -1 || a[i] < p[r] || (l >= j && a[i] > top[j])) continue;
        // push a[i] to the appropriate pile
        int h;
        if(l == -1 || a[i] > top[l]){
            l++;
            h = l;
        }else{
            h = lower_bound(top, top + MAX_S * 2, a[i]) - top;
            // h = lower_bound(top.begin(), top.end(), a[i]) - top.begin();
        }
        top[h] = a[i];
        sz[h]++;
        if(h == nexti){
            if(nextskip == -1) nextskip = i;
            nextp[nextidx++] = a[i];
            // nextp.push_back(a[i]);
        }
    }
    return l;
}

int main(){
    cin >> n;
    s = MAX_S;
    // s = sqrt(n);
    j = 2 * s - 1;
    // a.resize(n); sz.resize(2 * s); top.resize(2 * s);
    for(int i = 0; i < n; i++) cin >> a[i];
    // p.push_back(-1);
    p[0] = -1;
    idx = 1;
    while(1){
        int l = PatienceSorting(-1);
        if(l < 2 * s - 1){
            lis += l + 1;
            break;
        }
        int nexti = -1;
        for(int i = 2 * s - 1; i >= s; i--){
            if(sz[i] <= s && sz[i] > 0){
                nexti = i;
                break;
            }
        }
        // nextp.clear();
        nextskip = -1;
        nextidx = 0;
        PatienceSorting(nexti);
        // p = nextp;
        idx = nextidx;
        swap(p, nextp);
        skip = nextskip;
        lis += nexti + 1;
    }
    cout << lis << endl;
}


Measured memory_bytes: 3488
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>

using namespace std;

typedef long long ll;

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

  int n = s.size();

  ll l = 0;
  while (l < n && s[l] == '>') l++;
  ll r = 0;
  while (n - 1 - r >= 0 && s[n - 1 - r] == '<') r++;

  ll result = 0;
  result += l * (l + 1) / 2;
  result += r * (r + 1) / 2;

  //cerr << "l, r = " << l << " " << r << endl;

  for (int i = 0; i < n - 1; ++i) {
    if (s[i] == '<' && s[i + 1] == '>') {
      int j = i;
      while (j - 1 >= 0 && s[j - 1] == '<') j--;
      l = i - j + 1;

      j = i + 1;
      while (j + 1 < n && s[j + 1] == '>') j++;
      r = j - (i + 1) + 1;

      //cerr << "l, r = " << l << " " << r << endl;

      if (l < r) swap(l, r);
      result += l * (l + 1) / 2 + r * (r - 1) / 2;
    }
  }

  cout << result << endl;

  return 0;
}


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

int main() {
  int x, y;

  cin >> x >> y;

  if (y <= x * 4 && y >= x * 2 && y % 2 == 0) {
    cout << "Yes";
  } else {
    cout << "No";
  }

  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
const int MOD = 1e9 + 7;

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int k, x;
	cin >> k >> x;

	cout << (k * 500 >= x ? "Yes" : "No") << endl;
}
	

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int k;
 
int gcd(int a, int b){
    if(b == 0) return a;
 
    return gcd(b, a%b);
}
 
int main(){

    int n;
    cin >> n;
    vector<int> b(n-1);
    int ans=0;
    rep(i, n-1) cin >> b[i];

    for(int i= 0;i < n-2;i++){
        ans += min(b[i],b[i+1]);
    }
    ans += b[0];
    ans += b[n-2];

    cout << ans;

    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        int m = in.nextInt();
        int r = 1;
        for (int i = 0; i < m; i++) {
            r *= 2;
        }
        int y = (n - m) * 100;
        y += m * 1900;
        y *= r;
        out.print(y);
        out.close();
    }
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin >> n >> k;
    int *arr = new int[n]();
    for(int i=0;i<n;i++) cin >> arr[i];
    ll *dp = new ll[n]();
    for(int i=0;i<n;i++)
    {
        ll mn = mod;
        for(int j=((i-k > 0)?(i-k):0);j<i;j++)
        {
            mn = min(mn,abs(arr[i]-arr[j])+dp[j]);
            //cout << mn << " ";
        }
        //cout<<endl;
        dp[i] = (mn==mod)?0:mn;
    }
    //for(int i=0;i<n;i++) cout << dp[i] <<" ";
    cout<<dp[n-1];
    return 0;
}

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

int main() {
  int x1, y1, x2, y2;
  scanf("%d%d%d%d", &x1, &y1, &x2, &y2);

  int dx = x2 - x1;
  int dy = y2 - y1;

  int x3 = x2 - dy;
  int y3 = y2 + dx;
  int x4 = x3 - dx;
  int y4 = y3 - dy;
  printf("%d %d %d %d", x3, y3, x4, y4);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int x,n,r;
bool f[102];
int main()
{ cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin>>x>>n;
  for(int i=1;i<=n;i++)
  { int a;
    cin>>a;
    f[a]=1;
  }
  int st=x,dr=x;
  while(f[st] && f[dr])
  { if(st>0)
       st--;
    if(dr<101)
       dr++;
  }
  if(!f[st])
     cout<<st<<'\n';
  else if(!f[dr])
    cout<<dr<<'\n';
  return 0;
}


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

namespace WelcomeAtcordet
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int W = int.Parse(input[0]);
            int H = int.Parse(input[1]);
            int N = int.Parse(input[2]);
            string[,] white = new string[W, H];

            for (int i = 1; i <= N; i++)
            {
                string[] input2 = Console.ReadLine().Split(' ');
                int x = int.Parse(input2[0]);
                int y = int.Parse(input2[1]);
                int a = int.Parse(input2[2]);
                if (a == 1)
                {
                    for(int j = 0; j < x; j++)
                    {
                        for(int k = 0;k< H; k++)
                        {
                            white[j,k] = "black";
                        }
                    }
                }
                else if (a == 2)
                {
                    for (int j = x; j < W; j++)
                    {
                        for (int k = 0; k < H; k++)
                        {
                            white[j, k] = "black";
                        }
                    }
                }
                else if (a == 3)
                {
                    for (int j = 0; j < y; j++)
                    {
                        for (int k = 0; k < W; k++)
                        {
                            white[k, j] = "black";
                        }
                    }
                }
                else
                {
                    for (int j = y; j < H; j++)
                    {
                        for (int k = 0; k < W; k++)
                        {
                            white[k, j] = "black";
                        }
                    }
                }
            }

            int ans = 0;

            foreach(string s in white)
            {
                if (string.IsNullOrEmpty(s))
                {
                    ans++;
                }
            }

            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 13140
N, K = list(map(int, input().split()))
S = input()

if S[0] =='0':
  pre = '0'
  memo = {'0': [1], '1':[0]}
else:
  pre = '1'
  memo = {'0': [], '1':[1]}

for s in S[1:]:
  if s==pre:
    memo[s][-1] +=1
  else:
    pre = s
    memo[s].append(1)

if S[-1] =='0':
  memo['1'].append(0)
    
if len(memo['0'])<=K:
  print(len(S))
  exit()

window_sum = sum(memo['0'][:K] + memo['1'][:K+1])
answer = window_sum
for i in range(0, len(memo['0'])-K):
  window_sum = window_sum -memo['0'][i] - memo['1'][i] + memo['0'][i+K] + memo['1'][i+K+1]
  answer = max(answer, window_sum)

print(answer)

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

int main()
{
    bool primes[50000]={false};
    primes[0] = true;
    for(int i=2;i <= 25000;++i) {
        if (primes[i-1]) continue;
        for(int j=i+i;j <= 50000;j+=i) {
            primes[j-1] = true;
        }
    }

    int n;
    while (cin >> n && n) {
        int cnt = 0;
        for(int i=2; i <= n/2;++i) {
            if (!primes[i-1] && !primes[n-i-1]) {
                ++cnt;
            }
        }
        cout << cnt << endl;
    }

    return 0;
}

Measured memory_bytes: 1216
n=int(input())
a=list(map(int,input().split()))
ans=[]
sum=sum(a)
ct=0
for i in range(n):
  if i%2==0:
    ct+=a[i]
ans.append(ct*2-sum)
for i in range(n-1):
  ans.append(2*a[i]-ans[i])
for i in range(n):
  ans[i]=str(ans[i])
print(' '.join(ans))

Measured memory_bytes: 17352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int[] seqS = new int[n];
      String[] line = br.readLine().split(" ");
      for (int i=0; i<n; i++)
        seqS[i] = Integer.parseInt(line[i]);

      int q = Integer.parseInt(br.readLine());
      String[] lines = br.readLine().split(" ");
      
      int cnt=0;
      for (String ref : lines) {
        if( isExistSeachByBinary(seqS, Integer.parseInt(ref)) )
          cnt++;
      }

      System.out.println(cnt);
    }
  }

  static boolean isExistSeachByBinary(int[] tar, int ref) {
    int left = 0;
    int right= tar.length;
    int mid;
    while( left < right ) {
      mid  = (left + right) / 2;
      if( tar[mid] > ref ) right = mid;
      else if(tar[mid] < ref ) left = mid + 1;
      else return true;
    }

    return false;
  }
}


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

using namespace std;

#define Rep(i,a,b)  for (int i=(a);i<(b);i++)
#define rep(i,n)    for (int i=0;i<(n);i++)
#define all(x)      (x).begin(), (x).end()

#define ll long long

int main()
{
	ll k, a, b;

	cin >> k >> a >> b;

	ll ans = k + 1;
	ll u = k - (a - 1);
	if (u >= 0)
		ans = max(ans, a + u % 2 + u / 2 * (b - a));

	cout << ans << endl;
}



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

int main()
{
	char input[10];
	char stringArray [3][10] = { "Sunny", "Cloudy", "Rainy" };

	scanf("%s", &input);
	if (strcmp(input, stringArray[0]) == 0)
	{
		printf("%s \n", stringArray[1]);
	}
	else if (strcmp(input, stringArray[1]) == 0)
	{
		printf("%s \n", stringArray[2]);
	}
	else if ((strcmp(input, stringArray[2]) == 0))
	{
		printf("%s \n", stringArray[0]);
	}

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int N = 201000;
int f[N][2],s[N],d[N],sw[N],val[N],n,ans;
char c[N];
vector<int> e[N];
void dfs(int x,int dad){
	s[x]=1;sw[x]=c[x]=='W';
	for(int v:e[x]) if(v!=dad){
		dfs(v,x);
		s[x]+=s[v];
		sw[x]+=sw[v];
		if(sw[v]) d[x]++,d[v]++;
	}
}
void dp(int x,int dad){
	for(int v:e[x]) if(v!=dad){
		dp(v,x);
		if(f[v][0]>f[x][0]) f[x][1]=f[x][0],f[x][0]=f[v][0];
		else if(f[v][0]>f[x][1]) f[x][1]=f[v][0];
	}
	f[x][1]+=val[x];f[x][0]+=val[x];
	ans=max(ans,f[x][1]+f[x][0]-val[x]);
}
int main(){
	read(n);
	for(int i=1;i<n;i++){
		int x,y;read(x);read(y);
		e[x].push_back(y);
		e[y].push_back(x);
	}
	cin>>c+1;
	int x=0;
	for(int i=1;i<=n;i++)
		if(c[i]=='W') x=i;
	if(!x){puts("0");return 0;}
	dfs(x,0);
	if(sw[x]==1){puts("1");return 0;}
	int sum=0;
	for(int i=1;i<=n;i++){
		if(!sw[i]) continue;
		sum+=d[i];
		if(d[i]+(c[i]=='W')&1){
			sum++;val[i]=2;
		}
	}
	dp(x,0);
	cout<<sum-ans<<'\n';
	return 0;
}


Measured memory_bytes: 18432
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<stdio.h>
#include<vector>
#include<map>
using namespace std;

int a, b;
int ans;

int main() {
	cin >> a >> b;
	if (a < b) {
		swap(a, b);
	}
	ans += a;
	a -= 1;
	if (a < b) {
		swap(a, b);
	}
	ans += a;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	string a;
	cin >> a;
	int n = SZ(a);
	stack<char> S;
	for (int i = 0; i < n; i++) {
		if (a[i] == 'S')
			S.push(a[i]);
		else {
			if (S.empty() || S.top() == 'T')
				S.push(a[i]);
			else
				S.pop();
		}
	}
	cout << SZ(S) << endl;
	return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

using ll=long long;

int main() {
  int A,B; cin >>A >>B;
  cout <<A*B <<endl;
  return 0;
}


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

using namespace std;


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

	vector<double> A(n, 0);

	for(int i = 0;i<n;i++)
		cin>>A[i];

	vector<vector<double>> dp(n+1, vector<double> (n+1, 0.0));
	dp[0][0] = 1.0;
	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.0 - A[i-1]);
			}
			else
				dp[i][j] = dp[i-1][j] * (1.0 - A[i-1]) + dp[i-1][j-1] * A[i-1];
		}
	}

	double ans = 0.0;
	for(int i = (n+1)/2;i<=n;i++)
	{
		ans += dp[n][i];
	}

	cout<<setprecision(12)<<ans<<endl;
}

Measured memory_bytes: 70784
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int n, i;
    long long int *R;
    long long int max, min;

    scanf("%d", &n);

    R = malloc(n * sizeof(long long int));
    for (i = 0; i < n; i++) scanf("%lld", &R[i]);

    min = R[0];
    max = R[1] - R[0];

    for (i = 1; i < n; i++){
        max = max > R[i] - min ? max : R[i] - min;
        min = min < R[i] ? min : R[i];
    }

    printf("%lld\n", max);

    return (0);
}


Measured memory_bytes: 3324
package main

import "fmt"

func main() {
	var D, N int
	fmt.Scan(&D, &N)
	b := 1
	for i := 0; i < D; i++ {
		b *= 100
	}
	if N == 100 {
		fmt.Println(101 * b)
	} else {
		fmt.Println(N * b)
	}
}


Measured memory_bytes: 1768
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = 1234567;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	int n;
	cin>>n;
	double ans = 0;
	rep(i,n){
		double a;
		cin>>a;
		ans += 1/a;
	}
	cout<<1/ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
// -----------------<fast IO>------------------
#define IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FLSH             fflush(stdout)
#define fileIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);
#define PRECISION(x)     cout << fixed << setprecision(x);
// -----------------<TypeDef Start>------------------
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
// -----------------<Constants>------------------
const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI=acos(-1);

const int INF=1e9;

int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
/*ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}*/
// --------------------------------------------------</TEMPLATE>--------------------------------------------------

void solve()
{
    ll n;
    cin>>n;
    vector<pair<pair<ll,ll>,ll> >v;
    for(ll i=0;i<n;i++)
    {
        ll a,b,c;
        cin>>a>>b>>c;
        v.push_back({{a,b},c});
    }
    ll dp[n][3];
    dp[0][0]=v[0].first.first;
    dp[0][1]=v[0].first.second;
    dp[0][2]=v[0].second;
    for(ll i=1;i<n;i++)
    {
        dp[i][0]=v[i].first.first+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=v[i].first.second+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=v[i].second+max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
}

int main()
{
    IOS
    ll t=1;
   // cin>>t;
    while(t--)
    {
        solve();
    }
    return(0);
}


Measured memory_bytes: 7804
/*input
999999 999999
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}




const int N = 5e6+1;
int fact[N];

void solve(){
  	int x,y;cin >> x >> y;
  	int one = 2*y-x;
  	int two = 2*x-y;
  	if(one < 0 or two < 0){
  		cout << 0;
  		return;
  	}
  	if(one%3 or two%3){
  		cout << 0;
  		return;
  	}
  	one /= 3;
  	two /= 3;
  	fact[0] = 1;
  	RE(i,N-1){
  		fact[i] = fact[i-1]*i;
  		fact[i] %= MOD;
  	}
  	int gg = fact[one+two];
  	int wp = fact[one];
  	wp *= fact[two];
  	wp %= MOD;
  	wp = raise(wp,MOD-2,MOD);
  	gg *= wp;
  	gg %= MOD;
  	cout << gg;
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 39296
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
using namespace std;

inline int gcdt(int a, int b, int c){
  int d = gcd<uint32_t, uint32_t>(a, b);
  int e = gcd<uint32_t, uint32_t>(c, d);
  return e;
}

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long a, b=0;
  cin >> a;
  
  for(int i=1; i<=a; i++){
      for(int j=1; j<=a; j++){
          for(int k=1; k<=a; k++){
              b += gcdt(i, j, k);
          }
      }
  }

  cout << b << endl;
  
  return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
const ll mod=998244353;
ll n,ri,le,s0,f[1000005];
struct node{
	int x,y;
	bool operator<(node b)const{
		return x-y>b.x-b.y;
	}
}a[1000005];
char s[1000005];
int main(){
	n=read();
	for(int i=1;i<=n;i++){
		ll l=0,r=0;
		scanf("%s",s+1);
		for(int j=1;s[j];j++)
			if(s[j]=='(')l++;
			else{
				if(l)l--;
				else r++;
			}
		if(!l and r)ri+=r;
		else if(l and !r)le+=l;
		else a[i]=(node){l,r};	
		s0+=l-r;
	}
	if(s0!=0)return puts("No"),0;
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++){
		if(le<a[i].y)
			return puts("No"),0;
		le-=a[i].y-a[i].x;
	}
	if(le!=ri)puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 11332