akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define repi(n) rep(i,n)
#define int long long
#define str string
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;
#define SORT(a) sort(all(a));
#define INF 1LL<<60
#define inf INF
#define out(i) cout<<i<<endl;
int min(int a,int b){if(a>b)return b;return a;}
int max(int a,int b){if(a>b)return a;return b;}

signed main(){
  str s;
  cin>>s;
  for(int i=1;i<s.length();){
    if(s[i]==s[i-1])s.erase(i,1);
    else ++i;
  }
  int w=count(all(s),'W');
  int b=count(all(s),'B');
  out(w+b-1);

  return 0;
}



Measured memory_bytes: 512
S = input()
N = len(S)

A = [0] * (N+1)

c = 0
for i in range(N):
    if S[i] == '<':
        c += 1
    else:
        c = 0
    A[i+1] = c

c = 0
for i in range(N-1, -1, -1):
    if S[i] == '>':
        c += 1
    else:
        c = 0
    A[i] = max(A[i], c)

print(sum(A))

Measured memory_bytes: 23336
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

int min(int x, int y)
{
	return x<y?x:y;
}

int main()
{
	fastio;
	ll n, k, i, j;
	cin>>n>>k;
	ll h[n];
	for(i=0;i<n;i++)
		cin>>h[i];
	ll dp[n];
	for(i=n-1; i>=0; i--)
	{
		if(i==n-1)
		{
			dp[i]=0;
			continue;
		}
		dp[i] = INT_MAX;
		for(j=i+1; j<=i+k && j<n; j++)
		{
			dp[i] = min(dp[i], abs(h[j]-h[i])+dp[j]);
		}
	}
	cout<<dp[0];
	return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = ReadLine().Split().Select(int.Parse).ToArray();
        int t1 = n[0] * 60 + n[1];
        int t2 = n[2] * 60 + n[3];
        while(t1 > t2)
            t2 += 24 * 60;
        WriteLine(t2 - t1 - n[4]);
    }
}


Measured memory_bytes: 19024
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>

using namespace std;
typedef long long int ll;typedef pair<int, int> P;
const long long mod = 1e9 + 7;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }

double arr[100][100] = {0};
int main(void) {
	int n; cin >> n;
	vector<double> a(n), b(n);
	rep(i, n) {
		cin >> a[i] >> b[i];
	}
	double sum = 0;
	for (int hi = 0; hi < n; hi++) {
		for (int wi = 0; wi < n; wi++) {
			if (hi != wi) {
				arr[hi][wi] = sqrt((a[hi] - a[wi]) * (a[hi] - a[wi]) + (b[hi] - b[wi]) * (b[hi] - b[wi]));
				sum += arr[hi][wi];
			}

		}
	}
	cout << d10 << sum / n << endl;
	return 0;
}



Measured memory_bytes: 256
package main

import (
  "bufio"
  "fmt"
  "io"
  "os"
  "strconv"
)

func Solve(stdin io.Reader, stdout io.Writer) {
  sc := bufio.NewScanner(stdin)
  sc.Split(bufio.ScanWords)

  sc.Scan()
  a, _ := strconv.Atoi(sc.Text())

  sc.Scan()
  b, _ := strconv.Atoi(sc.Text())

  ret := a + b
  if a - b > ret {
    ret = a - b
  }

  if a * b > ret {
    ret = a * b
  }
  _, _ = fmt.Fprintf(stdout, "%d\n", ret)
}

func main() {
  Solve(os.Stdin, os.Stdout)
  return
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std; 
int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    int n;
    cin >> n;
    vector<double> p(n+1);
    vector<vector<double>> dp(n+1, vector<double>(n+1));
    for (int i=1; i<=n; i++)
        cin >> p[i];
    dp[0][0] = 1;
    for (int i=1; i<=n; i++){
        dp[i][0] = dp[i-1][0]*p[i];
        for (int j=1; j<=i; j++)
            dp[i][j] = dp[i-1][j]*p[i]+dp[i-1][j-1]*(1-p[i]);
    }
    cout.precision(10);
    double ans = 0;
    for (int i=0; i<=n/2; i++)
        ans += dp[n][i];
    cout << ans << "\n";
}

Measured memory_bytes: 73664
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <string>
#include <algorithm>
#include <climits>
#include <set>
#include <queue>
#include <unordered_set>
using namespace std;

#define ll long long

const ll mod = 1e9 + 7;

class Solver
{
private:
	ll n;
	vector<ll> s;
	vector<ll> not_tens;
	// vector<vector<ll>> dp;
	ll sum;
public:
	Solver();
	void exec();
};

Solver::Solver(){
	cin >> n;
	sum = 0;
	for (int i = 0; i < n; ++i)
	{
		int tmp;
		cin >> tmp;
		s.push_back(tmp);
		sum += tmp;
		if(tmp % 10 != 0) not_tens.push_back(tmp);
	}
	sort(not_tens.begin(), not_tens.end());
}

