akhauriyash/Code-Regression huggingface dataset:
def triangle?(a, b, c)
    return false if a + b <= c
    true
end

sankaku = 0
eikaku = 0
chokaku = 0
donkaku = 0

loop do
    line = gets
    if line == "\n"
        break;
    end

    a, b, c = line.split.map(&:to_i).sort

    if !triangle?(a, b, c)
        puts "#{sankaku} #{chokaku} #{eikaku} #{donkaku}"
        break;
    end

    sankaku += 1
    if a**2 + b**2 > c **2
        eikaku += 1
    elsif a**2 + b**2 == c **2
        chokaku += 1
    else
        donkaku += 1
    end
end



Measured memory_bytes: 6864
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(ll i=0;i<(n);++i)
#define Fr(i,n) for(long long i=1;i<=(n);++i)
#define ifr(i,n) for(long long i=(n)-1;i>=0;--i)
#define iFr(i,n) for(long long i=(n);i>0;--i)

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n;
  double ans,c;
  cin>>n;
  c=1;
  ans=0;
  double coo[n][2];
  double arr[n][n-1];
  c=n;

  fr(i,n){
    double a,b;
    cin>>a>>b;
    coo[i][0]=a;
    coo[i][1]=b;
  }
  fr(i,n){
    for(long long l=n-1;l>i;--l){
      ans+=2*pow(pow(coo[i][0]-coo[l][0],2.0)+pow(coo[i][1]-coo[l][1],2.0),0.5)/c;
    }
  }
  cout<< fixed << setprecision(10) << ans;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static readonly int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//string s = Console.ReadLine();
			//int h = int.Parse(Console.ReadLine());
			//long h = long.Parse(Console.ReadLine());
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			int h = vs[0];
			int n = vs[1];
			int[][] magic = new int[n][];
			for (int i = 0; i < n; i++) {
				magic[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
			}

			int[] dp = new int[h + 1];
			for (int j = 0; j < dp.Length; j++) {
				if (j == 0 || dp[j] != 0) {
					for (int i = 0; i < n; i++) {
						int dmg = j + magic[i][0];
						if (dmg >= dp.Length) {
							dmg = dp.Length - 1;
						}
						int mp = dp[j] + magic[i][1];
						if (dp[dmg] == 0 || dp[dmg] > mp) {
							dp[dmg] = mp;
						}
						//System.Diagnostics.Debug.WriteLine($"{j}-{i}:{string.Join(",", dp)}");
					}
				}
			}
			Console.WriteLine(dp[h]);


			Console.Out.Flush();
		}
	}
}


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

