akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
using namespace std;



int main() {
    int H,W;
    while (true) {
        cin >> H >> W;
        if (H==0 && W==0) break;
        for (int i=0; i<H; ++i) {
            for (int j=0; j<W; ++j) {
                if (i==0 || i==H-1 || j==0 || j==W-1) {
                    cout << '#';
                }else{
                    cout << '.';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll bg=1234567890123;
#define ff(i,n) for(i=0;i<n;i++)
#define gg1(n1) cin>>n1;
#define gg(n1,n2) cin>>n1>>n2;
#define gg3(n1,n2,n3) cin>>n1>>n2>>n3;
#define hh(n) cout<<n<<endl;
#define t top
#define p push
#define pb push_back
#define mp make_pair
int main()
{
  ll i,n;
  cin>>n;
  ll arr[n],dp[n];
  
  for(i=0;i<n;i++)
  {cin>>arr[i];dp[i]=bg;}
  dp[0]=0;
  for(i=0;i<n;i++)
  {
    if(i+1<n)
       dp[i+1]=min(dp[i+1],dp[i]+abs(arr[i+1]-arr[i]));
    if(i+2<n)
       dp[i+2]=min(dp[i+2],dp[i]+abs(arr[i+2]-arr[i]));
  }
  cout<<dp[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  string s,t;
  cin>>s>>t;
  sort(all(s));
  sort(all(t));
  reverse(all(t));
  if(s<t){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
} 

Measured memory_bytes: 256
#!/usr/bin/env python3
def main():
    from itertools import combinations
    from math import sqrt

    N = int(input())
    xy = [list(map(int, input().split())) for _ in range(N)]

    ans = 0
    for can_move in combinations(xy, 2):
        xi, yi = can_move[0]
        xj, yj = can_move[1]
        ans += sqrt((xi - xj) ** 2 + (yi - yj) ** 2)
    print(f'{ans * 2 / N:.10f}')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9136
#include <stdio.h>
int main(void)
{
	int n, x, i=1;
	scanf("%d", &n);
	do{
		x=i;
		if(x%3==0){
			printf(" %d", i);
		}else{
			do{
				if(x%10==3){
					printf(" %d", i);break;
				}else{
					x/=10;
				}
			}while(x!=0);
		}
	}while(++i<=n);
	puts("");
    return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

ll N, T[2000], A[2000];

signed main(){
    cin >> N;
    REP(i, N) cin >> T[i] >> A[i];
    ll t = T[0], a = A[0];
    REP(i, N - 1){
        ll k = max((t + T[i + 1] - 1) / T[i + 1], (a + A[i + 1] - 1) / A[i + 1]);
        t += T[i + 1] * k - t;
        a += A[i + 1] * k - a;
    }
    PRINT(t + a);
    return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5])
	cout<<"Yes";
	else 
	cout<<"No";
	return 0;
}


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

using namespace std;

int main() {

	string s;
	cin >> s;
	if (s.size() < 4) {
		cout << "No" << endl;
	}
	else if (s.substr(0, 4) == "YAKI") {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    char x[1001];
    int sum = 0;
    while(1){
        scanf("%s", x);
        if(x[0] == '0' && x[1] == '\0') break;
        for(int i=0; x[i] != '\0'; i++){
            sum += x[i] - '0';
        }
        printf("%d\n", sum);
        sum = 0;
    }
    return 0;
}



Measured memory_bytes: 2032
#include<bits/stdc++.h>
#define lli long long int
#define pb push_back

using namespace std;


int main() {
    lli n,l,r,ans=0;
    cin>>n;
    for(int i=0;i<n;i++){
    	cin>>l>>r;
    	ans += (r-l+1);
	}
	cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#if 0

#endif

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int N;
set<string> S;

int main() {
  cin >> N;
  string s;
  for (int i = 0; i < N; i++) {
    cin >> s;
    if (s == "insert") {
      cin >> s;
      S.insert(s);
    } else {
      cin >> s;
      cout << (S.count(s) ? "yes" : "no") << endl;
    }
  }
}



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

ll mx[233],num[233],n,tot;

inline ll rd()
{
	ll x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline ll ksm(ll x,ll y) { ll res=1;for (;y;y>>=1,x=x*x) if (y&1) res=res*x;return res; }

inline ll dfs(ll x,ll y)
{
	if (y==tot) return (bool)(x==n);
	if (n+mx[y]<x||n-mx[y]>x) return 0;
	ll res=0;
	for (ll i=-9;i<=9;i++)
	{
		if (y) res+=dfs(x+num[y]*i,y+1)*(10-abs(i));
		else if (i!=9) res+=dfs(x+num[y]*i,y+1)*(i>=0?9LL-i:10LL+i);
	}
	return res;
}

int main()
{
	n=rd();
	ll ans=0LL;
	for (ll i=1;i<=18;i++)
	{
		memset(num,0,sizeof(num));
		memset(mx,0,sizeof(mx));
		tot=(i+1)/2;
		for (ll j=0;j<tot;j++) num[j]=ksm(10,i-j)-ksm(10,j);
		for (ll j=0;j<tot;j++) for (ll k=j;k<tot;k++) mx[j]+=num[k]*9;
		ans+=dfs(0,0)*((i%2==0)?10:1);
	}
	printf("%lld\n",ans);
	return 0;
}

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

class Dice{
    public:
    int f[7];
    Dice(){}
        void roll_x(){roll(1,4,6,3);} // to E
        void roll_y(){roll(1,2,6,5);} // to N
        void roll_z(){roll(2,3,5,4);} // 上から見て時計回り
        void roll(int a, int b, int c, int d){
            int t=f[a]; f[a]=f[b]; f[b]=f[c]; f[c]=f[d]; f[d]=t;
        }
        void move(char ch){
            if(ch=='E') roll_x();
            if(ch=='S') for(int i=0;i<3;i++) roll_y();
            if(ch=='W') for(int i=0;i<3;i++) roll_x();
            if(ch=='N') roll_y();
        }
};

int getRight(Dice d, int t1, int t2){
    for(int i=0;i<6;i++){
        for(int j=0;j<4;j++){
            if(d.f[1]==t1 && d.f[2]==t2) return d.f[3];
            d.roll_z();
        }
        if(i%2==0) d.roll_x();
        else d.roll_y();
    }
    return -1;
}

int main(){
    Dice d;
    
    for(int i=1;i<=6;i++) cin >> d.f[i];
    int n,t1,t2;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> t1 >> t2;
        cout << getRight(d,t1,t2) << endl;
    }
    return 0;
}


Measured memory_bytes: 3004
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>

using namespace std;

template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}

template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}

#define int long long
#define left left228
#define right right228
#define prev prev228
#define mp make_pair
#define all(v) v.begin(), v.end()
#define forn(i, n) for (int i = 0; i < (int)n; ++i)
#define firn(i, n) for (int i = 1; i < (int)n; ++i)
#define x first
#define y second

struct guy
{
    int x, v;
    guy() {}
    guy(int _x, int _v) {x = _x, v = _v;}
};
bool operator<(guy a, guy b) {
    return a.x < b.x;
}
const int N = 200 * 1000 + 228;
const int MOD = 1e9 + 7;

int mod(int x){
    x %= MOD;
    if (x < 0) x += MOD;
    return x;
}

guy a[N];
int pref[N], suff[N], gol[N], gor[N], max_left[N];
int dp[N];
int sumpref[N];

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i].x >> a[i].v;
    }
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; ++i) {
        pref[i] = max(pref[i - 1], a[i].v);
    }
    suff[n] = a[n].v;
    for (int i = n-1; i; --i) {
        suff[i] = min(suff[i + 1], a[i].v);
    }
    for (int i = 1; i <= n; ++i) {
        int l = 0, r = i;
        while (r - l > 1) {
            int m = (l + r) >> 1;
            if (pref[m] > a[i].v) r = m;
            else l = m;
        }
        gol[i] = r;
        l = i, r = n + 1;
        while (r - l > 1) {
            int m = (l + r) >> 1;
            if (suff[m] < a[i].v) l = m;
            else r = m;
        }
        gor[i] = l;
        uax(max_left[gor[i]], gol[i]);
    }
    for (int i = 1; i <= n; ++i) {
        uax(max_left[i], max_left[i - 1]);
    }
    for (int i = 1; i <= n; ++i) {
        if (max_left[i - 1] == 0) {
            dp[i] = 1;
        }
        dp[i] = mod(dp[i] + sumpref[i - 1] - sumpref[max(0LL, max_left[i - 1]-1)]);
        sumpref[i] = mod(sumpref[i - 1] + dp[i]);
    }
    int ans = 0;
    for (int i = max_left[n]; i <= n; ++i) {
        ans = mod(ans + dp[i]);
    }
    cout << ans << '\n';
    return 0;
}

/*
3
1 1 2
2 2 2
3 3 2
2 1 1
3 2 1


2 2
1 1 2
2 2 2
1 2 3
2 1 1

2
2 1 2 2 3
2 2 2 1 1

*/


Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
int main(void){
  string s,t;
  cin>>s>>t;
  for(int i=s.size()-1; i>=0; i--){
    bool tf=true;
    for(int j=t.size()-1; j>=0;j--){
      if(t[j]==s[i-t.size()+1+j] || s[i-t.size()+1+j]=='?'){
        
      }else{
        tf=false;
        break;
      }
    }
    if(tf){
      for(int j=0;j+t.size()<i+1;j++){
        cout<<(s[j]=='?' ? 'a' : s[j]);
      }
      cout<<t;
      for(int j=i+1;j<s.size();j++){
        cout<<(s[j]=='?' ? 'a' : s[j]);
      }
      cout<<endl;
      return 0;
    }
  }
  cout<<"UNRESTORABLE"<<endl;
  return 0;
}

Measured memory_bytes: 3596
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimensi0n, default_val) assert(type(default_val) ~= 'table') local n=dimensi0n local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
local function tostringxx(o, depth) depth = depth or 0 if depth > 10 then return "<too deep!>" end if o == _G then return "<_G>" end local indent0 = (" "):rep((depth) * 2) local indent1 = (" "):rep((depth+1) * 2) local indent2= (" "):rep((depth+2) * 2) if type(o) == 'table' then local keys = {} local types = {} for k in pairs(o) do types[type(k)] = true table.insert(keys, k) end local types_count = 0 local lasttype for k in pairs(types) do types_count = types_count + 1 lasttype = k end if types_count == 1 and (lasttype == 'string' or lasttype == 'number') then table.sort(keys) end local inside = {} for i=1,#keys do local k = keys[i] local v = o[k] if type(k) == 'string' then k = string.format('%q', k) end table.insert(inside, indent1 .. '['..tostring(k)..'] = ' .. tostringxx(v, depth + 1)) end return '{\n' .. table.concat(inside, ',\n') .. '\n' .. indent0 .. '}' else if type(o) == 'string' then o = string.format('%q', o) end return tostring(o) end end
local function richtraceback() local x = 2 while true do local info = debug.getinfo(x) if not info then break end local fname = '<' .. info.short_src .. ":" .. info.linedefined .. ">" if info.name then fname = info.name end print(info.short_src .. ":" .. info.currentline .. ": in " .. ("%q"):format(fname)) print(" LOCALS:") local p = 1 while true do local name, val = debug.getlocal(x,p) if not name then break end print(" " .. name .. ": " .. tostringxx(val, 3)) p = p + 1 end print(" UPVALUES:") for p=1,info.nups do local name, val = debug.getupvalue(info.func,p) if not name then break end print(" " .. name .. ": " .. tostringxx(val, 3)) end x = x + 1 end end
local function myassert(b) if not b then richtraceback() error("assertion failed") end end 
--
local N = read.n()
local A = read.N(N)
A[0] = 0
local s = 0
for i=1,N do
    local a = 0
    if A[i-1] > A[i] then
        a = A[i-1] - A[i]
    end
    s = s + a
    A[i] = A[i] + a
end
print(s)

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

A = []

for i in range (0,N):
	A.append(int(input()))

temp = 0
total = 0

import math

for i in range (0, N):
	if A[i] != 0:
		temp+=A[i]
	else:
		total+=math.floor(temp/2)
		temp=0
        
total+=math.floor(temp/2)     

print(total)

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

int main (){
    int H, HH;
    int M, MM;
    int K;
    cin >> H >> M >> HH >> MM >> K;
    int Wake = 60*H + M;
    int Bed = 60*HH + MM;
    int ans = Bed - Wake - K;
  	cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); i++) {
    char data = s.at(i);
    if(data + N <= 'Z') {
      cout << (char)(data + N);
    }
    else {
      cout << (char)(data + N - ('Z' - 'A' + 1));
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

N = INT()

C = Counter()
for x in range(1, N+1):
    for y in range(1, N+1):
        if x**2 + y**2 + x*y > N:
            break
        for z in range(1, N+1):
            n = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if n > N:
                break
            C[n] += 1

for i in range(1, N+1):
    print(C[i])


Measured memory_bytes: 10312
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

const char *BASE = "ACGT";
const char *OPP = "TGCA";

int main(void) {
  char c;
  cin >> c;
  REP(i, 4) {
    if(c == BASE[i]) {
      cout << OPP[i] << endl;
      break;
    }
  }
  
  return 0;
}


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

using namespace std;

int n, m, k;
int cal(int x, int y)
{
    if(n - x < 0)
        return 0;
    int res = m * x + y * (n - x) - y * x;

    return res < 0 ? 0 : res;
}

int main()
{
    scanf("%d %d %d", &n, &m, &k);
    
    bool ok = false;
    for(int x = 0; x <= n; x++)
        for(int y = 0; y <= m; y++) {
            if(cal(x, y) == k)
                ok = true;
        }
    
    printf("%s\n", ok ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
int main(){
    int count = 0;
    std::string s1, s2;
    std::cin >> s1 >> s2;
    for(int i=0; i<s1.length(); i++){
        if(s1.compare(i, 1, s2, i, 1) != 0){
           count++; 
        }
    }
    std::cout << count << "\n";
    return 0;
}

Measured memory_bytes: 3472
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>

#define MAX 310

using namespace std;

typedef long long int Int;

int H,W,D;
int Q;

map<int,pair<int,int> > A;

int px[MAX*MAX],py[MAX*MAX];
int dp[MAX*MAX];

int main(void) {
    cin>>H>>W>>D;
    for(int i = 1;i <= H;i++) {
        for(int j = 1;j <= W;j++) {
            int temp;
            cin>>temp;
            px[temp] = j;
            py[temp] = i;
        }
    }

    for(int i = D+1;i <= W*H;i++) {
      dp[i] = dp[i-D]+abs(px[i]-px[i-D])+abs(py[i]-py[i-D]);
    }

    cin>>Q;

    for(int i = 0;i < Q;i++) {
        int l,r;
        cin>>l>>r;
        cout<<dp[r]-dp[l]<<endl;
    }

    return 0;
}


Measured memory_bytes: 2176
import sys

f_i = sys.stdin

n = int(f_i.readline())

adj = [[]] * n
for x in f_i:
    x = list(map(int, x.split()))
    adj[x[0]] = [c_v for c_v in zip(x[3::2], x[2::2])]

import heapq

def dijkstra():
    PQ = [(0, 0)]
    isVisited = [False] * n
    distance = [999900001] * n

    distance[0] = 0
    
    while PQ:
        uc, u = heapq.heappop(PQ)

        if uc <= distance[u]:
            isVisited[u] = True
        
            for vc, v in adj[u]:
                if isVisited[v] == False:
                    t_cost = distance[u] + vc
                    if t_cost < distance[v]:
                        distance[v] = t_cost
                        heapq.heappush(PQ, (t_cost, v))

    for v, d in enumerate(distance):
        print(v, d)


dijkstra()

Measured memory_bytes: 70288
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
using namespace std;
#define ll long long 
#define dd cout<<endl
const int mod=1e9+7;
const int inf=1e9+7;

const int maxn=2e5+10;

int sum[maxn];
vector<int>edge[maxn];

int n,m;
int x,y;

int book[maxn];

void dfs(int now,int mark)
{
	mark+=book[now];
		
	sum[now]+=mark;
	
	for(int i=0;i<edge[now].size();i++)
		dfs(edge[now][i],mark);
}

int main()
{
   	//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    
    scanf("%d%d",&n,&m);
    
    //memset(sum,0,sizeof(sum));
    	
    //for(int i=0;i<=n;i++)
    //	edge[i].clear();
    		
	for(int i=0;i<n-1;i++)
	{
		cin>>x>>y;
		edge[x].push_back(y);
	}
	
	//cout<<"hehe"<<endl;
	
	for(int i=0;i<m;i++)
	{
		scanf("%d%d",&x,&y);
		book[x]+=y;
	}
	
	dfs(1,0);
	
	for(int i=1;i<n;i++)
		printf("%d ",sum[i]);
	printf("%d\n",sum[n]);
	
    return 0;
}

Measured memory_bytes: 24064
using System;

public class Program
{
	public static void Main(string[] args)
	{
		var ss = new StreamScanner();
		//---------------------------------
		var n = ss.Next<int>();
		long[] a = ss.Next<long>(n);
			long sum = 0;
			for (int i = 0; i < n; i++)
			{
				sum += a[i];
			}
		long max = long.MinValue;
			for (int i = 0; i < n; i++)
			{
				if (max < a[i])
				{
					max = a[i];
				}
			}
		long min = long.MaxValue;
			for (int i = 0; i < n; i++)
			{
				if (min > a[i])
				{
					min = a[i];
				}
			}

			Console.WriteLine(min + " " + max + " " + sum);

		/*
		//????????????int, double, string?????????????????£????????????
		int i = ss.Next<int>();
		double d = ss.Next<double>();
		string s = ss.Next<string>();

		//?????°???????????????????????¨?????????????????????????????????????????????????´???????
		int[] array = ss.Next<int>(10);
		*/
		//---------------------------------
	}
}



public class StreamScanner
{
	private readonly char[] _c = { ' ' };
	private int _index = -1;
	private string[] _input = new string[0];
	private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

	public T Next<T>()
	{
		if (_index == _input.Length - 1)
		{
			_index = -1;
			while (true)
			{
				string rl = _sr.ReadLine();
				if (rl == null)
				{
					if (typeof(T).IsClass) return default(T);
					return (T)typeof(T).GetField("MinValue").GetValue(null);
				}
				if (rl != "")
				{
					_input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
					break;
				}
			}
		}
		return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
	}

	public T[] Next<T>(int x)
	{
		var ret = new T[x];
		for (var i = 0; i < x; ++i) ret[i] = Next<T>();
		return ret;
	}

	public T[][] Next<T>(int x, int y)
	{
		var ret = new T[y][];
		for (var i = 0; i < y; ++i) ret[i] = Next<T>(x);
		return ret;
	}
}

Measured memory_bytes: 10816
//B.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int n,m;
  cin >> n >> m;
  int a;
  rep(i,m){
    cin >> a;
    n -= a;
  }
  if(n >= 0) printf("%d\n", n);
  else printf("-1\n");
  return 0;
}


Measured memory_bytes: 3768
A1=list(map(int, input().split()))
A2=list(map(int, input().split()))
A3=list(map(int, input().split()))
A=A1+A2+A3
N=int(input())
s=set()
for _ in range(N):
  b=int(input())
  if b in A:
    s|={A.index(b)}
bingo=[{0,1,2},{0,3,6},{0,4,8},{1,4,7},{2,4,6},{2,5,8},{3,4,5},{6,7,8}]
print(["No","Yes"][any(s>=b for b in bingo)])



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

typedef int Capacity;
struct Edge {
    int src, dst;
    Capacity cap;
    Edge(int src_, int dst_, Capacity cap_) :
        src(src_), dst(dst_), cap(cap_) { }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

struct Dinic {
    int n, s, t;
    vector<int> level, vis;
    vector<vector<Capacity>> cap, flow;
    vector<vector<int>> g;
    Capacity inf;
    Dinic(int n)
        : n(n), cap(n, vector<Capacity>(n)), flow(n, vector<Capacity>(n)),
          g(n, vector<int>()), inf(numeric_limits<Capacity>::max()/8){}
    Dinic(const Graph &graph){
        *this = Dinic(graph.size());
        rep(i,n) for(auto &e : graph[i]) addEdge(e.src, e.dst, e.cap);
    }
    void addEdge(int u, int v, Capacity c){
        cap[u][v] += c; cap[v][u] += c; flow[v][u] += c;
        g[u].push_back(v); g[v].push_back(u);
    }
    Capacity solve(int s, int t){
        Capacity res = 0, aug = 1;
        this->t = t, this->s = s;
        while(aug > 0){
            levelize();
            vis.assign(n, false); aug = 0;
            Capacity tmp = 1;
            while(tmp > 0) aug += (tmp = augment(s, inf));
            res += aug;
        }
        return res;
    }
    void levelize(){
        level.assign(n, inf); level[s] = 0;
        queue<int> q; q.emplace(s);
        while(q.size()){
            int v = q.front(); q.pop();
            for(const int &d : g[v]){
                if(level[d] <= level[v] + 1 || cap[v][d] - flow[v][d] == 0) continue;
                level[d] = level[v] + 1; q.emplace(d);
            }
        }
    }
    Capacity augment(int v, const Capacity &lim){
        vis[v] = true;
        if(v == t) return lim;
        for(const int &d : g[v]){
            if(vis[d] || flow[v][d] == cap[v][d] || level[v] >= level[d]) continue;
            Capacity aug = augment(d, min(lim, cap[v][d] - flow[v][d]));
            flow[v][d] += aug; flow[d][v] -= aug;
            if(aug > 0) return aug;
        }
        return 0;
    }
};

int main(){
    int N,M;
    cin >> N >> M;
    Graph g(N);
    rep(i,M){
        int a,b,c;
        cin >> a >> b >> c;
        g[a].emplace_back(a,b,c);
    }
    Dinic ek(g);
    cout << ek.solve(0,N-1) << endl;
}

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

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int n, m;
double ans = 0.0;
void f(double t, double p, int depth = 0) {
    if (depth == 1000) return;
    depth++;
    t += 1800 * m + 100 * n;
    ans += t * (1-p) * pow(1.0 / 2.0, m);
    p += (1-p) * pow(1.0 / 2.0, m);
    f(t, p, depth);
}

int main() {
#ifdef LOCAL_TEST
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    cin >> n >> m;
    f(0.0, 0.0);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

using int64 = long long;

int main()
{
  string S;
  int X, Y;

  cin >> S;
  cin >> X >> Y;

  vector< int > compress;
  compress.emplace_back(0);
  for(int i = 0; i < S.size(); i++) {
    if(S[i] == 'T') compress.emplace_back(0);
    else compress.back()++;
  }

  bitset< 16001 > latte, malta;
  latte[8000 + compress.front()] = malta[8000] = true;
  for(int i = 1; i < compress.size(); i++) {
    if(i % 2 == 0) latte = (latte << compress[i]) | (latte >> compress[i]);
    else malta = (malta << compress[i]) | (malta >> compress[i]);
  }

  if(latte[8000 + X] && malta[8000 + Y]) puts("Yes");
  else puts("No");
}

Measured memory_bytes: 384
private inline fun <T, R> Collection<T>.foldEach(initial: R, operation: (R, T) -> R): List<R> {
    var accumulator = initial
    val result = mutableListOf(accumulator)
    for (element in this) accumulator = operation(accumulator, element).apply { result.add(this) }
    return result.toList()
}

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val S = readLine()!!

    println(S.map { if (it == 'I') 1 else -1 }.foldEach(0) { f, s -> f + s }.max())
}

Measured memory_bytes: 33748
n = int(input())
f = []
p = []
for i in range(n):
    f.append(list(map(int,input().split())))
for i in range(n):
    p.append(list(map(int,input().split())))

ans = -10000000000
for i in range(1,1024):
    b = []
    a = 0
    for j in range(10):
        if i | (2**j) == i:
            b.append(1)
        else:
            b.append(0)
    for j in range(n):
        count = 0
        for k in range(10):
            if b[k] == 1 and f[j][k] == 1:
                count += 1
        a += p[j][count]
    ans = max(a,ans)
print(ans)

Measured memory_bytes: 3064
//@source : 
//@create : 19:50:06 Sunday 05/07/2020
//@author : nghethuat102
//@status : 
#include <bits/stdc++.h>
using namespace std;

#define fastio() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
template<typename T> void write(const T&x) { cout << x; }
template<typename T, typename... Args> void write(const T&x, Args... args) { cout << x; write(args...); }
template<typename... Args> void writeln(Args... args) { write(args..., "\n"); }
template<typename T> void read(T&x) { cin >> x; }
template<typename T, typename... Args> void read(T&x, Args&... args) { cin >> x; read(args...); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << "\n"; err(++it, args...); }

void solve() {
    int n;
    read(n);
    long long ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans += 1LL * i * (n - i + 1);
    }
    for (int i = 1; i < n; ++i) {
        int u, v;
        read(u, v);
        if (u > v) {
            swap(u, v);
        }
        ans -= 1LL * u * (n - v + 1);
    }
    writeln(ans);
}

int main() {
    fastio();
    int t = 1;
    for (int it = 1; it <= t; ++it) {
        solve();
    }
    return 0;
}

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

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

int main(){

    int n, m;
    std::cin >> n >> m;

    int a[100][100], b[100];

    REP(i, n) REP(j, m) std::cin >> a[i][j];
    REP(i, m)           std::cin >> b[i];

    REP(i, n) {
        int sum = 0;
        REP(j, m) sum += a[i][j] * b[j];
        std::cout << sum << std::endl;
    }

    return 0;
}



Measured memory_bytes: 3108
main:: IO ()
main = do
    ss <- words <$> getLine
    putStrLn $ if solve ss then "YES" else "NO"

-- |
--
-- >>> solve ["rng", "gorilla", "apple"]
-- True
--
-- >>> solve ["yakiniku", "unagi", "sushi"]
-- False
solve :: [String] -> Bool
solve (a:b:c:_) = y1 && y2
  where
    y1 = last a == head b
    y2 = last b == head c


Measured memory_bytes: 380
#include <stdio.h>

int main(void) {
	long long int n, k;
	long long int num, pre_num;

	scanf("%lld%lld", &n, &k);

	num = n % k;

	pre_num = k - num;

	if (pre_num < 0)
		pre_num *= -1;

	if (pre_num < num)
		num = pre_num;

	printf("%lld", num);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long int
#define MOD 1000000007
#define all(c) c.begin(), c.end()
#define rep(i, s, e) for (auto i = s; i < e; i++)
#define peek(c)      \
	for (auto i : c) \
		cout << i << ' ';

void solve()
{
	ll n;
	cin >> n;
	ll res = 1;
	rep(i, 0, n)
	{
		ll t;
		cin >> t;
		res *= t / __gcd(res, t);
	}
	cout << res;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	solve();
	cerr << "\n\n~" << 500 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Measured memory_bytes: 256
import itertools
r = 110000
s = int(r*0.5)
p = [1] * r
p[0] = 0
for i in range(1,s):
	if p[i]:
		p[2*i+1::i+1] = [0 for x in range(2*i+1,r,i+1)]
		
while 1:
	N,P = map(int,raw_input().split())
	if N == -1: break
	i = N + 1
	prime = [0]*23
	j = 0
	while j < 23:
		if p[i-1] == 1:
			prime[j] = i
			j += 1
		i += 1
	wa = sorted([sum(comb) for comb in itertools.combinations(prime,2)] + [2*a for a in prime])
	print wa[P-1]

Measured memory_bytes: 9024
<?php
$n = int();
printf("%d", 3*$n**2);
function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

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

int main() {
  long long W, H, x, y;
  cin >> W >> H >> x >> y;
  cout << fixed << setprecision(12)
       << W*H/2. << " " << (x*2==W&&y*2==H?1:0) << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if(a<b){
            System.out.println("a < b");
        }else if(a>b){
            System.out.println("a > b");
        }else{
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26280
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

// 2^n
mint f(int n){
	if(n == 0) return 1;
	mint x = f(n/2);
	x *= x;
	if(n%2 == 1) x *= 2;
	return x;
}

// nCa
mint choose(int n, int a){
	mint x = 1, y = 1;
	rep(i,a){
		x *= n-i;
		y *= i+1;
	}
	return x / y;
}

struct Combination{
	vector<mint> fact, ifact;
	Combination(int n):fact(n+1),ifact(n+1){
		assert(n < mod);
		fact[0] = 1;
		for(int i = 1; i <= n; i++) fact[i] = fact[i-1]*i;
		ifact[n] = fact[n].inv();
		for(int i = n; i >= 1; i--) ifact[i-1] = ifact[i]*i;
	}
	mint operator()(int n, int k){
		if(k < 0 || k > n) return 0;
		return fact[n]*ifact[k]*ifact[n-k];
	}
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k;
    string s;
    cin >> k >> s;
    int n = s.size();
    Combination comb(n+k);
    mint ans = 0;
    for(int i = 0; i <= k; ++i){
        mint add = mint(26).pow(k-i);
        add *= mint(25).pow(i);
        add *= comb(i+n-1, n-1);
        ans += add;
    }
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 35612
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
const int N = 2e5 + 5, MOD = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int power(int x, int y, int p = 998244353LL){
    int res = 1;
    x = x % p;

    while (y > 0){
        if (y & 1)  res = (res*x) % p;

        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

int modInverse(int n, int p = 998244353LL){
    return power(n, p-2, p);
}

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

    int n, cnt = 0, p = 998244353LL;
    cin>>n;
    int a[n + 5];
    map<int, int> m;
    m.clear();
    for(int i = 1; i <= n; i++){
        cin>>a[i];
        m[a[i]]++;
        if(a[i] == 0)   cnt++;
    }

    if(cnt == 0 or cnt > 1){
        cout<<0;
        return 0;
    }

    if(a[1] != 0){
        cout<<0;
        return 0;
    }

    sort(a + 1, a + n + 1);
    for(int i = 2; i <= n; i++){
        if((a[i] - a[i - 1]) > 1){
            cout<<0;
            return 0;
        }
    }

    int prev = 1LL, ans = 1LL;
    for(auto u: m){
        int num = power(prev, u.second);
        ans *= num;
        ans %= p;
        prev = u.second;
    }
    cout<<ans;



    return 0;
}


Measured memory_bytes: 7296
class UnionFind:
    def __init__(self, size: int):
        self.__size = size
        self.__root = [-1] * size

    def find(self, x: int)->int:
        if self.__root[x] < 0:
            return x
        self.__root[x] = self.find(self.__root[x])
        return self.__root[x]

    def union(self, x: int, y: int)->int:
        rx, ry = self.find(x), self.find(y)

        if rx == ry:
            return

        if self.__root[ry] < self.__root[rx]:
            rx, ry = ry, rx

        self.__root[rx] += self.__root[ry]
        self.__root[ry] = rx

    def same(self, x: int, y: int)->bool:
        return self.find(x) == self.find(y)


def one_or_two(N: int, M: int, queries: list)->int:
    uf = UnionFind(N)

    for x, y, _ in queries:
        uf.union(x-1, y-1)

    return len(set(uf.find(i) for i in range(N)))


if __name__ == "__main__":
    M = 0
    N, M = map(int, input().split())
    queries = [tuple(int(s) for s in input().split()) for _ in range(M)]

    ans = one_or_two(N, M, queries)
    print(ans)


Measured memory_bytes: 27104
#include <stdio.h>
int main(void){
	int n[10000],m[10000];
	int h,i,j,k;
	h=0;
	do{
		h++;
		scanf("%d %d",&n[h],&m[h]);
	}while(n[h]!=0&&m[h]!=0);
	i=1;
	while(i<h){
		for(j=1;j<=n[i];j++){
			for(k=1;k<=m[i];k++){
				if(k==1||k==m[i]||j==1||j==n[i])printf("#");
				else printf(".");
			}
			printf("\n");
		}
		i++;
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 1996
import itertools
import math

N = int(input())
d = [list(map(int, input().split())) for i in range(N)]

ans = 0
cnt = 0

for i in itertools.permutations(d, N):
  cnt += 1
  for j in range(len(i)-1):
    ans += math.sqrt((i[j][0]-i[j+1][0])**2+(i[j][1]-i[j+1][1])**2)
   
print(ans/cnt)

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <cstdlib>

using namespace std;

int main()
{
    int N, K;
    scanf("%d%d", &N, &K);
    int candles[N];
    for (int i = 0; i < N; i++) {
        int candle;
        scanf("%d", &candle);
        candles[i] = candle;
    }

    int min_time = 2 * abs(candles[0] - candles[N - 1]);

    for (int i = 0; i < N; i++) {
        int end_index = i + K - 1;
        if (end_index >= N) {
            break;
        }
        int l_end = candles[i], r_end = candles[end_index];
        int d = abs(r_end - l_end);

        int time = min(abs(l_end) + d, abs(r_end) + d);
        min_time = min(time, min_time);
    }

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


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>

using namespace std;

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


int main() {
	ll n, x;

	cin >> n >> x;

	ll a[n];
	rep(i, n) {
		cin >> a[i];
	}
	ll ans = 0;
	rep(i,n) {
		if (a[i] > x) {

			
			ans += a[i] - x;
			a[i] = x;
		}
	}

	for(int i = 1; i < n - 1; i++) {
		ll cur = a[i - 1] + a[i];
		ll next = a[i] + a[i + 1];
		if (cur > x && next > x) {

			ll diff = min(cur - x, next - x);
			ll diff0 = min(a[i], diff);
			a[i] -= diff0;
			ans += diff0; 
		} 
	} 

	for(int i = 1; i < n; i++) {

		if (a[i - 1] + a[i] > x) {
 			ll sub = (a[i - 1] + a[i]) - x;
			ll sub0 = min(a[i - 1], sub);
			a[i - 1] -= sub0;
			ans += sub0; 
 
		}
	}


	if (a[n - 2] + a[n - 1] > x) {
		ll sub = x - (a[n - 2] + a[n - 1]);
		ll sub0 = min(a[n - 1], sub);
		a[n - 1] -= sub0;
		ans += sub0; 
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int c=0,m=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T') c++;
    else c=0;
    m=max(m,c);
  }
  cout<<m;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pi pair<ll, ll>
#define mp make_pair
#define pb push_back
#define vi vector<ll>
#define pd pair<double, double>
#define vp vector<pi>
#define f(i, n) for(int i = 0; i < n; i++)
#define fo(i, a, n) for(int i = a; i < n; i++)
#define mod (1000*1000*1000+7)
#define sz(x) int((x).size())
#define all(x) x.begin(),x.end()
#define DBG(v) cerr << #v << " = " << (v) << endl;
ll INF = (1ll<<61);

using namespace std;

set<int> s[26];

int main(int argc, char* argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    // cin >> t;
    while(t--){
      int n; cin >> n; string t; cin >> t;
      f(i, n) s[t[i] - 'a'].insert(i);
      int q; cin >> q;
      while(q--){
        // DBG(1)
        ll a, b; cin >> a >> b;
        if(a == 1){
          char c; cin >> c;
          int x = t[b-1] - 'a';
          s[x].erase(b-1);
          t[b-1] = c;
          s[c-'a'].insert(b-1);
        }else{
          ll c; cin >> c;
          b--;c--;
          ll ans = 0;
          f(i, 26){
            if(s[i].empty() || *s[i].rbegin() < b || *s[i].begin() > c) continue;
            int k = *s[i].lower_bound(b);
            if(k <= c) ans++;
          }
          cout << ans << endl;
        }
      }
    }
    return 0;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

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

    int N; cin >> N;
    string str = "";
    while (N != 0) {
        int r = N % 2;
        if (r < 0) r = -r;
        N = (N - r) / (-2);
        str += (char)('0' + r);
    }
    reverse(all(str));
    if (str == "") str = "0";
    cout << str << endl;
    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11451419194545;

int main(){
    ll A; cin >> A;
	ll ans = A / 2 * (A - (A / 2));

    cout << ans <<  endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  int n,sum;
  cin >> n;
  if(1<=n&&n<10)sum = n;
    else if(10<=n&&n<100) sum = 9;
      else if(100<=n&&n<1000) sum = n-90;
        else if(1000<=n&&n<10000) sum = 909;
          else if(10000<=n&&n<100000) sum = n-10000+910;
            else sum = 99999-10000+910;
            cout << sum << endl;
}


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


class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split(' ');
        var b = Console.ReadLine().Split(' ');
        var c = Console.ReadLine().Split(' ');

        var prev = -2;
        var ret = 0;
        foreach (var i in a)
        {
            var tmp = int.Parse(i) - 1;
            ret += int.Parse(b[tmp]);
            if (tmp == prev + 1) ret += int.Parse(c[prev]);
            prev = tmp;
        }

        Console.Write(ret);
    }
}


Measured memory_bytes: 13140
#include<stdio.h>

int main(){
    int n, max=0, sum=0;
    char s[105];
    scanf("%d",&n);
    scanf("%s",s);
    
    for(int i=0; i<n; i++){
        if(s[i] == 'I'){
            sum++;
        }
        if(s[i] == 'D'){
            sum--;
        }
        if(max < sum){
            max = sum;
        }
    }
    printf("%d\n",max);
    return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
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; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, x;
    cin >> n >> m >> x;
    V<> a(m);
    rep(i, m) cin >> a[i];
    int c = lower_bound(all(a), x) - a.begin();
    cout << min(c, m - c) << endl;
}

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

int main() {
    ll N, D;
    cin >> N >> D;
    vector<ll> x(N);
    vector<ll> y(N);
    for(ll i = 0; i < N; i++){
        cin >> x.at(i) >> y.at(i);
    }

    vector<double> dis(N);
    for(ll i = 0; i < N; i++){
        dis.at(i) = sqrt(x.at(i)*x.at(i) + y.at(i)*y.at(i));
    }
    ll ans = 0;
    for(ll i = 0; i < N; i++){
        if(dis.at(i) <= D){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 8004
#include <stdio.h> 

int main(void)
{
	int a;
	int b;
	int x;
	int y;

	for (y=1; y<=4; y=y+1)
	{
		scanf("%d %d", &a, &b);

		if (a==1)
		{
			x=6000*b;

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

		if (a==2)
		{
			x=4000*b;

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

		if (a==3)
		{
			x=3000*b;

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

		if (a==4)
		{
			x=2000*b;

			printf("%d\n", x);

		}
	}

	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;
typedef vector<long long int> vll;

int main() {
	map<int, int> mp;
	int n;
	cin >> n;
	vi a(n);
	rep(i, 0, n) {
		cin >> a[i];
		a[i] -= i + 1;
		if (!mp.count(a[i])) {
			mp[a[i]] = 0;
		}
		mp[a[i]]++;
	}
	int mid = (n + 1) / 2;
	int i = 0, x;
	for (auto ite : mp) {
		i += ite.second;
		if (i >= mid) {
			x = ite.first;
			break;
		}
	}
	i64 ans = 0;
	rep(i, 0, n) {
		ans += abs(a[i] - x);
	}
	cout << ans << endl;
}


Measured memory_bytes: 10368
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        
        int result = 0;
        for (int i = a; i <= b; i++) {
            if (c % i == 0) {
                result++;
            }
        }
        System.out.println(result);
        
    }
}


Measured memory_bytes: 26344