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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n, k, a[202020];
void solve(){
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	i64 ans = 0, cnt = 0;
	for(int i = 0; i < k; i++){
		cnt += a[i]+1;
	}
	chmax(ans, cnt);
	for(int i = k; i < n; i++){
		cnt += a[i] - a[i-k];
		chmax(ans, cnt);
	}
	printf("%.10f\n", ans/2.0);
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/pypy
N=int(raw_input())
xn=[]
for i in range(N):
    xn.append(map(int, raw_input().split()))

S = 0
for i in range(N):
    for j in range(N):
        S += pow( \
               pow(xn[i][0] - xn[j][0], 2) + \
               pow(xn[i][1] - xn[j][1], 2) , \
               0.5 \
             )

print str(S / N)

Measured memory_bytes: 28012
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main(void){
    double x1,x2,y1,y2;
    cin >> x1 >>y1;
    cin >> x2 >>y2;
    double d =pow(x1-x2,2)+ pow(y1-y2,2);
    cout << fixed << setprecision(5) << sqrt(d);
    cout << endl;
   
}



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

const int size = 2*123456+1;
bool p[size];
int dp[size];

int main() {
    memset( p, false, sizeof(p) );
    for ( int i = 3; i <= size; i += 2 ) {
        p[i] = true;
    }
    dp[0] = 0;
    dp[1] = 0;
    dp[2] = 1;
    for ( int i = 3; i <= size; i++ ) {
        dp[i] = dp[i-1];
        if ( !p[i] ) continue;
        dp[i]++;
        for ( int j = i+i; j <= size; j += i ) {
            p[j] = false;
        }
    }

    int n;
    while ( cin >> n && n ) {
        cout << dp[2*n] - dp[n] << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int sx,sy,tx,ty; cin>>sx>>sy>>tx>>ty;

    string ans;
    rep(i,0,tx-sx) ans+="R";
    rep(i,0,ty-sy) ans+="U";
    rep(i,0,tx-sx) ans+="L";
    rep(i,0,ty-sy) ans+="D";

    ans+="D";
    rep(i,0,tx-sx+1) ans+="R";
    rep(i,0,ty-sy+1) ans+="U";
    ans+="LU";
    rep(i,0,tx-sx+1) ans+="L";
    rep(i,0,ty-sy+1) ans+="D";
    ans+="R";

    cout<<ans<<endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

// utils
func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func max(a, b int) int {
	return int(math.Max(float64(a), float64(b)))
}

func min(a, b int) int {
	return int(math.Min(float64(a), float64(b)))
}

func abs(a, b int) int {
	return int(math.Abs(float64(a) - float64(b)))
}

//data types

type set map[int]struct{}

type pair struct {
	first  int
	second int
}

func main() {
	sc.Split(bufio.ScanWords)
	s := next()

	for i := 0; i < len(s); i++ {
		fmt.Print("x")
	}
}


Measured memory_bytes: 640
#include<stdio.h>

int main(void){
	int n;
	int i;
	int j;
	int min;
	int a[150];
	int b[300]={0};
	scanf("%d",&n);
	for(i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	for(i=-100;i<101;i++){
		for(j=0;j<n;j++){
			b[i+100]+=(a[j]-i)*(a[j]-i);
		}
	}
	min=b[0];
	for(i=0;i<201;i++){
		if(min>b[i]){
			min=b[i];
		}else{}
	}
	printf("%d",min);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <queue>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    int bits = 0;
    for (int i = 0; i < n; i++) {
        int input;
        cin >> input;
        bits <<= 1;
        bits |= input;
    }
    int goal[2] = {0, 0};
    int seq;
    for (int i = 0; i < m; i++) {
        cin >> seq;
        for (int j = 0; j < seq; j++) {
            goal[0] <<= 1;
            goal[0] |= i % 2;
        }
    }
    int range = (1 << n) - 1;
    goal[1] = ~goal[0] & range;
    int mask = 0b11;
    int dp[65536];
    fill_n((int *)dp, 65535, -2);
    dp[bits] = 0;
    dp[goal[0]] = dp[goal[1]] = -1;
    if (bits == goal[0] || bits == goal[1]) {
        cout << 0 << endl;
        exit(0);
    }
    queue<int> que;
    que.push(bits);
    while(!que.empty()){
        int p = que.front(); que.pop();
        for (int i = 0; i < n-1; i++) {
            if ((~p & (mask << i)) == 0 || (p & (mask << i)) == 0) continue;
            int swaped = (~p & (mask << i)) | (p & ~(mask << i));
            if (dp[swaped] == -1) {
                cout << dp[p] + 1 << endl;
                goto end;
            }
            if (dp[swaped] != -2) continue;
            que.push(swaped);
            dp[swaped] = dp[p] + 1;
        }
    }
    cout << 0 << endl;
    end:
    return 0;
}

Measured memory_bytes: 3424
#include <iostream>

using namespace std;

int main(){
  int a,b,c,ans=0;
  cin >> a >> b >> c;
  for(int i = a; i <=  b; i++){
    if(c >= i){
      if(c % i == 0) ans ++;
    }
  }
  cout << ans << endl;
  return 0;
}



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

int main(){
    int n;
    cin>>n;
    int i;

    int mia=1000000000;
    int maa=0;
    int mib=1000000000;
    int mab=0;
    

    vector<P> v;
    for(i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        mia=min(mia,x);
        maa=max(maa,x);
        mib=min(mib,y);
        mab=max(mab,y);

        v.push_back(P(x,i));
        v.push_back(P(y,i));
    }

    sort(v.begin(),v.end());

    bool f[n];
    for(i=0;i<n;i++) f[i]=0;

    for(i=0;i<n;i++){
        f[v[i].second]=1;
    }

    bool flag=1;
    for(i=0;i<n;i++){
        flag=flag&f[i];
    }

    ll ans=0;

    int plus;

    for(i=0;i<n;i++) ans+=v[i].first;

    if(flag==0||maa<=mib||mab<=mia) {
        cout<<ans<<endl;
        return 0;
    }
    else if(v[n-1].second!=v[n].second) {
        cout<<ans+v[n].first-v[n-1].first<<endl;
        return 0;
    }
    else {
        plus=v[n].first-v[n-2].first;
        plus=min(plus,v[n+1].first-v[n-1].first);
        cout<<ans+plus<<endl;
        return 0;
    }

}


Measured memory_bytes: 2420
import sys
x = []
for line in sys.stdin:
    h,w = line.split()
    h,w = int(h), int(w)
    if h == 0 and w== 0: break
    s1 = ('.#' * ((w+1)/2))[:w]
    s2 = ('#.' * ((w+1)/2))[:w]
    for j in range(h):
        if (j & 1)==0: print s2
        else: print s1
    print
    

Measured memory_bytes: 4228
S = input()
if S == 'SUN':
  print(7)
elif S == 'MON':
  print(6)
elif S == 'TUE':
  print(5)
elif S == 'WED':
  print(4)
elif S == 'THU':
  print(3)
elif S == 'FRI':
  print(2)
else:
  print(1)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double flt;
typedef pair<int, int> PII;
const int MAXN = 100000 + 10;

vector<flt> p, dp;
int n;

int main() {
  while (scanf("%d", &n) == 1 && n) {
    flt sum = 0; p.clear();
    for (int i = 0; i < n; ++ i) {
      flt x; scanf("%lf", &x);
      if (x == 1.00) sum += 1.0;
      else {
        if (sum > 0) p.push_back(sum), sum = 0;
        p.push_back(x);
      }
    }
    if (sum > 0) p.push_back(sum);
    n = p.size();
    dp.resize(n + 1); dp[n] = 0;
    for (int i = n - 1; i >= 0; -- i) {
      flt now = 0; dp[i] = 1e9;
      for (int j = i + 1; j <= n && j - i <= 50; ++ j) {
        if (p[j - 1] < 1.0) now = (now + 1.0) / p[j - 1];
        else now += p[j - 1];
        dp[i] = min(dp[i], now + dp[j] + 1);
      }
    }
    printf("%.10f\n", dp[0] - 1);
  }
  return 0;
}

Measured memory_bytes: 3464
from itertools import permutations

def chk(a,b):
    A,B=len(a),len(b)
    rt=[0]*A
    for i in range(A):
        f=1
        for j in range(min(A-i,B)):
            if a[i+j]!=b[j] and a[i+j]!='?' and b[j]!='?':
                f=0;break
        rt[i]=f
    return rt+[1]

def tri_chk(ix):
    i1,i2,i3=ix
    a,b,c=[S[i] for i in ix]
    ab,bc,ac=M[i1][i2],M[i2][i3],M[i1][i3]
    A,B,C=map(len,(a,b,c))
    rt=A+B+C
    for l in range(A+1):
        if ab[l]==0:
            continue
        for r in range(l,A+B+1):
            if (B<r-l or bc[r-l]==1) and ac[min(A,r)]==1:
                alt=max(A,l+B,r+C)
                if alt<rt:
                    rt=alt
    return rt

S=[input()for i in'abc']
A,B,C=map(len,S)
L=10**5
M=[[chk(S[i],S[j]) if i!=j else []for j in range(3)]for i in range(3)]

for i in permutations(range(3)):
    L=min(L,tri_chk(i))

print(L)

Measured memory_bytes: 51804
//created by missever

#include<bits/stdc++.h>
#define MAX 1000000007
using namespace std;
typedef long long LL;

const int maxn = 1e5 + 5;
int r,c;
struct node {
    int x,y;
    node(int _x = 0,int _y = 0):x(_x),y(_y) {};
} f[maxn];

bool judge(int x,int y){
    if(x == 0 || x == r) return true;
    if(y == 0 || y == c) return true;
    return false;
}

int ff(int x,int y){
    if(y == 0) return x;
    if(x == r) return y + r;
    if(y == c) return r + c + r - x;
    if(x == 0) return r + c + r + c - y;
}

bool cmp(const node &a,const node &b){
    return a.x < b.x;
}

stack<int> q;

int main() {
    int n,m,i;
    int x1,y1,x2,y2;
    m = 0;
    scanf("%d%d%d",&r,&c,&n);
    for(i = 0;i < n; i++){
        scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
        if(judge(x1,y1) && judge(x2,y2)){
            x1 = ff(x1,y1);
            x2 = ff(x2,y2);
            if(x1 > x2) swap(x1,x2);
            f[m++] = node(x1,x2);
        }
    }
    sort(f,f + m,cmp);
    for(i = 0;i < m; i++){
        while(!q.empty() && q.top() < f[i].x) q.pop();
        if(!q.empty() && q.top() < f[i].y){
            puts("NO");
            return 0;
        }
        q.push(f[i].y);
    }
    puts("YES");
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i =(b)-1;i>=(a);--i)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
typedef vector<int> vi;
const int mod = 1e9 + 7;
const int maxn = 2e6 + 10; 
vi edge[maxn];
int f[maxn];
queue<int> qs;
int main(){
	int n,m;
	cin >> n >> m;
	rep(i,0,m){
		int u,v;
		cin >> u >> v;
		edge[u].pb(v);
		edge[v].pb(u);
	}
	f[1] = -1;
	qs.push(1);
	while(!qs.empty()){
		int p = qs.front();
		qs.pop();
		for(auto it:edge[p]){
			if(!f[it]){
				f[it] = p;
				qs.push(it);
			}
		}
	}
	rep(i,2,n+1){
		if(!f[i]){
			cout << "No";
			return 0;
		}
	}
	cout << "Yes\n";
	rep(i,2,n+1)cout << f[i] << '\n';
	return 0;
}


Measured memory_bytes: 54880
#include <iostream>
#include <vector>
 
int main(){
  std::string s;
  std::cin >> s;
  unsigned len = s.size();
  unsigned num[len];
  
  for(int i=0; i<len;i++)
    num[i] = s[i]-'0';
  
  unsigned min=999;
  for(int i=0; i<len-2;i++){
    unsigned tmp = num[i]*100 +num[i+1]*10 + num[i+2];
    int diff = tmp-753; if(diff<0) diff*=-1;
    if(diff<min)
      min=diff;
  }
  std::cout << min << std::endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int main(){
	double a, b, x;
	cin >> a >> b >> x;
	if(x * 2 >= a * a * b){
		b -= x / (a * a);
		printf("%.10f\n", atan2(2 * b, a) * 180 / M_PI);
	}else{
		x /= a;
		double c = x * 2 / b;
		printf("%.10f\n", atan2(b, c) * 180 / M_PI);
	}
	return 0;
}


Measured memory_bytes: 384
//Bismillahir Rahmanir Rahim 
#include<bits/stdc++.h>

using namespace std;

#define ll long long 
#define gcd(a,b) __gcd(a,b)
#define endl '\n'
const int N=2e5+10;
const int inf=1e9;
const int mod=1e9+7;

int  main(int argc, char const *argv[])
{
	#ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);

	int n;
	cin >> n;

	string s;
	cin >> s;

	map<char, ll>m;

	for(int i=0; i<n; i++)
	{
		m[s[i]]++;
	}

	ll ans=m['R']*m['G']*m['B'];

	for(int i=0; i<n; i++)
	{
		for(int j=0; j<n; j++)
		{
			if(j-i<0 || i+j>=n)
				continue;
			if(s[j-i]!=s[j] && s[j-i]!=s[i+j] && s[j]!=s[i+j])
				ans--;
			/*if(i-j<0 || i+j>=n)
				continue;
			if(s[i-j]!=s[i] && s[i]!=s[i+j] && s[i-j]!=s[i+j])
			{
				cout << i << " " << j << endl;//i-j==0
				ans--;
			}*/
		}
	}
 
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3636
import java.util.*;
public 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();
  	int f=0;
  	while(f==0){
  		c-=b;
  		if(c<=0){
  			System.out.print("Yes");
  			break;
  		}
  		a-=d;
  		if(a<=0){
  			System.out.print("No");
  			break;
  		}
  	}
  }
}

Measured memory_bytes: 35776
n=int(input())
S=[]
for i in range(n):
  s=input()
  S.append(s)
flg=True
for i in range(1,n):
  if S[i][0]!=S[i-1][-1]:
    print('No')
    exit()

if len(set(S))!=n:
  print('No')
else: print('Yes')


Measured memory_bytes: 38256
a,b,c = map(int, input().split(' '))
k = int(input())
 
for _ in range(k):
    if a >= b:
        b *= 2
    elif b >= c:
        c *= 2
    else:
        break

if a<b and b<c:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9184
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
using namespace std;
using ll = long long;
const ll mod =  1000000007;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (int i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

signed main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int ans = 1;
  int mc;
  cin >> mc;
  REP_FROM(i, 1, n) {
    int c;
    cin >> c;
    if(c >= mc) {
      ans++;
      mc = c;
    }
  }
  cout << ans <<endl;
}


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

int main() {
  int N;
  int L[10];
  cin >> N;
  int longestLineIndex = 0;
  int longestLineLength = 1;
  for (int i = 0; i < N; i++) {
    cin >> L[i];
    if (L[i] > longestLineLength) {
      longestLineLength = L[i];
      longestLineIndex = i;
    }
  }

  int otherLineLength = 0;
  for (int i = 0; i < N; i++) {
    if (i != longestLineIndex) {
      otherLineLength += L[i];
    }
  }
  
  if (longestLineLength < otherLineLength) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pII;
#define pb push_back
#define mp make_pair
#define clr(x,y) memset(x,y,sizeof(x))
const int inf=0x3f3f3f3f;
const ll mod=1e9+7;
const int maxn=1e6+5;
//ll fmod(ll x,ll y){ll res=1;while(y){if(y&1)res=res*x%mod;y>>=1;x=x*x%mod;}return res;}
//ll gcd(ll x,ll y){return y==0?x:gcd(y,x%y);}
char s[5][5];
int main()
{
   for(int i = 0; i < 3; ++i)
    scanf("%s",s[i]);
    printf("%c%c%c\n",s[0][0],s[1][1],s[2][2]);
}
















Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()

int main()
{   SPEED;
	ll n;
	cin>>n;
	vector<ll> v;
	for(ll i=1;i*i<=n;i++)
	{
		if(n%i==0)
		{
			v.pb(i);
			v.pb(n/i);
		}

	}
	sort(all(v));
	

   auto it=v.begin()- 1+ (v.size() / 2);
   if(v.size() %2 == 0)
   {
     cout<<*it - 1  +(*(it+1) -1)<<endl; 
   }
   else
   {
       cout<< 2*(*it-1)<<endl; 
   }


	
    
return 0;
}

Measured memory_bytes: 384
import sys
from collections import defaultdict
import numpy as np


def prepare(n, MOD):
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
    return factorials, invs


MOD = 10 ** 9 + 7
n = int(sys.stdin.buffer.readline())
ab = list(map(int, sys.stdin.buffer.read().split()))
aaa = ab[0::2]
bbb = ab[1::2]
max_a = max(aaa)
max_b = max(bbb)
facts, invs = prepare(2 * (max_a + max_b), MOD)
dp_size = max_b * 2 + 1
ans = 0

dd_create_func = lambda: np.zeros(dp_size, dtype=np.int64)
put_ab = defaultdict(dd_create_func)
get_ab = defaultdict(dd_create_func)
for a, b in zip(aaa, bbb):
    put_ab[-a][-b + max_b] += 1
    get_ab[a][b + max_b] += 1
    ans = (ans - facts[2 * (a + b)] * invs[2 * a] * invs[2 * b]) % MOD

dp = np.zeros(dp_size, dtype=np.int64)
for i in range(-max_a, max_a + 1):
    if i < 0 and i in put_ab:
        dp += put_ab[i]
    dp = np.add.accumulate(dp) % MOD
    if i > 0 and i in get_ab:
        ans = (ans + (dp * get_ab[i]).sum()) % MOD

print(ans * invs[2] % MOD)


Measured memory_bytes: 149584
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

//#define int ll

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



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, h[N], m, ans;
vi g[N];
main() {
  file("threesum");
  ios;
  cin >> n >> m;
  fo(i, 1, n, 1) cin >> h[i];
  fo(i, 1, m, 1) {
    int u, v;
    cin >> u >> v;
    g[u].eb(v);
    g[v].eb(u);
  }
  fo(i, 1, n, 1){
    bool flag = 1;
    for (int j : g[i]) flag &= (h[j] < h[i]);
    ans += (int)flag;
  }
  cout << ans;
  return 0;
}
/**

*/


Measured memory_bytes: 11512
s=input()
times=int(input())
for _ in range(times):
    order=input().split()
    a=int(order[1])
    b=int(order[2])
    if order[0]=="print":
        print(s[a:b+1])
    elif order[0]=="reverse":
        s=s[:a]+s[a:b+1][::-1]+s[b+1:]
    else :
        s=s[:a]+order[3]+s[b+1:]
    


Measured memory_bytes: 5608
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        boolean judge = true;
        
        if(S.length()%2 == 1){
            judge = false;
        }
        
        else{
        for(int i =0; i<S.length(); i=i+2){
            if(S.charAt(i) == 'h' && S.charAt(i+1) == 'i'){
                continue;
            }
            
            else{
                judge = false;
                break;
            }
        }
        }
        
        if(judge == true){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
        
    }
}

Measured memory_bytes: 22996
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin>>a>>b;
    if(a>b){
        cout<<'a'<<' '<<'>'<<' '<<'b'<<endl;
    }
    else if(a<b){
        cout<<'a'<<' '<<'<'<<' '<<'b'<<endl;
    }
    else{
        cout<<'a'<<' '<<"=="<<' '<<'b'<<endl;
    }
}



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

 int main(){
    string s;
    int maru=0,bou=0;
    cin >> s;
    for(int i=0;i<s.size();i++){
       if(s.at(i)=='0'){
          maru++;
       }
       if(s.at(i)=='1'){
          bou++;
       }
    }
    cout << min(maru,bou)*2 << endl;
 }

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct edge{
  ll from,to,dis;
};
bool cmp(const edge& a,const edge& b){
  return a.dis<b.dis;
}
ll par[200010];
ll len[200010];
void init(ll n){
  for(ll i=0;i<n;i++){
    par[i]=i;
    len[i]=0;
  }
}
ll root(ll n){
  if(par[n]==n)return n;
  return par[n]=root(par[n]);
}
void unit(ll a,ll b){
  a=root(a);
  b=root(b);
  if(a==b)return;
  if(len[a]<len[b]){
    par[a]=b;
  }
  else{
    par[b]=a;
    if(len[a]==len[b])len[a]++;
  }
}
int main(){
  ll n,m,k;cin>>n>>m>>k;
  ll c[n];
  ll now=1;
  for(int i=0;i<n;i++){
    cin>>c[i];
    if(c[i]==0){
      c[i]=now+100000;
      now++;
    }
  }
  vector<edge> v;
  for(int i=0;i<m;i++){
    ll a,b,w;cin>>a>>b>>w;
    a--;b--;
    edge e={a,b,w};
    v.push_back(e);
  }
  sort(v.begin(),v.end(),cmp);
  init(200001);
  ll ans=0;
  ll cnt=0;
  for(int i=0;i<m;i++){
    edge e=v[i];
    ll f=e.from,t=e.to,d=e.dis;
    f=c[f],t=c[t];
    if(root(f)!=root(t)){
      unit(f,t);
      ans+=d;
      cnt++;
    }
    if(cnt==k-1){
      cout<<ans<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
}

Measured memory_bytes: 7280
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;
using ll = long long;
const ll mod = (ll)1e9 + 7;

int main() {
  int n;
  cin >> n;
  cout << 1 - n << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll dd[55];

vector<vector<ll> > vv;

void dfs(ll a, ll p, ll h){
  dd[a] = 1;
  if(vv[a].sz==1&&p!=-1){
    return;
  }
  rep(i,0,vv[a].sz){
    if(vv[a][i]==p)continue;
    if(dd[vv[a][i]]==1)continue;
    dfs(vv[a][i],a,h+1);
  }
  return;
}


int main() {
  ll n,m;
  cin>>n>>m;
  vector<pair<ll,ll> > vv_;
  rep(i,0,m){
    ll a,b;
    cin>>a>>b;
    a--;b--;
    vv_.pb(mp(a,b));
  }
  ll ans = 0;
  rep(i,0,m){
    vector<vector<ll> > vv1(n,vector<ll>());
    rep(j,0,m){
      if(i==j)continue;
      ll x = vv_[j].fi;
      ll y = vv_[j].se;
      vv1[x].pb(y);
      vv1[y].pb(x);
    }
    vv = vv1;
    clr(dd,0);
    dfs(0,-1,0);
    ll c = 0;
    rep(k,0,n){
      if(dd[k]==1)c++;
    }
    if(c!=n)ans++;
  }
  cout << ans << endl;
  return 0;
}






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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 29
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}

int a,b;
int h = 100,w = 100;
char s[100][101];

int cnt_w = 0;
int cnt_b = 0;
int h_n = 1;

bool ok(int i,int j,char t){
  FOR(y,-1,2)FOR(x,-1,2){
    int nx = j + x;
    int ny = i + y;
    if(nx <0 || nx >= w || ny < 0 || ny >= h) continue;
    if(s[ny][nx] == t) return false;
  }
  return true;
}

int main(){
  cin >> a >> b;
  REP(i,50)REP(j,w) s[i][j]='#';
  FOR(i,50,h)REP(j,w) s[i][j] = '.';
  REP(i,49)REP(j,w){
    if(cnt_w == a-1) break;
    if(ok(i,j,'.')){
      s[i][j] = '.';
      cnt_w++;
    }
  }
  FOR(i,50,h)REP(j,w){
    if(cnt_b == b-1) break;
    if(ok(i,j,'#')){
      s[i][j] = '#';
      cnt_b++;
    }
  }
  cout << 100 << " " << 100 << endl;
  REP(i,h) cout << s[i] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

vector<vector<int>> G(100100, vector<int>());
vector<bool> visited(100100, false);

void dfs(int st){
	visited[st] = true;
	for(auto t:G[st]){
		if(!visited[t])dfs(t);
	}
}

int main(){
	int N, M, x, y, z;
	cin >> N >> M;
	rep(i,M){
		cin >> x >> y >> z;
		--x; --y;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	int ans = 0;
	rep(i,N){
		if(!visited[i]){
			++ans;
			dfs(i);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 11808
function Main(input) {
   var input = input.split(' ');
  
   var a = parseInt(input[0]);
   var b = parseInt(input[1]);
   var c = parseInt(input[2]);
   var d = parseInt(input[3]);
   if (a + b < d + c) {
       console.log('Right');
   } else if (a + b > d + c) {
       console.log('Left');
   } else {
       console.log('Balanced');
   }
}

 Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
 

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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for (auto& e : d) cin >> e;
  sort(begin(d), end(d));
  cout << d[n / 2] - d[n / 2 - 1] << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
vector<int> G[100000];
long ans[100000];
long DP[100000];
long buffer[100000];
long buffer2[100000];
void Calc(){
	int N = rei();
	long M = rel();
	for(int i=0;i<N-1;i++){
		int x = rei()-1;
		int y = rei()-1;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	stack<pair<int,int>> sp1;
	sp1.push({0,-1});
	while(!sp1.empty()){
		int v = sp1.top().first;
		int f = sp1.top().second;
		sp1.pop();
		if(v >= N){
			v -= N;
			long c = 1;
			for(int t:G[v]){
				if(t != f){
					c *= (DP[t]+1);
					c %= M;
				}
			}
			DP[v] = c;
		}
		else{
			sp1.push({v+N,f});
			for(int t:G[v]){
				if(t != f){
					sp1.push({t,v});
				}
			}
		}
	}
	stack<tuple<int,int,long>> sp2;
	sp2.push(make_tuple(0,-1,1));
	while(!sp2.empty()){
		int v = get<0>(sp2.top());
		int f = get<1>(sp2.top());
		long par = get<2>(sp2.top());
		ans[v] = par * DP[v] % M;
		sp2.pop();
		int g = G[v].size();
		buffer[0] = 1;
		buffer2[g] = 1;
		for(int i=0;i<g;i++){
			int t = G[v][i];
			if(t != f){
				buffer[i+1] = buffer[i] * (DP[t] + 1) % M;
			}
			else{
				buffer[i+1] = buffer[i];
			}
		}
		for(int i=g-1;i>=0;i--){
			int t = G[v][i];
			if(t != f){
				buffer2[i] = buffer2[i+1] * (DP[t] + 1) % M;
			}
			else{
				buffer2[i] = buffer2[i+1];
			}
		}
		for(int i=0;i<g;i++){
			int t = G[v][i];
			if(t != f){
				long c = (buffer[i] * buffer2[i+1] % M * par + 1) % M; 
				sp2.push(make_tuple(t,v,c));
			}
		}
	}
	for(int i=0;i<N;i++){
		cout << ans[i] << endl;
	}
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 11596
// Prime Gap
// English only

#include <iostream>

using namespace std;

const int Size = 1299710;

int main() {
  int k;
  bool prime[Size];
  fill(prime, prime+Size, true);
  prime[0]=prime[1]=false;
  for(int i=2; i<Size; i++) {
    if(prime[i]) { // iが素数であれば
      for(int j=2; i*j<Size; j++) {
	prime[i*j] = false;
      }
    }
  }

  while(1) {
    cin>>k;
    if(k==0) {
      break;
    }

    int l=k, r=k;
    while(!prime[l]) {
      l--;
    }
    while(!prime[r]) {
      r++;
    }
    cout<<r-l<<endl;
  }
}

Measured memory_bytes: 2428
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <tuple>
#include <bitset>
#include <random>
#define REP(i,n) for(int i=0;i<n;i++)
#define INF 100000000000007
using namespace std;
using pii=pair<int,int>;

int median(int length,vector<int> a){/*中央値を返す．長さ偶数のときはその二倍*/
    sort(a.begin(),a.end());
    if(length%2==1){
        return a.at((length+1)/2-1);
    }else{
        return a.at(length/2-1)+a.at(length/2);
    }
}
int main(){
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    REP(i,n){
        cin>>a.at(i)>>b.at(i);
    }

    int left,right;
    left=median(n,a);
    right=median(n,b);

    cout<<right-left+1<<endl;
    return 0;
}

Measured memory_bytes: 5164
N=io.read("n")
M=io.read("n")
local count=0
if N==1 and M==1 then
  count=1
  elseif N==1 and M>=3 then
  count=M-2
  elseif M==1 and N>=3 then
  count=N-2
  elseif N==2 or M==2 then
  count=0
  elseif N>=3 and M>=3 then
  count=(N-2)*(M-2)
end
print(count)



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

int n, a[100005];
long long ans;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for(int i=1; i<=n; i++) cin >> a[i];

    for(int i=1; i<=n; i++) {
        ans += (a[i]/2);
        if(a[i]&1) a[i] = 1;
        else a[i] = 0;
        if(a[i]==1&&a[i+1]>=1) {
            a[i] = 0;
            a[i+1]--;
            ans++;
        }
    }
    cout << ans << '\n';

    return 0;
}


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

typedef long long ll;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define MOD 1000000007

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int n, b;
  vector<int> ans;
  cin >> n;
  int a = n % 2 == 0 ? 1 : 0;
  rep(i, 0, n) {
    cin >> b;
    if(i % 2 == a) ans.insert(ans.begin(), b);
    else ans.pb(b);
  }
  rep(i, 0, n) {
    cout << ans[i] << " ";
  }
  cout << endl;
}


Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <vector>



int t;
std::vector<int> balls(10);


int dfs(int d,int a,int b)
{
  if(d==10)
    {
      return 1;
    }

  //

  if(balls[d] > a   )
    {
      if(dfs(d+1,balls[d],b) == 1 )
        return 1;
    }

  if(balls[d] > b)
    {
      if( dfs(d+1,a,balls[d]) == 1)
        return 1;
    }

  return 0;
}

int main(int argc,char* argv[])
{
  //freopen("in.txt","r",stdin);
  std::cin>>t;
  while(t--)
    {
      for(int i = 0 ; i < 10 ; i++)
        std::cin >> balls[i];
      if(dfs(0,0,0) == 1 )
        std::cout<<"YES"<<std::endl;
      else
        std::cout<<"NO"<<std::endl;
    }
  return 0;
}

Measured memory_bytes: 1180
#include <vector>
#include <iostream>
#include <map>
using namespace std;
using ll = int64_t;

int main() {
  ll n,x,m;
  cin >> n >> x >> m;
  map<ll,ll> AM;
  vector<ll> A;
  ll sum = 0;
  bool found_cycle = false;
  while(n>0) {
    A.push_back(x);
    sum += x;
    n--;
    if(!found_cycle) {
      if(AM.count(x) == 1) {
        ll cycle_length = A.size()-AM[x];
        ll cycle_sum = 0;
        for(ll i=A.size()-cycle_length; i<A.size(); i++) {
          cycle_sum += A[i];
        }
        //cerr << "CYCLE: A[" << A.size() << "] = A[" << AM[x] << "] = " << x << " length=" << cycle_length << " sum=" << cycle_sum << endl;

        ll amt = n/cycle_length;
        sum += amt*cycle_sum;
        n -= amt*cycle_length;
        found_cycle = true;
      } else {
        AM[x] = A.size();
      }
    }
    x = (x*x)%m;
  }
  cout << sum << endl;
}


Measured memory_bytes: 6888
def main():

    x,y = list(map(int,input().split()))

#y -= 2 or 4
    a = x
    while a >= 0:
        if 2*a+4*(x-a) == y and x-a >= 0:
            return print('Yes')
        a -= 1

    return print('No')


if __name__=='__main__':
    main()


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

// a quote from http://www.igaris.com/math/c.pdf

#define MOD (1000000000+7)

long long C[1001][1001];

long long power( long long x, int n )
{
	if( n == 0 ) {
		return 1;
	}
	if( n % 2 ) {
		return x * power( x, n - 1 ) % MOD;
	}
	else {
		return power( x * x % MOD, n / 2 );
	}
}

long long ifac( long long x )
{
	long long f = 1;
	while( x > 1 ) {
		f *= power( x, MOD - 2 );
		f %= MOD;
		x--;
	}
	return f;
}

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

	// Pascal's triangle for combination
	C[0][0] = 1;
	for( int i = 1; i < 1001; i++ ) {
		for( int j = 0; j <= i; j++ ) {
			if( j == 0 || j == i ) {
				C[i][j] = C[i - 1][0];
			}
			else {
				C[i][j] = ( C[i - 1][j - 1] + C[i - 1][j] ) % MOD;
			}
		}
	}

	long long ans = 0;
	if( k >= n ) {
		ans = 1;
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 10004
#include<stdio.h>
#include<string.h>
#include<algorithm>
using std::sort;
#define min(a,b) ((a) < (b) ? (a) : (b))


char s1[128],s2[128];
int s1len,s2len;

bool judge(void){
    int minlen=min(s1len,s2len);
    for(int i=0;i<minlen;i++)
        if(s1[i]<s2[i])
            return true;
        else if(s1[i]==s2[i])
        	continue;
        else
			return false;
    if(s1len<s2len)
    	return true;
    else
		return false;
}

bool cmp1(char a,char b){
    return a<b;
}

bool cmp2(char a,char b){
    return a>b;
}

int main(void){
    scanf("%s",s1);
    scanf("%s",s2);
    s1len=strlen(s1);
    s2len=strlen(s2);
    sort(s1,s1+s1len,cmp1);
    sort(s2,s2+s2len,cmp2);
    if(judge())
		puts("Yes");
    else
		puts("No");
    return 0;
}

Measured memory_bytes: 128
dic = {}
while True:
    try:
        num = int(raw_input())
        if not num in dic:
            dic[num] = 1
        else:
            dic[num] = dic[num] + 1
          
    except EOFError:
        max_num = 0
        index = 0
        for k, v in sorted(dic.items(), key=lambda x: x[1], reverse=True):
            if index == 0:
                max_num = v
            if max_num != v:
                break
            print k
            index += 1
        break

Measured memory_bytes: 4220
#include<iostream>
using namespace std;
int a[100005];
int swap(int a[],int n,int m)
{
	int t;
	t=a[n];
	a[n]=a[m];
	a[m]=t;
}
int main()
{
	int n,i,j;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int count=0;
	for(i=0;i<n;)
		for(j=i;j<n;j++)
			{
				if(a[j]==j+1)
					{
					swap(a,j,j+1);
					count++;
					}
				i++;
			}
	cout<<count;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N,M;
    Scd2(N,M);
    vector< int > t[N];
    int a,b;
    Rep(i,M){
        Scd2(a,b);
        t[a].push_back(b);
    }

    bool ans = 0;
    for( int i : t[1] ){
        for( int j : t[i] ){
            ans |= j==N;
        }
    }

    printf ( ans ? "POSSIBLE\n" : "IMPOSSIBLE" );

    return 0;
}



Measured memory_bytes: 8576
#include <iostream>

using namespace std;

long long int MOD = 1000000007;

long long int dp[2020][2020];

int S;

long long int C[2020][2020];

int main(void) {

	cin >> S;

	/*dp[0][0] = 1;
	for (int i = 1; i <= S/3+1; i++) {
		for(int j=0;j<=S;j++){
			for (int k = 3; k <= S; k++) {
				if (j + k > S) { break; }
				dp[i][j + k] += dp[i - 1][j];
				dp[i][j + k] %= MOD;
		  }
		}
	}

	long long int ans = 0;
	for (int i = 1; i <= S; i++) {
		ans += dp[i][S];
		ans %= MOD;
	}

	cout << ans << endl;*/

	C[0][0] = 1;

	for (int i = 1; i <= S; i++) {
		C[i][0] = 1;
		C[i][i] = 1;
	}

	for (int i = 1; i <= S; i++) {
		for (int j = 1; j <= i - 1; j++) {
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
		}
	}

	/*for (int i = 1; i <= 4; i++) {
		for (int j = 0; j <= i; j++) {
			cout << "C[" << i << "][" << j << "]= " << C[i][j] << endl;
		}
	}*/

	long long int ans = 0;

	for (int i = 1; i <= S / 3; i++) {
		ans += C[S - 3 * i + i - 1][i - 1];
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 26220
N, M, K = map(int, input().split())
times_a = list(map(int, input().split()))
times_b = list(map(int, input().split()))
read_time = 0
read_time_a = [0]
read_time_b = [0]
for i in range(N):
    read_time_a.append(read_time_a[i]+times_a[i])
for i in range(M):
    read_time_b.append(read_time_b[i]+times_b[i])

ans = 0
for a_count in range(N+1):
    if read_time_a[a_count] > K:
        continue
    a_read_time = read_time_a[a_count]
    max_b_count = 0
    r = len(read_time_b)
    # 消化時間の配列はソートされている状態だから二分探索
    # 計算量をlog(M)に削減
    while max_b_count + 1 < r:
        c = (max_b_count + r) // 2
        # bがインデックスcで時間がaの時間+bの時間でK以下ならmax_b_countを二分探索の開始位置に更新する。
        if a_read_time + read_time_b[c] <= K:
            max_b_count = c
        # 超えちゃったら二分探索の前方に探索領域の終端を絞る
        else:
            r = c
    # 積読消化時間がKより小さく、a_count + max_b_countの最大数が最大になるものをansに代入し続ける
    ans = max(ans, a_count + max_b_count)
print(ans)


Measured memory_bytes: 47308
N, K = map(int, input().split())
A = [0] + [int(a) - 1 for a in input().split()]
for i in range(1, N+1):
    A[i] = (A[i] + A[i-1]) % K

D = {0: 1}
ans = 0
for i in range(1, N+1):
    if i >= K:
        D[A[i-K]] -= 1
    a = A[i]
    if a not in D: D[a] = 0
    ans += D[a]
    D[a] += 1
print(ans)

Measured memory_bytes: 33128
#include <iostream>

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    ll n, k;
    cin >> n >> k;
    ll odp = 0;
    for (ll b = 1; b <= n; ++b)
    {
        ll c = n / b;
        ll r = n - c * b;
        if (k <= b - 1)
            odp += ((b - 1) - k + 1) * c;
        if (k <= r)
        {
            if (k != 0)
                odp += r - k + 1;
            else
                odp += r;
        }
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
using ll = long long;

const long double PI = acos(-1.0);
const int MOD = 1e9 + 7;

int main() {
    int cnt = 1;
    for(int i = 0; i < 5; i++) {
        int x;
        cin >> x;
        if(x == 0) break;
        else cnt++;
    }

    cout << cnt << endl;
    

    return 0;
}

Measured memory_bytes: 3628
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (let* ((r (read))
         (d (read))
         (x (read)))
    (dotimes (i 10)
      (setf x (- (* r x) d))
      (println x))))

#-swank(main)


;; For Test
#+swank
(defun io-equal (in-string out-string &optional (func #'main))
  (labels ((ensure-last-lf (s)
             (if (and (> (length s) 0)
                      (eql (char s (- (length s) 1)) #\Linefeed))
                 s
                 (uiop:strcat s uiop:+lf+))))
    (equal (ensure-last-lf out-string)
           (with-output-to-string (out)
             (let ((*standard-output* out))
               (with-input-from-string (*standard-input* (ensure-last-lf in-string))
                 (funcall func)))))))

#+swank
(defun get-clipbrd ()
  (with-output-to-string (out)
    (run-program "C:/msys64/usr/bin/cat.exe" '("/dev/clipboard") :output out)))

#+swank (defparameter *this-pathname* (uiop:current-lisp-file-pathname))
#+swank (defparameter *dat-pathname* (uiop:merge-pathnames* "test.dat" *this-pathname*))

#+swank
(defun run (&optional thing (out *standard-output*))
  (let ((*standard-output* out))
    (etypecase thing
      (null ; Runs #'MAIN with the string on clipboard
       (with-input-from-string (*standard-input* (delete #\Return (get-clipbrd)))
         (main)))
      (string
       (with-input-from-string (*standard-input* (delete #\Return thing))
         (main)))
      (symbol (5am:run! thing))
      (pathname ; Runs #'MAIN with the string in a text file
       (with-open-file (*standard-input* thing)
         (main))))))

#+swank
(defun gen-dat ()
  (uiop:with-output-file (out *dat-pathname* :if-exists :supersede)
    (format out "")))

#+swank
(defun bench (&optional (out (make-broadcast-stream)))
  (time (run *dat-pathname* out)))


Measured memory_bytes: 15588
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve() {
    int a, b, c; cin >> a >> b >> c;

    if((a < c && c < b) || (b < c && c < a)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

    solve();
    return 0;
}
 


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

int main(int argc, const char * argv[]) {
    int n;
    scanf("%d",&n);
    char S[n+1];
    long long R[4000],G[4000],B[4000],ir=0,ig=0,ib=0;
    scanf("%s",S);
    for(int i=0;i<n;i++){
        if(S[i]=='R'){
            R[ir]=i;
            ir++;
        }
        if(S[i]=='G'){
            G[ig]=i;
            ig++;
        }
        if(S[i]=='B'){
            B[ib]=i;
            ib++;
        }
    }
    long long ans=ir*ib*ig;
      for(int i=0;i<ir;i++){
        for(int j=0;j<ib;j++){
            if(R[i]>B[j]){
                long long distance=R[i]-B[j];
                if(R[i]+distance<n&&S[R[i]+distance]=='G'){
                    ans--;
                }
                if(B[j]-distance>=0&&S[B[j]-distance]=='G'){
                    ans--;
                }
            }else{
                long long distance=B[j]-R[i];
                if(B[j]+distance<n&&S[B[j]+distance]=='G'){
                    ans--;
                }
                if(R[i]-distance>=0&&S[R[i]-distance]=='G'){
                    ans--;
                }
            }
            if(llabs(R[i]-B[j])%2==0&&S[(R[i]+B[j])/2]=='G'){
                ans--;
            }
        }
    }
     
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 1740
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

struct Card
{
    char first;
    int second;
};

void out(std::vector<struct Card>& a, int p, int r)
{
    for(int i=p; i<r; i++){
        cout << a[i].first << " " << a[i].second << endl;;
    }
}

int partition(std::vector<struct Card>& a, int p, int r)
{
    //out(a, 0, a.size());
    int x = a[r].second;
    int i = p-1;
    for(int j=p; j<r; j++){
        if(a[j].second <= x){
            i++;
            struct Card tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }
    }
    struct Card tmp = a[i+1];
    a[i+1] = a[r];
    a[r] = tmp;
    return i+1;
}

void quicksort(std::vector<struct Card>& a, int p, int r)
{
    //out(a, 0, a.size());
    if(p >= r) return;
    int q = partition(a, p, r);
    quicksort(a, p, q-1);
    quicksort(a, q+1, r);
}

bool isStable(std::vector<struct Card>& org, std::vector<struct Card>& sorted)
{
    std::map<int, std::string> m1, m2;
    for(int i=0; i<org.size(); i++){
        m1[org[i].second] += org[i].first;
        m2[sorted[i].second] += sorted[i].first;
    }
    std::map<int, std::string>::iterator itr1 = m1.begin();
    std::map<int, std::string>::iterator itr2 = m2.begin();
    while(itr1 != m1.end()){
        if(itr1->second != itr2->second) return false;
         ++itr1; ++itr2;
    }
    return true;
}

int main()
{
    int n;
    cin >> n;
    std::vector<struct Card> a;
    for(int i=0; i<n; i++){
        struct Card card;
        cin >> card.first >> card.second;
        a.push_back(card);
    }
    std::vector<struct Card> org(a.size());
    std::copy(a.begin(), a.end(), org.begin());
    quicksort(a, 0, n-1);

    if(isStable(org, a) == true){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }
    out(a, 0, n);
}



Measured memory_bytes: 9784