akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9+7;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
int dist_1[111111];
int dist_n[111111];
vector<int> edge[111111];
int n, a, b;
queue<int> Q;

int main(void)
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int i, u, v; cin>>n;
	for(i=1 ; i<=n-1 ; i++)
	{
		cin>>u>>v;
		edge[u].push_back(v);
		edge[v].push_back(u);
	}
	for(i=1 ; i<=n ; i++) dist_1[i]=1e9;
	for(i=1 ; i<=n ; i++) dist_n[i]=1e9;
	dist_1[1]=dist_n[n]=0;
	Q.push(1);
	while(!Q.empty())
	{
		int x=Q.front(); Q.pop();
		for(i=0 ; i<edge[x].size() ; i++)
		{
			int nxt=edge[x][i];
			if(dist_1[nxt]>dist_1[x]+1)
				dist_1[nxt]=dist_1[x]+1, Q.push(nxt);
		}
	}
	Q.push(n);
	while(!Q.empty())
	{
		int x=Q.front(); Q.pop();
		for(i=0 ; i<edge[x].size() ; i++)
		{
			int nxt=edge[x][i];
			if(dist_n[nxt]>dist_n[x]+1)
				dist_n[nxt]=dist_n[x]+1, Q.push(nxt);
		}
	}
	for(i=1 ; i<=n ; i++) if(dist_1[i]<=dist_n[i]) a++;
	if(a>n-a) cout<<"Fennec"; 
	else cout<<"Snuke"; return 0;
}

// 제출하기 전에 생각햇나요?
// it may be easier/harder than you think
// ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

Measured memory_bytes: 6912
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    int N;
    cin >> N;
    cout << "ABC" << N << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
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; }
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
static const int mod = 1e+7;
int main(){
    int N;
    cin >> N;
    vector<ll> h(N);
    rep(i,N) cin >> h[i];
    ll dp[100010];
    const ll INF = 1LL << 60;
    rep(i,100010){
        dp[i] = INF;
    }
    dp[0] = 0;
    for(int i = 1; i < N; i++){ //dp[i]はINFで初期化されているからできること
        chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if(i > 1){
            chmin(dp[i], dp[i-2] + abs(h[i]-h[i-2]));
        }
    }
    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1920
# coding: utf-8
# Your code here!
s = input()
t = input()
s += s
ans = "No"
for i in range(len(s)//2):
    if s[i] == t[0]:
        for j in range(len(t)):
            if s[i+j] != t[j]:
                break
            elif j == len(t)-1:
                ans = "Yes"
print(ans)
            


Measured memory_bytes: 5564
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), Y = sc.nextInt() / 1000;
		boolean find = false;
		for(int x = 0; x <= N && x * 10 <= Y; x++) {
			for(int y = 0; x + y <= N && x * 10 + y * 5 <= Y; y++) {
				if(Y - 10 * x - 5 * y == N - x - y) {
					find = true;
					System.out.println(x + " " + y + " " + (N - x - y));
					break;
				}
			}
			if(find) break;
		}
		if(!find) System.out.println("-1 -1 -1");
	}
}

