akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int N = 200005;

int ft[N];

int qry(int id){
	int ret = 0;
	while(id){
		ret += ft[id];
		id -= id & (-id);
	}
	return ret;
}

void upd(int id, int val){
	while(id < N){
		ft[id] += val;
		id += id & (-id);
	}
}

void upd(int l, int r, int val){
	upd(l, val);
	upd(r+1, -val);
}
int lst[N];

int main(){
	int n, k;
	int v[N];
	scanf("%d %d", &n, &k);
	for(int i = 1; i <= n; i++){
		scanf("%d", v+i);
		lst[i] = v[i];
		upd(i, i, v[i]);
	}
	for(int i = 0; i < k; i++){
		for(int j = 1; j <= n; j++){
			upd(max(1, j - v[j]), min(n, j + v[j]), 1);
		}
		int cnt = 0;
		for(int j = 1; j <= n; j++){
			v[j] = qry(j) - lst[j];
			lst[j] = v[j] + lst[j];
			cnt += v[j] == n;
		}
		if(cnt == n) break;
	}
	for(int i = 1; i <= n; i++){
		printf("%d ", v[i]);
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 6152
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

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

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    LL n,m,k;cin>>n>>m>>k;

    VL a(n),b(m);
    REP(i,n){
        cin>>a[i];
        if(i!=0){
            a[i]+=a[i-1];
        }
    }
    REP(i,m){
        cin>>b[i];
        if(i!=0){
            b[i]+=b[i-1];
        }
    }


    LL result = 0;
    REP(i,n){
        if(a[i]>k){
            break;
        }
        auto itr =  upper_bound(ALL(b), k-a[i]);
        result = max(result, LL(i+1 + (itr - b.begin())));
        //dump(i)
        //dump(itr - b.begin())
    }
    REP(i,m){
        if(b[i]>k){
            break;
        }
        auto itr =  upper_bound(ALL(a), k-b[i]);
        result = max(result, LL(i+1 + (itr - a.begin())));
        //dump(i)
        //dump(itr - b.begin())
    }

    cout<<result<<endl;


    
	return;
}

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

Measured memory_bytes: 6364
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main() {
  ll n,m;
  cin>>n>>m;
  
  vector<ll> X(m);
  rep(i,m) cin>>X[i];
  
  if(n>=m) cout<<0<<endl;
  else{
    vector<ll> Y;
    sort(ALL(X));
    rep(i,m-1){
      Y.push_back(X[i+1]-X[i]);
    }
    sort(ALL(Y));
    rep(i,n-1) Y.pop_back();
    ll sum=0;
    for(auto t:Y) sum+=t;
    cout<<sum<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 4872
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;
typedef long long ll;

const int    INF = 1000000000;
const int    MOD = 1000000007;
const double EPS = 1e-8;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> from;
    vector<int> to;
    for(int i = 1; i <= N; i++){
        int a; cin >> a;
        if(i < a){
            from.push_back(i);
            to.push_back(a);
        }
    }
    int ans = 0;
    for(int s = 0; s < from.size(); s++){
        vector<int> dp(from.size() + 1, INF);
        dp[0] = dp[1] = to[s];
        int max_k = 1;
        for(int i = s + 1; i < from.size(); i++){
            if(from[i] >= to[s]) break;
            int k = upper_bound(dp.begin(), dp.end(), to[i]) - dp.begin();
            //printf("s = %d i = %d k = %d\n", s, i, k);
            if(k < 2) continue;
            dp[k] = to[i];
            max_k = max(max_k, k);
        }
        ans = max(ans, min(N / 2, max_k + K));
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    string s,t;
    cin>>s>>t;
    bool f=0;
    for (int i=0;i<s.size();i++) {
        s=s.substr(1)+s[0];
        if (s==t)
            f=1;
    }
    if (f)
        puts("Yes");
    else
        puts("No");
    return 0;
}

Measured memory_bytes: 256
def l_in(type_): return list(map(type_, input().split()))
def i_in(): return int(input())
def m_in(type_): return map(type_, input().split())
def r_in(n, type_): return [type_(input()) for _ in range(n)]
ans = None

d, t, s = m_in(int)
ans = 'Yes' if d <= t*s else 'No'

print(ans)


Measured memory_bytes: 9188
import itertools as it

N,M,X=map(int,input().split())
book = [[int(_) for _ in input().split()] for i in range(N)]

combs = it.product([0, 1], repeat=N)
prices = []
for comb in combs:
	bag = [0] * (M+1)
	for i in range(N):
		if comb[i] == 0:
			continue
		else:
			for j in range(M+1):
				bag[j]+=book[i][j]
	if min(bag[1:]) < X:
		continue
	else:
		prices.append(bag[0])

if len(prices) == 0:
	print(-1)
else:
	print(min(prices))


Measured memory_bytes: 9240
#include <stdio.h>
int main()
{
  int h, w ;
  int i, j ;

  for(;;){
    scanf("%d %d",&h,&w);

    if(h!=0 || w!=0){
      for(i=1 ; i<=h ; i++){
        for(j=1 ; j<=w ; j++){
          if((i+j)%2 == 0){
            printf("#") ;
          }else{
            printf(".") ;
          }
        }
        printf("\n") ;
      }
      printf("\n") ;
    }else if(h==0 && w==0){
      break ;
    }
  }

  return 0 ;
}


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

using namespace std;

int costs[10][10];
int best[10][10];

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int h, w;
	cin >> h >> w;
	for (int i = 0; i <= 9; ++i) {
		for (int j = 0; j <= 9; ++j) {
			cin >> costs[i][j];
			best[i][j] = costs[i][j];
		}
	}
	for (int k = 0; k <= 9; ++k) {
		for (int i = 0; i <= 9; ++i) {
			for (int j = 0; j <= 9; ++j) {
				best[i][j] = min(best[i][j], best[i][k] + best[k][j]);
			}
		}
	}
	long long sum = 0;
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			int x;
			cin >> x;
			if (x == -1) continue;
			sum += best[x][1];
		}
	}
	cout << sum << '\n';
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2) //O2ÓÅ»¯£¿

