akhauriyash/Code-Regression huggingface dataset:
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;

fn main() {
    let n: usize;
    input!(n);
    let mut sum = 0;
    for _ in 0..n {
        let (a, b): (usize, usize);
        input!(a, b);
        sum += b - a + 1;
    }
    p(sum);
}

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

int main(){
	string s;
	int n;
	cin>>n;
	cin>>s;
	int ans=0,ma=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='I'){
			ans++;
		}
		if(s[i]=='D'){
			ans--;
		}
		ma=max(ma,ans);
	}
	cout<<ma<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second

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

const int N=100005;
vector<pi>e[N];
int n,weight[2],w,sz[N];
ll ans;

void dfs(int x,int fa){
	int y=0,v;
	sz[x]++;
	for(auto i:e[x])if((v=i.fi)!=fa){
		dfs(v,x),sz[x]+=sz[v],y=max(y,sz[v]);
		ans+=(ll)min(sz[v],n-sz[v])*i.se*2;
	}
	y=max(y,n-sz[x]);
	if(y<=n/2)weight[w++]=x;
}

int main(){
	scanf("%d",&n);
	for(int i=1,u,v,c;i<n;i++)scanf("%d%d%d",&u,&v,&c),e[u].pb({v,c}),e[v].pb({u,c});
	dfs(1,0);
	if(w==2){
		for(auto i:e[weight[0]])if(i.fi==weight[1]){ans-=i.se;break;}
	}else{
		int mv=1e9;
		for(auto i:e[weight[0]])if(mv>i.se)mv=i.se;
		ans-=mv;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 12800
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 100100
#define PI 3.141592653589793238
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans%p;
}
ll inv(ll a,ll m)
{
    return power(a,m-2,m);
}
//code begins
void solve(){
    ll n,k;cin>>n>>k;
    ll a[n+1];
    for(ll i=1;i<=n;i++)cin>>a[i];
    for(ll i=k+1;i<=n;i++)
        if(a[i]>a[i-k])cout<<"Yes\n";
        else cout<<"No\n";
}
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);cout.tie(NULL);

//    ll t;cin>>t;while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 5176
#!/usr/bin/env python3

import sys

P_NUM = 1000000007


def solv(n, m, a):
    comb_m2 = 1
    if 1 in a:
        comb_m1 = 0
    else:
        comb_m1 = 1

    comb = 1
    for i in range(2, n+1):
        if i in a:
            comb = 0
            a.remove(i)
        else:
            comb = (comb_m1 + comb_m2) % P_NUM

        comb_m1, comb_m2 = comb, comb_m1

    return comb


if __name__ == '__main__':

    n, m = map(int, input().split())
    if m:
        a = set(map(int, sys.stdin))
    else:
        a = set()

    ans = solv(n, m, a)

    print(ans)


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

int main(){

        long long N;
        long long i;
        double rt;
        long long up;
        long long minval;
        int digits=0;

        scanf("%lld",&N);
        rt = (double ) N;
        rt = sqrt (rt);
        up = 1 + (long long) rt;
        for(i=1; i<up; i++)
        {
                if((N%i)==0) minval=N/i;

        }
        for(i=1; i<11; i++){
                if(minval>=1) digits++;
                minval = minval/10;
        }
        printf("%d \n",digits);

        return 0;
}


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

template <int MOD = 1000000007>
struct Mint {
    int x;

    Mint() : x(0) {}
    Mint(long long t) {
        x = t % MOD;
        if (x < 0) x += MOD;
    }

    Mint pow(int n) {
        Mint res(1), t(x);
        while (n > 0) {
            if (n & 1) res *= t;
            t *= t;
            n >>= 1;
        }
        return res;
    }

