akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

template <ll mod>
class modint
{
public:
    constexpr modint(ll value = 0) : _value(value >= 0 ? value % mod : (value % mod) + mod) {}

    constexpr modint operator+() const { return *this; }
    constexpr modint operator-() const { return modint(-_value); }

    constexpr modint &operator+=(const modint &rhs) {
        if ((_value += rhs._value) >= mod) _value -= mod;
        return *this;
    }
    constexpr modint &operator-=(const modint &rhs) {
        if ((_value += mod - rhs._value) >= mod) _value -= mod;
        return *this;
    }
    constexpr modint &operator*=(const modint &rhs) {
        (_value *= rhs._value) %= mod;
        return *this;
    }
    constexpr modint &operator/=(const modint &rhs) {
        *this *= rhs.inv();
        return *this;
    }
    constexpr modint operator+(const modint &rhs) const { return modint(*this) += rhs; }
    constexpr modint operator-(const modint &rhs) const { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint &rhs) const { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint &rhs) const { return modint(*this) /= rhs; }

    constexpr modint operator++() { *this += 1; return *this; }
    constexpr modint operator--() { *this -= 1; return *this; }
    constexpr modint operator++(int) { modint tmp = *this; ++*this; return tmp; }
    constexpr modint operator--(int) { modint tmp = *this; --*this; return tmp; }

    constexpr bool operator==(const modint &rhs) const { return _value == rhs._value; }
    constexpr bool operator!=(const modint &rhs) const { return _value != rhs._value; }

    constexpr modint inv() const {
        ll a = _value, b = mod, u = 1LL, v = 0LL;
        while (b > 0) {
            ll tmp = a / b;
            a -= tmp * b; swap(a, b);
            u -= tmp * v; swap(u, v);
        }
        return modint(u);
    }

    constexpr modint pow(ll n) const {
        modint e = *this, res = 1;
        while (n) {
            if (n & 1) res *= e;
            e *= e, n >>= 1;
        }
        return res;
    }

    friend ostream &operator<<(ostream &os, const modint &m) {
        os << m._value;
        return os;
    }

    friend istream &operator>>(istream &is, modint &m) {
        ll in;
        is >> in;
        m = modint(in);
        return is;
    }

private:
    ll _value;
};
using mint = modint<1000000007>;

mint dp[3000][3000];

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

    int n; cin >> n;
    string s; cin >> s;
    
    for (int i = 0; i < n; i++) dp[0][i] = 1;
    for (int i = 0; i < n - 1; i++) {
        vector<mint> sum(n + 1);
        for (int k = 0; k < n; k++) sum[k + 1] = sum[k] + dp[i][k];

        if (s[i] == '<') {
            for (int j = 0; j < n - i; j++) dp[i + 1][j] = sum[j + 1] - sum[0];
        } else {
            for (int j = 0; j < n - i; j++) dp[i + 1][j] = sum[n - i] - sum[j + 1];
        }
    }
    cout << dp[n - 1][0] << endl;
    return 0;
}


Measured memory_bytes: 70016
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class BCountABC {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      string s; cin >> s;
      int ans = 0;
      rep(i, n-2) {
        if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') {
          ans++;
        }
      }
      cout << ans << endl;
    }
};

