akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC098.D2
{
    class Program
    {
        static void Main()
        {
            var sc = new Scanner();
            var n = sc.Nextint();
            var A = sc.Arrayint(n);
            var l = 0;
            var r = 0;
            var xor = (long) A[0];
            var sum = (long) A[0];
            var count = 0L;
            while (l < A.Length)
            {
                while (xor == sum && r < A.Length)
                {
                    if (++r >= A.Length) break;
                    xor ^= A[r];
                    sum += A[r];
                }
                count += r - l;
                xor ^= A[l];
                sum -= A[l];
                l++;
            }
            Console.WriteLine(count);
        }
    }
    class Scanner
    {
        string[] s;
        long i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public int Nextint()
        {
            return int.Parse(Next());
        }
        public int[] Arrayint(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Nextint() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }

        public double[] ArrayDouble(long N, double add = 0)
        {
            double[] Array = new double[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }

        public decimal NextDecimal()
        {
            return decimal.Parse(Next());
        }

        public decimal[] ArrayDecimal(long N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDecimal();
            }
            return Array;
        }
    }
}

Measured memory_bytes: 31836
n=int(input())

s=input().split(' ')

s=[int(i) for i in s]

dp = [10001]*100000

dp[0] = 0

dp[1] = abs(s[1] - s[0])

for i in range(2,n):
    
    dp[i] = min(dp[i-1] + abs(s[i]-s[i-1]), dp[i-2] + abs(s[i]-s[i-2]))

print(dp[n-1])

Measured memory_bytes: 13928
import java. io.*;

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

	BufferedReader br =
    	 new BufferedReader (new InputStreamReader(System.in));
	
	String str1 = br.readLine();
	String str2[] = str1.split(" ");
	int a = Integer.parseInt(str2[0]);
	int b = Integer.parseInt(str2[1]);
	int c = a*b;
	int d = 2*(a+b);
	System.out.println( c + " " + d );
	
      }
}

Measured memory_bytes: 24144
gets.to_i.times do
  xa, ya, ra, xb, yb, rb = gets.split(" ").map(&:to_f)
  l = Math.sqrt((xa - xb)**2 + (ya - yb)**2)
  if ra + rb < l
    puts "0"
  elsif (ra - rb).abs <= l and l <= ra + rb
    puts "1"
  elsif ra > rb
    puts "2"
  elsif ra < rb
    puts "-2"
  end
end

Measured memory_bytes: 6136
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;

LL n, m;
vector<vector<pair<LL, LL>>> graph;
vector<LL> length;
vector<bool> check;
bool flag = true;

void dfs(int from) {
  check[from] = true;
  for (int i = 0; i < graph[from].size(); i ++) {
    LL to = graph[from][i].first;
    LL distance = graph[from][i].second;
    if (check[to]) {
      if (length[to] != length[from] + distance) flag = false;
    } else {
      length[to] = length[from] + distance;
      dfs(to);
    }
  }
}


int main() {
  cin >> n >> m;
  graph = vector<vector<pair<LL, LL>>>(n);
  length = vector<LL>(n);
  check = vector<bool>(n, false);
  for (int i = 0; i < m; i ++) {
    LL l, r, d;
    cin >> l >> r >> d;
    l --, r --;
    graph[l].push_back(make_pair(r, d));
    graph[r].push_back(make_pair(l, -d));
  }

  for (int i = 0; i < n; i ++) {
    if (!check[i]) dfs(i);
  }

  string ans = "No";
  if (flag) ans = "Yes";
  cout << ans << endl;
}

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

int main()
{
    int a[5],k;
    for(int i=0;i<5;i++){
        cin >> a[i];
    }
    cin >> k;
    sort(a,a+5);
    int sum=a[4]-a[0];
    if(sum>k){
        cout << ":(" << endl;
    }
    else cout << "Yay!" << endl;
}


Measured memory_bytes: 256
var a=["":0];for _ in 0..<Int(readLine()!)!{let s=readLine()!;a[s]=(a[s] ?? 0)+1};for _ in 0..<Int(readLine()!)!{let t=readLine()!;a[t]=(a[t] ?? 0)-1};print(a.sort{$0.1>$1.1}[0].1)

Measured memory_bytes: 5872
/* Coached by Dukkha */
#include <stdio.h>

