akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
#include <map>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < (n); ++(i))
typedef long long ll;
using namespace std;

const int mod = 1e9+9;

vector<vector<ll> > operator * (vector<vector<ll> > const & p, vector<vector<ll> > const & q) {
    int n = p.size();
    vector<vector<ll> > r(n, vector<ll>(n));
    repeat (y,n) {
        repeat (z,n) {
            repeat (x,n) {
                r[y][x] += p[y][z] * q[z][x] % mod;
                r[y][x] %= mod;
            }
        }
    }
    return r;
}
vector<ll> operator * (vector<vector<ll> > const & p, vector<ll> const & q) {
    int n = p.size();
    vector<ll> r(n);
    repeat (y,n) {
        repeat (z,n) {
            r[y] += p[y][z] * q[z] % mod;
            r[y] %= mod;
        }
    }
    return r;
}
vector<vector<ll> > unit_matrix(int n) {
    vector<vector<ll> > e(n, vector<ll>(n));
    repeat (i,n) e[i][i] = 1;
    return e;
}
vector<vector<ll> > zero_matrix(int n) {
    vector<vector<ll> > o(n, vector<ll>(n));
    return o;
}

vector<vector<ll> > mul(vector<vector<ll> > const & p, vector<vector<ll> > const & q) { return p * q; }
template <typename T, typename F>
T powt(T x, ll y, T unit, F f) {
    T z = unit;
    for (ll i = 1; i <= y; i <<= 1) {
        if (y & i) z = f(z, x);
        x = f(x, x);
    }
    return z;
}

int main() {
    for (int testcase = 1; ; ++ testcase) {
        // input
        int w; ll h; int n; scanf("%d%lld%d", &w, &h, &n);
        if (w == 0 and h == 0 and n == 0) break;
        map<ll,vector<int> > obsts;
        repeat (i,n) {
            int x; ll y; scanf("%d%lld", &x, &y);
            -- x; -- y;
            obsts[y].push_back(x);
        }
        // compute
        vector<vector<ll> > f = zero_matrix(w);
        repeat (i,w) {
            for (int j : { i-1, i, i+1 }) if (0 <= j and j < w) {
                f[i][j] = 1;
            }
        }
        vector<ll> x(w);
        x[0] = 1;
        ll y = 0;
        obsts[h-1].push_back(-1);
        for (auto it : obsts) {
            ll ny = it.first;
            x = powt(f, ny-y, unit_matrix(w), mul) * x;
            for (int obst : it.second) if (obst != -1) x[obst] = 0;
            y = ny;
        }
        // output
        printf("Case %d: %lld\n", testcase, x[w-1]);
    }
    return 0;
}

Measured memory_bytes: 2872
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const double pi=3.141592653589;



int main() 
{
  ll A,B,H,M; cin>>A>>B>>H>>M;
  cout<< fixed << setprecision(15)<<sqrt(A*A+B*B-2*A*B*cos(abs(pi/6*H-pi*11/360*M)))<<endl;
  return 0;
}


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

using namespace std;

#define li long long int
#define FOR(i, a, b) for (li (i) = (a) ; (i) < (b) ; ++(i))
#define REP(i, n) FOR(i, 0, n)