#include<bits/stdc++.h>
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define BINF 0x7fffffff
#define INF 0x3f3f3f3f
#define LINF 9223372036854775807
#define END(s) {cout<<s;return 0;}
#define CON(s) {cout<<s;continue;}
#define BRE(s) {cout<<s;break;}
#define pb push_back
#define All(a) a.begin(),a.end()  //with A in CAPITAL!!!
#define sz(a) (int)a.size()
#define F first
#define S second
#define LOCAL_JUDGE 1 //remember to change
using namespace std;

bool p[1010];
int a[1010][1010];
long long res=0;

int n;

void pr(){
	for(int i=2;i<=n;i++){
		if(p[i]) continue;
		for(int j=i*i;j<=n;j+=i) p[j]=true;
	}
}

void pre(){
	for(int i=1;i<=n;i++){
		int sth=i;
		for(int j=2;j<=sth;j++){
			if(!p[j]){
				while(!(sth%j)) sth/=j,a[i][j]++;
			}
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	pr();
	pre();
	long long fact=1;
//	rep(i,n+1) cout<<p[i]<<" ";
//	cout<<endl;
//	rep(i,n+1){
//		rep(j,n+1) cout<<a[i][j]<<" ";
//		cout<<endl;
//	}
	for(int i=2;i<=n;i++){
		res=0;
		for(int j=2;j<=n;j++)
			res+=a[j][i],res%=1000000007;
		res++;res%=1000000007;
		fact*=res;fact%=1000000007;
	}
	cout<<fact<<endl;
	return 0;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
#define rint register int 
#define ll long long 
using namespace std;
ll A,B,V,W,T;
int main(){
	cin>>A>>V>>B>>W>>T;
	ll d=abs(A-B);
	if(A==B) cout<<"YES\n";
	else {
		if(d<=(V-W)*T) cout<<"YES\n";
		else cout<<"NO\n";
	}
	return 0;
}

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

int gcd (int a,int b,int c);
int main(){
    ll ans = 0;
    int n;
    cin >> n;

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            for(int k = 1; k <= n; k++ ){
                ans +=gcd(k,j,i);
            }
        }
    }

    cout << ans << endl;
    
}

int gcd(int a,int b,int c){
    int minn = min({a,b,c});
    int ans = 0;
    for(int i = 1; i <= minn; i++){
        if(a % i == 0 && b % i == 0 && c % i == 0){
            ans = i;
        }
    }

    return ans;
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <array>
#include <cassert>
#include <utility>
#include <vector>


bool dfs(int a, int b, int c, int k){
    if(k == 0) return a < b and b < c;
    if(a < b and b < c) return true;
    return dfs(2 * a, b, c, k - 1) or dfs(a, 2 * b, c, k - 1) or dfs(a, b, 2 * c, k - 1);
}


int main(void){
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); 
    std::cout << std::fixed << std::setprecision(16);
    
    int n, k; std::cin >> n >> k;
    std::vector<int> A(n); for(auto& itr : A) std::cin >> itr;
    for(int i = 0, j = k; j < n; ++i, ++j){
        if(A[i] < A[j]) std::cout << "Yes\n";
        else std::cout << "No\n";
    }
    
    return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double c =
        cos(abs(2 * M_PI * h / 12 + M_PI / 6 * m / 60 - 2 * M_PI * m / 60));
    printf("%.12lf\n", sqrt(a * a + b * b - 2 * a * b * c));
    return 0;
}

Measured memory_bytes: 4172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

int main(){
    
    int N;cin>>N;
    vector<ll> A(N),B(N);
    ll cnt=0;
    priority_queue<pair<ll,int>> PQ;
    for(int i=0;i<N;i++){
        cin>>B[i];
    }
    for(int i=0;i<N;i++){
        cin>>A[i];
        PQ.push(make_pair(A[i],i));
    }
    
    while(!PQ.empty()){
        ll a=PQ.top().first;
        int b=PQ.top().second;
        PQ.pop();
        if(a==B[b]) continue;
        if(a<B[b]){
            cnt=-1;
            break;
        }
        ll c=A[(b+N-1)%N],d=A[(b+1)%N];
        ll e=a%(c+d);
        if(a<c+d){
            cnt=-1;
            break;
        }
        if(e>=B[b]){
            cnt+=a/(c+d);
            PQ.push(make_pair(e,b));
            A[b]=e;
        }else{
            ll f=a-(a-B[b])/(c+d)*(c+d);
            if(a==f){
                cnt=-1;
                break;
            }
            cnt+=(a-B[b])/(c+d);
            PQ.push(make_pair(f,b));
            A[b]=f;
        }
        
    }
    
    cout<<cnt<<endl;
    
}




Measured memory_bytes: 9584
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)
 
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define repp(i, a, b) for(int i = a; i <= b; i++)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, b, a) for(int i = b; i >= a; i--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define mem(a, b) memset(a, b, sizeof(a));
#define mem0(a) memset(a, 0, sizeof(a));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in_edges(m) repp(i, 1, m){ll a, b; cin >> a >> b; v[a].pb(b), v[b].pb(a);}
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define endl "\n"
ll power(ll x, ll y); 

const ll MOD = 1000000007;
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    ll n;
    cin >> n;
    
    bool flag = 1;
    rep(i, 0, n){
        ll x;
        cin >> x;
        if(x % 2 == 0)
            if(x % 3 != 0 && x % 5 != 0) flag = 0;
    }

    if(flag) cout << "APPROVED";
    else cout << "DENIED";
}
 
ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  unsigned long long i, o, t, j, l, s, z;
  std::cin >> i >> o >> t >> j >> l >> s >> z;
  unsigned long long ans = 0ull;
  ans += (i / 2) * 4;
  ans += o * 2;
  ans += (j / 2) * 4;
  ans += (l / 2) * 4;
  unsigned long long tmp = ans;
  if (j % 2 == 0 && j > 0) tmp -= 3;
  if (l % 2 == 0 && l > 0) tmp -= 3;
  if (i % 2 == 0 && i > 0) tmp -= 4;
  if (i > 0 && l > 0 && j > 0) tmp += 6;
  if (ans < tmp) {
    ans = tmp;
  }
  std::cout << ans / 2;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <unordered_map>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);

  unordered_map<long long, long> m;
  unordered_map<long long, long> cache;

  vector<long long> A(n);
  for (int i = 0; i < n; i++) {
    long long a;
    scanf("%lld", &a);
    A[i] = a;
    if (m.find(a) == m.end()) {
      m[a] = 1;
    } else {
      m[a] += 1;
    }
  }

  long long sum = 0;
  for (pair<long, long> p : m) {
    long long key = p.first;
    long long  value = p.second;
    sum += value * (value - 1) / 2;
  }

  for (pair<long long, long long> p : m) {
    long long key = p.first;
    long long value = p.second;
    cache[key] = sum - (value * (value - 1) / 2);
  }

  for (int i = 0; i < n; i++) {
    long long a = A[i];
    long long  k = m[a] - 1;
    cout << (cache[a] + k * (k - 1) / 2)  << endl;
  }

  return 0;
}


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

