akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

long long pow_mod(long long n, long long p, long long m)
{
    if (p == 0) {
        return 1;
    }

    if (p % 2 == 0) {
        long long t = pow_mod(n, p / 2, m);
        return t * t % m;
    }
    return n * pow_mod(n, p - 1, m) % mod;
}

long long nCr_mod(long long n, long long r)
{
    long long x = 1;
    for (long long i = n - r + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }

    long long a = 1;
    for (long long i = 1; i <= r; i++) {
        a *= i;
        a %= mod;
    }

    long long y = pow_mod(a, mod - 2, mod) % mod;

    return x * y % mod;
}

bool is_prime(long long n)
{
    if (n == 1) {
        return false;
    }

    for (long long i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            return false;
        }
    }

    return true;
}

int main()
{
    long long a, b;
    std::cin >> a >> b;

    std::cout << (a == b ? "Yes" : "No") << std::endl;
}


Measured memory_bytes: 256
s=input()
q=int(input())
h=0
m=''
u=''
for _  in range(q):
  d=input()
  if '2' in d:
    a,b,c=map(str,d.split())
    if b=='1':
      if h%2==0:
        m+=c
      else:
        u+=c
        
    else:
      if h%2==0:
        u+=c
      else:
        m+=c
        
  else:
    h+=1
    
M=list(m)
G=list(reversed(M))
GG=''.join(G)
s=GG+s+u
if h%2==0:
  print(s)
else:
  f=list(s)
  g=list(reversed(f))
  print(''.join(g))

Measured memory_bytes: 16076
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a, b, c = [tuple(map(int, input().split())) for i in range(3)]
    ans = 0
    pre = -2

    for i in a:
        ans += b[i-1]
        if pre + 1 == i:
            ans += c[pre-1]
        pre = i
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	
	ll N;
	cin >> N;
	vector<ll> A(N+2);
	A.at(0) = 0;
	A.at(N + 1) = 0;
	ll S=0;
	rep(i, N) {
		cin >> A.at(i+1);
		S += abs(A.at(i + 1) - A.at(i));
	}
	S+= abs(A.at(N + 1) - A.at(N));
	rep(i, N) {
		cout << S + abs(A.at(i + 2) - A.at(i)) - abs(A.at(i + 1) - A.at(i)) - abs(A.at(i + 2) - A.at(i + 1)) << endl;
	}
}

Measured memory_bytes: 4012
n = int(input())
d=[]
flg = False

for i in range(n)  :
    a=input()
    d.append(a.split())

# print(d)


for i in range(0,n-2) :
    if d[i][0] == d[i][1] and d[i+1][0] == d[i+1][1] and d[i+2][0] == d[i+2][1] :
        flg = True
        break


if flg == True :
    print('Yes')
else:
    print('No')

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

long  double a,b,c,ans,k,h,m,x,z,y,o,p;
string s;

int main(){
    cin>>a>>b>>h>>m;

    o=h*30+0.5*m;
    p=m*6;

    x=a*a+b*b-2*a*b*cos((M_PI/180)*(max(o,p)-min(o,p)));
    z=sqrtl(x);
    cout<<setprecision(15)<<z<<endl;


}


Measured memory_bytes: 4164
public class Main {

