akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

const int N_MAX = 100000;
const int H_MAX = 1000000000;

long n,a,b;
long h[N_MAX + 10];
long tmp_h[N_MAX + 10];

bool enough(long t);

int main(){
  cin >> n >> a >> b;
  for(int i = 0;i<N_MAX+10;i++)
    h[i] = -1;
  for(int i = 0;i<n;i++)
    cin >> h[i];

  long t = H_MAX/2;
  long low = 0;
  long high = H_MAX;

  // binary search
  while(true){
    if(enough(t)){
      high = t;
    }else{
      low = t;
    }
    t = (high + low)/2;
    if(low >= t){
      cout << (low+1) << endl;
      return 0;
    }
  }
}


bool enough(long t){
  for(int i = 0;i<N_MAX;i++)
    tmp_h[i] = h[i];
  
  for(int i=0;i<n;i++)
    if(tmp_h[i] != -1){
      tmp_h[i] -= t * b;
      if(tmp_h[i] <= 0) tmp_h[i] = -1;
    }

  long count = 0;
  for(int i = 0;i<n;i++){
    if(tmp_h[i] != -1){
      count += (int)(tmp_h[i]/(a-b));
      if(tmp_h[i]%(a-b) != 0) count++;
      if(count > t) return false;
    }
  }

  return true;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n; cin >> n;
    vi a(n); rep(i,n) cin >> a[i];

    vi b;
    b.push_back(a[0]);
    for(int i = 0; i < n-1; ++i) {
        if(a[i]!=a[i+1]) b.push_back(a[i+1]);
    }
    a = b;
    n = a.size();

    int cnt = 0;
    for(int i = 0; i < n-2; ++i) {
        int p = a[i], q = a[i+1], r = a[i+2];
        if((p<q && q>r) || (p>q && q<r)) {
            cnt++;
            ++i;  // skip
        }
    }

    cout << cnt+1 << '\n';

    // printf("ExcutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< i_i, int>
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define begin(a) a.begin()
#define end(a) a.end()

//int dxy[5] = {0, 1, 0, -1, 0};
// assign

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

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

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

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

signed main()
{
    int N, K, A[200000];

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

    int sum = 0;
    vector< int > odd;
    odd.push_back(0);
    for(int i = 0; i < N; i++) {
        sum += A[i];
        odd.push_back(sum - (i + 1) * K);
    }
    sort(begin(odd), end(odd));
    odd.erase(unique(begin(odd), end(odd)), end(odd));

    sum = 0;
    int ret = 0;
    BinaryIndexedTree< long long > bit(odd.size() + 2);
    bit.add(lower_bound(begin(odd), end(odd), 0) - begin(odd), 1);
    for(int i = 0; i < N; i++) {
        sum += A[i];
        ret += bit.sum(lower_bound(begin(odd), end(odd), sum - (i + 1) * K) - begin(odd));
        bit.add(lower_bound(begin(odd), end(odd), sum - (i + 1) * K) - begin(odd), 1);
    }
    cout << ret << endl;
}



Measured memory_bytes: 5104
from collections import Counter

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

mod = 998244353
c = Counter(D)
m = max(c.keys())

if D[0] == 0 and c[0] == 1:
  ans = 1
  for i in D[1:]:
    ans *= c[i-1]
    ans %= mod
  print(ans)
else:
  print(0)

Measured memory_bytes: 24512
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    long n=sc.nextLong();
    long x=sc.nextLong();
    long a=n-x;
    long b=x;
    long tmp;
    long ans=n;
    while(true){
      System.err.println(b+"/"+a+"="+(b/a)+":"+(b%a));
      ans+=(b/a)*2*a;
      if(b%a==0){
        break;
      }
      tmp=a;
      a=b%a;
      b=tmp;
    }
    System.out.println(ans-a);
  }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}

string s;
bool cnt[200];