int main(){

	int a, b;
	cin >> a >> b;

	if( a==2 || b==2){
		cout << "No\n";
	}
	else if( a==4 || a==6 || a==9 || a==11){
		if( b==4 || b==6 || b==9 || b==11 ){
			cout << "Yes\n";
		}
		else{
			cout << "No\n";
		}
	}
	else{
		if( b==1 || b ==3 || b==5 || b ==7 || b==8 || b==10 || b==12){
			cout << "Yes\n";
		}
		else{
			cout << "No\n";
		}
	}

	return 0;

}

Measured memory_bytes: 888
N = int(input())
# Nは奇数
A = [int(i) for i in input().split()]

answer = (sum(A) - 2 * sum([A[i] for i in range(N) if i % 2 != 0])) // 2
answer_list = []
answer_list.append(answer)
for j in A:
  if (j - answer) < 0:
    break
  answer = j - answer
  answer_list.append(answer)
if answer_list[0] == answer_list[-1] and len(answer_list) == N+1:
  print(' '.join([str(i*2) for i in answer_list[:N]]))
  exit()

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

int main(){
	string s;
	cin >> s;
	int count = 0;
	if(s[0]=='o') count++;
	if(s[1]=='o') count++;
	if(s[2]=='o') count++;
	cout << 700 + count*100 << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		long mod = 1000000007;
		int n = sc.nextInt();
		int q = sc.nextInt();
		int[] a = new int[n];
		for(int i=0; i<n; i++) {
			a[i] = sc.nextInt();
		}
		long dp[][] = new long[n][n];
		for(int i=0; i<n; i++) {
			for(int j=0; j<n; j++) {
				if(a[i] > a[j])
					dp[i][j] = 1;
			}
		}
		long half = inverse(2,mod);

		for(int i=0; i<q; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			for(int j=0; j<n; j++) {
				if(j!=y-1 && j!=x-1) {
					dp[y-1][j] = dp[x-1][j] = (half * dp[x-1][j] % mod + half * dp[y-1][j] % mod)%mod;
					dp[j][x-1] = dp[j][y-1] = (half * dp[j][x-1] % mod + half * dp[j][y-1] % mod)%mod;
				}
				dp[y-1][x-1] = dp[x-1][y-1] = (half * dp[y-1][x-1] % mod + half * dp[x-1][y-1] % mod)%mod;
			}

		}

		long expectation = 0;
		for(int i=0; i<n; i++) {
			for(int j=i+1; j<n; j++) {
				expectation = (expectation + dp[i][j]) %mod;
			}
		}
		System.out.println(expectation*bin_exp(2,q,mod)%mod);
	}
	
	public static long bin_exp(long base, long exp, long mod) {
		if(exp == 0)
			return 1;
		return bin_exp(base*base%mod, exp/2, mod) * (exp%2 == 1? base : 1) % mod;
	}
	
	public static long inverse(long a, long mod) {
		return bin_exp(a,mod-2,mod);
	}
}

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

