akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a < b) {
            System.out.println("a < b");
        } else if (a > b) {
            System.out.println("a > b");
        } else {
            System.out.println("a == b");
        }
    }
}



Measured memory_bytes: 26216
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    O = input().rstrip()
    E = input().rstrip()
    password=""
    last = ""

    if len(O) > len(E):
        last = O[-1]
    elif len(O) < len(E):
        last = E[-1]
    else:
        last=""

    for p1,p2 in zip(O,E):
        password+=p1+p2
    print(password+last)

if __name__=="__main__":
    main()

Measured memory_bytes: 9024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        long s = Long.parseLong(sc.next());
        
        int x1 = 1000000000;
        int x2 = 1;
        int y1, y2;
        if(s%x1 == 0){
            y1 = 0;
            y2 = (int)(s/x1);
        }else{
            y1 = x1 - (int)(s%x1);
            y2 = (int)(s/x1) +1;
        }
        
        System.out.println(x1 +" " +y1 +" " +x2 +" " +y2 +" 0 0");
    }
}

Measured memory_bytes: 23764
using System;

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var w = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < s.Length; i+= w )
            Console.Write(s[i]);
        Console.WriteLine();
    }
}

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

int main() {
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1;i <= n;i += 2) {
		int d = 0;
		for (int j = 1;j <= n;j++) {
			if (i%j == 0)d++;
		}
		if (d == 8)ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
    int n, m, l;
    int i, j, k;
    int a[100][100], b[100][100];
    long long sum;
 
    scanf("%d %d %d", &n, &m, &l);
 
    for(i=0;i<n;i++){
        for(j=0;j<m;j++)
            scanf("%d", &a[i][j]);
    }
 
    for(i=0;i<m;i++){
        for(j=0;j<l;j++)
            scanf("%d", &b[i][j]);
    }
 
 
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            sum = 0;
            for(k=0;k<m;k++)
                sum += a[i][k] * b[k][j];
            if(j==l-1)
                printf("%ld", sum);
            else
                printf("%ld ", sum);
        }
        printf("\n");
    }
 
    return 0;
}

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

#define INF 100000000
#define ABS(a) (a<0?-(a):a)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define REP(i,a) for(int i=0;i<a;i++) 

using namespace std;
int main(){
  int r,g,b;
  cin >> r >> g>> b;

  if((10*g+b)%4 == 0){
    cout << "YES" << endl;
  }else {
    cout << "NO"<< endl;
  }
}



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

int main()
{
	int n, m = 0;
	cin >> n >> m;
	int a, b;
	vector<int> c(n);
	for (int i = 0; i < m; i++)
	{
		cin >> a >> b;
		c[a - 1]++;
		c[b - 1]++;
	}
	for (int i = 0; i < n; ++i)
	{
		cout << c[i] << "\n";
	}

	// cout << ans << "\n";
	// return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};

fn main() {
    input! {
        d:i32,
        c: [i32; 26],
        s: [[i32; 26];d],
        mut t: [i32; d],
        m: i32,
        q: [(i32, i32);m]

    };

    for i in q {
        t[i.0 as usize - 1] = i.1;

        let mut s_d = vec![0; 26];
        let mut score: i32 = 0;
        for (x, i) in t.iter().enumerate() {
            let x = x as usize;
            let i = *i as usize;

            score += s[x][i - 1]; //スコア反映
            s_d[i - 1] = x + 1;
            for j in 0..26 {
                if i - 1 != j {
                    score -= c[j] * (x as i32 + 1 - s_d[j] as i32);
                }
            }
        }
        println!("{}", score);
    }

    //for i in s.iter() {
    //    let pos = i
    //        .iter()
    //        .position(|&x| x == *i.iter().max().unwrap())
    //        .unwrap();
    //}
}


Measured memory_bytes: 3388
#include<stdio.h>
const int MAX_V = 999999;
int main(){
        int prime[MAX_V+1];
        int sum[MAX_V+1];
        int i, j, n;
        for(i = 2; i <= MAX_V; i++){
                prime[i] = 1;
        }
        for(i = 2; i * i <= MAX_V; i++){
                if(prime[i]){
                        for(j = 2 * i; j <= MAX_V; j += i){
                                prime[j] = 0;
                        }
                }
        }
        sum[0] = 0;
        prime[0] = 0;
        prime[1] = 0;
        for(i = 0; i <= MAX_V; i++){
                sum[i+1] = sum[i] + prime[i];
        }
        while(scanf("%d",&n)!=EOF){
                printf("%d\n", sum[n + 1]);
        }
        return 0;
}

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

int main(){
  int N,K; cin >> N >> K;
  string S; cin >> S;
  if (S.at(K - 1) == 'A'){
    S.at(K - 1) = 'a';
  } else if (S.at(K - 1) == 'B'){
    S.at(K - 1) = 'b';
  } else {
    S.at(K - 1) = 'c';}
  cout << S << endl; 
}
    
    
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define in insert
#define b back
#define f front
#define p push
#define FOR(i,a,b) for (ll i=a; i<=b; i++)
#define FOD(i,a,b) for (ll i=a; i>=b; i--)
#define mp make_pair
#define up upper_bound
#define lp lower_bound
#define endl "\n"
//priority_queue <int> ; less
//priority_queue <int,vector<int>,greater<int> > ; greater
using namespace std;
ll n,i,a[200005],kq[200005];
set <ll> dp;
set <ll> ::iterator it,tg;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n;
	for (i=1;i<=n;i++) cin>>a[i];
	for (i=1;i<=n;i++) cin>>kq[a[i]];
	dp.in(a[1]);
	for (i=2;i<=n;i++)
	{
		it=dp.up(a[i]);
		if (it==dp.end())
		{
			tg=dp.end();
			tg--;
			kq[a[i]]+=kq[*tg];
			dp.in(a[i]);
		}
			else 
			{
				if (it==dp.begin())
				{
					while(kq[*it]<=kq[a[i]]&&it!=dp.end()) 
					{
						dp.erase(it);
						it=dp.up(a[i]);
					}
					dp.in(a[i]);
				}
				else
				{
					tg=it;
					tg--;
					kq[a[i]]+=kq[*tg];
					while(kq[*it]<=kq[a[i]]&&it!=dp.end()) 
					{
						dp.erase(it);
						it=dp.up(a[i]);
					}
					dp.in(a[i]);
				}
			}
	}
	cout<<kq[*(--dp.end())];
	return 0;
}


