akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    long long x[n], y[n], z[n];
    int base = 0;
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i] >> z[i];
        if(z[i]) base = i;
    }
    for(int i = 0; i <= 100; i++){
        for(int j = 0;  j<= 100; j++){
                long long h = abs(i - x[base]) + abs(j - y[base]) + z[base];
                int f = 0;
                for(int k = 0; k < n; k++){
                    long long hh = h - (abs(i - x[k]) + abs(j - y[k]));
                    hh = max(hh, 0ll);
                    if(hh != z[k]) {
                        f = 1; break;
                    }
                }
                if(!f){
                    cout << i << " " << j << " " << h << endl;
                    return 0;
                }

        }
    }
}


Measured memory_bytes: 3632
// ------- PBDS ------ //
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
// ------- PBDS ------ //

#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define testcase ll tt; cin>>tt; while(tt--)
#define pb push_back
#define nn cout<<"\n"
#define MOD 1000000007
#define pi 3.1415926535
#define endl "\n"
#define vll vector<ll>
#define MULTI int T; cin >> T; while(T--)
#define all(a)      (a).begin(),(a).end()
#define here cout<<"I'm here\n";
void vout(vector<ll> ans){
    for(auto ele:ans) cout<<ele<<" "; cout<<endl;
}
vector<ll> adj[200001];
bool vis[200001];

// ------- PBDS ------ //
typedef tree<
// change this for any data-type
string,
null_type,
// change this for any data-type
less<string>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

/*
    to get the position of an element in set , do
    s.order_of_key(ele);
    this returns the number of elements strictly lesser than ele in set s
    Let us assume we have a set s : {1, 5, 6, 17, 88}, then :
    s.order_of_key(6) : Count of elements strictly smaller than 6 is 2.
    s.order_of_key(25) : Count of elements strictly smaller than 25 is 4.

    to get the element at position k
    s.find_by_order(k);
    returns an iterator to the ele counting from 0
    Let us assume we have a set s : {1, 5, 6, 17, 88}, then :
    *(s.find_by_order(2)) : 3rd element in the set i.e. 6
    *(s.find_by_order(4)) : 5th element in the set i.e. 88
*/

// ------- PBDS ------ //

clock_t time_p=clock();
void purvansh11()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

//BINARY EXPONENTIATION  -- O(log2(b))
ll power(ll a, ll b) {
    /*
        for 3^11 :
        as 11 -> 1011, we mean 3^8 * 3^2 * 3^1
        so multiply for all ones in binary rep of b
    */

    ll ans = 1;
    ll num = a;
    while (b > 0) {
        if (b & 1) ans = ((ans % MOD) * (num % MOD)) % MOD;
        num = ((num % MOD) * (num % MOD)) % MOD;
        b /= 2;
    }
    return ans;
}

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

    SPEED;
    cout.precision(8);
    cout << fixed;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max({a*c,a*d,b*c,b*d});

    purvansh11();
    return 0;
}

Measured memory_bytes: 8492
S = input()
T = input()
Answer = len(T)
for i in range(0,len(S)-len(T)):
    String = S[i:i+len(T)]
    B = len(T)
    for j in range(len(String)):
        if String[j] == T[j]:
            B -= 1
    Answer = min(Answer,B)
if len(S) == len(T):
    B = len(S)
    for j in range(len(S)):
        if T[j] == S[j]:
            B -=1
    Answer = min(Answer,B)
print(Answer)

Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =999999999;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




//10億7。　　　100000007
//2*2行列 H*W
//vector<vector<int>> vec(H,vector<int>(W));
//for(int i=0;i<H;i++){
//for(int j=0;j<W;j++){
//cin>>vec[i][j];
//  }
//}

//文字列→数列
//string S;int A=atoi(S.c_str());
//数列→文字列
//int A;string S=to_string(A);
//数字判定　isdigit(a)
//pair宣言　pair<int,int> p(5,7);
//ソート　sort(vec.begin(),vec.end());



int main(){
cout<<fixed<<setprecision(10);

int N;cin>>N;
  if(1<=N&&N<=999){cout<<"ABC";
                  }else{cout<<"ABD";
                       }

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		long[,] dp=new long[n+1,3];
		for(int i=1;i<=n;i++){
			int[] q=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
			dp[i,0]=Math.Max(dp[i-1,1]+q[0],dp[i-1,2]+q[0]);
			dp[i,1]=Math.Max(dp[i-1,0]+q[1],dp[i-1,2]+q[1]);
			dp[i,2]=Math.Max(dp[i-1,0]+q[2],dp[i-1,1]+q[2]);
		}
		long ans=0;
		for(int i=0;i<3;i++){ans=Math.Max(ans,dp[n,i]);}
		Console.WriteLine("{0}",ans);
	}
}

