akhauriyash/Code-Regression huggingface dataset:
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint mo=1000000007;
lint na[100100],nc[100100],nq[100100];
lint zyo[100100];
int main()
{
	zyo[0]=1;rep(i,100010) zyo[i+1]=(zyo[i]*3)%mo;
	string s;cin>>s;
	int n=s.size();
	na[0]=nc[0]=nq[0]=0;
	rep(i,n){
		na[i+1]=na[i];nc[i+1]=nc[i];nq[i+1]=nq[i];
		if(s[i]=='A') na[i+1]++;
		if(s[i]=='C') nc[i+1]++;
		if(s[i]=='?') nq[i+1]++;
	}
	lint out=0;
	rep(i,n){
		if(s[i]!='B' && s[i]!='?') continue;
		lint la=na[i],rc=nc[n]-nc[i+1],lq=nq[i],rq=nq[n]-nq[i+1];
		//cout<<la<<' '<<rc<<' '<<lq<<' '<<rq<<endl;
		out+=((la*rc)%mo)*zyo[lq+rq];out%=mo;
		if(lq>0){
			out+=((lq*rc)%mo)*zyo[lq+rq-1];out%=mo;
		}
		if(rq>0){
			out+=((la*rq)%mo)*zyo[lq+rq-1];out%=mo;
		}
		if(lq>0 && rq>0){
			out+=((lq*rq)%mo)*zyo[lq+rq-2];out%=mo;
		}
		//cout<<out<<endl;
	}
	cout<<out%mo<<endl;
}


Measured memory_bytes: 3584
#include <stdio.h>

#define N 1000000

int A[N];
 
int Partition(int p, int r){
  int x, i, j, tmp;
  x = A[r];
  i = p-1;
  for(j = p; j < r; j++){
    if(A[j] <= x){
      i++;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  tmp = A[i+1];
  A[i+1] = A[r];
  A[r] = tmp;
  return i+1;
}
 
 int main(){
  int n, i, x;
  scanf("%d", &n);
  for(i = 1; i <= n; i++){
    scanf("%d", &A[i]);
  }
  x = Partition(1, n);
 for(i = 1; i <= n; i++){
  if(i == x){
    printf("[%d]",A[i]);
  }
  else
  {
    printf("%d",A[i]);
  }
  if(i < n)
  {
    printf(" ");
  }
 }
  printf("\n");
  return 0;
}

Measured memory_bytes: 992
// author:  Harsh Nema
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 10000000000000;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;

ll modexp(ll x, ll y, ll p)
{
  ll res = 1;
  x = x % p;
  while (y > 0)
  {
      if (y & 1)
          res = (res * x) % p;
      y = y >> 1;
      x = (x * x) % p;
  }
  return res;
}
//
ll mulmod(ll a, ll b)
{
    ll res = 0;
    a = a % mod;
    while (b > 0)
    {
        if (b % 2 == 1)
            res = (res + a) % mod;
        a = (a * 2) % mod;
        b /= 2;
    }
    return res % mod;
}

// ll sub_mod(ll a, ll b, ll m)
//{
//    if (a >= b)
//        return a - b;
//    else
//        return m - b + a;
//}

 ll add_mod(ll a, ll b)
{
    if (0 == b)
        return a;
    b = mod - b;
    if (a >= b)
        return a - b;
    else
        return mod - b + a;
}

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

// ll modInv(ll a)
// {
//     ll g = gcd(a, mod);
//     if (g != 1)
//         return -1;
//     else
//         return modexp(a, mod-2, mod);
// }
// ll lcm(ll a, ll b)
// {
//     return (a*b)/gcd(a,b);
// }

int main()
{
    fastio;
   ll n=0,k=0;
   cin>>n>>k;
    ll ans=0;
    ll i=k;
    while(i<=n+1){
        ll p=(i*(n-i+1)+1)%mod;
        ans=add_mod(ans,p);
        ++i;
    }
    cout<<ans;

    return 0;
}


Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;

//dp[i][j]はiからjまでを合体させる最小コスト
vector<vector<ll>> dp(410, vector<ll>(410,INF));

vector<ll> a(410,0);

ll ans(ll x,ll y){
    if(dp[x][y]!=INF)return dp[x][y];
    if(x==y)return dp[x][y]=0;
    ll k=INF;
    ll sum=0;
    for(ll i=x;i<=y;i++){
        sum+=a[i]
    ;}
    for(ll i=x;i<=y-1;i++){
        k=min(k,ans(x,i)+ans(i+1,y)+sum);
    ;}
    return dp[x][y]=k;
}


int main(){
    ll N;
    cin >> N;
    for(ll i=0;i<N;i++){
        cin>>a[i]
    ;}
    cout<<ans(0,N-1)<<endl;

    return 0;
}


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


int main(){
    string s;
    int cnt=0, ans=0;
    cin >> s;
    for(int i=0; i < s.length(); i++){
        if (s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G'){
            cnt++;
        }
        else{
            ans = max(ans, cnt);
            cnt=0;
        }
    }
    ans = max(ans, cnt);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 1001001001001001001;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
   ll N,W;
   cin >> N >> W;
   vector<ll> v(N),w(N);
   vector<tuple<double,ll,ll>> C;
   bool flag = 1;
   rep(i,N){
      cin >> w[i] >> v[i];
      if(w[i] > 1000) flag = 0;
      C.emplace_back(v[i]/w[i],v[i],w[i]);
   }
   sort(ALL(C));
   reverse(ALL(C));
   rep(i,N){
      v[i] = get<1>(C[i]);
      w[i] = get<2>(C[i]);
   }
      ll ans = 0;
      rep(i,N+1) rep(j,N+1) rep(k,N+1){
         ll res = 0,sum = 0;
         rep(l,N){
            if(l != i && l != j && l != k && sum + w[l] <= W){
               res += v[l];
               sum += w[l];
            }
         }
         ans = max(ans,res);
      }
      cout << ans << endl;
}


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

using namespace std;

using int64 = long long;

const int mod = 1e9 + 7;


template< class T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) (ret += data[k]) %= mod;
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) (data[k] += x) %= mod;
  }
};

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

  BinaryIndexedTree< int > bit(N + 1);
  bit.add(0, 1);
  int mul = 1;
  for(int i = 1; i <= N; i++) {
    (mul *= 2) %= mod;
    bit.add(i, bit.sum(i - 1));
    bit.add(i, mod - bit.sum(i - M - 1));
  }
  cout << (mul + mod - (bit.sum(N) + mod - bit.sum(N - M)) % mod) % mod << endl;
}





Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)
const int INF=1e9;
using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
vector<int> h(101);
int solve1(int st,int en,int curr){
  if(st>en) return 0;
  int idx=min_element(h.begin()+st,h.begin()+en+1)-h.begin();
  vector<int> v;
  rep(i,st,en+1) if(h[i]==h[idx]) v.pb(i);
  int ans=solve1(st,v[0]-1,h[idx])+h[idx]-curr;
  rep(i,1,v.size()) ans+= solve1(v[i-1]+1,v[i]-1,h[idx]);
  ans+= solve1(v[v.size()-1]+1,en,h[idx]);
  return ans;
}
void  solve(){
  int n;
  cin>>n;
  rep(i,0,n) cin>>h[i];
  int idx=min_element(h.begin(),h.begin()+n)-h.begin();
  vector<int> v;
  rep(i,0,n) if(h[i]==h[idx]) v.pb(i);
  int ans=solve1(0,v[0]-1,h[idx])+h[idx];
  rep(i,1,v.size()) ans+= solve1(v[i-1]+1,v[i]-1,h[idx]);
  ans+= solve1(v[v.size()-1]+1,n-1,h[idx]);
  cout<<ans<<endl;
}
int main(){

    optimizeIO();
    // tc
    { solve();
    }
}

