akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}




signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
 
    string s;
    cin>>s;
    int a[4];
    for(int i=0;i<4;i++){
        a[i] = s[i] - '0';
    }
    for(int bit=0;bit<(1<<3);bit++){
        int now = a[0];
        for(int i=0;i<3;i++){
            if(bit&(1<<i)){
                now += a[i+1];
            }
            else now -= a[i+1];
        }
        if(now == 7){
            cout << a[0];
            for(int i=0;i<3;i++){
                if(bit&(1<<i)){
                    cout << "+";
                }
                else cout << "-";
                cout << a[i+1];
            }
            cout << "=7";
            cout << endl;
            return 0;
        }
    }
}

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


class Program{
    public static void Main(){
        int number = 0;
        string S = ReadLine();
        
        for(int i = 0; i < S.Length; i++){
            if(S[i] == '+'){
                number++;
            }
            else{
                number--;
            }
        }
        WriteLine(number);
    } 
}

Measured memory_bytes: 11092
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stdint.h>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
typedef pair<int ,int> pp;

int main(){
    int n;
    cin>>n;
    vector<pp> v;
    for(int i = 0; i < n; i++){
        int a,b;
        cin>>a>>b;
        pp x = make_pair(a, b);
        v.push_back(x);
    }
    double k;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            int p = v[i].first - v[j].first;
            int q = v[i].second - v[j].second;
            k += sqrt(p * p + q * q);
        }
    }
    k = 2 * k / n;
    printf("%f\n", k);
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define EPS 1e-10
#define INF 1000000000
#define mp make_pair
#define pb push_back

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