int main() {
	int n, cnt;

	scanf("%d", &n);
	cnt = 0;
	while (n--) {
		int a;

		scanf("%d", &a);
		while (a % 2 == 0) {
			cnt++;
			a /= 2;
		}
	}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n,m,x;
	cin>>n>>m>>x;
	
	vi c(n);
	vvi a(n,vi(m));
	REP(i,n){
		cin>>c[i];
		REP(j,m) cin>>a[i][j];
	}
	
	int ans=INF;
	REP(i,(1<<n)){
		vi sum(m,0);
		int cost=0;
		REP(j,n){
			if((i>>j)&1){
				REP(k,m) sum[k]+=a[j][k];
				cost+=c[j];
			}
		}
		bool jud=true;
		REP(j,m) if(sum[j]<x) jud=false;
		if(jud) ans=min(ans,cost);
	}
	
	cout<<(ans==INF?-1:ans)<<endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <map>
#include <set>

using namespace std;

int main() {
    long long int N;
    cin >> N;
    string str;
    cin >> str;
    map<char, set<long long int> > mp;
    for(int n=0; n<str.size(); n++) {
        mp[str[n]].insert(n+1);
    }

    long long int Q;
    cin >> Q;
    for(long long int q=0; q<Q; q++) {
        int t;
        cin >> t;
        if(t==1) {
            long long int i;
            char c;
            cin >> i >> c;
            
            if(c!=str[i-1]) {
                mp[str[i-1]].erase(i);
                mp[c].insert(i);
                str[i-1]=c;
            }
        } else {
            long long int l, r;
            cin >> l >> r;

            int ans=0;
            for(auto itr=mp.begin(); itr!=mp.end(); itr++) {
                if(itr->second.lower_bound(l)!=itr->second.upper_bound(r)) {
                    ans++;
                }
            }
            cout << ans << endl;
        }
    }


    return 0;
    
}

Measured memory_bytes: 26244
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;

vector<vector<int>> g(100005);
bool memo[100005];
map<P,int> m;

void color(int u,int pu,int k){
  memo[u]=1;
  // cout<<"u "<<u<<endl;
  int j=1;
  rep(i,g[u].size()){
    int to=g[u][i];
    // cout<<"to "<<to<<endl;
    if(memo[to]) continue;
    if(j==m[{u,pu}]) j++;
    P c={u,to};
    P d={to,u};
    m[c]=j;
    m[d]=j;
    j++;
    // cout<<"u to m "<<u<<" "<<to<<" "<<j<<endl;
    color(to,u,k);
  }
}

int main(){
  int n; cin>>n;
  vector<P> a(n-1);
  rep(i,n-1){
    int u,v; cin>>u>>v;
    u--;v--;
    g[u].push_back(v);
    g[v].push_back(u);
    a[i]={u,v};
  }

  P k={-1,-1};
  rep(i,n){
    k=max(k,{g[i].size(),i});
  }

  color(k.second,-1,k.first);

  cout<<k.first<<endl;
  rep(i,n-1){
    cout<<m[a[i]]<<endl;
  }

  return 0;
}


Measured memory_bytes: 21376
#include <iostream>

using namespace std;

int main() {
    long long N; cin >> N;
    if (N % 2 == 1) {
        cout << 0 << endl;
    } else {
        long long ans = 0;
        while (N >= 5) {
            ans += N / 10;
            N /= 5;
        }
        cout << ans << endl;
    }
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;

int n ;
ll tx , ty ;

void init() {
  scanf( "%d" , &n ) ;
}

void process() {
  ll x , y ;
  for ( int i = 0 ; i < n ; i ++ ) {
    scanf( "%lld%lld" , &x , &y ) ;
    ll tp = __gcd( x , y ) ;
    x /= tp , y /= tp ;
    ll lw = 1 , hg = 1000000000000000000 / max( x , y ) ;
    while ( lw < hg ) {
      ll mid = ( lw + hg ) / 2 ;
      if ( x * mid >= tx && y * mid >= ty ) {
        hg = mid ;
      } else lw = mid + 1 ;
    }
    tx = x * lw ;
    ty = y * lw ;
  }
  printf( "%lld\n" , tx + ty ) ;
}

int main() {
  init() ;
  process() ;
  return 0 ;
}


Measured memory_bytes: 256
def partial_match_table(word):
    table = [0] * (len(word) + 1)
    table[0] = -1
    i, j = 0, 1
    while j < len(word):
        matched = word[i] == word[j]
        if not matched and i > 0:
            i = table[i]
        else:
            if matched:
                i += 1
            j += 1
            table[j] = i
    return table

def kmp_search(text, word):
    table = partial_match_table(word)
    i, p = 0, 0
    results = []
    while i < len(text) and p < len(word):
        if text[i] == word[p]:
            i += 1
            p += 1
            if p == len(word):
                p = table[p]
                results.append((i-len(word), i))
        elif p == 0:
            i += 1
        else:
            p = table[p]
    return results

N, = map(int, input().split())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
A = []
B = []
for i in range(2*N-1):
    A.append(As[i%N] ^ As[(i+1)%N])
    if i < N:
        B.append(Bs[i%N] ^ Bs[(i+1)%N])
for k, l in kmp_search(A, B):
    print(k, As[k] ^ Bs[0])


Measured memory_bytes: 128080
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

int main(){
    int N, X;
    cin >> N >> X;
    int minimum = 1e9, sum = 0;
    for(int i = 0; i < N; i++){
        int m;
        cin >> m;
        minimum = min(minimum, m);
        sum += m;
    }
    cout << N + (X - sum) / minimum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d)){
    cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl;
}

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

#define endl '\n'
#define int ll
using namespace std;
typedef long long ll;

const int N = 110, W = 100005;

ll w, n;
ll weight[N], val[N];
ll dp[N][W];

void init();
void process();

int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

void init()
{
    cin >> n >> w;
    for(int i = 1; i <= n; i++) cin >> weight[i] >> val[i];
}

void process()
{
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= w; j++)
        {
            dp[i][j] = dp[i-1][j];
            if(j >= weight[i]) dp[i][j] = max(dp[i][j], dp[i-1][j-weight[i]]+val[i]);
        }
    cout << dp[n][w] << endl;
}