    Mint inv() const {
        int a = x, b = MOD, u = 1, v = 0, t;
        while (b > 0) {
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return Mint(u);
    }

    Mint &operator+=(Mint a) {
        x += a.x;
        if (x >= MOD) x -= MOD;
        return *this;
    }

    Mint &operator-=(Mint a) {
        x += MOD - a.x;
        if (x >= MOD) x -= MOD;
        return *this;
    }

    Mint &operator*=(Mint a) {
        x = int(1LL * x * a.x % MOD);
        return *this;
    }

    Mint &operator/=(Mint a) {
        return (*this) *= a.inv();
    }

    Mint operator+(Mint a) const {
        return Mint(x) += a;
    }
    Mint operator-(Mint a) const {
        return Mint(x) -= a;
    }
    Mint operator*(Mint a) const {
        return Mint(x) *= a;
    }
    Mint operator/(Mint a) const {
        return Mint(x) /= a;
    }

    Mint operator-() const {
        return Mint(-x);
    }

    bool operator==(const Mint a) {
        return x == a.x;
    }
    bool operator!=(const Mint a) {
        return x != a.x;
    }
    bool operator<(const Mint a) {
        return x < a.x;
    }

    friend ostream &operator<<(ostream &os, const Mint &a) {
        return os << a.x;
    }

    friend istream &operator>>(istream &is, Mint &a) {
        int t;
        is >> t;
        a = Mint<MOD>(t);
        return (is);
    }
};

signed main() {
    int n;
    cin >> n;
    cout << Mint<>(10).pow(n) - Mint<>(9).pow(n) - Mint<>(9).pow(n) +
                Mint<>(8).pow(n)
         << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int a, b, c;
  cin >> a >> b >> c;
  bool isPoor = false;
  if (a == b && b != c) isPoor = true;
  if (b == c && c != a) isPoor = true;
  if (c == a && a != b) isPoor = true;

  if (isPoor) cout << "Yes" << endl;
  else cout << "No" << endl;

}


Measured memory_bytes: 3548
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

#define INF 1e9+7

int main() {
    int S, first, second;
    cin >> S;

    first = S / 100;
    second = S % 100;

    if (1 <= first&&first <= 12) {
        if (1 <= second&&second <= 12)cout << "AMBIGUOUS";
        else cout << "MMYY";
    }
    else {
        if (1 <= second&&second <= 12)cout << "YYMM";
        else cout << "NA";
    }
}

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

using namespace std;

typedef pair<int,int> pii;
#define N 2200

int n,m,tot,x,y,head[N],f[N][N],ans,lca[N][N],q[N];
bool vis[N];
struct edge{int v,nxt;}e[N<<1];

void ins(int,int);

struct tree{
	int rt,fa[N],d[N];
	void dfs(int u){
		d[u]=d[fa[u]]+1;
		for (int i=head[u],v;i;i=e[i].nxt)
			if ((v=e[i].v)!=fa[u]){fa[v]=u; dfs(v);}
	}
	void cov(int o,vector<pii> &ed){
		int tt=0,ww=1; q[1]=o;
		f[rt][o]=o;
		while (tt<ww){
			int u=q[++tt];
			for (int i=head[u],v;i;i=e[i].nxt)
				if ((v=e[i].v)!=fa[u]){
					if (f[rt][v]){
						ed.emplace_back(o,f[rt][v]);
						f[rt][v]=o;
					}
					else{f[rt][v]=o; q[++ww]=v;}
				}
		}
	}
}T[N];

void add(int x,int y){
	e[++tot].v=y; e[tot].nxt=head[x]; head[x]=tot;
}

void ins(int x,int y){
	if (x==y) return;
	if (f[x][y]==y) return;
	if (f[x][y]){ins(f[x][y],y); return;}
	if (f[y][x]){ins(f[y][x],x); return;}
	vector<pii> ed;
	T[x].cov(y,ed);
	T[y].cov(x,ed);
	for (auto i:ed) ins(i.first,i.second);
}

void getlca(int x,int y){
	if (lca[x][y]) return;
	if (x==y) lca[x][y]=x;
	else{
		if (T[1].d[x]<T[1].d[y]) swap(x,y);
		getlca(T[1].fa[x],y);
		lca[x][y]=lca[y][x]=lca[T[1].fa[x]][y];
	}
}

bool calclca(int x,int y,int z){
	int t=lca[x][y]^lca[y][z]^lca[z][x];
	return t==x||t==y||t==z;
}

void calc(int u,int o){
	vis[u]=1; ++ans;
	for (int i=head[u],v;i;i=e[i].nxt)
		if (!vis[v=e[i].v]&&calclca(u,o,v)) calc(v,u);
}

int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<n;++i){
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	for (int i=1;i<=n;++i){T[i].rt=i; T[i].dfs(i);}
	for (int i=1;i<=n;++i)
		for (int j=1;j<=n;++j) getlca(i,j);
	for (int i=1;i<=m;++i){
		scanf("%d%d",&x,&y);
		ins(x,y);
	}
	memset(head,0,sizeof head); tot=0;
	for (int i=1;i<=n;++i)
		for (int j=1;j<=n;++j)
			if (i!=j&&f[i][j]==j) add(i,j);
	for (int i=1;i<=n;++i){
		memset(vis,0,sizeof vis); calc(i,i);
	}
	printf("%d\n",(ans-n)/2);
	
	return 0;
}
			

Measured memory_bytes: 72448
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string str;
	cin >> str;
	str[3] = '8';
	cout << str << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

bool can(ll x, ll p) {
  while(x % p == 0) {
    x /= p;
  }
  return x % p == 1;
}