int main(void) {
    li N, M, X, Y;
    cin >> N >> M >> X >> Y;

    li x[N];
    li y[M];

    FOR(i, 0, N) {
        cin >> x[i];
    }

    FOR(i, 0, M) {
        cin >> y[i];
    }

    // x, y を昇順にソート
    sort(x, x + N);
    sort(y, y + M);

    li xmax = x[N - 1];
    li ymin = y[0];

    if (xmax < ymin && xmax < Y && ymin > X) {
        // yの最小値がxの最大値よりも大きく
        // Yがxの最大値より大きく、xがyの最小値より小さい場合は戦争回避
        cout << "No War";
    } else {
        cout << "War";
    }

    return 0;
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////
	int a,b,c;
	cin >> a >> b >> c;
	if(c-b<=0) cout << "delicious" << endl;
	else if(c-b<=a) cout << "safe" << endl;
	else cout << "dangerous" << endl;

	
//////////////////////////////////////////////
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:10240000")
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 55;

int a[MAXN];
long long dp[MAXN][MAXN*MAXN];

int main ()
{
    int n, m;
    scanf ("%d%d", &n, &m);
    int total = 0;
    for (int i = 1; i <= n; i ++)
    {
        scanf ("%d", &a[i]);
        total += a[i];
    }
    memset (dp, 0, sizeof (dp));
    dp[0][0] = 1;
    for (int i = 1; i <= n; i ++)
    {
        for (int j = i; j >= 1; j --)
        {
            for (int k = total; k >= a[i]; k --)
            {
                dp[j][k] += dp[j - 1][k - a[i]];
            }
        }
    }
    long long ans = 0;
    for (int i = 1; i <= n; i ++)
    {
        int v = i * m;
        ans += dp[i][v];
    }
    printf ("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1536
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main() {
	int a, b, c;
	int tmp = 0;
	scanf("%d %d %d", &a, &b, &c);
	if (a > b) {
		tmp = b;
		b = a;
		a = tmp;
	}
	if (b > c) {
		tmp = c;
		c = b;
		b = tmp;
	}
	if (a > b) {
		tmp = b;
		b = a;
		a = tmp;
	}
	printf("%d %d %d\n", a, b, c);
	return 0;
}

Measured memory_bytes: 596
# 提出用のインプット
n, m, l = map(int, input().split())
A = [[0] * m for i in range(n)]
B = [[0] * l for i in range(m)]
C = [[0] * l for i in range(n)]
for i in range(n):
    A[i] = [int(i) for i in input().split()]
for i in range(m):
    B[i] = [int(i) for i in input().split()]

# # 動作確認用のインプット
# with open(file='input_itp1_7_d_1.txt', mode='r', encoding='utf8') as input:
#     n, m, l = map(int, next(input).split())
#     A = [[0] * m for i in range(n)]
#     B = [[0] * l for i in range(m)]
#     C = [[0] * l for i in range(n)]
#     for i in range(n):
#         A[i] = [int(i) for i in next(input).split()]
#     print(A)
#     for i in range(m):
#         B[i] = [int(i) for i in next(input).split()]
#     print(B)

for row in range(n):
    for col in range(l):
        tmp = 0
        for k in range(m):
            tmp += A[row][k] * B[k][col]
        C[row][col] = tmp
    print(' '.join(map(str, C[row])))




Measured memory_bytes: 6896
require 'pp'

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

N, W = gets_i_list
wv_list = []
N.times do
  wv_list.push gets_i_list
end

# 最大容量以下で、容量ごとの価値の最大値を格納する
dp = Array.new(W + 1, 0)

wv_list.each do |w, v|
  # 許容できる容量(wからW)の範囲の価値を更新する
  # uptoを使うと、ループで更新した値を参照してしまうため、downtoを使う
  W.downto(w) do |i|
    # 現在の値(dp[i])より、　itemを追加した場合の価値(dp[i - w] + v)が大きければ更新する
    if dp[i] < dp[i - w] + v
      dp[i] = dp[i - w] + v 
    end
  end
end
puts dp.max

Measured memory_bytes: 2812
from typing import List, Any


def read_int() -> int:
    return int(input().strip())


def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' ')))


def solve() -> Any:
    N, M = read_ints()
    # key to cover
    cover = [0]*M
    # key to cost
    costs = [0]*M
    INF = 10**9+1
    for i in range(M):
        a, b = read_ints()
        costs[i] = a
        for c in read_ints():
            cover[i] |= 1<<(c-1)
    # mask to cost
    mask_to_cost = [INF]*(1<<N)
    mask_to_cost[0] = 0
    for mask in range(1<<N):
        for i in range(M):
            mask_to_cost[cover[i]|mask] = min(mask_to_cost[cover[i]|mask], mask_to_cost[mask]+costs[i])
    return mask_to_cost[(1<<N)-1] if mask_to_cost[(1<<N)-1] != INF else -1


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 78992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);

template<typename T>
int get_digit(T x) {
  int y = 0;
  while (x > 0) {
    x /= 10;
    y++;
  }
  return y;
}


int main() {
  ll N; cin >> N;

  int ans = INF;
  for (ll A = 1LL; A <= sqrt(N); A++) {
    if (N % A != 0LL) continue;
    ll B = N / A;
    
    ans = min(ans, max(get_digit(A), get_digit(B)));
  }
    
  cout << ans << endl;

  return 0;
}


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

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();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int A,B,M; cin >> A >> B >> M;
    VI a(A), b(B);
    VI x(M), y(M), c(M);
    REP(i,A) cin >> a[i];
    REP(i,B) cin >> b[i];
    REP(i,M) cin >> x[i] >> y[i] >> c[i];

    int ans = INT_INF;
    REP(i,M){
        chmin(ans, a[x[i]-1]+b[y[i]-1]-c[i]);
    }
    SORT(a); SORT(b);
    chmin(ans, a[0]+b[0]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef vector<lld> vi;
typedef pair<int,int> pi;
#define F first
#define S second
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (int i = a; i < b; i++)
static lld r,j,l,x,y,b,m,n,s,q,i,z,p,k,c,d,a,t,u,e,g;string s1,s2,s3,s4;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>a>>b;
    if(abs((a-b))%2==0)
      cout<<"Alice";
    else
      cout<<"Borys";
}  

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

