akhauriyash/Code-Regression huggingface dataset:
s = input()
l = len(s)
flag = 1
for i in range(l//2):
    if s[i]!=s[-1-i]:
        flag = 0
        break
x = int((l-1)/2)
a = s[:x]
for i in range(x//2):
    if a[i]!=a[-i-1]:
        flag = 0
        break
y = (l+3)//2
b = s[y-1:]
for i in range((l-y+1)//2):
    if b[i]!=b[-1-i]:
        flag = 0
        break
if flag==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
bool check(ll n){
    ll ans=0;
    while(n>0){
        ans+=1;
        n/=10;
    }
    if(ans%2)
        return true;
    return false;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,i,ans=0;
    cin>>n;
    for(i=1;i<=n;i++){
        if(check(i))
            ans+=1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> pii;
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define SZ(x) x.size()
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

LL sum[N];
int main() {
    int n;
    cin >> n;
    rep(i, 1, n) {
        LL x; cin >> x;
        sum[i] = sum[i-1] + x;
    }
    LL ans = INF;
    rep(i, 1, n-1) ans = min(ans, abs(sum[i]-(sum[n]-sum[i])));
    cout << ans << endl; 

    system("pause");
    return 0;
}

Measured memory_bytes: 2040
using System;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
    	string s = Console.ReadLine();
    	var a = new List<int>();
    	for(int i = 0;i < s.Length; i++)
    	{
    		if(s[i]=='0')a.Add(0);
    		else if(s[i]=='1')a.Add(1);
    		else if(a.Count>0)a.RemoveAt(a.Count-1);
    	}
    	for(int i= 0 ;i<a.Count;i++)
    	Console.Write(a[i]);
    	
    	Console.WriteLine();
    }
    static int[] scan()
    {
        return Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
    }
}

Measured memory_bytes: 2776
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cstring>
#include<string>
#include<vector>
//#include<unordered_set>
#include<unordered_map>
#include<cmath>
using namespace std;

#define ull unsigned long long
#define ll long long
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1

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

const double eps = 1e-6;
const int MAXN = 100005;
const int MAXM = 5005;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
const double FINF = 1e18;
int ans[MAXN],a[MAXN], sum[MAXN];

int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	a += b, a %= 24;
	cout << a << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[110];
int main()
{
    int i;
    cin>>i;
    for(int t=0;t<i;t++)
        cin>>a[t];
    int sum=0;
    for(int t=0;t<i;t++)
        sum=sum+a[t];
        int i2;
        cin>>i2;
    int p,x;
    while(i2--)
    {
        cin>>p>>x;
        int sum2=sum;
        sum2=sum2-a[p-1];
        sum2=sum2+x;
        cout<<sum2<<endl;
    }
    return 0;
}


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


int main()
{
    int k;
    string s;
    cin >> k >> s;

    int size = s.size();
    if(size <= k)
    {
        cout << s << "\n";
    } else
    {
        cout << s.substr(0, k) + "..." << "\n";
    }
    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m,i,a[10000],b,j,t;
 while(cin>>n)
 {
   for(i=1;i<=n;i++)
   {
     cin>>a[i];
   }
   int cnt=0;
   for(i=1;i<=n;i++)
   {
     if(a[i]!=i)
     {
       cnt++;
     }
   }
   if(cnt<=2)
   {
     printf("YES\n");
   }
   else printf("NO\n");
 }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y>a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[130113];
int l[100310];
int j[302];

long long x,y,z,mod=1000000007;
//string r;
char r[111];

P u[100101],u1[100101];
queue<int> q;

//stack<int> s;
set<int> s;
map<int,int> p;
vector<P> v[200101];

bool as(P a,P b)
{
  if(a.x==b.x)
  return a.y<b.y;
  return a.x<b.x;
}

void f(int n)
{
  l[n]=1;
  k++;
  if(!l[o[n]])
  {
    f(o[n]);
  }
}

int main()
{
  scanf("%d",&a);
  for(int t=1;t<=a;u[t].y=t,t++)
    scanf("%d",&u[t].x);
  for(int t=1;t<=a;u1[t].y=t,t++)
    scanf("%d",&u1[t].x);
  sort(u+1,u+a+1,as);
  sort(u1+1,u1+a+1,as);
  for(int t=1;t<=a;t++)
    if(u[t].x>u1[t].x)
    {
      puts("No");
      return 0;
    }
  for(int t=1;t<a;t++)
    if(u[t+1].x<=u1[t].x)
    {
      puts("Yes");
      return 0;
    }
  for(int t=1;t<=a;t++)
    o[u[t].y]=u1[t].y;
  
  f(1);
  if(k==a) puts("No");
  else puts("Yes");
}




Measured memory_bytes: 7296
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;


	void doIt() {
		boolean end = true;
		char[] c = sc.next().toCharArray();
		int cnt[] = new int[c.length];
		Arrays.fill(cnt,  0);
		for(int i = 0; i < c.length;) {
			int l = i;
			while(c[i] == 'R') {
				i++;
			}
			int r = i;
			while(c[r] == 'L') {
				r++;
				if(r >= c.length) {
					end = false;
					break;
				}
			}
			//System.out.println(l +  " >>> " + r);
			if((i - l) % 2 != 0) {
				cnt[i - 1] ++ ;
			}
			cnt[i - 1] += (i - l) / 2;
			cnt[i] += (i - l) / 2;
			if((r - i) % 2 != 0) {
				cnt[i]++ ;
			}
			cnt[i - 1] += (r - i) / 2;
			cnt[i] += (r - i) / 2;

			//System.out.println("i:" + i);
			i = r;
			//System.out.println("i:" + i);
		}
		for(int i = 0; i < c.length; i++) {
			System.out.print(cnt[i] + " ");
		}
		System.out.println();
	}

	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 47096
import java.util.Scanner

import scala.collection.mutable.{ArrayBuffer, Map => MMap, Queue => MQueue}

object Main extends App
{
	val sc = new Scanner(System.in)
	val (n, m) = readInts()
	
	val adj = ArrayBuffer.fill(n)(List.empty[Int])
	(1 to m).foreach { _ =>
		val (from, to) = readInts()
		adj(from - 1) ::= to - 1
		adj(to - 1) ::= from - 1
	}
	
	val resultPreMap = calc()
	println("Yes")
	(1 until n).foreach(node => println(resultPreMap(node) + 1))
	
	private def calc(queue: MQueue[Int] = MQueue(0), preMap: MMap[Int, Int] = MMap(0 -> 0)): MMap[Int, Int] =
	{
		while (queue.nonEmpty) {
			val node = queue.dequeue()
			for (nextNode <- adj(node) if !preMap.contains(nextNode)) {
				queue += nextNode
				preMap += Tuple2(nextNode, node)
			}
		}
		preMap
	}
	
	private def readInts(): (Int, Int) =
	{
		(sc.nextInt(), sc.nextInt())
	}
}

Measured memory_bytes: 91756
a,b,c=map(int,input().split())
k=int(input())
abc=[a,b,c]
for i in range(k):
    if a>=b:
        b*=2
    elif a<b:
        if b>=c:
            c*=2
        else:
            c*=2
if a<b<c:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9188
/* it was worth becoming a chemist */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned int uni;
typedef unsigned long long unll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long long, int> pli;
typedef pair<int, long long> pil;
typedef vector<int> vi;
typedef vector<long long> vll;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define NAME "puts"
#define F first
#define S second

const ll INF = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const db EPS = (db) 1e-9;
const db pi = acos(-1.0);
const int MAXN = 1e5 + 5;

int n, a[MAXN];

bool check(int l, int r) {
	for (int i = l; i < r; i++) {
		if (a[i] != a[i + 1]) return 0; 
	}
	return 1;
}

int main() {	
    
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int res = 0, j = 1;
	for (int i = 1; i <= n; i++) {
		while (check(i, j)) j++;
		res += ((j - i) >> 1);
		i = j - 1;
	}
	cout << res;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
 
#include<deque>
#define pi 3.141592653589793238
#include<chrono>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const int N = 9e5 + 1;
ll fac[N];
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;

    while (y > 0)
    {

        if (y & 1)
            res = (res * x) % p;


        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

ll modi(ll a, ll m)
{
    return power(a, m - 2, m);

}
ll nCr(ll n, ll r, ll p)
{

    if (r == 0)
        return 1;
    fac[0] = 1;
    
    return (fac[n] * modi(fac[r], p) % p *
        modi(fac[n - r], p) % p) % p;
} 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    fac[0] = 1;
    for (i = 1; i <= 9e5; i++){
        fac[i] = (fac[i - 1] * i) % MOD;
    }

    //cin >> T;
    while (T--) {
        ll h, w, a, b;
        cin >> h >> w >> a >> b;
        ll ans = 0;
        ll ways = 1;
        for(i = 1; i <= h - a; i++){
            ll v1, v2;
            ll m, n;
            m = i, n = b;
            v1 = nCr(m + n - 2, n - 1, MOD);
            ways = v1;
            m = h - i + 1, n = w - b;
            v2 = nCr(m + n - 2 , n - 1, MOD);
            ans += v1 * v2;
            ans %= MOD;
        }
        
        cout << ans;
    }
    return 0;
}

Measured memory_bytes: 10668
n,k=map(int,input().split())
R,S,P=map(int,input().split())
string=input()
ans=0
for i in range(k):
    F=""
    for j in range(n):
        if i+j*k<=n-1:
            F+=string[i+j*k]
        else:
            break
    length=len(F)
    gu=[0 for i in range(length+1)]
    tyoki=[0 for i in range(length+1)]
    pa=[0 for i in range(length+1)]
    for index in range(1,length+1):
        gu[index]=max(tyoki[index-1],pa[index-1])
        tyoki[index]=max(gu[index-1],pa[index-1])
        pa[index]=max(gu[index-1],tyoki[index-1])
        if F[index-1]=="r":
            pa[index]+=P
        elif F[index-1]=="p":
            tyoki[index]+=S    
        elif F[index-1]=="s":
            gu[index]+=R
    ans+=max(tyoki[length],pa[length],gu[length])
print(ans)

Measured memory_bytes: 8856
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        //int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        //Console.WriteLine(Console.ReadLine().Replace("2017", "2018"));
        List<int> mochi = new List<int>();
        for (int i = 0; i < n; i++)
        {
            mochi.Add(int.Parse(Console.ReadLine()));
        }
        Console.WriteLine(mochi.Distinct().Count());
    }
}

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

int main() {
  char a, b;
  int ans;
  cin >> a >> b;
  if (a=='H'){
    ans=1;
  }
  else{
    ans=2;
  }
  if (b=='H'){
    ans=ans*1;
  }
  else{
    ans=ans*2;
  }

  if (ans==1 || ans==4){
    cout << "H" << endl;
  }
  else{
    cout << "D" << endl;
  }
}


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

#define pb push_back
#define pf push_front
#define pp pop_back
#define sz(a) (int)(a.size())
#define mp make_pair
#define F first
#define S second
#define next _next
#define prev _prev
#define left _left
#define right _right
#define y1 _y1
#define all(x) x.begin(), x.end()
#define what_is(x) #x << " is " << (x)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = (int)1e6 + 123;
const ll INF = (ll)1e18 + 123;
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;

void megaRandom() {
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  srand(FOR);
}

int n, a[N];
    
void no() {
	puts("NO");
	exit(0);
}

void yes() {
	puts("YES");
	exit(0);
}

int main() {
	megaRandom();
	scanf("%d", &n);
	ll sum = 0, op = 0;
	for(int i= 1; i <= n; i ++) {
		scanf("%d", &a[i]);
		sum += a[i];
		op += i;
	}
	if(sum % op != 0)	no();	
	if(n == 1) yes();
	ll cnt = sum / op;
	a[n + 1] = a[1];
	for(int i = 1; i <= n; i ++) {
		int raz = a[i + 1] - a[i];
		
		if(cnt - raz < 0 || (cnt - raz) % n != 0)
			no();
	}
	yes();
	return 0;  
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fr(i,a,n) for(i=a;i<n;i++)
#define frn(i,a,n) for(i=a;i<=n;i++)
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define ub upper_bound
#define lb lower_bound
//#define map map<ll,ll>
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define bs binary_search
#define qll queue<ll>
#define sll set<ll>
#define ma 500000
ll power(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return power(x*x,n/2);
    else                             //n is odd
        return x*power(x*x,(n-1)/2);
}
int highestPowerof2(int n)
{
   int p = (int)log2(n);
   return (int)pow(2, p);  
}
ll powermod(ll x, ll y, ll p)  
{  
    ll res = 1;
    x = x % p;
    if (x == 0) return 0;  
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
}
 
int main()
{
    ll c=0;
   string s1,s2;
   cin>>s1>>s2;
   if(s1==s2)
   cout<<0<<endl;
   else
   {
       for(ll  i=0;i<s1.length();i++)
       {
           if(s1[i]!=s2[i])
           c++;
       }
       cout<<c<<endl;
   }
   
}


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

const int MAX = 100001;
int a[MAX];

int main()
{
    int n, x;
    cin>>n>>x;
    long long ans = 0LL;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++)
    {
        int adding = a[i] + a[i+1] - x;
        if(adding > 0)
        {
            ans += adding;
            a[i+1] -= adding;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
a,b=map(int,input().split())
grid=[['.']*100 for _ in range(100)]

for i in range(50):
    for j in range(100):
        grid[i][j]='#'

nx=0
ny=0
for _ in range(a-1):
    grid[ny][nx]='.'
    if nx<98:
        nx+=2
    else:
        nx=0
        ny+=2

nx=0
ny=51
for _ in range(b-1):
    grid[ny][nx]='#'
    if nx<98:
        nx+=2
    else:
        nx=0
        ny+=2

print(100,100)
for i in range(100):
    print(*grid[i],sep='')

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

ll mod(ll a) {
	if (a > 0) return a % MOD;
	if (a % MOD == 0) return 0;
	ll x = -a / MOD + 1;
	a += x * MOD;
	return a % MOD;
}

template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(double x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
// int dx[4]    = {1, 0, -1, 0};
// int dy[4]    = {0, 1, 0, -1};
// ll pas[5001][5002];

int main() {
	IOS();
	ll a[4] = {};
	for (int i = 0; i < 3; ++i) {
		ll x, y;
		cin >> x;
		a[x]++;
		cin >> x;
		a[x]++;
	}
	ll cnt  = 0;
	bool ok = true;
	for (int i = 0; i < 4; ++i) {
		if (a[i] % 2 == 1) cnt++;
	}
	dump(cnt <= 2 ? "YES" : "NO");
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = [int(_x) for _x in input().split()]
    AA = A.copy()

    total = 0
    for i in range(len(AA)):
        if i == 0:
            continue
        dif = AA[i-1] - AA[i]
        if dif > 0:
            total += dif
            AA[i] = AA[i-1]
    print(total)


main()


Measured memory_bytes: 32200
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>

using namespace std;

typedef complex<double> xy_t;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF= 1 << 30;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;

int nums[10];
bool used[10];
int n, k;

map<int, bool> mp;
int pow(int n){
	int res = 1;
	while(n--) res *= 10;
	return res;
}

void dfs(int c, int num){
	if(c == k){
		mp[num] = true;
	}else{
		for(int i = 0; i < n; i++){
			if(!used[i]){
				int d = 1;
				if(nums[i] >= 10) d++;
				used[i] = true;
				dfs(c + 1, num * pow(d) + nums[i]);
				used[i] = false;
			}
		}
	}
}

int main(){
	while(cin >> n >> k && (n || k)){
		mp.clear();
		for(int i = 0; i < n; i++){
			cin >> nums[i];
		}
		fill(used, used + 10, false);
		dfs(0, 0);
		cout << mp.size() << endl;
	}
}

Measured memory_bytes: 0
#include<cstdio>
#include<algorithm>
using namespace std;
int n,x,vis[200005],a[200005],hd=1,i;
void pt(int x,int y)
{
	vis[x]=1;
	a[y]=x;
}
int main()
{
	scanf("%d%d",&n,&x);
	if(x==1||x==2*n-1)
	{
		printf("No\n");
		return 0;
	}
	if(n==2)
	{
		printf("Yes\n1\n2\n3\n");
		return 0;
	}
	printf("Yes\n");
	vis[x]=1;vis[1]=vis[2*n-1]=1;
	a[n]=x;a[n+1]=2*n-1;a[n-1]=1;
	if(x==2*n-2)pt(x-1,n+2);
	else pt(x+1,n-2);
	hd=1;
	for(i=1;i<=2*n-1;i++)
	{
		if(a[i])printf("%d\n",a[i]);
		else
		{
			while(vis[hd])hd++;
			printf("%d\n",hd);
			vis[hd]=1;
		}
	}
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
   int n,k;cin>>n>>k;
   vector<int> v(n),dp(n,2e9);
   for(int i=0;i<n;i++)cin>>v[i];
   dp[0]=0;
   for(int i=1;i<n;i++){
     for(int j=1;j<=k;j++){
       if(i-j>=0){
         dp[i]=min(dp[i-j]+abs(v[i-j]-v[i]),dp[i]);
       }
     }
   }
   cout<<dp[n-1];
    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int d[N];
  for (int i = 0; i < N; i++){
    cin >> d[i];
  }
  int sum=0;
  for (int i = 0; i < N; i++){
    for (int j = i+1; j < N; j++){
      sum+=d[i]*d[j];
    }
  }
  cout << sum;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	string n;
	cin >> n;
	for(int i = 0; i < 3; i++)
		n[i] = 10 - n[i] + '0' * 2;

	cout << n << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <cmath>
#include <cstring>

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)
#define SCANFD(x) scanf("%d",&x)

#define MAX 101

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

int main(){
    int N,M,X;
    int A[MAX];
    int reso=0,resn=0;
    
    scanf("%d %d %d",&N,&M,&X);

    REPI(M){
        scanf("%d",&A[i]);
    }

    REPI(M){
        if(A[i]<X){
            reso++;
        }else{
            resn++;
        }
    }

    printf("%d\n",mint(reso,resn));
    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

ll dp[105][2][5];

void Main() {
    string S;
    ll K;
    cin >> S >> K;
    ll N = S.size();
    dp[0][0][0] = 1;
    rep(i, N) {
        rep(j, 2) {
            rep(k, K + 1) {
                int d = S[i] - '0';
                if (j == 1) {
                    d = 9;
                }
                rep(m, d + 1) {
                    if (m == 0) {
                        dp[i + 1][j == 1 || m < d][k] += dp[i][j][k];
                    }else{
                        dp[i + 1][j == 1 || m < d][k + 1] += dp[i][j][k];
                    }
                }
            }
        }
    }
    cout << dp[N][1][K] + dp[N][0][K] << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int k;
	cin>>k;
	queue<ll>q;
	for(int i=1; i<10; i++)
	 q.push(i);
	ll num;
	while(k--)
	{
		num=q.front();
		q.pop();
		int rem=num%10;
		if(rem!=0)
		 q.push(10*num+rem-1);
		q.push(10*num+rem);
	    if(rem!=9)
	     q.push(10*num+rem+1);
	}
	cout<<num;
	return 0;
}

Measured memory_bytes: 5148
# -*- coding: utf-8 -*-
"""
Created on Tue Mar  5 15:34:44 2019

@author: avina
"""

n = int(input())
L = list(map(int, input().strip().split()))
dp = [0 for i in range(n)]
dp[1] = abs(L[1] - L[0]) 
for i in range(2,n):
    dp[i] = min(dp[i-2] + abs(L[i]-L[i-2]),dp[i-1] + abs(L[i] - L[i-1]))

print(dp[-1])

Measured memory_bytes: 13928
#include <cstddef>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;

    int a, b, c;
    cin >> a >> b >> c;

    ll ans {};

    if (a + b >= c)
    {
        ans = b + c;
    }
    else
    {
        ans = a + b + b;
        if (c > a + b)
            ans += 1;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define rv(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int M = 220000;
typedef long long ll;
int n,m,k;
int a[M];
int main(){
    cin>>n;
    fo(i,1,n) cin>>a[i];
    sort(a+1,a+1+n);
    bool fg=1;
    fo(i,1,n-1) {
        if(a[i]==a[i+1]) fg=0;
    }
    if(fg) puts("YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 1024
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    K = int(readline())

    N = 50

    q, r = divmod(K, N)
    A = [0] * N
    for i in range(N):
        if i < r:
            A[i] = N - 1 + (N + 1) * (q + 1) - K
        else:
            A[i] = N - 1 + (N + 1) * q - K

    print(N)
    print(*A)
    return


if __name__ == '__main__':
    main()


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

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> a(M);
    vector<int> b(M);
    rep(i, M){
        cin >> a[i] >> b[i];
    }
    vector<int> road(N+1);
    rep(i, M){
        road[a[i]]++;
        road[b[i]]++;
    }
    for(int i = 1; i<N+1; i++){
        cout << road[i] << endl;
    }
return 0;}
/**
 * g++ code.cpp
 * ./a.out
 * shift + ctrl + i
**/ 

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i < m; i++)
#define ll long long int

using namespace std;

#define DIV 1000000007

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

ll modinv(ll a, ll mod) {
  return modpow(a, mod - 2, mod);
}

ll conb(ll n, ll r) {
  ll result = 1;
  REP(i, r) {
    result = (result * (n - i)) % DIV;
  }
  FOR(i, 1, r + 1) {
    result = (result * modinv(i, DIV)) % DIV;
  }
  return result;
}

int main() {
  int m;
  ll n;
  vector<int> p;
  cin >> n >> m;

  while (m != 1) {
    bool flg = true;
    FOR(i, 2, (int)sqrt(m) + 1) {
      if (m % i == 0) {
        p.push_back(i);
        m = m / i;
        flg = false;
        break;
      }
    }
    if (flg) {
      p.push_back(m);
      break;
    }
  }

  ll result = 1;
  sort(p.begin(), p.end());
  int po = p[0];
  ll bj = 0;
  REP(i,p.size()) {
    if(po != p[i]) {
      result = (result*conb(bj + n - 1LL, bj))%DIV;
      po = p[i];
      bj = 0;
    }
    bj++;
  }

  result = (result*conb(bj + n - 1LL, bj))%DIV;

  cout << result << endl;
}



Measured memory_bytes: 256
import math

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

tsum=0

for x in range(1,N+1):
	
	logarithm=max(math.ceil(math.log(K/x,2)),0)
	# print(logarithm)
	tsum+=(1/(N*pow(2,logarithm)))

print(tsum)


Measured memory_bytes: 3060
/*
解き方：
対角成分が黒であれば、その行と列は削られない。
逆に言えば、対角成分が白の場所しか削られない。

*/

#include <iostream>
#include <cstdio>

using namespace std;

int main(){
  int h, w;
  cin >> h >> w;
  char map[101][101] = {};
  int chk[101][101] = {};

  for(int i = 0; i < h; i++){
    scanf("%s", map[i]);
  }

  for(int i=0;i<h;i++) { //横を見る
      bool flag=false;
      //その列に黒があればフラグを立てる
      for(int j=0;j<w;j++) if(map[i][j]=='#') flag=true;
      if(!flag) for(int j=0;j<w;j++) chk[i][j]=true;
  }

  for(int i=0; i < w; i++){ //縦を見る
    bool flag =  false;
    for(int j = 0; j < h; j++) if(map[j][i] == '#') flag = true;
    if(!flag) for(int j = 0; j<h; j++) chk[j][i] =true;
  }

  for(int i=0; i < h; i++){
    bool flag = false;
    for(int j=0; j < w; j++){
      if(!chk[i][j]){ // フラグが立ってないとこをみて
        flag = true;
        printf("%c", map[i][j]);
      }
    }
    if(flag) puts("");
  }


}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;
const long long mod = 1000000007;


int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	int n;
	cin >> n;
	vvi a(n + 1, vi(3));
	for (int i = 0; i < n; i++)
	{
		vi cur(3);
		for (int j = 0; j < 3; j++)
			cin >> cur[j];
		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k < 3; k++)
			{
				if (k == j)
					continue;
				a[i + 1][j] = max(a[i][k], a[i + 1][j]);
			}
			a[i + 1][j] += cur[j];
		}
	}
	cout << *max_element(all(a[n]));
	
	return 0;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

/* debugging */
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << ": " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<"| ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e5 + 10;
const int mod = 1e9 + 7;

int32_t main(){
    boost;
    
    //code
    int a[3];

    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    cout << a[0] + a[1];

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#define int long long
using namespace std;
#define deb(x) cout<<#x<<" = "<<x<<"\n";

signed main()
{
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//#endif
	/************************************/
	
	int n; cin>>n;
	int dp[n][3];
	for(int i=0; i<n; i++)
		for(int j=0; j<3; j++)
			cin>>dp[i][j];
	
	for(int i=1; i<n; i++)
	{
		dp[i][0] += max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] += max(dp[i-1][0], dp[i-1][2]);
		dp[i][2] += max(dp[i-1][0], dp[i-1][1]);
	}
	cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
	
return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n,k;
	cin >> n >> k;
	vector<int> a(n+1);
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}

	int p = -1,m = INF;
	for(int i = 1; i <= n; i++){
		if(a[i]<m){
			m = a[i];
			p = i;
		}
	}

	int ans = INF;
	
	for(int i = 0; i < k; i++){

		//cout << "p = " << p << " i = " << i << endl;
		int res = ceil((double)max(p+i-k,0) / (k-1))+1;
		//cout << "res = " << res << endl;
		res += ceil((double)max(n-p-i,0)/(k-1));
		//cout << "res = " << res << endl;
		if(res<ans) ans = res;
	}
	if(n==k) ans = 1;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

        int p = 0;
        while (((int) Math.pow(k, p)) <= n) {
            p++;
        }
        System.out.println(p);
    }
}

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

using namespace std;
#define ll long long
#define mod 1000000007

vector<pair<ll, ll>> v;
ll dp[101][100001];

ll f(ll i, ll cv) {
    if (i == v.size() && !cv) {
        return 0;
    } else if (i == v.size()) {
        return -1;
    }

    if (dp[i][cv] != -2) return dp[i][cv];

    ll ans1, ans2 = -1, ans;
    ans1 = f(i + 1, cv);
    if (v[i].second <= cv) {
        ans2 = f(i + 1, cv - v[i].second);
        if (ans2 != -1) {
            ans2 += v[i].first;
        }
    }

    if (ans1 == -1 && ans2 == -1) ans = -1;
    else if (ans1 == -1) ans = ans2;
    else if (ans2 == -1) ans = ans1;
    else ans = min(ans1, ans2);

    dp[i][cv] = ans;
    return ans;
}

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

    for (int i = 0; i <= 100; i++) {
        for (int j = 0; j <= 100000; j++) {
            dp[i][j] = -2;
        }
    }
    ll n, W;
    cin >> n >> W;

    v.resize(n);
    ll V = 0;
    for (ll i = 0; i < n; i++) {
        cin >> v[i].first >> v[i].second;
        V += v[i].second;
    }

    for (ll i = V; i >= 0; i--) {
        f(0, i);
    }

    for (ll i = V; i >= 0; i--) {
        if (f(0, i) != -1 && f(0, i) <= W) {
            cout << i;
            break;
        }
    }
}


Measured memory_bytes: 82608
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define pp pop
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
typedef long double ld;

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	cout << min(A, B) + min(C, D) << '\n';
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int hp = sc.nextInt();
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            hp -= sc.nextInt();
            if (hp <= 0)
                break;
        }
        System.out.println(hp <= 0 ? "Yes" : "No");
    }
}

Measured memory_bytes: 46472
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define len(n) (int)n.length()
#define pb push_back
#define ll long long
#define make_pair mkp
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) (v).begin(), (v).end()
#ifdef DBGPRT
#define dbg(n) cerr << "//" << #n << ":" << n <<endl
#else
#define dbg(n) ;
#endif
typedef pair<ll, ll> LLARR;
#define INF 999999999
const double PI = 3.1415926535897932384626433832795;

int main()
{
    int N;
    cin >> N;
     
    int *a = new int[N];
     
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
     
    int v = 0;
            for (int k = 0; k < N - 1; k++) {
            cout << a[k] << " ";
        }
        cout << a[N - 1] << endl;
    for (int i = 1; i < N; i++) {
        v = a[i];
        int j = i - 1;
        while ((j >= 0) && (a[j] > v))
        {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
                for (int k = 0; k < N - 1; k++) {
            cout << a[k] << " ";
        }
		dbg(4);
        cout << a[N - 1] << endl;
    }
     
    delete[] a;
     
    return 0;
}

Measured memory_bytes: 3032
#include<iostream>
#include<vector>
using namespace std;
#define yes(n) cout << ((n) ? "Yes" : "No") << endl
int main()
{
    int n,m;
    cin >> n >> m;
    if(n-2*m > 0)
    {
        cout << n-2*m;
    }
    else
    {
        cout << 0;
    }
}

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

namespace atc
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = new Solve();
            s.Exe();
            Console.ReadLine();
        }
    }
    
    class Solve
    {
        public void Exe()
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToList();
            var N = input[0]; var M = input[1];
            UnionFind uf = new UnionFind(N);
            for(int i = 0;i < M; i++)
            {
                var ab = Console.ReadLine().Split().Select(int.Parse).ToList();
                uf.unite(ab[0] - 1, ab[1] - 1);
            }
            int ans = 0;
            for(int i = 1; i < N; i++)
            {
                if(!uf.is_same(0, i))
                {
                    uf.unite(0, i);
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }

    }

    class UnionFind
    {
        int size;
        long[] root;
        public UnionFind(int n)
        {
            this.size = n;
            root = new long[n];
            for(int i = 0;i < n; i++)
            {
                root[i] = -1;
            }
        }

        long find_root(long a)
        {
            if (root[a] < 0) return a;
            return find_root(root[a]);
        }

        public void unite(long a, long b)
        {
            var a_root = find_root(a);
            var b_root = find_root(b);

            if (a_root != b_root)
            {
                if(root[b_root] < root[a_root])
                {
                    var t = a_root;
                    a_root = b_root;
                    b_root = t;
                }
                root[a_root] += root[b_root];
                root[b_root] = a_root;

            }
        

        }

        public bool is_same(long a, long b)
        {
            var a_root = find_root(a);
            var b_root = find_root(b);
            return a_root == b_root;
        }


    }
}


Measured memory_bytes: 42112
#include <bits/stdc++.h>
using namespace std;
const int seed = 998244353;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<int> a;
	vector<int> b;
	vector<vector<unsigned long long> > h;
	vector<vector<unsigned long long> > rev;
	vector<unsigned long long> Pow;
	h.resize(31);
	rev.resize(31);
	a.resize(n);
	b.resize(n);
	Pow.resize(n);
	Pow[0] = 1;
	for(int i = 1; i < n; ++i) {
		Pow[i] = Pow[i - 1] * seed;
	}
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for(int i = 0; i < n; ++i) {
		cin >> b[i];
	}
	for(int i = 0; i < 31; ++i) {
		h[i].resize(n);
		rev[i].resize(n);
	}
	for(int j = 0; j < 31; ++j) {
		for(int i = 0; i < n; ++i) {
			h[j][0] = h[j][0] * seed + (a[i] >> j & 1);	
			rev[j][0] = rev[j][0] * seed + ((a[i] >> j & 1) ^ 1);
		}
		for(int i = 1; i < n; ++i) {
			h[j][i] = (h[j][i - 1] - Pow[n - 1] * (a[i - 1] >> j & 1)) * seed + (a[i - 1] >> j & 1);
			rev[j][i] = (rev[j][i - 1] - Pow[n - 1] * ((a[i - 1] >> j & 1) ^ 1)) * seed + ((a[i - 1] >> j & 1) ^ 1);
		}
	}
	vector<unsigned long long> H;
	H.resize(31);
	for(int j = 0; j < 31; ++j) {
		for(int i = 0; i < n; ++i) {
			H[j] = H[j] * seed + (b[i] >> j & 1);
		}
	}
	for(int i = 0; i < n; ++i) {
		bool f = 1;
		int x = a[i] ^ b[0];
		for(int j = 0; j < 31; ++j) {
			if(x >> j & 1) {
				if(rev[j][i] != H[j]) {
					f = 0;
				}
			} else {
				if(h[j][i] != H[j]) {
					f = 0;
				}
			}
		}
		if(f == 1) {
			cout << i << ' ' << x << '\n';
		}
	}
	return 0;
}

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