int main() {
  ll H; read(H);
  ll ans = 0;
  for(ll i = 1; i <= H; i *= 2LL) {
    ans += i;
  }
  print(ans);
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int d = sc.nextInt();
		int MAX = h * w + 1;
		int[] x = new int[MAX];
		int[] y = new int[MAX];
		int[][] dd = new int[h][w];

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				int a = sc.nextInt();
				y[a] = i;
				x[a] = j;
			}
		}

		for (int i = 1; i < MAX; i++) {
			if (i <= d) {
				dd[y[i]][x[i]] = 0;
			} else {
				dd[y[i]][x[i]] = dd[y[i-d]][x[i-d]] + mp(y[i], x[i], y[i-d], x[i-d]);
			}
		}

		int q = sc.nextInt();
		for (int i = 0; i < q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			int dl = dd[y[l]][x[l]];
			int dr = dd[y[r]][x[r]];

			System.out.println(dr - dl);
		}
	}

	private static int mp(int y1, int x1, int y2, int x2) {
		return Math.abs(y2 - y1) + Math.abs(x2 - x1);
	}
}


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

using namespace std;

#define LL long long

LL n,a,b,f[500000];

int main(){
	scanf("%lld%lld%lld",&n,&a,&b);
	if (a+b>n+1||n>a*b){puts("-1"); return 0;}
	for (LL i=1;i<=n;i++){
		LL j=i/b;
		if (i%b) j++;
		if (n-i+j==a){
			for (LL k=1;k<j;k++)
				for (LL l=b;l>=1;l--)
					f[(k-1)*b+b-l+1]=(k-1)*b+l;
			for (LL k=n;k>i;k--) f[k]=k;
			for (LL k=i,l=b*(j-1)+1;l<=i;l++,k--) f[l]=k;
			break;
		}
	}
	for (LL i=1;i<=n;i++) printf(i==n?"%lld\n":"%lld ",f[i]);
	
	return 0;
}
			

