akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
int inf = 1e9;
int n;
bool func(vector<long long int> a, int pos) {
  if(pos < 0 || pos >= n) return false;
  long long int s = a[pos];
  for(int i=0; i<n; i++) {
    if(i == pos) continue;
    // cerr << s << endl;
    if(a[i] > 2*s) {
      return false;
    }
    s += a[i];
  }
  return true;
}

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

  int l = 0, r = n;
  int m = (l + r) / 2;
  int p = 100;
  while(p--) {
    // cerr << l << " " << m << " " << r << endl;
    if(func(a, m)){
      r = m;
    } else {
      l = m;
    }
    m = (l+r) / 2;
  }

  for(int i=m; ; i++) {
    if(func(a, i)) {
      cout << n - i << endl;
      return 0;
    }
  }

  return 0;
}


//EOF


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

bool check;

void rec(string s) {
    if (s == "ABC") {
        check = true;
        return;
    }
    Int n = s.size();
    string t = "";
    map<char, int> mp;
    bool update = false;
    for (int i = 0; i < n; i++) {
        if (i + 2 < (Int)s.size() and s.substr(i, 3) == "ABC") {
            update = true;
            i += 2;
            t += "T";
        } else {
            t += s[i];
            mp[s[i]]++;
        }
    }
    if (not update or mp.size() != 2) return;
    char c = 'A';
    if (mp['B'] == 0) c = 'B';
    if (mp['C'] == 0) c = 'C';
    for (Int i = 0; i < (Int)t.size(); i++) {
        if (t[i] == 'T') {
            t[i] = c;
        }
    }
    rec(t);
}

int main() {
    string s;
    cin >> s;
    check = false;
    rec(s);
    dump(check ? "Yes" : "No");
    return 0;
}



Measured memory_bytes: 22176
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n,a,b,c,d;cin>>n>>a>>b>>c>>d;
    ll dis=d*(n-1)-abs(b-a);
    bool f=1;
    if(dis<0)f=0;
    else if(dis%(d+c)>(d-c)*(n-1))f=0;
    cout<<(f?"YES":"NO")<<endl;
}

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

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] line = br.readLine().split(" ");
      int n     = Integer.parseInt(line[0]);
      int qTime = Integer.parseInt(line[1]);
      Queue<Process> queue = new Queue<>(n+2+(n/4));

      for(int i=0; i!=n; i++) {
        line = br.readLine().split(" ");
        queue.enQueue( new Process(line[0], Integer.parseInt(line[1])) );
      }

      int usingTime = 0;
      Process proc;
      StringBuilder result = new StringBuilder(n*5);

      while(!queue.isEmpty()) {
        proc = queue.deQueue();
        proc.pTime -= qTime;

        if(proc.pTime < 1) {
          usingTime += qTime + proc.pTime;
          result.append(proc.name).append(" ").append(usingTime).append("\n"); 
        } else {
          usingTime += qTime;
          queue.enQueue(proc);
        }
      }

      System.out.print(result);
    }
  }
}

class Process {
  final String name;
  int pTime;

  public Process(String name, int time) {
    this.name = name;
    this.pTime = time;
  }
}

class Queue<E> {

  private Object[] queue;
  private int head;
  private int tail;
  private int max;

  public Queue(int capacity) {
    queue = new Object[capacity];
    head = tail = 0;
    max  = queue.length;
  }

  boolean isEmpty() {
    return head == tail;
  }
  boolean isFull() {
    return head == (tail + 1) % max;
  }

  void enQueue(E x) {
    if(isFull()) System.out.println("queue is full!");

    queue[tail] = x;
    if(tail+1 == max) tail = 0;
    else tail++;
  }
  @SuppressWarnings("unchecked")
  E deQueue() {
    if(isEmpty()) {
      System.out.println("queue is empty!");
      throw new IllegalStateException("queue is empty!");
    }

    E ret = (E)queue[head];

    if(head+1 == max) head = 0;
    else head++;

    return ret;
  }
}


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

ll solve(ll t){
	ll ans=0;
	if (t>9){
		ans+=9;
		if (t<=999 and t>99){
			ans+=(t-99);
			return ans;
		}
		else if (t<=99)return ans;
	}
	else{
		return t;
	}
	ans+=900;
	if (t<=99999 and t>9999){
		ans+=(t-9999);
		return ans;
	}
	else if (t<=9999) return ans;
	ans+=90000;
  	return ans;
}

int main(){
	ll t;
  	cin>>t;
  	cout<<solve(t);
}

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