int main(int argc, char *argv[])
{
	int i;
	int N, M;
	int tmpD;
	cin >> N >> M;

	tmpD = M / N;
	for (i = tmpD; i >= 1; i--) {
		if (M % i == 0) {
			cout << i << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
while True:
  n,p=map(int,input().split())
  if n==0 and p==0:
    break
  count=[0 for i in range(n)]
  wan=p
  while True:
    if max(count)==p:
      break
    for i in range(n):
      if count[i]>=0 and wan>0:
        count[i]+=1
        wan-=1
      elif count[i]==0 and wan==0:
        pass
      elif count[i]>0 and wan==0:
        wan+=count[i]
        count[i]=0
  for i in range(len(count)):
    if count[i]!=0:
      tousen=i
  print(tousen)


Measured memory_bytes: 5596
from collections import deque
import sys

stack = deque()

def linked_list(stack,command,x=None):

    if command == "insert":#stackの左端にxを追加
        stack.appendleft(x)

    elif command == "delete":#左端から数えて最初のxを削除
        try:
            stack.remove(x)
        except:
            pass

    elif command == "deleteFirst":#左端の要素を削除
        stack.popleft()

    elif command == "deleteLast":#右端の要素を削除
        stack.pop() 


N = int(input())
#lst = [l.split() for l in sys.stdin.readlines()]
#print(lst)
for i in range(N):

    #print(i)
    input_command = input()


    if input_command == "deleteFirst":#左端の要素を削除
        stack.popleft()

    elif input_command == "deleteLast":#右端の要素を削除
        stack.pop() 

    else:
        command,x = input_command.split()
        if command == "insert":#stackの左端にxを追加
            stack.appendleft(x)

        elif command == "delete":#左端から数えて最初のxを削除
            try:
                stack.remove(x)
            except:
                pass

print(" ".join(map(str,stack)))


Measured memory_bytes: 69812
#include <bits/stdc++.h>
#include<string.h>
#define ll long long 
#include<vector>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int mod=1e9+7;
void add_self(int &a, int b){
	a+=b;
	if(a>=mod)
	a-=mod;
}
int main(){
	
	string k;
	int d;
	//cout<<"hey";
	cin>>k;
	cin>>d;
	
     int n=k.length();
     vector<vector<int> > dp=vector<vector<int> > (d,vector<int>(2));
     dp[0][1]=1;
     for(int where=0;where<n;where++){
     	//if it is tight my value willl go upto s[where] else my value will go upto 9
     	vector<vector<int> > new_dp=vector<vector<int> > (d,vector<int>(2));
     	for(int rem=0;rem<d;rem++)
     	{
          for(int tight=0;tight<2;tight++){
          	int my_limit=9;
          	if(tight) my_limit=k[where]-'0';
          	for(int my_digit=0;my_digit<=my_limit;my_digit++){
          		add_self(new_dp[(rem+my_digit)%d][tight&(my_digit==(k[where]-'0'))], dp[rem][tight]);
				 }
		  }
		 }
		 dp=new_dp;
		 /*cout<<where<<endl;
		 for(int i=0;i<d;i++){
		 	for(int tight=0;tight<2;tight++){
		 		cout<<dp[i][tight]<<" ";
			 }
			 cout<<endl;
		 }*/
	 }
	    ll ans=(dp[0][0]+dp[0][1]-1+mod)%mod;
	    cout<<ans;
	 	//cout<<(dp[0][0]+dp[0][1]-1)%mod;
		 
	}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>

using namespace std;


int main()
{
	int N;
	vector<int> list;

	cin >> N;	

	int n;
	for (int ni = 0; ni < N; ni++){
		cin >> n;
		list.push_back(n);
	}

	int ans = 0;
	for (int ni = 1; ni < N- 1; ni++){
		if (list[ni-1] < list[ni] && list[ni] < list[ni+1]) ans++;
		if (list[ni-1] > list[ni] && list[ni] > list[ni+1]) ans++;
	}

	printf("%d",ans);


	return 0;
}



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


def solve(N: int, X: "List[float]", U: "List[str]"):
    money = 0

    for x,u in zip(X,U):
        xx = x
        if u == "BTC":
            xx = x*380000.0

        money += xx
    
    print(money)



# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [float()] * (N)  # type: "List[float]" 
    u = [str()] * (N)  # type: "List[str]" 
    for i in range(N):
        x[i] = float(next(tokens))
        u[i] = next(tokens)
    solve(N, x, u)

if __name__ == '__main__':
    main()


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

int main() {
  
  int A=0, B=0, C=0, D=0;
  int area1=0, area2=0;
  
  cin >> A >> B >> C >> D;
  
  area1 = A * B;
  area2 = C * D;
  
  if( area1 < area2 ){
    
    cout << area2 << endl;
    
  } else if( area2 < area1 ){
    
    cout << area1 << endl;
    
  } else if( area1 == area2 ){
    
    cout << area1 << endl;
    
  }
  
  return 0;
  
}

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif


template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

#endif


void solve(){
    int N;
    cin >> N;
    vector<int> X(N);
    rep(i,N) cin >> X[i];
    
    int ans = INF;
    for(int p=1; p<=100; p++){
        int t = 0;
        rep(i,N) t += (X[i] - p) * (X[i] - p);
        ans = min(ans, t);
    }
    cout << ans << endl;
}

signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


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

const int MAXN = (int)2e5;
int N;
bool A[30][MAXN], B[30][MAXN];
int ans[30][MAXN];

vector<int> prefix_function(int idx) {
    vector<int> pi(N);
    for (int i = 1; i < N; i++) {
        int j = pi[i - 1];
        while (j > 0 && A[idx][j] != A[idx][i])
            j = pi[j - 1];
        if (A[idx][i] == A[idx][j])
            j++;
        pi[i] = j;
    }
    return pi;
}

void kmp(int idx, vector<int>& prefix, bool reverse = false) {
    int match = 0;
    for (int i = 0; i < 2 * N - 1; i++) {
        while (match > 0 && A[idx][match] != reverse ^ B[idx][i % N])
            match = prefix[match - 1];
        if (A[idx][match] == reverse ^ B[idx][i % N])
            match++;
        if (match == N) {
            ans[idx][i - N + 1] = reverse;
            match = prefix[match - 1]; 
        }
    }
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        for (int j = 0; a > 0; a >>= 1, j++)
            A[j][i] = a % 2;
    }
    for (int i = 0; i < N; i++) {
        int b;
        cin >> b;
        for (int j = 0; b > 0; b >>= 1, j++)
            B[j][i] = b % 2;
    }

    fill(&ans[0][0], &ans[29][MAXN], -1);
    for (int i = 0; i < 30; i++) {
        vector<int> prefix = prefix_function(i);
        kmp(i, prefix, false);
        kmp(i, prefix, true);
    }

    for (int i = N; i > 0; i--) {
        bool flag = ans[0][i % N] >= 0;
        for (int j = 1; j < 30; j++) {
            if (ans[j][i % N] < 0)
                flag = false;
        }
        if (flag) {
            int x = 0;
            for (int j = 29; j >= 0; j--) {
                x |= ans[j][i % N];
                if (j > 0)
                    x <<= 1;
            }
            cout << (N - i) << " " << x << endl;
        }
    }
}

Measured memory_bytes: 39024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int D;
  cin>>D;
  VL C(26);
  rep(i,26) cin>>C[i];
  VVL S(D,VL(26));
  rep(i,D) rep(j,26) cin>>S[i][j];
  VPL P(26);
  rep(i,26) P[i]=mp(-C[i],i+1);
  sort(all(P));
  rep(i,D){
    ll X=0;
    rep(j,26) if(S[i][X]<S[i][j]) X=j;
    if(i%3==2) cout<<P[i/3%5].second<<endl;
    else cout<<X+1<<endl;
  }
}


Measured memory_bytes: 3744
import std.stdio;
import std.string;
import std.math;
import std.conv;
import std.algorithm;
import std.bigint;

void main(){

    int[10][10] map;
    while(true){
	auto s = split(chomp(readln()),',');
	if(stdin.eof()) break;
	int x,y,size;
	x = to!int(s[0]);
	y = to!int(s[1]);
	size = to!int(s[2]);

	if(size >0){
	    auto d = [1,0,-1,0 ,0];
	    auto d1 = [0,1,0,-1,0];
	    for(int i=0;i<5;i++){
		if(0 <= d[i] + x &&  d[i] + x < 10 && 0 <= d1[i] + y &&  d1[i] + y < 10){
		    map[d[i] + x][d1[i] + y]++;
		}
	    }
	}
	size--;
	if(size>0){
	    auto d = [ 1,-1];
	    for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
		    if(0 <= d[i] + x &&  d[i] + x < 10 && 0 <= d[j] + y &&  d[j] + y < 10){
			map[d[i] + x][d[j] + y]++;
		    }
		}
	    }
	}
	size--;
	if(size>0){
	    auto d = [2,0,-2,0,0];
	    auto d1 = [0,2,0,-2,0];
	    for(int i=0;i<5;i++){
		if(0 <= d[i] + x &&  d[i] + x < 10 && 0 <= d1[i] + y &&  d1[i] + y < 10){
		    map[d[i] + x][d1[i] + y]++;
		}
	    }
	}
    }
    int ans1 = 0,ans2=0;
    for(int i=0;i<10;i++){
	for(int j=0;j<10;j++){
	    if(map[i][j] == 0) ans1++;
	    ans2 = max(map[i][j] , ans2);
	}
    }
    writeln(ans1);
    writeln(ans2);
}