int A,B,C,D;

int main(){
    cin>>A>>B>>C>>D;
    while(1){
        C=C-B;
        if(C<=0)break;
        A=A-D;
        if(A<=0)break;
    }
    if(A>C){printf("Yes");}else {printf("No");}
}

Measured memory_bytes: 3724
#include<iostream>
using namespace std;
int n;
main()
{
	cin>>n;
	int p=0;
	long cnt=0;
	for(;n--;)
	{
		long a;cin>>a;
		if(p+1>=a)
		{
			if(p<a)p=a;
			continue;
		}
		long now=a/(p+1);
		a%=p+1;
		if(a==0)
		{
			now--;
			a+=p+1;
		}
		if(p&&now>0)a=p;
		cnt+=now;
		if(p<a)p=a;
	}
	cout<<cnt<<endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi; 
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(a) int((a).size())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define inin(a, n, i) memset(a, i, sizeof(a[0])*(n))
#define contains(c, i) ((c).find(i) != (c).end())
#define present(i, c) (find(all(c), i) != (c).end())

#define trav(x, c) for(auto &x : c)
#define rep(i, n) for(int i = 0; i < n; i++)
#define repa(i, b, e) for(int i = (b)-((b)>(e)); i != (e)-((b)>(e)); i += 1-2*((b)>(e)))
	
template<class T> bool chkmax(T &x, T y) { return x < y ? x = y, true : false; }
template<class T> bool chkmin(T &x, T y) { return x > y ? x = y, true : false; }
template<class A, class B> A cvt(B x) { stringstream s; s << x; A r; s >> r; return r; }

void read() {}
void print() {}
template<class T, class... Args> void read(T& a, Args&... args) { cin >> a; read(args...); }
template<class T, class... Args> void print(T a, Args... args) { cout << a << ' '; print(args...); }
template<class... Args> void println(Args... args) { print(args...); cout << endl; }

#define debug(args...) { string s_(#args); replace(all(s_), ',', ' '); stringstream ss_(s_); istream_iterator<string> it_(ss_); cerr_(it_, args); }
void cerr_(istream_iterator<string> it) { (void) it; }
template<class T, class... Args> void cerr_(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; cerr_(++it, args...); }

template<class T, class S>  ostream& operator<<(ostream& os, const pair<T, S>& p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<class T> ostream& operator<<(ostream &os, const set<T> &s) { os << '{'; string sep; for (const auto &x : s) os << sep << x, sep = ", "; return os << '}'; }
template<class T, class S> ostream& operator<<(ostream &os, const map<T, S> &m) { os << '{'; string sep; for (const auto &x : m) os << sep << x, sep = ", "; return os << '}'; }
template<class T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }

//=========================

void run_test() {
	int n; double d;
    read(n, d);
    int ans = 0;
    rep(i, n) {
        double x, y;
        read(x, y);
        if(x * x + y * y <= d * d) ans++;
    }
    println(ans);
}

//=========================

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//int t_ = 1, t__; cin >> t__; while(t_ <= t__) { cout << "Case #" << t_++ << ": "; run_test(); }
	// int t_; cin >> t_; while(t_--) run_test();
	run_test();
	return 0;	
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;

  if (s[k-1] == 'A') {
    s[k-1] = 'a';
  } else if (s[k-1] == 'B') {
    s[k-1] = 'b';
  } else {
    s[k-1] = 'c';
  }

  cout << s << endl;

  return 0;
}


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

