akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
typedef long long ll;
#define MAX 100002
using namespace std;

int main() {
    int n, a, max_a=0;
    cin >> n;
    ll cnt[MAX]={0};
    for(int i=0; i<n; i++) {
        cin >> a;
        cnt[a]++;
        cnt[a+1]++;
        cnt[a+2]++;
        if(max_a<a) max_a = a;
    }

    ll max=0;
    for(int i=0; i<max_a+2; i++) {
        if(max<cnt[i]) max = cnt[i];
    }

    cout << max << endl;

    return 0;
}


Measured memory_bytes: 1024
n=int(input())
import math
mod=10**9+7
m=math.factorial(n)
fli=[]#素数リスト
ans=[0]*(n+1)
ans[0]=ans[1]=1
i=2
while i*i<=n:
    j=2
    while i*j<=n and ans[i]==0:
        ans[i*j]=1
        j+=1
    i+=1
for i in range(n+1):
    if ans[i]==0:
        fli.append(i)
total=1
for i in fli:
    cnt=0
    while m%i==0:
        cnt+=1
        m=m//i
    total*=(cnt+1)
print(total%mod)

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

int main()
{
	std::string s;
	std::cin >> s;

	bool flag = false;
	unsigned int count = 0;
	for (int i = 0; i < s.length(); i++)
	{
		const bool bit = (s[i] != '0');
		if (bit == flag)
		{
			count++;
		}

		flag = !flag;
	}

	count = std::min(count, (unsigned int)(s.length()) - count);
	std::cout << count << std::endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  double A,B,H,M;cin>>A>>B>>H>>M;
  printf("%.10lf\n",sqrt(A*A+B*B-2*A*B*cos((H*30-M*5.5)*acos(-1)/180)));
  return 0;
}

