akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define N 3
#define N2 9

int kei(int,int,int,int);
int f[9];

int main()
{
	int i,a;
	for(i=0;i<N2;i++){
		scanf("%d",&f[i]);
		if(f[i]==0)a=i;
	}
	printf("%d\n",k(a,0,10,1));
	return 0;
}

int k(int a,int b,int c,int d)
{
	int min=999,sum=0,i,m;
	if((d==b || c==10) && a==8){	
		for(i=0;i<8;i++){
			if(f[i]!=i+1){
				sum++;
				break;
			}
		}
		if(sum==0)return b;
	}
	while(b<d){
	
		if((a+1)%3!=0 && c!=a+1){
			m=f[a+1];
			f[a+1]=f[a];
			f[a]=m;
			m=k(a+1,b+1,a,d);
			if(min>m){
				min=m;
				break;
			}
			m=f[a];
			f[a]=f[a+1];
			f[a+1]=m;
		}
		if((a-1)%N!=2 && a!=0 && c!=a-1){
			m=f[a];
			f[a]=f[a-1];
			f[a-1]=m;
			m=k(a-1,b+1,a,d);
			if(min>m){
				min=m;
				break;
			}
			m=f[a];
			f[a]=f[a-1];
			f[a-1]=m;
		}
		if(a-N>=0 && c!=a-N){
			m=f[a];
			f[a]=f[a-N];
			f[a-N]=m;
			m=k(a-N,b+1,a,d);
			if(min>m){
				min=m;
				break;
			}
			m=f[a];
			f[a]=f[a-N];
			f[a-N]=m;
		}
		if(a+N<N2 && c!=a+N){
			m=f[a];
			f[a]=f[a+N];
			f[a+N]=m;
			m=k(a+N,b+1,a,d);
			if(min>m){
				min=m;
				break;
			}
			m=f[a];
			f[a]=f[a+N];
			f[a+N]=m;
		}
		if(c==10)d++;		
		else return min;
	}
	return min;
}


Measured memory_bytes: 2140
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<String> S = new ArrayList<String>();
        ArrayList<String> P = new ArrayList<String>();
        for (int i=0; i<N; i++) {
            S.add(sc.next() + "," + sc.next() + "," + (i+1));
        }
        S.sort(new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                String[] o1s =  o1.split(",");
                String[] o2s =  o2.split(",");
                if (o1s[0].compareTo(o2s[0]) == 0) {
                    int n1 = Integer.parseInt(o1s[1]);
                    int n2 = Integer.parseInt(o2s[1]);
                    return Integer.compare(n2, n1);
                }
                else {
                    return o1s[0].compareTo(o2s[0]);
                }
            }
        });
        for (int i=0; i<N; i++) {
            String[] index =  S.get(i).split(",");
            System.out.println(index[2]);
        }

    }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
    {
        int a,b,k;
		stack <int>f;
		cin>>a>>b>>k;
		int js=0;
		
		for(int i=1;i<=min(a,b);i++)
			{
				if(b%i==0&a%i==0)
					f.push(i);
			}
		for(int i=1;i<k;i++)
			{
				f.pop();
			}
		cout<<f.top();
    }

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

long long llmin(long long a, long long b){return a > b ? b : a;}