    public static void main(String[] args) throws Exception {
        var inputText = AtCoderReader.readInputText();
        var degree = Integer.parseInt(inputText);
        var roomTemperature = new RoomTemperature(degree);
        if (roomTemperature.isTooHot()) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    public static class RoomTemperature {
        private final int degree;

        public RoomTemperature(int degree) {
            this.degree = degree;
        }

        public boolean isTooHot() {
            if (degree >= 30) {
                return true;
            } else {
                return false;
            }
        }
    }

    public static class AtCoderReader {
        public static String readInputText() {
            try (var input = System.in) {
                return new String(System.in.readAllBytes()).trim();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
}

Measured memory_bytes: 32296
# /usr/bin/python
# -*- coding: utf-8 -*-
#
import sys


s = list(str(input()))
ret1 = 0
ret2 = 0

for i in range(len(s)):
  t = int(s[i])
  if i&1 == t:
    ret1 += 1
  if i&1 != t:
    ret2 += 1

print(min(ret1, ret2))


Measured memory_bytes: 49520
n = int(input())

x = []
u = []

for i in range(n):
    tmpx, tmpu = input().split()
    x.append(float(tmpx))
    u.append(tmpu)

ans = 0.0
for i in range(n):
    if u[i] == "JPY":
        ans += float(x[i])
    else:
        ans += float(x[i]) * 380000.0

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
    int D;
    
    scanf("%d",&D);
  
    if(D==25) printf("Christmas\n");
    else if(D==24) printf("Christmas Eve\n");
    else if(D==23) printf("Christmas Eve Eve\n");
    else printf("Christmas Eve Eve Eve\n");
  
    return 0;
}

Measured memory_bytes: 1644
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

int main() {
    int h, w;
    cin >> h >> w;
    int ch, cw, dh, dw;
    cin >> ch >> cw >> dh >> dw;
    ch--; cw--; dh--; dw--;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    vector<vector<int>> dist(h, vector<int>(w, INF));
    deque<P> q;
    dist[ch][cw] = 0;
    q.emplace_back(ch,cw);
    while (!q.empty()) {
      int i = q.front().first;
      int j = q.front().second;
      q.pop_front();
      int d = dist[i][j];
      rep(v,4) {
        int ni = i+di[v], nj = j+dj[v];
        if (ni<0||ni>=h||nj<0||nj>=w) continue;
        if (s[ni][nj] == '#') continue;
        if (dist[ni][nj] <= d) continue;
        dist[ni][nj] = d;
        q.emplace_front(ni,nj);
      }
      for (int ei = -2; ei <= 2; ei++) {
        for (int ej = -2; ej <= 2; ej++) {
          int ni = i+ei, nj = j+ej;
          if (ni<0||ni>=h||nj<0||nj>=w) continue;
          if (s[ni][nj] == '#') continue;
          if (dist[ni][nj] <= d+1) continue;
          dist[ni][nj] = d+1;
          q.emplace_back(ni,nj);
        }
      }
    }
    int ans = dist[dh][dw];
    if (ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9564
def main():
    N,K = map(int,input().split())
    h = list(map(int,input().split()))
    INF = 10**10
    DP = [INF]*N
    DP[0] = 0
    DP[1] = abs(h[1]-h[0])
    for i in range(2,N):
        DP[i] = min(DP[i-j] + abs(h[i-j]-h[i]) for j in range(1,min(K,i)+1))
    print(DP[-1])
    
if __name__ == "__main__":
    main()


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

int main() {
    int n;
    cin >> n;
    int ans = 0;
    rep(i, n){
        ans += to_string(i+1).length() % 2 == 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
use std::io;
use std::cmp;

// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}


fn main() {
    let n = read_line().parse::<i32>().unwrap();
    let mut aa = read_t_in_line::<i32>();
    let mut ans = 0;
    loop {
        let mut invalid = false;
        for mut a in aa.iter_mut() {
            if *a % 2 == 0 {
                *a /= 2;
            }
            else{
                invalid = true;
            }
        }
        if invalid {
            break;
        }
        ans +=1;
    }
    println!("{}", ans);

}


Measured memory_bytes: 4352
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	long long l,r;
	scanf("%lld %lld",&l,&r);
	if(l%2019==0||r%2019==0)
	{
		printf("0");
		return 0;
	}
	if(l/2019<r/2019)
	{
		printf("0");
		return 0;
	}
	long long pd=2019;
	for(long long i=l;i<=r;i++)
	{
		for(long long j=i+1;j<=r;j++)
		{
			pd=min(i*j%2019,pd);
		}
	}
	printf("%lld",pd);
	
}

Measured memory_bytes: 128
ABCD = input()

A = int(ABCD[0])
B = int(ABCD[1])
C = int(ABCD[2])
D = int(ABCD[3])


def get_op(num):
  if num == -1:
    _ = '-'
  else:
    _ = '+'

  return _
  

for x in [-1,1]:
  for y in [-1,1]:
    for z in [-1,1]:
      _ = A+x*B+y*C+z*D
      if _ == 7:
        op1 = get_op(x)
        op2 = get_op(y)
        op3 = get_op(z)        
        ans = str(A)+op1+str(B)+op2+str(C)+op3+str(D)+'=7'

print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll n; cin >> n;
  ll ans = 0;
  for (ll d = 1; d*(d+1) < n; d++) {
    if (n % d == 0) ans += n/d - 1;
  }
  outl(ans);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

using namespace std;

typedef pair<long long, long long> P;

int main(void)
{
  int N, M;
  cin >> N >> M;

  vector<P> store;

  for (int i = 0; i < N; ++i) {
    P temp;
    cin >> temp.first >> temp.second;
    store.push_back(temp);
  }

  sort(
    store.begin(),
    store.end(),
    [](const P& x, const P& y){ return x.first < y.first; }
  );

  long long sum = 0;
  auto itr = store.begin();
  while (M > 0) {
    if (M >= itr->second) {
      M -= itr->second;
      sum += itr->first*itr->second;
    }
    else {
      sum += itr->first*M;
      M = 0;
    }
    ++itr;
  }

  cout << sum << endl;

  return 0;
}

//00:35::00


Measured memory_bytes: 2420
#include <bits/stdc++.h>
const int N=100005;
typedef long long ll;
ll sum,s[N],b[N];
int n,m,a[N];
void modify(ll *a,int l,int r,int val){
	a[l]+=val,a[r+1]-=val;
}
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=2;i<=n;i++){
		int x=a[i-1],y=a[i];
		if (x>y){
			sum=sum+y+m-x;	
			modify(s,1,y,-(x-m)-1);
			modify(b,1,y,1);
			modify(s,x+1,m,-x-1);
			modify(b,x+1,m,1);
		}else{
			sum=sum+y-x;
			modify(s,x+1,y,-x-1);
			modify(b,x+1,y,1);
		}
	}
	ll ans=0;
	for (int i=1;i<=m;i++) b[i]+=b[i-1],s[i]+=s[i-1];
	for (int i=1;i<=m;i++) ans=std::max(ans,b[i]*i+s[i]);
	printf("%lld\n",sum-ans);
}

Measured memory_bytes: 2176
import sys
import math


prime_numbers = [2, 3, 5, 7]

def prime_numbers_under(num):
  global prime_numbers

  prime_number_max = max(prime_numbers)
  if prime_number_max > num:
    return prime_numbers

  for i in range(prime_number_max + 1, num + 1):
    check_max = math.floor(math.sqrt(i))
    for j in prime_numbers:
      if j <= check_max:
        if i % j == 0:
          break
    else:
      prime_numbers.append(i)

  return prime_numbers

def main():
  amount = 0

  length = int(input())
  for _ in range(0, length):
    i = int(input())
    check_max = math.floor(math.sqrt(i))
    for j in prime_numbers_under(check_max):
      if j <= check_max:
        if i % j == 0:
          break
    else:
      amount += 1

  print(amount)
  return 0


if __name__ == '__main__':
  main()

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

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}

using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}

int main(){
  string S;
  cin >>S;
  int Q;
  cin >> Q;
  vector<tuple<int,int,char>> t(Q);
  int r = 0;//反転回数
  rep(i,Q){
    int T;
    cin >> T;
    if(T == 1) {
      r++;
      get<0>(t[i]) = 1;
    }
    else if(T == 2){
      get<0>(t[i]) = 2;
      cin >> get<1>(t[i]) >> get<2>(t[i]);
    }
  }
  string vl;
  string vr;
    //T = 2の時、初め左右どちら側に追加され、その後何回反転するかを記録
  int cr = 0;//今まで何回反転したか
  rep(i,Q){
    if(get<0>(t[i]) == 1) cr++;
    
    if(get<0>(t[i]) == 2){
      int rr = r - cr;//残りの反転回数
      if(get<1>(t[i]) == 1){//初めて文字が追加された時、左側につく時
       if(rr%2 == 0){//残りの反転回数が偶数回なら左側のまま
        vl.push_back(get<2>(t[i]));
       }
       else{
        vr.push_back(get<2>(t[i]));
       }
      }
      else{//初めて文字が追加された時、右側
        if(rr%2 == 0){//残りの反転回数が偶数回なら右側のまま
         vr.push_back(get<2>(t[i]));
        }
        else{
          vl.push_back(get<2>(t[i]));
        }
      }
   }
  }
  reverse(vl.begin(),vl.end());
  if(r%2) reverse(S.begin(),S.end());
  
  string ans;
  ans = vl + S + vr;
  cout << ans << endl;
 }

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

using namespace std;
typedef long long int ll;

int main()
{
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for(int i = 0; i <= 999; i++)
    {
       int a = i / 100;
       int b = (i/10) % 10;
       int c = i % 10;
       int pa,pb,pc;
       pa = -1,pb = -1, pc = -1;
       int j = 0;
       while(pa == -1)
       {
           if(j >= s.length()) break;
           if(a == s[j] - '0') pa = j;
           j++;
       }
       while(pb == -1)
       {
           if(j >= s.length()) break;
           if(b == s[j] - '0') pb = j;
           j++;
       }
       while(pc == -1)
       {
           if(j >= s.length()) break;
           if(c == s[j] - '0') pc = j;
           j++;
       }
       if(pa != -1 && pb != -1 && pc != -1) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3640
program main
    implicit none
    integer n,k,sum,i
    integer, allocatable :: p(:)
    read(*,*) n,k
    allocate(p(n))
    read(*,*) p
    call heapsort(n,p)
    sum=0
    do i=1,k
        sum=sum+p(i)
    enddo
    write(*,*)sum
end program main

subroutine heapsort(n,array)
    implicit none
    integer,intent(in) :: n
    integer,intent(inout) :: array(1:n)
   
    integer ::i,k,j,l
    integer :: t
   
    if(n.le.0)then
       write(6,*)"Error, at heapsort"; stop
    endif
    if(n.eq.1)return
  
    l=n/2+1
    k=n
    do while(k.ne.1)
       if(l.gt.1)then
          l=l-1
          t=array(L)
       else
          t=array(k)
          array(k)=array(1)
          k=k-1
          if(k.eq.1) then
             array(1)=t
             exit
          endif
       endif
       i=l
       j=l+l
       do while(j.le.k)
          if(j.lt.k)then
             if(array(j).lt.array(j+1))j=j+1
          endif
          if (t.lt.array(j))then
             array(i)=array(j)
             i=j
             j=j+j
          else
             j=k+1
          endif
        enddo
        array(i)=t
    enddo
end subroutine heapsort


Measured memory_bytes: 2800
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int INF = 1e9 + 7;


ll A,B,N;
ll a[51], b[51], c[51], d[51];
ll ans = 0;

int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	cin >> A >> B >> N;

	ll u = min(B - 1, N);
	cout << (A*u) / B<<endl;

	return 0;
}


Measured memory_bytes: 3156
#include <stdio.h>
using namespace std;
 
int main(){
    int a,b,c;
    int cnt=0;
    scanf("%d %d %d",&a,&b,&c);
    // for(int i=a;i<=b;i++){
    //     if(c%i==0){
    //         cnt++;
    //     }
    // }
    for(a;a<=b;a++){
        if(c%a==0){
            cnt++;
        }
    }
    printf("%d\n",cnt);
}


Measured memory_bytes: 2736
#include <bits/stdc++.h>
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define eb emplace_back
#define uqv(v) v.erase(unique(all(v)), v.end());
#define INF 1e9
#define LINF 1e18

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

int arr[2020];

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

	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> arr[i];
	}
	sort(arr+1, arr+n+1);

	long long ans = 0;
	for(int i = 3; i <= n; i++) {
		for(int j = 2; j < i; j++) {
			ans += max(0LL, (long long)(arr + j - upper_bound(arr+1, arr+n+1, arr[i] - arr[j])));
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.Math.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
        int n = sc.nextInt();

        int max = Math.max(h, w);
        int cnt = (int) Math.ceil((double) n/max);
      
      System.out.println(cnt);
	}
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=1000000007;
ll a[100100],b[100100];
ll n,m,ans=1;
int main()
{
    a[0]=0;a[1]=1;a[2]=1;b[0]=-1;
    for(int i=3;i<100100;i++) a[i]=(a[i-1]+a[i-2])%mod;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        scanf("%d",&b[i]);
        ans=(ans*a[b[i]-b[i-1]-1])%mod;
    }
    ans=(ans*a[n-b[m]])%mod;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
int main() {
	double a, b;
	int x;
	cin >> a >> b >> x;
	double rad = acos(-1) * x / 180.0;
	double s = sin(rad) * a * b / 2.0;
	printf("%.10lf\n", s);
	double c = sqrt(pow(a, 2.0) + pow(b, 2.0) - 2.0 * a * b * cos(rad));
	printf("%.10lf\n", a + b + c);
	printf("%.10lf\n", 2.0 * s / a);
	return 0;
}

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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    int x[5];
    int ans;
    fo(i, 5) {
        cin >> x[i];
        if ( x[i] == 0 ) ans = i + 1;
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  string S, T;
  cin >> S >> T;
  int ans = INT_MAX;
  for (int i = 0; i + T.size() - 1 < S.size(); i++) {
    int tmp = 0;
    for (int j = 0; j < T.size(); j++) {
      if (S.at(i + j) != T.at(j)) tmp++;
    }
    ans = min(ans, tmp);
  }
  cout << ((ans == INT_MAX) ? T.size() : ans) << "\n";
}

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

#define LL long long int
#define mp make_pair
#define FOR(i, n) for(i = 0; i < n; ++i)
typedef vector <int> vi;
typedef vector <LL> vll;
typedef pair<LL, LL> iPair;
const int MOD = 1e9+7;

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

    LL t = 1;
    LL i,j;
    // cin>>t;
    
    while(t--)
    {
        int n;
        cin>>n;
        vi seq(n);
        vi arr(n);
        vi brr(n-1);
        FOR(i, n) cin>>seq[i];
        FOR(i, n) cin>>arr[i];
        FOR(i, n-1) cin>>brr[i];

        int ans = 0;
        FOR(i, n) ans += arr[seq[i]-1];
        for(int i = 1; i < n; ++i)
        {
            if((seq[i] - seq[i-1]) == 1)
            {
                ans += brr[seq[i-1]-1];
            }
        }
        cout<<ans;

    }

	return 0;
}


Measured memory_bytes: 256
n = int(input())
arr = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for i in range(n):
    s = input().split(" ")
    nums = list(map(int, s))
    arr[nums[0]-1][nums[1]-1][nums[2]-1] += nums[3]
for k in range(4):
    for j in range(3):
        for i in range(10):
            print(" {0}".format(arr[k][j][i]),end="")
        print("")
    if k < 3:
        for l in range(20):
            print("#",end="")
        print("")

Measured memory_bytes: 7696
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;

int main() {
    int n,m,k;
    cin >> n >> m >> k;
    bool can = false;
    for(int i=0;i<=m;i++){ //たて
        for(int j=0;j<=n;j++){ //よこ
            int on = i*(n-j)+j*(m-i);
            if(on==k) can = true;
        }
    }
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n,q,max=0;
    cin>>n>>q;
    int y;
    string name,ans="kogakubu10gokan";
    for(int i=0;i<n;i++){
        cin>>y>>name;
        if(y<=q&&max<y){
            ans=name;
            max=y;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3212
using namespace std;
#include<string>
#include<cmath>
#include<list>
#include <map>
#include <unordered_map>
#include <set>
#define ll long long
#define ld long double
#define ull unsigned long long
#define ml map<ll,ll>
#define pb push_back
#define mp make_pair
#define ppl pair<ll,ll>
#define F first
#define S second
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

#define fr(i,a,b) for(ll i=a;i<b;i++)
#define ffr(i,a,b) for(ll i=a;i>=b;i--)
#include<bits/stdc++.h>
#include<vector>
#define vl vector<ll>
#define PI 3.141592654
const ll N = 1e9 + 7;
#include<iterator>
#define EPSILON numeric_limits<double>::epsilon()



// vector<bool> visited;
// vector<vl> v;
// ll cnt[2];

// void dfs(ll pnt, ll col) {
// 	visited[pnt] = true;
// 	cnt[col]++;
// 	fr(i, 0, v[pnt].size()) {
// 		if (!visited[v[pnt][i]])dfs(v[pnt][i], !col);
// 	}
// }



int gcd(int a, int b) {
	if (a == b)return a;
	if (a % b == 0)return b;
	if (b % a == 0)return a;
	if (b > a)return gcd(a, b % a);
	if (a > b)return gcd(a % b, b);
	return 0;
}





void solve() {
	string s; cin >> s;
	cout << s;
	if (s[s.size() - 1] == 's')cout << "es";
	else cout << "s";
}






int main() {
	fio;
#ifndef ONLINE_JUDGE
	// for getting input
	freopen("input.txt", "r", stdin);
	//for writing output
	freopen("jout.txt", "w", stdout);
#endif
	//precompute();
	ll t;
	if (1)
		t = 1;
	else
		cin >> t;
	while (t--) {
		//cout << "Case #" << h << ": ";
		solve();
		//h++;
		cout << '\n';
	}
	return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
#define abs(a)(a>0?a:-(a))
#define ctz(x)__builtin_ctz(x)
#define swap(x,y)(x^=y^=x^=y)

int mgcd(int u,int v){
  int s,r,b;
  b=ctz(u|v);
  u>>=ctz(u);v>>=ctz(v);

  if(u<v)swap(u,v);
  while (v){
    r=u%v;
    s=v-r;
    r>>=ctz(r);
    s>>=ctz(s);
    if (s<r) {u=r; v=s; }else {u=s; v=r; };
  }

  return (u&~-v)+v << b;
}


int main(){
  int N,X,x0,x1;
  scanf("%d%d%d",&N,&X,&x0);
  x0=abs(x0-X);
  while(--N){
    scanf("%d",&x1);
    x0 = mgcd(x0,abs(x1-X));
  }
  printf("%d\n",x0);
}

Measured memory_bytes: 128
H, W = map(int, input().split())
A = [list(input()) for i in range(H)]
h = 0
w = 0
ans = 'Possible'
for i in range(H):
  for j in range(W):
    if A[i][j] == '#':
      if (i == h and j - w < 2) or (i - h < 2 and j == w):
        h = i
        w = j
      else:
        ans = 'Impossible'
print(ans)
      

Measured memory_bytes: 9076
#include<stdio.h>
#include<string.h>

#define BUFF 101

int main(void){
    int n;
    char s[BUFF],t[BUFF];
    char ans[BUFF*2];

    scanf("%d",&n);
    scanf("%s %s",s,t);

    int i;
    for(i=0;i<n;i++){
        ans[i*2] = s[i];
        ans[i*2+1] = t[i];
    }
    ans[n*2] = '\0';

    printf("%s\n",ans);
    return 0;
}

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

using namespace std;

typedef struct {
    int index;
    string address;
    int score;
} Restaurant;

int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    
    vector<Restaurant> list;
    for (int i = 0; i < N; i++) {
        Restaurant t_restaurant;
        cin >> t_restaurant.address >> t_restaurant.score;
        t_restaurant.index = i + 1;
        list.push_back(t_restaurant);
    }
    
    sort(list.begin(), list.end(), [](const Restaurant& r1, const Restaurant& r2) {
        if (r1.address == r2.address) {
            return r1.score > r2.score;
        } else {
            return r1.address < r2.address;
        }
    });
    
    for_each(begin(list), end(list), [](const Restaurant& r) {
        cout << r.index << endl;
    });
    
    return 0;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef int64_t ll; typedef vector<int> VI;typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;


int main()
{

	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;ll c,k;
	cin >>n >>c >>k;
	vector<ll> t(n);
	rep(i,n) cin >>t[i];
	
	sort(all(t));
	ll sm=0, lt=mod, ans = 0;
	rep(i,n){
		if(sm==0){
			lt = t[i]+k;
			sm=1;
		}else if(t[i]<= lt && sm+1< c ){
			sm++;
		}else if(t[i]<= lt && sm+1==c ){
			ans++;
			sm=0;
		}else{
			ans++;
			sm=1;
			lt=t[i]+k;
		}
		//printf("%d:%d:%d  ",i,sm,ans);
	}
	if(sm>0) ans++;
	
	cout << ans <<endl;
	
	return 0;

}


Measured memory_bytes: 1024
var i:Longint;
s:String;
function f(c:char):char;
begin
f:=chr(ord(c)-32);
end;
begin
readln(s);
write(f(s[1]));
i:=1;
while s[i]<>' 'do inc(i);
inc(i);
write(f(s[i]));
while s[i]<>' 'do inc(i);
writeln(f(s[i+1]));
end.

Measured memory_bytes: 128
a, b = map(int, input().split())
temp = 0
bar_heights = []
for i in range(1, 1000):
    temp += i
    bar_heights.append(temp)

for i in range(1, 499501):
    if (a + i) in bar_heights and \
       (b + i) == bar_heights[bar_heights.index(a + i) + 1]:
        print(i)
        break


Measured memory_bytes: 38768
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N, K = getNM()
red = N - K

def cmb(n, r):
    a = 1
    b = 1
    for i in range(r):
        a *= (n - i)
        b *= (i + 1)
    return a // b

for i in range(1, K + 1):
    ans = (cmb(red + 1, i) * cmb(K - 1, i - 1)) % mod
    print(ans)

Measured memory_bytes: 47068
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.ArrayList;

public class Main{
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] nums =  br.readLine().split("");
        
        int total;
        ArrayList<String> expr = new ArrayList<>();
        StringBuilder buff = new StringBuilder();
        
        for(int bit=0; bit<(1<<nums.length-1); bit++){
            total = Integer.parseInt(nums[0]);
            buff.append(nums[0]);
            for(int i=0; i<nums.length-1; i++){
                if((bit&1<<i)==1<<i){
                    total += Integer.parseInt(nums[i+1]);
                    buff.append("+" + nums[i+1]);
                } else if((bit&1<<i)==0){
                    total -= Integer.parseInt(nums[i+1]);
                    buff.append("-" + nums[i+1]);
                }
            }
            if(total==7)expr.add(buff.toString() + "=7");
            buff.delete(0, buff.length());
        }
        System.out.println(expr.get(0));
    }
}

Measured memory_bytes: 21332
#include <iostream>
#include <vector>
#include <cstring>
#include <queue>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;

const int INF = 100000000;

struct edge {
    int to, cost;
    bool operator<(const edge& r)const{
        return cost>r.cost;
    }
};

// state = edge
// struct state {
//     int from, d;
// };
vector<vector<edge> > G;
int V;

bool used[111];
int prim(){
    int sum=0;
    int es=0;
    memset(used,0,sizeof(used));
    priority_queue<edge> q;
    q.push({0,0});
    while(es!=G.size()){
        edge e=q.top(); q.pop();
        if(used[e.to])continue;
        es++;
        used[e.to]=1;
        int from=e.to;
        //cout<<" "<<from<<endl;
        sum+=e.cost;
        FOR(i,0,G[from].size()){
            q.push(G[from][i]);
        }
    }
    return sum;
}

int main(){
    int m;
    while(1){
        cin>>V>>m;
        if(!(m||V))break;
        G=vector<vector<edge> >(V);
        FOR(i,0,m){
            int a,b,cost;cin>>a>>b>>cost;
            G[a].push_back({b,cost});
            G[b].push_back({a,cost});
        }
        cout<<prim()<<endl;
    }
}

Measured memory_bytes: 1224
import java.util.Scanner;
import java.util.Random;
import java.util.Arrays;
import java.util.Comparator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.HashMap;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;

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


Measured memory_bytes: 23764
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		char c=s.charAt(0);
		if(Character.isUpperCase(c))
			System.out.print("A");
		else
			System.out.print("a");
	}
}


Measured memory_bytes: 26928
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
using namespace std;

int main(){
	long n,k;
	cin >> n >> k;
	vector<long> a(n,0);
	long hani=k-1;
	
	for(long i=0;i<n;i++){
		cin >> a[i];
	}
	
	/*
	long count_l,count_r;
	for(long i=0;i<n;i++){
		if(a[i]==1){
			count_l=i;
			count_r=n-1-i;
			break;
		}
	}
	
	long cost_l=(count_l+(hani-1))/hani;
	long cost_r=(count_r+(hani-1))/hani;
	*/
	long cost=((n-1)+(hani-1))/hani;
	
	cout << cost << endl;
	
	return 0;
}


Measured memory_bytes: 1024
import Data.Char
import Data.List

main = interact $ unlines . map (show . hierarchical_democracy) . tail . lines

hierarchical_democracy = head . extract . until decisive minimal . majority
 where decisive (_:x:_) = isDigit x

extract = map read . words . map (\x -> if isDigit x then x else ' ')

minimal xxs@(b:x1:x2:xs)
 | isDigit x1 = xxs
 | isDigit x2 = let (d,xs') = takeDistrict [] xxs in vote (extract d) ++ minimal xs' 
 | otherwise = b : minimal (tail xxs)
 where
  vote xs = "[" ++ show (sum (take (div (length xs + 1) 2) (sort xs))) ++ "]"
  takeDistrict acc (']':']':xs) = (reverse (']':']':acc), xs)
  takeDistrict acc (x:xs) = takeDistrict (x:acc) xs
minimal xs = xs

majority = concat . map half . groupBy digits
 where
  digits c1 c2 = isDigit c1 && isDigit c2
  half xs = if isDigit (head xs) then show (div (read xs + 1) 2) else xs

Measured memory_bytes: 5916
# frozen_string_literal: true
require 'prime'

n = gets.to_i

h = n.prime_division

def count(n)
  c = 0
  i = 1
  loop do
    break if n < i

    n -= i
    i += 1
    c += 1
  end
  c
end
sum = 0
if n == 1
  puts 0
  exit
end
h.each do |e|
  sum += count(e[1])
end

puts sum


Measured memory_bytes: 14452
//
//  main.cpp
//  atcoder94
//
//  Created by cfhaiteeh on 2018/4/14.
//  Copyright © 2018 cfhaiteeh. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#define LL long long
using namespace std;
const int maxn=123;
int bi[maxn];
int n,m,x;
void init(){
    memset(bi,0,sizeof(bi));
    for(int i=1;i<=m;i++){
        int a;
        scanf("%d",&a);
        bi[a]=1;
    }
}
int ans;
void play(){
    int sum1=0,sum2=0;
    for(int i=x;i>=1;i--){
        sum1+=bi[i];
    }
    for(int i=x;i<=n;i++){
        sum2+=bi[i];
    }
    ans=min(sum1,sum2);
}
void pri(){
    printf("%d\n",ans);
}
int main() {
    // insert code here...
    while(scanf("%d%d%d",&n,&m,&x)!=EOF){
        init();
        play();
        pri();
    }
    return 0;
}


Measured memory_bytes: 256
import math
import collections


def sosu(N):
    res = [0] * (N + 1)
    res[0] = res[1] = 1
    for i in range(2, math.ceil((math.sqrt(N)) + 1)):
        if res[i] != 0: continue
        for j in range(2, N):
            if i * j > N: break
            res[i * j] = 1
    return [i for (i, v) in enumerate(res) if v == 0]


N = int(input())
p_tbl = sosu(N)

counter = collections.Counter()
for i in range(2, N + 1):
    tmp = i
    for p in p_tbl:
        while tmp % p == 0 and tmp // p > 0:
            counter[p] += 1
            tmp = tmp // p
ans = 1
for v in counter.values():
    ans *= (v + 1)
    ans %= (10**9)+7
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define FORN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define FORR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll n;
	cin >> n;
	string s;
	cin >> s;

	vector<Vec> li(10);
	rep(i, n){
		ll m = s[i]-'0';
		li[m].pb(i);
	}

	ll ans = 0;
	rep(i, 10){
		if(li[i].empty()) continue;
		ll x = li[i][0];
		rep(j, 10){
			if(li[j].empty()) continue;
			if(upper_bound(all(li[j]), x) == li[j].end()) continue;
			ll p = upper_bound(all(li[j]), x)-li[j].begin();
			ll y = li[j][p];
			rep(k, 10){
				if(li[k].empty()) continue;
				if(upper_bound(all(li[k]), y) == li[k].end()) continue;
				else ans++;
			}
		}
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 768
A,B,K = map(int,input().split())
if A >= 1:
    if A >= K:
        A-=K
        print(str(A) + ' ' + str(B))
    else:
        #A = 0
        if B >= 1:
            if B-(K-A) >= 0:
                print(str(0) + ' ' + str(B-(K-A)))
            else:
                print(str(0) + ' ' + str(0))
else:
    if B >= K:
        B-=K
        print(str(0) + ' ' + str(B))
    else:
        print(str(0) + ' ' + str(0))

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    int n, k; cin >> n >> k;

    vector<int> l(n);
    for (int i = 0; i < n; ++i) {
        cin >> l[i];
    }

    sort(l.rbegin(), l.rend());

    int ans = 0;

    for (int i = 0; i < k; ++i) {
        ans += l[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
    int b[101];
int main()
{
    int a;
    cin>>a;
    char s;
    for (int i=1;i<=a;i++){
        cin>>s;
        if (s=='P') b[1]++;
        if (s=='W') b[2]++;
        if (s=='G') b[3]++;
        if (s=='Y') b[4]++;
    }
    int cnt=0;
    for (int i=1;i<=4;i++)
        if (b[i]>=1) cnt++;
    if (cnt==3) cout<<"Three";
    if (cnt==4) cout<<"Four";
    return 0;
}

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

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

  while(k) {
    if(a >= b) {
      b *= 2;
    }else if(b >= c) {
      c *= 2;
    }
    k--;
  }

  if(a < b && b < c) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>
int main()
{
    int i, w, l;
    char s[1010];
    gets(s);
    l=strlen(s);
    scanf("%d", &w);
    for(i=0; i<l; i=i+w)
        printf("%c", s[i]);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	map<int,int> ma;
	int n; cin>>n;
	for(int i=0;i<n;i++)
	{
		int x; cin>>x; ma[x]++;
	}
	int ans=0;
	for(auto it=ma.begin();it!=ma.end();it++)
	{
		if(it->se>=it->fi) ans+=it->se-it->fi;
		else ans+=it->se;
	}
	cout<<ans<<'\n';
}


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

using namespace std;

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  int left = A+B;
  int right = C+D;
  
  if (left < right)
    cout << "Right" << endl;
  else if (left > right)
    cout << "Left" << endl;
  else
    cout << "Balanced" << endl;
    
}

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

int main(){

	int n,m,i,j,swap;
	int a[100];
	
	cin >> n >> m;
	
	for (i=0;i<n;i++){
		cin >> a[i];
		}
	
	for (i=1;i<m+1;i++){
		for (j=0;j<n-1;j++){
			if ((a[j] % i) > (a[j+1] % i)){
				swap=a[j];a[j]=a[j+1];a[j+1]=swap;
				}
			}
		}
	
	for (i=0;i<n;i++){
		cout << a[i] << endl;
		}
	
	return 0;
	
}

Measured memory_bytes: 3104
#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 main(){
    vi v(3);
    rep(i, 3) cin >> v[i];
    sort(all(v));
    int cnt = 0;
    while(1) {
        if(v[0] == v[2]) break;
        if(v[1] == v[2]) {
            v[0] += 2;
        }
        else {
            v[0]++;
            v[1]++;
        }
        cnt++;
        sort(all(v));
    }
    cout << cnt << endl;
    return 0;
}

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

int N,D;
int X[21][21];
int main(){
    cin >> N >> D;
    for(int i=1;i<=N;i++) for(int j=1;j<=D;j++) cin >> X[i][j];
    int ans = 0;
    for(int i=1;i<N;i++) for(int j=i+1;j<=N;j++){
        int res = 0;
        for(int k=1;k<=D;k++) res += (X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
        bool ok = false;
        for(int t=0;t*t<=res;t++){
            if(t*t==res) ok = true;
        }
        ans += ok;
    }
    cout << ans << endl;
}

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

int main(){
    int x1,x2,x3,x4,y1,y2,y3,y4,a,b;
    cin>>x1>>y1>>x2>>y2;
    a=x1-x2;
    b=y1-y2;
    x3=x2+b;
    y3=y2-a;
    x4=x3+a;
    y4=y3+b;
    cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main (void){
   int a,b,c;
   cin >> a>>b>>c;
 
   if(a<b && b<c) {
       cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }
 
 
return 0;
 
}


Measured memory_bytes: 3108
#include<stdio.h>
#include<string.h>
int main(){
  int h,w,i,j,high=0,width=0,check;
  scanf("%d%d",&h,&w);
  char a[h+1][w+1],b[h+1][w+1];
  for(i=0;i<h;i++){
    scanf("%s",a[i]);
    check=0;
    for(j=0;j<w;j++)
      if(a[i][j]=='#')
        check=1;
    if(check==1)
      strcpy(b[high++],a[i]);
  }
  for(i=0;i<w;i++){
    check=0;
    for(j=0;j<high;j++)
      if(b[j][i]=='#')
        check=1;
    if(check==1){
      for(j=0;j<high;j++)
        a[j][width]=b[j][i];
      width++;
    }
  }
  for(i=0;i<high;i++){
    for(j=0;j<width;j++)
      printf("%c",a[i][j]);
    puts("");
  }
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};
long double eps = 1e-6;
long double pi = acos(-1);

ll mod = 998244353;
template<typename T> void add(T &a,T b){a=(a+b)%mod;}
template<typename T> void sub(T &a,T b){a=(a+mod-b)%mod;}

ll dp[333][333][333];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    string s;
    int k;
    cin>>s>>k;
    int n = s.size();
    int sum[n+1]={};
    int z = 0;
    int o = 0;
    for(int i=0;i<n;i++){
        if(s[i] == '0'){
            z++;
            sum[z+1] = sum[z];
        }
        else o++;
        sum[z+1] = o;
    }
    
    dp[0][0][0] = 1;
    for(int i=0;i<z;i++){
        for(int y=0;y<=min(k,o);y++){
            for(int j=sum[i];j<=min(o,sum[i]+k);j++){
                if(j-sum[i] > y)break;
                for(int p=max(j,sum[i+1]);p<=min(sum[i+1]+k,o);p++){
                    ll ret = dp[i][j][y];
                    int cnt = y;
                    int dif = p - j;
                    dif -= sum[i+1] - sum[i];
                    dif = max(0,dif);
                    cnt += dif;
                    if(cnt <= k){
                        add(dp[i+1][p][cnt],ret);
                    }
                    else break;
                }
            }
        }
    }
    ll ans = 0;
    for(int i=sum[z];i<=o;i++){
        for(int y=0;y<=min(o,k);y++){
            add(ans,dp[z][i][y]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 33736