Measured memory_bytes: 12800
#include<cstdio>
int main()
{
	int n, k, x, y;
	scanf("%d", &n);
	scanf("%d", &k);
	scanf("%d", &x);
	scanf("%d", &y);
	int pay;
	if (n <= k)
	{
		pay = x * n;
	}
	else
	{
		pay = x * k + y * (n - k);
	}
	printf("%d", pay);
	return 0;
}



Measured memory_bytes: 128
function Main(input) {
    let rows = input.split("\n");
    let row  = rows[0].split(" ");
    let a = parseInt(row[0], 10);
    let b = parseInt(row[1], 10);
    let c = parseInt(row[2], 10);
    let k = parseInt(row[3], 10);
    if (a >= k) {
      console.log(k)
    } else {
      k -= a+b;
      console.log(a-k)
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29808
while True:
    ab = input().split(' ')
    a = int(ab[0])
    b = int(ab[2])
    op = ab[1]
    if op == '?':
        break
    elif op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a //b)
    


Measured memory_bytes: 5592
#include<bits/stdc++.h>
#define MSET(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
#define ll long long
#define ld long double
#define INF 1e18
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vll vector<ll>
#define sorrt(a) sort(a.begin(), a.end())
using namespace std;
ll MOD = 1000000007;
string yes = "YES\n";
string no = "NO\n";
#define PI 3.1415926535 


int32_t main() {
  fastio;
  ll n,cnt=0;
  cin>>n;
  vector<ll> a(n);
  for(ll i=0;i<n;i++) {
    cin>>a[i];
    if(i%2 == 0 and a[i]%2==1) cnt++;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;

int main(){
    fast_io();
    int N; cin >> N;
    vector<int> members(N + 1, 0);
    int mem;
    rep(i,N - 1){
        cin >> mem;
        members[mem]++;
    }
    rep1(i,N){
        cout << members[i] << '\n';
    }
    return 0;
}


Measured memory_bytes: 3988
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORE(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
const int INF=1<<30;
int dx[5]={0,1,0,-1,0}, dy[5]={1,0,-1,0,0};
using namespace std;
typedef pair<int,int> pr;
typedef pair<int,pr> ppr;
typedef vector<int> vi;
bool mass[22][22];
int DP[20][22][22];
int main() {
	int H,W,N;
	char tmp;
	int sx,sy,gx,gy;
	cin >> H >> W;
	REP(i,20)
		REP(j,22)
			REP(k,22)
				DP[i][j][k]=INF;
	FORE(i,0,H+1)
		FORE(j,0,W+1)
			if(j&&i&&i<=H&&j<=W){
				cin >> tmp;
				if(tmp=='S'){
					sx=j;
					sy=i;
				}
				else if(tmp =='G'){
					gx=j;
					gy=i;
				}
				if(tmp=='#')
				mass[i][j]=false;
				else
				mass[i][j]=true;
			}
	cin >>N;
	DP[0][sy][sx]=0;
	int times;
		queue<ppr > qu;
		qu.push(ppr(0,pr(sx,sy) ));
		REP(i,N+1){
		if(i!=N)
		cin >>times;
		else
		times=INF;
		while(!qu.empty()){
			int nx=qu.front().second.first,ny=qu.front().second.second;
			int nowtime=qu.front().first;
			qu.pop();
			if(nowtime+1==times)
			continue;
			REP(k,4)
			if(mass[ny+dy[k]][nx+dx[k]] && DP[i][ny+dy[k]][nx+dx[k]]>DP[i][ny][nx]+1){
				DP[i][ny+dy[k]][nx+dx[k]]=DP[i][ny][nx]+1;
				
				qu.push(ppr(nowtime+1,pr(nx+dx[k],ny+dy[k])));
			}
		}
		if(i==N)
		break;
		FORE(k,1,H)
			FORE(j,1,W){
				cin >> tmp;
				if(tmp=='#')
				mass[k][j]=false;
				else
				mass[k][j]=true;
				if(mass[k][j]){
				DP[i+1][k][j]=DP[i][k][j];
				REP(l,4)
				DP[i+1][k][j]=min(DP[i+1][k][j],DP[i][k+dy[l]][j+dx[l]]+1);
				if(DP[i+1][k][j]!=INF)
				qu.push(ppr(times,pr(j,k)));
				}
			}
	}
	int minium=INF;
	REP(i,N+1){
	minium=min(minium,DP[i][gy][gx]);
	}
	if(minium==INF)
	cout <<"-1" << endl;
	else
	cout << minium << endl;
	// your code goes here
	return 0;
}


Measured memory_bytes: 1256
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;

int main(){
  ll n,ans=0;
  std::cin >> n;
  if(n%2==1){
    std::cout << 0 << std::endl;
    exit(0);
  }
  rrep(i,1,30){
    ans+=n/2/ll(powl(5ll,i));
  }
  std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(b,a*n)<<endl;
}


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

int main() {
  string X, Y;
  cin >> X >> Y;
  if (X > Y) {
    cout << ">" << endl;
  } else if (X < Y) {
    cout << "<" << endl;
  } else {
    cout << "=" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
n,t=map(int,input().split())
a=list(map(int,input().split()))

mi=[a[0]]
ma=[a[n-1]]
for i in range(1,n):
    if a[i]<mi[-1]:
        mi.append(a[i])
    else:
        mi.append(mi[-1])

for i in range(n-2,-1,-1):
    if a[i]>ma[-1]:
        ma.append(a[i])
    else:
        ma.append(ma[-1])

ma.reverse()

sa=0
for i in range(n):
    x=ma[i]-mi[i]
    sa=max(sa,x)
se=set()
for i in range(n):
    if ma[i]-mi[i]==sa:
        se.add(mi[i])

print(len(se))


Measured memory_bytes: 14480
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	char s[1000];
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int a[2222][2222], ans[2222];

int main(void)
{
	int n, x, y, i, j;

	scanf("%d %d %d", &n, &x, &y);

	for (i = 1; i <= n; i++)
		for (j = 1; j <= n; j++)
			if (i < j)
				a[i][j] = j - i;

	for (i = 1; i <= n; i++)
		for (j = 1; j <= n; j++)
			if (i < j)
			{
				if (i <= x && y <= j)
					a[i][j] = x - i + j - y + 1;
				else if (i <= x)
					a[i][j] = min(j - i, x - i + 1 + y - j);
				else if (y <= j)
					a[i][j] = min(j - i, i - x + 1 + j - y);
				else if (x <= i && j <= y)
					a[i][j] = min(j - i, i - x + 1 + y - j);
			}

	for (i = 1; i <= n; i++)
		for (j = 1; j <= n; j++)
			if (i < j)
				ans[a[i][j]]++;

	for (i = 1; i < n; i++)
		printf("%d\n", ans[i]);
	return 0;
}

Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数

int main(){
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll ans = INF;
    for (long long i = 0; i <= 1000000;i++)
    {
        ans = min(ans,i * 2 * c + max(0LL, x - i) * a + max(0LL, y - i) * b);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.sort()
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            if A[i] + A[j] > A[k] and A[i] != A[j] and A[j] != A[k] and A[k] != A[i]:
                ans += 1
print(ans)


Measured memory_bytes: 9104
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;
typedef tree<
    pair<int, int>,
    null_type,
    less_equal<pair<int, int>>,
    rb_tree_tag,
    tree_order_statistics_node_update>
    ordered_set;
#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define lb(v, z) lower_bound(all(v), z)
#define ub(v, z) upper_bound(all(v), z)
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define rdp(i, a, b) for (int i = (a); i >= (b); i--)
#define rlt(i, a, b) for (int i = (a); i < (b); i++)
#define cns(z) cout << (z) << ' '
#define cnl(z) cout << (z) << '\n'
#define M1 1000000007
#define M2 998244353
#define MAXN 300005
#define INF (1ll << 60)
#define endl "\n"
#define garr(ip)       \
    for (auto &x : ip) \
        cin >> x;
#define parr(ip)          \
    for (auto &x : ip)    \
        cout << x << " "; \
    cout << endl;
#define nl cout << endl
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vp;

void solve(int testCaseNumber = 1)
{
    int n, m;
    cin >> n >> m;
    vi h(n + 1), maxConnected(n + 1);
    rep(i, 1, n) cin >> h[i];
    rep(i, 1, m)
    {
        int a, b;
        cin >> a >> b;
        maxConnected[a] = max(maxConnected[a], h[b]);
        maxConnected[b] = max(maxConnected[b], h[a]);
    }
    int ans = 0;
    rep(a, 1, n) ans += h[a] > maxConnected[a];
    cnl(ans);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
}

Measured memory_bytes: 4768
/*
 * 	The way if it's all predetermined
 * 		And the way i should go all my life
 * 			I swear to go wherever will be
 * 				'Cause there'll be something to see and to find
 */
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifdef rd
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
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...);
}
#else
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=4e18;
const int infi=1e9;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int powm(ll a, ll b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

void solve() {
	int n,k;
	cin>>n>>k;
	if(k>((n-1)*(n-2))/2) {
		cout<<-1<<endl;
		return;
	}
	vector<pii> edges;
	for(int i=2; i<=n; i++) {
		edges.pb({1,i});
	}
	k=((n-1)*(n-2))/2-k;
	fr(i,2,n) {
		for(int j=i+1; j<=n&&k>0; j++) {
			edges.pb({i,j});
			k--;
		}
	}
	cout<<sz(edges)<<endl;
	for(auto i:edges)
		cout<<i.fi<<" "<<i.se<<endl;
}

signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	fr(i,1,t)
		solve();
#ifdef rd
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


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

using namespace std;

#define fo(i,n) for(int i=0; i<n; i++)
#define Fo(i,k,n) for(int i=k; i<n; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it=a.begin(); it!=a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

int N;
vector<long double> pi;
vector<vector<long double>> dp;

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

    cin>>N;
    pi.resize(N+1);
    dp.resize(N+1, vector<long double>(N+1));
    Fo(i,1,N+1){
        cin>>pi[i];
    }
    dp[1][0] = (1.0-pi[1]);
    dp[1][1] = pi[1];
    Fo(i,2,N+1){
        Fo(j,0,i){
            dp[i][j] += dp[i-1][j]*(1.0-pi[i]);
            if(j!=0)dp[i][j] += dp[i-1][j-1]*(pi[i]);
        }
        dp[i][i] += dp[i-1][i-1]*pi[i];
    }
    long double ans = 0.0;
    Fo(i,N/2+1, N+1){
        ans += dp[N][i];
    }
    // fo(i,N+1){
    //     fo(j,N+1){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    cout<<fixed<<setprecision(10)<<ans<<endl;
    
    return 0;
}

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

int main(){
  int n; cin >> n;
  string s; cin >> s;
  bool ans = true;
  
  for(int i = 0; i < n/2; i++){
  	if(s[i] != s[i+(n+1)/2]) ans = false;
  }
  if(n%2==1) ans = false;
  
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}


int main() {
	int h, w;
	cin >> h >> w;
	vector<string> field(h);
	vector<bool> checkw(w, false);
	vector<bool> checkh(h, false);
	for (int i = 0; i < h; i++) {
		cin >> field[i];
	}
	for (int i = 0; i < w; i++) {
		for (int j = 0; j < h; j++) {
			if (field[j][i] == '#') {
				checkw[i] = true;
			}
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (field[i][j] == '#') {
				checkh[i] = true;
			}
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (checkh[i] && checkw[j]) {
				cout << field[i][j];
			}
		}
		if (checkh[i])cout << endl;
	}
}


Measured memory_bytes: 256
#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;


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

    string s;
    cin >> s;
    ll k;
    cin >> k;

    ll n = s.size();
    
    set<char> keys;
    for(auto c : s) keys.insert(c);
    
    set<string> st;
    for(auto first = keys.begin(); first != keys.end(); first++){
        rep(l, n){
            if(s[l] != *first) continue;
            for(ll r = l+1; r <= n; r++){
                string x = s.substr(l, r-l);
                st.insert(x);
                if(k <= r-l && k <= (ll)st.size()) break;
            }
            //if(k <= (ll)st.size()) break;
        }
        if(k <= (ll)st.size()) break;
    }    

    auto iter = st.begin();
    rep(i, k-1) iter++;
    string ans = *iter;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int sum=0;
  int maxi =0;
  for(int i=0;i<3;i++){
    int in;
    cin>>in;
    sum+= in;
    chmax(maxi,in);
  }
    cout << sum-maxi << endl;
    return 0;
}


Measured memory_bytes: 256
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

N = I()
T = []
for i in range(N):
    T.append(S())

print(len(Counter(T)))

Measured memory_bytes: 56524
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n=scan.nextInt();
		int i=1;
		
		do{
			int x=i;
			if(x%3==0){
				System.out.print(" "+i);
			}
			else{
				do{
					if(x%10==3){
						System.out.print(" "+i);
						break;
					}
				}while((x/=10)!=0);
			}
		}while(++i<=n);
		System.out.println();
	}
}

Measured memory_bytes: 28652
type ABC(stream:System.IO.TextReader) =
  member this.Scan1 f = stream.ReadLine() |> f
  member this.Scan2 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1]))
  member this.Scan3 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2]))
  member this.Scan4 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2], a.[3]))
  member this.ScanVecH f = stream.ReadLine().Split() |> Array.map f
  member this.ScanVecV n f = [| for i in 1..n -> stream.ReadLine() |> f |]
  member this.ScanMatrix n f  = [ for i in 1..n do yield stream.ReadLine().Split() |> Array.map f ]
  member this.ScanCharMatrix n = [| for i in 1..n -> stream.ReadLine().ToCharArray() |]
  member this.Close () = stream.Close()

