akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		double[][] a = new double[n+1][3];
		for(int i=1;i<=n;i++) {
			for(int j=0;j<3;j++) {
				a[i][j] = in.nextInt();
			}
		}
		double[][][] dp = new double[n+1][3][3];
		for(int i=1;i<=n;i++) {
			for(int j=0;j<3;j++) {
				dp[i][j][0] = Math.max(Math.max(dp[i-1][j][1], dp[i-1][(j-1+3)%3][1])+a[i][(j+1+3)%3], Math.max(dp[i-1][(j+1+3)%3][1],dp[i-1][j][1])+a[i][(j-1+3)%3]);
				dp[i][j][1] = Math.max(0, dp[i-1][j][0]+a[i][j]);
				//dp[i][j][2] = Math.max(0, dp[i-1][j][1]+a[i][j]);
				/*
				System.out.println(j+":");
				for(int k=0;k<3;k++) {
					System.out.print(dp[i][j][k]+" ");
				}
				System.out.println();
				*/
			}
		}
		System.out.println((int)Math.max(dp[n][0][1], Math.max(dp[n][1][1], dp[n][2][1])));
	}
}

Measured memory_bytes: 113340
a = input()

for i in range(2**3):
    N = ["+"]*3
    for j in range(3):
        if (i>>j) & 1:
            N[j] = "-"

    sum = a[0] + N[0] + a[1] + N[1] + a[2] + N[2] + a[3]
    if eval(sum) == 7:
        print(sum + "=7")
        exit()


Measured memory_bytes: 3060
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
int n,m;
int num;
string s;
map<int,bool>mp;
int w[100010];
int ac,wa;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n>>m;
	while(m--){
		cin>>num>>s;
		if(!mp[num]){
			if(s=="WA")w[num]++;
			else wa+=w[num],ac++,mp[num]=1;
		}
	}
	cout<<ac<<' '<<wa;
	return 0;
}


Measured memory_bytes: 4992
import java.util.Scanner;

class Main {
    
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int r, c, i, j, sum = 0, sumr = 0;
    	int ary[][], sumc[];
    	
    	r = sc.nextInt();
    	c = sc.nextInt();
    	
    	ary = new int[r][c];
    	sumc = new int[c];
    	
    	for(i = 0; i < r; i++) {
    		for(j = 0; j< c; j++) {
    			ary[i][j] = sc.nextInt();
    		}
    	}
    	
    	for(i = 0; i < r; i++) {
    		for(j = 0; j < c; j++) {
    			sum += ary[i][j];
    			sumr += ary[i][j];
    			sumc[j] += ary[i][j];
    			System.out.print(ary[i][j] + " ");
    			if(j == c-1) System.out.println(sumr);
    		}
    		sumr = 0;
    	}
    	for(i = 0; i < c; i++) {
    		System.out.print(sumc[i] + " ");
    	}
    	System.out.println(sum);
    }
}


Measured memory_bytes: 41696
use std::io;


