akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
#AGC34 B

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
n = len(s)
t = ''
i = 0
while i < n-1:
    if s[i:i+2] == 'BC':
        t += 'D'
        i += 2
    else:
        t += s[i]
        i += 1
m = len(t)
ans = 0
a,d = 0,0
for i in range(m):
    if t[i] == 'A':
        a += 1
    elif t[i] == 'D':
        ans += a
    else:
        a,d = 0,0
print(ans)


Measured memory_bytes: 3832
#include<bits/stdc++.h>
    #define ll long long
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define pb push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define vi vector < ll  int >
    #define CLR(a) memset((a),0,sizeof(a))
    #define mp make_pair
    #define hell 1000000007
    using namespace std;
 ll mod=998244353;
void solve()
{
 ll i,j=1,k,n,m=0,f,s1=0,x,c=1,t,y=0;
cin>>k>>n;
vector < ll > v(n);
rep(i,0,n) cin>>v[i];
y=1e9;
y=v[n-1]-v[0];
rep(i,1,n-1)
{
    //f=(n-1+1)%n;
    y=min(y,k-(v[i]-v[i-1]));
    y=min(y,k-v[i+1]+v[i]);
}
y=min(y,v[n-1]-v[0]);
y=min(y,2*k-v[n-1]);
cout<<y;
}


 //}

    signed main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int t=1;
         //cin>>t;
        while(t--)
        solve();
    }


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

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, n, sum, A[500010], B[500000], rui[500000], dp[5000];
str S, T, U; bool check = false;	vector<ll> v;
double d;


int main() {
	//Code Line
	cin >> n >> a;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		sum += A[i];
	}
	sort(A, A + n);
	double e = 4 * a;
	d = (double)sum / e;
	for (int i = 0; i < n; i++) {
		if (A[i] >= d)a--;
		if (a == 0) { check = true; break; }
	}
	if (check)cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 2304
sx,sy,tx,ty = map(int,input().split())

len_x = tx-sx
len_y = ty-sy

s = "U"*len_y+"R"*len_x+"D"*len_y+"L"*len_x
s += "L"
s += "U"*(len_y+1)
s += "R"*(len_x+1)
s += "D"
s += "R"
s += "D"*(len_y+1)
s += "L"*(len_x+1)
s += "U"

print(s)

Measured memory_bytes: 3060
// abc_046_A.cpp
//

#include <iostream>
#include <vector>
#include <set>

using namespace std;

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

	set<int> s(v.begin(), v.end());

	cout << s.size() << "\n";

	return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long a, b; 
	while (true) {
		cin >> a >> b;
		if (a == 0 && b == 0) return 0;
		for (int h = 1; h <= a; h++) {
			for (int i = 1; i <= b; i++) {
				if (h % 2 == 1) {
					if (i % 2 == 1) {
						cout << '#';
					}
					else {
						cout << '.';
					}
				}
				else {
					if (i % 2 == 0) {
						cout << '#';
					}
					else {
						cout << '.';
					}
				}
			}
			cout << endl;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3076
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	ll X, K;
	cin >> X >> K;
	int r[100002];
	rep1(i, K) cin >> r[i];
	r[0] = 0;
	r[K + 1] = 2e9;

	ll L = 0;
	ll R = X;
	ll takasa = 0;
	int katamuki = -1;
	int *ri = r + 1;

	int Q;
	cin >> Q;
	rep(i, Q) {
		ll t, a;
		cin >> t >> a;
		
		while (t > *ri) {
			takasa += katamuki * (*ri - *(ri - 1));
			ll nl = takasa + L;
			ll nr = takasa + R;
			if (katamuki < 0) {
				if (nl < 0) L -= nl;
				if (nr < 0) R -= nr;
			}
			else {
				if (nl > X) L -= nl - X;
				if (nr > X) R -= nr - X;
			}
			ri++;
			katamuki *= -1;
		}

		chmax(a, L);
		chmin(a, R);
		a += takasa + katamuki * (t - *(ri - 1));
		chmax(a, 0ll);
		chmin(a, X);
		co(a);
	}

	Would you please return 0;
}

Measured memory_bytes: 1664
// abc146_a
#include <iostream>
#include <math.h>
#include <cstring>
#define US unsigned short
#define UI unsigned int
#define UC unsigned char
#define UL unsigned long
using namespace std;

int main(int argc, char const *argv[])
{
    char s[4];
    UI o;
    cin >> s;

    if (s[0] == 'S' && s[1] == 'U')
        o = 7;
    else if (s[0] == 'M')
        o = 6;
    else if (s[0] == 'T' && s[1] == 'U')
        o = 5;
    else if (s[0] == 'W')
        o = 4;
    else if (s[0] == 'T' && s[1] == 'H')
        o = 3;
    else if (s[0] == 'F')
        o = 2;
    else if (s[0] == 'S' && s[1] == 'A')
        o = 1;

    cout << o << endl;
}


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

int main() {
	int n, pn, pnc=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> pn;
		if ((pn == 2)||(pn == 3))
			pnc += 1;
		else if (pn % 2 == 0) {}
		else {
			for (int j = 3; j <= pn/j; j += 2) {
				if (pn % j == 0) {
					pnc -= 1; 
					break;
				}
			}
			pnc += 1;
		}
	}	
	cout << pnc << endl;
	return 0;
}

Measured memory_bytes: 3084
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;

typedef long long ll;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define INF 1000000000

