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

#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 ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N,M; cin >> N >> M;
    vector<int> X(M); REP(i,M) cin >> X[i];
    sort(ALL(X));
    vector<int> dist(M-1); REP(i,M-1) dist[i] = X[i+1] - X[i];
    sort(ALL(dist));
    int ans = 0;
    REP(i, M-N){
        ans += dist[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4052
W, H = map(int, input().split())
*A, = map(int, input().split())
*B, = map(int, input().split())
A.sort(reverse=1)
ok =+ (sum(A) == sum(B))
for a in A:
    B.sort(reverse=1)
    for i in range(a):
        if i >= len(B) or B[i] == 0:
            ok = 0
            break
        B[i] -= 1
print(ok)



Measured memory_bytes: 5720
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;
typedef pair<double, int> Pdi;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

class BIT
{
public:
    vector<int> bit;
    int M;

    BIT(int M):
        bit(vector<int>(M+1, 0)), M(M) {}

    int sum(int i) {
        if (!i) return 0;
        return bit[i] + sum(i-(i&-i));
    }

    void add(int i, int x) {
        if (i > M) return;
        bit[i] += x;
        add(i+(i&-i), x);
    }
};

double calcans(int N, vector<double> &A, vector<double> &B, vector<double> &C){
    //傾き順にソート
    vector<Pdi> p(N);
    REP(i, N) p[i] = Pdi(-1.0 * A[i] / B[i], i);
    SORT(p);
    vector<int> invp(N);
    //傾きの順位(1~N)
    REP(i, N) invp[p[i].second] = i + 1;

    int N_tot = N * (N - 1) / 2;

    double x1 = -1.0e10, x2 = 1.0e10;
    while(x2 - x1 > max(1.0e-12, max(abs(x1), abs(x2)) * 1.0e-12)){
        double x = (x1 + x2) / 2.0;
        vector<Pdi> y(N);
        //y(x)でソート
        REP(i, N) y[i] = Pdi(-1.0 * A[i] / B[i] * x + C[i] / B[i], i);
        SORT(y);
        int count = 0;
        BIT b(N);
        REP(i, N){
            int i0 = y[i].second;
            count += b.sum(invp[i0]);
            b.add(invp[i0], 1);
        }
        if(count >= (N_tot + 1) / 2) x2 = x;
        else x1 = x;
    }
    return x2;
}

signed main(){

    int N; cin >> N;
    vector<double> A(N), B(N), C(N);
    REP(i, N) cin >> A[i] >> B[i] >> C[i];
    cout << setprecision(15) << calcans(N, A, B, C) << " " << calcans(N, B, A, C);
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 3152
let () = Scanf.scanf "%d" @@ fun n ->
  let l_ary = Array.init n @@ fun _ -> Scanf.scanf " %d" Fun.id in
  Printf.printf "%s\n" @@
  if 2 * (Array.fold_left max min_int l_ary) < Array.fold_left ( + ) 0 l_ary then "Yes" else "No"

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<long long int> a,b;
    for(int i = 0;i < n + 1;i++)
    {
        long long int x;
        cin >> x;
        a.push_back(x);
    }
    for(int i = 0;i < n;i++)
    {
        long long int x;
        cin >> x;
        b.push_back(x);
    }
    long long int count = 0;
    for(int i = 0;i < n;i++)
    {
        if(b.at(i) > a.at(i))
        {
            count += a.at(i);
            b.at(i) -= a.at(i);
            if(b.at(i) > a.at(i + 1))
            {
                count += a.at(i + 1);
                a.at(i + 1) = 0;
            }
            else
            {
                count += b.at(i);
                a.at(i + 1) -= b.at(i);
            }    
        }
        else
        {
            count += b.at(i);
        }
    }
    cout << count;
    
    return 0;
}


Measured memory_bytes: 2548
kards = [[0]*13 for i in range(4)]
maping = dict(zip(['S', 'H','C', 'D'], range(4)))
map_inv = dict(zip(range(4), ['S', 'H','C', 'D']))

n = int(input())
for i in range(n):
    m, num = input().split()
    num = int(num)
    m_int = maping[m]
    kards[m_int][num-1] = 1

for i in range(4):
    for j in range(13):
        if kards[i][j]==0:
            print(map_inv[i] + ' ' + str(j+1))


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

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

	int n,l;
	cin>>n>>l;
	int s=0;
	for(int i=1;i<=n;i++){
		s+=(l+i-1);
	}
	if(l<=0 && l+n-1>=0) cout<<s<<"\n";
	else if(l+n-1<0) cout<<s-(l+n-1)<<"\n";
	else cout<<s-l<<"\n";

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class AtCoderA
{
    static void Main()
    {
        int n;
        int r;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            n = int.Parse(words[0]);
            r = int.Parse(words[1]);
        }

        Console.WriteLine(n < 10 ? r + 1000 - 100 * n : r);
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
const int inm = 1145141919;
int main(void){
    int l,r; cin>>l>>r;
    if(r-l-2019>=0) {  cout<<0<<endl; return 0;}
    l %= 2019;
    r%=2019;
    
    if(r<=l)  {cout<<0<<endl; return 0;}
    int m = inm;
    for(int i=l;i<=r;i++){
        for(int j=l;j<=r;j++){
            if(j==i) continue;
            int z = i*j;
            z%=2019;
            m = min(m, z%2019);
            
        }
    }
    cout<<m<<endl;
}

Measured memory_bytes: 256
import itertools

N = input()
P = input()
Q = input()
PList = P.split()
QList = Q.split()

PQList = []
for i in itertools.permutations(range(1,int(N) + 1)):
    x = list(i)
    x_str = [str(n) for n in x]
    PQList.append(x_str)


a = PQList.index(PList) + 1
b = PQList.index(QList) + 1
print(abs(a - b))

Measured memory_bytes: 26996
#include<bits/stdc++.h>
#define maxn 10000
using namespace std;
int n,cnt=0;
string s[maxn];
vector<string> v;
int a=0,b=0,c=0;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
		for(int j=0;j<=s[i].size()-2;j++)
			if(s[i].substr(j,2)=="AB")
				++cnt;
		string t="";
		if(s[i][0]=='B'&&s[i][s[i].size()-1]=='A')
			c++;
		if(s[i][0]=='B')
			a++;
		if(s[i][s[i].size()-1]=='A')
			b++;
	}
	cnt+=min(a,b);
	if(a==c&&b==c&&b>0)
		--cnt;
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 896
N,A,B,C = map(int,(input().split()))
s = [[] for _ in range(N+1)]
for i in range(N):
    s[i] = input()
s[N] = "NOTHING"

flag = 0
ans = []
S = A+B+C

if S >= 3:
    for i in range(N):
        if s[i] == "AB":
            if A+B <= 0:
                flag = 1
                break
            if A >= B:
                ans.append("B")
                B += 1
                A -= 1
            else:
                ans.append("A")
                A += 1
                B -= 1

        if s[i] == "AC":
            if A+C <= 0:
                flag = 1
                break
            if A >= C:
                ans.append("C")
                C += 1
                A -= 1
            else:
                ans.append("A")
                A += 1
                C -= 1

        if s[i] == "BC":
            if B+C <= 0:
                flag = 1
                break
            if B >= C:
                ans.append("C")
                C += 1
                B -= 1
            else:
                ans.append("B")
                B += 1
                C -= 1
    if flag == 1:
        print("No")
    else:
        print("Yes")
        for i in ans:
            print(i)

else:
    
    for i in range(N):
        #print(A,B,C)
        if s[i] == "AB":
            if A+B <= 0:
                flag = 1
                break
            if B == 0:
                ans.append("B")
                B += 1
                A -= 1
            elif A == 0:
                ans.append("A")
                A += 1
                B -= 1
            else:
                if s[i+1] == "AC":
                    ans.append("A")
                    A += 1
                    B -= 1
                else:
                    ans.append("B")
                    B += 1
                    A -= 1

        if s[i] == "AC":
            if A+C <= 0:
                flag = 1
                break
            if C == 0:
                ans.append("C")
                C += 1
                A -= 1
            elif A == 0:
                ans.append("A")
                A += 1
                C -= 1
            else:
                if s[i+1] == "BC":
                    ans.append("C")
                    C += 1
                    A -= 1
                else:
                    ans.append("A")
                    A += 1
                    C -= 1

        if s[i] == "BC":
            if B+C <= 0:
                flag = 1
                break
            if C == 0:
                ans.append("C")
                C += 1
                B -= 1
            elif B == 0:
                ans.append("B")
                B += 1
                C -= 1
            else:
                if s[i+1] == "AC":
                    ans.append("C")
                    C += 1
                    B -= 1
                else:
                    ans.append("B")
                    B += 1
                    C -= 1

    if flag == 1:
        print("No")
    else:
        print("Yes")
        for i in ans:
            print(i)

Measured memory_bytes: 86416
using System;

namespace csITP1c
{
    class Program
    {
        static void Main()
        {
            int copy;
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);

            copy = a * b;
            b = (a + b) * 2; 
            Console.WriteLine("{0} {1}", copy, b);
        }
    }
}

Measured memory_bytes: 9224
#include <iostream>
#include <cstring>
using namespace std;
int arr[3][2];
int k[4];
int sea[3];
void dp(int n) {
	int i, j, a, b, num=0;
	for (i = 0; i < 3; i++) {
		for (j = 0; j < 2; j++) {
			if (arr[i][j] == n && !sea[i]) {
				num++, a = i, b = j;
			}
		}
	}
	if (num > 1) {
		return ;
	}
	else {
		k[n - 1] = 1;
		int y = abs(1 - b);
		k[arr[a][y]-1] = 1;
		sea[a] = 1;
		if(sea[0]&&sea[1]&&sea[2])
		return ;
		dp(arr[a][y]);
	}
}
int main()
{
	int i;
	for (i = 0; i < 3; i++) {
		cin >> arr[i][0] >> arr[i][1];
	}
	dp(1);
	for (i = 0; i < 4; i++) {
		if (!k[i]) {
			break;
		}
	}
	if (i == 4)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

Measured memory_bytes: 256
import sys
import numpy as np
import heapq


def input():
    return sys.stdin.readline()[:-1]


def solve():
    H,W = map(int, input().split())
    c = W//2
    if H==1 or W==1:
        print(1)
        exit()
    if W%2==0:
        if H%2==0:
            ans = (H//2)*2*c
        else:
            ans = (H//2)*c + (H//2+1)*c
    else:
        if H%2==0:
            ans = (H//2)*(2*c+1)
        else:
            ans = (H//2)*c + (H//2+1)*(c+1)
    print(int(ans))


if __name__ == "__main__":
    solve()


Measured memory_bytes: 12508
n = int(input())
t, a = map(int, input().split())
H = list(map(int, input().split()))
for i in range(n):
    h = H[i]
    chk = t - h*0.006
    if i == 0:
        ans = chk
        ans_index = i+1
    else:
        if abs(chk - a) < abs(ans - a):
            ans = chk
            ans_index = i+1
print(ans_index)

Measured memory_bytes: 9200
using System;
using System.Collections.Generic;
using System.IO;

class Solve{
    static void Main(string[] args){
        var s = int.Parse(Console.ReadLine());
        var hash = new HashSet<int>();
        var answer = 1;
        while (!hash.Contains(s)){
            hash.Add(s);
            s = s % 2 == 0 ? s / 2 : 3 * s + 1;
            answer++;}
        var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

Measured memory_bytes: 27640
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:f64,
    b:f64,
    c:f64,
    }
    println!("{}",a*b/2.0)
}

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

#define task "A"
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define pb push_back
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;

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

// Limit

// Struct

// Variables
int n,n1;
// Function

int main()
{
	//freopen(task".in","r",stdin);
	//freopen(task".out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	cin >> n;
	n1=n;
	n1=(n1-1)/2+1;
	cout << fixed << setprecision(8) << (double)(n1)/(double)(n);
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <set>
using namespace std;
 
struct NODE {
    int id;
    int degree;
    int parent;
    int depth;
    vector<int> child;
};
 
 
int main() {
    vector<NODE> node;
    int n;
    int i,j;
    int id,k;
    scanf("%d",&n);
    node.resize(n);
    for(i=0; i<n; ++i) {
        scanf("%d%d",&id,&k);
        node[id].parent=-1; // default
        node[id].depth=0;   // default
        if(0==(node[id].degree=k)) {
            continue;
        }
        node[id].child.resize(k);
        for(j=0; j<k; ++j) {
            scanf("%d",&node[id].child[j]);
        }
    }
    for(i=0; i<n; ++i) {
        if((k=node[i].degree)==0) continue;
        for(j=0; j<k; ++j) {
            node[node[i].child[j]].parent=i;
        }
    }
    for(i=0; i<n; ++i) {
        j=i;
        while(node[j].parent!=-1){
            j=node[j].parent;
            ++node[i].depth;
        }
    }
    for(i=0; i<n; ++i) {
        if(node[i].parent==-1) {
            printf("node %d: parent = %d, depth = %d, root, [",i,node[i].parent,node[i].depth);
            for(j=0; j<node[i].degree-1; ++j) {
                printf("%d, ",node[i].child[j]);
            }
            if(node[i].degree!=0) {
                printf("%d",node[i].child[j]);
            }
            printf("]\n");
        } else if(node[i].degree==0) {
            printf("node %d: parent = %d, depth = %d, leaf, [",i,node[i].parent,node[i].depth);
            for(j=0; j<node[i].degree-1; ++j) {
                printf("%d, ",node[i].child[j]);
            }
            if(node[i].degree!=0) {
                printf("%d",node[i].child[j]);
            }
            printf("]\n");
        } else {
            printf("node %d: parent = %d, depth = %d, internal node, [",i,node[i].parent,node[i].depth);
            for(j=0; j<node[i].degree-1; ++j) {
                printf("%d, ",node[i].child[j]);
            }
            if(node[i].degree!=0) {
                printf("%d",node[i].child[j]);
            }
            printf("]\n");
        }
    }
    return 0;
}

Measured memory_bytes: 6556
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };



int main() {
	int x[4],y[4];
	for (int i = 0; i < 2;i++)scanf("%d%d", &x[i],&y[i]);

	int dx = x[1] - x[0];
	int dy = y[1] - y[0];

	x[2] = x[1] - dy;
	y[2] = y[1] + dx;

	x[3] = x[2] - dx;
	y[3] = y[2] - dy;

	printf("%d %d %d %d", x[2], y[2], x[3], y[3]);


}



/*         提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
・文字列の＜＜スペル＞＞は確認したか？
・＜＜解の存在性＞＞は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
*/

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
    int N,K;
    cin>>N>>K;
    if(N%K==0|| N==K)
    {
        cout<<'0';
    }
    else
    {
        int div=N/K;
        cout<<(div+1-div)<<endl;
    }
}

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

using namespace std;

int len=0;

int get_length(int x)
{
	while(x)
	{
		x/=10;
		len++;
	}
	return len;
}

int main()
{
	int a,b;
	double result,number;
	while(cin>>a>>b)
	{
		len=get_length(b);
		number=a*pow(10,len)+b;
		result=sqrt(number);
		if(abs(round(result)-result)<1e-8)
			cout<<"Yes";
		else
			cout<<"No";
	}
	return 0;
}

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

using lint = long long;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	vector<vector<lint>> freq(n, vector<lint>(26));
	map<string, lint> mapa;
	for (int i = 0; i < n; ++i) {
		string str, aux;
		cin >> str;
		for (char c : str) freq[i][c-'a']++;
		for (int j = 0; j < 26; ++j)
			aux.push_back(freq[i][j]);
		mapa[aux]++;
	}
	lint result = 0;
	for (auto m : mapa) {
		if (m.second > 1) result += (lint)(m.second*(m.second-1))/2;
	}	
	cout << result << '\n';

}



Measured memory_bytes: 38528
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

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

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

signed main(void)
{
    ll n, l;
    cin >> n >> l;
    ll r = 0;
    int f = 0;
    
    vll a(n);
    
    for (ll i = 0; i < n; i++) {
        a[i] = l+(i+1)-1;
        if (a[i] == 0) f = 1;
    }
    
    if (f == 1) {
        for (ll j = 0; j < n; j++) {
            r +=a[j];
        }
        mes(r);
        re0;
    }
    
    
    if (abs(a[0]) > abs(a[n-1])) {
        for (ll i = 0; i < n-1; i++) {
            r +=a[i];
        }
    } else if (abs(a[0]) < abs(a[n-1])) {
        for (ll i = 1; i < n; i++) {
            r +=a[i];
        }
    }
        
    mes(r);
    
    
}

Measured memory_bytes: 3624
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define elif else if
#define lli long long int
#define ld long double
#define vec vector
#define forn(a) for(lli a=0; a<n; a++)
#define all(x) x.begin(), x.end()
#define presicion(x) cout<<fixed<<setprecision(x)
#define deb(x) cerr<<#x<<" = "<<x<<endl

using namespace std;

int main() {
    IOS;

    int n; cin>>n;
    vec<int> h(n); forn(i) cin>>h[i];

    int cont = 0;
    int cant_ceros = 0;
    for(auto &it: h) cant_ceros += it==0;
    vec<bool> ceros(n, false);
    while(true){
        if(cant_ceros==n){
            cout<<cont<<endl;
            return 0;
        }
        bool in_ceros = true;
        for(int i=0; i<n; i++){
            if( h[i]>0 & in_ceros ){
                in_ceros = false;
                cont++;
                h[i]--; if(h[i]==0) cant_ceros++;
            }elif( h[i]>0 & not in_ceros ){
                h[i]--; if(h[i]==0) cant_ceros++;
            }elif( h[i]==0 & in_ceros ){
                //nada
            }elif( h[i]==0 & not in_ceros ){
                in_ceros = true;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;  cin >> n;   vector<int> vec(n); int sum=0;
    for(int i=0;n>i;i++){
        cin >> vec[i];  sum+=vec[i];
    }
    if(sum%10){
        cout << sum;    return 0;
    }
    sort(vec.begin(), vec.end());
    for(int i=0;n>i;i++){
        if(vec[i]%10){
            cout << sum-vec[i];    return 0;
        }
    }
    cout << 0;
}

Measured memory_bytes: 256
s = input()
n = len(s)

def j(x:str):
    for i in range(len(x)//2):
        if x[i] != x[-(i+1)]:
            return False
    return True

if not j(s):
    print ("No")
    exit ()

if not j(s[0:((n-1)//2)]):
    print ("No")
    exit ()

if not j(s[((n+3)//2)-1::]):
    print ("No")
    exit ()

print ("Yes")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  int n,k;
  cin>>n>>k;
  vector<int> h(n);
  for(auto&& e: h) 
  {
    cin>>e;
  }
  vector<int> cost(n);
  cost[0]=0;
  for (int i = 1; i < n; ++i)
  {
    int tmp_cost=cost[i-1]+abs(h[i]-h[i-1]);
    for (int j = 2; j <= min(k,i); ++j)
    {
      tmp_cost=min(tmp_cost,
        cost[i-j]+abs(h[i]-h[i-j]));
    }
    cost[i]=tmp_cost;
  }
  cout<<cost.back()<<endl;
}

Measured memory_bytes: 4048
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <utility>
 
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

int main(void) {
    Int x, y;
    cin >> x >> y;
    cout << x + y / 2 << endl;
    return 0;
}



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

int main(){
  int n;
  long long ans = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    if (i % 3 == 0 || i % 5 == 0) {
      continue;
    }
    ans += i;
  }
  cout << ans << endl;
}

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

using namespace std;

#define INF (1<<29)
#define INFF 0x7fffffff
#define LINF (1ll<<60)
#define LINFF 0x7fffffffffffffff
#define PI 3.14159265359

#define _fi(n) for(int i = 0;i < n;i++)
#define _fj(n) for(int j = 0;j < n;j++)
#define _fk(n) for(int k = 0;k < n;k++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define prec(x) cout << fixed << setprecision(x)

#define hash sodnf9843bsd
#define ll long long
#define pqueue priority_queue
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define endl '\n'

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll a, ll b){return uniform_int_distribution<ll>(a, b)(rng);}

int n;
double p[3003] = {};
double dp[3003][3003] = {};
bool vis[3003][3003] = {};
double full = 1;

double solve(int i, int j){
    if (i == n){
        if (j > n/2) return 1;
        return 0;
    }

    if (vis[i][j] == false){
        vis[i][j] = true;
        dp[i][j] = (1.-p[i])*solve(i+1, j)+p[i]*solve(i+1, j+1);
    }
    return dp[i][j];
}

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

    cin>>n;
    _fi(n) {
        cin>>p[i];
        full *= p[i];
    }

    prec(10);
    cout << solve(0, 0) << endl;

    return 0;
}


Measured memory_bytes: 79616
// URL: https://atcoder.jp/contests/abc174/tasks/abc174_a

import std.algorithm, std.array, std.bitmanip, std.container, std.conv, std.format,
       std.functional, std.math, std.range, std.traits, std.typecons, std.stdio, std.string;

version(unittest) {} else
void main()
{
  int X; io.getV(X);
  io.putB(X >= 30, "Yes", "No");
}

auto io = IO!()();
import std.stdio;
struct IO(alias IN = stdin, alias OUT = stdout)
{
  import std.meta : allSatisfy;
  import core.stdc.stdlib : exit;

  void getV(T...)(ref T v)
  {
    foreach (ref w; v) get(w);
  }
  void getA(T)(size_t n, ref T v)
    if (hasAssignableElements!T)
  {
    v = new T(n);
    foreach (ref w; v) get(w);
  }
  void getC(T...)(size_t n, ref T v)
    if (allSatisfy!(hasAssignableElements, T))
  {
    foreach (ref w; v) w = new typeof(w)(n);
    foreach (i; 0..n) foreach (ref w; v) get(w[i]);
  }
  void getM(T)(size_t r, size_t c, ref T v)
    if (hasAssignableElements!T && hasAssignableElements!(ElementType!T))
  {
    v = new T(r);
    foreach (ref w; v) getA(c, w);
  }
  template getS(E...)
  {
    void getS(T)(size_t n, ref T v)
    {
      v = new T(n);
      foreach (ref w; v) foreach (e; E) mixin("get(w."~e~");");
    }
  }

  const struct PutConf
  {
    bool newline = true, flush, exit;
    string floatFormat = "%.10f", delimiter = " ";
  }

  void put(alias conf = "{}", T...)(T v)
  {
    mixin("const PutConf c = "~conf~"; putMain!c(v);");
  }
  void putB(alias conf = "{}", S, T)(bool c, S t, T f)
  {
    if (c) put!conf(t);
    else put!conf(f);
  }
  void putRaw(T...)(T v)
  {
    OUT.write(v);
    OUT.writeln;
  }

  private
  {
    dchar[] buf;
    auto sp = (new dchar[](0)).splitter;

    void nextLine()
    {
      IN.readln(buf);
      sp = buf.splitter;
    }
    void get(T)(ref T v)
    {
      if (sp.empty) nextLine();
      v = sp.front.to!T;
      sp.popFront();
    }

    void putMain(PutConf c, T...)(T v)
    {
      foreach (i, w; v) {
        putOne!c(w);
        if (i+1 < v.length) OUT.write(c.delimiter);
      }
      static if (c.newline) OUT.writeln;
      static if (c.flush) OUT.flush();
      static if (c.exit) exit(0);
    }
    void putOne(PutConf c, T)(T v)
    {
      static if (isInputRange!T && !isSomeString!T) putRange!c(v);
      else static if (isFloatingPoint!T) OUT.write(format(c.floatFormat, v));
      else static if (hasMember!(T, "fprint")) v.fprint(OUT);
      else OUT.write(v);
    }
    void putRange(PutConf c, T)(T v)
    {
      auto w = v;
      while (!w.empty) {
        putOne!c(w.front); w.popFront();
        if (!w.empty) OUT.write(c.delimiter);
      }
    }
  }
}


Measured memory_bytes: 2732
n = int(input())
hs = list(map(int, input().split()))

ans = 0
tmp = 0
for i in range(n-1):
  # 右隣が小さかったらインクリメント
  if hs[i+1] <= hs[i]:
    tmp += 1
  # そうでなかったら初期化
  else:
    tmp = 0
  ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 14252
import java.util.Scanner;
import java.io.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int A[] = new int[n];
        int B[] = new int[n];
        int k = -1;
        for(int i = 0 ; i < n ; i++){
            A[i] = sc.nextInt();
            k = Math.max(A[i],k);
        }
        int C[] = new int[k+1];
        for(int i = 0 ; i <= k ; i++)
            C[i] = 0;
        for(int i = 0 ; i < n ; i++)
            C[A[i]]++;
        for(int i = 1 ; i <= k ; i++)
            C[i] += C[i-1];
        for(int i = 0 ; i < n ; i++)
            B[(C[A[i]]--)-1] = A[i];
        StringBuilder sb = new StringBuilder();
        for(int i = 0 ; i < n-1 ; i++)
            sb.append(B[i] + " ");
        System.out.println(sb.append(B[n-1]));
    }
}


Measured memory_bytes: 578736
#include<bits/stdc++.h>
using namespace std ;
#define endl "\n"
#define int long long int 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int32_t main()
{
    /*#ifndef ONLINE_JUDGE 
    freopen("input.txt","r",stdin) ;
    freopen("output.txt","w",stdout) ;
    #endif */
    char c ;
    cin >> c ;
    if(c == 'A')cout<<"T"<<endl;
    else if(c=='T')cout<<"A"<<endl;
    else if(c=='G')cout<<"C"<<endl;
    else cout<<"G"<<endl; 


}

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

#define     F       first
#define     S       second
typedef pair<int, int>  pi;
typedef long long       ll;

const int MAX=2e3+9;
int n, x, y, adj[MAX][MAX], freq[MAX];

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

    cin >> n >> x >> y;
    for (int i=2; i<=n; ++i) {
        for (int j=1; j<i; ++j) {
            adj[i][j]=adj[j][i]=i-j;
        }
    }

    adj[x][y]=adj[y][x]=1;

    for (int i=1; i<=n; ++i) {
        for (int j=1; j<=n; ++j) {
            adj[i][j]=min(adj[i][j], adj[i][x]+adj[x][j]);
        }
    }

    for (int i=1; i<=n; ++i) {
        for (int j=1; j<=n; ++j) {
            adj[i][j]=min(adj[i][j], adj[i][y]+adj[y][j]);
        }
    }

    for (int i=1; i<=n; ++i) {
        for (int j=i+1; j<=n; ++j) {
            ++freq[adj[i][j]];
        }
    }

    for (int i=1; i<n; ++i) {
        cout << freq[i] << "\n";
    }

    return 0;
}


Measured memory_bytes: 16000
stdin = open(0).read().rstrip().split('\n')
N = int(stdin[0])
s = stdin[1:]
d = {}
for i in range(N):
    a = list(s[i][:])
    b = ''.join(sorted(a))
    if b in d:
        d[b]+=1
    else:
        d[b]=1
ans = 0
for j in d.values():
    ans+=j*(j-1)//2
print(ans)

Measured memory_bytes: 27272
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    vector<int> a(7);
    rep(i, 7) cin >> a[i];

    int i = a[0];
    int j = a[3];
    int l = a[4];
    int m = min(a[0], min(a[3], a[4]));
    a[0] -= m;
    a[3] -= m;
    a[4] -= m;
    int ans = m * 3;
    ans += a[0] / 2 * 2 + a[3] / 2 * 2 + a[4] / 2 * 2;
    if(i > 0 && a[3] % 2 == 1 && a[4] % 2 == 1){
        ans++;
    }
    if(j > 0 && a[0] % 2 == 1 && a[4] % 2 == 1){
        ans++;
    }
    if(l > 0 && a[3] % 2 == 1 && a[0] % 2 == 1){
        ans++;
    }
    cout << ans + a[1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long H, W;
  cin >> H >> W;
  vector<string> foo(H);
  rep (i, H) cin >> foo[i];
  rep (h, H) rep (w, W) {
    if (foo[h][w] == '.') continue;
    bool allwhite = true;
    if (h > 0 and foo[h-1][w] == '#') allwhite = false;
    if (h < H-1 and foo[h+1][w] == '#') allwhite = false;
    if (w > 0 and foo[h][w-1] == '#') allwhite = false;
    if (w < W-1 and foo[h][w+1] == '#') allwhite = false;
    if (allwhite) {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
from sys import stdin


def main() -> int:
    n = next_int()
    a = [next_int() for _ in range(n)]

    j = 1

    for i in range(n):
        j = a[j - 1]
        if j == 2:
            print(i + 1)
            return 0

    print(-1)
    return 0


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 7088
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<utility>
#include<bitset>
#include<complex>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>

using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=a; i<=b; ++i)
#define FOR(i,a,b) for(int i=a; i<b; ++i)
#define MP make_pair
#define PB push_back
#define fi first
#define se second
typedef long long LL;
typedef pair<int,int> pii;

const int maxn = 1e5, maxm = 2e5;
const int md = 1e9 + 7;

struct Edge {
    int u, v, dd;
    Edge() {}
    Edge(int _u, int _v, int _dd) { u = _u, v = _v, dd = _dd; }
} edge[maxm + 5];

int n, m, S, T;
vector<pii> G[maxn + 5];
LL dist1[maxn + 5], dist2[maxn + 5], cnt1[maxn + 5], cnt2[maxn + 5];

int deg[maxn + 5];
void Run(int ss, LL* dist, LL *cnt) {
    for(int i = 1; i <= n; ++i) dist[i] = 1LL << 60, cnt[i] = 0, deg[i] = 0;
    priority_queue<pair<LL,int>> que;
    dist[ss] = 0; que.push(MP(0LL,ss));
    while(!que.empty()) {
        pair<LL,int> x = que.top(); que.pop();
        if(-x.fi != dist[x.se]) continue;
        for(auto it : G[x.se])
            if(-x.fi + it.se < dist[it.fi]) {
                dist[it.fi] = -x.fi + it.se;
                que.push(MP(-dist[it.fi],it.fi));
            }
    }
    for(int i = 1; i <= n; ++i)
        for(auto it : G[i]) {
            if(dist[i] + it.se == dist[it.fi])
                ++deg[it.fi];
        }
    queue<int> qu2;
    cnt[ss] = 1; qu2.push(ss);
    while(!qu2.empty()) {
        int x = qu2.front(); qu2.pop();
        for(auto it : G[x])
            if(dist[x] + it.se == dist[it.fi]) {
                cnt[it.fi] = (cnt[it.fi] + cnt[x]) % md, --deg[it.fi];
                if(!deg[it.fi])
                    qu2.push(it.fi);
            }
    }
}

int main() {
    //freopen("in.txt", "r", stdin);
    scanf("%d%d%d%d", &n, &m, &S, &T);
    for(int i = 1, u, v, d; i <= m; ++i) {
        scanf("%d%d%d", &u, &v, &d);
        edge[i] = Edge(u,v,d);
        G[u].PB( MP(v,d) );
        G[v].PB( MP(u,d) );
    }
    Run(S, dist1, cnt1);
    Run(T, dist2, cnt2);
    LL ans = (cnt1[T] - 1 + md) % md * cnt1[T] % md;
    for(int i = 1; i <= n; ++i)
        if(dist1[i] == dist2[i] && (dist1[i] << 1) == dist1[T]) {
            LL tmp = cnt1[i] * cnt2[i] % md;
            ans = (ans - (tmp-1+md) % md * tmp % md + md) % md;
        }
    for(int i = 1; i <= m; ++i) {
        int u = edge[i].u, v = edge[i].v, d = edge[i].dd;
        if(abs(dist1[u]-dist2[v]) < d && dist1[u] + d + dist2[v] == dist1[T]) {
            LL tmp = cnt1[u] * cnt2[v] % md;
            ans = (ans - (tmp-1+md) % md * tmp % md + md) % md;
        }
        u = edge[i].v, v = edge[i].u;
        if(abs(dist1[u]-dist2[v]) < d && dist1[u] + d + dist2[v] == dist1[T]) {
            LL tmp = cnt1[u] * cnt2[v] % md;
            ans = (ans - (tmp-1+md) % md * tmp % md + md) % md;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 17876
N=int(input())
h=list(map(int,input().split()))

if N==1:
    print(h[0])
    exit()

mi=min(h)
p=0
h0=h[0]
c=h0-mi
ans=mi+h0
for i in range(1,N):
    if h0<h[i]:
        c+=h[i]-h0
    elif h0>h[i]:
        c=h0-min(h[p:i])
        ans+=c
        p = i
        c=h[i]-mi
    h0=h[i]

ans+=c-min(h[p:])
print(ans)


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

namespace C_Christmas_Eve
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int N = int.Parse(str[0]);
            int K = int.Parse(str[1]);
            int[] H = new int[N];
            for(int i = 0; i < N; i++)
            {
                H[i] = int.Parse(Console.ReadLine());
            }

            int gap=int.MaxValue;

            Array.Sort(H);

            for(int i = 0; i < N - K +1; i++)
            {
                if(gap> H[i + K - 1] - H[i])
                gap = H[i + K - 1] - H[i];
            }

            Console.Write(gap);
        }
    }
}

Measured memory_bytes: 17344
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int64_t x; cin >> x;
	int64_t v = 100;
	int ans = 0;
	while (v < x) {
		v = v + (v / 100);
		ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3656
import numpy as np
D = int(input())
c_list = np.array(list(map(int,input().split())))
s_list = [list(map(int,input().split())) for _ in range(D)]
last_d_list = np.array([0]*26)
for s_row in s_list:
    choice_d = None
    max_reward = -1
    for i,last_d in enumerate(last_d_list):
        reward = s_row[i] + (last_d+1)*c_list[i]# - sum(c_list)
        if reward > max_reward:
            max_reward = reward
            choice_d = i
    last_d_list+=1
    last_d_list[choice_d] = 0
    
    print(choice_d+1)
    

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

string a="CODEFESTIVAL2016",s;
int ans;

int main()
{
	int l=a.length();
	cin>>s;
	for(int i=0;i<l;i++) if(a[i]!=s[i]) ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
const int INF = 1e9;


ll N, A[5];

int main() {
    cin >> N >> A[0] >> A[1] >> A[2] >> A[3] >> A[4];
    ll res = 0;
    for (int i = 1; i < 5; i++) {
        chmin(A[0],A[i]);
    }
    cout << (N + A[0] - 1) / A[0] + 4 << endl;;
}


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

using namespace std;

#define fin(ans) cout << ans << endl

int main(void) {
  int num, i;
  cin >> num;
  for (i = 1; i < 10; i++) {
    if (num % i == 0 && num / i <= 9) {
      fin("Yes");
      break;
    }
  }

  if (i == 10) {
    fin("No");
  }
  return 0;
}



Measured memory_bytes: 256
#include "iostream"
using namespace std;

int main(int argc, char const *argv[])
{
	int n;
	int x,i=1;
	cin >> n;

	while(i<=n)
	{
		x = i;
		if(x%3 == 0)
		{
			cout << " " << i;
		}else 
		{
			while(x != 0)
			{
				if (x%10 == 3)
				{
					cout << " " <<i;
					break;
				}
				x /= 10;
			}
		}


		i++;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3080
length = int(input())
eles = [l for l in input().split()]
is_stable = 'Stable'

import copy
_copy = copy.deepcopy(eles)

for i in range(length):
    for j in range(length-1, 0, -1):
        if _copy[j][1] < _copy[j-1][1]:
            _copy[j], _copy[j-1] = _copy[j-1], _copy[j]

print(*_copy)
print(is_stable)

__copy = copy.deepcopy(eles)
for i in range(length-1):
    _min = i
    for l in range(i, length):
        if __copy[l][1] < __copy[_min][1]:
            _min = l
    if __copy[i][1] > __copy[_min][1]:
        __copy[i], __copy[_min] = __copy[_min], __copy[i]

print(*__copy)

for i in range(length -1):
    if _copy[i] != __copy[i]:
        is_stable = 'Not stable'

print(is_stable)

Measured memory_bytes: 8172
//おまじないc++
#include <iostream>
#include<cmath>
#include<vector>
#include <algorithm>
using namespace std;

int main() {
	string s;
	cin >> s;

	if (s == "SUN")
		cout << 7;
	if (s == "MON")
		cout << 6;
	if (s == "TUE")
		cout << 5;
	if (s == "WED")
		cout << 4;
	if (s == "THU")
		cout << 3;
	if (s == "FRI")
		cout << 2;
	if (s == "SAT")
		cout << 1;
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os;
}
template<class T> istream& operator>>(istream& is, vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) is >> *i; return is;
}

#define MOD 1000000007

long long dp[301][301][301];
vector<pair<int, int>> conds[301];

void incr(int i, int j, int k, long long cnt)
{
	for (auto& x : conds[i])
	{
		int diff = 1;
		if (j >= x.first)
			diff++;
		if (k >= x.first)
			diff++;
		if (diff != x.second)
			return;
	}

	dp[i][j][k] += cnt;
	while (dp[i][j][k] > MOD)
		dp[i][j][k] -= MOD;
}


int main() {

#if defined(_DEBUG) 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);



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

	for (int i = 0; i < m; i++)
	{
		int l, r, x;
		cin >> l >> r >> x;
		conds[r].push_back({ l,x });
	}
	incr(1, 0, 0, 1);

	for (int i = 1; i < n; i++)
	{
		for (int k = 0; k <= n; k++)
		{
			for (int j = 0; j <= n; j++)
			{
				if (dp[i][j][k] == 0)
					continue;

				incr(i + 1, j, k, dp[i][j][k]);
				incr(i + 1, i, k, dp[i][j][k]);
				incr(i + 1, j, i, dp[i][j][k]);
			}
		}
	}

	long long ans = 0;
	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j <= n; j++)
		{
			ans = (ans + dp[n][i][j]) % MOD;
		}
	}

	cout << (ans * 3LL) % MOD;

	return 0;
}


Measured memory_bytes: 211328
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
dp = [2] * (N+1)
dp[1] = 1

for i in range(2, N+1):
    dp[i] = dp[i-1] + dp[i-2]

print(dp[N])


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

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

#if __has_include("debug.hpp")
#include "debug.hpp"
#else
template<typename T>
void debug(T& obj) {}
#endif

//----------------------------------------------------------------------
void solve() {

	ll a,b;
	cin >> a >> b;
	ll mn=min(a,b),mx=max(a,b);
	rep(i,mx) cout << mn;

}
//----------------------------------------------------------------------

int main(int argc, char* argv[]) {
	solve();
	return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define For(a,b,c) for(int a=b;a<=c;++a)
using namespace std;
const int N=103;
string S[N];
int P[N],C[N];
bool cmp(int x,int y) {
	return S[x]<S[y]||(S[x]==S[y]&&C[x]>C[y]);
}
int main() {
	int n;
	cin>>n;
	For(i,1,n) cin>>S[i]>>C[i],P[i]=i;
	sort(P+1,P+1+n,cmp);
	For(i,1,n) printf("%d\n",P[i]);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
//typedef pair<int, int> P;

/** Problem2219 : THE BYDOLM@STER **/
int C[301], V[301], D[301], L[301];
int dp[301][301];
int M, N;

int solve(int cost, int n, int *t)
{
	if (n==N) {
		return 0;
	}
	
	if (dp[cost][n]>=0)
		return dp[cost][n];
	
	int res=0;
	for (int i=0; cost+i*C[n]<=M; i++) {
		res = max(res, i*t[n]+solve(cost+i*C[n], n+1, t));
	}
	return dp[cost][n] = res;
}

int main()
{
	while (cin>>N>>M) {
		rep(i, N) {
			string s;
			cin.ignore();
			getline(cin, s);
			cin>>C[i]>>V[i]>>D[i]>>L[i];
		}
		int ans = 0;
		memset(dp, -1, sizeof(dp));
		ans = max(ans, solve(0, 0, V));
	
		memset(dp, -1, sizeof(dp));
		ans = max(ans, solve(0, 0, D));
	
		memset(dp, -1, sizeof(dp));
		ans = max(ans, solve(0, 0, L));
	
		cout << ans << endl;
	}
}

Measured memory_bytes: 1600
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
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 (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL <<60;
typedef long long ll;
using namespace std;
 
ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
 
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}
 
ll choose2(ll n){
    return n*(n-1)/2;
}
 
int main() {
    int n,q;
    cin>>n>>q;
    string s;
    cin>>s;

    vector<int> a(q),b(q);
    rep(i,0,q-1) cin>>a[i]>>b[i];
    vector<int> t(n,0);
    rep(i,1,n-1){
        if(s[i-1] == 'A' && s[i] == 'C') t[i] = t[i-1] + 1;
        else t[i] = t[i-1]; 
    }

    rep(i,0,q-1){
        cout<<t[b[i] - 1] - t[a[i] - 1]<<endl;
    }
 
    return 0;
}

Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int x = sc.nextInt();
    System.out.println(x >= a && x <= a + b ? "YES" : "NO");
  }

}


Measured memory_bytes: 23252
n = int(input())
S = input()
k = 0
num = 0
r, g, b = 0, 0, 0
for s in S:
    if s == "R": r += 1
    elif s == "G": g += 1
    else: b += 1
whole = r * g * b
for i in range(n-2):
    for j in range(i+1,n-1):
        k = 2 * j - i
        if k >= n:
            continue
        if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
            num += 1
print(whole - num)

Measured memory_bytes: 73804