akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using ll = unsigned long long;
using namespace std;

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

    vector<int> x(N), y(M);

    for(int ix  =  0 ; ix < N; ++ix) {
        cin >> x[ix];
    }

    for(int iy  =  0 ; iy < M; ++iy) {
        cin >> y[iy];
    }
    x.push_back(X);
    y.push_back(Y);

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    bool war = false;

    // for (int z = x[x.size()-1]+1; z <= y[0]; ++z) {
        // 
    // }
    if  (x[x.size()-1]+1 <= y[0]) {
        war = true;
    }

    cout << (war ? "No War" : "War") << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
	K = int(input())
	AB = list(map(int,input().split()))
	A = 0
	for i in range(AB[0],(AB[1]+1)):
		if(i%K==0):
			A += 1
	if(A>0):
		return(print("OK"))
	
	return(print("NG"))
      
      

    
main()

Measured memory_bytes: 9124
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#include<bits/stdc++.h>
using ll = int;
using pii = std::pair<int,int>;
using namespace std;
template<class T>T chmin(T a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T b,T a){if(a<b){a^=b;b^=a;a^=b;return 1;}return 0;}

int a,b,c;
void input(){
    cin>>a>>b>>c;
}
void src(){
    cout<<(c>(a-b)? c-(a-b):0);
    return;
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
    //ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define MN 3000
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
bool ans[MN+5]; 
int n,head[MN+5],cnt=0,f[MN+5],a[MN+5];
struct edge{int to,next;}e[MN*2+5];
inline void ins(int f,int t)
{
	e[++cnt]=(edge){t,head[f]};head[f]=cnt;
	e[++cnt]=(edge){f,head[t]};head[t]=cnt;	
}
void dfs(int x,int fa)
{
	f[x]=0;
	for(int i=head[x];i;i=e[i].next)
		if(e[i].to!=fa)
			dfs(e[i].to,x),f[x]+=(a[e[i].to]<a[x]&&!f[e[i].to]);
}
void Solve(int x,int fa)
{
	if(f[x]) ans[x]=1;
	for(int i=head[x];i;i=e[i].next)
		if(e[i].to!=fa)
		{
			int Gf=f[x]-(a[e[i].to]<a[x]&&!f[e[i].to]);
			if(a[e[i].to]>a[x]) f[e[i].to]+=!Gf;
			Solve(e[i].to,x);	
		}
} 
int main()
{
	n=read();
	for(int i=1;i<=n;++i) a[i]=read();
	for(int i=1;i<n;++i) ins(read(),read());
	dfs(1,0);Solve(1,0);
	for(int i=1;i<=n;++i) if(ans[i]) printf("%d ",i);
	return 0;
}



Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
using namespace std;

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  int r;
  cin >> r;
    cout << r * r << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
  fio();
  int n;
  cin >> n;
  vector<string> s(n);
  vi t(n);
  rep (i, n) {
    cin >> s[i] >> t[i];
  }

  string x;
  cin >> x;
  bool start = false;
  ll ans = 0;
  rep (i, n) {
    if (start) ans += t[i];
    if (s[i] == x) start = true;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

signed main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  vint wcount(n);
  vint ecount(n);
  int wwcount = 0;
  int eecount = 0;
  rep(i,n){
    if(s[i] == 'W') wwcount++;
    wcount[i] = wwcount;
  }
  for(int i = n-1;i >= 0;i--){
    if(s[i] == 'E') eecount++;
    ecount[i] = eecount;
  }
  int ans = INF;
  rep(i,n-2){
    ans = min(ans,wcount[i] + ecount[i+2]);
  }
  ans = min(ans,wcount[n-1]);
  ans = min(ans,ecount[1]);
  cout << ans << endl;
}

Measured memory_bytes: 5380
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define pb(x)           push_back(x)
#define mkp(x,y)        make_pair(x,y)
#define L               length()
#define int             long long
#define bs              binary_search
#define mod             1e9+7
#define IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define mem0(a)         memset(a,0,sizeof(a))
#define mem1(a)         memset(a,-1,sizeof(a))
#define F               first
#define S               second
#define pii             pair<int,int>
#define vi              vector<int>
#define vs              size()
#define endl            '\n'
#define atoi            stoi
#define elasped_time    1.0 * clock() / CLOCKS_PER_SEC
#define si              set <int>
#define vpii            vector < pair <int,int> >
#define memf(a)         memset(a,false,sizeof(a))
#define memt(a)         memset(a,true,sizeof(a))
#define xxx             998244353
#define pi              3.141592653589
#define ninf            INT_MIN
#define inf             INT_MAX
#define sz(v)           ((int)(v).size())
#define rep(i,a,b)      for(int i=a;i<=b;i++)
int max(int a,int b){if(a>b){return a;}else{return b;}}
int min(int a,int b){if(a<b){return a;}else{return b;}}
int power(int b,int e)
{
    if(e==0)
    return 1;
    if(e%2)
    return ((b*power((b)*(b),(e-1)/2)));
    else
    return power((b)*(b),e/2);
}
int modpower(int b,int e,int q)
{
    int MOD=q;
    if(e==0)
    return 1;
    if(e%2)
    return ((b%MOD)*modpower((b%MOD)*(b%MOD),(e-1)/2,q))%MOD;
    else
    return modpower((b%MOD)*(b%MOD),e/2,q)%MOD;
}
void dpv(vi v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void dpv(vpii v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i].F<<" "<<v[i].S<<endl;
    }
}
void dpv(set <int> v)
{
    for(auto i:v)
    {
        cout<<i<<" ";
    }
    cout<<endl;
}
//////////////////////**TREE MOVES STARTS**//////////////////////////////
///// **TREE MOVES ENDS**////////////////////////////