using namespace std;
 
typedef long long ll;
const ll MOD = 1e9+7;
const ll INF = 1e18;


#define PB push_back
#define MP make_pair
#define F first
#define S second

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}

ll ans=0;
ll n,m,q;
ll a[100][4];
vector<ll> v; 

void dfs(vector<ll> V){
    if(V.size()==n){
        ll tmp=0;
        for(ll i=0;i<q;i++){
            if( -V[ a[i][0]-1 ]+ V[ a[i][1]-1] == a[i][2]){
                 tmp+=a[i][3];
            }
        }
        chmax(ans,tmp);
    }else{
        V.PB(V.back());
        while(V.back()<=m){
            dfs(V);
            V.back()++;
        }
    }
}
int main(){
  	
    cin >> n >> m >> q;
    for(ll i=0;i<q;i++){
        for(ll j=0;j<4;j++){
            cin >> a[i][j];
        }
    }
    v.PB(1);
    dfs(v);
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#include<set>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N,a,res=0;
  set<int> sets;
  map<int,int> mp;
  cin >> N;
  REP(i,N){
    cin >> a;
    mp[a]++;
    sets.insert(a);
  }
  auto itr = sets.begin();
  for(auto itr=sets.begin();itr!=sets.end();++itr){
    if(mp[*itr] - *itr < 0){
      res += mp[*itr];
    }else
      res += mp[*itr] - *itr;
  }
  
  cout << res << endl;
  return 0;
}
int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 9216
require 'pp'