let util = ABC(stdin)
  
util.Scan1 int |> ignore
let hs = util.ScanVecH int

// ttfftf -> 2
let rec rcount flg cnt xs =
  match xs with
  | [] -> cnt
  | x::xs ->
      match x with
      | true -> rcount true (cnt+(if flg then 0 else 1)) xs
      | false-> rcount false cnt xs

[
  for h in 1..100 ->
    hs
    |> Array.map (fun x -> x >= h)
    |> Array.toList
    |> rcount false 0
]
|> List.sum
|> printfn "%d"



Measured memory_bytes: 14288
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=1e9+7;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-4;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>int LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>int UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	int n,Q,i;cin>>n>>Q;
	vector<int> a(n);
	for(i=0;i<n;i++){cin>>a[i];}
	SO(a);
	while(Q--){
		int l,r;cin>>l>>r;
		cout<<UBI(a,r)-LBI(a,l)<<endl;
	}
	return 0;
}



Measured memory_bytes: 3148
#include "bits/stdc++.h"
using namespace std;

int main(void) {
	int a, b;
	//int ans;

	cin >> a >> b;
	
	if (b%a == 0) {
		cout << a + b;

	}
	else {
		cout << b - a;

	}

	//cout << ans;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  int x;
  cin >> x;
  if(x) cout << 0 << endl;
  else cout << 1 << endl;
  return 0;
}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m;
    cin>>n;
    std::deque<string> id;
    string s,card;
    for (int i=0;i<n;i++) {
        cin>>s;
        id.emplace_back(s);
    }
    cin>>m;
    int flag=0;
    for (int j=0;j<m;j++) {
        cin>>card;
        if (find(id.begin(),id.end(),card)!=id.end()) {
            if (flag==0) {
                flag=1;
                cout<<"Opened by "<<card<<endl;
            } else {
                flag=0;
                cout<<"Closed by "<<card<<endl;
            }
        } else {
            cout<<"Unknown "<<card<<endl;
        }
    }
}



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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
#define MAX 999999999

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

