akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    string s;
    cin >> s;
    if (s == "ARC") cout << "ABC" << endl;
    else cout << "ARC" << endl;
} 

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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<long long>
#define inf 1000000100
#define infll 1LL << 50

int main()
{
    int n;
    cin >> n;
    int t = 3*n;
    vi data(t);
    vll mxx(n+1), mnn(n+1); //k = n-1 to 2n-1
    for(int i = 0; i < t; i++)
    {
        cin >> data[i];
    }

    int k = n-1;
    ll mx = 0, mn = 0;
    priority_queue<int> q;
    for(int i = 0; i <= k; i++)
    {
        mx += data[i];
        q.push(-data[i]); //smallest on top
    }

    mxx[0] = mx;

    while(++k <= 2*n-1)
    {
        if(-data[k] < q.top())
        {
            mx -= -q.top();
            mx += data[k];
            q.pop();
            q.push(-data[k]);
        }
        mxx[k - (n-1)] = mx;
    }
    q = priority_queue<int>();

    reverse(data.begin(), data.end());

    k = n - 1;

    for(int i = 0; i <= k; i++)
    {
        mn += data[i];
        q.push(data[i]);
    }

    mnn[0] = mn;

    while(++k <= 2*n - 1)
    {
        if(data[k] < q.top())
        {
            mn -= q.top();
            mn += data[k];
            q.pop();
            q.push(data[k]);
        }
        mnn[k - (n-1)] = mn;
    }
    ll ans = -infll;
    for(int i = 0; i < n+1; i++)
    {
        ans = max(mxx[i] - mnn[n-i], ans);
    }

    cout << ans << endl;



}

Measured memory_bytes: 3952
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<cstring>
#include<climits>
#include<algorithm>
#include <iomanip> 
#define ll long long int
using namespace std;

int main(){
	int n,m;
	cin>>n>>m;
	int a[m],sum=0;
	for(int i=0;i<m;i++){
		cin>>a[i];
		sum+=a[i];
	}
	if((n-sum)<0){
		cout<<-1<<endl;
	}
	else{
		cout<<(n-sum)<<endl;
	}
	}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
  int A,B,C,X,Y;
  int max;
  int loop;
  int min;
  int minx;

  cin >> A >> B >> C >> X >> Y;
  int AB = A*X + B*Y;
  min = AB;

  
  if(X>Y){
    loop = X;
  }else{
    loop = Y;
  }

  int res = AB;
  for(int i=1;i<loop+1;i++){
    res = res + C*2;
    if(i<=X){
      res= res -A;
    }
    if(i<=Y){
      res= res -B;
    }
    if(min>res){
      min=res;
      minx=i;
    }
  } 
  
  cout << min << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String[] array = new String[n];

		int account = 0;
		int wacount = 0;
		int tlecount = 0;
		int recount = 0;

		for(int i=0;i<array.length;i++) {
			array[i] = scan.next();
			if(array[i].equals("AC")) {
				account = account + 1;
			}else if(array[i].equals("WA")) {
				wacount = wacount + 1;
			}else if(array[i].equals("TLE")) {
				tlecount = tlecount + 1;
			}else if(array[i].equals("RE")) {
				recount = recount + 1;
			}
		}

		System.out.println("AC x "+account);
		System.out.println("WA x "+wacount);
		System.out.println("TLE x "+tlecount);
		System.out.println("RE x "+recount);

	}

}

Measured memory_bytes: 63104
def main():
    cs = [list(input()) for _ in range(2)]
    ul = cs[0][0]
    uc = cs[0][1]
    ur = cs[0][2]
    bl = cs[1][0]
    bc = cs[1][1]
    br = cs[1][2]

    if ul == br and uc == bc and ur == bl:
        ans = 'YES'
    else:
        ans = 'NO'

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================
//using系

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ld = long double;
using qul = queue<ll>;
using pql = priority_queue<ll>;

// ========================================================================
//define系

//#define int long long;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i <= n; i++)