////*SOLUTION TO THE QUESTION STARTS HERE*///////
vector < vi > adj(100005);
bool vis[100005];
void dfs(int x)
{
    vis[x]=true;
    for(auto i:adj[x])
    {
        if(!vis[i])
        {
            dfs(i);
        }
    }
}
void oblivious()
{
    memf(vis);
    int n;
    cin>>n;
    int k;
    cin>>k;
    for(int i=0;i<k;i++)
    {
        int a,b;
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            dfs(i);
            cnt++;
        }
    }
    cout<<cnt-1<<endl;
}
signed main()
{
    IOS;//Try this case
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    int t=1;
    //cin>>t;
    //int z=t;
    while(t--)
    {
        //cout<<"Case #"<<(z-t)<<": ";
        oblivious();
    }
    return 0;
}
//Editorial
/*

    */

Measured memory_bytes: 10060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, M := sc.nextInt(), sc.nextInt()

	fmt.Fprintln(wtr, (N-1)*(M-1))
	wtr.Flush()
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>

int main() {
	int n, k;
	std::cin >> n >> k;

	std::vector<int> v;
	v.resize(n);
	auto tab = v;
	
	
	for (auto&e : v) 
		std::cin >> e;

	//一回で端まで飛べるならそれが最適
	if (n - 1 <= k) {
		std::cout << std::abs(v[n - 1] - v[0]) << "\n";
		goto endproc;
	}	


	//k番目の足場までは一回で飛ぶのが最適
	for (int i{1}; i <= k; ++i)
		tab[i] = std::abs(v[i]-v[0]);


	/*
	for (const auto&e : tab) 
		std::cout << " " << e;
	std::cout << "\n";
	*/

	//k+1番目からdp
	for (int i{ k+1 }; i < n; ++i) {
		auto min_cost = 1'000'000'000;//>10^4
		for (int ki{1}; ki <= k; ++ki) {
			/*
			std::cout
				<< "(" << i << ", " << i-ki << ") "
				<< "|" << v[i] << " - " << v[i - ki] << "|"
				<< " + " << tab[i-ki] << "\n";
			*/
			auto cost
				= std::abs(v[i] - v[i - ki]) + tab[i - ki];

			min_cost = std::min(min_cost, cost);
		}
		//std::cout <<"min i = "<< min_cost << "\n";
		tab[i] = min_cost;
	}
	/*
	for (const auto&e : tab)
		std::cout << " " << e;
	std::cout << "\n";
	*/


	std::cout << tab[n - 1] << "\n";
	endproc:

	return 0;
}

Measured memory_bytes: 1024
#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)
using namespace std;
typedef long long ll;

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

    double n;
    cin >> n;
    double sum = 0;
    vector<double> a(n);
    rep(i, n){
        cin >> a[i];
        sum += a[i];
    }

    double ave = sum / n;
    double min_d = 101;
    int res = 0;
    rep(i, n){
        if(abs(ave - a[i]) < min_d){
            min_d = abs(ave - a[i]);
            res = i;
        }
    }

    cout << res << endl;

    return 0;
}

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

void Main() {
  int N, M;
  cin >> N >> M;
  int a[N];
  int total = 0;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    total += a[i];
  }

  int ninki = 0;
  for (int i = 0; i < N; i++) {
    if (a[i] >= total / (4.0 * M)) ninki++;
  }

  if (ninki >= M) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;

