akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
#define NMAX 110000

struct info {
    int p;
    int y;
    int x;
};


int main(void)
{
    int n,m;
    cin >> n >> m;
    info py[NMAX];

    for(int i = 0; i < m;i++)  {
        cin >> py[i].p >> py[i].y;
    }
    vector<int> mp[NMAX];
    for(int i = 0; i < m; i++){
        mp[py[i].p].emplace_back(py[i].y);
    }
    for (int i = 0; i <= n; i++) {
        sort(mp[i].begin(), mp[i].end());
    }
    for (int i = 0; i < m; i++){
        auto itr = lower_bound(mp[py[i].p].begin(), mp[py[i].p].end(), py[i].y);
        py[i].x = (int) (itr - mp[py[i].p].begin()) + 1;
        cout << setw(6) << setfill('0') << py[i].p;
        cout << setw(6) << setfill('0') << py[i].x << endl;
    }

    return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const ll MOD = 1e9 + 7;
int N;
int T[100010], A[100010];
int L[100010], R[100010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> T[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  int tmp = -1;
  for (int i = 0; i < N; i++) {
    if (T[i] != tmp) {
      tmp = T[i];
      L[i] = T[i];
    }
  }
  tmp = -1;
  for (int i = N - 1; i >= 0; i--) {
    if (A[i] != tmp) {
      tmp = A[i];
      R[i] = A[i];
    }
  }

  ll ans = 1;  
  for (int i = 0; i < N; i++) {
    if (L[i] != 0 && R[i] != 0) {
      if (L[i] != R[i]) ans = 0;
    } else if (L[i] == 0 && R[i] != 0) {
      if (T[i] < A[i]) ans = 0;
    } else if (L[i] != 0 && R[i] == 0) {
      if (T[i] > A[i]) ans = 0;
    } else {
      ans *= min(T[i], A[i]);
      ans %= MOD;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

typedef long long LL;

int main(){
    string s;
    cin >> s;
    LL n = s.size();
    LL ans = 0;
    vector<LL> f_freq(256);
    for(int i = 0; i < n; ++i){
        f_freq[s[i]] += 1;
    }
    for(int i = 0; i < n; ++i){
        f_freq[s[i]] -= 1;
        ans += f_freq[s[i]];
    }
    cout << 1 + n*(n-1)/2 - ans << endl;
    return 0;
}


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

int main() {
    std::ios::sync_with_stdio(false);
    cout.tie(0); cin.tie(0);
    int N; cin >> N;
    int  A[N];
    for (int i=0; i<N; i++) {
        cin >> A[i];
    }
    sort(A,A+N);
    int maxDiff=A[N-1]-A[0];
    cout << maxDiff << endl;
    return 0;
}


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

void solve(){
    ll N, M; cin >> N >> M;
    vector<pair<ll, ll>> ab(M);
    for (ll i = 0; i < M; ++i){
        ll a, b; 
        scanf("%lld", &a);
        scanf("%lld", &b);
        --a; --b;
        ab[i].first = a;
        ab[i].second = b;
    }
    sort(ab.begin(), ab.end(),
         [](const pair<ll ,ll>& x, const pair<ll, ll>& y){return x.second < y.second;});
    
    float right = -1;
    ll ans = 0;
    for (ll i = 0; i < M; ++i){
        if (right < ab[i].first) {
            ans++;
            right = ab[i].second - 0.1;
        }
    }
    printf("%lld\n", ans);


}
int main(void){
    //////////////////////////

    solve();

    //////////////////////////
    return 0;
}

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

int main(void) {
	
	vector<char> x(6);
	rep(i, 6) cin >> x[i];
	if (x[0] == x[5] && x[1] == x[4] && x[2] == x[3]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;

}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

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

        int N = scanner.nextInt();
        int K = scanner.nextInt();

        Set<Integer> set = new HashSet<>();

        for (int i = 0 ; i < K ; i++) {
            int d = scanner.nextInt();

            for (int j = 0 ; j < d ; j++) {
                int a = scanner.nextInt();
                set.add(a);
            }
        }

        System.out.println(N - set.size());
    }
}


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

#define int long long
typedef pair<int, int> P;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

/*
ifstream ifs("in.txt");
ofstream ofs("out.txt");
#define cin ifs
#define cout ofs
//*/

int N, X;
int m[110];
signed main() {
    cin >> N >> X;
    int a = 1100;
    for (int i = 0; i < N; i++) {
        cin >> m[i];
        a = min(a, m[i]);
        X -= m[i];
    }
    cout << N + X / a << endl;
}

Measured memory_bytes: 256
import itertools
# Minesweeper
# input
H, W = map(int, input().split())
R = [[0 for i in range(W+2)] for j in range(H+2)]
memo = []

# processing
for h in range(1, H+1):
    for w, s in zip(range(1, W+1), input()):
        if s == '#':
            memo.append([h, w])
            for i, j in itertools.product([-1, 0, 1], [-1, 0, 1]):
                R[h+i][w+j] += 1

for h, w in memo:
    R[h][w] = '#'

# output
for S in R[1:-1]:
    print(''.join([str(e) for e in S[1:-1]]))

Measured memory_bytes: 3316
N = int(input())
cnt = 0
if N<10:
    print(N)
elif 10<=N<100:
    print(9)
elif 100<=N<1000:
    print(9+N-99)
elif 1000<= N <10000:
    print(909)
elif 10000<=N<100000:
    print(909+N-9999)
else:
    print(99999-9999+909)


Measured memory_bytes: 2940
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n=o.a();
  var t=o.m(n);
  var graph=xArray("{from:[],to:[]}",n*(n-1)/2);
  for(var i=0;i<n;i++){
    var b=f(t[i][0]-1,i);
    for(var j=1;j<n-1;j++){
      var a=f(t[i][j]-1,i);
      graph[b].to.push(a);
      graph[a].from.push(b);
      b=a;
    }
  }
  var g=topologicalSort(graph);
  if(g===-1)return -1;
  return g[g.length-1][1]+1;
}

function f(a,b){
  var mx=Math.max(a,b);
  return (mx*(mx-1)>>1)+Math.min(a,b);
}

function topologicalSort(g){
  var n=g.length;
  var a=Array(n).fill(0);
  var q=[];
  for(var i=0;i<n;i++){
    if(g[i].from.length)a[i]=g[i].from.length;
    else q.push([i,0]);
  }
  for(i=0;i<q.length;i++){
    var v=q[i][0];
    for(var j=0;j<g[v].to.length;j++){
      var V=g[v].to[j];
      if(--a[V]===0)q.push([V,q[i][1]+1]);
    }
  }
  return q.length<n?-1:q;
}

Measured memory_bytes: 410304
import sys
from heapq import heappush, heappop

readline = sys.stdin.readline


def solve():
    N = int(readline())

    left = [[] for _ in range(N)]
    right = [[] for _ in range(N)]
    ans = 0
    for _ in range(N):
        K, L, R = map(int, readline().split())
        if L > R:
            ans += R
            left[K - 1].append(L - R)
        else:
            ans += L
            if 0 <= N - K - 1:
                right[N - K - 1].append(R - L)

    for vec in (left, right):
        hq = []
        n = len(vec)

        for i in range(n):
            for p in vec[i]:
                heappush(hq, p)
            while len(hq) > i + 1:
                heappop(hq)

        for i in range(n, N):
            for p in vec[i]:
                heappush(hq, p)
            while len(hq) > n:
                heappop(hq)

        ans += sum(hq)

    return ans


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

    ans = [0] * T
    for i in range(T):
        ans[i] = solve()

    print('\n'.join(map(str, ans)))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 104192
S = input().strip()
target = S
if target == 'hi':
    print('Yes')
elif target == 'hihi':
    print('Yes')
elif target == 'hihihi':
    print('Yes')    
elif target == 'hihihihi':
    print('Yes')
elif target == 'hihihihihi':
    print('Yes')
else:
    print('No')

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
map<ll,ll> insuu;
void prime_factor(ll n){
    ll k=n;
	for(ll i=2;i*i<=n;i++){
	    while(k%i==0){
	        insuu[i]++;
	        k/=i;
	    }
	}
	if(k!=1) insuu[k]++;
	return ;
}
int main(){
  ll n;
  cin>>n;
  for(int i=2;i<=n;i++){
    prime_factor(i);
  }
  for(auto p:insuu){
    insuu[p.F]++;
  }
  ll t75=0;
  ll t25=0;
  ll t3=0;
  ll t5=0;
  ll t15=0;
  ll ans=0;
  for(auto p:insuu){
    if(p.S>=75) t75++;
     if(p.S>=25) t25++;
     if(p.S>=15) t15++;
     if(p.S>=5) t5++;
     if(p.S>=3) t3++;
  }
  ans=t75+t25*(t3-1)+(t5-1)*t15+t5*(t5-1)*(t3-2)/2;
  COUT(ans);
}

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

int main()
{
	string S;
	cin >> S;
	int ans = 0;
	for (int i = 0; i < S.size(); ++i)
	{
		for (int j = 1; j <= S.size() - i; ++j)
		{
			string temp = S.substr(i,j);
			bool flag = true;

			int l = temp.size();
			
			for (int k = 0; k < l; ++k)
			{
				if (temp[k] != 'A' && temp[k] != 'T' && temp[k] != 'C' && temp[k] != 'G')
				{
					flag = false;
				}
			}

			if(flag) ans = max(ans,l);

			//cout << temp << " " << flag << endl;
		}
	}

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

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int main() {
  int a, b;
  cin >> a >> b;
  cout << 6 - a - b << endl;
  return 0;
}


Measured memory_bytes: 764
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
n,k = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)
a.sort!

plusc = a.count{|e| e > 0}
minusc = a.count{|e| e < 0}
has_zero = a.any?{|e| e == 0}

if plusc == 0 && k.odd?
  if has_zero
    puts 0
  else
    ans = 1
    k.times do |i|
      ans = ans * a[-i-1] % MOD
      # ans = ans % MOD if i.even?
    end
    ans = (ans + MOD) % MOD
    puts ans
  end
  exit
end
# -------


ans = 1
l = 0
r = n - 1

if k.even?
  while l + (n-1-r) + 2 <= k
    lmul = a[l] * a[l+1]
    rmul = a[r-1] * a[r]
    if lmul > rmul || (plusc <= 2 && k.odd?)
      ans = ans * lmul % MOD
      l += 2
      minusc -= 2
    else
      ans = ans * rmul % MOD
      r -= 2
      plusc -= 2
    end
    # p [[l, r], [lmul, rmul], ans]
  end

else
  while l + (n-1-r) + 2 <= k
    lmul = a[l] * a[l+1]
    rmul = a[r-1] * a[r]
    if lmul * a[r] > rmul * a[r-2] || (plusc <= 2 && k.odd?)
      ans = ans * lmul % MOD
      l += 2
      minusc -= 2
    else
      ans = ans * rmul % MOD
      r -= 2
      plusc -= 2
    end
    # p [[l, r], [lmul, rmul], ans]
  end
end


if l + (n-1-r) < k
  ans = [ans * a[l], ans * a[r]].max
end

ans = (ans + MOD) % MOD
puts ans


# 0の場合！！！


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

using namespace std;
typedef long long ll;

#define gc getchar
int getint() { unsigned int c; int x = 0; while (((c = gc()) - '0') >= 10) { if (c == '-') return -getint(); if (!~c) exit(0); } do { x = (x << 3) + (x << 1) + (c - '0'); } while (((c = gc()) - '0') < 10); return x; }
int getstr(char *s) { int c, n = 0; while ((c = gc()) <= ' ') { if (!~c) exit(0); } do { s[n++] = c; } while ((c = gc()) > ' ' ); s[n] = 0; return n; }
template<class T> inline bool chmin(T &a, T b) { return a > b ? a = b, 1 : 0; }
template<class T> inline bool chmax(T &a, T b) { return a < b ? a = b, 1 : 0; }

int n, k;
int dislikes[10];
int digits[20];
int res[20];
int done;

void solve(int d, int bigger, int non_leading_zero) {
    if (done) return;
    if (d < 0) {
        done = 1;
        return;
    }
    for (int k = 0; k < 10; ++k) {
        if (dislikes[k]) {
            if (k != 0 || non_leading_zero) continue;
        }
        if (bigger) {
            res[d] = k;
            solve(d - 1, bigger, non_leading_zero || k);
            if (done) return;
        } else {
            if (k == digits[d]) {
                res[d] = k;
                solve(d - 1, 0, non_leading_zero || k);
                if (done) return;
            } else if (k > digits[d]) {
                res[d] = k;
                solve(d - 1, 1, non_leading_zero || k);
                if (done) return;
            }
        }
    }
}

int main () {
    int i, j;
    n = getint(), k = getint();
    for (i = 0; i < k; ++i) dislikes[getint()] = 1;
    for (i = 0; ; ++i) {
        if (!n) break;
        digits[i] = n % 10, n /= 10;
    }
    solve(18, 0, 0);
    int on = 0;
    for (i = 18; ~i; --i) {
        if (on) cout << res[i];
        else if (res[i]) {
            on = 1, cout << res[i];
        }
    }
    puts("");
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split()) # 入力が複数
# [int(i) for i in input().split()] # 配列で数字
# seg or imos 違った。
req = []
for _ in range(m):
    a, b = map(int, input().split())
    req.append((a, b))
req.sort(key=lambda x: x[1])
ans = 0
pre = 0
for a, b in req:
    if a >= pre:
        ans += 1
        pre = b
print(ans)

Measured memory_bytes: 56792
#include <bits/stdc++.h>
using namespace std;
#define ll                  long long
#define ld                  long double
#define pb                  push_back
#define mkp                 make_pair
#define f(i,l,h)            for(ll i=l;i<h;i++)
#define fr(i,h,l)           for(ll i=h;i>=l;i--)
#define mem(a,val)          memset(a,val,sizeof(a))
#define all(v)              (v).begin(),(v).end()
#define ff                  first
#define ss                  second
#define spc(x)              cout<<fixed<<setprecision((x));
#define deb(x)              cout<<#x<<" "<<x<<endl;
#define deba(x)             cout<<#x<<": "; for(auto u:x) cout<<u<<" ";  cout<<endl;
#define check               cout<<"hello"<<endl;
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
const ld pi=3.141592653589793;
const ll mod=998244353;
const ll INF=(ll)(1e9+7);
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

ll power(ll a,ll b){
    ll res=1;
	while(b){
	    if(b&1) res=(res*a);
	    a=(a*a);
	    b>>=1;
	}
	return res;
}

int main()
{
    //cout << "Hello world!" << endl;
    ll t;
    t=1ll;
    while(t--){
        ll n;
        cin>>n;
        ll temp1=n/1000;
        ll temp2=n%1000;
        if(temp2==0){
            cout<<"0"<<endl;
            continue;
        }
        cout<<(temp1+1)*1000-n<<endl;
    }
    return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>
int main(void){
	
	int a,b,c= 0;
	
	scanf("%d %d %d",&a, &b, &c);
	if((a<b)&&(b<c)){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16

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

ll N,M;
ll p[3001*3001 + 1];
ll f[3001],finv[3001];
ll S[3001][3001];

ll comb(ll n,ll r,ll mod){
  if(n<0||r<0||n<r)return 0;
  else return (f[n]*finv[n-r]%mod)*finv[r]%mod;
}

int main(){
  cin>>N>>M;
  f[0]=1;
  rep(i,3000)f[i+1]=f[i]*(i+1)%M;
  rep(i,3001)finv[i]=mod_pow(f[i],M-2,M);
  p[0]=1;
  rep(i,3001*3001)p[i+1]=p[i]*2%M;
  S[0][0]=1;
  for(int i=1;i<=3000;i++){
    for(int j=1;j<=i;j++)S[i][j]=(S[i-1][j-1]+j*S[i-1][j])%M;
  }

  ll res=0;
  rep(i,N+1){
    ll crt=0;
    rep(j,i+1){
      (crt+=S[i][j]*p[(N-i)*j]%M)%=M;
      (crt+=(S[i][j+1]*(j+1)%M)*p[(N-i)*j]%M)%=M;
    }
    (crt*=comb(N,i,M))%=M;
    (crt*=mod_pow(2,mod_pow(2,N-i,M-1),M))%=M;

    if(i%2==0)(res+=crt)%=M;
    else (res+=M-crt)%=M;
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 139392
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

int main(void){
    int n;
    scanf("%d",&n);
    int ans=2*n;
    char s[n],t[n];
    bool wrong=false;
    scanf("%s%s",s,t);
    for (int i=0; i<n; i++){
        if (t[0]==s[i]){
            for (int j=0; j<n-i-1; j++){
                if (t[0+j]==s[i+j]){
                } else {
                    wrong=true;
                    break;
                }
            }
            if (wrong==false){
                ans=n+i;
                break;
            }
            wrong=false;
        }
    }
    printf("%d\n",ans);
	return 0 ;
}

Measured memory_bytes: 128
// ALDS1_10_A
#include <iostream>
#include <vector>
using namespace std;

int main(){
	int n;
	vector<int> fib;

	cin>>n;
	for(int i=0;i<=n;i++){
		if(i <= 1)
			fib.push_back(1);
		else
			fib.push_back(fib[i-1]+fib[i-2]);
	}
	
	cout<<fib[n]<<endl;

	return 0;
}

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

int main(){
    int ans = 0;
    int n; cin >> n;
    vector<int> d(n);
    for(int i = 0; i < n; ++i) cin >> d[i];
    for(int i = 0; i < n-1; ++i){
        for(int j = i + 1; j < n; ++j){
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
}

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

char s[100010];

int main(){
	int n, a, b;
	scanf("%d%d%d%s", &n, &a, &b, s);
	int passed = 0, os = 1;
	int mx = a + b;
	for(int i = 0; i < n; i++) {
		if(s[i] == 'a') {
			if(passed < mx) {
				printf("Yes\n");
				passed++;
			} else printf("No\n");
		}else if(s[i] == 'b') {
			if(passed < mx && os <= b) {
				printf("Yes\n");
				passed++; os++;
			} else printf("No\n");
		}else{
			printf("No\n");
		}
	}
}


Measured memory_bytes: 768
<?php
// define('DEBUG', true);
define('DEBUG', false);

fscanf(STDIN, "%d", $N);

$answer = 0;
for ($i = 1; $i <= $N; $i += 2) {
	if (solve($i) === true) {
		$answer++;
	}
}
echo $answer;

function solve($num) {
	$array = array();
	for ($i = 1; $i <= sqrt($num); $i++) {
		if ($num % $i === 0) {
			$pair = $num / $i;

			$array[] = $i;
			if ($i != $pair) {
				$array[] = $pair;
			}

		}
	}
	if (DEBUG) {
		if (count($array) === 8) {
			var_dump($array);
		}
	}
	return count($array) === 8;
}

Measured memory_bytes: 4728
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    	
    	Scanner sc = new Scanner(System.in);
        int i, j, k;
        int sum = 0;
        
        while(true) {
            String alphabet = sc.next();
            
            if(alphabet.equals("-")) break;
            int m = sc.nextInt();
            
            for(i = 0; i < m; i++) {
                int h = sc.nextInt();
                alphabet = alphabet.substring(h) + alphabet.substring(0, h);
            }
            System.out.println(alphabet);
        }
    }
}



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

namespace HABIT{
    #define f(a,b,c,d) for(register int a=b,c=d;a<=c;a++)
    #define g(a,b,c,d) for(register int a=b,c=d;a>=c;a--)
    #define LOCAL
    typedef int i32;
    typedef unsigned int u32;
    typedef long long int i64;
    typedef unsigned long long int u64;
    typedef pair<i32,i32> pii;
    const i32 MAXN=1024;
    typedef i32 ar[MAXN];
    
    template<typename T> inline T Max(T a) { return a; }
    template<typename T,typename... Args> inline T Max(T a,Args... args){
        T b=Max(args...);
        return (a>b)?a:b;
    }
    template<typename T> inline T Min(T a) { return a; }
    template<typename T,typename... Args> inline T Min(T a,Args... args){
        T b=Min(args...);
        return (a<b)?a:b;
    }

    #ifdef LOCAL
        inline char gc() { return getchar(); }
    #else
        inline char gc() {
            static char s[1<<20|1]={0},*p1=s,*p2=s;
            return (p1==p2)&&(p2=(p1=s)+fread(s,1,1<<20,stdin),p1==p2)?EOF:*(p1++);
        }
    #endif
    inline i64 read(){
        register i64 ans=0;register char c=gc();register bool neg=0;
        while(c<48||c>57) neg^=!(c^'-'),c=gc();
        while(c>=48&&c<=57) ans=(ans<<3)+(ans<<1)+(c^48),c=gc();
        return neg?-ans:ans;
    }

    char Output_Ans[1<<20|1],*Output_Cur=Output_Ans;
    inline void output() { Output_Cur-=fwrite(Output_Ans,1,Output_Cur-Output_Ans,stdout); }
    inline void print(char c){
        if(Output_Cur-Output_Ans+1>>20) output();
        *(Output_Cur++)=c;
    }
    inline void print(char *s) { while(*s) print( *(s++) ); }
    inline void print(u64 x){
        if(!x) { print('0'); return ; }
        char buf[30]={0},*p=buf+28;
        while(x) *(p--)=x%10+48,x/=10;
        print(p+1);
    }
    inline void print(u32 x) { print( (u64)x ); }
    inline void print(i64 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
    inline void print(i32 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
}
using namespace HABIT;

int main(){
    i32 A=read(),B=read(),C=read(),D=read();
    while(A>0&&B>0){
        C-=B;
        if(C<=0)
            break;
        A-=D;
    }
    if(A<=0) print("No");
    else print("Yes");
    output();
    return 0;
}

Measured memory_bytes: 3676
#pragma GCC optimize("Ofast")
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <iterator>
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <regex>
#include <unordered_set>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <cassert>
#include <time.h>
#include <numeric>
#include <complex>
 
using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
 
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next next
#define sz(x) ((int)x.size())
 
template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }
 
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int mod = 1000000007;
 
 
#define FILENAME ""
 
const ll MAXN = 100002;

                        
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
    //freopen("sum2.in", "r", stdin);
    //freopen("sum2.out", "w", stdout);
	ll n;
	cin >> n;
	vector <ll> a, b;
	for (int i = 0; i < n; i++) {
	 	ll x;
	 	cin >> x;
	 	a.pb(x);
    }  
    for (int i = 0; i < n; i++) {
    	ll x;
    	cin >> x;
    	b.pb(x);
    }
    vector <ll> c;
    for (int i = 1; i <= n; i++) {
     	c.pb(i);
	}
	ll ans1 = 0, ans2 = 0;
	ll r = 0;
	do {
		if (c == a) ans1 = r;
		if (c == b) ans2 = r;
		++r;	 	
	} while (next_permutation(all(c)));
	cout << abs(ans1 - ans2);
    re 0;
}

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

using namespace std;

int main() {
	int N;
	cin >> N;
	
	int count = 0;
	for (int i = 1; i <= N; i++) {
		string s = to_string(i);
		if (s.length() % 2 == 1) {
			count++;
		}
	}
	
	cout << count << endl;
	
}


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

namespace competitive_programming
{
    class Program
    {
        static void Main(string[] args)
        {
            var main = new Program();
            main.solve();
        }

        void solve()
        {
            long n = int.Parse(Console.ReadLine());
            long sum = 0;

            for (long i = 1; i <= n; i++)
            {
                if (i % 3 != 0 && i % 5 != 0)
                {
                    sum += i;
                }
            }
            Console.WriteLine(sum);
        }

        public static long Gcd(long a, long b)
        {
            Func<long, long, long> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
    }

    struct Vector2
    {
        public Vector2(long x, long y)
        {
            this.x = x;
            this.y = y;
        }
        public long x;
        public long y;
    }

    struct Vector3
    {
        public int x;
        public int y;
        public int z;
    }
}


Measured memory_bytes: 17640
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        boolean first=true;
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = br.readLine()) != null) {
            	String[] str=line.split(" ");
            	int x=Integer.parseInt(str[0]);
            	int y=Integer.parseInt(str[1]);

            	if(x==0&&y==0){
            		break;
            	}
            	for(int i=0;i<x;i++){
            		for(int j=0;j<y;j++){
            			System.out.print("#");
            		}
            		System.out.println();
            	}
            	System.out.println();
            }
        }
    }

}

Measured memory_bytes: 30568
N=int(input())
A=list(map(int,input().split()))
B=[abs(x) for x in A]
ct=0
for i in range(N):
  if A[i]!=B[i]:
    ct+=1
B.sort()
if B[0]==0 or ct%2==0:
  print(sum(B))
else:
  B[0]*=(-1)
  print(sum(B))

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

int main(){
    
    int N;
    string s;
    cin >> N >> s;
    
    long int r=0,g=0,b=0;
    
    for(int i=0; i<N; i++){
        if(s.at(i)=='R')
            r++;
        else if(s.at(i)=='G')
            g++;
        
    }
    b = N - r - g;
    
    long int ans =0;
    ans = r*g*b;
    
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N && 2*j-i < N; j++){
            if(s.at(i)!=s.at(j) && s.at(i)!= s.at(2*j-i) && s.at(j)!= s.at(2*j-i))
                ans--;
        }
    }
    
    
    
    cout << ans << endl;
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 3620
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {   
                string[] s = Console.ReadLine().Split();
                int h = int.Parse(s[0]);
                int w = int.Parse(s[1]);

                if (h == 0 && w == 0)
                {
                    break;
                }
                for (int i = 0; i < h; i++)
                {
                    Console.Write("#");
                    for (int j = 0; j < w-2; j++)
                       {
                           if((i == 0) || (i == h - 1))
                           {
                               Console.Write("#");
                           }else
                           {
                               Console.Write(".");
                           }
                       }
                    Console.Write("#");
                    Console.WriteLine("");
                }
                Console.WriteLine("");
            }
        }
    }
}

