akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int a, b,c; cin >> a>>b>>c;
	vector <int> n(3);
	n[0] = abs(a - b);
	n[1] = abs(a - c);
	n[2] = abs(c - b);
	ssort(n);
	cout << n[0] + n[1];


	cout << endl;
	return 0;
}

Measured memory_bytes: 256
n,q=map(int,input().split())
c=[0 for i in range(n)]
tree=sorted([list(map(int,input().split())) for i in range(n-1)])
for j in range(q):
    p,x=map(int,input().split())
    c[p-1]+=x
for i in range(n-1):
    c[tree[i][1]-1]+=c[tree[i][0]-1]
for i in range(n):
    c[i]=str(c[i])
print(' '.join(c))




Measured memory_bytes: 77352
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


ll n, now = INF;
vector<P> s;
int main() {
	cin >> n;
	REP(i, n) {
		ll a, b;
		cin >> a >> b;
		s.push_back(P(b, a));
	}
	sort(ALL(s), greater<P>());
	REP(i, n) {
		now = min(now, s[i].first);
		now -= s[i].second;
	}
	if (now < 0)cout << "No" << endl;
	else cout << "Yes" << endl;
}	


Measured memory_bytes: 6556
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d;
cin>>a>>b>>c>>d;
if(abs(c-a)<=d){
cout<<"Yes"<<endl;
}
else if(abs(b-a)<=d&&abs(c-b)<=d){
    cout<<"Yes"<<endl;
}
else
{
    cout<<"No"<<endl;
}

}


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

using namespace std;

int main(){
	int n; cin >> n;
	for(int i=0;i<n;i++){
		string s, t; cin >> s >> t;
		int a[4] = {}, b[4] = {};
		int num = 1;
		for(int j=0;j<s.length();j++){
			if(s[j]=='m') a[0] = num, num = 1;
			else if(s[j]=='c') a[1] = num, num = 1;
			else if(s[j]=='x') a[2] = num, num = 1;
			else if(s[j]=='i') a[3] = num, num = 1;
			else num = s[j]-'0';
		}
		num = 1;
		for(int j=0;j<t.length();j++){
			if(t[j]=='m') b[0] = num, num = 1;
			else if(t[j]=='c') b[1] = num, num = 1;
			else if(t[j]=='x') b[2] = num, num = 1;
			else if(t[j]=='i') b[3] = num, num = 1;
			else num = t[j]-'0';
		}
		int carry = 0;
		int sum[4] = {};
		for(int i=3;i>=0;i--){
			sum[i] = a[i] + b[i] + carry;
			carry = sum[i] / 10;
			sum[i] %= 10;
		}
		char c[4] = { 'm', 'c', 'x', 'i' };
		for(int i=0;i<4;i++){
			if(sum[i]>1) cout << sum[i];
			if(sum[i]>0) cout << c[i];
		}
		cout << endl;
	}
}

Measured memory_bytes: 0
import java.util.Scanner;
import java.util.Stack;

public class Main {
	public static void main(String [] args){
		Stack<Integer> stack = new Stack<Integer>();
		Scanner scanner = new Scanner(System.in);
		String string = scanner.nextLine();
		String [ ] strings = string.split(" ");
		int size = strings.length;
		int i = 0;
		while( i<size ){
			if("+".equals(strings[i])){
				int a = stack.pop();
				int b = stack.pop();
				int c = a+b;
				stack.push(c);
			}else if("-".equals(strings[i])){
				int a = stack.pop();
				int b = stack.pop();
				int c = b-a;
				stack.push(c);
			}else if("*".equals(strings[i])){
				int a = stack.pop();
				int b = stack.pop();
				int c = b*a;
				stack.push(c);
			}else{
				stack.push(Integer.parseInt(strings[i]));
				
			}
			i++;
		}
		
		System.out.println(stack.pop());
		scanner.close();
	}
}

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


ll countYakusu(ll x){
    vector<ll> vec;
    ll result=0;
    for(ll i = 1; i*i <= x; i++){
      if(x%i==0){
        result++;
        // vec.push_back(i);
        if(x!=i*i){
          result++;
          // vec.push_back(x/i);
        }
      }
    }
    cout << x << ":" << result << endl;
    return result;
}

// 間に合わない
void solve(ll N){
  ll result=0;
  for(ll i=1; i<=N; i++){
    for(ll l=1; l*l <= i; l++){
      if(i%l==0){
        result+=i;
        if(i!=l*l){
          result+=i;
        }
      }
    }
  }
  cout << result << endl;
}

