akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define prique priority_queue
int n,sum=0,x=0,ans=INF;
int a[400000];
signed main(){
    cin>>n;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    rep(i,n-1){
        x+=a[i];
        int y=sum-x;
        ans=min(ans,abs(x-y));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#素因数分解(1に対しては空のリストを返す)
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

#入力の高速化
import sys
input = sys.stdin.readline

from collections import defaultdict
d = defaultdict(int)

n= int(input())
a= list(map(int, input().split()))

v=prime_factorize(a[0])
v=set(v)
v=list(v)
for i in range(len(v)):
    d[v[i]]+=1

setwise=0
pairwise=0
for i in range(1,n):
    w=prime_factorize(a[i])
    flag=True
    w=set(w)
    w=list(w)
    for j in range(len(w)):
        if d[w[j]]!=0:
            pairwise=1
            if d[w[j]]==i:
                flag=False
        d[w[j]]+=1
    if flag:
        setwise=1


if pairwise==0:
    print('pairwise coprime')
elif setwise==1:
    print('setwise coprime')
else:
    print('not coprime')

Measured memory_bytes: 190792
# include <cstdio>
# include <algorithm>
using namespace std;

static const int maxn = 100 + 2;
int n, a[maxn], cnt;

void put_out() {
    for (int i = 0; i < n-1; i++) printf("%d ", a[i]);
    printf("%d\n%d\n", a[n-1], cnt);
}

void bubblesort() {
	int flag = 1;
	int j = 0;
	while (flag) {
		flag = 0;
		for (int i = n-1; i >= j+1; i--) {
			if (a[i] < a[i-1]) {
				swap(a[i], a[i-1]);
				flag = 1;
				cnt++;
			}
		}
		j++;
	}
}

int main() {
    // freopen("data.in", "r", stdin);
    // freopen("data.out", "w", stdout);
    while (scanf("%d", &n) == 1) {
        for (int i = 0; i < n; i++) scanf("%d", &a[i]);
        cnt = 0;
        bubblesort();
        put_out();
    }
    return 0;
}



Measured memory_bytes: 2744
#include <iostream>
#include <stack>
#include <cstdlib>
using namespace std;

int main(){
    stack<int> S;
    int a, b;
    string s;

    while(cin >> s){
        if(s[0] == '+'){
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a + b);
        }else if(s[0] == '-'){
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(b - a);
        }else if(s[0] == '*'){
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a * b);
        }else{
            S.push(atoi(s.c_str()));
        }
    }

    cout << S.top() << endl;

    return 0;
}


Measured memory_bytes: 3176
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

string getReverse(string str);
bool isLeap(int y);
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
double distanceAB(double xa, double ya, double xb, double yb);
void trace(int A[], int N);

/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/



int main()
{
	int m;
	string inp, front, back;
	
	cin >> m;
	rep(i, m)
	{
		cin >> inp;
		set<string> s;
		for (int i=1; i<=inp.length()-1; i++)
		{
			front = inp.substr(0, i);
			back = inp.substr(i);
			s.insert(front + back);
			s.insert(back + front);
			s.insert(getReverse(front) + back);
			s.insert(back + getReverse(front));
			s.insert(front + getReverse(back));
			s.insert(getReverse(back) + front);
			s.insert(getReverse(front) + getReverse(back));
			s.insert(getReverse(back) + getReverse(front));
		}
		cout << s.size() << endl;
	}
	
	return 0;
}


string getReverse(string str)
{
	string ret = "";
	for (int i=str.length()-1; i>=0; i--)
	{
		ret += str.substr(i, 1);
	}
	return ret;
}

bool isLeap(int y)
{
	return y % 400 == 0
						? true : y % 100 == 0
						? false : y % 4 == 0
						? true : false;
}

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

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