Measured memory_bytes: 8800
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int sx,sy,tx,ty;

int main(){
    cin>>sx>>sy>>tx>>ty;
    int y=ty-sy;
    int x=tx-sx;
    rep(i,y)printf("U");
    rep(i,x)printf("R");
    rep(i,y)printf("D");
    rep(i,x+1)printf("L");
    rep(i,y+1)printf("U");
    rep(i,x+1)printf("R");
    printf("D");
    printf("R");
    rep(i,y+1)printf("D");
    rep(i,x+1)printf("L");
    printf("U");
    out("");





}


Measured memory_bytes: 256
from collections import deque

s_a = deque(list(input()))
s_b = deque(list(input()))
s_c = deque(list(input()))

next_player = s_a.popleft()
while(len(s_a) >= 0 and len(s_b) >= 0 and len(s_c) >= 0):
    if next_player == 'a':
        if len(s_a) == 0:
            print('A')
            exit()
        next_player = s_a.popleft()
    if next_player == 'b':
        if len(s_b) == 0:
            print('B')
            exit()
        next_player = s_b.popleft()
    if next_player == 'c':
        if len(s_c) == 0:
            print('C')
            exit()
        next_player = s_c.popleft()



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

#define PI acos(-1)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define endl '\n'
#define io  ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define file freopen ("maxflow.in", "r", stdin),freopen ("maxflow.out", "w", stdout);
#define all(v) ((v).begin()), ((v).end())