//
// int main(){
//
//   int N, i, j, cnt = 0; cin >> N;
//   vector<int> h(N);
//   for(i=0; i<N; i++) cin >> h[i];
//
//   while(true){
//
//     j = 0;
//     while(h[j] == 0) j++;
//
//     for(i = j; i < N; i++){
//
//       if(h[i] == 0){
//         cnt++;
//         break;
//       }
//       h[i]--;
//       if(i == N - 1) cnt++;
//     }
//
//     bool flag = true;
//     for(i = 0; i < N; i++){
//       if(h[i] != 0) flag = false;
//     }
//     if(flag){
//       cout << cnt << endl;
//       return 0;
//     }
//   }
//   return -1;
// }


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N,K;cin>>N>>K;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec[i];
  }
  
  sort(vec.begin(),vec.end());
  
  int ans=0;
  
  for(int i=0;i<K;i++){
    ans+=vec[i];
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
import collections as c

# 入力
N = int(input())
An = [int(x) for x in input().split()]
 
# 各数字の個数を求める
Cn = c.Counter(An)
 
# 全部の組み合わせ
s = 0
for v in Cn.values():
    s += int(v*(v-1) / 2)

for i in range(0,N):
    print(s - (Cn[An[i]] - 1))

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

#define int long long
#define reps(i,s,n) for(ll (i)=(s);(i)<(ll)(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) reps(i,0,n+1)
#define repst(i,s,n) reps(i,s,n+1)
#define reprt(i,n,t) for(ll (i)=(n);(i)>=t;--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<n;++i){cout<<x[i]<<(i==n-1?'\n':' ');}}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

// NがL桁の整数だと仮定すると、L桁の整数nとNの大小はstr(n)とstr(N)の大小と一致する
// 10nとNの大小は？ n<Nのときstr(10n)<str(N) n>=Nのときstr(10n)>str(N)
// つまり"? 10n"に対してYが返ってくるL桁の最小の整数nがNってことになる 桁数Lがわかれば二分探索できる
// Lは"? 10^(k-1)"にYが返ってくる最大のkで求められる
// ただしNが10^aって形の場合は例外で "? 10^k"に対してはkをどこまで大きくしてもYが返ってきてしまう
// この場合だけ"? 2*10^k"でYが返ってくる最小のkがL

int l, le, ri;

bool q(ll n) {
	cout << "? " << n << ln << flush;
	char c;
	cin >> c;
	return c=='Y';
}

void fin(ll n) {
	cout << "! " << n << ln << flush;
}

signed main() {
	bool ten = false;
	rep(i,10) {
		if (!q(pow(10ll,i))) {
			l = i-1;
			break;
		}
		if (i==9) ten = true;
	}
	// N = 10^a
	if (ten) {
		rep(i,10) {
			if (q(pow(10ll,i)*2)) {
				fin(pow(10ll,i));
				return 0;
			}
		}
	}
	// N != 10^a
	else {
		le = pow(10ll,l), ri = le*10;
		while (ri-le>1) {
			int m = (le+ri)/2;
			if (q(m*10)) ri = m;
			else le = m;
		}
		fin(ri);
	}
}

Measured memory_bytes: 632
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {
    ll mod = 1000000007;
    ll N;
    cin >> N;
    ll A[N+1];
    rep(i,N+1) A[i] = 0;
    for(ll i=2;i<=N;i++){
        ll I = i;
        while(I>1){
            if((ll)sqrt(I)==1){
                A[I]++;
                I /= I;
                break;
            }
            for(ll j=2;j<=sqrt(I);j++){
                if(I%j==0){
                    if(j!=1) A[j]++;
                    I /= j;
                    break;
                }
                if(j==(ll)sqrt(I)){
                    A[I]++;
                    I /= I;
                    break;
                }
            }
        }
    }
    ll out = 1;
    rep(i,N+1) out = (out * (A[i]+1)) % mod;
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3648
WIN  = 1
LOSE = 0

N, K = map(int, input().split())
a = [int(i) for i in input().split()]

Sa = set(a)
Sk = set()

dp = [LOSE] * (K+1)

for k in range(1, K+1):
    if k in Sa: 
        dp[k] = WIN
        Sk.add(k)
    else:
        for i in range(N):
            if k-a[i] >0:
                if k-a[i] not in Sk:
                    dp[k] = WIN
                    Sk.add(k)
                    break

#print(Sa, K, Sk)
#print(dp[1:])
if dp[-1] == 1:
    print('First')
else:
    print('Second')


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

int n;
int p[100000];
int dp[100000];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> p[i];
	for (int i = 0; i < n; i++) dp[i] = 11451419;
	
	queue<int> que;
	que.push(0); dp[0] = 0;
	while (!que.empty()) {
		int v = que.front(); que.pop();
		if (p[v] != 0) {
			if (dp[v + p[v]] > dp[v]) {
				que.push(v + p[v]);
				dp[v + p[v]] = dp[v];
			}
		}
		else {
			for (int i = 1; i <= 6; i++) {
				if (dp[v + i] > dp[v] + 1) {
					que.push(v + i);
					dp[v + i] = dp[v] + 1;
				}
			}
		}
	}
	
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 3952
#include <stdio.h>
#include <string.h>

int main() {
	char str[4]={};
	scanf("%s", str);
	char week[7][4]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
	for (int i = 0; i < 7; i++) {
		if(strcmp(str,week[i])==0){
			printf("%d\n", 7-i);
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
inline long long read(){
	long long x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
long long num,n,a,b,c,d;
int main(){
	n=read()-1,a=read(),b=read(),c=read(),d=read();
	num=b-a;
	for(int i=n;i>=0;i--)
		if((long long)i*d-(n-i)*c>=num&&(long long)num>=i*c-(n-i)*d){printf("YES");return 0;}
	printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
using namespace std;

int main(){
int N , A , B;
  cin >> N >> A >> B;
  int X = N * A;
  if (X < B){
    cout << X << endl;
  } else {cout << B << endl;}
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = N/100;
    int B = N%100;
    int ans = 0;
    if(A != 0){
      if((double)B/A <= 5){
        ans = 1;
      }
    }
    System.out.println(ans);
  }
}

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

int main(){
  int N,K;
  cin>>N>>K;
  string S;
  cin>>S;
  
  if(S.at(K-1)=='A'){
        S.at(K-1)='a';
    }
  if(S.at(K-1)=='B'){
        S.at(K-1)='b';
    }
  if(S.at(K-1)=='C'){
        S.at(K-1)='c';
  }
    cout<<S<<endl;
}


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()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n, W;
    cin >> n >> W;
    vector<ll> w(n), v(n);
    REP(i,n) cin >> w[i] >> v[i];
    ll w1 = w[0];

    vector<vector<vector<ll>>> dp(n+10,vector<vector<ll>>(n+10,vector<ll>(n*3+10)));

    ll ans = 0;
    REP(i,n) REP(j,n) REP(k,i*3+1) {
        dp[i+1][j][k] = max(dp[i+1][j][k],dp[i][j][k]);
        ll k1 = w[i] - w1;
        if (w1 * j + k + w[i] <= W) {
            dp[i+1][j+1][k+k1] = max(dp[i+1][j+1][k+k1],dp[i][j][k] + v[i]);
            ans = max(ans,dp[i+1][j+1][k+k1]);
        }
    } 

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 30336
#include <bits/stdc++.h>
#define ll long long
#define B break
#define R return
#define pb push_back
using namespace std;

ll a[100010];
int main()
{
 ll n,k,c=0;
 cin>>n>>k;
 for(ll i=0;i<n;i++)
 {
     cin>>a[i];
     if(a[i]>=k)c++;
 }
 cout<<c;
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
using namespace std;
int n;
const int INF = 2000000005;

int mp2[100005] = { 0 };
int main() {
	for (int i = 0; i < 100005; i++) {
		
		mp2[i] = INF;
	}
	mp2[0] = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> mp2[i];
	}
	mp2[n + 1] = 0;
	int yo=0;
	for (int i = 0; i <= n; i++) {
		 yo+= abs(mp2[i + 1] - mp2[i]);
	}

	for (int i = 1; i <= n; i++) {
		int ans = yo;
		
		ans -= (abs(mp2[i - 1] - mp2[i]) + abs(mp2[i] - mp2[i + 1]));
		
		ans += abs(mp2[i - 1] - mp2[i + 1]);
		cout << ans << endl;
		
	}
	

	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#define llint long long
#define inf 1e18
#define mod 2
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)

using namespace std;

llint n;
string s;
llint a[1000005];

const int FACT_MAX = 2000005;
llint fact[FACT_MAX], fact_inv[FACT_MAX];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < FACT_MAX; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	fact_inv[FACT_MAX-1] = modpow(fact[FACT_MAX-1], mod-2);
	for(int i = FACT_MAX-2; i >= 0; i--){
		fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
	}
}

llint comb(llint n, llint k)
{
	if((n^k^(n-k)) == 0) return 1;
	else return 0;
}

llint calc()
{
	llint ret = 0;
	for(int i = 0; i < n; i++){
		//cout << a[i] << " " << comb(n-1, i) << endl;
		ret += a[i] * comb(n-1, i);
		ret %= 2;
	}
	return ret;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	cin >> s;
	
	for(int i = 0; i < n; i++) a[i] = s[i]-'0', a[i]--;
	bool flag = false;
	for(int i = 0; i < n; i++){
		if(a[i] == 1) flag = true;
	}
	
	if(flag){
		for(int i = 0; i < n; i++) a[i] %= 2;
		cout << calc() << endl;
		return 0;
	}
	else{
		for(int i = 0; i < n; i++) a[i] /= 2;
		cout << calc() * 2 << endl;
		return 0;
	}
	
	return 0;
}

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

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

  string ans = "No";

  if (t.substr(0, s.length()) == s) {
    ans = "Yes";
  }

  cout << ans << endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
const double PI = acos(-1);
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    vector<int> cnt(100100);
    cnt[0] = 0;
    cnt[1] = 0;
    for (int i = 2; i < 100100; i++) {
        if (i % 2 == 0)
            cnt[i] = cnt[i - 1];
        else {
            int add = 1;
            for (int d = 2; d <= sqrt(i); d++) {
                if (i % d == 0) add = 0;
            }
            for (int d = 2; d <= sqrt((i + 1) / 2); d++) {
                if ((i + 1) / 2 % d == 0) add = 0;
            }
            cnt[i] = cnt[i - 1] + add;
        }
    }
    int q;
    cin >> q;
    while (q--) {
        int l, r;
        cin >> l >> r;
        cout << cnt[r] - cnt[l - 1] << endl;
    }
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <stdio.h>
#include <set>
#include <map>
#include <vector>

using namespace std;

#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
// #define req(j, n) for (ll j = 1; j < (n+1); j++)
// #define rer(k, n) for (ll k = 1; k < (n+1); k++)



int main()
{
    ll N, M;
    cin >> N >> M;
    vector<int> H(N);
    vector<int> h(N, 0);
    vector<int> A, B;
    ll tenbo = 0;
    A = B = vector<int> (M);
    rep(i, N) {
        cin >> H[i];
    }
    rep(i, M) {
        cin >> A[i] >> B[i];
        if (H[A[i]-1] > H[B[i]-1]) {
            h[B[i]-1] += 1;
        } else if (H[A[i]-1] < H[B[i]-1]) {
            h[A[i]-1] += 1;
        } else
        {
            h[A[i]-1] += 1;
            h[B[i]-1] += 1;           
        }
        
    }
    rep(i, N) {
        if (h[i] == 0) {
            tenbo += 1;
        }
        else {
            continue;
        }
    }
    cout << tenbo << endl;
}

Measured memory_bytes: 4472
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		ArrayList<Long> list = new ArrayList<>();
		for(int i = 0; i < N; i++) {
			list.add(Long.parseLong(sc.next()));
		}
		sc.close();

		long ans = 1L;
		long check = 1000000000000000000L;
		for(int i = 0; i < list.size(); i++) {
			ans *= list.get(i);
			if(ans > Long.MAX_VALUE) {
				System.out.println(-1);
			}
		}
		if(list.contains(0L)) {
			System.out.println(0);
		}else {
			if(ans > check) {
				System.out.println(-1);
			}else if(ans <= 0) {
				System.out.println(-1);
			}else {
				System.out.println(ans);
			}
		}
	}

}

Measured memory_bytes: 61632
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string o,e;
    cin >> o >> e;
    string res;
    for(int i=0;i<o.size()+e.size(); i++){
        if(i%2==0){
            res.push_back(o.at(i/2));
        }else{
            res.push_back(e.at(i/2));
        }
    }
    cout << res << endl;
}


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

using namespace std;

#define ALL(c) c.begin(), c.end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define DB(a) cerr << #a << " = " << (a) << endl;
#define OUT( a , n ) for( int J = 0; J < (n); J++ )cout<< (a)[J] << " \n"[J == (n) - 1 ]
#define WAIT cout << flush , system("PAUSE");
#define lowbit(x) ((x) & (-x))
#define CONTAINS(a, x) ((a).find(x) != (a).end())
#define endl '\n'
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repi(i,0,n)

typedef long long ll;

const int N = 1e6+100;

int n , k , p;

char s[15];
char ans[15];

bool test(){
	printf("? %s\n",s); fflush(stdout);
	scanf("%s", ans);
	return ans[0] == 'Y';
}

bool is_pow_10(ll x){
	while(x > 1){
		if(x % 10)return false;
		x /= 10;
	}
	return true;
}
bool checkend(int pos){
	long long num = 0;
	for( int i = 0; i <= pos; ++i){
		num = num * 10 + s[i] - '0';
	}

	int last_dig = num % 10;

	if(last_dig == 9){
		 long long other = num + 1;
		 printf("? %lld\n",other); fflush(stdout);
		 scanf("%s", ans);

		if(is_pow_10(other)){
			return ans[0] == 'N';
		}
		else{
			return ans[0] == 'Y';
		}
	}
	else{
		num++;
		printf("? %lld\n",num); fflush(stdout);
		scanf("%s", ans);
		return ans[0] == 'Y';
	}
}

int main()
{
	ios::sync_with_stdio( 0 );
	cin.tie( 0 );
	for( int i = 0; i < 14; i++ ){
		s[i] = '9';
	}


	for( int i = 0; i < 11; i++ ){
		s[i] = '1';

		int lo = i == 0 ? 1 : 0;
		int hi = 9;

		while(lo < hi){
			int mid = (lo + hi) / 2;
			s[i] = '0' + mid;
			if(test()){
				hi = mid;
			}
			else lo = mid + 1;
		}
		s[i] = '0' + lo;

		if(checkend(i)){
			s[i + 1] = 0;
			printf("! %s\n",s); fflush(stdout);

			exit(0);
		}

	}

    return 0;
}


Measured memory_bytes: 660
from collections import deque
n=int(input().strip())
a=list(map(int, input().split()))
b = deque()
for i in range(n):
    if i%2==0:
        b.append(a[i])
    else:
        b.appendleft(a[i])
b=list(b)
if n%2==1:
    b=b[::-1]
print(' '.join(map(str, b)))

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

int main() {
	int A;
  int B;
  double T;
  int security_keksz=0;
  cin >> A;
  cin >> B;
  cin >> T;
  T+=0.5;
  security_keksz=(T/A);
  cout << security_keksz*B;
	return 0;
}


Measured memory_bytes: 3712
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val pw = PrintWriter(System.out)
fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    // 回答をここに書く
    val (A, B) = listOfInt()
    val r = if (A <= 8 && B <= 8)  "Yay!" else ":("
    println(r)
}

// 入力取得
fun next() = br.readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }
fun listOfLong() =listOfString().map { it.toLong() }
fun listOfDouble() =listOfString().map { it.toDouble() }

