akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define reps(i,j,k) for(int i=(j);i<=(k);++i)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))
#define sz size()


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

enum FACE{TOP,BOTTOM,FRONT,BACK,LEFT,RIGHT};
class dice{
public:
  dice(int t,int f){
    id[TOP]=1; id[FRONT]=3; id[LEFT]=2;
    id[RIGHT]=5; id[BACK]=4; id[BOTTOM]=6;
    if(!roll(7-t) && id[TOP]!=t)
      rep(i,2) roll(TOP,FRONT,BOTTOM,BACK);
    while(id[FRONT]!=f)
      roll(FRONT,LEFT,BACK,RIGHT);
  }

  bool roll(int num){
    int opp[]={0,0,3,2,5,4};
    for(int i=2;i<6;++i)
      if(id[i]==num){
	roll(TOP,(FACE)opp[i],BOTTOM,(FACE)i);
	return 1;
      }
    return 0;
  }
  void roll(FACE a,FACE b,FACE c,FACE d){
    int tmp=id[a];
    id[a]=id[b]; id[b]=id[c];
    id[c]=id[d]; id[d]=tmp;
  }
  int id[6];
};
ostream& operator<<(ostream &os,const dice &d){
  os<<d.id[TOP]<<endl;
  os<<d.id[FRONT]<<" "<<d.id[RIGHT]<<" "<<d.id[BACK]<<" "<<d.id[LEFT]<<endl;
  os<<d.id[BOTTOM]<<endl;
  return os;
}
int dx[]={1,0,-1,0},dy[]={0,1,0,-1},dd[]={FRONT,RIGHT,BACK,LEFT};
int main(){
  int n;
  while(cin>>n,n){
    int tp,fr;
    int hei[300][300]={},val[300][300]={};
    rep(i,n){
      int y=150,x=150;
      cin>>tp>>fr;
      dice d(tp,fr);
      int f=1;
      while(f){
	f=0;
	for(int v=6;v>3;--v){
	  rep(i,4)if(d.id[dd[i]]==v)
	    if(hei[y+dy[i]][x+dx[i]]<hei[y][x]){
	      y+=dy[i]; x+=dx[i];
	      d.roll(v);
	      //cout<<v<<","<<i<<endl;
	      f=1; break;
	    }
	  if(f)break;
	}
      }
      hei[y][x]++;
      val[y][x]=d.id[TOP];
      /*
      for(int i=145;i<155;++i){
	for(int j=145;j<155;++j)
	  cout<<hei[i][j]<<",";
	cout<<endl;
      }cout<<endl;
      for(int i=145;i<155;++i){
	for(int j=145;j<155;++j)
	  cout<<val[i][j]<<",";
	cout<<endl;
	}cout<<"----"<<endl;*/
    }
    vector<int> re(7);
    rep(i,300)rep(j,300)
      re[val[i][j]]++;
    rep(i,7)if(i)
      cout<<(i==1?"":" ")<<re[i];
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1908
n,s = map(int,input().split())
a = list(map(int,input().split()))
mod = 998244353
half = mod//2+1
now = [0 for _ in range(s+1)]
dp00 = 1
for _ in range(n):
  dp00 *= 2
  dp00 %= mod
now[0] = dp00
for i in range(n):
  for j in range(s+1)[::-1]:
    if j + a[i] <= s:
      now[j+a[i]] += now[j] * half
      now[j+a[i]] %= mod
print(now[-1]%mod)

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

C = input()

S = list(C)

dp = [[0 for i in range(8)] for j in range(N + 1)]

dp[0][1] = 1

for i in range(N):
    if C[i] == "J":
        dp[i + 1][1] = dp[i][1] + dp[i][2] + dp[i][3] + dp[i][4];
        dp[i + 1][2] = dp[i][1] + dp[i][2] + dp[i][3] + dp[i][4] + dp[i][5] + dp[i][6];
        dp[i + 1][3] = dp[i][1] + dp[i][2] + dp[i][3] + dp[i][4] + dp[i][6] + dp[i][7];
        dp[i + 1][4] = dp[i][1] + dp[i][2] + dp[i][3] + dp[i][4] + dp[i][5] + dp[i][6] + dp[i][7];
        dp[i + 1][5] = 0;
        dp[i + 1][6] = 0;
        dp[i + 1][7] = 0;
    if C[i] == 'O':
        dp[i + 1][1] = 0;
        dp[i + 1][2] = dp[i][1] + dp[i][2] + dp[i][3] + dp[i][4] + dp[i][5] + dp[i][6];
        dp[i + 1][3] = 0;
        dp[i + 1][4] = dp[i][1] + dp[i][2] + dp[i][3] + dp[i][4] + dp[i][5] + dp[i][6] + dp[i][7];
        dp[i + 1][5] = dp[i][2] + dp[i][4] + dp[i][5] + dp[i][6];
        dp[i + 1][6] = dp[i][2] + dp[i][3] + dp[i][4] + dp[i][5] + dp[i][6] + dp[i][7];
        dp[i + 1][7] = 0;
    if C[i] == 'I':
        dp[i + 1][1] = 0;
        dp[i + 1][2] = 0;
        dp[i + 1][3] = dp[i][1] + dp[i][2] + dp[i][3] + dp[i][4] + dp[i][6] + dp[i][7];
        dp[i + 1][4] = dp[i][1] + dp[i][2] + dp[i][3] + dp[i][4] + dp[i][5] + dp[i][6] + dp[i][7];
        dp[i + 1][5] = 0;
        dp[i + 1][6] = dp[i][2] + dp[i][3] + dp[i][4] + dp[i][5] + dp[i][6] + dp[i][7];
        dp[i + 1][7] = dp[i][3] + dp[i][4] + dp[i][6] + dp[i][7];

print((dp[N][1] + dp[N][2] + dp[N][3] + dp[N][4] + dp[N][5] + dp[N][6] + dp[N][7]) % 10007)

Measured memory_bytes: 8472
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void)
{
    int N;
    cin >> N;
    vector<int> W(N), S(N + 1);
    for (auto &i: W) cin >> i;
    sort(S.begin(), S.end());
    S[0] = 0;
    for (int i = 0; i < N; i++) S[i + 1] = S[i] + W[i];
    auto s = S[N];
    int ans = 100000;
    for (int i = 0; i < N; i++) ans = min(ans, abs(s - S[i] * 2));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//-------------------------------------------
//-               Train Fare                -
//-                                         -
//-       autumn_eel niha katemasen!        -
//-------------------------------------------

#include<iostream>
#include<functional>
#include<queue>
#include<deque>
#include<vector>
#include<algorithm>
using namespace std;

void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (true) {
		k = getchar_unlocked();
		if (k < '0' || k > '9') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
void writeln(int x) {
	int s = 0; char f[7];
	while (x) {
		f[s++] = x % 10;
		x /= 10;
	}
	if (!s) f[s++] = 0;
	while (s--) putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}
#pragma warning(disable:4996)
int n, m, q, a[200003], b[200003], c[200003], d[200003], e[100003], dist[100003], E[200003];
vector<pair<int, int> > z[100003]; vector<int> x[100003];
vector<int>D[100003];
int main() {
	reader(&n); reader(&m); reader(&q);
	fill(d, d + m + 1, 1 << 30);
	for (int i = 1; i <= m; i++) reader(&a[i]), reader(&b[i]);
	for (int i = 1; i <= q; i++) reader(&c[i]), d[c[i]] = i;
	for (int i = 1; i <= m; i++) {
		x[a[i]].push_back(b[i]);
		x[b[i]].push_back(a[i]);
	}
	fill(dist, dist + n + 1, -1); dist[1] = 0;
	queue<int> Q1; Q1.emplace(1);
	while (!Q1.empty()) {
		int a1 = Q1.front(); Q1.pop();
		for (int i : x[a1]) {
			if (dist[i] == -1) {
				dist[i] = dist[a1] + 1;
				Q1.emplace(i);
			}
		}
	}
	for (int i = 1; i <= m; i++) {
		if (dist[a[i]] > dist[b[i]]) z[a[i]].push_back(make_pair(b[i], d[i]));
		if (dist[b[i]] > dist[a[i]]) z[b[i]].push_back(make_pair(a[i], d[i]));
	}
	for (int i = 1; i <= n; i++) D[dist[i]].push_back(i);
	e[1] = (1 << 30);
	for (int i = 1; i < n; i++) {
		for (int j : D[i]) {
			for (pair<int, int>k : z[j]) {
				e[j] = max(e[j], min(e[k.first], k.second));
			}
		}
	}
	for (int i = 2; i <= n; i++) {
		if (e[i] < 300000) E[e[i]]++;
	}
	for (int i = 1; i <= q; i++) {
		E[i] += E[i - 1];
		writeln(E[i]);
	}
	return 0;
}

Measured memory_bytes: 23328
#pragma region header
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
using namespace std;
typedef long long ll;
template <class T> ll size(const T& x) { return x.size(); }
#define rep(i,a,b) for(ll i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end();++it)
#define pb push_back
#define fs first
#define sc second
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const int INF = ~(1 << 31);
const double pi = acos(-1);
const double EPS = 1e-9;

#pragma endregion

int main()
{
	double l;
	cin >> l;
	double l3 = l / 3;
	cout << fixed << setprecision(15) << l3 * l3 * l3 << endl;
}

Measured memory_bytes: 256
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n = ir()
a = [[i,ir()] for i in range(n)]
a.reverse()
pre = -1
ans = 0
pre_max = -1
for ind, num in a:
    if pre_max <= num <= ind:
        if pre-1 != num:
            ans+=num
            pre_max = max(num-1, 0)
            pre = num
        else:
            # nice
            pre_max = max(pre_max-1, 0)
            pre = num
    else:
        print(-1)
        sys.exit()
print(ans)

Measured memory_bytes: 108588
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
	int n;
	float neparni=0;
    scanf("%d", &n);

    if(n%2==0) neparni=n/2;
    else neparni=n/2+1;

    printf("%f", neparni/n);

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;


int main() {
	ll x, y;
	cin >> x >> y;
	int count = 1;
	while (1) {
		x *= 2;
		if (x <= y) {
			count++;
		}
		else {
			break;
		}
	}
	cout << count << endl;

}



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

using namespace std;

int main(){
	char dm[7];
	int y,m,d;
	while(1){
		scanf("%s",dm);
		if(dm[0]=='#')
		break;
		scanf("%d %d %d",&y,&m,&d);
		if(y<=31){
			if(y==31&&m>=5)
			printf("? 1 %d %d\n",m,d);
			else
			printf("HEISEI %d %d %d\n",y,m,d);
		}
		else{
			printf("? %d %d %d\n",y-31+1,m,d);
		}
	}
}


Measured memory_bytes: 3132
import java.util.*;

public class Main {
	public static void main ( String[] args ) {
		Scanner sc = new Scanner(System.in);
		while ( !sc.hasNext("0") ) {
			int n = sc.nextInt();
			int[] table = new int[10];
			for ( int i = 0; i < n; i++ ) {
				int index = sc.nextInt();
				table[index]++;
			}
			for ( int i = 0; i < 10; i++ ) {
				if ( table[i] == 0 ) System.out.println("-");
				else {
					for ( int j = 0; j < table[i]; j++ ) {
						System.out.print("*");
					}
					System.out.println("");
				}
			}
		}
	}
}

Measured memory_bytes: 0
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
D = []
for _ in range(M):
    d = list(map(int, input().split()))
    D.append(d)

A.sort()
D.sort(key=lambda x:x[1], reverse=True)
NewCard = []
for d in D:
    b, c = d
    NewCard += [c] * b
    if(len(NewCard) > N):
        break

i = 0
len_min = min(len(A), len(NewCard))
while i < len_min:
    if A[i] >= NewCard[i]:
        break
    i += 1

print(sum(NewCard[:i]) + sum(A[i:]))


Measured memory_bytes: 34424
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;


      ll x;
      string str;

      cin>>r>>d>>x;

      for(i=1; i<=10; i++)
      {
          x=(r*x)-d;

          cout<<x<<endl;
      }












}



Measured memory_bytes: 3592
n, k = gets.chomp.split(" ").map(&:to_i)
h = gets.chomp.split(" ").map(&:to_i)

# cost[i] : i-1段目到達の最小コスト
cost = []
cost[0] = 0
cost[1] = (h[1] - h[0]).abs

(2..(n-1)).each do |i|
    min = Float::INFINITY
    (1..k).each do |j|
        break if i < j
        c = cost[i-j] + (h[i]-h[i-j]).abs
        min = c if min > c
    end
    cost[i] = min
end

puts cost[n-1]

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

int main(){
    int l;
    int chokin = 0;
    int tmp;
    int m;
    int n;
    bool flug = false;
    int month;

    while(cin >> l, l != 0){
        chokin = 0;
        flug = false;
        month = 0;
        for(int i=1; i<=12; i++){
            cin >> m >> n;
            if(flug == false){
                tmp = m - n;
                chokin += tmp;
                if(chokin >= l){
                    flug = true;
                    month = i;
                }
            }
        }
        if(flug == true){
            cout << month << endl;
        }else{
            cout << "NA" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 0
import java.util.*;
import java.io.*;
import java.text.*;
public class Main{
    //SOLUTION BEGIN
    //Into the Hardware Mode
    void pre() throws Exception{}
    void solve(int TC) throws Exception{
        long a = nl()+nl();
        if(a%2 == 0)pn(a/2);
        else pn("IMPOSSIBLE");
    }
    //SOLUTION END
    void hold(boolean b)throws Exception{if(!b)throw new Exception("Hold right there, Sparky!");}
    long IINF = (long)1e18, mod = (long)1e9+7;
    final int INF = (int)1e9, MX = (int)2e5+5;
    DecimalFormat df = new DecimalFormat("0.00");
    double PI = 3.141592653589793238462643383279502884197169399, eps = 1e-6;
    static boolean multipleTC = false, memory = false, fileIO = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        if(fileIO){
            in = new FastReader("input.txt");
            out = new PrintWriter("output.txt");
        }else {
            in = new FastReader();
            out = new PrintWriter(System.out);
        }
        //Solution Credits: Taranpreet Singh
        int T = (multipleTC)?ni():1;
        pre();for(int t = 1; t<= T; t++)solve(t);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n()throws Exception{return in.next();}
    String nln()throws Exception{return in.nextLine();}
    int ni()throws Exception{return Integer.parseInt(in.next());}
    long nl()throws Exception{return Long.parseLong(in.next());}
    double nd()throws Exception{return Double.parseDouble(in.next());}
 
    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }
 
        String next() throws Exception{
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    throw new Exception(e.toString());
                }
            }
            return st.nextToken();
        }
 
        String nextLine() throws Exception{
            String str = "";
            try{   
                str = br.readLine();
            }catch (IOException e){
                throw new Exception(e.toString());
            }  
            return str;
        }
    }
}

Measured memory_bytes: 21716
#include "bits/stdc++.h"
using namespace std;
#define int long long

int n,t,a;
vector<int> v;

signed main() {
	cin >> n >> t >> a;
	v.resize(n);
	for (size_t i = 0; i < n; i++)
	{
		cin >> v[i];
	}
	
	double mn = 99999;
	int index = 0;
	for (size_t i = 0; i < n; i++)
	{
		if (mn > abs(a - (t - v[i] * 0.006))) {
			index = i + 1;
			mn = abs(a - (t - v[i] * 0.006));
		}
	}

	cout << index << endl;


}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Arrays;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] t = in.nextIntArray(n);
            int[] v = in.nextIntArray(n);

            int sumT = Arrays.stream(t).sum();
            int m = 2 * sumT + 1;
            double[] maxV = new double[m];
            Arrays.fill(maxV, Double.MAX_VALUE);
            maxV[0] = maxV[m - 1] = 0;

            int tmpSum = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j <= 2 * t[i]; j++) {
                    maxV[tmpSum + j] = Math.min(maxV[tmpSum + j], v[i]);
                }
                tmpSum += 2 * t[i];
            }

            for (int i = 1; i < m; i++) {
                maxV[i] = Math.min(maxV[i], maxV[i - 1] + 0.5);
            }
            for (int i = m - 2; i >= 0; i--) {
                maxV[i] = Math.min(maxV[i], maxV[i + 1] + 0.5);
            }

            double ans = 0;
            for (int i = 0; i < m - 1; i++) {
                ans += (maxV[i] + maxV[i + 1]) * 0.5 / 2;
            }

            out.println(ans);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 28372
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int insertion_sort(int * a, int length, int g){
  int count = 0;
  for( int i = 0; i < length; i ++ ){
    int v = a[ i ];
    int j = i - g;
    while( j >= 0 && a[ j ] > v ){
      a[ j + g ] = a[ j ];
      j = j - g;
      count ++;
    }
    a[ j + g ] = v;
  }
  return count;
}