// 約数の数を記録していく
void solve2(ll N){
  vector<int> record_yakusu(N+1,0);

  // 約数を全てカウント
  for(ll i=1; i<=N; i++){
    for(ll l=i; l <= N; l+=i){
      record_yakusu[l]++;
    }
  }

  ll result=0;
  for(ll i=1; i<=N; i++){
    result += i * record_yakusu[i];
  }
  cout << result << endl;

}

int main(){
  // 標準入力高速化のおまじない
  // scanfとの同期を切る。以降紛らわしいのでscanf使用不可。
  ios::sync_with_stdio(false);
  // // cin前の自動flashをやめる
  cin.tie(nullptr);
  ll N;
  cin >> N;
  solve2(N);
  return 0;
}

Measured memory_bytes: 42276
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1<<60)
#define MOD 1000000007
# define rep(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int xdif = abs(x1 - x2);
    int ydif = abs(y1 - y2);
    if (x1<=x2&&y1<=y2)cout<<x2-ydif<<' '<<y2+xdif<<' '<< x1-ydif<<' '<<y1+xdif<<endl;
    else if (x1>=x2&&y1<=y2)cout<<x2-ydif<<' '<<y2-xdif<<' '<<x1-ydif<<' '<<y1-xdif<<endl;
    else if (x1>=x2&&y1>=y2)cout<<x2+ydif<<' '<<y2-xdif<<' '<<x1+ydif<<' '<<y1-xdif<<endl;
    else if (x1<=x2&&y1>=y2)cout<<x2+ydif<<' '<< y2+xdif<<' '<<x1+ydif<<' '<<y1+xdif <<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		if(n == 1){
			System.out.println(1);
		} else {
			long[] l = new long[n+1];
			l[0] = 2;
			l[1] = 1;
			l[2] = 3;
			for(int i = 3;i <= n;i++){
				l[i] = l[i-1] + l[i-2];
			}
			System.out.println(l[n]);
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
#define ll long long
#define F(type, i, a, b) for(type i = a; i <= b; i ++)
#define RF(type, i, a, b) for(type i = a; i >= b;i --)
#define sz(a) sizeof(a)
#define deb(a) cerr<<" ["<<#a<<"->"<<a<<"] "
#define next_line cerr<<'\n'
#define all(a) a.begin(), a.end()
#define iter(it, s) for(auto it = s.begin(); it != s.end(); it ++)

using namespace std;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

void solve()
{
    //If you cannot approach a problem
    //directly in the way it is proposed then try to think from backwards
    int n;
    cin>>n;
    if(n % 7 == 0){
        n /= 7;
    }
    ll term = 1LL;
    F(int, i, 1, 9*n){
        term *= 10LL;
        term %= 9LL * n;
        if(term == 1LL){
            cout<<i<<'\n';
            return;
        }
    }
    cout<<"-1\n";
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        freopen("Debug.txt", "w", stderr);
    #else
    #endif
        solve();
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int X;
	cin >> X;
	for (int i = 1; i <= 7; ++ i) {
		if (X >= 2000 - i*200) {
			cout << i << endl;
			return 0;
		}
	}
	cout << 8 << endl;
}


Measured memory_bytes: 3592
/*|In The Name of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

int n;
int h[N];
int dp[N];

int main(){
    scanf("%d" , &n);
    for(int i = 1; i <= n; i++){
        scanf("%d" , &h[i]);
        dp[i] = 1e9;
    }
    dp[1] = 0;
    for(int i = 2; i <= n; i++){
        if(i - 2 >= 1)
         dp[i] = dp[i - 2] + abs(h[i] - h[i - 2]);
        dp[i] = min(dp[i] , dp[i - 1] + abs(h[i] - h[i - 1]));
    }
    printf("%d\n" , dp[n]);
    return 0;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());

  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = j + 1; k < n; k++) {
        if (a[i] == a[j] || a[j] == a[k] || a[i] == a[k]) continue;
        if (a[i] + a[j] > a[k]) ans++;
      }
    }
  }
  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3664
#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

const int MOD = 1e9 + 7;

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

	int n, k;
	cin >> n >> k;
	n++;
	vector<int> ps(n + 1);
	for (int i = 0; i < n; i++) {
		ps[i + 1] = ps[i] + i;
	}
	int ans = 0;
	for (int tk = k; tk <= n; tk++) {
		int small = ps[tk];
		int big = ps[n] - ps[n - tk];
		// cerr << small << ' ' << big << endl;
		ans += (big - small + 1);
		ans %= MOD;
	}
	cout << ans << endl;
}


Measured memory_bytes: 4364
import sys
sys.setrecursionlimit(10**8)
alpha = "abcdefghij"
ans = []
N = int(input())

def dfs(S, num):
    if len(S) == N:
        ans.append(S)
    else:
        right = num + 2
        seq = alpha[:right]
        for i, c in enumerate(seq):
            dfs(S+c, max(i, num))

dfs("a", 0)
ans = sorted(ans)
for a in ans:
    print(a)

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

int main() {
    string T; cin >> T;
    for (int i = 0; i < T.size(); i++) {
        if (T.at(i) == '?') {
            T.at(i) = 'D';
        }
    }
    cout << T << endl;
}

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

int main(){
  int n;
  string s[60];
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> s[i];
  }
  char kekka[60]; 
  char alp = 'a';
  char b[30];
  for(int i = 1;i <= 26;i++){
    b[i] = alp;
    alp++;
  }
  int mozisu[30];
  for(int i = 1;i <= 26;i++){
    mozisu[i] = 100;
  }
  for(int k = 1;k <= 26;k++){
    for(int i = 0;i < n;i++){
      int cur = 0;
      for(int j = 0;j < s[i].size();j++){
        if(s[i].at(j) == b[k]){
          cur++;
        }
      }
      mozisu[k] = min(mozisu[k],cur);
    }
  }
  
  for(int i = 1;i <= 26;i++){
    for(int j = 1;j <= mozisu[i];j++){
      cout << b[i];
    }
  }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
int calc (string s) {
  string t;
  vector<int> cnt;
  for (char c : s) {
    if (t.empty() || t.back() != c) {
      t.push_back(c);
      cnt.push_back(1);
    } else {
      cnt[(int) cnt.size() - 1]++;
    }
  }
  int res = 0;
  for (int i = 1; i + 1 < (int) t.size(); i++) {
    if (t[i - 1] == 'B' && t[i] == 'W' && t[i + 1] == 'B') return 0;
    if (t[i - 1] == 'W' && t[i] == 'B' && t[i + 1] == 'W') res = max(res, cnt[i]);
  }
  return res;
}
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  for (char& c : s) {
    if (c == '.') {
      c = 'W';
      ans = max(ans, calc(s));
      c = '.';
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7;
const int MAX_N=10000;
int a,b,li[101];

int main(){
	REP(i,0,2) cin >> a >> b,li[a]++,li[b]--;
	
	int pos=0,s=0;
	REP(i,0,101){
		pos+=li[i];
		if(pos==2) s++;
	}
	
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <string>
#include <cctype>
#include <deque>
using namespace std;
typedef long long ll;
//__builtin_popcount(n);
#define IOS ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define RI register int
const int MOD = 998244353;
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int SZ = 2e5 + 10;
int n,s;
int A[SZ];
ll dp[3050][3050];
int main()
{
	/*
	int T;
	scanf("%d",&T);
	while(T --)
	{
		
	}
	*/
	//system("pause");
	scanf("%d%d",&n,&s);
	for(int i = 1;i <= n;i ++) scanf("%d",&A[i]);
	dp[0][0] = 1;
	for(int i = 1;i <= n;i ++)
		for(int j = 0;j <= s;j ++)
		{
			dp[i][j] =  (dp[i - 1][j] * 2) % MOD ; 
			if(j >= A[i]) dp[i][j] = ( dp[i][j] + dp[i - 1][j - A[i]] ) % MOD;
		}
	printf("%lld",dp[n][s]);
	return 0;
} 