Measured memory_bytes: 4224
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    T = int(math.sqrt(N))
    ret = float('inf')
    for i in range(1, T+1):
        if N % i == 0:
            ret = min(ret, N//i+i-2)
    print(ret)


if __name__ == '__main__':
    main()


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll L;
ll N;
ll X[202020];
ll LL[202020];
ll RR[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>L>>N;
	for(i=1;i<=N;i++) cin>>X[i];
	
	for(i=1;i<=N;i++) {
		LL[i]=LL[i-1]+(L-X[N+1-i]);
		RR[i]=RR[i-1]+X[i];
	}
	
	ll ma=max(X[N],L-X[1]);
	for(int le=1;le<=N-1;le++) {
		int ri=N-le;
		
		ll pat=0;
		x=min(le,ri+1);
		y=x-1;
		pat=(LL[le]+LL[le-1]-2*LL[le-x]);
		pat+=2*(RR[ri]-RR[ri-y]);
		ma=max(ma,pat);

		y=min(le+1,ri);
		x=y-1;
		pat=2*(LL[le]-LL[le-x]);
		pat+=RR[ri]+RR[ri-1]-2*RR[ri-y];
		ma=max(ma,pat);
		
		x=y=min(le,ri);
		pat=2*(LL[le]-LL[le-x]);
		pat+=RR[ri]+RR[ri-1]-2*RR[ri-y];
		ma=max(ma,pat);

		pat=(LL[le]+LL[le-1]-2*LL[le-x]);
		pat+=2*(RR[ri]-RR[ri-y]);
		ma=max(ma,pat);
		
	}
	cout<<ma<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int P, Q, R;
int main() {
  cin >> P >> Q >> R;

  int ans = min(P + Q, min(Q + R, R + P));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;



int main() {
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    s = s.substr(0, s.length() - 8);
    cout << s << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int m = 0;
    for (int i = 0; i < n; i++) m = max(m, a[i]);
    int h = 0;
    for (int i = 0; i < n; i++) if (min(h,m-h) < min(a[i],m-a[i])) h = a[i];
    cout << m << " " << h << endl;
    return 0;
}


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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    ll n;
    cin >> n;

    ll s_power = 1;
    repi(i, 1, n+1){
        s_power = mul_mod(s_power, i, 1e9 + 7);
    }

    cout << s_power << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <numeric>
#include <array>
#include <queue>
#include <set>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0;i<n;i++)

int main()
{
    int N, M;
    cin >> N >> M;
    vector<ll> A;
    priority_queue<ll> queue;
    for (int i = 0; i < N; i++)
    {
        ll temp;
        cin >> temp;
        queue.push(temp);
    }

    for (int count=0; count < M; count++)
    {
        int max = queue.top();
        queue.pop();
        queue.push(max / 2);
    }

    ll sum = 0;
    while (!queue.empty())
    {
        ll temp = queue.top();
        sum += temp;
        queue.pop();
    }
    
    cout << sum << endl;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b,c,d,x;
  long long la,lb;
  double da,db;
  string s,ss,sss;
  
  int ans = 0;
  string anss = "";
  
  cin >> x >> s;
  
  int ab [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  int result3 = std::max({a, b, c});
//--------------------------------------------------------------------------------
int count = 0;
  rep(i,0,x-2){
  	if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ans++;
    
  }
  
  cout << ans << endl;

}

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

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

#define INF 100000000

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

  bool APPROVED = true;
  for(int i = 0; i < N; ++i){
    int A;
    cin >> A;
    if (A%2==0){
      if(A%3==0 || A%5==0){
      }
      else{
        APPROVED = false;
        break;
      }
    }
  }
  if(APPROVED){
    cout << "APPROVED" << endl;
  }
  else{
    cout << "DENIED" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//BIAR MANTAB LAH YA
#define Willy using
#define Indrayana namespace
#define Komara std
 
Willy Indrayana Komara;

using ll = long long;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b, c, k;
    int a2, b2, c2;
    cin >> a >> b >> c >> k;
    a2 = (a >= k ? k : a);
    k -= (a >= k ? k : a);
    if (k == 0)
    {
        cout << a2 << '\n';
        //cout << "t";
        return 0;
    }
    b2 = (b >= k ? k : b);
    k -= (b >= k ? k : b);
    if (k == 0)
    {
        cout << a2 << '\n';
        return 0;
    }
    c2 = (c >= k ? k : c);
    k -= (c >= k ? k : c);
    cout << a2 - c2 << '\n';
    
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for (ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i, r, n) for (ll i = (ll)(n - 1); i >= r; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/

int main()
{
    cin >> n;
    vi vcc(n), vss(n), vff(n), vgg(n), vans;
    vans.push_back(0);
    REP(i, n - 1)
    {
        cin >> vcc[i] >> vss[i] >> vff[i];
        sum += vcc[i];
    }
    REP(i, n)
    {
        ans = 0;
        ans += vss[i];
        FOR(j, i, n - 2)
        {
            ans += vcc[j];
            if (vss[j + 1] > ans) {
                ans = vss[j + 1];
            }
            if (vss[j + 1] < ans&&ans%vff[j + 1] != 0) {
                ll a = (ans + vff[j + 1] - 1) / vff[j + 1];
                ll b = a * vff[j + 1];
                ans = b;
            } else if (vss[j + 1] < ans&&ans%vff[j + 1] == 0) {
                ans = ans;
            }
        }
        ans += vcc[n - 2];
        if (i == n - 1) {
            cout << 0 << endl;
        } else {
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;

int d[201][201];

int main(){
    int n, m, r;
    cin >> n >> m >> r;
    vector<int> R(r);
    rep(i, r){
        cin >> R[i];
        R[i]--;
    } 

    rep(i, n){
        rep(j, n) if(i != j) d[i][j] = INF;
    }

    rep(i, m){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        d[a][b] = c;
        d[b][a] = c;
    }

    rep(k, n){
        rep(i, n){
            rep(j, n) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
    }
    
    int ans = INF;

    vector<int> per;
    rep(i, r) per.push_back(i);
    do {
        int tmp = 0;
        rep(i, per.size()-1){
            int from = R[per[i]];
            int to = R[per[i+1]];
            tmp += d[from][to];
        }
        ans = min(ans, tmp);
    } while(next_permutation(all(per)));

    cout << ans << endl;
}

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

int main(){
  long long N; cin >> N;
  long long a=N/3;
  long long b=N/5;
  long long c=N/15;
  cout << N*(N+1)/2-3*a*(a+1)/2-5*b*(b+1)/2+15*c*(c+1)/2 << endl;
}

Measured memory_bytes: 3620
fn read() -> (i32, i32) {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let vec: Vec<i32> = s
        .trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    (vec[0], vec[1])
}

fn main() {
    let (mut a, mut b) = read();
    if a == 1 {
        a = 14;
    };
    if b == 1 {
        b = 14;
    }

    match (a > b, a < b) {
        (true, false) => println!("Alice"),
        (false, true) => println!("Bob"),
        _ => println!("Draw"),
    };
}


Measured memory_bytes: 4352
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] v = new int[n];
        int[] c = new int[n];
        int ans = 0;
        for (int i = 0; i < n; i++)
            v[i] = sc.nextInt();
        for (int i = 0; i < n; i++) {
            c[i] = sc.nextInt();
            if (v[i] > c[i])
                ans += v[i] - c[i];
        }

        System.out.println(ans);
        sc.close();
    }
}

Measured memory_bytes: 21844
package main

import "fmt"

func solve() {
	var A, B, C int
	fmt.Scan(&A, &B, &C)

	if A == B && A != C && B != C {
		fmt.Println(C)
	} else if A == C && A != B && C != B {
		fmt.Println(B)
	} else {
		fmt.Println(A)
	}
}

func main() {
	solve()
}


Measured memory_bytes: 512
import math
d,g=map(int,input().split())
p=[]
p_=[]
c=[]
ans=float('inf')
for i in range(d):
    pi,ci=map(int,input().split())
    p.append(pi)
    p_.append(pi)
    c.append(ci)
for i in range(2**d):
    s_bit=[int(x) for x in list(format(i,'b'))]
    point=0
    number=0
    for j in range(len(s_bit)):
        point+=s_bit[len(s_bit)-1-j]*100*(j+1)*p[j]+s_bit[len(s_bit)-1-j]*c[j]
        number+=s_bit[len(s_bit)-1-j]*p[j]
        p_[j]=p[j]-p[j]*s_bit[len(s_bit)-1-j]
    if point>=g:
        ans=min(ans,number)
    else:
        remain=g-point
        for j in range(d):
            if 100*(j+1)*p_[j]>=remain:
                k=math.ceil(remain/(100*(j+1)))
                ans=min(ans,number+k)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int h, w, d;
struct xydata {
    int x; int y;
};

ll xyabs(xydata const &aa, xydata const &bb) {
    ll nxy = abs(aa.x-bb.x) + abs(aa.y-bb.y);
    return nxy;
}

int main() {
    cin >> h >> w >> d;
    int limit = h*w;
    vector<xydata> Zxy(limit);
    vector<ll> Zsum(limit, 0);
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            int A; cin >> A; A--;
            xydata indata; indata.x = j; indata.y = i;
            Zxy.at(A) = indata;
        }
    }

    for(int i = limit-1; i >= 0; --i) {
        if(i-d >= 0) {
            Zsum.at(i-d) = Zsum.at(i) + xyabs(Zxy.at(i), Zxy.at(i-d));
        }
    }

    int Q; cin >> Q;
    for(int i = 0; i < Q; ++i) {
        int l, r; cin >> l >> r;
        l--; r--;
        cout << Zsum.at(l) - Zsum.at(r) << endl;
    }
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && b == c && a % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }
  int ans = 0;
  while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
    int na = b / 2 + c / 2;
    int nb = c / 2 + a / 2;
    int nc = a / 2 + b / 2;
    a = na;
    b = nb;
    c = nc;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3576
N,A,B,C = map(int,input().split())
data = {
  "A":A,
  "B":B,
  "C":C
}
select = []
S = list(input() for _ in range(N))
for i in range(N):
  s = S[i]
  if data[s[0]] == data[s[1]] ==0:
    print("No")
    exit(0)
  elif data[s[0]] > data[s[1]]:
    data[s[0]] -= 1
    data[s[1]] += 1
    select.append(s[1])
  elif data[s[0]] < data[s[1]]:
    data[s[0]] += 1
    data[s[1]] -= 1
    select.append(s[0])
  elif i == N-1:
    select.append(s[0])
  elif s[0] in S[i+1]:
    data[s[0]] += 1
    data[s[1]] -= 1
    select.append(s[0])
  else:
    data[s[0]] -= 1
    data[s[1]] += 1
    select.append(s[1])
print("Yes")
for i in select:
  print(i)

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

#define all(p) p.begin(), p.end()
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define ll long long
#define llu unsigned long long
#define ld long double
#define vll vector<long long int>
#define vi vector<int>
#define pii pair <int, int>
#define pll pair <long long int, long long int>
#define vpii vector<pair<int,int> >
#define nl cout<<"\n"
#define sp cout<<" "
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)

const  int  INF = 0x7f7f7f7f;

bool dp[100005] = {0};

int  main ()
{
	ios_base::sync_with_stdio(false);
    //freopen ("input.txt", "r", stdin);
    //freopen ("output.txt", "w", stdout);
    string s;
    string t1="dream", t2="dreamer", t3="erase", t4="eraser";
    cin>>s;
    int len = s.length();
    if(len<5) {cout<<"NO\n"; return 0;}
    for(int i=0; i<5; i++) dp[i]=false;
    dp[0] = true;

    for(int i=5; i<=len; i++)
    {
        if(i>=7 && dp[i-7]==true)
        {
            int l=i-7,r=0;
            bool flag=true;
            while(r<7)
            {
                if(s[l]!=t2[r])
                {
                    flag=false;
                    break;
                }
                l++;
                r++;
            }
            if(flag) {dp[i]=true; continue;}
            else dp[i] = false;
        }

        if(i>=6 && dp[i-6]==true)
        {
            //if(i==10 || i==11) cout<<"here\n";
            int l=i-6,r=0;
            bool flag=true;
            while(r<6)
            {
                if(s[l]!=t4[r])
                {
                    flag=false;
                    break;
                }
                l++;
                r++;
            }
            if(flag) {dp[i]=true; continue;}
            else dp[i] = false;
        }

        if(i>=5 && dp[i-5]==true)
        {
            int l=i-5,r=0;
            string tmp;
            if(s[l]=='d') tmp=t1;
            else if(s[l]=='e') tmp=t3;

            bool flag=true;
            while(r<5)
            {
                if(s[l]!=tmp[r])
                {
                    flag=false;
                    break;
                }
                l++;
                r++;
            }
            if(flag) {dp[i]=true; continue;}
            else dp[i] = false;
        }
    }

    //rep(i,0,len) cout<<dp[i],sp;nl;
    if(dp[len]) cout<<"YES\n";
    else cout<<"NO\n";
    return  0;
}


Measured memory_bytes: 620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		sc.nextInt();
		sc.nextInt();
		sc.nextInt();
		int e = sc.nextInt();
		int k = sc.nextInt();
		sc.close();
		if(e-a > k) {
			System.out.println(":(");
		}else {
			System.out.println("Yay!");
		}

	}

}


Measured memory_bytes: 23252
n = int(input())
d = [list(map(int,input().split())) for _ in range(n)]

ans = [i[0] == i[1] for i in d] + [False, False]
ans2 = [sum( ans[i:i+3] ) for i in range(n)]

if max(ans2) == 3:
  print('Yes')
else:
  print('No')	

Measured memory_bytes: 62584
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


int main(){
    int L; cin >> L;
    double a = L / 3.0;
    cout << fixed << setprecision(12) << a * a * a << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define REP(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define REPS(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define RREP(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define RREPS(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define BIT(n) ((int)(1) << (n))
#define ALL(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
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 gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int n, k;
    cin >> n >> k;
    if (k > (n - 1) * (n - 2) / 2) {
        cout << -1 << endl;
    } else {
        int m = n - 1;
        std::queue<pii> qu;
        for (int i = 1; i < n; i++) {
            qu.push({(int)1, i + 1});
        }
        int now = (n - 1) * (n - 2) / 2;
        for (int i = 1; i < n; i++) {
            if (now == k) {
                break;
            }
            for (int j = i + 1; j < n; j++) {
                if (now == k) {
                    break;
                }
                qu.push({i + 1, j + 1});
                now--;
                m++;
            }
        }
        cout << m << endl;
        for (int i = 0; i < m; i++) {
            cout << qu.front().first << " " << qu.front().second << endl;
            qu.pop();
        }
    }
    return 0;
}

Measured memory_bytes: 384
string = input()
N = len(string)
N0 = 7
judge = 0

if string == "keyence":
	judge = 1

for i in range(0,N0):
	stringnew = string[0:i]+string[i+N-N0:N]
	if stringnew == "keyence":
		judge = 1

if judge == 1:
	print("YES")
else:
	print("NO")


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <queue>

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

using namespace std;

typedef pair<int,int> P;

const int INF = 0x3fffffff;

int vx[] = {1,0,-1,0}, vy[] = {0,1,0,-1};

int main(){
	int W, H;
	while(cin >> W >> H, W|H){
		int wall[2][50][50];
		fill( (int*)wall, (int*)wall[2], 1 );
		rep(y,H) rep(k,2) rep(x,W){
			int a;
			if( k==0 ){
				if( x == W-1 ) break;
			}else{
				if( y == H-1 ) break;
			}
			cin >> wall[k][x+1][y+1];
		}
		queue<P> que;
		int dp[50][50];
		fill( (int*)dp[0], (int*)dp[50], INF );
		que.push( P(1,1) );
		dp[1][1] = 1;
		while( !que.empty() ){
			int x = que.front().first;
			int y = que.front().second;
			que.pop();
			rep(k, 4){
				if( dp[x+vx[k]][y+vy[k]] <= dp[x][y] + 1 ){
					continue;
				}
				if( vx[k] == -1 && wall[0][x-1][y] == 1 ) continue;
				if( vx[k] ==  1 && wall[0][x][y] == 1 ) continue;
				if( vy[k] == -1 && wall[1][x][y-1] == 1 ) continue;
				if( vy[k] ==  1 && wall[1][x][y] == 1 ) continue;
				dp[x+vx[k]][y+vy[k]] = dp[x][y] + 1;
				que.push( P(x+vx[k], y+vy[k]) );
			}
		}
		if( dp[W][H] == INF ) dp[W][H] = 0;
		cout << dp[W][H] << endl;
	}
	return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vs vector<string>
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main()
{
    int n, m;
    cin>>n>>m;
    cout<<(n==m?"Yes\n":"No\n");
}

Measured memory_bytes: 256
/*
AizuOnline A1180
Title  Recurring Decimals
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
int N,L;
char buf[7];
int  log_[21];
//
int comp_char(void * x,void * y)
{
  return(*(char *)x - *(char *)y);
}
int comp_char_r(void * x,void * y)
{
  return(*(char *)y - *(char *)x);
}

int rule(int a,int d)
{
  int saishou,saidai;

  sprintf(buf,"%0*d",d,a);
  qsort(buf,d,sizeof(char),comp_char_r);
  //printf("MAX:%s\n",buf);
  sscanf(buf,"%d",&saidai);
  //printf("sd:%d\n",saidai);
  qsort(buf,d,sizeof(char),comp_char);
  //printf("MIN:%s\n",buf);
  sscanf(buf,"%d",&saishou);
  //printf("ss:%d\n",saishou);
  return(saidai-saishou);
}
int chkloop(int N,int Len)
{
  int i;

  for(i=0;i<Len;i++)
    if(N==log_[i])
      return(i);
  return(-1);
}
main()
{
  int i,ret;

  while(EOF!=scanf("%d %d",&N,&L) && (N || L))
    {
      log_[0]=N;
      for(i=0;i<20;i++)
	{
	  N=rule(N,L);
	  log_[i+1]=N;
	  ret=chkloop(N,i+1);
	  //printf("r=%d:",ret);
	  if(ret>=0)
	    break;
      //printf("%d\n",N);
	}
      printf("%d %d %d\n",ret,N,i-ret+1);
    }
return(0);
}

Measured memory_bytes: 636
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
using namespace std;
int main()
 {
	long long int n,i,j,k=0,l=1,m=0;
	string s;
	cin>>n>>j;
	if(j>n)
	  cout<<"0"<<'\n';
	else
	  cout<<n-j<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> P;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

int N, d, p;
ll M, ans = 0LL;

void solve(void){
    while (1) {
        scanf("%d %lld\n", &N, &M);
        if (N==0&&M==0) return;
        ans = 0LL;
        vector <P> v(N);
        rep(N, i) {
            scanf("%d %d\n", &d, &p);
            v.pb(P(p, d));
            ans += p*d;
        }
        sort(all(v));
        reverse(all(v));
        for (P pd : v) {
            if (pd.second > M) {
                ans -= pd.first*M;
                break;
            }
            ans -= pd.first*pd.second;
            M -= pd.second;
        }
        printf("%lld\n", ans);
    }

}

int main(void){
  solve();
  return 0;
}



Measured memory_bytes: 3424
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    vector<double> x(n), y(n);
    for(int i=0; i<n; i++) cin>>x[i]>>y[i];

    vector<int> v(n);
    iota(v.begin(), v.end(), 0);

    double sum = 0;
    do{
        vector<int> id;
        for(int i=0; i<n; i++){
            id.emplace_back(v[i]);
        }

        for(int i=0; i<n-1; i++){
            sum += sqrt((x[id[i]] - x[id[i+1]]) * (x[id[i]] - x[id[i+1]]) + (y[id[i]] - y[id[i+1]]) * (y[id[i]] - y[id[i+1]]));
        }

    }while(next_permutation(v.begin(), v.end()));

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

    printf("%.10f\n", sum);

    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if ((s.charAt(2) == s.charAt(3)) && (s.charAt(4) == s.charAt(5))) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}


Measured memory_bytes: 35588
#include <iostream>
#include <string>

int main(int argc, char const* argv[])
{
  std::string s;
  std::cin >> s;

  const std::string t_s[] = {"dream", "dreamer", "erase", "eraser"};

  size_t tail = s.length();
  while (tail > 0) {
    bool flag = false;
    for (int i = 0; i < 4; ++i) {
      if (t_s[i].length() > tail) {
        continue;
      }

      std::size_t pos = s.rfind(t_s[i], tail - 1);
      if (pos == tail - t_s[i].length()) {
        tail = pos;
        flag = true;
        break;
      }
    }
    if (!flag) {
      break;
    }
  }

  std::cout << (tail == 0 ? "YES" : "NO") << std::endl;
  return 0;
}

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

using namespace std;

int main() {
  int n,m,c;cin>>n>>m>>c;
  vector<int> b(m);
  rep(i,m)cin>>b[i];
  vector<vector<int>> a(n,vector<int>(m));
  rep(i,n)rep(j,m)cin>>a[i][j];
  int ans=0;
  rep(i,n){
    int cnt=0;
    rep(j,m){
    cnt+=a[i][j]*b[j];
  }
    cnt+=c;
  if(cnt>0)ans++;
  }
    cout<<ans<<endl;
}

Measured memory_bytes: 3612
#include <stdio.h>

int main(void)
{
    int n=0;
    int d[51]={};
    long sum=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&d[i]);
    for(int i=1;i<n;i++){
        for(int j=0;j<i;j++){
            sum+=d[i]*d[j];
        }
    }
    printf("%ld",sum);
    return 0;
}


Measured memory_bytes: 1728
import sys
sys.setrecursionlimit(10**7)

n = int(input())
g = [[] for _ in range(n)]

for _ in range(n-1):
  u, v, w = map(int, input().split())
  g[u-1].append((v-1, w))
  g[v-1].append((u-1, w))

ans = [0] * n
def dfs(v,p,c):
  ans[v] = c
  for i in g[v]:
    if i[0] != p:
      if i[1] % 2 == 0:
        dfs(i[0], v, c)
      else:
        dfs(i[0], v, 1-c)
        
dfs(0,-1,0)

for i in ans:
  print(i)

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

class Main {

	void solve() {
		
		out.println(instr().contains("9") ? "Yes" : "No");
		
	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

	public int inint() {
		return in.nextInt();
	}

	public long inlong() {
		return in.nextLong();
	}
	
	public String instr() {
		return in.next();
	}

	public char inchar() {
		return in.next().charAt(0);
	}
	
	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

}

Measured memory_bytes: 23764
/*
ツ深ツつウツ優ツ静ヲツ探ツ催オツづ?嘉ーツつッツづ慊つキ.
Red and Blackツづ?つサツづアツづ按づ可陛渉づュツづィツづ慊つケツづア.
ツマツッツプツづーツ債カツ湘」ツづ個催?標ツつゥツづァツ渉?氾板づ可個ゥツづ? ツ塗ツづィツづつづ板つオツづ?つ「ツづ?づ?
ツ塗ツづィツづつづ板つオツつスツ嘉アツ青板つェツ督堋つヲツづ可づ按づィツづ慊つキ.

ツ暗按可コツづ個づヲツつ、ツづ按マツッツプツづ?つ?づェツづ? ツづ慊つク[0][0]ツつゥツづァツ塗ツづィツづつづ板つオ.

  ####
  #@##
  @@**
  ツ?ォ
  EEEE
  E@EE
  @@**

ツ塗ツづィツ終ツつヲツつスツづ?つアツづォツづー'E'ツづ可陛渉つヲツづ慊つキ.
ツ塗ツづィツづつづ板つオ1ツ嘉アツつェ, ツつソツづ・ツつ、ツづ?ツ凝ヲツ嘉ヲツづーツ表ツつキツつアツづ?づ可づ按づィツづ慊つキ.

ツ篠淞づ? ツ債カツ湘」ツつゥツづァツ個ゥツづ?つ「ツづ?づ? ツづ慊つセツ塗ツづィツ終ツつヲツづ?つ「ツづ按つ「ツ催?標ツつゥツづァツ塗ツづィツづつづ板つオツづ慊つキ.
ツづ按づ個づ? [1][1]ツつゥツづァツ塗ツづィツづつづ板つオ.

  EEEE
  E@EE
  @@**
  ツ?ォ
  EEEE
  EEEE
  EE**

ツつアツづェツづ? 2ツ凝ヲツ嘉ヲツ姪堋つェツ塗ツづェツづ慊つオツつス.
ツつ?づ?づ? ツ債カツ湘」ツつゥツづァツ渉?氾板づ可個ゥツづ?つ「ツつュツづ? [2][2]ツつェツづ慊つセツ塗ツづェツづ?つ「ツづ按つ「ツづ個づ?
[2][2]ツつゥツづァツ塗ツづィツづつづ板つオツづ慊つキ.

  EEEE
  EEEE
  EEEE

ツつアツづェツづ? 3ツ凝ヲツ嘉ヲツ姪堋つェツ塗ツづェツづ? ツ全ツづ?づ個催?標ツづーツ塗ツづィツ終ツつヲツづゥツつアツづ?つェツづ?つォツづ慊つオツつス.
ツ債。ツ嘉アツづ? 3ツ嘉アツ塗ツづィツづつづ板つオツつスツづ個づ? ツ督堋つヲツづ?ツ凝ヲツ嘉ヲツづ?つキ.
 */
#include <iostream>
using namespace std;

#define END 'E'

int h, w;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
char t[102][102];

//ツ催?標[y][x]ツつゥツづァ, ツ閉カツ篠嗅indツづ?づつづ按つェツづゥツ地ツ姪環づーツ全ツづ?塗ツづィツづつづ板つキツ催?帰ツ甘鳴青?
void dfs(int x, int y, char kind){
  t[y][x] = END; //ツ辿ツづ?つスツ催?標ツづーツ塗ツづゥ

  //4ツ陛サツ古シツづ鳴古シツつッツづ?催?帰ツつオツづ慊つキ
  for(int i = 0; i < 4; i++){
    int nx = x + dx[i];
    int ny = y + dy[i];

    //ツ篠淞行ツつュツ湘ェツ渉環つェツマツッツプツ禿?づ? ツ篠淞行ツつュツ湘ェツ渉環づ個閉カツ篠堋つェkindツづ?つ?づェツづ篠催?帰
    if(0 <= nx && nx < w && 0 <= ny && ny < h && t[ny][nx] == kind){
      dfs(nx, ny, kind);
    }
  }
}

int main(){
  //hツづ?ツづ個渉?氾板づ債気ツづーツづつつッツづヲツつ、ツ！(ツ債。ツ嘉アツづ個湘ェツ債?づ? wツづ?ツつェツ暗ェツ致ツつオツつスツ禿シツ療債つオツつゥツづ按つ「ツつゥツづァツ要ツ陳債暗督！)
  while(cin >> h >> w, h || w){
    for(int i = 0; i < h; i++){
      cin >> t[i];
    }

    int ans = 0;

    //ツ債カツ湘」ツづ個催?標ツつゥツづァツ渉?氾板づ? ツ塗ツづィツ終ツつヲツづ?つ「ツづ按つ「ツマツスツづーツ塗ツづィツづつづ板つオツづ慊つキ
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        //ツ塗ツづィツ終ツつヲツづ?つ「ツづ按つ「ツマツスツつェツつ?づェツづ篠カツウツδ督トツつオツつスツ古」, ツ塗ツづィツづつづ板つオ
        if(t[i][j] != END){
          ans++;
          dfs(j, i, t[i][j]);
        }
      }
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll a = 1, b = 0;
    while (n--)
    {
        ll q, x;
        cin >> q >> x;
        if (q == 1)
        {
            a *= x;
            b *= x;
        }
        else if (q == 2)
        {
            b += x;
        }
        else
        {
            b -= x;
        }
    }
    cout << -b << ' ' << a << endl;
}


Measured memory_bytes: 3176
import java.io.*;
import java.util.*;
//import java.util.Map.Entry;
//import java.util.stream.*;
//import java.math.*;

public class Main {

    public static int gcd(int a, int b) {
        return (b == 0) ? a : gcd(b, a % b);
    }

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc = new Scanner(System.in);
        char c = br.readLine().charAt(0);
        int num = (int) c;
        System.out.println(c <= 122 && c >= 97 ? "a" : "A"
        );
        bw.flush();
    }
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//

    static class Pair implements Comparable<Pair> {

        int a, b;

        public Pair(int x, int y) {
            a = x;
            b = y;
        }

        @Override
        public int compareTo(Pair p) {
            return a - p.a;
        }
    }

    static void forl_0(int n, int[] array, Scanner sc) {
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
    }

    static void forl_1(int n, int[] array, Scanner sc) {
        for (int i = 1; i <= n; i++) {
            array[i] = sc.nextInt();
        }
    }

    static void two_d(int n, int m, int[][] array, Scanner sc) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                array[i][j] = sc.nextInt();
            }
        }
    }

    static boolean isPrime(long n) {
        if (n < 2) {
            return false;
        } else if (n == 2 || n == 3) {
            return true;
        } else if (n % 2 == 0 || n % 3 == 0) {
            return false;
        }
        long sqrtN = (long) Math.sqrt(n) + 1;
        for (long i = 6L; i <= sqrtN; i += 6) {
            if (n % (i - 1) == 0 || n % (i + 1) == 0) {
                return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 26896
n = int(input())
x = list(map(int, input().split()))
dist = [x[i+1]-x[i] for i in range(n-1)]
mod = 10 ** 9 + 7

fact = [1]*(n+1)
r = 1
for i in range(1, n+1):
  fact[i] = r = r * i % mod
now = fact[n-1]
ans = 0
for k,d in enumerate(dist):
  ans = (ans + now * d) % mod 
  now += (fact[n-1] * pow(k+2,mod-2,mod)) % mod
print(ans)


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

int main(){
    int r, c;
    cin >> r >> c;
    vector<vector<int>> vec(r+1, vector<int>(c+1));
    for (int i = 0; i < r; i++){
        for (int j = 0; j < c; j++){
            cin >> vec[i][j];
        }
    }
    for (int i = 0; i < r; i++){
        int sum = 0;
        for (int j = 0; j < c; j++){
            sum += vec[i][j];
        }
        vec[i][c] = sum;
    }
    for (int i = 0; i < c; i++){
        int sum = 0;
        for (int j = 0; j < r; j++){
            sum += vec[j][i];
        }
        vec[r][i] = sum;
    }
    int sum1 = 0;
    int sum2 = 0;
    for (int i = 0; i < r; i++){
        sum1 += vec[i][c];
    }
    for (int i = 0; i < c; i++){
        sum2 += vec[r][c];
    }
    vec[r][c] = sum1 + sum2;

    for (int i = 0; i <= r; i++){
        for (int j = 0; j < c; j++){
            cout << vec[i][j] << " ";
        }
        cout << vec[i][c] << endl;
    }


}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n, k;
    cin >> n >> k;
    string yes = "YES", no = "NO";
    cout << (n+1 >= 2*k ? yes : no) << endl;
    return 0;
}

Measured memory_bytes: 256
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { let mut $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { let $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut count = vec![0; 100000];
    for num in a {
        count[num] += 1;
    }
    let mut ans = 0;
    for i in 1..100000 - 1 {
        ans = std::cmp::max(ans, count[i -1] + count[i] + count[i + 1]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
import collections

N = int(input())
A = list(map(int, input().split()))
B = collections.defaultdict(int)
C = collections.defaultdict(int)

for i in range(N):
    B[i-A[i]] += 1 
    C[i+A[i]] += 1
#print(B)
#print(C)
ans = 0
for i in B:
    #print(i) i=Key
    if i in C:
        ans += B[i]*C[i]
print(ans)

Measured memory_bytes: 57540
use std::io::*;
use std::str::FromStr;

fn parse_line<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn parse_pair<T: FromStr, U: FromStr>() -> (T, U) {
    let line = parse_line::<String>();
    let mut iter = line.split_whitespace();
    (
        iter.next().unwrap().parse().ok().unwrap(),
        iter.next().unwrap().parse().ok().unwrap(),
    )
}

fn print_from_iterator<T: ToString, I>(
    iterator: &mut I,
    separator: &str
) where
    I: Iterator<Item = T>,
{
    println!(
        "{}",
        iterator
            .map(|e| e.to_string())
            .collect::<Vec<String>>()
            .join(separator),
    );
}

// ------------------------------------------------------------------------

fn main() {
    let (k, x) = parse_pair::<isize, isize>();

    let min = x - (k - 1);
    let max = x + (k - 1) + 1;
    let range = min..max;

    print_from_iterator(&mut range.into_iter(), " ");
}


Measured memory_bytes: 4352
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,a[200000],i,j,b[3]={0},k=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(j=n-1;j>=0;j--)
    {       
        if(a[j]==a[j-1]) 
        {
            b[k]=a[j--];
            k++;
            if(k==2)
            {
                break;
            }
        }         
    }
    cout<<(b[0]*b[1])<<endl;
    return 0;
}

Measured memory_bytes: 4416
#include <iostream>
#include <algorithm>
#include <map>
#include <set>

using namespace std;
typedef long long int ll;

#define rep(x, a, b) for (int x = a; x < b; x++)
#define Min(x, y) (((x) < (y))?(x):(y))
#define Max(x, y) (((x) > (y))?(x):(y))

struct node {
  bool visit;
  ll val;
  node(bool vis, ll val) : visit(vis), val(val) {};
};

struct edge {
  int d, a;
  edge(int d, int a) : d(d), a(a) {};
};

vector<node> nodes[2];
vector<vector<edge>> edges[2];

const ll toobig = 1LL<<50;
ll mins[2];
bool consistent;

void
dfs(int r, bool i, ll cur) {
  if (nodes[i][r].visit) {
    consistent &= cur == nodes[i][r].val;
    return;
  }

  nodes[i][r] = node(true, cur);
  mins[i] = Min(cur, mins[i]);

  for (auto e : edges[i][r]) {
    dfs(e.d, i?0:1, e.a - cur);
  }
}

int main()
{
  int h, w, n;

  cin >> h >> w >> n;

  nodes[0] = vector<node>(w, node(false, 0));
  nodes[1] = vector<node>(h, node(false, 0));
  edges[0] = vector<vector<edge>>(w);
  edges[1] = vector<vector<edge>>(h);

  rep (i, 0, n) {
    int r, c;
    ll a;

    cin >> r >> c >> a;
    r--; c--;

    edges[0][c].emplace_back(r, a);
    edges[1][r].emplace_back(c, a);
  }

  bool success = true;
  
  rep (i, 0, h) {
    if (nodes[1][i].visit) continue;

    consistent = true;
    mins[0] = mins[1] = toobig;
    dfs(i, 1, 0);
    success &= (mins[0] + mins[1] >= 0) & consistent;
  }

  cout << (success?"Yes":"No") << endl;

  return 0;
}


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

int LCS(string X, string Y) {
  /*
  if (X.length() == 0 || Y.length() == 0) {
    return 0;
  }
  else if (X[X.length()-1] == Y[Y.length()-1]) {
    string miniX = X.substr(0, X.length()-1),  miniY = Y.substr(0, Y.length()-1);
    return LCS(miniX, miniY) + 1;
  }
  else {
    string miniX = X.substr(0, X.length()-1),  miniY = Y.substr(0, Y.length()-1);
    return max(LCS(miniX, Y), LCS(X, miniY));
  }
  */
 int m = X.length(), n = Y.length();
 int c[m+1][n+1];
 for (int i = 0; i <= m; i++) {c[i][0] = 0;}
 for (int i = 0; i <= n; i++) {c[0][i] = 0;}
 int maxL = 0;
 X = ' '+ X; Y = ' ' + Y;
 for (int i = 1; i <= m; i++) {
   for (int j = 1; j <= n; j++) {
     if (X[i] == Y[j]) c[i][j] = c[i-1][j-1]+1;
     else c[i][j] = max(c[i][j-1], c[i-1][j]);
  maxL = max(maxL, c[i][j]);   
  }
 }
 return maxL;
}
int main(void) {
  int q; cin >> q;
  string X[q], Y[q];
  for (int i = 0; i < q; i++)  {
    cin >> X[i] >> Y[i];
  }

  int ans[q];
  for (int i = 0; i < q; i++) {
    ans[i] = LCS(X[i], Y[i]);
  }

  for (int i = 0; i < q; i++) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 7084
// 2011/11/07 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){

	int N, M;
	cin >> N >> M;

	if(N==0&&M==0)
		break;

	int S[1001];
	for(int i=1; i<=N; i++)
		cin >> S[i];

	int D[1001];
	for(int i=1; i<=M; i++)
		cin >> D[i];

	int P = 1;
	int I = 1;
	for(; I<=M; I++){
		P += D[I];
		if(P>=N)
			break;

		P += S[P];
		if(P>=N)
			break;
	}

	cout << I << endl;

	}

	return 0;
}

Measured memory_bytes: 0