akhauriyash/Code-Regression huggingface dataset:
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

void Check(map<char, int> m) {
	string ans = "Yes";
	for (auto itr = m.begin(); itr != m.end(); ++itr) {
		if (itr->second % 2 != 0) {
			ans = "No";
			break;
		}
	}
	cout << ans << endl;
}

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.

	string w;
	map<char, int> m;
	
	cin >> w;
	FOR(i, 0, w.length()) {
		if (m.count(w[i])==0) {
			m.insert(MP(w[i], 1));
		}
		else {
			m.insert(MP(w[i], ++m[w[i]]));
		}
	}

	Check(m);
	
	return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
MOD=10**9+7 #先に書いておく

s=[0] #sのリスト(累積和)
for i in range(0,N): #累積和を作る
    s.append(s[i]+A[i])

sum=0
for j in range(0,N): #合計をだす
    sum+=A[j]*(s[N]-s[j+1])

ans=sum%MOD #10^9+7で割った余りが答え
print(ans)

Measured memory_bytes: 31444
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn vec<T, F: FnMut(usize) -> T>(n: usize, mut f: F) -> Vec<T> {
    (0..n).map(|i| f(i)).collect()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let a: Vec<i64> = vec(n, |_| scan(tokens));
    let mut alt: i64 = 0;
    for i in 0..n {
        if i % 2 == 0 {
            alt += a[i];
        } else {
            alt -= a[i];
        }
    }
    let mut x = alt;
    print!("{}", x);
    for i in 1..n {
        x = 2 * a[i - 1] - x;
        print!(" {}", x);
    }
    println!("");
}


Measured memory_bytes: 7420
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			double a = sc.nextDouble();
			double b = sc.nextDouble();
			int c = 0;
			int d = 0;
			int max = 0;
			
			if(a<35.5) c = 1;
			else if(a<37.5) c = 2;
			else if(a<40.0) c = 3;
			else if(a<43.0) c = 4;
			else if(a<50.0) c = 5;
			else if(a<55.0) c = 6;
			else if(a<70.0) c = 7;
			else c = 8;
			
			if(b<71.0) d = 1;
			else if(b<77.0) d = 2;
			else if(b<83.0) d = 3;
			else if(b<89.0) d = 4;
			else if(b<105.0) d = 5;
			else if(b<116.0) d = 6;
			else if(b<148.0) d = 7;
			else d = 8;
			
			max = Math.max(c, d);
			
			if(max==1) System.out.println("AAA");
			else if(max==2) System.out.println("AA");
			else if(max==3) System.out.println("A");
			else if(max==4) System.out.println("B");
			else if(max==5) System.out.println("C");
			else if(max==6) System.out.println("D");
			else if(max==7) System.out.println("E");
			else if(max==8) System.out.println("NA");
		}
	}	
}

Measured memory_bytes: 20504
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int n,m,k;
    cin >> n >> m >> k;
    vector a(n,0LL);
    vector b(m, 0LL);

    for (int i=0; i<n; i++) cin >> a[i];
    for (int i=0; i<m; i++) cin >> b[i];

    vector acsum(n+1, 0LL);
    vector bcsum(m+1, 0LL);
    for (int i=1; i<=n; i++) acsum[i] += acsum[i-1] + a[i-1];
    for (int i=1; i<=m; i++) bcsum[i] += bcsum[i-1] + b[i-1];

    debug(acsum);
    debug(bcsum);

    int64 ans = 0;
    for (int i=0; i<=n; i++) {
        if (acsum[i] > k) break;
        int64 t = k - acsum[i];
//        debug(t);
        auto it = upper_bound(bcsum.begin(), bcsum.end(), t);
        int64 index = (int64)(it - bcsum.begin());
//        debug(index);
        ans = max(ans, i + index - 1);
    }

    cout << ans << endl;
}

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

#define INF 1234567890
#define ll long long

int N, Q;

int main()
{
	scanf("%d %d", &N, &Q);
	dsu tree(N);
	while(Q--)
	{
		int t, a, b;
		scanf("%d %d %d", &t, &a, &b);
		if (t == 0)
		{
			tree.merge(a, b);
		}
		else
		{
			printf("%d\n", (int)tree.same(a, b));
		}
	}
	return 0;
}

Measured memory_bytes: 3952
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(n):
    s = str(n)
    array = list(map(int, list(s)))
    N=sum(array)
    if n%N==0:
        return "Yes"
    else:
        return "No"

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    return int(line)