Measured memory_bytes: 2384
#include <iostream>

using namespace std;

long long n, tmp;
long long ret = 1e18;


int main(){


    cin >> n;

    for(long long i = 1; i*i <= n; i++){
        if(n % i == 0){
            tmp = i + n / i - 2;
            if(tmp < ret)
                ret = tmp;
        }
    }

    cout << ret;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
double eps=1e-7;
bool eq(double a,double b){return (b-a<eps&&a-b<eps);}
double cross(P a,P b){return imag(b*conj(a));}
double dot(P a,P b){return real(b*conj(a));}
P project(P a,P b,P c){b-=a;c-=a;return a+b*real(c/b);}
P reflect(P a,P b,P c){b-=a;c-=a;return a+conj(c/b)*b;}
int ccw(P a,P b,P c){
  b-=a,c-=a,a=c*conj(b);
  if(a.imag()>eps)return 1;//ccw
  if(a.imag()<-eps)return -1;//cw
  if(a.real()<-eps)return 2;//ob
  if(abs(b)+eps<abs(c))return -2;//of
  return 0;//os
}

//segment ab , point c
double dist(P a,P b,P c){
  if(dot(b-a,c-a)<0)return abs(c-a);
  if(dot(a-b,c-b)<0)return abs(c-b);
  return abs(cross(b-a,c-a))/abs(b-a);
}

bool isintersect(P a,P b,P c,P d){
  return ((ccw(a,b,c)*ccw(a,b,d)<=0)&&(ccw(c,d,a)*ccw(c,d,b)<=0));
}

//segment ab , segment cd
P intersect(P a,P b,P c,P d){
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}

double dist(P a,P b,P c,P d){
  if(isintersect(a,b,c,d))return 0;
  double ab=min(dist(a,b,c),dist(a,b,d));
  double cd=min(dist(c,d,a),dist(c,d,b));
  return min(ab,cd);
}

int main(){
  int T;
  cin>>T;
  while(T--){
    double ax,ay,bx,by,cx,cy,dx,dy;
    cin>>ax>>ay>>bx>>by>>cx>>cy>>dx>>dy;  
    printf("%.12f\n",dist( P(ax,ay) , P(bx,by) , P(cx,cy) , P(dx,dy) ) );
  }
}

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

int main(void){
  string s;
  cin >> s;
  if(s == "Sunny") {
    cout << "Cloudy" << endl;
  } else if(s == "Cloudy"){
    cout << "Rainy" << endl;
  } else {
    cout << " Sunny" << endl;
  }
 return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,k;
  cin>>n>>k;
  vecint p(n);
  REP(i,n) cin>>p[i];
  sort(ALL(p));
  int ans = 0;
  REP(i,k) ans += p[i];
  cout<<ans<<endl;
  return 0;
}


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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    freopen ("in.txt", "r", stdin);
#endif
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;cin>>n;
    int h;cin>>h;
    --h;
    for(int i=1;i<n;++i){
        int h2;cin>>h2;
        if (h2<h) {cout << "No";return 0;}
        h=max(h,h2-1);
    }
    cout << "Yes";
    return 0;
}



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