using namespace std;

const int mod = 1e9 + 7;

int n, cnt[26];
string s;

int main() {
    cin >> n >> s;
    for (int i = 0; i < n; i++) cnt[s[i] - 'a']++;
    int ans = 1;
    for (int i = 0; i < 26; i++) ans = 1LL * ans * (cnt[i] + 1) % mod;
    ans--;
    if (ans < 0) ans += mod;
    cout << ans;
    return 0;
}

Measured memory_bytes: 512
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.*;

public class Main{
	static long mod = 1000000007;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int x = -1;
		int y = -1;
		int z = -1;
		long ans = 1;
		for (int i = 0; i < n; i++) {
			long tmp = 0;
			if (a[i] == x + 1) {
				tmp++;
			}
			if (a[i] == y + 1) {
				tmp++;
			}
			if (a[i] == z + 1) {
				tmp++;
			}
			ans *= tmp;
			ans %= mod;
			if (a[i] == x + 1) {
				x++;
			} else if (a[i] == y + 1) {
				y++;
			} else if (a[i] == z + 1) {
				z++;
			}
		}
		System.out.println(ans);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 24656
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) //[l, r)
#define rep(i,n) REP(i,0,n)           //[0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showslr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i];}cerr<<endl //[l, r))

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}

void _DEBUG(){cerr<<endl;}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<",";_DEBUG(b...);}