Measured memory_bytes: 74712
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    s = input()
    t = input()

    res = n
    for i in range(n):
        for j in range(n):
            if i + j < n:
                if s[i + j] != t[j]:
                    break
        else:
            res = i
            break

    print(res + n)


if __name__ == '__main__':
    resolve()


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

#define N 10
#define MAX 101

int top;
int S[MAX];

void initialize(void);
int isEmpty(void);
int isFull(void);
void push(int);
int pop(void);

int main(void){
  char A[N];
  int x=0,a,b;
  int i;

  while(scanf(" %s",A) != EOF){
    if(A[0] == '+'){
      b = pop();
      a = pop();
      x = a + b;
      push(x);
    }
    else if(A[0] == '-'){
      b = pop();
      a = pop();
      x = a - b;
      push(x);
    }
    else if(A[0] == '*'){
      b = pop();
      a = pop();
      x = a * b;
      push(x);
    }
    else{
      x = atoi(A);
      push(x);
    }
  }

  printf("%d\n",pop());
  
  return 0;
}

void initialize(void){
  top = 0;
}

int isEmpty(void){
  return top == 0;
}

int isFull(void){
  return top >= MAX - 1;
}

void push(int x){
  if(isFull()){
    fprintf(stderr,"stuck is full\n");
  }
  else{
    top++;
    S[top] = x;
  }
}

