akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

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

int main(){
  int a[8][8] = {
    {1,2,1,2,1,4,1,4},
    {1,2,1,4,1,4,1,2},
    {1,4,1,2,1,2,1,4},
    {1,4,1,4,1,2,1,2},
    {2,1,2,1,4,1,4,1},
    {2,1,4,1,4,1,2,1},
    {4,1,2,1,2,1,4,1},
    {4,1,4,1,2,1,2,1}}; 

    int b[8];

  while(~scanf("%d" ,&b[0])){
    int ans[8],min_ = (1<<29);
    for(int i = 1 ; i < 8 ; i++){
      scanf("%d" ,b + i);
    }
    
    rep(i,8){
      int npas = 0;
      rep(j,8){
	int d = b[j] - a[i][j];
	if(d > 0){
	  npas += d;
	}
      }
      if(min_ > npas){
	min_ = npas;
	rep(j,8){
	  ans[j] = a[i][j]; 
	}
      }
    }

    rep(i,8){
      if(i != 7){
	printf("%d " ,ans[i]);
      }else{
	printf("%d\n" ,ans[i]);
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 1028
#include <stdio.h>
#include <string.h>
#define MAX_N 100000
 
typedef struct process{
    char name[20];
    int time;
} P;
 
P queue[MAX_N];
int head, tail;
 
void initialize(){
    head = 0;
    tail = 0;
}
 
void enqueue(P x){
    queue[tail] = x;
    tail = (tail+1) % MAX_N;
}
 
P dequeue(){
    P x = queue[head];
    head = (head+1) % MAX_N;
    return x;
}
 
int main(){
    int i, n, q;
    scanf("%d %d\n", &n, &q);
 
    for(i = 0; i < n; i++){
        P que;
        scanf("%s %d", que.name, &que.time);
        enqueue(que);
    }
 
    int elapsed = 0;
    while (head != tail){
        P proc = dequeue();
        if (proc.time <= q){
            elapsed += proc.time;
            printf("%s %d\n", proc.name, elapsed);
        }else{
            elapsed += q;
            proc.time -= q;
            enqueue(proc);
        }
    }
 
    return 0;
}

Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>

using namespace std;

void solve() {
	int n, q, a[100000], b[50000],i,j;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	cin >> q;
	for (i = 0; i < q; i++) {
		cin >> b[i];
	}
	int r, l;
	int ans = 0;
	for (i = 0; i < q; i++) {
		r = 0; l = n - 1;
		if (b[i] == a[0]) ans++;
		else {
			while (l - r > 1) {
				int m;
				if ((l + r) % 2 == 1)m = (l + r + 1) / 2;
				else m = (l + r) / 2;
				if (a[m] >= b[i])l = m;
				else r = m;
				
			}
			if (b[i] == a[l])ans++;
		}
	}
	cout << ans<<endl;
}

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


Measured memory_bytes: 3616
import copy,collections
N = int(input())
s = ['a']
for i in range(2,N+1):

    tmp = copy.copy(s)
    tmp2 = []
    for tm in tmp:
        tc = collections.Counter(tm)
        lc = len(tc.values())
        for j in range(1,lc+2):
            tmp2.append(tm+chr(96+j))
    s = copy.copy(tmp2)
for sa in s:
    print(sa)


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

int main(){
  int a, b, c, d;
  cin >> a >> b;
  cin >> c >> d;
  if(d == 1) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<functional>
#include<map>
using namespace std;

int main() {
	int a;
	cin >> a;
	for (int b = 0; b < a; b++) {
		string c; cin >> c;
		if ((c.length() & 1)==0&&c.length()>=6) {
			if (c[0] == '>'&&c[1] == '^'&&c[c.length() - 1] == '~'&&c[c.length() - 2] == '~') {
				bool e = true;
				for (int d = 2; d < c.length() - 2; d += 2) {
					if (c[d] != 'Q' || c[d + 1] != '=')e = false;
				}
				if (e) {
					puts("B");
					continue;
				}
			}
			if (c[0] == '>'&&c[1] == '\''&&c[c.length() - 1] == '~') {
				bool k = true;
				for (int j = 2; j < c.length() - 1; j++) {
					if (j == c.length() / 2) {
						if (c[j] != '#')k = false;
					}
					else {
						if (c[j] != '=')k = false;
					}
				}
				if (k) { puts("A"); continue; }
			}
		}
		puts("NA");
	}
}

Measured memory_bytes: 2884
#include <iostream>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

int N;
string S;
bool length(string S, int len) {
  rep(i, N-len+1) {
    if (S.find(S.substr(i, len), i+len) != string::npos) {
      return true;
    }
  }
  return false;
}

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

  int ok = -1, ng = N;
  while (abs(ok - ng) > 1) {
    int mid = (ok + ng) / 2;
    if (length(S, mid)) ok = mid;
    else ng = mid;
  }
  out(ok);

  return 0;
}


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

#define F first
#define S second
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()

#define rep(i,n) for(int i=0;i<n;++i)
#define Rep(i,a,n) for(int i=a;i<=n;++i)
#define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mset multiset
#define pqueue priority_queue
#define umap unordered_map
 
using namespace std;

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

const double PI=acos(-1),eps=1e-9;
const int dx[]={-1,1,0,0},dy[]={0,0,-1,1};
const int N=3e5+5,mod=1e9+7,inf=1e9;

void solve(){
	int n,d;
	cin>>n>>d;
	int x[n][d];
	for(int i=0;i<n;++i){
		for(int j=0;j<d;j++){
			cin>>x[i][j];
		}
	}
	int ans=0;
	for(int i=1;i<n;++i){
		for(int k=0;k<i;k++){
			ll s=0;
			for(int j=0;j<d;j++){
				s+=abs(x[k][j]-x[i][j])*abs(x[k][j]-x[i][j]);
			}
			ll b=sqrt(s);
			if(b*b==s){
				ans++;
			}
		}
	}
	cout<<ans;
}

int main(){
	Speed();
	int T=1;
	//cin>>T;
	while(T--)solve();
}



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

// #undef LOCAL
#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);
  int N;
  cin >> N;
  vector<int> x(N);
  vector<int> y(N);
  vector<ll> h(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i] >> h[i];
  }
  dumpv(x);
  dumpv(y);
  dumpv(h);
  for (int cy = 0; cy <= 100; cy++) {
    for (int cx = 0; cx <= 100; cx++) {
      ll ch = -1;
      for (int i = 0; i < N; i++) {
        if (h[i] > 0) {
          ch = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
          break;
        }
      }
      int match = 1;
      for (int i = 0; i < N; i++) {
        if (h[i] != max(ch - abs(x[i] - cx) - abs(y[i] - cy), 0LL)) {
          match = 0;
          break;
        }
        // if (ch != hh && h[i] > 0) {
        //   match = 0;
        //   break;
        // }
      }
      // dump(cx, cy, match);
      if (match) {
        cout << cx << " " << cy << " " << ch << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
PS = [list(input().split()) for _ in range(M)]

acdic = {}

wadic = [0] * 10 ** 5

ac = 0
wa = 0

for ps in PS:
    p = int(ps[0])
    s = ps[1]

    if not p in acdic:
        if s == "WA":
            wadic[p] += 1
        else:
            ac += 1
            acdic[p] = True
            wa += wadic[p]


print(ac, wa)

Measured memory_bytes: 41308
def main():
    s = str(input())
    t = str(input())

    temp = s[:]

    if (len(s) != len(t)):
        print('No')
        return

    for i in range(len(s)):
        s = temp[1:] + temp[0]
        temp = s[:]
        if (s == t):
            print('Yes')
            return

    print('No')


if __name__ == '__main__':
    main()


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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nk = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var n = nk[0];
        var k = nk[1];
        var xs = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

        k -= 1;
        var shortest = long.MaxValue;
        int i = k;
        while (i < n && xs[i] < 0)
        {
            shortest = -xs[i - k];
            i++;
        }
        while (i < n && xs[i - k] < 0)
        {
            var s = -xs[i - k];
            var l = xs[i];
            if (s > l)
            {
                var t = s;
                s = l;
                l = t;
            }
            shortest = Math.Min(shortest, s * 2 + l);
            i++;
        }
        if (i < n && xs[i] < shortest)
        {
            shortest = xs[i];
        }
        Console.WriteLine(shortest);
    }
}

Measured memory_bytes: 21728
#入力
S = input()
#扱いやすくするためリスト化
ls = list(S)
#反転させたものもリスト化する
lsr = list(reversed(ls))
count = 0
for i in range(len(ls)):
  if ls[i] != lsr[i]:
    count += 1
print(count//2)

Measured memory_bytes: 3060
from sys import stdin
from numpy import argmin

n = int(stdin.readline().strip())
h_lst = [int(x) for x in stdin.readline().split()]
cnt = 0

def glow(lst, start_pos):
  global cnt
  if len(lst) == 0:
    return -1
  elif len(lst) == 1:
    cnt += lst[0] - start_pos
    return -1
  else:
    pos = min(lst)
    cnt += pos - start_pos
    id_ = argmin(lst)
    glow(lst[:id_], pos)
    glow(lst[id_+1:], pos)
    
glow(h_lst, 0)
print(cnt)


Measured memory_bytes: 27116
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int c;
	int end;
	
	c = end = 0;
	
	while (1) {
		scanf("%d %d", &a, &b);
		
		if ((a == 0) && (b == 0)){
			break;
		}
		
		if (end != 0){
			printf("\n");
		}
		
		for (; a <= b; a++){
			if ((a % 4 == 0) && (a % 100 != 0) || (a % 400 == 0)){
				printf("%d\n", a);
				c++;
			}
		}
		if (c == 0){
			printf("NA\n");
		}
		end++;
		c = 0;
	} 
	
	return (0);
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<pair<double, double>> p(n);
  vector<int> v(n);
  rep(i, n) {
    double x, y;
    cin >> x >> y;
    p[i] = make_pair(x, y);
  }
  double sum = 0;
  iota(ALL(v), 0);
  do {
    rep(i, n - 1) {
      sum += sqrt((p[v[i]].first - p[v[i + 1]].first) *
                      (p[v[i]].first - p[v[i + 1]].first) +
                  (p[v[i]].second - p[v[i + 1]].second) *
                      (p[v[i]].second - p[v[i + 1]].second));
    }
  } while (next_permutation(ALL(v)));
  int m = 1;
  while (n > 0) {
    m *= n;
    n--;
  }
  cout << setprecision(12) << sum / m << endl;
  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
mod=10**9+7
d=[mod]*(n+1)
d[0]=1;d[1]=1
for i in a:
  d[i]=0
for i in range(2,n+1):
  d[i]=min(d[i],(d[i-1]+d[i-2])%mod)
print(d[n])

Measured memory_bytes: 50264
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<vector>
#include<cmath>
#define maxn 777 
#define ll long long  
using namespace std;
int n,T,a[maxn] = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}; 
inline int read()
{
	int x = 0;
	int flag = 1;
	char ch;
	ch = getchar();
	while(!isdigit(ch)) 
	{
		if(ch == '-') flag = -1;
	ch = getchar();
	} 
	while(isdigit(ch))
	{
		x = (x<<1) + (x<<3) + ch - 48;
		ch = getchar();
	}
	return x * flag;
}


int main()
{
	n = read();
	printf("%d\n",a[n]); 
	
	return 0;
}


Measured memory_bytes: 256
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 8 2019
 * 
 */

#include <bits/stdc++.h>

//#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 

    int n;

    cin>>n;

    vi v(n);

    iv(v);

    sort(all(v));

    cout<<v[n/2] - v[n/2 - 1]<<endl;



    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   String a = sc.next();
    
   if(a.charAt(0)==a.charAt(1)||a.charAt(1)==a.charAt(2)||a.charAt(2)==a.charAt(0)) System.out.println("No");
   else System.out.println("Yes");
 }
}

Measured memory_bytes: 21844
from sys import stderr, setrecursionlimit
setrecursionlimit(2147483647)
def getInt():
    return int(input())
def getInts():
    return [int(i) for i in input().split()]
def getIntLines(n=1):
    res = []
    for _ in range(n):
        res.append(getInt())
    return res
def getIntsLines(n=1):
    res = []
    for _ in range(n):
        res.append(getInts())
    return res
def debug(*args, sep=" ", end="\n"):
    for item in args:
        stderr.write(str(item))
        stderr.write(sep)
    stderr.write(end)

n, t = getInts()
tl = getInts()
ans = 0
last = 0
last_head = 0
for v in tl:
    if v <= last:
        last += (v + t) - last
    else:
        ans += last - last_head
        last_head = v
        last = last_head + t
ans += last - last_head
print(ans)

Measured memory_bytes: 25836
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
const long long mod = 1000000007;

struct D {
	int a, n;
};

int search(D* d, int t, int n) {
	if (d[0].a == t)return 0;
	int r = 0;
	for (int i = 20; i >= 0; i--) {
		int c = r + 1 << i;
		if (c >= n)continue;
		if (d[c].a == t)return c;
		if (d[c].a < t)r = c;
	}
	return -1;
}

int main() {
	int N;
	scanf("%d", &N);
	int *a = new int[N];
	for (int i = 0; i < N; i++) {
		scanf("%d", a + i);
	}
	std::sort(a, a + N);
	std::vector<D> d;
	for (int i = 0; i < N; i++) {
		if (i != 0 && d[d.size() - 1].a == a[i]) {
			d[d.size() - 1].n++;
		}
		else {
			d.push_back({ a[i],1 });
		}
	}
	bool can = false;
	d[0].n--;
	int n = d.size();
  if(n>=1000){printf("No");return 0;}
	for (int i = 0; i < n; i++) {
		int bb = d[0].a, b;
		if (d[i].n == 0)continue;
		b = d[i].a;
		int c = search(d.data(), bb^b, n);
		if (c != -1 && d[c].n > 0) {
			std::vector<D> e;
			for (int j = 0; j < n; j++) {
				e.push_back(d[j]);
			}
			e[i].n--;
			can = true;
			for (int j = 0; j < N - 2; j++) {
				int c = search(e.data(), bb^b, n);
				if (c != -1 && e[c].n > 0) {
					bb = b;
					b = e[c].a;
					e[c].n--;
				}
				else {
					can = false;
					break;
				}
			}
			if (can) {
				if (bb^b == e[0].a) {
					break;
				}
				else {
					can = false;
				}
			}
		}
	}
	printf(can ? "Yes" : "No");
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N+1);
  vector<int> B(N);
  for(int i=0;i<(N+1);i++){
    cin >> A.at(i);
  }
  for(int i=0;i<N;i++){
    cin >> B.at(i);
  }
  
  int64_t ans = 0;
  for(int i=0;i<N;i++){
    if(A.at(i)-B.at(i)>=0){
      A.at(i) -= B.at(i);
      ans += B.at(i);
      continue;
    }
    int x = B.at(i) - A.at(i);
    int y = min(A.at(i+1),x);
    ans += y + A.at(i);
    A.at(i+1) -= y;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        cout<<"x";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
/*input

*/
#include <bits/stdc++.h>
#define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i))
#define down(i,b,a) for(int (i) = (b);i>=(a);--i)
#define debug(x) cerr << (x) << '\n';
#define bits(x,i) ((x >> i) & 1)
using namespace std;
long long n;
long long pw(int x){
    return 1LL*x*x*x*x*x;
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    long long x = 0;
    while (pw(x) <= n){
        long long y = n - pw(x);
            y = pow(y, 0.2);
        if (pw(x) + pw(y) == n) {
            cout << x << ' ' << -y << '\n';
            return 0;
        }
        x++;
    }   
    for(int i=1;i<=1500;++i){
        if (n % i == 0){
            int j = 1;
            while (pw(j+i) - pw(j) <= n){
                if (pw(j+i) - pw(j) == n) {
                    cout << j+i << ' ' << j << '\n';
                    return 0;
                }
                j++;
            }
            i = n/i;
            while (pw(j+i) - pw(j) <= n){
                if (pw(j+i) - pw(j) == n) {
                    cout << j+i << ' ' << j << '\n';
                    return 0;
                }
                j++;
            }
            i =  n/i;
        }
    }
}

Measured memory_bytes: 4088
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <stack> 
#include <map>
#include <queue>
#include <unordered_map>
#include <cassert>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
#define pb 					push_back
#define FAST_IO          ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
template<typename T,typename S>
ostream& operator <<(ostream& os, pair<T, S> input) {
	os<<"("<<input.first<<", "<<input.second<<")";
	return os;
}
template<typename T>
ostream& operator <<(ostream& os, vector<T> input) {
	for(auto t: input)
		os << t <<" ";
	return os;
}
template<typename T>
ostream& operator <<(ostream& os, set<T> input) {
	for(auto t: input)
		os << t <<" ";
	return os;
}



int main() {	
	string s;
	cin >> s;
	if(s[1]=='B')
		s[1] = 'R';
	else
		s[1] = 'B';
	cout << s;
	return 0;
}














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

int main() {
  int N,K,i,j,n,c,d,count,ans,M;
  cin >> N >> K;
  vector<int> a(N);
  for(i=0;i<N;i++){
    cin >> a.at(i);
    if(a.at(i)==1) j=i;
  }
  c = max(0,j+K-N);
  d = min(j,K-1);
  ans = 100000;
  for(n=c;n<=d;n++){
    count = 1;
    M = j-n;
    while(M>0){
      M -= K-1;
      count++;
    }
    M = j+K-n-1;
    while(M<N-1){
      M += K-1;
      count++;
    }
    if(count < ans) ans = count;
  }
  cout << ans << endl;
  
  return 0;
}



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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    REP(i, S.length()) {
        if (S[i] == '?')
            S[i] = 'D';
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// clang-format off
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// clang-format on

void solve(long long N) {
  ll a = 1e17;
  for (ll i = 1; i <= sqrt(N) + 1; i++)
    if (N % i == 0 && i + N / i - 2 <= a)
      a = i + N / i - 2;
  cout << a << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
ans = 0
s0 = 0
s = 0

for i in range(k):
    s0 += i
    s += n
    n -= 1
while s - s0 + 1 >= 0:
    ans += s - s0 + 1
    s += n
    n -= 1
    s0 += k
    k += 1
print(ans % (10**9 + 7))

Measured memory_bytes: 64128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
const int N = 3e3+ 2, mod = 1e9 + 7;
int r, c, k;
ll a[N][N];
ll dp[N][N][4];
// vector<vector<ll>> dp(N, vector<ll> (N));

void solve() {
	cin >> r >> c >> k;
	for (int i = 0; i < k; i++) {
		int x, y, v;
		cin >> x >> y >> v;
		a[x][y] = v;
	}
	for (int i = 1; i <= r; i++) {
		for (int j = 1; j <= c; j++) {
			for (int t = 3; t; --t) {
				dp[i][j][t] = max(dp[i][j][t], dp[i][j][t-1] + a[i][j]);
			}
			for (int t = 0; t <= 3; t++) {
				dp[i][j+1][t] = max(dp[i][j+1][t], dp[i][j][t]);
				dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][t]);
			}
		}
	}
	ll ans = 0;
	for (int t = 0; t <= 3; t++) {
		ans = max(dp[r][c][t], ans);
	}
	cout << ans;
}

int main() {
	int tt = 1;
	// cin >> tt;
	for (int tc = 1; tc <= tt; tc++) {
		solve();
	}
}

Measured memory_bytes: 355512
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut a = read_vec::<i128>();
    a.dedup();
    let n = a.len();
    if n == 1 {
        println!("{}", 1000);
        return;
    }

    let mut points = vec![];
    let mut increasing = false;
    if a[0] < a[1] {
        increasing = true;
        points.push(0);
    }
    for i in 1..n - 1 {
        if increasing {
            if a[i] > a[i + 1] {
                points.push(i);
                increasing = false;
            }
        } else {
            if a[i] < a[i + 1] {
                points.push(i);
                increasing = true;
            }
        }
    }
    if a[n - 2] < a[n - 1] {
        points.push(n - 1);
        increasing = true;
    }
    if points.len() % 2 == 1 {
        points.pop();
    }
    debug!(points);

    let mut cur_money = 1000;
    let mut cur_stock = 0;
    //assert!(points.len() % 2 == 0);
    for i in 0..points.len() / 2 {
        cur_stock += cur_money / a[points[2 * i]];
        cur_money %= a[points[2 * i]];
        cur_money += cur_stock * a[points[2 * i + 1]];
        cur_stock = 0;
    }
    println!("{}", cur_money);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2168
H,W=map(int,input().split())
s=[]
for _ in range(H):
    s.append(list(input()))
def dfs(y,x):
    q=[(y,x)]
    visited=[[-1]*W for _ in range(H)]
    visited[y][x]=0
    while q:
        cy,cx=q.pop(0)
        for dy,dx in ((1,0),(-1,0),(0,-1),(0,1)):
            nx=cx+dx
            ny=cy+dy
            if 0<=ny<H and 0<=nx<W and s[ny][nx]=='.' and visited[ny][nx]==-1:
                visited[ny][nx]=visited[cy][cx]+1
                q.append((ny,nx))
    return max(max(i) for i  in visited)
ans=0
for h in range(H):
    for w in range(W):
        if s[h][w]=='.':
            ans=max(dfs(h,w),ans)
print(ans)

Measured memory_bytes: 3188
n=gets.to_i
xy=$<.map{|s|s.split.map &:to_i}

s,t=xy.map{|x,y|x+y&1}.uniq

if t
  p -1
else
  uv=xy.map{|x,y|[x+y,x-y]}
  a=(0..31).map{|i|1<<i}
  a.unshift 1 if s==0
  p a.size
  puts a*" "
  
  uv.map{|u,v|
    ub=(u+(1<<32)-s)/2
    vb=(v+(1<<32)-s)/2
    r=""
    r+="L" if s==0
    32.times{|i|
      u=ub[i]
      v=vb[i]
      r+="LDUR"[u*2+v]
    }
    puts r
  }
end


Measured memory_bytes: 4220
#include <map>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
int N, Q, pos, x, y, a[200009], b[200009]; map<int, int> d;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cin >> N >> Q;
	for (int i = 0; i < 2 * N; i++) cin >> a[i];
	for (int i = 0; i < 2 * N; i++) cin >> b[i];
	long long s = 0; int c = 0;
	for (int i = 0; i < 2 * N; i++) {
		if (i == 0 || i == 2 * N - 1) s += a[i];
		else {
			if (a[i] > b[i]) c++;
			s += max(a[i], b[i]);
			d[abs(a[i] - b[i])]++;
		}
	}
	for (int i = 0; i < Q; i++) {
		cin >> pos >> x >> y; pos--;
		if (pos == 0 || pos == 2 * N - 1) {
			s -= a[pos];
			a[pos] = x; b[pos] = y;
			s += a[pos];
		}
		else {
			if (a[pos] > b[pos]) c--;
			s -= max(a[pos], b[pos]);
			d[abs(a[pos] - b[pos])]--;
			if (d[abs(a[pos] - b[pos])] == 0) d.erase(abs(a[pos] - b[pos]));
			a[pos] = x; b[pos] = y;
			if (a[pos] > b[pos]) c++;
			s += max(a[pos], b[pos]);
			d[abs(a[pos] - b[pos])]++;
		}
		cout << s - (c & 1 ? d.begin()->first : 0) << '\n';
	}
	return 0;
}

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

int a[10][10];
int main(void){
    int n, c=1;
    while(cin >> n && n) {
        int idx = 1;
        int x = 1;
        int y = 0;
        int d = 1;
        a[0][0] = 1;
        for(int sum = 1; sum <= 2*n-2; ++sum) {
            for(;;) {
                a[y][x] = ++idx;
                if(y==n-1 && x==n-1) break;
                if(sum%2==0) {x++; y--;}
                else {x--; y++;}
                if(x < 0 || y < 0 || x >= n || y >= n) break;
            }
            if(sum < n-1) {
                if(sum%2==1) {x=0; y=sum+1;}
                else {y=0; x=sum+1;}
            } else {
                if(sum%2==1) {y=n-1; x=sum+1-y;}
                else {x=n-1; y=sum+1-x;}
            }
        }
        printf("Case %d:\n", c);
        rep(i, n) {
            rep(j, n) {
                if(a[i][j]>=100) cout << a[i][j];
                else if(a[i][j]>=10) cout << " " << a[i][j];
                else cout << "  " << a[i][j];
            }
            cout << endl;
        }
        c++;
    }
}

Measured memory_bytes: 1192
package main

import (
	"fmt"
	"sort"
	"strings"
)

func main() {
	var a, b, c string
	fmt.Scan(&a, &b, &c)

	arr := []string{a, b, c}

	sort.Strings(arr)
	fmt.Println(strings.Join(arr, " "))
}



Measured memory_bytes: 1132
import java.util.Scanner;

public class Main {
    Scanner sc = new Scanner(System.in);
    
    void run() {
        for (;;) {
            String in = sc.next();
            if (in.equals("#END")) {
                return;
            }
            String ans = "";
            for (int i = 1; i < in.length(); i++) {
                String lcs = lcs(in.substring(0, i), in.substring(i, in.length()));
                if (lcs.length() > ans.length()) {
                    ans = lcs;
                }
            }
            System.out.println(ans);
        }
    }
    
    String lcs(String s, String t) {
        int n = s.length();
        int m = t.length();
        int[][] dp = new int[n + 1][m + 1];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (s.charAt(i) == t.charAt(j)) {
                    dp[i + 1][j + 1] = dp[i][j] + 1;
                } else {
                    dp[i + 1][j + 1] = Math.max(dp[i + 1][j], dp[i][j + 1]);
                }
            }
        }
        char[] res = new char[dp[n][m]];
        while (n > 0 && m > 0) {
            if (dp[n][m] == dp[n - 1][m]) {
                n--;
            } else if (dp[n][m] == dp[n][m - 1]) {
                m--;
            } else {
                res[dp[n - 1][m - 1]] = s.charAt(n - 1);
                n--;
                m--;
            }
        }
        return String.valueOf(res);
    }
    
    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 284772
import java.util.*;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashMap;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();
		int sum = 0;
		for(int i = 0; i < S.length-1; i++) {
			if(S[i] != S[i+1]) sum++;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 26144
#include<bits/stdc++.h>
using namespace std;
int dp[1000000];
int ar[1000000];
int f(int i,int n,int k)
{
	if(i==n)
	return 0;
	if(dp[i]!=-1)
	return dp[i];
	int cost=f(i+1,n,k)+abs(ar[i]-ar[i+1]);
	for(int j=2;j<=k;j++)
{
		if(i+j<=n)
	{  
		cost=min(cost,f(i+j,n,k)+abs(ar[i]-ar[i+j]));
	}
}
	return dp[i]=cost;
}
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>ar[i];
	}
	memset(dp,-1,sizeof(dp));
	cout<<f(1,n,k);
}