template<typename T> inline void in(T &e){cin>>e;}
template<typename H,typename... T>void in(H &a, T&... b){in(a);in(b...);}
template<typename T> inline void out(T e){cout<<e<<endl;}
template<typename H,typename... T> void out(H a, T... b){out(a);out(b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int n;

signed main(){
    io();

    in(n);
    int ki=n/2+n%2;
    int gu=n/2;
    out(ki*gu);    

    return 0;
}


Measured memory_bytes: 504
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n; cin>>n; 
    int rem=n%100,ans=0;
    while (rem>0){
        if (rem>=5) ans += 105, rem -= 5;
        else if (rem>=4) ans += 104, rem -= 4;
        else if (rem>=3) ans += 103, rem -= 3;
        else if (rem>=2) ans += 102, rem -= 2;
        else ans += 101, rem -= 1;
    }
    if (ans>n) cout << 0 << endl;
    else cout << 1 << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
using Graph = vector<vector<int>>;

int main(){
	int n; cin >> n;
	string s, t; cin >> s >> t;
	rep(i, n){
		cout << s[i];
		cout << t[i];
	}
	cout << endl;
}

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

#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

inline void Main() {
  int x, n, tmp;
  vector<bool> p(110, true);

  cin >> x >> n;
  rep(i, n) {
    cin >> tmp;
    p[tmp] = false;
  }

  int a = 2 * x, b = 0, c;
  rep(i, 110) {
    c = abs(x - i);
    if (p[i]) {
      if (a > c) {
        a = c;
        b = i;
      } else {
        break;
      }
    }
  }

  if (x+1 < a) {
    cout << -1 << endl;
  } else {
    cout << b << endl;
  }
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 3660
#include<iostream>
using namespace std;
int main(){
  int w,a,b; cin >> w >> a >> b;
  if(b >= a and b <= a + w or a >= b and a <= b + w)
    cout << 0;
  else{
  	int sabun = min(abs(b- a-w),abs(a-b-w));
  	cout << max(0,sabun);
  }
}

Measured memory_bytes: 3648
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

const int C = 30;
vector<PI> pool[C];

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, cc;
  cin >> n >> cc;
  REP(i, 0, n) {
    int s, t, c;
    cin >> s >> t >> c;
    c--;
    pool[c].push_back(PI(s, t));
  }
  vector<PI> all;
  REP(i, 0, cc) {
    sort(pool[i].begin(), pool[i].end());
    vector<PI> tmp(pool[i]);
    pool[i].clear();
    int st = -1;
    int en = -1;
    REP(i, 0, tmp.size()) {
      if (tmp[i].first != en) {
	if (en >= 0) {
	  all.push_back(PI(2 * st - 1, 1));
	  all.push_back(PI(2 * en, -1));
	}
	st = tmp[i].first;
	en = tmp[i].second;
      } else {
	en = tmp[i].second;
      }
    }
    if (st >= 0) {
      all.push_back(PI(2 * st - 1, 1));
      all.push_back(PI(2 * en, -1));
    }
  }
  sort(all.begin(), all.end());
  int ma = 0;
  int cur = 0;
  REP(i, 0, all.size()) {
    cur += all[i].second;
    ma = max(ma, cur);
  }
  cout << ma << endl;
}


Measured memory_bytes: 3700
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  
  vector<int> l;
  l.push_back(1);
  l.push_back(1);

  for (int i = 2; i <= n; i++) {
    l.push_back(l[i-2] + l[i-1]);
  }
  cout << l[n] << endl;

  return 0;
}

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

int rank(char c) {
    if ('2' <= c && c <= '9') {
        return c - '2';
    }
    if (c == 'T') return 8;
    if (c == 'J') return 9;
    if (c == 'Q') return 10;
    if (c == 'K') return 11;
    if (c == 'A') return 12;
    assert(false); 
}

char trump;
int num[4][13];
char suit[4][13];

int main () {
    while (true) {
        cin >> trump;

        if (trump == '#') break;

        string token;
        for (int j = 0; j < 4; ++j) {
            for (int k = 0; k < 13; ++k) {
                cin >> token;
                num[j][k] = rank(token[0]);
                suit[j][k] = token[1];
            }
        }

        int ew_trick = 0, ns_trick = 0;
        int prev_winner = 3;

        for (int j = 0; j < 13; ++j) {
            int winner = -1;
            int max_rank = -1;
            bool trump_exists = false;
            for (int k = 0; k < 4; ++k) {
                if (trump == suit[k][j]) {
                    if (!trump_exists || num[k][j] > max_rank) {
                        max_rank = num[k][j];
                        winner = k;
                    }
                    trump_exists = true;
                } else if (!trump_exists && suit[prev_winner][j] == suit[k][j]) {
                    if (num[k][j] > max_rank) {
                        max_rank = num[k][j];
                        winner = k;
                    }
                }
            }

            if (winner % 2 == 0) {
                ++ns_trick;
            } else {
                ++ew_trick;
            }

            prev_winner = winner;
        }

        if (ew_trick > ns_trick) {
            cout << "EW " << (ew_trick - 6) << endl;
        } else {
            cout << "NS " << (ns_trick - 6) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1188
// package app;

import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);

        // final String N = sc.next();
        final int N = sc.nextInt();
        final int A = sc.nextInt();
        // final int N = sc.nextInt();
        // final int D = sc.nextInt();
        // System.out.println();

        System.out.println(N * N - A);

        // System.out.println(A <= X && A + B >= X ? "YES" : "NO");

    }
}

Measured memory_bytes: 22996
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

min_diff = float('inf')
min_index = None
for i, h in enumerate(H):
    ave_temp = T - h * 0.006
    diff = abs(ave_temp - A)
    if diff < min_diff:
        min_diff = diff
        min_index = i
print(min_index + 1)


Measured memory_bytes: 3060
S = input()

ans = [0]*len(S)

rflag = False
nowr = 0
lflag = False
nowl = 0
for i in range(len(S)):
    s1 = S[(-1)*(i+1)]
    s2 = S[i]

    #from right
    if s1 == "R":
        if rflag:
            if (i - nowr) % 2 == 1:
                ans[(-1) * (nowr)] += 1
            else:
                ans[(-1) * (nowr + 1)] += 1
        else:
            ans[(-1)*(i+1)] += 1
            rflag = True
            nowr = i
    elif s1 == "L" and rflag:
        rflag = False

    # from left
    if s2 == "L":
        if lflag:
            if (i - nowl) % 2 == 1:
                ans[nowl-1] += 1
            else:
                ans[nowl] += 1
        else:
            ans[i] += 1
            lflag = True
            nowl = i
    elif s2 == "R" and lflag:
        lflag = False

print(' '.join([str(_) for _ in ans]))

Measured memory_bytes: 53872
#include <iostream>
#include <climits>
#define int long long

using namespace std;

main() {

    cin.sync_with_stdio(false);

    int n;
    cin >> n;
    int t1,t2,T1,T2;

    for(int i = 1; i <= n; i++) {

        cin >> t1 >> t2;

        if(i == 1) {
            T1 = t1;
            T2 = t2;
            continue;
        }

        int mi = 0;
        int mid;
        int l = 1;
        int r = min(LLONG_MAX/t1, LLONG_MAX/t2);

        while(l <= r) {

            mid = l + (r-l)/2;

            if(t1*mid >= T1 && t2*mid >= T2) {
                r = mid-1;
                mi = mid;
            } else
                l = mid+1;

        }

        T1 = mi*t1;
        T2 = mi*t2;
        //cout << "T " << i << " " << T1 << " " << T2 << " " << mi << '\n';

    }

    cout << T1+T2 << '\n';

    return 0;
}


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

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
    #include "lib/dump.hpp"
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

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


Measured memory_bytes: 256
a=int(input())
b=[]
for i in range(a):
    b.append(input())
    if i!=0:
        if b[i-1][-1]!=b[i][0]:
            print("No")
            exit()
        for j in range(i-1):
            if b[j]==b[i]:
                print("No")
                exit()
print("Yes")


Measured memory_bytes: 2940
module WeightedDirectedGraph
  (Vertex : sig
    type t
    val compare : t -> t -> int
  end)
  (Weight : sig
    type t
    val zero : t
    val ( + ) : t -> t -> t
    val compare : t -> t -> int
  end) :
sig
  val dijkstra :
    (* 隣接リスト *)
    (Vertex.t -> (Vertex.t * Weight.t) list) ->
    (* 始点 *)
    Vertex.t ->
    (* 始点から辿り着けなければNoneを返す *)
    (Vertex.t -> Weight.t option)
end =
struct
  module WMap = Map.Make (Weight)
  module VMap = Map.Make (Vertex)

  let dijkstra e s =
    (* 始点sからの距離 *)
    (* d に入っていない頂点への距離は無限大とみなす *)
    let d = ref @@ VMap.singleton s Weight.zero in
    (* 優先度付きキュー *)
    let q = ref @@ WMap.singleton Weight.zero [s] in
    (* ダイクストラ法のメインループ *)
    let rec dijkstra_aux t =
      match WMap.min_binding !q with
      | exception Not_found ->
          (try Some (VMap.find t !d) with Not_found -> None)
      | (w, us) ->
          if
            (* 現時点で終点までの距離が分かっているか *)
            try Weight.compare (VMap.find t !d) w <= 0
            with Not_found -> false
          (* 既に終点までの距離が分かっているので返す *)
          then Some (VMap.find t !d)
          else begin
            (* 終点までの距離が分かっていないので，ダイクストラ法を続行 *)
            q := WMap.remove w !q;
            List.iter (fun u ->
              if 0 <= Weight.compare (VMap.find u !d) w then
                (* 未だ頂点uを訪れていない *)
                List.iter (fun (v, c) ->
                  let open Weight in
                  if
                    try 0 < Weight.compare (VMap.find v !d) (w + c)
                    with Not_found -> true  (* d.(v) は無限大 *)
                  then begin
                    d := VMap.add v (w + c) !d;
                    q := WMap.add (w + c) (v :: try WMap.find (w + c) !q with Not_found -> []) !q
                  end) (e u)) us;
            dijkstra_aux t
          end in dijkstra_aux
end

module G = WeightedDirectedGraph
  (struct
    type t = int * int
    let compare = compare
  end)
  (struct
    type t = int
    let zero = 0
    let ( + ) = ( + )
    let compare = compare
  end)

module IntMap = Map.Make (struct
  type t = int
  let compare = compare
end)

let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let es = Array.make n IntMap.empty in
  for i = 0 to m - 1 do
    Scanf.scanf "%d %d %d\n" @@ fun p q c ->
      es.(p - 1) <- IntMap.add c (q - 1 :: try IntMap.find c es.(p - 1) with Not_found -> []) es.(p - 1);
      es.(q - 1) <- IntMap.add c (p - 1 :: try IntMap.find c es.(q - 1) with Not_found -> []) es.(q - 1)
  done;
  match
    G.dijkstra (function
      | (v, 0) -> List.map (fun (c, _) -> ((v, c), 1)) @@ IntMap.bindings es.(v)
      | (v, c) -> ((v, 0), 0) :: (List.map (fun v -> ((v, c), 0)) (try IntMap.find c es.(v) with Not_found -> []))) (0, 0) (n - 1, 0)
  with 
  | None -> print_endline "-1"
  | Some d -> Printf.printf "%d\n" d


Measured memory_bytes: 100088
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;

using int64 = long long;

const int64 mod = 1e9 + 7;

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

    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }

    static int64 table[410][410];   // table[i][j] := (a_i^j + a_(i+1)^j + ... + B_i^j)
    for (int i = 0; i < N; i++) {
        for (int k = A[i]; k <= B[i]; k++) {
            int64 val = 1;
            for (int j = 0; j <= C; j++) {
                (table[i][j] += val) %= mod;
                (val *= k) %= mod;
            }
        }
    }

    static int64 dp[410][410];
    dp[0][0] = 1;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= C; j++) {

            for (int k = 0; k <= C; k++) {
                if (j - k < 0) continue;
                (dp[i + 1][j] += (table[i][k] * dp[i][j - k]) % mod) %= mod;
            }
        }
    }
    cout << dp[N][C] << endl;

    return 0;
}