Measured memory_bytes: 19392
#include <bits/stdc++.h>
#define REP(i, n) for (int i=0, i##_limit=(n); i<i##_limit; ++i)
#define FOR(i, a, b) for (int i=(a), i##_limit=(b); i<i##_limit; ++i)
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long;
using pi = pair<int, int>;

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

    int ret = 0;
    FOR(i, 1, M+1) FOR(j, 22, D+1)
    {
        if ((j/10)*(j%10) == i && j%10 >= 2) ++ret;
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N,Y,a,b,c,total;
    cin >> N >> Y;
    for(int i=0;i<=2000;i++){
        a = i;
        for(int j=0;j<=2000;j++){
            b = j;
            c = N - a - b;
            if(c>=0){
            total = 10000*a + 5000*b + 1000*c;
            if(total == Y){
            cout << a << " " << b << " " << c << endl;
            return 0;
                }
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 <<endl;
}


Measured memory_bytes: 256
import sys,collections;sys.setrecursionlimit(10**7)
import itertools
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n = I()
d = collections.defaultdict(int)
for _ in range(n):
    s = S()[0]
    if list("MARCH").count(s) > 0:
        d[s] += 1
if len(d) < 3:
    print(0)
    exit()
c = list(itertools.combinations(d.items(),3))
sum = 0
for e in c:
    sum += e[0][1]*e[1][1]*e[2][1]
print(sum)

Measured memory_bytes: 3572
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

int main(){
    ll n,k,q;
    cin >> n >> k >> q;

    ll a[q];
    ll score[n] = {};

    REP(i,q)
    {
        cin >> a[i];
        --a[i];
        ++score[a[i]];
    }

    REP(i,n)
    {
        string res;
        if(k - q + score[i] > 0)res = "Yes";
        else res = "No";

        cout << res << endl;
    }
    return 0;    
}



Measured memory_bytes: 2176
#include <iostream>
#include <numeric>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {

	string S;
	cin >> S;
	string k = "No";
	if (S.size() > 3 && S.at(0) == 'Y' && S.at(1) == 'A' && S.at(2) == 'K' && S.at(3) == 'I') {
		k = "Yes";
	}
	cout << k << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>

using namespace std;

vector<int> dat;

int m;

#define bt 131072

struct itree {
  vector<int> tree;
  itree() : tree(bt * 2) { }

  long long count(int limit) {
    int l = bt, r = limit + bt;
    long long ans = 0;
    while (l <= r) {
      if (l & 1) ans += tree[l];
      if (!(r & 1)) ans += tree[r];
      l = (l + 1) >> 1;
      r = (r - 1) >> 1;
    }
    return ans;
  }

  void mark(int pos) {
    pos += bt;
    while (pos >= 1) {
      tree[pos]++;
      pos >>= 1;
    }
  }
};


long long count0(int test) {
  int n = dat.size();
  vector<int> depths;
  depths.reserve(n + 1);

  {
    int depth = 0;
    depths.push_back(depth);
    for (int i = 0; i < n; i++) {
      int score;
      if (test <= dat[i]) score = 1;
      else score = -1;
      depth += score;
      depths.push_back(depth);
    }
  }
  int offset = 1-*min_element(depths.begin(), depths.end());
  // add offset

  itree t;
  long long ans = 0;
  for (int i = n; i >= 0; i--) {
    long long cnt = t.count(depths[i] + offset - 1);
    ans += cnt;
    t.mark(depths[i] + offset);
  }
  return ans;
}

int main() {
  int n;
  scanf("%d", &n);
  dat.resize(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &dat[i]);
  }

  vector<int> sorteddat = dat;
  sort(sorteddat.begin(), sorteddat.end());
  sorteddat.resize(unique(sorteddat.begin(), sorteddat.end()) - sorteddat.begin());
  m = sorteddat.size();
  for (int i = 0; i < n; i++) {
    dat[i] = lower_bound(sorteddat.begin(), sorteddat.end(), dat[i]) - sorteddat.begin();
  }

  int lowind = 0, highind = sorteddat.size() - 1;
  int ans = 0;
  long long total_count = (long long)n * (long long)(n + 1ll) / 2;
  while (lowind <= highind) {
    int midind = (lowind + highind) / 2;
    long long checkvalue = count0(midind);
    if (checkvalue <= total_count / 2) {
      ans = midind;
      lowind = midind + 1;
    }
    else {
      highind = midind - 1;
    }
  }
  ans = sorteddat[ans];
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 2432
k=int(input())
 
if (k%2==0) or (k%5==0):
  print(-1)
  exit()
 
if k%7==0:
  k//=7
 
o=0
m=1
if k==1:
  print(1)
  exit()
 
for i in range(k):
  m*=10
  m=m%k
  o+=m%k
  o%=k
  if o==0:
    print(i+1)
    exit()

Measured memory_bytes: 8960
#include<iostream>
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>

using namespace std;

class Counting {
	unsigned long long p, n;
	vector<long long> invMemo, facMemo, facInvMemo;
public:
	Counting(unsigned long long nn, unsigned long long np) {
		p = np;
		n = nn;
		invMemo.resize(n + 1);
		facMemo.resize(n + 1);
		facInvMemo.resize(n + 1);
		facMemo[0] = 1;
		facMemo[1] = 1;
		facInvMemo[0] = 1;
		facInvMemo[1] = 1;
		invMemo[0] = 0;
		invMemo[1] = 1;
		for (unsigned long long i = 2; i <= n; i++) {
			invMemo[i] = p - (p / i)*invMemo[p%i] % p;
			facMemo[i] = (facMemo[i - 1] * i) % p;
			facInvMemo[i] = (facInvMemo[i - 1] * invMemo[i]) % p;
		}
	}
	unsigned long long fac(unsigned long long k) {
		return facMemo[k];
	}
	unsigned long long facInv(unsigned long long k) {
		return facInvMemo[k];
	}
	unsigned long long choose(unsigned long long n, unsigned long long k) {
		if (!(0 <= k && k <= n))
			return 0;
		return (((facMemo[n] * facInvMemo[k]) % p)*facMemo[n - k]) % p;
	}
	unsigned long long divide(unsigned long long a, unsigned long long b) {
		return (a * invMemo[b]) % p;
	}
	unsigned long long mod(unsigned long long a) {
		a %= p;
		if (a < 0) a += p;
		return a;
	}
	unsigned long long power(unsigned long long a, unsigned long long e) {
		unsigned long long ans = 1;
		for (; e > 0; e /= 2) {
			if (e % 2 != 0)
				ans = ans * a % p;
			a = a*a%p;
		}
		return ans;
	}
};

long long k, t, ans = 0, Max, sum = 0;
vector<long long> a;
map<int, int> mp;

int main() {
	cin >> k >> t;
	a.resize(t);
	for (int i = 0; i < t; i++) {
		cin >> a[i];
		sum += a[i];
	}
	sort(a.begin(), a.end());
	Max = a[t - 1];
	sum -= Max;
	ans = Max - sum - 1;
	if (ans < 0)
		ans = 0;
	cout << ans << endl;
//	cin >> t;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

vector<ll> suffix_array(const string &S) {
  ll n = S.length(), k = 1;
  vector<ll> sa(n + 1), rnk(n + 1), tmp(n + 1);

  auto compare_sa = [&](ll i, ll j) {
    if(rnk[i] != rnk[j]) return rnk[i] < rnk[j];
    ll ri = i + k <= n ? rnk[i + k] : -1;
    ll rj = j + k <= n ? rnk[j + k] : -1;
    return ri < rj;
  };

  REP(i, 0, n + 1) sa[i] = i;
  REP(i, 0, n + 1) rnk[i] = i < n ? S[i] : -1;

  for(; k <= n; k *= 2) {
    sort(sa.begin(), sa.end(), compare_sa);
    tmp[sa[0]] = 0;
    REP(i, 1, n + 1) tmp[sa[i]] = tmp[sa[i - 1]] + (compare_sa(sa[i - 1], sa[i]) ? 1 : 0);
    REP(i, 0, n + 1) rnk[i] = tmp[i];
  }

  return sa;
}

int main(void) {
  ll N, H;
  string S;
  cin >> N >> H >> S;

  vector<ll> a(N, 0);
  REP(i, 0, N - 1) if(S[i] == '0') a[i + 1] += a[i] + 1;

  vector<ll> imos(N + 2, 0);
  REP(i, 0, N) {
    if(S[i] != '0') {
      imos[1] += a[i] + 1;
      imos[N - i + 1] -= a[i] + 1;
    } else {
      imos[1] += a[i] + 1;
      imos[2] -= a[i] + 1;
    }
  }
  REP(i, 0, N + 1) imos[i + 1] += imos[i];

  ll x = 1, cnt = 1;
  while(1) {
    if(cnt <= H && H < cnt + imos[x]) break;
    cnt += imos[x];
    x++;
  }

  vector<ll> sa = suffix_array(S);
  REP(i, 1, N + 1) {
    ll j = sa[i];
    if((x == 1 || S[j] != '0') && j + x <= N) {
      if(cnt <= H && H < cnt + a[j] + 1) {
        cout << S.substr(j, x) << endl;
        break;
      }
      cnt += a[j] + 1;
    }
  }
}



Measured memory_bytes: 6908
#include<iostream>
using namespace std;
int main() {
	int N, i;
	unsigned long long L[87];
	L[0] = 2;
	L[1] = 1;
		cin >> N;
		for (i = 2;i <= N;i++) {
			L[i] = L[i - 1] + L[i - 2];
		}
		cout << L[N] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int k,a,b;
int main(){
    scanf("%d%d%d",&k,&a,&b);
    for(;a<=b;a++){
        if(a%k==0){
            puts("OK");
            return 0;
        }
    }
    puts("NG");
    return 0;
}

Measured memory_bytes: 1664
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;


int main() {
    int N; cin >> N;
    graph A(N);
    for (int i = 1; i <N; i++) {
        int a; cin >> a;
        A[a-1].push_back(i);

    }
    rep(i, N) {
        cout << A[i].size() << endl;
    }
   
}

    


    








































































































































Measured memory_bytes: 13992
def abc150_d():
    n, m = (int(x) for x in input().split())
    A = [int(x) // 2 for x in input().split()]

    from math import gcd
    def lcm(a, b):
        return a * b // gcd(a, b)

    x = 1
    for a in A:
        x = lcm(x, a)

    valid = True
    for a in A:
        if (x // a) % 2 == 0:
            valid = False
            break

    if valid: ans = (m // x + 1) // 2
    else: ans = 0
    print(ans)

if __name__ == '__main__':
    abc150_d()

Measured memory_bytes: 19896
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define ff first
#define ar array
#define ss second
#define ll long long int
#define mem(x) memset(x,0,sizeof(x))
#define setbits(x)  __builtin_popcount(x)
#define ull unsigned long long int
#define all(c) (c).begin(),(c).end()
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define db double
#define endl "\n"
#define  fbo(x) find_by_order(x)
#define  ook(x) order_of_key(x)
 
using namespace __gnu_pbds;
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair<ll,ll > iil;
typedef pair<ll,int> li;
typedef pair<int,int> ii;
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os1;
typedef tree<int, null_type, greater<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os2;

inline void fast()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
const ll pi=31;
const ll MOD[2] = {1187278649, 1149736019};//for double hashing
const ll mod=(ll)(1e9)+7;
ll pmod(ll x,ll n){
  ll r=1;
  while(n>0)
  {
    if(n&1LL)
      r=(r*x)%mod;
    x=(x*x)%mod;
    n=n/2;
    n%=mod;
  }
  return r;
}
ll pMod(ll x,ll n,ll mod)
{ ll r=1;
  while(n>0)
  {
    if(n&1LL)
      r=(r*x)%mod;
    x=(x*x)%mod;
    n=n/2;
    n%=mod;
  }
  return r;
 
}
 
//think recursively also;
const int mxn=1e5;
ll a[mxn+1][3];
ll n;
ll dp[mxn+1][4];
void solve()
{ 
  cin>>n;
  for(int i=0;i<n;i++)
  {
    cin>>a[i][0]>>a[i][1]>>a[i][2];
  }

  for(int i=0;i<n;i++)
  {
     for(int j=0;j<3;j++)
     {
       if(i==0)
       {
        dp[i][j]=a[i][j];
       }
       else
       {
         for(int k=0;k<3;k++)
         {
           if(k!=j)
            dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i][j]);
         }
       }
     }
 }
  cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
  
}
int main()
{
  fast();
   // int t;
   // cin>>t;
   // for(int casee=1;casee<=t;casee++)
  {//cout<<"Case #"<<casee<<": ";
    solve();
  }
 
 
 
}

Measured memory_bytes: 9108
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

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


Measured memory_bytes: 256
a = 3.times.map { gets.chomp.split(' ').map(&:to_i) }
n = gets.chomp.to_i
b = n.times.map { gets.chomp.to_i }

marked = [[false, false, false], [false, false, false], [false, false, false]]
b.each do |num|
  (0..2).each do |i|
    (0..2).each do |j|
      marked[i][j] = true if a[i][j] == num
    end
  end
end

ans = 'No'
(0..2).each do |i|
  ans = 'Yes' if marked[i][0] && marked[i][1] && marked[i][2]
end
(0..2).each do |j|
  ans = 'Yes' if marked[0][j] && marked[1][j] && marked[2][j]
end
ans = 'Yes' if marked[0][0] && marked[1][1] && marked[2][2]
ans = 'Yes' if marked[0][2] && marked[1][1] && marked[2][0]

puts ans


Measured memory_bytes: 3836
from itertools import combinations
def main():
    N, M, Q = map( int, input().split())
    ABCD = [ tuple( map( int, input().split())) for _ in range(Q)]
    ans = 0
    for C in combinations( range(N+M-1), M-1):
        A = []
        index = 0
        now = 1
        for i in range(N+M-1):
            if index < M-1:
                if C[index] == i:
                    now += 1
                    index += 1
                    continue
            A.append(now)

        lans = 0
        for a, b, c, d in ABCD:
            if A[b-1] - A[a-1] == c:
                lans += d
        if ans < lans:
            ans = lans
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 9224
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
// using Graph = vector<vector<Edge>>;
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  string c;
  cin >> c;
  int cnt1 = 0, cnt2 = 0;
  for (int i = 0; i < N; i++) {
    if (c[i] == 'R')
      cnt1++;
    if (c[i] == 'W')
      cnt2++;
  }

  int lidx = 0, ridx = N - 1;
  int cnt3 = 0;
  while(lidx < ridx) {
    bool findWhite = false;
    if (c[lidx] == 'W') {
      findWhite = true;
    }
    if (findWhite && c[ridx] == 'R') {
      swap(c[lidx], c[ridx]);
      cnt3++;
      lidx++, ridx--;
    } else if (findWhite && c[ridx] == 'W') {
      ridx--;
    } else {
      lidx++;
    }
  }
  cout << min(cnt1, min(cnt2, cnt3)) << endl;
  return 0;
}


Measured memory_bytes: 3720
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define _ << " _ " <<
#define TRACE(x) cerr << #x << " = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
//#define debug
//#define TRACE(x)

using namespace std;

typedef long long llint;

const int MAXN = 200010;

int n, k, par;
char s[MAXN];
deque<int> d;

void update() {
  if ((d.front() ^ par) == 0) {
    d.pop_front();
    d.push_front(par ^ 1);
    return;
  }
  d.pop_front();
  par ^= 1;
  d.push_back(par);
}

void print() {
  for (; !d.empty(); d.pop_front())
    printf(d.front() ^ par ? "B" : "A");
  printf("\n");
}

int main(void) {
  scanf("%d %d",&n,&k);
  scanf("%s",s);
  REP(i, n) d.push_back(s[i] == 'A' ? 0 : 1);

  REP(it, 2 * n) {
    update();
    if (it + 1 == k) {
      print();
      return 0;
    }
  }

  if (k % 2 == 1)
    update();
  
  print();
  
  return 0;
}


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

#define int long long

using namespace std;

vector <int> g[100001];
int u[100001];
int pr[100001];
int a, b;
vector <int> ans, ans1;

void dfs (int v) {
	u[v] = 1;
	ans.push_back (v);
	for (auto to : g[v]) {
		if (u[to]) continue;
		dfs (to);
		break;
	}
}

void dfs1 (int v) {
	u[v] = 1;
	if (v > 1) ans1.push_back (v);
	for (auto to : g[v]) {
		if (u[to]) continue;
		dfs1 (to);
		break;
	}
}

 main () {
	int n;
	int m;
	cin >> n >> m;
	for (int i = 1;i <= m;i ++) {
		int x, y;
		cin >> x >> y;
		g[x].push_back (y);
		g[y].push_back (x);
	}         
	dfs (1);	
	for (int i = 1;i <= n;i ++) reverse (g[i].begin (), g[i].end ());
	dfs1 (1);                
	reverse (ans.begin (), ans.end ());
	cout << ans.size () + ans1.size () << endl;
	for (auto to : ans) cout << to << ' ';
	for (auto to : ans1) cout << to << ' ';
	return 0;
}

Measured memory_bytes: 10868
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int n;
    cin>>n;
    int a[n+5];
    int i;
    FOR(i, 1, n+1) cin>>a[i];
    int sol[n+5];
    FORD(i, n, 1)
    {
        int cur = a[i];
        int j = 2;
        while(i*j < n+1)
        {
            cur ^= sol[i*j];
            j++;
        }
        sol[i] = cur;
    }
    vi out;
    FOR(i, 1, n+1) if(sol[i]) out.pb(i);
    int si = out.size();
    cout<<si<<endl;
    FOR0(i, si) cout<<out[i]<<" ";
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

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

int my_strcmp(char* str1, char*str2) {
	int i;

	for(i = 0; str1[i] && str2[i]; i++) {
		if(str1[i] != str2[i])
			return 0;
	}

	if(str2[i])
		return 0;

	return 1;
}

int main(void) {
	char input[1024] = {0};
	char ans[1024] = {0};

	int i;
	int j;

	fgets(input, 1024, stdin);
	for(i = 0; input[i];) {
		if(my_strcmp(input + i, "apple")) {
			strcat(ans + i, "peach");
			i += 5;
		}
		else if(my_strcmp(input + i, "peach")) {
			strcat(ans + i, "apple");
			i += 5;
		}

		while('a' <= input[i] && input[i] <= 'z') {
			ans[i] = input[i];
			i++;
		}

		while((input[i] < 'a' || 'z' < input[i]) && input[i]) {
			ans[i] = input[i];
			i++;
		}
	}

	printf("%s", ans);

	return 0;
}

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

#define endl "\n"
#define int long long int
#define mod 1000000007
#define pint pair<int,int>
#define vint vector<vector<int>>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const int N = 1e6;
int A[N];

int mat[1005][1005];

void solve(string st[], int n)
{
    int ac = 0, wa = 0, tle = 0, re = 0;
    int i;
    for(i=0;i<n;i++)
    {
        if(st[i] == "AC")
            ac++;
        else if(st[i] == "WA")
            wa++;
        else if(st[i] == "TLE")
            tle++;
        else if(st[i] == "RE")
        re++;
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
}

int32_t main()
{
    //code
	IOS;

    int t,n,m,k,i,j,x,y,a,b;

    //cin>>t;
    t=1;
    while(t--)
    {
        cin>>n;
        string st[n];
        for(i=0;i<n;i++)
        {
            cin>>st[i];
        }
        solve(st, n);
    }

	return 0;
}

Measured memory_bytes: 6768
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
bool judge(char c,char d){
  string j1 = "wi()";
  string j2 = "wi)(";
  REP(i,4)if(c==j1[i]&&d==j2[i])return true;
  return false;
}

int main(){
  string s;
  cin>>s;
  int ans = 0;
  REP(i,s.size()/2){
    if(!judge(s[i],s[s.size()-1-i]))ans ++;
  }
  if(s.size()%2 == 1){
    if(s[s.size()/2] == '(' || s[s.size()/2] == ')')ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
//#define int ll
typedef long long ll;

const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}

int main(){
    int a[3];
    rep(i,3) cin >> a[i];
    
    sort(a,a+3);
    
    cout << a[2]*10 + a[1] + a[0] << endl;
}












Measured memory_bytes: 256
use std::collections::BinaryHeap;

macro_rules! scan {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };

    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };

    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
}

fn dikstra(graph: Vec<Vec<(usize, i64)>>) -> i64 {
    let n = graph.len();
    let mut dists: Vec<_> = (0..n).map(|_| (1i64 << 60)).collect();

    let mut q = BinaryHeap::new();
    q.push((0, 1));
    while let Some((dist, v)) = q.pop() {
        for &(to, d) in graph[v].iter() {
            if -dist + d < dists[to] {
                dists[to] = -dist + d;
                q.push((dist - d, to))
            }
        }
    }
    dists[0]
}

#[test]
fn test_tuple_binheap() {
    let mut q = BinaryHeap::new();
    q.push((-3, 2));
    q.push((-2, 3));
    q.push((-1, 5));
    assert_eq!(q.pop(), Some((-1, 5)));
    assert_eq!(q.pop(), Some((-2, 3)));
    assert_eq!(q.pop(), Some((-3, 2)));
}

fn main() {
    let k = scan!(i64);

    let mut graph = Vec::new();
    for _ in 0..k {
        graph.push(Vec::new())
    }

    for i in 1..k {
        graph[i as usize].push((((i + 1) % k) as usize, 1));
        graph[i as usize].push((((10 * i) % k) as usize, 0));
    }
    println!("{}", dikstra(graph) + 1)
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i=0; i<n; i++) cin >> a.at(i);
  
  int cnt = 0;
  bool flag = true;
  while (flag) {
	for (int i=0; i<n; i++) {
		if (a.at(i) % 2 == 0) {
			a.at(i) /= 2;
        }
      	else {
			flag = false;
        }
      
    }
    if(flag) cnt++;
  }
  cout << cnt << endl;
}


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

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

  int n = s.size(), m = t.size();

  for (int i = n - m; i >= 0; i--) {
    bool ok = true;
    for (int j = 0; j < m; j++) {
      if (!(s[i + j] == t[j] || s[i + j] == '?')) ok = false;
    }
    if (ok) {
      for (int j = 0; j < i; j++) {
        if (j < i && s[j] == '?')
          cout << "a";
        else if (j < i && s[j] != '?')
          cout << s[j];
      }
      cout << t;
      for (int j = i + m; j < n; j++) {
        if (j >= i + m && s[j] == '?')
          cout << "a";
        else if (j && s[j] != '?')
          cout << s[j];
      }
      cout << endl;
      return 0;
    }
  }
  cout << "UNRESTORABLE" << endl;
}

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

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

int main() {
  int x;
  while(cin >> x && x) {
    int res = 0;
    for(int a = 2; a <= x-a; ++a) {
      if(isPrime(a) && isPrime(x-a)) ++res;
    }
    cout << res << endl;
  }
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    int64_t property = 1000;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N - 1; i++){
      if (A[i] < A[i + 1]) property = property / A[i] * A[i + 1] + property % A[i];
    }
    cout << property << endl;
}


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

counter = 0
exist_odd = 0
while 1:
  for i in range(len(A)):
    if A[i]%2 == 1:
      exist_odd = 1
    A[i] = A[i]/2
  if exist_odd == 1: break
  counter+=1

print(counter)

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <forward_list>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <string>
#include <bitset>
#include <memory>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <cstdint>

using namespace std;

set<int> prime;

void calc_prime(int mm) {
    int cur = 2;
    while(cur <= mm) {
        for(auto itr = prime.begin();itr != prime.end();itr++) {
            if(cur % *itr == 0)
                goto not_prime;
        }
        prime.insert(cur);
    not_prime:
        cur++;
    }
}

int main(void) {
    string s;
    int w;
    cin >> s;
    cin >> w;
    for(int i = 0;i < s.length();i = i + w) {
        cout << s[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
robots = []
for _ in range(n):
    x, l = map(int, input().split())
    robots.append([x-l, x+l])

robots = sorted(robots, key=lambda x: x[1])
robots.append([-2*10**9, 2*10**9])

cnt = 1
current_end = robots[0][1]
for i in range(1, n):
    if current_end <= robots[i][0]:
        cnt += 1
        current_end = robots[i][1]

print(cnt)

Measured memory_bytes: 22104
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <cmath>
#include <cassert>
#include <iostream>
#include <string>
#include <map>
#define mkp make_pair
#define IOS ios_base::sync_with_stdio(0),cin.tie(0)
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
const int maxn=1e6+5;
const int mod=998244353;
const int INF=2147483647;
int A[1005][1005];
vector<int> G[maxn];
int encode(int x,int y,int n){
	if(x<y) return x*n+y;
	else return y*n+x;
}
int vis[maxn];
int d[maxn];
bool dfs(int u){
	if(vis[u]==1) return 1;
	vis[u]=-1;
	int ma=0;
	for(int v:G[u]){
		if(vis[v]==-1) return 0;
		if(!dfs(v)) return 0;
		ma=max(ma,d[v]);
	}
	d[u]=ma+1;
	vis[u]=1;
	return 1;
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int last;
		scanf("%d",&last);
		last--;
		for(int j=2;j<n;j++){
			int x;
			scanf("%d",&x);
			x--;
			G[encode(i,last,n)].push_back(encode(i,x,n));
			last=x;
		}
	}
	int ans=0;
	for(int i=0;i<n*n;i++){
		if(i/n>=i%n) continue;
		if(!dfs(i)) return 0*puts("-1");
		else ans=max(ans,d[i]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 48640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int a, b, c;
    cin >> a >> b >> c;
    int n = a * 100 + b * 10 + c;
    string ans[2] = { "Open\n","Close\n" };
    switch (n) {
    case 100:
        cout << ans[1];
        break;
    case 10:
        cout << ans[1];
        break;
    case 110:
        cout << ans[0];
        break;
    case 1:
        cout << ans[0];
        break;
    case 0:
        cout << ans[1];
        break;
    }
}


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

using std::cin;
using std::cout;
using std::vector;
using std::pair;
using std::endl;
using std::ios_base;
using std::unordered_map;
using std::cerr;
using std::string;
using std::to_string;
using std::max;
using std::min;

const int INF = 1e9;
        
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int n;
    cin >> n;
    vector<int> dp(n + 3, INF);
    vector<int> a(n);
    for (int& i : a) cin >> i;
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(a[i] - a[i + 1]));
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(a[i] - a[i + 2]));
    }
    cout << dp[n - 1] << endl;


    return 0;
}



Measured memory_bytes: 1024
import itertools

A = int(input())
B = int(input())
C = int(input())
X = int(input())//50
count = 0

for i,j,k in itertools.product(range(A+1),range(B+1),range(C+1)):
    if i*10+j*2+k == X:
        count += 1

print(count)

Measured memory_bytes: 39408
N, M = map(int, input().split())
int_switch_repr = 2**N
light_bulbs_switches = []
for i in range(M):
  k_s = [int(x) for x in input().split()]
  k_i = k_s[0]
  light_bulbs_switches.append(k_s[1:]) # i-th light bulb
P = [int(x) for x in input().split()]  # p_i

ans = 0
for itg in range(int_switch_repr):
  binary_switch_repr = "{w:{fill}{width}b}".format(w=itg, fill='0', width=N)
  all_on = True
  for lbs_i, p_i in zip(light_bulbs_switches, P):
    is_light_on = sum([1 for sw in lbs_i if binary_switch_repr[int(sw)-1]=='1'])%2 == p_i
    if not is_light_on:
      all_on = False
  if all_on:
    ans+=1

print(ans)

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

#define reg register
#define pr std::pair<int, int>
#define fi first
#define se second
#define FIN(s) freopen(s, "r", stdin)
#define FOUT(s) freopen(s, "w", stdout)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, l, r) for (int i = l; i <= r; ++i)
#define lep(i, l, r) for (int i = l; i < r; ++i)
#define irep(i, r, l) for (int i = r; i >= l; --i)
#define ilep(i, r, l) for (int i = r; i > l; --i)
#define Rep(i, n) rep(i, 1, n)
#define Lep(i, n) lep(i, 1, n)
#define IRep(i, n) irep(i, n, 1)
#define ILep(i, n) ilep(i, n, 1)
typedef long long ll;
typedef long double ld;

namespace modular {
    const int MOD = 1000000007;
    inline int add(int x, int y) { return (x += y) >= MOD ? x -= MOD : x; }
    inline void inc(int &x, int y) { (x += y) >= MOD ? x -= MOD : 0; }
    inline int mul(int x, int y) { return 1LL * x * y % MOD; }
    inline int qpow(int x, int y) {
        int ans = 1;
        for (; y; y >>= 1, x = mul(x, x))
            if (y & 1) ans = mul(ans, x);
        return ans;
    }
};  // namespace modular

namespace Base {
    template <typename Tp>
    inline Tp input() {
        Tp x = 0, y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-') y = -1;
            c = getchar();
        }
        if (c == EOF) return 0;
        while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getchar();
        return x *= y;
    }
    template <typename Tp>
    inline void read(Tp &x) {
        x = input<Tp>();
    }
    template <typename Tp>
    inline void chmax(Tp &x, Tp y) {
        x < y ? x = y : 0;
    }
    template <typename Tp>
    inline void chmin(Tp &x, Tp y) {
        x > y ? x = y : 0;
    }
};  // namespace Base
using namespace Base;
/*----------------------------------------------------------------------------*/

#define MAX_N 5007

int N, pos[MAX_N];
ll A, B, f[MAX_N][MAX_N];

int main() {
#ifdef LOCAL
    FIN("in");
#endif
    read(N), read(A), read(B);
    Rep(i, N) pos[input<int>()] = i;
    rep(i, 0, N) rep(j, 0, N) f[i][j] = 1e16;
    f[0][0] = 0;
    Rep(i, N) {
        lep(j, 0, i) {
            if (pos[i] > pos[j]) {
                chmin(f[i][i], f[i - 1][j]);
                chmin(f[i][j], f[i - 1][j] + B);
            } else
                chmin(f[i][j], f[i - 1][j] + A);
        }
    }
    ll res = 1e16;
    rep(i, 0, N) chmin(res, f[N][i]);
    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 195840
n = int(input())
h = list(map(int, input().split()))

cnt = 0
max_cnt = 0
i = 0
while True:
    max_cnt = max(max_cnt, cnt)
    if i+1 == n:
        break
    if h[i] >= h[i+1]:
        i += 1
        cnt += 1
        max_cnt = max(max_cnt, cnt)
    else:
        max_cnt = max(max_cnt, cnt)
        cnt = 0
        i += 1
print(max_cnt)

Measured memory_bytes: 63984
k, n = gets.split(' ').map{|n| n.to_i}
a = gets.split(' ').map{|n| n.to_i}

max = 0
max_id = 0
a.each_with_index do |distance, idx|
  length = distance - a[idx-1]
  if idx == 0
    length += k
  end
  if max < length 
    max_id = idx 
    max = length
  end
end

puts k - max


Measured memory_bytes: 15364
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        NIkkei_B solver = new NIkkei_B();
        solver.solve(1, in, out);
        out.close();
    }

    static class NIkkei_B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();

            String a = in.next();
            String b = in.next();
            String c = in.next();
            int ans = 0;
            for (int i = 0; i < n; i++) {
                char x = a.charAt(i);
                char y = b.charAt(i);
                char z = c.charAt(i);

                if (x == y && y == z) {
                    continue;
                }

                if (x == y || y == z || z == x) {
                    ans++;
                    continue;
                }

                ans += 2;


            }

            out.print(ans);
        }

    }
}