int main() {
  int N;
  cin >> N;
  vi D(N);
  map<int, int> exists, wants;
  for (int i = 0; i < N; i++) {
    cin >> D[i];
    if (exists.count(D[i])) {
      exists[D[i]] = exists.find(D[i])->second + 1;
    } else {
      exists[D[i]] = 1;
    }
  }
  int M;
  cin >> M;
  vi T(M);
  for (int i = 0; i < M; i++) {
    cin >> T[i];
    if (wants.count(T[i])) {
      wants[T[i]] = wants.find(T[i])->second + 1;
    } else {
      wants[T[i]] = 1;
    }
  }

  bool ok = true;
  map<int, int>::iterator it;
  for (it = wants.begin(); it != wants.end(); ++it) {
    int w = (*it).first;
    map<int, int>::iterator e = exists.find(w);
    if (exists.count(w) < 1 || (*it).second > (*e).second) {
      ok = false;
      break;
    }
  }

  if (ok) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 20608
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1000000;
const int mod = 1000000000+7;
const ll INF = 1LL << 60;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define fix(n) fixed<<setprecision(n)
#define itr vector<ll>::iterator
#define print(s) cout<<s<<endl
#define input(s) cin>>s
ll n, v[100010],ct[100010];
int main() {
	bool ans = 1;
	input(n);
	rep(i, n)input(v[i]),ct[v[i]]++;
	if (n % 2 == 0) {
		for (int i = 1; i < n; i += 2)if (ct[i] != 2)ans = 0;
	}
	else {
		if (ct[0] != 1)ans = 0;
		for (int i = 2; i < n; i += 2)if (ct[i] != 2)ans = 0;
	}
	ll num = 1;
	rep(i, n / 2)num *= 2, num %= mod;
	print((ans ? num : 0));
	return 0;
}

Measured memory_bytes: 1792
N = int(input())
count = [[0] * 10 for _ in range(10)]
ans = 0
for i in range(1,N + 1):
    a, b = int(str(i)[0]), int(str(i)[-1])
    count[a][b] += 1
for i in range(1,10):
    for j in range(10):
        ans += count[i][j] * count[j][i]
print(ans)     

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

int main() {
  int N, K; cin >> N >> K;
  vector<long long> H(N); for(int i = 0; i < N; ++i) cin >> H[i];
  sort(H.rbegin(), H.rend());
  long long ans = 0;
  for(int i = K; i < N; i++) ans += H[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
/*Rabbi Zidni Ilma*/

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define scl(n) scanf("%lld",&n)
#define scll(n,m) scanf("%lld%lld",&n,&m)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define mod 1000000007
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)

ll dp[105][100005],w[100005],p[100005];

int main()
{
	ll n,c,i,j;
    scll(n,c);
    for(i=1;i<=n;i++)
    scll(w[i],p[i]);
    
    for(i=n;i>=1;i--)
    {
    	for(j=0;j<=c;j++)
    	{
    		if(j-w[i]>=0)
    		dp[i][j]=max(dp[i+1][j],dp[i+1][j-w[i]]+p[i]);
    		else
    		dp[i][j]=dp[i+1][j];
		}
	}
	ll ans=0;
	for(i=0;i<=c;i++)
	{
		ans=max(ans,dp[1][i]);
	}
    printf("%lld\n",ans);
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

int main() {
  string s, t;
  cin >> s >> t;
  for (int i = s.size() - t.size(); 0 <= i; i--) {
    bool can = true;
    for (int j = 0; j < t.size(); j++) {
      if (s[i + j] != t[j] && s[i + j] != '?') can = false;
    }
    if (can) {
      for (int j = 0; j < i; j++)
        cout << ((s[j] == '?') ? 'a' : s[j]);
      cout << t;
      for (int j = i + t.size(); j < s.size(); j++) {
        cout << ((s[j] == '?') ? 'a' : s[j]);
      }
      cout << endl;
      return 0;
    }
  }
  cout << "UNRESTORABLE" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)



int main(){
    string s,kai;
    cin >> s;
    
    for(int i = 0;i < s.size();i += 2){
        kai += s.at(i);
    }

    cout << kai << endl;

}

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

int main( int argc, char *argv[] )
{
int i;
char S[ 100 ];

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> S;
	i = strlen( S );
	S[ i - 8 ] = '\0';
	cout << S << endl;

	return 0;
}




Measured memory_bytes: 256
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

N, X = map(int, input().split())
if N>1: x = [int(_)-X for _ in input().split()]; print(gcd_list(x))
else: x = int(input()) - X; print(abs(x))


Measured memory_bytes: 87704
# ABC150C
"""
大きさ N の順列 ((1, 2, ..., N) を並び替えてできる数列) P, Qがあります。
大きさ Nの順列は N! 通り考えられます。このうち、P が辞書順で a 番目に小さく、Q が辞書順で b 番目に小さいとして、|a−b|を求めてください。
2つの数列 X, Y について、ある整数 k が存在して Xi=Yi(1≤i<k) かつ Xk<Yk が成り立つとき、X は Y より辞書順で小さいと定義されます。
"""

from itertools import permutations 

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

ls = list(permutations(range(1, n+1)))

print(abs(ls.index(p) - ls.index(q)))



Measured memory_bytes: 13864
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#define N 100005
using namespace std;
typedef long long ll;
int n;
string s;
string getres(char a, char b) {
	string res(n, ' ');
	res[0]= a;
	res[n-1] = b;
	for (int i = 0; i < n; ++i) {
		int j = (i+1) % n;
		int k = (i-1+n)%n;
		char nxt;
		if (res[i] == 'S') {
			if (s[i] == 'o') {
				nxt = res[k];
			} else {
				nxt = (res[k] == 'S' ? 'W' : 'S');
			}
		} else {
			if (s[i] == 'x') {
				nxt = res[k];
			} else {
				nxt = (res[k] == 'S' ? 'W' : 'S');
			}
		}
		if (res[j] != ' ') {
			if (res[j] != nxt) return "";
		} else {
			res[j] = nxt;
		}
	}
	return res;
}
int main() {
	cin>>n>>s;
	string res=getres('S', 'S');
	if (!res.empty()) {
		cout<<res<<endl;
	} else {
		res = getres('S', 'W');
		if (!res.empty()) {
			cout<<res<<endl;
		} else {
			res= getres('W', 'S');
			if (!res.empty()) {
				cout<<res<<endl;
			} else {
				res = getres('W', 'W');
				if (!res.empty()) {
					cout<<res<<endl;
				} else {
					cout<<-1<<endl;
				}
			}
		}
	}
	return 0;
}

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

int main(void) {
    int N;
    cin >> N;

    int count = 0;
    for (int i = 0; i < N; i++) {
        int l_i, r_i;
        cin >> l_i >> r_i;
        count += r_i - l_i + 1;
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
//A - Weather Prediction
//2019/9/20

#include <stdio.h>

int main(void) {
    char weather[7];
    scanf("%s",weather);
    if (weather[0]=='S') {
        printf("Cloudy\n");
    }
    else if (weather[0]=='C') {
        printf("Rainy\n");
    }
    else {
        printf("Sunny\n");
    }
    return 0;
}

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

int main(){
  int N;
    long long int ans;
    cin >>N;
    cin>>ans;
    bool t=true;
  
    if(ans>1000000000000000000){
       ans=-1;
    }
  
    if(ans>0){
    for(int i=1;i<N;i++){
       long int a;
       cin>>a;
      if(ans==0||a==0){
      ans=0;
      }
      else if(ans>0&&1000000000000000000/ans>=a){
      ans*=a;
      }
      else if(ans==-1){
      }
      else{
      ans=-1;
      }
      
    }
}
    cout<<ans<<endl;
}





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

char s[100001];
int n;
bool sh[100001];

bool ok(){
	f(i, 1, n - 1){
		if (sh[i]){
			if (s[i] == 'o')sh[i + 1] = sh[i - 1];
			else sh[i + 1] = !sh[i - 1];
		}
		else if (s[i] == 'o')sh[i + 1] = !sh[i - 1];
		else sh[i + 1] = sh[i - 1];
	}
	if (sh[n - 1]){
		if (s[n - 1] == 'o' && sh[n - 2] != sh[0])return false;
		else if (s[n - 1] == 'x' && sh[n - 2] == sh[0])return false;
	}
	else if (s[n - 1] == 'o' && sh[n - 2] == sh[0])return false;
	else if (s[n - 1] == 'x' && sh[n - 2] != sh[0])return false;
	if (sh[0]){
		if (s[0] == 'o' && sh[n - 1] != sh[1])return false;
		else if (s[0] == 'x' && sh[n - 1] == sh[1])return false;
	}
	else if (s[0] == 'o' && sh[n - 1] == sh[1])return false;
	else if (s[0] == 'x' && sh[n - 1] != sh[1])return false;
	return true;
}

void win(){
	f(i, 0, n)printf("%c", sh[i] ? 'S' : 'W');
	printf("\n");
	exit(0);
}

int main(){
	scanf("%d%s", &n, s);
	f(i, 0, 4){
		sh[0] = i & 1;
		sh[1] = (i & 2) >> 1;
		if (ok())win();
	}
	printf("-1\n");
}


Measured memory_bytes: 512
/*
 *  Author : Jun_SH
 *  Solution for ddcc2020-qual D
 */
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
    int f=1,x=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return f*x;
}
int a[10];
main(){
    int m=read();
    int sum=0;
    int d=0;
    for(int i=1;i<=m;++i){
        int x,y;
        cin>>x>>y;
        a[x]+=y;
        sum+=x*y;
        d+=y;
    }
    cout<<(d-1)+(sum-1)/9<<endl;

}


Measured memory_bytes: 256
n, c, k = map(int, input().split())
T = sorted([int(input()) for _ in range(n)])

limit = T[0] + k
bus = [0]
ans = 0
for t in T:
    if t <= limit:
        if bus[-1] < c:
            bus[-1] += 1
        else:
            bus.append(1)
            limit = t + k

    else:
        limit = t + k
        ans += len(bus)
        bus = [1]

ans += len(bus)

print(ans)

Measured memory_bytes: 13996
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++){
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		int cnt = 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[k] < a[i] + a[j]){
						cnt++;
					}
				}
			}
		}
		System.out.print(cnt);
	}

}

