akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define pb push_back
#define MAXN 21010
#define Scan(a) scanf("%I64d", &a)
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<int, int> II;
typedef vector<II> vi;

int n, k, trace[5010][5010], f[5010], a[5010];
bool dp[5010][5010];

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin >> n >> k;
    FOR(i,1,n) cin >> a[i];
    sort(a+1, a+n+1);
    FOR(i,1,n/2) swap(a[i], a[n-i+1]);
    dp[0][0] = true;
    FOR(i,1,n)
        FOR(j,0,k-1) {
            if (dp[i-1][j]) {
                dp[i][j] = true;
                trace[i][j] = j;
                continue;
            }
            if (j-a[i] >= 0 && dp[i-1][j-a[i]]) {
                dp[i][j] = true;
                trace[i][j] = j-a[i];
            }
        }
    int vt = 0;
    FORE(i,k-1,0)
        if (dp[n][i]) {
            vt = i;
            break;
        }
    if (vt == 0) {
        cout << 0;
        return 0;
    }
    int g = vt;
    FORE(i,n,1)
        if (trace[i][vt] < vt) {
            f[i] = true;
            vt = trace[i][vt];
        }
    int Min = 2000000000;
    FOR(i,1,n)
        if (!f[i]) Min = min(Min, a[i]);
    if (Min == 2000000000) {
        cout << n;
        return 0;
    }
    g += Min;
    int res = 0;
    FOR(i,1,n)
        if (f[i])
            if (g-a[i] >= k) res++;
    cout << res;
    return 0;
}