def main():
    n = readQuestion()
    answer = solve(n)
    print(answer)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

constexpr int Nmax = 100000;
int N, M, S[2];
int U[Nmax], V[Nmax];
vector<int> to[100000];
lint C[2][Nmax], d[2][Nmax];

int main()
{
    cin >> N >> M >> S[0] >> S[1];
    S[0]--;
    S[1]--;
    REP(e, M)
    {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        U[e] = u - 1;
        V[e] = v - 1;
        C[0][e] = a;
        C[1][e] = b;
        to[u - 1].push_back(e);
        to[v - 1].push_back(e);
    }

    REP(i, 2)
    {
        REP(j, N) d[i][j] = 1E15;
        d[i][S[i]] = 0;
        priority_queue<plint, vector<plint>, greater<plint>> pq;
        for (auto e : to[S[i]]) pq.push(plint(C[i][e], U[e] + V[e] - S[i]));

        while (!pq.empty())
        {
            auto pa = pq.top();
            pq.pop();
            int now = pa.second;
            if (d[i][now] > pa.first)
            {
                d[i][now] = pa.first;
                for (auto e : to[now])
                {
                    int nxt = U[e] + V[e] - now;
                    if (d[i][nxt] > d[i][now] + C[i][e]) pq.push(plint(d[i][now] + C[i][e], nxt));
                }
            }
        }
    }

    lint ans[Nmax];
    lint tmp_cost = 1E15;
    IREP(i, N)
    {
        tmp_cost = min(tmp_cost, d[0][i] + d[1][i]);
        ans[i] = tmp_cost;
    }
    REP(i, N) cout << (lint)1E15 - ans[i] << endl;
}


