akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>

using namespace std;

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int r,c,n;
stack<int> stk;
vector<PII> u,b,rr,l;
void check(int i){
	if(!stk.empty()){
		if(stk.top() == i){
			stk.pop();
			return;
		}
	}
	stk.push(i);
}
int main() {
	cin >> r  >> c >> n;
	REP(i,n){
		int x1,x2,y1,y2;
		cin >> x1 >> y1 >> x2 >> y2;
		if((x1==0 || x1==r || y1==0 || y1==c) &&
				(x2==0 || x2==r || y2==0 || y2==c)){
			if(x1==0)
				l.PB(MP(y1,i));
			else if(x1==r)
				rr.PB(MP(y1,i));
			else if(y1==0)
				u.PB(MP(x1,i));
			else if(y1==c)
				b.PB(MP(x1,i));

			if(x2==0)
				l.PB(MP(y2,i));
			else if(x2==r)
				rr.PB(MP(y2,i));
			else if(y2==0)
				u.PB(MP(x2,i));
			else if(y2==c)
				b.PB(MP(x2,i));
		}
	}
	SORT(u);SORT(rr);sort(ALL(b), greater<PII>());sort(ALL(l), greater<PII>());
	bool f = false;
	EACH(i,u)check((*i).second);
	EACH(i,rr)check((*i).second);
	EACH(i,b)check((*i).second);
	EACH(i,l)check((*i).second);
	cout << (stk.size() ? "NO" : "YES") << endl;
	return 0;
}