Measured memory_bytes: 2816
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PipedInputStream;
import java.util.*;

public class Main {
    private static final int MOD = (int) Math.pow(10, 9);
    private static final int[][] DIRS = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

    public static void main(String[] args) {
        FastReader sc = new FastReader();

        int[] nums = new int[10];

        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a == b) {
            print("Yes");
        } else {
            print("No");
        }

        System.exit(0);
    }

    static  private void print(String s) {
        System.out.println(s);
    }

    static private int log2(int x) {
        return (int)(Math.log(x) / Math.log(2));
    }

    static private long gcd(long m, long n) {
        if (m < n) { return gcd(n, m); }
        if (m % n == 0) { return n; }
        return gcd(n, m%n);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    if (i % 3 != 0 && i % 5 != 0) ans += i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double PI = 3.14159265358979323846;
typedef long long ll;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) for (ll i = 0; i < (n); ++i)

int main(void) {
  int k;
  string s;
  cin >> k >> s;
  string ans;
  if (s.size() <= k) {
    ans = s;
  } else {
    s.erase(k);
    ans = s + "...";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void)
{
  long int n,x,y,z,sum;
  
  scanf("%ld", &n);
  
  for(long int i=1;i<=n;i++){
    sum=0;
    for(x=1;x<=sqrt(i);x++){
      for(y=1;y<=sqrt(i);y++){
        for(z=1;z<=sqrt(i);z++){
          if(x*x+y*y+z*z+x*y+y*z+z*x==i)
            sum++;
          if(x*x+y*y+z*z+x*y+y*z+z*x>i)
            break;
        }
      }
    }
  printf("%ld\n", sum);}
  
  return 0;
}


Measured memory_bytes: 2136
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7


def gcd(x, y):
    if x < y:
        x, y = y, x
    while y > 0:
        x, y = y, x % y
    return x

def lcm(x, y):
    return x * y // gcd(x, y)

n, m = MAP()
a = LIST()
a0 = a[0]
aa = 0
while a0 % 2 == 0:
    a0 //= 2
    aa += 1
for i in range(1, n):
    ai = a[i]
    for _ in range(aa):
        if ai % 2 == 1:
            print(0)
            exit()
        ai //= 2
    if ai % 2 == 0:
        print(0)
        exit()

b = [i // 2 for i in a]
l = 1
for i in range(n):
    l = lcm(l, b[i])
ans = m // l
ans = (ans + 1) // 2
print(ans)

Measured memory_bytes: 85100
// atcoder/abc177/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

template<typename T>
struct PrefixSum {
  vector<T> sum;
  PrefixSum(vector<T> v) {
    sum.push_back(0);
    for (int i = 0; i < v.size(); ++i) {
      sum.push_back((sum.back() + v[i]) % mod);
    }
  }
  T operator () (size_t begin, size_t end) const {
    assert(begin <= end);
    return sum[end] - sum[begin];
  }
};

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n;
  while (cin >> n) {
    vec<lli> a(n);
    cin >> a;

    PrefixSum<lli> s(a);
    lli sum = 0;

    for (int i = 0; i < a.size(); ++i) {
      // cout << a[i] << ' ' << s(i+1, a.size()) << endl;
      lli x = a[i] * (s(i + 1, a.size()) + mod) % mod;
      x %= mod;
      sum += x;
      sum %= mod;
    }

    cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 8436
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout<<endl
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }

int main()
{
	int n, k; cin >> n >> k;
	if ((n + 1)/ 2 >= k)co("YES");
	else co("NO");
	return 0;
}


Measured memory_bytes: 256
x=int(input())
a=[0]*x
k=0
t=0
for i in range(11,55555,10):
	t=0
	for j in range (2,round(i**0.5)+2):
		if i%j==0:
			t=1
	if t==0 and k<x:
		a[k]=i
		k=k+1
print(*a)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

string keyence="keyence";

int main() {
  lli N;
  cin >> N;
  lli sumA=0,sumB=0;
  vector<lli> A(N);
  vector<lli> B(N);
  int ans=0;
  lli lack=0;
  rep(i, N){
  cin >> A[i];
    sumA+=A[i];
  }
  rep(i, N){
  cin >> B[i];
    sumB+=B[i];
  }
  if(sumA<sumB){
    cout << -1 << endl;
    return 0;
  }
  
  vector<lli> defference(N);
  rep(i, N)
  {
  defference[i]=A[i]-B[i];
    if(defference[i]<0){
      lack-=defference[i];
      ans++;
    }
  }
  sort(ALL(defference));
  reverse(ALL(defference));
  rep(i, N){if(lack<=0){
  break;
  }
  ans++;
    lack-=defference[i];
  
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 1000000007
#define bitcnt(a) (ll) __builtin_popcount((a))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
  ll n;
  cin >> n;
  vector<ll> v;
  REP(i, n) {
    ll h;
    cin >> h;
    v.pb(h);
  }
  ll cnt = 0, left = 0, right = 0, x = 0;
  while (1) {
    if (left > right) {
      right++;
      continue;
    }
    if ((x & v[right]) > 0) {
      x ^= v[left];
      if (left == n - 1)
        break;
      left++;
      continue;
    }
    cnt += right - left + 1;
    // cout << left << " " << right << endl;
    x ^= v[right];
    if (right != n - 1) {
      right++;
    } else {
      break;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 2420
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>

using namespace std;

int main(){
   int a,b;
   cin>>a>>b;
   if(a<=8 && b<=8)cout<<"Yay!"<<endl;
   else cout<<":("<<endl;
   
   
}

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

typedef long long ll;

#define pb push_back
#define mp make_pair
#define forn(n) for(int i=0; i < n; i++)
#define MOD 1000000007
#define endl '\n'

template<typename T>
void max_self(T& a, T b) { a=a>b?a:b; }
template<typename T>
void min_self(T& a, T b) { a=a<b?a:b; }

using namespace std;

#define int long long

const int mxW = 1e5+5;
int n;
int w;

int temp_value, temp_weight;

int weights[mxW];


#undef int
int main() {
#define int long long
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> w;

    while(n--) {
        cin >> temp_weight >> temp_value;
        for(int i=w-temp_weight; i>=0; --i)
            max_self(weights[i+temp_weight],weights[i]+temp_value);
    }
    cout << weights[w] << endl;

    return 0;

}



Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
	char x[110];
int main()
{
	int n;
	int i,j;
	scanf("%d",&n);
	int a=0,b=0;
	scanf("%s",&x);
	for(i=0;i<n; i++)
    {
		if(x[i]=='(')
        {
			a++;
		}
        else
        {
			if(a>0)
			{
				a--;
			}
            else
            {
				b++;
			}
		}
	}
	for(i=0;i<b;i++)
    {
		printf("(");
	}
	printf("%s",x);
	for(i=0;i<a;i++)
    {
		printf(")");
	}
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>




using namespace std;
int main() {
	
	string p;
	cin >> p;
	sort(p.begin(), p.end());

	if (p.size() % 2) {
		cout << "No" << endl; return 0;
	}
  set<char>x;
	for (int i = 1; i < p.size() / 2; i++) {
      x.insert(p[i]);
      x.insert(p[i+p.size()/2]);
		if (p[i] != p[i - 1] || p[i + p.size() / 2] != p[i - 1 + p.size() / 2]) {
			cout << "No" << endl;
			return 0;
		}
	}
if(x.size()!=2)cout<<"No"<<endl; 
	else cout << "Yes" << endl;
	

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  int s;
  cin >> s;
  set<int> a;
  while(!(a.count(s))) {
    a.insert(s);
    if(s % 2 == 0)
      s /= 2;
    else
      s = 3 * s + 1;
  }
  cout << a.size() + 1;
}

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

typedef long long ll;

ll K;
string S;
ll N;
const ll MOD = 1e9 + 7;
vector<ll> Inv, Fact, IFact;
ll Res;

ll choose(ll a, ll b) { return Fact[a] * IFact[b] % MOD * IFact[a - b] % MOD; }
ll power(ll a, ll b) {
  ll res = 1, tmp = a;
  for (ll x = 1; x <= b; x <<= 1) {
    if (b & x) (res *= tmp) %= MOD;
    (tmp *= tmp) %= MOD;
  }
  return res;
}
int main() {
  cin >> K >> S;
  N = S.size();
  Inv.resize(N + K + 1), Fact.resize(N + K + 1), IFact.resize(N + K + 1);
  Inv[1] = Fact[0] = Fact[1] = IFact[0] = IFact[1] = 1;
  for (ll i = 2; i <= N + K; ++i) {
    Inv[i] = MOD - MOD / i * Inv[MOD % i] % MOD;
    Fact[i] = i * Fact[i - 1] % MOD;
    IFact[i] = Inv[i] * IFact[i - 1] % MOD;
  }
  for (ll i = 0; i <= K; ++i) {
    (Res +=
     choose(N - 1 + i, i) * power(25, i) % MOD * power(26, K - i) % MOD) %= MOD;
  }
  cout << Res << endl;
  return 0;
}


Measured memory_bytes: 51084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m;
string s;
map<string,int> num[19];
int main(){
    cin>>n>>s;
    for(int i=0;i<(1<<n);i++){
        string cur="";
        int cnt=0;
        for(int j=0;j<n;j++){
            if(((i>>j)&1)==0){
                cnt++; cur += s[j];
            }
        }
        for(int j=0;j<n;j++){
            if(((i>>j)&1)==1) cur += s[j];
        }
        num[cnt][cur]++;
    }
    reverse(s.begin(),s.end());
    ll ans=0;
    for(int i=0;i<(1<<n);i++){
        string cur = "";
        int cnt=0;
        for(int j=0;j<n;j++){
            if(((i>>j)&1)==1){
                cnt++; cur+=s[j];
            }
        }
        for(int j=0;j<n;j++){
            if(((i>>j)&1)==0){
                cur+=s[j];
            }
        }
        ans += num[cnt][cur];
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 73984
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<map>
#define debug(a) cout << "*" << a << "*" << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int n, m, mod = 12805;
int x, a[85][85], b[85][85];
bool dp[2][85][12805];
int main()
{   
	while (scanf("%d%d", &n, &m) != EOF)
	{
		memset(a, 0, sizeof(a));
		memset(b, 0, sizeof(b));
		memset(dp, 0, sizeof(dp));
		dp[0][1][0] = true;
		for (int i = 1; i <= n; i++)
		{
			for (int j = 1; j <= m; j++)
			{
				scanf("%d", &a[i][j]);
			}
		}
		for (int i = 1; i <= n; i++)
		{
			for (int j = 1; j <= m; j++)
			{
				scanf("%d", &x);
				a[i][j] = abs(a[i][j] - x);
				b[i][j] = a[i][j] + max(b[i - 1][j], b[i][j - 1]); 
			}
		}
		for (int i = 1; i <= n; i++)
		{
			memset(dp[i & 1], 0, sizeof(dp[i & 1]));
			for (int j = 1; j <= m; j++)
			{
				for (int k = 0; k <= max(b[i - 1][j], b[i][j - 1]); k++)
				{
					if (dp[(i + 1) & 1][j][k] || dp[i & 1][j - 1][k])
					{
						dp[i & 1][j][abs(a[i][j] - k)] = true;
						dp[i & 1][j][abs(-a[i][j] + k)] = true;
						dp[i & 1][j][abs(-a[i][j] - k)] = true;
						dp[i & 1][j][abs(a[i][j] + k)] = true;
					}
				}
			}
		}
		int i;
		for (i = 0; i < mod; i++)
		{
			if (dp[n & 1][m][i])	break;
		}
		printf("%d\n", i);
	}
}

Measured memory_bytes: 2560
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST

main :: IO ()
main = do
  n <- readLn :: IO Int
  as <- map read . words <$> getLine :: IO [Int]
  bs <- map read . words <$> getLine :: IO [Int]
  cs <- map read . words <$> getLine :: IO [Int]
  print $ solve n as bs cs

solve :: Int -> [Int] -> [Int] -> [Int] -> Int
solve n as bs cs = sum bs + (fst $ foldl' f (0, -1) as)
  where
    -- b = listArray (1, n) bs
    c = listArray (1, n-1) cs

    f :: (Int, Int) -> Int -> (Int, Int)
    f (!acc, !prev) a 
      -- | a == 1 = (acc, a)
      = (acc + if prev+1 == a then c!(a-1) else 0, a)

Measured memory_bytes: 764
n,k=map(int,input().split())
a=[]
for i in range(0,k):
  d=int(input())
  b=list(map(int,input().split()))
  a=a+b

ans=[]
for i in range(1,n+1):
  if i not in(a):
    ans.append(i)
print(len(ans))

Measured memory_bytes: 9192
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N, M, A[SIZE];
  pair<int,int> query[SIZE];

  scanf("%d%d", &N, &M);

  for (int i=0; i<N; i++)
    scanf("%d", A+i);

  sort(A, A+N, greater<int>());

  for (int i=0; i<M; i++) {
    int B, C;
    scanf("%d%d", &B ,&C);
    query[i] = {C, B};
  }

  sort(query, query+M, greater<pair<int,int>>());

  ll ans = 0;

  int t = 0, s = 0;
  for (int i=0; i<N; i++) {
    if (s >= M || query[s].first <= A[t]) {
      ans += A[t];
      t++;
    } else {
      ans += query[s].first;
      query[s].second--;
      if (query[s].second == 0) s++;
    }
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 2560