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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)1e9+7

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

signed main() {
  string s;
  string a = "dream", b = "dreamer", c = "erase", d = "eraser";
  cin >> s;
  string ss = "";
  for(int i = 0; i < s.length(); i++) {
    string e;
    if(s[i] == 'd') e = a;
    else if(s[i] == 'e') e = c;
    else break;
    bool f = 1;
    if(s.length() - i < 5) break;
    rep(j, 0, 5) {
      if(s[i] != e[j]) f = 0;
      i++;
    }
    i--;
    if(!f) break;
    if(s.length() - i > 2 && s[i - 4] == 'd') {
      if(s[i + 1] == 'e' && s[i + 2] == 'r') {
        if(s.length() - i > 3 && s[i + 3] == 'a') ss += e;
        else ss += b, i += 2;
      }else {
        ss += e;
      }
    }else if(s.length() - i > 1 && s[i - 4] == 'e') {
      if(s[i + 1] == 'r') ss += d, i++;
      else ss += e;
    }else {
      ss += e;
    }

    if(s == ss) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}


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

int main(){
    int N,C,K;
    cin >>N >>C >>K;
    vector<int> T(N);
    for (int i=0;i<N;i++){
        cin >>T[i];
    }
    sort(T.begin(),T.end());
    
    int cnt=1,first=0;

    for (int i=0;i<N;i++){
        if(i-first>C-1 or T[i]-T[first]>K ){
            first=i;
            cnt++;
        }

    }
    cout << cnt <<endl;
}

Measured memory_bytes: 640
import itertools
import collections
n=int(input())
X=[]
for i in range(n):
  X.append([int(i) for i in input().split()])
X.sort(key=lambda x:(x[0],x[1]))
Y=[]
for c in itertools.combinations(range(n),2):
  x1,y1,x2,y2=X[c[0]][0],X[c[0]][1],X[c[1]][0],X[c[1]][1]
  Y.append((x2-x1,y2-y1))
yy=collections.Counter(Y)
print(1 if n==1 else n-yy.most_common()[0][1])

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

int main(){
  string a;

  while(cin >> a){
    for(int i = 0; i < a.length(); i++){
      char tmp = (a[i] - 'A' + 26 - 3) % 26 + 'A';
      a[i] = tmp;
    }
    cout << a << endl;
  }
}

Measured memory_bytes: 0
N = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
if min(a,b,c,d,e) == a:
  if N % a == 0:
    print(N//a + 4)
  else:
    print(N//a + 5)
elif min(b,c,d,e) == b:
  if N % b == 0:
    print(N//b + 4)
  else:
    print(N//b + 5)
elif min(c,d,e) == c:
  if N % c == 0:
    print(N//c + 4)
  else:
    print(N//c + 5)
elif min(d,e) == d:
  if N % d == 0:
    print(N//d + 4)
  else:
    print(N//d + 5)
else:
  if N % e == 0:
    print(N//e + 4)
  else:
    print(N//e + 5)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		int n = sc.nextInt();
		boolean[][] cards = new boolean[4][13];
		char[] suit_tb = new char[] {'S', 'H', 'C', 'D'};
		
		for (int i = 0; i < n; i++) {
			char suit = sc.next().toCharArray()[0];
			int rank = sc.nextInt();
			int suit_index;
			switch (suit) {
			case 'S':
				suit_index = 0;
				break;
			case 'H':
				suit_index = 1;
				break;
			case 'C':
				suit_index = 2;
				break;
			case 'D':
				suit_index = 3;
				break;
			default:
				suit_index = -1;
				break;
			}
			cards[suit_index][rank - 1] = true;
		}
		
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 13; j++) {
				if (!cards[i][j]) {
					System.out.println(suit_tb[i] + " " + (j + 1));
				}
			}
		}
		
		sc.close();
	}
}

Measured memory_bytes: 18052
#include<iostream>
#include <algorithm>
#include<iomanip>
#include<math.h>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
using namespace std;
 
int main()
{
	long N;
	cin >> N;
	if (N % 10 == 7)cout << "Yes" << endl;
	else if (N / 100 == 7)cout << "Yes" << endl;
	else if (N / 10 % 10 == 7)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main(){
	int N, Q, i;
	scanf("%d", &N);
	int *c = (int *)malloc(sizeof(int) * N);
	int *now_c = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%d", &c[i]);
		now_c[i] = 0;
	}
	scanf("%d", &Q);
	int *t = (int *)malloc(sizeof(int) * Q);
	int *x = (int *)malloc(sizeof(int) * Q);
	int *d = (int *)malloc(sizeof(int) * Q);
	for(i = 0; i < Q; i++){
		scanf("%d%d%d", &t[i], &x[i], &d[i]);
		x[i]--;
	}
	for(i = 0; i < Q; i++){
		if(t[i] == 1){
			now_c[x[i]] += d[i];
			if(now_c[x[i]] > c[x[i]]){
				printf("%d\n", x[i] + 1);
				return 0;
			}
		}
		else{
			now_c[x[i]] -= d[i];
			if(now_c[x[i]] < 0){
				printf("%d\n", x[i] + 1);
				return 0;
			}
		}
	}
	printf("0\n");
	return 0;
}


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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader buff = null;
		buff = new BufferedReader(new InputStreamReader(System.in));
		int count = 0;
		String[] box = buff.readLine().split("");
		for(int i = 0; i < 3; ++i){
			if(box[i].equals("o")){
				count++;
			}
		}
		System.out.println(700 + (100 * count));

	}

	static long f() {
		long ans = 0;


		return ans;
	}
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    ll k;
    cin >> k;
    int a[n];
    rep(i, 0, n) cin >> a[i];
    vector<int> order;
    int now = 1;
    ll cnt = 1;
    order.push_back(1);
    vector<int> dist(n + 1, -1);
    int t = 0;
    while (1) {
        int next = a[now - 1];
        if (dist[next] == -1) {
            dist[next] = cnt;
            order.push_back(next);
            now = next;
            cnt++;
        } else {
            t = cnt - dist[next];
            break;
        }
    }
    int m = (int)order.size() - t;
    if (k < m) cout << order[k] << endl;
    else cout << order[(k - m) % t + m] << endl;
    return 0;
}


Measured memory_bytes: 5824
N, Y = map(int, input().split())
ans = [-1, -1, -1]
for x in range(N+1):
    if 10000 * x > Y:
        break
    for y in range(N+1):
        if 10000 * x + 5000 * y > Y:
            break
        if 10000 * x + 5000 * y + 1000 * (N-x-y) == Y:
            ans = [x, y, N-x-y]
print(*ans)


Measured memory_bytes: 2940
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        w: usize, h: usize, x: usize, y: usize,
    }
    if x * 2 == w && y * 2 == h {
        println!("{} {}", w as f64 * h as f64 / 2., 1);
    } else {
        println!("{} {}", w as f64 * h as f64 / 2., 0);
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[])
{
	stack<int> S1;
	stack<pair<int, int> > S2;
	char ch;
	int sum = 0;

	for (int i = 0; cin >> ch; i++) {
		if (ch == '\\') {
			S1.push(i);
		} else if (ch == '/' && S1.size() > 0) {
			int j = S1.top(); S1.pop();
			sum += i - j;
			int a = i - j;
			while (S2.size() > 0 && S2.top().first > j) {
				a += S2.top().second; S2.pop();
			}
			S2.push(make_pair(j, a));
		}
	}

	vector<int> V;
	while (S2.size() > 0) {
		V.push_back(S2.top().second); S2.pop();
	}
	reverse(V.begin(), V.end());

	cout << sum <<endl;
	cout << V.size();
	for (int i = 0; i < V.size(); i++) {
		cout << " ";
		cout << V[i];
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 3240
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	int m,f,b;
	scanf("%d %d %d",&m,&f,&b);
	if(b-m>0){
		if(b-m>f)
		printf("NA\n");
		else{
			printf("%d\n",b-m);
		}
	}
	else
	printf("0\n");
}


Measured memory_bytes: 3196
#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>
using namespace std;

struct edge{
	int to;
	int weight;
	int height;
};

typedef vector<edge> Edges;
typedef vector<Edges> Graph;

int HeightCalc(Graph &G, int i, int j){
	if(G[i][j].height>0) return G[i][j].height;
	G[i][j].height=G[i][j].weight;
	int u=G[i][j].to;
	for(int k=0;k<G[u].size();k++){
		if(G[u][k].to==i){continue;}
		G[i][j].height=max(G[i][j].height,HeightCalc(G,u,k)+G[i][j].weight);
	}
	return G[i][j].height;
}

int main(){
	int V,E,s,t,w;
	edge e;
	cin>> V ;
	E=V-1;
	Graph G(V);
	vector<int> h(V,0);
	
	for (int i=0;i<E;i++){
		cin >> s >> t >> w;
		e.to=t;
		e.weight=w;
		e.height=-1;
		G[s].push_back(e);
		e.to=s;
		e.weight=w;
		e.height=-1;
		G[t].push_back(e);
	}
	
	for(int i=0;i<V;i++){
		for (int j=0;j<G[i].size();j++){
			HeightCalc(G,i,j);
		}
	}
	
	for (int i=0;i<V;i++){
		for (int j=0;j<G[i].size();j++){
			h[i]=max(h[i],G[i][j].height);
		}
		cout << h[i] <<endl;
	}
	
	return 0;
}

Measured memory_bytes: 2344
/*  -*- coding: utf-8 -*-
 *
 * 2846.cc: Slimming Plan
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_D = 100000;
const long long LINF = 1LL << 62;

/* typedef */

typedef long long ll;

/* global variables */

ll wsums[MAX_D + 1];

/* subroutines */

inline void setmin(ll &a, ll b) { if (a > b) a = b; }
inline void setmax(ll &a, ll b) { if (a < b) a = b; }

/* main */

int main() {
  ll s, t;
  int d;
  scanf("%lld%lld%d", &s, &t, &d);
  ll dt = -(t - s);

  ll maxw = 0;
  for (int i = 0; i < d; i++) {
    int wi;
    scanf("%d", &wi);
    wsums[i + 1] = wsums[i] - wi;
    setmax(maxw, wsums[i + 1]);
  }
  //printf("dt=%lld, maxw=%lld, wsum=%lld\n", dt, maxw, wsums[d]);

  if (maxw >= dt) {
    int k = 0;
    for (; k <= d; k++)
      if (wsums[k] >= dt) break;
    printf("%d\n", k);
  }
  else if (wsums[d] > 0) {
    ll m = (dt - maxw + wsums[d] - 1) / wsums[d];
    dt -= m * wsums[d];
    int k = 0;
    for (; k <= d; k++)
      if (wsums[k] >= dt) break;
    printf("%lld\n", m * d + k);
  }
  else
    puts("-1");
  return 0;
}



Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define PB push_back
#define ar2 array<int, 2>
typedef long long LL;
const LL P = 998244353;
const int N = 2e5+5;
mt19937 rng(time(0));

int n, last[N][26];
string s[N];
LL ans = 0;

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	
	cin>>n;
	rep(i,1,n){
		cin>>s[i];
		int sz = s[i].size();
		rep(j,0,sz/2-1) swap(s[i][j],s[i][sz-1-j]);
	}
	sort(s+1,s+n+1);
	
	memset(last,0,sizeof last);
	rep(i,1,n){
		int sz = s[i].size();
		rep(j,0,sz-1) last[i][s[i][j]-'a'] = j+1;
	}
	
	rep(i,1,n){
		int l = 1, r = n, sz = s[i].size();
		rep(j,0,sz-2){
			int l1 = l, r1 = i;
			l = i;
			while(l1<=r1){
				int mid = (l1+r1)>>1;
				if((int)s[mid].size()>=sz && s[mid][j]==s[i][j])
					r1 = mid-1, l = mid;
				else
					l1 = mid+1;
			}
			l1 = i, r1 = r;
			r = i;
			while(l1<=r1){
				int mid = (l1+r1)>>1;
				if((int)s[mid].size()>=sz && s[mid][j]==s[i][j])
					l1 = mid+1, r = mid;
				else
					r1 = mid-1;
			}
		}
		
		char ch = s[i][sz-1];
		rep(j,l,r)
			if(last[j][ch-'a'] >= sz){
				//cerr<<s[i]<<" "<<s[j]<<" "<<last[j][ch-'a']<<endl;
				ans++;
			}
	}
	cout<<ans-n<<endl;
	return 0;
}

Measured memory_bytes: 31868
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))

count = [[0]*2 for i in range(N)]

for i in range(N-1):
    for j in range(i+1,N):
        if i == j:
            continue
        elif A[i] < A[j]:
            count[j][0] += 1
        elif A[j] < A[i]:
            count[i][1] += 1

ans = 0
for i in range(N):
    ans += count[i][0]*(K-1)*(K)//2
    ans % 1000000007
for i in range(N):
    ans += count[i][1]*K*(K+1)//2
    ans % 1000000007
print(ans%1000000007)

Measured memory_bytes: 3376
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

const int MAX_N = 200010;
int prime[MAX_N];
bool is_prime[MAX_N + 1];
int sieve(int n){
   int p = 0;
   for(int i = 0; i <= n; i++) is_prime[i] = true;
   is_prime[0] = is_prime[1] = false;
   for(int i = 2; i <= n; i++){
   if(is_prime[i]){
           prime[p++] = i;
           for(int j = 2*i; j <= n; j += i) is_prime[j] = false;
       }
   }
   return p;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int sz = sieve(200010);
    while(1){
        int n, p;
        cin >> n >> p;
        if(n == -1 && p == -1) break;
        int idx = 0;
        rep(i, 0, sz){
            if(prime[i] > n){
                idx = i; break;
            }
        }
        vector<int> d;
        rep(i, idx, idx + 200){
            rep(j, i, idx + 200){
                d.push_back(prime[i] + prime[j]);
            }
        }
        sort(all(d));
        cout << d[p - 1] << endl;
    }   
}


Measured memory_bytes: 3792
#include <iostream>

using namespace std;
int main()
{
  string s;
  cin >> s;
  char c = s[0];
  for (int i = 1; i < 3; i++) {
    if (s[i] != c) {
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
  return 0;
}

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

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; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

int main() {
    int n;
    cin >> n;
    vector<int> six, nine;
    six.push_back(6);
    nine.push_back(9);
    while(six.back() < 100000) {
        six.push_back(six.back() * 6);
    }
    while(nine.back() < 100000) {
        nine.push_back(nine.back() * 9);
    }
    vector<int> dp(n+1, 1e9+7);
    dp[0] = 0;
    rep (i, 1, n+1) {
        dp[i] = dp[i-1] + 1;
        rep (j, six.size()) {
            if (i >= six[j]) {
                chmin(dp[i], dp[i -six[j]] + 1);
            } else {
                break;
            }
        }
        rep (j, nine.size()) {
            if (i >= nine[j]) {
                chmin(dp[i], dp[i - nine[j]] + 1);
            } else {
                break;
            }
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
 
using namespace std;

void reverseStr(string& str) 
{ 
    int n = str.length(); 
  
    // Swap character starting from two 
    // corners 
    for (int i = 0; i < n / 2; i++) 
        swap(str[i], str[n - i - 1]); 
}

signed main()
{
    fast;
    string s;
    cin>>s;

    deque<char> q;

    for ( int i = 0 ; i < s.length() ; i++ )
    {
        q.pb(s[i]);
    }
    int n;
    cin>>n;
    int x = 0;
    while(n--)
    {
        int v;
        cin>>v;
        if ( v == 1 )
        {
            x = (x == 0)?1:0;
        }
        else
        {
            int a;
            char b;
            cin>>a>>b;
            if ( (a+x) % 2 == 1 )
            {
                q.push_front(b);
            }
            else
            {
                q.pb(b);
            }
        }
    }

    if ( x == 1 )
    {
        for ( auto it = q.rbegin() ; it != q.rend() ; it++ )
        {
            cout<<*it;
        }
        cout<<endl;
    }
    else
    {
        for ( auto it = q.begin() ; it != q.end() ; it++ )
        {
            cout<<*it;
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 976
import copy
a=int(input())
b=[int(input()) for _ in range(a)]
c=copy.deepcopy(b)

n=max(b)
c.remove(n)
m=max(c)

o=b.index(n)

l=0
p=0

while l!=o:
    print(n)
    l+=1

print(m)
q=a-o-1
while p!=q:
    print(n)
    p+=1




Measured memory_bytes: 14568
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define DBG(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define EN cout<<"\n"
#define fi first
#define se second
#define PI (acos(-1))
#define fastread ios::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 200005
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T,class V> ostream& operator<<(ostream &s,pair<T,V> a)
{
    s<<a.fi<<' '<<a.se;
    return s;
}
int main()
{
    fastread;
    ll T=1;
//    cin>>T;
    for(ll qq=1;qq<=T; qq++)
    {
        ll n;
        cin>>n;
        ll od=0;
        while(n--){
            ll x;
            cin>>x;
            od+=x%2;
        }
        if(od%2==0)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 256
A, B = map(int, input().split())		# 5 7

S = input()

l=['0','1','2','3','4','5','6','7','8','9']
#print(l)


if (S[A] != '-'):
	print("No")
	exit(0)


for i in range(A):
	if S[i] in l:
		continue
	
	print("No")
	exit(0)


for i in range(A+1, A+B+1):
	if S[i] in l:
		continue
	
	print("No")
	exit(0)


print('Yes')



Measured memory_bytes: 3064
N=int(input())
A=list(map(int,input().split()))
ans=[0 for i in range(N)]
c=0
d=0
for i in range(N):
        if N%2==0:
                if i%2==0:
                        ans[N//2+c]=A[i]
                        c+=1
                else:
                        ans[N//2-1-d]=A[i]
                        d+=1
        else:
                if i%2==0:
                        ans[N//2-d]=A[i]
                        d+=1
                else:
                        ans[N//2+1+c]=A[i]
                        c+=1 
print(*ans,sep=" ")

Measured memory_bytes: 26180
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n-r+1;
	int sum = 1;
	for(int i =s;i<=n;i++)
		sum *= i;
	return sum;
}
//int nCr1(int n, int r)
//int nCr2(int n, int r) 
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}

using namespace std;
#pragma endregion
signed main() {
	int K, N;
	string s;
	cin >> K >> N;
	rep(i, K) {
		rep(j, N) {
			cin >> s;
			if (s == "snuke")
				cout << char('A'+j) << i+1;
		}
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;
#define all(c) begin(c), end(c)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define rep(i, n) for (ll i = 0; i < ll(n); i++)

ll n, m, s;
ll a[110], b[110];
ll c[55], d[55];

vector<pll> adj[55];
vector<pll> adjstate[55 * 2500];

ll conv(ll v, ll s) {
    return v * 2500ll + s;
}

vl dijkstra(int s) {
    priority_queue<pll, vector<pll>, greater<pll>> pq;
    vector<ll> dist(55 * 2500, 1e18);
    dist[s] = 0;
    pq.push(mp(dist[s], s));
    while(!pq.empty()){
        auto tmp = pq.top();
        pq.pop();
        ll from = tmp.second;
        ll d = tmp.first;
        if (dist[from] < d) continue;
        for(auto p : adjstate[from]){
            ll to = p.first;
            ll cost = p.second;
            if(dist[to] > dist[from] + cost){
                dist[to] = dist[from] + cost;
                pq.push(mp(dist[to], to));
            }
        }
    }
    return dist;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m >> s;
    rep(i, m) {
        ll u, v;
        cin >> u >> v >> a[i] >> b[i];
        u--, v--;
        adj[u].pb(mp(v, i));
        adj[v].pb(mp(u, i));
    }
    rep(i, n) cin >> c[i] >> d[i];

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 2500; j++) {
            int to = min(j + c[i], 2499ll);
            // exchanging currencies
            adjstate[conv(i, j)].pb(mp(conv(i, to), d[i]));

            for (auto p : adj[i]) {
                ll to = p.first;
                ll eid = p.second;
                if (j < a[eid]) continue;
                // transit while paying b[i]
                adjstate[conv(i, j)].pb(mp(conv(to, j - a[eid]), b[eid]));
            }
        }
    }
    s = min(s, 2499ll);
    auto dist = dijkstra(conv(0, s));
    for (int i = 1; i < n;i++){
        ll ans = 1e18;
        for (int j = 0; j < 2500; j++) {
            ans = min(ans, dist[conv(i, j)]);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 24016
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,k;
  cin>>n>>k;
  vector<int> a(n);
  for(int i=0;i<n;i++){
  	cin>>a[i];
  }
  int dp[n+1][k+1];
  for(int i=0;i<=n;i++){
  	for(int j=0;j<=k;j++){
    	dp[i][j]=0;
    }	
  }
  for(int i=1;i<=n;i++){
  	for(int j=1;j<=k;j++){
    	if(j<a[i-1]){
        	dp[i][j]=dp[i-1][j];
        }
      else{
      	for(int k=1;k<=i;k++){
        	dp[i][j]=dp[i][j]||(!dp[i][j-a[k-1]]);
        }
      }
    }
  }
  if(dp[n][k]){
  	cout<<"First"<<endl;
  }
  else{
  	cout<<"Second"<<endl;
  }
  return 0;
}

Measured memory_bytes: 39680
#include <bits/stdc++.h>
#include <map> // pair
using namespace std;
int main(){
  string ans = "APPROVED";
  int N;
  cin>>N;
  int A;
  for(int i=0;i<N;i++){
    cin>>A;
    if(A%3!=0&&A%5!=0&&A%2==0){
      ans = "DENIED";
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    intl x;
    cin >> x;
    intl cnt1 = 0;
    intl cnt2 = 0;
    rep(i,m){
        intl b;
        cin >> b;
        cnt1 += (x < b);
        cnt2 += (x > b);
    }
    cout << min(cnt1,cnt2) << endl;
    return 0;
}

Measured memory_bytes: 256
import heapq
def solve():
  n = int(input())
  a = list(int(i) for i in input().split())
  an = []
  a2n = a[n:2*n]
  a3n = []
  for i in range(n):
    heapq.heappush(an,a[i])
    heapq.heappush(a3n,-1*a[i+2*n])
  ta2n = a2n
  
  tmpsuman = sum(an)
  tmpsuma3n = -1*sum(a3n)
  
  suman = [tmpsuman]
  suma3n = [tmpsuma3n]
  
  for i in range(n):
    tmp = ta2n[i]
    tmpsuman += tmp
    heapq.heappush(an,tmp)
    tmpsuman -= heapq.heappop(an)
    
    suman.append(tmpsuman)
  for i in range(n):
    tmp = ta2n[n-i-1]
    tmpsuma3n += tmp
    heapq.heappush(a3n,-1*tmp)
    tmpsuma3n -= -1*heapq.heappop(a3n)
    suma3n.append(tmpsuma3n)

  ans = -10000000000000000
  for i in range(n+1):
    tmpans = suman[i]-suma3n[n-i]
    ans = max(ans,tmpans)
  print(ans)
solve()

Measured memory_bytes: 37212
#include<bits/stdc++.h>
#include<bitset>
#include<random>
#include<time.h>

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code

int main()
{
  string s;
  cin>>s;
  int ans = 0;
  rep(i, 0, s.length()) if(s[i] == '1') ans++;
  cout<<ans<<endl;
}


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

#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)n; ++i)

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
        
    //~ const int M = 1e9 + 10;
    int n, a, b, c;
    cin >> n;
    vector<vector<int> > h(3, vector<int> (n, -1));
    cin >> a >> b >> c;
    h[0][0] = a;
    h[1][0] = b;
    h[2][0] = c;
    for (int i = 1; i < n; i++) {
        cin >> a >> b >> c;
        h[0][i] = max(h[1][i - 1], h[2][i - 1]) + a; 
        h[1][i] = max(h[0][i - 1], h[2][i - 1]) + b;
        h[2][i] = max(h[0][i - 1], h[1][i - 1]) + c;
    }
    cout << max(max(h[0][n - 1], h[1][n - 1]), h[2][n - 1]) << endl;
}


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

int choose(vector <vector <int>> stores, int i, int n, int m, vector <int> books, int cost) {
	if (i == n) {
		for (int j = 1; j < m + 1; j++) {
			if (books[j] > 0) {
				return INT_MAX;
			}
		}
		return cost;
	}
	int ans1 = choose(stores, i + 1, n, m, books, cost);
	for (int j = 0; j < m + 1; j++) {
		books[j] -= stores[i][j];
	}
	int ans2 = choose(stores, i + 1, n, m, books, cost + stores[i][0]);
	return min(ans1, ans2);
}

void solve() {
	int n, m, x;
	cin >> n >> m >> x;

	vector <vector <int>> stores(n);
	for (int i = 0; i < n; i++) {
		for (int j = 0, ele; j < m + 1; j++) {
			cin >> ele;
			stores[i].push_back(ele);
		}
	}
	vector <int> books(m + 1, x);
	int ans = choose(stores, 0, n, m, books, 0);
	if (ans == INT_MAX) {
		cout << -1;
	}
	else {
		cout << ans;
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
# ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
# endif
	solve();
	return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define mp make_pair
#define ld long double
#define ull unsigned long long int
#define mod 1000000007
ll dp[200000],n,k,h[200000];
ll recurs(ll pos)
{
	if(dp[pos]!=-1) return dp[pos];
	if(pos>n) return (2e5);
	if(pos==n) return 0;
	ll min1=abs(h[pos+1]-h[pos])+recurs(pos+1);
	for (int i = 2; i <=k; ++i)
	{
		min1=min(abs(h[pos+i]-h[pos])+recurs(pos+i),min1);
	}
	dp[pos]=min1;
	return dp[pos];
}
int main()
{
    ios_base::sync_with_stdio(false);//this works only
    cin.tie(NULL);// when first all inputs are from user
    cout.tie(NULL);//you will see all outputs afterwards
    cin>>n>>k;
 	for (int i = 1; i <=n; ++i)
	  {
	  		cin>>h[i];
	  }  
	 memset(dp,-1,sizeof(dp));
	 ll ans=recurs(1);
	 cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 7296
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

#define MAX_V 200000

long long int INF = 100000000000000000LL;

struct edge{
	int to;
	long long int cost;
};

typedef pair<long long int, int> P; // firstは最短距離、secondは頂点の番号

vector<edge> G[MAX_V];
long long int d[MAX_V];

// 速さはO(|E|log|V|)

void shortest_path(int s, int V){ // Vは頂点数
	
	priority_queue<P, vector<P>, greater<P> > que;
	
	for(int i = 0; i < V; i++){
		d[i] = INF;
	}
	d[s] = 0;
	
	que.push(P(0, s));
	
	while(!que.empty()){
		
		P p = que.top();
		que.pop();
		
		int v = p.second;
		
		if(d[v] < p.first){
			continue;
		}
		
		for(int i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > e.cost + d[v]){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		} // 頂点への最小コストを更新
	}
}

int main(){
	
	int N;
	cin >> N;
	
	for(int i = 0; i < N; i++){
		edge e;
		e.to = i + 1;
		e.cost = 1;
		G[i].push_back(e);
	}
	
	for(int i = 1; i < N; i++){
		edge e;
		e.to = (i * 10) % N;
		if(e.to == 0){
			e.to = N;
		}
		e.cost = 0;
		G[i].push_back(e);
	}
	
	shortest_path(0, N + 1);
	
	cout << d[N] << endl;
	
	return 0;
}

Measured memory_bytes: 11640
H,W=map(int,input().split())
field=[]
for i in range(H):
    field.append(input())

new_field=[]
for i in range(H):
    for j in range(W):
        if(field[i][j]=="#"):
            new_field.append(field[i])
            break

new_new_field=[]
for i in range(W):
    tmp=[]
    flag=0
    for j in range(len(new_field)):
        if(new_field[j][i]=="#"):
            flag=1
        tmp.append(new_field[j][i])
    if(flag==1):
        new_new_field.append(tmp)

for i in range(len(new_new_field[0])):
    for j in range(len(new_new_field)):
        print("{}".format(new_new_field[j][i]),end="")
    print()

Measured memory_bytes: 4596
#include <cstdio>


int main(void){
    int n, k;
    int taboo[10] = {0};
    
    scanf("%d%d", &n, &k);
    for (int i=0; i<k; i++){
        int t;
        scanf("%d", &t);
        taboo[t] = 1;
    }
    
    int ans = n, cont = 1;
    do {
        int t = ans;
        cont = 0;
        while (t){
            if (taboo[t%10]){
                cont = 1;
                break;
            }
            t /= 10;
        }
    } while (cont?ans++:0);
    printf("%d\n", ans);
    
    return 0;
}
    

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    bool Run()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int a = sc.NextInt() - 1;
        int b = sc.NextInt() - 1;
        int c = sc.NextInt() - 1;
        int d = sc.NextInt() - 1;
        string s = sc.NextString();

        bool sp = false;
        for (int i = b; i < Math.Min(d + 1, n - 1); i++)
        {
            if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') sp = true;
        }

        if (c > d && !sp) return false;

        int q = b;
        while (q < d)
        {
            if (q + 1 < n && s[q + 1] == '.')
            {
                q += 1;
                continue;
            }
            if (q + 2 < n && s[q + 2] == '.')
            {
                q += 2;
                continue;
            }
            return false;
        }
        if (q != d) return false;

        int p = a;
        while (p < c)
        {
            if (p + 1 < n && s[p + 1] == '.')
            {
                p += 1;
                continue;
            }
            if (p + 2 < n && s[p + 2] == '.')
            {
                p += 2;
                continue;
            }
            return false;
        }
        if (p != c) return false;

        return true;
    }

    static void Main(string[] args)
    {
        Console.WriteLine(new Program().Run() ? "Yes" : "No");
    }

    static long Gcd(long a, long b)

    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 12384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  double h,a;
  cin >> h >> a;
  int ans = ceil(h/a);

  cout << ans << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll h,w,c;

ll field[2][10][10];
bool used[10][10];
ll dx[] = {0,1,0,-1};
ll dy[] = {1,0,-1,0};

void init(){
	rep(i,h)rep(j,w){
		field[1][i][j] = field[0][i][j];
		used[i][j] = true;
	}
}

void make(ll y,ll x,ll c){
	// cout << "!!" << y << " " << x << endl;
	// if(c == field[1][y][x])return;
	ll cc = field[1][y][x];
	// cout << "!" << c << " " << field[1][y][x] << endl;
	field[1][y][x] = c;
	// cout << cc << endl;
	rep(i,4){
		ll ny = y + dy[i];
		ll nx = x + dx[i];
		if(ny < 0 || ny >= h || nx < 0 || nx >= w)continue;
		// cout << ny << " " << nx << " " << field[1][ny][nx] << endl;
		if(field[1][ny][nx] == cc)make(ny,nx,c);
	}
}

ll count(ll y,ll x, ll c){
	ll res = 1;
	used[y][x] = false;
	rep(i,4){
		ll ny = y + dy[i];
		ll nx = x + dx[i];
		if(ny < 0 || ny >= h || nx < 0 || nx >= w)continue;
		if(field[1][ny][nx] == c && used[ny][nx])res += count(ny,nx,c);
	}
	return res;
}

void print(){
	rep(i,h){
		rep(j,w)cout << field[1][i][j] << " ";
		cout << endl;
	}
}

int main(){
	while(cin >> h >> w >> c && h){
		rep(i,h)rep(j,w)cin >> field[0][i][j];
		ll ans = 0;
		vector<ll> v;
		// rep(i,6)v.push_back(i+1);
		FOR(i,1,6+1){
			v.push_back(i);
			FOR(j,1,6+1){
				v.push_back(j);
				FOR(k,1,6+1){
					v.push_back(k);
					FOR(l,1,6+1){
						v.push_back(l);
						v.push_back(c);
						init();
						rep(m,v.size()){
							if(field[1][0][0] == v[m])continue;
							make(0,0,v[m]);
						}
						// print();
						// cout << endl;
						ans = max(ans,count(0,0,c));
						v.pop_back();
						v.pop_back();
					}
					v.pop_back();
				}
				v.pop_back();
			}
		v.pop_back();
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3036
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>
using namespace std;

int N;

int main() {
    cin >> N;
    int left = 0;
    vector<int> A(N);
    cin >> A[0];
    long long sum = A[0];
    long long cnt = 1;
    for (int right = 1; right < N; right++) {
        cin >> A[right];
        while (sum & A[right]) {
            sum -= A[left];
            ++left;
        }
      sum += A[right];
        cnt += right - left + 1;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 1024
import itertools
N = int(input())
L = list(map(int,input().split()))
combination_list =  list(itertools.combinations(L, 3))
ans = 0
for i in combination_list:
    j = sorted(list(i))
    if j[0] + j[1] > j[2] and j[0] != j[1] and j[1] != j[2] and j[2] != j[0]:
        ans += 1
print(ans)

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

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

S = input()
T = input()

C1 = sorted(Counter(S).values())
C2 = sorted(Counter(T).values())

N = len(C1)
if len(C2) != N:
    No()
    exit()
for i in range(N):
    if C1[i] != C2[i]:
        No()
        exit()
Yes()


Measured memory_bytes: 3896
import sys
sys.setrecursionlimit(10**7)
def lmi(): return list(map(int, input().split()))

n = int(input())
t = [0] * n
for i in range(n):
    s, p = input().split()
    t[i] = (s, -int(p), i+1)

for i in sorted(t):
    print(i[2])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define int long long
#define inf (int)1e18 + 7

int n, a[303];
int cnt[4] = {0};

double dp[303][303][303];

double solve(int one, int two, int three) {
  int rem = one + two + three;
  if (rem == 0) {
    return 0;
  }
  double &res = dp[one][two][three];
  if (res != 0) return res;
  res = 0.0;
  if (three > 0) {
    res += solve(one, two + 1, three - 1) * (double)three / (double)rem;
  }
  if (two > 0) {
    res += solve(one + 1, two - 1, three) * (double)two / (double)rem;
  }
  if (one > 0) {
    res += solve(one - 1, two, three) * (double)one / (double)rem;
  }

  res += (double)n / (double)rem;
  return res;
}

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

  cin >> n;
  for (int i = 0; i < n; i ++) {
    cin >> a[i];
    cnt[a[i]] ++;
  }

  // memset(dp, -1, sizeof dp);
  double res = solve(cnt[1], cnt[2], cnt[3]);
  cout << fixed << setprecision(10);
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 217344
from sys import stdin
 
def main():
    N = int(input())
    AB = [tuple(map(int, input().split())) for _ in [0] * N]
 
    dish = sorted(AB, reverse=1, key=lambda x: sum(x))
    taka, aoki = 0, 0
    for i in range(N):
        aoki += dish[i][1]
        if not i % 2:
            taka += sum(dish[i])
    print(taka - aoki)
 
input = lambda: stdin.readline()
main()

Measured memory_bytes: 22020
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <cmath>
#include <functional>
#include <numeric>

using namespace std;

const int Max = 300;
int main(void)
{
	int road[Max][Max];
	int n;
	long long int res = 0;
	bool flag = false;
	bool flag2[Max][Max];

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			flag2[i][j] = true;
		}
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			cin >> road[i][j];
		}
	}

	for (int k = 0; k < n; k++)
	{
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < n; j++)
			{
				if (road[i][j] > road[i][k] + road[k][j])
				{
					flag = true;

				}

				if (road[i][j] == road[i][k] + road[k][j])
				{
					if (road[i][k] != 0 && road[k][j] != 0)
					{
						flag2[i][j] = false;
					}
				}
			}
		}
	}
	 
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			if (flag2[i][j] == true)
			{
				res += road[i][j];
			}
		}
	}

	if (flag == true)
	{
		cout << "-1" << endl;
	}
	else
	{
		cout << res << endl;
	}

	return 0;

}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
S = str(input())

if S.startswith("YAKI") :
  print ("Yes")
else :
  print ("No")
  

Measured memory_bytes: 38324
using System;
using System.Linq;

namespace AizuOnlineJudge {
    class Program {
        static void Main() {
            Console.ReadLine();
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var swap = 0;

            for (var i = 0; i < input.Length; ++i) {
                var min = i;
                for (var j = i + 1; j < input.Length; ++j) {
                    if (input[j] < input[min]) {
                        min = j;
                    }
                }

                if (min != i) {
                    var temp = input[min];
                    input[min] = input[i];
                    input[i] = temp;
                    ++swap;
                }
            }

            Console.WriteLine(string.Join(" ", input));
            Console.WriteLine(swap);
        }
    }
}



Measured memory_bytes: 18364
//#define _GRIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int N, M;
int main() {
    cin >> N >> M;
    if (N - M <= -2 || 2 <= N - M) cout << 0 << endl;
    else {
        int ret = 1;
        for (int i = 1; i <= N; i++) ret = 1LL * ret * i % mod;
        for (int i = 1; i <= M; i++) ret = 1LL * ret * i % mod;
        cout << ret * (N - M == 0 ? 2 : 1) % mod << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n=int(input())
p=input().split()
k=0
for i in range(n-2):
  if (int(p[i])+int(p[i+1])+int(p[i+2])-min(int(p[i]),int(p[i+1]),int(p[i+2]))-max(int(p[i]),int(p[i+1]),int(p[i+2])))==int(p[i+1]):
    k+=1
  else:
    k+=0
print(k)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <functional>
#include <queue>
using namespace std;

typedef long long W;

const W INF = 1LL << 50;

struct edge {
	int to;
	W cost;
};
typedef pair<W, int> P;
typedef vector<vector <edge > > Graph;

void dijkstra(int s, const Graph& G, vector<W>& d) {
	priority_queue< P, vector<P>, greater<P> > que;
	fill(d.begin(), d.end(), INF);
	d[s] = 0;
	que.push(P(0, s));
	while(!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}


Graph G(100 * 110);
vector<W> d(100 * 110);

int toV(int n, int m) {
	return 110 * n + m;
}

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

	int N, M, L, K, A, H;
	while(cin >> N >> M >> L >> K >> A >> H, N) {
		for(int i = 0; i < 100 * 110; i++) {
			G[i].clear();
		}

		bool freeze[100] = { 0 };
		freeze[A] = freeze[H] = true;
		for(int i = 0; i < L; i++) {
			int x;
			cin >> x;
			freeze[x] = true;
		}

		for(int i = 0; i < N; i++) {
			if(freeze[i]) {
				for(int m = 0; m < M; m++) {
					G[toV(i, m)].push_back(edge{ toV(i, m + 1), 1 });
				}
			}
		}
		for(int i = 0; i < K; i++) {
			int x, y, t;
			cin >> x >> y >> t;
			for(int m = 1; m <= M; m++) {
				if(m - t >= 0) {
					G[toV(x, m)].push_back(edge{ toV(y, m - t), t });
					G[toV(y, m)].push_back(edge{ toV(x, m - t), t });
				}
			}
		}

		dijkstra(toV(A, M), G, d);
		W ans = INF;
		for(int m = 0; m <= M; m++) {
			ans = min(ans, d[toV(H, m)]);
		}
		if(ans == INF) {
			cout << "Help!" << endl;
		}
		else {
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 8296
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,a,b = readline() |> split |> parseMap
	if a%2==b%2
		println((b-a)>>1)
	else
		println(min(a+(b-a-1)>>1,n-b+1+(b-a-1)>>1))
	end
end

main()

Measured memory_bytes: 110216