Measured memory_bytes: 21844
import math
A,B,H,M=map(int,input().split())
Atheta=2*math.pi*(60*H+M)/720
Btheta=2*math.pi*M/60
theta=Atheta-Btheta
ans=math.sqrt(A**2+B**2-2*A*B*math.cos(theta))
print(ans)

Measured memory_bytes: 9400
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<int> c(n, 0), s(n, 0), f(n, 0);
    rep(i, n-1) cin >> c[i] >> s[i] >> f[i];
    c[n-1] = 0;
    s[n-1] = 0;
    f[n-1] = 0;

    rep(i, n) {
        int station = i;
        int x = s[station] + c[station];
        //cout << "station: " << station << " time: " << x << endl;
        for(int a = station+1; a <= n-1; a++) {
            if(x <= s[a]) x = s[a] + c[a];
            else {
                if(f[a] != 0) {
                    if(x % f[a] == 0) x = f[a]*(x/f[a]) + c[a];
                    else x = f[a]*(x/f[a] + 1) + c[a];
                }
            }
           // cout << "station: " << station << " time: " << x << endl;
        }
        cout << x << endl;
    }
 }



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int mod=1e9+7;

int main(){
  int n,d;cin>>n>>d;
  cout<<(n+2*d)/(2*d+1)<<endl;
}

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