int pop(void){
  if(isEmpty()){
    fprintf(stderr,"stuck is empty\n");
    return 0;
  }
  else{
    top--;
    return S[top+1];
  }
}



Measured memory_bytes: 2108
<?php
$input = explode(' ', trim(fgets(STDIN)));
switch($input[1]){
	case '+':
		$ans = $input[0] + $input[2];
		break;
	case '-':
		$ans = $input[0] - $input[2];
		break;
	default:
}
echo $ans.PHP_EOL;
?>

Measured memory_bytes: 3576
#include<vector>
#include<iostream>
using namespace std;
int main()
{
	char a, b, c;
	cin >> a >> b >> c;
	int A = 0;
	int B = 0; 
	int C = 0;
	if (a == 'o')
	{
		A += 100;
	}
	if (b == 'o')
	{
		B += 100;
	}
	if (c == 'o')
	{
		C+=100;
	}
	cout << 700 + A + B + C << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
    int M = sc.nextInt();
    int N = sc.nextInt();
    int[] count = new int[N];
    for (int i = 0; i < M; i++) {
	  int K = sc.nextInt();
      for (int j = 0; j < K; j++) {
		count[sc.nextInt()-1]++;
      }
    }
    int counter = 0;
    for (int i = 0; i < N; i++) if (count[i] == M) counter++;
    System.out.println(counter);
  }
}

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

int main(){
  int n;cin>>n;
  for(;n--;){
    double a,b,c,d,e,f,g,h;cin>>a>>b>>c>>d>>e>>f>>g>>h;
    cout<<(abs((d-b)*(g-e)-(h-f)*(c-a))<1e-10?"YES":"NO")<<endl;
  }
}



Measured memory_bytes: 3164
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
/*
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>


typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
*/

using namespace std;

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

    double x[105], y[105], d[105];
    for (int i = 0; i < n; i++)
        cin >> x[i];
    for (int i = 0; i < n; i++)
        cin >> y[i];
    for (int i = 0; i < n; i++)
        d[i] = abs(x[i] - y[i]);

    double d1 = 0, d2 = 0, d3 = 0, dinf = 0;
    for (int i = 0; i < n; i++)
    {
        d1 += d[i];
        d2 += pow(d[i], 2);
        d3 += pow(d[i], 3);
        dinf = max(dinf, d[i]);
    }
    d2 = sqrt(d2);
    d3 = pow(d3, 1.0 / 3.0);

    cout << fixed << setprecision(8) << d1 << endl;
    cout << fixed << setprecision(8) << d2 << endl;
    cout << fixed << setprecision(8) << d3 << endl;
    cout << fixed << setprecision(8) << dinf << endl;
}


Measured memory_bytes: 3396
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <numeric>
#include <array>
#include <float.h>
#include <memory>
#include <functional>
#include <iomanip>
#include <queue>
#include <random>
#include <map>
#include <set>

#pragma warning(disable:4996)

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (b - a == c - b ? "YES" : "NO") << endl;

  return 0;
}

Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(){

    int AB, BC, CA; cin>>AB>>BC>>CA;
    int ans = 0;

    cout<<AB*BC/2<<endl;
    return 0;
}

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

long long euclidean_gcd(long long a, long long b) {
    if(a < b) return euclidean_gcd(b, a);;
    long long r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
};
 
int main() {
    long long int a, b, c , d, lcm;
    cin >> a >> b >> c >> d;
    lcm = c*d/(euclidean_gcd(c, d));
    cout << b-a+1 - (b/c-(a-1)/c) - (b/d-(a-1)/d) + (b/lcm-(a-1)/lcm) << "\n";
}

Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