int main(){
	cin >> s;
	rep(i,s.size())cnt[s[i]- 'a'] = 1;
	rep(i,26){
		if(!cnt[i]){
			cout << (char)('a'+i) << endl;
			return 0;
		}
	}
	cout << "None" << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <unordered_map>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    unordered_map<ll, ll> ma;
    ll N;
    cin>>N;
    ll a;
    rep(i, N){
        cin>>a;
        ma[a]++;
    }
    ll count=0;
    for(auto itr : ma){
        count+=(itr.second)%2;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 4388
#include<iostream>
using namespace std;
main() {
	string s,u="[<++++++++++>-]>",c=">+++++[<++++++>-]>+++++[<++++++++>-]>+++++"+u+"++++++"+u+"+++++++"+u+"++++++++"+u+"+++++++++"+u+"++++++++++"+u+"+++++++++++"+u+"++++++++++++"+u+"<<<<<<<<<<<";
	int p=0,t[10]={},i,j,a,b,d;
	for(cin>>s,i=0;i<s.length();++i){
		a=s[i]/10-3,b=a-p,p=a,d=s[i]-(a+3)*10;
		for(j=b>0?b:-b;j--;)c+=(b>=0?62:60);
		for(j=d;j--;)c+=43;
		c+=".";
		for(j=d;j--;)c+=45;
	}
	cout<<c<<endl;
}

Measured memory_bytes: 1248
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstring>
using namespace std;
#define U(v) \
cerr << #v << ": " << (v) << endl

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int& i : a)
        cin >> i;
    int mn = 1 << 30;
    for (int p = -100; p <= 100; ++p) {
        int sm = 0;
        for (int q : a)
            sm += (p - q) * (p - q);
        mn = min(mn, sm);
    }
    cout << mn << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define pb push_back
#define pii pair<int,int>
#define SZ(x) (int)x.size()
#ifdef __linux__
#define getchar getchar_unlocked
#endif
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
const int N=1000010;
const int inf=0x3f3f3f3f;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifdef ztzshiwo
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int n,A,B;
int p[N];
int main()
{
	file();
	read(n),read(A),read(B);
	if(A+B-1>n||1ll*A*B<n)puts("-1");
	else
	{
		int now=n;
		A--;
		For(i,n-B+1,n)p[i]=now--;
		for(int i=1;;i+=A)
		{
			if(i>n-B)break;
			int pos=min(n-B,i+A-1);
			rFor(j,pos,i)
				p[j]=now--;
		}
		For(i,1,n)printf("%d ",p[i]);
	}
	return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
  int D, N;
  cin >> D >> N;

  if(N != 100){
    cout << N * pow(100, D) << endl;
  }else{
    if(D == 0){
      cout << 101 << endl;
    }else if(D == 1){
      cout << 10100 << endl;
    }else if(D == 2){
      cout << 1010000 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

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

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

int n,m,a,b,c,d[100005] = {};
string s,w;


int main(){

    cin >> s;

    rep(i,0,sz(s)){
        if(i == 3)cout << "8";
        else cout <<s[i];
    }
    cout << endl;
	
	return  0;
}

Measured memory_bytes: 768
#pragma region 宣言部分
#include <iostream>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
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;

#pragma endregion



int main(){
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
#define INF 2000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){
	int b = a/1;
	if(a==b){
		return true;
	}
	else {
		return false;
	}
}
int main(){
	int N;cin>>N;
	int  D; cin>> D;
	int ans = 0;
	vector<vector<int>> coord(N,vector<int>(D));
	for(int i = 0 ; i < N; i ++ ){
		for(int j =0; j < D ; j++){
			cin>>coord[i][j];
		}
	}
	for(int i = 0 ; i < N-1; i++){
		for(int j = i+1 ; j < N ; j++){
			int dist = 0;
			for(int d = 0; d < D; d++){
				dist += pow(coord[i][d]-coord[j][d],2);
			}
			//distは距離の２乗なのでこれのルートが整数になるか判定する
			double a = pow(dist,0.5);
			if(IsInt(a)) ans++;//IsIntを作ろう
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <iostream>
#include <algorithm>
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define PER(i,a,b) for(int i=(a);i>=(b);i--)
#define RVC(i,S) for(int i=0;i<(S).size();i++)
#define RAL(i,u) for(int i=fr[u];i!=-1;i=e[i].next)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
     
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
/*============ Header Template ============*/

const int maxn=(int)(1e5)+5;
int ai[maxn];

int main() {
    int n;
    read(n);
    REP(i,1,n) read(ai[i]);
    int sgn=0,cnt=0;
    REP(i,2,n) {
        if(ai[i]<ai[i-1]) {
            if(sgn==1) ++cnt,sgn=0; else sgn=-1;
        }
        if(ai[i]>ai[i-1]) {
            if(sgn==-1) ++cnt,sgn=0; else sgn=1;
        }
    } ++cnt;
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 640
import sys

sys.setrecursionlimit(1000000)

import bisect
import math
import collections
import heapq


def solve(N, As):
    diffs = [As[i] - As[i - 1] for i in range(1, N)]
    own = 0
    money = 1000
    for i in range(N - 1):
        if own == 0 and diffs[i] > 0:
            k = (money // As[i])
            own = k
            money -= k * As[i]
        elif own > 0 and diffs[i] < 0:
            money += own * As[i]
            own = 0

    if own > 0:
        money += own * As[-1]
    return money



if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split(" ")))
    print(solve(N, As))


Measured memory_bytes: 9488
n,m,c = map(int,input().split())
b = list(map(int, input().split()))
a = [list(map(int,input().split())) for i in range(n)]
d = -1000
x = 0
for i in range(n):
    d = 0
    for j in range(m):
        d += a[i][j]*b[j]
    else:
        if d+c>0:
            x+=1
print(x)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define il inline
#define RG register
#define ll long long
#define lb(x) (x & -x)
#define eps (1e-12)
#define N (50005)

using namespace std;

struct data{ double k,y; int i; }p[N];
struct node{ double a,b,c; }l[N];

double hsh[N],X,Y,L,R,mid;
int c[N],n,k,cnt;

il int gi(){
  RG int x=0,q=1; RG char ch=getchar();
  while ((ch<'0' || ch>'9') && ch!='-') ch=getchar();
  if (ch=='-') q=-1,ch=getchar();
  while (ch>='0' && ch<='9') x=x*10+ch-48,ch=getchar();
  return q*x;
}

il int cmpk(const data &a,const data &b){ return a.k<b.k; }

il int cmp(const double &a,const double &b){ return fabs(a-b)<eps; }

il void add(RG int x){ for (;x<=n;x+=lb(x)) ++c[x]; return; }

il int query(RG int x){
  RG int res=0; for (;x;x^=lb(x)) res+=c[x]; return res;
}

il int check(RG double key){
  RG int tot=0,res=0;
  for (RG int i=1;i<=n;++i)
    p[i].k=-l[i].a/l[i].b,p[i].y=(l[i].c-l[i].a*key)/l[i].b,hsh[++tot]=p[i].y;
  sort(p+1,p+n+1,cmpk),sort(hsh+1,hsh+tot+1),tot=unique(hsh+1,hsh+tot+1,cmp)-hsh-1;
  for (RG int i=1;i<=n;++i) c[i]=0,p[i].i=lower_bound(hsh+1,hsh+tot+1,p[i].y)-hsh;
  for (RG int i=1;i<=n;++i) res+=query(p[i].i),add(p[i].i); return res>=k;
}

int main(){
  n=gi(),k=((n*(n-1)>>1)+1)>>1;
  for (RG int i=1;i<=n;++i)
    l[i].a=gi(),l[i].b=gi(),l[i].c=gi();
  L=-1e9,R=1e9,cnt=0;
  while (R-L>eps){
    ++cnt; if (cnt>100) break;
    mid=(L+R)/2,check(mid)?(X=mid,R=mid):L=mid;
  }
  for (RG int i=1;i<=n;++i) swap(l[i].a,l[i].b);
  L=-1e9,R=1e9,cnt=0;
  while (R-L>eps){
    ++cnt; if (cnt>100) break;
    mid=(L+R)/2,check(mid)?(Y=mid,R=mid):L=mid;
  }
  printf("%0.12lf %0.12lf\n",X,Y); return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
int main(){
    int n;
    cin >> n;
    vector <char> s(n);
    string ans = "Three";
    for (size_t i = 0; i < n; i++)
    {
        cin >> s[i];
        if(s[i] == 'Y'){
            ans = "Four";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pi pair<ll, ll>
#define mp make_pair
#define pb push_back
#define vi vector<ll>
#define pd pair<double, double>
#define vp vector<pi>
#define f(i, n) for(int i = 0; i < n; i++)
#define fo(i, a, n) for(int i = a; i < n; i++)
#define mod (1000*1000*1000+7)
#define sz(x) int((x).size())
#define all(x) x.begin(),x.end()
#define DBG(v) cerr << #v << " = " << (v) << endl;
ll INF = (1ll<<30);

using namespace std;

pi arr[1005];
int dp[1005][5000];
int n, m;

int d(int i, int j){
    if(dp[i][j] != -1) return dp[i][j];
    if(j == (1 << n) - 1) return 0;
    if(i == m) return INF;
    return dp[i][j] = min(arr[i].second + d(i+1, arr[i].first | j), (ll) d(i+1, j));
}

int main(int argc, char* argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin >> n >> m;
    f(i, m){
        int a, b; cin >> a >> b;
        int bm = 0;
        f(j, b){
            int x; cin >> x;
            bm |= (1 << (x-1));
        }
        arr[i] = mp(bm, a);
    }
    f(i, m+1) f(j, 5000) dp[i][j] = -1;
    ll an = d(0,0);
    cout << (an>=INF?-1:an) << endl;
    return 0;
}


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

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef pair<int,int> pii;

const int INF = 1 << 29;
const double EPS = 1e-10;


int main() {
  for (int n, p; cin >> n >> p, (n | p ) != 0; ) {
    int stone[51];
    rep(i, 51) stone[i] = 0;
    int cup = p;
    int cur = 0;
    for(; ; ) {
      if (cup != 0) {
        stone[cur]++;
        cup--;
      }
      else {
        cup = stone[cur];
        stone[cur] = 0;
      }

      if (stone[cur] == p) break;

      cur = (cur + 1 ) % n;
    }
    
    cout << cur << endl;


  }
  
  return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, k, s;
  in2(n, k);
  if(k % 2 == 1)
    s = (n / k) * (n / k) * (n / k);
  else{
    s = (n / k) * (n / k) * (n / k);
    if(n % k >= k / 2)
      s += (n / k + 1) * (n / k + 1) * (n / k + 1);
    else
      s = 2 * s;
  }
  out(s);
  memi;
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())
mod = pow(10, 9) + 7
      
def cmb(n, r, mod):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) % mod * pow(i+1, mod-2, mod) % mod
    return res

ans = pow(2, n, mod) -1 - cmb(n, a, mod) - cmb(n, b, mod)
print(ans % mod)

Measured memory_bytes: 3064
H, W = map(int, input().split())
S = []
for i in range(H):
    S.append(input())

left = [[-1 for j in range(W)] for i in range(H)]
right = [[W for j in range(W)] for i in range(H)]
up = [[-1 for j in range(W)] for i in range(H)]
down = [[H for j in range(W)] for i in range(H)]

# from left upper to right down
up_wall = [-1 for i in range(W)]
for h in range(H):
    left_wall = -1    
    for w in range(W):
        if S[h][w] == '#':
            left_wall = w
            up_wall[w] = h
        left[h][w] = left_wall
        up[h][w] = up_wall[w]

# from right down to left up
down_wall = [H for i in range(W)]
for h in range(H - 1, -1, -1):
    right_wall = W
    for w in range(W - 1, -1, -1):
        if S[h][w] == '#':
            right_wall = w
            down_wall[w] = h
        right[h][w] = right_wall
        down[h][w] = down_wall[w]

# print(left)
# print(right)
# print(up)
# print(down)

max_score = 0
for h in range(H):
    for w in range(W):
        left_score = (w - left[h][w])
        right_score = (right[h][w] - w)
        up_score = (h - up[h][w])
        down_score = (down[h][w] - h)
        score = left_score + right_score + up_score + down_score - 3
        # print(h, w, score, left_score, right_score, up_score, down_score)
        if max_score < score:
            max_score = score
print(max_score)

Measured memory_bytes: 183684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;
 
template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}
 
ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}
 
ll RS(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

P rev(P x) {
    ll a = -x.first;
    ll b = x.second;
    if(a < 0) {
        return P(-b,-a);
    }
    return P(b,a);
}

int main() {
    int N;
    cin >> N;
    map<P,ll> ma;
    ll zero = 0;
    ll Azero = 0;
    ll Bzero = 0;
    for(int i = 0;i < N;i++) {
        ll A,B;
        cin >> A >> B;
        if(A == 0 && B == 0) {
            zero++;
        }
        else if(A == 0) {
            Azero++;
        }
        else if(B == 0) {
            Bzero++;
        }
        else {
            ll cnt = gcd(A,B);
            A /= cnt;
            B /= cnt;
            if(B < 0) {
                A = -A;
                B = -B;
            }
            ma[P(A,B)]++;
        }
    }
    ll ret = mod(RS(2,Azero,MOD) + RS(2,Bzero,MOD) - 1);
    set<P> used;
    for(auto x:ma) {
        if(!used.count(x.first)) {
            P key = x.first;
            ll value = x.second;
            if(ma.count(key)) {
                ret *= mod(RS(2,value,MOD) + RS(2,ma[rev(key)],MOD) - 1);
                ret %= MOD;
                used.insert(rev(key));
            }
            else {
                ret *= RS(2,value,MOD);
                ret %= MOD;
            }
        }
    }
    ret += zero;
    ret--;
    ret = mod(ret);
    cout << ret << endl;
}

Measured memory_bytes: 41108
// Problem : C - Many Medians
// Contest : AtCoder Regular Contest 095
// URL : https://atcoder.jp/contests/arc095/tasks/arc095_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;

// begin of indexed_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;
// end of indexed_set

using ll = long long;
#define size(x) (int)x.size()

const int N = 2e5 + 1, MAX = 1e9;

int n, a[N];
indexed_multiset im;

int main() { cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		im.insert({a[i], i});
	}
	for (int i = 1; i <= n; i++) {
		im.erase(im.lower_bound({a[i], i}));	
		cout << im.find_by_order(n / 2 - 1)->first << '\n';	
		im.insert({a[i], i});
	}
}

Measured memory_bytes: 15488
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	int n;
	cin >> n;

	set<string> st;
	rep(i, n){
		string s;
		cin >> s;
		st.insert(s);
	}

	if(st.size() == 3){
		cout << "Three" << endl;
	}else{
		cout << "Four" << endl;
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int K,A,B,a,b;
  cin >> K >> A >> B ;
  a=(A-1)/K;
  b=B/K;
  if(b>a)
  {
    cout << "OK" << endl;
  }
  else
  {
    cout << "NG" << endl;
  }
  
  
}


Measured memory_bytes: 3572
def resolve():
    s = input()
    ans = [0]*len(s)
    start = -1
    center = -1
    end = -1
    for i in range(len(s)):
        if i == 0:
            start = i
        elif s[i-1] == "L" and s[i] == "R":
            start = i
        if s[i] == "R" and s[i+1] == "L":
            center = i
        if i == len(s)-1:
            end = i
        elif s[i] == "L" and s[i+1] == "R":
            end = i

        if 0 <= start <= center <= end:
            if (end-start) % 2 == 1:
                ans[center] = (end-start+1) // 2
                ans[center+1] = (end-start+1) // 2
            else:
                total = end-start+1
                if (end-center) > (center-start+1):
                    if (end-center) % 2 == 1:

                        ans[center] = (total-1)//2
                        ans[center+1] = (total+1)//2
                    else:
                        ans[center+1] = (total-1)//2
                        ans[center] = (total+1)//2
                else:
                    if (center-start+1)%2 == 0:
                        ans[center] = (total-1)//2
                        ans[center+1] = (total+1)//2
                    else:
                        ans[center+1] = (total-1)//2
                        ans[center] = (total+1)//2

    print(" ".join(map(str, ans)))
resolve()

Measured memory_bytes: 10612
#include<stdio.h>
int stpint(int *n,int k){
  int i,j,r=0,c,a[10]={1,1,1,1,1,1,1,1,1,1};
  int m=1;
  for(i=0;i<k;i++)m*=i+1;
  for(i=0;i<k;i++){
    m/=k-i;
    for(j=c=0;j<n[i];j++)c+=a[j];
    r+=c*m;
    a[j]=0;
  }
  return r;
}
void f(int *d,int n,int k){
  int i,j,c,m=1,a[10]={1,1,1,1,1,1,1,1,1,1};
  for(i=0;i<k;i++)m*=i+1;
  for(i=0;i<k;i++){
    m/=k-i;
    c=n/m+1;
    for(j=0;c;j++)c-=a[j];
    n%=m;
    d[i]=j-1;
    a[j-1]=0;
  }
}
int X[]={0,1,0,-1};
int Y[]={1,0,-1,0};
int main(){
  int i,j,k,ny,nx,n[10],r=1,t=0,q[50000],d[50000]={1};
  q[0]=0;
  for(r=1;r-t;t++){
    f(n,q[t],8);
    /*if(t<10){
      for(i=0;i<8;i++)printf("%d ",n[i]);
      printf("%5d %d\n",stpint(n,8),d[stpint(n,8)]);
      }//*/
    for(i=0;n[i];i++);
    for(j=0;j<4;j++){
      ny=i/4+Y[j];
      nx=i%4+X[j];
      if(ny<0||1<ny||nx<0||3<nx)continue;
      n[i]=n[ny*4+nx];
      n[ny*4+nx]=0;
      k=stpint(n,8);
      if(d[k]==0){
	d[k  ]=d[q[t]]+1;
	q[r++]=k;
      }
      n[ny*4+nx]=n[i];
      n[i]=0;
    }
  }
  while(~scanf("%d",&n[0])){
    for(i=1;i<8;i++)scanf("%d",&n[i]);
    // printf("%d ",stpint(n,8));
    printf("%d\n",d[stpint(n,8)]-1);
  }
  return 0;
}
  



Measured memory_bytes: 2036
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

std::string N;

int main()
{
	in >> N;
	if (N[0] == '9' || N[1] == '9') { out << "Yes" << std::endl; }
	else { out << "No" << std::endl; }
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        String[] exp = new Scanner(System.in).nextLine().split(" ", 3);
        int a = Integer.parseInt(exp[0]);
        int b = Integer.parseInt(exp[2]);
        char op = exp[1].charAt(0);

        if (op == '+') {
            System.out.println(a + b);
        } else {
            System.out.println(a - b);
        }
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;

int INF = 1E+9 + 1;
int N;

void dp(int s, const int *H, int *cost) {
    if (s<=N-3) cost[s+2] = min(cost[s+2], cost[s] + abs(H[s] - H[s+2]));
    if (s<=N-2) {
        cost[s+1] = min(cost[s+1], cost[s] + abs(H[s] - H[s+1]));
        dp(s+1, H, cost);
    }
}

int main() {
    cin >> N;
    int H[N], cost[N];
    for (int i=0; i<N; i++) scanf("%d", &H[i]), cost[i]=INF;

    cost[0] = 0;
    dp(0, H, cost);

    cout << cost[N-1] << endl;

    return 0;
}



Measured memory_bytes: 1024
#include<stdio.h>
#define MAX 100000

int parent(int);
int left(int);
int right(int);


int main(){
  int A,i,N[MAX+1];

  scanf("%d",&A);
  for(i=1;i<=A;i++){
    scanf("%d",&N[i]);
  }
  for(i=1;i <= A;i++){
    printf("node %d: key = %d, ",i,N[i]);
    if(parent(i) >= 1)printf("parent key = %d, ",N[parent(i)]);
    if(left(i) <= A)printf("left key = %d, ",N[left(i)]);
    if(right(i) <= A)printf("right key = %d, ",N[right(i)]);
    printf("\n");
  }return 0;
}

int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define pb push_back

using namespace std;

const int MAX_N = 100000;

vector<int> G[MAX_N];
int val[MAX_N];

string s;
int num,id;

void dfs(int p)
{
    int nw = id++;
    int st = 0;
    G[p].pb(nw);
    while(num < len(s)){
        if(s[num] == '['){
            st++;
            num++;
            dfs(nw);
        }else if(s[num] == ']'){
            st--;
            if(st < 0){
                break;
            }
            num++;
        }else{
            string kazu;
            while(isdigit(s[num])){
                kazu.pb(s[num++]);
            }
            val[nw] = stoi(kazu);
            break;
        }
    }
}

int dfs2(int u)
{
    if(len(G[u]) == 0){
        return val[u]/2+1;
    }
    vector<int> cnt;
    for(auto& v : G[u]){
        cnt.pb(dfs2(v));
    }
    // rep(i,len(cnt)){
    //     cout << cnt[i] << " ";
    // }
    // cout << "\n";
    sort(all(cnt));
    return accumulate(cnt.begin(),cnt.begin()+len(cnt)/2+1,0);
}

int main()
{
    int n;
    cin >> n;
    rep(i,n){
        cin >> s;
        num = id = 0;
        dfs(0);
        cout << dfs2(1) << "\n";
        rep(i,id){
            G[i].clear();
        }
    }
}



Measured memory_bytes: 5692
#include<iostream>
#include <cmath>
#include<vector>
#include <algorithm>
#include <map>

using namespace std;
#define pb push_back
#define mp make_pair


int main()
{
    int n;
    int num[110];
    for(long long i = 0;i<40;i++)num[i]=0;
    cin>>n;
    if( n == 0  ) cout<<0<<endl;
    if( n>0 ){
        for( long long i = 0;i < 40;i++ ){
            if( n&( 1LL << i )  && i%2==0 ) num[i]++;
            else if( n&( 1LL<<i )  ){
                num[i]++;
                num[i+1]++;
            }
        }
  /*      for( int i = 0; i <40;i++ ){
                if( num[i] > 0  ) cout << num[i] << " ragib " << i  <<endl;
        }*/

        ///
        for( int i = 0;i < 40;i++ ){
        if( num[i] == 2 ){
          //      cout << i << " mirza " <<endl;
            if( i%2==0 && num[i+1] == 0 ){
                num[i+1]++;
                num[i+2]++;
                num[i]=0;
            }
            else if( i%2==0  ){
                num[i]=0;
                num[i+1]=0;
            }
        }
    }
    //long long res=0;
    string res = "";
    for(int i = 0;i < 40;i++){
         //   if( num[i]  ) cout <<  i << "  ramo " << num[i] <<endl;
        if( num[i] ) res.pb( '1' );
        else res.pb( '0' );
    }
    int curr = res.size() - 1;
    while( res[curr] == '0' ) curr--;
    for( int i =curr;i>=0;i-- ){
        cout<<res[i];
    }
    cout<<endl;
    //cout<<res<<endl;
    }
    ///  DRUGI DIO - DRUGI DIO - DRUGI DIO - DRUGI DIO
    else{
            n*=-1;
        for( long long i = 0;i < 40;i++ ){
            if( n&( 1LL << i )  && i%2==1 ) num[i]++;
            else if( n&( 1LL<<i )  ){
                num[i]++;
                num[i+1]++;
            }
        }
   /*     for( int i = 0; i <40;i++ ){
                if( num[i] > 0  ) cout << num[i] << " ragib " << i  <<endl;
        }*/

        ///
        for( int i = 0;i < 40;i++ ){
        if( num[i] == 2 ){
           //     cout << i << " mirza " <<endl;
            if( i%2==1 && num[i+1] == 0 ){
                num[i+1]++;
                num[i+2]++;
                num[i]=0;
            }
            else if( i%2==1  ){
                num[i]=0;
                num[i+1]=0;
            }
        }
    }
    //long long res=0;
    string res = "";
    for(int i = 0;i < 40;i++){
         //   if( num[i]  ) cout <<  i << "  ramo " << num[i] <<endl;
        if( num[i] ) res.pb( '1' );
        else res.pb( '0' );
    }
    int curr = res.size() - 1;
    while( res[curr] == '0' ) curr--;
    for( int i =curr;i>=0;i-- ){
        cout<<res[i];
    }
    cout<<endl;
    }

}

























Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)

using namespace std;

int i,j,k;

int main(){
    int h,w,ans;
    ans=0;
    cin >>h>>w;
    char s[h][w];
    int dp[h+1][w+1];
    REP(i,h)REP(j,w){
        cin>>s[i][j];
        dp[i][j]=INT_MAX;
    }
    dp[0][w]=INT_MAX;
    dp[h][0]=INT_MAX;
    dp[0][1]=0;
    dp[1][0]=0;
    for(i=1;i<=h;i++){
        for(j=1;j<=w;j++){
            
            if(s[i-1][j-1]=='.'){
                dp[i][j]=min(dp[i-1][j],dp[i][j-1]);
            }
            else if(i>1 && j>1){
                if(s[i-2][j-1]=='#' && s[i-1][j-2]=='#'){
                    dp[i][j]=min(dp[i-1][j],dp[i][j-1]);
                }
                else if(s[i-2][j-1]=='.' && s[i-1][j-2]=='#'){
                    dp[i][j]=min(dp[i-1][j]+1,dp[i][j-1]);
                }
                else if(s[i-2][j-1]=='#' && s[i-1][j-2]=='.'){
                    dp[i][j]=min(dp[i-1][j],dp[i][j-1]+1);
                }
                else{
                    dp[i][j]=min(dp[i-1][j],dp[i][j-1])+1;
                }

            }
            else if(i>1 && j<2){
                if(s[i-2][j-1]=='#'){
                    dp[i][j]=min(dp[i-1][j],dp[i][j-1]);
                }
                else{
                    dp[i][j]=min(dp[i-1][j],dp[i][j-1])+1;
                }
            }
            else if(i<2 && j>1){
                if(s[i-1][j-2]=='#'){
                    dp[i][j]=min(dp[i-1][j],dp[i][j-1]);
                }
                else{
                    dp[i][j]=min(dp[i-1][j],dp[i][j-1])+1;
                }
            }
            else{
                dp[i][j]=min(dp[i-1][j],dp[i][j-1])+1;
            }
        }
    }
    
    cout<< dp[h][w] << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B_017_44
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            new Logic_A().Start();//OK
            Console.ReadLine();
        }

        public class Logic_A
        {
            public void Start()
            {
                var N = Convert.ToInt32(Console.ReadLine());
                var K = Convert.ToInt32(Console.ReadLine());
                var X = Convert.ToInt32(Console.ReadLine());
                var Y = Convert.ToInt32(Console.ReadLine());

                Console.WriteLine(N <= K ? N * X : X * K + (N - K) * Y);
            }
        }
    }
}

Measured memory_bytes: 13268
from itertools import count, repeat

h = int(input().split()[0])
a0 = repeat('.')
r0 = count()
for i in range(h):
  a = input()
  r = [i]
  for x, y, z, u in zip(a0, '.' + a, a, r0):
    r.append(min(u + (x > z), r[-1] + (y > z)))
  a0 = a
  r0 = r[1:]
print(r[-1])


Measured memory_bytes: 3060
N,D = map(int, input().split())
List = []
for i in range(N):
    List.append([int(x) for x in input().split()])
    
ans = 0
for i in range(N-1):
    for j in range(i+1,N):
        d = 0
        for k in range(D):
            d += (List[i][k]-List[j][k])**2
        d = d**0.5
        if int(d) == d:
            ans += 1
    
print(ans)

Measured memory_bytes: 38384
package main

import (
        "fmt"
        "strconv"
)

func solution(a, b int) int {
        out := 0
        for i := a; i <= b; i++ {
                s := strconv.Itoa(i)
                if isPalindrome(s) {
                        out++
                }
        }
        return out
}

func isPalindrome(s string) bool {
        l := len(s)

        for i := 0; i < l; i++ {
                if s[i] != s[l-1-i] {
                        return false
                }
        }
        return true
}

func main() {
        var a, b int
        fmt.Scan(&a, &b)
        fmt.Println(solution(a, b))
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <stack>
#include <string>
#include <cmath>
#include <sstream>
#include <queue>
#include <map>
#include <cstring>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
using namespace std;

int main() {
    string S;
    bool hasC = false;
    bool hasF = false;
    cin >> S;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == 'C') {
            hasC = true;
        } else if (S[i] == 'F' && hasC) {
            hasF = true;
        }
    }
    cout << (hasF ? "Yes" : "No") << endl;
    return 0;
}

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

typedef long long ll;

using namespace std;

int main() {
	int n, m, sum = 0; cin >> n >> m;
	for(int i = 1; i < n; i++) {
		sum += i;
	}
	for(int i = 1; i < m; i++) {
		sum += i;
	}
	cout << sum;
}





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

int main(){
	string s;
	cin >>s;
  int ans=s.size()/2;
  if(ans*2==s.size())ans--;
  while(1){
   if(s.substr(0,ans)==s.substr(ans,ans)){
     cout << ans*2 << endl;
     return 0;
   }else ans--;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  string S; cin >> S;
  int N = S.size();
  int a[N] = {};

  // 左から見る
  int cnt[2]={};
  int j = 0;
  rep(i,N){
    if (S[i]=='R') {
      cnt[j%2]++;
      j++;
    }
    if (i+1<N && S.substr(i,2)=="RL" && j>0){
      a[i] += cnt[(j+1)%2];
      a[i+1] += cnt[j%2];
      j=0;
      cnt[0] = 0;
      cnt[1] = 0;
    }
  }
  cnt[0]=0, cnt[1]=0;
  j=0;
  rep(i,N){
    if (S[N-1-i]=='L') {
      cnt[j%2]++;
      j++;
    }
    if (N-i-2>=0 && S.substr(N-2-i,2)=="RL" && j>0){
      a[N-2-i] += cnt[j%2];
      a[N-1-i] += cnt[(j+1)%2];
      j=0;
      cnt[0] = 0;
      cnt[1] = 0;
    }
  }
  rep(i,N) {
    if (i>0) cout << " ";
    cout << a[i];
  }

  // cout << fixed << setprecision(10);
  
  return 0;
}


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

long long int *s;
long long int ans[100][100][2];

int result = 0;
int inw,inh;

long long int SUM(int w,int h,int d){
  s = new long long int();
  *s = 0;
  for(int n = (d == 0 ? w : h)-2;n>=0;n--){
    *s += ans[(d == 0 ? n : w)][(d == 0 ? h : n)][(d == 0 ? 1 : 0)];
  }
  return *s%100000;
}

int main(){
  for(int n = 0;n<100;n++){
    ans[n][0][0] = 1;
    ans[0][n][1] = 1;
  }
  for(int n = 1;n<100;n++){
    for(int m = 1;m<100;m++){
      ans[n][m][0] = SUM(n,m,0)%100000;
      ans[n][m][1] = SUM(n,m,1)%100000;
    }
  }
  while(1){
    cin >> inw >> inh;
    if(inw == 0 && inh == 0)break;
    result = 0;
    for(int n = 0;n<inw-1;n++)result += ans[n][inh-1][1];
    for(int n = 0;n<inh-1;n++)result += ans[inw-1][n][0];
    cout << result%100000 << endl;
  }
  return 0;
}

Measured memory_bytes: 3832
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();

        int xmax = -101;
        for(int i = 0;i < n;i++){
            int temp = sc.nextInt();
            xmax = Math.max(xmax, temp);
        }

        int ymin = 101;
        for(int i = 0;i < m;i++){
            int temp = sc.nextInt();
            ymin = Math.min(ymin, temp);
        }

        if(ymin <= xmax){
            System.out.println("War");
            System.exit(0);
        }

        if(ymin <= x || xmax >= y){
            System.out.println("War");
            System.exit(0);
        }

        System.out.println("No War");
    }
}


Measured memory_bytes: 22868
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

// conversion
//------------------------------------------
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

// 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)

// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

const long long MOD = 2;
/*

3
1 0 0 ...

1 1 1, 1;
0 1 0  0
0 0 1  0

0 0 0 0 0 
0

1 1 0


*/

int table[501010];

void make_table(int N){
  REP(i, N+10)table[i]=0;
  table[1]=1;
  for(int i=2; i <= N; i++){
    for(int j=1; j<=sqrt(i); j++){
      if(i % j ==0) table[i]++;
    }
    table[i]++;
  }
  return;
}

void solve(long long N, std::vector<long long> a) {
}

int a [202020];
int b [202020];
int main() {
  int N;
  cin>>N;
  REP(i, N)cin>>a[i+1];
  for(int i=N;i >=1; i--){
    int cnt=0;
    for(int j=2; i*j<=N; j++){
      cnt += b[i*j];
    }
    if(cnt%2!=a[i])b[i]=1;
  }
  VI ans;
  for(int i=1; i <=N; i++){
    if(b[i]==1)ans.PB(i);
  }
  cout<<ans.size()<<endl;
  for (auto i : ans)cout<<i<<" ";
  cout<<endl;
  return 0;
}


Measured memory_bytes: 2936
N, P = map(int, input().split())
A = list(map(int, input().split()))
A = [i % 2 for i in A]

if sum(A) == 0:
    if P == 0:
        print(pow(2, N))
    else:
        print(0)
else:
    print(pow(2, N-1))

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>
   
int main(void){
   
  int x[1000];
  int y[1000];
  int n;
  double P1 = 0;
  double P2 = 0;
  double P3 = 0;
  double Pinf = 0;
  double max = 0;
  double calc = 0;
  register int i;
   
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&x[i]);
  }
  for(i = 0;i < n;i++){
    scanf("%d",&y[i]);
  }
   
  for(i = 0;i < n;i++){
    P1 += fabs(x[i] - y[i]);
  }
   
  for(i = 0;i < n;i++){
    P2 += pow(fabs(x[i] - y[i]),2);
  }
  P2 = sqrt(P2);
   
  for(i = 0;i < n;i++){
    P3 += pow(fabs(x[i] - y[i]),3);
  }
  P3 = pow(P3,0.3333333333333);
   
  for(i = 0;i < n;i++){
    calc = fabs(x[i] - y[i]);
    if(max < calc){
      max = calc;
    }
  }
  Pinf = max;
   
  printf("%f\n",P1);
  printf("%.8f\n",P2);
  printf("%.8f\n",P3);
  printf("%f\n",Pinf);
   
  return 0;
}

Measured memory_bytes: 708