void shell( int *a, int length ){
  int count = 0;
  int m = length / 3 + 1;
  int *g = ( int * )malloc( m * sizeof( int ) );
  int k = 3, i;
  for( i = 0; i < m && (k - 1)/2 <= length; i ++ ){
    g[ i ] = (k - 1)/2;
    k *= 3;
  }
  m = i;
  printf("%d\n", m );
  for( i = m - 1; i > 0; i -- )
    printf("%d ", g[ i ] );
  printf("%d\n", g[ i ] );

  for( i = m - 1; i >= 0; i -- )
    count += insertion_sort( a, length, g[ i ] );

  printf("%d\n", count );
}

int main( void ){
  int n;
  scanf("%d\n", &n );

  int *a = ( int * )malloc( n * sizeof( int ) );
  for( int i = 0; i < n; i ++ )
    scanf("%d\n", a + i );

  shell( a, n );
  for( int i = 0; i < n ; i ++ )
    printf("%d\n", a[ i ] );

  return 0;
}


Measured memory_bytes: 5652
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  int N;
  cin>>N;
  vector<int>A(N),B(N);
  for(int i=0;i<N;i++){
    cin>>A[i]>>B[i];
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  if(N%2!=0){
    cout<<B[N/2]-A[N/2]+1<<endl;
  }
  else{
   int64_t a = A[N/2-1] + A[N/2];
   int64_t b = B[N/2-1] + B[N/2];
    cout<<b-a+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 4820
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;

class PathConnection {
	public PathNode to;
	public int weight;
	
	public PathConnection(PathNode to, int weight) {
		this.to = to;
		this.weight = weight;
	}
}

class PathNode {
	public int id;
//	public ArrayList<PathConnection> sources;
	public ArrayList<PathConnection> connections;
	
	public PathNode(int id) {
		this.id = id;
//		sources = new ArrayList<>();
		connections = new ArrayList<>();
	}
	
	public void addConnection(PathNode target, int weight) {
		connections.add(new PathConnection(target, weight));
	}
}

public class Main {
	public static int[] DijkstrasAlgorithm(PathNode[] nodes) {
		int[] minDist = new int[nodes.length];
		boolean[] settled = new boolean[nodes.length];
		
		//initialize all nodes besides minDist[0] to infinity
		minDist[0] = 0;
		for (int i = 1; i < minDist.length; i++) {
			minDist[i] = Integer.MAX_VALUE;
		}
		
		//our loop for dijkstras
		boolean shouldContinue = true;
		while(shouldContinue) {
			PathNode currentNode = null;
			int smallestIndex = -1;
			shouldContinue = false;
			//get index with smallest minDist so far
			for (int i = 0; i < minDist.length; i++) {
				if (settled[i] == false) {
					shouldContinue = true;//we should continue if at least one node isn't settled
					if (smallestIndex == -1 || minDist[i] < minDist[smallestIndex]) {
						smallestIndex = i;
					}
				}
			}
			
			if (!shouldContinue) break;
			
			//currentNode is the node with smallest minDist
			currentNode = nodes[smallestIndex];
			//go through every node connected to it
			Iterator<PathConnection> i = currentNode.connections.iterator();
			while (i.hasNext()) {
				PathConnection connection = i.next();
				minDist[connection.to.id] = Math.min(minDist[connection.to.id], minDist[currentNode.id]+connection.weight);
			}
			settled[currentNode.id] = true;
		}
		
		return minDist;
	}
	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int numNodes = scanner.nextInt();
		PathNode[] nodes = new PathNode[numNodes];
		
		//initialize nodes
		for (int i = 0; i < nodes.length; i++) {
			nodes[i] = new PathNode(i);
		}
		for (int i = 0; i < nodes.length; i++) {
			int id = scanner.nextInt();
			int numConnections = scanner.nextInt();
			//connections to other nodes with weights
			for (int j = 0; j < numConnections; j++) {
				int target = scanner.nextInt();
				int weight = scanner.nextInt();
				nodes[i].addConnection(nodes[target], weight);
			}
		}
		scanner.close();
		
		int[] results = DijkstrasAlgorithm(nodes);
		for (int i = 0; i < results.length; i++) {
			System.out.println(i + " " + results[i]);
		}
	}
}



Measured memory_bytes: 39708
from math import sqrt
while True:
    R, N = map(int, input().split())
    if not (R | N):
        break
    geta = 20
    buildings = [0] * (geta * 2)
    for _ in range(N):
        xl, xr, h = map(int, input().split())
        for i in range(xl + geta, xr + geta):
            buildings[i] = max(buildings[i], h)

    print(min(buildings[i] - sqrt(R * R - (i - geta + (i < geta)) * (i - geta + (i < geta))) + R for i in range(-R + geta, R + geta)))

Measured memory_bytes: 7668
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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 = 1e9;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    vector<vector<int>> c(m);
    rep(i,m){
        cin >> a[i] >> b[i];
        c[i].resize(b[i]);
        rep(j,b[i]){
            cin >> c[i][j];
            --c[i][j];
        }
    }
    vector<int> dp((1<<n), INF);
    dp[0] = 0;
    rep(S,(1<<n)){
        if(dp[S] == INF) continue;
        rep(i,m){
            int nextS = S;
            rep(j,b[i]){
                nextS |= (1<<c[i][j]);
            }
            chmin(dp[nextS], dp[S] + a[i]);
        }
    }
    if(dp[(1<<n)-1] == INF) cout << -1 << endl;
    else cout << dp[(1<<n)-1] << endl;
    return 0;
}