Measured memory_bytes: 12672
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()

bc = [None]*(N+1)
bc[N] = 0
for i in range(N-1, -1, -1):
    bc[i] = bc[i+1] + N - bisect.bisect_right(C, B[i])
ans = 0
for i in range(N):
    ans += bc[bisect.bisect_right(B, A[i])]
print(ans)


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

using namespace std;

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

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(int i = (int)m; i < (int)n; i++)
#define rep(i,n) REP(i,0,n)
#define rep2(i,n) REP(i,1,n+1)
#define rep3(i,n) REP(i,0,n+1)
#define REPM(i,m,n) for(int i = (int)m; i >= (int)n; i--)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define repll(i,n) REPLL(i,0,n)
#define repll2(i,n) REPLL(i,1,n+1)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define Size(s) (int) s.size()
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >

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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll csum_E[n + 2];
    csum_E[0] = 0;

    rep(i, n) {
        csum_E[i + 1] = csum_E[i] + (s[i] == 'E' ? 1 : 0);
    }
    csum_E[n + 1] = csum_E[n];

    ll Min = LINF;

    rep2(i, n) {
        ll sum = 0;
        sum += i - 1 - csum_E[i - 1];
        sum += csum_E[n] - csum_E[i];
        Min = min(Min, sum);
    }

    cout << Min << endl;



    return 0;
}