using namespace std;

typedef pair<int, int> pii;

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

int n, k;

int main() {
//#ifndef ONLINE_JUDGE
//freopen ("in.txt", "r", stdin);
//#endif

  cin >> n >> k;
  int g = 0, good = 0, mx = 0;
  for(int i = 0; i < n; i++) {
    int t;
    cin >> t;
    good |= t == k;
    mx = max(mx, t);
    g = __gcd(g, t);
  }
  if((k % g == 0 && k <= mx) || good) {
    cout << "POSSIBLE\n";
  }else {
    cout << "IMPOSSIBLE\n";
  }
  return 0;
}

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

int main() {
    int a,b;
    cin >> a >> b;
    if(((a%2 == 0) && (b%2 == 0))||(a&1 == 1 && b&1 == 1))
    {
        int c = max(a,b)-min(a,b);
        int d = min(a,b) + (c>>1);
        cout << d << endl;
    }
    else
    {
        cout << "IMPOSSIBLE"<<endl;
    }
    
}

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

int main (){
    int64_t N, i, j, num = 0;

    cin >> N;
    vector<string> str(N);
    for(i = 0; i < N; i++){
        cin >> str[i];
        sort(str[i].begin(), str[i].end());
    }
    sort(str.begin(), str.end());
    for(i = 0; i < N - 1; i++){
        j = i;
        while(j < N - 1){
            if(str[i] == str[j+1]){
                j++;
                continue;
            }
            break;
        }
        num += (j - i) * (j - i + 1) / 2;
        i = j;
    }
    cout << num << endl;
}