Measured memory_bytes: 3728
/*     *******************Bismillahir Rahmanir Rahim************************
                          MD. ASFAKUL GHANI!
                          *ProMAGFAT*!
 SECRET_warning :)->FAT   CSE-25!
                          JAHANGIRNAGAR UNIVERSITY!
                          Dhaka,Bangladesh!
*/

#include <bits/stdc++.h>
#include <set>
using namespace std;

#define           fasterIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define           Im int main()
#define           ll long long
#define           sc scanf
#define           pf printf
#define           rn0 return 0
#define           rn return
#define           f0(i,n) for(ll i=0;i<n;i++)
#define           f1(i,n) for(ll i=1;i<=n;i++)
#define           f2(i,n) for(ll i=n-1;i>=0;i--)
#define           pi 2*acos(0.0)
#define           modulo 1000003
#define           dd double
#define           PI 3.14159265358979
#define           pi 2*acos(0.0)
#define           p_b push_back
#define           ps push

/*
ll for_binarySearch(ll a,ll b,ll aa[],ll x){while(a<=b){ll mid=(a+b)/2;if(aa[mid]==x) return 1;else if(aa[mid] > x) b=mid-1;else a=mid+1;}return -1;}
ll for_gcd(ll a,ll b){if(a==0) return b;else return for_gcd(b%a,a);}
ll for_prime(ll x){for (ll i=2;i*i<=x;i++){if(x%i==0) return 0;}return 1;}
void for_swap(char *x,char *y){char temp;temp=*x;*x=*y;*y=temp;}
ll for_big_mod(ll b,ll p,ll m){if(p==0) return 1;else if(p%2==0){ll k=for_big_mod(b,p/2,m);return (k*k)%m;}else return ((b%m)*(for_big_mod(b,p-1,m)))%m;}
ll for_josephus(ll n,ll k){if(n==1) return 1;return (for_josephus(n-1,k)+k-1)%n+1;}
ll for_gcdExtended(ll a,ll b,ll *x,ll *y){if(a==0){*x=0;*y=1;return b;}ll x1,y1;ll gcd=for_gcdExtended(b%a,a,&x1,&y1);*x=y1-(b/a)*x1;*y=x1;return gcd;}
*/
/*
void debug1()
{
    cout << "***" << endl;
}

void debug11(ll n)
{
    cout << n << endl;
}
*/