Measured memory_bytes: 2520
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;
/*
ll bin(ll i,ll j){
	ll mid=(i+j)/2;
	if(a[mid]==x)reutrn mid;
	else if(ans>x)return bin(i,mid-1);
	else return bin(mid+1,j);
}/*
ll power(ll base,ll power){
    ll res=1;
    base=base%mod;
    while(power>0){
    	if(power&1){
    		res=(res*base)%mod;
		}
		power=power>>1;
		base=(base*base)%mod;
	}
	return res;
}
*/
/*
int nCr(int x, int y){
	if(y>x)return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}
*/
/*bool prime[n+1];
void SieveOfEratosthenes(int n){
	rep(i,0,n+1)prime[i]=true
    for (int p=2;p*p<=n;p++)
        if (prime[p])
            for (int i=p*p;i<=n;i+=p)prime[i]=false;
}*/
/*
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
*/
int solve(){
    int n;
    cin>>n;
	string s;
	cin>>s;
	int p=s.length();
	ll gcnt=0,rcnt=0,bcnt=0;
	rep(i,0,p){
		if(s[i]=='R')rcnt++;
		else if(s[i]=='G')gcnt++;
		else bcnt++;
	}
	ll cnt=0;
	rep(i,0,p){
		int j=1+i,k=2+i;
		while(k<n){
			if(s[i]!=s[j]&&s[i]!=s[k]&&s[j]!=s[k])cnt++;
			j++;k++;k++;
		}
	}
	ll ans=bcnt*gcnt*rcnt-cnt;
	cout<<ans<<endl;
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define REP(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define dup(x, y) (((x) + (y)-1) / (y))
#define PI 3.14159265359
typedef long long LL;
typedef vector<vector<int>> Graph;
typedef vector<int> Vector;
const LL MOD = 1e9 + 7;
const LL LLINF = 1LL << 60;
const int INF = 1 << 30;
template <class T> inline void chmax(T &a, T b) {
    if(a < b) {
        a = b;
    }
}
template <class T> inline void chmin(T &a, T b) {
    if(a > b) {
        a = b;
    }
}
template <class T> inline T gcd(T x, T y) {
    if(y == 0) {
        return x;
    } else if(x == 0) {
        return y;
    }
    return gcd(y, x % y);
}
template <class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template <class T> inline void print_vector(vector<T> vec) {
    for(int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    cout << endl;
}
template <class T> inline T mpower(T x, T n) {
    if(n == 0) {
        return 1;
    } else if(n % 2 == 0) {
        return mpower(x * x % MOD, n / 2);
    } else {
        return x * mpower(x, n - 1) % MOD;
    }
}
LL mfrac(LL x) {
    LL res = 1;
    for(LL i = x; i >= 1; i--) {
        res *= i;
        res %= MOD;
    }
    return res;
}
LL mcomb(LL n, LL r) {

    if(n == 0 and r == 0) {
        return 1;
    } else if(n < r || n < 0) {
        return 0;
    }

    LL res = mfrac(n) * mpower(mfrac(r), MOD - 2) % MOD;
    res *= mpower(mfrac(n - r), MOD - 2) % MOD;

    return res;
}

int main(void) {
    int M1, D1, M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;

    if(M1 == M2) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<numeric>
#include<vector>
#include<tuple>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
typedef long long ll;
const int MOD = 1e9 + 7;

string a;
int main(void)
{
	cin >> a;
	bool w=false,e=false,n=false,s=false;
	int le = a.length();
	FOR(i, 0, le) {
		switch (a[i]) {
		case 'S':
			s = true;
			break;
		case 'W':
			w = true;
			break;
		case 'N':
			n = true;
			break;
		case 'E':
			e = true;
			break;
		}
	}
	if (e == w && s == n)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#-----------にゃんにゃん準備-----------#
def nyan(f=lambda x: x): return map(f,input().split())
#------------にゃんにゃん------------#
a,b = nyan(int)
print(max(a,b)*2-int(a!=b))
#---------にゃんにゃんおしまい---------#

Measured memory_bytes: 2940
A, B, C = map(int, input().split())
K = int(input())
flag = 0
if A < B and B < C:
    flag = 1

for i in range(K):
    Bcp = B
    Ccp = C
    for j in range(i):
        Bcp *= 2
    for j in range(K-i):
        Ccp *= 2
    if A < Bcp and Bcp < Ccp:
        flag = 1
    #print(A, Bcp, Ccp)
if flag == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61700
#include <cstdio>
#include <cstdlib>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){

  while(x->left != NIL){
      x = x->left;
    }

  return x;
}

Node treeMaximum(Node x){

  while(x->right != NIL){
    x = x->right;
  }

  return x;
}

Node treeSearch(Node u, int k){
  Node x;

  x = u;
  while(x->key != NIL){ 
    if(k < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
    if(k == x->key) return x;
  }
  
  return NIL;
}

Node treeSuccessor(Node x){
  Node y;
  
  if(x->right != NIL) return treeMinimum(x->right);

  y = x->parent;
  
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = (Node)malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x-> right;
  }
  z->parent = y;
  
  if(y == NIL) root = z;
  else{
    if(z->key < y->key) y->left = z;
    else y->right = z;
  }
}

void inorder(Node u){

  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){

  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 26116
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    final String s=new Scanner(System.in).next();
    final char[] S=s.toCharArray();
    boolean flg=false;
    for(int i=0;i<s.length();i++){
      if(i%2==1){
        if(S[i]!='L'){
          if(S[i]!='U'){
            if(S[i]!='D'){
              flg=true;
            }
          }
        }
      }else{
        if(S[i]!='R'){
          if(S[i]!='U'){
            if(S[i]!='D'){
              flg=true;
            }
          }
        }
      }
    }
    if(flg){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }
  }
}

Measured memory_bytes: 21076
n, m = map(int, input().split())
mod = 10**9+7
nums = 5*(10**5) # 制約に合わせよう

g1, g2, inverse = [1, 1] , [1, 1], [0, 1]
 
for num in range(2, nums + 1):
    g1.append((g1[-1] * num) % mod)
    inverse.append((-inverse[mod % num] * (mod//num)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)
    
def nPr(n, r):
    return g1[n] * g2[n-r] % mod

def nCr(n, r):
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

ans = 0
for r in range(n+1):
    tmp = nCr(n, r)*nPr(m, r)*(nPr(m-r, n-r)**2)%mod
    ans = (ans+(-1)**r*tmp)%mod
print(ans)

Measured memory_bytes: 68812
#include <algorithm>
#include <iostream>

using namespace std;

namespace {

class Cube {
 private:
  enum Face {
    TOP,     // 1
    FRONT,   // 2
    RIGHT,   // 3
    LEFT,    // 4
    BACK,    // 5
    BOTTOM,  // 6
  };

 public:
  Cube(const int* face) { copy(face, face + 6, face_); }

  // to east
  void rotate_x() { rotate(TOP, LEFT, BOTTOM, RIGHT); }
  // to north
  void rotate_y() { rotate(TOP, FRONT, BOTTOM, BACK); }

  void rotate_z() { rotate(FRONT, LEFT, BACK, RIGHT); }

  bool equal_faces(const Cube& other) const {
    for (int i = 0; i < 6; ++i) {
      if (face_[i] != other.face_[i])
        return false;
    }
    return true;
  }

 private:
  void rotate(Face f1, Face f2, Face f3, Face f4) {
    const int t = face_[f1];
    face_[f1] = face_[f2];
    face_[f2] = face_[f3];
    face_[f3] = face_[f4];
    face_[f4] = t;
  }

  int face_[6];
};

// Check two dices are identical.
inline bool operator==(const Cube& a, const Cube& b) {
  Cube c = b;
  // http://www.prefield.com/algorithm/misc/dice.html
  for (int i = 0; i < 6; ++i) {
    for (int j = 0; j < 4; ++j) {
      if (a.equal_faces(c))
        return true;
      c.rotate_z();
    }
    if (i % 2 == 1)
      c.rotate_x();
    else
      c.rotate_y();
  }
  return false;
}

}  // namespace

int main() {
  int face1[6];
  int face2[6];
  for (int i = 0; i < 6; ++i)
    cin >> face1[i];
  for (int i = 0; i < 6; ++i)
    cin >> face2[i];

  const Cube c1(face1);
  const Cube c2(face2);
  if (c1 == c2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3092
def tmpq4(n,alist):
    akouho = []
    for tmpi,ai in enumerate(alist):
        i = tmpi+1
        if(ai<=i):
            akouho.append(ai)
    if(n==len(akouho)):
        return akouho
    return tmpq4(len(akouho),akouho)

def q4(n,alist):
    alis = tmpq4(n,alist)
    alis = list(set(alis))
    anslist=[]
    for i in range(len(alis)):
        if((i+1)==alis[i]):
            anslist.append(alis[i])
        else:
            break
    if(len(anslist)>0):
        return (n-len(anslist))
    else:
        return -1
    
n= int(input())
alisttmp = input().split()
alist = []
for num in alisttmp:
    alist.append(int(num))
    
print(q4(n,alist))

Measured memory_bytes: 39968
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int M,N,sum=0;
    cin >> N >> M;
    vector<int> A(N);
    rep(i,N){
        cin >> A.at(i);
        sum += A.at(i);
    }
    int cnt=0;
    rep(i,N){
        if(A.at(i)*4*M >= sum)cnt++;
    }
    if(cnt >= M)cout << "Yes" << endl;
    else cout << "No" << endl;
}   

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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(),(V).end()

using namespace std;
typedef long long ll;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;
const double EPS = 1e-10;

int main(){

    int h,w,k;
    cin >> h >> w >> k;
    vector<vector<int>> v(h, vector<int>(w));

    rep(i, h){
        rep(j, w){
            char tmp;
            cin >> tmp;

            if(tmp == '#') v[i][j] = 1;
        }
    }

    int ans = 0;

    for(int bith = 0; bith < (1<<h); bith++){
        for(int bitw = 0; bitw < (1<<w); bitw++){
            int count = 0;
            rep(i, h){
                rep(j, w){
                    if((bith & (1<<i)) || (bitw & (1<<j))){

                    }else{
                        if(v[i][j]) count++;
                    }
                }
            }

            if(count == k) ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> x(n);
	rep(i, n) cin >> x[i];
	sort(all(x));
	int ans = inf;
	for (int i = 1; i <= 100; ++i) {
		int tmp = 0;
		rep(j, n) {
			tmp += (i - x[j]) * (i - x[j]);
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  int A,B;
  cin >> A >> B;
  int count = 0;
  for(int i = A; i <B+1;i++){
  if(i /10000 == i %10 && (i / 1000) % 10 == (i / 10) % 10){
  count += 1;
  }
  }
  cout << count;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

 
int main(){
  string s;
  cin >> s;
  if(s[2]==s[3]&&s[4]==s[5]){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;

int main() {
    vi A = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int K;
    cin >> K;

    cout << A.at(K-1) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	char x[1005];
	int n,w,s,e,i,len;
	while(~scanf("%s",x))
	{
		n=w=s=e=0;
		len=strlen(x);
		for(i=0;i<len;i++)
		{
			if(x[i]=='S') s++;
			else if(x[i]=='W') w++;
			else if(x[i]=='N') n++;
			else if(x[i]=='E') e++;
		}
		if((n==0&&s!=0)||(n!=0&&s==0)||(w==0&&e!=0)||(e==0&&w!=0))
		printf("No\n");
		else printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
int main(){
    std::string s;std::cin>>s;
    int n=s.length();
    long long ans=0;
    for(int i=0,j=0;j<n;){
        for(;j<n&&s.at(j)=='<';j++);
        long long a=j-i;i=j;
        for(;j<n&&s.at(j)=='>';j++);
        long long b=j-i;i=j;
        ans+=a*(a+1)/2+b*(b+1)/2-std::min(a,b);
    }
    std::cout<<ans<<std::endl;
}



Measured memory_bytes: 900
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
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...));
}
const int MOD = 1000000007;

int main(){
    ll A, V; cin >> A >> V;
    ll B, W; cin >> B >> W;
    ll T; cin >> T;

    ll diff = V-W;
    if (diff <= 0){
        cout << "NO" << endl;
        return 0;
    }

    ll diff_p = abs(A-B);

    if ((diff_p+(diff-1))/diff <= T){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

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

using namespace std;

void fastio() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
}

int main() {
	fastio();
	int n, d; cin >> n >> d;
	int ans = 0;
	for (int i=1; i<=n; i++) {
		double x, y; cin >> x >> y;
		if (sqrt(x*x + y*y) <= d) ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3860
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;





int main(){
  ll n,c;
  cin >> n >> c;
  ll d[c+1][c+1];
  if(n == 1){
    cout << 0 << endl;
    return 0;
  }
  rep(i,1,c+1){
    rep(j,1,c+1){
      cin >> d[i][j];
    }
  }
  ll a[n][n];
  REP(i,n){
    REP(j,n){
      cin >> a[i][j];
    }
  }
  ll num[3][c+1];
  REP(i,3){
    REP(j,c+1){
      num[i][j] = 0;
    }
  }
  REP(i,n){
    int x = 0;
    if(i%3 == 1){
      x = 2;
    }
    else if(i%3 == 2){
      x = 1;
    }
    for(int j = x;j < n;j += 3){
      num[0][a[i][j]]++;
    }
  }
  REP(i,n){
    int x = 1;
    if(i%3 == 1){
      x = 0;
    }
    else if(i%3 == 2){
      x = 2;
    }
    for(int j = x;j < n;j += 3){
      num[1][a[i][j]]++;
    }
  }
  REP(i,n){
    int x = 2;
    if(i%3 == 1){
      x = 1;
    }
    else if(i%3 == 2){
      x = 0;
    }
    for(int j = x;j < n;j += 3){
      num[2][a[i][j]]++;
    }
  }
  /*
  REP(i,3){
    rep(j,1,c+1){
      cout << num[i][j] << "    " ;
    }
    cout << endl;
  }
  */
  ll res[3][c+1];
  REP(i,3){
    REP(j,c+1){
      res[i][j] = 0;
    }
  }
  REP(i,3){
    rep(j,1,c+1){
      rep(k,1,c+1){
	//cout << num[i][k] << "   "  << d[k][j] << endl;
	res[i][j] += num[i][k]*d[k][j];
      }
    }
  }
  /*
  REP(i,3){
    rep(j,1,c+1){
      cout << res[i][j] << endl;
    }
  }
  */
  ll r = 1e18;
  rep(i,1,c+1){
    rep(j,1,c+1){
      rep(k,1,c+1){
       
	if(i != j && j != k && i != k){
	  ll b;
	  b = res[0][i]+res[1][j]+res[2][k];
	  r = min(r,b);
	}
      }
    }
  }
  cout << r << endl;
  return 0;
}


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

using namespace std;

const int ms = 55555 + 1;
bool arr[ms];

void fill_arr()
{
    for(int i = 0; i <= ms; ++i)
        arr[i] = true;
}

void erat()
{
    fill_arr();
    arr[0] = arr[1] = false;

    for(int i = 2; i < ms; ++i)
    {
      //  cout << i << '\n';
        if(arr[i])
        {
            if(i * 1ll * i < ms)
                for(int j = i * i; j < ms; j += i)
                    arr[j] = false;
        }

    }
}

int main()
{
    int n, counter = 0;
    cin >> n;

    erat();

    //cout << "JOPA\n";

    for(int i = 0; i < ms && counter < n; ++i)
        if(arr[i])
        {
            if(i % 5 == 1)
            {
                ++counter;
                cout << i << ' ';
            }

        }

}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
int f[2][303][303][3],n,m;
vector<pii> ask[303];
int&F(int x,int a,int b,int c)
{
	if(a==x) return f[x&1][b][c][0];
	if(b==x) return f[x&1][a][c][1];
	return f[x&1][a][b][2];
}
const int MOD=1e9+7;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int l,r,x;
		scanf("%d%d%d",&l,&r,&x);
		ask[r].pb(pii(l,x));
	}
	f[0][0][0][0]=1;
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		memset(f[i&1],0,sizeof f[0]);
		for(int j=0;j<=i;j++)
		{
			for(int k=0;k<=i;k++)
			{
				for(int g=0;g<3;g++)
				{
					if(f[(i&1)^1][j][k][g]);else continue;
					int x[3];
					if(g==0) x[0]=i-1,x[1]=j,x[2]=k;
					else if(g==2) x[0]=j,x[1]=i-1,x[2]=k;
					else x[0]=j,x[1]=k,x[2]=i-1;
					for(int l=0;l<3;l++)
					{
						int w[3]={x[0],x[1],x[2]}; w[l]=i;
						int&p=F(i,w[0],w[1],w[2]);
						p=(p+f[(i&1)^1][j][k][g])%MOD;
					}
				}
			}
		}
		for(int j=0;j<=i;j++)
		{
			for(int k=0;k<=i;k++)
			{
				for(int g=0;g<3;g++)
				{
					if(f[i&1][j][k][g]);else continue;
					int x[3];
					if(g==0) x[0]=i,x[1]=j,x[2]=k;
					else if(g==2) x[0]=j,x[1]=i,x[2]=k;
					else x[0]=j,x[1]=k,x[2]=i;
					bool ok=1;
					for(auto j:ask[i])
					{
						int A=j.fi,B=j.se,cn=0;
						for(int p=0;p<3;p++)
							cn+=(x[p]>=A);
						if(cn!=B) {ok=0; break;}
					}
					if(!ok) f[i&1][j][k][g]=0;
					if(i==n) ans+=f[i&1][j][k][g];
				}
			}
		}
	}
	ans=(ans%MOD+MOD)%MOD;
	printf("%d\n",int(ans));
}


Measured memory_bytes: 2432
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn solve(mut a: Vec<i64>) -> bool {
  a.sort();
  let n = a.len();
  if n % 3 != 0 {
    return a[n-1] == 0;
  }
  let m = n / 3;
  if a[m-1] == 0 && a[m] == a[n-1] {
    return true;
  }
  if a[0] == a[m-1] && a[m] == a[2*m-1] && a[2*m] == a[n-1] {
    return a[0] ^ a[m] ^ a[2*m] == 0;
  }
  return false;
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    a: [i64; n],
  }


  puts!("{}\n", if solve(a) { "Yes" } else { "No" });
}


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

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

int minTime(vector<int> &arr) {
  int time = 24;
  vector<int> c;
  rep(i, arr.size()) if (arr[i] >= 1) c.push_back(i);

  rep(i, c.size() - 1) time = min(time, c[i + 1] - c[i]);
  time = min(time, 24 - c.back());
  return time;
}

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

  vector<int> d(n);
  rep(i, n) cin >> d[i];

  map<int, int> mp;
  rep(i, n) {
    if (d[i] >= 13) d[i] = 24 - d[i];
    mp[d[i]]++;
  }

  for (auto x : mp) {
    if ((x.first == 0 && x.second >= 1) || (x.first == 12 && x.second >= 2) ||
        (x.first != 0 && x.first != 12 && x.second >= 3)) {
      cout << 0 << endl;
      return 0;
    }
  }

  int ans = 0;
  for (int i = 0; i < (1 << 11); i++) {
    vector<int> time(24, 0);
    time[0] = 1;
    if (mp.count(12)) time[12] = 1;
    bool good = true;
    rep(j, 11) {
      if (i & (1 << j)) {
        if (mp[(j + 1)] == 2) time[(j + 1)] = 1, time[(24 - (j + 1))] = 1;
        if (mp[(j + 1)] == 1) time[(j + 1)] = 1;
      } else {
        if (mp[(j + 1)] == 2) good = false;
        if (mp[(j + 1)] == 1) time[24 - (j + 1)] = 1;
      }
    }
    
    if (!good) continue;
    int t = minTime(time);
    ans = max(ans, t);
  }

  cout << ans << endl;
}


Measured memory_bytes: 3544
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
//#define rep(i, n) for(int (i) = 0, TmP = (n); (i) < (int)TmP ; ++(i))
#define asort(v, n) sort((v), (v + n)) //Using array
#define vsort(v) sort((v).begin(), (v).end()) // Using vector
#define vint vector<int>
typedef long long ll;

using namespace std;

signed main(){
  string a, b;
  cin >> a >> b;

  int l = a.size();
  for(int i = 0; i < l; i++){
    if(a[i] != b[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


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

using namespace std;

#define ll long long int
#define get(a) ll a; cin >> a;
#define show(a) cout << a << endl;
#define full(p) p.begin(), p.end()
#define sz(a) (ll)(a.size())
#define pb push_back

int find_diff(vector<int> &v, int d)
{
	int total = 0;
	for (int i = 0; i < v.size(); ++i)
	{
		total += (d - v[i])*(d-v[i]);
	}
		// cout << d << " " << total << endl;

	return total;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout<<fixed;
	////////////////////////////////
	get(n);
	std::vector<int> v;
	ll start = INT_MAX;
	ll end = 0;
	for (int i = 0; i < n; ++i)
	{
		get(ni);
		start = min(start, ni);
		end = max(end, ni);
		v.push_back(ni);
	}
	int total = INT_MAX;
	for(int i = start ; i<= end ; i++)
	{
		total = min(total, find_diff(v, i));
	}
	cout << total << endl;
	return 0;
}

Measured memory_bytes: 3616
import java.util.*;

public class Main {
	int h, w, c;
	int[][] cost, costzero;
	int[][][] map;
	ArrayList<Integer> stack = new ArrayList<Integer>();
	int ans=0;
	int sum=0;
		
	public void zero(){
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cost[i][j]=0;
			}
		}
	}
	
	public void change(int z, int y, int x, int a){
		int b = map[z-1][0][0];
		map[z][y][x]=a;
		if(y!=0 && map[z][y-1][x]==0 && map[z-1][y-1][x]==b)change(z, y-1, x, a);
		if(x!=0 && map[z][y][x-1]==0 && map[z-1][y][x-1]==b)change(z, y, x-1, a);
		if(y!=h-1 && map[z][y+1][x]==0 && map[z-1][y+1][x]==b)change(z, y+1, x, a);
		if(x!=w-1 && map[z][y][x+1]==0 && map[z-1][y][x+1]==b)change(z, y, x+1, a);
	}
	
	public void check(int y, int x){
		cost[y][x]=1;
		sum++;
		if(y!=0 && map[5][y-1][x]==c && cost[y-1][x]==0)check(y-1, x);
		if(x!=0 && map[5][y][x-1]==c && cost[y][x-1]==0)check(y, x-1);
		if(y!=h-1 && map[5][y+1][x]==c && cost[y+1][x]==0)check(y+1, x);
		if(x!=w-1 && map[5][y][x+1]==c && cost[y][x+1]==0)check(y, x+1);
	}
	
	public void fill(int z, int f){
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(f==0)map[z][i][j]=0;
				if(f==1 && map[z][i][j]==0)map[z][i][j]=map[z-1][i][j];
			}
		}
	}
	
	public void func(int s){
		if(s!=5){
			for(int i=1;i<7;i++){
				if(s==4)i=c;
				if(i!=map[s][0][0]){
					stack.add(i);
					change(s+1,0,0,i);
					fill(s+1,1);
					func(s+1);
				}
				if(s==4)i=7;
			}
		}
		if(s==5){
			check(0,0);
			if(sum>ans)ans=sum;
			zero();
			sum=0;
		}
		fill(s,0);
		if(stack.size()!=0)stack.remove(stack.size()-1);
	}
	
	
	public static void main(String[] args) {
		Main C = new Main();
		Scanner sc = new Scanner(System.in);
		int exit=0;
		while(exit==0){
			C.h = sc.nextInt();
			C.w = sc.nextInt();
			C.c = sc.nextInt();
			if(C.h==0 && C.w==0 && C.c==0)exit=1;
			if(exit==0){
				C.map = new int[6][C.h][C.w];
				C.cost = new int[C.h][C.w];				
				for(int i=0;i<C.h;i++){
					for(int j=0;j<C.w;j++){
						C.map[0][i][j]=sc.nextInt();
					}
				}
				C.func(0);
				System.out.println(C.ans);
				C.ans=0;
			}
		}
	}
	
}

Measured memory_bytes: 81740
/* warshall_floyd.cpp
    ワーシャルフロイド法を用いて、全点間最短路を求める。

    初期化：dis[i][j] = iからjへの距離(辺がなければINF) (i≠j)
            dist[i][i] = 0
            prev[i][j] = i

    負閉路の検出：dis[i][i] < 0 となる i が存在するか

    verified:
        http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_C&lang=ja
*/

#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e17;

/* warshall_floyd(dist,prev)
    入力：初期化した dist, prev
    計算量：O(|V|^3)
    副作用：dis[i][j]にiからjへの最短路のコストを格納、prev[i][j]にiからjへの最短路でのjの1つ前の点を格納
*/
void warshall_floyd(vector<vector<long long>> &dist, vector<vector<long long>> &prev) {
    int V = dist.size();
    for (int k = 0; k < V; k++) {
        for (int i = 0; i < V; i++) {
            for (int j = 0; j < V; j++) {
                if (dist[i][k] + dist[k][j] < dist[i][j]) {
                    dist[i][j] = dist[i][k] + dist[k][j];
                    prev[i][j] = prev[k][j];
                }
            }
        }
    }
}

/* get_path(prev, s, t)
    入力：warshall_floyd で得た prev, スタート s, ゴール t
    出力：s から t への最短路のパス
*/
vector<int> get_path(const vector<vector<long long>> &prev, int s, int t) {
    vector<int> path;
    for (int cur = t; cur != s; cur = prev[s][cur]) {
        path.push_back(cur);
    }
    path.push_back(s);
    reverse(path.begin(), path.end());
    return path;
}

/* is_negative(dist)
    入力：warshall_floyd で得た dist
    出力：負の有向路を含むかどうか
*/
bool is_negative(const vector<vector<long long>> &dist) {
    int V = dist.size();
    for (int i = 0; i < V; i++) {
        if (dist[i][i] < 0) {
            return true;
        }
    }
    return false;
}

int main() {
    int H, W;
    cin >> H >> W;

    // initialization
    vector<vector<long long>> dist(10, vector<long long>(10, INF));
    vector<vector<long long>> prev(10);
    for (int i = 0; i < 10; ++i) {
        dist[i][i] = 0;
        prev[i] = vector<long long>(10, i);
    }

    // input
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> dist[i][j];
        }
    }

    warshall_floyd(dist, prev);

    long long ans = 0;
    vector<vector<int>> A(H, vector<int>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> A[i][j];
            if (A[i][j] != -1) {
                ans += dist[A[i][j]][1];
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A, V;
    cin >> A >> V;
    int B, W;
    cin >> B >> W;
    int T;
    cin >> T;
    int L;
    L = abs(A-B);
    if (L <= T*(V-W)) cout << "YES" << "\n";
    else cout << "NO" << "\n";
}

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

int main(void) {
    char a[5];
    char b[5];
    char btoa[5] = {};
    char atob[5] = {};
    int count = 0;
    int i, j = 0;

    gets(a);
    gets(b);

    for (i = 0; b[i] != '\0'; i++){
        count++;
    }   
    for (i=count - 1; i>= 0; i--){
       // printf("%c", b[i]);
        btoa[j] = b[i];
        j++;
    }
    count = 0;
    j = 0;
    for (i = 0; a[i] != '\0'; i++){
        count++;
    }   
    for (i=count - 1; i>= 0; i--){
        //printf("%c", a[i]);
        atob[j] = a[i];
        j++;
    }
    if(strcmp(btoa,a)==0 && strcmp(atob,b)==0){
        printf("YES");
    }else printf("NO");

    return 0;
}

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

#define int int64_t
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,n) for(int i=1; i<=(n); ++i)
const long long mod = 1000000007;

int h,w,dp[1010][1010];
string str[3010];
signed main(){

    cin>>h>>w;
    dp[0][0] = 1;

    rep(i,h){
        cin>>str[i];
    }

    rep(i,h){
        rep(j,w){
            if(str[i+1][j] != '#') dp[i+1][j] += (dp[i][j]) % mod;
            else dp[i+1][j] = 0;
            if(str[i][j+1] != '#') dp[i][j+1] += (dp[i][j]) % mod;
            else dp[i][j+1] = 0;
        }
    }

    cout<<dp[h-1][w-1] % mod<<'\n';
}

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

int main(){
	int x;
  	cin >> x;
  	cout << (x ? 0 : 1) << endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a[100000],ans=1,t=2;
  cin>>n>>a[0];
  for(int i=1;i<n;i++){
    cin>>a[i];
    if(t==2&&a[i-1]<a[i])t=1;
    if(t==2&&a[i-1]>a[i])t=0;
    if(a[i-1]>a[i]&&t==1)ans++,t=2;
    if(a[i-1]<a[i]&&t==0)ans++,t=2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline
n,m = map(int, input().split())
A = set()
for i in range(m):
    a = int(input())
    A.add(a)
mod = (10**9)+7
dp = [1] + [0]*(n)
for i in range(1,n+1):
    if i in A:
    #リストに対するinは激遅なのでset
        dp[i] == 0
    else:
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= mod
print(dp[-1])

Measured memory_bytes: 47832
#include<stdio.h>
int main()
{
	int n,h[200],m[200],flg[200]={0};
	int t,a,i,j;
	a=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&h[i],&m[i]);
	}
	scanf("%d",&t);
	for(i=n;i<t+n;i++){
		scanf("%d %d",&h[i],&m[i]);
	}
	for(i=0;i<n+t-1;i++){
		for(j=i+1;j<n+t;j++){
			if(h[i]>h[j]||h[i]==h[j]&&m[i]>m[j]){
				a=h[i];
				h[i]=h[j];
				h[j]=a;
				
				a=m[i];
				m[i]=m[j];
				m[j]=a;
			}	
		}
	}
	for(i=0;i<n+t-1;i++){
		if(flg[i]!=1){
			if(h[i]==h[i+1]&&m[i]==m[i+1]){
				flg[i+1]=1;
			}
		}
	}
	if(m[0]<10){
		printf("%d:0%d",h[0],m[0]);
	}
	else{
		printf("%d:%d",h[0],m[0]);
	}
	for(i=1;i<n+t;i++){
		if(flg[i]==0){
			if(m[i]<10){
				printf(" %d:0%d",h[i],m[i]);
			}
			else{
				printf(" %d:%d",h[i],m[i]);
			}
		}
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2144
object Main extends App {
  val a = scala.io.StdIn.readInt()
  val b = scala.io.StdIn.readInt()
  if ((a == 1 && b == 2) || (a == 2 && b == 1)) {
    println(3)
  } else if((a == 1 && b == 3) || (a == 3 && b == 1))  {
    println(2)
  } else {
    println(1)
  }

}

Measured memory_bytes: 25396
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	for _, w := range []string{"eraser", "erase", "dreamer", "dream"} {
		s = strings.Replace(s, w, "", -1)
	}

	if s == "" {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

bool comp(int a, int b){
    return (a<b);
}

int main(){
    string a, b; cin >> a >> b;
    if(a<b){
        REP(i,0,stoi(b)) cout << a;
    }
    else{
        REP(i,0,stoi(a)) cout << b;
    }
    cout << endl;
    return 0;
}

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

x = 0
for i,a in enumerate(A):
    if i%2==0:
        x += a
    else:
        x -= a
ans = [str(x)]
for i in range(1,N):
    x = 2*A[i-1] - x
    ans.append(str(x))

print(' '.join(ans))

Measured memory_bytes: 74340
from time import *
from random import *
t=time()
T0,T1=2000,600
Tt=2000
D=int(input())
C=list(map(int,input().split()))
S=[list(map(int,input().split())) for i in range(D)]
X=[0]*26
XX=[0]*26
P=[]
for i in range(D):
  for j in range(26):
    X[j]+=C[j]
    XX[j]+=X[j]
  P.append([])
  for j in range(26):
    P[i].append(j)
  P[i].sort(reverse=True,key=lambda x:X[x]+S[i][x])
  XX[P[i][0]]-=X[P[i][0]]
  X[P[i][0]]=0
SC,SC2=0,0
for i in range(D):
  SC+=S[i][P[i][0]]
YY=[]
Y=[]
A,B=0,0
e=0
E=1
for i in range(50):
  e+=E
  E*=1/(i+1)
def f(x):
  global e,Tt
  if x>=0:
    return True
  else:
    return randrange(0,10000000)<=pow(e,x/Tt)
CO=0
for l in range(12):
  for k in range(25):
    for i in range(D):
      SC2=SC
      YY=XX[:]
      Y=X[:]
      SC2-=S[i][P[i][0]]
      SC2+=S[i][P[i][k+1]]
      for j in range(26):
        Y[j]=0
      YY[P[i][0]],YY[P[i][k+1]]=0,0
      for j in range(D):
        if j==i:
          Z=P[j][k+1]
        else:
          Z=P[j][0]
        Y[P[i][0]]+=C[P[i][0]]
        Y[P[i][k+1]]+=C[P[i][k+1]]
        Y[Z]=0
        YY[P[i][0]]+=Y[P[i][0]]
        YY[P[i][k+1]]+=Y[P[i][k+1]]
      if f((SC2-sum(YY))-(SC-sum(XX))):
        P[i].insert(0,P[i][k+1])
        del P[i][k+2]
        XX=YY[:]
        SC=SC2
      CO+=1
      if CO%500==0:
        Tt=pow(T0,1-(time()-t))*pow(T1,time()-t)
    for i in range(D-1):
      SC2=SC
      YY=XX[:]
      Y=X[:]
      A=i
      B=randrange(A+1,D)
      SC2-=S[A][P[A][0]]+S[B][P[B][0]]
      SC2+=S[A][P[B][0]]+S[B][P[A][0]]
      for j in range(26):
        Y[j]=0
      YY[P[A][0]],YY[P[B][0]]=0,0
      for j in range(D):
        if j==A:
          Z=P[B][0]
        elif j==B:
          Z=P[A][0]
        else:
          Z=P[j][0]
        Y[P[A][0]]+=C[P[A][0]]
        Y[P[B][0]]+=C[P[B][0]]
        Y[Z]=0
        YY[P[A][0]]+=Y[P[A][0]]
        YY[P[B][0]]+=Y[P[B][0]]
      if f((SC2-sum(YY))-(SC-sum(XX))):
        P[A],P[B]=P[B][:],P[A][:]
        XX=YY[:]
        SC=SC2
      CO+=1
      if CO%500==0:
        Tt=pow(T0,1-(time()-t))*pow(T1,time()-t)
for i in range(D):
  print(P[i][0]+1)

Measured memory_bytes: 91152
/* Bismillahir Rahmanir Rahim */

#include <bits/stdc++.h>

#define rep(i, n)	for(int i=0;i<int(n);i++)
#define repn(i, n)	for(int i=1;i<=int(n);i++)
#define set(i, n)	memset(i, n, sizeof(i))

#define pb	push_back
#define f	first
#define s	second

using namespace std;

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

long long x;

bool OK(ll f){
	ll d = (f * (f+1LL)) / 2LL;
	if(d >= x) return true;
	else return false;
}

int main(){
	cin >> x;
	ll lo = 0, hi = x, ret = x;
	while(lo <= hi){
		ll mid = (lo + hi) / 2LL;
		if(OK(mid)) ret = mid, hi = mid - 1;
		else lo = mid + 1;
	}
	cout << ret << endl;
	return 0;
}



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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, k,  m, y, q ;
string s, t;
ld w;

// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> s;
	ll cou = 1;
	for(ll i=1;i<n;i++) cou+=(s[i]!=s[i-1]);
	cout<<cou; 
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 3724
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;
void solve() {
    LL a,v,b,w,t;
    R(a,v,b,w,t);
    if(v<=w)W("NO");
    else{
        W((v-w)*t>=abs(a-b)?"YES":"NO");
    }
}
int main(){
#define MULTITEST 0
#if MULTITEST    
    CASET{
        solve();
    }
#else
    solve();
#endif
    return 0;
}


Measured memory_bytes: 3688
import java.util.*

fun main(arg: Array<String>) {
    val x = readLine()!!.toInt()
    val n = readLine()!!.split(" ")
                        .map(String::toInt)
                        .reversed()
    for (i in 0..(x-1)) {
        if (i == (x-1)) {
            println(n[i])
            break
        }
        print(Integer.toString(n[i]) + " ")
    }
}


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

int main(void)
{
	char s[101],p[101],s2[201];
	int i,ck;
	
	
	scanf("%s",s);
	scanf("%s",p);
	
	strcpy(s2,s);
	strcat(s2,s);
	
	
	i=0;
	ck=0;
	while((strlen(p)+i) <= (strlen(s2)))
	{
		if(strncmp(&s2[i],p,strlen(p))==0)
		{
			ck=1;
			break;
		}
			
		i++;
	}
	
	if(ck)
		printf("Yes\n");
	else
		printf("No\n");
	
	return 0;
}

Measured memory_bytes: 548
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a, b = 0, n, k;
string s, t;
//cout<<<<endl;


int main()
{
	int x, y;
	cin >> x;
	
	cout << (x-1)/2<< endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
const int N = 2e5 + 100;

int n, a[N];

int main() {
	
	cin >> n;
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	
	int ans = 0, pos = 1;
	while(pos) {
		ans++;
		int tmp = pos;
		pos = a[pos];
		a[tmp] = 0;
		
		if(pos == 2) {
			printf("%d\n", ans);
			return 0;
		}
	}
	
	puts("-1");
	return 0;	
} 

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

int main(){
    int n;
    int mon=100000;
    cin>>n;
    for(int i=0; i<n;i++){
        int sum=mon*1.05;
        int num=(sum+999)/1000;
        mon=num*1000;
    }
    cout<<mon<<endl;
    return 0;
}

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

int main(){
  int N;
  int A[2][101];

  cin >> N;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < N; j++) cin >> A[i][j];
  }

  int max = 0;

  for (int i = 0; i < N; i++) {
    int y = 0;
    int candies = 0;
    int count[2][101] = {0};
    for (int j = 0; j < N; j++) {
      if (i == j) {
        y++;
        candies += A[y-1][j] + A[y][j];

      }
      else{
        candies += A[y][j];
      }
    }
    if (candies >= max) {
      max = candies;
    }
  }

  cout << max << endl;

  return 0;
}


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

s = (10**9) // 2
step = s
best= 999999999999
import math

for j in range(50):
  c = 0
  arr = list(f)

  for i in range(n):
    if arr[i] > s:
      v = 0
      if arr[i] % s != 0:
        c += arr[i] // s
        v += arr[i] // s
      else:
        c += arr[i] // s
        v += arr[i] // s
        c -= 1
        v -= 1
      cor = 0
      if arr[i] % (v+1) != 0:
        cor = 1
      arr[i] = arr[i]//(v+1) + cor
    
  step = step//2
  step = max(1, step)
 
  if c<=k:
    best = min(best,max(arr))
   # print(s,best)
    s -= step
  else:
    s += step
    
  if s==0:
    s=1
      
print(best)

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

for i in range(N):
  if A[i] % 2 == 0:
    if A[i] % 3 == 0 or A[i] % 5 == 0:
      continue
    else:
      print('DENIED')
      exit()

print('APPROVED')

Measured memory_bytes: 3060
import Data.Maybe
import Text.Printf
import qualified Data.ByteString.Char8 as C

getInts :: IO [Int]
getInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  [a, b, c, d] <- getInts
  printf "%d\n" $ maximum [a * c, a * d, b * c, b * d]


Measured memory_bytes: 4020