ll power(int x, int n)
{
	ll power = 1;
	for (int i = 0; i < n; i++) power *= x;
	return power;
}
int A[100010];
int main()
{
	int N, P;
	cin >> N >> P;
	ll even = 0, odd = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (A[i] % 2 == 0) even++;
		else odd++;
	}
	ll ans = 0;
	if (odd == 0) {
		if (P == 0) ans = power(2, N);
		else ans = 0;
	}
	else {
		ans = power(2, N - 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3504
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <cstring>
#include <climits>
#include <queue>
#include <map>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define EPS 1e-9

bool primes[1000001];
void make_prime(){
	primes[0]=primes[1]=true;
	for(int i=2; i*i<=1000001; i++)if( !primes[i] )
		for(int j=i*2; j<1000001; j+=i)primes[j]=true;
}
int main(){
	int a,d,n;
	make_prime();
	while(cin>>a>>d>>n,a|d|n){
		for(int i=a; ; i+=d){
			if( !primes[i] )n--;
			if( !n ){
				printf("%d\n",i);
				break;
			}
		}
	}
	return 0;
}

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

using namespace std;

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


int main() {
    int n; cin >> n;
    vector<int> a{1,2,3,4,5,6,7,8,9}; vector<int> b{1,2,3,4,5,6,7,8,9};
    bool ans = false;
    rep(i,9) rep(j, 9){
        if(n == a[i]*b[j]){
            ans = true;
        }
    }

    if(ans) cout << "Yes"; else cout << "No";
}

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

using namespace std;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define f first
#define s second

typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

const int MOD = 1e9+7;

int memo[2][1<<21];

int main(){ _

	int n; cin >> n;
	vector<vector<int>> g(n, vector<int>(n));
	for(auto& w : g) for(auto& i : w) cin >> i;

	memo[0][0] = memo[1][0] = 1;

	for(int i=0; i<n; i++) {
		for(int k=0; k<n; k++) if(g[i][k]) {
			for(int j=0; j<(1<<n); j++) if(j & (1<<k)) {
				memo[i&1][j] = (memo[i&1][j] + memo[(i&1)^1][j^(1<<k)]) % MOD;	
			}
		}	
	}

	cout << memo[(n-1)&1][(1<<n)-1] << endl;

	return 0;
}


Measured memory_bytes: 20024
#include<stdio.h>

int main(){

  int a,b,c,x;
  x=0;
  scanf("%d %d %d", &a,&b,&c);
  for(;a<=b;a++){
    if(c%a==0){
      x=x+1;
    } else{
    }
  }
 printf("%d\n",x);
 return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define ll long long int 
#define ull unsigned long long int
#define mem(a) memset(a,0,sizeof(a))
#define reg register 
#define fio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define For(i,a,b) for(int i=a;i<b;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
int main(){
	int k,x;
	cin>>k>>x;
	if(k*500>=x)
		cout<<"Yes\n";
	else
		cout<<"No\n";	
}

Measured memory_bytes: 384
#pragma GCC optimize("O2")

#include <bits/stdc++.h>
#ifdef DEBUG
	#include "debug.hpp"
#endif

using namespace std;

#define all(c) (c).begin(), (c).end()
#define traverse(c, it) for(auto it = (c).begin(); it != (c).end(); it++)
#define rep(i, N) for(int i = 0; i < (N); i++)
#define rep1(i, N) for(int i = 1; i <= (N); i++)
#define rep2(i, s, e) for(int i = (s); i <= (e); i++)
#define rep3(i, s, e, d) for(int i = (s); (d) >= 0 ? i <= (e) : i >= (e); i += (d))
#define pb push_back


#ifdef DEBUG
	#define debug(x...) {dbg::depth++; string dbg_vals = dbg::to_string(x); dbg::depth--; dbg::fprint(__func__, __LINE__, #x, dbg_vals);}
	#define light_debug(x) {dbg::light = 1; dbg::dout << __func__ << ":" << __LINE__ << "  " << #x << " = " << x << endl; dbg::light = 0;}
#else
	#define debug(x...)
	#define light_debug(x) 
#endif


using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;


signed main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	#ifdef DEBUG
		freopen("debug", "w", stderr);
	#endif

	int N;
	ll A1, A2, X = 0;
	cin >> N >> A1 >> A2;
	rep(i, N - 2){
		ll a;
		cin >> a;
		X ^= a;
	}

	if((A1 ^ A2) == X){
		cout << 0 << '\n';
		return 0;
	}

	ll D = A1 + A2 - X;
	debug(D, X);
	if(D & 1 || D < 0 || D >= 2 * A1){
		cout << -1 << '\n';
		return 0;
	}
	D >>= 1;

	if(D & X){
		cout << -1 << '\n';
		return 0;
	}

	ll Y = 0;
	for(int i = 50; i >= 0; i--){
		if(X & (1LL << i)){
			debug(i);
			Y += (1LL << i);
			debug(Y);
			if((Y ^ D) >= A1)
				Y -= (1LL << i);
		}
	}
	if((Y ^ D) == 0){
		cout << -1 << '\n';
		return 0;
	}

	cout << A1 - (Y ^ D) << '\n';

	#ifdef DEBUG
		dbg::dout << "\nExecution time: " << clock() << "ms\n";
	#endif

	return 0;
}


Measured memory_bytes: 3620
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();
		int r = sc.nextInt();
		int d = sc.nextInt();
		int count = 0;
		for (int i = l; i <= r ; i++) {
			if (i % d == 0) {
				count++;
			}

		}
		System.out.println(count);
	}

}