void trace(int A[], int N)
{
	REP(N)
	{
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}

double distanceAB(double xa, double ya, double xb, double yb)
{
	return sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
}

Measured memory_bytes: 1304
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

int main() {
    ll T1, T2;
    cin >> T1 >> T2;
    ll A1, A2;
    cin >> A1 >> A2;
    ll B1, B2;
    cin >> B1 >> B2;
    if ((B1 > A1 && B2 > A2) || (B1 < A1 && B2 < A2)) {
        cout << 0 << endl;
        return 0;
    }
    ll x = abs((B1 - A1) * T1);
    ll y = abs((B2 - A2) * T2);
    if (y < x) {
        cout << 0 << endl;
        return 0;
    }
    if (y == x) {
        cout << "infinity" << endl;
        return 0;
    }
    ll z = y - x;
    ll n = x / z + 1;
    bool tangent = (x % z == 0);
    cout << 2 * n - 1 - tangent << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include <cmath>
#include<bits/stdc++.h>
#include<math.h>
//for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;
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; }
int main(){
    int n; cin >> n;
    ll a[n]; cinf(n,a);
    ll b[n]={};
    for(int i=0;i<n;i++){
        if(i % 2 != 0) b[0] -= a[i];
        else b[0] += a[i];
    }
    cout << b[0] << ' ';
    for(int i=1;i<n;i++){
        b[i]=2*a[i-1]-b[i-1];
        cout << b[i] << ' ';
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

ll pow5(ll n) {
    ll res = 1;
    REP(i, 5) { res *= n; }
    return res;
}

int X;

vector< pair<int, int> > bf() {
    vector< pair<int, int> > ret;
    for(int a = -100; a <= 100; ++a) {
        for (int b = -100; b <= 100; ++b) {
            if(pow5(a) - pow5(b) == X) {
                ret.push_back(make_pair(a, b));
            }
        }
    }
    return ret;
}

pair<int, int> solve() {
    for(int a = 1; a <= 1000; ++a) {
        for (int b = -1000; b <= 1000; ++b) {
            if(pow5(a) - pow5(b) == X) {
                return make_pair(a, b);
            }
        }
    }
    return make_pair(1, 1);
}

signed main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
#if 1
    cin >> X;
    pair<int, int> ans = solve();
    //pair<int, int> ans = bf();
    printf("%lld %lld\n", ans.first, ans.second);
#else
    for(X = 1; X <= 2000; ++X) {
        auto res = bf();
        if(res.size() > 0) {
            printf("X: %lld\n", X);
            for(auto& v : res) {
                printf("  %lld %lld\n", v.first, v.second);
            }
        }
    }
#endif

    return 0;
}


Measured memory_bytes: 3580
#include <cstring>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstring>
#include <map>
#include <bitset>
#include <iostream>
#include <string>
using namespace std;
typedef long long int lli;
typedef pair<int,int> P;
const int INF=100000000;
const long long int INF_=1000000000000000000;

struct Edge{
	int from,to,cost;
	Edge():from(-1),to(-1),cost(INF){}
	Edge(int a=-1,int b=-1,int c=INF):from(a),to(b),cost(c){}
};

template<class T_> void AddList(T_ &dst,T_ &src){
	dst.insert(dst.end(),src.begin(),src.end());
}

int StringToNumber(string str){
	return atoi(str.c_str());
}

int M,N,K,D;

void BellmanFord(int s,vector<Edge> &ee,vector<vector<int> > &d){
	for(int i=0; i<d.size(); ++i) for(int j=0; j<d[i].size(); ++j) d[i][j]=INF;
	d[0][s]=0;
	vector<Edge> es[1<<6];
	for(int i=0; i<(1<<M); ++i) es[i]=ee;
	for(int count=0; count<D; ++count){
		for(int i=0; i<(1<<M); ++i){
			for(int j=0; j<es[i].size(); ++j){
				Edge e=es[i][j];
				//cout << i << " " << j << " " << e.from << " " << e.to << endl;
				if(1<=e.to&&e.to<=6&&((1<<(e.to-1))&i)!=0){
					continue;
				}
				if(1<=e.to&&e.to<=6){
					if(d[i][e.from]!=INF&&d[(1<<(e.to-1))|i][e.to]>d[i][e.from]+e.cost){
						d[(1<<(e.to-1))|i][e.to]=d[i][e.from]+e.cost;
					}
				} else if(d[i][e.from]!=INF&&d[i][e.to]>d[i][e.from]+e.cost){
					d[i][e.to]=d[i][e.from]+e.cost;
				}
			}
		}
	}
}

int f(string str){
	string sub(str.substr(1));
	if(str[0]=='H') return 0;
	else if(str[0]=='D') return 107;
	else if(str[0]=='C') return StringToNumber(sub);
	else if(str[0]=='L') return StringToNumber(sub)+6;
}

int main(){
	while(cin >> M >> N >> K >> D){
		if(M+N+K+D==0) break;
		vector<int> c(M);
		for(int i=0; i<M; ++i) cin >> c[i];
		vector<Edge> e;
		for(int i=0; i<D; ++i){
			string a,b;
			int cc;
			cin >> a >> b >> cc;
			string sub=b.substr(1);
			int idx=StringToNumber(sub)-1;
			e.push_back(Edge(f(a),f(b),cc*K-(b[0]=='C'?c[idx]:0)));
			sub=a.substr(1);
			idx=StringToNumber(sub)-1;
			e.push_back(Edge(f(b),f(a),cc*K-(a[0]=='C'?c[idx]:0)));
		}
		vector<vector<int> > d(1<<6,vector<int>(108));
		BellmanFord(0,e,d);
		int ans=INF;
		for(int i=0; i<(1<<6); ++i) ans=min(ans,d[i][107]);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>

using namespace std;

int main(){

  int N;
  long long int min = 1000000000, max = 0;
  cin >> N;

  for(int i = 0; i < N; i++){
    int num;
    cin >> num;
    if(max < num){
      max = num;
    }
    if(num < min){
      min = num;
    }
  }

  cout << max - min << "\n";
  
  return 0;
}


Measured memory_bytes: 256
import Data.List
import Data.Char
import Data.Maybe
import qualified Data.ByteString.Char8 as BS8

main :: IO ()
main = do
    [_, k] <- unfoldr (BS8.readInt . BS8.dropWhile isSpace) <$> BS8.getLine
    h <- unfoldr (BS8.readInt . BS8.dropWhile isSpace) <$> BS8.getLine

    print $ length $ filter (k <=) h

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

using namespace std;
int main(void){
    // Your code here!
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if (s[i] == ',') {
            s[i] = ' ';
        }
    }
    cout<<s<<endl;
}


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

int main() {
    int N, M;
    cin>>N>>M;
    int par[N], ans[N];
    for(int i=0;i<N;++i){
        par[i] = 0;
        ans[i] = 0;
    }
    map<int, vector<int> > graph;
    int x, y;
    for(int i=0;i<M;++i){
        cin>>x>>y;
        x--;
        y--;
        par[y]++;
        graph[x].push_back(y);
    }
    queue<int> que;
    int state;
    for(int i=0;i<N;++i){
        if(par[i]==0)que.push(i);
    }
    while(!que.empty()){
        state = que.front();que.pop();
        for(int i=0;i<graph[state].size();++i){
            par[graph[state][i]]--;
            if(par[graph[state][i]]==0){
                ans[graph[state][i]] = ans[state]+1;
                que.push(graph[state][i]);
            }
        }
    }
    int answer = 0;
    for(int i=0;i<N;++i){
        if(answer < ans[i])answer = ans[i];
    }
    cout<<answer<<endl;
}


Measured memory_bytes: 11904
#Macで実行する時
import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../atcoder/input.txt'))
	sys.stdin = open(name)

s,n = map(int,input().split())
l = list(map(int,input().split()))

if s<=sum(l):
    print("Yes")
else:
    print("No")



Measured memory_bytes: 83772
from operator import itemgetter
N=int(input())
A=list(map(int, input().split()))
B=[[i, A[i]] for i in range(N)] 
B=sorted(B, key=itemgetter(1), reverse=True)

dp=[[0]*(N+1) for _ in range(N+1)]

for x in range(N):
    dp[x+1][0]=dp[x][0]+B[x][1]*abs(B[x][0]-x)
    
for y in range(N):
    dp[0][y+1]=dp[0][y]+B[y][1]*abs(N-1-y-B[y][0])
    
for z in range(2, N+1):
    for x in range(1, z):
        y=z-x
        dp[x][y]=max(dp[x][y-1]+B[z-1][1]*abs(N-y-B[z-1][0]), dp[x-1][y]+B[z-1][1]*abs(x-1-B[z-1][0]))
        
print(max([dp[x][N-x] for x in range(N+1)]))

Measured memory_bytes: 100748
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
const int maxn=55;
int h,k;
int g[maxn][maxn];
inline bool check(int x,int y)
{
	if(x>h||x<=0) return 0;
	if(y>k||y<=0) return 0;
	return 1;
}
int cx[]={0,1,1,1,0,0,-1,-1,-1};
int cy[]={0,-1,0,1,-1,1,-1,0,1};
int main()
{
	cin>>h>>k;
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=k;j++)
		{
			char x=getchar();
			while(x!='.'&&x!='#') x=getchar();
			if(x=='#') g[i][j]=-1;
		}
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=k;j++)
		{
			if(g[i][j]==-1)continue;
			for(int l=1;l<=8;l++)
				if(check(i+cx[l],j+cy[l]))
				{
					if(g[i+cx[l]][j+cy[l]]==-1) g[i][j]++;
				}
		}
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=k;j++)
		{
			if(g[i][j]==-1){printf("#");continue;}
			printf("%d",g[i][j]);
		}
		printf("\n");
	}
	return 0;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi v(n);
	REP(i, n)cin >> v[i];
	vl l(n + 1, 0);
	ll sum = 0;
	REP(i, n) {
		sum += v[i];
		if (v[i] == 0) {
			l[i + 1] = min(sum, l[i] + 2);
		}
		else {
			l[i + 1] = min(sum, l[i] + v[i] % 2);
		}
	}
	vl r(n + 1, 0);
	sum = 0;
	RREP(i, n) {
		sum += v[i];
		if (v[i] == 0) {
			r[i] = min(sum, r[i + 1] + 2);
		}
		else {
			r[i] = min(sum, r[i + 1] + v[i] % 2);
		}
	}
	vl cnt(n + 1, 0);
	REP(i, n) {
		cnt[i + 1] = cnt[i] + (1 - v[i] % 2);
	}
	ll ans = INF;
	int p = 0;
	REP(i, n) {
		if (l[i + 1] < l[p] + cnt[i + 1] - cnt[p]) {
			p = i + 1;
		}
		chmin(ans, cnt[i + 1] - cnt[p] + l[p] + r[i + 1]);
	}
	cout << ans << endl;
}

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