// 約数のList
fun divisor(value : Long) : List<Long> {
    val max = Math.sqrt(value.toDouble()).toLong()
    return (1..max)
        .filter { value % it == 0L }
        .map { listOf(it, value / it) }
        .flatten()
        .sorted()
}

// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun prime(from : Long, to : Long = from) : List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j ->  i % j != 0L }
    }
}

// 素因数分解
fun decom(value : Long) : List<Long>{
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}

// 最大公約数
fun gcd(a : Long, b : Long) : Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

// 文字列を入れ替え
fun swap(base : String, a : String, b : String) : String {
    return base.map {
        when (it) {
            a.toCharArray()[0] -> b
            b.toCharArray()[0] -> a
            else -> it.toString()
        }
    }.joinToString()
}

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 35900
from copy import deepcopy
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions
from operator import itemgetter
import itertools
import copy


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


def gcd(a, b):
    while(b != 0):
        a, b = b, a % b
    return a


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

n = int(input())
k = int(input())
ans = 1
for i in range(n):
    ans = min(ans*2, ans+k)
print(ans)


Measured memory_bytes: 10560
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    static class Fast {
        BufferedReader br;
        StringTokenizer st;

        public Fast() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String args[]) throws Exception {
        Fast in = new Fast();
        int a=in.nextInt(),b=in.nextInt(),c=in.nextInt();
        int x=in.nextInt();
        int ways=0;
        for (int i = 0; i <=a; i++) {
            for (int j = 0; j <= b; j++) {
                for (int k = 0; k <= c; k++) {
                    if((k*50)+(j*100)+(i*500)==x){
                        ways++;
                    }
                }
            }
        }
        System.out.println(ways);

    }
}