signed main() {
  BCountABC solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

int main() {
    int a, b;  cin >> a >> b;
    if (a >= 13)  cout << b << endl;
    else if (a <= 12 && a >= 6)  cout << b/2 << endl;
    else  cout << 0 << endl;
}

Measured memory_bytes: 256
def fact(n, div):
    ans = 1
    for i in range(2,n+1):
        ans *= i
        ans %= div
    return ans

N,M=map(int,input().split())

div = 10**9+7
if N==M:
    print((2*fact(N,div)**2)%div)
else:
    if abs(N-M)>1:
        print(0)
    else:
        print((fact(N,div)*fact(M,div))%div)


Measured memory_bytes: 3060
import java.util.Scanner;

class Main{
  public static void main(String args[]){
    
    Scanner scan = new Scanner(System.in);
    int n = Integer.parseInt(scan.next());
    int k = Integer.parseInt(scan.next());
    
    int keijibanNo = 1;
    int keijibanNoAfCalcA = 0;
    int keijibanNoAfCalcB = 0;
    
    for (int i = 0 ; i < n ; i++) {
    	keijibanNoAfCalcA = calcA(keijibanNo);
    	keijibanNoAfCalcB = calcB(keijibanNo, k);
    	if (keijibanNoAfCalcA > keijibanNoAfCalcB) {
    		keijibanNo = keijibanNoAfCalcB;
    	} else {
    		keijibanNo = keijibanNoAfCalcA;
    	}	
    }
	System.out.println(String.valueOf(keijibanNo));
	return;
  }
  
  private static int calcA(int keijibanNo){
  	return keijibanNo * 2;
  }

  private static int calcB(int keijibanNo, int k){
  	return keijibanNo + k;
  }
  
}



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

int main() {
    int N, Y;
    cin >> N >> Y;

    for(int x=0; x<=N; x++){
        for(int y=0; y<=N; y++){
            if(9*x+4*y == Y/1000 - N && N-x-y >=0){
                cout << x << " " << y << " " << N-x-y << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $monster_count, $critical);
$monster_s = fgets(STDIN);
$exploded_monster_s = explode(' ', trim($monster_s));
rsort($exploded_monster_s);
array_splice($exploded_monster_s, 0, $critical);
$result = array_sum($exploded_monster_s);
echo $result;

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

#define FOR(i,a,b) for (int i=(a); i<(b); ++i)
typedef vector<int> vi;
typedef vector<vi> vvi;
inline int in() { int x; cin >> x; return x; }
#define chmax(x,y) x=max(x,y)

int n;
int count(int x) {
    int ans = 0;
    FOR(i,0,n) ans += (x>>i)&1;
    return ans;
}

void solve() {
  n = in();
  vvi h(n, vi(n, -1));
  FOR(i,0,n) {
    int a = in();
    FOR(j,0,a) {
      int x = in()-1, y = in();
      h[i][x] = y;
    }
  }
  int ans = 0;
  FOR(i,1,1<<n) {
    int ok = 1;
    FOR(j,0,n) {
      if (!((i>>j)&1)) continue;
      FOR(k,0,n) {
        if (h[j][k]==-1) continue;
        if (h[j][k]!=((i>>k)&1)) ok = 0;
      }
    }
    if (ok) chmax(ans, count(i));
  }
  cout << ans << endl;
}

#undef int
int main() {
  solve();
  return 0;
}

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

using namespace std;

using ll=long long;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;
constexpr int mo = 1e9+7;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;
    string str;
    cin>>n>>str;
    int count = 0;
    for(int i=0;i<n-2;++i){
        if(str.substr(i,3) == "ABC")count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn is_enough(t: i64, h: &Vec<i64>, a: i64, b: i64) -> bool{
    let mut h = h.clone();

    for i in 0..h.len(){
        h[i] -= b*t ;
    }

    let mut additions = 0;
    for i in 0..h.len(){
        if h[i] <= 0{
            return true;
        }

        additions += (h[i]+(a-b)-1)/(a-b);
        h[i] = 0;
        if additions > t{
            return false;
        }
    }
    return true;
}

//01:09
fn main(){
    let line = read_as_vec::<usize>();
    let (n, a, b) = (line[0], line[1] as i64, line[2] as i64);

    let mut h: Vec<i64> = vec![];
    for _ in 0..n{
        h.push(read_as_vec()[0]);
    }

    h.sort();
    h.reverse();

    let mut left = 0;
    let mut right = (h[0]/b+1);
    while left < right{
        let mid = (left+right)/2;
        if is_enough(mid, &h, a, b){
            right = mid;

        }else{
            left = mid;

        }
        if left + 1 == right{
            break;
        }
    }

    println!("{}", right);
}


Measured memory_bytes: 6396
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define pi 3.1415926535
using namespace std;

int n,i,j,k;
int x[100005],y[100005];
double ans[100005];

long long cross(int a1,int b1,int a2,int b2){return (long long)a1*b2-(long long)a2*b1;}

double calc(int i)
{
	int j,k;
	for(j=1;j<=n;++j)
	if(j!=i)
	{
		for(k=1;k<=n;++k)
		if(k!=i&&k!=j&&cross(x[j]-x[i],y[j]-y[i],x[k]-x[i],y[k]-y[i])>0)
		break;
		if(k>n)break;
	}
	if(j>n)return 0;
	double a=atan2(y[j]-y[i],x[j]-x[i]);
	for(j=1;j<=n;++j)
	if(j!=i&&fabs(atan2(y[j]-y[i],x[j]-x[i])-a)>0.000001)
	{
		for(k=1;k<=n;++k)
		if(k!=i&&k!=j&&cross(x[j]-x[i],y[j]-y[i],x[k]-x[i],y[k]-y[i])<0)
		break;
		if(k>n)break;
	}
	if(j>n)return 0.5;
	double b=atan2(y[j]-y[i],x[j]-x[i]);
	double c=fabs(a-b);
	if(c>pi)c=2*pi-c;
	return (pi-c)/2/pi;
}

int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d%d",&x[i],&y[i]);
	for(i=1;i<=n;++i)printf("%.10lf\n",calc(i));
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main() {
	int sum;
	int a;
	while (cin >> sum) {
		if (sum == 0) {
			break;
		}
	for (int i = 0; i < 9; i++) {
		cin >> a;
		sum -= a;
	}
	cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
n=int(input())
a=list(map(str,input().split()))

ab=a[:]
flg=True
i=0
while flg:
    flg=False
    for j in range(n-1,i,-1):
        if ab[j][1]<ab[j-1][1]:
            ab[j],ab[j-1]=ab[j-1],ab[j]
            flg=True
    i+=1
print(' '.join(map(str,ab)))
print('Stable')

ac=a[:]
for i in range(n):
    minj=i
    for j in range(i,n):
        if ac[j][1]<ac[minj][1]:
            j,minj=minj,j
    if i!=minj:
        ac[i],ac[minj]=ac[minj],ac[i]
print(' '.join(map(str,ac)))

if ab==ac:
    print('Stable')
else:
    print('Not stable')


Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e18,MOD=1e9+7;
const int iINF=1e9;
int main(){
    int a,b,k;
    cin>>a>>b>>k;
    set<int>ans;
    for(int i=0;(i<k)&&(i+a<=b);i++)ans.insert(a+i);
    for(int i=0;(i<k)&&(b-i>=a);i++)ans.insert(b-i);
    for(auto &x:ans)cout<<x<<endl;
}

Measured memory_bytes: 256
from collections import defaultdict


def read_input():
    l, r = map(int, input().split())
    return l, r


def candidates():
    cand = defaultdict(list)
    for i in range(1, 2019):
        for j in range(i + 1, 2019):
            cand[(i*j) % 2019].append((i, j))

    return cand


def check_in_range(l, r, x):
    if r - l > 2019:
        return True

    base = (l // 2019) * 2019

    test = base + x
    while base <= r:
        if l <= test <= r:
            return True
        base += 2019
        test = base + x

    return False


def submit():
    l, r = read_input()

    cands = candidates()
    for i in range(2019):
        cand = cands[i]

        for c in cand:
            if check_in_range(l, r, c[0]) and check_in_range(l, r, c[1]):
                print(i)
                return







if __name__ == '__main__':
    submit()


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

using namespace std;

struct UnionFind {
    vector<int> par;

    UnionFind(int N) : par(N) {
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> P(N);
    for(int i = 0; i < N; i++){
        cin >> P[i];
    }

    UnionFind tree(N);

    for(int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        tree.unite(x-1, y-1);
    }

    int cnt = 0;
    for(int i = 0; i < N; i++) {
        if (tree.same(i, P[i]-1)) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
v = list(map(int, input().split(' ')))
c = list(map(int, input().split(' ')))
v_sum = sum(v)
c_sum = sum(c)
ans = v_sum - c_sum


diff = []
for i in range(n):
    diff.append(v[i] - c[i])

diff = sorted(diff)

for num in diff:
    if num < 0:
        ans -= num

print(max(ans, 0))
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    vector<ll> a(3);
    rep(i, 3) cin >> a[i];
    sort(all(a));
    if ((a[0] == a[1]) && (a[1] != a[2])) {
        cout << "Yes" << endl;
        return 0;
    }
    else if ((a[1] == a[2]) && (a[0] != a[1])) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


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

int main() {
  string S;
  long K;
  cin >> S >> K;
  long N = S.size();
  if (K <= N) {
    for (int i = 0; i < K; i++) {
      if (S.at(i) != '1') return cout << S.at(i) << "\n", 0;
    }
    return cout << '1' << "\n", 0;
  } else {
    for (char c : S) if (c != '1') return cout << c << "\n", 0;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int a, b, c,flag=3;

	scanf("%d%d%d", &a, &b, &c);

	if (a == b || b == c || c == a)
	{
		flag--;

		if (a == b&&b == c)
			flag--;
	}

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

	return 0;
}

Measured memory_bytes: 128
W,H,N=map(int,input().split())
l=[list(map(int,input().split())) for i in range(N)]
l_s,b_s = 0,0
r_s,u_s = W,H
for i in range(N):
    if l[i][2]==1 and l_s < l[i][0]:
        l_s =l[i][0]
    elif l[i][2]==2 and r_s > l[i][0]:
        r_s = l[i][0]
    elif l[i][2]==3 and b_s < l[i][1]:
        b_s = l[i][1]
    elif l[i][2]==4 and u_s > l[i][1]:
        u_s = l[i][1]
#print(r_s,l_s,u_s,b_s)
if (r_s-l_s)>0 and (u_s-b_s)>0:
    print((r_s-l_s)*(u_s-b_s))
else :
    print("0")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define endl "\n"
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

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

  int N; cin >> N;
  vec A(N); rep(i,N) cin >> A[i];

  int res = 0;
  reps(i, 1, N+1) {
    while(i<N && A[i-1]==A[i])i++;    // これをしないと，同じ値が続いた場合に下の2つの分岐で分けることができない．

    if(A[i-1]<A[i]) {
      while(i<N && A[i-1]<=A[i])i++;
    }
    else if(A[i-1]>A[i]) {
      while(i<N && A[i-1]>=A[i])i++;
    }
    res++;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 1024
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    s = IS()
    n = len(s)
    for i in range(2,n,2):
        si = s[:n-i]
        sl = si[:(n-i)//2]
        sr = si[(n-i)//2:]
        if sl == sr:
            print(n-i)
            return None

if __name__ == '__main__':
    main()

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

typedef long long ll;
int main(){
    int n;
    cin>>n;
    if(n % 1000 == 0)
        cout<<"0"<<endl;
    else{
        int x = (n / 1000) + 1;
        x = 1000 * x;
        n = x - n;
        cout<<n<<endl;
    }
}

Measured memory_bytes: 3588
n = list(map(int, input().split()))

list = [list(input().split()) for i in range(n[0])]

yen = 0
btc = 380000
for row in list:
    if row[1] == 'JPY':
        yen += int(row[0])
    else:
        yen += float(row[0]) * btc

print(yen)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <map>
#include <queue>
#include <set>
using namespace std;
#define so(Dwarf) sort(Dwarf.begin(), Dwarf.end());
#define star(a,n) long   *a=new long  [n];
#define  m(a,b,s) memset(a,b,s);
#define NOLIMT ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
void right() {
	cout << "YES";
	exit(0);
}
void p(int num) {
	cout << num << "\n";
}
vector<vector<int>>g;
int dp[100005];
int dfs(int v) {
	if (dp[v])return dp[v];
	int ans = 0;
	for (int i = 0; i < g[v].size(); i++) {
		ans = max(ans, dfs(g[v][i])+1);
	}
	return dp[v] = ans;
}
int main(void) {
	NOLIMT;
	int n, m;
	cin >> n >> m;
	g.resize(n + 1);
	int x, y;
	while (m--) {
		cin >> x >> y;
		g[x].push_back(y);
	}
	int ans=0;
	for (int i = 1; i <=n; i++) {
		if (dp[i] == 0)ans = max(ans, dfs(i));
	}
	p(ans);
}

Measured memory_bytes: 8192
while 1:
    w,h = map(int,raw_input().split())
    if w == h == 0:
        break
    for i in range(w):
        if i % 2 == 0:
            if h % 2 == 0:
                print ("#"+".")*(h/2)
            else:
                print ("#"+".")*(h/2)+"#"
        else:
            if h % 2 == 0:
                print ("."+"#")*(h/2)
            else:
                print ("."+"#")*(h/2)+"."
    print ""

Measured memory_bytes: 6440
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long ll;

const ll INF=0x3fffffffffffffffll;

ll n;

inline ll min(ll a,ll b){return a<b?a:b;}

inline ll get_phi(ll x)
{
    ll res=x;
    for(int i=2;i<=x/i;i++)
        if(x%i==0)
        {
            res-=res/i;
            while(x%i==0)x/=i;
        }
    if(x>1)res-=res/x;
    return res;
}

ll qmi(ll k,ll mod)
{
    ll res=1,a=10;
    while(k)
    {
        if(k&1)res=res*a%mod;
        a=a*a%mod;
        k>>=1;
    }
    return res%mod;
}

int main()
{
    scanf("%lld",&n);
    if(n%10)
    {
        if(n%7==0)n/=7;
        n*=9;
        ll phi=get_phi(n),res=INF;
        for(ll i=1;i<=phi/i;i++)
            if(phi%i==0)
            {
                if(qmi(i,n)==1)res=min(res,i);
                else if(qmi(phi/i,n)==1)res=min(res,phi/i);
            }
        printf("%lld\n",res==INF?-1:res);
    }
    else puts("-1");
    return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int a, b;
  cin >> a >> b;
  int ans = 0;
  for(int i=0; i<(b - a); i++)
    ans += i+1;
  cout << ans - b << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<stack>
#include<set>
using namespace std;
#define pb push_back
#define POP pop_back()
#define ll long long
#define db double
#define POP pop_back()
#define endl '\n'
#define PII pair<int,int>
#define FI first
#define SE second
#define VI vector<int>
#define QI queue<int>
#define SI stack<int>
#define debug cout<<"debug"<<endl;
#define PLL pair<ll,ll>
#define PDD pair<double,double>
#define ULL unsigned long long
#define fo(i,a,b) for (int i=a;i<=b;++i)
#define fd(i,a,b) for (int i=a;i>=b;--i)
#define mem(x,a) memset(x,a,sizeof(x))
const int maxn = 1e3 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int main(){
	ll ans = 0, x;cin >> x;
	ll cnt = 100;
	while(1){
		if(cnt >= x)break;
		cnt = cnt + cnt/100;
		ans++;
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 3620
def li():
    return list(map(int, input().split()))


if __name__ == '__main__':
    [n, k] = li()
    s = input()
    output = ""
    for index, si in enumerate(s):
        if index + 1 == k:
            output = output + si.lower()
        else:
            output = output + si
    print(output)


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(){
    
    int a,b;
    
    cin>>a>>b;
    
    if (a>b){
    cout<<"a > b"<<endl;
    
    }
    else if (a<b){
        
        cout<<"a < b"<<endl;
    }
        else{
        
            cout<<"a == b"<<endl;
        }
        
        return 0;
    }


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

using namespace std;

const vector<int64_t> divisor = {2, 3, 5};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T;
  cin >> T;
  for (int i = 0; i < T; i++) {
    int64_t N;
    vector<int64_t> X(4);
    cin >> N;
    for (int i = 0; i < 4; i++) {
      cin >> X[i];
    }
    int64_t res = INT64_C(1) << 58;
    priority_queue<pair<int64_t, int64_t>, vector<pair<int64_t, int64_t>>,
                   greater<pair<int64_t, int64_t>>>
        que;
    que.push(make_pair(0, N));
    set<int64_t> st;
    while (!que.empty()) {
      auto q = que.top();
      que.pop();
      int64_t c = q.first, n = q.second;
      if (c > res) continue;
      if (st.find(n) != st.end()) continue;
      if (n == 0) res = min(res, c);
      st.insert(n);
      for (int i = 0; i < 3; i++) {
        int64_t d = divisor[i];
        if (n % d == 0) {
          int64_t m = n / d, nc = c + X[i];
          if (n - m < (INT64_C(1) << 32)) nc = min(nc, c + (n - m) * X[3]);
          que.push(make_pair(nc, m));
        } else {
          int64_t m = (n / d) * d;
          que.push(make_pair(c + (n - m) * X[3], m));
          if (m + d < N + 100)
            que.push(make_pair(c + (m + d - n) * X[3], m + d));
        }
      }
    }
    cout << res << '\n';
  }
  return 0;
}


Measured memory_bytes: 6788
#include <iostream>
#include <cstdio>

using namespace std;


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

    long long n, m, d;
    cin >> n >> m >> d;
    double ans;
    if (d == 0) {
        ans = 1.0 / n * (m - 1);

    } else {
        ans = 2.0 * (n - d) / (n * n) * (m - 1);
    }
    printf("%.14lf\n", ans);
    return 0;
}

Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())
X = x2 - x1
Y = y2 - y1

if x2 > x1 or y2 > y1:
  x3, y3 = x2 - Y, y2 + X
  x4, y4 = x3 - X, y3 - Y

else:
  x3, y3 = x2 + abs(Y), y2 + X
  x4, y4 = x3 - X, y3 + abs(Y)

print(x3, y3, x4, y4)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define MAX 10000
using namespace std;

int main(){
  vector<int> vec(26, 0);
  string s;
  cin >> s;
  rep(i, 0, s.length()){
    vec[s[i]-'a']++;
  }
  rep(i, 0, 26){
    if(vec[i]==0){
      cout << char(i+'a') << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}

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

using namespace std;

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

    string s;
    cin >> s;
    int count = 0;
    for (char i : s) {
        count += (i == '2');
    }

    cout << count << '\n';

    return 0;
}


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

ll res = 0;
int N;
vector<int> v;
priority_queue<int> pq;

int main()
{
	scanf("%d", &N);
	v.resize(N);
	for(int i=0; i<N; i++)
		scanf("%d", &v[i]);
	sort(v.begin(), v.end());

	pq.push(v.back()); v.pop_back(); // 8 하나
	while(!v.empty())
	{
		int x = v.back(); v.pop_back();
		int val = pq.top(); pq.pop();
		res += val;
		pq.push(x); pq.push(x);
	}
	printf("%lld", res);
	return 0;
}

Measured memory_bytes: 5024
from sys import stdin
import math
import fractions

n = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]
b = [int(x) for x in stdin.readline().rstrip().split()]

cnt = 0
for i in range(len(b)):
    if a[i] < b[i]:
        cnt += a[i]
        b[i] -= a[i]
        a[i] = 0
        if a[i+1] < b[i]:
            cnt += a[i+1]
            a[i+1] = 0
        else:
            cnt += b[i]
            a[i+1] -= b[i]
    else:
        a[i] -= b[i]
        cnt += b[i]

print(cnt)

Measured memory_bytes: 20492
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
using namespace std;
map <int,int > m;
int sum;
int main()
{

    long long int num;
    scanf("%lld",&num);

    int num1 = num;



        for(long long int j=2; j<=sqrt(num); j++) //提供质因数
        {
            while(0 == (num%j))//循环判断质因数
            {
                if(0 == (num%j))//如果j是num的质因数
                {
                   m[j]++;
                   //cout<<j<<endl;
                }
                num = num / j;
            }
        }
        if(num!=1)
        {
            m[num]++;
        }

    map<int,int>::iterator iter;
   for (iter=m.begin(); iter!=m.end(); iter++)
    {

        int k=iter->second;
        //cout<<k<<endl;
        int q=1;
        while(k>0)
        {

            if((k-q)>=0)
            {
                sum++;
            }

            k=k-q; q++;
        }
    }
    cout<<sum<<endl;
    return 0;
}


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

int main(){
  ll N,count=0;
  cin>>N;
  vector<string> s(N);
  for(int i=0; i<N; i++){
    cin>>s[i];
    sort(s[i].begin(),s[i].end());
  }
  sort(s.begin(),s.end());
  ll huga=0;
  for(int i=0; i<N-1; i++){
    if(s[i]==s[i+1]){
      count=count+huga+1;
      huga++;
    }
    else{
      huga=0;
    }
  }
  cout<<count<<endl;
}
  

Measured memory_bytes: 6340
import math
a, b, h, m = map(int, input().split())
m_rad = 6 * m
h_rad = 0.5 * 60 * h + 0.5 * m
length = math.sqrt(a*a + b*b - 2*a*b*math.cos(math.radians(abs(m_rad - h_rad))))
print('{:.10f}'.format(length))


Measured memory_bytes: 9496
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

ll n,t[225816],a[123456],s[123456];

void update(ll p, ll x){
	while(p<225816ll){
		t[p] += x;
		p += (p&(-p));
	}
}

ll query(ll p){
	ll x=0ll;
	while(p){
		x += t[p];
		p -= (p&(-p));
	}
	return x;
}

ll f(ll x){
	ll i,ret=0ll;
	fill(t,t+225816,0ll);
	s[0] = 111111ll;
	for(i=0; i<n; ++i){
		s[i+1] = s[i];
		if(a[i] < x){
			--s[i+1];
		}else{
			++s[i+1];
		}
	}
	for(i=0; i<=n; ++i){
		ret += query(s[i]);
		update(s[i],1ll);
	}
	return ret;
}

int main(void){
	ll i,l=0ll,r=(ll)(1e10),m,q;
	fill(t,t+225816,0ll);
	cin >> n;
	for(i=0ll; i<n; ++i){
		cin >> a[i];
	}
	if(n==1ll){
		cout << a[0] << endl;
		return 0;
	}
	q = (n+1)*n/4;
	while(r-l>1ll){
		m = (l+r)/2;
		if(f(m) < q){
			r = m;
		}else{
			l = m;
		}
	}
	cout << l << endl;
	return 0;
}


Measured memory_bytes: 3584
/*  ex7_1 Ruined Square
    pandacodeb  */

#include <stdio.h>
#include <stdlib.h>

typedef struct point{
    int x_elem;
    int y_elem;
}point;

point shift_point(point p, int xshift, int yshift);

int main(void){
    point p1, p2, p3, p4;
    scanf("%d %d %d %d", &p1.x_elem, &p1.y_elem, &p2.x_elem, &p2.y_elem);
    int xshift = p2.x_elem - p1.x_elem;
    int yshift = p2.y_elem - p1.y_elem;
    p3 = shift_point(p2, -yshift, xshift);
    p4 = shift_point(p3, -xshift, -yshift);
    printf("%d %d %d %d\n", p3.x_elem, p3.y_elem, p4.x_elem, p4.y_elem);
    return 0;
}

point shift_point(point p, int xshift, int yshift){
    point p_shift = {p.x_elem + xshift, p.y_elem + yshift};
    return p_shift;
}

Measured memory_bytes: 1696
#include <bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define pb push_back
#define ff first
#define ss second
#define sz size()
#define mp make_pair
#define p(x) cout<< x << " ";
#define pe(x) cout<< x << endl ;
#define int long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROR(i,a,b) for(int i=a;i>=b;i--)
const int N = 1e5 + 5;
#define M 1000000007
int32_t main()
{
    FAST
    int n,cnt=0;
    cin>>n;
    int a[n];
    FOR(i,0,n)
    cin>>a[i];
    sort(a,a+n);
    int x=a[n/2];
    int y=a[n/2-1];
    cout<<(long)(x-y);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    int res = 0;
    rep(i, n){
        int l, r; cin >> l >> r;
        res += (r - l + 1);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,Z,W,H,sum=0,num=0,flag=0;string S,T;
  cin >> N >> M;
  Vec(P,lli,M,0);
  Vec(Q,pint,M,pint(0,0));
  Vec(ans,string,M,"");
  Vec(dis,lli,N,1);
  rep(i,0,M){
    cin >> P[i];
    cin >> Q[i].first;
    Q[i].second=i;
  }
  Sort(Q);
  rep(i,0,M){
    S=to_string(P[Q[i].second]);
    T=to_string(dis[P[Q[i].second]-1]);
    rep(j,0,6-S.size())ans[Q[i].second]+='0';
    ans[Q[i].second]+=S;
    rep(j,0,6-T.size())ans[Q[i].second]+='0';
    ans[Q[i].second]+=T;
    dis[P[Q[i].second]-1]++;
  }
  rep(i,0,M)Out(ans[i]);
}


Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 2019;

struct mint {
  ll x; //
  mint(ll x=0):x((x%mod+mod)%mod){}
  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;
  }
};

long long ama(int num, int keta){
  //10のketa乗を2019で割ったあまりかけるnum
  mint n=10;
  mint m=n.pow(keta)*num;
  return m.x;
}

int main(){
  string s;
  cin >> s;
  long long ans=0;
  map<int, int> mp;
  
  int amari[200005];//i桁目までの余り
  amari[0]=0;
  mp[0]++;
  for(int i=1;i<=s.size();i++){
    int tmp=s[s.size()-i]-'0';
    amari[i]=(amari[i-1]+ama(tmp, i))%2019;
    mp[amari[i]]++;
  }
  // for(int i=0;i<=s.size();i++)cout << "[" << amari[i] << "]";

  for(int i=0;i<2019;i++){
    // if(mp[i]>0){
    //   cout << "[" << mp[i] << "]";
    // }
    ans += mp[i]*(mp[i]-1)/2;
  }

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


Measured memory_bytes: 4536
// Created by Davidia on 2018-12-17.
//

// copyright@ Dr. Davidia


#include <bits/stdc++.h>

using namespace std;

int costs(int i, int j, vector<int> &heights){
    return abs(heights.at(i) - heights.at(j));
}

int main(){
    int n,k; cin >> n >> k;
    vector<int> heights(n);
    for (int i = 0; i < n; i++)
        cin >> heights.at(i);

    
    vector<int> dp(n,0);
    /*
    for (int i = 1; i < n; i++){
        dp.at(i) = INT_MAX;
        for (int j = i-1; j > i-k && j >= 0; j--){
            dp.at(i) = min(dp.at(i), dp.at(j) + costs.at(i).at(j));
        }
    }
    cout << dp.at(n-1) << '\n';*/

    for (int i = n-2; i >= 0; i--){
        dp.at(i) = INT_MAX;
        for (int j = i+1; j < n && j <= i+k; j++){
            dp.at(i) = min(dp.at(i), dp.at(j) + costs(i,j,heights));
        }
    }
    cout << dp.at(0) << '\n';


    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
//import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int r = sc.nextInt();
		
		System.out.println(n >= 10 ? r : r + (100 * (10 - n)));
	}
}


Measured memory_bytes: 35468
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;
namespace AtCoder
{
    class Abc162F
    {

        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());

             if(n%2==0)
               Console.Write(n/2); 
              else
                 Console.Write((n/2)+1);
            Console.WriteLine();

        }
    }
}


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

#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.bigin(), a.end())
#define rep(i,n) for(int i = 0; i < (n); i++)
#define Srep(i,a,n) for(int i = (a); i < (n); i++)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vector<int>>
#define vvi64 vector<vector<int64_t>>

using namespace std;

int main(){
    int a, b, ans = 0;
    cin >> a >> b;
    rep(i,2){
        if(a < b){
            ans += b;
            b--;
        }else{
            ans += a;
            a--;
        }
    }
    cout << ans << endl;
}

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

int main(){
    int n;
    cin>>n;
    int a[n];
    ll sum=0;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<n-1;i++)sum+=a[i];
    sum+=a[n-1]/2;
    cout<<sum;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int i;
  string s;
  cin >> s;
  int ans=0;
  for(i=0;i<s.size();i++){
  if(i%2==0 && s[i]=='L'){
cout << "No" << endl;
    return 0;
  }else if(i%2==1 && s[i]=='R'){
  cout << "No" << endl;
    return 0;
  }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
 
using namespace std;

int main(){
    
    long long data[31];
    
    data[1]=1;
    data[2]=2;
    data[3]=4;
    
    for(int i=4; i < 31; i++){
        data[i] = data[i-1] + data[i-2] + data[i-3];
    }
    
    int n,y;
    
    while(true){
        scanf("%d",&n);
        if(n == 0)break;
 
        y = 0;
 
        y += data[n]/3650;
        
        if(data[n]%3650 > 0){
            y = y + 1;
        }
        
        printf("%d\n",y);
    }
 
    return 0;
}


Measured memory_bytes: 2556
import math;
n,d = map(int,input().split())
x = list(list(map(int,input().split()))for i in range(n))
ans = 0
l = 0
for i in range(n):
    for j in range(i+1,n):
        for k in range(d):
            l+=(x[i][k]-x[j][k])**2
        l=math.sqrt(l)
        if l.is_integer():
            ans+=1
        l = 0
print(ans)

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

int main(){
  int K,S;
  cin>>K>>S;
  int res=0;
  for(int X=0;X<=min(K,S);++X){
    if(S-X>=0 && S-X<=K) res += (S-X)+1;
    else if(S-X>K && S-X<=2*K) res += 2*K-(S-X)+1;
  }
  cout<<res<<endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

H, W = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]
for k in range(10):
    for i in range(10):
        for j in range(10):
            C[i][j] = min(C[i][j], C[i][k]+C[k][j])
ans = 0
for i in range(H):
    for j in range(W):
        if A[i][j] != -1:
            ans += C[A[i][j]][1]
print(ans)


Measured memory_bytes: 74000
#include <iostream>

using namespace std;
typedef long long LL;
int M, N;

LL exp_mod(int a, int b, int p) {
	LL res = 1;
	while(b != 0) {
		if(b&1) res = (res * a) % p;
		a = a * a % p;
		b >>= 1;
	}
	return res;
}
int C(LL a, LL b, LL p) {
	if(a < b) return 0;
	if(a == b) return 1;
	if(b > a - b) b = a - b;
	LL ans = 1, ca = 1, cb = 1;
	for(LL i = 0; i < b; i++) {
		ca *= (a - i) % p;
		cb *= (b - i) % p;
	}
	ans = (ca * exp_mod(cb, p - 2, p));
	return ans;
}

LL Lucas(int n, int m, int p) {
	LL ans = 1;
	
	while(n && m && ans) {
		ans = (ans * C(n % p, m % p, p)) % p;
		n /= p;
		m /= p;
	}
	return ans;
}
LL x[100010];
LL y[100010];

void run() {
	int n, m;
	
	while(cin >> n >> m) {
			LL p = 1000000007;
			
			for(int i = 1; i <= n; ++i) 
				cin >> x[i];
			for(int i = 1; i <= m; ++i) 
				cin >> y[i];
				
			LL x_sum = 0;
			LL y_sum = 0;
			for(int i = 1; i <= n; ++i) {
				x_sum += ((i - 1) * x[i] - (n - i) * x[i] );
				x_sum %= p;
			}
			for(int i = 1; i <= m; ++i) {
				y_sum += y[i] * (2 * i - 1 - m) % p;
				y_sum %= p;
			}
			LL ans = y_sum * x_sum % p;
			cout << ans << endl;
	}
	
}
int main(int argc, char *argv[]) {
	//freopen("data.txt", "r", stdin);
	run();
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, k;
  cin >> n >> k;
  map<int, int> m;
  for(int i=0; i<n; i++){
    int c;
    cin >> c;
    m[c]++;
  }
  vector<int> v(n);
  for(int i=1; i<=n; i++){
    v[i-1] = (m[i]);
    //cout << m[i] << " ";
  }
  sort(v.begin(), v.end());
  int ans = 0;
  for(int i=0; i<n-k; i++){
    ans += v[i];
    //cout << v[i] << endl;
  }
  cout << ans << endl;
  return 0;
}  

Measured memory_bytes: 10368
#include <stdio.h>
#include <algorithm>
#include <utility>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp make_pair
#define INF (1<<28)
inline void cmin(int &a, int b) { if (a > b) a = b; }

int N, M;
pair<int, int> ps[128];
int dp[128];

int main() {
    scanf("%d%d", &N, &M);
    rep (i, M) {
        int x, y;
        scanf("%d%d", &x, &y);
        ps[i] = mp(x-1, y-1);
    }
    sort(ps, ps+M);
    rep (i, 128) dp[i] = INF;
    dp[0] = 0;
    rep (k, M) {
        for (int i = ps[k].first; i < N; i++) {
            cmin(dp[ps[k].second+1], dp[i] + 1);
        }
    }
    if (dp[N] == INF) puts("Impossible");
    else printf("%d\n", dp[N]);
    return 0;
}

Measured memory_bytes: 1028
kazu = int(input())
word = input()
score = word.split()

maxn = 10**18
zero = 0
answer = 1
scin = [0]*kazu

for i in range(kazu):
    scin[i] = int(score[i])
    if scin[i] == 0:
        zero = 1
if zero == 1:
    answer = 0
else:
    for j in range(kazu):
        answer *= scin[j]
        if answer > maxn:
            answer = -1
            break
print(answer)

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

int main() {
    string s;
    cin >> s;
    int a = s[0] - '0', b = s[1] - '0', c = s[2] - '0', d = s[3] - '0';
    string ans;
    if(a + b + c + d == 7) {
        ans = to_string(a) + '+' + to_string(b) + '+' + to_string(c) + '+' + to_string(d) + '=' + '7'; 
    } else if(a - b + c + d == 7) {
        ans = to_string(a) + '-' + to_string(b) + '+' + to_string(c) + '+' + to_string(d) + '=' + '7'; 
    } else if(a + b - c + d == 7) {
        ans = to_string(a) + '+' + to_string(b) + '-' + to_string(c) + '+' + to_string(d) + '=' + '7'; 
    } else if(a - b - c + d == 7) {
        ans = to_string(a) + '-' + to_string(b) + '-' + to_string(c) + '+' + to_string(d) + '=' + '7'; 
    } else if(a + b + c - d == 7) {
        ans = to_string(a) + '+' + to_string(b) + '+' + to_string(c) + '-' + to_string(d) + '=' + '7'; 
    } else if(a + b - c - d == 7) {
        ans = to_string(a) + '+' + to_string(b) + '-' + to_string(c) + '-' + to_string(d) + '=' + '7'; 
    } else if(a - b + c - d == 7) {
        ans = to_string(a) + '-' + to_string(b) + '+' + to_string(c) + '-' + to_string(d) + '=' + '7'; 
    } else if(a - b - c - d == 7) {
        ans = to_string(a) + '-' + to_string(b) + '-' + to_string(c) + '-' + to_string(d) + '=' + '7';
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int H, W, N;
    cin >> H >> W >> N;
    vector<int> X(N + W), Y(N + W);
    rep(i, N) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        X[i] = x;
        Y[i] = y;
    }
    rep(w, W) {
        X[N + w] = H;
        Y[N + w] = w;
    }

    vector<int> idx(N + W);
    iota(all(idx), 0);
    sort(all(idx), [&](int l, int r) { return X[l] == X[r] ? Y[l] < Y[r] : X[l] < X[r]; });

    int D = 0;
    rep(i, N + W) {
        if (Y[idx[i]] < X[idx[i]] - D) {
            int ans = X[idx[i]];
            write(ans);
            return 0;
        }
        else if (Y[idx[i]] == X[idx[i]] - D) {
            D++;
        }
    }
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

vvi g;
vvi q(3);
vvi col(2);

void dfs(int v, int pr, int t) {
  col[t].push_back(v);
  for (int nv : g[v]) if (nv != pr) {
    dfs(nv, v, (t + 1) % 2);
  }
}

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n;
  cin >> n;
  g.resize(n);
  col.resize(n);
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i = 1; i <= n; ++i) q[i % 3].push_back(i);
  dfs(0, -1, 0);
  vi res(n);
  if (col[0].size() > col[1].size()) swap(col[0], col[1]);
  cerr << col[0].size() << ' ' << col[1].size() << endl;
  if (col[0].size() <= q[0].size()) {
    for (int t = 0; t < 2; ++t) {
      for (int x : col[t]) {
        for (int r = 0; r < 3; ++r) if (!q[r].empty()) {
          res[x] = q[r].back();
          q[r].pop_back();
          break;
        }
      }
    }
  } else {
    for (int t = 0; t < 2; ++t) {
      for (int x : col[t]) {
        for (int r : {t + 1, 0}) if (!q[r].empty()) {
          res[x] = q[r].back();
          q[r].pop_back();
          break;
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) cout << res[i] << ' ';
  return 0;
}


Measured memory_bytes: 24728