fn main() {
    let s = read_one::<String>().chars()
        .map(|c| c as usize - '0' as usize)
        .collect::<Vec<usize>>();

    let mut ans = 0;
    for j in 0..1 << (s.len() - 1) {
        let mut sum = 0;
        for k in 0..s.len() {
            sum *= 10;
            sum += s[k];
            if (j & 1 << k) != 0 {
                ans += sum;
                sum = 0;
            }
        }
        ans += sum;
    }

    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
n, y = map(int ,input().split())
for i in range(y//10000+1):
  for j in range((y-10000*i)//5000+1):
    rest = y - 10000*i - 5000*j
    if i+j+rest//1000 == n:
      print('{} {} {}'.format(i,j,rest//1000))
      exit()
print('-1 -1 -1')

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using P = pair<ll,ll>;

int main(){
    int n;cin >>n;
    ll d=n%10;
    if(d==3)puts("bon");
    else if(d==0)puts("pon");
    else if(d==1)puts("pon");
    else if(d==6)puts("pon");
    else if(d==8)puts("pon");
    else puts("hon");
}

Measured memory_bytes: 3632
N = int(input())
C, S, F = [0] * (N - 1), [0] * (N - 1), [0] * (N - 1)
for i in range(N - 1):
    C[i], S[i], F[i] = map(int, input().split())

for i in range(N):
    t = 0
    for j in range(i, N - 1):
        if t < S[j]:
            t = S[j]
        elif t % F[j] == 0:
            pass
        else:
            t += F[j] - t % F[j]
        t += C[j]
    print(t)

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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
typedef long long ll;


int main(){
  while(1) {
    int n,x; cin >> n >> x;
    if (n == 0 && x == 0) break;
    int r=0;
    reps(i,n) {
      for (int j=i+1; j <= n; j++) {
        for (int k=j+1; k <= n; k++) {
          if (i+j+k == x) r++;
        }
      }
    }
    cout << r << endl;
  }
}



Measured memory_bytes: 3032
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back

int main() {
  int n,m,r;
  cin >> n >> m >> r;
  vector<int> city(r,0);
  rep(i,r) {
    cin >> city[i];
    city[i]--;
  }

  ll cost[n+1][n+1];

  rep(i,n)rep(j,n) {
    if (i == j) cost[i][j] = 0;
    else cost[i][j] = INF;
  }

  rep(i,m) {
    ll a,b,c;
    cin >> a >> b >> c;
    a--,b--;
    cost[a][b] = cost[b][a] = c;
  }

  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
      }
    }
  }

  ll ans = 0;
  sort(city.begin(), city.end());
  rep(i,city.size() - 1) {
    ans += cost[city[i]][city[i+1]];
  }
  while (next_permutation(city.begin(), city.end())) {
    ll tmp = 0;
    rep(i,city.size()-1) tmp += cost[city[i]][city[i+1]];
    ans = min(ans,tmp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<math.h>
 
main(){
 
        int A,B,K,i;
        scanf("%d %d %d",&A,&B,&K);
 
        if((B-A+1) < K*2){
                for(i=A;i<=B;i++){
                        printf("%d\n",i);
                }
        }
        else{
                for(i=A;i<=A+K-1;i++){
                        printf("%d\n",i);
                }
                for(i=B-K+1;i<=B;i++){
                        printf("%d\n",i);
                }
 
        }
 
}

Measured memory_bytes: 128
using System;
class Program
{
	static void Main(string[] args)
	{
	   string[] inputs = Console.ReadLine().Split(' ');
	   int five = 0;
	   int seven = 0;
	   string result = "NO";
	   
	   for (int i = 0; i < 3; i++)
	   {
	      if(inputs[i] == "5"){five++;}
	      if(inputs[i] == "7"){seven++;}
	   }
	   if(five == 2 && seven == 1){result = "YES";}
	   
	   Console.WriteLine(result);
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b+c || b==a+c || c==a+b)  cout << "Yes" << endl;
  else  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n;
  while(cin >> n,n){
    int i,j,k;
    string buf;
    int d[50]={};
    for(i=0;i<n;i++){
      cin >> buf;
      d[i]=buf.size();
    }
    for(i=0;i<n;i++){
      int c=0;
      j=i;
      while(c<5) c+=d[j++];
      if(c!=5) continue;
      c=0;
      while(c<7) c+=d[j++];
      if(c!=7) continue;
      c=0;
      while(c<5) c+=d[j++];
      if(c!=5) continue;
      c=0;while(c<7) c+=d[j++];
      if(c!=7) continue;
      c=0;
      while(c<7) c+=d[j++];
      if(c!=7) continue;
      c=0;
      cout << i+1 << endl;
      break;
    }
  }
  return 0;
}

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

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

typedef long long ll;
typedef pair<int, int> P;

#define MAX 100005
#define INF 1001001001

int main(int, char**)
{
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  int q;
  cin >> q;
  int b, m, e;
  rep(i,q) {
    cin >> b >> m >> e;
    rotate(a.begin()+b, a.begin()+m, a.begin()+e);
  }
  rep(i,n) {
    cout << a[i];
    if (i==n-1) cout << endl;
    else cout << " ";
  }

  return 0;
}



Measured memory_bytes: 3156
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
    int W,H,a;
    char s ='#';
    while(1){
        cin>>H>>W;
        for(int i=0;i<H;i++){
            for(int a = 0;a<W;a++){
                cout <<s;
            }
            cout<<endl;
            a= 0;
        } 
        if(W==0||H==0){
            break;
      
       
        } 
        cout<<endl;
    }
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A,B,a,b,c,d,e;
  cin >> N >> A >> B;
  int sum=0;
  for(int i=1;i<=N;i++){
    e=i/10000;
    a=i%10000/1000;
    b=i%1000/100;
    c=i%100/10;
    d=i%10;
    if(A<=a+b+c+d+e && a+b+c+d+e<=B){sum+=i;}
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	nums := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
	}
	counter := make(map[int]int)
	for _, num := range nums {
		counter[num]++
	}
	for _, v := range counter {
		if v > 1 {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
	return
}


Measured memory_bytes: 13952
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int seconds = sc.nextInt();
        int hour = seconds / 3600;
        int min = seconds % 3600 / 60;
        int sec = seconds % 60;
        System.out.printf("%d:%d:%d%n",hour,min,sec);
        sc.close();
    }
}



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

#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define Rrep(i,n) for(int i=((int)n-1); i>=0; i--)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e15
#define MOD 1000000007

typedef vector<int> vint;
typedef long long ll;


//累積和dp
int main()
{
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(15);

        ll n,k;
        cin>>n>>k;

        vector <pair<int,int>> sec;
        
        rep(i,k){
                int a,b;
                cin >> a >> b;
                sec.push_back(make_pair(a,b));
        }

        vector<ll> dp(n+1,0);
        vector<ll> ruiseki(n+1,0);

        dp[1]=1;
        ruiseki[1]=1;
        for(int i=1;i<n;i++){
                rep(j,k){
                        int start = i+1-sec.at(j).second;
                        int end = i+1-sec.at(j).first;
                        if(end<1) continue;
                        else if(start<1) dp[i+1] += ruiseki[end];
                        else dp[i+1] +=  (ruiseki[end]-ruiseki[start-1]);
                        dp[i+1] =dp[i+1]%998244353;
                }
                ruiseki[i+1] = dp[i+1] + ruiseki[i];
                ruiseki[i+1] = ruiseki[i+1]%998244353;
        }
        cout << (dp[n]+998244353)%998244353 <<endl;

        /*for(int i=0;i<n;i++){
                for(auto x:lr){
                        if(i-x+1<0){continue;}
                        dp[i+1]+=dp[i-x+1];
                        dp[i+1] %= 998244353;
                }
        }
        cout<<dp[n]%998244353<<endl;

        for(auto x:dp){
                cout<<x<<endl;
        }*/

        return 0;
}


Measured memory_bytes: 6336
#include<bits/stdc++.h>
#define mx 200005
using namespace std;

int main(){
	int n, p, a[mx] = {}, m = 0;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &p);
		a[p] = a[p-1] + 1;
		m = max(m, a[p]);
	}
	printf("%d", n - m);
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

int main(void){
    long long int a,b,s,i,n,count;
    long long int p[50];
    long long int aa[50];
    long long int bb[50];
    scanf("%lld", &n);
    for (i=0; i<n; i++){
        scanf("%lld", &p[i]);
    }
    count=0;
    for(i=0; i<n; i++){
        if(p[i]==i+1){
        }else{
            aa[count]=p[i];
            bb[count]=i+1;
            count++;
        }
    }
    
    if(count==0 || (count==2 && aa[0]==bb[1] && aa[1]==bb[0])){
        printf("YES");
    }else{
        printf("NO");
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;
int main(){
    speed;
    int n,k,q;
    cin >> n>>k>>q;
    vector<int>pep(q);
    vector<int>apep(n);
    fill(apep.begin(),apep.end(),k);
    for (int i = 0;i < q;i++){
        cin >> pep[i];
    }
        for (int i = 0 ; i < apep.size();i++){
            apep[i]=k-q;
        }
    for (int i = 0;i < pep.size();i++){
        apep[pep[i]-1]++;
    }
    for (int i = 0 ; i < n;i++){
        if(apep[i]<=0){
            cout << "No\n";
        }else{
            cout << "Yes\n";
        }
    }
}





Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i, n) for (int i=0; i < n; i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define repran(i, a,b) for (int i = a; i<b;i++)
#define all(x) (x).begin(), (x).end()
#define v(T) vector<T>
#define vv(T) vector<v(T)>
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

const int N= 3000;
mint dp[N+1][N+1];
int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    dp[a][b] = 1;
    for (int i = a;i < c+1;i++){
        for (int j = b; j < d+1;j++){
            if (i > a) dp[i][j] += (mint)j*dp[i-1][j];
            if (j > b) dp[i][j] += (mint)i*dp[i][j-1];
            if (i > a and j > b) dp[i][j] -= (mint)(i-1)*(j-1)*dp[i-1][j-1];
        }
    }
    cout << dp[c][d] << endl;
}

Measured memory_bytes: 74036
t=input()
s=list(t)
k=int(input())

# 全部同じ文字の場合
if s==[s[0]]*len(s):
  print((len(s)*k)//2)
  exit()

b=[1]
for i in range(1,len(s)):
  if s[i-1]==s[i]:
      b[-1]+=1
  else:
      b.append(1)

ans=0
for i in b:
    ans+=i//2*k

if t[0]==t[-1] and (b[0]+b[-1])%2==0:
    ans+=k-1
print(ans)

Measured memory_bytes: 9208
from heapq import heappush, heappop
from operator import itemgetter
N, K = map(int, input().split())
x = list(map(int, input().split()))
t = []
for i in range(K):
    ta, tb = map(int, input().split())
    t.append([ta,tb]) 
a = sorted(t, key=itemgetter(1))
x.sort()
x = x[::-1]
s = 0
l = []
while x or a:
    if a[-1][0] == 0:a.pop()
    if not a:
        s+=sum(x)
        break
    if len(x) ==0:break
    r = x.pop()
    if r < a[-1][1]:
        s+=a[-1][1]
        a[-1][0]-=1
    else:
        s+=sum(x)+r
        break
print(s)

Measured memory_bytes: 82712
#include <bits/stdc++.h>
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define YEET ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define f first
#define s second
#define mod 1000000007

using namespace std;

int main ()
{
	YEET;
	string s;
	cin>>s;
	int flag=0;
	for(int y=0;y<s.length()-1;y++)
	{
		if(s[y]==s[y+1])
			flag=1;
	}
	if(flag)
		cout<<"Bad\n";
	else
		cout<<"Good\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
using namespace std;
 
int main()
{
    int H, W;
    cin>>H>>W;
    vector<int> A(H), B(H);
    for (int y=0; y<H; y++)
    {
        cin>>A[y]>>B[y];
        A[y]--;
    }
 
    set<pair<int, int>> S;
    multiset<int> T;
    for (int x=0; x<W; x++)
    {
        S.insert({x, 0});
        T.insert(0);
    }
 
    for (int y=0; y<H; y++)
    {
        int t = 999999;
        for (auto s=S.lower_bound({A[y], 0}); s!=S.end() && s->first<B[y]; s=S.erase(s))
        {
            T.erase(T.find(s->second)); 
            t = min(t, s->second+(B[y]-s->first));
        }
        if (B[y]<W && t<999999)
        {
            S.insert({B[y], t});
            T.insert(t);
        }
 
        if (T.empty())
            cout<<-1<<endl;
        else
            cout<<*T.begin()+y+1<<endl;
    }
}


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

int main() {
	int A, B;
	cin >> A >> B;
	string x0;
	int n = 0;
	int len, k;
	for (int i = 0; i < B - A + 1; i++) {
		x0 = to_string(A + i);
		len = (int)x0.length();
		k = 0;
		for (int j = 0; j <= len/2-1;j++){
			if (x0.substr(j,1) == x0.substr(len-j-1, 1))
			{
				k++;
			}
		}
		if (k == len/2){
			n++;
		}
	}
	cout << n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#warning do not forget to change size of N and M 
#define popcnt(a) __builtin_popcount(a)
#define gcd(a,b) __gcd(a,b)
#define IO() assert(freopen("in.in", "rt", stdin)), assert(freopen("out.out", "wt", stdout))
#define FastIO() ios::sync_with_stdio(false),cin.tie(0);
#define debug(x) cout << __LINE__ << ": " << #x << " = " << (x) << endl


typedef long long ll;

const ll MOD = 1e9 + 7;
const int N = 1e7 + 9, M = 1e5 + 9, OO = 0x3f3f3f3f;
const double EPS = 1e-10,PI=acos(-1.0);

//Number Theory
inline bool dCMP(const long double &a, const long double &b) { return fabsl(a - b) < EPS;}

//Geometry 
inline double MintoDeg(double min){return min/60;}
inline double to_Radian(double deg){return deg*PI/180.0;}
inline double to_Degree(double radian){if(radian<0) radian+=2*PI; return radian*180/PI ;}
inline double fixAngle(double A){return A>1 ? 1 : (A<-1 ? -1 : A);}
char str[N];
int main()
{
  
  int k,s,ans=0;
  scanf("%d%d",&k,&s);
  for(int y=0;y<=k;++y)
  {
    for(int z=0;z<=k;++z)
   {
     int x=s-y-z;
     if(x>=0 && x<=k) ans++;
   }
  }
   
   
   printf("%d\n",ans);
     
     

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c[100],i,n;
	scanf("%d",&b);
	i=0;
	while(b!=0){
	a=1000-b;
	c[i]=0;
	c[i]+=a/500;
	a=a%500;
	c[i]+=a/100;
	a=a%100;
	c[i]+=a/50;
	a=a%50;
	c[i]+=a/10;
	a=a%10;
	c[i]+=a/5;
	a=a%5;
	c[i]+=a/1;
	i+=1;
	scanf("%d",&b);
	}
	for(n=0;n<i;n++){
	printf("%d\n",c[n]);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main()
{

    string S;
    cin >> S;

    // cout << S << endl;

    if (S.at(2) == S.at(3) && S.at(4) == S.at(5))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
a.sort()
l = [0] * N

for i in range(N):
  l[i] = l[i-1] + a[i]

ans = 1
i = N-1
while i > 0 and 2 * l[i-1] >= a[i]:
  ans += 1
  i -= 1

print(ans)

Measured memory_bytes: 14224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int m,d;
  cin>>m>>d;
  int ans=0;
  FOR(i,1,m+1){
    FOR(j,1,d+1){
      if(j<10) continue;
      string s=to_string(j);
      int a=s[0]-'0',b=s[1]-'0';
      if(a<2 || b<2) continue;
      if(i==(s[0]-'0')*(s[1]-'0')) ans++;
    }
  }
  cout<<ans<<endl;
}

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

void solve(long long N, long long x, vector<long long> a){
	long long ans = 0;
	for(int i = 0 ; i+1 < N ; i++){
		long long v = a[i] + a[i+1];
		if( v <= x ) continue;
		long long u = v - x;
		ans += u;
		a[i+1] = max(0ll,a[i+1]-u);
	}
	cout << ans << endl;
}

int main(){	
	long long N;
	long long x;
	scanf("%lld",&N);
	vector<long long> a(N-1+1);
	scanf("%lld",&x);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&a[i]);
	}
	solve(N, x, a);
	return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

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

	int n;
	cin >> n;
	vector<int> d(n);
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		d[i] += x;
	}
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		d[i] -= x;
	}
	int s = 0;
	for (int i = 0; i < n; i++) {
		s += d[i];
	}
	int sum_neg = 0;
	int c_neg = 0;
	vector<int> pos;
	for (int i = 0; i < n; i++) {
		if (d[i] >= 0) {
			pos.push_back(d[i]);
		} else {
			sum_neg += d[i];
			c_neg++;
		}
	}
	sort(pos.rbegin(), pos.rend());
	for (int i = 0; i <= (int)pos.size(); i++) {
		if (sum_neg >= 0) {
			cout << i + c_neg << '\n';
			return 0;
		}
		if (i < (int)pos.size()) sum_neg += pos[i];
	}
	cout << -1 << '\n';
}



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

int main() {
	string str;
	long long count = 0;
	long long b_count = 0;
	cin >> str;

	for (int i = 0; i < str.length(); i++) {
		if (str[i] == 'B') {
			b_count++;
		}
		else {
			count += b_count;
		}
	}

	cout << count << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;

int main() {

    int a, b, c;
    cin >> a >> b >> c;
    if (b - a == c - b) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

ll dp[10010][110][2];

int main(){
  string k;
  cin>>k;
  int n=k.size();
  int d;
  cin>>d;

  dp[0][0][0]=1;
  for(int i=1;i<=n;i++){
    for(int j=0;j<d;j++){
      for(int f=0;f<=1;f++){
        int lim;
        if(f) lim=9;
        else lim=k[i-1]-'0';

        for(int l=0;l<=lim;l++){
          if(f==0){
            if(l!=lim) dp[i][(j+l)%d][1]=(dp[i][(j+l)%d][1]+dp[i-1][j][0])%MOD;
            else dp[i][(j+l)%d][0]=(dp[i][(j+l)%d][0]+dp[i-1][j][0])%MOD;
          }else{
            dp[i][(j+l)%d][1]=(dp[i][(j+l)%d][1]+dp[i-1][j][1])%MOD;
          }
        }
      }
    }
  }

  cout<<(dp[n][0][0]+dp[n][0][1]-1+MOD)%MOD<<endl;

  return 0;
}


Measured memory_bytes: 17408
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 500005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int ans = 1;
    ll a, b;
    cin >> a >> b;
    b /= a;
    while(b >= 2){
        ans++;
        b /= 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize,
        ta: [(usize, usize); n]
    }

    if n == 1 {
        println!("{}", ta[0].0 + ta[0].1);
        return;
    }

    let (mut prev_t, mut prev_a) = ta[0];
    for (t, a) in ta.into_iter().skip(1) {
        let t_fac = (prev_t + t - 1) / t;
        let a_fac = (prev_a + a - 1) / a;
        let factor = max(t_fac, a_fac);
        prev_t = t * factor;
        prev_a = a * factor;
    }
    println!("{}", prev_t + prev_a);
}


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

#define ALL(obj) (obj).begin(), (obj).end()
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,b) for(int i=a; i<=b; i++)
using ll = long long;
#define pb push_back

typedef vector<int> VI;
typedef vector<ll> VL;
const double pi = acos(-1.0);
typedef complex<double> Comp;

int main()
{
  int a[3];
  rep(i,3)
    cin >> a[i];
  sort(a, a+3);
  int ans = 0;
  bool flag1, flag2;

  ans += (a[2]-a[0])/2;
  // cout << "a[2]-a[0] / 2 " <<  ans << endl;
  flag1 = (((a[2]-a[0])%2)==0)? false : true;
  ans += (a[2]-a[1])/2;
  flag2 = (((a[2]-a[1])%2)==0)? false : true;

  if (! (flag1 || flag2) )
     ;
  else if ( flag1 && flag2 ) 
    ans += 1;
  else 
    ans += 2;
  cout << ans << endl;

}

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

int main(){
  string s;
  int exist = 0;
  
  cin >> s;
  
  if (s.size() == 2){
    if (s.at(0) == s.at(1)){
      cout << "1 2";
      exist = 1;
    }
  } else { 
    for (int i = 2; i < s.size(); i++){
      if (s.at(i) == s.at(i-2)){
        cout << i-1 << " " << i+1;
        exist = 1;
        break;
      } else if (s.at(i) == s.at(i-1)){
        cout << i << " " << i+1;
        exist = 1;
        break;
      }
    }
  }
  
  if (!exist) cout << "-1 -1";
}

Measured memory_bytes: 3736
n, m = map(int, input().split())

conds = []

for i in range(m):
    s, c = map(int, input().split())
    conds.append([s, c])

# seiri conditions
conds = sorted(conds)
for i in range(len(conds)):
    if i + 1 < len(conds) and (conds[i][0] == conds[i + 1][0]
                               and conds[i][1] != conds[i + 1][1]):
        print(-1)
        exit(0)

# list to check conditions.If -1, no condition
fix = [-1] * n

for i in range(len(conds)):
    fix[conds[i][0] - 1] = conds[i][1]

ans = 0
isTopNumFixd = False
for i in range(n):
    if fix[i] == -1 and (i == 0 and n != 1):
        fix[i] = 1
        isTopNumFixd = True
    elif fix[i] == -1:
        fix[i] = 0
        isTopNumFixd = True
    elif fix[i] == 0 and (i == 0 and n != 1):
        print(-1)
        exit(0)

for i in range(n):
    ans = ans * 10 + fix[i]

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[200010],vis[200010];
vector<int>v;
int main(){
    int l;
    cin>>l;
    double v=(l*l*l)/27.0;
    cout<<setprecision(7)<<v;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}



signed main(){
  int n,k,ans;string s;cin>>n>>k>>s;
  s[k-1] = s[k-1]+ 0x20;
  cout << s << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <climits>
#include <algorithm>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    
    vector<int> g(n);
    int ans = a[n-1];
    for(int i=1; i<n; i++){
        ans = __gcd(ans, a[n-i]);
        g[n-i] = ans;
    }
    g[0] = a[0];
    
    for(int i=1; i<n-1; i++){
        int tmp = __gcd(g[0], g[i+1]);
        if(tmp > ans){
            ans = tmp;
        }
        g[0] = __gcd(g[0], a[i]);
    }
    ans = g[0] > ans ? g[0] : ans;
    
    if(n == 2){
        ans = a[0] > a[1] ? a[0] : a[1];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define for(i,a,b) for(int i=a;i<=b;i++)
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
_inline void read(int &x){
	int res=0,f=1;
	char c=getchar();
	if(c=='-') f=-1;
	while(c>'9'||c<'0') c=getchar();
	while(c>='0'&&c<='9'){
		res=res*10+c-'0';
		c=getchar();
	}
	x=res*f;
}
inline void print(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
int a,b,h;
int main(){
	read(a),read(b),read(h);
	print((a+b)*h/2);
	exit(0);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include<set>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
llfor;///////////////////////////////////////////////////////////
int main(){
 ll n,k;
 sc(k);sc(n);
 pr(k-n+1);
return 0;}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};
//スタート点,頂点数、辺を渡して、最短経路の配列を返す
std::vector<int> dijkstra(int s,int N,vector<Edge> E){
    std::vector<int> ans(N,INF);
    std::vector<std::vector<Edge>> Edges(N);
    FOREACH(e,E){
        Edges.at(e.from).push_back(e);
    }
    priority_queue<P, std::vector<P>, greater<P>> que;
    ans.at(s)= 0;
    que.push(make_pair(0,s));
    while(!que.empty()){
        P p = que.top();que.pop();
        if(ans.at(p.second) < p.first)continue;
        for(int i = 0;i < Edges.at(p.second).size();i++){
            if(ans.at(p.second) + Edges.at(p.second).at(i).value < ans.at(Edges.at(p.second).at(i).to)){
                ans.at(Edges.at(p.second).at(i).to) = ans.at(p.second) + Edges.at(p.second).at(i).value;
                que.push(make_pair(ans.at(Edges.at(p.second).at(i).to),Edges.at(p.second).at(i).to));
            }
        }
    }
    return ans;
}
int main(){
    CIN(N);CIN(M);
    V<Edge> vec;
    REP(a,M){
        CIN(from);
        CIN(to);
        CIN(value);
        Edge e(from-1,to-1,value);
        Edge w(to-1,from-1,value);
        vec.pb(e);
        vec.pb(w);
    }
    V<V<int>> moke;
    for(int a = 0;a < N;a++){
        moke.pb(dijkstra(a,N,vec));
    }
    int ans = 0;
    REP(a,M*2){
        bool result = true;
        REP(b,N){
            REP(c,N){
                if(moke.at(b).at(vec.at(a).from)+vec.at(a).value+moke.at(vec.at(a).to).at(c)==moke.at(b).at(c)){
                    result = false;
                }
            }
        }
       if(result)ans++;
    }
    COUT(ans/2);
}


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

int main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL);
    int n ; 
    cin >> n;
    vector<int> a(n+1,0);
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }

    vector<int> prefGcd(n+1);
    prefGcd[0] = 0;
    for (int i = 1; i <= n; ++i)
        prefGcd[i] = __gcd(prefGcd[i-1], a[i]);

    vector<int> sufGcd(n+2);
    sufGcd[n+1] = 0;
    for (int i = n; i > 0; --i)
        sufGcd[i] = __gcd(sufGcd[i+1], a[i]);

    int res = 0;
    for (int i = 1; i <= n; ++i) {
        res = max(res, __gcd(prefGcd[i-1], sufGcd[i+1]));
    }
    cout << res << endl;
    return 0;
}


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

int main() {
    string s, t;
    cin >> s >> t;
    int sl = s.length();
    int tl = t.length();
    int idx = -1;
    int cnt = 0;
    
    rep(i, (sl - tl + 1)) {
        bool f = true;
        
        rep(ii, tl) {
            if ((s[i + ii] != t[ii]) && (s[i + ii] != '?')) {
                f = false;
                break;
            }
        }
        
        if (f) {
            idx = i;
        }
    }
    
    if (idx == -1) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    
    rep(i, sl) {
        if ((i >= idx) && (i < (idx + tl))) {
            s[i] = t[cnt++];
        }
        else if (s[i] == '?') {
            s[i] = 'a';
        }
    }
    
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
void erato(bool prime[], int N) {
    for (int i = 0; i < N; ++i) prime[i] = true;
    prime[0] = prime[1] = false;
    for (int i = 2; i*i <= N; ++i)
        if (prime[i])
            for (int j = i*2; j <= N; j+=i) prime[j] = false;
}
#include<iostream>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    bool prime[2<<17];
    erato(prime, 2<<17);

    int num[2<<17] = {};
    for(int i=3; i<2<<17; i+=2)
        if(prime[i] && prime[(i+1)/2]) ++num[i];
    for(int i=1; i<2<<17; ++i) num[i] += num[i-1];
    
    int Q;
    cin >> Q;
    for(int i=0; i<Q; ++i){
        int l, r;
        cin >> l >> r;
        cout << num[r] - num[l-1] << endl;
    }
}


Measured memory_bytes: 1920
# -*- coding: utf-8 -*-
import sys
INF=10**9
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()

def main():
    l=list(input())+['7']
    ans=[l[i//2] for i in range(10)]
    ans[-2]=ans[-3]='='
    for i in range(8):
        for j in range(3):
            if (i>>j)&1:
                ans[j*2+1]='+'
            else:
                ans[j*2+1]='-'
        if eval(''.join(ans)):
            del ans[-2]
            print(''.join(ans))
            exit()

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	string A, B, C;
	cin >> A >> B >> C;
	YESNO(A.back() == B.front() && B.back() == C.front());
}

Measured memory_bytes: 256
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);

	double calc(int a,int b){

		return Math.sqrt((a+b)*(a+b) - (a-b)*(a-b));

	}

	

	void run(){

		for(;sc.hasNextLine();){

			Scanner in = new Scanner(sc.nextLine());

			int boxSize = in.nextInt();

			LinkedList<Integer> data = new LinkedList<Integer>();

			for(;in.hasNextInt();){

				data.push(in.nextInt());

			}			

			double[][] dp = new double[1<<data.size()][data.size()];

			for(int i = 1 ; i< 1<<data.size(); i++){

				Arrays.fill(dp[i], Double.MAX_VALUE);

			}

			for(int i =0; i < data.size(); i++){

				dp[1<<i][i] = data.get(i);

			}

			for(int i = 1; i< 1<<data.size(); i++){

				for(int j = 0; j < data.size();j++){

					int sh = 1<<j;

					if((i & sh) != 0){

						continue;

					}

					for(int k = 0; k < data.size();k++){

						dp[i|sh][j] = Math.min(dp[i][k] + calc(data.get(j),data.get(k)),dp[i|sh][j]);		

					}

				}

			}

			double min = Double.MAX_VALUE;

			for(int i = 0; i < data.size();i++){

				dp[(1<<data.size()) - 1][i] += data.get(i);

				min = Math.min(min, dp[(1<<data.size())-1][i]);

			}

			System.out.println(min < boxSize+1e-8 ? "OK":"NA");

		}		

	}

	public static void main(String[] args){

		Main m = new Main();

		m.run();

	}

}

Measured memory_bytes: 14000
# coding: utf-8
# Your code here!

K, N = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

B = []
max_len = 0

for i in range(1, N):
    l = A[i] - A[i-1]
    max_len = max(max_len, l)
    B.append(l)
l = K-A[-1]+A[0]
max_len = max(max_len, l)
B.append(l)

sum_v = sum(B)
print(sum_v-max_len)


Measured memory_bytes: 26624
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;

int ds(int n) {
  int r = 0;
  while (n > 0) {
    r += n % 10;
    n /= 10;
  }
  return r;
}

int main(void) {

  ll h, n, a[100001];
  cin >> h >> n;
  rep(i, n) cin >> a[i];

  ll sum = 0;
  rep(i, n) sum += a[i];

  if (h > sum) cout << "No\n";
  else cout << "Yes\n";

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000



int main(){
	
	int N;
	cin>>N;
	string S;
	cin>>S;
	
	if(N%2==0&&S.substr(0,N/2) == S.substr(N/2)){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n;

    ll a[50];

    cin >> n;

    REP(i, n)
    cin >> a[i];

    ll res = 0;

    while (true)
    {
        ll s = 0;

        REP(i, n)
        {
            s += a[i] / n;
        }

        if (s == 0)
            break;

        res += s;

        REP(i, n)
        {
            ll tmp = s - a[i] / n;
            a[i] %= n;
            a[i] += tmp;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

int main() {
  //
  int n;
  cin >> n;
  ll sum = 0;
  vl a(n), s(n);
  rep(i, n) {
    cin >> a[i];
    if (i > 0) {
      s[i] = s[i - 1] + a[i];
    } else {
      s[i] = a[i];
    }
    sum += a[i];
  }
  ll m = INT_MAX;
  rep(i, n - 1) { m = min(m, abs(s[i] - (sum - s[i]))); }
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 3328
#include<stdio.h>
int main(void)
{
int a,b,d,r;
double f;
scanf("%d",&a);
scanf("%d",&b);
d = a/b;
r = a%b;
f = (double)a/b;
printf("%d %d %lf\n",d,r,f);
return 0;
}
  

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

using namespace std;

#define int long long
#define  IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int INF = 1e11;

signed main() {
    int n, m;
    cin >> n >> m;
    vector<int> v(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> v[i];
    }
    int sum=0;
    sum = accumulate(v.begin()+1, v.end(), sum);
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (4 * m * v[i] >= sum) {
            ans++;
        }
    }
    if(ans>=m) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,a,b;
vector<int> v[55];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&a,&b);
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for(int i=1;i<=n;i++){
		printf("%d\n",v[i].size());
	}
}

Measured memory_bytes: 256