Measured memory_bytes: 21588
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    print(3*n**2)
    return

#B
def B():
    n,d = LI()
    f = [1]*(n+2*d+2)
    ans = 0
    for i in range(n):
        if f[i]:
            for j in range(i,i+2*d+1):
                f[j] = 0
            ans += 1
    print(ans)
    return

#C
def C():
    n = I()
    a = IR(n)
    mi = max(a)
    if a.count(mi) > 1:
        for i in range(n):
            print(mi)
    else:
        b = [a[i] for i in range(n)]
        b.sort()
        b = b[::-1]
        for i in range(n):
            if mi != a[i]:
                print(mi)
            else:
                print(b[1])

    return

#D
def D():
    n = I()
    a = LI()
    b = [0]*(n+1)
    for i in range(1,n+1)[::-1]:
        j = 2*i
        k = 0
        while j <= n:
            k ^= b[j]
            j += i
        if a[i-1]^k:
            b[i] = 1
    ans = []
    for i in range(n+1):
        if b[i]:
            ans.append(i)
    print(len(ans))
    if ans:
        print(*ans)
    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    D()


Measured memory_bytes: 73976
import numpy as np
N = int(input())
XY = np.array([[int(x) for x in input().split()] for _ in range(N)],dtype=np.int64)
X = XY[:,0]
Y = XY[:,1]
command  = np.array([""]*N,dtype=object)