Measured memory_bytes: 4480
#include <iterator>
#include <algorithm>
#include <iostream>
#include <unordered_set>
#include <vector>
#include <sstream>
#include <iomanip>
#include <string>
using namespace std;
int main(int argc, char **argv) {
  int N;
  cin >> N;

  vector<int> H;
  H.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  int ans = 1;
  for (int i = 1; i < N; i++) {
    int j = i-1;
    while (j >= 0 && H[i] >= H[j])
      --j;

    if (j < 0)
      ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python2
# -*- coding: utf-8 -*-

import itertools

while True:
    n, s = map(int, raw_input().split())
    if n == 0 and s == 0:
        break
    L = [i for i in xrange(10)]
    cnt = 0
    for i in itertools.combinations(L, n):
        if sum(i) == s:
            cnt += 1
    print cnt

Measured memory_bytes: 4712
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 156
#define fi(a, b, c, d) for(int a = b; i < c; i += d)
#define fl(a, b, c, d) for(ll a = b; i < c; i += d)

ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;


int main() {
	scanf("%lld %lld %lld", &A, &B, &C);
	ll X = (A + B);
	C -= X;
	ll temp = (C * C);
	if(C > 0 && temp > 4 * A * B) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}
/*
	Powered by Buggy Plugin
*/




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

int main(){
  int n;
  while(cin >> n){
    int a = 1;
    bool first = true;
    while(true){
      if(n % 2  == 1){
	if(first) first = false;
	else cout << " ";
	cout << a;
      }
      a *= 2;
      n /= 2;
      if(n == 0) break;
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 1160
/* AOJ 0065
 *
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0065
 *
 */

#include <stdio.h>
#include <string.h>

#define DEBUG 0

typedef struct TRecord Record;
struct TRecord {
    int fID;
    int fValue;
};

Record last[1000];
int last_n;
Record this[1000];
int this_n;

Record match[2002];
int match_n;


int comp(const void* a, const void*b){
    return ((Record*)a)->fID - ((Record*)b)->fID;
}


int load(char* buf, Record* xs, int xn){
    int id, date;
    
    sscanf(buf, "%d,%d",&id, &date);
    xs[xn].fID = id;
    xs[xn].fValue = date;
    return xn + 1;
}

int main(){
    char buf[101];
    int i,j,k;
    int chunk;
    int last_id;


    chunk = 0;
    this_n = 0;
    last_n = 0;

    while(fgets(buf, 100, stdin)){
        if(strlen(buf) > 2){
            if(chunk == 0){
                this_n = load(buf, this, this_n);
            }
            if(chunk == 1){
                last_n = load(buf, last, last_n);
            }
        }else{
            chunk++;
        }
    }

    if(DEBUG){
        for(i=0;i<this_n;i++){
            printf("%d %d\n", this[i].fID, this[i].fValue);
        }
        printf("====\n");
    }

    if(DEBUG){
        for(i=0;i<last_n;i++){
            printf("%d %d\n", last[i].fID, last[i].fValue);
        }
        printf("====\n");
    }


    match_n = 0;
    for(i=0;i<this_n;i++){
        for(j=0;j<last_n;j++){
            if(DEBUG){
                printf("%d %d\n", i,j);
            }
            if(this[i].fID == last[j].fID){
                match[match_n].fID = this[i].fID;
                match_n++;
            }
        }
    }
    if(DEBUG){
        printf("%d\n", match_n);
    }

    for(k=0;k<match_n;k++){
        for(i=0;i<this_n;i++){
            if(this[i].fID == match[k].fID){
                match[k].fValue++;
            }
        }
        for(j=0;j<last_n;j++){
            if(last[j].fID == match[k].fID){
                match[k].fValue++;
            }
        }
    }

    qsort(match, match_n, sizeof(Record), comp);

    last_id = -1;
    for(k=0;k<match_n;k++){
        if(last_id != match[k].fID){
            last_id = match[k].fID;
            printf("%d %d\n", match[k].fID, match[k].fValue);
        }
    }
    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int dir[8][2]= {{1,0},{-1,0},{0,1},{0,-1},{1,1},{-1,-1},{1,-1},{-1,1}};
int main()
{
    int i,j,a,b,d[55][55];
    char c[55][55];
    while(cin>>a>>b)
    {
        memset(d,0,sizeof(d));
        for(i=0; i<a; i++)
            scanf("%s",c[i]);
        for(i=0; i<a; i++)
            for(j=0; j<b; j++)
            {
                if(c[i][j]=='#')//如果出现的字符是#    则做标记d[i][j]=-1;
                    d[i][j]=-1;
                else//如果是.   则做计算它附近的八个点   有几个#
                    for(int k=0; k<8; k++)
                    {
                        int newx=i+dir[k][0];
                        int newy=j+dir[k][1];
                        if(newx>=0 && newx<a && newy >=0 && newy <b)  //判断是否越界
                            if(c[newx][newy]=='#')
                                d[i][j]=d[i][j]+1;//我的计数包括了我本身的点  但是本身的点就是.  不会影响计数
                    }
            }
        for(i=0; i<a; i++)
        {
            for(j=0; j<b; j++) //输出每个.身边有多少#   如果是#  则输出#
            {
                if(d[i][j]==-1)
                    cout<<'#';
                else
                    cout<<d[i][j];
            }
            cout<<endl;
        }
    }

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define EVEL 1

#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;

    int A,B,C;
    int N,M,K,X,Y,W,H;
    int ans;
    string S;
    int temp[100]={0};
    bool f=true;
    bool fir=true;

int main(){
    cin>>A>>B>>C;
    A<=C&&C<=B?cout<<"Yes":cout<<"No";
    return 0;

}


Measured memory_bytes: 256
n = int(input())
a = [int(i)-1 for i in input().split()]


count = 0
if a[-1] == n-1:
    b = a[-1]
    a[-1] = a[-2]
    a[-2] = b
    count =1

for i in range(n):
    if a[i] == i:
        b = a[i]
        a[i] = a[i+1]
        a[i+1] = b
        count +=1
print(count)

Measured memory_bytes: 13880
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
ll mod=pow(10,9)+7;

struct Combination{
    vec n,n_rev;

    Combination(int N){
        n.resize(N+1);
        n_rev.resize(N+1);
        n[0]=1;n_rev[1]=1;
        for(int i=1;i<=N;i++){
            n[i]=((ll)i*n[i-1])%mod;
        }
        for(int i=2;i<=N;i++){
            n_rev[i]=matpow(n[i],mod-2);
        }
    }

    //累乗(aのk乗)
    ll matpow(ll a,int k){
        ll dp=1,mt=a;
        while(k>0){
            if(k & 1)dp=(dp*mt)%mod;
            mt=(mt*mt)%mod;
            k/=2;
        }
        return dp;
    }

    ll comb(int N,int r){  
        if(r==0 || N==r)return 1;
        return (((n[N]*n_rev[r])%mod)*n_rev[N-r])%mod;
    }
};

int main(){
    int n,k;cin>>n>>k;
    Combination Comb(n);
    ll ans=0;
    int M=min(n-1,k);
    for(int i=0;i<=M;i++){
        ans=(ans+(Comb.comb(n,i)*Comb.comb(n-1,i))%mod)%mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>

using namespace std;


#define WA cout << "WA" << endl; return;


class B {
	string S;
public:
	void solve()
	{
		cin >> S;

		bool containsC{ false };

		if (S[0] != 'A')
		{
			WA
		}

		if (S[1] <= 'Z' || S.back() <= 'Z')
		{
			WA
		}

		for (int i{ 2 }; i < S.size() - 1; i++)
		{
			if (S[i] == 'C')
			{
				if (containsC)
				{
					WA
				}
				containsC = true;
			}

			else
			{
				if (S[i] <= 'Z')
				{
					WA
				}
			}
		}

		if (!containsC)
		{
			WA
		}

		else
			cout << "AC" << endl;

	}
};


int main()
{
	B solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;

int main() {
	ll n, m;
	cin >> n >> m;
	VL x(n), y(m);
	REP(i, n) cin >> x[i];
	REP(i, m) cin >> y[i];
	ll Sx = 0,Sy = 0;
	REP(i, n){
		Sx += (i * x[i] - (n - 1 - i)*x[i]) % MOD;
		Sx %= MOD;
	}
	REP(i, m) {
		Sy += (i * y[i] - (m - 1 - i)*y[i]) % MOD;
		Sy %= MOD;
	}
	
	cout << (Sx*Sy) % MOD << endl;
	return 0;
}


Measured memory_bytes: 1792
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n, a = IR(2)
    n %= 500
    if a >= n:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    _ = II()
    a = LI()
    a.sort(reverse=True)
    op = 0
    ans = 0
    for ai in a:
        ans += -ai * op or ai
        op ^= 1
    print(ans)
    return

#C
def C():
    c = LIR(3)
    for x in range(c[0][0] + 1):
        b = (c[0][0] - x, c[0][1] - x, c[0][2] - x)
        if (c[1][0] - b[0]) == (c[1][1] - b[1]) == (c[1][2] - b[2]):
            if (c[2][0] - b[0]) == (c[2][1] - b[1]) == (c[2][2] - b[2]):
                print("Yes")
                return
    print("No")
    return
#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 39920
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a;
    cin>>a;
    for(int i=0;i<a.length()-1;i++)
    	if(a[i]=='C'){
    		for(int j=i+1;j<a.length();j++)
    			if(a[j]=='F'){cout<<"Yes";return 0;} 
			cout<<"No";
			return 0;
		}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
int s[1000]; 

void reset(void);

main()
{
	int n,i;
	double a=0,m=0;
	
	while(1){
		reset();
		a=0,m=0;
		scanf("%d",&n);
		if(n==0){break;}
		for(i=0;i<n;i++){
			scanf("%d",&s[i]);
		}
		
		for(i=0;i<n;i++){
			m+=s[i];
		}
		m/=(double)n;
		
		for(i=0;i<n;i++){
			a+=(double)((s[i]-m)*(s[i]-m));
		}
		a/=(double)n;
		
		a=sqrt(a);
		
		printf("%.8f\n",a);
	}
	return 0;
}

void reset(void){
	int a;
	for(a=0;a<1000;a++){
		s[a]=0;
	}
}

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

int main(void){
    // Your code here!
    bool answer=true;
    int n;
    cin>>n;
    int b;
    int a[1000]={0};
    for(int i=0;i<n;i++){
        cin>>b;
        for(int j=0;b!=0;j++){
            a[j]=(a[j]+b%2)%2;
            b/=2;
        }
    }
    for(int i=0;i<1000;i++){
        if(a[i]!=0){
            answer=false;
            break;
        }
    }
    if(answer) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

typedef long long int ll;

int main()
{
    string s;
    cin >> s;
    vector<ll> a(26, 0);
    ll len = s.length();
    for(ll i = 0;i < len;i++){
        a[s[i] - 'a']++;
    }

    bool f = true;
    for(ll i = 0;i < 26;i++){
        if(a[i] % 2 == 0){
        }
        else{
            f = false;
            break;
        }
    }

    if(f){
        cout << "Yes";
    }
    else{
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.read
def main():
    s = input()
    lens = len(s)
    mae_end = (lens - 1) // 2
    mae = s[:mae_end]
    if mae != mae[::-1]:
        print('No')
        sys.exit()
    ushiro_start = (lens+3) // 2 - 1
    ushiro = s[ushiro_start:]
    if mae != ushiro[::-1]:
        print('No')
        sys.exit()
    print('Yes')

if __name__ == '__main__':
    main()


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


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
#define all(v) v.begin(),v.end()
#define endl "\n"
#define clr(n, r) memset(n,r,sizeof(n));

void fast() {
    cin.tie(0);
    cin.sync_with_stdio(0);
}

int OO = 100000000,n,m;
int dp[100009];
vector<vector<int>>edges(1e5);
int ans(int i){
    int &ret=dp[i];
    if(~ret)return ret;
    if(i==n+1||edges[i].empty())return 0;
    ret =0;
    for (int j = 0; j <edges[i].size() ; ++j) {
        ret=max (ret,1+ans(edges[i][j]));
    }
    return ret;
}



int main() {
    fast();
    string s,b,c;cin>>s>>b>>c;
    char last='a';
    while(1){
        if(last=='a'){
            if(s.empty()){
                cout<<"A";
                break;
            }

            last=*s.begin();
            s.erase(s.begin());
        }
        else if(last=='b'){
            if(b.empty()){
                cout<<"B";
                break;
            }
            last=*b.begin();
            b.erase(b.begin());
        }
        else {
            if(c.empty()){
                cout<<"C";
                break;
            }
            last=*c.begin();
            c.erase(c.begin());
        }
    }
}

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

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

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

    private static void solve() {
        String s = in.next();
        StringBuilder ans = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            ans.append("x");
        }
        out.println(ans.toString());
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 23124
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
typedef pair<int, int> PII;
typedef long long ll;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


int H, W;
char s[60][60];
int dy[4] = { 0, 1, 0, -1 };
int dx[4] = { 1, 0, -1, 0 };
queue<PII> q;
bool used[60][60];
int d[60][60];


int main() {
	cin >> H >> W;
	rep(i, H) rep(j, W) cin >> s[i][j];

	q.push({ 0, 0 });
	while (!q.empty()){
		PII p = q.front();
		q.pop();
		used[p.fi][p.se] = true;
		rep(i, 4){
			int Y = p.fi + dy[i];
			int X = p.se + dx[i];
			if (0 <= Y && Y < H && 0 <= X && X < W && !used[Y][X] && s[Y][X] == '.'){
				d[Y][X] = d[p.fi][p.se] + 1;
				used[Y][X] = true;
				q.push({ Y, X });
			}
		}
	}

	int ans = 0;
	rep(i, H) ans += count(&s[i][0], &s[i][W], '.');

	if(d[H-1][W-1]) cout << ans - d[H-1][W-1]-1 << endl;
	else cout << -1 << endl;

	return 0;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
const int inf = 1000000001;
const ll INF = 2e18;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };



int main() {
	string s;
	cin >> s;
	if (s.size() == 1) {
		cout << s << endl;
		return 0;
	}
	bool M = true;
	int ans = 0;
	rep1(i, s.size() - 1) {
		if (s[i] != '9') {
			M = false;
			break;
		}
	}
	if (M) {
		rep(i, s.size()) {
			ans += s[i] - '0';
		}
		cout << ans << endl;
		return 0;
	}
	ans = 0;
	ans += (s[0] - '0') - 1;
	rep(i, s.size() - 1) {
		ans += 9;
	}
	cout << ans << endl;
}

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

i64 pow_mod(i64 a, i64 r, i64 m) {
  i64 ans = 1;
  while(r) {
    if(r & 1) ans = (ans * a) % m;
    r >>= 1;
    a = (a * a) % m;
  }
  return ans;
}

int main() {
  i64 N, K, M;
  cin >> N >> K >> M;
  i64 all = pow_mod(K, N, M);
  if(2 * K < N) {
    cout << all << endl;
    return 0;
  }

  vector<vector<i64>> dp(1 << (2 * K - 1), vector<i64>(K, 0));
  for(i64 i = 0;i < K;i++) dp[0][i] = 1;
  for(i64 s = 0;s < (1 << (2 * K - 1));s++) {
    for(i64 i = 0;i < K;i++) {
      for(i64 j = 0;j < K;j++) {
        if(s & (1 << (j - i + K - 1))) continue;
        (dp[s | (1 << (j - i + K - 1))][j] += dp[s][i]) %= M;
      }
    }
  }
  for(i64 s = 0;s < (1 << (2 * K - 1));s++) {
    for(i64 i = 0;i < K;i++) {
      if(__builtin_popcountll(s) == N - 1) {
        all = (all - dp[s][i] + M) % M;
      }
    }
  }
  cout << all << endl;
}



Measured memory_bytes: 64352
H,W=map(int,input().split())
A=[list(map(int,input().split())) for i in range(H)]

t=0
ans=[]
for i in range(H):
	a=A[i]
	if i%2==0:
		for j in range(W-1):
			if (a[j]+t)%2!=0:
				ans.append([i,j,i,j+1])
				t=1
			else:
				t=0
		
		if (a[-1]+t)%2!=0 and (i+1)<H:
			ans.append([i,W-1,i+1,W-1])
			t=1
		else:
			t=0
	else:
		for j in range(1,W)[::-1]:
			if (a[j]+t)%2!=0:
				ans.append([i,j,i,j-1])
				t=1
			else:
				t=0
		
		if (a[0]+t)%2!=0 and (i+1)<H:
			ans.append([i,0,i+1,0])
			t=1
		else:
			t=0

print(len(ans))
for a in ans:
	for i in range(4):a[i]+=1
	print(*a)

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

int main() {
	string S, ans;
	cin >> S;
	
	for (int i = 0; i < S.size(); i++){
		if(S[i]=='0'){
			ans += '0';
			
		}else if(S[i]=='1'){
			ans += '1';
			
		}else if(S[i]=='B'){
			if(ans.size()) ans.pop_back();
			
		}
		
	}
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  vector<vector<int>> a(n, vector<int>(m));
  for (int i = 0; i < k; i++) {
    int r, c, v;
    cin >> r >> c >> v;
    --r; --c;
    a[r][c] = v;
  }
  vector<vector<vector<long long>>> dp(n + 1, vector<vector<long long>>(m + 1, vector<long long>(5)));
  auto upd = [&](int i1, int j1, int s1, int i2, int j2, int s2, long long v) {
    dp[i1][j1][s1] = max(dp[i1][j1][s1], dp[i2][j2][s2] + v);
    dp[i1][j1][4] = max(dp[i1][j1][4], dp[i1][j1][s1]);
  };
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int s = 0; s < 4; s++) {
        upd(i + 1, j + 1, s, i, j + 1, 4, 0);
        upd(i + 1, j + 1, s, i + 1, j, s, 0);
        if (s != 0) {
          upd(i + 1, j + 1, s, i, j + 1, 4, a[i][j]);
          upd(i + 1, j + 1, s, i + 1, j, s - (bool) a[i][j], a[i][j]);
        }
      }
    }
  }
  cout << dp[n][m].back() << '\n';
  return 0;
}


Measured memory_bytes: 671796
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using pii = pair<int, int>;
const int MOD = (int)1e9 + 7, INF = (1 << 27); const ll INFLL = (1LL << 55);
#define FOR(i,a,b) for(int (i)=(a);(i)<(int)(b);(i)++)
#define rep(i,n) FOR(i,0,n)
template<typename T, typename U> inline void chmax(T &x, U y) { if (x < y) x = y; }
template<typename T, typename U> inline void chmin(T &x, U y) { if (x > y) x = y; }


int main() {
	int t, x;
	cin >> t >> x;
	printf("%.10f", 1.0 * t / x);
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    for (int i = 1, ai; i <= N; i++) {
        cin >> ai;
        mp.emplace(ai, 0).first -> second++;
    }
    int diameter = mp.rbegin() -> first;
    for (int i = 0; i <= diameter; i++) {
        int a = max(i, diameter - i);
        auto it = mp.find(a);
        if (it == mp.end()) goto impossible;
        if (--(it -> second) == 0) mp.erase(it);
    }
    if (!mp.empty() && mp.begin() -> first <= (diameter + 1) / 2) goto impossible;
    possible:
    cout << "Possible\n";
    return 0;

    impossible:
    cout << "Impossible\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
    int N, M;
    std::cin >> N >> M;

    int ans = 0;

    if (N >= 2)
    {
        ans += N * (N - 1) / 2;
    }

    if (M >= 2)
    {
        ans += M * (M - 1) / 2;
    }

    std::cout << ans << std::endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;


int main(){

	int N,tmp,count,right,pre,sum;
	bool FLG,AGARI;
	vector<int> V;

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		V.clear();

		sum = 0;
		for(int i = 0; i < N; i++){
			scanf("%d",&tmp);
			V.push_back(tmp);
			sum += tmp;
		}

		FLG = false;

		for(int k = 1; ;k++){
			if(k*(k+1)/2 == sum){
				FLG = true;
				break;
			}
			if(k*(k+1)/2 > sum){
				break;
			}
		}

		if(!FLG){
			count = 10000;
		}else{
			count = 0;
		}

		FLG = false;
		while(count < 10000){

			AGARI = true;
			pre = 0;

			for(int i = 0; i < V.size(); i++){
				if(V[i] > 0){
					if(V[i] != pre+1){
						AGARI = false;
						break;
					}
					pre = V[i];
				}
			}

			if(AGARI){
				FLG = true;
				break;
			}

			right = 0;
			for(int i = 0; i < V.size(); i++){
				if(V[i] > 0){
					V[i]--;
					right++;
				}
			}
			V.push_back(right);

			for(int i = 0; i < V.size(); i++){
				if(V[i] == 0){
					V.erase(V.begin()+i);
				}
			}
			count++;
		}

		if(!FLG){
			printf("-1\n");
		}else{
			printf("%d\n",count);
		}
	}

	return 0;
}

Measured memory_bytes: 2764
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+100;
typedef long long ll;
int n;
int w[maxn];
int v[maxn];
ll dp[maxn];
int W;
int main(){
    scanf("%d%d",&n,&W);
    for (int i=0;i<n;i++){
        scanf("%d%d",w+i,v+i);
    }
    for (int i=0;i<n;i++){
        for (int j=W;j>=w[i];j--){
            dp[j] = max(dp[j],dp[j-w[i]] + v[i]);
        }
    }
    cout<<dp[W]<<endl;
    return 0;
}

Measured memory_bytes: 1024
n, m = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a)
r = s/(4*m)
a = sorted(a, reverse=True)
can = True
for x in a[:m]:
    if x < r:
        can = False
        break
if can: print("Yes")
else: print("No")


Measured memory_bytes: 3060
// ABC 147-B
// 2019.12.8 bal4u

#include <stdio.h>
#include <string.h>

char S[105];

int main()
{
	int i, j, w, ans;
	
	scanf("%s", S);
	w = strlen(S);
	ans = 0;
	for (i = 0, j = w-1; i < j; ++i, --j) {
		if (S[i] != S[j]) ans++;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
char S[1000010];
int K, N, Q, cnt[1000010];
int main(){
  int Lj4PdHRW, i, j, k;
  long long res, x, y;
  rd(N);
  rd(S);
  rd(Q);
  for(i=0;i<N;i++){
    cnt[i+1] = cnt[i];
    if(S[i]=='M'){
      cnt[i+1]++;
    }
  }
  for(Lj4PdHRW=0;Lj4PdHRW<Q;Lj4PdHRW++){
    rd(K);
    x = y = res = 0;
    for(i=0;i<N;i++){
      if(i >= K && S[i-K]=='D'){
        x--;
        y -= cnt[i]-cnt[i-K];
      }
      if(S[i]=='D'){
        x++;
      }
      if(S[i]=='M'){
        y += x;
      }
      if(S[i]=='C'){
        res += y;
      }
    }
    wt_L(res);
    putchar_unlocked('\n');
  }
  return 0;
}
// cLay varsion 20180730-1

// --- original code ---
// int N, Q, K;
// char S[1000010];
// int cnt[1000010];
// {
//   int i, j, k;
//   ll x, y, res;
//   rd(N,S,Q);
// 
//   rep(i,N){
//     cnt[i+1] = cnt[i];
//     if(S[i]=='M') cnt[i+1]++;
//   }
// 
//   rep(Q){
//     rd(K);
//     x = y = res = 0;
//     rep(i,N){
//       if(i >= K && S[i-K]=='D'){
//         x--;
//         y -= cnt[i]-cnt[i-K];
//       }
//       if(S[i]=='D') x++;
//       if(S[i]=='M') y += x;
//       if(S[i]=='C') res += y;
//     }
//     wt(res);
//   }
// }


Measured memory_bytes: 5120
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;
struct Edge {
    ll to;
    ll cost;
    Edge(ll t, ll w) : to(t), cost(w) { }
};

using Graph = vector<vector<Edge> >;
ll d[MAX];
Graph G(MAX);

void dijkstra(ll s) {
    fill(d, d + MAX, 1e18);
    d[s] = 0;  // 始点sへの最短距離は0

    priority_queue<P, vector<P>, greater<P> > que;  // 距離が小さい順に取り出せるようgreater<P>を指定
    que.push(P(0, s));
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        ll v = p.second;  // 更新した頂点の中で距離が最小の頂点v
        if (d[v] < p.first) {
            continue;
        }
        for (auto e : G[v]) {  // 頂点vから出る辺eを走査
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}


int main(){
  ll N,M,S;cin>>N>>M>>S;

  // 銀貨の数それぞれに関して違う頂点を考える

  rep(i,M){
    ll from, to , mar , weight;
    cin >> from >> to >> mar >>weight;
    rep(j,2500){
      // jは保有している銀貨の枚数
      if(mar > j) continue;
      else{
        G[from * 2500 + j].pb(Edge(to * 2500 + j - mar , weight));
        G[to * 2500 + j].pb(Edge(from * 2500 + j - mar , weight));
      }
    }
  }
  // 銀貨を増やすプロセスについての経路を作る
  repn(i,N){
    ll to, weight;
    cin >> to >> weight;
    rep(j,2500){
      if( ( j + to) >= 2500) continue;
      G[i * 2500 + j].pb(Edge(i * 2500 + j + to , weight));
    }
  }

  if(S >= 2500) S = 2499;
  dijkstra(1 * 2500 + S);

  //check
  /*
  repn(i,N){
    rep(j,10){
      cout<<d[i*2500 + j]<<" ";
    }
    cout<<endl;
  }
  */

  // ans出力
  for(ll i = 2; i <= N; i++){
    ll ans = 1e18;
    rep(j, 2500){
      ans = min(ans , d[i * 2500 + j]);
    }
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 35692
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Test | diff Test.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Test.cpp && ./a.out

/*
 
 5/2/2020
 
 15:47-
 
 */

string S;
int N;

string T;
bool ok(string &S, int x0, int x1) {
  int N=SZ(S);
  VI x(N,-1);
  x[0]=x0,x[1]=x1;
  
  auto nex=[&](int ani, int sign, int left)->int {
    if(ani==sign) return left^1;
    else return left;
  };
  
  FOR(i,1,N-1) {
    int l=x[i-1];
    int ani=x[i],sign=S[i]=='o';
    x[i+1]=nex(ani,sign,l);
  }
  int y=nex(x[N-1],S[N-1]=='o',x[N-2]);
  
  string ani="SW";
  T=string(N,'?');
  REP(i,N) T[i]=ani[x[i]];

  return x[0]==y&&x[N-1]==nex(x[0],S[0]=='o',x[1]);
}
void solve() {
  REP(i,2)REP(j,2) if(ok(S,i,j)) {
    cout<<T<<endl;
    return;
  }
  cout<<-1<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>S;
  solve();
  
  return 0;
}


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

#define ll long long
#define ar array

int n, W;
ll dp[100001];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	fill(dp+1, dp+100001, -1e18);
	cin >> n >> W;
	for (int i=0, w, v; i<n; ++i) {
		cin >> w >> v;
		for (int i=W; i>=w; --i)
			dp[i]=max(dp[i], dp[i-w]+v);
	}
	ll ans=0;
	for (int i=1; i<=W; ++i) ans=max(ans, dp[i]);
	cout << ans;
	return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/



Measured memory_bytes: 4288