int main() {
	int N;
	cin >> N;
	vector<int> vec(N);
	for (int i = 0; i < N; i++) {
		cin >> vec.at(i);
	}
	int sum = 0;
	for (int i = 0; i < N; i++) {
		sum += vec.at(i);
	}
	int mini = sum;
	for (int i = 0; i < N; i++) {
		sum -= 2 * vec.at(i);
		if (sum > 0) {
			mini = min(mini, sum);
		}
		else {
			mini = min(mini, -sum);
		}
	}
	cout << mini << endl;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n, k;
	cin >> n >> k;

	string s;
	cin >> s;

	int score = 0;
	for (int i = 0; i < n - 1; i++) {
		if (s[i] == s[i + 1]) {
			score++;
		}
	}

	int ans = min(score + 2 * k, n - 1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

#define N 600000
#define NIL -1

//array
int key[N];
int parent[N];
int leftc[N];
int rightc[N];
//root
int root=NIL;
//function insert
void insert(int z){
  int x,y;
  
  y=NIL;
  x=root;

  while(x!=NIL){
    y=x;
    if(key[z]<key[x]) x=leftc[x];
    else x=rightc[x];
  }  
  
  parent[z]=y;

  if(y==NIL) root=z;
    
  else if(key[z]<key[y]) leftc[y]=z;

  else rightc[y]=z;
  
  
}

//function search
int find(int now,int data){
  if(now==NIL||data==key[now]) return now;
  if(data<key[now]) return find(leftc[now],data);
  else return find(rightc[now],data);
}

//print
void inorderprint(int now){
  if(now!=NIL){
    inorderprint(leftc[now]);
    printf(" %d",key[now]);
    inorderprint(rightc[now]);
  }
}

void preorderprint(int now){
  if(now!=NIL){
    printf(" %d",key[now]);
    preorderprint(leftc[now]);
    preorderprint(rightc[now]);
  }
}



int main(){

  int n,i,j,data;
  int z=0;
  char str[10];
  //initialize array
  for(i=0;i<N;i++){
    parent[i]=NIL;
    key[i]=NIL;
    rightc[i]=NIL;
    leftc[i]=NIL;
  }
  //load n
  scanf("%d",&n);
  //load commnad and key
  for(i=0;i<n;i++){
    scanf("%s",str);
    if(strcmp(str,"insert")==0) {
      scanf("%d",&data);
      key[z]=data;
      insert(z);
      z++;
    }
    else if(strcmp(str,"find")==0){
      scanf("%d",&data);
      if(find(root,data)!=NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(strcmp(str,"print")==0){
      inorderprint(root);
      cout <<endl;
      preorderprint(root);
      cout <<endl;
    }
  }

  return 0;
}

Measured memory_bytes: 10000
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto HS = readln.split.to!(int[]);

    int c, max_c;
    foreach_reverse (i; 0..N) {
        if (i+1 == N) continue;
        if (HS[i] >= HS[i+1]) {
            ++c;
        } else {
            max_c = max(c, max_c);
            c = 0;
        }
    }
    writeln(max(c, max_c));
}

Measured memory_bytes: 4348
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define nav(...) "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
#define oo INT_MAX/2
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
template<class T> struct rge { T b, e; };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
	~debug() {cout<<endl;}
	template<class T> debug& operator<<(T x) {cout<<boolalpha<<x; return *this;}
	template<class B, class C> debug& operator<< (pair<B, C> x){return *this<<"("<<x.first<<", "<<x.second<<")";}
	template<class T> debug& operator<<(rge<T> x) {
		*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}return *this<<"]";}
	template<class T> debug& operator<<(vector<T> x){ return *this<<range(all(x));}
};


bool solve(void) {

	
	return true;
}

int main(int argc, char* argv[]) {

	int k, x;
	scanf("%d%d", &k, &x);
	puts(500*k >= x ? "Yes" : "No");

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

#define ll long long
#define maxn 52
#define MOD 1000000007

char a[maxn + 1], b[maxn + 1];
int v[maxn + 1];

int main() {
    int n;
    scanf("%d", &n);
    char ch = fgetc(stdin);
    for (int i = 1; i <= n; i++) {
        a[i] = fgetc(stdin);
    }
    ch = fgetc(stdin);
    for (int i = 1; i <= n; i++) {
        b[i] = fgetc(stdin);
    }
    int i = 1, j = 1;
    while (i <= n) {
        if (a[i] == b[i])
            v[j] = 1;
        else {
            v[j] = 2;
            i++;
        }
        j++;
        i++;
    }
    ll rez = 1;
    if (v[1] == 1)
        rez = rez * 3;
    else if (v[1] == 2)
        rez = rez * 6;
    for (int i = 2; i <= j - 1; i++) {
        if (v[i - 1] == 1 && v[i] == 1)
            rez = rez * 2 % MOD;
        else if (v[i - 1] == 1 && v[i] == 2)
            rez = rez * 2 % MOD;
        else if (v[i - 1] == 2 && v[i] == 1)
            rez = rez * 1 % MOD;
        else if (v[i - 1] == 2 && v[i] == 2)
            rez = rez * 3 % MOD;
    }
    printf("%lld", rez);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#define FOR(i,a,n) for (int i = a; i < n; i++)
#define IFOR(i,n,a) for (int i = n; i >= a; i--)
#define mp make_pair
#define full(a) a.begin(), a.end()
#define SZ(x) ((int)(x).size())
#define TC(tc) while (tc--)
#define VI vector<int>
#define PII pair<int, int>
#define trav(a,x) for (auto& a : x)
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
using namespace std;
const int mod = 1e9 + 7;
const ull num = 1e18;

int main()
{
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int x, y; cin >> x >> y;
	if (y & 1 || y <= x)
	{
		cout << "No";
		return 0;
	}
	int b = -((2 * x - y) / 2);
	if (b < 0 || b > x)
	{
		cout << "No";
		return 0;
	}
	cout << "Yes";
	return 0;
}

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

using namespace std;

int main(){
  int x,y,k;
  int i;
  vector <int> v;
  
  cin>>x>>y>>k;
  for(i=1;i<=min({x,y});i++){
    if(x%i==0&&y%i==0)
      v.push_back(i);
  }
  sort(v.begin(),v.end(),greater<int>());
  cout<<v[k-1]<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
int m,d,ans;
int main(){
	m=read(),d=read();
	for(int i=1;i<=m;i++)
		for(int j=22;j<=d;j++)
			if(j%10>=2 and (j/10)*(j%10)==i)ans++;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import kotlin.math.pow

fun solve(x: Long, n: Long): Pair<Long, Long> {
    for (a in 0L..n) {
        for (b in 0L..n) {
            val a5 = a.toDouble().pow(5).toLong()
            val b5 = b.toDouble().pow(5).toLong()

            if (a5 - b5 == x) return a to b
            if (a5 + b5 == x) return a to -b
        }
    }
    throw Exception("$x $n")
}

fun main() {
    val x = readLine()!!.toLong()
    val (a, b) = solve(x, 1000)
    println("$a $b")
}


Measured memory_bytes: 34644
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		long a[] = new long[3];

		for(int i = 0; i < 3; i++){
			a[i] = sc.nextInt();

			if(a[i] % 2 == 1){
				System.out.println(0);
				return;
			}
		}

//		Arrays.sort(a);

		if(a[2] == a[1] && a[1] == a[0]){
			System.out.println(-1);
			return;
		}

		int count = 0;

		while(true){
			if(a[0] % 2 == 1 || a[1] % 2 == 1 || a[2] % 2 == 1){
				break;
			}
			count++;

			long s = a[0];
			long t = a[1];
			long u = a[2];

			a[0] = (t + u)/2;
			a[1] = (s + u)/2;
			a[2] = (s + t)/2;
		}

		System.out.println(count);

	}
}


Measured memory_bytes: 26956
import java.util.Scanner;

public class Main {
	String [] words = new String[100];
	int f,b;
	private Scanner kb;
	public void process() {
		kb = new Scanner(System.in);
		String S = kb.next();
		
		for(int i=0; i<4; i++) {
			words[i] = S.substring(i,i+1);
		}
		f = Integer.parseInt(words[0])*10 + Integer.parseInt(words[1]);
		b = Integer.parseInt(words[2])*10 + Integer.parseInt(words[3]);
		if(f>0 && f<=12 && b>0 && b<=12)
			System.out.println("AMBIGUOUS");
		else if(f>0 && f<=12)
			System.out.println("MMYY");
		else if(b>0 && b<=12)
			System.out.println("YYMM");
		else
			System.out.println("NA");
	}

	public static void main(String [] args) {
		Main app = new Main();
		app.process();
	}
}


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

int main() {
	int h, n, a;
	cin >> h >> n;
	for (int i = 0; i < n; i++) {
		a = 0;
		cin >> a;
		h -= a;
	}
	if (h <= 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    string s;
    cin >> s;
    s[5] = ' ';
    s[13] = ' ';
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3608
A = []
for _ in range(3):
    a = list(map(int, input().split()))
    A.append(a)

N = int(input())
Bn = set([int(input()) for _ in range(N)])

for b in Bn:
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                A[i][j] = 0

ans = False
if A[0][0] == A[1][1] == A[2][2] == 0:
    ans = True

if A[0][2] == A[1][1] == A[2][0] == 0:
    ans = True

# col
for i in range(3):
    cnt = 0
    for j in range(3):
        if A[j][i] == 0:
            cnt += 1
    if cnt == 3:
        ans = True

# row
for i in range(3):
    cnt = 0
    for j in range(3):
        if A[i][j] == 0:
            cnt += 1
    if cnt == 3:
        ans = True

print("Yes" if ans else "No")


Measured memory_bytes: 3064
a = int(input())
height_list = input().split()
int_height = []
for i in range(a):
    b = int(height_list[i])
    int_height.append(b)

count = 0 
for i in range(a):
    if max(int_height[:i+1]) == int_height[i]:
        count += 1
        


print(count)

Measured memory_bytes: 3060
PROGRAM ATCODER

implicit none
integer(16) :: n,t(1:5),ans

read*, n,t(1:5)

ans = n/minval(t)

if ( mod(n,minval(t)) /= 0 ) then
  ans = ans + 1
end if

print'(i0)', 5 + ans - 1 

contains

END PROGRAM ATCODER

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int a1,a2,a3;
    cin >> a1  >>a2 >> a3;

    if(a1 + a2 + a3 >= 22) {
    cout << "bust" << endl;
    }
    else {
    cout << "win" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main (){

  int  data[100000];
  int max,min;
  int n,num,i;
  long long sum=0;

  scanf("%d",&num);



 for(i=0;i<num;i++){

   scanf("%d",&data[i]);

 
  sum += data[i];
 }

 max = data[0];
 min = data[0];
 for(i=0;i<num;i++){

   if(max < data[i])
     max = data[i];
 if(min > data[i])
   min = data[i];
 }


 printf("%d %d %lld\n",min,max,sum);

 return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>*/
 
#define pb push_back
#define mp make_pair
#define sz(s) ((int)(s.size()))
#define all(s) s.begin(), s.end()
#define rep(i, a, n) for (int i = a; i <= n; ++i)
#define per(i, n, a) for (int i = n; i >= a; --i)
#define onlycin ios_base::sync_with_stdio(false); cin.tie(0) 
using namespace std;
// using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
/*typedef tree<
pair < int, int >,
null_type,
less< pair < int, int > >,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;*/
// find_by_order() order_of_key()
const int MAXN = (int)5e5+228;
const char nxtl = '\n';
const int mod = (int)1e9+7;
const double eps = (double)1e-7;
template<typename T> inline bool updmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
template<typename T> inline bool updmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}
#define int long long
int n, m, cnt[2][MAXN];
ll dp[2][MAXN];
vector < pair < int, int > > g[MAXN];

void go(int type, int x) {
	set < pair < int, int > > S;
	rep(i, 0, n) dp[type][i] = (ll)1e15;
	dp[type][x] = 0;
	cnt[type][x] = 1;
	S.insert(mp(0, x));
	while(!S.empty()) {
		int v = S.begin()->second; S.erase(S.begin());
		for(auto &it : g[v]) {
			int to = it.first; ll D = dp[type][v] + it.second;
			if(D < dp[type][to]) {
				S.erase(mp(dp[type][to], to));
				dp[type][to] = D;
				cnt[type][to] = cnt[type][v];
				S.insert(mp(dp[type][to], to));
			} else if(D == dp[type][to]) {
				(cnt[type][to] += cnt[type][v]) %= mod;
			}
		}
	}
}
int get(int x) {
	return x *1ll * x % mod;
}

signed main() {
	#ifdef accepted
		freopen(".in", "r", stdin);
		freopen(".out", "w", stdout);
	#endif
	onlycin;
	cin >> n >> m;
	int x, y; cin >> x >> y;
	rep(i, 1, m) {
		int from, to, w; cin >> from >> to >> w;
		g[from].pb(mp(to, w));
		g[to].pb(mp(from, w));
	}
	go(0, x); go(1, y);
	int res = get(cnt[0][y]);
	cerr << res << nxtl;
	rep(i, 1, n) {
		if(dp[0][i] * 2 == dp[0][y] && dp[1][i] * 2 == dp[0][y]) {
			res = (res - (get(cnt[1][i] * 1ll * cnt[0][i] % mod) % mod) + mod) % mod;
			// cerr << get(cnt[1][i] * 1ll * cnt[0][i] % mod) << nxtl;
			// continue;
	 	}
		rep(j, 0, sz(g[i]) - 1) {
			// if(g[i][j].first == y || g[i][j].first == x) continue;
			int to = g[i][j].first, ww = g[i][j].second;
			if(dp[0][i] + dp[1][to] + ww == dp[0][y] && dp[0][i] *2 < dp[0][y] && dp[1][to] *2 < dp[0][y])
				res = (res - get(cnt[0][i] * 1ll * cnt[1][to] % mod) + mod) % mod;
		}
	}
	cout << res % mod << nxtl;
	return 0;
}

Measured memory_bytes: 38256
l = []
def pl(m):
    for i in range(len(l)):
        print str(l[i]),
    print str(m)
def rfunc(n,lim):
    if n<=lim: pl(n)
    for i in range(1,n):
        if(i<n-lim):continue
        l.append(n-i)
        rfunc(i, n-i)
        l.pop()
while(1):
    m = int(raw_input())
    if m==0: break
    rfunc(m,m)

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


int N, T, A;
int H[1010]; 
int Z[1010];        // 最大 200 個なので余裕を持って 210 に --- 200 以上ならなんでもよいです

int abss(int i){
    if(i >= 0)return i;
    else return -i;
}

int main() {
    cin >> N >> T >> A;
    int min = 50000000;
    int solve = -1;

    for (int i = 0; i < N; ++i){
        cin >> H[i];
        Z[i] = abss((1000 * T - 6 * H[i]) - 1000 * A);
        if(min >= Z[i]){
            min = Z[i];
            solve = i;
        }
    } 

    
    cout << solve + 1 << endl;

}

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

int main() {
    int N;
    cin >> N;
    vector<vector<int>> A(2, vector<int>(N));
    for (int i = 0; i < 2; ++i){
        for (int j = 0; j < N; ++j ){
            cin >> A.at(i).at(j);
        }
    }
    
    
    int res = 0;
    for (int i = 0 ; i < N ; ++i ){
        int total = 0;
        for (int j = 0; j <= i; ++j ){
            total += A.at(0).at(j);
        }
        for (int k = i; k < N ; ++k ){
            total += A.at(1).at(k);
        }
        res = max(res,total);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	
	int b[3];

	while (cin >> b[0] >> b[1] >> b[2]) {

		string check;
		check.clear();

		for (int i = 0; i < 3; i++) {

			if (b[i])
				check += '1';
			else
				check += '0';

		}

		if (check == "110" || check == "001")
			cout << "Open\n";

		else
			cout << "Close\n";

	}
	
	return 0;

}







Measured memory_bytes: 3180
#include<iostream>
using namespace std;
int main(int argc, char const *argv[])
{
   int A, B;
   cin >> A >> B;
   if( A < 10  &&  B < 10)
   {
      cout << A*B << endl;
   }
   else
   {
         cout << "-1" << endl;
   }
   return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main{
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		int N=sc.nextInt();
		int X=sc.nextInt();
		int[] L=new int[N+1];
		for(int i=1; i<=N; i++) {
			L[i]=sc.nextInt();
		}
		for(int i=1; i<=N; i++) {
			L[i]=L[i]+L[i-1];
		}
		int ans=0;
		for(int i=0; i<=N; i++) {
			if(X>=L[i]) {
				ans++;
			}
		}
		pl(ans);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}


Measured memory_bytes: 21204
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

//# include <ext/pb_ds/assoc_container.hpp>
//# include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;
using namespace std;
 
//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;
//	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//	shuffle(permutation.begin(), permutation.end(), rng);



int main () {
	SpeedForce;
	cin >> n;
	int x, y;
	cin >> x >> y;

	for (int i = 1; i <= n; ++i) {
		for (int j = i + 1; j <= n; ++j) {
			res = abs(i-j);
			res = min(abs(i-x) + abs(y-j) + 1, res);
			res = min(abs(i-y) + abs(x-j) + 1, res);
			a[res]++;
		}
	}

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


	return Accepted;
}

// B...a

Measured memory_bytes: 18688
//
// Created by tac on 2016/10/15.
//

#include <cstdlib>
#include <string>
#include <iostream>

namespace {

const size_t ALPHA_SIZE = 26;

}

int main() {
    int count_char[ALPHA_SIZE] {};
    std::string str;

    while (true) {
        if (std::cin.eof()) {
            break;
        }
        getline(std::cin, str);
        for (auto c: str) {
            if (isalpha(c)) {
                int i = toupper(c) - 'A';
                count_char[i] += 1;
            }
        }
    }

    for (int i = 0; i < ALPHA_SIZE; ++i) {
        char c = i + 'a';
        std::cout << c << " : " << count_char[i] << std::endl;
    }

    return EXIT_SUCCESS;
}

Measured memory_bytes: 3132
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path;
int main() {
	ll R, G, B, N;
	cin >> R >> G >> B >> N;
	for (i = 0; i <= N; i++) {
		for (j = 0; j <= N; j++) {
			if ((R*i+G*j)<=N && (N - i * R - j * G) % B == 0) ans++;
			//debug(i, j,ans);
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

// O( ( |V| + |E| ) * log|V| )
const int W = 0, B = 1;
//重み付き有効グラフの隣接リスト表現
vector<vector<int>> dijkstra(const vector<vector<pair<int, int>>> &g, int s) {
	int n = g.size();
	priority_queue<pair<int, int>>pq;// cost, node
	vector<int>color(n, W), d(n, INF);
	d[s] = 0;
	pq.push(make_pair(0, s));

	while (!pq.empty()) {
		pair<int, int>f(pq.top()); pq.pop();// d[v], v
		color[f.second] = B;

		if (d[f.second] < (-1)*f.first)continue; // 最小値を取り出し、それが最短でなければ無視

		rep(i, 0, g[f.second].size()) {
			pair<int, int>v(g[f.second][i]);
			if (color[v.first] != B&&d[f.second] + v.second < d[v.first]) {
				d[v.first] = d[f.second] + v.second;
				pq.push(make_pair(d[v.first] * (-1), v.first)); // priority_queueはデフォルトで大きい値を優先するため-1を掛ける
			}
		}
	}

	vector < vector<int>>ret(11);
	rep(i, 0, n) {
		if (0 <= d[i] && d[i] <= 10)ret[d[i]].emplace_back(i);
	}
	return ret;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M; cin >> N >> M;

	vector<vector<int>> adj(N);
	rep(i, 0, M) {
		int a, b; cin >> a >> b; a--, b--;
		// vは頂点の番号、cは有効辺の重み
		adj[a].push_back(b);
		adj[b].push_back(a);
	}

	vector<int>color(N, 0);
	int Q; cin >> Q;
	vector<int>v(Q), d(Q), c(Q);
	rep(i, 0, Q) {
		cin >> v[i] >> d[i] >> c[i];
		v[i]--;
	}
	reverse(all(v)); reverse(all(d)); reverse(all(c));
	static bool dp[100010][11]; memset(dp, 0, sizeof(dp));
	function<void(int, int, int)>dfs = [&](int v, int d, int c) {
		if (dp[v][d])return;
		dp[v][d] = true;
		if (d == 0) {
			color[v] = c;
			dump(color);
			return;
		}
		dfs(v, d - 1, c);
		rep(i, 0, adj[v].size())dfs(adj[v][i], d - 1, c);

	};

	rep(i, 0, Q)dfs(v[i], d[i], c[i]);

	rep(i, 0, N)cout << color[i] << endl;

	return 0;
}

Measured memory_bytes: 9208
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define LINF (ll)1e17
#define INF 1e9
#define MOD 1e9+7
#define sMOD 1e5
#define fs first
#define sc second


signed main(){
	
	ll a,b,c;
	cin >> a >> b >> c;
	
	if(a+b >= c) cout << b+c << endl;
	else cout << a+b+b+1 << endl;
	
	return 0;

}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int h,w; 
int l[200010],r[200010];
struct tree{
	int l,r;
	long long tag,v;
}tr[2][4*200010];
void build(int i,int l,int r)
{
	tr[0][i].l=l,tr[0][i].r=r;
	if (l==r) return;
	int mid=(l+r)>>1;
	build(i<<1,l,mid);
	build(i<<1|1,mid+1,r);
}
void update(int i,int id)
{
	tr[id][i].v=min(tr[id][i<<1].v,tr[id][i<<1|1].v);
}
void build2(int i,int l,int r)
{
	tr[1][i].l=l,tr[1][i].r=r;
	
	if (l==r) {tr[1][i].v=-l;return;}
	int mid=(l+r)>>1;
	build2(i<<1,l,mid);
	build2(i<<1|1,mid+1,r);
	update(i,1);
}
void add(int i,long long x,int id)
{
	//if (id==0&&tr[id][i].l==2&&tr[id][i].l==tr[id][i].r)
	//	cout<<tr[id][i].v<<" "<<x<<" tree"<<endl;
	tr[id][i].v+=x;
	tr[id][i].tag+=x;
}
void pushdown(int i,int id)
{
	if (tr[id][i].tag)
	{
		add(i<<1,tr[id][i].tag,id);
		add(i<<1|1,tr[id][i].tag,id);
		tr[id][i].tag=0;
	}
}
void modify(int i,int l,int r,long long x,int id)
{
	int L=tr[id][i].l,R=tr[id][i].r;
	if (l>R) return;
	if (l<=L&&R<=r)
	{
		add(i,x,id);
		return;
	}
	pushdown(i,id);
	int mid=(L+R)>>1;
	if (l<=mid) modify(i<<1,l,r,x,id);
	if (r>mid) modify(i<<1|1,l,r,x,id);
	update(i,id); 
}
long long query(int i,int l,int r,int id)
{
	int L=tr[id][i].l,R=tr[id][i].r;
	if (l>R) return 0;
	//cout<<l<<" "<<r<<" "<<L<<" "<<R<<" "<<tr[id][i].v<<endl; 
	if (l<=L&&R<=r) return tr[id][i].v; 
	pushdown(i,id);
	int mid=(L+R)>>1;
	long long maxn=1e18;
	if (l<=mid) maxn=min(maxn,query(i<<1,l,r,id));
	if (r>mid) maxn=min(maxn,query(i<<1|1,l,r,id));
	return maxn;
}
int main()
{
	scanf("%d%d",&h,&w);
	for (int i=1;i<=h;i++)
		scanf("%d%d",&l[i],&r[i]);
	build(1,1,w);build2(1,1,w);
	for (int i=1;i<=h;i++)
	{
		long long other=min(0ll,r[i]+1+query(1,1,r[i],1)-query(1,r[i]+1,r[i]+1,0));
		modify(1,r[i]+1,r[i]+1,other,0);
		modify(1,r[i]+1,r[i]+1,other,1);
		
		modify(1,l[i],r[i],1e9,0);
		modify(1,l[i],r[i],1e9,1);
		
		modify(1,1,w,1,0);
		modify(1,1,w,1,1);
		long long ans=query(1,1,w,0);
		if (ans>=1e9) printf("-1\n");
		else printf("%d\n",ans);
	}
}


Measured memory_bytes: 29804
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string  S, ans;
  int n, m;
  cin >> S;
  ans = "Yes";
  n = S.size();
  m = (n-1)/2;
  
  for(int i=0; i < m; i++){
    if(S[i] != S[n-1-i]){
      ans = "No";
      break;
    }
  }

  if(ans == "Yes"){
    if(m%2 == 0){
      for(int i=0; i < m/2; i++){
        if(S[i] != S[m-1-i]){
          ans = "No";
          break;
        }
      }
    }else{
      for(int i=0; i < m/2; i++){
        if(S[i] != S[m-1-i]){
          ans = "No";
          break;
        }
      }
    }
  }

  if(ans == "Yes"){
    for(int i=0; i < m/2; i++){
      if(S[n-1-i] != S[m+i+1]){
        ans = "No";
        break;
      }
    }
  }
  
  
  cout << ans <<endl;
}


Measured memory_bytes: 256
n = int(input())
a = [int(input())-1 for i in range(n)]
 
light = [False for i in range(n)]
cnt = 1
botan = a[0]
if botan == 1:
    pass
else:
    while cnt <= n:
        cnt += 1
        botan = a[botan]
        light[botan] = True
        if light[1]:
            break
 
if cnt < n:
    print(cnt)
else:
    print(-1)

Measured memory_bytes: 7980
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
ll gcd(ll u,ll v){
    long long shift;
    if (u == 0) return v;
    if (v == 0) return u;
    shift = __builtin_ctz(u | v);
    u >>= __builtin_ctz(u);
    do {
        v >>= __builtin_ctz(v);
        if (u > v) {
            ll t = v;
            v = u;
            u = t;
        }  
        v = v - u;
    } while (v != 0);
    return u << shift;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    ll r=0;
    cin>>n;
    map<tuple<int,int,int>,int>q;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                // if(q[make_tuple(i,j,k)]!=0){
                //     r+=q[make_tuple(i,j,k)];
                // }else{
                //     ll gc=gcd(i,gcd(j,k));
                //     r+=gc;
                //     q[make_tuple(i,j,k)]=gc;
                //     q[make_tuple(i,k,j)]=gc;
                //     q[make_tuple(j,i,k)]=gc;
                //     q[make_tuple(j,k,i)]=gc;
                //     q[make_tuple(k,i,j)]=gc;
                //     q[make_tuple(k,j,i)]=gc;
                // }
                r+=gcd(i,gcd(j,k));
            }
        }
    }
    cout<<r<<'\n';
    
    return 0;
}

Measured memory_bytes: 3636