typedef long long ll;

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

    int n, k;
    cin >> n >> k;

    vector<int> nums(n);
    rep(i, n) cin >> nums[i];
    sort(all(nums));

    int sum = 0;
    rep(i, n){
        if(i >= n - k) sum += nums[i];
    }

    cout << sum << endl;
}

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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max() / 2;
const ll mod = 1e9+7;

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}
template<typename T> bool chmin(T& a, const T& b) {
  if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
  if (a < b) return a = b, true; else return false;
}


void solve(){
  int S, W;
  cin >> S >> W;
  cout << ((W >= S) ? "unsafe" : "safe") << endl;
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>

using namespace std;

const int maxk = 1010;
int val[2][maxk][maxk];
int sum[2][maxk][maxk];

int n, k;

int arr(int t, int x, int y) {
    if (x >= 0 && y >= 0) return sum[t][x][y];
    return 0;
}

int getchanged(int t, int x, int y) {
    return (arr(t, x-1, k-1)-arr(t, x-1, y-1))+(arr(t, k-1, y-1)-arr(t, x-1, y-1));
}

int getnotchanged(int t, int x, int y) {
    return (arr(t, x-1, y-1))+arr(t, k-1, k-1)+arr(t, x-1, y-1)-arr(t, x-1, k-1)-arr(t, k-1, y-1);
}

int main() {
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; i++) {
        int x, y; char c[4];
        scanf("%d%d%s", &x, &y, c);
        int t1 = x%k, t2 = y%k;
        int bc = (x/k+y/k)&1;
        val[0][t1][t2] += ((c[0] == 'B')==bc);
        val[1][t1][t2] += ((c[0] != 'B')==bc);
    }
    for (int t = 0; t < 2; t++) {
        for (int i = 0; i < k; i++) {
            for (int j = 0; j < k; j++) {
                sum[t][i][j] = arr(t, i-1, j)+arr(t, i, j-1)-arr(t, i-1, j-1)+val[t][i][j];
            }
        }
    }
    int ans = 0;
    for (int cx = 0; cx < k; cx++) {
        for (int cy = 0; cy < k; cy++) {
            int tans = getnotchanged(0, cx, cy)+getchanged(1, cx, cy);
            ans = max(ans, max(tans, n-tans));
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

#define N 100016
#define INF 345678

int dist[3*N], q[3*N];
vi adj[3*N];

int main()
{
    canhazfast();

    int n, m, s, t, ans, k = 0;

    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        adj[u].pb(v+n);
        adj[u+n].pb(v+2*n);
        adj[u+2*n].pb(v);
    }
    fill_n(dist+1, 3*n, INF);
    cin >> s >> t;
    dist[s] = 0;
    q[k++] = s;
    for (int i = 0; i < k; ++i) {
        int u = q[i];
        int dv = dist[u]+1;
        for (int v : adj[u]) {
            if (dist[v] > dv) {
                dist[v] = dv;
                q[k++] = v;
            }
        }
    }
    ans = dist[t];
    cout << (ans < INF ? ans/3 : -1) << '\n';

    return 0;
}


Measured memory_bytes: 19072
#include <stdio.h>
#include <math.h>

double radOf(double deg) {
	return deg * M_PI/180.0;
}

int main(void) {
	int a,b,C;
	double h,S,r;
	scanf("%d %d %d",&a,&b,&C);
	h = b*sin(radOf(C));
	r = sqrt(pow(a - b*cos(radOf(C)),2)+pow(h,2));
	S = a*h/2;
	printf("%.6lf\n",S);
	printf("%.6lf\n",a+b+r);
	printf("%.6lf\n",h);
	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	cout << ((c-a)?"1":"0") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h[i];

    sort(all(h));
    int ans = inf;
    for(int i = 0; i <= n - k; i++) {
        ans = min(ans, h[i+k-1] - h[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3704
#include<bits/stdc++.h> 
typedef long long int ll;
#define pb push_back
#define MP make_pair

using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int x;
    cin>>x;
    
    if(x>=30)
    cout<<"Yes";
    else
    cout<<"No";
     return 0;
}


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

int main(){
  long N;
  long C0 = 0, C1 = 0, C2 = 0, C3 = 0;
  cin >> N;
  string S[N];
  for(long i = 0; i < N; i++){
    cin >> S[i];
    if(S[i] == "AC") C0++;
    else if(S[i] == "WA") C1++;
    else if(S[i] == "TLE") C2++;
    else if(S[i] == "RE") C3++;
    else continue;
  }
  cout << "AC x "<< C0 << "\n";
  cout << "WA x "<< C1 << "\n";
  cout << "TLE x "<< C2 << "\n";
  cout << "RE x "<< C3 << "\n";
}


Measured memory_bytes: 6732
#include <string>
#include <list>
#include <iostream>
using namespace std;
int main()
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  string str;
  list<int> data;
  list<int>::iterator it, l;
  int n, x;
  cin >> n;
  while (n--)
  {
    cin >> str;
    if (str == "insert")
    {
      cin >> x;
      data.push_front(x);
    }
    else if (str == "delete")
    {
      cin >> x;
      for (it = data.begin(), l = data.end(); it != l; ++it)
      {
        if (*it == x)
        {
          data.erase(it);
          break;
        }
      }
    }
    else if (str == "deleteFirst")
      data.pop_front();
    else
      data.pop_back();
  }
  for (it = data.begin(), l = --data.end(); it != l; ++it)
    cout << *it << " ";
  cout << *it << endl;
}



Measured memory_bytes: 34264
#include<stdio.h>
#include<string>
#include<string.h>
#include<algorithm>
using namespace std;
char w[15][30];
int len[15];
char str[5100];
char in[210];
int m[5100][13];
char dp[5100][1<<12];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<a;i++)scanf("%s",w[i]);
		string s="";
		for(int i=0;i<b;i++){
			scanf("%s",in);
			string tmp=in;
			s+=tmp;
		}
		for(int i=0;i<a;i++)len[i]=strlen(w[i]);
		
		int n=s.size();
		for(int i=0;i<n;i++)str[i]=s[i];
		str[n]=0;
		for(int i=0;i<n;i++)for(int j=0;j<a;j++)m[i][j]=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<a;j++){
				if(i+len[j]>n)continue;
				bool ok=true;
				for(int k=0;w[j][k];k++)if(w[j][k]!=str[i+k])ok=false;
				if(ok)m[i][j]=1;
			}
		}
		for(int i=0;i<=n;i++)for(int j=0;j<(1<<a);j++)dp[i][j]=0;
		
		for(int i=0;i<n;i++){
			dp[i][0]=1;
			for(int j=0;j<(1<<a);j++){
				if(!dp[i][j])continue;
				for(int k=0;k<a;k++){
					if(j&(1<<k))continue;
					if(m[i][k])dp[i+len[k]][j+(1<<k)]=1;
				}
			}
		}
		int ret=0;
		for(int i=0;i<=n;i++)if(dp[i][(1<<a)-1])ret++;
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 21748
#include <iostream>

inline bool is_right_triangle(const u_int a, const u_int b, const u_int c) {
    return (a*a == b*b + c*c || b*b == c*c + a*a || c*c == a*a + b*b);
}

int main(void) {
    u_int n, a, b, c;

    std::cin >> n;
    for (u_int i = 0; i < n; ++i) {
        std::cin >> a >> b >> c;
        std::cout << (is_right_triangle(a, b, c) ? "YES\n" : "NO\n");
    }

    return 0;
}

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

using namespace std;

#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(STL) STL.begin(), STL.end()
#define stl_rep(itr, STL) for (auto itr = STL.begin(); itr != STL.end(); ++itr)

const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};