Measured memory_bytes: 35640
<?php
fscanf(STDIN, "%d", $N);

$inputList1=explode(' ',trim(fgets(STDIN)));
$inputList2=explode(' ',trim(fgets(STDIN)));




$can = true;
$count = 0;
$totalList = array();
 for ($i = 0; $i < $N; $i++) {
    $total = 0;
    for ($j = 0; $j < $N; ++$j) {
      // 最初
      if($i==0){
        $total += intval($inputList1[$j]);

        if($j == ($N-1)){
          $total += intval($inputList2[$j]);
        }
      }else{
        if($j >= ($N-$i)){
          $total += intval($inputList2[$j]);          
        }else{
          
          $total += intval($inputList1[$j]);

          if($j >= ($N-$i-1)){
            $total += intval($inputList2[$j]);
          }
        }
      }
    }

    $totalList[] = $total;
    
  }

rsort($totalList);

echo $totalList[0];


?>

Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
  int N, X[100];
  cin >> N;
  REP(i, N) {
    cin >> X[i];
  }
  int ret = 99999999;
  REP(i, 101) {
    int sum = 0;
    REP(j, N) {
      sum += (X[j] - i) * (X[j] - i);
    }
    if(ret > sum) {
      ret = sum;
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
N, K=map(int, input().split())
def cmb(n, r, p):
  if (r < 0) or (n < r):
    return 0
  r = min(r, n - r)
  return fact[n] * factinv[r] * factinv[n-r] % p
p=10**9+7

fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
  fact.append((fact[-1] * i) % p)
  inv.append((-inv[p % i] * (p // i)) % p)
  factinv.append((factinv[-1] * inv[-1]) % p)


A=sorted(list(map(int, input().split())))

mn=0
mx=0
for i in range(N):
  mn+=(A[i]*cmb(N-i-1,K-1,p))%p
  mx+=(A[i]*cmb(i, K-1,p))%p
  mn%=p
  mx%=p
print((mx-mn)%p)

Measured memory_bytes: 26704
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set;

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define     int                 ll
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'

int prime[(int)1e6];

bool fprime(int x){
    if(x%2==0){
        if(prime[2]){
            return false;
        }
        else{
            prime[2] = 1;
        }
    }
    while(x%2==0){
        x/=2;
    }
    for(int i = 3; i <= sqrt(x); i+=2){
        if(x%i==0){
            if(prime[i]){
                return false;
            }
            else{
                prime[i] = 1;
            }
            while(x%i==0){
                x /= i;
            }
        }
    }
    if(x > 2){
        if(prime[x]){
            return false;
        }
        else{
            prime[x] = 1;
        }
    }
    return true;
}

void solve(){
    clr(prime);
    int n, gcd;
    cin >> n; 
    vector<int> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        if(i){
            gcd = __gcd(gcd,a[i]);
        }
        else{
            gcd = a[i];
        }
    }
    if(gcd!=1){
        cout << "not coprime\n";
    }
    else{
        for(int i : a){
            if(!fprime(i)){
                cout << "setwise coprime\n";
                return;
            }
        }
        cout << "pairwise coprime\n";
    }
}

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

Measured memory_bytes: 18772
#include<cstdio>
#include<cstring>
using namespace std;

const int maxn=30,inf=0x3f3f3f3f;
int n,m,f[500][500],ans,mx[4]={-1,0,1,0},my[4]={0,-1,0,1},id[maxn][maxn],cnt;
char c[maxn][maxn];
bool b[500];

int mmax(int a,int b)
{
	if (a>=b)
		return a;
	return b;
}

int mmin(int a,int b)
{
	if (a<=b)
		return a;
	return b;
}

bool jud(int x,int y)
{
	return x>=1&&x<=n&&y>=1&&y<=m;
}

int main()
{
	int i,j,k,x,y;
	scanf("%d%d",&n,&m);
	memset(f,0x3f,sizeof(f));
	for (i=1;i<=n;i++)
		scanf("%s",c[i]+1);
	for (i=1;i<=n;i++)
		for (j=1;j<=m;j++)
		{
			id[i][j]=(++cnt);
			if (c[i][j]=='.')
				b[cnt]=1,f[cnt][cnt]=0;
		}
	for (i=1;i<=n;i++)
		for (j=1;j<=m;j++)
			if (c[i][j]=='.')
				for (k=0;k<=3;k++)
				{
					x=i+mx[k],y=j+my[k];
					if (jud(x,y)&&c[x][y]=='.')
						f[id[i][j]][id[x][y]]=f[id[x][y]][id[i][j]]=1;
				}
	for (k=1;k<=cnt;k++)
		if (b[k])
		for (i=1;i<=cnt;i++)
			if (b[i])
			if (i!=k)
				for (j=1;j<=cnt;j++)
					if (b[j])
					if (i!=j&&k!=j)
						f[i][j]=mmin(f[i][k]+f[k][j],f[i][j]);
	for (i=1;i<=cnt;i++)
		if (b[i])
		for (j=1;j<=cnt;j++)
			if (b[j])
			if (f[i][j]<inf)
				ans=mmax(ans,f[i][j]);
	printf("%d\n",ans);
}


Measured memory_bytes: 1152
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    s = S()
    t = S()
    ans = "UNRESTORABLE"
    for i in range(len(s)-len(t),-1,-1):
        part = s[i:i+len(t)]
        for schar, tchar in zip(part, t):
            if schar!=tchar and schar!="?":
                break
        else:
            ans = s[:i] + t + s[i+len(t):]
            ans = ans.replace("?","a")
            break
    print(ans)
main()


Measured memory_bytes: 74568
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] rows = new int[n + 1];
        int[] cols = new int[n + 1];
        char[][] field = new char[h][];
        for (int i = 0; i < h; i++) {
            field[i] = sc.next().toCharArray();
            for (int j = 0; j < w; j++) {
                if (field[i][j] == 'X' || field[i][j] == '.') {
                    continue;
                }
                if (field[i][j] == 'S') {
                    rows[0] = i;
                    cols[0] = j;
                } else {
                    rows[field[i][j] - '0'] = i;
                    cols[field[i][j] - '0'] = j;
                }
            }
        }
        int[][] costs = new int[h][w];
        int start = 0;
        for (int i = 1; i <= n; i++) {
            init(costs);
            PriorityQueue<Path> queue = new PriorityQueue<>();
            queue.add(new Path(rows[i - 1], cols[i - 1], start));
            while (queue.size() > 0) {
                Path p = queue.poll();
                if (p.row == rows[i] && p.col == cols[i]) {
                    start = p.value;
                    break;
                }
                if (costs[p.row][p.col] <= p.value) {
                    continue;
                }
                costs[p.row][p.col] = p.value;
                if (p.row > 0 && field[p.row - 1][p.col] != 'X') {
                    queue.add(new Path(p.row - 1, p.col, p.value + 1));
                }
                if (p.row < h - 1 && field[p.row + 1][p.col] != 'X') {
                    queue.add(new Path(p.row + 1, p.col, p.value + 1));
                }
                if (p.col > 0 && field[p.row][p.col - 1] != 'X') {
                    queue.add(new Path(p.row, p.col - 1, p.value + 1));
                }
                if (p.col < w - 1 && field[p.row][p.col + 1] != 'X') {
                    queue.add(new Path(p.row, p.col + 1, p.value + 1));
                }
            }
        }
        System.out.println(start);
    }
    
    static void init(int[][] arr) {
        for (int[] each : arr) {
            Arrays.fill(each, Integer.MAX_VALUE);
        }
    }
    
    static class Path implements Comparable<Path> {
        int row;
        int col;
        int value;
        
        public Path (int row, int col, int value) {
            this.row = row;
            this.col = col;
            this.value = value;
        }
        
        public int compareTo(Path another) {
            return value - another.value;
        }
    }
}



Measured memory_bytes: 105264
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
	    int n = IO.GetInt();
	    string s = IO.GetString();
	    int count = 0;
	    int index = 0;
	    while(index < n){
	        if(s.IndexOf("ABC",index)>=0){
	            count++;
	            index = s.IndexOf("ABC",index);
	            index++;
	        }else{
	            break;
	        }
	    }
	    Console.WriteLine(count);
	}

}