//Country Road
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		while(T--!=0){
			int n = sc.nextInt(), k = sc.nextInt();
			int[] a = new int[n], len = new int[n-1];
			for(int i=0;i<n;i++)a[i] = sc.nextInt();
			for(int i=0;i<n-1;i++)len[i]=a[i+1]-a[i];
			Arrays.sort(len);
			int res = a[n-1]-a[0];
			int j = n-2;
			while(j>=0&&--k!=0)res-=len[j--];
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 15000
#include<bits/stdc++.h>
#define endl "\n"
#ifdef ONLINE_JUDGE
#define DEBUG(x)
#else
#define DEBUG(x) cout<<#x<<" : {"<<x<<"}"<<endl; 
#endif
using namespace std;
typedef long long int lli;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int x;
	for(int i=0; i<5; ++i){
		cin>>x;
		if(x == 0){
			cout<<i+1<<endl;
			break;
		}
	}
    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
string s;
int main(){
	cin>>s;
	int n=s.size();
	if(n<5) puts("NO");
	else {
		int f=1;
		for(int i=n-1;~i;){
			if(i-4>=0&&s.substr(i-4,5)=="dream") i-=5;
			else if(i-4>=0&&s.substr(i-4,5)=="erase") i-=5;
			else if(i-5>=0&&s.substr(i-5,6)=="eraser") i-=6;
			else if(i-6>=0&&s.substr(i-6,7)=="dreamer") i-=7;
			else {
				f=0;
				break;
			}
		}
		puts(f?"YES":"NO");
	}
	return 0;
}

Measured memory_bytes: 3752
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion


int32_t main() {
    make(int, n);
    cout << n / 500 * 1000 + (n % 500) / 5 * 5;
    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val N = sc.nextInt()
    val K = sc.nextLong()
    val A = LongArray(N){0L}
    val bit = IntArray(40){0}// 10^12 < 2^40
    for (i in 0 until N) {
        A[i] = sc.nextLong()
        val a = java.lang.Long.toBinaryString(A[i])
        for (i in 0 until a.length)
            if(a[i] == '1') bit[40-a.length+i]++ 
    }
    
    //bit.forEach{print("$it ")}
    var isK = true
    val Kbi = "%40s".format(java.lang.Long.toBinaryString(K).toString()).replace(" ","0")
    var x = ""
    for (i in 0 until 40) {
        if(bit[i] > N/2 || (isK && Kbi[i] == '0')) x += "0"
        else x += "1"
        if (!isK || Kbi[i] != x[i]) isK = false
    }
    val X = java.lang.Long.parseLong(x,2)
    var ans = 0L
    A.forEach{ans += X xor it}
    println(ans)
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<vector<char>> S(n + 1, vector<char>(n + 1)), T(n + 1, vector<char>(n + 1));
    for(int i = 0; i < n;i++){
        for(int j = 0; j < n;j++){
            cin >> S[i][j];
        }
    }
    int ret = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n;j++){
            for(int k = 0; k < n;k++){
                T[j][k] = S[(i + j) % n][k];
            }
        }
        bool flag = false;
        for(int j = 0; j < n;j++){
            for(int k = j+1; k < n;k++){
                if(T[j][k] != T[k][j]) flag = true;
            }
        }
        if(!flag){
            ret += n;
        }
    }
    cout << ret << endl;
    return 0;
}

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

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

    char str0[n];
    scanf("%s", str0);
 
    string str1 = str0;
    
    //printf("%s\n", str0);
    //std::cout << str1 << std::endl;

    //前半と後半を比較。文字数が偶数とは限らない点に注意。
    
    int m;
    m = n / 2; // 小数点以下切り捨て
    
    string substr1 = str1.substr(0, m);
    string substr2;
    
    if (n % 2 == 0) {
        substr2 = str1.substr(m, m);
    }else{
        substr2 = str1.substr(m, m+1);
    }
    
    //std::cout << substr << std::endl;
    
    if(substr1 == substr2){
        printf("Yes");
    }else{
        printf("No");
    }
    //std::cout << substr1 << std::endl;
    //std::cout << substr2 << std::endl;
    
    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.conv;
import std.array;
import std.string;
import std.math;
import std.functional;
import std.range;
import std.typecons;
import std.format;

void main(string[] args) {
  readln.solve.writeln;
}

auto solve(string line1) {
  auto _ = line1.split.map!(to!real);
  real a = _[0];
  real b = _[1];
  return ((a + b)/2).ceil.to!int;
} unittest {
  assert(solve("1 3") == 2, "1");
  assert(solve("7 4") == 6, "2");
  assert(solve("5 5") == 5, "3");
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws InterruptedException {
		FastScanner fs=new FastScanner();
		int mod=fs.nextInt();
		int val=7%mod;
		for (int i=1; i<1e7; i++) {
			if (val==0) {
				System.out.println(i);
				return;
			}
			val=(val*10+7)%mod;
		}
		System.out.println("-1");
	}
	
	void sort(int[] a) {
		ArrayList<Integer> list=new ArrayList<>();
		for (int i:a) list.add(i);
		Collections.sort(list);
		for (int i=0; i<a.length; i++) a[i]=list.get(i);
	}
	
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
		
		public long[] readLongArray(int n) {
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
	}

}


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

typedef long long int ll;
#define MOD 1000000007