int main (int argc, char *argv[]) {
    cin.tie(0); 
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    vector<llong> X(n), Y(n), Z(n);
    rep(i, n) {
        cin >> X[i] >> Y[i] >> Z[i];
    }

    bitset<3> mask(7);
    vector<priority_queue<llong> > V(8);
    for (int bit = 0; bit < (1 << 3); ++bit) {
        mask &= bit;
        rep(l, n) {
            V[bit].push(pow(-1, (int)mask[0]) * X[l] + pow(-1, (int)mask[1]) * Y[l] + pow(-1, (int)mask[2]) * Z[l]);
        }
        mask.set();
    }

    priority_queue<llong> A;
    llong tmp = 0;
    rep(i, 8) {
        rep(j, m) {
            tmp += V[i].top();
            V[i].pop();
        }
        A.push(tmp);
        tmp = 0;
    }

    cout << A.top() << endl;

    return 0;
}

Measured memory_bytes: 384
import bisect
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
from operator import mul

import numpy as np
import re
import sys

sys.setrecursionlimit(10000)
INF = float('inf')

N = int(input())
A = list(map(int, input().split()))
A.sort()

# nCr を求める
# r が同じなら、n は大きいほうが nCr は大きい
n = A[-1]
# n が同じなら、r は n / 2 に近いほど大きい
r = bisect.bisect_left(A, n / 2)