static class IO
{
    static public string GetString() { return Console.ReadLine(); }
    static public int GetInt() { return int.Parse(Console.ReadLine()); }
    static public long GetLong() { return long.Parse(Console.ReadLine()); }
    static public List<string> GetStringList() { return Console.ReadLine().Split(' ').ToList(); }
    static public List<int> GetIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
    static public List<long> GetLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
    static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
    static public void WriteStrings<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
}

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

int main() {
  int N;
  cin >> N;
  
  int min = 0;
  for (int i = 0; i < N; i++) {
    int x;
    int count = 0;
    int two = 2;
    cin >> x;
    while (x % two == 0) {
      count++;
      two *= 2;
    }
    if (i == 0 || min > count) {
      min = count;
    }
  }
  cout << min << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <climits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <unordered_map>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <random>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>

using namespace std;

#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e15
#define _INFLL (long long)-1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;

/*******************************************************/

int main() {
  int n; cin >> n;
  map<int, int> mp;
  Loop(i, n) {
    int a; cin >> a;
    mp[a]++;
  }
  int ans = 0;
  for (auto itr = mp.begin();itr != mp.end();++itr) {
    if (itr->first <= itr->second) {
      ans += itr->second - itr->first;
    }
    else ans += itr->second;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4736
/*I wanna be the very best, like no one ever was...*/

#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and Constants    *******/

#define ll long long
#define ull unsigned long long 
#define ld long double
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);
 

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif


int pow(int a , int n ){
    ll res =1;
    n = n/2;
    while(n){
        if(n%2==1){
            res= (res*a)%MOD;
        }
        a=(a*a)%MOD;
        n/=2;
    }
    return res;
}

int pow2(int a , int n ){
    n = n/2;
    long result=1;
            for(long i=0; i<n; i++){
                result=result*2;
                result=result%(1000000000+7);
            }
            
            // cout << result << endl;
    return result;
}


int main() {
    io;
    // freopen("in","r",stdin); 
    // freopen("out","w",stdout);
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,0,n)cin>>v[i];
    int flag = 1;
    sort(all(v));
    if(n%2==0){
        int start = 1;
        for(int i =0;i<n;i+=2){
            if(v[i]==start && v[i+1]==start){
                start+=2;

            }
            else {
                flag = 0;
                break;
            }

        }
        if(flag){
            // see(n/2);
            // cout<<pow(3,9);
            cout<<pow2(2,n)<<endl;
            return 0;
        }
        else {
            cout<<0<<endl;
            return 0;
        }
    }
    else {
        // see("fasdfa");
        int start = 0;
        if(v[0]!=start){
            flag = 0;
        }
        start+=2; 

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

            if(v[i]==start && v[i+1]==start){
                start+=2;
            }
            else{
                // see(v[i]);
                flag = 0;
                break;
            }
        }

        if(flag){
            
            cout<<pow2(2,n)<<endl;
            return 0;
        }
        else {
            cout<<0<<endl;
            return 0;
        }



    }

 
 
 
    
 
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		String t = sc.next();
		String ss = s.substring(0,1);
		String total = ss.concat(t.substring(0,1));

		for(int i = 1; i < n;i++) {
			ss = s.substring(i,i+1);
			total = total.concat(ss);
			total = total.concat(t.substring(i,i+1));
		}

		System.out.println(total);
	}

}

