akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(){
  int n,x;
  cin >> n>>x;
  int l[n+1];
  l[0]=0;
  for(int i=1; i<=n;i++) cin >> l[i];
  int ans=1;
  int pre=0;
  for(int i=2;i<=n+1;i++){
    if(pre+l[i-1]<=x) {
    //  cout << pre+l[i-1] << endl;
      ans++;
    }
    pre+=l[i-1];
   // cout << pre << " " << l[i-1] << " " << ans << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def actual(a, b):
    towers = [1]
    for x in range(2, 999 + 1):
        towers.append(towers[-1] + x)

    for i in range(len(towers)):
        west_tower_height = towers[i]
        east_tower_height = towers[i + 1]

        assert east_tower_height > west_tower_height

        diff = east_tower_height - west_tower_height

        if diff == (b - a):
            return east_tower_height - b

a, b = map(int, input().split())
print(actual(a, b))

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

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

int main() {
  ll N;cin>>N;
  vector<int> ps(N);
  int ans = 0;
  int tmp = 0;
  REP(i,N) {
    int p;cin>>p;
    if (p==i+1) {
      tmp++;
    } else {
      ans += (tmp+1)/2;
      tmp = 0;
    }
  }
  if (tmp!=0) ans += (tmp+1)/2;
  OUT(ans);

  return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(void){
  int n,a,min;
  int count;
  cin >> n;
  
  cin >> a;
  count = 0;
  while(a%2 == 0){
    count++;
    a = a/2;
  }
  min = count;
  
  for(int i = 1 ; i < n ; i++){
    cin >> a;
    count = 0;
    while(a%2 == 0){
      count++;
      a = a/2;
    }
    if(min > count) min = count;
  }
  
  cout << min << endl;
  
  return 0;
}

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

using namespace std;
int main(){
    //freopen("output.txt","w",stdout);
    int n;
    cin >> n;
    for(int j=n;j<=999;j++){
        int i = j;
        int a = i%10;
        i -= (i%10);
        i /= 10;
        int b = i%10;
        i -= (i%10);
        i /= 10;
        int c = i%10;
        if(a==b && b==c){
            cout << a << a << a << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


# MOD = 998244353


def mod_invs(max, mod):
    """
    逆元 0, 1/1, 1/2, 1/3, ..., 1/max
    :param int max:
    :param int mod:
    """
    invs = [1] * (max + 1)
    invs[0] = 0
    for x in range(2, max + 1):
        invs[x] = (-(mod // x) * invs[mod % x]) % mod
    return invs


def factorial_invs(max, mod):
    """
    階乗 0!, 1!, 2!, ..., max! の逆元
    :param int max:
    :param int mod:
    """
    ret = [1]
    r = 1
    for inv in mod_invs(max, mod)[1:]:
        r = r * inv % mod
        ret.append(r)
    return ret


def get_factorials(max, mod=None):
    """
    階乗 0!, 1!, 2!, ..., max!
    :param int max:
    :param int mod:
    """
    ret = [1]
    n = 1
    if mod:
        for i in range(1, max + 1):
            n *= i
            n %= mod
            ret.append(n)
    else:
        for i in range(1, max + 1):
            n *= i
            ret.append(n)
    return ret


class Combination:
    def __init__(self, max, mod):
        """
        :param int max:
        :param int mod: 3 以上の素数であること
        """
        self._factorials = get_factorials(max, mod)
        self._finvs = factorial_invs(max, mod)
        self._mod = mod

    def ncr(self, n, r):
        """
        :param int n:
        :param int r:
        :rtype: int
        """
        if n < r:
            return 0
        return self._factorials[n] * self._finvs[r] % self._mod * self._finvs[n - r] % self._mod


R1, C1, R2, C2 = list(map(int, sys.stdin.buffer.readline().split()))

comb = Combination(max=10 ** 6 * 2 + 100, mod=MOD)


# 解説
# ある要素に注目して残りを選ぶ数を数えると分かる
# ncr(n, r) == ncr(n-1,r) + (n-1,r-1)
# nhr(n, r) == sum([nhr(n-1,k) for k in range(r)])

# g(r, c) を f(i, j) (0<=i<=r, 0<=j<=c) の総和とすると
# g(R2, C2) - g(R1-1, C2) - g(R2, C1-1) + g(R1-1, C1-1)

def f(n, r):
    return comb.ncr(n + r, r)


# @debug
def g(r, c):
    # ret = 0
    # for i in range(1, c + 2):
    #     ret += f(r, i)
    #     ret %= MOD

    # f(r,k) (k=[1,c+1]) の和
    return f(r + 1, c + 1) - f(r, 0)


ans = g(R2, C2) - g(R1 - 1, C2) - g(R2, C1 - 1) + g(R1 - 1, C1 - 1)
ans %= MOD
print(ans)


Measured memory_bytes: 258584
val = input()
val = [int(x.strip()) for x in val.split(" ")]
h = val[0]
w = val[1]

s = [[0]*w]*h
for i in range(h):
    s[i] = input()

ans = "Yes"

for i in range(h):
    for j in range(w):
        d = 0
        if s[i][j] == ".":
            continue

        if i > 0:
            if s[i-1][j] == "#":
                d += 1

        if i < h-1:
            if s[i+1][j] == "#":
                d += 1

        if j > 0:
            if s[i][j-1] == "#":
                d += 1

        if j < w-1:
            if s[i][j+1] == "#":
                d += 1
        
        if d == 0:
            ans = "No"
            break
    if ans == "No":
        break

print(ans)


Measured memory_bytes: 3064
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;

int main(){
	string s;
  cin >> s;
  int n = s.length();
	int ans = n;
  for(int i = 1; i < n; i++){
		if(s[i]!=s[i-1]){
			if(max(i,n-i)<ans) ans = max(i,n-i);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 512
import math

def prime_number(num):
    if num == 1:
        return False

    for i in range(2, int(math.sqrt(num))+1):
        if num % i == 0:
            return False

    return True

count = 0
n = int(input().rstrip())
for i in range(n):
    num = int(input().rstrip())
    judge = prime_number(num)
    if judge == True:
        count += 1

print(count)


Measured memory_bytes: 5672
s = int(input())

i = 0

alist = [s]

while 1:
    i += 1

    if alist[i-1] % 2 == 0:
        atmp = alist[i-1] / 2
    
    elif alist[i-1] % 2 == 1:
        atmp = alist[i-1]*3 + 1

    alist.append(atmp)

    if len(alist) != len(set(alist)):
        print(i+1)
        break

Measured memory_bytes: 3060
program main
  implicit none
  character(100) :: s, t
  read(*, *) s, t
  if (sorted(trim(s), .false.) <sorted(trim(t), .true.)) then
    write(*, "(a)") "Yes"
  else
    write(*, "(a)") "No"
  end if
  contains

  function sorted(s, reverse)
    implicit none
    character(*), intent(in) :: s
    logical, intent(in) :: reverse
    character(len(s)) :: sorted
    integer :: i, j
    sorted = s
    do i = 2, len(s)  ! [1, i] の範囲を昇順に保つ
      do j = i, 2, -1
        if (sorted(j:j) < sorted(j - 1:j - 1) .neqv. reverse) then
          call swap(sorted(j:j), sorted(j - 1:j - 1))
        else
          exit
        end if
      end do
    end do
  end function sorted

  subroutine swap(x, y)
    implicit none
    character(1), intent(inout) :: x, y
    character(1) :: tmp
    tmp = x
    x = y
    y = tmp
  end subroutine swap
end program main


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{  
  int a,b,c,d,as,bs,cs;
  cin >> a >> b >> c >> d;
  as = abs(a - b);
  bs = abs(c - b);
  cs = abs(a - c);
  if(d >= as && d >= bs || d >= cs )cout << "Yes"<< endl;
  else cout << "No" << endl;

  return 0;
}


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

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

ll dp[1000006][2];

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

    string S; cin >> S;

    S += "0";


    for (int i = 0;i < S.size()+4;i++){
        dp[i][0] = dp[i][1] = LLONG_MAX;
    }

    dp[0][0] = 0;

    for (int i = 0;i < S.size();i++){
        if(dp[i][0] != LLONG_MAX){
            dp[i+1][0] = min(dp[i+1][0],dp[i][0]+(S[i]-'0'));
            dp[i+1][1] = min(dp[i+1][1],dp[i][0]+(10-(S[i]-'0')));
        }
        if(dp[i][1] != LLONG_MAX){
            dp[i+1][0] = min(dp[i+1][0],dp[i][1]+(S[i]-'0'+1));
            dp[i+1][1] = min(dp[i+1][1],dp[i][1]+(10-(S[i]-'0'+1)));
        }
    }

    cout << dp[S.size()][0] << endl;

    return 0;

}

Measured memory_bytes: 17052
from sys import stdin, setrecursionlimit
from collections import deque

setrecursionlimit(10 ** 9)
INF = 1 << 60


MOD = 1000000007
N = int(input())
G = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)

pow2 = [1] * (N + 1)
for i in range(N):
    pow2[i + 1] = pow2[i] * 2 % MOD

order = []
parent = [-1] * N

stack = deque([0])
while stack:
    v = stack.pop()
    order.append(v)
    for nv in G[v]:
        if parent[v] != nv:
            parent[nv] = v
            stack.append(nv)

numer = 0
nums = [0] * N

for v in reversed(order):
    tmp = 1
    for nv in G[v]:
        if parent[v] != nv:
            nums[v] += nums[nv] + 1
            tmp += pow2[nums[nv] + 1] - 1
    tmp += pow2[N - nums[v] - 1] - 1
    numer = (numer + pow2[N - 1] - tmp) % MOD

denom = pow2[N]
ans = numer * pow(denom, MOD - 2, MOD) % MOD
print(ans)


Measured memory_bytes: 58092
#include <stdio.h>
#include <stdlib.h>

int main(){
    char S[4];
    scanf("%s", S);
    int max = 0;
    int cnt = 0;
    for (int i = 0; i < 3;i++){
        if(S[i]=='R'){
            cnt++;
        }else{
            max = (max > cnt) ? max : cnt;
            cnt = 0;
        }
    }
    max = (max > cnt) ? max : cnt;
    printf("%d", max);
    return 0;
}

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

int main(){
    long long int n;
    scanf("%lld",&n);
    long long int min=n-1;
    for(int i=1;i<=sqrt(n);i++){
        if(n%i==0 && n/i-2<min) min=i+n/i-2;
    }

    printf("%lld\n",min);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n, h, w;
  cin >> n >> h >> w;
  ll ans = (n - h + 1) * (n - w + 1);
  cout  << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
using namespace std;
 
typedef long long ll;
 
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }
 
template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

template<typename T>
map<T, long long> factorize(T x) {
  map<T, long long> res;
  for (long long i = 2; i * i <= x; ++i) {
    while (x % i == 0) {
      x /= i;
      res[i] += 1;
    }
  }
  if (x != 1) res[x]++;
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  ll n, p;
  cin >> n >> p;

  if (n == 1) {
    cout << p << endl;
    return 0;
  }

  auto f = [](ll t, ll rem) -> ll {
    ll p = 1;
    while (rem > 0) {
      p *= t;
      rem--;
    }

    return p;
  };

  map<ll, ll> fac = factorize(p);
  ll ans = 1;
  for (auto itr : fac) {
    // cout << itr.first << " " << itr.second << " " << itr.first * (itr.second / n) << endl;
    ans *= (itr.second >= n) ? f(itr.first, itr.second / n) : 1;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
struct Edge{
  int src, dst, cost, type;
  Edge(int s, int d, int c, int t):
    src(s), dst(d), cost(c), type(t) {}
  bool operator < (const Edge& e) const {
    if(cost != e.cost) return cost > e.cost;
    return type > e.type;
  }
};
typedef vector<Edge> Node;
typedef vector<Node> Graph;

int main(){
  int N;
  while(cin >> N && N){
    int S, T; cin >> S >> T;
    S--; T--;
    int M;
    cin >> M;
    Graph G(N);
    REP(i, M){
      int A, B;
      cin >> A >> B;
      A--; B--;
      G[A].push_back(Edge(A, B, 1, -1));
      G[B].push_back(Edge(B, A, 1, i));
    }
    Edge start(-1, S, 0, -1);
    priority_queue<Edge> que;
    bool used[1000][1001] = {};
    que.push(start);
    while(!que.empty()){
      Edge s = que.top(); que.pop();
      //printf("%d %d %d\n", s.dst, s.cost, s.type);
      if(s.dst == T){
        cout << s.cost << " " << s.type + 1 << endl;
        break;
      }
      FORIT(e, G[s.dst]){
        Edge next(e->src, e->dst, s.cost + e->cost, e->type);
        //printf("-> %d %d %d\n", next.dst, next.cost, next.type);
        if(next.type != -1 && s.type != -1) continue;
        if(next.type == -1) next.type = s.type;
        if(!used[next.dst][next.type + 1]){
          used[next.dst][next.type + 1] = true;
          que.push(next);
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 2868
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
  int N;
  long long int ans=0;
  vector<int> A(200000);
  cin >> N;
  
  for(int i=0; i<N;i++){
    cin >> A[i];
  }
  for(int i=1; i<N; i++){
    if(A[i-1]>A[i]){
      ans+=A[i-1]-A[i];
      A[i] = A[i-1];
    }
  }
  cout << ans <<'\n';
  return 0;
	
}
  

Measured memory_bytes: 3804
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

#define loop(i,a,b) for(int i=int(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<ll> vl;

int main(){
    int x; cin >> x;
    rep(xx,x){
        int n,y;
        ll init;
        cin >> init >> y >> n;
        vl m(n);

        rep(i,n){
            int type, pay;
            double rate;
            cin >> type >> rate >> pay;
            if(type==0){
                m[i] = init;
                ll interest = 0;
                rep(j,y){
                    interest += m[i] * rate;
                    m[i] -= pay;
                }
                m[i] += interest;
            } else {
                m[i] = init;
                rep(j,y){
                    m[i] *= (rate + 1);
                    m[i] -= pay;
                }
            }
        } 
        cout << *max_element(all(m)) << endl;
    }
}

Measured memory_bytes: 1244
#include <stdio.h>
int isprime(int n);
int main()
{
    int i,n,p1,q1;
    while(1){
        scanf("%d",&n);
        if(n==0) break;
        for(i=n;i>0;i--){
            if(isprime(i)){
                if(isprime(i-2)){
                    p1 = i-2;
                    q1 = i;
                    break;
                }
            }
        }
        printf("%d %d\n" ,p1 ,q1);
    }
    return 0;
}

int isprime(int n) {
    int i;
    if(n<=1)return 0;
    for(i=2;i*i<=n;i++){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <string>
using namespace std;
#define MAX 200000

int main(){
	int N, M;
	vector<int> V1;		//1から行ける所
	vector<bool> V(MAX);		//Nに行ける所
	cin >> N >> M;

	for (int i = 0; i < N; i++) V[i] = false;

	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		if (a == 1) {
			V1.push_back(b);
		}
		else if (b == N) {
			V[a] = true;
		}
	}

	//for (int i = 0; i < N; i++) {
	//	cout << V[i] << endl;
	//}
	
	for (vector<int>::iterator it = V1.begin(); it != V1.end(); it++) {
		int x = *it;
		if (V[x]) {
			cout << "POSSIBLE" << endl;
			break;
		}
		else if (it == V1.end() - 1) cout << "IMPOSSIBLE" << endl;
	}



	return 0;
}

Measured memory_bytes: 896
x,y,p,q=map(int,input().split())
print("U"*(q-y)+"R"*(p-x)+"D"*(q-y)+"L"*(p-x+1)+"U"*(q-y+1)+"R"*(p-x+1)+"D"+"R"+"D"*(q-y+1)+"L"*(p-x+1)+"U")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
const int nax = 1e5;
const int mod = 1e9 + 7;
int main(int argc,char ** argv){
	int n; // n biased coins 
	cin >> n;
	double p;
	vector< double > dp(n + 1);
	dp[0] = 1;
	for(int i = 0 ; i < n ; i++){
		cin >> p;
		for(int j = i + 1 ; j >= 0 ; j--){
			dp[j] = ( j == 0 ? 0 : dp[j - 1] * p ) + dp[j] *(1 - p);
		}
		//cout <<"new probability" <<  dp[0] << endl;
	}
	double ans = 0; 
	for(int i = 0 ; i <= n ; i++){
		//cout << dp[i] << " ";
		if(i > (n - i))
			ans += dp[i];
	}
	//cout << endl;
	cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++ )

int main()
{
  int a, b;
  cin >> a >> b;
  if(a == 1) a += 13;
  if(b == 1) b += 13;
  if(a > b) {
    cout << "Alice" << endl;
  }else if(a < b){
    cout << "Bob" << endl;
  }else{
    cout << "Draw" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void chOut(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;



signed main(){

    int N; cin >> N;
    vec X(N), Y(N), P(N);
    REP(i, N) cin >> X[i] >> Y[i] >> P[i];

    vec cost(bit(N), INF);
    REP(s, bit(N)){
        REP(i, N){
            int tmp = 0;
            REP(j, N) if((s >> j) & 1) tmp += llabs(X[j] - X[i]) * P[j];
            chmin(cost[s], tmp);

            tmp = 0;
            REP(j, N) if((s >> j) & 1) tmp += llabs(Y[j] - Y[i]) * P[j];
            chmin(cost[s], tmp);
        }
    }
    //vdebug(cost);

    mat dp(N + 1, vec(bit(N), INF));
    REP(s, bit(N)){
        int tmp = 0;
        REP(j, N) if((s >> j) & 1) tmp += min(llabs(X[j]), llabs(Y[j])) * P[j];
        dp[0][s] = tmp;
    }

    REP(i, N){
        REP(sup, bit(N)){
            int sub = sup;
            do{
                chmin(dp[i + 1][sup], dp[i][sub] + cost[sup ^ sub]);
                sub = (sub - 1) & sup;
            }while(sub != sup);
        }
    }
    REP(i, N + 1) Out(dp[i][bit(N) - 1]);

    return 0;
}


Measured memory_bytes: 7948
#include<cstdio>
char c[4001],d[4001],*a,*b;int main(){for(int m,o,i,k,s;~scanf("%s%s",c,d);)for(a=c,b=d,k=m=0;k++<2||printf("%d\n",m)&0;a=d,b=c)for(o=0;a[o];o++)for(i=s=0;a[i+o]&&b[i];i++)a[i+o]-b[i]?s=0:m<++s&&(m=s);return 0;}

Measured memory_bytes: 772
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
            int n = sc.nextInt();
            int x = sc.nextInt();
            if(n==0 && x==0) break;
            int count=0;
            for(int i=1; i<=n; i++){
                for(int j=1; i>j; j++){
                    for(int k=1; j>k; k++){
                        if(i+j+k==x) count++;
                    }
                }
            }
            System.out.println(count);

        }
    }
}


Measured memory_bytes: 26628
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORit(it,a) for(auto it=a.begin();it!=a.end();it++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define vec vector
#define pb push_back
#define pop pop_back
#define all(x) x.begin(),x.end()
#define testcases ll t;cin>>t;while(t--)
#define mem(a,k) memset(a,k,sizeof(a))
#define F first
#define S second
#define MP(x,y) make_pair(x,y)
#define rt return
#define br break
#define ct continue
#define elif else if
#define ii pair<ll,ll>
#define arrin(a,n,index) for(int i=index;i<n;i++)cin>>a[i]
#define vecin(a,n,index) for(int i=index;i<n;i++)cin>>a[i]
#define arrout(a,n,index) for(int i=index;i<n;i++)cout<<a[i]<<" ";cout<<endl;
#define vecout(a,n,index) for(int i=index;i<n;i++)cout<<a[i]<<" ";cout<<endl;
//ll mod = 1000000007;
int s[1000001] = {0};
int check[1000001] = {0};
void sieve() {
	int maxn = 1000000;
	for (int i = 1; i <= maxn; i++)s[i] = -1;
	for (int i = 2; i <= maxn; i++) {
		if (s[i] == -1) {
			for (int j = i; j <= maxn; j += i) {
				if (s[j] == -1)s[j] = i;
			}
		}
	}

}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
	// START FROM HERE :)
	sieve();
	int n; cin >> n; int a[n]; arrin(a, n, 0);
	int setg = a[0], flag = 1;
	//bitset <1000001> f[n];
	FOR(i, 1, n)setg = __gcd(setg, a[i]);
	FOR(i, 0, n) {
		while (a[0] != 1) {
			check[s[a[0]]] = 1;
			a[0] /= s[a[0]];
		}
	}
	FOR(i, 1, n) {
		vec <int> v;
		while (a[i] != 1) {
			if (binary_search(all(v), s[a[i]]) == false)v.pb(s[a[i]]);
			a[i] /= s[a[i]];
		}
		FOR(k, 0, v.size()) {
			if (check[v[k]] == 0)check[v[k]] = 1;
			else flag = 0;

		}
		if (flag == 0)br;

	}
	if (flag == 1)cout << "pairwise coprime\n";
	elif(flag == 0 && setg == 1)cout << "setwise coprime\n";
	else cout << "not coprime\n";

}


Measured memory_bytes: 11728
import java.io.*;
import java.math.*;
import java.util.*;
import java.lang.*;

// import java.text.DecimalFormat; 
// import java.text.DecimalFormatSymbols; 
 
public class Main {
    
    public static final long max = (long)1e18+1; 
    
    public static void main(String args[] ) throws Exception {
        StringBuffer str = new StringBuffer();
        PrintWriter pw=new PrintWriter(System.out);
        FastScanner sc = new FastScanner();
        
        int n = sc.nextInt();
        long w = sc.nextLong();
        long[] a = new long[n];
        int[] v = new int[n];
        int su =0;
        for(int i=0;i<n;i++){
            a[i] = sc.nextLong();
            v[i] = sc.nextInt();
            su+=v[i];
        }
        
        long[] dp = new long[su+1];
        Arrays.fill(dp,max);
        dp[0]=0;
        int ans=0;
        for(int i=0;i<n;i++){
            for(int j=su-v[i];j>=0;j--){
                int t = j+v[i];
                if(t>=0)
                    dp[t] = (dp[t]>dp[j]+a[i])?dp[j]+a[i]:dp[t];
            }
        }
        for(int j=0;j<=su;j++){
            if(dp[j]<=w){
                ans = Math.max(ans,j);
            }       
        }
        str.append(ans);
        //deb(Arrays.toString(dp));
        
        pw.println(str.toString());
        
        pw.close();
    }
     
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   public static <T> void deb(T x){
       System.out.println(x);
   }
   
   
   static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		public String next(int k) {
			try {
				return br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return "Not able to read";
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		double nextDouble() {
			return Double.parseDouble(next());
		}
		
	    
	}
   
}

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

int main() {
  int R, G, B, N, count = 0;
  cin >> R >> G >> B >> N;
  
  for (int i = 0; i <= N/R; i++) {
    for (int j = 0; j <= (N-i*R)/G; j++) {
      if ((N-i*R-j*G) % B == 0)
        count++;
    }
  }
  
  cout << count << endl;  
}

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

namespace ABC064C
{
    class Program
    {
        static void Main(string[] args)
        {
            new Solver().Solve();
        }
    }

    class Solver
    {
        static bool[] Color = new bool[8];
        int NumC;
        int HighRates;

        public void Solve()
        {
            int min;
            if (NumC == 0)
            {
                min = 1;
            }
            else
            {
                min = NumC;
            }
            int max = NumC + HighRates;

            Console.WriteLine("{0} {1}", min, max);
        }

        public Solver()
        {
            int N = ReadInt();

            foreach (int a in ReadIntArray())
            {
                if (a < 3200)
                {
                    Color[a / 400] = true;
                }
                else
                {
                    HighRates++;
                }
            }
            NumC = Color.Count(e => e);
        }

        static String ReadString() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static String[] ReadStringArray() { return Console.ReadLine().Split(' '); }
        static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToArray(); }
        static long[] ReadLongArray() { return Console.ReadLine().Split(' ').Select(e => long.Parse(e)).ToArray(); }
        static double[] ReadDoubleArray() { return Console.ReadLine().Split(' ').Select(e => double.Parse(e)).ToArray(); }
    }

}


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

using namespace std;

int main(){
    string S, S1, S2;
    cin >> S;

    S1 = S.substr(0, 2);
    S2 = S.substr(2, 2);

    bool f1, f2;
    f1 = f2 = false;
    if(stoi(S1)>12 || stoi(S1)==0)f1 = true;
    if(stoi(S2)>12 || stoi(S2)==0)f2 = true;

    string outS = "AMBIGUOUS";
    if(f1 && !f2)outS = "YYMM";
    else if(!f1 && f2)outS = "MMYY";
    else if(f1 && f2)outS = "NA";

    cout << outS << endl;
}

Measured memory_bytes: 256
// 各ターンで、各色のリンゴは高々1個までしか減らせない
// リンゴの数が偶数なら、ルンルンは"あなた"が直前に食べた場合に食べるようにすることで、
// かならず最後にその種類のリンゴを食べることができる。
// リンゴの数が1より大きい奇数なら、ルンルンは"あなた"が最初に食べたあと、そのリンゴを食べないようにして、
// あなたのターンが回ってきた時にそのリンゴの数が偶数個になるようにして、あとは偶数個の場合の戦略で、
// 最後にそのリンゴを食べることができる。
// →だれが先にそのリンゴを食べるかによって戦略が変わるのか？
#include <bits/stdc++.h>
using namespace std;

int N;
int a[200000];

int tesuu[310000];

// cur := 現在の手数(1,2,3,...)
void rec(int cur) {
    /*
    for (int i = 0; i < N; ++i) {
        cout << a[i] << " ";
    }
    cout << endl;
    cout << cur << endl;
    */
    bool flg = true;
    for (int i = 0; i < N; ++i) {
        if (a[i] > 0) {
            flg = false;
            break;
        }
    }
    if (flg) {
        // 結果を出力
        cout << "cur: " << cur << endl;

        for (int i = 1; i < cur; ++i) {
            if (i % 2)
                cout << "You  :";
            else
                cout << "LnLn :";
            for (int j = 0; j < N; ++j) {
                if ((tesuu[i] >> j) & 1)
                    cout << 1 << " ";
                else
                    cout << 0 << " ";
            }
            cout << endl;
        }
        if ((cur - 1) % 2)
            cout << "winner: You" << endl;
        else
            cout << "winner: LnLn" << endl;
        cout << endl;
        return;
    }

    for (int bits = 1; bits < (1 << N); ++bits) {
        flg = true;
        for (int i = 0; i < N; ++i) {
            if (((bits >> i) & 1) && a[i] <= 0) {
                flg = false;
                break;
            }
        }
        if (!flg) continue;
        for (int i = 0; i < N; ++i) {
            if ((bits >> i) & 1) --a[i];
        }
        tesuu[cur] = bits;
        rec(cur + 1);
        // 元に戻す
        for (int i = 0; i < N; ++i) {
            if ((bits >> i) & 1) ++a[i];
        }
    }
}

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    //rec(1);
    for(int i = 0; i < N; ++i) {
        if(a[i]%2) {
            cout << "first" << endl;
            return 0;
        }
    }
    cout << "second" << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b >= c)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <iomanip>
#include <cmath>
#include <chrono>

#define vi vector<int>
#define tests int t; cin>>t; while(t--)
#define ll long long
#define vll vector<long long>
#define srt(v) sort(v.begin(), v.end())
#define srtg(v) sort(v.begin(), v.end(), greater<int> ())
#define FOR(k, n) for(int k=0; k<n; k++)



using namespace std;


char nums[10] = { '0','1','2','3','4','5','6','7','8','9' };
char alphsl[26] = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' };
const ll MOD = 1000000007;
char alphs[26] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };


void solve() {

    ll n;
    cin>>n;
    vll dp(n+1, 0);
    dp[0]=0;
    dp[1]=0;
    dp[2]=0;
    dp[3]=1;
    ll sum=0;
    for(int i=4; i<=n; i++){
        sum+=dp[i-3];
        dp[i]=1+sum;
        dp[i]%=MOD;
    }
    cout<<dp[n]<<endl;
}

int main() {

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

    
        solve();


    return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
int n, k, m, mx, a[200003], he[200003];
double ans, x[200003], sum[200003];
string ss, t;

signed main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	cin>>n>>k;
	for (int i = 1; i <= n; i+=1)cin>>a[i],mx = max(mx, a[i]);
	for (int i = 1; i <= mx; i+=1) he[i] = he[i - 1] + i;
	for (int i = 1; i <= n; i+=1)
	{
		x[i] = 1. * he[a[i]] * (1. / a[i]);
	//	printf("%lld %.5lf %.5lf\n", he[a[i]], 1. / a[i], x[i]);
	}
	for (int i = 1; i <= n; i+=1) 
	{
		sum[i] = sum[i - 1] + x[i];
	}
	ans = 0.0;
	for (int i = 1; i + k - 1 <= n; i+=1)
	{
		double kk = sum[i + k - 1] - sum[i - 1];
		//printf("%.5lf %.5lf\n", sum[i + k - 1], sum[i - 1]);
		if (kk > ans) ans = kk;
		//printf("%.5lf %.5lf\n", kk, ans);
	}
	printf("%.10lf\n", ans);
	return 0;
}


Measured memory_bytes: 4992
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;

fn main() {
    input! {
        S: String,
    }

    let mut ans = 0;
    for c in S.chars() {
        let num = (c as u8 - ('0' as u8)) as i32;
        ans = (ans + num) % 9;
    }

    if ans % 9 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


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


void solve(long long X){
    cout << X / 500 * 1000 + ((X % 500) / 5) * 5 << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

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

  cout << min(b / a, c) << endl;

  return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::HashMap;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_variables)]
        #[allow(unused_mut)]
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("parse error")
    };
}

fn main() {
    input!{
        s: chars,
    }
    let a = s.iter().any(|x| *x == '7');
    println!("{}", if a {"Yes"} else {"No"});
}


Measured memory_bytes: 2148
// template.cpp

// Defines.
//#define DEBUG
#define NUMBER_OF_DIGITS 6

// Includes.
#include <bits/stdc++.h>

#ifdef DEBUG
#include <chrono>
#endif

// Usings.
using namespace std;

// Main function.
int main()
{
#ifdef DEBUG
	chrono::system_clock::time_point start, end;
	
	start = chrono::system_clock::now();
#endif
	
	// settings.
	ios::sync_with_stdio(false);
	
	//cout << fixed;
	//cout << setprecision(NUMBER_OF_DIGITS);
	
	// logic.
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	
	int total = 0;
	if ((a + b) >= (2 * c))
	{
		total += (min(x, y) * 2 * c);
		if (x > y)
		{
			if (a > (c * 2))
			{
				total += ((x - y) * 2 * c);
			}
			else
			{
				total += ((x - y) * a);
			}
		}
		else
		{
			if (b > (c * 2))
			{
				total += ((y - x) * 2 * c);
			}
			else
			{
				total += ((y - x) * b);
			}
		}
	}
	else
	{
		total += (a * x);
		total += (b * y);
	}
	
	cout << total << endl;

#ifdef DEBUG
	end = chrono::system_clock::now();
	
	double elapsed = chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
	cout << elapsed << "[ms]" << endl;
#endif
	
	return 0;
}


Measured memory_bytes: 3632
import sys
import math

a,b,h,m=map(int, sys.stdin.readline().rstrip().split())
m_angle = m*6
h_angle = h*30+m/2
theta=abs(h_angle-m_angle)
if theta>180:theta=360-theta
c = a**2+b**2-2*a*b*math.cos(math.radians(theta))
print(c**0.5)

Measured memory_bytes: 9440
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] a=new int[n];
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
		}
		int count=0;
		boolean boo=true;
		for(int i=0;i<n;i++){
			if(a[i]<0)
				count++;
			else if(a[i]==0)
				boo=false;
		}
		long ans=0;
		for(int i=0;i<n;i++){
			if(a[i]<0)
				a[i]=-a[i];
		}
		for(int i=0;i<n;i++){
			ans+=a[i];
		}
		int m=a[0];
		if(count%2!=0&&boo){
			for(int i=1;i<n;i++){
				if(a[i]<m)
					m=a[i];
			}
			ans=ans-2*m;
		}
		System.out.println(ans);
	}
	
}

Measured memory_bytes: 50228
// B - 754
// https://atcoder.jp/contests/abc114/tasks/abc114_b
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const long double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
#define pb push_back
#define eb emplace_back
#pragma GCC optimize("Ofast")
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using P = pair<lli, lli>;
// vector<P> vp;
// vp.emplace_back(a[i], b[i]);
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

bool cmp(int a, int b)
{
  return abs(a - 753) < abs(b - 753);
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = 0, count = 0;
  string s, t;
  cin >> s;
  n = s.size();
  vlli d;
  rep(i, 0, n - 2)
  {
    a = stoi(s.substr(i, 3));
    d.eb(a);
  }
  sort(d.begin(), d.end(), cmp);
  ans = abs(d[0] - 753);
  cout << ans << "\n";
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include<algorithm>
using namespace std;
int bits(long long num)
{
	if (num / 10000000000)
		return 11;
	else if (num / 1000000000)
		return 10;
	else if(num/100000000)
		return 9;
	else if(num/10000000)
		return 8;
	else if (num / 1000000)
		return 7;
	else if (num / 100000)
		return 6;
	else if (num / 10000)
		return 5;
	else if (num / 1000)
		return 4;
	else if (num / 100)
		return 3;
	else if (num / 10)
		return 2;
	else
		return 1;
}
int main()
{
	long long N;
	while (scanf("%lld", &N) != EOF)
	{
		for (long long i = sqrt(N); i > 0; i--)
			if (N % i == 0)
			{
				printf("%d\n", max(bits(i), bits(N / i)));
				break;
			}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
int main(){
    int N,A=0,W=0,T=0,R=0;
    cin>>N;
    for (int a =0;a <N; a++){
        string s;
        cin>>s;
        if (s=="AC") A++;
        else if(s=="WA") W++;
        else if(s=="TLE") T++;
        else if(s=="RE") R++;    
    }
    cout<<"AC x "<<A<<endl;
    cout<<"WA x "<<W<<endl;
    cout<<"TLE x "<<T<<endl;
    cout<<"RE x "<<R<<endl;
   return 0;}

Measured memory_bytes: 3588
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Data.Char

main = do
  arr <- map (read::String -> Int) . words <$> getLine
  let num = foldl1 (\acc val -> acc * 10 + val) arr
  putStrLn $ if num `mod` 4 == 0 then "YES" else "NO"



Measured memory_bytes: 508
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
int main() {
    string s,t;
    std::cin >> s;
    std::cin >> t;
  
	int dp[3010][3010];
    Fill(dp,0);
  
	int s_len = s.length();
    int t_len = t.length();

    for (int i = 0; i < s_len; i++) {
        for (int j = 0; j < t_len; j++) {
            if(s[i] == t[j]){
				dp[i+1][j+1] = dp[i][j]+1;
            }else{
				dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
            }
        }
    }
    
    string result = "";
    int i,j;
    i = s_len;
    j = t_len;
    while(i>=0 && j>=0){
        if(dp[i-1][j] == dp[i][j] ){
            i--;
            continue;
        }
        if(dp[i][j-1] == dp[i][j] ){
            j--;
            continue;
        }
        result = s[i-1]+result;
        i--;
        j--;
    }

    std::cout << result << std::endl;
}   


Measured memory_bytes: 35712
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		double ans = 0;
		if (N%2 == 0) {
			System.out.println("0.5000000000");
		}else {
			double n = (double)N;
			double m = (double)(N-1)/2;
			ans = 1 - m/n;
			System.out.println(ans);
		}

	}
}


Measured memory_bytes: 21716
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

/**
 *
 * @author dkcs
 */
class Main
{
    static class FastReader {
        
        BufferedReader br;
        StringTokenizer st;
        
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    
    static class NodeX {
        
       long a,b;
       NodeX(long x,long y)
       {
           a=x;
           b=y;
       }
    }
    
    static class CompX implements Comparator<NodeX> {
        
        public int compare(NodeX o1, NodeX o2) {
            if (o1.b > o2.b) {
                return 1;
            } else {
                return -1;
            }
        }
    }

    public static void main(String[] args) 
    {
        FastReader sc = new FastReader();
        int n=sc.nextInt();
        PriorityQueue<NodeX> pq=new PriorityQueue(new CompX());
        for(int i=0;i<n;i++)
        {
            long a=sc.nextLong();
            long b=sc.nextLong();
            pq.add(new NodeX(a,b));
        }
        long sum=0;
        while(!pq.isEmpty())
        {
            NodeX t=pq.poll();
            sum=sum+t.a;
            if(sum>t.b)
            {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");           
    }
    
    
}


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

using namespace std;

int main(){
    int A,B,a;
    cin >> A >> B;
    if(A > B){
        a=2*A-1;
    }
    else if(A==B){
        a=A+B;    
    }
    else{
        a=2*B-1;
    }
    cout << a << endl;

    return 0;
}

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

//n / a == b
// n / b == a
int countDivisor(int n){
    int result = 0;
    
    for (int i = 1; i *i <= n; i++){
        if(n % i == 0){
             if (i * i == n) result++; //nが平方数のときだけ注意せよ
        else result += 2; //２つ同時に数えて良い
        }
    }
    return result;
}

int main(){
    int n;
    cin >> n;
    
    int numberOfAns = 0;
    
    for (int i = 1; i <= n; i += 2){
        if (countDivisor(i) == 8) numberOfAns++;
    }
    cout << numberOfAns << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

ll mul(ll x){
    ll sum=1;
    for(int i=1;i<=x;i++){
        sum*=i;
        sum%=mod;
    }
    return sum;
}
int main(){
    ll n,m; cin>>n>>m;
    if(abs(n-m)>1){
        cout<<0<<endl;
        return 0;
    }
    ll ans=mul(n)*mul(m)%mod;
    if(n-m==0){
        ans*=2;
        ans%=mod;
    }
    cout<<ans<<endl;
}








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

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

  int TakasaNoSa = b - a;

  int HontoNoTakasa = 0;
  rep(i, 1, TakasaNoSa) {
    HontoNoTakasa += i;
  }

  cout << HontoNoTakasa - a << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

    long long l[87];
    l[0] = 2;
    l[1] = 1;
    for( int i = 2 ; i < 87 ; ++i ){
        l[i] = l[i-1] + l[i-2];
    }
    int n; cin >> n;
    cout << l[n] << '\n';


}


Measured memory_bytes: 256