Measured memory_bytes: 25172
#include<stdio.h>
int main(){
    char s[3];
    char t[3];
    int i;

    scanf("%s",s);
    scanf("%s",t);
    int count = 0;
    for(i=0;i<3;i++){
        if(s[i]==t[i]){
        count++;
        }
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	i64 n, x; scanf("%lld%lld", &n, &x);
	
	i64 p = 1, b = 0;
	for(int i = 0; i < n; i++) {
		p = 2 * p + 1;
		b = 2 * b + 2;
	}
	i64 ans = 0;
	while(p > 1 and x) {
		p = (p - 1) >> 1;
		b = (b - 2) >> 1;
		if(p + b + 1 < x) {
			ans += p + 1;
			x -= p + b + 2;
		} else {
			x--;
		}
	}
	if(x) ans++;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 7;
int a[MAXN], MIN[MAXN], MAX[MAXN];
int len[MAXN];
bool b[MAXN];
struct node{int pos, val;};
deque<node>qmin, qmax;

int f[MAXN];
int find(int x) {return x == f[x] ? x : f[x] = find(f[x]);}
void unite(int x, int y)
{
    x = find(x), y = find(y);
    if (x == y) return;
    if (x < y) swap(x, y);
    f[x] = y;
}
vector<int>vec;
int main()
{
    int n, k; scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++) f[i] = i;
    for (int i = 1; i <= n; i++)
    {
        if (a[i] >= a[i - 1]) len[i] = len[i - 1] + 1;
        else len[i] = 1;
        if (len[i] >= k) b[i] = 1;
        if (b[i]) vec.push_back(i);
    }
    for (int i = 1; i < vec.size(); i++) unite(vec[i - 1], vec[i]);
    for (int i = 1; i <= n; i++) 
    {
        while (qmin.size() && qmin.front().pos < i - k) qmin.pop_front();
        while (qmin.size() && qmin.back().val >= a[i]) qmin.pop_back();
        qmin.push_back({i, a[i]});

        while (qmax.size() && qmax.front().pos < i - k) qmax.pop_front();
        while (qmax.size() && qmax.back().val <= a[i]) qmax.pop_back();
        qmax.push_back({i, a[i]});
        if (i > k)
        {
            if (qmin.front().val == a[i - k] && qmax.front().val == a[i]) unite(i - 1, i);
        }
    }
    int ans = 0;
    for (int i = k; i <= n; i++) if (find(i) == i) ans++;
    printf("%d\n", ans);
    return 0;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

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

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

  int n;
  cin >> n;

  vector<ll> a(n);

  rep(i, n) cin >> a[i];

  ll now = 2;

  ll ans = a[0]-1;

  rep(i, 1, n){

    if(now == a[i]){
      now++;
    }else{

      ans += (a[i] + now - 1) / now - 1; 

    }


  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif




#define int long long
#define rng(i,l,r) for(size_t i=(l);i<(r);++i)
#define rep(i,n) rng(i,0,n)
#define gnr(i,l,r) for(size_t i=(r)-1;i>=(l);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()   //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend()//...,3,2,1

using namespace std;


//constant
const int MOD = 1e9+7;
const int INF = 1e18;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};
const double pi = acos(-1);


template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int gcd(int a,int b){return b?gcd(b,a%b):a;}
//*max_element(ALL(vector))
//count(ALL(vector),num) -> n
//memset(obj,value,sizeof(obj));




void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,k; cin >> n >> k;
    
    int ans = 0;
    
    for (int ik = k; ik <= n+1; ik++) {
        int front = (0+ik-1)*ik/2;
        int end = (n-ik+1+n)*ik/2;
        ans += end-front+1;
        ans %= MOD;
    }
    
    cout << ans << endl;
    
    
    
    
    
    
}





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




Measured memory_bytes: 3664
object Main extends App {
  import scala.io.StdIn._
  val Array(a, b, c, d) = readLine.trim.split(' ').map(_.toLong)
  val lower = (a - 1) - (a - 1) / c - (a - 1) / d + (a - 1) / lcm(c, d)
  val upper = b - b / c - b / d + b / lcm(c, d)
  println(upper - lower)
  def gcd(a: Long, b: Long): Long = {
    b match {
      case 0 => a
      case _ => gcd(b, a % b)
    }
  }
  def lcm(a: Long, b: Long): Long = {
    a / gcd(a, b) * b
  }
}


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

int a,b,c;
string message;
int temp = 0;
int main() {
  cin >> a >> b >> c;
  if (a == b) temp++;
  if (c == b) temp++;
  if (a == c) temp++;
  if (temp == 1) {
    message = "Yes";
  }else{
    message = "No";
  }
  cout << message << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

// Solution
public class Main {
  private static Scanner in;
  private static PrintWriter out;
  private static final String INPUT = ""; // input file name

  /**
   * Interactive get next command
   */
  static int get(int pos) {
    out.println(pos + 1);
    out.flush();
    return ni();
  }

  static void solve() {
    int[] arr = new int[5];
    
    for (int i = 0; i < 5; i++) {
    	arr[i] = ni();
    }
    
    for (int i = 0; i < 5; i++) {
      if (arr[i] == 0) {
        out.println(i + 1);
      }
    }
  }

  public static void main(String[] args) throws Exception {
    long S = System.currentTimeMillis();
    in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
    out = new PrintWriter(System.out);

    solve();
    out.flush();
    long G = System.currentTimeMillis();
    tr(G - S + "ms");
  }

  private static int ni() {
    return Integer.parseInt(in.next());
  }

  private static long nl() {
    return Long.parseLong(in.next());
  }

  // Math Utils
  private static int pi(int num, int pow) {
    int result = 1;

    while (pow > 0) {
      if (pow % 2 == 1) {
        result *= num;
      }

      num *= num;
      pow /= 2;
    }

    return result;
  }

  private static int pim(int num, int pow, int mod) {
    int result = 1;

    while (pow > 0) {
      if (pow % 2 == 1) {
        // keep collecting `odd` num in result
        result = (result * num) % mod;
      }

      num = (num * num) % mod;
      pow /= 2;
    }

    return result;
  }

  private static long pl(long num, long pow) {
    long result = 1;

    while (pow > 0) {
      if (pow % 2 == 1) {
        result *= num;
      }

      num *= num;
      pow /= 2;
    }

    return result;
  }

  private static long plm(long num, long pow, long mod) {
    long result = 1;

    while (pow > 0) {
      if (pow % 2 == 1) {
        // keep collecting `odd` num in result
        result = (result * num) % mod;
      }

      num = (num * num) % mod;
      pow /= 2;
    }

    return result;
  }

  static void tr(Object... o) {
    if (!INPUT.isEmpty())
      out.println(Arrays.deepToString(o));
  }
}


Measured memory_bytes: 38668
dxy = zip([1,0,-1,0],[0,1,0,-1])
while 1:
    H,W,L = map(int,raw_input().split())
    if H == 0: break
    c = [raw_input() for i in xrange(H)]
    
    for h in xrange(H):
        for w in xrange(W):
            if c[h][w] in "ESWN":
                x,y = w,h
                d = "ESWN".index(c[h][w])

    visited = [[[-1]*4 for i in xrange(W)] for j in xrange(H)]
    visited[y][x][d] = 0
    step = 0
    inloop = False
    while L:
        dx,dy = dxy[d]
        nx,ny = x+dx,y+dy
        if not (0 <= nx < W and 0 <= ny < H and c[ny][nx] != "#"):
            d = (d+1)%4
        else:
            x,y = nx,ny
            step += 1
            L -= 1
        if visited[y][x][d] > -1 and not inloop:
            L %= step-visited[y][x][d]
            L += step-visited[y][x][d]
            inloop = True
        visited[y][x][d] = step
    print y+1,x+1,"ESWN"[d]

Measured memory_bytes: 6904
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

// const int maxn = 102;
// const int mo = 1e9 + 7;

int n, x;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> x;

	int sum = 0, l;
	for (int i = 0; i < n; ++i) {
		cin >> l;
		sum += l;
		if (sum > x) {
			cout << i+1 << endl;
			return 0;
		}
	}

	cout << n+1 << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    string S;
    cin >> S;
    for (int i = 0; i < S.length(); i++){
        cout << 'x';
    }
    cout << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    
		String x = "";
		try {
			x = in.readLine();
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		String[] ab = x.split(" ");
		
		int[] a = new int[3];
		a[0] = Integer.parseInt(ab[0]);
		a[1] = Integer.parseInt(ab[1]);
		a[2] = Integer.parseInt(ab[2]);
		
		Arrays.sort(a);
		System.out.println(a[0] + " " + a[1] + " " + a[2]);
	}
}

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

using namespace std;
#define FOR(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)

int main(){
  int n;
  const int max_n = 2*1e5;
  int a[max_n + 1];
  cin >> n;
  for(int i = 0; i < n; i++) cin >> a[i];
  sort(a, a+n);
  string ans = "YES";
  for(int i = 1; i < n; i++){
    if(a[i] == a[i-1]) ans = "NO";
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
implicit none
integer:: n,i
integer,allocatable:: t(:),x(:),y(:),ta(:),xa(:),ya(:)
 
read(*,*) n
allocate(t(n))
allocate(x(n))
allocate(y(n))
allocate(ta(n))
allocate(xa(n))
allocate(ya(n))
do i=1,n
read(*,*) t(i),x(i),y(i)
end do
ta(1)=t(1)
xa(1)=x(1)
ya(1)=y(1)
do i=2,n
ta(i)=abs(t(i)-t(i-1))
xa(i)=abs(x(i)-x(i-1))
ya(i)=abs(y(i)-y(i-1))
end do
 
do i=1,n
if(ta(i)<xa(i)+ya(i).or.mod(ta(i),2)/=mod(xa(i)+ya(i),2))then
write(*,*) 'No'
goto 100
endif
end do
 
write(*,*) 'Yes'
 
100 end

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

int main() {
    char o;
    int a,b;
    bool ed = 0;
    while (ed==0){
        cin >> a >> o >> b;
        switch(o){
            case'+':cout << a+b << endl;
                    break;
            case'-':cout << a-b << endl;
                    break;
            case'*':cout << a*b << endl;
                    break;
            case'/':cout << a/b << endl;
                    break;
            default:ed=1;
        }
    }
    return 0;
}


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;

int main(){
  // 入力
  double R;
  cin >> R;
  double pi = 3.14159;
  
  double result = 2*pi*R;

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3784
/*
 * atcoder/abc130/a.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

int A[3];

void input() {
  loop(n,0,3) {
    cin >> A[n];
  }
  sort(A, A+3);
}

void solve() {
  cout << A[0] + A[1] << endl;
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}


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

int a[3], d;

int main(){

	cin >> a[0] >> a[1] >> a[2];

	d = a[2];

	sort(a, a + 3);

	if (d == a[1])cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

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

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

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

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

#define int ll

int convert(string ts){
  int h,m,s,t;
  h = stoi(ts.substr(0,2));
  m = stoi(ts.substr(3,2));
  s = stoi(ts.substr(6,2));
  t = h * 60 * 60 + m * 60 + s;
  return t;
}

main()
{
  while(1){
    int n; cin >> n;
    if(n == 0) break;

    vi time(24*60*60);

    rep(i,n){
      string sts,gts; cin >> sts >> gts;
      int st = convert(sts), gt = convert(gts);
      time[st]++; time[gt]--;
      //dump(time[st],time[gt]);
    }

    rep(i,sz(time)-1) time[i+1] += time[i];

    cout << *max_element(all(time)) << endl;
  }
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
int main(){
  	int a[3];
  cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  int ret=1;
  if(a[0]!=a[1]) ret++;
  if (a[1]!=a[2] )ret++;
  cout<<ret<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define MAX 100005
#define endl "\n"
lli arr[MAX];
bool flag[MAX];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	lli x,n;
	cin>>x>>n;
	set <lli> arr;
	lli temp;
	for(lli i = 0; i<n; i++){
		cin>>temp;
		arr.insert(temp);
	}
	for(lli i = 0; i<=MAX; i++){
		if(arr.count(x-i) == false){
			cout<<(x-i);
			break;
		}
		else if(arr.count(x+i) == false){
			cout<<(x+i);
			break;
		}
	}
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ull B=100000007;
const int MAX_N=300;
int N;
char S[MAX_N][MAX_N+1];

ull ha[MAX_N][MAX_N][2];

ull pow_B[MAX_N+1];

int main(){
	scanf("%d",&N);
	REP(i,N){
		scanf("%s",S[i]);
		REP(j,N){
			S[i][j]-='a';
		}
	}
	pow_B[0]=1;
	REP(i,N){
		pow_B[i+1]=pow_B[i]*B;
	}
	REP(r,N){
		ha[r][0][0]=S[r][0];
		FOR(c,1,N){
			ha[r][c][0]=ha[r][c-1][0]*B+S[r][c];
		}
	}
	REP(c,N){
		ha[0][c][1]=S[0][c];
		FOR(r,1,N){
			ha[r][c][1]=ha[r-1][c][1]*B+S[r][c];
		}
	}
	int ans=0;
	REP(X,N){
		REP(Y,N){
			bool flg=true;
			REP(i,N-1){
				ull xh,yh;
				int len=N-i-1;
				int x2=(i+X)%N;
				int y2=(i+Y)%N;
				xh=ha[y2][min(x2+len,N-1)][0]-ha[y2][x2][0]*pow_B[min(x2+len,N-1)-x2];
				len-=min(x2+len,N-1)-x2;
				xh=xh * pow_B[len]+((len>0) ? ha[y2][len-1][0] : (ull)0);
				len=N-i-1;
				yh=ha[min(y2+len,N-1)][x2][1]-ha[y2][x2][1]*pow_B[min(y2+len,N-1)-y2];
				len-=min(y2+len,N-1)-y2;
				yh=yh*pow_B[len]+((len>0) ? ha[len-1][x2][1] : 0);
				if (xh!=yh){
					flg=false;
					break;
				}
			}
			if (flg) ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

int main(){
  int n;
  cin >> n;
  
  vector<ll> h(n);
  for(int i=0; i<n; ++i) cin >> h[i];
  int res;
  for(int i=n-2; i>0; --i){
    if(h[i] > h[i+1]){
      if(h[i] - h[i+1] >= 2){
        cout << "No" << endl;
        return 0;
      }
      h[i]--;
    }
  }
  cout << "Yes";
  return 0;
}

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

int M,W;
int dp[13][(1<<12)];
int B[13],D[13];

int get(int a,int b){
  return abs(a-b) * (abs( a - b ) - 30) * (abs( a - b ) - 30);
}

int solve(int id,int st){
  if( dp[id][st] != -1 ) return dp[id][st];
  if( id == M ) return 0;
  int ret = 0;
  for(int i=0;i<W;i++){
    if( st & (1<<i) ) continue;
    ret = max( ret, solve( id+1, st | (1<<i) ) + get( B[id],D[i] ) );
  }
  ret = max( ret, solve( id + 1, st ) );
  return dp[id][st] = ret;
}

int main(){
  while( cin >> M >> W && (M||W) ){
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<M;i++)
      cin >> B[i];
    for(int i=0;i<W;i++)
      cin >> D[i];
    cout << solve( 0, 0 ) << endl;
  }
}

Measured memory_bytes: 1376
N = int(input())
points = [(0, 0)]
T = [0]
for i in range(N):
    t, x, y = map(int, input().split())
    T.append(t)
    points.append((x, y))


def distance(p1, p2):
    return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1])


def judge(T, points, N):
    for i in range(N):
        delta_t = T[i + 1] - T[i]
        d = distance(points[i + 1], points[i])
        if not (delta_t >= d and (delta_t - d) % 2 == 0):
            return "No"
    return "Yes"


print(judge(T, points, N))


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

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ld long double
#define forn(low,high,i) for(i = low; i < high; i++)
#define forrev(high,low,i) for(i = high; i >= low; i--)
#define all(v) v.begin(),v.end()
#define decimal_digits cout << fixed << setprecision(15);

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const int inf = 1e9;
const long long INF = 1e18;
const int mod = 1e9 + 7;
const int bit32 = log2(inf) + 3;
const int bit64 = log2(INF) + 3;

inline int add(long long a, long long b){a += b; if(a >= mod) a -= mod; return a;}
inline int sub(long long a, long long b){a -= b; if(a < 0) a += mod; return a;}
inline int mul(long long a, long long b){a %= mod; b %= mod; return (int)((long long) a * b % mod);}
inline int modexpo(long long a, long long b){int res = 1; while(b > 0){ if(b & 1) res = mul(res, a); a = mul(a, a); b /= 2;} return res;}
inline int divide(long long a, long long b){return mul(a, modexpo(b, mod - 2));}
inline int inv(long long a){return modexpo(a, mod - 2);}

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

void pre(){ // Reset each global variable (esp. for graphs)
  
}

void solve(){
  int n, i, j, k, q;
  cin >> n;
  long long sum = 0;
  map<int, int> cnt;
  for(i = 1; i <= n; i++){
    int x; cin >> x; cnt[x] += 1;
    sum += x;
  }
  cin >> q;
  while(q--){
    long long b, c; cin >> b >> c;
    long long cc = cnt[b];
    cnt[b] -= cc;
    sum -= cc * b;
    sum += cc * c;
    cnt[c] += cc;
    cout << sum << '\n';
  }
}


#define GOOGLE 0
#define MULTIPLE_TC 0

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL); 

  pre();

  int t = 1, T;
  if(MULTIPLE_TC)
    cin >> t;

  for(T = 1; T <= t; T++){
    if(GOOGLE)
      cout << "Case #" << T << ": ";
    solve();
  }

  ktj();
}

Measured memory_bytes: 8308
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
  int n;
  cin >> n;
  double a[n];
  double sum = 0, ave;

  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  ave = round(sum / n);

  int cost = 0;

  for (int i = 0; i < n; i++) {
    cost += (a[i] - ave) * (a[i] - ave);
  }

  cout << cost << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 #define rep(i,n) for(long long i=0;i<n;i++)
 using namespace std;
  int main(){
      int n;
      cin >> n;
      vector<long long> a(n);
      rep(i,n){
          cin >> a[i];
      }
      int num=0;
      int r=0;
      sort(a.begin(),a.end());
      rep(i,n-1){
          if(a[i]!=a[i+1])continue;
          if(r==a[i]){r=0; continue;}
          r = a[i];
          num++;
      }
    cout << n-(num*2) << endl;
    return 0;
  }

Measured memory_bytes: 3948
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define EPS 1e-10
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


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

    ll N ;
    cin >> N ;
    
    int ans = 0 ;
    for(int i = 1; i <= N/2; i++){
        ans ++;
    }
    
    if(N%2 == 0) ans --;
    cout << ans << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
constexpr int m = (int)(1e7)+100;
bool is_prime[m];
int A[m], B[m];

int main(){
  fill(is_prime,is_prime+m,true);
  for(int i = 2; i*i < m; ++i){
    if(not is_prime[i]) continue;
    for(int j = 2*i; j < m; j+=i){
      is_prime[j] = false;
    }
  }

  fill(A,A+m,0);
  fill(B,B+m,0);
  int d[] = {2,6,8};
  for(int i = 8; i < m; ++i){
    // if(is_prime[i]) A[i] = max(A[i],1);
    // if(is_prime[i] and i+2 < m and is_prime[i+2]) A[i+2] = max(A[i]+1,A[i+2]);
    // if(A[i] >= 4) {
    //   if(i < 100) fprintf(stderr, "B[%d]\n", i);
    //   B[i] = i;
    // }
    // else B[i] = B[i-1];
    if(not is_prime[i]){
      B[i] = B[i-1];
      continue;
    }
    bool f = true;
    for(int j = 0; j < 3; ++j)
      f &= is_prime[i-d[j]];
    if(f) B[i] = i;
    else B[i] = B[i-1];
  }
  int n;
  while(cin >> n, n){
    cout << B[n] << endl;
  }
}



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

int main(void){
	int N,M;
	cin >> N >> M;
	vector<string> A(N),B(M);
	for(int i=0;i<N;i++)
		cin >> A[i];
	for(int i=0;i<M;i++)
		cin >> B[i];

	for(int i=0;i<N-M+1;i++){
		for(int j=0;j<N-M+1;j++){
			bool ch = true;
			for(int y=0;y<M;y++){
				for(int x=0;x<M;x++){
					if( A[i+y][j+x] != B[y][x] )ch = false;
				}
			}
			if(ch){
				cout << "Yes" << endl;
				exit(0);
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
def min_graph(graph)
  10.times do |k|
    10.times do |i|
      10.times do |j|
        graph[i][j] = [graph[i][j], graph[i][k] + graph[k][j]].min
      end
    end
  end
end

def solve(graph)
  min_graph(graph)
  min = INF
  index = -1
  (0...10).each do |i|
    res = (0...10).map do |j|
      graph[i][j] == INF ? 0 : graph[i][j]
    end.reduce(&:+)
    if res != 0 and res < min
      min = res
      index = i
    end
  end
  [index, min]
end

INF = 1 << 31

loop do
  n = gets.to_i
  break if n == 0
  graph = Array.new(10).map {Array.new(10, INF)}
  n.times do
    from, to, cost = gets.split(" ").map(&:to_i)
    graph[from][to] = cost
    graph[to][from] = cost
    graph[from][from] = 0
    graph[to][to] = 0
  end
  i, dist = solve(graph)
  puts "#{i} #{dist}"
end

Measured memory_bytes: 8736
#include<iostream>
#include<string>
#include<sstream>
using namespace std;

class Stack{
 private:
 int sp;
 int S[100];

 public:
 Stack()	{sp=0;}
 bool isFull() const 	{return(sp==100);}
 bool isEmpty() const	{return(sp==0);}
 void push(int d);
 int top();
 void pop();
};

void Stack::push(int d){
 if(isFull())
	return ;

 S[sp++]=d;
}
int Stack::top(){
 if(isEmpty())
	return -1;

 return S[sp-1];
}
void Stack::pop(){
 if(isEmpty())
	return;
 sp--;
}

int main(){
 Stack s;
 string expr;
 getline(cin,expr);
 istringstream is (expr);

 while(!is.eof()){
	string op;
	is>>op;

	int tmp1,tmp2;

	switch(op[0]){
	case'+':
		tmp1=s.top();s.pop();
		tmp2=s.top();s.pop();
		s.push(tmp2+tmp1);
		break;
	case'-':
		tmp1=s.top();s.pop();
		tmp2=s.top();s.pop();
		s.push(tmp2-tmp1);
		break;
	case'*':
		tmp1=s.top();s.pop();
		tmp2=s.top();s.pop();
		s.push(tmp2*tmp1);
		break;
	default:
		istringstream is2(op);
		is2>>tmp1;
		s.push(tmp1);
		break;
	}
 }
 cout<<s.top()<<endl;
 return 0;
}

Measured memory_bytes: 3200
import qualified Data.List as DL
import Control.Monad

main = do
  [a,b,k] <- map read . words <$> getLine
  let as = take k [a..b]
      bs = take k [b,(b-1)..a]
      cs = DL.sort $ DL.nub (as `mappend` bs)
    in mapM (putStrLn . show) cs



Measured memory_bytes: 764
k, n = map(int, input().split())
A = list(map(int, input().split()))
r = k

for i in range(n - 1):
    if i == 0:
        j = n - 1
        r = min(r, A[j] - A[i])
    else:
        j = i + 1
        r = min(r, A[i] + k - A[j])
print(r)


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

using namespace std;

int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    int m = 0, g = 0;
    for (int i = 0; i < n; i++) {
        int v;
        scanf("%d", &v);
        g = __gcd(g, v);
        m = max(m, v);
    }
    if (k <= m && (k - m) % g == 0) {
        printf("POSSIBLE\n");
    } else {
        printf("IMPOSSIBLE\n");
    }
    return 0;
}

Measured memory_bytes: 892
import java.util.*;
import java.lang.*;

public class Main {
	static int n;
	static int m;
	static int[] a;
	static int[] b;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		m = sc.nextInt();
		a = new int[m];
		b = new int[m];
		for (int i = 0; i < m; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		UnionFind tree = new UnionFind(n);
		long[] ans = new long[m];
		ans[m - 1] = (long) n * (n - 1) / 2;
		for (int i = m - 1; i > 0; i--) {
			if (!tree.same(a[i] - 1, b[i] - 1)) {
				ans[i - 1] = ans[i] - (long) tree.size(a[i] - 1) * tree.size(b[i] - 1);
			} else {
				ans[i - 1] = ans[i];
			}
			tree.unite(a[i] - 1, b[i] - 1);
		}
		for (int i = 0; i < m; i++) {
			System.out.println(ans[i]);
		}
	}
}
class UnionFind {
	int[] par;
	int[] rank;
	int[] size;

	UnionFind(int n) {
		par = new int[n];
		rank = new int[n];
		size = new int[n];
		for (int i = 0; i < n; i++) {
			par[i] = i;
			rank[i] = 0;
			size[i] = 1;
		}
	}

	int find(int x) {
		if (par[x] == x) {
			return x;
		}
		return par[x] = find(par[x]);
	}

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

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

	int size(int x) {
		return size[find(x)];
	}
}

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


int main()
{
  string s, t;
  cin >> s >> t;
  bool ans = true;
  for(int i = 0; i < s.length(); i++) {
    if (s[i] != t[t.length() - i - 1]) {
      ans = false;
    }
  }
  if (ans) {cout << "YES" << endl;}
  else {cout << "NO" <<endl;}
}

Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <string>
#include <limits.h>
#include <iomanip>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <set>
#include <bitset>
#include <unordered_map>
#include <string.h>
#define fastIo                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define MOD 1000000007

using namespace std;
int main()
{
    fastIo;
    int n;
    double d;
    cin>>n>>d;
    int ct=0;
    while(n--)
    {
        double a,b;
        cin>>a>>b;

        if(sqrt(a*a+b*b)<=d)
        {
            ct++;
        } 
    }
    cout<<ct<<endl;

    return 0;
}

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

using namespace std;

#define nl '\n'

int main() {
  long long L, R;
  cin >> L >> R;

  long long upper;
  if (L + 2019 <= R) {
    upper = L + 2019;
  } else {
    upper = R;
  }

  long long min = LLONG_MAX;
  for (long long i = L; i <= upper; i++) {
    for (long long j = i + 1; j <= upper; j++) {
      if (((i * j) % 2019 < min)) {
        min = ((i * j) % 2019);
      }
    }
  }

  cout << min << nl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,m,p,x,ans=0,temp;
  cin >> n;
  int t[n];
  for (int i=0;i<n;i++){
    cin >> t[i];
  }
  cin >> m;
  for (int i=0;i<m;i++){
    cin >> p >> x;
    ans = 0;
    temp = t[p-1];
    t[p-1] = x;
    for (int j=0;j<n;j++){
      ans += t[j];
    }
    cout << ans << endl;
    t[p-1] = temp;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll t1,t2,a1,a2,b1,b2;

int main(){
	cin>>t1>>t2>>a1>>a2>>b1>>b2;
	if(t1*a1+t2*a2 == t1*b1+t2*b2){
		cout << "infinity" << endl;
		return 0;
	}
	else if(t1*a1+t2*a2 < t1*b1+t2*b2){
		swap(a1,b1);
		swap(a2,b2);
	}
	ll dif = t1*a1+t2*a2 - t1*b1-t2*b2;
	ll ans = 0;
	bool  j = 0;
	//cout << dif << a1 << b1 << endl;
	if(a1 >= b1);
	else{
		ll dif2 = t1*(b1-a1);
		if(dif2%dif == 0) j = 1;
		ans += dif2 / dif;
		//cout<<j<<endl;
		ans += dif2 / dif;
		//if(j ) ans--;
		if(!j)ans++;
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

#define ll long long
#define ull unsigned long long

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

    ll k, n;
    std::cin >> k >> n;
    std::vector<long long> vec(n);
    for (int i = 0; i < n; ++i) { std::cin >> vec[i]; }
    std::sort(vec.begin(), vec.end());
    ll tmp = 0;
    for (int i = 0; i < n - 1; ++i) { tmp = std::max(vec[i + 1] - vec[i], tmp); }
    std::cout << k - std::max((k - vec[vec.size() - 1]) + vec[0], tmp) << std::endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;
    vector<ll> v(N + 1);
    rep(i, N + 1) cin >> v[i];

    vector<ll> v2(N);
    rep(i, N) cin >> v2[i];
    ll ans = 0;

    for(int i = 0; i < N; i++) {
        if(v[i] <= v2[i]) {
            ans += v[i];
            v2[i] -= v[i];
            if(v[i + 1] >= v2[i]) {
                ans += v2[i];
                v[i + 1] -= v2[i];
            } else {
                ans += v[i + 1];
                v[i + 1] = 0;
            }
        } else {
            ans += v2[i];
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(a) a.begin(),a.end()
typedef long long ll;
typedef pair<int,int> Bug;
vector<Bug> bug;
int N;

int solve(int l,int r){
	if(l+1==r)return l;
	int k=(l+r)/2;
	ll sumA=0;
	priority_queue<int> pq;
	rep(i,k){
		sumA+=bug[i].second;
		pq.push(bug[i].second);
	}

	if(sumA<=(ll)k*bug[k-1].first){
		return solve(k,r);
	}

	for(int i=k;i<N;i++){
		int d=pq.top()-bug[i].second;
		if(d>0){
			sumA-=d;
			pq.pop();
			pq.push(bug[i].second);
		}
		if(sumA<=(ll)k*bug[i].first){
			return solve(k,r);
		}
	}
	return solve(l,k);
}

int main(void){
	cin>>N;
	bug.resize(N);
	rep(i,N)cin>>bug[i].second>>bug[i].first;
	sort(all(bug),greater<Bug>());
	cout<<solve(0,N+1)<<endl;
	return 0;
}

Measured memory_bytes: 27976
// 素因数分解
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cassert>

#include<vector>
#include<queue>
#include<set>

using namespace std;

const int MAX_N = 10000;

bool isPrime(int x);

int main(void)
{
	int n, tmp;

	cin >> n;

	tmp = n;

	printf("%d:", n);

	// 素数は n の半分の範囲まで探索すれば十分
	for(int i = 2; i * 2 <= n; i++)
	{
		if( isPrime(i) == true )
		{
			// 素数が見つかったら, 可能な限り割り算をする
			while( tmp % i == 0 )
			{
				tmp = tmp / i;
				// 素因数分解の数値を表示
				printf(" %d", i);
			}
		}

		if( tmp == 1 )
		{
			// 割り切れたら処理を終了する
			break;
		}

		if( i * i > n && tmp == n )
		{
			// 素数で割り切れない状態が続いたら,
			// 自分自身でしか割り切れないと判定して処理を抜ける
			printf(" %d", n);
			break;
		}

	}

	printf("\n");

	return 0;
 }

// x が素数かを判定する関数
// x  : 判定する数
bool isPrime(int x)
{

	int i;

	if( x < 2 )
	{
		return false;
	}
	else if( x == 2 )
	{
		// 2は素数
		return true;
	}
	else if( x % 2  == 0 )
	{
		// 偶数は素数で無い
		return false;
	}

	// 素数を求める範囲は、xの平方根の範囲までで十分
	for( i = 3; i * i <= x; i = i + 2 )
	{
		if( x % i == 0 )
		{
			// 割れる数が見つかれば素数では無い
			return false;
		}
	}

	return true;
}



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

int main()
{
        ll N; cin >> N;
        vector<ll> v(5, 0);
        for (int i = 0; i < N; ++i) {
                string s;
                cin >> s;
                if (s[0] == 'M') v[0]++;
                else if (s[0] == 'A') v[1]++;
                else if (s[0] == 'R') v[2]++;
                else if (s[0] == 'C') v[3]++;
                else if (s[0] == 'H') v[4]++;
        }
        cout << endl;
        ll ans = 0;
        for (int i = 0; i < 3; ++i) {
                for (int j = i+1; j < 4; ++j) {
                        for (int k=j+1; k < 5; ++k) {
//                              cout << i << " " << j << " " << k << endl;
                                ans += (v[i] * v[j] * v[k]);
                        }
                }
        }
        cout << ans << endl;

}


Measured memory_bytes: 256
def c_to_infinity(S, K):
    ans = '1'
    for s in S[:K]:
        if s != '1':
            ans = s  # 現れた数字が5000兆回の操作によってK文字目に必ず現れる
            break
    return ans

S = input().strip()
K = int(input())
print(c_to_infinity(S, K))

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

int a[5000],b[5000],ans,n;

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        ans+=b[i]-a[i]+1;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

int dp[100000][5];

int main(void){
	dp[0][0]=1;
	for(int i=1;i*i<=(1<<15);i++){
		for(int j=0;j<4;j++){
			for(int k=0;k<(1<<15);k++){
				if(dp[k][j]>=1){
					dp[k+i*i][j+1]+=dp[k][j];
				}
			}
		}
	}
	while(1){
		int n;
		scanf("%d",&n);
		if(n==0)break;
		printf("%d\n",dp[n][1]+dp[n][2]+dp[n][3]+dp[n][4]);
	}
	return 0;
}

Measured memory_bytes: 2308
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
	int n;
	cin >> n;
	int odd = (n + 1) / 2;
	double ans = (double)odd / n;
	cout << ans << endl;
}

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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    freopen("debug.out","w",stderr);
    #endif
} 

// Code Here

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

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

int main() {
	int a,b,c;
	cin >> a >> b >> c;
	int k;
	cin >> k;

	rep1(i,k){
		if(b <= a) b=b*2;
		else if(c <= b) c=c*2;
	}

	if ((b > a) && (c > b)) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3640
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
list($N,$M) =  explode(" ",trim(fgets(STDIN)));

for($i=0;$i<$M;$i++) {
  list($L[],$R[]) =  explode(" ",trim(fgets(STDIN)));
}
$maxL = max($L);
$minR = min($R);

$ans = $minR - $maxL + 1;
printf("%d\n",max($ans,0));


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

int match(string a, string b){// search string a in string b.
  for(int i = b.size() - a.size() + 1; i >= 0; --i){
    int flag = 1;
    for(int j=0; j < a.size(); j++){
      if(a[j] != b[i+j] && b[i+j] != '?'){
        flag = 0;
        break;
      }
    }
    if (flag == 0)
      continue;
    else
      return i;
  }
  return -1;
}

string repl(string s){
  for(int i=0; i < s.size(); i++){
    if(s[i] == '?')
      s[i] = 'a';
  }
  return s;
}

int main(){
  string s,t;
  cin >> s >> t;
  
  int i;
  if((i = match(t,s)) >= 0){
    s.replace(i, t.size(), t, 0, t.size());
    cout << repl(s) << endl;
  }else
    cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N, K;
	cin >> N >> K;

	int A[200000];
	rep(i, N) cin >> A[i];

	rep(i, N - K) {
		if (A[i + K] > A[i]) co("Yes");
		else co("No");


	}




	Would you please return 0;
}

Measured memory_bytes: 4428