Measured memory_bytes: 21844
import sys
import heapq
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))

    """
    エラトステネスの篩は脳裏に浮かんだが、
    計算量がO(NloglogN)になる理屈を分かってなかったのを丁度突かれてしまった。
    1,2,3,...に対してそれぞれの倍数が1~Nにどれだけ含まれるかのチェックは
        N + N//2 + N//3 + ... = N (1 + 1/2 + 1/3 + ...) = NlogN
    になるのがミソ。
    さらに1~Nのリストに倍数チェックをつける際に、ある数xの倍数をすべて見るとして
    xのところに既にチェックがあればその先のチェックもすでに終わっているので計算量はさらに減らせる。 
    """

    sieve = [0] * (10**6 + 1)
    for a in A:
        if sieve[a] == 2: continue # 重複がある場合
        if sieve[a] == 1:
            sieve[a] += 1
            continue
        if sieve[a] == 0:
            num = a
            while num <= 10**6:
                sieve[num] += 1
                num += a
    ans = 0
    for a in A:
        if sieve[a] == 1: ans += 1
    print(ans)
    

if __name__ == "__main__":
    main()


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

vector<int> to[100005];
int n;
vector<int> dist;

void dfs(int v,int d=0,int p=-1){
  dist.at(v)=d;
  for(int u:to[v]){
    if(u==p)continue;
    dfs(u,d+1,v);
  }
}

vector<int> calcDist(int s){
  dist=vector<int>(n);
  dfs(s);
  return dist;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    int s,t;
    cin>>s>>t;
    s--,t--;
    rep(i,n-1){
      int a,b;
      cin>>a>>b;
      a--,b--;
      to[a].push_back(b);
      to[b].push_back(a);
    }

    vector<int> distS=calcDist(s);
    vector<int> distT=calcDist(t);
    int mx=0;
    rep(i,n){
      if(distS[i]<distT[i]) mx=max(mx,distT[i]);
    }
    cout<<mx-1<<endl;
}


Measured memory_bytes: 10744
#include <bits/stdc++.h>
using namespace std;
int h,w,n,ans=1e9;
int main(){
	cin>>h>>w>>n;
	for (int i=0;i<=h;i++) for (int j=0;j<=w;j++)
		if (n<=i*w+j*h-i*j) ans=min(ans,i+j);
	cout<<ans;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int m,f,b;
    scanf("%d%d%d",&m,&f,&b);
    if(m+f<b){
        printf("NA\n");
    }else if(m>=b){
        printf("0\n");
    }else{
        f=b-m;
        printf("%d\n",f);
    }
    return 0;
}