Measured memory_bytes: 9344
#include <iostream>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	int N, M; cin >> N >> M;
	int B[200000];
	rep(i, 0, N) {
		B[i] = 0;
	}
	rep(i, 0, M) {
		int a, b; cin >> a >> b;
		if (a == 1) {
			B[b]++;
		}
		else if (b == 1) {
			B[a]++;
		}
		else if (a == N) {
			B[b]++;
		}
		else if (b == N) {
			B[a]++;
		}
	}
	rep(i, 0, N) {
		if (B[i] >= 2)
		{
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int d,t,s;
    while(cin>>d>>t>>s)
    {
        double ans = (1.0*d)/(1.0*s);
        if(ans<= (1.0*t))
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3616
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int a, b;
  cin >> a >> b;
  if(a > 9 || b > 9){
      cout << -1 << endl;
  }else{
      cout << a * b << endl;
  }
  return 0;
}



Measured memory_bytes: 256
<?php

$stdins = [];
while($line=fgets(STDIN)){
    $stdins[] = trim($line);
}

$S = $stdins[0];
$aji = ($S[0] === 'o')?1:0;
$cha = ($S[1] === 'o')?1:0;
$neg = ($S[2] === 'o')?1:0;

$price = 700 + 100*$aji + 100*$cha + 100*$neg;
print("{$price}\n");


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

int main(){
	int a,b,c;
	int ans;
	bool flg;
	int cnt=-1;
	
	while(cin>>a>>b){
		cnt++;flg=false;
		//-----test-----
		if(cnt==104) break;
		//--------------
		c=a+b;
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_3_D&lang=jp

#include<iostream>
 using namespace std;

int main(){

    int a , b ;
    int d , r ;
    double da , db, f ;
    cin >> a >> b ;

    da = a ;
    db = b ;

    cout << fixed ;
    cout<< a / b << " " << a % b << " " << da / db << endl ;  
    return 0;

}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<string,int> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF "~"

int n,m,s,t;
vector<P> g[44];
string d[44][500];

int main(){
	cin.sync_with_stdio(false);
  while(1){
    cin>>n>>m>>s>>t;
    if(n==0)break;
    rep(i,44)g[i].clear();
    rep(i,m){
      int a,b;
      string ss;
      cin>>a>>b>>ss;
      g[a].pb(P(ss,b));
    }
    rep(i,44)rep(j,500)d[i][j]=INF;
    d[s][0]="";
    rep(j,500)rep(i,n){
      rep(k,g[i].size()){
        P p=g[i][k];
        if(p.fi.length()+j<500){
          minch(d[p.se][j+p.fi.length()],d[i][j]+p.fi);
        }
      }
    }
    string res=INF;
    repl(j,1,401){
      minch(res,d[t][j]);
    }
    bool ok=true;
    repl(j,401,500){
      if(d[t][j]<res)ok=false;
    }
    if(res!=INF&&ok)cout<<res<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 12664
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;
typedef long long ll;
#define ip(arr, n) for(int i=0; i<n; i++) cin>>arr[i];
#define op(arr, n) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
#define fstIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MAX 100005
#define Inf 1000000000005

ll n,k;
ll arr[MAX], dp[MAX]={0};

void bottomUp(){
    dp[0]=0;
    for(int i=0; i<n; i++){
        for(int j=1; j<=k; j++){
            if(i+j<n) dp[i+j] = min(dp[i+j], dp[i]+abs(arr[i]-arr[i+j]));
        }
    }
    cout<<dp[n-1]<<endl;
}

int main(){
    cin>>n>>k;
    ip(arr, n);
    for(int i=0; i<n+5; i++) dp[i]=Inf;
    bottomUp();
    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#include <limits>
#define rep(i,n) for (int i=0; i<n;++i)
using namespace std;
typedef long long ll;
const int INF = 1e9;
int H, W, d[10][10];

void warshall_floyd() {
  rep(k, 10){
    rep(i, 10){
      rep(j, 10) d[i][j] =min(d[i][j], d[i][k]+d[k][j]);
    }
  }
}

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

  cin >> H >> W;
  rep(i, 10){
    rep(j, 10) cin >> d[i][j];
  }

  warshall_floyd();
  int sm = 0;
  rep(i, H){
    rep(j, W) {
      int a;
      cin >> a;
      if (a<0) continue;
      sm += d[a][1];
    }
  }
  cout << sm << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    const double pi = acos(-1);
    double atheta =  pi / 2 - (pi * h / 6 + pi * m / 360);
    double btheta =  pi / 2 - (pi * m / 30);
    
    cout << fixed << setprecision(15) << sqrt(a*a + b*b - 2*a*b*cos(atheta - btheta)) << endl;

    // double ax = a * cos(atheta), ay = a * sin(atheta);
    // double bx = b * cos(btheta), by = b * sin(btheta);
    // double ans = hypot(ax - bx, ay - by);
    // cout << fixed << setprecision(15) << ans << endl;

}

Measured memory_bytes: 4184
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define DIVCEIL(A,B) ((A+(B-1))/B)
using namespace std;


void solve(long long X){
    long long acc=0;
    long long t=0;
    while(acc < X){
        t++;
        acc += t;
    }
    cout << t << endl;
}

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


Measured memory_bytes: 256
#include<iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
using namespace std;

int main(){
    char a[1002];
    int b;
    int c=0;
    int len;
    int i;
    
    for (;;){
        fgets(a,1002,stdin);
        if ((int)(a[0]-'0')==0)break;
        len = strlen(a);
        
        for (i=0;i<len-1;i++){
            b=(int)(a[i]-'0');
            c = c + b;
        }
       cout << c << endl;
       c=0;
    }
    
    return 0;
}

Measured memory_bytes: 3068
//#include <bits/stdc++.h>
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
#include <cctype>
#include <fstream>   // ifstream, ofstream
#include <sstream>   // istringstream
using namespace std;
using ll = long long;
const int mod = 1000000007;
 
ll gcd(ll a, ll b){return b ? gcd(b,a%b) : a;};//最大公約数
ll lcm(ll a, ll b){return a*b/gcd(a,b);};//最小公倍数
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
typedef pair<string,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
//ll a[100000];
//ll dom[100001];
 
int main(){
  int a,b;
  cin>>a>>b;
  double xa,xb;
  xa=100*a/8.0;
  xb=100*b/10;
  int cb,ca,c;
  c=100*a/8;
  ca=100*a/8;
  if(xa-(double)ca>0)ca++;
  int p=(a+1)*100/8;
  int q=(a+1)*100%8;
  if(q>0) p++;
  for(int i=ca;i<p;i++){
    if(i*10/100==b){
      cout<<i;
      return 0;
    }
  }
  cout<<"-1";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long N,A,B,n;
  cin >> N >> A >> B;
  n = N/(A+B);
  if(N%(A+B)<=A){
    cout << n*A + N%(A+B) << endl;
  }else{
    cout << (n+1)*A;
  }
  return 0;
}

Measured memory_bytes: 256
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let mut X=read::<usize>();
    let mut Y=read::<usize>();
    let mut x=0;
    let mut y=0;
    let n=read::<usize>();
    for i in 0..n{
        let a=read::<usize>();
        let b=read::<usize>();
        let c=read::<usize>();
        if c==1&&x<a{x=a}
        if c==2&&X>a{X=a}
        if c==3&&y<b{y=b}
        if c==4&&Y>b{Y=b}
    }
    println!("{}",(if x<X{X-x}else{0})*(if y<Y{Y-y}else{0}))
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <cassert>
using namespace std;

//common
typedef long long ll;

#define BR "\n"
#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

//config
//#undef NDEBUG
//#define INF 1<<30
//#define EPS 1e-8
//const ll MOD =100000007;

//debug
#ifdef NDEBUG
#define DUMP(x)
#define DUMPLN(x)
#define DEBUG(x)
#define DEBUGLN(x)
#define LINE()
#define LINELN()
#define CHECK(exp,act)
#define STOP(e)
#else
#define DUMP(x)  cerr << #x << " = " << (x)
#define DUMPLN(x)  DUMP(x) <<endl
#define DEBUG(x) DUMP(x) << LINE() << " " << __FILE__
#define DEBUGLN(x) DEBUG(x)<<endl
#define LINE()    cerr<< " (L" << __LINE__ << ")"
#define LINELN()    LINE()<<endl
#define CHECK(exp,act)  if(exp!=act){DUMPLN(exp);DEBUGLN(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}

template<class T> inline string toString(const vector<vector<T> >& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

//ind -> V から V->ind (注:単射)
template<typename T>
map<T,int> rev(const vector<T>& xs){
	map<T,int> rev;
	REP(i,(int)xs.size())rev.insert(make_pair(xs[i],i));
	return rev;
}

template<typename T,typename V> inline T mod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}



int main(){
	while(true){
		int n,d;cin >> n >> d;
		if(n==0)break;
		vector<vector<int> > cs(n);
		vector<int> sum(n);
		REP(i,n){
			int m;cin >> m;
			REP(j,m){
				int c;cin >>c;
				cs[i].push_back(c);
				sum[i]+=c;
			}
		}
		vector<int> ps(n);
		REP(i,ps.size()){
			ps[i]=cs[i].size()-1;
		}

		bool ok=true;
		//高々100000*100
		while(true){
			int mv=0;REP(i,n)mv=max(mv,sum[i]);
			if(mv==0)break;
			bool change=false;
			REP(i,n){
				if(ps[i]==-1)continue;
				sum[i]-=cs[i][ps[i]];
				mv=0;REP(j,n)mv=max(mv,sum[j]);
				if(abs(mv-sum[i])<=d){
					ps[i]--;change=true;
				}else{
					sum[i]+=cs[i][ps[i]];
				}
			}
			if(!change){
				ok=false;break;
			}
		}
		cout <<(ok?"Yes":"No")<<endl;
	}
	return 0;
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 
ll dp[2][100010];
int main() {
	string s;
	cin>>s;
	dp[0][0]=1;
	for(ll i=0;i<s.size();i++){
		if(s[i]=='1'){
			dp[0][i+1]+=2*dp[0][i];
			dp[1][i+1]+=3*dp[1][i]+dp[0][i];
		}
		if(s[i]=='0'){
			dp[0][i+1]+=dp[0][i];
			dp[1][i+1]+=3*dp[1][i];
		}
		dp[0][i+1]%=inf;
		dp[1][i+1]%=inf;
	}
	cout << (dp[0][s.size()]+dp[1][s.size()])%inf;
	// your code goes here
	return 0;
}

Measured memory_bytes: 5272