int main(){
    int a, b;
    bool flag=false;
    bool ini=false;
    while(cin >> a >> b, a != 0 && b != 0){
        flag = false;
        if(ini)cout << endl;
        else ini = true;
        for(int y = a; y<=b; y++){
            if(y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)){
                flag = true;
                cout << y << endl;
            }
        }

        if(!flag){
            cout << "NA" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

map<int, char> m;

int main()
{	
	int h, w;
	cin >> h >> w;

	int cnt = 0;
	for (char i = 'A'; i <= 'Z'; i++) {
		m[cnt] = i;
		cnt++;
	}

	int ans_i, ans_j;
	rep(i, h) {
		rep(j, w) {
			string s;
			cin >> s;
			if (s == "snuke") {
				ans_i = i + 1;
				ans_j = j;
			}
		}
	}
	cout << m[ans_j] << ans_i << endl;
	return	0;
}




Measured memory_bytes: 384
//
// Created on 2018-12-08.
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<(n);++i)
#define RFOR(i,m,n) for(int i=(n)-1;i>=(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }

#define PB push_back
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vs> vvs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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


    int N, A, B, Pt;
    cin >> N >> A >> B;

    vector<int> v;
    REP(_, N){cin >> Pt; v.emplace_back(Pt);}

    vi a, b, c;
    REP(i, N){
        if (v[i] <= A) a.emplace_back(v[i]);
        else if (A+1 <= v[i] and v[i] <= B) b.emplace_back(v[i]);
        else c.emplace_back(v[i]);
    }

    cout << min( min(a.size(), b.size()), c.size()) << endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
 
int main() {

    int h,w,k;
    cin >> h >> w >> k;

    char c[h][w];
    char d[h][w];
    rep(i,h) {
        rep(j,w) {
            cin >> c[i][j];
            d[i][j] = c[i][j];
        }
    }
    //h個についてbit全探索
    //t[i]をtrue,falseで判断
    int ans=0;
    vector<int> t(h);
    for(int bit=0; bit <(1<<h); ++bit) {
        for(int i=0;i<h;i++) {
            if(bit & (1<<i))    t[i]=true;
            else    t[i]=false;
        }
        //ここから処理を書く
        //w個についてbit全探索
        //t[i]をtrue,falseで判断
        vector<int> s(w);
        for(int bits=0; bits <(1<<w); ++bits) {
            for(int i=0;i<w;i++) {
                if(bits & (1<<i))    s[i]=true;
                else    s[i]=false;
            }
            //ここから処理を書く
            rep(i,h) {
                if(t[i] == true) {
                    rep(j,w) {
                        c[i][j] ='a';
                    }
                }
            }
            rep(i,w) {
                if(s[i] == true) {
                    rep(j,h) {
                        c[j][i] = 'a';
                    }
                }
            }
            int res = 0; 
            rep(i,h) {
                rep(j,w) {
                    if(c[i][j] == '#')  res++;
                    c[i][j] = d[i][j];
                }
            }
            if(res == k)    ans ++ ;
        }
    }

    cout<<ans<<endl;


 return 0;
}

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

int main(){
	string s;
	int a[26] = {0};
	
	cin >> s;
	for(int i = 0;i < s.size();i++){
		a[s[i]-'a']++;
	}
	
	for(int i = 0;i<26;i++){
		if(a[i]%2){
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
using namespace std;
int main() {
        int n = 0;
        unsigned long long int a, b, x[100000], ans = 0;
        cin >> n >> a >> b;
        for (int i = 0; i < n; i++)
                cin >> x[i];
        for (int i = 0; i < n - 1; i++) {
                if ((x[i + 1] - x[i])*a < b)
                        ans += (x[i + 1] - x[i])*a;
                else
                        ans += b;
        }
        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 1024
let s = readLine()!

let a = Array(s.characters)
let evens: [Character] = ["R", "U", "D"]
let odds: [Character] = ["L", "U", "D"] 
var i = 0
var good = true

while i < a.count {
  if !evens.contains(a[i]) {
    good = false
    print("No")
    break
  }
  i += 2
}

i = 1 

while i < a.count && good {
  if !odds.contains(a[i]) {
    good = false
    print("No")
    break
  }
  i += 2
}

if good {
  print("Yes")
}

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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define MP make_pair
#define FI first
#define SE second
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;

const double EPS = 1e-9;
const double PI = acos(-1);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

ll addMod(ll a, ll b){
	return (a+b) % MOD;
}

ll mulMod(ll a, ll b){
	return (a*b) % MOD;
}

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


ll n,k,x,y;

ll solve(){
	if(n <= k) return n*x;
	return k*x + (n-k) * y;
}

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k >> x >> y;
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define chmin(a,b) a = min(a,b)
#define chmax(a,b) a = max(a,b)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;
using P  = pair<int,int>;//(cost,to)
using vP = vector<P>;
using vvP= vector<vP>;

const int INF = 1001001001;


int main(){
    ll n;cin>>n;
    
    ll ans = 0;
    
    for(ll i=1; i<=n; i++){
        ans += i*(n+1-i);
    }
    
    rep(i,n-1){
        ll a,b;
        cin>>a>>b;
        
        if(a>b)swap(a,b);
        
        ans -= a*(n+1-b);
    }
    
    cout << ans << endl;
    return 0;
}

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

int main() {
  int k; cin>>k;
  int ans=-1;

  // kが10と素のときに、オイラーの定理より答えが存在する
  if(k%2!=0 && k%5!= 0) {
    // mod部分
    int n;
    // kが7の倍数かどうかで場合分け
    // 10^n = 1 (mod 9k/7)
    if(k%7==0) n=9*k/7;
    // 10^n = 1 (mod 9k)
    else n=9*k;
    int modN;
    for(int i=1;;i++) {
      if(i==1) modN=(int)pow(10,i)%n;
      else modN=modN*10%n;
      if(modN==1) {
        ans = i;
        break;
      }
    }
  }
  cout << ans << endl;
}


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

using namespace std;

int main()
{
    int n , x=0;
    string s;

    cin >> n >> s;

    if( n%2==1 )
    {
        cout << "No" << endl;
    }
    else
    {
        for( int i=0 ; i<n/2 ; i++)
        {
            if ( s[i]!=s[i+(n/2)] )
            {
                x++;
            }
        }

        if ( x==0 )
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout<< "No" << endl;
        }
    }



    return 0;
}


Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

/*
thx
https://beta.atcoder.jp/contests/arc082/submissions/1561286
*/
const int N = 100000;//10^5
vector<int> r(N);//反転時間,10^5個>=K個
//クエリの入力
vector<int> t(N);//指定時間 Q個:Q<=10^5
vector<int> init(N);//初期値 Q個

void solve(){
	int x,n;
	//x:=砂時計に入っている砂の量
	//n:=反転回数
	cin >> x >> n;
	for(int i=0;i<n;++i){
		cin >> r[i];
	}

	int tt;
	cin >> tt;//クエリ数
	for(int i=0;i<tt; ++i){
		cin >> t[i] >> init[i];
	}
	//////
	/*
	グラフの形
	最初は[／]
	上下に動いて端が平らになる。
	　＿／￣
	このグラフを記録する。
	最小値、最大値、中央の直線の切片
	*/
	int a = 0;
	int val_a = 0;
	int b = x;
	int val_b = x;
	int dir = -1;//現在の増減方向-1:減る +1:増える
	int ptr = 0;//クエリの番号

	for(int i=0;i<=n;++i){//反転回数+1:最後の反転時間後のクエリ時間用
		//クエリの時間までシミュレーションする
		
		//クエリの処理
		//i==nは最後の反転が終わって、クエリ時間がその後の場合に使う
		while( ptr < tt && (i==n || t[ptr] <= r[i]) ){
			//クエリが残っている。クエリタイムが次の反転時間以下
			//r[i-1]までの反転の処理+余りの処理で計算できる
			int now = -1;//適当な値。
			//＿／￣:3区間に分類できている
			if( init[ptr] <= a ){//＿の部分
				now = val_a;
			}else if( b <= init[ptr] ){//￣の部分
				now = val_b;
			}else{//／の部分: a <= init[ptr] <= b
				now = val_a + (init[ptr]-a);
			}
			////
			now += (t[ptr] - (i==0? 0: r[i-1])) * dir;//時間*増減方向*(1val/s)
			now = max(now,0);//負なら0に
			now = min(now,x);//xを超えているならxに
			cout << now << '\n';

			ptr++;//次のクエリ番号へ
		}

		//反転r[i]の処理
		if( i < n ){//
			int pass = r[i] - (i==0? 0 : r[i-1]);//経過時間
			//dir:減るか増えるか
			//dir*pass = この区間での総増減
			//一旦、グラフをdirにずらす
			val_a += dir * pass;
			val_b += dir * pass;
			if( val_b < 0 ){//全てが0になる。
				a = 0;
				val_a = 0;
				b = 0;
				val_b = 0;
			}else if( x < val_a ){//全てがxになる。
				a = 0;
				val_a = x;
				b = 0;
				val_b = x;///////////////
			}else{//[a,b]の切り替えを更新
				if( val_a < 0 ){
					a -= val_a;//aを右にずらす
					val_a = 0;
				}
				
				if( x < val_b ){
					//val_b-x分、上限xを超えている、
					//b -= 超えた分ずらしている
					b -= val_b - x;//bを左にずらす
					val_b = x;
				}
				//a,bの変更がない場合val_a,val_bは既に経過時間分変更してある。
			}

			dir = -dir;
		}
	}
	cout << flush;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 2432
#include <bits/stdc++.h>
 
using namespace std;
 
 
 
//c++ templte for help...........................................................
 
//#define deb(x) cout<<#x<<" "<<x<<endl;/* for debuging  printing variable with name*/
//#define debb(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;										
//#define debbb(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;			
 
typedef long long ll;
	
 
//for loop
//#define fo(i,n) for(int i=0;i<(ll)n;i++)
//#define Fo(i,k,n) for(int i=k;i<n;i++)
 
 
//to print vector element 
//template<typename T>
//void printV(T vec){
	//fo(i,vec.size()) cout<<vec[i]<<" "<<flush;
	//cout<<endl;
	//}
	
 
//#define modulo 1000000007
//const int INF=1e9+5;
 
//template<typename T>
//void printS(T st){
	//while(!st.empty()) {cout<<st.top()<<" ";st.pop();}
	//cout<<endl;
//}
 
 
 
//c++ template for help........................................................



int main() {
	//stringstream ss;
	//ss<<"akhil";
	//cout<<ss.str()<<endl;
	cout<<setprecision(16);
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	
	 // TESTCASE KO DEKH KA BHAUT SARA CONDITION GENERATE MAT KRO 
	 // PAPER PD CONFIRM HO JAO THORA JADA TIME HI KYU NA LGA
	 // greedy ma jadatr exceptional case check kr ke dekh lo
	 
	 // WHILE DOING THE QUESTION OF DYNAMIC PROGRAMMING GREEDY KA TRAH SOCHNA BAND KRO
	 // DP M DATA KA BHI USE KRNA PDTA HA BE BHULO MT 
	 // DP BHI WO LEETCODE WALE MATRIX KA QUESTION KI TARAH HA
	 // CONSTRAIN WILL BE THE DIMENSION OF DP
	 // DP MA STATE PTA KRO AUR PHIR FUNCTION GENERATE KRO
	 // OBJECT KO CHOOSE KIA YA NAE KIA AGAR KIA TO KYA HOGA AUR NAE KIA TO KYA HOGA
	 // KYA KYA CHEJ IMPORTANT HA WO STATE BN JYAGA AUR HUM LOG STATE KO CHANGE KR SKTA HA JYSA KNPSACK 2 WALE PROBLEM MA KIA THA
	 
	 
	 ll n;
	 cin>>n;
	 vector<ll> vec(n);
	 unordered_map<ll,ll> mp;
	 for(int i=0;i<n;i++){
		cin>>vec[i];
		mp[vec[i]]++;
	 }
	 
	 ll sum=0,sqr=0;
	 for(auto itr=mp.begin();itr!=mp.end();itr++){
		sum+=itr->second;
		sqr+=pow(itr->second,2);
	}
	
	for(int i=0;i<n;i++){
		cout<<((sqr-((2*mp[vec[i]])+1)-(sum-1))/2)+1<<endl;
	}
	 
	 
	
	 
	 
	 
	 
	 
	 

	
	
	return 0;
}


Measured memory_bytes: 9160
#include <iostream>
#include <vector>
#include <algorithm>
#define T true
#define F false

using namespace std;

int num, mm, ans = 0;

void Search(vector<int> &l, const vector<vector<bool>> &con, const vector<int> &p, int a) {
	int i = 0;
	if (a == num) {
		for (; i < mm; i++) {
			if ((l[i] & 1) != p[i])
				break;
		}
		if (i == mm)
			ans++;
		return;
	}
	vector<int> ll(mm);
	for (; i < mm; i++) {
		if (con[a][i])
			ll[i] = l[i] + 1;
		else
			ll[i] = l[i];
	}
	Search(ll, con, p, a + 1);
	Search(l, con, p, a + 1);
	return;
}

int main(void) {
	int i = 0, j, a, k;
	cin >> num >> mm;
	vector<int> light(mm, 0), p(mm);
	vector<vector<bool>> con(num, vector<bool>(mm, F));
	for (; i < mm; i++) {
		cin >> k;
		for (j = 0; j < k; j++) {
			scanf("%d", &a);
			con[a - 1][i] = T;
		}
	}
	for (i = 0; i < mm; i++)
		scanf("%d", &p[i]);
	Search(light, con, p, 0);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
using System;

public class Card
{
  public char mark;
  public int value;
  public bool judge;
  public Card(char mark,int value,bool judge){
    this.mark = mark;
    this.value = value;
    this.judge = judge;
  }
}

public class Program
{
  public static void Main(string[] args)
  {
    Card[] SHCD = new Card[52];
    for(int i = 0;i < 52;i++)
    {
      if(i < 13) SHCD[i] = new Card('S',i + 1,false);
      else if(i < 26) SHCD[i] = new Card('H',(i + 1)-13,false);
      else if(i < 39) SHCD[i] = new Card('C',(i + 1)-26,false);
      else SHCD[i] = new Card('D',(i + 1)-39,false);
    }
    int count = int.Parse(Console.ReadLine());
    int j = 0;
    while(j < count)
    {
      string[] read = Console.ReadLine().Split(' ');
      if(read == null) break;
      char tmp_mark = char.Parse(read[0]);
      int tmp_value = int.Parse(read[1]);
      for(int i = 0;i < 52;i++)
      {
        if(tmp_mark == SHCD[i].mark && tmp_value == SHCD[i].value){
          SHCD[i].judge = true;
        }
      }
      j++;
    }
    for(int i = 0;i < 52;i++)
    {
      if(!SHCD[i].judge) Console.WriteLine(SHCD[i].mark + " " + SHCD[i].value);
    }
  }
}

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

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	for (auto& v : A)
	{
		cin >> v;
	}

	vector<int>::iterator max_it = max_element(A.begin(), A.end());
	size_t max_idx = distance(A.begin(), max_it);

	vector<int> temp(A);
	temp.erase(temp.begin() + max_idx);
	vector<int>::iterator sec_it = max_element(temp.begin(), temp.end());

	for (int i = 0; i < N; ++i)
	{
		if (A[i] == *max_it)
		{
			cout << *sec_it << endl;
		}
		else
		{
			cout << *max_it << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

typedef long long ll;
#define INF 100000000
#define MOD 1000000007

int main()
{
	const int N = 3;
	string s[N];
	
	for (int i = 0; i < N; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < N - 1; i++) {
		if (s[i][s[i].size() - 1] != s[i + 1][0]) {
			cout << "NO" << endl;
			return (0);
		}
	}
	cout << "YES" << endl;

	return (0);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MAX 100000
typedef long long ll;
typedef pair<ll,ll> P;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/

int main(){
    int N,d[60];
    ll ans=0;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>d[i];
    }
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            ans+=d[i]*d[j];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int N;
    string S;
    cin >> N >> S;
    int a[N];
    rep(i, N) {
        a[i] = 0;
    }

    for(int i = 1; i < N; i++) {
        if(S[i] == 'E') {
            a[0]++;
        }
    }

    for(int i = 1; i < N; i++) {
        if(S[i-1] == 'W' && S[i] == 'W') {
            a[i] = a[i-1] + 1; 
        }
        else if(S[i-1] == 'E' && S[i] == 'E') {
            a[i] = a[i-1] - 1;
        }
        else {
            a[i] = a[i-1];
        }
    }

    sort(a, a+N);

    cout << a[0];

    cout << endl;
    return 0;
}

Measured memory_bytes: 1796
s = input()
t = input()
len_s = len(s)
len_t = len(t)
dp = [[0]*(len_t+1) for _ in range(len_s+1)]
# dp[i][j]はi、j文字目までのs[i],t[j]で、最長の部分列の長さ
for i in range(len_s):
    for j in range(len_t):
        if s[i] == t[j]:
            dp[i+1][j+1] = max(dp[i][j]+1, dp[i+1][j], dp[i][j+1])

        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j], dp[i][j+1])
#print(dp)
ans = ""
while len_t > 0 and len_s > 0:
    if dp[len_s][len_t] == dp[len_s-1][len_t]:
        len_s -= 1
    elif dp[len_s][len_t] == dp[len_s][len_t-1]:
        len_t -= 1
    else:
        ans += s[len_s-1]
        len_s -= 1
        len_t -= 1
print(ans[::-1])

Measured memory_bytes: 112988
import java.util.Scanner;

class Main {
  public static void main(String args[]){

    Scanner sc = new Scanner(System.in);

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

    if(a-c <= d && a-c >= -d){
      System.out.println("Yes");
    }else if(a-b <= d && a-b >= -d){
      if (b-c <= d && b-c >= -d) {
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }else{
      System.out.println("No");
    }
    return;

  }
}


Measured memory_bytes: 20820
#include<bits/stdc++.h>
using namespace std;
namespace comp {
    struct istream {
        template <typename T> inline const istream& operator>>(T &_a) const {
            T x = 0, f = 1;
            char c = getchar();
            while (c < '0' || c > '9' ) {
                if (c == '-') f = -1;
                c = getchar();
            }
            while (c >= '0' && c <= '9') {
                x = x*10+c-'0';
                c = getchar();
            }
            _a = x*f;
            return *this;
        }
    };
}
int main() {
    comp::istream cin;
    int N, M;
    cin >> N >> M;
    vector<pair<pair<int, int>, int> > edges(M);
    for (int i = 0; i < M; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        edges[i] = make_pair(make_pair(a, b), c);
    }
    vector<long long> dist(N+1, INT64_MIN);
    dist[1] = 0;
    for (int i = 0; i < N-1; i++) {
        for (auto &edge : edges) {
            if (dist[edge.first.first] == INT64_MIN) continue;
            if (dist[edge.first.second] < dist[edge.first.first] + edge.second) {
                dist[edge.first.second] = dist[edge.first.first] + edge.second;
            }
        }
    }
    vector<bool> inf(N+1, false);
    for (int i = 0; i < N; i++) {
        for (auto &edge : edges) {
            if (dist[edge.first.first] == INT64_MIN) continue;
            inf[edge.first.second] = inf[edge.first.first];
            if (dist[edge.first.second] < dist[edge.first.first] + edge.second) {
                dist[edge.first.second] = dist[edge.first.first] + edge.second;
                inf[edge.first.second] = true;
            }
        }
    }
    if (inf[N]) puts("inf");
    else printf("%lld\n", dist[N]);
    return 0;
}


Measured memory_bytes: 256
N = int(input())
# N, K = map(int, input().split())
# c = list(map(int, input().split()))
# d = [list(map(int, input().split())) for _ in range(N)]
# s = input()


ans = "Yes"

if N < 4:
    ans = "No"
elif 5<=N<=6:
    ans = "No"
elif 9<=N<=10:
    ans = "No"
elif 13<=N<=14:
    ans = "No"
elif 17==N:
    ans = "No"



print(ans)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<string>
using namespace std;

long long a[510][510];
long long c, res, tot;
long long n, m, h, w;
int i, j;

int main()
{
	scanf("%lld%lld%lld%lld", &n, &m, &h, &w);

	for (i = h; i <= n; i += h)
		for (j = w; j <= m; j += w) tot++;
	
	if (n * m - h * w * tot > 0)
		c = tot / (n * m - h * w * tot) + 1;
	else c = 1;
	
	for (i = 1; i <= n; i++)
		for (j = 1; j <= m; j++) a[i][j] = c;
	
	res = c * (long long)n * (long long)m;
	
	for (i = h; i <= n; i += h)
		for (j = w; j <= m; j += w)
		{
			res -= c;
			a[i][j] = - (h * w - 1) * c - 1;
			res += - (h * w - 1) * c - 1;
		}
	
	if (res > 0)
	{
		puts("Yes");
		for (i = 1; i <= n; i++)
		{
			for (j = 1; j <= m; j++)
			{
				printf("%d ", (int)a[i][j]);
			}
			puts("");
		}
	}
	else puts("No");
	return 0;
}

Measured memory_bytes: 3328
program main
  implicit none

  character(len=100) :: s
  character(len=7) :: c
  integer :: n

  read(*,*) s

  n = len_trim(s)
  c = 'keyence'

  if(index(s,c) /= 0) then
     if (index(s,c) == 1 .or. index(s,c, back=.true.) == n-6) then
        write(*,*) 'YES'
     else
        write(*,*) 'NO'
     end if
     stop
  else
     if(index(s,c(1:1)) /= 0) then
        if(index(s,c(2:7)) /= 0) then
           if(index(s,c(1:1)) == 1 .and. index(s,c(2:7), back=.true.) == n-5) then
              write(*,*) 'YES'
              stop
           end if
        else
           if(index(s,c(1:2)) /= 0) then
              if(index(s,c(3:7)) /= 0) then
                 if(index(s,c(1:2)) == 1 .and. index(s,c(3:7), back=.true.) == n-4) then
                    write(*,*) 'YES'
                    stop
                 end if
              else
                 if(index(s,c(1:3)) /= 0) then
                    if(index(s,c(4:7)) /= 0) then
                       if(index(s,c(1:3)) == 1 .and. index(s,c(4:7), back=.true.) == n-3) then
                          write(*,*) 'YES'
                          stop
                       end if
                    else
                       if(index(s,c(1:4)) /= 0) then
                          if(index(s,c(5:7)) /= 0) then
                             if(index(s,c(1:4)) == 1 .and. index(s,c(5:7), back=.true.) == n-2) then
                                write(*,*) 'YES'
                                stop
                             end if
                          else
                             if(index(s,c(1:5)) /= 0) then
                                if(index(s,c(6:7)) /= 0) then
                                   if(index(s,c(1:5)) == 1 .and. index(s,c(6:7), back=.true.) == n-1) then
                                      write(*,*) 'YES'
                                      stop
                                   end if
                                else
                                   if(index(s,c(1:6)) /= 0) then
                                      if(index(s,c(7:7)) /= 0) then
                                         if(index(s,c(1:6)) == 1 .and. index(s,c(7:7), back=.true.) == n) then
                                            write(*,*) 'YES'
                                            stop
                                         end if
                                      else
                                         
                                      end if
                                   end if                     
                                end if
                             end if
                          end if
                       end if
                    end if
                 end if
              end if
           end if
        end if
     end if
     write(*,*) 'NO'
  end if
end program main


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<char,char> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const LL INF=1<<17;



int main(){
    int n,q;cin >> n >> q;
    string s;
    cin >> s;
    vector<P> v;
    for (int i = 0; i < q; i++) {
        char x,y;cin >> x >> y;
        v.pb({x,y});
    }
    int k=0,z=0;
    int l=0,r=n-1;
    for (int i = q-1; i >=0; i--) {
        if(v[i].sc=='L'){
            if(v[i].fs==s[l]) l++;
            if(v[i].fs==s[min(n-1,r+1)]) r=min(r+1,n-1);
        }
        else{
            if(v[i].fs==s[r]) r--;
            if(v[i].fs==s[max(0,l-1)]) l=max(0,l-1);
        }
    }
    cout << n-(l+(n-1-r)) << endl;
    return 0;
}


Measured memory_bytes: 1024
#define NDEBUG

#include <cassert>
#include <cstddef>
#include <vector>

template <class Monoid> class dual_segment_tree {
  using size_t = std::size_t;
  using T = typename Monoid::value_type;

public:
  using value_type = T;
  using size_type = size_t;

private:
  static size_t lsb(const size_t x) { return __builtin_ctz(x); }
  static size_t msb(const size_t x) { return 31 - __builtin_clz(x); }
  static void add(T &x, const T y) { x = Monoid::operation(x, y); }

  std::vector<T> tree;

  void push(const size_t index) {
    add(tree[index * 2], tree[index]);
    add(tree[index * 2 + 1], tree[index]);
    tree[index] = Monoid::identity;
  }
  void propagate(const size_t index) {
    if (index == 0)
      return;
    const size_t lsb_ = lsb(index);
    for (size_t h = msb(index); h != lsb_; h -= 1)
      push(index >> h);
  }

public:
  dual_segment_tree() = default;
  explicit dual_segment_tree(const size_t n) : tree(n * 2, Monoid::identity) {}

  size_t size() const noexcept { return tree.size() / 2; }

  T fold(size_t index) const {
    assert(index < size());
    index += size();
    T ret = tree[index];
    while (index != 1) {
      index /= 2;
      add(ret, tree[index]);
    }
    return ret;
  }

  void update(size_t first, size_t last, const T x) {
    assert(first <= last);
    assert(last <= size());
    first += size();
    last += size();
    propagate(first);
    propagate(last);
    while (first != last) {
      if (first % 2 != 0) {
        add(tree[first], x);
        first += 1;
      }
      first /= 2;
      if (last % 2 != 0) {
        last -= 1;
        add(tree[last], x);
      }
      last /= 2;
    }
  }
};

#include <utility>

template <class T> class assign_monoid {
public:
  using value_type = std::pair<T, bool>;

  static constexpr value_type operation(const value_type &x,
                                        const value_type &y) noexcept {
    return y.second ? y : x;
  }
  static constexpr value_type identity = {T{}, false};
};
template <class T>
constexpr typename assign_monoid<T>::value_type assign_monoid<T>::identity;

#include <cstdio>

int scan() {
  int r = 0;
  int c;
  while ((c = getchar_unlocked() - '0') >= 0)
    r = r * 10 + c;
  return r;
}

int main() {
  const int n = scan();
  const int q = scan();

  dual_segment_tree<assign_monoid<int>> dst(n);
  dst.update(0, n, {2147483647, true});

  for (int k = 0; k != q; k += 1) {
    if (scan() == 0) {
      const int s = scan();
      const int t = scan() + 1;
      const int x = scan();
      dst.update(s, t, {x, true});
    } else {
      const int i = scan();
      printf("%d\n", dst.fold(i).first);
    }
  }
}



Measured memory_bytes: 3864
from collections import Counter

n=int(input())
a=list(map(int,input().split()))

l1=[i+a[i] for i in range(n)]
l2=[i-a[i] for i in range(n)]

c1=Counter(l1)
c2=Counter(l2)

ans=0
for i in c1:
  ans+=c1[i]*c2[i]

print(ans)

Measured memory_bytes: 63280
#include<bits/stdc++.h>
using namespace std;
long long a,b;
int f[1000005];
int k[100005];
int main()
{
	cin>>a>>b;
	int cnt=0;
	for(int i=2;i<=1000000;++i)
	{
		if(f[i]) continue;
		k[++cnt]=i;
	    for(int j=i+i;j<=1000000;j+=i)
	       f[j]=1;
	}
	long long gcd=__gcd(a,b);
	//cout<<gcd<<endl;
	long long ans=1;
	for(int i=1;i<=cnt;++i)
	{
		if(!(gcd%k[i])) ++ans;
		while(!(gcd%k[i])) gcd/=k[i];
	}
    if(gcd!=1) ++ans;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7836
/*
Problem: Distance Sums (AtCoder 4434)
Algorithm: Math??Graph??
Status:
*/

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <deque>
#include <set>
#include <sstream>
#include <utility>
#include <list>
#include <ctime>
#include <memory.h>
#include <stack>
#include <stdio.h>
#include <string.h>

using namespace std;

#define INF 1000000007
typedef long long ll;

int n;
map<ll,int> d;
vector<pair<ll,int> > ev;
vector<pair<int,int> > ans;
ll dp[100005],sz[100005];

void bye(){
	cout<<-1<<endl;
	exit(0);
}

int main()
{
	#ifndef ZZZYT
		//freopen(".in","r",stdin);
		//freopen(".out","w",stdout);
	#endif
	
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		ll tmp;
		scanf("%lld",&tmp);
		ev.push_back(make_pair(tmp,i));
		d[tmp]=i;
	}
	sort(ev.rbegin(),ev.rend());
	ll center=ev.back().first;
	for(int i=0;i<n;i++)sz[i]=1;
	for(int i=0;i<ev.size();i++){
		int x=ev[i].second;
		ll s=ev[i].first;
		if(s!=center){
			if(sz[x]*2>=n)bye();
			ll ps=s+sz[x]-(n-sz[x]);
			if(d.count(ps)==0)bye();
			int p=d[ps];
			sz[p]+=sz[x];
			dp[p]+=dp[x]+sz[x];
			ans.push_back(make_pair(x,p));
		}
	}
	if(dp[ev.back().second]!=center)bye();
	for(int i=0;i<ans.size();i++){
		printf("%d %d\n",ans[i].first+1,ans[i].second+1);
	}
	return 0;
}


Measured memory_bytes: 12528