int main() {
    ll n;
    cin >> n;
    string ans;
    while(n) {
        n--;
        ans += 'a' + n%26;
        n /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
import collections 
n = int(input())
d = collections.Counter(input())
for _ in range(n-1):
    s = input()
    cnt = collections.Counter(s)
    for k,v in cnt.items():
        de = d.get(k,False)
        if de:
            d[k] = min(de,cnt[k])
    for k,v in d.items():
        if not cnt.get(k,False):
            d[k] = 0

ans = ''
for k,v in sorted(d.items()):
    ans += k*v
print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
int n,p;
int a[100];
int odd=0,even=0;
int mypow(int a,int b){
    if(b==1)return a;
    int t=mypow(a,b/2);
    if(b%2==0)return t*t;
    return t*t*a;
}
signed main(){
    cin>>n>>p;
    rep(i,n){
        cin>>a[i];
        if(a[i]%2)odd++;
        else even++;
    }
    if(p==1&&odd==0){
        cout<<0<<endl;
        return 0;
    }
    int e=1,o;
    for(int i=0;i<even;i++){
        e*=2;
    }
    if(p%2)o=mypow(2,odd-1);
    else if(odd==0)o=1;
    else o=mypow(2,odd-1);
    int ans=e*o;
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

ifstream fin("fisier.in");
ofstream fout("fisier.out");

int v[100005];
int dp[100005];

int main(){
    int n,i;

    cin>>n;

    for(i=1;i<=n;i++)
        cin>>v[i];

    dp[2]=abs(v[2]-v[1]);

    for(i=3;i<=n;i++)
        dp[i]=min(abs(v[i]-v[i-2])+dp[i-2],abs(v[i]-v[i-1])+dp[i-1]);

    cout<<dp[n];

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define inf 100000000000000000
#define mod 1000000007
#define endl '\n'
#define omarshagar                    \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
using namespace std;
bool check(int mn,int mx,bool arr[])
{
    for(int i=mn;i<=mx;i++)
    {
        if(arr[i]==0)return 0;
    }
    return 1;
}
int main() {
    omarshagar
   ll n,m;
    cin>>n>>m;
    ll arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        arr[i]%=m;
       // cout<<arr[i]<<" sss"<<endl;
    }
    ll sum[n];
    ll ss=0;
    ll res=0;
    for(int i=0;i<n;i++)
    {
        sum[i]=(arr[i]+ss)%m;
        ss=sum[i];
        ss%=m;
       // cout<<"vv "<<ss<<endl;
        if(sum[i]==0){res++;/*cout<<i<<endl;*/};
    }

    sort(sum,sum+n);


    for(int i=0;i<n;)
    {
        ll tmp=sum[i];
        ll cnt=0;
        for(int ii=i;ii<n;ii++)
        {
            if(sum[ii]!=tmp)break;
            cnt++;
        }
        i+=cnt;
          //  cout<<cnt<<endl;
        if(cnt>1)
        {
            res+=(cnt*(cnt-1))/2.0;
        }
    }
    cout<<res<<endl;
    return 0;
}
/*
 1
 4
1000
0010
0100
0001


 */


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define re register
using namespace std;
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int n;
long long ans;
char s[200002];
map<int,int>v;
inline int ksm(re int x,re int y){
	re int an=1;
	while(y){
		if(y&1)an=an*x%2019;
		x=x*x%2019;
		y>>=1;
	}
	return an;
}
inline void work(re int l,re int r){
	if(l==r)return;
	re int mid=l+r>>1;
	v.clear();
	re int pw=1,m=0;
	for(re int i=mid;i>=l;--i){
		m=m+(s[i]-'0')*ksm(10,mid-i);
		m%=2019;
		++v[m];
	}
	m=0;
	for(re int i=mid+1;i<=r;++i){
		m=m*10+s[i]-'0';
		m%=2019;
		pw*=10;
		pw%=2019;
		for(re int j=0;j<=2018;++j)if((j*pw+m)%2019==0){
			ans+=v[j];
			break;
		}
	}
	work(l,mid),work(mid+1,r);
}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	work(1,n);
	printf("%lld\n",ans);
}


Measured memory_bytes: 4072
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
using Graph = vector<vector<int>>;

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

    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

        // BFS のためのデータ構造
        vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
        vector<int> mark(N, -1); // 全頂点を「未訪問」に初期化
        queue<int> que;

        // 初期条件 (頂点 0 を初期ノードとする)
        dist[0] = 0;
        que.push(0); // 0 を橙色頂点にする

        // BFS 開始 (キューが空になるまで探索を行う)
        while (!que.empty()) {
            int v = que.front(); // キューから先頭頂点を取り出す
            que.pop();

            // v から辿れる頂点をすべて調べる
            for (int nv : G[v]) {
                if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

                // 新たな白色頂点 nv について距離情報を更新してキューに追加する
                dist[nv] = dist[v] + 1;
                mark[nv] = v + 1;
                que.push(nv);
            }
        }

    for(int i = 1; i < N; i++){
        if(mark[i] == -1){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    for(int i = 1; i < N; i++){
        cout << mark[i] << endl;
    }

}


Measured memory_bytes: 10664
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
int main() {
	int N,K;
	cin>>N>>K;
	if(K==1)
		cout<<0<<endl;
	else
		cout<<N-K<<endl;
    return 0;
}

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

int main(){

    string s; cin >> s;
    string t;
    for(int i = 0; i < 4; i++){
        t += s[i];
    }

    t += ' ';
    for(int i = 4; i < 12; i++){
        t += s[i];
    }

    cout << t << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
//const int MAX=;

int main(){
	int N;
	cin>>N;
	int h[100];
	rep(i,N)cin>>h[i];
	
	int ans=0;
	rep(j,100){
		bool all0=true;
		bool cons=false;
		rep(i,N){
			if(h[i]>0){
				all0=false;
				h[i]--;
				if(cons==false){
					ans++;
					cons=true;
				}
			}
			else{
				cons=false;
			}
		}
		if(all0)break;
	}
	cout<<ans;
}

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

int main(){
  int S;
  int s1, s2, s3;
  
  cin >> S;
  s1 = S / 100;
  s2 = (S-s1*100)/10;
  s3 = S - s1*100 - s2*10;
  
  cout << s1+s2+s3 << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int a, b, c;
    cin >> a >> b >> c;

    for (int i = 0; i < 200; ++i) {
        if((i*a)%b==c){
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a, b, c;
  int max;

  while(1){
    scanf("%d", &a);
    if(a<=0 || a>10000){
      printf("Input error!: please input integer(1<=a<=10000)\n");
      continue;
    }else{
      break;
    }
  }

  while(1){
    scanf("%d", &b);
    if(b<=0 || b>10000){
      printf("Input error!: please input integer(1<=b<=10000)\n");
      continue;
    }else{
      break;
    }
  }

  while(1){
    scanf("%d", &c);
    if(c<=0 || c>10000){
      printf("Input error!: please input integer(1<=c<=10000)\n");
      continue;
    }else{
      break;
    }
  }

  max = 0;
  if(max<a){
    max = a;
  }
  if(max<b){
    max = b;
  }
  if(max<c){
    max = c;
  }
  printf("%d\n", a+b+c-max);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    int n,k;
    cin >> n >> k;
    if((n+1)/2>=k){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

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

int main() {
    string S;
    string T;
    cin >> S;
    cin >> T;
    int cnt = 0;
    for(int i=0;i<S.size();i++) {
        if(S.at(i) != T.at(i)) {
            cnt++;
        }
    }
    cout << cnt << endl;

}

Measured memory_bytes: 3812
'use strict'

function main(inp) {
  inp = inp.trim().split(' ')
  const A = Number(inp[0])
  const B = Number(inp[1])

  const t8 = Math.ceil(A / 0.08)
  const t10 = Math.ceil(B / 0.1)

  for (let i = Math.min(t8, t10); i <= Math.max(t8, t10); i++) {
    if (Math.floor(i * 0.08) === A && Math.floor(i * 0.1) === B) {
      return console.log(i)
    }
  }
  console.log(-1)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 11468
#include <bits/stdc++.h>
using namespace std;
const double eps=1e-9;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
int T,D,L;
int X[100005];
int main(void)
{
  while(cin >> T >> D >> L && T)
    {
      int ans=0;
      for(int i=0;i<T;i++)
	{
	  cin >> X[i];
	}
      int sink=0;
      for(int i=0;i<T;i++)
	{
	  if(X[i]>=L) sink=D;
	  if(sink>0) 
	    {
	      ans++;
	    }
	   sink=max(sink-1,0);
	}
      cout << max(0,ans-1) << endl;
    }
  return 0;
}



Measured memory_bytes: 3460
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int win = 15 - S.Length;
		for(int i=0;i<S.Length;i++) if(S[i] == 'o') win++;
		Console.WriteLine(win >= 8 ? "YES" : "NO");
	}
	String S;
	public Sol(){
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

int main(){
  long long a,b,c,ans;
  bool judge;
  cin >> a;
  cin >> b;
  cin >> c;

  ans = (c - a - b)*(c - a - b) - 4*a*b;

  if((ans > 0)&&((c - a - b) > 0)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  return 0;
}
    

  
  

  


Measured memory_bytes: 256
/*************************************************\
           In the name of almighty ALLAH
                 MD.Faysal Hasan
                Comilla Univesity
\*************************************************/

#include<bits/stdc++.h>
using namespace std;

#define     ikarus_101  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef     long long             ll;
typedef     long double           ld;
typedef     unsigned long long    ull;
typedef     vector<ll>            vll;
typedef     pair<ll,ll>           pll;
typedef     vector<pll>           vpl;
typedef     map<ll,ll>            mll;
typedef     multiset<ll>          msl;
typedef     multimap<ll,ll>       Mll;
using pqboro=priority_queue<ll,vll,less<ll>>;
using pqchoto=priority_queue<ll,vll,greater<ll>>;

#define    all(str)       str.begin(),str.end()
#define    sajo(str)      sort(str.begin(),str.end())
#define    rev(str)       reverse(str.begin(),str.end())
#define    usajo(str)     sort(str.rbegin(),str.rend())
#define    vin(a)         for(auto &it : a) cin>>it
#define    vout(a)        for(auto it:a) cout<<it<<' ';cout<<nn
#define    vmax(a)        *max_element(all(a))
#define    vmin(a)        *min_element(all(a))
#define    pb             push_back
#define    eb             emplace_back
#define    mkp(x,y)       make_pair(x,y)
#define    F              first
#define    S              second
#define    yes            cout<<"Yes"<<nn
#define    no             cout<<"No"<<nn
#define    nn             "\n" ///endl
#define    rep(i,n)       for (i=0;i<n;++i )
#define    rep1(i,n)      for (i=1;i<=n;++i )

#define    min3(a,b,c)    min(a,min(b,c))
#define    max3(a,b,c)    max(a,max(b,c))
#define    sqr(x)         ((x)*(x))
#define    pi             2*acos(0.0)
#define    gcd(a,b)       __gcd(a,b)
#define    lcm(a,b)       (a/gcd(a,b))*b
#define    mem(a,b)       memset(a,b,sizeof (a))
#define    dec(x)         cout<<fixed<<setprecision(x)
#define    none(n)         __builtin_popcountll(n)

template < typename T > string toString ( T Number ) { stringstream ss ; ss << Number ; return ss.str() ; }
template < typename T > ll toll ( T str ) { stringstream ss ; ss << str ; ll num ; ss >> num ; return num ; }

const   int  N   =   2e5+7;
const   int  M   =   1e9+7;
const   ll  inf  =   0x7f7f7f7f7f7f7f7f;
const   int dx[] =   {+1,+2,+2,+1,-1,-2,-2,-1};
const   int dy[] =   {-2,-1,+1,+2,+2,+1,-1,-2};

int main() {ikarus_101

    ll n,m,i,j,k,x;

    int d , t , s;
    cin>>d>>t>>s;
    if(t*s >= d)
        yes;
    else
        no;














    return 0;
}


Measured memory_bytes: 3652
K = int(input())
N = 50

base = K // N
resi = K % N

A = [49 + base] * N

for i in range(N):
    if i < resi:
        A[i] += N - resi + 1
    else:
        A[i] -= resi

print(N)
print(' '.join(map(str,A)))



Measured memory_bytes: 3064
#include <iostream>
#define rep(i, n)	for(int i = 0; i < (n); i++)
using namespace std;

int main(){
	/*input*/
	char s[3];
	rep(i, 3)cin >> s[i];
	/*calculation*/
	int ans = 0;
	rep(i, 3){
		if(s[i] == '1')ans++;
	}
	/*output*/
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int N=100005;

int k,sum;
bool f[46][N];
char q1[46*N];
int q2[46*N],head,tail;
int main()
{
	scanf("%d",&k);
	int tmp=k;
	while (tmp) sum+=tmp%10,tmp=tmp/10;
	
	f[0][0]=true;
	q1[1]=0,q2[1]=0;head=tail=1;
	while (head<=tail) 
	{
		int i=q1[head],j=q2[head],x,y;head++;
		for (int l=0;l<10;l++)  
		{
			x=i+l,y=(j*10+l)%k;
			if (x>sum) continue;
			if (f[x][y]) continue;
			f[x][y]=true;
			++tail;q1[tail]=x,q2[tail]=y;
		}
	}
	for (int i=1;i<=sum;i++) if (f[i][0]) 
	{
		printf("%d",i);
		return 0;
	}
	return 0;
}

Measured memory_bytes: 27008
using System;
using System.Collections.Generic;
using System.Linq;
/*
using System.Text;
using System.Diagnostics;
using System.IO;
*/

namespace AtCoder
{
    class Program
    {
        private const int M = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static bool Solve(int N, List<int>[] paths)
        {
            int[] b = Enumerable.Repeat(int.MaxValue, N).ToArray();
            {
                var q = new Queue<int>();
                b[0] = 0;
                q.Enqueue(0);
                while (q.Count > 0)
                {
                    int i = q.Dequeue();
                    foreach (var j in paths[i])
                    {
                        if (b[j] > b[i] + 1)
                        {
                            b[j] = b[i] + 1;
                            q.Enqueue(j);
                        }
                    }
                }
            }
            int[] w = Enumerable.Repeat(int.MaxValue, N).ToArray();
            {
                var q = new Queue<int>();
                w[N - 1] = 0;
                q.Enqueue(N - 1);
                while (q.Count > 0)
                {
                    int i = q.Dequeue();
                    foreach (var j in paths[i])
                    {
                        if (w[j] > w[i] + 1)
                        {
                            w[j] = w[i] + 1;
                            q.Enqueue(j);
                        }
                    }
                }
            }
            int fennec = 0;
            int snuke = 0;
            for (int i = 0; i < N; ++i)
            {
                if (b[i] <= w[i]) { ++fennec; } else { ++snuke; }
            }
            return fennec > snuke;
        }

        static void Main(string[] args)
        {
            int N = ReadInt();
            var paths = new List<int>[N];
            for (int i = 0; i < N; ++i) { paths[i] = new List<int>(); }
            for (int i = 0; i < N - 1; ++i)
            {
                int[] values = ReadInts();
                int a = values[0] - 1;
                int b = values[1] - 1;
                paths[a].Add(b);
                paths[b].Add(a);
            }
            Console.WriteLine(Solve(N, paths) ? "Fennec" : "Snuke");
        }
    }
}


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

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

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

bool includes7(int n) {
    while (n > 0) {
        if (n % 10 == 7)
            return true;
        n = n / 10;
    }

    return false;
}

int main() {
    ios::sync_with_stdio(false);
    int n;

    cin >> n;
    if (includes7(n)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3652
N, M = gets.split.map(&:to_i)
A = N.times.map { gets.chomp }
B = M.times.map { gets.chomp }
(0..(N - M)).each do |y|
  (0..(N - M)).each do |x|
    if M.times.all? { |k| A[k + y][x..(x + M - 1)] == B[k] }
      puts "Yes"
      exit
    end
  end
end
puts "No"


Measured memory_bytes: 1788
#include<stdio.h>

int main(void){
    int l,r,d;

    scanf("%d %d %d",&l,&r,&d);

    int i,c=0;

    for(i = l ; i <= r ; i++){
        if(i % d == 0)c++;
    }

    printf("%d",c);
    return 0;


}

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

using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<int> high(n);
    int cnt = 0,max_cnt=0;

    for (int i = 0; i < n; i++){
        cin >> high.at(i);
    }

    for (int i = 0; i < n-1;i++){
        
            if (high.at(i) >= high.at(i+1)){
                cnt++;
                max_cnt = max(max_cnt, cnt);
            }
            else
                cnt = 0;
    }

        cout << max_cnt << endl;

        return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define Cout(x)        cout << #x << " " << x << endl
#define ld long double
#define ll long long
#define vll vector<ll>
#define pll pair<ll ,ll >
#define vpll vector< pll >
#define pb push_back
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define fr(i,n) for(ll (i) = 0 ; (i) < (n) ; ++(i))
#define fr1(i,n) for(ll (i) = 1 ; (i) <= (n) ; ++(i))
#define frr(i,n) for(ll (i) = (n)-1 ; (i)>=0 ; --(i))
#define frab(i,a,b,c) for(ll (i) = a ; (i) < (b) ; (i)+=(c))
#define print(v) for( auto it: v) cout<<it<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll A[300005];
ll dp[2005][2005];
ll cal( ll pos , ll s) {
	if (s < 0) return 0;
	if (s == 0) {
		return 1;
	}
	if (dp[pos][s] != -1) return dp[pos][s];
	ll ans = 0;
	for ( int i = 3; i <= s; i++) {
		if (s - i < 0) break;
		ans += cal(pos + 1, s - i);
		ans %= MOD;
	}
	dp[pos][s] = ans % MOD;
	return ans;
}
int main()
{
	ios;
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
	ll a, b, c, d, n, m, k,   q;


	double t;
	vll v, v1;
	vpll A;
	cin >> n;
	fr(i, n) {
		cin >> a >> b;
		A.pb({a, b});
		a += b;
		v.pb(a);
	}
	sort(all(v));
	ll ans = abs(v[n - 1] - v[0]);
	v.clear();
	fr(i, n) {

		a = A[i].first;
		b = A[i].second;
		a -= b;
		v.pb(a);
	}
	sort(all(v));
	//print(v);
	ans = max(ans, abs(v[n - 1] - v[0]));
	cout << ans << endl;


}


Measured memory_bytes: 10028
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;

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

using ll = long long;
using Pii = pair<int, int>;

const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;

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

using MIte = multimap<ll, ll, greater<ll> >::iterator;

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

	// long long?
	int N, T;
	cin >> N >> T;

	int ans = inf;
	rep(i, N) {
		int c, t;
		cin >> c >> t;
		if (t <= T) {
			ans = min(ans, c);
		}
	}

	if (ans == inf) {
		cout << "TLE" << endl;
	}
	else {
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;
using i32 = int;
using i64 = long long;
using f64 = double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf64 = vector<f64>;
using vstr = vector<string>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  int n, k;
  string s;
  cin >> n >> s >> k;
  char c = s[k - 1];
  rep(i, n) if (s[i] == c) cout << c; else cout << '*';
  cout << endl;
  return 0;
}


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

int sort(const void *a,const void *b){
	return *(int *)a-*(int *)b;
}

int main(){
	int i,j,k;
	int a[3];
	int count=0,counter;
	scanf("%d",&counter);
	while(count<counter){
		for(i=0;i<3;i++){
			scanf("%d",&a[i]);
		}
		qsort(a,3,sizeof(int),sort);
		if(a[0]*a[0]+a[1]*a[1]==a[2]*a[2]){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
		count++;
	}
	return 0;
}

Measured memory_bytes: 584
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define rate 380000
int main(void)
{
  int n,i;
  int change,sum=0;
  float bit=0,bitc,coin;
  scanf("%d",&n);
  //printf("%d\n",n);
  char price[n][13];
  char payment[n][4];
  
  for(i=0;i<n;i++){
    scanf("%s",price[i]);
    scanf("%s",payment[i]);
    //printf("%s ",price[i]);
    //printf("%s\n",payment[i]);
  }
  
  for(i=0;i<n;i++){
    if(strcmp( payment[i], "JPY" ) == 0){
      change=atoi(price[i]);
      sum+=change;
    }
    if(strcmp( payment[i], "BTC" ) == 0){
      bitc=atof(price[i]);
      bit+=bitc;
    }
    //printf("%d %d %.8f %.8f \n",sum,change,bit,bitc);
  }

  coin=bit*rate;
  
  printf("%f",coin+sum);  
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  ll x;
  cin >> n >> x;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll cnt = 0;
  rep(i,n-1) {
    ll sum = a[i] + a[i+1];
    if (sum > x) {
      cnt += a[i]+a[i+1]-x;
      a[i+1] -= a[i]+a[i+1]-x;
      if (a[i+1] < 0) {
        a[i] += a[i+1];
        a[i+1] = 0;
      }
    }
  }
  // rep(i,n) debug(a[i]);
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
int a[25][25];
int dp[23][2345678];
int memo[2345678][23];
int N;
int change(int n,int j){
  int x=((1<<N)-1)-((1<<j)-1);
  return (x&n)*2+(1<<j)+((~x)&n);
}
//main
signed main(){
  cin>>N;
  //cout<<(1<<0)<<endl;return 0;
  //int q,qq;cin>>q>>qq;cout<<change(q,qq)<<" "<<(change(q,qq)^(1<<qq))<<endl;return 0;
  for(int i=0;i<N;i++)for(int j=0;j<N;j++)cin>>a[i][j];
  memset(dp,0,sizeof(dp));memset(memo,-1,sizeof(memo));
  dp[0][0]=1;
  for(int i=0;i<N;i++)dp[1][1<<i]=a[0][i];
  for(int i=1;i<N;i++){
    for(int j=0;j<N;j++){
      if(a[i][j]==0)continue;
      int comb=(1<<i)-1;
      while(comb<(1<<(N-1))){
        //cout<<i<<" "<<j<<" "<<comb<<" "<<change(comb,j)<<" "<<(change(comb,j)^(1<<j))<<endl;
        dp[i+1][change(comb,j)]+=dp[i][change(comb,j)^(1<<j)];
        dp[i+1][change(comb,j)]%=MOD;
        int x=comb&-comb,y=comb+x;
        comb=(((comb&~y)/x)>>1)|y;
      }
    }
  }
  /*
  cout<<"-----------"<<endl;
  for(int i=0;i<N+1;i++){
    for(int j=0;j<16;j++)cout<<dp[i][j]<<" ";cout<<endl;
  }
  cout<<"-----------"<<endl;
  */
  cout<<dp[N][(1<<N)-1]<<endl;
}


Measured memory_bytes: 843264
N,M = map(int,input().split())
L = [list(map(int,input().split())) for i in range(M)]
L.sort()
ans = 1
l = L[0][0]
r = L[0][1]
for a,b in L:
    if r <= a or l >= b:
        ans += 1
        l = a
        r = b
    else:
        l = a
        r = min(r,b)
print(ans)


Measured memory_bytes: 29884
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#define ll long long int
#define lim 100010
#define mod 1e9+7
#define INF 1e9
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define ABS(x) ((x)>0?(x):-(x))

typedef struct{
	int ind,num;
}data;
int comp(const void *a,const void *b){return ((data*)b)->num - ((data*)a)->num;}

int compare(const void *a,const void *b){return *(int*)a-*(int*)b;}

int main(void){
	int N;
	scanf("%d",&N);
	data A[N];
	for(int i=0;i<N;i++){
		scanf("%d",&A[i].num);
		A[i].ind = i;
	}
	qsort(A,N,sizeof(data),comp);
	for(int i=0;i<N;i++){
		if(i==A[0].ind){
			printf("%d\n",A[1].num);
		}else
			printf("%d\n",A[0].num);
	}
	return 0;
}

Measured memory_bytes: 3324
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

ll N, a[100010];

signed main(){
    cin >> N;
    ll n = 1, sum = 0, i = 0;
    while(N != 0){
        n = abs(N) % 2;
        if(N < 0) n = (2 - n) % 2;
        a[i] = n; i++;
        N = (N - n) / (-2);
    }
    if(i == 0) i++;
    for(int j = i - 1; j >= 0; j--){
        cout << a[j];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main() {
  int N,i,ans=0;
  int s[50] = { 0 };
  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    scanf("%d", s + i);
    if (s[i] != i+1) {
      ans++;
    }
  }
  if (ans <= 2) {
    printf("YES");
  }
  else {
    printf("NO");
  }


}

Measured memory_bytes: 256
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
int md(int a, int b, int c, int d) {
	return abs(a - c) + abs(b - d);
}
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int d = a;
	while (d < (b + 1)*a) {
		if (d%b == c) {
			cout << "YES";
			return 0;
		}
		d += a;
	}
	cout << "NO";
	return 0;
}




Measured memory_bytes: 256