if abs(A[r - 1] - n / 2) < abs(A[r] - n / 2):
    r -= 1
while A[r] == n:
    r -= 1
print(n, A[r])


Measured memory_bytes: 24344
import sys
def sieve(m):
    N=range(1,m+2,2)
    r=int(m**.5)
    h=len(N)
    N[0]=0
    for i in range(h):
        x=N[i]
        if x>r: break
        if x and i+x<h: N[i+x:h:x]=[0]*((h-1-i-x)/x+1)
    return N
def f0056(n):
    x=0
    if n<4:x=0
    elif n==4:x=1
    elif n%2==1:
        if S[(n-2)/2]:
            x=1
    else:
        a=n/2
        for e in PRIMES:
            if e>a: break
            if S[(n-e)/2]:
                x+=1
    return x

S=sieve(50000)
PRIMES=filter(None,S)
for n in sys.stdin:
    n=int(n)
    if n==0: break
    print f0056(n)

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ull,ull> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define mod 1000000097LL

int n[2],m;
vector<int> g[2][301010];
int cnt[300010];
vector<int> vs;
vector<ull> r;

void predfs(int v,int pre,bool f){
  vs.push_back(v);
  cnt[v]=1;
  for(int nv : g[f][v]){
    if(nv==pre)continue;
    predfs(nv,v,f);
    cnt[v]+=cnt[nv];
  }
}