Measured memory_bytes: 27492
MAX = 2*10**6
MOD = 10**9+7

fac = [0] * (MAX)
finv = [0] * (MAX)
inv = [0] * (MAX)

def comb_init():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i-1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i-1] * inv[i] % MOD

def comb(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD


if __name__ == '__main__':
    k = int(input())
    s = input()
    n = len(s)
    comb_init()
    ans = 0
    for i in range(k+1):
        val = comb(i+n-1, n-1)
        val *= pow(25, i, MOD)
        val %= MOD
        val *= pow(26, k-i, MOD)
        val %= MOD
        ans += val
        ans %= MOD
    print(ans)


Measured memory_bytes: 135364
whn = gets.chomp.split
w = whn[0].to_i
h = whn[1].to_i
n = whn[2].to_i

xya_a = []
n.times do
    xya = gets.chomp.split
    xya.length.times do |i|
        xya[i] = xya[i].to_i
    end
    xya_a << xya
end

bottom_left = [0, 0]
top_right = [w, h]

n.times do |i|
    case xya_a[i][2]
    when 1
        bottom_left[0] = xya_a[i][0] if bottom_left[0] < xya_a[i][0]
    when 2
        top_right[0] = xya_a[i][0] if top_right[0] > xya_a[i][0]
    when 3
        bottom_left[1] = xya_a[i][1] if bottom_left[1] < xya_a[i][1]
    when 4
        top_right[1] = xya_a[i][1] if top_right[1] > xya_a[i][1]
    end
end

if top_right[0] - bottom_left[0] <= 0 || top_right[1] - bottom_left[1] <= 0
    puts 0
elsif
    white = (top_right[0] - bottom_left[0]) * (top_right[1] - bottom_left[1])
    puts white >= 0 ? white : 0
end

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

using namespace std;

void a()
{
    int n;
    cin >> n;
    string temp = to_string(n);
    if(temp[0] == '9')
    {
       cout << "Yes" << endl;
        return;
    }else if(temp[1] == '9')
    {
        cout << "Yes" << endl;
        return;
    }
    cout << "No" << endl;
}

void b()
{
    int n;
    cin >> n;
    vector<pair<int, int>> lr;
    for(int i = 0; i < n; i++)
    {
        int r, l;
        cin >> l >> r;
        lr.push_back(make_pair(l, r));
    }
    int result = 0;
    for(auto elem : lr)
    {
        result += (elem.second - elem.first) + 1;
    }
    cout << result << endl;
}

void c()
{

}

void d()
{

}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int main(){
    cin>>s;
    long long ans = 0;
    bool flag = 0;
        for(int i=1;i<s.size();i++){
            if(s[i] != '9'){
                flag = 1;
            }
        }
        if(!flag){
            for(int i=0;i<s.size();i++){
                ans += s[i]-'0';
            }           cout<<ans<<endl;
         exit(0);
    }
    if(s[0] == '1'){
        
        for(int i=0;i<s.size()-1;i++)
            ans+=9;
        cout<<ans<<endl;
    }
    else{
        s[0]--;
        ans += s[0]-'0';
        for(int i=0;i<s.size()-1;i++)
            ans += 9;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()
#pragma endregion

int dp[110][2][110];

ll solver(string s, int x)
{
	int l = s.size();
	rep(i, 110)rep(j, 2)rep(k, 110)dp[i][j][k] = 0;
	dp[0][0][0] = 1;
	rep(i, l)
	{
		int d = s[i] - '0';
		rep(j, 2)
		{
			rep(k, 105)
			{
				for (int m = 0; m <= (j ? 9 : d); ++m)
				{
					if (m == 0)dp[i + 1][j || (m < d)][k] += dp[i][j][k];
					else dp[i + 1][j || (m < d)][k + 1] += dp[i][j][k];
				}
			}
		}
	}
	return dp[l][0][x] + dp[l][1][x];
}

int main()
{
	string n; cin >> n;
	int k; cin >> k;
	cout << solver(n, k) << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>
#include <typeinfo>
#include <set>
#include <bitset>
#include <map>
#include <numeric>
#include <queue>

using namespace std;
typedef long long ll;

int main(){
    int a,b;
    cin >> a >> b;
    if(a<10 and b<10){
        cout << a*b << endl;
    }else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256
import std.algorithm, std.array, std.container, std.range;
import std.string, std.uni, std.regex;
import std.stdio, std.conv, std.typecons;

void main()
{
  for (;;) {
    auto s = readln.chomp;
    if (s == "-") break;

    auto m = readln.chomp.to!size_t;
    auto hi = iota(m).map!(_ => readln.chomp.to!int);

    foreach (h; hi)
      s = s[h..$] ~ s[0..h];

    writeln(s);
  }
}

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

int a, b;

int main() {
    for (;;) {
        cin >> a >> b;
        if (a > b) cout << b << ' ' << a << endl;
        else if (a==0 && b==0) break;
        else cout << a << ' ' << b << endl;
    }
    return 0;
}


Measured memory_bytes: 3036
#include <stdio.h>

int main(void){

	int a, b;
	char op;

	do{
		scanf("%d %c %d", &a, &op, &b);

		switch (op)
		{
		case '+':printf("%d\n", a + b);
			break;

		case '-':printf("%d\n", a - b);
			break;

		case '*':printf("%d\n", a*b);
			break;

		case '/':printf("%d\n", a / b);
			break;
		}

	} while (op != '?');

	return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N;
  cin >> N;
  vector<int> A(1<<N);
  REP(i,1<<N) cin >> A[i];

  REP(i,N) {
    for(int j = 0; j < (1<<N); j += (1<<(i + 1))) {
      A[j] = (A[j] == A[j + (1<<i)]) ? A[j] : abs(A[j] - A[j + (1<<i)]);
    }
  }
  cout << A[0] << endl;
  return 0;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  cout<<800*n-200*(n/15)<<endl;
}

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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(ll i=0; i<(n); i++)
#define REPj(n) for(ll j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
#define SORT(c) sort((c).begin(),(c).end())
#define CONTAINER_ALL(a) a.begin(),a.end()

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

//std out
template<typename T>
void print_container(const vector<T> vals) {
    REPinit(i, 0, vals.size() - 1) cout << vals.at(i) << " ";
    cout << vals.back();
}


bool judge(int a, int b, int c) {
    if ((a > b && b > c) || (a < b && b < c)) return true;
    return false;
}

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

    int A, B;
    cin >> A >> B;
    int sum = 1;
    int ans = 0;

    while (true) {
        if ((sum - ans) >= B) break;
        sum += A;
        ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3632
#0.0001以下の誤差があってもよい
#三角形の面積 S、周の長さ L, a を底辺としたときの高さ h 
x, r1, do1 = gets.split(" ").map(&:to_f)

h = Math.sin(do1/180*Math::PI) * r1

s = x * h / 2

if r1 > x then
    r1, x = x, r1
end

y = Math.sin(do1/180*Math::PI) * r1

x1 = Math.cos(do1/180*Math::PI) * r1
x2 = x - x1

do2 = 0.0
r2 = 0.0

do2 = Math.atan(y / x2)
    
r2 = x2 / Math.cos(do2)

print s, "\n"
print x + r1 + r2, "\n"
print h, "\n"



Measured memory_bytes: 6972
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define dbg(n) cout<<#n<<' '<<n<<endl;
ll dp[3001][3001];
ll  solve(int i,int j,ll a[]){
	if(i==j)
		return dp[i][j]=a[i];
	else if(j==i+1)
		return dp[i][j]=max(a[i],a[j]);
	else if(dp[i][j]!=-1)
		return dp[i][j];
	return dp[i][j]=max(a[i]+min(solve(i+2,j,a),solve(i+1,j-1,a)),a[j]+min(solve(i,j-2,a),solve(i+1,j-1,a)));	
}
int main(){
	for(int i=0;i<3001;i++)
	for(int j=0;j<3001;j++)dp[i][j]=-1;
	int n;
	cin>>n;
	ll a[n];
	ll sum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	ll mx=solve(0,n-1,a);
	ll ans=2*mx-sum;
	cout<<ans<<endl;
}



Measured memory_bytes: 74096
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;

class Program
{
    static void Main(string[] args)
    {
        var blue = ToInt32(ReadLine());
        var p = new Dictionary<string, int>();
        for(var i = 0; i < blue; i++)
        {
            var str = ReadLine();
            if (p.ContainsKey(str)) p[str]++;
            else p[str] = 1;
        }
        var red = ToInt32(ReadLine());
        for(var i = 0; i < red; i++)
        {
            var str= ReadLine();
            if (p.ContainsKey(str)) p[str]--;
            else p[str] = -1;
        }
        var max = p.Values.Max();
        if (max < 0) WriteLine(0);
        else WriteLine(max);

    }
}



Measured memory_bytes: 13280
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::unordered_map;using std::unordered_set;using std::bitset;using std::pair;using std::set;using std::string;using std::vector;using std::sort;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _dbg(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _dbg(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_dbg(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}

int32_t main(){
    int l,r;
    cin>>l>>r;
    if(r-l+1>=2019){
        cout<<"0\n";
        return 0;
    }
    int mn=2019;
    for(int i=l;i<=r;++i){
        for(int j=i+1;j<=r;++j){
            upn(mn,(i*j)%2019);
        }
    }
    cout<<mn<<'\n';

    return 0;
}


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  long double a, b; cin >> a >> b;
  cout << (ll)(a * b) << endl;

}
























Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=1e6+5;
int main() {
	std::vector<int> V(10);
	for(int i=1;i<=5;i++) {
		cin>>V[i];    
		if(V[i]==0) cout<<i<<endl;
	}
    return 0;
}

Measured memory_bytes: 3536
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dup(x,y) (((x)+(y)-1)/(y))
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int N, D;
	cin >> N >> D;
	int ans = 0;
	D = D * D;
	rep(i, N) {
		int X, Y;
		cin >> X >> Y;
		int dis = X * X + Y * Y;
		if (dis <= D)ans++;
	}
	cout << ans;
}

Measured memory_bytes: 3632
#include <cstring>
#include <cstdint>
#include <iostream>
#include <string>
#include <memory>
#include <queue>
#include <limits>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <sstream>
#include <random>
#include <functional>
#include<algorithm>
#include <array>
#include<random>
using namespace std;
int main() {
	std::array<int16_t,3> x;
	for (size_t i = 0; i < 3; i++)cin >> x[i];

	uint16_t ans = 0;
	while (!(x[0] == x[1] && x[1] == x[2])) {
		std::sort(x.begin(), x.end());
		if (x[0] == x[1]) {
			x[0] += 1;
			x[1] += 1;
		}
		else {
			x[0] += 2;
		}
		++ans;
	}
	
	cout << ans;

	return 0;
}

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

#define ll long long

int main(void){

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

    ll x[m],y[m];
    for(int i=0;i<m;i++)cin>>x[i]>>y[i];

    for(int i=0;i<n;i++){
        ll mind = 10000000000000;
        int minc = 0;
        for(int j=0;j<m;j++){
            ll dis = abs(a[i]-x[j])+abs(b[i]-y[j]);
            if(dis<mind){
                minc=j+1;
                mind=dis;
            }
        }
        cout<<minc<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int d[100000][2];
vector<int> v[100000];
void f(int x, int y, int z){
    d[x][y] = z;
    for(int i=0;i<v[x].size();i++){
        if(d[v[x][i]][y] == -1){
            f(v[x][i], y, z+1);
        }
    }
}
int main(void){
    int n, c=0;
    cin >> n;
    for(int i=0;i<n-1;i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for(int i=0;i<n;i++){
        d[i][0] = d[i][1] = -1;
    }
    f(0, 0, 0);
    f(n-1, 1, 0);
    for(int i=0;i<n;i++){
        if(d[i][0] <= d[i][1]){
            c++;
        }
    }
    
    if(c*2 > n){
        cout << "Fennec" << endl;
    }else{
        cout << "Snuke" << endl;
    }
}


Measured memory_bytes: 12800
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;
        
        static void Solve()
        {
            int n = ReadAndParseInt();
            var a = ReadAndParseIntArr();
            var list = new List<int>(a);
            list.Sort();
            long ans = 1;
            if( n % 2 == 0)
            {
                if(IsValidEvent(list))
                {
                    n /= 2;
                    ans = pow(2, n);
                }
                else
                {
                    ans = 0;
                }
            }
            else
            {
                if( IsValidOdd(list))
                {
                    n -= 1;
                    n /= 2;
                    ans = pow(2, n);
                }
                else
                {
                    ans = 0;
                }
            }
            Console.WriteLine(ans);
        }
        private static bool IsValidEvent(List<int> list)
        {
            for(int i=0;i<list.Count;++i)
            {
                if(  list[i] != i / 2 * 2 + 1) { return false; }
            }
            return true;
        }
        private static bool IsValidOdd(List<int> list)
        {
            if(list[0] != 0) { return false; }
            for(int i=1;i<list.Count;++i)
            {
                if( list[i] != ((i-1)/2+1) * 2) { return false; }
            }
            return true;
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

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

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
using namespace std;
typedef long long ll;
const int MAXN = 2e5;
ll a[MAXN + 5], b[MAXN + 5], f[MAXN + 5];
ll n, k, tot, ans;

#define CHECK
#undef CHECK

#ifdef CHECK
void printf_a(){
  printf("a: ");
  for(int i=0;i<n+1;i++){
    printf("%lld ", a[i]);
  }
  printf("\n");
}

void printf_f(){
  printf("f: ");
  for(int i=0;i<n+1;i++){
    printf("%lld ", f[i]);
  }
  printf("\n");
}

void printf_b(){
  printf("b: ");
  for(int i=0;i<n+1;i++){
    printf("%lld ", b[i]);
  }
  printf("\n");
}
#endif

bool cmp(ll a, ll b) { return a > b; }
bool Check(ll x) {
#ifdef CHECK
  printf("check %lld\n", x);
#endif
  for (int i = 1; i <= n; i++)
    b[i] = x / f[i]; //使a[i]小于等于x达到的上界

    #ifdef CHECK
  printf_b();
    #endif
  ll res = 0;
  for (int i = 1; i <= n; i++)
    res += max(0ll, a[i] - b[i]);
#ifdef CHECK
  printf("res: %lld\n", res);
#endif
  return res <= k;
}

ll BS() {
  ll l = 0, r = (ll)1e12;
  while (l + 1 <= r) {
    ll mid = (l + r) >> 1;
    if (Check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  return r;
}
int main() {
//#ifndef ONLINE_JUDGE
//  ifstream in("input.txt", ios::in);
//  streambuf *backup, *file;
//  backup = cin.rdbuf();
//  file = in.rdbuf();
//  cin.rdbuf(file);
//#endif

  scanf("%lld%lld", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    tot += a[i];
  }
  for (int i = 1; i <= n; i++)
    scanf("%lld", &f[i]);
  if (tot <= k) //个人值可被减完
  {
    printf("0\n");
    return 0;
  }
  sort(a + 1, a + n + 1);
  sort(f + 1, f + n + 1, cmp);

#ifdef CHECK
  printf_a();
  printf_f();
#endif
  printf("%lld\n", BS());
  return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

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

int H, W;
vector<string> s(51);

bool is_rectangle(int sy, int sx, int gy, int gx) {
    char c = '#';
    for(int y=sy;y<=gy;++y) {
        for(int x=sx;x<=gx;++x) {
            if(s[y][x] != '#') {
                if(c == '#') {
                    c = s[y][x];
                } else if(s[y][x] != c){
                    return false;
                }
            }
        }
    }
    for(int i=0;i<H;++i) {
        if(sy <= i && i<= gy) continue;
        for(int j=0;j<W;++j) {
            if(sx <= j && j <= gx) continue;
            if(s[i][j] == c) return false;
        }
    }
    return true;
}

bool solve() {
    cin >> H >> W;
    for(int i=0;i<H;++i) {
        cin >> s[i];
    }

    map<char, int> sy, sx, gy, gx;
    set<char> st;
    for(int y=0;y<H;++y) {
        for(int x=0;x<W;++x) {
            if(s[y][x] == '.') continue;
            char  c = s[y][x];
            if(st.find(c) == st.end()) {
                st.insert(c);
                sy[c] = y;
                sx[c] = x;
            }
            sy[c] = min(y, sy[c]);
            sx[c] = min(x, sx[c]);
            gy[c] = max(y, gy[c]);
            gx[c] = max(x, gx[c]);
        }
    }

    bool changed = true;
    while(changed) {
        changed = false;
        vector<char> cc;
        for(char c: st) {
            if(is_rectangle(sy[c], sx[c], gy[c], gx[c])) {
                changed = true;
                cc.push_back(c);
                for(int y=sy[c];y<=gy[c];++y) {
                    for(int x=sx[c];x<=gx[c];++x) {
                        s[y][x] = '#';
                    }
                }
            }
        }
        for(char ccc: cc) st.erase(ccc);
    }
    return st.empty();
}

int main() {
    int n;
    cin >> n;
    while(n--) {
        cout << (solve()?"SAFE\n":"SUSPICIOUS\n");
    }
}



Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>v(n);
    for(int i=0;i<n;i++) {
        cin >> v[i];
    }
    sort(v.begin() , v.end());
    cout << v[n/2] - v[n/2 -1]<<endl;
    
}

Measured memory_bytes: 640
Option Strict On

Module Module1
    Const n As Long = 8

    Sub Main()
        'let'
        Dim tmp() As Long =
            Array.ConvertAll(Of String, Long) _
            (Split(Console.ReadLine()), AddressOf Long.Parse)

        Dim A As Long = tmp(0)
        Dim B As Long = tmp(1)

        'var'
        Dim ans As String

        If Math.Max(A, B) <= n Then
            ans = "Yay!"
        Else
            ans = ":("
        End If

        Console.WriteLine(ans)

    End Sub
End Module

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

int main(){
  int N, A;
  cin >> N >> A;
  if (A>=500){
    cout << "Yes" <<endl;
  }
  else if(N%500 <= A){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 3604
import string
import collections

n = int(input())
S_count = []
for i in range(n):
    S_count.append(collections.Counter(input()))    

ans = ''    

for a in string.ascii_lowercase:
    c = 100
    for S_i in S_count:
        c = min(c, S_i[a])
    ans += a*c

print(ans)

Measured memory_bytes: 3956
#include <iostream>
#include <numeric>

using namespace std;

int main()
{
  string pat = "CODEFESTIVAL2016";
  string S; cin >> S;
  int ans = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] != pat[i]) ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
H, W, K = map(int, input().split(" "))
cake = [input() for _ in range(H)]

is_strawberry = []
for i in cake:
    is_strawberry.append(('#' in i))

cut = [[0 for _ in range(W)] for _ in range(H)]
num = 1
for h, c in enumerate(cake):
    if is_strawberry[h]:
        st_count = sum([s == '#' for s in c])
        for w in range(W):
            if cake[h][w] == '.' or st_count == 0:
                cut[h][w] = num
            else:
                cut[h][w] = num
                st_count -= 1
                if st_count > 0:
                    num += 1
        num += 1

ind = is_strawberry.index(True)
for h in range(H):
    if not is_strawberry[h]:
        for w in range(W):
            cut[h][w] = cut[ind][w]
    else:
        ind = h

for c in cut:
    print(' '.join([str(s) for s in c]))

Measured memory_bytes: 43884
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int count = 0;
  string S;
  cin >> N >> S;
  for (int i = 0; i < N - 2; i++) {
    if (S.at(i) == 'A' ) {
      if (S.at(i + 1) == 'B') {
        if (S.at(i + 2) == 'C') {
          count++;
        }
      }
    }
  }
  cout << count << endl;
}

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

int main() {
	int x, n, min, max;
	long long sum = 0;
	max = -10000001;
	min = 10000001;
	cin >> n;
	for (int i=1;i<=n;i++) {
		cin >> x;
		sum += x;
		if (x > max) {
			max = x;
		} if (x < min) {
			min = x;
		}	
	}
	cout << min << " " << max << " " << sum << endl;
	return 0;
}



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

int main(){
    long n,m;
    cin>>n>>m;
    long p;
    string s;
    int flg[n+10];
    long appear[n+10];
    long ac=0,wa=0;
    for(long i=0;i<n+10;i++) {
        flg[i] = 1;
        appear[i]=0;
    }
    for(long i=0;i<m;i++){
        cin>>p>>s;
        if(flg[p-1]==1&&s=="AC") {
            ac++;
            flg[p-1]=0;
            wa+=appear[p-1];
        }
        else if(flg[p-1]==1&&s=="WA") {
            appear[p-1]++;
        }
    }
    cout<<ac<<" "<<wa<<endl;
}

Measured memory_bytes: 1408
# -*- coding: utf-8 -*-

N = int(input().strip())
A_list = list(map(int, input().rstrip().split()))
#-----

# A_index[i] = ( value of A , index of A)
A_index = [ (A_list[i], i) for i in range(len(A_list)) ]
A_index.sort(reverse=True)


# dp[left][right] = score
dp = [ [0]*(N+1) for _ in range(N+1) ]


for L in range(N):
    for R in range(N-L):
        i = L + R
        append_L = dp[L][R] + A_index[i][0] * abs(L - A_index[i][1])
        append_R = dp[L][R] + A_index[i][0] * abs((N-1-R) - A_index[i][1])
        
        dp[L+1][R] = max(dp[L+1][R], append_L)
        dp[L][R+1] = max(dp[L][R+1], append_R)


ans = max( [ dp[i][N-i] for i in range(N+1)] )
print(ans)


Measured memory_bytes: 105940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976

int n;
const int V_MAX = 105;
ll d[V_MAX][V_MAX];

void warshall_floyd(){
    for(int k = 0; k < n; k++){
        for(int i = 0; i < n; i++){
            if(d[i][k] == INF) continue;
            for(int j = 0; j < n; j++){
                if(d[k][j] == INF) continue;
                d[i][j] = min(d[i][j],d[i][k] + d[k][j]);
            }
        }
    }
}

int main()
{
    int e;
    cin >> n >> e;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i == j) d[i][j] = 0;
            else d[i][j] = INF;
        }
    }
    for(int i = 0; i < e; i++){
        int s,t,v;
        cin >> s >> t >> v;
        d[s][t] = v;
    }

    warshall_floyd();

    bool negative_cycle = false;
    for(int i = 0; i < n; i++) if(d[i][i] < 0) negative_cycle = true;

    if(negative_cycle){
        cout << "NEGATIVE CYCLE" << endl;
    }else{
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(j) cout << ' ';
                
                if(d[i][j] == INF)cout << "INF";
                else cout << d[i][j];
            }
            cout << endl;
        }
    }
}   


Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1001001001;
const ll MOD = 1e9 + 7;
const double PI = 3.14159265358979;


int main(){
  int a, b;
  string s;
  cin >> a >> b >> s;
  if(int(s.size()) == a + b + 1 && s[a] == '-'){
    rep(i, a+b+1){
      if(i == a) continue;
      if(!isdigit(s[i])){
        cout << "No" <<endl;
        return 0;
      }
    }
    cout << "Yes" <<endl;
    return 0;
  }
  cout << "No"<<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a[5];
  for(int i=0;i<5;i++)
  {
    cin>>a[i];
  }
  for(int i=0;i<5;i++)
  {
    if(a[i]!=i+1)
    {
      cout<<i+1;
      break;
    }
  }
}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

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




Measured memory_bytes: 3684
k,n = list(map(int,input().split()))
a = list(map(int,input().split()))

d = {}
for i in range(n):
  if i == 0:
    d[i] = a[i]
  elif i == n-1:
    d[i] = a[i] - a[i-1]
    d[0] += k - a[i]
  else:
    d[i] = a[i] - a[i-1]
#print(d)
d2 = sorted(d.items(),key=lambda x:x[1], reverse=True)
print(k - d2[0][1])

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

const int maxn = 3010;
int a[maxn];
bitset <maxn> w;
vector <int> adj[maxn];

void dfs(int v, int p = -1) {
	for (auto u: adj[v]) {
		if (u != p) {
			dfs(u, v);
			if (!w[u] && a[u] < a[v]) {
				w[v] = 1;
				break;
			}
		}
	}
}

inline void vitex() {
	w = 0;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i < n; i++) {
		int v, u;
		cin >> v >> u;
		v--;
		u--;
		adj[v].push_back(u);
		adj[u].push_back(v);
	}
	vector <int> ans;
	for (int i = 0; i < n; i++) {
		dfs(i);
		if (w[i])
			ans.push_back(i + 1);
		vitex();
	}
	for (auto b: ans)
		cout << b << ' ';
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define INF 0x3f3f3f3f
typedef long long ll;
using namespace std;

int main()
{
	IO;
	int n,m;
	cin>>n>>m;
	if(n>m) cout<<"safe"<<endl;
	else cout<<"unsafe"<<endl;
 	return 0;
}







Measured memory_bytes: 3620
#include <iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#define pb              push_back
#define pi              acos(-1.0)
#define loop(i,a,n)     for(int i=a;i<n;i++)
#define rloop(i,n,a)    for(int i=n;i>=a;i--)
#define ll              long long int
#define ff              first
#define ss              second
#define pii             pair<ll,ll>
#define sc1(a)          scanf("%d",&a)
#define sc2(a,b)        scanf("%d %d",&a,&b)
#define sc3(a,b,c)      scanf("%d %d %d",&a,&b,&c)
#define all(v)          v.begin(),v.end()
#define ms(a,b)         memset(a,b,sizeof a)
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define fileout         freopen("output.txt","w",stdout)
#define filein          freopen("input.txt","r",stdin)
#define inf             2e9+5
#define Q               int q;cin>>q;while(q--)
#define check           cout<<"HI"<<endl;

//int x[]= {-1,0,0,1};
//int y[]= {0,-1,1,0};

using namespace std;

int main()
{
    int p = 0;
    string a,b;
    cin >> a>>b;
    loop(i,0,a.size())
    {
        if(a[i]!=b[i])p++;
    }
    cout<<p<<endl;
}













Measured memory_bytes: 3464