int main(){
  int n,m;
  cin >> n >> m;
  if(abs(n-m) > 1){
    cout << 0 << endl;
    return 0;
  }
  else{
    ll n1 = 1, m1 = 1, ans;
    for(int i = 1; i <= n; i++){
      n1 = (n1*i) % MOD;
    }
    for(int i = 1; i <= m; i++){
      m1 = (m1*i) % MOD;
    }
    if (n == m) {
        ans = (n1 * m1 * 2) % MOD;
    } else {
        ans = (n1 * m1) % MOD;
    }
 
    cout << ans << endl;
    return 0;
  }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for(ll i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	ll ans=0;
	for(ll i=0;i<k;i++) ans+=a[i];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;

    string res = "";
    res += 'A'+(s1[0]-'a');
    res += 'A'+(s2[0]-'a');
    res += 'A'+(s3[0]-'a');

    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

int main() {
  int N;
  cin >> N;
  vector<int> T(N);
  int sum=0;
  rep(i, N) {
    cin >> T[i];
    sum += T[i];
  }
  int M;
  cin >> M;
  vector<int> P(M), X(M);
  rep(i, M) cin >> P[i] >> X[i];
  rep(i, M) cout << sum-T[P[i]-1]+X[i] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
const long long MOD = 1e9+7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

ll H, W;
vector<vector<ll>> MAP;
struct query {
	ll x0, y0;
	ll x, y;
};
vector<query> ans;

int main() {
	cin >> H >> W;
	MAP.resize(W, vector<ll>(H, 0));
	for (ll y = 0; y < H; y++) {
		for (ll x = 0; x < W; x++)cin >> MAP[x][y];
	}
	for (ll y = 0; y < H; y++) {
		for (ll x = 0; x < W; x++) {
			if (MAP[x][y] % 2 == 0)continue;
			if (x + 1 < W) {
				MAP[x][y]--;
				MAP[x + 1][y]++;
				ans.push_back({ x,y,x + 1,y });
				continue;
			}
			if (y + 1 < H) {
				MAP[x][y]--;
				MAP[x][y + 1]++;
				ans.push_back({ x,y,x,y + 1 });
				continue;
			}
		}
	}
	cout << ans.size() << endl;
	for (auto q : ans) {
		cout << q.y0+1 << " " << q.x0+1 << " " << q.y+1 << " " << q.x+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 8304
#include<bits/stdc++.h>
using namespace std;
int N,M,ans[1025][1025];
inline void solve(int lx,int rx,int ly,int ry)
{
	if(lx==rx) return;
	int midx=(lx+rx)>>1,midy=(ly+ry)>>1;
	ans[midx][midy]=0;
	solve(lx,midx-1,ly,midy-1);
	solve(lx,midx-1,midy+1,ry);
	solve(midx+1,rx,ly,midy-1);
	solve(midx+1,rx,midy+1,ry);
}
int main()
{
	cin>>N>>M;
	for(int i=1;i<(1<<N);i++) for(int j=1;j<(1<<M);j++) ans[i][j]=1;
	int T=max(N,M);solve(1,(1<<T)-1,1,(1<<T)-1);
	for(int i=1;i<(1<<N);i++){for(int j=1;j<(1<<M);j++) putchar(ans[i][j]+'0');putchar('\n');}
	return 0;
}

Measured memory_bytes: 7660
import java.util.*;
import java.io.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		System.out.println(Math.max(a, Math.max(b, c)) - Math.min(a, Math.min(b, c))); 
	}
}

Measured memory_bytes: 21844
class RootedTree
  attr_accessor :nodes

  class Node
    attr_accessor :id, :children, :parent

    def initialize(id, parent = nil)
      @id = id
      @children = []
      @parent = parent
    end

    def type
      if @parent.id == -1
        "root"
      elsif @children.size == 0
        "leaf"
      else
        "internal node"
      end
    end

    def depth
      dep = 0
      parent = @parent
      while parent.id != -1
        dep += 1
        parent = parent.parent
      end
      return dep
    end

  end

  def initialize
    @nodes = []
    @root_parent = Node.new(-1)
  end

  # children ::= [1, 2, 14]
  def add_node(id, children)
    @nodes[id] = Node.new(id, @root_parent) unless @nodes[id]
    children.each do |i|
      if @nodes[i]
        @nodes[i].parent = @nodes[id]
      else
        @nodes[i] = Node.new(i, @nodes[id])
      end
      @nodes[id].children << @nodes[i]
    end
  end

  def print
    @nodes.each do |n|
      puts "node #{n.id}: parent = #{n.parent.id}, depth = #{n.depth}, #{n.type}, [#{n.children.map{ |c| c.id }*', '}]"
    end
  end

end

rt = RootedTree.new
n = gets.to_i
n.times do |k|
  id, k, *children = gets.split.map { |i| i.to_i }
  rt.add_node(id, children)
end
rt.print

Measured memory_bytes: 28648
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto G = new int[][](N);
    auto H = new int[][](N);
    foreach (i; 0..M) {
        s = readln.split.map!(to!int);
        auto u = s[0] - 1;
        auto v = s[1] - 1;
        G[u] ~= v;
        H[v] ~= u;
    }

    auto dp = new real[](N);
    dp[] = 0;

    foreach_reverse (i; 0..N-1) {
        dp[i] = G[i].map!(j => dp[j]).sum / G[i].length + 1;
    }

    real ans = dp[0];

    foreach (i; 0..N-1) if (G[i].length > 1) {
        auto ep = dp.dup;
        ep[i] = (G[i].map!(i => dp[i]).sum - G[i].map!(i => dp[i]).reduce!max) / (G[i].length.to!long - 1) + 1;
        foreach_reverse (j; 0..i) {
            ep[j] = G[j].map!(k => ep[k]).sum / G[j].length + 1;
        }
        ans = min(ans, ep[0]);
    }

    writefln("%.15f", ans);
}


Measured memory_bytes: 12796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll mod=1e9+7,INF=mod*mod*3;//M_PI
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define si(x) x.size()

ll N;
ll PP[200005];
ll RP[200005];
ll f[200005];
ll dp[200005];
ll ans=INF;

int main(){

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

cin>>N;
rep(i,N){
	ll p,k; 
	cin>>p;
	k=N-p+1;
	PP[p]=i;
	RP[k]=N-1-i;
}
rep1(k,N+1){
	if(RP[k-1]<RP[k]) dp[k]=dp[k-1];
	else dp[k]=k-1;
}
rep(i,N+1){
	f[i]=i+dp[N-i];
	if(i>0&&PP[i]==0) f[i]--;
}
rep(i,N+1){
	ans=min(ans,f[i]);
}
cout<<ans<<endl;

}
	

Measured memory_bytes: 9892
#include <bits/stdc++.h>
 
#define int long long
 
#define pii pair<int, int>
 
#define x1 x1228
#define y1 y1228
 
#define left left228
#define right right228
 
#define pb push_back
#define eb emplace_back
 
#define mp make_pair                                                                
                                                                                                                                        
#define ff first                                                                  
#define ss second   
 
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << ": " << x << endl; 
#define TIME (ld)clock()/CLOCKS_PER_SEC
 
using namespace std;
typedef long long ll; 
typedef long double ld; 
                                                                                                   
const int maxn = 3e5 + 7, mod = 1e9 + 7, MAXN = 1e6 + 7;
const double eps = 1e-9;
const ll INF = 1e18, inf = 1e15;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n;
int a[maxn];
string s; 
 
void add(vector<int> &base, int x) {
    for (int i = 59; i >= 0; --i) {
        if (((x >> i) & 1ll) == 0) continue; 
        if (base[i] == -1) {
            base[i] = x; 
            break; 
        } 
        x ^= base[i]; 
    }
}

vector<int> build(vector<int> value) {
    vector<int> base(60, -1);
    for (auto v : value) {
        add(base, v); 
    }        
    return base; 
}

bool check(vector<int> &base, int x) {
    for (int i = 59; i >= 0; --i) {
        if (((x >> i) & 1ll) == 0) continue; 
        if (base[i] == -1) return false;  
        x ^= base[i]; 
    }
    return true; 
}

void solve() {
    cin >> n; 
    for (int i = 0; i < n; ++i) cin >> a[i]; 
    cin >> s; 
    for (int i = 0; i < n; ++i) {
        if (s[i] == '0') continue; 
        vector<int> value; 
        for (int j = i + 1; j < n; ++j) if (s[j] == '0') value.pb(a[j]); 
        vector<int> base = build(value); 
        if (!check(base, a[i])) {
            cout << "1\n"; 
            return; 
        }
    }                             
    cout << "0\n"; 
}                                   
   
signed main() {
#ifdef LOCAL
    freopen("TASK.in", "r", stdin);
    freopen("TASK.out", "w", stdout);
#else 
    
#endif // LOCAL
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20); 
    cout << fixed; 
    int t = 1; cin >> t;  
    for (int i = 0; i < t; ++i) {              
        solve();
    }
    return 0;
}  

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int s=S.size();
  set<char> seet;
  for (int i=0;i<s;i++){
    seet.insert(S[i]);
  }
  if (s==seet.size()){
    cout << "yes" << endl;
  }
  else {
    cout << "no" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<complex>
#include<algorithm>
#include<vector>
#include<math.h>
#include<set>

int main()
{
	std::string str;
	int k;
	std::set<std::string> strings;

	std::cin >> str >> k;
	for (int i = 0; i < str.size(); ++i)
	{
		std::string tmp;
		for (int j = 0; j < 5 && i + j < str.size(); ++j)
		{
			tmp.push_back(str[i + j]);
			strings.insert(tmp);
		}
	}

	int count{};
	for (auto e : strings)
	{
		count++;
		if (count == k)
		{
			std::cout << e << std::endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 1664
n,T = map(int, input().split())
c = []
t = []
for i in range(n):
    ctmp,ttmp = map(int, input().split())
    c.append(ctmp)
    t.append(ttmp)

idx = []
for i in range(n):
    if t[i]<=T:
        idx.append(i)

if len(idx)==0:
    print("TLE")
else:
    minCost = c[idx[0]]
    for j in idx:
        if minCost > c[j]:
            minCost = c[j]
    print(minCost)

Measured memory_bytes: 3064
import kotlin.random.Random

//

fun main() {
    intro_heuristicsa()
}

fun intro_heuristicsa() {
    val d = readLine()!!.toInt()
    val c = readLine()!!.split(" ").map { it.toInt() }
    val s = MutableList(d) { listOf<Int>()}
    repeat(d) {
        s[it] = readLine()!!.split(" ").map { it.toInt() }
    }
    val nextContest = (1..26).toMutableList()
    nextContest.shuffle()
    repeat(d) {
        if (nextContest.isEmpty()) {
            nextContest.addAll(1..26)
            nextContest.shuffle()
        }
        val i = nextContest[0]
        nextContest.removeAt(0)
        println(i)
    }
}


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

int main()
{
    std::string first;
    std::cin >> first;

    std::string second;
    std::cin >> second;

    if (first == second.substr(0, first.length()))
    {
        std::cout << "Yes";
    }
    else
    {
        std::cout << "No";
    }
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

ll a[200000];
ll sum[200001];//i未満の累積和
ll xox[200001];//i未満のxor

int main()
{
	int n;
	ll ans=0;
	
	cin>>n;
	sum[0]=0;
	xox[0]=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		sum[i+1]=sum[i]+a[i];
		ll d=(xox[i]^a[i]);
		xox[i+1]=d;
	}

	//尺取り法
	int r=0;
	for(int l=0;l<n;l++)
	{
		ll ss=sum[r+1]-sum[l];
		ll xx=(xox[r+1]^xox[l]);
		while(ss==xx && r<n+1)
		{
			r++;
			ss=sum[r+1]-sum[l];
			xx=(xox[r+1]^xox[l]);
			//cerr<<ss<<" "<<xx<<endl;
		}
		r=min(r,n);
		//cerr<<l<<" "<<r<<endl;
		ans+=(r-1)-l+1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4992
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        int[] l = new int[n];
        for (int i = 0; i < n; i++) {
            l[i] = sc.nextInt();
        }

        long sum = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (l[i] >= l[j]) continue;

                for (int k = 0; k < n; k++) {
                    if (l[i] >= l[k] || l[j] >= l[k]) continue;

                    if (l[i] + l[j] > l[k] &&
                        l[j] + l[k] > l[i] &&
                        l[k] + l[i] > l[j]) {
                        sum++;
                    }
                }
            }
        }
        System.out.println(sum);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 32832
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[n];
        int sum = 0;
        for(int i=0; i<n; i++) {
            a[i] = sc.nextInt();
            sum += a[i];
        }
        Arrays.sort(a);
        for(int i=0; i<m; i++) {
            int num = a[n-1-i];
            if(num * 4 * m < sum) {
                System.out.println("No");
                return;
            }

        }
        System.out.println("Yes");


    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> dp(n + 1, 0);

	vector<pair<int, int>>area(k);
	for (int i = 0; i < k; i++) {
		cin >> area[i].first >> area[i].second;
	}

	dp[1] = 1;
	int r, l, rp, lp;
	int sum;

	for (int i = 2; i <= n; i++) {
		sum = 0;
		for (int j = 0; j < k; j++) {
			r = i - area[j].first;
			l = i - area[j].second-1;
			//printf("%d,%d", r, l);
			if (r <= 0)rp = 0;
			else rp = dp[r];
			if (l <= 0)lp = 0;
			else lp = dp[l];
			sum += rp - lp;
			//printf("[%d,%d]", rp, lp);
			if (sum < 0)sum += MOD_Q;
			sum %= MOD_Q;
			//printf("+%d\n", sum);
		}
		dp[i] = dp[i - 1] + sum;
		dp[i] %= MOD_Q;
		//printf("->dp[%d] = %d\n", i, dp[i]);
	}
	int ans = dp[n] - dp[n - 1];
	if (ans < 0)ans += MOD_Q;

	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 4036
Al = [chr(i) for i in range(65, 65+26)]
N = int(input())
S = list(input())
#print(S)

Al_ans = []
for i in S:
    n = Al.index(i) + N
    if n > 25:
        n = n - 26
    Al_ans.append(Al[n])
ans = "".join(Al_ans)

print(ans)

Measured memory_bytes: 3188
class Stack():
  def __init__(self, max=100):
    self.max = max
    self.top = 0
    self.arr = [None for _ in range(max)]
  
  def is_empty(self):
    return self.top == 0

  def is_full(self):
    return self.top >= self.max - 1

  def push(self, x):
    if self.is_full():
      raise IndexError()
    self.top += 1
    self.arr[self.top] = x

  def pop(self):
    if self.is_empty():
      raise IndexError()
    self.top -= 1
    return self.arr[self.top + 1]

s = input().split()

stack = Stack(300)

for x in s:
  if x == "+":
    a = int(stack.pop())
    b = int(stack.pop())
    stack.push(b + a)
  elif x == "-":
    a = int(stack.pop())
    b = int(stack.pop())
    stack.push(b - a)
  elif x == "*":
    a = int(stack.pop())
    b = int(stack.pop())
    stack.push(b * a)
  else:
    stack.push(int(x))

print(stack.pop())


Measured memory_bytes: 5612
use proconio::marker::Chars;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
        r: u32,
        s: u32,
        p: u32,
        t: Chars,
    }
    let mut ans: u32 = 0;
    let mut draw = vec![false; n];
    for i in 0..n {
        if i >= k && &t[i - k] == &t[i] && !&draw[i - k] {
            draw[i] = true;
        } else {
            ans += match &t[i] {
                'r' => p,
                's' => r,
                'p' => s,
                _ => 0,
            }
        }
    }
    println!("{}", ans);
}


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

int main()
{
  int N;
  cin >> N;
  vector<int> pvec(N);
  for (int i = 0; i < N; i++)
  {
    cin >> pvec.at(i);
  }
  vector<int> qvec(N);
  for (int i = 0; i < N; i++)
  {
    qvec.at(i) = i + 1;
  }
  int num = 0;
  for (int i = 0; i < N; i++)
  {
    if (pvec.at(i) != qvec.at(i))
      num++;
  }
  if (num == 0 or num == 2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 256
# encoding: utf-8

class UFSet
  def initialize(sz)
    @sz = sz
    @par = [0] * sz
    (0..sz - 1).each { |idx| @par[idx] = idx}
  end

  def find(x)
    if @par[x] == x
      x
    else
      @par[x] = find(@par[x])
    end
  end

  def same(x, y)
    find(x) == find(y)
  end

  def unite(x, y)
    fx = find(x)
    fy = find(y)
    @par[fx] = fy if fx != fy
  end
end

class Graph
  def initialize(v)
    @v = v
    @edge = []
    @g = []
    (0..@v - 1).each { @g << Array.new}
    @dist = [0x3fffffff] * v
    @prev = [-1] * v
  end

  def add_edge(u, v, w)
    @edge << { from: u, to: v, weight: w}
    @g[u] << { to: v, weight: w}
  end

  def mst_kruskal
    ans = 0
    @edge = @edge.sort_by { |x| x[:weight]}
    ufset = UFSet.new(@v)
    @edge.each do |ee|
      u, v, c = ee[:from], ee[:to], ee[:weight]
      if not ufset.same(u, v)
        ans += c
        ufset.unite(u, v)
      else
        next
      end
    end
    ans
  end

  def dijkstra(s)
    @dist[s] = 0
    que = { }
    que[s] = 0

    while not que.empty?
      v, d = que.min_by { |key, val| val}
      que.delete_if { |key, val| key == v and val == d}
      next if (@dist[v] < d)
      @g[v].each do |node|
        to, weight = node[:to], node[:weight]
        if @dist[to] > @dist[v] + weight
          @prev[to] = v
          @dist[to] = @dist[v] + weight
          que[to] = @dist[to]
        end
      end
    end

    (0..@v - 1).each do |i|
      puts "#{i} #{@dist[i]}"
    end
  end
end

def main
  n = gets.rstrip.to_i
  g = Graph.new(n)
  (0..n - 1).each do |row|
    info = gets.rstrip.split(/\s/).map(&:to_i)
    idx, kk = info[0], info[1]
    edges = info[2..-1]
    (0..kk - 1).each do |k|
      v, c = edges[2 * k], edges[2 * k + 1]
      g.add_edge(row, v, c)
    end
  end
  g.dijkstra(0)
end

main

Measured memory_bytes: 8672
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i <= n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i <= n; i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;
typedef std::vector<double> v_double;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(void)
{
    int n, k; 
    cin >> n >> k;
    
    v_int p(n);
    irep(i, n) {
        cin >> p[i];
    }
    
    v_double exp_sum(n);

    irep(i, n) {
        double tmp;
        tmp = (p[i]*(p[i]+1))/2.0;
        tmp /= (double)p[i];
        exp_sum[i] = tmp;
    }

    irep(i, n-1) {
        exp_sum[i+1] += exp_sum[i];
    }

    double ans = -1.0;
    irep(i, n-k+1) {
        double r = exp_sum[i+k-1];
        double l = 0.0;
        if(i != 0) { l = exp_sum[i-1]; }

        double sum = r-l;
        if(sum-ans > 1e-6) {
            ans = sum;
        }
    }
    printf("%.12f\n", ans);

    return 0;
}
/** atcoder **/


Measured memory_bytes: 2560
package main

import "fmt"

func main() {
	var n string
	fmt.Scan(&n)
	ans := ""

	for i := 0; i < len(n); i++ {
		if n[i] == '1' {
			ans += "9"
		}
		if n[i] == '9' {
			ans += "1"
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
package main

import (
	"fmt"
	"math"
)

func intMin(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func main() {
	var S string
	fmt.Scan(&S)

	red, blue := 0, 0
	for _, cube := range S {
		if cube == '0' {
			red++
		} else {
			blue++
		}
	}
	fmt.Println(intMin(red, blue) * 2)
}


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

using namespace std;

//void dfs()

int main()
{
    int v,e;
    cin >> v >> e;
    vector <int> vv[v+1];
    int dp[v+1];
 //   bool cek[v+1];
    for (int i=0;i<v+1;i++){
        dp[i]=-1;
 //       cek[i]=0;
    }

    for (int i=0;i<e;i++){
        int a,b;
        cin >> a >> b;
        vv[a].push_back(b);
    }
    stack <int> st;
    int ans=0;

    for (int i=1;i<v+1;i++){
        if (dp[i]!=-1){
            continue;
        }
        st.push(i);
        while (st.empty()==false){
            int n=vv[st.top()].size();
            if (n==0){
                dp[st.top()]=0;
                st.pop();
                continue;
            }

            for (int j=0;j<n;j++){
                if (dp[vv[st.top()][j]]!=-1){
                    dp[st.top()]=max(dp[st.top()],dp[vv[st.top()][j]]+1);
                    if (j==n-1)
                        st.pop();
                }
                else{
                    st.push(vv[st.top()][j]);
                    break;
                }
            }
        }
 //       st.pop();
        ans=max(dp[i],ans);
    }

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


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

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    
    if(a+b>c+d)
        return cout<<"Left",0;
    if(a+b<c+d)
        return cout<<"Right",0;
    if(a+b==c+d)
        return cout<<"Balanced",0;
    
    
    return 0;
}


Measured memory_bytes: 768
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    string s;
    cin >> s;

    ll y = stoi(s.substr(0, 4));
    ll m = stoi(s.substr(5, 2));
    ll d = stoi(s.substr(8, 2));
    
    if(y<=2019 && m<=4 && d<=30){
        p("Heisei");
    }else{
        p("TBD");
    }
    
    return 0;
}

Measured memory_bytes: 256
A, B, C, D, E, F = map(int, input().split())
a_num = int(F/(100*A))
b_num = int(F/(100*B))
c_num = int(F/C)
concentration = 0
ans1 = 100*A
ans2 = 0
for i in range(a_num+1):
    a = i*100*A
    for j in range(b_num+1):
        b = j*100*B
        if a+b > F:
            break
        for k in range(c_num+1):
            c = k*C
            if a+b+c > F:
                break
            if ((a+b)/100)*E < c:
                break
            limit_e = ((a+b)/100)*E - c
            limit_f = F - (a+b+c)

            d = min(int(limit_e/D)*D, int(limit_f/D)*D)
            if d < 0:
                break
            if a+b+c+d == 0:
                break
            _concentration = (100*(c+d))/(a+b+c+d)
            if _concentration > concentration:
                concentration = _concentration
                ans1 = a+b+c+d
                ans2 = c+d
print(ans1, ans2)


Measured memory_bytes: 3064
/**
*    author:  souzai32
*    created: 02.08.2020 14:04:13
**/

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

int main() {

    string S;
    cin >> S;
    int n=S.size();
    vector<char> s(n);
    rep(i,n) s.at(i)=S.at(i);

    int q;
    cin >> q;
    int t,f;
    char c;
    int rev=0;
    rep(i,q){
        cin >> t;
        if(t==1){
            rev+=1;
        }
        else{
            cin >> f >> c;
            if((rev+f)%2){
                auto it=s.begin();
                it=s.insert(it,c);
            }
            else s.push_back(c);
        }
    }
    if(rev%2) reverse(s.begin(),s.end());

    rep(i,s.size()) cout << s.at(i);
    cout <<  endl;

    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll ans = 0;
    string S;
    cin >> S;
    iter(c, S) ans += c == 'x';
    if(ans <= 7) cout << "YES";
    else cout << "NO";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int N;
    while(cin >> N){
        vector<int> x(N), y(N), h(N);
        int idx = -1;
        for(int i=0;i<N;i++){
            cin >> x[i] >> y[i] >> h[i];
            if(h[i] > 0) idx = i;
        }
        int resX = -1, resY = -1, resH = -1;
        for(int i=0;i<=100;i++){
            for(int j=0;j<=100;j++){
                int testH = h[idx] + abs(x[idx] - i) + abs(y[idx] - j);
                bool ok = true;
                for(int k=0;k<N;k++){
                    if(max(0, testH - abs(x[k] - i) - abs(y[k] - j)) != h[k]){
                        ok = false;
                        break;
                    }
                }
                if(ok){
                    resX = i, resY = j, resH = testH;
                }
            }
        }
        cout << resX << " " << resY << " " << resH << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    char a = str.charAt(0);
    int b = (int)a;
    char c = (char)(b+1);    
    System.out.println(c);
  }
}


Measured memory_bytes: 24404
#include <iostream>
#include <stdio.h>
#include <math.h> 
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>
#include <numeric>
#include <bitset>
#include <queue>
#include <map>

using namespace std;


int main() {
	/*
	①同じ文字が異なる文字に変換された。(a->b,a->c)  例:aab&cdd
	②異なる文字が同じ文字に変換された。(b->a,c->a) こっちはOK 例：chokudai&redcoder
	の一つでも該当したらNo
	*/

	//input
	string S, T;
	cin >> S >> T;

	map<char, char> st, ts;
	int ans_st = 0;

	//S,Tの同じ番目のmapをつくる
	for (int i = 0; i < S.size(); ++i) {
		char s = S[i];
		char t = T[i];

		st.insert(make_pair(s, t));
		ts.insert(make_pair(t, s));
	}

	//①ここを高速化したい
	for (int i = 0; i < S.size(); ++i) {
		char tmp = T[i];
		if (st[S[i]] != tmp) {
			ans_st = 1;
			cout << "No" << endl;
			return 0;
		}
	}

	//Sの重複の削除
	sort(S.begin(), S.end());
	S.erase(unique(S.begin(), S.end()), S.end());

	//st[S[i]]をvecに格納する(Tに重複があるとき)
	vector<char> vec;
	for (int i = 0; i < st.size(); ++i) {
		vec.push_back(st[S[i]]);
	}
	//②vecに同じ文字があったら一つの文字が二つの変換先を持つということになるのでフラグを立てる
	for (int i = 0; i < vec.size(); ++i) {
		for (int j = i + 1; j < vec.size(); ++j) {
			if (vec[i] == vec[j]) {
				ans_st = 1;
				cout << "No" << endl;
				return 0;
			}
		}
	}

	/*
	//Tの重複の削除
	sort(T.begin(), T.end());
	T.erase(unique(T.begin(), T.end()), T.end());

	//st[T[i]]をvecに格納する(Sに重複があるとき)
	vector<char> vec2;
	for (int i = 0; i < ts.size(); ++i) {
		vec2.push_back(ts[T[i]]);
	}
	//②vecに同じ文字があったら一つの文字が二つの変換先を持つということになるのでフラグを立てる
	for (int i = 0; i < vec2.size(); ++i) {
		for (int j = i + 1; j < vec2.size(); ++j) {
			if (vec2[i] == vec2[j]) {
				ans_st = 1;
				cout << "No" << endl;
				return 0;
			}
		}
	}
	*/

	if (ans_st == 0) cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 776
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define nummax 110000
using namespace std;

int main() {
	double ans = 0.0, y;
	int i, N, K, x;
	cin >> N >> K;
	for (i = 1; i <= N; i++)
	{
		x = 0;
		while (1)
		{
			if (i * pow(2, x) >= K)
				break;
			x++;
		}
		y = pow(0.5, x);
		ans += y;
	}
	ans /= N;
	//cout << ans << endl;
	printf("%.12f\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main() {
    long long ans = 0;
    long long N;
    cin >> N;
    vector<long long> counter(N + 1, 1);
    counter[0] = 0;

    int k = 2;
    while (k <= N) {
        counter[k] += 1;
        for (int p = 2 * k; p <= N; p += k) {
            counter[p] += 1;
        }
        k += 1;
    }

    for (long long i = 1; i <= N; i++)
        ans += i * counter[i];

    cout << ans << endl;
}


Measured memory_bytes: 81400
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s, t;
  cin >> s;
  cin >> t;
  
  int min = 1000000000;
  for (int i = 0; i <= s.size()-t.size(); i++) {
    int minbuff = 0;
    for (int j = 0; j < t.size(); j++){
      if (s[j+i] != t[j]){
        minbuff++;
      }
    }
    if(minbuff < min){
      min = minbuff;
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#define llint long long

using namespace std;

llint N, T;
llint t[200005];

int main(void)
{
	cin >> N >> T;
	for(int i = 0; i < N; i++) cin >> t[i];
	
	llint ans = 0;
	for(int i = 0; i < N-1; i++){
		ans += max(0ll, t[i+1] - t[i] - T);
	}
	ans = t[N-1] + T - ans;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
import Data.Maybe
import Text.Printf
import Control.Monad
import qualified Data.ByteString.Char8 as B

readIntegers = map (fst . fromJust . B.readInteger) . B.words <$> B.getLine

mp [a, b] = (a, b)

main = do
    [n, d] <- readIntegers
    ps <- map mp <$> replicateM (fromIntegral n) readIntegers
    print $ length $ filter (f d) ps

f d (x, y) = x^2 + y^2 <= d^2

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

char BUF[1 << 21] , *buf = BUF;
void putch(char c){*(buf++) = c;}
void putint(int x){if(!(x / 10)){putch('0' + x); return;} putint(x / 10); putch('0' + x % 10);}
void flush(){fwrite(BUF , 1 , buf - BUF , stdout);}

bool vis[603][603]; int N , D1 , D2;
void color(int dist){
	int now = 0; while(!(dist & 3)){dist >>= 2; ++now;}
	if(dist % 4 == 3) return;
	for(int i = 0 ; i < 2 * N ; ++i)
		for(int j = 0 ; j < 2 * N ; ++j)
			vis[i][j] |= ((dist & 2) && (i >> now & 1)) || ((dist & 1) && (((i >> now) + (j >> now)) & 1));
}

int main(){
	cin >> N >> D1 >> D2; color(D1); color(D2); int num = 0;
	for(int i = 0 ; i < 2 * N ; ++i)
		for(int j = 0 ; j < 2 * N ; ++j)
			if(!vis[i][j] && ++num <= N * N){putint(i); putch(' '); putint(j); putch('\n');}
	flush(); return 0;
}

Measured memory_bytes: 1920