ull dfs(int v,int pre,bool f,int d){
  ull res=1;
  for(int nv : g[f][v]){
    if(nv==pre)continue;
    res*=((r[d]+dfs(nv,v,f,d+1))%mod);
    res%=mod;
  }
  return res;
}

P mhash(int v,bool f){
  vs.clear();
  predfs(v,-1,f);
  vector<int> cs;
  int n=vs.size();
  for(int vv : vs){
    bool ok=true;
    for(int ch : g[f][vv]){
      if(cnt[ch]>cnt[vv])continue;
      if(cnt[ch]>n/2)ok=false;
    }
    if(n-cnt[vv]>n/2)ok=false;
    if(ok){
      cs.push_back(vv);
    }
  }
  if(cs.size()==1){
    ull h=dfs(cs[0],-1,f,0);
    return P(h,h);
  }else{
    ull h1=dfs(cs[0],-1,f,0);
    ull h2=dfs(cs[1],-1,f,0);
    return P(min(h1,h2),max(h1,h2));
  }
}

int main(){

  mt19937_64 mt(time(0));
  rep(i,300000)r.push_back(mt()%mod);

  cin>>n[0]>>m;
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    g[0][a].push_back(b);
    g[0][b].push_back(a);
  }
  cin>>n[1];
  rep(i,n[1]-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    g[1][a].push_back(b);
    g[1][b].push_back(a);
  }

  P ha=mhash(0,1);

  memset(cnt,0,sizeof(cnt));

  int res=0;
  rep(i,n[0]){
    if(cnt[i]>0)continue;
    P hoge=mhash(i,0);
    if(ha==hoge)res++;
  }

  cout<<res<<endl;

  return 0;
}