Measured memory_bytes: 3076
#include <stdio.h>
#include <math.h>
#include <limits.h>
unsigned long long f(long long i, long long j){
    return (unsigned long long)(pow(i, 5) - pow(j, 5));
}
int main(){
    unsigned long long X;
    scanf("%llu", &X);
    for( long long i = 0; i <= 500; i++ ){
        for( long long j = 0; j <= 500 ; j++ ){
            if( f(i, j) == X ){
                printf("%lld %lld\n", i, j);
                goto OUT;
            }else if( f(-i, -j) == X ){
                printf("%lld %lld\n", -i, -j);
                goto OUT;
            }else if( f(i, -j) == X ){
                printf("%lld %lld\n", i, -j);
                goto OUT;
            }else if( f(-i, j) == X ){
                printf("%lld %lld\n", -i, j);
                goto OUT;
            }
        }
    }
OUT:
    return 0;
}

Measured memory_bytes: 2536
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)

int main() {
	ll n; cin >> n;
	string s, t; cin >> s >> t;

	ll minV = 1 << 21;
	rep(i, 0, s.size()) {
		ll k = 0;
		bool match = true;
		rep(j, i, s.size()) {
			if (s[j] == t[k]) {
				k++;
			}
			else {
				match = false;
				break;
			}
		}
		if (match) {
			minV = min(minV, i);
		}
	}
	minV = minV == 1 << 21 ? s.size() : minV;
	cout << minV + t.size() << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func moreToTen(n int) int {
  return (10 - n % 10) % 10
}

func main() {
	var a,b,c,d,e int
	fmt.Scan(&a,&b,&c,&d,&e)
	
	nums := []int{a,b,c,d,e}
	moreToTens := []int{moreToTen(a),moreToTen(b),moreToTen(c),moreToTen(d),moreToTen(e)}
	
	maxIdx := 0
	max := 0
	for i := 0; i < len(moreToTens); i++ {
		if max < moreToTens[i] {
			maxIdx = i
			max = moreToTens[i]
		}
	}

 	
 	sum := 0
 	for i := 0; i < len(nums); i++ {
 		if i != maxIdx {
 			sum += nums[i] +  moreToTens[i]
 		} else {
 			sum += nums[i]
 		}
     
 	}
 	fmt.Println(sum)
}

Measured memory_bytes: 512
#include<cstdio>
int n,a,b,ans;
int main()
{
	scanf("%d%d%d",&n,&a,&b);
	for(int i=1;i<=n;++i){
		int d=0,s=i;
		while(s) d+=s%10,s/=10;
		if(a<=d&&d<=b) ans+=i;
	}
	printf("%d\n",ans);
	return 0; 
}

Measured memory_bytes: 128
N = list(map(int,input().split()))
ans = set([])
for i in range(N[1]+1):
	ans.add(i)
for i in range(N[0]):
	receive = list(map(int,input().split()))
	sub_ans = set(receive[1:])
	ans = ans & sub_ans
print(len(ans))

Measured memory_bytes: 3060
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#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
#define trace4(a, b, c, d)          cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)     cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}



int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(a*b,c*d);
    return 0;
}
/* The judge is never wrong! Your code is buggy 
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

Measured memory_bytes: 256
group_a = {1, 3, 5, 7, 8, 10, 12}
group_b = {4, 6, 9, 11}
group_c = {2}

x, y = map(int, input().split())
if x in group_a and y in group_a:
  print("Yes")
elif x in group_b and y in group_b:
  print("Yes")
elif x in group_c and y in group_c:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll k, n;
    cin>>k>>n;
    ll a[2*n], i, ans = 1e17;
    for(i = 0; i < n; i++) {
    	cin>>a[i];
    }
    for(i = n; i < 2*n; i++) {
    	a[i] = a[i - n] + k;
    }
    for(i = 0; i < n; i++) {
    	ans = min(ans, a[i + n - 1] - a[i]);
    }
    cout<<ans<<"\n";
}

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

typedef long long ll;

ll ceill(ll a, ll b) { 
    ll k = a/b;
    if(a%b != 0)
        k++;
    return k;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    while(cin >> n) {
        ll a = 1, b = 1;
        for(int i = 0; i < n; i++) {
            ll x, y; cin >> x >> y;
            if(x < a || y < b) {
                ll k = max(ceill(a,x), ceill(b,y));
                x *= k; y *= k;
            }
            a = x; b = y;
        }
        cout << a+b << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <sstream>
#include <map>
#include <unordered_map>
#include <ctime>
#include <cassert>
#include <cstring>
#include <sys/time.h>
#include <stdlib.h>
using namespace std;

int main(int argc, char *argv[]){
  int h, a, o;
  cin >> h >> a;
  if(h%a==0){
    o = h/a;
  }else{
    o = h/a+1;
  }
  cout << o << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
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() {
    int a,b,x;
    cin >> a >> b >> x;
    if (x-a <= b && x >= a) {
        cout << "YES" << "\n";
    } else {
        cout << "NO" << "\n";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=100005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    vector<ll> A(N),sum(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    
    sum[N-1]=A[N-1];
    for(int i=N-2;i>=0;i--){
        sum[i]=(sum[i+1]+A[i])%mod;
    }
    
    ll ans=0;
    
    for(int i=0;i+1<N;i++){
        ans+=A[i]*sum[i+1];
        ans%=mod;
    }
    
    cout<<ans<<endl;
}




Measured memory_bytes: 6364
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n, m;
    cin >> n >> m;
    if (n == m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define itn int
#define gI gi
#define int long long

using namespace std;

typedef long long ll;

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

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

int po[103], ans, n, m, a[200003], minn = 200003;
char s[100003];

signed main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	n = gi();
	int xx = n, cnt = 0;
	while (xx)
	{
		xx = xx / 10, ++cnt;
	}
	po[1] = 1;
	for (int i = 2; i <= 8; i+=1) po[i] = po[i - 1] * 10;
	for (int i = 1; i <= n; i+=1)
	{
		int ii = i, x = 0, y = ii % 10;
		if (!y) continue;
		while (ii)
		{
			x = ii % 10, ii /= 10;
		}
		for (int j = 1; j <= cnt; j+=1)
		{
			if (j == 1)
			{
				if (x == y) ++ans;
			}
			else if (j < cnt) ans += po[j - 1];
			else
			{
				int xsl = y * po[cnt] + x, xxsl = xsl;
				for (int k = 2; k < cnt; k+=1)
				{
					xxsl += 9 * po[k];
				}
				if (n >= xsl) 
				{
					ans += (min(xxsl, n) - xsl) / 10 + 1;
				}
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,a[15];
bool vis[15];
vector<int>v[15];
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int x;
        scanf("%d",&x);
        while(x--)
        {
            int y;
            scanf("%d",&y);
            v[i].push_back(y);
        }
    }
    for(int i=1;i<=m;i++)
        scanf("%d",&a[i]);
    int ans=0;
    for(int i=0;i<1<<n;i++)
    {
        memset(vis,false,sizeof(vis));
        for(int j=0;j<n;j++)
            if(1<<j&i) vis[j+1]=true;
        bool flag=true;
        for(int j=1;j<=m;j++)
        {
            int res=0;
            for(int k=0;k<v[j].size();k++)
                if(vis[v[j][k]]) res^=1;
            if(res!=a[j]) flag=false;
        }
        ans+=flag;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define debug1(a) cout<<"------\n"<<#a<<" = "<<a<<endl<<"------"<<endl
#define debug2(a,b) cout<<"--------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<endl<<"--------------"<<endl
#define debug3(a,b,c) cout<<"----------------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<" ; "<<#c<<" = "<<c<<endl<<"----------------------"<<endl
#define sz(a) (ll)(a.size())
#define debug4(a) cout<<"chu "<<a<<endl
#define endl "\n"

string s[1005];
ll dp[1005][1005];

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  ll h,w;
  cin>>h>>w;
  forn(i,1,h+1){
    cin>>s[i];
    s[i]=" "+s[i];
  }
  forn(i,1,h+1){
    forn(j,1,w+1){
      if(i+j==2) {
        dp[i][j]=1;
        continue;
      }
      ll a=0,b=0;
      if(s[i-1][j]!='#')
        a=dp[i-1][j];
      if(s[i][j-1]!='#')
        b=dp[i][j-1];
      dp[i][j]=(a+b)%mod;
    }
  }
  ll ans=dp[h][w];
  cout<<ans<<endl;
  return 0;
}


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

frogs = list(map(int, input().split()))

dp = [float('inf')] * n
dp[0] = 0
for i in range(n):
    temp = float('inf')
    for j in range(1, k+1):
        if i >= j:
            temp = min(abs(frogs[i] - frogs[i-j]) + dp[i-j], temp)
    dp[i] = min(dp[i], temp)


print(dp[-1])

Measured memory_bytes: 85156
#include <bits/stdc++.h>
#define ll long long
#define fort(i,n) for (int i = 1; i <= n; ++i)
#define pi pair<int,int>
#define vi vector<int>
#define pb push_back
#define sz size()
#define er erase
#define fr first
#define sc second
#define rc(x) return cout << x, 0
using namespace std;

string s;
int a,b;

int32_t main()
{
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> s;
    string t="keyence";
    for (int i = 0 ; i < 7; ++i)
        if (s[i]==t[i]) ++a;
        else break;
    for (int i = 1; i <= 7; ++i)
        if (s[s.sz-i]==t[7-i]) ++b;
        else break;
    if (a+b>=7) cout << "YES";
    else cout << "NO";
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long X = sc.nextLong();

        long sum = 100; 
        long year = 0; 
        while (sum < X) {
            sum += sum/100;
            year++;
        }

        System.out.println(year);
    }
}

Measured memory_bytes: 35736
N = int(input())

import fractions
a = list(map(int, input().split()))
#最大公約数
ans = a[0]
for i in range(1, N):
    ans = fractions.gcd(ans, a[i])

cnt = 0

while ans%2 == 0:
    ans /= 2
    cnt += 1

print(cnt)

Measured memory_bytes: 5048
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
//long long num[100000];
int main(){
	int a,b;
	cin>>a>>b;
	if(a%3&&b%3&&(a+b)%3){
		cout<<"Impossible"<<endl;
	}else cout<<"Possible"<<endl;
	return 0;
}

Measured memory_bytes: 256
s = input()
n = len(s)
ans = ''
for i in range(n):
    if s[i] == '0':
        ans +='0'
    elif s[i] == '1':
        ans+= '1'
    else:
        if len(ans)>0:
            ans = ans[:len(ans)-1]
        else:
            continue
print(ans)
        

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

cnt = [0 for i in range(n + 1)]

for _a in a:
  cnt[_a] += 1

ans = 0
for _cnt in cnt:
  ans += _cnt * (_cnt - 1) // 2

for _a in a:
  print(ans - cnt[_a] + 1)

Measured memory_bytes: 26268