n, k = gets.chomp!.split.map(&:to_i)
h_n = gets.chomp!.split.map(&:to_i).sort

k.times do |i|
    h_n.pop
end

sum = 0
while h_n.empty?.!
    sum += h_n.pop
end

puts sum



Measured memory_bytes: 18888
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
#define REP(i, d, n) for(int i=(d); i<(n); i++)
typedef long long ll;
const int mod = 1e9 + 7;

int main() {

    string s;
    cin >> s;

    int a = (int) (s[0] - '0');
    int b = (int) (s[1] - '0');
    int c = (int) (s[2] - '0');
    int d = (int) (s[3] - '0');
    
    if(a+b+c+d == 7){
        cout << a << '+' << b << '+' << c << '+'<< d << '=' << 7 << endl;
    }
    else if(a+b+c-d == 7){
        cout << a << '+' << b << '+' << c << '-'<< d << '=' << 7 << endl;
    }
    else if(a+b-c+d == 7){
        cout << a << '+' << b << '-' << c << '+'<< d << '=' << 7 << endl;
    }
    else if(a-b+c+d == 7){
        cout << a << '-' << b << '+' << c << '+'<< d << '=' << 7 << endl;
    }
    else if(a+b-c-d == 7){
        cout << a << '+' << b << '-' << c << '-'<< d << '=' << 7 << endl;
    }
    else if(a-b-c+d == 7){
        cout << a << '-' << b << '-' << c << '+'<< d << '=' << 7 << endl;
    }
    else if(a-b+c-d == 7){
        cout << a << '-' << b << '+' << c << '-'<< d << '=' << 7 << endl;
    }
    else if(a-b-c-d == 7){
        cout << a << '-' << b << '-' << c << '-'<< d << '=' << 7 << endl;
    }

    return 0;
}

Measured memory_bytes: 256