int main()
{
    long long q,h,s,d,n;
    cin >> q >> h >> s >> d >> n;

    long long ans = n / 2 * llmin(q * 8, min(h * 4, min(s * 2, d)));
    n %= 2;
    ans += n * llmin(q * 4, llmin(h * 2, s));

    cout<< ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
class P
{
    static void Main()
    {
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] c = new int[a[0]];
        for (int i = 0; i < a[1]; i++)
        {
            int[] xy = Console.ReadLine().Split().Select(x => int.Parse(x) - 1).ToArray();
            c[xy[0]]++;
            c[xy[1]]++;
        }
        Console.WriteLine(string.Join("\n",c));
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int a, b;
  cin >> a >> b;
  ll right = 0, left = 0;
  for(int i = 1; i < 1000; i++){
    left = right;
    right += i;

    ll x = left - a, y = right - b;
    // cout << left << " " << right << endl;

    if(x < 0 || y < 0) continue;
    if(x == y){
      cout << x << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,d;
  cin>>n>>d;
  long long int x[n],y[n];
  int count=0;
  for(int i=0;i<n;i++)
  {
    cin>>x[i]>>y[i];
  }
  for(int i=0;i<n;i++)
  {
    if(x[i]*x[i]+y[i]*y[i]<=d*d)
    {
      count++;
    }
  }
  cout<<count;
}
  


Measured memory_bytes: 6732
import Control.Monad

solve n f' p = maximum $ map calc $ replicateM 10 [False,True] where
  calc op
    | or op = sum $ zipWith (cal op) f p
    | otherwise = -(10^10)
  cal op f = (!! length (filter id (zipWith (&&) op f)))
  f = map (map (== 1)) f'

main = do
  n <- readLn
  f <- replicateM n readWords
  p <- replicateM n readWords
  print $ solve n f p

readWords = map read . words <$> getLine

Measured memory_bytes: 1916
#include<iostream>

using namespace std;

int main()
{
	int N;
	cin >> N;
	int hon[5]={2,4,5,7,9};
	int pon[4]={0,1,6,8};

	int a = N%10;

	if(a == 3)
	{
		cout << "bon" << endl;
		return 0;
	}

	for(int i=0;i<5;i++)
	{
		if(hon[i] == a)
		{
			cout << "hon" << endl;
			return 0;
		}
	}

	for(int i=0;i<4;i++)
	{
		if(pon[i]==a)
		{
			cout << "pon" << endl;
			return 0;
		}
	}

	return 0;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)

using namespace std;


double solve(ll maxx, ll len, ll d){
    if(d == 0) return 1.0*(len-1.0) / maxx;
    return 2.0*(maxx-d) * (len-1.0) / maxx / maxx;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    
    ll maxx, len, d;
    cin >> maxx >> len >> d;
    
    // (2*d)*(len-1)*pow(maxx, len-2) / pow(maxx, len)
    // 2*(maxx-2*d)*(len-1)*pow(maxx, len-2) / pow(maxx, len)

    cout << setprecision(10);

    cout << solve(maxx, len, d) << endl;
    // [1,2] [1,2] [1,2]

    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
ll x;
cin >> x;
ll n=x%11;
ll m=x/11;
if(n==0)cout<< 2*m << endl;
else if(n<=6)cout << 2*m+1 << endl;
else cout << 2*m+2 << endl;

}



Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
using namespace std;
int gcd(int a, int b){
    if(b==0) return a;
    else return gcd(b,a%b);
}
signed main(){
    int a,b,k; cin>>a>>b>>k;
    int c=gcd(a, b);
    for(int i=c; i>=1; i--){
        if(c%i==0){
            k--;
        }
        if(k==0){
            cout<<i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
const int INF = 1 << 25;

int main() {
  int N, K;
  while (cin >> N >> K) {
    vector<vector<int>> G(N), rG(N);
    for (int i = 0; i < N; i++) {
      int a;
      cin >> a;
      --a;
      G[i].push_back(a);
      rG[a].push_back(i);
    }
    vector<int> dist(N, INF);
    dist[0] = 0;
    queue<int> q;
    q.push(0);
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      for (int u : rG[v]) {
        if (dist[v] + 1 < dist[u]) {
          dist[u] = dist[v] + 1;
          q.push(u);
        }
      }
    }
    auto comp = [&](int a, int b) {
      if (dist[a] != dist[b]) {
        return dist[a] > dist[b];
      }
      return a > b;
    };
    set<int, decltype(comp)> S(comp);
    for (int i = 1; i < N; i++) {
      S.insert(i);
    }
    int res = 0;
    if (G[0][0] != 0) {
      ++res;
    }
    while (!S.empty() && dist[*S.begin()] > K) {
      int v = *S.begin();
      for (int i = 0; i < K - 1; i++) {
        v = G[v][0];
      }
      queue<int> q;
      q.push(v);
      while (!q.empty()) {
        int v = q.front();
        q.pop();
        S.erase(v);
        for (int u : rG[v]) {
          if (S.count(u)) {
            q.push(u);
          }
        }
      }
      ++res;
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 16256
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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<_>>()
    };

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"2 3
abc
arc"# => r#"#####
#abc#
#arc#
#####"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        h: usize, w: usize,
        a: [String; h],
    }

    let mut ans = "".to_string();
    let tb = (0..w+2).map(|_| "#").collect::<String>();

    ans.push_str(&tb);
    ans.push_str(&"\n");
    for i in 0..h {
        let mut s = "#".to_string();
        s.push_str(&a[i]);
        s.push_str(&"#");
        s.push_str(&"\n");
        ans.push_str(&s);
    }
    ans.push_str(&tb);
    ans.to_string()
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef       long long int      ll;
#define       READ               freopen("in.txt", "r", stdin);
#define       WRITE              freopen("out.txt", "w", stdout);
#define       optimize           ios::sync_with_stdio(0);cin.tie(0);
#define       RESET(a, b)        memset(a, b, sizeof(a))
#define       gcd(a, b)          __gcd(a, b)
#define       MX                 300005
#define       MOD               1000000007
inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p & 1LL) r = modMul(r, b); b = modMul(b, b); p >>= 1LL; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }
/*bool cmp(ll x,ll y)
{
   return x>y;
}*/
bool cmp(pair<int,int>a, pair<int,int>b)
{
   if(a.first==b.first)
      return a.second<b.second;
   else
      return a.first<b.first;
}
int main(void)
{
   optimize
   //ll t,n,m,k,x,y,a[200001];
   vector<ll> v,v1,v2;
   vector< pair<ll,ll> > p,p1,p2;
   set<ll> st;
   priority_queue<ll> pq;
   priority_queue< ll,vector<ll>,greater<ll> > lpq;
   priority_queue< pair<ll,ll> > phpq;
   priority_queue< pair<ll,ll>,vector< pair<ll,ll> >,greater< pair<ll,ll> > > plpq;
   string s;
   //cin>>t;
   //while(t--)
   //{
   ll a,b,c,d;
      cin>>a>>b>>c>>d;
      ll ans;
      ans=a*c;
      ans=max(ans,a*d);
      ans=max(ans,b*c);
      ans=max(ans,b*d);
      cout<<ans<<endl;
   //}
   return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=110;
int main()
{
  int d;
  cin>>d;
  if(d==25) cout<<"Christmas\n";
  else if(d==24) cout<<"Christmas Eve\n";
  else if(d==23) cout<<"Christmas Eve Eve\n";
  else if(d==22) cout<<"Christmas Eve Eve Eve\n";
  return 0;
}


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

int main() {
    int S; cin >> S;
    if (S / 100 == 0 && S % 100 == 0) {
        cout << "NA" << endl;
    } else if (S / 100 == 0 && S % 100 <= 12) {
        cout << "YYMM" << endl;
    } else if (S / 100 <= 12 && S % 100 == 0) {
        cout << "MMYY" << endl;
    } else if (S / 100 <= 12 && S % 100 <= 12) {
        cout << "AMBIGUOUS" << endl;
    } else if(S / 100 <= 12 && S / 100 != 0) {
        cout << "MMYY" << endl;
    } else if(S % 100 <= 12 && S % 100 != 0) {
        cout << "YYMM" << endl;
    } else {
        cout << "NA" << endl;
    }
}

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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const int MOD = (int) 1e9 + 7;
//const int MOD = (int) 998244353;
const int maxn = (int) 2e5 + 20;
const int maxm = (int) 1000000 + 20;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL m = MOD) {LL res = 1; for(; n; n >>= 1, a = a * a % m) if(n & 1) res = res * a % m; return res;}

int n;
int a[maxn << 1], b[maxn];
int s[maxn << 1], t[maxn];
int f[maxn];

void kmp()
{
    f[1] = f[2] = 1;
    for(int i = 2; i < n; i++)
    {
        int j = f[i];
        while(j != 1 && t[j] != t[i]) j = f[j];
        f[i + 1] = t[j] == t[i] ? j + 1 : 1;
    }
}


void work()
{
    cin >>n;
    for(int i = 0; i < n; i++) cin >>a[i], a[i + n] = a[i];
    for(int i = 0; i < n; i++) cin >>b[i];

    if(n == 1)
    {
        cout <<0 <<" " <<(a[0] ^ b[0]) <<endl;
        return ;
    }

    for(int i = 1; i < n * 2; i++) s[i] = a[i - 1] ^ a[i];
    for(int i = 1; i < n; i++) t[i] = b[i - 1] ^ b[i];
    t[n] = -1;

    kmp();

//    for(int i = 1; i < n * 2; i ++) cout <<s[i] <<" "; cout <<endl;
//    for(int i = 1; i < n; i ++) cout <<t[i] <<" "; cout <<endl;

    int j = 1;
    for(int i = 1; i < n * 2 - 1; i++)
    {
        while(j != 1 && s[i] != t[j]) j = f[j];
        j = s[i] == t[j] ? j + 1 : 1;

        if(j == n)
        {
            cout <<i - n + 1 <<" " <<(a[i - n + 1] ^ b[0]) <<endl;
        }
    }
}

int main()
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 8960
#define taskname "test"

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long lli;
typedef pair<int, int> pii;
const int maxn = (1 << 18) + 5;
int n;
int a[maxn];
pii dp[maxn];

void read_input()
{
    cin >> n;
    for(int i = 0; i < (1 << n); ++i)
        cin >> a[i];
}

inline void combine(pii&tar, pii val)
{
    if(tar.first < val.first) swap(tar.first, val.first);
    tar.second = max(tar.second, val.first);
}

void solve()
{
    for(int i = 0; i < (1 << n); ++i)
        dp[i] = pii(a[i], 0);
    for(int k = 0; k < n; ++k)
        for(int mask = 0; mask < (1 << n); ++mask)
        {
            int bit = (mask >> k & 1);
            if(bit) continue;
            combine(dp[mask | (1 << k)], dp[mask]);
        }
    int ans = 0;
    for(int mask = 1; mask < (1 << n); ++mask)
    {
        ans = max(ans, dp[mask].first + dp[mask].second);
        cout << ans << '\n';
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}


Measured memory_bytes: 6144
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int[] U = new int[10000];
		int[] L = new int[10000];
		U[1] = 1;
		L[1] = 1;
		for(int i=2;i<10000;i++){
			U[i] = U[i-1]+i;
			L[i] = U[i-1]+1;
		}
		
		List<int> Li = new List<int>();
		for(int i=9999;i>=1;i--){
			if(L[i] <= N && N <= U[i]){
				N -= i;
				Li.Add(i);
			}
		}
		
		Li.Sort();
		Console.WriteLine(String.Join("\n",Li));
		
		
	}
	int N;
	public Sol(){
		N = ri();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 3160
#配るDP
#DPテーブル＆最小化問題なのでINFに初期化
h = [0]*100010
dp = [float("inf")]*100010

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

for i in range(N):
    h[i] = H[i]

#初期条件
dp[0] = 0
#ループ
for i in range(N):
    dp[i+1] = min(dp[i+1],dp[i]+abs(h[i]-h[i+1]))
    dp[i+2] = min(dp[i+2],dp[i]+abs(h[i]-h[i+2]))
print(dp[N-1])


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


int main() {
  string S, T; cin >> S >> T;
  string p1, p2;
  for(int i=0; i<S.size(); i++){
    p1 = S.substr(0,i+1);
    p2 = S.substr(i+1);
    if(T.find(p1)!=string::npos && T.find(p2)!=string::npos){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    ArrayList<Integer> a = new ArrayList<Integer>();
    int ans = 0;

    for (int i = 0; i < n; i++) {
      a.add(sc.nextInt());
    }

    a.sort(Collections.reverseOrder());

    for (int i = 0; i < n; i++) {
      if ((i % 2) == 0) {
        ans += a.get(i);
      } else {
        ans -= a.get(i);
      }
    }

    System.out.println(ans);

  }
}

Measured memory_bytes: 36216
#include <iostream>
#include <map>
#include <math.h>

#define DEBUG 0

using namespace std;

int max(int a,int b){
	return a>=b ? a : b;
}
int min(int a,int b){
	return a>=b ? b : a;
}

int main(){

	int r,n;
	int xi,xr,h;

	while(cin>>r>>n){
		if(r==0 && n==0){
			break;
		}

		map< int , int > data;
		map< int , int > data2;

		for(int i=-42;i<=42;i++){
			data[i]=0;
			data2[i]=0;
		}

		for(int i=0;i<n;i++){
			cin>>xi>>xr>>h;
			for(int j=0;j+xi*2<=xr*2;j++){
				data[j+xi*2] = max(data[j+xi*2],h);
			}
		}
		
		if(DEBUG){
		for(int i=-40;i<=40;i++){
			cout<<i<<" "<<data[i]<<endl;
		}
		}

		for(int i=-40;i<=40;i+=2){
			data[i]=min(data[i-1],data[i+1]);
		}

		if(DEBUG){
		for(int i=-40;i<=40;i++){
			cout<<i<<" "<<data[i]<<endl;
		}
		}

		for(int i=-20;i<=20;i++){
			data2[i] = data[i*2];
		}
		double ans = 100000000;
		for(int i=-r+1;i<r;i++){
			double offset = r - sqrt(r*r - i*i);
			if(DEBUG){
				cout<<"ans="<<ans<<" data2[i]= "<<data2[i]<<" offset= "<<offset<<endl;
			}
			if(ans >= data2[i]+offset){
				ans = data2[i]+offset;
			}
		}
		cout<<ans<<endl;

	}

	return 0;

}

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

int main() {
    int64_t N, ans;
    cin >> N;
    ans = N;
    map<string, bool> v;
    for (int64_t i = 0; i < N; i++) {
        string s;
        cin >> s;
        if (v.count(s)) {
            ans--;
        } else {
            v[s] = true;
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 19216
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main()
{
  	int N;
  	cin >> N;
	string S, T;
  	cin >> S >> T;
  	string ans;
  	rep(i,N){
		ans.push_back(S[i]);
      	ans.push_back(T[i]);
    }
  	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        String 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";
        
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        
        int k = Integer.parseInt(str);
        String[] v = a.split(",", 0);
        int _v = Integer.parseInt(v[k - 1].trim());

        System.out.println(_v);
        
    }
}


Measured memory_bytes: 22996
N, X, Y = list(map(int, input().split()))

dist = [N-i-1 for i in range(N-1)]

for a in range(X+int((Y-X)/2)+2) :
  temp = [0 for i in range(a)]
  for b in range(a+1, N) :
    d = abs(a+1-X)+abs(b+1-Y)+1
    if((b-a) > d) :
      dist[b-a-1] -= 1
      dist[d-1] += 1
  
for k in range(len(dist)) :
  print(dist[k])

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

typedef long long int ll;
using ii= pair<ll,ll>;
#define all(o) (o).begin(),(o).end()
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ld long double
#define eps 0.00000000001

class prioritize{
    public: bool operator() (ii &p1,ii &p2){
        return p1.F<p2.F;
    }
};

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

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    ll n;
    cin>>n;

    string s;
    cin>>s;
   
    ll count=0;

   
   

 
    ll i=0;
    ll j=n-1;

   

    while(i<j&&i<n&&j>=0){
    	
    	while(s[i]=='R'&&i<n){
    		i++;
    	}
    	while(s[j]=='W'&&j>0){
    		j--;
    	}


        if(i<n&&j>=0&&i<j){
        	s[i]='R';
    	    s[j]='W';
    	    count++;
    	    
        }
    	
    }


    if(count==0) cout<<0<<"\n";
    else{
        cout<<count<<"\n";
    } 
    	
  
}

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

void func(long long N, std::vector<long long> P, std::vector<long long> Q){
    vector<ll> a(N);
    rep(i,N) a[i] = i+1;
    map<vector<ll>, ll> mp;
    do {
        mp[a] = mp.size();
    } while (next_permutation(a.begin(), a.end()));

    cout << abs(mp[P] - mp[Q]) << endl;


}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> P(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&P[i]);
    }
    std::vector<long long> Q(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&Q[i]);
    }
    func(N, std::move(P), std::move(Q));
    return 0;
}


Measured memory_bytes: 6528
n, x, m = map(int, input().split())

dic = {}
tmp = []

a = x
sum_a = x
for i in range(n - 1):
    if a in dic:
        tmp.append(sum_a)
        idx0 = dic[a] - 1
        idx1 = i - 1
        period = idx1 - idx0
        times = (n - 1 - idx0) // period
        res = (n - 1 - idx0) % period
        before = tmp[idx0]
        if idx0 >= 0:
            ans = tmp[idx0 + res] + (tmp[idx1] - tmp[idx0]) * times
            print(ans)
        elif idx0 < 0:
            if res > 0:
                ans = (tmp[idx1 + 1] - tmp[idx0 + 1]) * times + tmp[res - 1]
                print(ans)
            else:
                ans = (tmp[idx1 + 1] - tmp[idx0 + 1]) * times
                print(ans)
        break
    else:
        tmp.append(sum_a)
        dic[a] = i
        a = a ** 2 % m
        sum_a += a
else:
    print(sum_a)

Measured memory_bytes: 17412
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std; 
const int N=1000000+10;
char a[N],b[N];
int n,m,q,nxt[N],f[N],g[N],sum[N];

void get_next() {
	nxt[1]=0; 
	for (int i=2,j=0;i<=n;i++) {
		while (j>0 && a[j+1]!=a[i]) j=nxt[j];
		if (a[j+1]==a[i]) j++;
		nxt[i]=j;
	}
}

void KMP() {
	for (int i=1,j=0;i<=m;i++) {
		while (j>0 && (j==n || b[i]!=a[j+1])) j=nxt[j];
		if (b[i]==a[j+1]) j++;
		f[i]=j;
		if (f[i]==n) g[i]=1;  //这就是A在B中的某一次出现 
	}
}

int main()
{
	cin>>m>>q;
	scanf("%s",b+1);
	n=2; a[1]='A'; a[2]='C'; a[3]='\0';
	get_next();
	KMP();
	for (int i=1;i<=m;i++) sum[i]=sum[i-1]+g[i];
	for (int i=1;i<=q;i++) {
		int l,r; scanf("%d%d",&l,&r);
		if (r-l+1<2) printf("%d\n",0);
		else printf("%d\n",sum[r]-sum[l]);
	}
	return 0;
}

Measured memory_bytes: 13568
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long K = sc.nextLong();
		long[] A = new long[N];
		int negative = 0;
		int positive = 0;
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextLong();
			if(A[i] > 0) {
				positive++;
			}
			else if(A[i] < 0) {
				negative++;
			}
		}
		Arrays.sort(A);
		long inf = A[0]*A[N-1]-1;
		long max = Math.max(A[0]*A[1], A[N-2]*A[N-1]);
		long mid;
		while(max-inf >= 0) {
			mid = (max+inf)/2;
			if(ok(A,K,mid)) {
				inf = mid+1;
			}
			else {
				max = mid-1;
			}
		}
		System.out.println(max);
	}
	static boolean ok(long[] a, long K,long mid) {
		int L = a.length;
		long sum = 0;
		for(int i = 0; i < L; i++) {
			long now = a[i];
			int left = 0;
			int right = L-1;
			if(now >= 0) {
				while(right-left>=0) {
					int center = (left+right)/2;
					if(now*a[center]<mid) {
						left = center+1;
					}
					else {
						right = center-1;
					}
				}
				sum += left;
			}
			else {
				while(right-left>=0) {
					int center = (left+right)/2;
					if(now*a[center]>=mid) {
						left = center+1;
					}
					else {
						right = center-1;
					}
				}
				sum+=L-left;
			}
			if((long)a[i]*a[i]<mid) {
				sum--;
			}
		}
		return sum/2 < K;
	}
}

Measured memory_bytes: 90148
function main(input){
  input = input.split('\n');
  const K = Number(input[0]);
  const [A, B] = input[1].split(' ').map(Number);

  for(let i=A; i<=B; i++){
    if(i%K ===0){
      console.log('OK')
      return
    }
  }

  console.log('NG');
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim());


Measured memory_bytes: 30700
#include <stdio.h>

int main(){

  int i;
  int count[26]={0};
  char str;

  while(scanf("%c",&str)!=EOF){
    if(str>='a' && str<='z'){
      count[str-'a']++;
    }else if(str>='A' && str<='Z'){
      count[str-'A']++;
    }
  }
  for(i=0;i<26;i++){
    printf("%c : %d\n",'a'+i,count[i]);
  }
  return 0;
}


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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define pii pair<int, int>
#define sz size()

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>void __f(const char* name, Arg1&& arg1){cout<<name<<" : "<<arg1<<"\n";}
template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args)
{const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" , ";__f(comma+1, args...);} 
#define traceloop(x,a) { cerr<<#a<<": "; for(ll ix=0;ix<x;ix++) cerr<<a[ix]<<" "; cerr<<endl; }