bool isAcgtStr(string str) {
    bool isAcgtStr = true;
    string acgt = "ACGT";
    for (char alphabet : str) {
        if (find(acgt.begin(), acgt.end(), alphabet) == acgt.end()) isAcgtStr = false;
    }
    return isAcgtStr;
}

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

    int ans = 0;
    for (int i = 0; i < S.size(); i++) {
        for (int j = 1; j <= S.size() - i; j++) {
            string subS = S.substr(i, j); // 部分文字列
            if (isAcgtStr(subS)) ans = max(ans, (int)subS.size());
        }
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

inline int read(){
	char ch=getchar();int x=0,f=1;
    while(ch<'0' || ch>'9') {
       if(ch=='-') f=-1;
	  	  ch=getchar();
	}
    while(ch<='9' && ch>='0') {
	   x=x*10+ch-'0';
	   ch=getchar();
	}
    return x*f;
}

char a[1001011],b[1010101];

int s[101010],t[1010011];

int main(){
	cin>>a+1;
	cin>>b+1;
	int l=strlen(a+1);
	for(int i=1;i<=l;i++){
		s[a[i]-'a']++;
		t[b[i]-'a']++;
	}
	sort(s,s+26);
	sort(t,t+26);
	for(int i=0;i<=25;i++){
		if(s[i]!=t[i]){
			cout<<"No\n";
			return 0;
		}
	}
	cout<<"Yes\n";
	return 0;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define vl vector<ll>
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define sz size()
#define en end()
#define ro return 0
#define br break
#define con continue;
#define um unordered_map<ll,ll>
#define ms(x) memset(x , 0 , so x)
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define forr(i,a,b) for(ll i=a;i<b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
int main()
{
    ios;
    ll n ;
    cin >> n ;
    ll t = n ;
    ll ans = 0 ;
    while(t > 0 ){
        ll foo = t% 10 ;
        t =  t / 10 ;
        ans = ans + foo ;
    }
    if(n % ans ){
        cout << "No\n";
        ro;
    }
    else cout << "Yes\n";
    ro ;

}


























Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;

int main() {
	int n;

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

	map<int64_t, int> b; //rabel ga ookisugiru

	int64_t ans =0;
	for (int i = 1; i <= n; i++) { //a[i]+i==j-a[j]
		ans += b[i - a[i-1]];
		b[a[i-1]+i]++;
	}

	cout << ans << endl;


}

Measured memory_bytes: 27372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;


int main() {
    string s; cin >> s;
    int ans = 0;
    for(int i = 0;i < 4;i++){
        if(s[i] == '+'){
            ans++;
        }else{
            ans--;
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

sa = set(a)
sa = list(sa)

if len(sa)>3:
    print('No')
    exit()

if len(sa)==3:
    aa = sa[0]
    bb = sa[1]
    cc = sa[2]
    if a.count(aa) != n/3 or a.count(bb) != n/3 or a.count(cc) != n/3:
        print('No')
        exit()
    if aa^bb^cc!=0:
        print('No')
        exit()

if len(sa)==2:
    aa = sa[0]
    bb = sa[1]
    if bb != 0 and aa != 0:
        print('No')
        exit()
    else:
        if aa==0:
            aa = bb
    if a.count(0) != n/3 or a.count(aa)!=n/3*2:
        print('No')
        exit()

if len(sa)==1:
    aa = sa[0]
    if aa != 0:
        print('No')
        exit()

print('Yes')



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

using ll = long long;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using ull = unsigned long long;

#define NL '\n'
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sii(x, y) scanf("%d%d",&x, &y)
#define sll(x, y) scanf("%lld%lld",&x, &y)

#define xx first
#define yy second
#define ins insert
#define mp make_pair
#define pb push_back
#define mdx ((l+r)>>1)
#define ldx ((idx<<1))
#define rdx ((idx<<1)|1)
#define sz(x) x.size()
#define pi 2.0*acos(0.0)
#define sqr(x)  ((x) * 1ll * (x))
#define all(x) (x).begin(),(x).end()
#define mem(a, b) memset(a, b, sizeof(a))
#define file_in(); freopen("input.txt", "r", stdin);
#define file_out(); freopen("output.txt", "w", stdout);
#define file_err(); freopen("serr.txt", "w", stderr);
#define rep(ii,aa,bb) for(ll (ii)=ll(aa);(ii)<(ll)(bb);++(ii))
#define _fastIO() ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define _runtime() cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"

template<class T> T setbit(T n, T pos){n=n|(1<<pos); return n;}
template<class T> T checkbit(T n, T pos){n=n&(1<<pos); return n;}
template<class T> T gcd(T a, T b ) {return b<=0?a:gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return ((a / gcd(a,b) ) * b);}





const int mxx = 1e5+9;
int n, w, a[101], b[101];
ll dp[101][mxx];

ll f(int pos, int weight){
	if(pos >= n || weight <= 0) return 0;
	ll &ret = dp[pos][weight];
	if(ret != -1) return ret;
	ret = f(pos+1,weight);
	if(weight >= a[pos]) ret = max(f(pos+1,weight-a[pos])+b[pos],ret);
	return ret;
}

int main(){
	_fastIO();
	cin >> n >> w;
	rep(i, 0, n) cin >> a[i] >> b[i];
	mem(dp, -1);
	cout << f(0, w) << NL; 
}

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

int main()
{
	int x, y;
	scanf("%d", &x);
	scanf("%d", &y);
	if (x == 2 || y == 2)
	{
		printf("%s\n", "No");
	}
	else if (x == 4 || x == 6 || x == 9 || x == 11)
	{
		if (y == 4 || y == 6 || y == 9 || y == 11)
		{
			printf("%s\n", "Yes");
		}
		else
		{
			printf("%s\n", "No");
		}
	}
	else if (x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12)
	{
		if (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12)
		{
			printf("%s\n", "Yes");
		}
		else
		{
			printf("%s\n", "No");
		}
	}
	else
	{
		printf("%s\n", "No");
	}

}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  string s;
  cin>>s;
  for(int i = 0; i < s.size(); i+=2){
    cout<<s[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>


using namespace std;

int main() {
	int N=0;

	cin >> N;
	std::vector<int> L(N);

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

	int max = *max_element(L.begin(),L.end());
	int sum = accumulate(L.begin(), L.end(), 0) - max;

	if (max < sum)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll n,m,x; cin >>n>>m>>x;
  vector<ll> c(n);
  vector<vector<ll>> a(n,vector<ll>(m));
  rep(i,n){
    cin >>c[i];
    rep(j,m) cin>>a[i][j];
  }
  ll ans=1000000007;
  for (int tmp = 0; tmp < (1 << n); tmp++) {
  bitset<12> s(tmp);
  // (ビット列sに対する処理)
    ll sum = 0;
    vector<ll> b(m,0);
    for (int i = 0; i < n; i++) {
      if (s.test(i)) {
        rep(j,m) b[j]+=a[i][j];
        sum+=c[i];
      }
    }
    int key=0;
    rep(i,m) if(b[i]<x) key=-1;
    if(key==0) {
      ans=min(ans,sum);
    }
  }
  if(ans!=1000000007)cout <<ans<<endl;
  else cout <<-1<<endl;
}

Measured memory_bytes: 3644
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val a = (1..n).map { sc.next() }


  val array = Array(n) { Array(26) { 0 } }
  
  for ((i, ai) in a.withIndex()) {
    val arrayi = array[i]
    for (c in ai) {
      val tmp = c.toInt() - 'a'.toInt()
      arrayi[tmp]++
    }
  }

  val map = mutableMapOf<String, Long>()
  for (ai in array) {
    if (ai.toList().contains(10)) {
      continue
    }
    
    val key = ai.joinToString("")
    val tmp = map.getOrElse(key) { 0L }
    map.put(key, tmp+1)
  }

  val size = map.values.filter { it > 1 }.map { it * (it - 1) / 2 }.sum()

  println(size)


}

Measured memory_bytes: 93948
#include <stdio.h>
#include <algorithm>

using namespace std;

void print(char str[],int a,int b){
	for(int i = a; i <= b; i++)	printf("%c",str[i]);
	printf("\n");
}

void replace(char str[],char p[],int a,int b){
	int p_length = b-a+1;
	for(int i = 0; i < p_length;i++) str[a+i] = p[i];
}

void reverse(char str[],int a,int b){
	int left = a,right = b;
	while(left < right){
		swap(str[left++],str[right--]);
	}
}

int main(){
	char str[1001],p[1001],order[8];
	int q,a,b;
	scanf("%s",str);
	scanf("%d",&q);
	for(int i = 0; i < q; i++){
		scanf("%s %d %d",order,&a,&b);
		switch(order[2]){
		case 'i':
			print(str,a,b);
			break;
		case 'v':
			reverse(str,a,b);
			break;
		case 'p':
			scanf("%s",p);
			replace(str,p,a,b);
			break;
		}
	}
}

Measured memory_bytes: 1000
k, n = map(int, input().split())
lst = list(map(int, input().split()))
lst.sort()
dlst = list()

for i in range(n):
    if i == 0:
        continue
    dlst.append(lst[i] - lst[i - 1])

if lst[0] == 0:
    dlst.append(k - lst[n - 1])
else:
    dlst.append(k - lst[n - 1] + lst[0])

dlst.sort(reverse=True)
dlst.pop(0)

print(sum(dlst))

Measured memory_bytes: 26444
s = [i for i in input()]
count = 1
s0 = s[0]
flag = 0
for i in range(1, len(s)):
    try:
        if flag==1:
            flag = 0
            continue
        if s0==s[i]:
            s0 = s[i] + s[i+1]
            flag = 1
        else:
            s0 = s[i]
        count += 1
    except:
        continue
print(count)

Measured memory_bytes: 5096
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
ll a,b,k;
cin>>a>>b>>k;
ll flag=0;
for(int i=100;i>=1;i--){
    if(flag>=k-1&&a%i==0&&b%i==0){
        cout<<i<<endl;
        break;
    }
        if(a%i==0&&b%i==0){
        flag++;
    }
}
}












Measured memory_bytes: 256
K, A, B = [int(_) for _ in input().split()]
if B - A < 3:
    print(1 + K)
    exit()

if (K - A + 1) % 2 == 0:
    K1 = A - 1
    K2 = (K - A + 1) // 2
else:
    K1 = A
    K2 = (K - A) // 2
print(1 + K1 + K2 * (B - A))


Measured memory_bytes: 3060
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(D, G, pc):
    point_map = []
    point_sum = []
    for i in range(D):
        p, c = pc[i]
        tmp = [100 * (i + 1)] * p
        tmp[-1] += c
        point_map.append(tmp)
        point_sum.append(sum(tmp))

    ans = 100 * 11
    for i in range(2 ** D):
        count = 0
        point = 0
        other_problems = []
        for j in range(D):
            if i >> j & 1:
                count += pc[j][0]
                point += point_sum[j]
            else:
                other_problems = point_map[j][:-1] + other_problems
        if point < G:
            for op in other_problems:
                count += 1
                point += op
                if point >= G:
                    break
        if point >= G:
            ans = min(ans, count)
    print(ans)


if __name__ == '__main__':
    D, G = map(int, input().split())
    pc = [[int(i) for i in input().split()] for _ in range(D)]
    solve(D, G, pc)

    # # test
    # from random import randint
    # from func import random_str
    # solve()


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

int main(){

    long long N, M;
    cin >> N >> M;
    vector<pair<long long, long long> > bridge(M);
    for(long long i = 0; i < M; i++) cin >> bridge[i].second >> bridge[i].first;

    sort(bridge.begin(), bridge.end());

    long long ans = 1;
    long long right = bridge.front().first;
    for(int i = 1; i < M; i++){
        if(bridge[i].second >= right){
            ans++;
            right = bridge[i].first;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <map>
//#include "test.h"

using namespace std;

int main()
{
	string sToday;
	string sDays[8] = { "","SAT","FRI","THU","WED","TUE","MON","SUN" };

	cin >> sToday;

	for (int i = 1; i < 8; i++) {
		if (sToday == sDays[i]) {
			cout << i << endl;
			break;
		}
	}

	return 0;
}

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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

string s;

signed main()
{

    cin >> s;

    bool ans = true;

rep(i,s.size() ){
    if(i%2==0){
        if(s[i]=='L'){
            ans = false;
        }
    }
    else{
        if(s[i]=='R'){
            ans = false;
        }

    }

   

}

 if(ans){
        print("Yes");
    }
    else{
        print("No");
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
typedef long long ll;
const int maxn=1e6+5;
using namespace std;
const ll INF=1e13+7;
ll n,m;
char str[maxn];
ll dp[maxn];
ll q[maxn];
int pre[maxn];
void TraceBack(int x)
{
    if(pre[x]==-1)
    {
        printf("%d",x);
        return;
    }
    TraceBack(pre[x]);
    printf(" %d",x-pre[x]);
}
int main()
{
    memset(pre,-1,sizeof(pre));
    scanf("%lld%lld",&n,&m);
    scanf("%s",str);
    //数有n+1个
    int s=1,e=0;
    for(int i=0;i<=m;i++)
    {
        if(str[i]=='0')
            dp[i]=1;
        else
            dp[i]=INF;
        while(s<=e&&dp[i]<dp[q[e]]) e--;
        q[++e]=i;
    }
    s++;
    for(int i=m+1; i<=n; i++)
    {
        dp[i]=INF;
        if(str[i]=='0')
        {
            dp[i]=min(dp[q[s]]+1,dp[i]);
            if(!dp[i]!=INF)
                pre[i]=q[s];
        }
        while(s<=e&&dp[i]<dp[q[e]]) e--;
        q[++e]=i;
        while(s<=e&&q[s]<i+1-m)
            s++;
    }
    if(dp[n]==INF) printf("-1\n");
    else TraceBack(n);
    return 0;
}
 
/**
**/

Measured memory_bytes: 15872
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define clr clear()
#define sqr(a) (a*a)
#define mk make_pair
#define pb push_back
string en="\n";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define per(i,n) for(i=n-1;i>=0;i--)
#define peR(i,n) for(i=n;i>0;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
#define srch(a,x) binary_search(all(a),x)
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef unsigned long long ULL;
bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,c=0;
    while(cin>>n>>x>>y)
    {
        if(y<=x) cout<<"delicious"<<en;
        else if(y-x<=n) cout<<"safe"<<en;
        else cout<<"dangerous"<<en;
    }
}



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

using namespace std;

using ll = int64_t;

/// <summary>
/// 単純なcoutの時に使う
/// </summary>
#define co(a) cout<<a<<"\n"


/// <summary>
/// [beg, end)の範囲を，添え字indexでループするfor文に置換します
/// </summary>
#define rep(i,a) for(ll i=0; i<a; ++i)
#define reps(i, a, b) for(ll i = a; i < b; ++i)

/// <summary>
/// 迷路等で使う方向のベクトル
/// </summary>
const vector<ll> dx = { 0, 1, 0, -1 }, dy = { 1, 0, -1, 0 };

/// <summary>
/// デバッグ時に使う
/// </summary>
#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

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

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

	ll a;
	string s;
	cin >> a >> s;

	if (a >= 3200) {
		cout << s << endl;
	}
	else {
		cout << "red" << endl;
	}
}



Measured memory_bytes: 256
N = int(input())
L = [''] * N
for i in range(N):
    L[i] = input()
count = []
for i in range(N):
    C = [0] * 26
    S = list(L[i])
    for j in range(len(S)):
        num = ord(S[j]) - ord('a')
        C[num] = C[num] + 1
    count.append(C)
minimum = []
for i in range(26):
    M = 100
    for j in range(N):
        if count[j][i] < M:
            M = count[j][i]
    minimum.append(M)
flag = False
result = []
for i in range(26):
    if minimum[i] > 0:
        flag = True
        for j in range(minimum[i]):
            result.append(chr(ord('a') + i))
if flag == True:
    print(''.join(result))
else:
    print('')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;

db dp[3000][1600];

db fun(int c,int h,db *a)
{
    if(h==0)return 1;
    if(c==0)return 0;
    if(dp[c][h]>-0.9)return dp[c][h];
    return dp[c][h]=a[c-1]*fun(c-1,h-1,a)+(1-a[c-1])*fun(c-1,h,a);
}
void solve()
{
    int n;
    cin>>n;
    db a[n];
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    int h=(n+1)/2;
    memset(dp,-1,sizeof(dp));
    fun(n,h,a);
    cout<<fixed<<setprecision(10)<<dp[n][h];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    while(t--){
        solve();
        cout<<endl;
    }
}


Measured memory_bytes: 41568
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>

typedef long long ll;

const int N=201000;
const ll INF=1000000000000ll;

int A[N];
int n;

ll f(ll x)
{
	ll ret=0;
	for(int i=1;i<=n;i++)
		ret+=std::abs(A[i]-(x+i));
	return ret;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",A+i);

	ll u=INF,d=-INF;

	while(u-d+1>=3)
	{
		ll len=u-d+1;
		len/=3;

		if(f(d+len)<=f(u-len))u-=len;
		else d+=len;
	}

	while(f(d+1)<f(d))d++;

	printf("%lld\n",f(d));

	return 0;
}


Measured memory_bytes: 1024
from heapq import heappush, heappop

v,e,r = map(int,input().split())

edge = [[] for _ in range(v)]

for _ in range(e):
    s,t,d = map(int,input().split())
    edge[s].append((t, d))

cost = [float('inf')]*v
cost[r] = 0

q = [(r, 0)]
while q:
    now, distance = heappop(q)
    #print(q,now,distance)
    
    for nxt, newcost in edge[now]:
        if distance + newcost < cost[nxt] :
            cost[nxt] = distance + newcost
            heappush(q, (nxt, distance + newcost))

for i in range(v):
    if cost[i] == float('inf'):
        print('INF')
    else:
        print(cost[i])


Measured memory_bytes: 138224
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

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

    var(int, s, w);
    if (w >= s) {
        print("unsafe");
    } else {
        print("safe");
    }

    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int main(void){
    int N, A, B;
    cin >> N >> A >> B;

    cout << min(N*A, B) << '\n';

    return 0;
}

Measured memory_bytes: 256