void Solver::exec(){
	if(not_tens.size() == 0){
		cout << 0 << endl;
		return;
	}
	if(sum % 10 == 0){
		sum -= not_tens[0];
	}
	cout << sum << endl;
	// dp.resize(n);
	// for (int i = 0; i < n; ++i)
	// {
	// 	dp[i].resize(2);
	// 	dp[i][0] = 0;
	// 	dp[i][1] = 0;
	// }

	// for (int i = 0; i < n; ++i)
	// {
	// 	for (int j = 0; j <= i; ++j)
	// 	{
	// 		dp[]
			
	// 	}
	// }


}

int main(){
	Solver solution = Solver();
	solution.exec();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define RFOR(i, begin, end) for(int i=(end)-1, i##_begin_=(begin);i>=i##_begin_;i--)
#define rep(i, N) FOR(i, 0, N)
#define rrep(i, N) RFOR(i, 0, N)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long int;
using V = vector<ll>;
using P = pair<ll, ll>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
constexpr int mod = 1e9+7;
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;}

string s;

int main() {
    cin >> s;
    string v = "01";
    ll cnt[2] = {0};
    rep(i, s.size()) {
        if(s[i] == v[i%2]) cnt[0]++;
        else cnt[1]++;
    }
    cout << min(cnt[0], cnt[1]) << endl;
    return 0;
}


Measured memory_bytes: 512
import sys
input = sys.stdin.readline

def main():
    s = input().strip()
    l = len(s) - 1
    ans = 0
    for i in range(2**l):
        ss = s
        tmp = 0
        for j in range(l):
            tmp += 1
            if i&1:
                ans += int(ss[:tmp])
                ss = ss[tmp:]
                tmp = 0
            i >>= 1
        ans += int(ss)
        
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
def solve(A,N,b) -> str:
    ans = [[0,0,0]for _ in range(3)]
    for bn in b:
        for n,a in enumerate(A):
            if(bn in a):
                ans[n][a.index(bn)] = 1
    for a in ans:
        if(sum(a) == 3):
            return "Yes"
    for a in zip(*ans):
        if(sum(a) == 3):
            return "Yes"
    if(ans[1][1] == 1):
            if(ans[0][0]==1 and ans[2][2]==1 or ans[0][2] == 1 and ans[2][0] == 1):
                return "Yes"
    else:
        return "No"


def main():
    A = []
    for _ in range(3):
        A.append(list(map(int,input().split())))
    N = int(input())
    b = [int(input())for _ in range(N)]
    # solve()
    print(solve(A,N,b[:]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
bingo=[input().split(' ') for _ in range(3)]

#print(bingo)
N=int(input())
get=[input() for _ in range(N)]
#print(get)

for i in range(3):
    for j in range(3):
        if bingo[i][j] in get:
            bingo[i][j] = 'A'

#print(bingo)

if bingo[0][0]==bingo[0][1]==bingo[0][2]:
    print('Yes')
elif bingo[1][0]==bingo[1][1]==bingo[1][2]:
    print('Yes')
elif bingo[2][0]==bingo[2][1]==bingo[2][2]:
    print('Yes')
elif bingo[0][0]==bingo[1][0]==bingo[2][0]:
    print('Yes')
elif bingo[0][1]==bingo[1][1]==bingo[2][1]:
    print('Yes')
elif bingo[0][2]==bingo[1][2]==bingo[2][2]:
    print('Yes')
elif bingo[0][0]==bingo[1][1]==bingo[2][2]:
    print('Yes')
elif bingo[0][2]==bingo[1][1]==bingo[2][0]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		String a = "0";
		String b = "0";

		try {
			scanner = new Scanner(System.in);
			a = scanner.next();
			b = scanner.next();

			BigDecimal aB = new BigDecimal(a);
			BigDecimal bB = new BigDecimal(b);

			BigDecimal res = aB.add(bB);

			System.out.println(res.divide(new BigDecimal("2"), 0, RoundingMode.HALF_UP));

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		String s = "";
		String t = "";

		try {
			scanner = new Scanner(System.in);
			s = scanner.next();
			t = scanner.next();

			List<String> wkList = new ArrayList<String>();
			char[] sA = s.toCharArray();
			char[] tA = t.toCharArray();
			Arrays.sort(sA);
			Arrays.sort(tA);

			String wkSa = new String(sA);
			String wkTa = new StringBuilder(new String(tA)).reverse().toString();
			wkList.add(wkSa);
			wkList.add(wkTa);

			Collections.sort(wkList);

			boolean res = wkList.get(0).equals(wkSa);
			if (s.equals(t)) {
				res = false;
			}
			if (res) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 23124
#include <stdio.h>
#include <string.h>
int main(void){
char txt[256];
		scanf("%s",txt);
 
		int n = strlen(txt);
 
		int result=0;
		int i;
 
		if(txt[0]=='L')
			result=-1;
 
		for(i=1;i<n;i++){
			if(i%2==0){
				if(txt[i]=='L')
					result=-1;
			}else{
				if(txt[i]=='R')
					result=-1;
			}
			if(result!=0)
				break;
		}
		if(result==0)
			printf("Yes");
		else
			printf("No");
}

Measured memory_bytes: 128
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {
    char X, Y;
    cin >> X >> Y;

    int x,y;
    if(X=='A') {
        x = 10;
    } else if (X=='B') {
        x = 11;
    } else if (X=='C') {
        x = 12;
    } else if (X=='D') {
        x = 13;
    } else if (X=='E') {
        x = 14;
    } else if (X=='F') {
        x = 15;
    }
    if(Y=='A') {
        y = 10;
    } else if (Y=='B') {
        y = 11;
    } else if (Y=='C') {
        y = 12;
    } else if (Y=='D') {
        y = 13;
    } else if (Y=='E') {
        y = 14;
    } else if (Y=='F') {
        y = 15;
    }
    
    if(x==y) {
        print("=");
    }else {
        print(x>y?">":"<");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

ll modpow(ll a, ll n)
{
  ll res=1;
  while (n>0) {
    if (n&1) res = res*a % mod;
    a = a*a % mod;
    n >>= 1;
  }
  return res;
}

int main()
{
  ll N;
  scanf("%lld",&N);
  vector<ll> A(N);
  for(int i=0; i<N; i++){
    scanf("%lld",&A[i]);
  }
  sort(A.begin(),A.end());
  for (int i=0; i<N; i++) {
    if (A[i]!=i+(i+(N+1)%2)%2) {
      cout << 0 << endl;
      return 0;
    }
  }
  cout << modpow(2, N/2) << endl;

  return 0;
}


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

#define FOR(i,a,b)  for(ll i=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll i=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cout << #a << " = " << a << endl

const ll inf = 1e15;
const ll mod = 1e9+7;

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> arrow(N, -1);
    vector<vector<int>> road(N+1);
    int A, B;
    REP(i, M) {
        cin >> A >> B;
        road.at(A).push_back(B);
        road.at(B).push_back(A);
    }

    vector<int> next, next_tmp;
    next.push_back(1);
    arrow.at(0) = 0;
    int done = 1;
    while(done < arrow.size()) {
        //cout << "rest:" << count(arrow.begin(), arrow.end(), -1) << endl;
        //cout << "arrow" << endl;
        //REP(i, arrow.size()) {
        //    cout << i+1 << ":" << arrow.at(i) << endl;
        //}
        //cout << "next:" << next.size() << endl;
        REP(i, next.size()) {
            REP(j, road.at(next.at(i)).size()) {
                if (arrow.at(road.at(next.at(i)).at(j)-1) != -1) {
                    continue;
                }
                arrow.at(road.at(next.at(i)).at(j)-1) = next.at(i);
                next_tmp.push_back(road.at(next.at(i)).at(j));
                done++;
            }
        }
        next = next_tmp;
        next_tmp.clear();
    }
    cout << "Yes" << endl;
    REP(i, arrow.size() - 1) {
        cout << arrow.at(i+1) << endl;
    }
}


Measured memory_bytes: 10472
#include<iostream>
#include<climits>
using namespace std;
 
int main(){
    int n,a[5001];
    int ans;
    a[0]=0;
    while(cin>>n&&n){
        ans = INT_MIN;
        for(int i=1;i<=n;i++){
            cin>>a[i];
            a[i] += a[i-1];
        }
        for(int i=1;i<=n;i++){
            for(int j=i;j<=n;j++){
                ans = max(ans,a[j]-a[i-1]);
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

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

/**
 * @brief Process Class
 */
class Process
{
public:
    string name;
    int time;
    
    /* Constructor */
    Process(string n, int t) :
    name(n),
    time(t)
    {
    }
};

/**
 * @brief Result Output
 * @param [in] name Process Name
 * @param [in] time Process Exec Times
 * @return none
 */
void output( string name, int time )
{
    cout << name << " " << time << endl;
    return;
}
 
int main(void)
{
    /* Input Process Number */
    int numData;
    cin >> numData;
     
    /* Input Quantum */
    int quantum;
    cin >> quantum;
     
    /* Input Each Process Info */
    queue<Process> que;
    string p;
    int num;
    for( int loopCnt=0; numData > loopCnt; loopCnt++ )
    {
        cin >> p;
        cin >> num;
        que.push( Process(p,num) );
    }
     
    /* Round-Robin Scheduling */
    int time = 0;
    while( !que.empty() )
    {
        Process p = que.front();
        que.pop();
        if( p.time <= quantum )
        {
            time += p.time;
            output(p.name,time);
        }
        else
        {
            time += quantum;
            p.time -= quantum;
            que.push( p );
        }
    }
     
    return 0;
}

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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N,M;
struct E{
	int to,dist,cost;
};
vector<E> edge [10001];
const int INF = 1e9;

int main()
{
	while(scanf("%d%d",&N,&M),N){
		FOR(i,1,N + 1){
			edge [i].clear();
		}
		FOR(i,0,M){
			int u,v,d,c;
			scanf("%d%d%d%d",&u,&v,&d,&c);
			edge [u].push_back(E{v,d,c});
			edge [v].push_back(E{u,d,c});
		}

		vector< pair<int,int> > minDist(N + 1,make_pair(INF,0));
		minDist [1] = make_pair(0,0);
		priority_queue< pair< pair<int,int>,int >,vector< pair< pair<int,int>,int > >,greater< pair< pair<int,int>,int > > > pq;
		pq.push(make_pair(make_pair(0,0),1));
		while(pq.empty() == false){
			auto f = pq.top();
			pq.pop();

			if(f.first > minDist [f.second]) continue;
			for(const auto& it : edge [f.second]){
				chmin(minDist [it.to],make_pair(f.first.first + it.dist,it.cost));
				pq.push(make_pair(make_pair(f.first.first + it.dist,it.cost),it.to));
			}
		}
		int ans = 0;
		FOR(i,1,N + 1){
			ans += minDist [i].second;
		}
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 5580
#include<stdio.h>
#include<string.h>
int main(void){
    int A,B,C,D;
    char S[3];
    scanf("%d %d %d %d",&A,&B,&C,&D);
    if(A>B){
        if(C>D){
            printf("%d",B+D);
        }else{
            printf("%d",B+C);
        }
    }else{
        if(C>D){
            printf("%d",A+D);
        }else{
            printf("%d",A+C);
        }
    }
    return 0;
}

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

const ll mod=26;
const ll m=100;
vector<ll> v;

int main(){
    ll n; cin >> n;
    v.resize(m);
    ll count=0;
    for(; count<m; count++){
        n--;v[count]=n%mod;
        if(n/mod!=0) n/=mod;
        else break;
    }
    for(int i=count; i>=0; i--){ char a=v[i]+97; cout << a;}
    cout <<  "\n";
}

Measured memory_bytes: 3596
#include <stdio.h>
double times[7][2] = {
	{35.5, 71},
	{37.5, 77},
	{40, 83},
	{43, 89},
	{50, 105},
	{55, 116},
	{70, 148}
};
char rank[8][4] = {"AAA", "AA", "A", "B", "C", "D", "E", "NA"};
int main() {
	double x, y;
	int i;
	while(scanf("%lf %lf", &x, &y) != EOF) {
		for(i = 0; i < 7 && (times[i][0] <= x || times[i][1] <= y); ++ i);
		printf("%s\n", rank[i]);
	}
	return 0;
}

Measured memory_bytes: 608
fun main(args: Array<String>) {
    val n = readLine()!!.toLong()
    if (n % 2 == 1L) return println(0)
    var ans = 0L
    var num = 10L
    while (n / num != 0L) {
        ans += n / num
        num *= 5
    }
    println(ans)
}

Measured memory_bytes: 31776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define reverse(s) reverse(s.begin(),s.end())

int count(ll x){
    ll a = x;
    int i(0);
    while(1){
        if(a/10<1)  break;
        else    a = a/10;
        i++;
    }
    return i-1;
}

int main(){
    long double a,b;
    cin >> a >> b;
    ll x = a*b;
    cout << x << endl;
 
    return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    ll n; cin >> n;
    int cnt = 0;
    rep(i, n) {
        int a, b; cin >> a >> b;
        if(a == b) {
            cnt++;
            if(cnt == 3) {
            cout << "Yes" << endl;
            return 0;
        }
            continue;
        }
        cnt = 0;
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3592
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const double PI = acos(-1.0);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll A,B,C,X,Y; cin >> A >> B >> C >> X >> Y;

    ll ans = 1e18;
    rep(i,max(X,Y)+1) {
        chmin(ans, C*2*i+ max(0LL,X-i)*A + max(0LL,Y-i)*B);
    }

    cout << ans << ln;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define M 1000000007

int main(){
	ll h,w,i,j;
  cin>>h>>w;
  char arr[h][w];
  ll res[h][w];
  for(i=0;i<h;i++)
    for(j=0;j<w;j++)
      cin>>arr[i][j];
  res[0][0]=(arr[0][0]=='.')?1:0;
  
  for(i=1;i<w;i++)
    res[0][i]=(res[0][i-1]==1 && arr[0][i]=='.')?1:0;
  for(j=1;j<h;j++)
    res[j][0]=(res[j-1][0]==1 && arr[j][0]=='.')?1:0;
  for(i=1;i<h;i++)
    for(j=1;j<w;j++)
      res[i][j]=(arr[i][j]=='#')?0:((res[i-1][j]+res[i][j-1])%M);
  cout<<res[h-1][w-1]<<"\n";
  return 0;
}

Measured memory_bytes: 9088
import java.util.Scanner;
public class Main {
	 public static void main(String args[]){
		 Scanner std = new Scanner(System.in);
		 int r = std.nextInt();
		 int d = std.nextInt();
		 int x = std.nextInt();
		 for(int i=0;i<10;i++) {
			 x = r*x-d;
			 System.out.println(x);
		 }
	 }

}


Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <string.h>
#include <cstdio>
#include <bitset>
#include <cmath>
#include <map>
#include <set>
#include <fstream>

const long long maxn = 1e+10;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

ull gcd(ull a,ull b)
{
	if (a == 0ull) return b;
	if (b == 0ull) return a;
	if (a % 2 == 0ull && b % 2 == 0ull) return 2 * gcd(a >> 1, b >> 1);
	else if (a % 2 == 0ull) return gcd(a >> 1, b);
	else if (b % 2 == 0ull) return gcd(a, b >> 1);
	else return gcd(a<b ? b - a : a - b, min(a, b));
}
ull lcm(ull a,ull b)
{
	return a / gcd(a, b)*b;
}
	
int main()
{

	int n;
	cin >> n;
	vector<ull> v;
	for (int i = 0; i < n; ++i)
	{
		ull t;
		cin >> t;
		v.push_back(t);
	}
	ull ml = v[0];
	for (int i = 0; i < n; ++i)
	{
		ml = lcm(ml, v[i]);
	}
	cout << ml << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 512
x, y = map(int, input().split())

groups = (
    frozenset([1, 3, 5, 7, 8, 10, 12]),
    frozenset([4, 6, 9, 11]),
    frozenset([2])
    )

for group in groups:
    if x in group and y in group:
        print('Yes')
        break
else:
    print('No')


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

bool prime[1000010];

void set_prime() {
	prime[0] = 1;
	prime[1] = 1;
	for (int i = 2; i < 2000; i++) {
		int j = 2;
		while (i * j <= 1000000) {
			prime[i*j] = 1;
			j++;
		}
	}
}
int sum[200010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int Q; cin >> Q;
    set_prime();
    for(int i = 3; i <= 100000; i += 2) {
        if (prime[i] == 0 && prime[(i + 1)/2] == 0) sum[i]++;
    }
    REP(i, 1, 100000) sum[i + 1] += sum[i];

    while(Q--) {
        int l, r;
        cin >> l >> r;
        cout << sum[r] - sum[l - 1] << endl;
    }

    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int A[3];
    for(int i=0;i<3;i++) cin >> A[i];
    if(A[0] + A[1] + A[2] >=22) cout << "bust" << endl;
    else cout << "win" << endl;
    return 0;
}

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

using namespace std;
int main()
{
    int N;
    cin >> N;
    int ans = 0;
    int thr = 10;
    int thr2 = 100;
    for (int i = 1; i <= N; ++i)
    {
        if(i < thr){
            ++ans;
        }else if(i >= thr2){
            ++ans;
            thr *= 100;
            thr2 = thr * 10;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c,d;
	
	scanf("%d %d %d %d",&a,&b,&c,&d);
	
	if(a*b>=c*d){
		printf("%d\n",a*b);
	}else{
		printf("%d\n",c*d);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll x;
    cin >> x;
    
    ll ans = x / 11 * 2;
    
    if ((x % 11) > 6) {
        ans += 2;
    }
    else if ((x % 11) > 0) {
        ans ++;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))

ans = 0
d = 1 << 32
for i in range(N):
    if abs((T - H[i]*0.006) - A) < d:
        d = abs((T - H[i]*0.006) - A)
        ans = i

print(ans+1)

Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
struct mint{
    using ull=unsigned long long int;
    ull v;
    mint(ll vv=0){s(vv%mod+mod);}
    mint& s(ull vv){
        v=vv<mod?vv:vv-mod;
        return *this;
    }
    //オーバーロード
    mint operator-()const{return mint()-*this;}//符号反転
    mint&operator+=(const mint&val){return s(v+val.v);}
    mint&operator-=(const mint&val){return s(v+mod-val.v);}
    mint&operator*=(const mint&val){
        v=ull(v)*val.v%mod;
        return *this;
    }
    mint&operator/=(const mint&val){return *this*=val.inv();}
    mint operator+(const mint&val){return mint(*this)+=val;}
    mint operator-(const mint&val){return mint(*this)-=val;}
    mint operator*(const mint&val){return mint(*this)*=val;}
    mint operator/(const mint&val){return mint(*this)/=val;}
    mint pow(int n)const{
        mint res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }
    mint inv()const{return pow(mod-2);}
    //拡張ユークリッドの互除法
    /* mint inv()const{
        int x,y;
        int g=extgcd(v,mod,x,y);
        assert(g==1);
        if(x<0)x+=mod;
        return mint(x);
    }*/
    friend ostream& operator<<(ostream&os,const mint&val){
        return os<<val.v;
    }//出力
    bool operator<(const mint&val)const{return v<val.v;}
    bool operator==(const mint&val)const{return v==val.v;}
    bool operator>(const mint&val)const{return v>val.v;}
};
const ll MAX = 2000010;//設定
mint fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void init(){
    fac[0] = fac[1] = 1;
    for(int i=1;i<MAX;i++)fac[i]=fac[i-1]*i;
    finv[MAX-1]=fac[MAX-1].inv();
    for(int i=MAX-2;i>=0;i--)finv[i]=finv[i+1]*(i+1);
    for(int i=MAX-2;i>=1;i--)inv[i]=finv[i]+fac[i-1];
}
//階乗
mint factor(ll n,ll k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n]*finv[k];
}
// 二項係数計算
mint COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[k] * finv[n - k];
}
int main(){
ll n,k;
init();
cin>>n>>k;
mint ans=0;
for(int i=0;i<=k;i++){
	if((k-i)%2==0)ans+=COM(k,i)*mint(i).pow(n);
	else ans-=COM(k,i)*mint(i).pow(n);
}
cout<<ans<<"\n";
}


Measured memory_bytes: 50088
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
struct UnionFind {
    vector<int> d ;
    UnionFind (int n = 0) : d (n, -1) {}
    int find(int x){
        if(d[x] < 0) return x ;
        return find(d[x]) ;
    }
    bool unite (int x, int y){
        x = find(x) ;
        y = find(y) ;
        if(x == y) return false ;
        if(d[x] > d[y]) swap(x, y) ;
        d[x] += d[y] ;
        d[y] = x ;
        return true ;
    }
    bool same (int x, int y) {
        return find(x) == find(y) ;
    }
    int size (int x){
        return -d[find(x)] ;
    }
};



int main () {
    ll n, m ;
    cin >> n >> m ;
    UnionFind uf (n) ;
    vector<ll> ans ;
    vector<P> bd ;
    rep(i, m){
        int a, b ;
        cin >> a >> b ;
        a-- ; b-- ;
        bd.emplace_back(a, b) ;
    }
    ll dc = 0 ;
    for(int i = m - 1; i > 0; i--){
        int a = bd[i].first ;
        int b = bd[i].second ;
        if(uf.same(a, b)){
            ans.push_back(dc) ;
        }
        else {
            ll l = uf.size(a) ;
            ll p = uf.size(b) ;
            uf.unite(a,b) ;
            dc += l * p ;
            ans.push_back(dc) ;
        }
    }
    rep(i, m){
        if(i == m - 1){
            cout << n*(n-1)/2 << endl ;
        }
        else {
            cout << n*(n-1)/2 - ans[m - i - 2] << endl; 
        }
    }
}

Measured memory_bytes: 5924
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <queue>

using namespace std;

typedef long long LL;

const int N = 1e5+5;
const int P = 998244353;

const int INF = 0x3f3f3f3f;
const LL INFLL = 0x3f3f3f3f3f3f3f3f;

int n, m;
char M[205][205]; //0:empty 1:tree_edge -1:non-tree_edge
int dis[205];

vector <int> V[205];

inline bool solve(int id) {
    for(auto u: V[id]) {
        for(int v = 1; v <= n; v++) {
            if(M[u][v] == 1 && dis[v] != -1) if(abs(dis[u] - dis[v]) != 1) return false;
            if(M[u][v] == 1 && dis[v] == -1) {
                dis[v] = dis[u] + 1; 
                V[id + 1].push_back(v);
            }
        }
    }
    return true;
}

inline void init() {
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%s", M[i] + 1);
        for(int j = 1; j <= n; j++) {
            M[i][j] -= '0';
        }
    }
    int ans = -1;
    for(int root = 1; root <= n; root++) {
        for(int i = 1; i <= n; i++) dis[i] = -1;
        V[1].push_back(root);
        dis[root] = 1;
        int i = 1;
        while(V[i].empty() == false) {
            if(solve(i) == false) {
                i = 0;
                break;
            }
            i++;
        }
        ans = max(ans, i - 1);
        for(int j = 1; j <= i; j++) V[j].clear();
    }
    cout << ans << endl;
}

int main() {
    init();
    return 0; 
}

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

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll prev = a[0];
    ll curr;
    ll res1 = 0;
    if(prev == 0){
        prev = 1;
        ++res1;
    }

    rep1(i, n){
        curr = prev + a[i];
        if(curr == 0){
            if(prev < 0) curr = 1;
            else curr = -1;
            ++res1;
        }
        if(prev<0 && curr<0){
            res1 += 1 - curr;
            curr = 1;
        }
        if(prev>0 && curr>0){
            res1 += curr + 1;
            curr = -1;
        }

        prev = curr;
    }

    ll res2;
    if(a[0] > 0){
        prev = -1;
        res2 = a[0] + 1;
    }
    if(a[0] < 0){
        prev = 1;
        res2 = 1 - a[0];
    }
    if(a[0] == 0){
        prev = -1;
        res2 = 1;
    }
    
    rep1(i, n){
        curr = prev + a[i];
        if(curr == 0){
            if(prev < 0) curr = 1;
            else curr = -1;
            ++res2;
        }
        if(prev<0 && curr<0){
            res2 += 1 - curr;
            curr = 1;
        }
        if(prev>0 && curr>0){
            res2 += curr + 1;
            curr = -1;
        }

        prev = curr;
    }
    

    cout << min(res1, res2) << endl;

    return 0;
}

Measured memory_bytes: 3952
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード(アルファベット順,bits/stdc++.hは使わない派閥)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素


int main(){
    int N;
    cin >> N;
    vector<string> s(N);
    unordered_set<string> st;
    for(int i=0; i<N; i++){
        cin>>s[i];
        st.insert(s[i]);
    }

    cout<<st.size()<<endl;


}


Measured memory_bytes: 23936
#include <bits/stdc++.h>
#define db(x) cout<<x<<" "
#define db1(x) cout<<x<<'\n'
#define db2(x,y) cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pair(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define ll  long long int
#define vi vector<ll>
#define pi pair<ll,ll>
#define vpi vector<pair<ll,ll>>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define mod 1000000007
#define MAX_N 100000
using namespace std;
// int dx[4] = {1,-1,0,0};
// int dy[4] = {0,0,1,-1};



void solve(){

    string s,t;
    cin>>s>>t;    

    ll dp[s.length()+1][t.length()+1];

    repA(i,0,s.length())
    dp[i][0]=0;

    repA(i,0,t.length())
    dp[0][i]=0;

    repA(i,1,s.length()){
        repA(j,1,t.length()){
            if(s[i-1]==t[j-1]){
                dp[i][j] = 1+dp[i-1][j-1];
            }
            else{
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }

    string ans = "";

    ll row = s.length();
    ll col = t.length();

    while(row>0 && col>0){
        if(s[row-1]==t[col-1]){
            ans.push_back(s[row-1]);
            row--;
            col--;
        }
        else{
        if(dp[row][col-1]>dp[row-1][col])
            col--;
        else
            row--;
        }
    }

    reverse(all(ans));
    db1(ans);
}
int main(){ 

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





Measured memory_bytes: 70656
import math

#n = int(input())
n, a, b= [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for j in range(n)]
#table = [list(input()) for n in range(h)]
#list = [int(i) for i in input().split()]
#num = [int(i) for i in range(n)]
#s = [input() for i in range(n)]
#s = input()
#list = list(s)
#temp = [[0 for _ in range(13)] for _ in range(13)]

print(min(b,a*n))

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

int main(){
	int N,M;
	cin >> N >> M;
	vector<int> A;

	priority_queue<int> pque;
	rep(i,N){ int t; cin >> t; pque.push(t); }


	while(M>0){
		int t = pque.top(); pque.pop();
		pque.push(t/2);
		M--;
	}

	ll ans = 0;
	while(!pque.empty()){
		ans += pque.top(); pque.pop();
	}

	cout << ans << endl;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define pii pair<int,int>
#define mii map<int,int>
 
 
using namespace std;
 
int main(){
    int n,k;
    cin>>n>>k;
 
    vi a(n),dp(n+k,INT_MAX);
    
    dp[0]=0;
    for(int i=0;i<n;i++){
    	cin>>a[i];
    }
 
    for(int i=0;i<=n;i++){
    	for(int j=1;j<=k;j++){
    		if(i+j<n)
    			dp[i+j]=min(dp[i+j],dp[i]+abs(a[i]-a[i+j]));
    	}
    	// for(auto l:dp)
    	// 	cout<<l<<" ";
    	// cout<<endl;
    } 
 
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
n = gets.to_i
data = n.times.map { gets.strip.split.map(&:to_i) }

def is_reachable?(current, next_data)
  tc, xc, yc = current
  tn, xn, yn = next_data
  dist = (xc - xn).abs + (yc - yn).abs

  return false if dist > tn -tc
  (dist - (tn - tc)).even?
end

current = [0, 0, 0]
data.each do |d|
  unless is_reachable?(current, d)
    puts 'No'
    exit 0
  end
  current = d
end

puts 'Yes'

Measured memory_bytes: 9468
N, M = map(int, input().split())
bit = ['000', '001', '010', '011', '100', '101','110', '111']

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

max_v = float('-inf')
for bi in bit:
    c = []
    for cake in cake_origin:
        b = cake[0]
        t = cake[1]
        p = cake[2]
        if bi[0] == '1':
            b = cake[0] * -1
        if bi[1] == '1':
            t = cake[1] * -1
        if bi[2] == '1':
            p = cake[2] * -1
        c.append(b + t + p)
    c.sort(reverse=True)
    max_v = max(max_v, sum(c[:M]))
print(max_v)


Measured memory_bytes: 3260
import sys
h, w = (int(i) for i in input().split())
s =[list(input()) for i in range(h)]
flags = []
for i in range(0,h):
    flags.append([0 for i in range(w)])

for i in range(0,h):
    for j in range(0,w-1):
        if s[i][j]=='#' and s[i][j+1]=='#':
            flags[i][j]=1
            flags[i][j+1]=1

for i in range(0,w):
    for j in range(0,h-1):
        if s[j][i]=='#' and s[j+1][i]=='#':
            flags[j][i]=1
            flags[j+1][i]=1

for i in range(0,h):
    for j in range(0,w):
        if s[i][j]=="#":
            if flags[i][j]==0:
                print("No")
                sys.exit()
            else:
                continue

print("Yes")


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

int main(){
    int N;
    cin>>N;
    if(N%1000==0)cout<<0<<endl;
    else cout<<(N/1000+1)*1000 - N<<endl;
    return 0;
}

Measured memory_bytes: 3592
# https://atcoder.jp/contests/abc107/tasks/arc101_a

# 累積和を使って区間ごとの時間を求めて、更にスタートからの時間を足す
# 考える区間は0から左にK個〜右K個までK個ずつずらす

import sys
from bisect import bisect_left
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


N, K = read_ints()
X = read_ints()


# すべて正の場合
if X[0] >= 0:
    print(X[K - 1])
    exit()
# 負の場合
if X[-1] <= 0:
    print(abs(X[-K]))
    exit()


zeroidx = bisect_left(X, 0)
if X[zeroidx] == 0:
    K -= 1

l = max(zeroidx - K, 0)
# r_max = min(zeroidx + K, len(X) - 1)

ans = 10**16

for i in range(K):
    ll = l + i
    rr = ll + K - 1
    if rr >= len(X):
        break
    # print(X[ll:ll + K])
    ans = min(ans, 2 * abs(X[ll]) + abs(X[rr]),
              abs(X[ll]) + 2 * abs(X[rr]))


print(ans)


Measured memory_bytes: 14136
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

last = [0 for _ in range(26)]
calc = [0 for _ in range(26)]

for i in range(D):
  for j in range(26):
    day = i + 1
    calc[j] = c[j] * (day - last[j])
  min_idx = calc.index(max(calc))
  last[min_idx] = day
  print(min_idx + 1)

Measured memory_bytes: 9392
//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
//これは、頭が悪く競プロが世界で一番できないHIR180が
//IOI2014日本代表になるまでのN日間の記録である。
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define f first
#define s second
#define rep(i,x) for(int i=0;i<x;i++)
int a[5005],b[5005];
int main()
{
	srand((unsigned int)time(NULL));
	int n,m; scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(int i=0;i<m;i++)
	{
		scanf("%d",&b[i]);
	}
	int ret=0;
	for(int i=0;i<m;i++)
	{
		int nxt=i;
		for(int j=0;j<n && nxt<=m;j++)
		{
			if(a[j]==b[nxt]) nxt++;
		}
		ret=max(ret,nxt-i); 
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 1224
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);

const int INF = INT_MAX/10;

int main() {
	int N, M;
	while(cin >> N >> M, N) {
		vi C(M);
		REP(i, M) {
			cin >> C[i];
		}

		vvi dp(N+1, vi(256, INF));
		dp[0][128] = 0;
		int x;
		FOR(i, 1, N) {
			cin >> x;
			REP(j, 256) {
				REP(k, M) {
					int nx = j + C[k];
					nx = min(nx, 255);
					nx = max(0, nx);
					dp[i][nx] = min(dp[i][nx], dp[i-1][j] + (nx-x)*(nx-x));
				}
			}
		}

		int ans = INF;
		REP(i, 256) {
			ans = min(ans, dp[N][i]);
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 21924
#include<iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int *a = new int[n];
    int search = 0;

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

    for (int i = 0; i < n; i++) {
        if (search + 1 == a[i]) {
            search++;
        }
    }

    if (search == 0) {
        cout << "-1" << endl;
    } else {
        cout << n - search << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
sum_=[0]
sum_ = set(sum_)
for i in range(n):
  tmp = int(input())
  sum_ = set(map(lambda x: x+tmp, sum_)) | sum_

sum_ = sorted(list(sum_ ))
for value in sum_[::-1]:
  if value%10 !=0:
    print(value)
    exit()
print(0)

Measured memory_bytes: 5324
#include<stdio.h>
#define N 44

int main(){
  int num,i,n[N]={1,1};

  scanf("%d",&num);

  for(i=2; i<=num; i++){
    n[i] = n[i-1] + n[i-2];
  }
  
  printf("%d\n",n[num]);

  return 0;
}

Measured memory_bytes: 596
s=list(input())
K=int(input())

abc="bcdefghijklmnopqrstuvwxyza"

cnt=K
for i in range(len(s)):
    temp=25-abc.index(s[i])
    if cnt>=temp:
        s[i]="a"
        cnt-=temp

if cnt!=0:
    s[-1]=abc[(abc.index(s[-1])+cnt)%26]

print("".join(s))


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n, k;cin >> n >> k;
    string ans = "YES";
    if(n%2 == 0){
        if(k > n/2) ans = "NO";
    }else{
        if(k > n/2+1) ans = "NO";
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main()
{
    int N, dev;
    cin >> N;
    for(int n = N; n != 0; n /= 10)
        dev += n % 10;
    (N % dev == 0) ? (cout << "Yes" << endl) : (cout << "No" << endl);
}

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

int N;
int* u;
int* d;
int ans;

int main() {
	ans = 0;

	cin >> N;
	u = new int[N];
	d = new int[N];

	for (int i = 0; i<N; i++) {
		cin >> u[i];
	}
	for (int i = 0; i<N; i++) {
		cin >> d[i];
	}

	for (int i = 0; i < N; i++) {
		int tmp = 0;
		for (int j = 0; j <= i; j++) {
			tmp += u[j];
		}
		for (int j = i; j < N; j++) {
			tmp += d[j];
		}

		if (ans < tmp) {
			ans = tmp;
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256