int main() {

	string s, t, ans = "No";
	cin >> s;
	cin >> t;
	int a = s.length();

	FOR(i, a) {
		FOR(j, a) {
			if (s[j] != t[j])break;
			if (j == a - 1)ans = "Yes";
		}
		if (ans == "Yes")break;
		else s = s.substr(1, a) + s[0];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int count5 = 0;
    int count7 = 0;
    for(int i = 0; i < 3; i++){
      if(S[i].equals("5")){
        count5++;
      }else if(S[i].equals("7")){
        count7++;
      }
    }
    if(count5 == 2 && count7 == 1){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}

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

int main() {
	string str;
	int ans = 0, i = 0;
	cin >> str;
	while(i < str.size()){
		int jcnt = 0, ocnt = 0, icnt = 0; 
		if(str[i] == 'J'){
			bool flag = false;
			jcnt++;
			if(i + 1 >= str.size()){
				break;
			}
			for(int j = i + 1; j < str.size(); ++j){
				if(str[j] != 'J'){
					i = j;
					break;
				}
				jcnt++;
				if(j == str.size() - 1)
					i = j + 1;
			}
			if(i >= str.size()){
				break;
			}
			for(int j = i; j < str.size(); ++j){
				if(str[j] != 'O'){
					i = j;
					break;
				}
				ocnt++;
				flag = true;
				if(j == str.size() - 1)
					i = j + 1;
			}
			if(i >= str.size()){
				break;
			}
			if(!flag)
				continue;
			for(int j = i; j < str.size(); ++j){
				if(str[j] != 'I'){
					i = j;
					break;
				}
				icnt++;
			}
			if(jcnt >= ocnt && ocnt <= icnt)
				ans = max(ans, min(jcnt, ocnt));
		}
		else{
			i++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2048
s = input()
sl = []
for i in s:
    if i not in sl:
        sl.append(i)
if len(sl) == 2:
    n = 0
    for i in s:
        if i == sl[0]:
            n += 1
    if n == 2:
        print('Yes')
else:
    print('No')

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

class P
{
    static void Main()
    {
       // int n = int.Parse(Console.ReadLine());
        //int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(Console.ReadLine().Replace("2017", "2018"));
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <ostream>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

std::ostream& operator << (std::ostream& os, const std::vector<int>& v) {
  for (int i = 0; i < int(v.size()); ++i) {
    os << v[i];
    if (i != int(v.size()) - 1) cout << " ";
  }
  return os;
}

int main() {
  std::vector<int> tri(4, 0), edge(3);

  while (cin >> edge[0] >> edge[1] >> edge[2]) {
    std::sort(edge.begin(), edge.end(), std::greater<int>());

    int largest = edge[0] * edge[0], others = edge[1] * edge[1] + edge[2] * edge[2];

    if (edge[0] >= edge[1] + edge[2]) {
      break;
    }
    else if (largest == others) {
      tri[1]++;
    }
    else if (largest < others) {
      tri[2]++;
    }
    else if (largest > others) {
      tri[3]++;
    }

    tri[0]++;
  }

  cout << tri << endl;

  return 0;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll int64_t
#define ull uint64_t
using namespace std;

void primeFactors(int n, map<int, int>& m ){  
    while (n % 2 == 0)  
    {  
        n = n/2;  
        m[2] ++;
    }  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        while (n % i == 0)  
        {  
            n = n/i;  
            m[i] ++;
        }  
    }  
    if (n > 2)   
        m[n] ++; 
}

int main() {
	IOS;
	ull n, sum = 0;
	cin >> n;
	map<int ,int> m;
	for(int i = 1;i < n;i += 1){
	    ull prod = 1;
		primeFactors(n - i, m);
		for(pair<const int, int>& p : m){
			prod *= (p.second + 1);
			//cout << prod << " ";
		}
		sum += prod;
		m.clear();
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3672
#include <complex>
#include <stdio.h>
#include <math.h>
using namespace std;

// _ÀWð^Æ·é
typedef complex<double> P;

//XYÀW
#define X real()
#define Y imag()

// ¼üp1,p2Æüªp3,p4Ìð·»è
// (n < 0)<=>ð· , (n == 0)<=>¼üã, (n > 0)<=>ð·µÄ¢È¢  
double isIntersect(P p1, P p2, P p3, P p4){  
    return ( (p1.X-p2.X)*(p3.Y-p1.Y) + (p1.Y-p2.Y)*(p1.X-p3.X)) * ((p1.X-p2.X)*(p4.Y-p1.Y) + (p1.Y-p2.Y)*(p1.X-p4.X));  
}

int main(){
	double xa, xb, xc, xd, ya, yb, yc, yd;

	while( scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &xa, &ya, &xb, &yb, &xc, &yc, &xd, &yd) != EOF ){
		P a( xa , ya );
		P b( xb , yb );
		P c( xc , yc );
		P d( xd , yd );
		
		if( isIntersect(a,c,b,d) > 0.0 || isIntersect(b,d,a,c) > 0.0 ){
			printf("NO\n");
		}else{
			printf("YES\n");
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <vector>

// for the bellman-ford (BF) method
using graphBF = std::vector<std::vector<long long>>;

#define INF (long long)(1e18 + 7) 
#define ALL(x) std::begin(x), std::end(x) 

void print(std::vector<long long> vec){
    int n = vec.size();
    for(int i = 0; i < n; ++i){
        std::cout << vec.at(i) << std::endl;
    }
}

int main(){
    int n, m;
    std::cin >> n >> m;

    graphBF g;
    std::vector<long long> s(m), e(m), w(m);
    for(int i = 0; i < m; ++i){
        std::cin >> s.at(i) >> e.at(i) >> w.at(i);
        --s.at(i); --e.at(i); w.at(i); // since from-1-indexes are given, s and t have to be adjusted by -1
    }

    std::vector<long long> score(n, -INF);
    score.at(0) = 0;
    
    for(int i = 0; i < n - 1; ++i){
        for(int j = 0; j < m; ++j){
            long long buf = std::max(score.at(e.at(j)), score.at(s.at(j)) + w.at(j));
            if(buf != score.at(e.at(j))){
                score.at(e.at(j)) = buf;
            }
        }
        
//        print(score);
//        std::cout << "------" << std::endl;
    }

    std::vector<bool> isUpdated(n, false);
    for(int j = 0; j < m; ++j){
        if(isUpdated.at(s.at(j))){
            isUpdated.at(e.at(j)) = true;
        }else{
            long long buf = std::max(score.at(e.at(j)), score.at(s.at(j)) + w.at(j));
            if(buf != score.at(e.at(j))){
                isUpdated.at(e.at(j)) = true;
            }
        }
    }

    if(isUpdated.at(n - 1)){
        std::cout << "inf" << std::endl;
    }else{
        std::cout << score.at(n - 1) << std::endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1000000007

char a[52][52];
ll cnt[52][52],h,w,black=0;
int lr[5]={-1,0,1,0},ud[5]={0,-1,0,1};

void mov(int noh,int now,int step){
	if(cnt[noh][now]<step){
		step=cnt[noh][now] ;
	}
	cnt[noh][now]=step;
	if(noh==h&&now==w){
		return ;
	}
	for(int i=0;i<4;i++){
		ll neH= noh+ud[i],neW=now+lr[i];
		if(a[neH][neW]=='@'||a[neH][neW]=='#'){
			continue;
		}
		if(cnt[neH][neW]<=step+1){
			continue;
		}
		mov(neH,neW,step+1);
	}
}

int main() {
	cin>>h>>w;
	for(int i=0;i<52;i++){
		for(int j=0;j<52;j++){
			a[i][j]='@';
			cnt[i][j]=inf;
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin>>a[i][j];
			if(a[i][j]=='#'){
				black++;
			}
		}
	}
	mov(1,1,1);
	if(cnt[h][w]==inf){
		cout << -1;
		return 0;
	}
	cout << h*w-black-cnt[h][w];
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vb= vector<bool>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()


int main(){
  int h,n,asum=0;
  cin >> h >> n;
  vi a(n);
  rep(i,0,n){
    cin >> a[i];
    asum+= a[i];
  }
  if(asum>=h){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 640
//%std
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
int n,k,q;
const int MAXN=1e5+10;
int sc[MAXN];
int main()
{
	n=read(),k=read(),q=read();
	for(int i=1;i<=n;++i)	
		sc[i]=k;
	k=0;
	for(int i=1;i<=q;++i)
	{
		int x=read();
		++sc[x];
		++k;
	}
	for(int i=1;i<=n;++i)
		if(sc[i]>k)
			puts("Yes");
		else
			puts("No");
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int main(){
	int n;
	cin >> n;
	string s = "aabcdefghijklmnopqrstuvwxyz";
	vector<pair<string, int> > num[11];
	num[1].push_back(make_pair("a", 1));
	for (int i = 2; i <= n; i++){
		for (int j = 0; j < num[i-1].size(); j++){
			for (int k = 1; k <= num[i-1][j].second + 1; k++){
				num[i].push_back(make_pair(num[i-1][j].first + s[k], max(k, num[i-1][j].second)));
			}	
		}
	}
	for (int i = 0; i < num[n].size(); i++){
			cout << num[n][i].first << endl;
	}
	return 0;
 }



Measured memory_bytes: 10736
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)


const ll INF = 10010001010;
const int inf = 1000034000;

typedef tuple<string, int, int> TUP;

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

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> P(N);
    for (int i = 0; i < N;i++)
    {
        cin >> P[i];
    }
    ll ans = 0;
    sort(all(P));
    for (int i = 0; i < K;i++)
    {
        ans += P[i];
    }
    cout << ans << endl;
}


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

int main() {
  string S, T;
  cin >> S >> T;
  int s = S.size();
  int t = T.size();

  int min_count = 1000;
  for (int i = 0; i <= s - t; i++) {
    int count = 0;
    for (int j = 0; j < t; j++) {
     
      if (S.at(i + j) != T.at(j)) count++;
      
    }
     min_count = min(min_count, count);
  }
  
  cout << min_count << endl;
}
  

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

int main(){
	int n;
	cin >> n;

	char c;
	int count_b = 0;
	int count_r = 0;

	for(int i = 0; i < n; ++i){
		cin >> c;
		if(c == 'R'){
			++count_r;
		}else{
			++count_b;
		}
	}

	if(count_r > count_b){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
def rotn(n, s):

    ans = ""

    for i in s:
        ans += chr(ord("A")+(ord(i)+ n-ord("A"))%26)

    return ans

def main():
    n = int(input())
    s = list(str(input()))
    print(rotn(n, s))

if __name__ == '__main__':
    main()

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

int main(){
    int i;
    long long n=0;
    long long p=0;
    long long q=0;
    int ans=0;
    cin >> n;
    if(n<3){
        cout << 0;
        return 0;
    }
    vector<long long> a(n);
    for(i=0;i<n;i++){
        cin >> a[i];
    }
    for(i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                if(a[i] != a[j] && a[j] != a[k] && a[k] != a[i]){
                    p=max(a[i],max(a[j],a[k]));
                    q = a[i] + a[j] + a[k];
                    // printf("%d %d\n",p,q);
                    if(q-p>p){
                        // printf("%d  %d\n",q-p,p);
                        // printf("i;%d j;%d k;%d\n",i,j,k);
                        // printf("a[i];%d a[j];%d a[k];%d\n",a[i],a[j],a[k]);
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 3624
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <fstream>
#include <typeinfo>
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define I insert
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define repi(i, a, b) for (ll i = a; i < b; i++)
#define repj(j, a, b) for (ll j = a; j < b; j++)
#define vi vector<int>
#define pii pair<int, int>
#define vpii vector<pii>
#define mod 1000000007
#define lim 100001
#define pi 3.14159265

using namespace std;
ll factorial(ll n) { return (n == 1 || n == 0) ? 1 : n * factorial(n - 1); }
int max3(int a, int b, int c) { return max(a, max(c, b)); }
int gcd(int a, int b)
{
    if (a == 0)
    {
        return b;
    }
    else
    {
        return gcd(b % a, a);
    }
}
ll power(ll a, ll n)
{
    if (n == 1)
        return a;
    else if (n == 0)
        return 1;
    else
    {
        ll r = power(a, n / 2);
        if (n % 2 == 0)
            return r * r;
        else
            return r * a * r;
    }
}
ll nCr(ll n, ll r) { return ((factorial(n)) / (factorial(n - r) * factorial(r))); }
void dfs(vector<vector<int>> &v, vi &check, int start)
{
    check[start - 1] = 1;
    repj(j, 0, v[start - 1].size())
    {
        if (!check[v[start - 1][j] - 1])
        {
            dfs(v, check, v[start - 1][j]);
        }
    }
}
bool isPrime(ll n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
}
//works under 2 till 1e12

double newPrecision(double n)
{
    return floor(pow(10, 250) * n) / pow(10, 250);
}

ll f( ll arr[][3], ll pos, ll n, ll prev, ll rec[][3]){
    ll num = INT_MIN;
    if(pos == (n-1)){
        for (int i = 0; i < 3; i++)
        {
            if(i==prev)
                continue;
            num = max(num, arr[pos][i]);
        }
        return num;
    }
    /*if(rec[pos]!=-1){
        return rec[pos];
    }*/
    for (int i = 0; i < 3; i++)
    {
        if (i == prev)
            continue;
        if(rec[pos][i]!=-1){
            num = max(num, rec[pos][i]);
            continue;
        }
        rec[pos][i] = arr[pos][i] + f(arr, pos + 1, n, i, rec);
        num = max(num, rec[pos][i]);
    }
    return num;
}

    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        ll n;
        cin >> n;
        ll arr[n][3];
        for (ll i = 0; i < n; i++)
        {
            for (ll j = 0; j < 3; j++)
            {
                cin >> arr[i][j];
            }
        }
        ll rec[n][3];
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                rec[i][j] = -1;
            }
        }
        cout << f(arr, 0, n, -1, rec);

        return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define INF 1e9
#define endl '\n'
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define FORE(i, a, b) for (int i = (a), e = (b); i < e; ++i)
#define RFORE(i, a, b) for (int i = (b)-1, e = (a); i >= e; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>())
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    map<string, int> dic;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        dic[s] += 1;
    }
    int M;
    cin >> M;
    for (int i = 0; i < M; i++) {
        string t;
        cin >> t;
        dic[t] -= 1;
    }
    using pair_type = decltype(dic)::value_type;
    auto pr =
        max_element(ALL(dic), [](const pair_type& p1, const pair_type& p2) {
            return p1.second < p2.second;
        });
    cout << max(pr->second, 0) << endl;
}


Measured memory_bytes: 3612
import math


class Point:
    EPS = 1 << 10

    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __add__(self, other):
        return Point(self.x+other.x, self.y+other.y)

    def __sub__(self, other):
        return Point(self.x-other.x, self.y-other.y)

    def __mul__(self, other):
        return Point(self.x*other, self.y*other)

    def __floordiv__(self, other):
        return Point(self.x/other.x, self.y/other.y)

    def __abs__(self):
        return math.sqrt(self.norm())

    def norm(self):
        return self.x**2 + self.y**2

    def __eq__(self, other):
        EPS = self.__class__.EPS
        return abs(self.x-other.x) < EPS and abs(self.x-other.x) < EPS

    def dot(self, other):
        return self.x*other.x + self.y*other.y

    def cross(self, other):
        return self.x*other.y - self.y*other.x

    def isOrthogonal(self, a, b):
        return a.dot(b) == 0.0

    def isParallel(self, a, b):
        return a.cross(b) == 0.0

    def __str__(self):
        return str(self.x)+' '+str(self.y)


class Vector(Point):
    pass


class Segment:
    def __init__(self, p1, p2):
        self.p1 = p1
        self.p2 = p2

    def isOrthogonal(s1, s2):
        return (s1.p2-s1.p1).dot(s2.p2-s2.p1) == 0.0

    def isParallel(s1, s2):
        return (s1.p2-s1.p1).cross(s2.p2-s2.p1) == 0.0


class Line(Segment):
    pass


class Circle:
    def __init__(self, c, r):
        self.c = c
        self.r = r


class Polygon:
    def __init__(self, *points):
        self.points = points


def project(s, p):
    base = s.p2 - s.p1
    r = (p-s.p1).dot(base) / base.norm()
    return s.p1 + base * r



x1, y1, x2, y2 = map(int, input().split())
p1, p2 = Point(x1, y1), Point(x2, y2)
s = Segment(p1, p2)

q = int(input())
for i in range(q):
    p = Point(*map(int, input().split()))
    print(project(s, p))



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

int main()
{
	int n;cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	int counter=1;
	int curr=a[0];
	for(int i=1;i<n;i++)
	{
		if(curr>a[i])
			{curr=a[i];counter++;}
	}
	cout<<counter;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

const int MAX=50;
ll binom[MAX+1][MAX+1];

void calc_binom(){
	binom[1][0]=1;
	binom[1][1]=1;
	for(int i=2; i<=MAX; i++) binom[i][0]=1;
	for(int i=2; i<=MAX; i++){
		for(int j=1; j<=i; j++){
			binom[i][j]=binom[i-1][j-1]*i/j;
		}
	}
	return;
}

int main(){
	calc_binom();

	int n, a, b;
	cin >> n >> a >> b;
	ll v[n];
	for(int i=0; i<n; i++) cin >> v[i];
	sort(v, v+n, greater<ll>());

	int cnt1=0, cnt2=0, cnt3=0;
	for(int i=0; i<n; i++){
		if(v[i]==v[0]) cnt1++;
		if(v[i]>v[a-1]) cnt2++;
		if(v[i]==v[a-1]) cnt3++;
	}

	double ave;
	ll select=0;
	if(cnt1>=a){
		ave=(double)v[0];
		for(int i=a; i<=min(cnt1, b); i++){
			select+=binom[cnt1][i];
		}
	}else{
		ll sum=0;
		for(int i=0; i<a; i++) sum+=v[i];
		ave=(double)(sum)/a;
		select+=binom[cnt3][a-cnt2];
	}

	printf("%.9f\n", ave);
	cout << select << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> a(3);
  cin>>a.at(0)>>a.at(1)>>a.at(2);
  sort(a.begin(),a.end());
  int ans=a.at(2)*10+a.at(1)+a.at(0);
  cout<<ans<<endl;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 0; (1<<i) <= n; i++) {
        chmax(ans, 1<<i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#include <string>

using namespace std;

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

    string t = s.substr(0, 1), u;
    int sol = 1, i = 1;
    while (i < s.size()) {
        u.push_back(s[i]);
        if (u == t) {
            if (i == s.size() - 1)
                break;
            else {
                i++;
                u.push_back(s[i]);
            }
        }
        t = u;
        u = "";
        sol++;
        i++;
    }

    cout << sol << '\n';
    return 0;
}

Measured memory_bytes: 640
def main():
    N, X = map(int, input().split())
    L = [int(a) for a in input().split()]
    bound = 1
    D = 0
    for i in range(N):
        b = D + L[i]
        if b <= X:
            bound += 1
        D = b
    print(bound)
main()

Measured memory_bytes: 3060
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int N;
	int swapcount = 0;
	
	cin >> N;

	vector<int> A(N);

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

	bool flag = true;

	while (flag)
	{
		flag = false;

		for (int i = N - 1;i >= 1;i--)
		{
			if (A[i - 1] > A[i])
			{
				swap(A[i - 1], A[i]);
				swapcount++;
				flag = true;
			}
		}
	}

	for (int i = 0;i < N;i++)
	{
		if (i > 0)
			cout << " ";
		cout << A[i];
	}
	cout << endl;

	cout << swapcount << endl;

	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  uint64_t N;
  cin >> N;
  string s = to_string(N);
  uint64_t n = s.length();
  uint64_t n_start = s.at(n - 1) - '0';
  uint64_t n_end = s.at(0) - '0';
  vector<vector<uint64_t>> c(10, vector<uint64_t>(10, 0));
  uint64_t count = 0;

  for (uint64_t i = 1; i <= 9; i++) {
    for (uint64_t j = 1; j <= 9; j++) {
      if ((i == j) && i <= N) {
        c.at(i).at(j)++; //one digit
      }
      if (10 * j + i <= N) {
        c.at(i).at(j)++; //two digit
      }
      if (n >= 4) {
        c.at(i).at(j) += (uint64_t) (10 * (1 - pow(10, n - 3)) / (1 - 10)); //If N is more than 4 digits, you can enter any number from 0 to 9 for n-3 digits
      }
      if (n >= 3 && n_end == j && n_start >= i) {
        c.at(i).at(j) += (N % (uint64_t) pow(10, n - 1)) / 10 + 1; ////the same number of digits as N
      }
      if (n >= 3 && n_end == j && n_start < i) {
        c.at(i).at(j) += (N % (uint64_t) pow(10, n - 1)) / 10; //the same number of digits as N
      }
      if (n >= 3 && n_end > j) {
        c.at(i).at(j) += (uint64_t) pow(10, n - 2); //the same number of digits as N
      }
    }
  }

  for (uint64_t i = 1; i <= 9; i++) {
    for (uint64_t j = 1; j <= 9; j++) {
      count += c.at(i).at(j) * c.at(j).at(i);
    }
  }
  cout << count << endl;
}

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

int H, W;
int A[400][400];
int dp[401][400][400];
int D[2] = {0, 1};

int main() {
  cin >> H >> W;
  long long sum = 0;
  for (int y=0; y<H; y++) {
    for (int x=0; x<W; x++) {
      cin >> A[x][y];
      sum += A[x][y];
    }
  }
  if (W == 1 || H == 1) {
    cout << sum << "\n";
    return 0;
  }

  dp[1][0][1] = A[0][0] + A[0][1] + A[1][0];
  for (int i=1; i<W+H-3; i++) {
    int r = 1+i;
    int nr = 2+i;
    for (int a=0; a<r; a++) {
      for (int b=a+1; b<r; b++) {
        for (int ka=0; ka<2; ka++) {
          for (int kb=0; kb<2; kb++) {
            int na = a+D[ka], nb = b+D[kb];
            if (na < 0 || na >= nr || nb < 0 || nb >= nr) continue;
            if (na >= nb) continue;
            if (r-na<0 || r-nb<0) continue;
            dp[i+1][na][nb] = max(dp[i+1][na][nb], dp[i][a][b] + A[na][r-na] + A[nb][r-nb]);
          }
        }
      }
    }
  }
  cout << 0LL + A[W-1][H-1] + dp[W+H-3][W-2][W-1] << "\n";
  return 0;
}


Measured memory_bytes: 248448
#include <stdio.h>

void sort(int A[], int len_A){
    int i, j, tmp;
    for (i = 0; i < len_A - 1; i++){
        for (j = 0; j < len_A - 1; j++){
            if (A[j + 1] < A[j]){
                tmp = A[j];
                A[j] = A[j + 1];
                A[j + 1] = tmp;
            }
        }
    }
}

int main(void){
    int n;
    scanf("%d", &n);
    int d[n];
    for (int i = 0; i < n; i++){
        scanf("%d", &d[i]);
    }

    int ans = 0;
    sort(d, n);
    for (int i = 0; i < n - 1; i++){
        if (d[i] < d[i + 1]){
            ans += 1;
        }
    }
    printf("%d\n", ans + 1);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    string T,H;
    int sum_h = 0;
    int sum_t = 0;
    for (int i=0;i<n;i++) {
        cin >> T >> H;
        if ( T==H ) {
            sum_t = sum_t + 1;
            sum_h = sum_h + 1;
        } else if ( T.length() > H.length() ) {
            for (int j=0;j<H.length();j++) {
                char t = T.at(j);
                char h = H.at(j);
                if ( t > h ) {
                    sum_t = sum_t + 3;
                    break;
                } else if ( t < h ) {
                    sum_h = sum_h + 3;
                    break;
                } else if ( T.at(H.length()-1) == H.at(H.length()-1) ) {
                    sum_t = sum_t + 3;
                    break;
                }
            }
        } else if ( T.length() < H.length() ) {
            for (int k=0;k<T.length();k++) {
                char t = T.at(k);
                char h = H.at(k);
                if ( t > h ) {
                    sum_t = sum_t + 3;
                    break;
                } else if ( t < h ) {
                    sum_h = sum_h + 3;
                    break;
                } else if ( T.at(T.length()-1) == H.at(T.length()-1) ) {
                    sum_h = sum_h + 3;
                    break;
                }
            }
        } else {
            for (int l=0;l<T.length();l++) {
                char t = T.at(l);
                char h = H.at(l);
                if ( t > h ) {
                    sum_t = sum_t + 3;
                    break;
                } else if ( h > t ) {
                    sum_h = sum_h + 3;
                    break;
                }
            }
        }
    }
    cout << sum_t << " " << sum_h << endl;
}



Measured memory_bytes: 3172
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    int n = b - a;
    cout << n * (n + 1) / 2 - b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


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

	deque<int> que;

	for (int i = 0; i < n; i++){
		int index = lower_bound(que.begin(), que.end(), a[i]) - que.begin();
		if (index) que[index-1] = a[i];
		else que.push_front(a[i]);
	}

	cout << que.size() << endl;
	return 0;
}

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

int main(){
	
	int w,h,x,y;
	cin >> w >> h >> x >> y;
	
	ll wh = (ll)w*(ll)h;
	double m = wh/2.0;
	printf("%.9lf%s", m, " ");
	
	double midx = w/2.0;
	double midy = h/2.0;
	
	
	if(x == midx && y == midy) cout << 1 << endl;
	else cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256
while True:
    H,W = [int(i) for i in input().split()]

    if H == 0 and W == 0:
        break

    else:
        for i in range(H):
                for j in range(W):
                    if (i+j) % 2 ==0:
                        print("#", end="")
                    else:
                        print(".", end="")
                print()
    print()



Measured memory_bytes: 7012
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
  }
}init;



int main(){
  int a,b;
  while(cin >> a >> b){
    int ans = INT_MAX;


    if(b == 1) ans = 0;
    else{
      FORE(i,1,b){
        if((a-1)*(i-1) + a >= b){
          ans = i;
          break;
        }
      }
    }


    cout << ans << endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main() {
	long long int n, t;
	cin >> n >> t;
	vector<long long int> a(n);
	for (long long int i = 0; i < n; i++) {
		cin >> a[i];
	}
	map<long long int, long long int> mp;
	vector<long long int> b = a;
	for (long long int i = n-1; i > 0; i--) {
		b[i-1] = max(b[i], b[i-1]);
	}
	for (long long int i = 0; i < n-1; i++) {
		mp[b[i+1]-a[i]]++;
	}
	map<long long int, long long int>::iterator ite = mp.end();
	ite--;
	cout << (*ite).second << endl;
	
	return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007ll
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define db(x) cout << #x << " = " << x << '\n'
#define sep cout << "********************************************\n"
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL)
int main(int argc, char const *argv[])
{
	fast;
	ll s, w;
	cin >> s >> w;
	if (w >= s)
		cout << "unsafe";
	else
		cout << "safe";
	return 0;
}

Measured memory_bytes: 3580
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> II;
typedef pair<LL, II> III;
typedef priority_queue<III, vector<III>, greater<>> Queue;
static const LL INF = 1LL << 60;

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


void solve(long long N, std::vector<long long> &x, std::vector<long long> &y) {
	vector<LL> a(N), b(N);
	for (LL i = 0; i < N; ++i) {
		a[i] = x[i] - y[i];
		b[i] = x[i] + y[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	LL ans = max(b.back() - b.front(), a.back() - a.front());
	cout << ans << endl;
}

int main() {
    long long N;
	std::cin >> N;
	std::vector<long long> x(N);
	std::vector<long long> y(N);
	for (int i = 0; i < N; i++) {
		std::cin >> x[i]; // x[i]--;
		std::cin >> y[i]; // y[i]--;
	}
	solve(N, x, y);
	return 0;
}


Measured memory_bytes: 9608
import sys


class Walker:
    def __init__(self, n):
        self.start = n
        self.state = n

    def jump(self, pair):
        a, b = pair
        if self.state == a:
            self.state = b
        elif self.state == b:
            self.state = a
        return self



def to_pair(str):
    ab = str.split(',')
    a = int(ab[0])
    b = int(ab[1])
    return (a, b)



#input_file = open(sys.argv[1], "r")
#lines = input_file.readlines()
lines = sys.stdin.readlines()

w = int(lines.pop(0))
walkers = map((lambda x: Walker(x)), range(1, w+1))

lines.pop(0)

bars = map((lambda x: to_pair(x)), lines)

walkers_end = []
for walker in walkers:
    walker = reduce((lambda wkr, p: wkr.jump(p)), bars, walker)
    walkers_end.append(walker)
walkers_end.sort(lambda a, b: cmp(a.state, b.state))

for w in walkers_end:
    print w.start

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

int main()
{
    int n,len,i,x;
    string s;
    cin>>n>>s;
    len = s.size();

    for(i=0;i<len;i++)
    {
        x = s[i]-'A' +1;
        x+=n;
        x = x%26;
        if(x==0)s[i]='Z';
        else s[i]='A'+x-1;
    }
    cout<<s<<endl;

    return 0;
}


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

using namespace std;

int main()
{
int n;
int t,b,aa;
cin>>n;
cin>>t>>aa;
float a[n];
for(int i=0;i<n;i++)
{
    cin>>b;
    float gg = float(t)-float(b*0.006);
    a[i] = abs(gg-aa);
 }
 float min1=1000000;
 int flg;
 for(int i=0;i<n;i++)
 {
    if(min1>a[i])
       { min1= a[i];
         flg=i;
       }
       
 }
 cout<<(flg+1);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ll c[55][55];

ll solve(vi &a, int k, int s, int t)
{
	int n=a.size();
	ll cnt=0;
	for(int i=0;i<(1<<n);i++)
	{
		if(i==0) continue;
		if(__builtin_popcount(i)>k) continue;
		int ad = (1<<18)-1; int o=0;
		for(int j=0;j<n;j++)
		{
			if(i&(1<<j)) 
			{
				ad=(ad&a[j]);
				o=(o|a[j]);
			}
		}
		if(ad==s&&o==t) cnt++;
	}
	return cnt;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,k,s,t; cin>>n>>k>>s>>t;
	vi a;
	for(int i=0;i<n;i++)
	{
		int x; cin>>x;
		if((x&s)==s)
		{
			if((x&t)==x)
			{
				a.pb(x);
			}
		}
	}
	c[0][0]=1;
	for(int i=1;i<=50;i++)
	{
		c[i][0]=c[i][i]=1;
		for(int j=1;j<i;j++)
		{
			c[i][j]=c[i-1][j]+c[i-1][j-1];
		}
	}
	for(int i=1;i<=50;i++)
	{
		for(int j=2;j<=50;j++)
		{
			c[i][j]+=c[i][j-1];
			//cerr<<i<<' '<<j<<' '<<c[i][j]<<'\n';
		}
	}
	if(a.empty())
	{
		cout<<0<<'\n'; return 0;
	}
	ll ans=0;
	n=a.size();
	//cout<<solve(a,k,s,t)<<'\n';
	for(int i=0;i<(1<<18);i++)
	{
		if(!((i&s)==s)) continue;
		if(!((i&t)==i)) continue;
		//s C i C t
		map<int,int> ma;
		for(int j=0;j<n;j++)
		{
			int x=a[j];
			ma[(x&i)]++;
		}
		ll sgn = 1;
		if(__builtin_popcount(i^s)%2) sgn=-1;
		//cerr<<i<<'\n';
		//ll tmp=0;
		/*
		for(auto X:ma)
		{
			cerr<<X.fi<<' '<<X.se<<' '<<c[X.se][k]<<'\n';
			tmp+=c[X.se][k];
		}
		cerr<<"ANS: "<<i<<' '<<sgn<<' '<<tmp<<'\n';
		*/
		for(auto X:ma)
		{
			ans+=sgn*c[X.se][k];
		}
	}
	cout<<ans<<'\n';
}	


Measured memory_bytes: 3684
#include <iostream>
#include <stdio.h>
#include <stack>
#include <string>
using namespace std;

int main() {
	while (true) {
		char s[101];
		int c;
		int j = 0;
		while (true) {
			c = getchar();
			if (c == '\n') break;
			s[j++] = c;
		}
		s[j] = '\0';
		if (s[0] == '.') return 0;
		
		stack<char> stk;
		for (int i = 0; s[i] != '\0'; i++) {
			if (s[i] == '(') stk.push('(');
			else if (s[i] == '[') stk.push('[');
			else if (s[i] == ')') {
				if (!stk.empty()) {
					if (stk.top() == '(') stk.pop();
					else stk.push(')');
				} else stk.push(')');
			} else if (s[i] == ']') {
				if (!stk.empty()) {
					if (stk.top() == '[') stk.pop();
					else stk.push(']');
				} else stk.push(']');
			}
		}
		
		if (stk.empty()) cout << "yes" << endl;
		else cout << "no" << endl;
	}
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define N 500005
using namespace std;

int n,a[N],f[N][26],g[N][19]; char s[N];
int main(){
	scanf("%s",s+1); n=strlen(s+1);
	int i,j;
	for (i=1; i<=n; i++) a[i]=s[i]-'a';
	for (i=0; i<=25; i++) f[n+1][i]=f[n+2][i]=n+2;
	for (i=0; i<=18; i++) g[n+1][i]=g[n+2][i]=n+2;
	for (i=n; i; i--){
		f[i][a[i]]=i+1;
		for (j=a[i]+1; j<26; j++) f[i][j]=f[f[i][j-1]][j-1];
		g[i][0]=f[f[i][25]][25];
		for (j=1; j<=18; j++) g[i][j]=g[g[i][j-1]][j-1];
		for (j=0; j<a[i]; j++) f[i][j]=f[g[i][0]][j];
	}
	int cas,l,r; scanf("%d",&cas);
	while (cas--){
		scanf("%d%d",&l,&r); r++;
		for (i=18; i>=0; i--) if (g[l][i]<=r) l=g[l][i];
		puts((l==r)?"Yes":"No");
	}
	return 0;
}


Measured memory_bytes: 91008
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin>>n;
  vector<string> s(n);
  for(int i=0;i<n;i++){
    cin>>s[i];
  }
  vector<int> c(4);
  for(int i=0;i<n;i++){
    if(s[i]=="AC"){
      c[0]++;
    }
    else if(s[i]=="WA"){
      c[1]++;
    }
    else if(s[i]=="TLE"){
      c[2]++;
    }
    else{
      c[3]++;
    }
  }
  cout<<"AC x "<<c[0]<<endl;
  cout<<"WA x "<<c[1]<<endl;
  cout<<"TLE x "<<c[2]<<endl;
  cout<<"RE x "<<c[3]<<endl;
}

Measured memory_bytes: 6424
s  = input()
p = ""
cnt = 0
isCnt = False

for i in range(len(s)):
  if isCnt:
    n = s[i-1] + s[i]
  else:
    n = s[i]
    
  if p != n:
    cnt += 1
    isCnt = False
  elif p == n:
    isCnt = True
  
  p = n
#  print(p, cnt)
print(cnt)


Measured memory_bytes: 3500
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<map>
#include <algorithm>
int main() {

	int N, x;
	std::cin >> N >> x;
	long long int ax[105];
	int i = 0;
	int l;

	while (std::cin >> l) {
		ax[i] = l;
		i++;
		if (i >= N) break;
	}
	std::sort(ax , ax + N);
	if (x == 0) {
		std::cout << "0" << std::endl;
		return 0;
	}
	long long int tmpx = 0;
	int tmpk = 0;
	for (int k = 0; k < N; k++)
	{
		tmpx += ax[k];
		//std::cout << tmpx << " " << ax[k] << std::endl;
		if (tmpx <= x)
		{
			//std::cout << "k " << k << std::endl;
			tmpk = k+1;
		}
	}
	if (tmpx < x) {
		tmpk = tmpk - 1;
	}
	else if(tmpx > x ){
		//tmpk = N - 1;
	}
	std::cout << tmpk << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, double i)
{
    printf("%.20f", i);
    return my;
}

constexpr char BR = '\n';


///////////////////////////////////////////////////

int g(int x, int y, int z)
{
    return x*x + y*y + z*z + x*y + y*z + z*x;
}

int main()
{
    int N;
    io >> N;

    vi ans(N+1, 0);
    for (int x = 1; x <= 100; ++x)
    {
        for (int y = 1; y <= 100; ++y)
        {
            for (int z = 1; z <= 100; ++z)
            {
                int n = g(x, y, z);
                if (n <= N) ++ans[n];
            }
        }
    }

    for (int i = 1; i <= N; i++)
        io << ans[i] << BR;
    
}


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

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	int a;
	string s;
	cin >> a >> s;
	if(a >= 3200) cout << s << endl;
	else cout << "red" << endl;
	return 0;
}

Measured memory_bytes: 384