Measured memory_bytes: 122624
while True:
    a,op,b=input().split()
    a=int(a)
    b=int(b)
    
    if op=="?":
        break
    if op=="+":
        print(a+b)
    if op=="-":
        print(a-b)
    if op=="*":
        print(a*b)
    if op=="/":
        print(a//b)
        


Measured memory_bytes: 5592
#include<cstdio>
using namespace std;
#define N 1000500
#define mod 998244353
int fr[N],ifr[N],n,m,as;
int pw(int a,int p){int as=1;while(p){if(p&1)as=1ll*as*a%mod;a=1ll*a*a%mod;p>>=1;}return as;}
int main()
{
	scanf("%d%d",&n,&m);
	fr[0]=ifr[0]=1;for(int i=1;i<=m*2;i++)fr[i]=1ll*fr[i-1]*i%mod,ifr[i]=pw(fr[i],mod-2);
	for(int i=0;i<=m;i++)
	{
		if(i*2<m||i<n)continue;
		int s1=i*2-m,s2=m-i+s1-n;
		if(i*2==m)
		{
			as=(as+1ll*fr[m-1]*ifr[i]%mod*ifr[m-1-i])%mod;
			if(s1>=n||m-i-s2-2<0)continue;
			as=(as-1ll*fr[m-1]*ifr[i+s2+1]%mod*ifr[m-i-s2-2]%mod+mod)%mod;
			continue;
		}
		as=(as+1ll*fr[m]*ifr[i]%mod*ifr[m-i])%mod;
		if(s1>=n||m-i-s2-1<0)continue;
		as=(as-1ll*fr[m]*ifr[i+s2+1]%mod*ifr[m-i-s2-1]%mod+mod)%mod;
	}
	printf("%d\n",as);
}

Measured memory_bytes: 7936
#include <stdio.h>
     
    int max(int a, int b){
      int M = a;
      if(b > M)
        M = b;
      return M;
    }
     
    int main(void){
      int N;
      int T = 0;
      int i, j;
      scanf("%d", &N);
      
      int W[N];
      for(i=0; i<N; i++)
        scanf("%d", &W[i]);
     
      int minimum = 100, sub;
      for(i=0; i<N; i++){
        T = i;
        int S1 = 0, S2 = 0;
        for(j=0; j<T; j++)
          S1 += W[j];
        for(j=T; j<N; j++)
          S2 += W[j];
        sub = max(S1-S2, S2-S1);
        if(sub < minimum)
          minimum = sub;
      }
      
      printf("%d\n", minimum);
     
      return 0;
    }

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


int main()
{
	long int S;
	int h, m, s;

	cin >> S;

	h = S / 60 / 60;
	m = S / 60 - (h * 60);
	s = S - ((S / 60)*60);

	cout << h << ":" << m << ":" << s << endl;
	
	return 0;
}


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

int vx[]={0,-1,0,1};
int vy[]={1,0,-1,0};

int main(void){
    int H,W;
    int ans=0;
    queue<int> qx;
    queue<int> qy;
    cin>>H>>W;
    char a[1010][1010];
    int count[1010][1010];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>a[j][i];
            count[j][i]=999999;
            if(a[j][i]=='#'){
                count[j][i]=0;
                qx.push(j);
                qy.push(i);
            }
        }
    }
    while(!qx.empty()){
        int x,y;
        x=qx.front();
        y=qy.front();
        qx.pop();
        qy.pop();
        for(int i=0;i<4;i++){
            int nx=x+vx[i];
            int ny=y+vy[i];
            if(nx>=0&&ny>=0&&nx<W&&ny<H&&a[nx][ny]=='.'){
                a[nx][ny]='#';
                count[nx][ny]=count[x][y]+1;
                ans=count[nx][ny];
                qx.push(nx);
                qy.push(ny);
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 13312
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        long aMin = Long.MAX_VALUE, aMax = Long.MIN_VALUE;
        long bMin = Long.MAX_VALUE, bMax = Long.MIN_VALUE;
        for(int n=0; n<N; n++){
            long x = sc.nextLong();
            long y = sc.nextLong();

            long a = x-y, b = x+y;
            aMin = Math.min(aMin, a);
            aMax = Math.max(aMax, a);
            bMin = Math.min(bMin, b);
            bMax = Math.max(bMax, b);
        }

        System.out.println(Math.max(aMax-aMin, bMax-bMin));
    }
}

Measured memory_bytes: 59052
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <cstring>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    int n,sum=0;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n-1;i++){
        sum+=a[i];
    }
    if(a[n-1]<sum){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

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

template<class Type>
Type mod_pow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

void func(ll a, ll n, ll& x, ll& y)
{
	for (ll i = 0; i < a; i++) {
		//x *= (n - i) % mod;    // *=ではオーバーフロー
		//y *= (i + 1) % mod;    // *=ではオーバーフロー
		x = x * (n - i) % mod;
		y = y * (i + 1) % mod;
	}
	x %= mod;  // 二項係数の分子
	y %= mod;  // 二項係数の分母
	y = mod_pow(y, mod - 2, mod);  // 逆元
}

int main()
{
	ll n, a, b;
	cin >> n >> a >> b;

	ll sum = mod_pow(2LL, n, mod) - 1;  // 二項係数の総和-1

	ll ax = 1;
	ll ay = 1;
	func(a, n, ax, ay);
	ll nCa = ax * ay % mod;  // 二項係数nCa

	ll bx = 1;
	ll by = 1;
	func(b, n, bx, by);
	ll nCb = bx * by % mod;  // 二項係数nCb

	sum = (sum - nCa + mod) % mod;
	sum = (sum - nCb + mod) % mod;
	cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

int main(){
    int M;
    ll K;
    cin >> M >> K;
    ll t = 1;
    rep(i, M){
        t *= 2;
    }
    if (K >= t){
       cout << -1 << endl;
    } else if (M == 0) {
        cout << 0 << " " << 0 << endl;
    } else if (M == 1 && K == 0) {
        cout << 0 << " " << 0 << " " << 1 << " " << 1 << endl;
    } else if (M == 1 && K == 1) {
        cout << -1 << endl;
    } else {
        rep(i, t) {
            if (i == K) continue;
            cout << i << " " ;
        }
        cout << K << " ";
        rep(i, t) {
            if (t-i-1 == K) continue;
            cout << t-i-1 << " ";
        }
        cout << K << " " << endl;

    }
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ms(x,y) memset(x,y,sizeof(x))
using namespace std;
const int N=305;
const int T=200005;


int pn,rn,tn;
int tp[T],tr[T];
bool ter[N];
int untercnt=0;
int res[N],need[N][N],req[N][N];
int tmpres[N],tmpneed[N][N];
bool tmpter[N];

bool terminate(int pi) {
	for(int j=1;j<=rn;j++)
		if(need[pi][j])return false;
	return true;
}

bool canter(int pi) {
	for(int j=1;j<=rn;j++)
		if(tmpneed[pi][j]>tmpres[j])return false;
	return true;
}
queue<int> q;
bool check() {
	memcpy(tmpres,res,sizeof(res));
	memcpy(tmpneed,need,sizeof(need));
	memcpy(tmpter,ter,sizeof(ter));
	
	int cnt=0;
	while(!q.empty())q.pop();
	for(int i=1;i<=pn;i++) 
		if(!tmpter[i])
			if(canter(i))
				q.push(i);
	while(!q.empty()) {
		while(!q.empty()){
			int now=q.front();
			q.pop();
			cnt++;
			tmpter[now]=true;
			for(int j=1;j<=rn;j++)
				tmpres[j]+=req[now][j]-need[now][j];
		}
		for(int i=1;i<=pn;i++) 
			if(!tmpter[i])
				if(canter(i))
					q.push(i);
	}
	if(cnt<untercnt)return false;
	return true;
}

void goup(int now,int tt) {
	for(int t=now;t>tt;t--){
		if(ter[tp[t]])continue;
		res[tr[t]]++;
		need[tp[t]][tr[t]]++;
	}
}
void godown(int now,int tt){
	for(int t=now+1;t<=tt;t++) {
		if(ter[tp[t]])continue;
		res[tr[t]]--;
		need[tp[t]][tr[t]]--;
	}
}

int main(){
	scanf("%d%d%d",&pn,&rn,&tn);
	untercnt=pn;
	for(int i=1;i<=rn;i++)
		scanf("%d",&res[i]);
	for(int i=1;i<=pn;i++)
		for(int j=1;j<=rn;j++) {
			scanf("%d",&req[i][j]);
			if(req[i][j]>res[j]){
				printf("0\n");
				return 0;
			}
			need[i][j]=req[i][j];
		}
	ms(ter,0);
	for(int i=1;i<=tn;i++){
		scanf("%d%d",&tp[i],&tr[i]);
		need[tp[i]][tr[i]]--;
		res[tr[i]]--;		
		if(terminate(tp[i])){
			ter[tp[i]]=true;
			untercnt--;
			for(int j=1;j<=rn;j++)
				res[j]+=req[tp[i]][j];
		}
	}
	if(check()){
		printf("-1\n");
		return 0;
	}
	int l=0,r=tn,now=tn;
	while(l<r) {
		int mid=(l+r)/2;
		if(mid<now) goup(now,mid);
		else if(mid>now) godown(now,mid);
		now=mid;
		if(check())
			l=mid+1;
		else
			r=mid;
	}
	printf("%d\n",l);
	return 0;
}

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

int main() {
  int N,D,ans=0;cin>>N>>D;
  int X[N][D];
  rep(i,N)rep(j,D) cin>>X[i][j];
  
  for(int i=0;i<N;i++){
	for(int j=i+1;j<N;j++){
      int d2=0;
      rep(k,D) d2+=(X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
      int d=sqrt(d2);
      if(d*d==d2) ans++;
    }
  }
  
  cout << ans << endl;
}


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

#define ll long long int
#define endl '\n'
ll const mod = 1e9 + 7;

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin>>n;
    while(n)
    {
        if(n%10==7)
        {
            cout<<"Yes";
            return 0;
        }
        n/=10;
    }
    cout<<"No";
    
	// your code goes here
	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>                          
using namespace std;
int a[4][4];
int main(){
    for(int i=1;i<=3;i++)
        for(int j=1;j<=3;j++)
            cin>>a[i][j];
    for(int k=-1000;k<=1000;k++)
	{
        int a2,a3,b1,b2,b3,a1=k;
        bool f=true;
        b1=a[1][1]-k;
        b2=a[1][2]-k;
        b3=a[1][3]-k;
        a2=a[2][1]-b1;
        a3=a[3][1]-b1;
        if(a[2][2]!=a2+b2) f=false;
        if(a[2][3]!=a2+b3) f=false;
        if(a[3][2]!=a3+b2) f=false;
        if(a[3][3]!=a3+b3) f=false;
        if(f) {cout<<"Yes"<<endl;return 0;}
    }
    cout<<"No"<<endl;
    return 0;
}
//68871358
//76140264
//25446011
//200841159
//914174775

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int a[100005],d[100005];
int main()
{
    int n;
    scanf("%d",&n);
    for (int i = 1; i <= n; i++)
        scanf("%d",&a[i]);
    d[1]=0;
    d[2]=abs(a[1]-a[2]);
    for (int i = 3; i <= n; i++)
        d[i]=min(d[i-2]+abs(a[i]-a[i-2]),d[i-1]+abs(a[i]-a[i-1]));
    printf("%d",d[n]);
}

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

int main() {
	int n;
	cin>>n;
	int a[n],dp[n];
	fill(dp,dp+n,0);
	for(int i=0;i<n;i++)
	cin>>a[i];
	for(int i=1;i<n;i++)
	if(i-2>=0)
	dp[i]=min((dp[i-1]+abs(a[i]-a[i-1])),(dp[i-2]+abs(a[i]-a[i-2])));
	else
	dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <vector>
using namespace std;
typedef struct a{
	int n;
	int rep;
}node;


node t[10000];

int unite(int x,int y){
	int repx=x,repy=y;
	do{
		repx=t[repx].rep;
		
	}while(repx!=t[repx].rep);
	do{
		repy=t[repy].rep;
	}while(repy!=t[repy].rep);
	t[repx].rep=repy;
}

void search(int x,int y){
	int repx=x,repy=y;
	vector<int> v;
	vector<int>::iterator it;
	do{
		repx=t[repx].rep;
		v.push_back(repx);
	}while(repx!=t[repx].rep);
	for(it=v.begin();it!=v.end();it++){
		t[*it].rep=repx;
	}
	v.clear();
	do{
		repy=t[repy].rep;
		v.push_back(repy);
	}while(repy!=t[repy].rep);
	for(it=v.begin();it!=v.end();it++){
		t[*it].rep=repy;
	}

	if(repx==repy) printf("1\n");
	else printf("0\n");
}

int main(void){
	int n,q;
	int com,x,y;
	int i,j;
	node *work;
	scanf("%d%d",&n,&q);
	for(i=0;i<n;i++){
		t[i].n=i;
		t[i].rep=i; // ??£??¨????±???????
	}

	while(q--){
		scanf("%d%d%d",&com,&x,&y);
		if(com==0){
			unite(x,y);
		}
		else {
			search(x,y);
		}
	}
	return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll N, K;
	std::cin >> N >> K;

	vll A(N);
	vll sum(N + 1, 0);
	rep(i, 0, N) {
		std::cin >> A[i];
		sum[max(i - A[i], 0LL)]++;
		sum[min(i + A[i] + 1, N)]--;
	}

	rep(i, 0, K) {
		ll cnt = 0;
		vll tmp(N + 1, 0);
		rep(j, 0, N) {
			cnt += sum[j];
			A[j] = cnt;


			tmp[max(j - A[j], 0LL)]++;
			tmp[min(j + A[j] + 1, N)]--;
		}

		
		if (sum == tmp) {
			break;
		}
		sum = tmp;
	}
	rep(i, 0, N) {
		std::cout << A[i];
		if (i < N - 1) {
			std::cout << " ";
		}
	}
	std::cout << endl;

	return 0;
}


Measured memory_bytes: 8012
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    int n;
    cin>>n;
    int b=0,c=0,d=0;
    vector<long long int> a(n);
    REP(i,n) cin>>a[i];
    REP(i,n){
        if(a[i]%4==0){
            b++;
        }else if(a[i]%2==0){
            c++;
        }else{d++;}
    }
    if(n/2<=b){
        cout<<"Yes";
    }else if(n-2*b<=c){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 1024
N,x=map(int,input().split())
A=[0] + [int(i) for i in input().split()] + [0] 

ans=0
for i in range(1,len(A)):
    if A[i-1]+A[i]>x:
        ans+=A[i-1]+A[i]-x
        A[i]=x-A[i-1]

print(ans)


Measured memory_bytes: 14052
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		String line;
		int n;

		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		try {
			line = reader.readLine();
			n = Integer.parseInt(line);

			for(int i=1;i<=n;i++){
				if(i%3==0){
					System.out.print(" "+i);
				}
				else if(String.valueOf(i).contains("3")){
					System.out.print(" "+i);
				}
			}
			System.out.println();
		} catch (NumberFormatException e) {
			System.out.println(e);
		} catch (IOException e) {
			System.out.println(e);
		}
	}
}

Measured memory_bytes: 23396
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long
#define ll long long
using namespace std;

/*
 上下左右への隣接マスへの移動を表す配列 (もはやテンプレにしてよさそう)
 
 0: 下
 1: 右
 2: 上
 3: 左
*/
const int di[4] = {1, 0, -1, 0};
const int dj[4] = {0, 1, 0, -1};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    string p[h];
    for(int i=0;i<h;i++){
        cin >> p[i];
    }
    bool jadge=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(p[i][j]=='#'){
                int num_of_sharp = 0; // 上下左右に '#' が何個あるか

                // 上下左右を順み見ていく
                for (int direction = 0; direction < 4; ++direction) {
                    /* 隣接マス */
                    int ni = i + di[direction];
                    int nj = j + dj[direction];
                    
                    /* 隣接マスがフィールドの外にはみ出すならアウト (ここは毎回テンプレ) */
                    if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
                    
                    /* # をカウント */
                    if (p[ni][nj] == '#') num_of_sharp++;
                }
                
                // '#' が 1 個もなかったらダメ
                if (num_of_sharp == 0) jadge = 1;
            }
            else continue;
            
            if(jadge==1){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sc scanf
#define pr printf
#define pb push_back
#define ll long long int
int main()
{
double x,k;
cin>>k>>x;
set<int>s;
set<int>::iterator it;
for(int i=x;i>(x-k);i--)
s.insert(i);
for(int i=x+1;i<x+k;i++)
    s.insert(i);
    for(it=s.begin();it!=s.end();it++)
        cout<<*it<<" ";
    return 0;
}

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

int main() {
  int N,K,sum=0;
  cin >> N >> K;
  
  for(int i=0; i<N; i++){
    int x;
    cin >> x;
    if (2*x < 2*abs(K-x))
      sum += 2*x;
    else
      sum += 2*abs(K-x);
   
  }
  cout << sum << endl;
}




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

using namespace std;
const int INF = 100000000;

template<typename ISTREAM>
void readWeightedGraphMatrix(ISTREAM& cin, vector< vector<int> >& weightedGraphMatrix) {
	size_t n;
	cin >> n;
	int u, k, v, c;
	weightedGraphMatrix = vector< vector<int> >(n, vector<int>(n, -1));
	for (size_t i = 0; i != n; ++i) {
		cin >> u >> k;
		for (size_t j = 0; j != k; ++j) {
			cin >> v >> c;
			weightedGraphMatrix.at(u).at(v) = c;
		}
	}
}

void printSPST(const vector< vector<int> >& weightedGraphMatrix) {//ShortestPathSpaningTree
	enum Color {
		WHITE, GRAY, BLACK//白は未訪問でTと隣接していない。
		//グレーはTと隣接状態だが未訪問、黒は訪問済み。木は閉路を持たないグラフなので、全域木の計算では
		//各点は1度だけ訪問されるはず。
	};
	const size_t n = weightedGraphMatrix.size();
	vector<Color> color(n,Color::WHITE);
	vector<int> d(n, INF);
	vector<int> p(n, -1);
	color.front() = Color::GRAY;
	d.front() = 0;
	int currentNode = 0;
	while (true) {
		int min = INF;
		int u;
		//TからV-Tへ接続する辺の重みの中で最小のものを求める。
		//同時に、その辺に接続する辺のT内のノードを求める。
		for (size_t i = 0; i != n; ++i) {
			if (color.at(i) == Color::BLACK || color.at(i) == Color::WHITE) continue;//訪問済みはスキップ
			if (d.at(i) >= min)continue;
			min = d.at(i);//TからV-Tの中のノードiへ向かう辺の重みの最小値を更新
			u = i;
		}

		if (min == INF) {
			//ノード０からアクセス可能なすべての点を訪問済みになったらMST構築完了
			break;
		}

		color.at(u) = Color::BLACK;//訪問

		for (int v = 0; v != n; ++v) {
			if (color.at(v) == Color::BLACK) continue;//訪問済みはスキップ
			if (weightedGraphMatrix.at(u).at(v) < 0 ) continue;//辺がない場合はスキップ
			const int distanceToVThroughCurrentU = d.at(u) + weightedGraphMatrix.at(u).at(v);
			if (distanceToVThroughCurrentU >= d.at(v)) continue;
			d.at(v) = distanceToVThroughCurrentU;
			p.at(v) = u;
			color.at(v) = Color::GRAY;
		}
	}
	for (int i = 0; i != n; ++i) {
		cout << i << " " << d.at(i) << endl;
	}
}

template<typename T>
void execute(T& cin) {
	vector< vector<int> > graphList;
	readWeightedGraphMatrix(cin, graphList);
	printSPST(graphList);
}


int main()
{


	execute(cin);
	

	return 0;
}


Measured memory_bytes: 3140
import math 
a, b, C = map(float,input().split())

S = (1/2) * a * b * math.sin(math.radians(C))
L = a + b + math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(C)))
h = S * 2 / a

print("{:.8f}".format(S))
print("{:.8f}".format(L))
print("{:.8f}".format(h))


Measured memory_bytes: 5700
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        final int K = sc.nextInt();
        int ans = 1;
        for(int i=0; i<N; i++) {
            if(i == 0) ans *= K;
            else ans *= K-1;
        }
        System.out.println(ans);
    }
}


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

//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

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

    ll x, y;
    cin >> x >> y;

    ll cnt = 0;
    do {
        cnt++;
        x *= 2;
    } while (x <= y);

    out(cnt);
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  
  long ans = 0;
  for (int a = 1; a < N; ++a) {
    ans += N / a;
    if (N % a == 0) {
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define MX 10000000000
#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return sol;
}

ll gcd( ll a, ll b )
{
   if( b == 0 )
      return a;
   else
   {
      return gcd( b, a % b );
   }
}
void solve()
{
	ll n, ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		if (i % 3 != 0 && i % 5 != 0)
		{
			ans += i;
		}
	}
	cout << ans;
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
}


Measured memory_bytes: 3632
#include <fstream>
#include <iostream>

using namespace std;

int main(){
    int N,mod;
    long long ans=0, sum=0;
    cin>>N;
    long long A[N];
    mod = 1000000007;
    for (int i=0;i<N;i++) {
        cin >> A[i];
        sum+=A[i];
    }
    sum%=mod;
    for(int i=0;i<N;i++){
        sum-=A[i];
        if(sum<0){
            sum+=mod;
        }
        ans +=(sum*A[i]);
        ans%=mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5168
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	int n,k;
	cin>>n>>k;
	if(k==1){ cout<<0; return 0; }
	cout<<n-k;
	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
l = []
r = []
for i in range(m):
    left, right = map(int, input().split())
    l.append(left)
    r.append(right)

lmax = max(l)
rmin = min(r)
ans = rmin - lmax + 1
if ans < 0:
    ans = 0
print(ans)


Measured memory_bytes: 10996
/*
 * main.c
 *
 *  Created on: 2019/07/07
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

typedef unsigned long long int uint64_t;
typedef long long int int64my_t;

//qsort(a, 3, sizeof(int), sort_inc);
int sort_inc(const void *a, const void *b)
{
    return (*(int*)a - *(int*)b);
}
int sort_dec(const void* a, const void* b)
{
    return (*(int*)b - *(int*)a);
}

int main()
{
	int N = 0, D = 0, ans = 0;
	scanf("%d %d", &N, &D);

	while(N > 0) {
		N -= 2 * D;
		ans++;
		if(N <= 1) {
			break;
		}
		N--;
	}
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(int argc, char *argv[]){
    int n;
    scanf("%d", &n);
    int array[n];
    int ct = 0;

    while(fgetc(stdin) != EOF){
        scanf("%d", array+ct);
        ct++;
    }

    int sum = 0;
    int min = array[0];

    for(int i = 0; i < n; i++){
        int flag = 0;
        if(array[i] <= min){
            min = array[i];
            flag = 1;
        }
        sum += flag;
    }
    printf("%d", sum);

    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii  = pair<int,int>;
const int INF=1001001001;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define MOD 1000000007
#define EPS 10e-8
int gcd(int a,int b){return b?gcd(b,a%b):a;}    //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数

int main(){
    string s;
    cin >> s;
    ll k;
    cin >> k;
    rep(i, min((ll)s.size(),k))
    {
        if(s[i]!='1'){
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << '1' << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node {int parent, left, right;};

Node T[MAX];
int n, D[MAX];
// D[u]: the depth of u

void setDepth(int u, int p){
    // u is a node
    // p is a depth
    D[u] = p;
    if (T[u].left != NIL){
        setDepth(T[u].left, p+1);
    }
    if (T[u].right != NIL){
        setDepth(T[u].right, p);
    }
}

void printAll(int u){
    int i,c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].parent << ", ";
    cout << "depth = " << D[u] << ", ";

    if( T[u].parent == NIL){
        cout << "root, ";
    }
    else if( T[u].left == NIL ){
        cout << "leaf, ";
    }
    else{
        cout << "internal node, ";
    }

    cout << "[";

    for (i = 0, c = T[u].left; c != NIL ; ++i, c = T[c].right)
    {
        if(i){
            cout << ", ";
        }
        cout << c;
    }
    cout << "]" << endl;
}

int main(){
    int i,j,d,v,c,l,r;
    // n: # of nodes
    cin >> n;

    // initialization
    for (int i = 0; i < n; ++i)
    {
        T[i].parent = T[i].left = T[i].right = NIL;
    }
    for (int i = 0; i < n; ++i)
    {
        // v:id, d:degree of v
        cin >> v >> d;
        // set the children of v
        for (int j = 0; j < d; ++j)
        {
            cin >> c;
            // If j = 0, the current node is the first child of v
            if(j==0){
                T[v].left = c;
            }
            else{
                T[l].right = c;
            }
            l = c;
            T[c].parent = v;
        }
    }

    // r: root
    for (int i = 0; i < n; ++i)
    {
        if (T[i].parent == NIL)
        {
            r = i;
        }
    }

    setDepth(r, 0);

    for (int i = 0; i < n; ++i)
    {
        printAll(i);
    }

    return 0;

}

Measured memory_bytes: 4544
import Control.Monad
import Data.List
import Data.Ord

main = do
  _ <- getLine
  cs <- sortOn Down . map read . words <$> getLine :: IO [Int]
  let (as, bs) = f cs [] []
  print $ (sum as) - (sum bs)
  
f [] al bo = (al , bo)
f [a] al bo = (al ++ [a], bo)
f (a:b:cs) al bo = f cs (al ++ [a]) (bo ++ [b])
  
  


Measured memory_bytes: 1020
<?php
// fscanf(STDIN, "%d", $N);
// $judge1 = $N % 9 === 0 ? "Yes" : "No";

fscanf(STDIN, "%s", $S);
$S = array_map('intval', str_split($S));
$judge2 = array_sum($S) % 9 === 0 ? "Yes" : "No";

// echo $judge1 === $judge2 ? $judge1 : "ERROR";
echo $judge2;


Measured memory_bytes: 34912
n = gets.to_i
x = gets.split.map(&:to_i)
ans = 1000000000
for i in 1..100 do
    sum = 0
    for j in 0..n - 1 do
        sum = sum + (x[j] - i) * (x[j] - i)
    end
    ans > sum ? ans = sum : sum = sum
end
puts ans

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

// digit..残り桁数

/*
ll dfs(int digit, ll input, ll sum2)
{
    if (digit == 0)
        return 0;
    int sum = 0;
    for (ll i = 1; i <= digit; i++)
    {
        cout << "=" << i << "," << input << endl;

        ll tmp2 = sum;
        sum += ((input - lldiv(input, pow(10LL, digit - i)).rem) / pow(10LL, digit - i) + sum2);
        cout << "aaa" << sum - tmp2 << endl;

        ll tmp = sum;
        sum = sum + dfs(digit - i, lldiv(input, pow(10LL, digit - i)).rem, sum);
        if (tmp != sum)
            cout << "bbb" << sum - tmp << endl;
    }

    return sum;
}
*/

ll dfs(int digit, ll input, ll sum)
{
    if (digit == 0)
    {
        // cout << "==" << sum << endl;
        return sum;
    }

    int sum2 = 0;
    for (ll i = 1; i <= digit; i++)
    {
        int tmp = 0;
        tmp += ((input - lldiv(input, pow(10LL, digit - i)).rem) / pow(10LL, digit - i));
        sum2 += dfs(digit - i, lldiv(input, pow(10LL, digit - i)).rem, sum + tmp);
    }
    return sum2;
}

signed main()
{
    string s;
    cin >> s;

    // ll a = (lldiv(100LL, pow(10LL, a)));

    // 100LL - a;
    // cout << s.size() << "," << atoll(s.c_str()) << endl;
    cout << dfs(s.size(), atoll(s.c_str()), 0) << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    lh = rli()
    c = 0
    for h in lh:
        # print(c, h)
        if h < c:
            print("No")
            return
        elif h == c:
            c = h
        else:
            c = h-1
    print("Yes")


if __name__ == '__main__':
    main()


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

using namespace std;

vector <int> D[100000];
long long DP[2][100000], M=1000000007;

void dfs (int d, int p)
{
    int a;
    for (int i = 0; i < D[d].size(); i++)
    {
        a = D[d][i];
        if (a != p)
        {
            dfs(a,d);
        }
    }
    if ((p != -1 && D[d].size() == 1) || D[d].size() == 0)
    {
        DP[0][d] = 1;
        DP[1][d] = 1;
    }
    else
    {
        DP[0][d] = 1;
        DP[1][d] = 1;
        for (int i = 0; i < D[d].size(); i++)
        {
            a = D[d][i];
            if (a != p)
            {
                DP[0][d] *= DP[0][a] + DP[1][a];
                DP[1][d] *= DP[0][a];
                DP[0][d] %= M;
                DP[1][d] %= M;
            }
        }
    }
    return;
}

int main()
{
    ios::sync_with_stdio(false);
    int N, a, b;
    cin >> N;
    for (int i = 0; i < N-1; i++)
    {
        cin >> a >> b;
        a--;
        b--;
        D[a].push_back(b);
        D[b].push_back(a);
    }
    dfs(0,-1);
    cout << (DP[1][0] + DP[0][0]) % M;
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, m, k, ans;

int main() {
    cin >> n;
    if (n >= 30)
        cout <<  "Yes" << endl;
    else
        cout <<  "No" << endl;
    return 0;
}


Measured memory_bytes: 3608
n=int(input())
a=list(map(int,input().split()))
a1=0
t=0
for i in range(n):
    t+=a[i]
    if i%2==0:
        if t<=0:
            a1+=1-t
            t=1
    else:
        if t>=0:
            a1+=1+t
            t=-1
a2=0
t=0
for i in range(n):
    t+=a[i]
    if i%2==1:
        if t<=0:
            a2+=1-t
            t=1
    else:
        if t>=0:
            a2+=1+t
            t=-1
print(min(a1,a2))

Measured memory_bytes: 14468
/**
        	C++14 (GCC 5.4.1)
**/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;

int main(){
    int N;

    cin >> N;

    bool b = false;
    for(int i = 0 ; i < 10 ; i++){
        for (int j = 0 ; j < 10 ; j++){
            if(i * j == N){
                b = true;
            }
        }
    }
    
    if(b){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int hantei=0;
  string S;
  cin>>S;
  
  for(int i=0;i<3;i++){
    for(int j=i+1;j<4;j++){
      if(S.at(i)==S.at(j)){
        hantei+=1;
      }
    }
  }
  if(hantei==2){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };


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

	ll n,a,b,ans=0,ret=M;
	string s;
	cin >> a >> b;
	if (b % a == 0) cout << a + b << endl;
	else cout << b - a << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi freopen("input.txt","r",stdin)
#define fo freopen("output.txt","w",stdout)
#define l(s) int(s.size())
#define pb push_back
/*
long long toint(string s)
{
	long long x=0,cnt=1,y=0;
	for(int i=l(s)-1;i>=0;i--)
	{
		x=0;
		x+=s[i]-48;
		x*=cnt;
		y+=x;
		cnt*=10;
	}
	return y;
}
*/
int main()
{
	string s;
	cin>>s;
	long long now=0,sum=0,ans=0;
	int n=l(s);
	for(int i=0;i<1<<(n-1);i++)
	{
		now=0,sum=0;
		for(int j=0;j<n;j++)
		{
			now*=10;
			now+=s[j]-'0';
			if(j<n-1&&(i>>j&1))
			{
				sum+=now;
				now=0;
			}
		}
		sum+=now;
		ans+=sum;
	}
	cout<<ans;//+toint(s);
	return 0;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
S = []
for i in range(N):
  S.append(input())
S.sort()
c = Counter(S).most_common()
m = c[0][1]
c.sort()
for i in range(len(c)):
    if c[i][1] == m:
      print(c[i][0])

Measured memory_bytes: 45084
using System;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Enumerable.Range(0, 6).Select(i => Console.ReadLine()).Select(x => int.Parse(x)).ToArray();
            var abcde = input.Take(5);
            var k = input.Skip(5).First();
            var ex = abcde.SelectMany((x, i) => abcde.Skip(i).Select(y => Math.Abs(x - y))).All(abs => abs <= k);
            
                Console.WriteLine(ex ? "Yay!" : ":(");
   
        }
    }
}


Measured memory_bytes: 13524
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7


def main():
    s = input()
    r = ''
    for c in s:
        if c == 'B':
            r = r[:-1]
        else:
            r += c
    return r



print(main())


Measured memory_bytes: 5424
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef long long ll;
ll cnt,sum;
int dp[100000];

int ana_check(string S1, string S2){
    int used[2][10]={false};
    for (int k = 0; k < 10; k++) {
        for (int l = 0; l < 10; l++) {
            if ( S1[k] == S2[l] && used[0][k] == false && used[1][l] == false){
                used[0][k] = true;
                used[1][l] = true;
                break;
            }
            if(l==9){
                return false;
            }
        }
    }
    return true;
}

int main()
{
    int N;
    cin >> N;
    string S[N];
    rep(i,N) cin >> S[i];
    map<string,ll> M;

    for (int i = 0; i < N; i++) {
        sort(S[i].begin(), S[i].end());
        M[S[i]]++;
    }
    for(auto itr : M){
        sum += itr.second*(itr.second-1)/2;
    }

    // for (int i = 0; i < N; i++) {
    //     if (dp[i]) {
    //         continue;
    //     }
    //     cnt=0;
    //     for (int j = i+1; j < N; j++) {
    //         if(dp[j]){
    //             continue;
    //         }
    //         if (ana_check(S[i],S[j]) ){
    //             cnt++;
    //             dp[j] = true;
    //         }
    //     }
    //     cnt = cnt*(cnt+1)/2;
    //     sum+=cnt;
    // }

    cout << sum;

    return 0;
}


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

using namespace std;

#define foru(i, l, r) for (register int i = l; i <= r; i++)
#define ford(i, r, l) for (register int i = r; i >= l; i--)

int N, M, dp[102][102];
char ch[102][102];

int main() {
  scanf("%d%d", &N, &M);
  for (int i = 1; i <= N; i++) scanf("%s", ch[i] + 1);
  dp[1][1] = (ch[1][1] == '#');
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= M; j++) {
      if (i > 1 || j > 1) dp[i][j] = 0x3f3f3f3f;
      if (i > 1)
        dp[i][j] = min(dp[i][j],
                       dp[i - 1][j] + (ch[i][j] == '#' && ch[i - 1][j] == '.'));
      if (j > 1)
        dp[i][j] = min(dp[i][j],
                       dp[i][j - 1] + (ch[i][j] == '#' && ch[i][j - 1] == '.'));
    }
  }
  printf("%d\n", dp[N][M]);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b;
	double x,y,z;
	x=(a*100.0)/8;
	y=b*10;
	z=ceil(x);
	c=(z*0.08);
	d=(z*0.1);
	
	if(c==a && d==b)
	{
		cout<<z<<endl;
		return 0;
	}
	z=ceil(y);
	c=(z*0.08);
	d=(z*0.1);
	if(c==a && d==b)
	{
		cout<<z<<endl;
		return 0;
	}

	cout<<-1<<endl;
	
}

Measured memory_bytes: 3764
n = gets.to_i
map = Array.new(n).map{Array.new}

(n-1).times do
  a, b = gets.split.map{|s| (s.to_i) -1}
  map[a] << b
  map[b] << a
end

count = Hash.new(0)
checks = Array.new(n)

queue = []
queue << [0, :b]
queue << [n-1, :w]

until queue.empty?
  i, color = queue.shift
  if checks[i]
    next
  else
    checks[i] = color
    count[color] += 1
    map[i].each do |j|
      queue << [j, color]
    end
  end
end

puts (count[:b] > count[:w]) ? 'Fennec' : 'Snuke'

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

void solve(long long a_I, long long a_O, long long a_T, long long a_J, long long a_L, long long a_S, long long a_Z){
	long long res = 0;
	res = a_O + a_I / 2 * 2 + a_J / 2 * 2 + a_L / 2 * 2;

	long long c = a_I % 2 + a_J % 2 + a_L % 2;
	if(c == 3) {
		res += 3;
	} else if(c == 2 && a_I > 0 && a_J > 0 && a_L > 0) {
		res += 1;
	}
	cout << res << endl;
}

int main(){	
	long long a_I;
	long long a_S;
	long long a_O;
	long long a_Z;
	long long a_L;
	long long a_T;
	long long a_J;
	scanf("%lld",&a_I);
	scanf("%lld",&a_O);
	scanf("%lld",&a_T);
	scanf("%lld",&a_J);
	scanf("%lld",&a_L);
	scanf("%lld",&a_S);
	scanf("%lld",&a_Z);
	solve(a_I, a_O, a_T, a_J, a_L, a_S, a_Z);
	return 0;
}



Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

#ifdef DEBUG
#else
    #define cerr if (false) cerr
#endif

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int x, y;
    cin >> x >> y;
    forn (i, 0, 110)
        forn (j, 0, 110)
            if (i + j == x && 2 * i + 4 * j == y)
                return cout << "Yes", 0;
    cout << "No";
    return 0;
}

Measured memory_bytes: 3648
s = str(input())
K = int(input())

def find(str):
	lt = []
	for start in range(len(str)):
		for end in range(start + 1, len(str) + 1):
			lt.append(str[start:end])
	lt = list(set(lt))
	lt.sort()

	return lt

s_pt = list(set(list(s)))
s_pt.sort()
ans = []
for i in range(min(5, len(s_pt))):
	ind = [ix for ix, x in enumerate(s) if x == s_pt[i]]
	for j in ind:
		ans += find(s[j:min(j+5, len(s))])
	ans = list(set(ans))
	if len(ans) >= 5:
		break
ans = list(set(ans))
ans.sort()
print(ans[K-1])

Measured memory_bytes: 4664
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, long long m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

const int N=1e6+5;

int n, k, b;

int check(int m)
{
	int val=b*m + k;
	return (val<=n);
}

int binsearch(int lo, int hi)
{
	while(lo<hi)
	{
		int mid=(lo+hi+1)/2;
		if(check(mid))
			lo=mid;
		else
			hi=mid-1;
	}
	return lo;
}

int32_t main()
{
    IOS;
    cin>>n>>k;
    int ans=0;
    for(b=k+1;b<=n;b++)
    {
    	int range=(b-k);
    	range*=(n/(b));
    	ans+=range;
    	int extra=n%(b);
    	extra-=max(0LL, (k-1));
    	ans+=max(0LL, extra);
    }
    cout<<ans;
    return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int T, X;
	cin >> T >> X;
	cout << (double)T / X << "\n";

	return 0;
}

Measured memory_bytes: 256
n, z, w = map(int, input().split())
a = list(map(int, input().split()))

if n == 1:
    ans = abs(a[0] - w)
else:
    a1 = abs(a[-1] - w)
    a2 = abs(a[-2] - a[-1])
    ans = max(a1, a2)

print(ans)


Measured memory_bytes: 3188
/*
**   Contest : AtCoder Beginner Contest 177
**   Problem : B - Substring
**
**    Author : Dhiraj Govindvira
**      Date : 29-Aug-2020 ~ Saturday
**      Time : 07:33:38 PM
*/

#if __has_include("D:/dhiraj/Programming/debug.h")
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
    #define cerr if(0) cerr
#endif

// Macro --------------------------------------------------------------------

#define ll                  long long int
#define FOR(i, a, b, s)     for(ll i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define FOR1(b)             FOR(i, 0, b, 1)
#define FOR2(i, b)          FOR(i, 0, b, 1)
#define FOR3(i, a, b)       FOR(i, a, b, (a) <= (b) ? 1 :-1)
#define FOR4(i, a, b, s)    FOR(i, a, b, s)
#define GET5(a, b, c, d, e, ...) e
#define FORC(...)           GET5(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)
#define loop(...)           FORC(__VA_ARGS__)(__VA_ARGS__)
#define all(x)              x.begin(), x.end()
#define rall(x)             x.rbegin(), x.rend()
#define endl                '\n'

// Template -----------------------------------------------------------------

// multiple input
template <typename... T> 
inline void inp(T&... args) {
    ((cin>>args), ...);
}
// scan vector
template <typename T> 
inline istream& operator >>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U> 
inline istream& operator >>(istream &in, pair<T, U> &a) {
    in >> a.first >> a.second; 
    return in;
}

// Solve --------------------------------------------------------------------

void solve(int &T)
{
    string s, t;
    cin >> s >> t;

    ll n = s.size();
    ll m = t.size();

    ll ans = 1e10;
    loop(i, n - m + 1) {
        ll cur = 0;
        loop(j, m) {
            if(s[i + j] != t[j]) {
                cur++;
            }
        }
        ans = min(ans, cur);
    }   
    cout << ans << endl;
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt", "r", stdin);
        freopen("D:/dhiraj/Programming/o1.txt", "w", stdout);
        // freopen("D:/dhiraj/Programming/e1.txt", "w", stderr);
    #endif

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

    int t = 1;
    for(int i = 1; i <= t; i++) {
        cerr << "Case #" << i << "\n";
        solve(i);
    }
    return 0;
}

Measured memory_bytes: 3568
s=input()
t=input()
key=t[0]
l=[]
for k,v in enumerate(s):
    f=0
    x=s[k:k+len(t)]
    if len(x)==len(t):
        for ke,j in enumerate(x):
            if j=="?":
                continue
            else:
                if x[ke]!=t[ke]:
                    f=1
                    break
        if not f:
            y=(s[:k]+t+s[k+len(t):]).replace("?","a")
            l.append(y)
    else:
        break
if l:
    print(min(l))
else:
    print("UNRESTORABLE")

Measured memory_bytes: 38256