Measured memory_bytes: 45612
#include<stdio.h>

int main()
{
	int num[10][10];
	int x,y;
	char tmp[12];

	while(fgets(tmp,12,stdin)!=NULL)
	{
		for(x=0;x<10;x++)
		{
			num[x][0]=(int)(*(tmp+x)-'0');
		}
		for(y=1;y<10;y++)
		{
			for(x=0;x<10-y;x++)
			{
				num[x][y]=(num[x][y-1]+num[x+1][y-1])%10;
			}
		}
		printf("%d\n",num[0][9]);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;

signed main(){
	ios_base::sync_with_stdio(0);
	int d;
	cin>>d;
	if(d==25) cout<<"Christmas";
	if(d==24) cout<<"Christmas Eve";
	if(d==23) cout<<"Christmas Eve Eve";
	if(d==22) cout<<"Christmas Eve Eve Eve";
	re 0;
}

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

#define ll long long
#define LL long long
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define sch(n) scanf(" %c", &n)
#define ss(n) scanf("%s", n)
#define pii pair <int, int>
#define pll pair <ll, ll>
#define plp pair <int, pll >
#define pb push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()
#define Unique(a)  sort(all(a)),a.erase(unique(all(a)),a.end())

#define inf (1LL<<50)
#define eps 1e-9

ll Set(ll n, ll pos)
{
    return n|(1LL<<pos);
}

bool Check(ll n, ll pos)
{
    return (bool) (n&(1LL<<pos));
}


int main ()
{
    //  freopen("inl.txt", "r", stdin);
    // freopen("outu.txt", "w", stdout);
    //  ios_base::sync_with_stdio(0); // no printf/scanf must be present
    ll cs, ts, i, j, k, x, y, z, q, m, n, w;

    while(sl(w) != EOF)
    {
        sl(x);
        sl(y);

        if (x > y)
            swap(x, y);

        if (x <= y && y <= x + w)
        {
            printf("0\n");
            continue;
        }

        printf("%lld\n", y-x-w);
    }

    return 0;
}


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

int main() {
  vector<int> T(5);
  cin >> T[0] >> T[1] >> T[2] >> T[3] >> T[4];
  int cutt = 0;
  int ans = 0;
  for (int i=0; i<5; i++) {
    if (T[i] %10 == 0) {
      ans += T[i];
      continue;
    }
    cutt = max(cutt,10-T[i]%10);
    T[i] -= T[i] %10;
    T[i] += 10;
    ans += T[i];
  }
  cout << ans - cutt << endl;
}

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

void f(int n)
{
    int ans = 0;
    for (int number = 1; number <= sqrt(n); number++)
    {
        int low = number;
        int high = sqrt(n);

        while (low <= high)
        {
            if ((number * number) + (low * low) + (high * high) + (number * low) + (number * high) + (low * high) == n)
            {
                if(number==low && number==high){
                    ans++;
                } else if(number==low || number == high || low == high){
                    ans+=3; 
                } else{
                    ans+=6; 
                }
                low++;
                high--;
            }
            else if ((number * number) + (low * low) + (high * high) + (number * low) + (number * high) + (low * high) < n)
            {
                low++;
            }
            else
            {
                high--;
            }
        }
    }
    cout << ans << endl;
}

int main()
{
    int n;
    cin >> n;
    for (int number = 1; number <= n; number++)
    {
        f(number);
    }
    return 0;
}

Measured memory_bytes: 3612