Measured memory_bytes: 79360
n = int(input())
s = sorted(list(map(int,input().split())))

if n == 2:
  print(sum(s) / 2)

else:
  m_v = 0
  for i in range(2, n):
    m_v += 2 ** (i - 1) * s[i]
    
  print((m_v + sum(s[:2])) / (2 ** (n - 1)))

Measured memory_bytes: 3060
import sys,math,collections,itertools,heapq
input = sys.stdin.readline

N,K=list(map(int,input().split()))
A = list(map(int,input().split()))
under=0
upper=max(A)
num = upper//2

while True:
    ans = 0
    if num == 0:
        print(1)
        exit()
    for a in A:
        ans += math.ceil(a/num)-1
    if ans >K:
        under = num
        num = math.ceil((num+upper)/2)
    else:
        upper = num
        num = math.floor((num+under)/2)
    if upper-under ==1:
        print(upper)
        break



    


Measured memory_bytes: 32440
#import<iostream>
#define l long
l N,M,c,n=1,i=2,o=1e9+7;
l m(l a)
{
	l g=1,h=2*o-4;
	for(;h/=2;)
	{
		h&1?g=g*a%o:0,a=a*a%o;
    }
	return g;
}
l C(l b)
{
	l r=1,d=1;
	for(;b;r=r*(N-1+b)%o,d=d*b--%o);
	return r*m(d)%o;
}
main()
{
	for(std::cin>>N>>M;i*i<=M;++i)
	{
		for(c=0;M%i<1;++c,M/=i);
		n=n*C(c)%o;
	}
	std::cout<<n*(M^1?N:1)%o<<std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }

inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }



int main()
{
    char a[6];
    cin>>a;
    if(a[2]==a[3]&&a[4]==a[5])
        cout<<"Yes\n";
    else cout<<"No\n";




    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int n,m;
    int i,j;
    scanf("%d %d",&n,&m);

    int A[n][m],B[m],C[n];
    for(i=0;i<n;i++){
        C[i]=0;
        for(j=0;j<m;j++){
            scanf("%d",&A[i][j]);
        }
    }
    for(i=0;i<m;i++){
        scanf("%d",&B[i]);
    }

    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            C[i]+=A[i][j]*B[j];
        }
    }

    for(i=0;i<n;i++){
        printf("%d\n",C[i]);
    }

    return 0;
}


Measured memory_bytes: 2104
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
template<typename T> void SSS(T& t) { cin >> t; }
#define SS(T, ...)      T __VA_ARGS__; SSS(__VA_ARGS__);
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

int main() {
   ll a,b;cin>>a>>b;
   rep(i,max(a,b)){
       cout<<min(a,b);
   }
   cout<<endl;
}


Measured memory_bytes: 256
"use strict";

function Main(input) {
  input = input.split(" ");
  input[0] = parseInt(input[0]);
  input[1] = parseInt(input[1]);

  // const counter = [0, 0, 0];

  for (let counter1 = 0; counter1 <= input[0]; counter1++) {
    for (let counter2 = 0; counter2 <= input[0]; counter2++) {
      let counter3 = input[0] - (counter1 + counter2);
      if (counter3 < 0) continue;
      if (
        counter1 + counter2 + counter3 === input[0] &&
        counter1 * 10000 + counter2 * 5000 + counter3 * 1000 === input[1]
      ) {
        console.log(counter1, counter2, counter3);
        return;
      }
    }
  }
  console.log(-1, -1, -1);
}

Main(require("fs").readFileSync("/dev/stdin", "utf-8"));


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

using namespace std;

const int MOD = 2;

void solve(int N, vector<long> A){
  int ans = 10000;
  rep(i, N) {
    int num = 0;
    while (A[i] % MOD == 0) {
      A[i] /= MOD;
      num++;
    }
    ans = min(ans, num);
  }
  cout << ans << endl;
}

int main(){
  int N;
  cin >> N;
  vector<long> A(N);
  for(int i = 0 ; i < N ; i++){
    cin >> A[i];
  }
  solve(N, move(A));
  return 0;
}


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