Measured memory_bytes: 12144
void main() {
	auto ip = readAs!(long[]), K = ip[0], A = ip[1], B = ip[2];
	if(K+1 < A || B - A <= 2) {
		writeln(K+1);
		return;
	}
	K -= A-1;
	writeln((B-A) * (K/2) + K%2 + A);
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


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

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

    if ((N >= 'A') && (N <= 'Z')){
        cout << "A" << endl;
    }else{
        cout << "a" << endl;
    }

    return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<ll> a(3*N);
  for(int i=0;i<3*N;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());

  ll sum=0;
  for(int i=0;i<N;i++){
    sum+=a.at(2*i+1);
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 2560
from collections import OrderedDict
if __name__ == "__main__":
    n = int(input())
    job = dict()
    for i in range(n):
        tmp = list(map(int, input().split()))
        if tmp[1] in job:
            job[tmp[1]].append(tmp[0])
        else:
            job[tmp[1]] = [tmp[0]]

    sch = sorted(job)

    time = 0
    for j in sch:
        time += sum(job[j])
        if time <= j:
            continue
        else:
            print('No')
            exit()

    print('Yes')


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

#define ll long long
#define ull unsigned long long
#define mod 1e9+7
#define INF 1 << 30
#define MAX (1 << 20)
#define NINF (-(1 << 30))
#define triplet pair<pair<int, int>, int>

ll power(ll base, ll p, ll pr){
    ll ans = 1;

    if(base == 1)
        return 1;

    if(base == 0)
        return 0;

    while(p){
        if(p&1)
            ans = (ans*base)%pr;

        base = (base*base)%pr;
        p >>= 1;
    }

    return ans;
}

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

    int n;

    cin >> n;

    if(n < 2)
    	cout << 0 << endl;

    else {
    	ll ans = power(10, n, mod) + power(8, n, mod) - (((power(9, n, mod)) * 2) % ((ll)mod));
 		//cout << power(10, n, mod) << " " << power(8, n, mod) << " " << (((power(9, n, mod)) * 2) % ((ll) mod)) << endl;
    	if(ans < 0) ans += mod;
    	if(ans >= mod) ans -= mod;
    	cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<cstring>

int PrimeCount(int n){
	int A[n+5];
	memset(A,0,sizeof(A));//0は素数
	for(int i=2;i*i<=n;i++){
		if(A[i]==0){
			for(int j=i*2;j<=n;j+=i){
				A[j]=1;
			}
		}
	}
	int count=0;
	for(int i=2;i<=n;i++){
		if(A[i]==0) count++;
	}
	return count;
}

int main(void){
	int n;
	while(std::cin>>n){
		std::cout<<PrimeCount(n)<<std::endl;
	}
	return 0;
}



Measured memory_bytes: 6884
#include<iostream>
#include<string>
using namespace std;
int main () {
    string s;cin>>s;
    string k[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    if (s==k[0]) cout<<"7"<<endl;
if (s==k[1]) cout<<"6"<<endl;
if (s==k[2]) cout<<"5"<<endl;
if (s==k[3]) cout<<"4"<<endl;
if (s==k[4]) cout<<"3"<<endl;
if (s==k[5]) cout<<"2"<<endl;
if (s==k[6]) cout<<"1"<<endl;
}


Measured memory_bytes: 256
/*
O(N^2)
verify:
https://atcoder.jp/contests/abc005/tasks/abc005_4
*/

#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
template<class T,class U>constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;}
template<class T,class U>constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;}

template<class T>
struct CumulativeSum1D{
    int N;
    bool flag;
    vector<T> table;

    CumulativeSum1D(int N):N(N),flag(false){
        table.resize(N+1,0);
    }
    void add(int n,const T x){
        flag=false;
        table[n+1]+=x;
    }
    void build(){
        flag=true;
        for(int i=1;i<=N;i++){
            table[i]+=table[i-1];
        }
    }

    T &operator[](int k){
        assert(flag);
        return table[k];
    }
};

signed main(){
    int N,T;
    cin>>N>>T;
    CumulativeSum1D<int> C(T+1);
    for(int i=0;i<N;i++){
        int l,r;
        cin>>l>>r;
        C.add(l,1);
        C.add(r,-1);
    }
    C.build();
    int ret=0;
    for(int i=0;i<=T;i++){
        ret=max(ret,C[i]);
    }
    cout<<ret<<endl;
}


Measured memory_bytes: 3116
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
const int MAXN = 510;

int N;
ll K;
int arr[MAXN];
int cv[MAXN];
int ans;

void test (int x)
{
    int stot = 0;
    for (int i = 0; i < N; i++)
    {
        cv[i] = arr[i] % x;
        stot += cv[i];
    }
    sort (cv, cv + N);
    reverse (cv, cv + N);
    stot /= x;

    ll nneed = 0;
    for (int i = 0; i < stot; i++)
        nneed += x - cv[i];
    if (nneed <= K)
        ans = max (ans, x);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> N >> K;
    int ctot = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> arr[i];
        ctot += arr[i];
    }

    ans = 1;
    for (int i = 1; i * i <= ctot; i++)
        if (ctot % i == 0)
        {
            test (i);
            test (ctot / i);
        }
    cout << ans << "\n";
}

Measured memory_bytes: 384
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

int n,k,r,s,p,ans=0; 

int fun(char c){
    if (c=='r') return p;
    if (c=='s') return r;
    if (c=='p') return s;
    return 0;
}

inline void solve(){
    cin>>n>>k>>r>>s>>p; 
    string str; cin>>str;
    for (int i=k;i<n;i++){
        if (str[i]==str[i-k]) str[i] = '-1'; 
    }
    for (int i=0;i<n;i++)
        ans += fun(str[i]);
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(x) scanf("%d",&x)
#define sc(x) scanf(" %c",&x)
#define sll(x) scanf("%I64d",&x)
#define f(i,n,k) for(int i=k;i<n;i++)
#define pi(x) printf("%d ",x);
#define pll(x) printf("%I64d ",x);
int main()
{
    char ch[10];
    scanf(" %s",ch);
    if(ch[2]==ch[3] && ch[4]==ch[5])
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}


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


def read_h(conv=int):
    return map(conv, input().split())


def read_v(n, conv=int):
    return [conv(input()) for _ in range(n)]


def main():
    n = int(input())

    for i in range(n // 4 + 1):
        for j in range(n // 7 + 1):
            if 4 * i + 7 * j == n:
                print('Yes')
                return

    print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = (1e9)+7;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  int n;
  cin>>n;
  ll res=1;
  for(int i=1;i<=n;i++){
  	ll x;
  	cin>>x;
  	if(x%2==0){
  		res*=2;
  	}
  }
  cout<<pow(3,n)-res<<endl;
}





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

int main(){
  
  
  int a,b;
  cin >> a >> b;
  set<int> se;
  se.insert(1);
  se.insert(2);
  se.insert(3);
  se.erase(se.find(a));
  se.erase(se.find(b));	
  
  cout << *(se.begin()) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }

vector<pair<ll, ll>> G[100100];
ll dp[2][2][100100];

void dfs(ll id, ll st, ll v, ll res) {
  if (dp[id][st][v] == INF) {
    dp[id][st][v] = res;
    for (auto p: G[v]) {
      dfs(id, st ^ 1, p.first, p.second - res);
    }
  }
  if (dp[id][st][v] != res) {
    cout << 0 << '\n';
    exit(0);
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  ll n, m;
  cin >> n >> m;
  rep(i, m) {
    ll u, v, s;
    cin >> u >> v >> s;
    u--, v--;
    G[u].push_back({v, s});
    G[v].push_back({u, s});
  }

  rep(i, 2) rep(j, 2) rep(k, n) dp[i][j][k] = INF;
  dfs(0, 0, 0, 0);
  dfs(1, 0, 0, 1);
  if (dp[0][1][0] != INF) {
    ll res = abs(dp[0][0][0] - dp[0][1][0]);
    rep(j, 2) rep(k, n) dp[0][j][k] = INF;
    dfs(0, 0, 0, res / 2);
    rep(i, n) {
      if (min(dp[0][0][i], dp[0][1][i]) <= 0) {
        cout << 0 << '\n';
        return 0;
      }
    }
    cout << 1 << '\n';
  }
  else {
    ll l = 1, r = INF;
    FOR(i, 1, n) {
      ll st = (dp[0][0][i] == INF);
      ll diff = dp[1][st][i] - dp[0][st][i];
      if (diff == 1) chmax(l, 1 - dp[0][st][i]);
      else chmin(r, dp[0][st][i] - 1);
    }
    cout << max(0LL, r - l + 1) << '\n';
  }



  




  
  return 0;
}

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

using namespace std;

int main() {         
	int a;
	cin >> a;
	int a1 = a, s = 0;
	while (a1 > 0) {
	 	s += a1 % 10;
	 	a1 /= 10;
	}
	if (a % s == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a;
    int b;
    int c;
    int ans = 0;
    cin>>a>>b>>c;
    for(int i=a; i<b+1; i++){
        if(c%i==0){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3100
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main argv =
    let n = read int
    let vs = reads int
    let cs = reads int
    List.fold2 (fun s v c -> if v - c > 0 then s + (v - c) else s) 0 vs cs
    |> printfn "%i"
    0

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

namespace ConsoleApp11
{
    class Class39
    {
        static void Main()
        {
            var I = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var A = I[0];
            var B = I[1];
            var C = I[2];
            
            int count = 0;
            
            
            while (!(I[0] == I[1] & I[1] == I[2]))
            {
                var max = Math.Max(I[0], Math.Max(I[1], I[2]));
                int notmax = I.Count(x => x < max);
                if (notmax > 1)
                {
                    for(int i = 0; i < 3; i++)
                    {
                        if (I[i] < max)
                        {
                            I[i] += 1;
                            
                        }
                    }
                    count += 1;
                }
                else
                {
                    for(int i = 0; i < 3; i++)
                    {
                        if (I[i] < max)
                            I[i] += 2;
                        
                    }
                    count += 1;
                }
            }
            Console.WriteLine(count);
        }
    }
}



Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define RREP(i,a) for(long (i)=(a)-1;(i)>=0;(i)--)
#define FORR(i,a,b) for(long (i)=(a)-1;(i)>=(b);(i)--)
#define PI acos(-1.0)
#define DEBUG(C) cout<<C<<endl;
#define VI vector<int>
#define VII vector<VI>
#define VL vector<long>
#define VLL vector<VL>
#define VD vector<double>
#define VDD vector<VD>
#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<long,long>
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define REVERSE(a) reverse(ALL(a))
#define MP make_pair
#define FORE(a,b) for(auto &&a:b)

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int INF=1e9;
const int MOD=INF+7;

set<int> s;
bool numFind(int num){
    while(num){
        if(s.find(num%10)!=s.end()) return false;
        num/=10;
    }
    return true;
}

int search(int num){
    FOR(i,num-1,100000){
        if(numFind(i+1)) return i+1;
    }
}

int main (void){
    int N,K; cin>>N>>K;
    REP(i,K){
        int d; cin>>d;
        s.insert(d);
    }
    cout<<search(N)<<endl;
}


Measured memory_bytes: 256
def solve():
    MOD = 10**9 + 7

    N = int(input())
    Ass = [tuple(map(int, input().split())) for _ in range(N)]

    dp = [[0]*(1<<N) for _ in range(N+1)]
    dp[0][0] = 1
    for iM in range(N):
        for S in range(1<<N):
            if dp[iM][S]:
                dp[iM][S] %= MOD
                for iW in range(N):
                    if S & (1<<iW) == 0 and Ass[iM][iW]:
                        S2 = S ^ (1<<iW)
                        dp[iM+1][S2] += dp[iM][S]

    print(dp[-1][-1] % MOD)


solve()


Measured memory_bytes: 395288
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
vector<int> dy={1,0,-1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    sort(all(a));
    
    if(a[n-1]-a[0]>=2){
        cout<<"No"<<endl;
        return 0;
    }
    
    if(a[0]==a[n-1]){
        int x=a[0];
        if(n==x+1 || n>=x*2) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    else{
        int x=a[0];
        int now=0;
        while(a[now]==x) now++;
        
        if(now<x && n-now>=(x-now+1)*2) cout<<"Yes"<<endl;
        else if(now==x && n-now>=2) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;


int main()
{
  int temp;
  int64_t N;
  string ans = "";
  cin >> N;
  while(1){
    if(N % 2 == 0) ans = "0" + ans;
    else{
      ans = "1" + ans;
      N--;
    }
    N /= -2;
    if(N == 0) break;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int MAXN=200010, LOG=20;

int n, m, k, u, v, x, y, t, a, b, lazy;
deque<char> S;

inline void make(){
	char tmp=S.front();
	if (lazy) tmp='A'+'B'-tmp;
	if (tmp=='A'){
		S[0]='A'+'B'-S[0];
		return ;
	}
	S.push_back(S.front());
	S.pop_front();
	lazy^=1;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>k;
	S.resize(n);
	for (int i=0; i<n; i++) cin>>S[i];
	if (k>2*n) k=2*n+(k%2); 
	while (k--){
		make();
	}
	
	for (int i=0; i<n; i++){
		if (lazy) cout<<(char)('A'+'B'-S[i]);
		else cout<<S[i];
	}
	
	return 0;
}


Measured memory_bytes: 3872
#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==7&&b==5&&c==5)
	{
		printf("YES");
	}else if(a==5&&b==7&&c==5)
	{
		printf("YES");
	}else if(a==5&&b==5&&c==7)
	{
		printf("YES");
	}else printf("NO");
	return 0;
}

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

//.define
//#define FILE_IN_OUT
#define RET(_x)                       return std::cout << (_x), 0;
#define all(_obj)                     (_obj).begin(), (_obj).end()
#define fori(_iterator, _begin, _end) for (int _iterator = (_begin); _iterator < (_end); ++_iterator)
#define forr(_iterator, _begin, _end) for (int _iterator = (_begin); _iterator >= (_end); --_iterator)
#define loop(_n)                      for (int i = 0; i < (_n); ++i)
#define divCeil(_dividend, _divider)  (((_dividend) - 1LL + (_divider)) / (_divider))
#define sz(_obj)                      static_cast<int>((_obj).size())
#define endl                          "\n"
template<typename Tp>
inline void outarr(Tp _array, const std::size_t _N, const char* _delim = " ") {
    Tp end = _array + _N;
    for (Tp current = _array; current != end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = std::int64_t;
using pii = std::pair<int, int>;
constexpr int INF = INT_MAX;
constexpr int MOD = 1e9 + 7;

//.data

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream сin  ("input.txt",  std::ios::in);
    std::ofstream сout ("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

   int n, m;
   cin >> n >> m;

   int x = (18 * m + n) * 100;

   cout << x * (1 << m);

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
int main()
{
    long long h;
    int n;
    cin >> h >> n;
    rep(i,n){
        long long a;
        cin >> a;
        h -= a;
    }
    if(h <= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
ll a,b;
string s;
cin >> a >> b >> s;
for(ll i=0;i<a;i++){
    if(s[i]=='-'){cout << "No" << endl;
    return 0;}
}
if(s[a]!='-'){cout << "No" << endl;
return 0;}
for(ll i=a+1;i<s.size();i++){
    if(s[i]=='-'){cout << "No" << endl;
    return 0;}
}
cout << "Yes" << endl;
}


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

using namespace std;

int main(){
  string str;
  
  cin >> str;
  if(str[0]=='Y'&&str[1]=='A'&&str[2]=='K'&&str[3]=='I'){
    cout << "Yes" << endl;
  }else{
    cout << "No"  << endl;
  }
  return 0;
}

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

const int maxn=100010;
int n;
int t[maxn], x[maxn], y[maxn];
int tx[maxn], ty[maxn];

void noans(){ puts("No"); exit(0); }

int main(){

	scanf("%d", &n);
	for(int i=1;i<=n;i++){
		scanf("%d%d%d", &t[i], &x[i], &y[i]);
		tx[i]=x[i]+y[i]; ty[i]=x[i]-y[i];
	}
	for(int i=1;i<=n;i++){
		if((t[i] ^ tx[i]) & 1){ puts("No"); return 0; }
		if((t[i] ^ ty[i]) & 1){ puts("No"); return 0; }
		tx[i]=(tx[i]+t[i])>>1; ty[i]=(ty[i]+t[i])>>1;
	}
	for(int i=1;i<=n;i++){
		if(tx[i]<tx[i-1]) noans();
		if(ty[i]<ty[i-1]) noans();
		if(tx[i]>tx[i-1]+t[i]-t[i-1]){ puts("No"); return 0; }
		if(ty[i]>ty[i-1]+t[i]-t[i-1]){ puts("No"); return 0; }
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(ll i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin,(a).rend()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	dunk((n - 1) * (m - 1));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
#include<vector>
using namespace std;
#include<algorithm>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)

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



int main() {

	ll n,a[100000];
	ll x=0, y=0;

	cin >> n;
	rep(i, 0, n) {
		cin >> a[i];
	}
	sort(a, a + n);
	reverse(a, a + n);
	rep(i, 0, n) {
		if (a[i] == a[i + 1]) {
			if (x == 0) {
				x = a[i];
				i++;
			}
			else {
				y = a[i];
				break;
			}
		}
	}
	if (x && y)cout << x*y << endl;
	else cout << "0" << endl;

	return 0;
}

Measured memory_bytes: 1024
N, M = map(int, input().split())
A = list(map(int, input().split()))
check = ((1/(4*M))*sum(A))
x = 0
for item in A:
    if item < check:
        x += 1
ans = N - x
if ans >= M:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Linq;
    using System.Reflection.PortableExecutable;
    using System.Runtime.CompilerServices;
    using System.Text;
    using System.Xml.Serialization;

    public class Test
    {
        public static void Main(string[] args)
        {
            var t = new Test();
            var nk = t.ParseIntList(t.ReadInput());
            var p = t.ParseIntList(t.ReadInput());
            var total = 0;
            p.Sort();

            for(var i = 0; i<nk[1]; i++)
            {
                total += p[i];
            }
            Console.WriteLine(total);
        }

        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }

        public List<int> ParseIntList(string[] x)
        {
            var convertedList = new List<int>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(int.Parse(x[i]));
            }

            return convertedList;
        }


        public List<double> ParseDoubleList(string[] x)
        {
            var convertedList = new List<double>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(double.Parse(x[i]));
            }

            return convertedList;
        }

        public List<long> ParseLongList(string[] x)
        {
            var convertedList = new List<long>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(long.Parse(x[i]));
            }

            return convertedList;
        }

        public int CountContainWords(string source, string word)
        {
            var count = 0;
            var loopCount = source.Length - (word.Length - 1);
            for (var i = 0; i < loopCount; i++)
            {
                if (source.Substring(i, word.Length) == word)
                {
                    count++;
                }
            }
            return count;
        }
    }
}

Measured memory_bytes: 28040
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
const int MOD = 1000000007;

int main()
{
  int N,T=0;
  string S;
  
  cin >> S;
  if(S[0] == S[S.size()-1]){
    if(S.size()%2 == 1){
      cout << "Second" << endl;
    }else
      cout << "First" << endl;
  }else{
    if(S.size()%2 == 1){
      cout << "First" << endl;
    }else
      cout << "Second" << endl;
  
  }
 
  return 0;
}



Measured memory_bytes: 764
#include <stdio.h>
int main(void)
{
  int a,b,c,tmp;
  scanf("%d %d %d",&a,&b,&c);
  if(a>b)
{
    tmp=a;
    a=b;
    b=tmp;
  }

 if(a>c)
{
    tmp=a;
    a=c;
    c=tmp;
  }

  if(b>c)
{
    tmp=b;
    b=c;
    c=tmp;
  }

  printf("%d %d %d\n",a,b,c);
  
  return 0;
}


Measured memory_bytes: 2040
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string ab = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string as = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

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

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------
//提出するときC++に帰る
//--------------------------

int main() {

  int n, k;
  cin >> n >> k;
  int su[n];
  rep(i, n) su[i] = 0;

  int d[k];
  rep(i, k) {
    cin >> d[i];
    rep(j, d[i]) {
      int a;
      cin >> a;
      ++su[a-1];
    }
  }

  int cnt = 0;
  rep(i, n) {
    if(su[i]==0) ++cnt;
  }

  cout << cnt << endl;

  return 0;
}


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

int main() {
  string n,k;
  int sum=1,i;
  cin>>n>>k;
  
  while(i<n.size()){
  if(n.at(i)!=k.at(i))sum++;                     
    i++;
    
  }

cout<<sum-1<<endl;

}




Measured memory_bytes: 3920
//July Challenge 2020
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 1e10 + 5;
const double E= 1e-9;
 
//------------------------------------------------------------------------------

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*ifstream cin("input.txt");
    ofstream cout("output.txt");*/
    string s[4]={"AC","WA","TLE","RE"};
    int n;
    cin>>n;
    map<string,int> mp;
    while(n--)
    {
        string s;
        cin>>s;
        ++mp[s];
    }
    for(int i=0; i<4; i++)
    cout<<s[i]<<" x "<<mp[s[i]]<<"\n";
    return 0;
}
//Date: ###### Sun Jul 5 17:35:34 IST 2020
//------------------------------------------------------------------------------

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(max({a,b,c}) == a+b+c-max({a,b,c})){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
int main() {
  // int n;
  // string s;
  // cin >> n >> s;

  // int head_idx = s.find_first_of('#');
  // int last_idx = s.find_last_of('.');

  // int hc_w = 0;
  // int hc_b = 0;
  // for (int i = head_idx; i < s.length(); i++) {
  //   if (s[i] == '.') hc_w++;
  //   else hc_b++;
  // }
  // int lc_w = 0;
  // int lc_b = 0;
  // for (int i = last_idx; i >= 0; i--) {
  //   if (s[i] == '.') lc_w++;
  //   else lc_b++;
  // }

  // cout << min(min(hc_w, hc_b), min(lc_w, lc_b)) << endl;

  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string s;
  cin >> s;

  int wc = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '.') {
      wc++;
    }
  }

  int ans = INT_MAX;
  int bc = 0;
  for (int i = 0; i < s.length(); i++) {
    ans = min(ans, bc + wc);
    if (s[i] == '.') wc--;
    if (s[i] == '#') bc++;
  }

  cout << min(ans, bc + wc) << endl;

  return 0;
}


Measured memory_bytes: 720
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
ll b[10+5],x[10+5];
char a[10+5];
ll alen,t=0,tot,d,k,f;
ll ans=0;
ll Pow(int a,ll x)
{
	ll ret=1;
	while(x>0)
	{
		x--;
		ret*=a;
	}
	return ret;
}
int main()
{
	scanf("%s",a);
	alen=strlen(a);
	for(int i=0;i<alen;i++)
		b[t++]=a[i]-'0';
	for(int i=1;i<=t;i++)//处理每一位的系数,共有t位
	{
		f=i-1;
		d=0;
		k=0;
		tot=t-i+1;//系数位数
		if(tot==1)
			x[i]=pow(2,t-1);
		else
		{
			while(d<tot)
			{
				d++;
				if(d==2)
					f=i-1;
				k=1LL*k*10+Pow(2,f);
				f++;
			}
			x[i]=k;
		}
	}
	for(int i=1;i<=t;i++)
		ans+=b[i-1]*x[i];
	printf("%lld\n",ans);
	return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) static_cast<int>((x).size())

using LL = long long;
template<class T, size_t D>
struct vec : vector<vec<T, D - 1>> {
  template<class... Args>
  vec(size_t n = 0, Args... args)
    : vector<vec<T, D - 1>>(n, vec<T, D - 1>(args...)) {}
};
template<class T>
struct vec<T, 1> : vector<T> {
  template<class... Args>
  vec(Args... args)
    : vector<T>(args...) {}
};

template<class T>
inline bool asMn(T& a, const T& b) { return a > b ? a = b, true : false; }
template<class T>
inline bool asMx(T& a, const T& b) { return a < b ? a = b, true : false; }
inline int nex(int i, int n) { return i == n - 1 ? 0 : i + 1; }
inline int pre(int i, int n) { return !i ? n - 1 : i - 1; }

const LL LL_INF = 1e18;
mt19937 rng(static_cast<uint32_t>(chrono::steady_clock::now().time_since_epoch().count()));

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

  #ifdef EntityIT
  freopen("input.txt", "r", stdin);
  #endif // EntityIT

  int n; cin >> n;
  vec<int, 1> a(3 * n);
  for (auto& i : a) {
    cin >> i;
  }

  vec<LL, 1> pref(3 * n);
  priority_queue<int> pq;
  LL cur = 0;
  for (int i = 0; i < n; ++i) {
    pq.emplace(-a[i]);
    cur += a[i];
  }
  pref[n - 1] = cur;
  for (int i = n; i < 3 * n; ++i) {
    cur += a[i];
    pq.emplace(-a[i]);
    cur += pq.top();
    pq.pop();
    pref[i] = cur;
  }

  vec<LL, 1> suff(3 * n);
  while (sz(pq)) {
    pq.pop();
  }
  cur = 0;
  for (int i = 3 * n - 1; i >= 2 * n; --i) {
    pq.emplace(a[i]);
    cur += a[i];
  }
  suff[2 * n] = cur;
  for (int i = 2 * n - 1; ~i; --i) {
    cur += a[i];
    pq.emplace(a[i]);
    cur -= pq.top();
    pq.pop();
    suff[i] = cur;
  }

  LL ans = -LL_INF;
  for (int i = n - 1; i + n < 3 * n; ++i) {
    asMx(ans, pref[i] - suff[i + 1]);
  }
  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 9676
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

int main() {
  int a,b,c;
  cin >> a >> b >> c;

  if ((a <= c and c <= b) or (b <= c and c <= a)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
package main

import (
        "fmt"
)

func main() {
        var h, w int
        fmt.Scan(&h, &w)
        s := make([][]rune, h)
        for i := range s {
                s[i] = make([]rune, w)
        }
        for i := range s {
                for j := range s[i] {
                        fmt.Scanf("%c", &s[i][j])
                }
                fmt.Scanln()
        }

        for i := range s {
                for j := range s[i] {
                        if s[i][j] == '#' &&
                                (i+1 >= len(s) || s[i+1][j] != s[i][j]) &&
                                (i-1 < 0 || s[i-1][j] != s[i][j]) &&
                                (j+1 >= len(s[i]) || s[i][j+1] != s[i][j]) &&
                                (j-1 < 0 || s[i][j-1] != s[i][j]) {
                                fmt.Println("No")
                                return
                        }
                }
        }
        fmt.Println("Yes")
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

""" Input
N, A, B = map(int, input().split())
A = list(map(int, input().split()))
D = [int(input()) for _ in range(N)]
"""

a = int(input())
s = input().rstrip()

if a >= 3200:
    print(s)
else:
    print('red')




# def main():


# if __name__ == '__main__':
#     main()


Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rrep(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
typedef long long ll;
using namespace std;

const ll mod = 998244353;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const { //値をt乗する
    if (!t) return 1; // t == 0
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this; //*thisは元の値(t乗する対象)
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint dp[3050][3050][3];

int main(){
    int n, s; cin >> n >> s;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    dp[0][0][0] = 1;
    rep(i,n){
        rep(j,s+1){
            dp[i+1][j][0] += dp[i][j][0];
            dp[i+1][j][1] += dp[i][j][0] + dp[i][j][1];
            dp[i+1][j][2] += dp[i][j][0] + dp[i][j][1] + dp[i][j][2];
            if(j + a[i] <= s){
                dp[i+1][j+a[i]][1] += dp[i][j][0] + dp[i][j][1];
                dp[i+1][j+a[i]][2] += dp[i][j][0] + dp[i][j][1];
            }
        }
    }
    cout << dp[n][s][2].x << endl;
  
    return 0;
}

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

#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define eb emplace_back

typedef long long ll;
typedef pair<int,int> ii;
typedef vector< pair<int,int> > vii;
const int INF = 0x3f3f3f3f;

int main() {
    ios::sync_with_stdio(false);
    int a;
    string s;
    cin >> a >> s;
    cout << (a >= 3200? s : "red") << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		while (true) {
        // 入力されるH,Wを定義

        int H = scanner.nextInt();
        int W = scanner.nextInt();

        // H,Wともに0の時終了
        if (H == 0 && W == 0) {
        	break;
        }

        for (int i = 0; i < H; i++) {
        	for (int j = 0; j < W; j++) {
        		System.out.print("#");
        	}
        	System.out.println("");
        }
        System.out.println("");
		}
	}

}



Measured memory_bytes: 32972