Measured memory_bytes: 2112
N, M, X = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(N)]

ans = 10 ** 8

for bit in range(1<<N):
    rikaido = [0] * M
    cost = 0
    for i in range(N):
        mask = 1 << i
        if bit & mask:
            cost += ca[i][0]
            for j in range(1, M + 1):
                rikaido[j - 1] += ca[i][j]
    
    if min(rikaido) >= X:
        if cost < ans:
            ans = cost

if ans == 10 ** 8:
    print(-1)
else:
    print(ans)

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

int main(){
    int x, y;
    cin >> x >> y;

    long long int ans = 0;
    if(abs(x) < abs(y) && x < 0 || abs(x) > abs(y) && x > 0)ans++;
    if(abs(x) != abs(y))ans += abs(abs(x) - abs(y));
    else ans++;
    if(abs(x) < abs(y) && y < 0 || abs(x) > abs(y) && y > 0)ans++;
    cout << ans << endl;

    return 0;
}


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

deque<int> deq;
int n, k;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> k;
		if ((n - i) % 2) {
			deq.push_front(k);
		} else {
			deq.push_back(k);
		}
	}
	for (int i : deq) {
		cout << i << " ";
	}
}

Measured memory_bytes: 2944
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<cmath>
#include <bits/stdc++.h>

using namespace std;
using Graph = vector<vector<int>>;
typedef unsigned long long ll;
ll mod = (10e+8)+ 7;
	double ans = 0;
#define For(N,i) for(int i = 0; i < N; i++)


int main(){

	ll A,B,K;
	cin>>A>>B>>K;
	if(A == K){
		cout<<A - K <<" "<<B<<endl;
	}
	
	else if(A + B < K){
		cout<<0 <<" "<<0<<endl;
	}
	else if(A < K){
		cout<<0<<" "<<B-(K - A)<<endl;
	}	else{
		cout<<A - K <<" "<<B<<endl;
	}




}

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

#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int dp[101][10];

int n;
int s[101];

int main()
{
	cin >> n;

	rep(i,1,n) cin >> s[i];

	rep(i,0,n)
	{
		rep(j,0,9)
		{
			dp[i][j] = -1e9;
		}
	}

	dp[0][0] = 0;

	rep(i,1,n)
	{
		rep(j,0,9)
		{

			dp[i][j] = max(dp[i - 1][j],dp[i][j]);

			int next = (s[i] + j) % 10;

			dp[i][next] = max(dp[i][next],dp[i - 1][j] + s[i]);

		}
	}

	int result = 0;

	rep(j,1,9)
	{
		result = max(result , dp[n][j]);
	}

	cout << result << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
int main(){
  int N,i;scanf("%d",&N);
  int a[N];
  for(i=0;i<N;i++){
    scanf("%d",&a[i]);a[i]--;
  }
  int ans = 0;
  for(i=0;i<N;i++){
    if(a[i] == i){
      if(i+1 == N) swap(a[i],a[i-1]);
      else swap(a[i],a[i+1]);
      ans++;i++;
    }
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 4204
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
const double EPS = 1e-7;
const double INF = 1e12;
struct Vec {
    double x,y;
    Vec(){}
    Vec(double x,double y){ this->x=x,this->y=y; }
    void read(){ scanf("%lf%lf",&x,&y); }
    void prt() {printf("%.9f %.9f\n",x,y); }
    double len(){ return sqrt(x*x+y*y); }
    double len2(){ return x*x+y*y; }
    
    Vec operator+(const Vec&o)const{ return Vec(x+o.x,y+o.y); }
    Vec operator-(const Vec&o)const{ return Vec(x-o.x,y-o.y); }
    Vec operator*(const double&k)const{ return Vec(k*x,k*y); }
    double operator*(const Vec&o)const {return x*o.x+y*o.y; }
    double operator^(const Vec&o)const {return x*o.y-y*o.x; }
    Vec rotate(double ang){ return Vec(x*cos(ang)-y*sin(ang), x*sin(ang)+y*cos(ang)); }
    Vec change(double l){ if(len()<EPS) return *this; return (*this)*(l/len()); }
    double disToLine(Vec A, Vec B) {
        return abs((A-*this)^(B-*this))/(B-A).len();
    }
};

Vec Lineintersect(Vec A1,Vec A2,Vec B1,Vec B2) {
    if (abs((A2-A1)^(B2-B1)) < EPS) return Vec(INF,INF);
    return A1 + (A2 - A1) * ( (((A2-A1)^(B2-B1)) - ((A2-B1)^(B2-B1))) / ((A2-A1)^(B2-B1)) );
}

Vec Segintersect(Vec A1,Vec A2,Vec B1,Vec B2) {
    Vec P = Lineintersect(A1,A2,B1,B2);
    //P.prt();
    if ((P-A1)*(P-A2)<=0 && (P-B1)*(P-B2)<=0) return P; 
    return Vec(INF,INF);
}

bool onseg(Vec P,Vec A,Vec B){
    if(P.disToLine(A,B) > EPS) return 0;
    return (P-A)*(P-B) <= 0;
}

Vec A,B,C,D; int q;
int main(){
    scanf("%d",&q);
    while(q--){
        A.read(); B.read(); C.read(); D.read();
        Segintersect(A,B,C,D).prt();
    }
}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

int main () {
  int X,Y,A,B,C;cin>>X>>Y>>A>>B>>C;
  priority_queue<P> pq;
  rep(i,A) {
    ll p;cin>>p;
    pq.push(P(p,0));
  }
  rep(i,B) {
    ll q;cin>>q;
    pq.push(P(q,1));
  }
  rep(i,C) {
    ll r;cin>>r;
    pq.push(P(r,2));
  }
  int red = 0, green = 0, sum = 0;
  ll deli = 0;
  while(sum < X + Y) {
    ll d = pq.top().first;
    int typ = pq.top().second;
    pq.pop();
    if(typ == 0) {
      if(red < X) {
	red++;
	sum++;
	deli += d;
      }
    } else if(typ == 1) {
      if(green < Y) {
	green++;
	sum++;
	deli += d;
      }
    } else {
      sum++;
      deli += d;
    }
  }
  cout << deli << endl;
}


Measured memory_bytes: 11660
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}

signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    //*comment for all except cc/cf    
    #ifndef ONLINE_JUDGE    
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/
    int n;
    cin>>n;
    std::vector<pii> v(n);
    for (int i = 0; i < n; ++i)
    {
        cin>>v[i].ff>>v[i].ss;
    }
    bool ok = false;
    int c = 0;
    for (int i = 0; i < n; ++i)
    {
        if(v[i].ff==v[i].ss)
            c++;
        else
            c = 0;
        if(c>=3)
            ok = true;
    }


    cout<<(ok ? "Yes" : "No");

    printclock;
    return 0;
}

Measured memory_bytes: 3844
use proconio::input;


fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    }
    else {
        gcd(b, a % b)
    }
}


