akhauriyash/Code-Regression huggingface dataset:
// C - Tax Increase
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
int A,B;

int solve(){
	rp(i,1,1009+1) if(int(i*0.08)==A && int(i*0.10)==B) return i;
	return -1;
}

int main(){
	cin>>A>>B;
	cout<< solve() <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
int main(int argc, char *argv[])
{
	int n,i,j;
	bool t;
	while(cin>>n)
	{
		t=false;
		for(i=0;i*4<=n;i++)
		{
			for(j=0;(j*7+i*4)<=n;j++)
			{
				if(j*7+i*4==n)
				{t=true;break;}
			}
			if(t)break;
		}
		if(t)
			printf("Yes\n");
		else
			printf("No\n");		
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

int main(void){
  int N;
  cin >> N;
  vector<int> p(N+1,0);
  vector<ll> a(N+1,0),b(N+1,0),c(N+1,0);
  REP(i,1,N+1)
      cin >> p[i];
  REP(i,1,N+1)
    c[p[i]] = N+i;
  a[1] = 1;
  b[1] = c[1]-1;  
  REP(i,2,N+1)
    {
      a[i] = max(a[i-1]+1,c[i] - b[i-1] + 1);
      b[i] = min(b[i-1]- 1,c[i] - a[i-1] - 1);
    }
  REP(i,1,N+1)
      b[i] += 1 - b[N];
  
  REP(i,1,N+1)
    cout << a[i] << " ";
  cout << endl;
  REP(i,1,N+1)
    cout << b[i] << " ";
  cout << endl;
  
}


Measured memory_bytes: 1280
import java.util.Scanner;
 
class Main {
    Scanner sc = new Scanner(System.in);
 
     
    public void run() {
        while(true){
            int m=sc.nextInt(),f=sc.nextInt(),r=sc.nextInt();
            if(m==-1 && f==-1 && r==-1){
                break;
            }
            if(m!=-1 && f!=-1){
                if(m+f>=80){
                    ln("A");
                }else if(m+f >=65){
                    ln("B");
                }else if(m+f >=50){
                    ln("C");
                }else if(m+f >=30){
                    if(r>=50){
                        ln("C");
                    }else{
                        ln("D");
                    }
                }else{
                    ln("F");
                }
            }else{
                ln("F");
            }
        }
    }
 
    public static void main(String[] args) {
        new Main().run();
    }
 
    public static void pr(Object o) {
        System.out.print(o);
    }
 
    public static void ln(Object o) {
        System.out.println(o);
    }
 
    public static void ln() {
        System.out.println();
    }
}


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

int sum(int n){
    int ans = 0;
    if(n == 1) return 1;
    if(n % 2 == 0){
        ans = (1 + n)*n/2;
    }else{
        ans = (0 + n)*(n + 1)/2;
    }

    return ans;
}

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

    double ans = 0;
    vector<double> v(n + 1);
    vector<double> p(n - k + 1,0);
    for(int i = 0; i < k; ++i) cin >> v[i];
    for(int i = 0; i < k; ++i){
        p[0] += sum(v[i])/v[i];
    }
    ans = p[0];
    for(int i = k; i < n; ++i){
        cin >> v[i];
        p[i - k+1] = p[i - k] - sum(v[i - k])/v[i - k] + sum(v[i])/v[i];

        if(ans < p[i - k+1])ans = p[i - k+1];
    }

    cout << fixed << setprecision(15) << ans << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){

  vector <pair <int,int> > a;
  int x,y,i;
  
  for(int i=2;i<=150;i++) for(int j=1;j<i;j++) a.push_back(make_pair(i*i+j*j,j*1000+i));
  sort(a.begin(),a.end());
    
  while(cin>>y>>x,x){
    for(i=0;i<a.size();i++) if(a[i].first==x*x+y*y&&a[i].second==y*1000+x) break;
    cout<<a[i+1].second/1000<<" "<<a[i+1].second%1000<<endl;
  }
  
  return 0;
}

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

class SegmentTree
{
 private:
    int n;
    vector<int> node;
 public:
    SegmentTree(int sz){
        n=1;
        while(n<sz) n*=2;
        node.resize(2*n);
        for(int i=1;i<n;i++) node[i]=-1;
        for(int i=n;i<2*n;i++) node[i]=INT_MAX;
    }
    void update(int a,int b,int val,int k=1,int l=0,int r=-1){
        if(r<0) r=n;
        if(r<=a or b<=l) return;
        if(a<=l and r<=b){
            node[k]=val;
            return;
        }
        if(node[k]!=-1){
            node[2*k]=node[2*k+1]=node[k];
            node[k]=-1;
        }
        update(a,b,val,2*k,l,(l+r)/2);
        update(a,b,val,2*k+1,(l+r)/2,r);
    }
    int get(int idx){
        idx+=n;
        int res=node[idx];
        while(idx>>=1){
            if(node[idx]!=-1) res=node[idx];
        }
        return res;
    }
};

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

    int N,Q; cin>>N>>Q;
    SegmentTree seg(N);
    while(Q--){
        int q; cin>>q;
        if(q==0){
            int s,t,x; cin>>s>>t>>x;
            seg.update(s,t+1,x);
        }else{
            int i; cin>>i;
            cout<<seg.get(i)<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4940
#include<stdio.h>
#include<stdlib.h>
int main(){
int N, DispR;
int InnR;
scanf("%d", &N);
scanf("%d", &DispR);
if(N>=10)
{
InnR = DispR;
printf("%d", InnR);
}
else
{
InnR = DispR + 100*(10-N);
printf("%d", InnR);
}
return 0;
}

Measured memory_bytes: 128
from itertools import combinations
# combinations('ABCD', 2) --> AB AC AD BC BD CD
# combinations(range(4), 3) --> 012 013 023 123


N, K = map(int,input().split())
combi_list = list(combinations([i+1 for i in range(N-1)],2))
r = (N-1)*(N-2) // 2
if (N-1)*(N-2)//2 < K:
    print(-1)
    quit()
else:
    print(N-1 + r - K)
    for i in range(N-1):
        print(N,i+1)
    for i in range(r-K):
        print(combi_list[i][0],combi_list[i][1])




Measured memory_bytes: 42992
N, K = map(int, input().split())
x_list = [0]*N
y_list = [0]*N
for i in range(N):
    x_list[i], y_list[i] = map(int, input().split())

x_element = sorted(set(x_list))
y_element = sorted(set(y_list))
ans = float("inf")

for i in range(len(x_element)):
    for j in range(len(y_element)):
        for k in range(i+1, len(x_element)):
            for l in range(j+1, len(y_element)):
                num = 0
                for m in range(N):
                    if x_element[i] <= x_list[m] <= x_element[k] and y_element[j] <= y_list[m] <= y_element[l]:
                        num += 1
                if num >= K:
                    ans = min((x_element[k] - x_element[i]) * (y_element[l] - y_element[j]), ans)

print(ans)

Measured memory_bytes: 47196
use std::cmp::max;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let w:usize = read();
    let mut weight = Vec::new();
    let mut value = Vec::new();
    for _ in 0..n {
        weight.push(read::<usize>());
        value.push(read::<u128>());
    }

    let mut dp = vec![vec![0; w+1]; n+1];
    for i in 0..n {
        for sum_w in 0..=w {
            if sum_w >= weight[i] {
                dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w-weight[i]] + value[i]);
            }
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }
    println!("{}", dp[n][w]);
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

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

    int a, b, c, k;
    cin >> a >> b >> c >> k;

    ll ans = max(a, max(b, c));
    ll tmp = a + b + c - ans;
    rep(i, k){
        ans *= 2;
    }

    cout << ans+tmp << endl;

    return 0;
}


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

int main()
{
	int i, j, k;
	scanf("%d %d %d", &i, &j, &k);
	if (i > abs(j - k)) {
		printf("0\n");
	}
	else {
		if (j < k) {
			printf("%d", k - j - i);
		}
		else {
			printf("%d", j - k - i);
		}
	}
	return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-

from collections import defaultdict

#入力   
n = int(input())
v = tuple(int(i) for i in input().split())

def f(v):
    d = defaultdict(int)
    d[0] = 0

    for i in v:
        d[i] += 1
    return sorted(d.items(), key=lambda x: x[1], reverse=True)

t1 = f(v[::2])
t2 = f(v[1::2])

if t1[0][0] == t2[0][0]:
    if t1[0][1] + t2[1][1] > t1[1][1] + t2[0][1]:
        print(n - t1[0][1] - t2[1][1])
    else:
        print(n - t1[1][1] - t2[0][1])
else:
    print(n - t1[0][1] - t2[0][1])


Measured memory_bytes: 20696
import java.util.* ; 
import java.math.*;
class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner (System.in);

	
	int z  = scan.nextInt();
    int x = scan.nextInt();
    int y = scan.nextInt();
    
    System.out.println(Math.max(0,Math.abs(x-y)-z));
    
    
  }
}

Measured memory_bytes: 20948
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int t=n;
	int flag=0;
	while(t>0)
	{
		int a=t%10;
		t/=10;
		if(a==9)
		{
			flag=1;
			break;
		}
	}
	if(flag==1)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# B - Card Game for Two
# 標準入力の取得
N = int(input())
A_list = list(map(int, input().split()))

# リストを照準にソートしておく
sorted_A_list = sorted(A_list)

# AliceとBobの差の算出
Alice = 0
Bob = 0

if N % 2 == 0:
    # カード数が偶数の場合、a_2, a_4,・・・, a_NをAliceは取得する
    Alice = sum([sorted_A_list[i] for i in range(N) if i % 2 != 0])
    Bob = sum([sorted_A_list[i] for i in range(N) if i % 2 == 0])
else:
    # カード数が奇数の場合、a_1, a_3,・・・, a_NをAliceは取得する
    Alice = sum([sorted_A_list[i] for i in range(N) if i % 2 == 0])
    Bob = sum([sorted_A_list[i] for i in range(N) if i % 2 != 0])

print(Alice - Bob)

Measured memory_bytes: 3064
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int gcd(int a, int b)
{
  if (b == 0)
    return a;

  return gcd(b, a % b);
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, A, g = 0;

  std::cin >> N;

  for (int i = 0; i < N; i ++) {
    std::cin >> A;

    g = gcd(A, g);
  }

  std::cout << g << std::endl;

  return 0;
}


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

int main(void){
    string S;
    cin>>S;

    string y=S.substr(0,4);
    string m=S.substr(5,2);
    string d=S.substr(8,2);

    int iy=atoi(y.c_str());
    int im=atoi(m.c_str());
    int id=atoi(d.c_str());

    if(iy>=1900&&iy<=2018){
        cout<<"Heisei"<<endl;
    }else if(iy==1989&&im>=1&&id>=8){
        cout<<"Heisei"<<endl;
    }else if(iy==2019&&im<=4&&id<=30){
        cout<<"Heisei"<<endl;
    }else{
        cout<<"TBD"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
def main():
  n, m = list(map(int, input().split()))
  l = 0
  r = 100001
  for i in range(m):
    a, b = map(int, input().split())
    if l < a:
      l = a
    if b < r:
      r = b

  if r - l >= 0:
    print(r - l + 1)
  else:
    print(0)

main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n;
    cin >> n;
    vector<ll> arr(n, 0);
    for(auto& val: arr)
        cin >> val;
    ll mn = arr[0];
    ll ans = 0;
    for(int i = 1; i < n; i++) {
        if (arr[i] < mn) {
            ans += mn-arr[i];
        }
        mn = max(mn, arr[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4776
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;

struct cam {
    int k, l, r;
    bool operator < (const cam &x) const {
        return k < x.k;
    }
};

void solve() {
    int n;
    cin >> n;
    vector <cam> lft, rgh;

    for (int i = 0 ; i < n ; ++ i) {
        cam v;
        cin >> v.k >> v.l >> v.r;
        if (v.l > v.r) lft.push_back(v);
        else rgh.push_back(v);
    }

    vector <cam> keep[n + 3];

    for (cam &c : lft)
        keep[c.k].push_back(c);

    priority_queue < pair <int, cam>> setik;
    long long ans = 0;

    for (int i = 1 ; i <= int(lft.size()) ; ++ i) {
        for (cam c : keep[i])
            setik.emplace(c.r - c.l, c);
        while (int(setik.size() > i)) {
            ans += setik.top().second.r;
            setik.pop();
        }
    }

    for (int i = lft.size() + 1 ; i <= n ; ++ i)
        for (cam c : keep[i]) ans += c.l;

    while (!setik.empty()) {
        ans += setik.top().second.l;
        setik.pop();
    }

    for (int i = 1 ; i <= n ; ++ i)
        keep[i].clear();



    for (cam c : rgh)
        keep[c.k + 1].push_back(c);

    int now = 0;

    for (int i = n ; i > int(lft.size()) ; -- i) {
        ++ now;
        for (cam c : keep[i])
            setik.emplace(c.l - c.r, c);

        while (int(setik.size()) > now) {
            ans += setik.top().second.l;
            setik.pop();
        }
    }

    for (cam c : keep[n + 1]) ans += c.l;
    for (int i = 1 ; i <= lft.size() ; ++ i)
        for (cam c : keep[i]) ans += c.r;
    while (!setik.empty()) ans += setik.top().second.r, setik.pop();

    cout << ans << '\n';
}


int main () {
    int T;
    cin.tie(0)->sync_with_stdio(false);

    for (cin >> T ; T --  ;) {
        solve();
    }
}
/*
    Good Luck
        -Lucina
*/


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

int main(){
  int l[10];
  char c;
  while(1){
    for(int i = 0 ; i < 10 ; i++){
      cin >> l[i] >> c;
      if(cin.eof()) return 0;
    }
    int a, b;
    cin >> a >> c >> b;
    
    int n = 0;
    for(int i = 0 ; i < 10 ; i++){
      n += l[i];
    }
    double h = (double)n/(a+b);
    double d = (double)a*h;
    
    n = 0;
    
    for(int i = 0 ; i < 10 ; i++){
      n += l[i];
      if(d <= n){
	cout << i+1 << endl;
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)
#define MP(a,b) make_pair(a,b)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

void solve() {

	int N;
	cin >> N;
	cout << ceil((double)N/2);

}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	return 0;
}

Measured memory_bytes: 3744
#include <iostream>
#include <vector>
#include <stack>
#include <cctype>

int main()
{
	std::string rev_polish;
	getline(std::cin, rev_polish);
	int pos;
	int offset = 0;
	std::vector<std::string> vec;
	while ( (pos = rev_polish.find(' ', offset)) != std::string::npos ) {
		vec.push_back( rev_polish.substr(offset, pos-offset) );
		offset = pos + 1;
	}
	vec.push_back( rev_polish.substr(offset, pos-offset) );
	
	std::stack<int> st;
	for (std::vector<std::string>::iterator it = vec.begin(); it != vec.end(); ++it) {
		if ( isdigit((*it)[0]) != 0 ) {
			st.push( std::stoi(*it) );
		} else {
			int a = st.top(); st.pop();
			int b = st.top(); st.pop();
			if ( (*it) == "+" ) st.push(b+a);
			else if ( (*it) == "-" ) st.push(b-a);
			else if ( (*it) == "*" ) st.push(b*a);
		}
	}
	std::cout << st.top() << std::endl;
	
	return 0;
}




Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
//priority_queue<int,vector<int>,decltype(ascending)> que{ascending};
auto ascending=[](int a,int b){//昇順
  return a>b;
};
//priority_queue<int,vector<int>,decltype(descending)> que{descending};
auto descending=[](int a,int b){//降順
  return a<b;
};
int main(){
  int x;
  cin>>x;
  for(int i=1;i<=360;i++){
    if((i*x)%360==0){cout<<i<<endl;return 0;}
  }
}

Measured memory_bytes: 3632
{-# LANGUAGE  ViewPatterns #-}
module Main (main) where

main :: IO ()
main = interact solve

solve :: String -> String
solve (map (read :: String -> Int) . words ->  [a, b, c, x, y]) = show $ loop 0 0 0
  where loop ca cb  tot | ca < x && cb < y = loop (ca + 1) (cb + 1) $ if c * 2 <= a + b
                                                                      then tot + c * 2
                                                                      else tot + a + b
                        | ca < x           = if c * 2 <= a
                                             then loop (ca + 1) (cb + 1) (tot + c * 2)
                                             else loop (ca + 1) cb (tot + a)
                        | cb < y           = if c * 2 <= b
                                             then loop (ca + 1) (cb + 1) (tot + c * 2)
                                             else loop ca (cb + 1) (tot + b)
                        | otherwise        = tot


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin>>N;
    if(N%2==0){
        cout << (N-2)*(N-1)/2+N/2-1 << endl;
        int x=N+1;
        rep(i,N){
            for(int j=i+1;j<N;j++){
                if(i+j!=x-2){
                    cout << i+1 <<" "<< j+1 << endl;
                }
            }
        }
    }else{
        cout << (N-2)*(N-1)/2+N/2<<endl;
        int x=N;
        rep(i,N){
            for(int j=i+1;j<N;j++){
                if(i+j!=x-2){
                    cout << i+1 <<" "<< j+1 << endl;
                }
            }
        }
    }
    




    



}


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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

string s;
lli k;
string ans;

bool dfs(){
  if(k == 0) return true;
  for(char c = 'a';c <= 'z';c++){
    ans.push_back(c);
    // cout << ans << endl;
    if(search(s.begin(),s.end(),ans.begin(),ans.end()) != s.end()){
      k--;
      if(dfs()) return true;
    }
    ans.pop_back();
  }
  return false;
}




int main(){
  cin >> s;
  cin >> k;
  dfs();
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String input;
        int result = Integer.parseInt(br.readLine());

        while (!(input = br.readLine()).equals("=")) {
            int n = Integer.parseInt(br.readLine());

            switch (input) {
            case "+":
                result += n;
                break;
            case "-":
                result -= n;
                break;
            case "*":
                result *= n;
                break;
            case "/":
                result /= n;
                break;
            }

        }

        System.out.println(result);
    }
}


Measured memory_bytes: 24188
points = {:taro => 0, :hanako => 0}
loop = gets.to_i

loop.times{
    taro, hanako = gets.chomp.split
    if taro > hanako
        points[:taro] += 3
    elsif taro < hanako
        points[:hanako] += 3
    else
        points[:taro] += 1
        points[:hanako] += 1
    end
}

puts "#{points[:taro]} #{points[:hanako]}"


Measured memory_bytes: 6860
use std::io;
use io_ext::Reader;

fn main() {
    let stdin = io::stdin();
    let mut r = Reader::new(io::BufReader::new(stdin.lock()));
    let s = r.read_line();
    if s == "Sunny" {
        println!("Cloudy");
    } else if s == "Cloudy" {
        println!("Rainy");
    } else {
        println!("Sunny");
    }
}

/// Extension of io module.
pub mod io_ext {
    use std::io::BufRead;

    pub struct Reader<R> {
        buf: String,
        inner: R,
    }

    impl<R> Reader<R> {
        #[inline]
        pub fn new(inner: R) -> Self {
            Reader { buf: String::new(), inner: inner }
        }

        #[inline]
        pub fn into_inner(self) -> R {
            self.inner
        }
    }

    impl<R: BufRead> Reader<R> {
        #[allow(deprecated)]
        #[inline]
        pub fn read_line(&mut self) -> &str {
            self.buf.clear();
            self.inner.read_line(&mut self.buf).unwrap_or_else(|e| panic!("{}", e));
            self.buf.trim_right()
        }
    }
}

/// Module supporting to parse strings.
pub mod parse {
    use std::str::FromStr;
    use std::borrow::Borrow;

    pub trait ParseNext: Iterator {
        fn parse_next<F: FromStr>(&mut self) -> F;
    }

    impl<'a, S: Borrow<str>, I: Iterator<Item=S>> ParseNext for I {
        fn parse_next<F: FromStr>(&mut self) -> F {
            if let Some(s) = self.next() {
                match s.borrow().parse() {
                    Ok(x) => x,
                    Err(_) => panic!("provided string cannot be parsed")
                }
            } else {
                panic!("iterator has no next element")
            }
        }
    }
}


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

int main(){
  int n;cin >> n;
  vector<int> h(n);for(int i=0;i<n;i++)cin >> h[i];
  int j=0,maxi = 0;
  for(int i=0;i<n-1;i++){
    if(h[i] < h[i+1]){
      maxi = max(maxi,j);
      j = 0;
    } else {
      j += 1;
    }
  }
  if(h[n-2] >= h[n-1])maxi = max(maxi,j);
  cout << maxi << endl;
  return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const string s[4]={"maerd", "remaerd", "esare", "resare"};

int main() {
  string S; cin >> S;
  reverse(S.begin(), S.end());
  long long itr=0;
  string ans="";
  while(itr != (long long)S.length()) {
    bool matched=false;
    for(int i = 0; i < 4; ++i) {
      if(S.substr(itr, s[i].length()) == s[i]) {
        itr += (long long)s[i].length();
        matched = true;
      }
    }
    if(!matched) {
      cout << "NO" << endl;
      return 0;
    }
  }
  ans = (itr == S.length()) ? "YES" : "NO";
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
a,b,k = list(map(int, input().split()))
for i in range(k):
    if i%2 == 0:
        if a%2 == 1:
            a -= 1
        a = a//2
        b += a
    else:
        if b%2 == 1:
            b -= 1
        b = b//2
        a += b

print(a, b)

Measured memory_bytes: 3060
import numpy as np

N = int(input())

A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))

mx = -1

for i in range(N):
    topsum = np.sum(A1[:i+1])
    undersum = np.sum(A2[i:])
    now = topsum + undersum
    if now > mx:
        mx = now

print(mx)

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

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

    int A[3];
    std::cin >> A[0] >> A[1] >> A[2];

    sort(A, A+3);

    int res = A[2] - A[0];
    std::cout << res << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n ;
  cin >> n ;
  
  int a,b,tmp,r ;
  
  a = 2 ;
  b = n ;
  int x = a*b ;
  
  if(a<b){
    tmp =  a ;
    a = b ;
    b = tmp ;
  }

  r = a % b ;
  while(r!=0){
    a = b ;
    b = r ;
    r = a % b ;
  }
  
  cout << x/b << endl;
   return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  char s1[4],s2[4];
  scanf("%s\n%s",s1,s2);
  if(s1[0]==s2[2] && s1[1]==s2[1] && s1[2]==s2[0]) printf("YES\n");
  else printf("NO\n");
  return 0;
}

Measured memory_bytes: 1644
#include <stdio.h>
#include<vector>
using namespace std;
int main(void)
{
    int N;
    int ans=0;
    scanf("%d",&N);
    vector<int> list(N);
    for(int i=0;i<N;i++)
    {
       scanf("%d",&list[i]); 
    }
    
    for(int i=0;i<N;i++)
    {
        for(int j=i+1;j<N;j++)
        {
            ans+=list[i]*list[j];
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

    int n;
    while(cin>>n,n){
        for(int i=0;i<n;i++){
            int a,b,c,d,x,y,z,w;
            cin>>a>>b>>c>>d>>x>>y>>z>>w;
            int h=0,i=0,j=0,k=0;

            h = (a*x) - (b*y) - (c*z) - (d*w);
            i = (a*y) + (b*x) + (c*w) - (d*z);
            j = (a*z) - (b*w) + (c*x) + (d*y);
            k = (a*w) + (b*z) - (c*y) + (d*x);
            cout<<h<<" "<<i<<" "<<j<<" "<<k<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FI first
#define SE second
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
using namespace std;
//
int main(){
  int N,H;
  cin>>N>>H;
  int MA=-1,A,B[100000];
  FOR(i,0,N){
    cin>>A>>B[i];
    MA=max(MA,A);
  }
  sort(B,B+N,greater<int>());
  int i=0,cnt=0;
  while(H>0&&B[i]>=MA&&i<N){
    H-=B[i++];
    cnt++;
  }
  if(H>0){
    cnt+=(H+MA-1)/MA;
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#define RG register
using namespace std;
int n,m,ans=1;
int main()
{
//	freopen("Partition.in","r",stdin);
//	freopen(".out","w",stdout);
	scanf("%d%d",&n,&m);
	if(n==1)
	{
		printf("%d\n",m);
		return 0;
	}
	for(int i=2;i<=sqrt(m);i++)
	{
		if(m%i==0)
		{
			int a=i, b=m/i;
			if(a>=n)
			{
				printf("%d\n",b);
				return 0;
			}
			else if(b>=n)
			{
				ans=a;
			}
		}
	}
	printf("%d\n",ans);
//	fclose(stdin); fclose(stdout);
	return 0;
}


Measured memory_bytes: 256
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n
 
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
 
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
 
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
 
    return result
x,y = map(int,input().split())
mod=10**9+7
if (x+y)%3!=0 or x>2*y or y>2*x:
  print('0')
else:
  p=(2*y-x)//3
  q=(2*x-y)//3
  print(cmb(p+q,p)%mod)


Measured memory_bytes: 44148
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int read()
{
	char c=getchar(); int x=0,f=1;
	while (c<'0'||c>'9') {if (c=='-') f*=-1; c=getchar();}
	while (c>='0'&&c<='9') {x=x*10+c-'0'; c=getchar();}
	return x*f;
}
int n,a,b;
int main()
{
	cin>>n>>a>>b;
	int c=a-b;
	if (c<0)c=-c;
	if ((c-1)%2==0)cout<<"Borys"<<endl;
	else cout<<"Alice"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int m = 1e9+7;
/*long long cnt(int n, int k, vector<int>v,vector<vector<long long>>&dp)
{
    if(k==0)
    return 1;

    if(n==-1 && k!=0)
    return 0;

    if(dp[n][k]!=-1)
    return dp[n][k];

    if(v[n]>0)
    {
           long long a = (cnt(n-1,k,v,dp))%m;
           v[n]--;
           long long b = (cnt(n,k-1,v,dp))%m;
           dp[n][k] = (a+b)%m;
    }
    else
    {
        dp[n][k] = (cnt(n-1,k,v,dp))%m;
    }
    return ((dp[n][k])%m);
}
int main()
{
    int n,k;
    cin>>n>>k;

    vector<int>v(n,0);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    vector<vector<long long>>dp(n,vector<long long>(k+1,-1));

    long long ans = cnt(n-1,k,v,dp);
    cout<<(ans%m)<<endl;
}
*/
int main()
{
    int n,k;
    cin>>n>>k;

    vector<int>v(n+1,0);
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    vector<vector<long long>>dp(n+1,vector<long long>(k+1,-1));

    dp[0][0]=1;
    for(int i=1;i<=k;i++)
    {
        dp[0][i]=0;
    }
    for(int i=1;i<=n;i++)
    {
        dp[i][0]= dp[i-1][0];
    }

    for(int i=1;i<=n;i++)
    {
        vector<int>sum(k+1);
        sum[0] = dp[i-1][0];
        for(int j=1;j<=k;j++)
        {
             sum[j] = (dp[i-1][j]+sum[j-1])%m;
        }
        for(int j=0;j<=k;j++)
        {
            if(j<=v[i])
            {
              dp[i][j] = sum[j];
            }
            else
            {
                int a = j-v[i]-1;
                dp[i][j] = (sum[j]-sum[a]+m)%m;
            }
        }
        sum.clear();
    }
    cout<<dp[n][k]<<endl;
}


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

using namespace std;

int N, M;
map<char, char> ConversionTable;

int main() {
	char key, val;
	map<char, char>::iterator pos;

	while (cin >> N, N) {
		ConversionTable.clear();
		for (int i = 0; i < N; ++i) {
			cin >> key >> val;
			ConversionTable[key] = val;
		}
		cin >> M;
		for (int i = 0; i < M; ++i) {
			cin >> key;
			pos = ConversionTable.find(key);
			if (pos == ConversionTable.end()) {
				cout << key;
			}
			else {
				cout << pos->second;
			}
		}
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3016
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int compare(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(){
    int arr[10];

    for (int i = 0; i < 10; i++)
    {
        cin >> arr[i];
    }

    sort(arr, arr + 10);
    for (int i = 1; i <= 3; i++)
    {
        cout << arr[10 - i] << endl;
    }


    return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

ll N;

bool f(ll n){
    if(n == 1){
        return false;
    }

    ll m = n - 1, r = N / n;
    return N % m == r;
}

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

    std::cin >> N;

    ll n = 1;
    ll cnt = 0;

    for(n=1;n*n<N;++n){
        if(N % n > 0){
            continue;
        }

        ll m = N / n;

        if(f(n)){
            // std::cout << "[" << n << ", " << m << std::endl;
            cnt += n - 1;
        }

        if(f(m)){
            // std::cout << n << ", " << "[" << m << std::endl;
            cnt += m - 1;
        }
    }

    if(n * n == N && f(n)){
        cnt += n - 1;
    }

    std::cout << cnt << std::endl;
}


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

const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int dp[200];
int main()
{
    int n;
    cin >> n;
    dp[4] = dp[7] = 1;
    for(int i = 1; i < 110; i++){
        if(dp[i]){
            dp[i+4] = 1;
            dp[i+7] = 1;
        }
    }
    cout << (dp[n] ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
##入力
N = int(input())


##計算、出力
if N % 2 == 0:##偶数の場合
  
  a = int(N/2)
  print(a)
  
else:##そうじゃなかった場合 ->奇数の場合
  N = N + 1
  a = int(N/2)
  print(a)

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

int main() {
  int N, Q; cin >> N >> Q;
  string S; cin >> S;
  vector<pair<int, int>> LR(Q);
  for (int i = 0; i < Q; i++) {
    int l, r; cin >> l >> r;
    LR.at(i) = make_pair(l, r);
  }
  vector<int> sum(N, 0);
  for (int i = 1; i < N; i++) {
    sum.at(i) = sum.at(i-1);
    if (S.at(i) == 'C' && S.at(i-1) == 'A') sum.at(i)++;
  }
  for (auto p : LR) {
    cout << sum.at(p.second - 1) - sum.at(p.first - 1) << endl;
  }
}

Measured memory_bytes: 2176
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc= new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		int a[][]=new int[n][m];
		int b[]=new int[m];
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				a[i][j]=sc.nextInt();
			}
		}
		for(int i=0;i<m;i++){
			b[i]=sc.nextInt();
		}
		for(int i=0;i<n;i++){
			int c=0;
			for(int j=0;j<m;j++){
				c+=a[i][j]*b[j];
			}
			System.out.println(c);
		}
	}
}

Measured memory_bytes: 40692
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main(void){
    int K, S;
    cin >> K >> S;
    int ans = 0;
    rep(z,K+1) ans += max(0, min(2*K-S+z+1, S-z+1));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#ABC085C/Otoshidama
def main():
    n,y = map(int,input().split())

    for i in range(n+1):
        for j in range(n-i+1):
            if 10000*i + 5000*j + 1000*(n-i-j) == y:
                print(i,j,(n-i-j))
                exit()
    print("-1 -1 -1") 
main()

Measured memory_bytes: 38768
def solve():
    def recur(i, n, total):
        # print("i, n, total", i, n, total)

        if not TABLE[i][n][total] == -1:
            # print('cache!')
            return TABLE[i][n][total]

        if not i < N:
            if n > 0 and total == A * n:
                return 1
            return 0

        ans1 = recur(i + 1, n, total)
        ans2 = recur(i + 1, n + 1, total + XS[i])

        # print(ans1, ans2)

        TABLE[i][n][total] = ans1 + ans2
        return TABLE[i][n][total]

    N, A = tuple(map(int, input().split()))
    XS = tuple(map(int, input().split()))

    TABLE = []
    for _ in range(N + 1):
        lines = [[-1 for x in range(N * 50 + 1)] for y in range(N + 1)]
        TABLE.append(lines)

    return recur(0, 0, 0)


if __name__ == '__main__':
    print(solve())


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

ave = sum(a) / n
ans_i = 0
ans_v = float("inf")
for i in range(n):
    if abs(ans_v - ave) > abs(a[i] - ave):
        ans_i = i
        ans_v = a[i]

print(ans_i)

Measured memory_bytes: 3064
N,M=map(int,input().split())
abs_NM=abs(N-M)
if abs_NM>1:
    print(0)
    exit()

p=10**9+7
min_=min(N,M)
max_=max(N,M)
ans=1
for i in range(1,min_+1):
    ans=(ans*i)%p
    ans=(ans*i)%p

if abs_NM==1:
    ans=(ans*max_)%p
else:
    ans=(ans*2)%p

print(ans)

Measured memory_bytes: 9204
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int t = sc.nextInt();
    if(X - t < 0) {
      System.out.println(0);
      return;
    }
    System.out.println(X - t);
  }
}


Measured memory_bytes: 21972
N,A,B,C=map(int,input().split())
l=[int(input()) for i in range(N)]
odr=[4**i for i in range(N)][::-1]
minL=1145141919
for i in range(4**N):
    a=0
    b=0
    c=0
    count=0
    mod=i
    for j in range(N):
        idx,mod=divmod(mod,odr[j])
        if idx==1:
            a+=l[j]
            count+=10
        elif idx==2:
            b+=l[j]
            count+=10
        elif idx==3:
            c+=l[j]
            count+=10
    sumL = abs(a-A)+abs(b-B)+abs(c-C)+count-30
    minL = sumL if sumL<minL and min(a,b,c)>0 else minL
print(minL)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
const int mod = 1e9 + 7;

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

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

    vector<int> a(N + 1, true);
    for (int i = 0; i < M; i++) {
        int tmp;
        cin >> tmp;
        a[tmp] = false;
    }

    vector<long long int> dp(N + 1);
    dp[0] = 1;
    for (int now = 0; now < N; now++) {
        for (int next = now + 1; next <= min(N, now + 2); next++) {
            if (a[next]) {
                dp[next] += dp[now];
                dp[next] %= mod;
            }
        }
    }

    cout << dp[N] << '\n';
    return 0;
}

Measured memory_bytes: 1408
c[10];
main(){
	int n,t;
	for(;scanf("%d",&n),n;){
		for(;n--;){
			scanf("%d",&t);
			c[t]++;
		}
		for(t=0;t<10;t++){
			if(c[t])
				for(;c[t];c[t]--)
					putchar('*');
			else
				putchar('-');
			putchar('\n');
		}
	}
	exit(0);
}

Measured memory_bytes: 368
//creator :Harjot Singh	

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define vi vector<int> 
#define vll vector<long long > 
#define loop(i,a,b) for(int i=a;i<=b;i++)
#define vii vector<vector<int>> 
#define ll long long 

int main()
{


     int n;
     cin>>n;
     int ac=0;
     int wa=0;
     int tle=0;
     int re=0;
     string s;

     loop(i,1,n)
     {
     	cin>>s;
     	if(s=="AC") ac++;
     	else  if(s=="WA") wa++;
     	else  if(s=="TLE") tle++;
     	else  re++;

     }  

     cout<<"AC "<<"x "<<ac<<endl;
     cout<<"WA "<<"x "<<wa<<endl;
     cout<<"TLE "<<"x "<<tle<<endl;
     cout<<"RE "<<"x "<<re<<endl;

	return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int n,k;
  cin>>n>>k;	// data input
  int p[n];
  double e[n];
  double sum=0;
  for(int i=0; i<n; i++)
  {
    cin>>p[i];	// data input
    e[i]=(double)(p[i]+1)/2; //expectancy
    sum+=e[i];
  }
  
  double ans;
  for(int i=0; i<k; i++)
  {
    ans+=e[i];
  }
  double temp=ans;
  for(int i=1; i+k<=n; i++)
  {
    temp=temp-e[i-1]+e[i+k-1];
    ans=max(ans,temp);
  }
  
  cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 2560
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<bitset>
using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+8
#define EPS 1e-8
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = (j); i < (k); i++)
int main(){
	int a,b,c;
	while(scanf("%d%d%d",&a,&b,&c),a){
		int n;
		scanf("%d",&n);
		int ok[512];
		fill(ok,ok+500,2);
		int x[1024],y[1042],z[1024],state[1024];
		for(int i = 0; i < n; i++){
			scanf("%d%d%d%d",&x[i],&y[i],&z[i],&state[i]);
		}
		for(int i = 0; i < n; i++){
			if(state[i] == 1){
				ok[x[i]]=ok[y[i]] = ok[z[i]] = 1;
			}
		}
		for(int i = 0; i < n; i++){
			if(ok[x[i]] == 1 && ok[y[i]] == 1 && ok[z[i]] == 2)ok[z[i]] = 0;
			if(ok[x[i]] == 1 && ok[y[i]] == 2 && ok[z[i]] == 1)ok[y[i]] = 0;
			if(ok[x[i]] == 2 && ok[y[i]] == 1 && ok[z[i]] == 1)ok[x[i]] = 0;
		}
		for(int i = 1; i <= a+b+c; i++){
			printf("%d\n",ok[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 1204
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;


int N;
vector<int> s[1000];
int main()
{
	int k;
	
	while(cin>>N)
	{
		k=1;
		while((k*k-k)<2*N)	k++;
		if((k*k-k)==2*N)
		{
			for(int i=0;i<k;i++)
			s[i].clear();
			cout<<"Yes"<<endl;
			cout<<k<<endl;
			int num=1;
			for(int i=0;i<k;i++)
			{
				for(int j=i+1;j<k;j++)
				{
					s[i].push_back(num);
					s[j].push_back(num);
					num++;
				}
			}
			int l=s[0].size();
			for(int i=0;i<k;i++)
			{
				cout<<k-1;
				for(int j=0;j<l;j++)
				cout<<' '<<s[i][j];
				cout<<endl;
			}
		}
		else
		{
			cout<<"No"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2304
N=gets.to_i

actions = []
N.times do |n|
  actions << gets.split.map(&:to_i)  
end

dp_a = Array.new(N+1, 0)
dp_b = Array.new(N+1, 0)
dp_c = Array.new(N+1, 0)

N.times do |n|
  # a
  dp_a[n+1] = actions[n][0] + [dp_b[n], dp_c[n]].max
  # b
  dp_b[n+1] = actions[n][1] + [dp_a[n], dp_c[n]].max
  # c
  dp_c[n+1] = actions[n][2] + [dp_a[n], dp_b[n]].max
end

puts [dp_a[N], dp_b[N], dp_c[N]].max


Measured memory_bytes: 13948
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef complex<double> P;
static const double EPS = 1e-8;
static const int INF = (int)1e8;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) for (int i=0; i<(int)(n); ++i)
#define FOREQ(i,k,n) for (int i=(k); i<=(int)(n); ++i)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FIND(m,w) ((m).find(w)!=(m).end())

int c[10001][1261]={};
int main(void){
  int N,M;
  while(cin>>N>>M,N&&M){
    REP(i,10001)REP(j,1261)c[i][j]=0;
    int r;
    cin>>r;
    while(r--){
      int t,n,m,s;
      cin>>t>>n>>m>>s;
      REP(time,1260){
        if(time==t){
          if(s){
            c[m][time]++;
          }else{
            c[m][time]--;
          }
        }
      }
    }
    REP(m,10001)REP(time,1260)c[m][time+1]+=c[m][time];
    
    int q; cin>>q;
    while(q--){
      int ans = 0;
      int t1,t2,m;
      cin>>t1>>t2>>m;
      for(int time = t1; time < t2; time++){
        if(c[m][time]) ans ++;
      }
      cout<<ans<<endl;
    }
  }

  return 0;
}

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

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

//N=1のとき単調非減少
if(N==1){
    cout<<"Yes"<<endl;
    return 0;
}

int tmp,crr;
vector<int> H;
cin>>tmp;
for(int i=0;i<N-1;i++){
    cin>>crr;
    H.push_back(crr-tmp);
    if(crr-tmp<-1){
        cout
        <<"No"<<endl;
        return 0;    
    }
    tmp=crr;
}

for(int i=H.size()-1;i>=0;i--){
    if(H[i]==-1){
        H[i-1]-=1;
        if(H[i-1]<-1){
            cout<<"No"<<endl;
            return 0;    
        }
    }
}
cout<<"Yes"<<endl;
//system("pause");
return 0;
}

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

struct Node{
    int key;
    Node *prev,*next;
};

Node* nil;

void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void insert(int key){
    Node* x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

Node* search(int key){
    Node* cur=nil->next;
    while(cur != nil && cur->key != key){
        cur = cur->next;
    }
    return cur;
}

void deleteNode(Node *t){
    if(t==nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);//tのメモリ領域解放する
}

void deleteFirst(){
    deleteNode(nil->next);
}

void deleteLast(){
    deleteNode(nil->prev);
}

void deleteKey(int key){
    deleteNode(search(key));
}

void printList(){
    Node *cur = nil->next;
    int isf=0;
    while(1){
        if(cur==nil) break;
        if(isf++>0) cout << " ";
        printf("%d",cur->key);
        cur = cur->next;
    }
    cout << endl;
}

int main(){
    vector<int> v;
    queue<string> command;
    int n;
    char com[100];
    int d;
    cin >> n;
    init();
    for(int i=0;i<n;i++){
        scanf("%s%d",com,&d);
        if(com[0]=='i'){insert(d);}
        else if (com[0]=='d'){
            if(strlen(com)>6){
                if(com[6]=='F') deleteFirst();
                else if(com[6]=='L') deleteLast();
            }else{
                deleteKey(d);
            }
        }
    }
    
    printList();
    return 0;
}


Measured memory_bytes: 34376
import sys
input = sys.stdin.readline

n = int(input())
x = list(map(int, input().split()))
sort_x = sorted(x)
check = sort_x[n//2]
for i in range(n):
    if check <= x[i]:
        ans = sort_x[n//2-1]
    else:
        ans = check
    print(ans)


Measured memory_bytes: 25220