int main(){
  int N;
  cin >> N;
  
  vector<int> p(N);
  
  for(int i=0; i<N; i++){
    cin >> p.at(i);
  }
  
  int cnt=0;
  
  for(int i=0; i<N; i++){
    if(p.at(i)!=i+1){
      cnt++;
    }
  }
  
  if(cnt>2){
    cout << "NO" << endl;
  }
  else{
    cout << "YES" << endl;
  }
      
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>; // グラフ型
using pint = pair<int, int>;

int main()
{
    int N;
    cin >> N;
    ll ans = 0;
    rep2(i, 1, N + 1)
    {
        if (i % 3 == 0)
        {
            continue;
        }
        if (i % 5 == 0)
        {
            continue;
        }
        ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define allof(a) (a).begin(),(a).end()
using lint = long long;
template< typename T > using Vec = vector< T >;

template< typename T > bool inRange(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool inRange(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }
template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }
inline int bitCount(int x) { return __builtin_popcount(x); }
inline int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//

int N, M;
lint dp[100005], MOD = (lint)1e9 + 7;
bool broken[100005];

int main() {
	cin >> N >> M;
	fill(broken, broken + N, false);
	for_(i,0,M) {
		int a;
		cin >> a;
		broken[a] = true;
	}
	
	fill(dp, dp + N, 0);
	dp[0] = 1;
	for_(i,0,N) {
		if (broken[i]) continue;
		modAdd(dp[i+1], dp[i], MOD);
		modAdd(dp[i+2], dp[i], MOD);
	}
	cout << dp[N] << endl;
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 1152