fn main() {
    input! {
        k: i64,
    }

    let mut ans: i64 = 0;

    for i in 1..k+1 {
        for j in 1..k+1 {
            for k in 1..k+1 {
                ans += gcd(gcd(i, j), k);
            }
        }
    }

    print!("{}", ans);
}


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

using namespace std;

int main(int argc, char *argv[])
{
  int N, M;
  string A[60], B[60];
  cin >> N >> M;

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

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < A[i].size(); j++) {

      bool ok = true;
      for (int k = 0; k < M; k++) {
        for (int l = 0; l < B[k].size() ; l++) {
          if (j + l >= A[i + k].size() || i + k >= N) {
            ok = false;
            break;
          }

          if (A[i + k][j + l] == B[k][l]) continue;
          ok = false;
          break;
        }

        if (!ok) break;
      }

      if (ok) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
  return 0;
}


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

int main(){
    int N,i,Sum;
    int L[10];
    cin >> N;
    for(i=0;i<N;i++){
        cin >> L[i];
    }
    sort(L,L+N);
    Sum=0;
    for(i=0;i<N-1;i++){
        Sum += L[i];
    }
    if(L[N-1]<Sum){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)

for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Measured memory_bytes: 9668
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  ll n,W ;
  cin >> n >> W ;
  vector<pair<ll,ll>> v ;
  vector<vector<ll>> dp(n+1,vector<ll>(W+1)) ;
  for(ll i=0;i<n;i++)
  {
    ll a,b ;
    cin >> a >> b ;
    v.push_back({a,b}) ;
  }
  sort(v.begin(),v.end()) ;
  for(ll i=1;i<=n;i++)
  {
    for(ll j=1;j<=W;j++)
    {
      if(j<v[i-1].first)dp[i][j] = dp[i-1][j] ;
      else dp[i][j] = max(dp[i-1][j],v[i-1].second + dp[i-1][j-v[i-1].first]) ;
    }
  }
  cout << dp[n][W] << endl;
}

Measured memory_bytes: 83124
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define endl "\n"
#define F first
#define S second
#define EN cout<<endl;
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define pi 3.1415926535897
 ll dp[2000][2000];



int main(){
   double n,a,b,h,m;
   cin>>a>>b>>h>>m;
   double cb=min(abs(h/12+m/720-m/60),1-abs(h/12+m/720-m/60));
   printf("%.10f\n",sqrt(a*a+b*b -2*a*b*cos(pi*(cb*2))));
}


Measured memory_bytes: 4164