Im
{
    /*#ifdef FAT
       freopen("input.txt","w",stdin);
    #endif // FAT*/

    fasterIO;
    ll n;
    cin>>n;
    ll a1[n+5];
    ll c1 = 0;
    for (ll i = 0; i < n; i += 1){
        cin>>a1[i];
    }
    for (ll i = 0; i < n; i += 1){
        for (ll j = n-1; j >= i+1; j -= 1){
            if (a1[j] < a1[j-1]){
                c1 += 1;
                swap(a1[j],a1[j-1]);
            }
        }
    }
    for (ll i = 0; i < n; i += 1){
        if (i==0) cout << a1[i];
        else cout << " " << a1[i];
    }
    cout << endl;
    cout << c1 << endl;

   // main();

    rn0;
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
int n, m, a, b, ro[705][705], col[705], ans, cnt[705][2], tot, f[705][1405];
void dfs(int x, int c)
{
	col[x] = c;
	cnt[tot][c - 1]++;
	for (int i = 1; i <= n; i++)
		if (i != x && !ro[x][i])
		{
			if (!col[i]) dfs(i, 3 - c);
			else if (col[i] == col[x]) ans = -1;
		}
}
int get(int x) {return x * (x - 1) / 2;}
int main()
{
#ifdef _noname
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d%d", &n, &m);
	memset(ro, 0, sizeof ro);
	for (int i = 1; i <= m; i++)
	{
		scanf("%d%d", &a, &b);
		ro[a][b] = ro[b][a] = 1;
	}
	tot = 0;
	for (int i = 1; i <= n; i++)
		if (!col[i])
		{
			tot++;
			cnt[tot][0] = cnt[tot][1] = 0;
			dfs(i, 1);
		}
	if (ans == -1)
	{
		puts("-1");
		return 0;
	}
	memset(f, 0, sizeof f);
	f[0][0] = 1;
	for (int i = 1; i <= tot; i++)
		for (int j = 0; j < n; j++)
			f[i][j + cnt[i][0]] |= f[i - 1][j], f[i][j + cnt[i][1]] |= f[i - 1][j];
	ans = get(n);
	for (int i = 1; i <= n; i++)
		if (f[tot][i])
			ans = min(ans, get(i) + get(n - i));
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 6016
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<29

int main(){
  int i,j,k,n=0;
  double maxi = 0,tmp=0,mini = INF;
  double in[100];

  rep(i,100) in[i] = 0;
  for(i = 0; scanf("%lf",&in[i]) != EOF; i++,n++);
  rep(i,n){
    tmp = in[i];
    if(maxi < in[i]) maxi = in[i];
    if(mini > in[i]) mini = in[i];
  }
  printf("%.1lf\n", maxi - mini);

  return 0;
}

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

int main() {
    int r, g, b, a;
    cin >> r >> g >> b;
    a = 100*r + 10*g + b;
    if(a % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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


public class Main {

	Scanner sc;
	
	void solve(int p,int q){
		int[] remainder=new int[q];
		Arrays.fill(remainder,-1);
		
		int end;
		int d=0;
		p%=q;
		for(end=0;p!=0&&remainder[p]==-1;++end){
			remainder[p]=end;
			p*=10;
			d=p/q;
			System.out.print(d);
			p%=q;
		}
		System.out.println();
		if(p!=0){
			for(int i=0;i<end;++i){
				System.out.print(i<remainder[p]?' ':'^');
			}
			System.out.println();
		}
	}
	
	int ni(){
		return sc.nextInt();
	}
	
	void io(){
		sc=new Scanner(System.in);
		
		while(sc.hasNext()){
			solve(ni(),ni());
		}
		
		sc.close();
	}
	
	void debug(Object...os){
		System.err.println(Arrays.deepToString(os));
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().io();
	}

}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{
  gearup;
  int n; cin >> n;
  vl a(n);
  int two = 0,four = 0;
  rep(i,n){
    cin>>a[i];
    if(a[i] % 4 == 0) four++;
    else if(a[i] % 2 == 0)two++;
  }
  if(two >= 2)n-= (two-1);
  if(n/2 <= four)out("Yes");
  else out("No");
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long k=sc.nextLong();
		int q=Integer.parseInt(sc.next());
		sc.nextLine();
		long[] score=new long[n];
		while(sc.hasNextLine()) {
			score[Integer.parseInt(sc.nextLine())-1]++;
		}
		for(long l:score) {
			if(k-q+l>0) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}
	}
}

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

int main(){
    int n, count;
    cin >> n;
    count = 0;
    for (int x = 1; x < 10; x++){
        for (int i = 1; i < 10; i++){
            if (x * i == n){
                count ++;
                
            }
        }
    }
    if (count)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int d,n;
	cin >> d >> n;
	int ans = 1;
	for(int i = 0;i < d;i++){
		ans *= 100;
	}
	if(n == 100){
		cout << (ans*(n+1)) << endl;
		return 0;
	}
	cout << (ans*n) << endl;
	return 0; 
}

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

typedef long long ll;
typedef long double ld;
//#define int ll
//#define endl '\n'

// use unique(x) - removec consecutive items, returns vec.begin() + number of items
// for vector: sort(all(vec)); vec.erase(unique(all(vec)), vec.end());
// use iota(all(vec), 0) for filling a vector with 0,1,2...
// use fill(all(vec), 1) for filling a vector with 1,1,1...
// use rotate(vec.begin(), vec.begin() + 1, vec.end()) to rotate a vector | middle arg becomes first
// print number in binary -> cout << bitset<20>(n);

main(){
	cin.tie(0);cin.sync_with_stdio(0);
	int n;cin>>n;
	ll res=0;
	for(int i=1;i<n;++i)res+=n/i-(n%i==0);
	cout<<res<<endl;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

const int MAXN = 1E5 + 10;
const int MOD = 1E9 + 7;

int n;
ll A, B;
ll a[MAXN];
ll f[MAXN][2], s[MAXN][2];

int main(){
	scanf("%d%lld%lld", &n, &A, &B);
	for (int i = 1; i <= n; ++i)
		scanf("%lld", a + i);
	a[0] = -(a[n + 1] = 1ll << 61);
	int la = 1, lb = 1;
	f[0][0] = f[0][1] = 1;
	s[0][0] = s[0][1] = 1;
	for (int i = 1; i <= n; ++i){
		if (a[i] - a[i - 1] < A)
			la = i;
		if (a[i] - a[i - 1] < B)
			lb = i;

		int ra = upper_bound(a, a + i, a[i + 1] - B) - a - 1;
		if (la - 1 <= ra)
			f[i][0] = (s[ra][1] - (la == 1 ? 0 : s[la - 2][1]) + MOD) % MOD;
		int rb = upper_bound(a, a + i, a[i + 1] - A) - a - 1;
		if (lb - 1 <= rb)
			f[i][1] = (s[rb][0] - (lb == 1 ? 0 : s[lb - 2][0]) + MOD) % MOD;
		s[i][0] = (s[i - 1][0] + f[i][0]) % MOD;
		s[i][1] = (s[i - 1][1] + f[i][1]) % MOD;
	}
	printf("%d\n",(int)((f[n][0] + f[n][1]) % MOD));
	return 0;
}


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

int main()
{
    
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   
  
   
   int c1=0;
   
   while(a>0 && c>0)
   {
       
       if(c1%2==0)
       {
           c-=b;
       }
       else
       {
        a-=d;   
       }
     c1++;
   }
   
   if(c1%2!=0)
   cout<<"Yes";
   else
   cout<<"No";
   
    return 0;
}


Measured memory_bytes: 3636
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

def Z_algo(S):
    n=len(S)
    A=[0]*n
    A[0]=n
    i=1
    j=0
    while i<n:
        while i+j<n and S[j]==S[i+j]: j+=1
        A[i]=j
        if j==0:
            i+=1
            continue
        k=1
        while i+k<n and k+A[k]<j:
            A[i+k]=A[k]
            k+=1
        i+=k
        j-=k
    return A

N = I()
S = str(input())

T = ''.join(list(reversed(S)))

dp = [0]*N
for i in range(1,N):
    a = Z_algo(T[N-i-1:])
    b = []
    for j in range(len(a)):
        b.append(min(a[j],j))
    dp[i] = max(dp[i-1], max(b))

print(dp[N-1])

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

const ll mod = 1e9+7;


int num[2000+10];
int a[2000+10];
int b[2000+10];

int main()
{
	ll n,k;
	cin>>n>>k;
	for(int i=0; i<n; i++)
		cin>>num[i];
	for(int i=0; i<n; i++)
	{
		int j=i+1;
		while(j < n) 
		{
			if(num[j] < num[i]) a[i]++;	
			j++;		
		}
		if(!b[num[i]])
			{
				for(int k=0; k<n; k++)
				{
					if(num[k] < num[i])
					b[num[i]]++;
				}
			}
	}
//	for(int i=0; i<n; i++) cout<<a[i]<<' '<<b[num[i]]<<endl;

	ll ans=0;
	ll sum=(k-1)*k/2;
	sum = sum % mod;
	for(int i=0; i<n; i++)
	{
//		ans += b[num[i]]*sum%mod;
//		ans += k*a[i]%mod;
		
		ans=(ans+k*a[i]%mod+b[num[i]]*sum%mod)%mod;
	}
	cout<<ans%mod;
	return 0;
}

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

int main() {
  int A, B, C;
  int K;
  
  cin >> A >> B >> C >> K;
  
  int count = 0;
  
  while(A >= B){
    B *= 2;
    count++;
  }
  
  while(B >= C){
    C *= 2;
    count++;
  }
  
  if(count <= K)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

}


Measured memory_bytes: 3544
#include <stdio.h>
unsigned short dp[11][1024][341],ans[11][341];int main() {unsigned short i,j,k,s;dp[0][0][0]=1;
    for (i=0;i<10;i++) for (j=0;j<1024;j++) for (k=0;k<331;k++) {if (!dp[i][j][k]) continue; for (s=0;s<10;s++) if (!(j&(1<<s))) dp[i+1][j|(1<<s)][i*s+s+k]+=dp[i][j][k];}
    for (i=0;i<11;i++) for (j=0;j<1024;j++) for (k=0;k<331;ans[i][k]+=dp[i][j][k],k++);while (scanf("%hu %hu",&i,&j)!=EOF) {if (i>10 || j>330) {puts("0");continue;} else printf("%hu\n",ans[i][j]);} return 0;}

Measured memory_bytes: 5336
N = int(input())
txy = []
for i in range(N):
    txy.append(list(map(int,input().split())))
flag = 0
if N == 1:
    dt = txy[0][0]
    dx = txy[0][1]
    dy = txy[0][2]
    if (dx+dy-dt)%2 == 0 and (dx+dy) <= dt:
        pass
    else:
        flag = 1
        print("No")
for j in range(N-1):
    if j == 0:
        dt = txy[0][0]
        dx = txy[0][1]
        dy = txy[0][2]
    else:
        dt = txy[j+1][0]-txy[j][0]
        dx = abs(txy[j+1][1]-txy[j][1])
        dy = abs(txy[j+1][2]-txy[j][2])
    if (dx+dy-dt)%2 == 0 and (dx+dy) <= dt:
        pass
    else:
        flag = 1
        print("No")
        break
if flag == 0:
    print("Yes")

Measured memory_bytes: 27380
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        char[] input = sc.next().toCharArray();
        input[3] = '8';
        String ans = String.valueOf(input);

        System.out.println(ans);
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }
}


Measured memory_bytes: 20948
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }



int main() {
  int N;
  scanf("%d", &N);
  int N_hold = N;

  int len = 0;
  
  while(N>0){
    N /= 10;
    ++len;
  }

  if(len==1) cout << N_hold << endl;
  if(len==2) cout << 9 << endl;
  if(len==3) cout << 9+(N_hold-99) << endl;
  if(len==4) cout << 909 << endl;
  if(len==5) cout << 909+(N_hold-9999) << endl;
  if(len==6) cout << 90909 << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#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 Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
int main(){
    CIN(N);
    I vec;
    int ans = -INF;
    REP(a,N){
        CIN(b);
        vec.pb(b);

    }
    int ins = vec.front();
    REP(a,N-1){
         ans = max(ans, vec.at(a+1) - ins);
         ins = min(ins,vec.at(a+1));
    }
    COUT(ans);
    return 0;
}



Measured memory_bytes: 3848
#include <iostream>
#include <string>

using namespace std;

int main(){
  int A, Z;
  string S;

  cin >> S;

  for(int i = 0;i < S.size();i++){
    if(S[i] == 'A'){
      A = i;
      break;
    }
  }

  for(int i = S.size() - 1;i >= 0;i--){
    if(S[i] == 'Z'){
      Z = i;
      break;
    }
  }

  cout << Z - A + 1 << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	vector<pair<int, int>> b;
	b.emplace_back(make_pair(1, a[0]));
	int p = 0;
	for (int i = 1; i < n; i++) {
		if (b[p].second == a[i]) {
			b[p].first++;
		}
		else {
			p++;
			b.emplace_back(make_pair(1, a[i]));
		}
	}
	sort(b.begin(), b.end());

	int ans = 0;
	if (b.size() > k) {
		for (int i = 0; i < b.size() - k; i++) {
			
			ans += b[i].first;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

  string s; cin >> s;
  vector<int> vec(26);
  rep(i, s.length()) {
    int a = s[i] - 'A';
    vec[a]++;
  }
  bool flag = true;
  rep(i, 26) {
    if(vec[i]!=0 && vec[i]!=2) flag = false;
  }
  cout << (flag ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m = map(int, input().split())
P = list(map(int, input().split()))
uf = UnionFind(n)
for _ in range(m):
  x, y = map(int, input().split())
  x -= 1
  y -= 1
  uf.union(x, y)
ans = 0
for i in range(n):
  if uf.same(i, P[i]-1):
    ans += 1
print(ans)

Measured memory_bytes: 13812
package main
import (
   "fmt"
   "os"
   "bufio"
   "strconv"
)
var sc = bufio.NewScanner(os.Stdin)

func main() {
  sc.Split(bufio.ScanWords)
  n := nextInt()
  a := make([]int, n)
  result := ""
  for i := 0; i < n ; i++ {
	  a[i] = nextInt()
  }

  for i := 0; i < n ; i++ {
	  result = result + strconv.Itoa(a[n - i - 1])
	  if i != n - 1 {
		  result += " "
	  }
  }

      fmt.Println(result)

}

func getStdin() (string) {
	sc.Scan()
	v := sc.Text()
	return v
}

func nextInt() (int) {
	sc.Scan()
	v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}

func nextFloat() (float64) {
	sc.Scan()
	v, e := strconv.ParseFloat(sc.Text(), 64)
    if e != nil { panic(e) }
    return v
}



Measured memory_bytes: 1132