akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;
int main()
{
    int num;
    cin >> num;

    vector<int> v;
    int current;
    for(int i=0;i<num*2;i++){
        cin >> current;
        v.push_back(current);
    }
    sort(v.begin(),v.end(),greater<int>());
    int ans=0;
    for(int i=0;i<num*2;i++){
        i ++;
        ans += v[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(unused)]

//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
//入力マクロここまで

//input
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;

use std::cmp::*;

fn main() {
    input! {
        h : u64,
        w : u64,
    }

    if h == 1 || w == 1 {
        println!("1");
        return;
    }

    let ans = if h % 2 == 0 {
        (h / 2) * w
    } else if w % 2 == 0 {
        h * (w / 2)
    } else {
        (h + 1) / 2 * w - (w / 2)
    };

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


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
void xin(){
	#ifndef ONLINE_JUDGE 
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
}
int f[100005] = {0};

int main()
{
	xin();
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  	char s;
  	cin>>s;

   	if(s>=65 && s<=90)
   		cout<<'A'<<endl;
   	else
   	{
   		cout<<'a'<<endl;
   	}
 }

Measured memory_bytes: 3656
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve(A, Q):
    N = len(A)
    A = A[::-1]

    s, es = [0] * (N + 1), [0] * (N + 1)
    for i in range(N):
        s[i + 1] = s[i] + A[i]
        es[i + 1] = es[i] + (A[i] if i % 2 == 0 else 0)

    x_list, sum_t_list = [], []
    for n in range((N - 1) // 2):
        x = (A[n + 1] + A[n * 2 + 2]) // 2 + 1
        sum_t = s[n + 1] + (es[N] - es[n * 2 + 2])
        x_list.append(x)
        sum_t_list.append(sum_t)

    x_list = x_list[::-1]
    sum_t_list = sum_t_list[::-1]

    for _ in range(Q):
        x = int(input())
        p = bisect_right(x_list, x)
        if p == 0:
            print(s[(N + 1) // 2])
        else:
            print(sum_t_list[p - 1])


def main():
    N, Q = map(int, input().split())
    A = list(map(int, input().split()))

    solve(A, Q)


if __name__ == '__main__':
    main()


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

int main(){
  int64_t a, b, c, d, x=0LL;
  cin >> a >>b>>c>>d;
  if(b>=0 && a>=0){
    if(c>=0&&d>=0)x=b*d;
    else if(c<0&&d<0)x=a*d;
    else x=b*d;
  }
  else if(b>=0 && a<0){
    if(c>=0&&d>=0)x=b*d;
    else if(c<0&&d<0)x=a*c;
    else x=max(a*c, b*d);
  }
  else if(b<0&&a<0){
    if(c>=0&&d>=0)x=b*c;
    else x=a*c;
  }
  cout << x;
}

Measured memory_bytes: 3620
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <tchar.h>
//#include <intrin.h>

#define F first
#define S second
#define LL long long
#define MOD 1000000007
#define INF 2000000000
#define LINF 1000000000000000000

using namespace std;

const int N = 2e5 + 10;

int dp[N];
int a[N];

int main()
{
	
	int n, k;
	scanf("%d%d", &n, &k);

	for (int i = 1;i <= n;i++)
		cin >> a[i], dp[a[i]] = 1;

	for (int i = 1;i <= k;i++)
		for (int j = 1;j <= n;j++) 
			if (a[j] > i)continue;
			else dp[i] |= !dp[i - a[j]];
		
			puts(dp[k] ? "First" : "Second");
}

Measured memory_bytes: 3444
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>

int main() {
  int a, b, c, k;
  scanf("%d %d %d %d", &a, &b, &c, &k);

  int res = 0;
  if (k <= a) {
    res = k;
  } else {
    res += a;
    k -= a;
    if (k <= b) {
      //
    } else {
      k -= b;
      res -= std::min(k, c);
    }
  }

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


Measured memory_bytes: 1728
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 10000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
//bitset<maxx/2>vis;
//bitset<maxx>pr;
//int mobi[maxx+10];
//vector<ll>prime;
//void sieve(){
//    ll x=maxx/2, y=sqrt(maxx)/2;
//    for(ll i=1;i<=y;i++){
//        if(vis[i]==0){
//            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
//                vis[j]=1;
//        }
//    }
//    prime.push_back(2);
//    for(ll i=3;i<maxx;i+=2)
//        if(vis[i/2]==0)
//        prime.push_back(i);
//}
//void generate_mobius()
//{
//    for(int i=0;i<maxx;i++)mobi[i]=1;
//    for(int i=2;i<maxx;i++){
//        if(!pr[i]){
//            mobi[i]*=-1;
//            for(int j=i+i;j<maxx;j+=i){
//                pr[j]=1;
//                mobi[j]*=(j%(i*i)?-1:0);
//            }
//        }
//    }
//}
//bool isprime(ll a)
//{
//    if(a==1)return false;
//    if(a==2)return true;
//    if(a%2==0)return false;
//    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++)
//        if(a%prime[i]==0)return false;
//    return true;
//}
/* Calculate ( a*b ) %c */
inline ll mulmod(ll a, ll b, ll c) {
    ll ret = 0 , cur = a % c ;
    while(b) { if(b%2) ret=(ret+cur)%c; cur=(cur<<1)%c; b=b>>1; }
    return ret%c;
}
//Calculate (b^p)%m || modular inverse: b^-1 = bigmod(b, m-2, m)
inline ll bigmod(ll b, ll p, ll m){
    ll ret = 1, cur = b % m;
    while(p) { if(p&1) ret=(ret*cur)%m; cur=(cur*cur)%m; p=p>>1; }
    return ret;
}
inline ll modulo(ll a,ll b,ll c) { //Same as big mod, use for numbers over 1e10
    ll ret = 1 , cur = a%c ;
    while(b) { if(b%2) ret=mulmod(ret,cur,c); cur=mulmod(cur,cur,c); b=b>>1; }
    return ret%c ;
}
inline ll power(ll b, ll p){
    ll ret = 1, cur = b;
    while(p) { if(p&1) ret=(ret*cur); cur=(cur*cur); p=p>>1; }
    return ret;
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
void Dufaux()
{
    ll a,b,c;
    cin>>a>>b>>c;
    if(c>=a && c<=b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
int main()
{
    FastIO;
	///sieve();
	///generate_mobius();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}





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

int main() {
	// your code goes 
	long long int x;
	cin>>x;
	long long int ss=1e7;
	long long int ans=7;
	for(long int i=1;i<=ss;i++)
	{
	    if(ans%x==0)
	    {
	        cout<<i;
	        return 0;
	    }
	    ans=(ans*10+7)%x;
	}
	cout<<"-1"<<endl;
	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
  ll res = 1;
  while(b){
    if(b&1)res = res * x % MOD;
    x = x * x % MOD;
    b>>=1;
  }
  return res;
}

ll modinv(ll x){
  return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
  if(was_output)cout << " ";
  cout << a;
  was_output = true;
}
void outendl(){
  was_output = false;
  cout << endl;
}
ll in(){
  ll res;
  scanf("%lld", &res);
  return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
  for(auto &i:x)is >> i;
  return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
  is >> x.first >> x.second;
  return is;
}

template<class t>
void in(t&x){
  cin >> x;
}

template<class t>
void out(t x){
  cout << x;
}

int main(){
  string str;
  cin >> str;
  if(str[2]==str[3] and str[4]==str[5]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return 0;
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int h, w;
    cin >> h >> w;

    int n;
    cin >> n;

    vector<int> a(n);
    for(int in=0;in<n;in++) {
        cin >> a.at(in);
    }

    vector<int> c(h*w);
    int cnt = 0;
    for(int in=0;in<n;in++) {
        for(int jn=0;jn<a.at(in);jn++) {
            c.at(cnt) = in + 1;
            cnt++;
        }
    }

    bool forrev = true;
    int diff = w-1;
    for(int ihw=0;ihw<h*w;ihw++) {
        if(forrev==true) {
            cout << c.at(ihw) << " ";
        }
        else {
            cout << c.at(diff-ihw) << " ";
        }
        if(ihw%w==w-1) { 
            cout << endl;
            forrev = !forrev;
            diff += 2*w;
        }
    }
    return 0;
}


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

using namespace std;
int a, b, c;
int main(){
    cin >> a >> b >> c;
    if(a % 2 == b % 2 && a % 2 !=  c % 2){
        a++;
        b++;
        int mx = max(a, max(b, c));
        cout << (mx - a) / 2 + (mx - b) / 2 + (mx - c) / 2 + 1;
    }
    else if(a % 2 == c % 2 && a % 2 != b % 2){
        a++;
        c++;
        int mx = max(a, max(b, c));
        cout << (mx - a) / 2 + (mx - b) / 2 + (mx - c) / 2 + 1;
    }
    else if(c % 2 != a % 2 && c % 2 == b % 2){
        c++;
        b++;
        int mx = max(a, max(b, c));
        cout << (mx - a) / 2 + (mx - b) / 2 + (mx - c) / 2 + 1;
    }
    else if(a % 2 == b % 2 && b % 2 == c % 2){
        int mx = max(a, max(b, c));
        cout << (mx - a) / 2 + (mx - b) / 2 + (mx - c) / 2;
    }
}


Measured memory_bytes: 256
#include<functional>
#include<algorithm>
#include<exception>
#include<stdexcept>
#include<streambuf>
#include<iterator>
#include<string.h>
#include<stdlib.h>
#include<typeinfo>
#include<valarray>
#include<iostream>
#include<sstream>
#include<istream>
#include<stdio.h>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<ctype.h>
#include<cassert>
#include<cstdlib>
#include<utility>
#include<cstring>
#include<numeric>
#include<ostream>
#include<cwctype>
#include<fstream>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cctype>
#include<string>
#include<vector>
#include<limits>
#include<locale>
#include<memory>
#include<cerrno>
#include<time.h>
#include<iosfwd>
#include<cfloat>
#include<cstdio>
#include<cwchar>
#include<cmath>
#include<ctime>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<ios>
#include<map>
#include<set>
#include<new>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define MP make_pair
using namespace std;
const int INF=1e9+7;
string s,t;
int main()
{
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>s>>t;
	reverse(s.begin(),s.end());
	if (s==t) cout<<"YES"; else cout<<"NO";
	return 0;
}


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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n, m;
  cin >> n >> m;
  vi h(n);
  for(int i = 0; i < n; i++){
    cin >> h[i];
  }
  vi road(n, 0);
  for(int i = 0; i < m; i++){
    int a, b; cin >> a >> b;
    a--, b--;
    if(h[a] > h[b]) road[b]++;
    else if(h[b] > h[a]) road[a]++;
    else{
      road[a]++; road[b]++;
    }
  }
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(road[i] == 0) ans++;
  }
  cout << ans << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 4016
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))



count = 0
for i in range(N):
    if A[i] <= B[i]:
        count += (B[i] - A[i]) // 2
        continue
    else:
        count -= A[i] - B[i]


if count >= 0:
    print ('Yes')
else:
    print ('No')

Measured memory_bytes: 4596
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




typedef long long ll;
ll A, B;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> A >> B;


    ll AA = A, BB = B;
    deque<int> a, b;
    while (AA != BB) {
        a.push_back(AA % 2);
        b.push_back(BB % 2);

        AA /= 2;
        BB /= 2;
    }

    ll _A = A;

    A = 0, B = 0;
    while (!a.empty()) {
        A = A * 2 + a.back();
        a.pop_back();
        B = B * 2 + b.back();
        b.pop_back();
    }


    if (A == B) {
        printf("1\n");
        return;
    }

    if (A == 0) {
        ll line = 1;
        while (line <= B) line *= 2;
        line /= 2;

        ll ans = line * 2 - 1;
        if (_A != A) ans++;
        cout << ans << endl;
        return;
    }

    if (A == 1) {
        ll line = 1;
        while (line <= B) line *= 2;
        line /= 2;

        ll ans = line * 2 - 1;
        cout << ans << endl;
        return;
    }
        



    
    ll line = 1;
    while (line <= B) line *= 2;
    line /= 2;

   // cout << line << endl;

    ll ans = line - A;
    
    ll line2 = 1;
    while (line + line2 <= B) line2 *= 2;
    line2 /= 2;

  //  cout << line2 << endl;

    if (line2) {
        ans += line2 * 2;

        ll mi = max(line2 * 2, A);

        ans += line - mi;
    }
    else {
        ans += line - A + 1;
    }

    

    cout << ans << endl;
}

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

using namespace std;

int main()
{

    int n;
    map<string, int> a;

    cin >> n;

    for (size_t i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        a[s]++;
    }

    cout << "AC x " << a["AC"] << "\n" <<
            "WA x " << a["WA"] << "\n" <<
            "TLE x " << a["TLE"] << "\n" <<
            "RE x " << a["RE"];

    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

int calc(int start, int end, char *S){
    int a;
}

int main(void){
    char S[5*100000+3];
    long long cnt_p = 0, cnt_m = 0;
    long long ans = 0;

    scanf("%s", S);

    int i = 0;
    for(i = 0; S[i] != '\0'; i++){
        if(S[i] == '>'){
            cnt_m++;
        }else{
            cnt_p++;
        }
        if((S[i]=='>' && S[i+1] == '<') || S[i+1] == '\0'){
            if(cnt_p >= cnt_m){
                ans += cnt_p*(cnt_p+1)/2 + cnt_m*(cnt_m-1)/2;
            }else{
                ans += cnt_p*(cnt_p-1)/2 + cnt_m*(cnt_m+1)/2;
            }
            cnt_p = 0;
            cnt_m = 0;
        }
        

    }

    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 640
const Main = (input) => {
  const tmp = input.trim().split(' ').map(n => parseInt(n))
  const A = tmp[0]
  const B = tmp[1]
  const N = tmp[2]

  let x = Math.min(B - 1, N)

  const result = Math.floor(A * x / B) - (A * Math.floor(x / B))

  console.log(result)
  return result
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 29992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    vector<pair<int64_t,int64_t>> P;
    rep(n,0,N){
        int64_t x,y; cin>>x>>y;
        P.emplace_back(x,y);
    }

    map<pair<int64_t,int64_t>,int> mp;
    rep(i,0,N)rep(j,0,N){
        if(i!=j) mp[make_pair(P.at(i).first-P.at(j).first,P.at(i).second-P.at(j).second)]++;
    }

    int ans=0;
    for(auto m:mp){
        //cout<<m.first.first<<" "<<m.first.second<<" "<<m.second<<endl;
        ans=max(ans,m.second);
    }

    ans=N-ans;
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,po=0;
cin>>n;
int arr[n-1];
for(int i=0;i<n-1;i++)
    cin>>arr[i];
//cout<<po<<endl;
if(n>1){
    po+=arr[0];
    for(int i=0;i<n-2;i++){
        po+=min(arr[i],arr[i+1]);//cout<<po<<endl;
    }
    po+=arr[n-2];
}
else
    po=arr[0]*2;
cout<<po<<endl;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;

const int N = 1e6;
const int LOG = 61;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLMOD = 998244353;
const ll LLINF = 1e18;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int r;
    cin >> r;
    cout << 3 * r * r << "\n";

}


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

using namespace std;
typedef long long ll; //10^18
typedef unsigned long ul;

#define MOD 1000000007LL

signed main()
{

	ll n, k;
	cin >> n >> k;
    
    ll ans = 0;
        for(int i=k; i<=n+1; i++) {
            ans = (ans + i*(n-i+1) + 1) % MOD;
        }

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint a[205];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	llint ans = 1000;
	for(int i = 1; i <= n-1; i++){
		if(a[i+1] > a[i]){
			ans += ans/a[i] * (a[i+1]-a[i]);
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod = 998244353;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e6 + 5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;
ll qpow(ll a, ll b) { ll s = 1; while (b > 0) { if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1; }return s; }

int a[100];
int main(){
    // in;
    // out;
    int n,m;
    cin>>n>>m;
    mem(a,-1);
    bool flag=true;
    while(m--){
        int x,y;
        cin>>x>>y;
        if(a[x]!=-1){
            int z=a[x];
            if(z!=y){
                flag=false;
            }
        }
        else if(x>n) flag=false;
        else{
            a[x]=y;
        }
    }
    if(!flag||(a[1]==0&&n>1)) cout<<"-1"<<endl;
    else{
        if(a[1]==-1&&n>1) a[1]=1;
        else if(a[1]==-1&&n==1) a[1]=0;
        for(int i=1;i<=n;i++){
            if(a[i]==-1) a[i]=0;
                cout<<a[i];
        }
        cout<<endl;
    }
}

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

int bubbleSort(vector<int>& A, int N){
    int sw = 0;
    bool flag = 1;
    for (int i = 0; flag; i++){
        flag = 0;
        for (int j = N-1; j >= 1; j--){
            if (A.at(j) < A.at(j-1)){
                swap(A.at(j), A.at(j-1));
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main() {
    vector<int> A(100);
    int N, sw;
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A.at(i);
    sw = bubbleSort(A, N);
    for (int j = 0; j < N; j++){
        if (j > 0)  cout << " ";
        cout << A.at(j);
    }
    cout << endl;
    cout << sw << endl;
    
    return 0;
}


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

typedef pair<int, int> ii;

int main() {
	int n;
	cin >> n;

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

	sort(arr.begin(), arr.end());

	auto it = upper_bound(arr.begin(), arr.end(), arr.back() / 2);
	int ans;
	ans = *it;

	if (it != arr.begin()) {
		it--;
		if (*it >= arr.back() - ans) ans = *it;
	}

	cout << arr.back() << ' ' << ans;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
)
 
func main() {
	var N int
	fmt.Scanf("%d", &N)
	fmt.Println(NumToChar(N - 1))
}
 
func NumToChar(index int) string {
	ans := ""
 
	for ; index >= 0; index-- {
		add := 'a' + (index % 26)
		ans = string(byte(add)) + ans
		index /= 26
 
	}
	return ans
}

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

using namespace std;

int a, b;

int main ()
{
	cin >> a >> b;
	if (a + b == 15) { cout << "+\n"; return 0;}
	else if (a * b == 15) { cout << "*\n"; return 0;}
	else cout << "x\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int n;
	int a[3001];
	ll total=0;

	cin>>n;
	rep(i,n){
		cin>>a[i];
		total+=a[i]-1;
	}
	cout<<total<<endl;

	return 0;
}


Measured memory_bytes: 256
import math
a,b,x = map(int, input().split())

theta1 = math.atan((2/a*(b-x/(a**2))))
if math.tan(theta1) <= 2*x/(a**3):
  print(math.degrees(theta1))
  exit()
else:
  theta2 = math.atan(a*b**2/(2*x))
  print(math.degrees(theta2))

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int a, b; cin >> a >> b;
    int n = b - a;
    cout << n * (n+1) / 2 - b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
#define MOD 1000000007

ll dp[5][200010];//02120

int main(){
	int L;
	cin >> L;
	vector<ll> A(L), B(L);
	for (int i = 0;i < L;i++) {
		cin >> A[i];
		if (A[i] == 0)B[i] = 0;
		else if (A[i] & 1)B[i] = 1;
		else B[i] = 2;
	}

	dp[0][0] = dp[4][0] = A[0];
	dp[1][0] = dp[3][0] = abs(2 - B[0]);
	dp[2][0] = abs(1 - B[0]);

	for (int i = 1;i < L;i++) {
		dp[0][i] = dp[0][i - 1] + A[i];
		dp[1][i] = min(dp[1][i - 1], dp[0][i - 1]) + abs(2 - B[i]);
		dp[2][i] = min({ dp[2][i - 1],dp[1][i - 1],dp[0][i - 1] }) + abs(1 - B[i]);
		dp[3][i] = min({ dp[3][i - 1],dp[2][i - 1],dp[1][i - 1],dp[0][i - 1] }) + abs(2 - B[i]);
		dp[4][i] = min({ dp[4][i - 1],dp[3][i - 1],dp[2][i - 1],dp[1][i - 1],dp[0][i - 1] }) + A[i];
	}

	cout << min({ dp[4][L - 1],dp[3][L - 1],dp[2][L - 1],dp[1][L - 1],dp[0][L - 1] }) << endl;
}

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

int N, Q, s[1000000];
vector< int > Student;
multiset< int > Leader;

char Query[10];
int a;

bool Check(int value, int x)
{
  vector< int >::iterator last = Student.begin();
  int Lost = 0;
  for(multiset< int >::iterator it = Leader.begin(); it != Leader.end() && last != Student.end(); ++it) {
    Lost += lower_bound(last, Student.end(), *it - value) - last;
    last = upper_bound(last, Student.end(), *it);
  }
  Lost += Student.end() - last;
  return(Lost <= x);
}
int BinarySearch(int Lower, int Upper, int x)
{
  int Mid = (Lower + Upper) >> 1;
  if(Lower >= Upper) return(Lower);
  if(Check(Mid, x)) return(BinarySearch(Lower, Mid, x));
  return(BinarySearch(Mid + 1, Upper, x));
}
main()
{
  scanf("%d %d", &N, &Q);
  Student.resize(N);
  for(int i = 0; i < N; ++i) {
    scanf("%d", &Student[i]);
    s[i] = Student[i];
  }
  sort(Student.begin(), Student.end());
  while(Q--) {
    scanf("%s %d", &Query, &a);
    if(Query[0] == 'A') { // "ADD"
      Leader.insert(s[--a]);
    } else if(Query[0] == 'R') { // "REMOVE"
      Leader.erase(Leader.find(s[--a]));
    } else { // "CHECK"
      int ret = BinarySearch(0, 1 << 30, a);
      if(ret == 1 << 30) cout << "NA" << endl;
      else cout << ret << endl;
    }
  }
}

Measured memory_bytes: 8928
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int mod = 1e9 + 7;
const int inf = 2e18;

signed main() {
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    S += '0';
    int N = S.length();
    vector<vector<int>> dp(N + 1, vector<int>(2, inf));
    dp[0][0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 2; j++) {
            int base = S[i] - '0';
            base += j;
            for (int k = 0; k < 10; k++) {
                int down = 0;
                int next = k - base;
                if (next < 0) {
                    down = 1;
                    next += 10;
                }
                dp[i + 1][down] = min(dp[i + 1][down], dp[i][j] + k + next);
            }
        }
    }
    cout << dp[N][0] << endl;
}



Measured memory_bytes: 55940
N, C = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(N)]
c = [0]
rc = [0]
uc = [0]
ruc = [0]
sum = 0
out = 0
for x, cal in xy:
    sum += cal
    c.append(max(c[-1], sum-x))
    rc.append(max(rc[-1], sum-2*x))
sum = 0
for x, cal in xy[::-1]:
    sum += cal
    uc.append(max(uc[-1], sum-C+x))
    ruc.append(max(ruc[-1], sum-2*(C-x)))
for w, wr in zip(c, ruc[::-1]):
    out = max(out, w+wr)
for w, wr in zip(rc, uc[::-1]):
    out = max(out, w+wr)
print(out)


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

void solve() {
   int n;
   scanf("%d",&n);

   vector<vector<int> > group;
   int sum;
   int m ;
   m = (n*(n-1))/2;
   m -= n/2;
   if(n&1) {
      sum = n;
      vector<int> tmp;
      tmp.push_back(n);
      group.push_back(tmp);
   } else {
      sum = n+1;
   }
   for(int i = 1;i<=n;++i){
      int x = sum-i;
      if(i<x){
         vector<int> tmp;
         tmp.push_back(i);
         tmp.push_back(x);
         group.push_back(tmp);
      } else {
         break;
      }
   }
   printf("%d\n", m);
   for(int i = 0;i<group.size();++i){
      for(int j = 0;j<group[i].size();++j){
         int a = group[i][j],b;
         for(int k = 0;k<group.size();++k){
            if(k!=i){
               for(int g = 0;g<group[k].size();++g){
                  b = group[k][g];
                  if(a<b){
                     printf("%d %d\n",a,b);
                  }
               }
            }
         }
      }
   }
}
int main(){
   //freopen("input.txt","r",stdin);
   solve();
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#define ll long long
using namespace std;

int main(){
	int n;
	cin>>n;
	if(n>=64){
		cout<<64<<endl;
	}else if(n>=32&&n<64){
		cout<<32<<endl;
	}else if(n>=16&&n<32){
		cout<<16<<endl;
	}else if(n>=8&&n<16){
		cout<<8<<endl;
	}else if(n>=4&&n<8){
		cout<<4<<endl;
	}else if(n>=2&&n<4){
		cout<<2<<endl;
	}else{
		cout<<1<<endl;
	}
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x, k, d;
  cin >> x >> k >> d;
  long long min1=abs(x)%d, min2=abs(min1-d);
  long long cnt=(abs(x)-min1)/d;
  if(cnt>k) {
    cout << abs(x)-d*k << endl;
    return 0;
  }
  else if((k-cnt)%2==1) {
    cout << min2 << endl;
    return 0;
  }
  else {
    cout << min1 << endl;
    return 0;
  }
}

Measured memory_bytes: 3632
N = int(input())
A = [int(i) for i in input().split()]

L = [A[i]+i+1 for i in range(N)]
R = [i + 1 - A[i] for i in range(N)]
from collections import defaultdict
l = defaultdict(int)
for i in L:
  l[i] += 1
ans = 0
for r in R:
  ans += l.get(r, 0)
print(ans)

Measured memory_bytes: 50412
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define F first
#define S second
#define MP make_pair
#define PB push_back
 
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)
int main(){
	ll n;
	rl(n);
	ll ans=pow(n,3);
	wl(ans);
	NL;
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		int p;
		cin >> p;
		if (p == i) {
			ans++;
			if (i < N) {
				cin >> p;
				i++;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(300000)
from collections import Counter

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


S = input()

m = [0]
pow = 1
for i in range(len(S)):
    m.append((m[-1] + int(S[- i - 1]) * pow) % 2019)
    pow = (pow * 10) % 2019


ans = 0
for cnt in Counter(m).values():
    ans += cnt * (cnt - 1) // 2
print(ans)


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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); os << (i>0 ? " ":"") << v[i++]); return os;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int i, ans, c;
    c = 0;
    ans = 0;
    for(i=0;i<s.size();i++){
        if(s[i] == 'S'){
            ans = max(ans , c);
            c = 0;
        }else{
            c++;
            ans = max(ans , c);
        }
    }
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

int main(void)
{
int  a,b,c;

cin >> a >> b >> c;

a -= b;

while(1){
  a -= c;
  if(a < 0){
    break;
  }
}

cout << a + c << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long ;
int main()
{
    int n;
    double ans;
    cin>>n;
    vector<double> v(n);
    rep(i,n) cin>>v[i];
    sort(v.begin(),v.end());
    ans=v[0];
    rep(i,n-1){
        ans=(ans+v[i+1])/2;
    }
    printf("%.10f",ans);
}

Measured memory_bytes: 3792
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int n;
	cin >> n;
	long long ans=1;
	bool flg=true;
	bool zero=false;
	for(int i=0;i<n;i++)
	{
		long long a;
		cin >> a;
		if(a==0)
		{
			zero=true;
			break;
		}
		if(ans>1000000000000000000/a)
		{
			flg=false;
		}
		ans*=a;
		if(ans>1000000000000000000 or ans<0)
		{
			flg=false;
		}
	}
	if(zero)
		cout << 0 << endl;
	else if(!flg)
		cout << -1 << endl;
	else
		cout << ans << endl;




}

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

int selectionSort(int A[], int N)
{
  int i, j, t, sw = 0, minj;
  for(int i = 0; i < N - 1; i++) {
    minj = i;
    for(j = i; j < N; j++) {
      if(A[j] < A[minj]) minj = j;
    }
    t = A[i];
    A[i] = A[minj];
    A[minj] = t;
    if (i != minj) sw++;
  }
  return sw;
}

int main()
{
  int A[100], N, sw;
  cin >> N;
  for (int i = 0; i < N; i++)
    cin >> A[i];

  sw = selectionSort(A, N);

  for (int i = 0; i < N; i++)
  {
    if (i)
      cout << " ";
    cout << A[i];
  }
  cout << endl;
  cout << sw << endl;
}


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

bool check(int N, int K, vector<int> vec){
  int M = N;
  bool can = true;
  while(M > 0){
    for(int i = 0; i < K; i++){
      if(M % 10 == vec.at(i)){
        can = false;
        break;
      }
    }
    if(!can) break;
    M /= 10;
  }
  return can;
}

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> num(K);
  for(int i = 0; i < K; i++){
    cin >> num.at(i);
  }
  while(1){
    bool ans = check(N, K, num);
    if(!ans){
      N++;
    }else{
      break;
    }
  }
  cout << N << endl;
  return 0;
}

Measured memory_bytes: 256
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 基本はdouble
//map<キー,値> p は辞書。p[キー] = 値
//絶対値 abs()
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	int X, Y; cin >> X >> Y;
	cout << X + Y / 2 << endl;
}

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


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long a = 1;
		for (long i = 1; i * i <= n; i++) {
			if (n % i == 0) {
				a = i;
			}
		}
		System.out.println(Math.max(String.valueOf(a).length(), String.valueOf(n / a).length()));
	}
}

Measured memory_bytes: 23380
#if defined(LOCAL)
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) (debug(x, #x))
#define I(x, ...) (x)
#define C(x...) CHECK(x)
#else
#define L(x, ...) (x)
#define I(x, ...) (x)
#define C(x, ...) ;
#endif
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ii = pair<int, int>;
using lu = unsigned long long;
using l = long long;
using vs = vector<string>;
using vii = vector<ii>;
using vl = vector<l>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using ll = pair<l, l>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vd = vector<double>;
using vvd = vector<vd>;
using mll = unordered_map<l, l>;
using sl = unordered_set<l>;
const l      INF = numeric_limits<l>::max();
const double EPS = 1e-10;
const double PI = 3.14159265358979323846;
const l      e0 = 1, e3 = 1000, e5 = 100000, e6 = 10 * e5, e7 = 10 * e6,
        e8 = 10 * e7, e9 = 10 * e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a, b, c) for (l a = l(b); a < l(c); a++)
#define B(a, b, c) for (l a = l(c) - 1; a >= l(b); a--)
#define VVL(x, a, b, i) vvl x(a, vl(b, l(i)));
#define VVVL(x, a, b, c, i) vvvl x(a, vvl(b, vl(c, l(i))));

void solve(istream &in, ostream &out);
int  main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  tst::test_init(argc, argv);
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  tst::maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}
const l MOD = e9 + 7;  // end of template

void solve(istream &in, ostream &out) {
  l n;
  in >> n;
  vll v(n);
  F(i, 0, n) in >> v[i].first >> v[i].second;
  sort(all(v), [](const ll &a, const ll &b) {
    return (a.first + a.second) < (b.first + b.second);
  });
  l    z = -1;
  bool ok = true;
  vl   aa(n + 1);
  while (ok) {
    ok = false;
    z++;
    vl bb(n + 1, INF);
    F(i, 0, n) {
      bb[i + 1] = bb[i];
      if (aa[i] <= v[i].first)
        bb[i + 1] = min(bb[i + 1], v[i].second + aa[i]), ok = true;
    }
    swap(aa, bb);
  }
  out << z << lf;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcd(long long a,long long b){return a*b / gcd(a,b) / gcd(a,b);}
int main()
{
	int N;
	cin>>N;
	vector<int> b(N);

	for(int i=1; i<N; i++)
	{
		int _b;
		cin>>_b;
		_b--;

		b[_b]++;
	}
	for(int i=0; i<N; i++)
	{
		cout<<b[i]<<endl;
	}

}

Measured memory_bytes: 4048
#include<cstdio>
#include<cmath>

int main(){
	int n;
	double x[1000], y[1000];
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%lf", &x[i]);
	}

	for(int i = 0; i < n; i++){
		scanf("%lf", &y[i]);
	}

	double d;
	for(int j = 0; j < 3; j++){
		d = 0;
		for(int i = 0; i < n; i++){
			d += pow(fabs(x[i] - y[i]), j + 1);
		}
		printf("%lf\n", pow(d, 1.0 / (j + 1)));
	}

	d = 0;
	for(int i = 0; i < n; i++){
		if(fabs(x[i] - y[i]) > d){
			d = fabs(x[i] - y[i]);
		}
	}
	printf("%lf\n", d);
	return 0;
}

Measured memory_bytes: 1156
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


vector<ll>adj[Max+10];

map<pll,ll>mp;

ll k;


void dfs(ll s,ll p)
{

    ll c=1;

    for(auto  x  : adj[s])
    {
        if(x!=p)
        {
            if(mp[{p,s}]==c)c++;



                mp[{s,x}]=c;
                mp[{x,s}]=c;
                c++;

            dfs(x,s);
        }
    }
}



int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;

      cin>>n;

      vector<pll>Ans;

      k=0;


      for(i=1; i<n; i++)
      {
          cin>>a>>b;

          adj[a].eb(b);

          adj[b].eb(a);

          Ans.eb(a,b);

          k=max3((ll)adj[a].size(),(ll)adj[b].size(),k);


      }

      dfs(1,1);

      cout<<k<<endl;

      for(auto x  : Ans)
      cout<<mp[{x.F,x.S}]<<endl;











}



Measured memory_bytes: 69044
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;

int main(){
  int n, taro = 0, hanako = 0;
  cin >> n;
  string t, h;
  for (int i = 0; i < n; i ++) {
    cin >> t >> h;
    if (t > h) taro += 3;
    else if (t == h) taro ++, hanako ++;
    else if (t < h) hanako += 3;
  }

  cout << taro << " " << hanako << endl;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define ll long long
#define N 101
#define W 100010
using namespace std;

int n,w;
ll wi,vi,dp[N][W];

int main()
{
    cin>>n>>w;
    
    FOR(i,0,n)
    {
        cin>>wi>>vi;
        FOR(j,0,w+1)
        {
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
            if(j+wi<=w) dp[i+1][j+wi]=max(dp[i+1][j+wi],dp[i][j]+vi); 
        }
    }
    cout<<*max_element(dp[n],dp[n]+w+1)<<'\n';

    return 0;
}

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

using namespace std;
typedef long long ll;
const int MAXN = 2e5 + 5;
map<string, int> mp;

int main() {
    ll ans = 0;
    ll n, m;
    cin >> n >> m;
    if (n == 1 && m == 1)
        ans = 1;
    else if (n == 1)
        ans = m - 2;
    else if (m == 1)
        ans = n - 2;
    else
        ans = (n - 2) * (m - 2);
    cout << ans << endl;
    return 0;
}

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



int main() {
int N;
cin >> N;
int num[10000];
int ans = 0;
for(int i = 0; i< N;i++)cin >> num[i],num[i]--,ans+=num[i];
cout << ans << endl;

}


Measured memory_bytes: 256