def solve(k,X,Y,arms,command):
    if k==-1:
        return final_solve(X,Y,arms,command)
    else:
        #大きい方を変換
        #print(X,Y)
        bl_X = (np.abs(X)>np.abs(Y))
        bl_Y = ~bl_X
        neg_X = (X<0)
        neg_Y = (Y<0)
        L = bl_X & neg_X
        R = bl_X & (~neg_X)
        U = bl_Y & (~neg_Y)
        D = bl_Y & neg_Y
        p = 1<<k
        command[L] += "L"
        command[R] += "R"
        command[U] += "U"
        command[D] += "D"
        X[L] +=p

        X[R] -=p

        Y[U] -=p

        Y[D] +=p

        arms.append(p)
        return solve(k-1,X,Y,arms,command)
def final_solve(X,Y,arms,command):
    s = np.abs(X)+np.abs(Y)
    b0 = (s==0).all()
    b1 = (s==1).all()
    if b0:
        return arms,command
    elif not b1:
        return None,None

    arms.append(1)
    L = (X==-1)
    R = (X==1)
    D = (Y==-1)
    U = (Y==1)
    command[L] += "L"
    command[R] += "R"
    command[U] += "U"
    command[D] += "D"
    return arms,command


arms,command = solve(35,X,Y,[],command)