const ll MOD = 1e9 + 7;
map<ll, ll> m;

ll a(ll k)
{
	if(k < 2)
		return k+1;
	if(m.count(k))
		return m[k];
	//a(2k) = 2*a(k-1) + a(k); a(2k+1) = 2*a(k) + a(k-1)
	if(k&1)
		return m[k] = (2LL*a(k/2) % MOD + a(k/2-1)) % MOD;
	else
		return m[k] = (2LL*a(k/2-1)%MOD + a(k/2)) % MOD;
}

int main()
{
	ios::sync_with_stdio(0);
	ll i, j, k, n;

	cin >> n;
	cout << a(n);

	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 212345;
ll A[MAX_N];
ll S[MAX_N];
int N;

vector< pair<ll,ll> > f(int a, int b) {
  ll tot = S[b] - S[a];
  int pos = lower_bound(S+a, S+b, tot/2 + S[a]) - S;
  vector< pair<ll, ll> > res;


  if (a < pos-1 && pos-1 < b) res.push_back( { S[pos-1] - S[a], S[b] - S[pos-1] } );
  if (a < pos   && pos   < b) res.push_back( { S[pos]   - S[a], S[b] - S[pos]   } );
  if (a < pos+1 && pos+1 < b) res.push_back( { S[pos+1] - S[a], S[b] - S[pos+1] } );

  return res;
}

int main2() {
  N = nextInt();
  REP(i, N) A[i] = nextInt();
  S[0] = 0;
  REP(i, N) S[i+1] = S[i] + A[i];

  ll ans = 1LL << 58;
  for (int i = 2; i <= N-2; i++) {
    auto lefts = f(0, i);
    auto rights = f(i, N);
    for (auto left : lefts) {
      for (auto right: rights) {
        ll ma = max( { left.first, left.second, right.first, right.second } );
        ll mi = min( { left.first, left.second, right.first, right.second } );
        chmin(ans, ma - mi);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 3456
from collections import defaultdict

import sys
input = sys.stdin.readline

def main():
    num_land, num_ship = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(num_ship)]

    move_dic = defaultdict(set)

    for i in range(num_ship):
        a, b = data[i]
        move_dic[a].add(b)
        move_dic[b].add(a)

    next_land = move_dic[1]
    for ele in next_land:
        aaa = move_dic[ele]
        if num_land in aaa:
            print('POSSIBLE')
            break
    else:
        print('IMPOSSIBLE')

if __name__ == '__main__':
    main()

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

namespace ABC098A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, max;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
       
            max = a + b;

            if (max < a - b) max = a - b;
            if (max < a * b) max = a * b;
            
    
            Console.WriteLine(max);
      
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<string>
using namespace std;
typedef long long ll;

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

	if (s == "Sunny") {
		cout << "Cloudy" << endl;
	}
	else if (s == "Cloudy") {
		cout << "Rainy" << endl;
	}
	else {
		cout << "Sunny" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define yes { cout << "YES" << endl; exit(0); }
#define no { cout << "NO" << endl; exit(0); }
#define impossible { cout << "Impossible" << endl; exit(0); }

using namespace std;

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

const int Nmax = 1e5 + 5;

int A[Nmax], B[Nmax];
ll Sum[Nmax], sum;
int mns[Nmax];
int n;
int ord[Nmax], where[Nmax];

ll need(int s, int forb = 0)
{
    if(!forb) return sum - Sum[s];
    
    if(where[forb] > s) return sum - Sum[s];
    return sum - (Sum[s+1] - mns[forb]);
}

bool cmp(int x, int y)
{
    return mns[x] > mns[y];
}

int main()
{
//    freopen("inputD", "r", stdin);
    // freopen("output", "w", stdout);
    cin.sync_with_stdio(false); cin.tie(0);

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

    for(i=1; i<=n; ++i) sum += A[i];
    for(i=1; i<=n; ++i) mns[i] = max(A[i], B[i]), ord[i] = i;

    sort(ord+1, ord+n+1, cmp);
    for(i=1; i<=n; ++i) where[ord[i]] = i, Sum[i] = Sum[i-1] + mns[ord[i]];

    int st, dr, mid;

    st = 1; dr = n;
    while(st <= dr)
    {
        mid = (st + dr) / 2;
        if(need(n-mid+1) <= 0) st = mid + 1;
        else dr = mid - 1;
    }

    int start = dr;
    ll P = 0, Q = 1;

    for(i=1; i<=n; ++i)
    {
        ll p = -(need(n-start, i) - B[i]);
        ll q = B[i];

        double proc = -1.0 * (need(n-start, i) - B[i]) / B[i];
        // cerr << (dr-1 + proc) / n << '\n';

        if(p * Q > P * q) P = p, Q = q;
    }


    P += (ll) Q * (start - 1);
    Q *= n;

    ll g = __gcd(P, Q);
    P /= g;
    Q /= g;

    cout << P << ' ' << Q << '\n';

    return 0;
}



Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  
  if(a==0){
    cout << 1 << endl;
  }
  
  if(b==0){
    cout << 2 << endl;
  }
  
  if(c==0){
    cout << 3 << endl;
  }
  
  if(d==0){
    cout << 4 << endl;
  }
  
  if(e==0){
    cout << 5 << endl;
  }
  
}

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

queue<pair<int, int>> Q;
map<int, vector<int>> G;
short dist[200002];
int N, M, Ai, Bi, SOURCE = 1;

void bfs()
{
	Q.push(make_pair(0, SOURCE));

	while (!Q.empty())
	{
		int d = Q.front().first, u = Q.front().second;
		Q.pop();
		if (dist[u] != -1)
			continue;	// If visited (distance has been set), continue
		dist[u] = d; // Set distance
		for (int i = 0; i < G[u].size(); i++)
		{
			//cout << d + 1 << " " << G[u][i] << endl;
			Q.push(make_pair(d + 1, G[u][i]));
			// Increase distance by 1
		}
	}
}

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

	memset(dist, -1, sizeof(dist)); // Set every bit/entry of dist to -1

	cin >> N >> M;
	for (int i = 0; i < M; i++)
	{
		cin >> Ai >> Bi;
		if (G.find(Ai) == G.end()) // Initialise empty vector
			G.insert(make_pair(Ai, vector<int>()));
		G[Ai].push_back(Bi);

		if (G.find(Bi) == G.end()) // Initialise empty vector
			G.insert(make_pair(Bi, vector<int>()));
		G[Bi].push_back(Ai);
	}
	bfs();

	if (dist[N] == 2)
		cout << "POSSIBLE\n";
	else
		cout << "IMPOSSIBLE\n";
}


Measured memory_bytes: 24688
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    cin>>n;
    char a[100];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    int m=1;
    for(int i=0;i<n-1;i++){
        if(a[i]!=a[i+1]){
            m++;
        }
    }
    if(m==3){
        cout<<"Three"<<endl;
    }
    else{
        cout<<"Four"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int w=0, k=0;
  string s; cin >> s;
  k=s.length();
  for (int i=0; i<k; i++) if(s[i]=='o') w++;
  if(15-k+w>=8) cout << "YES" << "\n";
  else cout << "NO" << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

ll ans,M[100007];

ll compME(ll b, ll e, ll m){  // bのe乗のmod m を返す
    if (e == 0) return 1;
    ans = compME(b, e / 2, m);
    ans = (ans * ans) % m;
    if (e % 2 == 1) ans = (ans * b) % m;
    return ans;
}

int main(){
    string S;
    cin >> S;
    ll C=0;
    rep(i,S.size()){
        if(S[i]=='C' && C==0){
            C=1;
        }
        if(S[i]=='F' && C== 1){
            C=2;
        }
    }
    if(C==2){
        cYes;
    }
    else{
        cNo;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#define llint long long
#define mod 1000000007

using namespace std;

llint n;
llint x[100005], d[100005], sum[100005];
llint fsum[100005];

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

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

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

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	make_fact();
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> x[i];
	for(int i = 1; i <= n-1; i++) d[i] = x[i+1]-x[i], d[i] %= mod;
	
	for(int i = 1; i <= n-1; i++) sum[i] = sum[i-1] + d[i], sum[i] %= mod;
	
	for(int i = 1; i <= n-1; i++){
		fsum[i] = fsum[i-1] + fact[i-1] * fact_inv[i+1] % mod, fsum[i] %= mod;
	}
	
	llint ans = 0;
	for(int i = 1; i <= n-2; i++){
		if(n-1-i < i) continue;
		ans += ((sum[n-1-i]-sum[i-1]+mod)%mod) * ((fsum[n-1-i]-fsum[i-1]+mod)%mod) % mod;
		ans %= mod;
	}
	for(int i = 1; i <= n-1; i++){
		ans += (sum[n-1]-sum[n-i-1]+mod)%mod * modpow(i, mod-2) % mod, ans %= mod;
	}
	ans *= fact[n-1], ans %= mod;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 6528
require 'prime'
N = gets.to_i
# puts Prime.prime?(N)

if Prime.prime?(N)
  puts N.to_s.size
  exit
end
pre = Math.sqrt(N).floor
pre.downto(1) do |pr|
  if N % pr == 0
    puts (N / pr).to_s.size
    exit
  end
end

Measured memory_bytes: 2172
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <numeric>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecvec vector<vec>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

int func(vecvec& v,int h1,int w1,int h2,int w2){
    return v[h2][w2]-v[h2][w1]-v[h1][w2]+v[h1][w1];
}

int main(){
    int h=in(),w=in(),k=in();
    vecvec v(h+1,vec(w+1,0));
    rep(i,h){
        string s=stin();
        rep(j,w)v[i+1][j+1]=s[j]=='0'?v[i][j+1]+v[i+1][j]-v[i][j]:v[i][j+1]+v[i+1][j]-v[i][j]+1;
    }
    int ans=2000;
    rep(x,1<<(h-1)){
        int tmp=0;
        rep(i,h-1)if(x&(1<<i))tmp++;
        int end=0;
        rep(j,w){
            int ceil=0;
            bool flag=false;
            rep(i,h){
                if(func(v,i+1,j+1,ceil,end) > k)flag=true;
                if(x&(1<<i))ceil=i+1;
            }
            if(flag){
                if(j==end){
                    tmp=2000;
                    break;
                }
                tmp++;
                end=j;
            }
        }
        ans = min(ans,tmp);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3716
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut 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
        read_value!($iter, usize)
    };

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

// x ** n % mods を求める
pub fn mod_pow(x: i64, n: i64, mods: i64) -> i64 {
    if n == 0 {
        return 1;
    }
    let mut res = mod_pow(x * x % mods, n / 2, mods);
    if n % 2 == 1 {
        res = res * x % mods;
    }
    return res;
}

// (1/n) % mods を求める
pub fn mod_inv(n: i64, mods: i64) -> i64 {
    return mod_pow(n, mods-2, mods);
}

// nCk % mods を求める
pub fn mod_comb(n: i64, k: i64, mods: i64) -> i64 {
    let sum1 = (n-k+1..n+1).fold(1, |ac, x| ac * x % mods);
    let sum2 = (1..k+1).fold(1, |ac, x| ac * x % mods);
    return sum1 * mod_inv(sum2, mods) % mods;
}


fn main() {
    input!{
        n: usize,
        m: usize,
        sc: [(usize1, usize1); m],
    }
    //println!("{:?}", sc);
    let mut flag = 0;
    if n == 1 {
        let i = 0;
        flag = 1;
        for j in 0..m {
            if i.to_string().chars().nth(sc[j].0 - 1) != (sc[j].1).to_string().chars().nth(0) {
                flag = 0;
                break;
            }
        }
        if flag == 1 {
            println!("{}", i);
            return;
        }
    }
    for i in 10_i32.pow(n as u32 - 1)..10_i32.pow(n as u32) {
        flag = 1;
        for j in 0..m {
            if i.to_string().chars().nth(sc[j].0 - 1) != (sc[j].1).to_string().chars().nth(0) {
                flag = 0;
                break;
            }
            //println!("{:?}, {:?}", i.to_string().chars().nth(sc[j].0), (sc[j].1).to_string().chars().nth(0));
        }
        if flag == 1 {
            println!("{}", i);
            return;
        }
    }
    println!("-1");
}


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

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

    string S;
    cin >> S;

    if( S == "Sunny" ){
        cout << "Cloudy" << endl;
    }else if( S == "Cloudy" ){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define X first
#define Y second
using namespace std;
const int N = 200005, L = 262144, inf = 1e9;

int n, m, s[N];
pair<int,int> a[N];

struct minseg {
	int v[2*L];
	void init () {
		for(int i=2*L;i--;) v[i] = inf;
	}
	void upd (int P, int V) {
		P += L;
		while(P) {
			v[P] = min(v[P], V);
			P /= 2;
		}
	}
	int get (int S, int E) {
		S += L; E += L;
		int R = inf;
		while(S <= E) {
			if(S%2 == 1) R = min(R, v[S++]);
			if(E%2 == 0) R = min(R, v[E--]);
			S /= 2; E /= 2;
		}
		return R;
	}
} b, w;

int h (int I, int V) {return V ? I - s[I] : s[I];}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%d",&s[i]);
		s[i] += s[i-1];
	}
	scanf("%d",&m);
	for(int i=1;i<=m;i++) {
		scanf("%d%d",&a[i].X,&a[i].Y);
	}
	sort(a+1, a+1+m);
	b.init();
	w.init();
	w.upd(0, 0);
	for(int i=1;i<=m;i++) {
		int S = a[i].X, E = a[i].Y;
		int B = b.get(S-1, E-1), W = w.get(0, S-1);
		b.upd(E, B);
		w.upd(E, B + h(E, 1) - h(E, 0));
		b.upd(E, W + h(S-1, 0) - h(S-1, 1));
		w.upd(E, W + h(S-1, 0) - h(S-1, 1) + h(E, 1) - h(E, 0));
	}
	printf("%d\n", w.get(0,n) + s[n]);
}


Measured memory_bytes: 6656