int main(){
    int N;
    cin >>N;
    int ans =0;
    int roughans = 0;
    vector<long long>vec(N);
    for(int i=0 ;i<N;i++){
        cin >>vec[i];
    }
    for(int i=0;i<N-1;i++){
        if(vec[i] >= vec[i+1]){
            roughans++;
        }
        else{
            ans = max(ans,roughans);
            roughans = 0;
        }
    }
  	ans = max(ans,roughans);
  	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long ans = (long long) 1e18;
  for (int p = 0; p < 2; p++) {
    long long cur = 0;
    long long s = 0;
    for (int i = 0; i < n; i++) {
      s += a[i];
      if (i % 2 == p) {
        if (s < 1) {
          cur += 1 - s;
          s = 1;
        }
      } else {
        if (s > -1) {
          cur += s - -1;
          s = -1;
        }
      }
    }
    ans = min(ans, cur);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int mbk(long long a,int n,int m){return n?(mbk((a*a)%m,n/2,m)*(n%2?a:1))%m:1;}
int inv(int a,int m){return mbk((long long)a,m-2,m);}
int aCb(int a,int b,int m){
  long long s=1,i;
  if(b>a-b)b=a-b;
  for(i=0;i<b;i++)s=(((s*(a-i))%m)*inv(i+1,m))%m;  
  return (int)s;
}
int main(){
  long long n,m,s,M=1e9+7;
  scanf("%lld %lld",&n,&m);
  s=n+m;
  if(s%3)goto END;
  n-=s/3;
  m-=s/3;
  if(n<0||m<0)goto END;
  printf("%d\n",aCb(n+m,m,M));
  return 0;
 END:;
  printf("0\n");
  return 0;
}


Measured memory_bytes: 128
#![allow(dead_code)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(unused_variables)]

use std::collections::BinaryHeap;
use std::io::Read;

const U32_LARGE: u32 = 1 << 30;

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

fn main() {
    let n: usize = read();
    let a: Vec<usize> = (0..n).map(|_| read()).collect();
    let b: Vec<u32> = (0..n).map(|_| read()).collect();
    let c: Vec<u32> = (0..n - 1).map(|_| read()).collect();

    let mut res: u32 = 0;
    for v in b {
        res += v;
    }

    for w2 in a.windows(2) {
        let x = w2[0];
        let y = w2[1];
        if y == x + 1 {
            res += c[x - 1];
        }
    }

    println!("{}", res);
}


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

int main(){
    string s;
    cin >> s;
    if(s.at(s.size()-1) == 's'){
        cout << s << "es" << endl;
    }else{
        cout << s << "s" << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
using namespace std;
int N,A[10010];
int min()
{
    int min=A[0];
    for(int i=0;i<N;i++)
    {
        if(A[i]<min)
            min=A[i];
    }
    return min;
}
int max()
{
    int max=A[0];
    for(int i=0;i<N;i++)
    {
        if(A[i]>max)
            max=A[i];
    }
    return max;
}
long long sum()
{
    long long sum=0;
    for(int i=0;i<N;i++)
        sum+=A[i];
    return sum;
}
int main()
{
    cin>>N;
    for(int i=0;i<N;++i)
        cin>>A[i];
    cout<<min()<<' '<<max()<<' '<<sum()<<endl;
}


Measured memory_bytes: 3140
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <cstring>
#include <iomanip>
using namespace std;
typedef long long ll;



int main() {
    int N; cin >> N;
    string S; cin >> S;
    
    vector<int> Cum(N);
    vector<int> E(N);
    int sumE = 0;
    
    for(int i=0; i<N; i++)if(S[i]=='E') sumE++;
    
    for(int i=1; i<N; i++){
        if(S[i-1]=='W'){
            Cum[i] = Cum[i-1] + 1;
            E[i] = E[i-1];
        }
        else {
            Cum[i] = Cum[i-1];
            E[i] = E[i-1] + 1;
        }
    }
    
    
    int ans = 3e5;
    for(int i=0; i<N; i++){
        int con = Cum[i]+sumE-E[i];
        if(S[i] == 'E') con--;
        ans = min(ans, con);
    }

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



Measured memory_bytes: 3076
#![allow(unused_imports)]
#![allow(dead_code)]
#![macro_use]
use std::io::prelude::*;
use std::cmp::{max, min};
use std::collections::BinaryHeap;

const MOD: i64 = 1e9 as i64 + 7;

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)*}
    };
}

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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

fn main() {
    input! {
        a: isize,
        b: isize,
        c: isize,
    }
    println!("{}", if c >= a && c <= b {"Yes"} else {"No"});
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int n;
  	cin >> n;
  	vector<vector<int>> s(n,vector<int>(2));
  	int ans=0;
  	for(int i=0;i<n;i++){
    	for(int f=0;f<2;f++){
        	cin >> s.at(i).at(f);
        }
    }
  	for(int i=0;i<n;i++){
    	if(s.at(i).at(0) == s.at(i).at(1)) ans++;
      	if(ans == 3) break;
      	else if(s.at(i).at(0) != s.at(i).at(1)) ans = 0;
    }
  	if(ans >= 3) cout << "Yes" << endl;
	else cout << "No" << endl;  
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define show(x) cout<<x<<'\n'
#define go(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define mod 1000000007
int main() {
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll count=1;
	ll c[26]={0};
	go(i,0,n)
	{
	    c[s[i]-'a']++;
	}
	go(i,0,26)
	{
	    count=((count%mod)*((c[i]+1)%mod))%mod;
	}
	cout<<count-1;
	return 0;
}


Measured memory_bytes: 512
S = int(input())
h = 0
m = 0
s = 0
 
while True:
    if S >= 3600:
        h += 1
        S -= 3600
    elif S >= 60:
        m += 1
        S -= 60
    else:
        break
 
print(str(h) + ":" + str(m) + ":" + str(S))

Measured memory_bytes: 7668
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int n,a,b;
	cin>>n>>a>>b;
	a=min(a,b);
	b=max(a,b);
	long long int d=b-a;
	if(d%2==0)
	cout<<d/2<<endl;
	else{
		long long int ans1,ans2;
		ans1=a+(b-a-1)/2;
		ans2=n-b+1+(b-a-1)/2;
		cout<<min(ans1,ans2)<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
// #include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//BELOW

void solve(void)
{ 
  int N,A;
  cin>>N>>A;
  vector<int> vec (N,0);
  for (int i = 0; i < N; i++)
  {
     cin>>vec[i];
  }
  int M = 50*50+50;
  vector<vector<vector<int> > > DP (N+1,vector<vector<int> >(N+1,vector<int>(M,0)));
  DP[0][0][0] = 1;
  for (int i = 0; i <= N; i++)
  {
    DP[i][0][0] = 1;
  }
  

  for (int i = 1; i <= N; i++)
  {
    for (int j = 1; j <=N; j++)
    {
      for (int k = 1; k <= M; k++)
      {
        if(k-vec[i-1] >= 0)
        DP[i][j][k] += DP[i-1][j][k] +DP[i-1][j-1][k-vec[i-1]];
        else
        {
          DP[i][j][k] += DP[i-1][j][k];
        }
        
      }
      // DEBUG(DP[i]);
      
    }
    
  }

  int res = 0;
  for (int i = 1; i <= N; i++)
  {
    res += DP[N][i][i*A];
    // DEBUG(res);
  }
  cout<<res<<endl;
  
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 56260
import numpy as np
n, m = map(int, input().split())
stairs = set([int(input()) for i in range(m)])
ans = [1] * (n+1)
mod = 10**9 + 7
if 1 in stairs:
    ans[1] -= 1
for i in range(2, n+1):
    if i in stairs:
        ans[i] = 0
    else:
        ans[i] = ans[i-1] + ans[i-2]

print(ans[-1]%mod)


Measured memory_bytes: 468940
N = 100
WHITE = 0
GRAY = 1
BLACK = 2
INF = float('inf')
M = None
d = [INF for _ in range(N)]
p = [0 for _ in range(N)]
color = [WHITE for _ in range(N)]
n = 0


def main():
    global n, M

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

    for i in range(n):
        _, k, *v_s = map(int, input().split(' '))
        for j in range(k):
            c_i = 2*j + 1
            v = v_s[2*j]
            M[i][v] = v_s[c_i]

    dijkstra(0)

    for i in range(n):
        print('{} {}'.format(i, d[i]))


def dijkstra(s):
    d[s] = 0
    p[s] = -1

    while True:
        mincost = INF
        for i in range(n):
            if color[i] != BLACK and d[i] < mincost:
                mincost = d[i]
                u = i

        if mincost == INF:
            break

        color[u] = BLACK

        for v in range(n):
            if color[v] != BLACK and M[u][v] != INF:
                if d[u] + M[u][v] < d[v]:
                    d[v] = d[u] + M[u][v]
                    p[v] = u
                    color[v] = GRAY


if __name__ == '__main__':
    main()



Measured memory_bytes: 5788
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
using namespace std;

long long relu(long long x){
  if (x<0) return 0;
  return x;
}

int main(){
  int x, y, z, k;
  scanf("%lld %lld %lld %lld", &x, &y, &z, &k);
  
  long long a[1000], b[1000], c[1000];
  for(int i=0; i<x; i++) scanf("%lld", &a[i]);
  for(int i=0; i<y; i++) scanf("%lld", &b[i]);
  for(int i=0; i<z; i++) scanf("%lld", &c[i]);
  //printf("%lld %lld %lld %lld %lld %lld\n", n, d[0], d[1], d[2], d[3], d[4]);
  
  //for(int i=0; i<x; i++) printf("%lld\n", a[i]);
  //sort(c, c + z);
  long long ab[1000*1000];
  for(int i=0; i<x; i++) {
  	for(int j=0; j<y; j++) {
      ab[i*y+j] = a[i] + b[j];
    }
  }
  sort(ab, ab + x*y);
  //for(int i=0; i<x*y; i++) printf("%lld\n", ab[i]);
  
  long long abc[3000*1000];
  int limit = min(x*y, k);
  for(int i=0; i<limit; i++) {
  	for(int j=0; j<z; j++) {
      abc[i*z+j] = ab[x*y-i-1] + c[j];
    }
  }
  
  limit = limit * z;
  sort(abc, abc + limit);
    
  for(int i=0; i<k; i++) printf("%lld\n", abc[limit-i-1]);
  
  
  return 0;
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
int main() {
  //string a;
  int N, K;

  cin >> N >> K;
  //cout << N << K << endl;
  if (K == 1) {
    cout << "0" << endl;
    return 0;
  }
  cout << N-K << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int n;
  cin >> n;
  if(n <= 999){
    cout << "ABC" << endl;
  }
  else cout << "ABD" << endl;

  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define MOD1 1000000007
#define MOD2 1000000009
#define ll long long int
#define li long int
#define fi first
#define se second
#define ffl fflush(stdout);
#define whT int t; cin>>t; while(t--)
int main() 
{
	int x;
	cin>>x;
	int ans=0,tt=0;
	while(tt%360!=0 || tt==0) {
		ans++;
		tt+=x;

	}
	cout<<ans<<endl;

}


Measured memory_bytes: 3568
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#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 < typename T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    int len = comma - names;
    for (int i = 0; i < len; ++i) {
        cout << names[i];
    }
    cout <<  " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef pair < int, int > pii;
typedef vector < ll > vll;
typedef vector < int > vi;

#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, base = 1e9, MOD = 1e9 + 7, N = 1e5 + 5, M = 1e3 + 5;
const int INF = INT_MAX;
const db PI = acos(-1);

void test();

int main() {
    fast_io();
    test();
    return 0;
}

void test() {
    int n;
    cin >> n;
    int a[n], tot = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        tot += a[i];
    }
    int ans = INF, cur = 0;
    for (int i = 0; i < n; ++i) {
        ans = min(ans, abs(cur - (tot - cur)));
        cur += a[i];
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int gcd(int a,int b){
    int tmp;
    if(b>a){
        tmp = a;
        a = b;
        b = tmp;
    }
    while(b != 0){
        tmp = a%b;
        a = b;
        b = tmp;
    }
    return a;
}
int main(){
    int n,x;
    cin >> n >> x;
    vector<int> in(n);
    for(int i=0;i<n;i++){
        cin >> in[i];
        in[i] = abs(in[i] - x);
    }
    int ans = (n==1)?in[0]:gcd(in[0],in[1]);

    for(int i=2;i<n;i++){
        ans = gcd(ans,in[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    ll n, k;
    cin >> n >> k;
    ll ans = 1;
    for (int i = 0; i < n-1; ++i) {
        ans += (ans+k-2)/(k-1);
    }
    cout << ans-1 << "\n";
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	map<char,int> mp;
	ll n; cin >> n;
	rep(i,n){
		char c; cin >> c;
		mp[c]++;
	}
	if(mp.size()==3) puts("Three");
	else puts("Four");
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  long int a,b;
  int c;
  scanf("%ld",&a);
  c=0;
  if(a>=500)
  c=a/500;
  a=a%500;
  b=c*1000;
  c=a/5;
  b=b+c*5;
  printf("%ld",b);
  

}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  int res = 0;
  int count = 0;
  for (int i = 0; i < n-1; i++) {
    if(v[i+1] <= v[i]) count++;
    else{
      res = max(res, count);
      count = 0;
    }
  }
  res = max(res, count);
  cout << res << endl;

}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl

int main() {
	lint N, M;
	cin >> N >> M;
	vector<lint>H(N);
	rep(i, N) {
		cin >> H[i];
	}
	vector<lint>A(M);
	vector<lint>B(M);
	rep(i, M) {
		cin >> A[i] >> B[i];
	}
	vector<vector<lint>>G(N);
	rep(i, M) {
		G[A[i] - 1].push_back(H[B[i] - 1]);
		G[B[i] - 1].push_back(H[A[i] - 1]);
	}
	
	
	bool ok = true;
	lint ans = 0;
	rep(i, N) {
		rep(j, G[i].size()) {
			if (H[i] <= G[i][j]) {
				ok = false;
			}
		}
		if (ok == true) {
			ans++;
		}
		ok = true;
	}
	cout << ans << endl;
 }

Measured memory_bytes: 11444
#include <iostream>
#include <cstdlib>

int main(){
	int n;
	while(1){
		std::cin >> n;
		if(n==0) break;
		long a[n];
		for(int i=0;i<n;i++) std::cin >> a[i];
		long min = 2000000;
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				min=std::min(min,std::abs(a[i]-a[j]));
			}
		}
		std::cout << min << std::endl;
	}
}



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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()

const string YES = "Possible";
const string NO = "Impossible";

void solve(long long N, long long L, std::vector<long long> a){
    i64 s = -1;
    rep(i, N - 1){
        if(a[i] + a[i + 1] >= L){
            s = i;
        }
    }
    if(s == -1){
        cout << NO << endl;
        return;
    }
    cout << YES << endl;
    rep(i, 1, s + 1) cout << i << endl;
    for(i64 i = N - 1; i >= s + 1; --i) cout << i << endl;
}

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    long long N;
    scanf("%lld",&N);
    long long L;
    scanf("%lld",&L);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, L, std::move(a));
    return 0;
}


Measured memory_bytes: 1664
#include<iostream>
using namespace std;
int fact(int n){
	int ans=1;
	if(n==0 || n==1)return 1;
	for(int i=2;i<=n;i++){
		ans*=i;
	}
	return ans;
}
int Ret_Number(int num , int*dict,int count,int*used){
	int ans = 0;
    for(int i=0;i<count;i++){
     	if(used[i] ==0)continue;
      	if(used[i] < num){
         	ans++; 
        }
    }
     for(int i=0;i<count;i++){
		if(dict[i] == num){
            
			return i - ans;
		}
	}
	return -1;
}
int main(void){
	int n=0;
	cin>>n;
	int P[8];
	int Q[8];
	for(int i=0;i<n;i++){
		cin>>P[i];
	}
	for(int i=0;i<n;i++){
		cin>>Q[i];
	}
	int dic[8];
	for(int i=0;i<n;i++){
		dic[i] = P[i];
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(dic[i] > dic[j]){
				int temp = dic[i];
				dic[i] = dic[j];
				dic[j] = temp;
			}
		}
	}
	long long int a=0;
	long long int b=0;
    int used[8] = {0,0,0,0,0,0,0,0};    
	for(int i=0;i<n;i++){
        int k = Ret_Number(P[i],dic,n,used);
        used[i] = P[i];
		a+= k * fact(n-i-1);
	}
    used[0] = 0;
    used[1] = 0;
    used[2] = 0;
    used[3] = 0;
    used[4] = 0;
    used[5] = 0;
    used[6] = 0;
    used[7] = 0;
	for(int i=0;i<n;i++){
        int k = Ret_Number(Q[i],dic,n,used);
        used[i] = Q[i];
		b+= k * fact(n-i-1);
	}
	if(a>b){
		printf("%d\n",a-b);
	}else{
		printf("%d\n",b-a);
	}
	return 0;
}

Measured memory_bytes: 256
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    ll N,T;cin>>N>>T;
    typedef pair<ll,ll> P;
    vector<P> v(N);
    REP(i,N){
        cin>>v[i].first>>v[i].second;
    }
    ll c=INF;
    REP(i,N){
        if(v[i].second<=T&&v[i].first<c){
            c=v[i].first;
        }
    }
    if(c==INF){
        cout<<"TLE\n";
    }else{
        cout<<c<<"\n";
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	char s[5];
	char count = 0;
	
	gets(s);
	for(char i = 0; i < 3; i++)
	{
		for(char j = i + 1; j < 4; j++) if(s[i] == s[j]) count++;
	}
	if(count == 2) printf("Yes"); else printf("No");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

pair<int, double> calc_E(int p) {
    // pの期待値を計算する
    int se = 0; // 整数部
    double sm = 0.0; // 少数部
    if (p % 2 == 0) {
        se = p/2;
        sm = 0.5;
    } else {
        se = p/2 + 1;
    }
    return make_pair(se, sm);
}

pair<ll, double> narasi(pair<ll, double> a) {
    a.first += floor(a.second);
    a.second -= floor(a.second);
    return a;
}

bool is_bigger(pair<ll, double> a, pair<ll, double> b) {
    // bの方が大きければtrue
    if (a.first < b.first) {
        return true;
    } else if (a.first == b.first) {
        if (a.second < b.second) {
            return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
}

int main() {
    cout << fixed << setprecision(10);

    // p[i]までの累積和を計算しておく
    int p_max = 1000;
    vector<int> psums(p_max+1);
    int t_sum = 0;
    repr(i, 1, p_max+1) {
        t_sum += i;
        psums[i] = t_sum;
    }
    
    int N, K; cin >> N >> K;
    vector<int> p(N);
    rep(i, N) cin >> p[i];

    // pを期待値に変換
    vector<pair<int, double>> pm(N);
    rep(i, N) {
        pm[i] = calc_E(p[i]);
    }

    // max_psは一番左のK個の塊で初期化する
    ll temp_sum = 0;
    double is_05 = 0;
    rep(i, K) {
        temp_sum += pm[i].first;
        is_05 += pm[i].second;
    }
    temp_sum += floor(is_05);
    is_05 -= floor(is_05);
    pair<ll, double> temp_p = make_pair(temp_sum, is_05);
    
    pair<ll, double> ans = temp_p;
    // cout << ans << endl;
    repr(i, 1, N-K+1) {
        // ll n_sum = temp_sum - double(psums[p[i-1]])/p[i-1] + double(psums[p[i+K-1]])/p[i+K-1];
        ll se = temp_p.first - pm[i-1].first + pm[i+K-1].first;
        double syo = temp_p.second - pm[i-1].second + pm[i+K-1].second;
        auto temp_pn = narasi(make_pair(se, syo));
        // cout << n_sum << endl;
        if (is_bigger(ans, temp_pn)) {
            ans = temp_pn;
        }
        temp_p = temp_pn;
    }
    cout << ans.first;
    if (ans.second != 0) {
        cout << ".5";
    }
    cout << endl;
    
    return 0;
}

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

int main() {
    long long x, k, d, p;
    cin >> x >> k >> d;

    x = abs(x);
    if (x/d >= k) cout << x-k*d << endl;
    else { 
        p = x%d;
        k = k - (x/d);
        if(k%2 == 0) cout << p << endl;
        else cout << abs(p-d) << endl;
    }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
const int inf = 1e18;
typedef pair<int, int> P;
#define MAX 35000000

int price[32], value[32], segn = 1;
int segmax[MAX];
vector<P> a[2];

void dfs(int k, int t, int u, int pri, int val){
	if(k == t){
		a[u].push_back(P(pri, val));
		return ;
	}
	dfs(k+1, t, u, pri+price[k], val+value[k]);
	dfs(k+1, t, u, pri-price[k], val-value[k]);
	dfs(k+1, t, u, pri, val);
}

void init(int n){
	while(segn < n)segn *= 2;
	for(int i = 0;i < segn*2;i++)segmax[i] = -inf;
}

void add(int k, int val){
	k += segn-1;
	segmax[k] = val;
	while(k){
		k = (k-1)/2;
		segmax[k] = max(segmax[k*2+1], segmax[k*2+2]);
	}
}

int getmax(int a, int b, int k, int l, int r){
	if(b <= l || r <= a)return -inf;
	if(a <= l && r <= b)return segmax[k];
	int t1 = getmax(a, b, k*2+1, l, (l+r)/2);
	int t2 = getmax(a, b, k*2+2, (l+r)/2, r);
	return max(t1, t2);
}

signed main(){
	int n, d;
	scanf("%lld%lld", &n, &d);
	for(int i = 0;i < n;i++)
	scanf("%lld%lld", &price[i], &value[i]);
	
	int m = n/2;n = n-m;
	dfs(0, n, 0, 0, 0);
	dfs(n, n+m, 1, 0, 0);
	
	sort(a[0].begin(), a[0].end());
	sort(a[1].begin(), a[1].end(), greater<P>());
	
	init(a[1].size());
	for(int i = 0;i < a[1].size();i++){
		add(i, a[1][i].se);
	}
	
	int l = 0, r = 0, ans = 0;
	for(int i = 0;i < a[0].size();i++){
		int bn = a[1].size(), v = a[0][i].fi, v2 = a[0][i].se;
		while(r < bn && a[1][r].fi+v >= -d)r++;
		while(l < bn && a[1][l].fi+v > d)l++;
		int mx = getmax(l, r, 0, 0, segn);
		if(mx == -inf)continue;
		ans = max(ans, llabs(v2+mx));
	}
	
	/*for(int i = 0;i < a[0].size();i++){
		printf("%d ", a[0][i].se);
	}
	printf("\n");
	for(int i = 0;i < a[1].size();i++){
		printf("%d ", a[1][i].se);
	}
	printf("\n");*/
	printf("%lld\n", ans);
}


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

typedef long long ll;
#define PI 3.1415926535897932384626433
#define mod 1000000007

int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(){
    int n;
    string s, t;
    cin >> n >> s >> t;
    int ans = 1e9;
    for (int i = 0; i <= n; i++){
        string l, r;
        l = s.substr(i);
        r = t.substr(0, n - i);
        if (l == r)
        {
            cout << n + i << endl;
            return 0;
        }
    }
    return 0;
}


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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    vector<long long int> B;
    B.push_back(0);
    for(int i=0; i<N; i++) {
        int sub = A[i] - B.back();
        B.push_back(sub);
    }

    int diff = (B.back() - B.front()) / 2;
    for(int i=0; i<N; i++) {
        B[i] += (i % 2 ? -diff : diff);
        cout << B[i] * 2 << " \n"[i+1 == N];
    }
}


Measured memory_bytes: 2676
#include<bits/stdc++.h>
#define rep(i,n) for(long long int i=0;i<n;i++)
#define lli long long int
#define ll long long 
#define dd double
#define endl "\n"
#define mod 1000000007
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define limit 1000000000000000000
const double pi=3.14159265358;
const double pie=2*acos(0.0);
	
using namespace std;
lli power(lli a,lli b)
{
	lli res=1;
	while(b>0)
	{
		if(b%2!=0)
		{
			b--;
			res=(res%mod*a%mod)%mod;
		}
		else
		{
			a=(a%mod*a%mod)%mod;
			b/=2;
		}
	}
	return res%mod;
}
bool sortinrev(const pair<lli,lli> &a,  
               const pair<lli,lli> &b) 
{ 
       return (a.first > b.first); 
}

int main() {
	fast
	lli n;
	cin>>n;
	lli ar[n+1];
	for(int i=1;i<=n;i++)cin>>ar[i];
	lli sum=0;
	for(int i=1;i<=n;i++)sum+=ar[i];
	lli br[100001];
	rep(i,100001)br[i]=0;
	for(int i=1;i<=n;i++)br[ar[i]]++;
	lli q;
	cin>>q;
	while(q--)
	{
		lli x,y;
		cin>>x>>y;
		sum-=(br[x]*x);
		sum+=br[x]*y;
		br[y]+=br[x];
		br[x]=0;
		cout<<sum<<endl;
	}

	
}

Measured memory_bytes: 5176