if arms is None:
    print(-1)
else:
    print(len(arms))
    print(" ".join([str(i) for i in arms]))
    print("\n".join(command))

Measured memory_bytes: 12852
#include<bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i=0;i<e;i++)
#define all(a) (a).begin(),(a).end()
using LL=long long;

int main() {
  double t,x;
  cin>>t>>x;
  
  cout<<fixed<<setprecision(15);
  cout<<t/x<<endl;
      
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define MAX 1000000007
#define MAXN 100005
bool sortby1column(vector<ll> &v1,vector<ll> &v2){
 return v1[0]<v2[0];
}


int main(){
	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
  	int t=1;
	//cin>>t;
	while(t--){
       ll k,n;
       cin>>k>>n;
       ll a[n];
       for(int i=0;i<n;i++)
        cin>>a[i];
        ll ans=a[0],maxi=000000000;
       for(int i=1;i<n;i++){
        if(a[i]-a[i-1]>maxi)
            maxi = a[i]-a[i-1];
        ans+=a[i];
       }
       maxi = max(maxi,k-a[n-1]+a[0]);
       cout<<k-maxi<<endl;
	}
}

Measured memory_bytes: 1792
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

a = []

for i in range(N):
    a.append(V[i] - C[i])

a.sort()
a.reverse()

ans = 0

for i in a:
    if i >= 0:
        ans += i

print(ans)

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

int main(void)
{
    int D, T, S;
    cin >> D >> T >> S;
    if(T*S<D){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
using namespace std;
int main (){
int n,h[256][3],temp,u;
cin>>n;
for (int s=0;s<n;s++){
        for (int s_=0;s_<3;s_++){
                cin>>h[s][s_];
        }
}
for (int ka=0;ka<3;ka++){
        for (int s=0;s<n;s++){
u=0;
                for (int s_=0;s_<n;s_++){
                        if (h[s][ka]==h[s_][ka]&&s!=s_){
                        //      h[s][ka]=0;
                                h[s_][ka]=0;
u=1;
                        }
                }
if(u==1)h[s][ka]=0;
        }
}
for (int s=0;s<n;s++){
                temp=0;
        for (int s_=0;s_<3;s_++){
                temp=h[s][s_]+temp;
        }
cout<<temp<<endl;
}
return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <set>
using namespace std;

#define MP make_pair

bool flag[53][53][4];

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

int main(){
	int n,x0,y0,t;
	cin >> n >> x0 >> y0 >> t;
	x0++;
	y0++;
	for(int k=0;k<n;k++){
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		a++;b++;c++;d++;
		if(a==c){
			if(b>d)swap(b,d);
			for(int i=b;i<d;i++){
				flag[a][i][0] = 1;
			}
			for(int i=d;i>b;i--){
				flag[a][i][2] = 1;
			}
		}
		if(b==d){
			if(a>c)swap(a,c);
			for(int i=a;i<c;i++){
				flag[i][b][1] = 1;
			}
			for(int i=c;i>a;i--){
				flag[i][b][3] = 1;
			}
		}
	}
	map<int,int> mp;
	int s = 0;
	for(int i=0;i<t;i++){
		int a;
		cin >> a;
		char b;
		cin >> b;
		s += a;
		if(b=='N'){
			mp[s] = 0;
		}else if(b=='E'){
			mp[s] = 1;
		}else if(b=='S'){
			mp[s] = 2;
		}else{
			mp[s] = 3;
		}
	}
	queue<pair<pair<int,int>,pair<int,int> > >q;
	map<pair<pair<int,int>,pair<int,int> >,bool> m;
	if(flag[x0][y0][0]==1){
		q.push(MP(MP(x0,y0),MP(0,0)));
	}
	if(flag[x0][y0][1]==1){
		q.push(MP(MP(x0,y0),MP(0,1)));
	}
	if(flag[x0][y0][2]==1){
		q.push(MP(MP(x0,y0),MP(0,2)));
	}
	if(flag[x0][y0][3]==1){
		q.push(MP(MP(x0,y0),MP(0,3)));
	}
	set<pair<int,int> > ans;
	while(1){
		auto x = q.front();
		q.pop();
		int a,b,c,d;
		a = x.first.first;
		b = x.first.second;
		c = x.second.first;
		d = x.second.second;
		//cout << a <<" " << b << " " <<c << " " << d << endl;
		if(c>s)break;
		if(c==s){
			ans.insert(MP(a-1,b-1));
		}
		if(mp.find(c+1)!=mp.end()){
			if(d==mp[c+1]){
				for(int i=0;i<4;i++){
					if(i!=d&&(i+4-d)%2==0)continue;
					if(flag[a+dx[d]][b+dy[d]][i]==1&&m[MP(MP(a+dx[d],b+dy[d]),MP(c+1,i))]==0){
						m[MP(MP(a+dx[d],b+dy[d]),MP(c+1,i))]=1;
						q.push(MP(MP(a+dx[d],b+dy[d]),MP(c+1,i)));
					}
				}
			}else{
				if((d+4-mp[c+1])%2!=0&&flag[a+dx[d]][b+dy[d]][mp[c+1]]==1&&m[MP(MP(a+dx[d],b+dy[d]),MP(c+1,mp[c+1]))]==0){
					m[MP(MP(a+dx[d],b+dy[d]),MP(c+1,mp[c+1]))]=1;
					q.push(MP(MP(a+dx[d],b+dy[d]),MP(c+1,mp[c+1])));
				}
			}
		}else{
			for(int i=0;i<4;i++){
				if(i!=d&&(i+4-d)%2==0)continue;
				if(flag[a+dx[d]][b+dy[d]][i]==1&&m[MP(MP(a+dx[d],b+dy[d]),MP(c+1,i))]==0){
					m[MP(MP(a+dx[d],b+dy[d]),MP(c+1,i))]=1;
					q.push(MP(MP(a+dx[d],b+dy[d]),MP(c+1,i)));
				}
			}
		}
	}
	for(auto x:ans){
		cout << x.first << " " << x.second << endl;
	}
	return 0;
}


Measured memory_bytes: 52968
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        String s = sc.next();
        List<Integer> shiseiList = new ArrayList<>();

        for (int i = 0; i < s.length(); i++){
            int value = Character.getNumericValue(s.charAt(i));
            shiseiList.add(value);
        }

        List<Integer> changePointList = new ArrayList<>();

        for (int i = 0; i < n; i++){
            if (i == 0){
                changePointList.add(i);
            }else {
                if (!shiseiList.get(i).equals(shiseiList.get(i - 1))){
                    changePointList.add(i);
                }
            }
        }
        // end point
        changePointList.add(n);
        int changeSize = changePointList.size();
        List<Integer> answerList = new ArrayList<>();

        for (int i = 0; i < changeSize - 1; i++){
            int shisei = shiseiList.get(changePointList.get(i));
            if (shisei == 1){
                int endIndex = Math.min(i + k * 2 + 1, changeSize - 1);
                answerList.add(changePointList.get(endIndex) - changePointList.get(i));
            }else {
                int endIndex = Math.min(i + 2 * k, changeSize - 1);
                answerList.add(changePointList.get(endIndex) - changePointList.get(i));
            }
        }

        answerList.sort(Comparator.reverseOrder());

        System.out.println(answerList.get(0));

    }

}

Measured memory_bytes: 32880
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int L = sc.nextInt();
   int R = sc.nextInt();
   boolean zero = false; 
   
   if(L-R>=2019) zero = true;
   for(int i = L;i<R;i++)
   {
     if(i%2019==0) 
     {
       zero = true;
       break;
     }
   }
   L = L%2019;
   R = R%2019;
   int min = 2017*2018;
   if(!zero)
   {
     for(int i = L;i<R;i++)
     {
       for(int k = i+1;k<=R;k++)
       {
          if(min>(i*k)%2019) min = (i*k)%2019;         
       }
     }
   }
   if(zero) System.out.println(0);
   else System.out.println(min);
 }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){

	int x1, y1, x2, y2;

	cin>> x1 >> y1 >> x2 >> y2;

	cout<< x2-(y2-y1) << " " << y2+(x2-x1) << " " << x1-(y2-y1) << " " << y1+(x2-x1) << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\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 P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  int l, r;
  cin >> l >> r;

  ll ans = INF;
  if (r - l + 1 >= 2019) {
    cout << 0 << endl;
    return 0;
  } else {
    for (ll i = l; i <= r - 1; i++) {
      for (ll j = i + 1; j <= r; j++) {
	ans = min(ans, i * j % 2019);
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	int c[40];
	for (int i = 1; i <= m; i++) {
		c[i] = 0;
	}
	for (int i = 0; i < n; i++) {
		int k, x;
		cin >> k;
		for (int j = 0; j < k; j++) {
			cin >> x;
			c[x]++;
		}
	}
	int ans = 0;
	for (int i = 1; i <= m; i++) {
		if (c[i] == n) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
Sp = input()
T = input()
len_Sp = len(Sp)
len_T = len(T)
ans = ''
cnt = 0

i = len_Sp-len_T
while(i >= 0):
    j = len_T-1
    while(j >= 0):
        if Sp[i + j] == T[j] or Sp[i + j] == '?':
            cnt += 1
        else:
            cnt = 0
            break
        j -= 1
    if cnt == len_T:
        Sp_list = list(Sp)
        for k in range(len_T):
            Sp_list[i + k] = T[k]
        ans = ''.join(Sp_list)
        ans = ans.replace('?', 'a')
        print(ans)
        break
    i -= 1
if cnt != len_T:
    print('UNRESTORABLE')

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main() {
    long long n, a, b; cin >> n >> a >> b;
    if ((a - b) % 2) {
        if (a > b) swap(a, b);
        if (a - 1 < n - b) {
            cout << a + (b - a - 1) / 2 << endl;
        } else {
            cout << n - b + 1 + (b - a - 1) / 2 << endl;
        }
    } else cout << (b - a) / 2 << endl;
}


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

public class Main {

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

		String str[] = br.readLine().split(" ");

		int k = Integer.parseInt(str[0]);
		int x = Integer.parseInt(str[1]);

		System.out.print(x - k + 1);
		for (int i = x - k + 2; i < x + k; i++) {
			System.out.print(" " + i);
		}

		System.out.println();
	}
}

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

int64_t ncr2(int64_t n);
int main(void) {
    int64_t N;
    int64_t total = 0;
    cin >> N;

    vector<int64_t> A(N);
    vector<int64_t> B(200001,0);

    for(int64_t i=0;i<N;i++) {
        cin >> A[i];
        B[A[i]-1]++;
    }

    for(int64_t i=0;i<B.size();i++) {
        total += ncr2(B[i]);
    }
    for(int64_t i=0;i<N;i++) {
        cout << total - ncr2(B[A[i]-1]) + ncr2(B[A[i]-1]-1) << "\n";
    }

    return 0;
}

int64_t ncr2(int64_t n) {
    if(n < 2) return 0;
    if(n == 2) return 1;
    return (n * (n-1)) / 2;
}

Measured memory_bytes: 5760
#include <cstdio>
#include <cstring>

char s[200005];
int main()
{
	int n,sum=0;
	scanf("%d",&n);
	scanf("%s",s);
	int l=0,r=n-1;
	for (int i=0;i<n;i++){
		if (s[i]=='W') {
			l=i;
			int f=1;
			for (int j=r;j>i;j--){
				if (s[j]=='R') {
					s[i]='R';
					s[j]='W';
					sum++;
					f=0;
					r=j-1;
					break;
				}
			}
			if (f) break;
		}
	}
	if (l) {
		for (int i=l;i<r;i++) {
			if (s[i]=='R') sum++;
		}
	}
	printf("%d",sum);
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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


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

    double ans=0.0;

    rep(i,N){
        int x,h;
        cin>>x>>h;


        chmax(ans,1.0*t*h/x);
    }
    printf("%.20f\n",ans);
    return 0;
}

Measured memory_bytes: 3188
#!/usr/bin/env python3

def main():
    S = input()
    S_re = list(reversed(S))
    S = list(S)

    cnt = 0
    for i in range(0, len(S)//2):
        if not S[i] == S_re[i]:
            cnt = cnt + 1
    print(cnt)


main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int K;
	int S;
	int tempZ;
	int count = 0;
	cin >> K >> S;

	// not < , but <= .
	for (int i = 0; i <= K; i++) {
		for (int j = 0; j <= K; j++) {
			tempZ = S - i - j;
			if (0 <= tempZ && tempZ <= K) count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#define ll long long
using namespace std;
ll gcd(ll a,ll b){
    return (b>0)?gcd(b,a%b):a;
} 
int main(){
	int n;
	cin>>n;
	ll ans=1,num;
	for(int i=0;i<n;i++){
		cin>>num;
		ans=ans/gcd(ans,num)*num;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
H = list(map(int,input().split()))

H += [float("inf")]
ans,cnt = 0,0
cur = H[0]
for h in H[1:]:
	if cur >= h:
		cnt += 1
	else:
		ans = max(ans,cnt)
		cnt = 0
	cur = h
print(ans)

Measured memory_bytes: 14252
N,x = map(int, input().split())
A = [int(a) for a in input().split()]

ans = 0
for i in range(1, N):
    if A[i-1]+A[i] <= x:
        continue
    if A[i-1] <= x:
        ans += A[i]-(x-A[i-1])
        A[i] = x-A[i-1]
    else:
        ans += A[i]+A[i-1]-x
        A[i] = 0
        A[i-1] = x
        
print(ans)

Measured memory_bytes: 14132
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = 1000'000'007;
 
ll n,m;
ll a[112345];

ll dp[112345];
signed main(){
    cin>>n>>m;
        dp[0]=1;dp[1]=1;

    rep(i,m){
        cin>>a[i];
        dp[a[i]]=-1;
    }


    rep(i,n+1){
        if(dp[i+2]!=-1)dp[i+2]=(max(dp[i+1],0LL)+max(dp[i],0LL))%mod;
        
    }
    cout<<dp[n]%mod<<endl;
    

 
}

Measured memory_bytes: 1792