// ========================================================================


ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a)
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a)
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll mch(ll n) {
	if (n == 1) return 1;
	else return n * mch(n - 1);
}
//1から整数nまでの階乗を出す(INFで割っていない)
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double m = sqrt(a);
	for (int i = 3; i <= m; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定
ll modpow(ll a, ll n, ll mod) {
	ll hi = 1;
	while (n > 0) {
		if (n & 1) hi = hi * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return hi;
}
//いろいろやります（ただの前座）
ll mg(ll a, ll mod) {
	return modpow(a, mod - 2, mod);
}
//割り算の10^9+7等対策で逆元を出します 




// ========================================================================


/*signed*/int main() {
	ll n; cin >> n;
	ll cnt = 0;
	ll ans = 0;
	for (int i = 1; i <= n; i+=2) {
		for (int j = 1; j <= n; j++) {
			if (i % j == 0) {
				cnt++;
			}
		}
		if (cnt == 8) ans++;
		cnt = 0;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3672
#include<stdio.h>
int main() 
{
    int num[10000],n;
    n = 0;
    while (1) 
    {
        scanf("%d", &num[n]);
        if (num[n] == 0) break;
            n = n + 1;
    }
    n = 0;
    while (num[n] != 0)
    {
        printf("Case %d: %d\n", n+1, num[n]);
        n = n + 1;
    }
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
 
using namespace std;
 
int main(void) {
    int m;
    int n;
    while (1) {
        cin >> m >> n;
        if (m == 0 && n == 0) {
            break;
        }
 
        vector<bool> v(7368792, 0);
        int base = m;
        int count = 0;
        while (1) {
            for (int i = 1; i * base < v.size(); i++) {
                v[i * base] = 1;
            }
            count++;
 
            if (count == n) {
                break; 
            }
 
            while (1) {
                if (v[base] == 0) {
                    break;
                } else {
                    base++;
                }
            }
        }
 
 
        int check = m;
        while (1) {
            if (v[check] == 0) {
                cout << check << endl;
                break;
            }
            check++;
        }
    }
    return 0;
}

Measured memory_bytes: 4000
//coded by: pranonrahman-------------------------------------
//-----------------------------------------------------------
//-----------------------------------------------------------
#include<bits/stdc++.h>
using namespace std;


#define O_O ios_base::sync_with_stdio(0); cin.tie(NULL)
#define endl '\n'
#define PI acos(-1.0)
#define CASE(n) cout << "Case " << n << ": "
#define CASE_(n) cout << "Case " << n << endl
#define FIXED(n) cout << fixed << setprecision(n)
#define MOD 1000000007

inline void normal(long long &a) { a %= MOD; (a < 0) && (a += MOD); }
inline long long modMul(long long a, long long b) { normal(a), normal(b); return (a*b)%MOD; }
inline long long modAdd(long long a, long long b) { normal(a), normal(b); return (a+b)%MOD; }
inline long long modSub(long long a, long long b) { normal(a), normal(b); a -= b; normal(a); return a; }
inline long long modPow(long long b, long long p) { long long r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline long long modInverse(long long a) { return modPow(a, MOD-2); }
inline long long modDiv(long long a, long long b) { return modMul(a, modInverse(b)); }


int main()
{
    O_O;
#ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
#endif
    long long t=1;
    //cin >> t;
    long long T = t;
    while(t--)
    {
        //write your code here
        long long n;
        cin >> n;
        n*=3;
        long long arr[1000004];
        for(long long i=0;i<n;i++)	cin >> arr[i];
        sort(arr,arr+n);
    	long long sum =0ll;
    	//cout << "done\n";
    	for(long long i=(n) -2,j=0;j<n/3;i-=2,j++)	
    	{
    		sum+=arr[i];	
    	}
    	cout << sum << endl;
    }
    return 0;
}




Measured memory_bytes: 5960
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int manLength(int x1,int y1,int x2,int y2){
	return abs(x1-x2) + abs(y1-y2);
}
int main()
{
	string a,b;
	cin>>a;
	cin>>b;
	int n = min(a.length(),b.length());
	for(int i = 0 ; i < 2*n; i++){
		if( i % 2 == 0){
			cout<<a[i/2];
		}else{
			cout<<b[i/2];
		}
	}
	if( a.length() > n){
		cout<<a[a.length()-1];
	}
	cout<<endl;
	return 0;
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A,B;
  string S,T,U;
  cin >> S >> T;
  cin >> A >> B;
  cin >>U;
  
  if (U==S){
    A-=1;
  }else{
    B-=1;
  }
  
  cout << A << " " << B << endl;
}

Measured memory_bytes: 256
import java.util.Scanner
 
object Main extends App {
  val sc = new Scanner(System.in)
 
  val n = sc.nextInt()
  val a = new Array[Int](n)
  for(i <- 0 until n)
    a(i) = sc.nextInt()
 
  var cnt = 0L
  var ans = 0L
  for(i <- 0 until n){
    val now = a(i)
    cnt += now
 
    if(i % 2 == 0){
      if(cnt < 1){
        ans += 1 - cnt
        cnt = 1
      }
    }
    else{
      if(cnt > -1){
        ans += cnt - (-1)
        cnt = -1
      }
    }
  }
 
  cnt = 0L
  var ans2 = 0L
  for(i <- 0 until n){
    val now = a(i)
    cnt += now
 
    if(i % 2 != 0){
      if(cnt < 1){
        ans2 += 1 - cnt
        cnt = 1
      }
    }
    else{
      if(cnt > -1){
        ans2 += cnt - (-1)
        cnt = -1
      }
    }
  }
 
  println(Math.min(ans, ans2))
}


Measured memory_bytes: 52444
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
print(rs()[0]+rs()[1]+rs()[2])

Measured memory_bytes: 62956
/******************************************************************************

рассвет.

*******************************************************************************/
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define rapgame ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define eb emplace_back
#define vi vector <int>
#define vlli vector <lli>
#define vulli vector <ulli>
#define vchar vector <char>
#define vstr vector <string>
#define vb vector <bool>
#define fst first
#define sec second
#define all(a) (a).begin(),(a).end()
#define srt(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define vpii vector <pair <int,int> >
#define pii pair <int,int>
#define vplli vector <pair <lli,lli> >
#define vvi vector <vector <int> >
#define vvlli vector <vector <lli> >
#define vvpii vector <vector <pair <int,int>> >
#define fr(i,n) for (int i = 0; i < (n); ++i)
#define frbig(i,n) for (lli i = 0; i < (n); ++i)
#define fra(i,a,n) for (lli i = a; i < (n); ++i)
#define run(c,s) for(auto c:s)
#define read(n) int n; cin >> n;
#define readchar(n) char n; cin >> n;
#define readstr(n) string n; cin >> n;
#define readarr(a,n) fr(i,n) cin >> a[i];
#define read2(x,y) int x,y; cin >> x >> y;
#define read2ll(x,y) long long int x,y; cin >> x >> y;
#define readll(n) lli n; cin >> n;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define print_array(x) fr(i,x.size()) cout << x[i];
using namespace std;

const lli MOD=1e9+7;
const lli MAXN=5e4+1;
const ld PI=acos(-1);

int main(){
    rapgame
    //freopen("bridges.in", "r", stdin);
    //freopen("bridges.out", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--){
         read(n);
         lli sum=0;
         vlli a(n);
         fr(i,n){
             cin >> a[i];
             fr(j,i) {
                 sum+=a[i]*a[j];
             }
         }
         cout << sum;
    }
    return 0;
}

Measured memory_bytes: 3504
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int n,a[100],b;
  b=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  for(int i=0;i<n;i++){
    b=a[i]-a[0];
  }
  cout<<b<<endl;
  return 0;
}


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

char s[105], t[105];

int main() {
	ios::sync_with_stdio(false);

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


	for (int len = n; len >= 0; len--) {
		bool valid = true;
		for (int x = 0; x < len; x++)
			if (t[x] != s[n - len + x])
				valid = false;
		if (valid) {
			cout << 2 * n - len << endl;
			return 0;
		}
	}


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

constexpr int MOD = 1000000007;

int mod(const ll &x){
    return x > 0 ? x % MOD : (x+MOD) % MOD;
}

int modm(const ll &x,const ll &m){
    return (x % MOD) * (m % MOD) % MOD;
}

int modpow(ll x, ll p) {
    int ret = 1;
    while(p > 0) {
        if (p & 1) ret = modm(ret,x);
        x = modm(x,x);
        p >>= 1;
    }
    return ret;
}

// x * modinv(d)
int modd(ll x,ll d) {
    return modm(x,modpow(d,MOD-2));
}

int main(void)
{
    IOS
    int N, K;
    cin >> N >> K;
    K--;
    ll mx = 0, mn = 0;
    int ans = 0;
    REP(i,N+1) {
        mn += i;
        mx += N-i;
        if (i >=K) {
            int cnt = mod(mx - mn+1);
            ans = mod(ans + cnt);
        }
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3620
#include <iostream>

using namespace std;

const int MAX_V = 100;

int main ( void )
{
  int n;
  int E[MAX_V][MAX_V];

  cin >> n;

  for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) { E[i][j] = 0; }

  for (int i = 0; i < n; ++i) {
    int u, k, v;
    cin >> u >> k;

    for (int i = 0; i < k; ++i) { cin >> v; E[u-1][v-1] = 1; }
  }
  
  for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) {
    cout << E[i][j] << (j+1 == n ? '\n' : ' ');
  }
  return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  long long int res=0;
  for(int i=0;i<n;i++){
    int p=a[i]/2;
    res+=p;
    a[i]-=p*2;
    if(i+1==n) break;
    if(a[i]==1 && a[i+1]>=1){
      res++;
      a[i]--;
      a[i+1]--;
    }

  }
  cout<<res<<endl;
  return 0;

}


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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define MODA 1000000007 

int main() {
    ll ans = 0;
    int n;
    cin >> n;
    ans = (ll)(n-1)* (ll)n / 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
int main(){
  double a,b,x;
  cin>>a>>b>>x;
  double v=a*a*b/2;
  double ans;
  if(x<=v){
    ans=90-atan(2*x/(a*b*b))*180/M_PI;
  }
  else{
    double t=atan(a/b)*180/M_PI;
    double c=sqrt(a*a+b*b);
    v=a*a*b-x;
    ans=atan(2*v/(a*a*a))*180/M_PI;
  }
  printf("%.16lf\n",ans);
  //  cout<<ans<<endl;
  return 0;
}


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

int main()
{
	int n, m, k;
	cin >> n >> m >> k;
	vector<long long> a(n + 1), b(m + 1);
	for(int i = 0; i < n; i++){
		cin >> a[i + 1];
		a[i + 1] += a[i];
	}
	for(int i = 0; i < m; i++){
		cin >> b[i + 1];
		b[i + 1] += b[i];
	}
	long long ans = 0;
	for(int i = 0; i <= n; i++){
		if(a[i] > k) continue;
		long long tmp = upper_bound(b.begin(), b.end(), k - a[i]) - b.begin();
		ans = max(ans, tmp + i - 1);
	}
	cout << ans << endl;
}


Measured memory_bytes: 6432
def main():
	n = int(input())
	list1 = [int(t) for t in input().split()]
	list1.sort()
	ans = 1
	b = 0
	for i in range (0, n):
		ans = ans * list1[i]
		if int(ans) > int(1000000000000000000):
			print(-1)
			return
	print(ans)
	return

if __name__ == "__main__":
  #Run as main program
  main()

Measured memory_bytes: 21748
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

int main() {
  int n;cin>>n;
  vector<pair<double,double>> vpos;
  int num = 1;
  for(int i=0;i<n;++i) {
    num *= i+1;
    double x,y;cin >> x >>y;
    vpos.push_back(make_pair(x,y));
  }
  vector<int> v(n);
  iota(v.begin(), v.end(), 1);
  double tot_dist = 0.0d;
  do {
    for(int j=1;j<n;++j){
      tot_dist += sqrt( (vpos[v[j-1]-1].first - vpos[v[j]-1].first)*(vpos[v[j-1]-1].first - vpos[v[j]-1].first) + (vpos[v[j-1]-1].second - vpos[v[j]-1].second)*(vpos[v[j-1]-1].second - vpos[v[j]-1].second) );
    }
  } while( next_permutation(v.begin(), v.end()) );

  cout << setprecision(10)<<fixed<<tot_dist/(double)num << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

int h, w;
vector< string > field;
vector< vector< bool > > reached;

using P = pair<s64, s64>;

P dfs(int y, int x, char c)
{
    P ret{0, 0};
    if (c == '#') ret.first = 1;
    else ret.second = 1;

    reached[y][x] = true;
    int dy[] = {-1, 0, 1, 0};
    int dx[] = {0, -1, 0, 1};
    rep (i, 4)
    {
        int ny = y + dy[i];
        int nx = x + dx[i];
        if (IN(0, h, ny) && IN(0, w, nx) && !reached[ny][nx] && field[ny][nx] != c)
        {
            P temp = dfs(ny, nx, field[ny][nx]);
            ret.first += temp.first;
            ret.second += temp.second;
        }
    }

    return ret;
}

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

    cin >> h >> w;
    field.resize(h);
    reached.resize(h, vector<bool>(w, false));
    rep (i, h) cin >> field[i];

    s64 ans = 0;
    rep (i, h)
    {
        rep (j, w)
        {
            if (!reached[i][j] && field[i][j] == '#')
            {
                P p = dfs(i, j, '#');
                ans += p.first * p.second;
            }
        }
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 23040
n, nFlips = map(int, input().split())
s = input().rstrip()

segs = []
i = 0
while i < n:
    if s[i] == '0':
        j = i
        while j + 1 < n and s[j + 1] == '0':
            j += 1
        segs.append((i, j))
        i = j
    i += 1
segs = segs or [(0, n - 1)]

ret = 0
for right in range(len(segs)):
    left = max(0, right - nFlips + 1)
    size = segs[right][1] - segs[left][0] + 1
    size += segs[left][0] - segs[left - 1][1] - 1 if left - 1 >= 0 else segs[left][0]
    size += segs[right + 1][0] - segs[right][1] - 1 if right + 1 < len(segs) else n - segs[right][1] - 1
    ret = max(ret, size)
print(ret)


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

long long ModPow(long long x, long long n, long long m) {
        long long res = 1;
        while (n > 0) {
                if (n & 1) res = res * x % m;
                x = x * x % m;
                n >>= 1;
        }
        return res;
}

int main() {
        int n;
        scanf("%d", &n);
        vector<int> cnt(n);
        bool ng = false;
        rep(i, n) {
                int d;
                scanf("%d", &d);
                cnt[d] ++;
                if (i == 0 && d != 0) {
                        ng = true;
                }
                if (i != 0 && d == 0) {
                        ng = true;
                }
        }
        if (ng) {
                puts("0");
                return 0;
        }
        long long ans = 1;
        const int mod = 998244353;
        rep(i, n - 1) {
                (ans *= ModPow(cnt[i], cnt[i + 1], mod)) %= mod;
        }
        printf("%lld\n", ans);
        return 0;
}


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= m; i--)
#define ll long long
#define pb push_back
#define popb pop_back
using namespace std;

int main(){
  int n, at;
  vector<int> a;
  cin >> n;

  REP(c, n){
      cin >> at;
      a.pb(at); 
    }
    int s = a.size();
    int ans = 0;
    
    REP(i, s){
        while(a[i] != 0 && a[i] % 2 == 0){
            a[i] /= 2;
            ans++;
          }
      }
      cout << ans << endl;
}


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

int main(){
    int n;
    int a,b=0;
    cin >> n;
    vector<int> c(n);
    for(int i=0; i<n; i++){
        cin >> c.at(i);
    }

    sort(c.begin(), c.end());
    reverse(c.begin(), c.end());
    for(int i=0; i<n; i++){
        if(i%2 == 0){
            a += c.at(i);
        }else{
            b += c.at(i);
        }
    }

    cout << a-b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1000000007;
vector<vector<int> > G(101010);
vector<int> height(101010);
void dfs(int v) {
  int depth = 0;
  if (G[v].size() == 0) return;
  vector<int> V;
  for (int i = 0; i < G[v].size(); i++) {
    int u = G[v][i];
    dfs(u);
    V.push_back(height[u]);
  }
  sort(V.begin(), V.end(), greater<int> ());

  for (int i = 0; i < G[v].size(); i++) {
    height[v] = max(height[v], V[i] + (i + 1));    
  }
  return;
}

signed main(){
  int N;
  cin >> N;
  for(int i = 2; i <= N; i++) {
    int a;
    cin >> a;
    G[a].push_back(i);
  } 
  dfs(1);
  cout << height[1] << endl;
}


Measured memory_bytes: 14336
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;

    string s;
    cin>>s;
    ll ans=0;
    ll n=stoi(s);
    rep(i,(ll)s.size()){
        ans+=s[i]-'0';
    }
    // cout<<ans<<endl;
    if(n%ans==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>
#include <bitset>
#include <map>
#include <climits>
#include <set>
#include <cmath>

using namespace std;

int main()
{
    int N, Y;
    cin >> N >> Y;
    for (int i = 0; i <= Y / 10000; ++i)
    {
        for (int j = 0; j <= (Y - i * 10000) / 5000; ++j)
        {
            int k = N - (i + j);
            if (Y == (10000 * i + 5000 * j + 1000 * k))
            {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

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


int main(){
    string s;
    cin >> s;

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

    int ans = 0;
    int ret = 0;
    for(int i = 0; i < s.length(); ++i){
        if(s[i] == s[i+1]){
            ++ans;
        }
        else{
            ++ret;
        }

    }

    if(ans == 2){
        cout << "Yes" << "\n";
    }
    else{
        cout << "No" << "\n";
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,k;
  int i,j;
  int count;
  while(scanf("%d",&n)){
    if(n==0) break;
    int index[n];
    count = 0;
    for(i=0;i<n;i++) scanf("%d",&index[i]);
    for(i=n-1;i>0;i--){
      for(j=0;j<i;j++){
	if(index[j]>index[j+1]){
	  k = index[j];
	  index[j] = index[j+1];
	  index[j+1] = k;
	  count++;
	}
      }
    }
    printf("%d\n",count);
  }
  return 0;
}

Measured memory_bytes: 1028
#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 long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	
	ll ans =0;
	array<ll, 2019> dp, np;
	fill(all(dp), 0);
	rep(i, sz(s)){
		int d = s[i]-'0';
		fill(all(np), 0);
		rep(j, 2019){
			np[(j*10 + d)%2019] += dp[j];
		}
		np[d]++;
		swap(np, dp);
		ans += dp[0];
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int x = N, sum = 0;
  while (N != 0) {
    sum += N%10;
    N = N/10;
  }

  if (x % sum == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl; 
  }
}

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

int main()
{
	int dataset;
	cin >> dataset;
	int a[100];
	for (int i = 0; i < dataset; i++)
	{
		cin >> a[i];
	}
	int flag = 1;
	int kaisuu = 0;
	while (flag) {
		flag = 0;
		for (int i = 1; i < dataset; i++)
		{
			if (a[i - 1] > a[i]) {
				int z = a[i - 1];
				a[i - 1] = a[i];
				a[i] = z;
				flag = 1;
				kaisuu++;
			}
		}
	}
	for (int i = 0; i < dataset; i++)
	{
		if (i > 0) {
			cout << " " << a[i];
		}
		else {
			cout << a[i];
		}
	}

	cout << endl << kaisuu << endl;
}

Measured memory_bytes: 3080
#include <iostream>
#include <string>
using namespace std;
int main()
{string s;
 int count=0; 
 while(cin>>s)
 {for(int i=0;i<3;i++)
  if(s.at(i)==s.at(i+1))
  {cout<<"Bad"<<endl;
   count+=1;
   break;
  }
   if(count==0)
 {cout<<"Good"<<endl;
 }
 }
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;
 
int main() {
  ll a, b, c, x, y, ans=0;
  cin >> a >> b >> c >> x >> y;
  if(a + b > 2 * c) {
    ans += 2 * c * min(x, y);
    if(x < y) ans += (y - x) * b;
    else ans += (x - y) * a;
  }
  else{
    ans +=  a * x + b * y;
  }
  ans = min(ans, 2 * c * max(x, y));
  cout << ans;
}


Measured memory_bytes: 256
#include <cstdio>

int main() {
  int x, y, g[13] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  scanf("%d %d", &x, &y);
  if(g[x] == g[y])
    printf("Yes\n");
  else
    printf("No\n");
}

Measured memory_bytes: 128
N = int(input())
a = list(map(int, input().split()))

Alice_score = 0
Bob_score = 0
for i in range(-(-N//2)): # 回数
    Alice_score += max(a)
    a.remove(max(a))
    if len(a) == 0: 
        break
    Bob_score += max(a)
    a.remove(max(a))
print(Alice_score - Bob_score)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF INT_MAX
#define eps LDBL_EPSILON
#define moder 100000
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
using namespace std;
int n,w,a[110],b[110],mi=INF;
P dp[5][110];
vector<int> vec[5];
signed main(){
	cin>>n>>w;
	rep(i,n){
		cin>>a[i]>>b[i];
		mi=min(mi,a[i]);
	}
	rep(i,n){
		vec[a[i]-mi+1].push_back(b[i]);
	}
	rep(i,5){
		sort(vec[i].begin(),vec[i].end(),greater<int>());
		rep(j,vec[i].size()){
			if(j)vec[i][j]+=vec[i][j-1];
		}
		if(!vec[i].empty())vec[i].insert(vec[i].begin(),0);
		else vec[i].push_back(0);
	}
	int ans=0;
	rep(i,vec[1].size()){
		rep(j,vec[2].size()){
			rep(k,vec[3].size()){
				rep(l,vec[4].size()){
					if(mi*i+(mi+1)*j+(mi+2)*k+(mi+3)*l<=w)ans=max(ans,vec[1][i]+vec[2][j]+vec[3][k]+vec[4][l]);
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl

const long long MOD = 1000000007;

ll dp[100010][13];

int main(){
    string s;
    cin >> s;

    ll len = s.size();
    dp[0][0] = 1;
    rep(i, len){
        if(s[i] == '?'){
            rep(j, 13) {
                rep(k, 10){
                    dp[i+1][(j*10+k)%13] += dp[i][j];
                    dp[i+1][(j*10+k)%13] %= MOD;
                }
            }
        }else{
            ll n = s[i]-'0';
            rep(j, 13){
                dp[i+1][(j*10+n)%13] += dp[i][j];
                dp[i+1][(j*10+n)%13] %= MOD;
            }
        }
    }

    cout << dp[len][5] << endl;

    return 0;
}


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n;
    cin >> n;
    vvint a(2, vint(n));
    rep(i, 2) rep(j, n) cin >> a[i][j];

    int ans = 0;
    rep(i, n)
    {
        int tmp = accumulate(a[0].begin(), a[0].begin() + i + 1, 0) + accumulate(a[1].begin() + i, a[1].end(), 0);
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
N = int(input())
list_s = [input() for j in range(N)]
M = int(input())
list_t = [input() for i in range(M)]

###blue:N, red:M, blue:+1, red:-1
###差し引きマックス
###全部マイナスなら0

list = []

for s in list_s:
    list.append(list_s.count(s) - list_t.count(s))
if max(list)>=0:
    print(max(list))
else:
    print(0)


Measured memory_bytes: 2940
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;


long long int gcd(long long int x, long long int y){
	
	long long int tmp;
	while(x%y!=0){
		tmp=y;
		y=x%y;
		x=tmp;
	}
	return y;
}

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

long long int v_gcd(vector<long long int> v){
	
	if(v.size() <= 1){
		return v[0];
	}
	
	long long int tmp=v[0];
	
	for(int i=1;i<v.size();i++){
		tmp=gcd(tmp,v[i]);
	}
	return tmp;
}

long long int v_lcm(vector<long long int> v){
	
	if(v.size()<=1){
		return v[0];
	}
	
	long long int tmp=v[0];
	for(int i=1;i<v.size();i++){
		tmp = tmp*v[i]/gcd(tmp, v[i]);
	}
	return tmp;
}

int main(){
	int N;
	long long int X;
	cin>>N>>X;
	vector<long long int> x(N);
	for(int i=0;i<N;i++){
		cin>>x[i];
		x[i]=abs(X-x[i]);
	}
	cout<<v_gcd(x)<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <set>
#include <climits>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

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

    int m = max(a, max(b, c));
    int p = m;
    for (int i = 0; i < k; ++i) {
        p *= 2;
    }

    int ans = a + b + c + p - m;
    printf ("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
int main(){
    int A,B,K;
    cin >> A >> B >> K;
    set<int> s;
    for(int i=0; i<K; i++){
        s.insert(A+i);
        if(A+i >= B) break;
    }
    for(int i=0; i<K; i++){
        s.insert(B-i);
        if(B-i <= A) break;
    }

    auto itr = s.begin();
    while(itr != s.end()){
        cout << *itr << endl;
        itr++;
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static int sum(int a) {
		int ans = 0;
		while(a >= 10) {
			ans += a%10;
			a /= 10;
		}
		ans += a;
		return ans;
	}

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int A = stdIn.nextInt();
		int B = stdIn.nextInt();
		int Ans = 0;
		
		for(int i = 1; i <= N; i++) {
			if(A <= sum(i) && sum(i) <= B) {
				Ans += i;
			}
		}
		System.out.println(Ans);

	}

}

Measured memory_bytes: 21844
n, m = map(int, input().split())
mod = 1000000007

aa = {}
for _ in range(m):
  aa[int(input())] = True

dp = [0] * (n+1)
dp[0] = 1
if 1 in aa:
  dp[1] = 0
else:
  dp[1] = 1

for i in range(2, n+1):
  if i in aa:
    dp[i] = 0
  else:
    dp[i] = (dp[i-1] + dp[i-2]) % mod
print(dp[n])


Measured memory_bytes: 15076
#include "bits/stdc++.h"
using namespace std;

int main(int argc, char **argv) {
  const string exist = "Yay!";
  const string notexist = ":(";

  unsigned int k, x[5];
  for (int i = 0; i < 5; i++) {
    cin >> x[i];
  }
  cin >> k;

  bool ans = false;
  for (int i = 0; i < 5; i++) {
    for (int j = i; j < 5 - i; j++) {
      if (x[j] - x[i] > k)
        ans = true;
    }
  }

  if (ans)
    cout << notexist << endl;
  else
    cout << exist << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

//bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }

    friend std::istream &operator>>(std::istream &in, mint &o) {
        ll a;
        in >> a;
        o = a;
        return in;
    }

    friend std::ostream &operator<<(std::ostream &out, const mint &o) {
        out << o.x;
        return out;
    }

};

ll gcd(ll x, ll y) {
    if (x > y) swap(x, y);
    ll m = 1;
    while (m != 0) {
        m = y % x;
        y = x;
        x = m;
    }
    return y;
}

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

int main() {

    int n;
    cin >> n;
    vector<ll> numbers(n);
    rep(i, n) cin >> numbers[i];

    ll ans = numbers.front();
    rep(i, n) ans = lcm(ans, numbers[i]);

    cout << ans << endl;
}



Measured memory_bytes: 3112
#include<iostream>
#include<sstream>
#include<ios>
#include<iomanip>
#include<vector>
#include<list>
#include<queue>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<string>
#include<numeric>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
  string S;
  cin >> S;

  if(S == "Sunny")
    cout << "Cloudy" << endl;
  else if(S == "Cloudy")
    cout << "Rainy" << endl;
  else
    cout << "Sunny" << endl;
  
  return 0;
}

Measured memory_bytes: 256
n,x = gets.split.map(&:to_i)

arr = []
i = n + 1
y = x - 1
p = 2**i - 2

loop do
  i = i-1
  case
  when y < p
    arr << [:left, i]
    p = p - 2**i + 1
  when y > p
    arr << [:right, i]
    p = p + 2**i - 1
  when y == p
    arr << [:middle, i]
    break
  end
  break if i == 0
end

r = 0

arr.each do |v|
  case v[0]
  when :right, :middle
    r = r + 2**(v[1])
  end
end

puts r


Measured memory_bytes: 1788
#include <iomanip>
#include "algorithm"
#include "cmath"
#include "iostream"
using namespace std;
typedef long long ll;

int main() {
  ll A, B;
  cin >> A >> B;

  if (A <=9 && B <= 9) {
    cout << A*B << endl;
  } else {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

vector<vector<char>> d(100, vector<char>(100));
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){
    int r,c;
    cin >> r >> c;
    int sy = 0, sx = 0;
    int gx, gy;
    gx = r-1, gy = c-1;
    int cnt_w = 0;
    rep(i, r){
        rep(j, c){
            cin >> d.at(i).at(j);
            if(d[i].at(j) == '.'){
                cnt_w++;
            }
        }
    }
    vvi dep(r, vi(c, -1));
    dep.at(sy).at(sx) = 0;

    queue<pair<int, int> > que;
    que.push(make_pair(sy, sx));

    while(!que.empty()){
        pair<int, int> pos = que.front();
        que.pop();
        int x = pos.second;
        int y = pos.first;

        rep(i, 4){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(nx < 0 || nx > c-1 || ny < 0 || ny > r-1)
            continue;
            if(d.at(ny).at(nx) == '#')
            continue;

            if(dep.at(ny).at(nx) == -1){
                que.push(make_pair(ny, nx));
                dep.at(ny).at(nx) = dep.at(y).at(x) + 1;
            }
        }
    }
    /*
    rep(i, r){
        rep(j, c){
            printf("%3d", dep.at(i).at(j));
        }
        cout << endl;
    }
    */
    if(dep.at(gx).at(gy) == -1) {
        cout << -1 << endl;
    }
    else {
        cout << cnt_w - dep.at(gx).at(gy)-1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	if (n < 10) {
		cout << n <<endl;
	}
	else if (n < 100) {
		cout << 9 << endl;
	}
	else if (n < 1000) {
		cout << n - 90 << endl;
	}
	else if (n < 10000) {
		cout << 909 << endl;
	}
	else if (n < 100000) {
		cout << n - 90 - 9000 << endl;
	}
	else {
		cout << 90909 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
// Q from "https://atcoder.jp/contests/abc051/tasks/abc051_b"

#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1000000007;

void solve() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  rep(i, k+1) {
    for(int j = 0; j < k+1 ; j++) {
      if (i + j <= s && i + j + k >= s) ans++;
    }
  }
  cout << ans << endl;
}

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

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

def mergesort(a):
    def _merge_sort(a, left: int, right: int):
        if left < right:
            center = (left+right)//2

            _merge_sort(a,left,center)
            _merge_sort(a,center+1,right)

            #pは前半部をbuffにコピーする際のインデックス、jで取り出す
            p=j=0
            i=k=left

            #配列の前半部をbuffにコピー
            while i <= center:
                buff[p]=a[i]
                p+=1
                i+=1

            #後半部をコピーされた前半部と比較、小さい方をaに格納していく
            while i<= right and j < p:
                if buff[j] <= a[i]:
                    a[k]=buff[j]
                    j+=1
                else:
                    a[k]=a[i]
                    i+=1
                k+=1

            while j < p:
                a[k] =buff[j]
                k+=1
                j+=1

    n=len(a)
    #merge結果を一時的に格納
    buff=[None]*n
    _merge_sort(a,0,n-1)
    del buff

mergesort(d)
print(d[(n//2)]-d[(n//2)-1])

Measured memory_bytes: 14396