akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
const int N = 1e6 + 10, OO = 0x3f3f3f3f, mod = 1e9 + 7;

#define PI acos(-1)
#define clr(arr, val) memset(arr, val, sizeof(arr))
#define loop(i, n) for (int i = 0; i < int(n); i++)
#define rloop(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define xloop(i, a, b) for (int i = int(a); i <= int(b); i++)
#define ALL(v) ((v).begin()), ((v).end())
#define SZ(v) ((int)((v).size()))
int dx[] = {1, 0, -1, 0}; // {down , right , up , left}
int dy[] = {0, 1, 0, -1}; //4 Direction
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
//int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; //8 direction
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2};
//int dy[] = {1, 2, 2, 1, -1, -2, -2, -1}; //Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction

//-- "كلٌّ من يسعى لابد يصل .. كلٌّ من يسعى مضمون له الوصول" --//

int n, total;

int main()
{
  //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

  cin >> n;
  set<string> st;
  loop(i, n)
  {
    string s;
    cin >> s;
    st.insert(s);
  }

  cout << SZ(st) << "\n";

  return 0;
}


Measured memory_bytes: 19136
<>=~$";
@a=glob`dd`;
$a[$_-1]%2&&($%=$_%$'?$_:$_<$`*$'&&$_-1+$')&&++$a[$%]+push@_,$_-1,$%for 1..$`*$';
print@_/2,$/,map{$_/$'+1|0,$",$_%$'+1,--$|?$":$/}@_


Measured memory_bytes: 117288
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

int main(void) {
  llint a[4];
  REP(i, 4) scanf("%lld", &a[i]);

  llint n;
  scanf("%lld", &n);
  n *= 4;

  REP(i, 3) a[i + 1] = min(a[i + 1], 2 * a[i]);
  llint ret = 0;
  REP(i, 3) {
    if (n % 2) ret += a[i];
    n /= 2;
  }
  ret += n * a[3];

  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 256
from sys import stdin


def main():
    n = int(stdin.readline())
    a = list(map(int, stdin.readline().split()))

    ans = [0] * n

    for i in range(n - 1):
        ans[a[i] - 1] += 1

    print(*ans, sep='\n')


if __name__ == "__main__":
    main()


Measured memory_bytes: 31044
''' 1.降序排列，选出x个红苹果，y个绿苹果
    2.使用c个无色苹果去更新这x+y个苹果中的小值，直到最小也比无色苹果的大为止'''
nums = [int(i) for i in input().split()]
x = nums[0]
y = nums[1]
a = nums[2]
b = nums[3]
c = nums[4]
redApples = [int(i) for i in input().split()]
greenApples = [int(i) for i in input().split()]
colorless = [int(i) for i in input().split()]

redApples.sort(reverse=True)
greenApples.sort(reverse=True)
colorless.sort(reverse=True)
redApples = redApples[:x]
greenApples = greenApples[:y]

res = redApples+greenApples
res.sort(reverse=True)
currIndex = len(res)-1
for i in range(len(colorless)):
    if colorless[i] <= res[currIndex]:
        break
    res[currIndex] = colorless[i]
    currIndex -= 1
    if currIndex < 0:
        break

print(sum(res))


Measured memory_bytes: 29380
#include<iostream>
#include<cstring>

#define M 1046527
#define L 14
typedef long long ll;

using namespace std;

char H[M][L];

int getChar(char c)
{
	if (c == 'A')
		return 1;
	if (c == 'C')
		return 2;
	if (c == 'G')
		return 3;
	else
		return 4;
}

ll getKey(char name[])
{
	int p = 1;
	ll s = 0;
	for (int i = 0; i < strlen(name); ++i)
	{
		s += p * getChar(name[i]);
		p *= 5;
	}
	return s;
}

int h1 (ll key)
{
	return key % M;
}

int h2 (ll key)
{
	return 1 + key % (M - 1);
}

int insert(char name[])
{
	ll key = getKey(name);
	int h;
	for (int i = 0; ; ++i)
	{
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], name) == 0)
			return 1;
		else if (strlen(H[h]) == 0)
		{
			strcpy(H[h], name);	
			return 0;
		}
	}
	return 0;
}

bool find (char name[])
{
	ll key = getKey(name);
	int h;
	for (int i = 0; ; ++i)
	{
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], name) == 0)
			return true;
		else if (strlen(H[h]) == 0)
			return false;
	}
	return false;
}

int main()
{
	for (int i = 0; i < M; ++i)
		H[i][0] = '\0';
	int n;
	cin >> n;
	char com[9], name[L];
	for (int i = 0; i < n; ++i)
	{
		cin >> com >> name;
		if (com[0] == 'i')	
		{
			insert(name);
		}
		else 
		{
			if (find(name))
				cout << "yes" << endl;
			else 
				cout << "no" << endl;
		}
	}
}



Measured memory_bytes: 17444
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 1000000000;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

ll dp1[2010][2010];
ll dp2[2010][2010];

int main(){
    ll N,M;
    cin >> N >> M;
    vector<ll> S(N+1),T(M+1);
    rep(i,N) cin >> S[i];
    rep(i,M) cin >> T[i];
    dp1[0][0] = 1;
    rep(i,N+1) rep(j,M+1){
        dp1[i+1][j] += dp1[i][j];
        dp2[i][j] += dp1[i][j];
        dp2[i][j+1] += dp2[i][j];
        if(S[i] == T[j]){
            dp1[i+1][j+1] += dp2[i][j];
        }
        dp1[i+1][j] %= MOD;
        dp2[i][j] %= MOD;
        dp2[i][j+1] %= MOD;
        dp1[i][j+1] %= MOD;
    }
    cout << dp2[N][M] << endl;
}



Measured memory_bytes: 63232
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long long ll;

int main(){
    map<string,int> m;
    string S, T;
    cin >> S >> T;
    int a, b;
    cin >> a >> b;
    m[S] = a;
    m[T] = b;
    string op;
    cin >> op;
    m[op]--;
    
    cout << m[S] << " " << m[T] << endl;
    return 0;
}


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

#define ll long long
#define ull unsigned long long
#define vii vector<int>
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pdd pair<double,double>
#define pldld pair<long long double, long long double>
#define ff first
#define ss second
#define pb push_back
#define read freopen("alu.txt","r",stdin);
#define write freopen("vorta.txt","w",stdout);
#define fastio ios::sync_with_stdio(false); cin.tie(NULL);
#define PI 2*acos(0.0)
#define DEBUG(x) cerr << #x << " = " << x << endl

const int MAX = 3e5 + 5, MOD = 1e9 + 7, MAXLG = log2(MAX)+1;
const ll inf = 1e18 + 5;

pii arr[MAX];
multiset<pii>st;
map<int,int>mp;
int main(){

    fastio;
    int n,k;
    cin>>n>>k;
    for(int i=0; i<n; i++){
        cin>>arr[i].ss>>arr[i].ff;
    }
    sort(arr, arr+n, greater<pii>());

    ll val = 0;
    for(int i=0; i<k; i++){
        val += arr[i].ff;
        mp[arr[i].ss]++;
        st.insert(arr[i]);
    }

    ll var = mp.size();
    ll ans = val + var * var;

    for(int i=k; i<n; i++){
        if(!mp[arr[i].ss]){
            while(!st.empty()){
                if(mp[(*st.begin()).ss] > 1){
                    mp[(*st.begin()).ss]--;
                    mp[arr[i].ss]++;
                    val -= (*st.begin()).ff;
                    val += arr[i].ff;
                    var++;
                    st.erase(st.begin());
                    st.insert(arr[i]);
                    break;
                }
                else st.erase(st.begin());
            }
            if(st.empty()) break;

            ll temp = val + var * var;
            ans = max(ans, temp);
        }
    }

    cout<<ans<<"\n";

}




Measured memory_bytes: 8448
import bisect
import collections
import itertools


def getint(): return int(input())
def getints(): return list(map(int, input().split()))
def getint2d(rows): return [getints() for _ in range(rows)]
def getgrid(rows): return [input() for _ in range(rows)]
def array1d(n, value): return [value for _ in range(n)]
def array2d(n, m, value): return [array1d(m, value) for _ in range(n)]

k,x=getints()

min_value = max(x - k + 1, -1000000)
max_value = min(x + k - 1,  1000000)

for i in range(min_value, max_value + 1):
    print(i, end=" ")
print("")

Measured memory_bytes: 38256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

#define keta setprecision(10) //10桁表示

const int MAX = 1000005;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

	ll x, y;
	cin >> x >> y;

	ll ans = 1;

	ll hamiX = x;
	ll hamiY = y;

	for (int i = 1; i < max(x, y); i++)
	{
		hamiX--;
		hamiY--;
		if (hamiX + hamiY == i)
		{
			break;
		}
	}

	if ((x + y) % 3 == 0)
	{
		if (hamiX == 0 || hamiY == 0)
		{
			cout << 1 << endl;
		}
		else if (hamiX < 0 || hamiY < 0)
		{
			cout << 0 << endl;
		}
		else
		{
			cout << COM(hamiX + hamiY, max(hamiX,hamiY)) << endl;
		}
	}
	else
	{
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 23808
import sys

w = str(input())
arr = []

for i in range(0,len(w)):
  arr.append(w[i])
arr = sorted(arr)

if len(arr)%2 == 1:
  print("No")
  sys.exit()

for i in range(0,len(w),2):
  if arr[i] != arr[i+1]:
    print("No")
    sys.exit()
print("Yes")

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

int main()
{
    int A, B, C, temp;
    cin>>A>>B>>C;
    temp=A;
    A=B;
    B=temp;
    temp=A;
    A=C;
    C=temp;
    cout<<A<<" "<<B<<" "<<C;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>

struct modular_arithmetic{
	int mod;

	modular_arithmetic(){
		mod = 1000000007;
	}
	//No specific settings.
	int add(int x,int y){return (x+=y)<mod?x:x-mod;}
	int sub(int x,int y){return (x-=y)>=0?x:x+mod;}
	int mul(int x,int y){return (int)((long long int)x*y%mod);}
	int pw(int base, int p) {
		int res = 1, mu = base%mod;
		for(;p>0;p/=2) {
			if (p&1) res = mul(res, mu);
			mu = mul(mu, mu);
		}
		return res;
	}
	int rev(int x) {return pw(x, mod-2);}
};
modular_arithmetic ma;

int n, a, b, c;

int main() {
	scanf("%d%d%d%d", &n, &a, &b, &c);
	
	int ans = 0;
	int A = ma.mul(a, ma.rev(a+b));
	int B = ma.mul(b, ma.rev(a+b));
	
	int C = 0, alpha_n = ma.pw(A, n), beta_n = ma.pw(B, n);
	int alpha_i = 1, beta_i = 1;
	for(int i=0;i<n;i++) {
		if(i==0) C=1;
		else {
			C=ma.mul(C, n-1+i);
			C=ma.mul(C, ma.rev(i));
		}
		
		int va = ma.mul(C, ma.mul(alpha_n, ma.mul(beta_i, n+i)));
		int vb = ma.mul(C, ma.mul(alpha_i, ma.mul(beta_n, n+i)));
		ans = ma.add(ans, va);
		ans = ma.add(ans, vb);
		
		alpha_i = ma.mul(alpha_i, A);
		beta_i = ma.mul(beta_i, B);
	}
	
	ans = ma.mul(ans, 100);
	ans = ma.mul(ans, ma.rev(100-c));
	
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
static const int N=100;

int main(){
	int m[N][N];
	int n,u,k,v;
	
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			m[i][j]=0;
		}
	}
	
	for(int i=0;i<n;i++){
		cin>>u>>k;
		u--;
		for(int j=0;j<k;j++){
			cin>>v;
			v--;
			m[u][v]=1;
		}
	}
	
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(j) cout<<" ";
			cout<<m[i][j];
		}
		cout<<endl;
	}
	return 0;
} 

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

int main() {
  vector<char> a(2), b(2);
  cin >> a.at(0) >> a.at(1);
  b = a;
  sort(a.begin(), a.end());
  if(a.at(0) == a.at(1)) cout << '=' << endl;
  else if(a == b) cout << '<' << endl;
  else cout << '>' << endl;
}


Measured memory_bytes: 256
S=input()
T=input()
n=len(T)
l=len(S)-n
p=0
for i in range(l+1):
    j=0
    m=S[i:i+n]
    
    for k in range(n):
        if(m[k]==T[k]):
            j+=1

    if(p<j):
        p=j
print(n-p)


Measured memory_bytes: 9120
#include<stdio.h>
int teto(int,int);

int a[25],n,ayana=0;

int main(void){
  int q,m[205],i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
  }
  for(i=0;i<q;i++){
    teto(0,m[i]);
    if(ayana==1){
	printf("yes\n");
    }
    else{
      printf("no\n");
    }
    ayana=0;
  }

  return 0;
}

int teto(int i,int x){
  if(x==0){
    ayana=1;
    return 1;
  }
  else if(i<n){
    teto(i+1,x-a[i]);
    teto(i+1,x);
  }
  return 0;
}

Measured memory_bytes: 580
# coding: utf-8
"""docstring"""


def arr2d(d1, d2, init=None):
    return [[init for i in range(d2)] for j in range(d1)]


def solve(N, W):
    v = [None] * N
    w = [None] * N
    for i in range(N):
        v[i], w[i] = map(int, input().split())

    # dp[i][j]: item 0..i ??????weight sum <= j ??¨????????????????????¶????????§????????§???value sum
    # (i: 0..N-1, j: 0..W)
    dp = arr2d(N, W + 1, 0)
    # i==0
    for j in range(0, W + 1):
        dp[0][j] = (j // w[0]) * v[0]
    for i in range(1, N):
        for j in range(0, W + 1):
            dp[i][j] = dp[i-1][j]
            if j >= w[i]:
                dp[i][j] = max(dp[i][j], dp[i-1][j-w[i]] + v[i])
                dp[i][j] = max(dp[i][j], dp[i][j-w[i]] + v[i])
    return dp[-1][-1]


def main():
    n, w = map(int, input().split())
    print(solve(n, w))


if __name__ == "__main__":
    main()

Measured memory_bytes: 17888
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int main(){

    string B;
    cin >> B;
    string tmp;
    tmp = B.substr(0,1);
    string tmp2;
    
    string ans = "Good";
    for( int bi = 1 ; bi < B.length() ; bi++ ){
        tmp2 = B.substr(bi,1);
        if(tmp == tmp2) ans = "Bad";
        tmp = B.substr(bi,1);
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
#include <cstdint>

typedef long long int llint;

void solve(){

  llint a, v, b, w, t;
  std::cin >> a >> v >> b >> w >> t;

  llint diff = std::abs(a-b);

  llint diff_v = v-w;

  if(diff <= diff_v * t) std::cout << "YES" << std::endl;
  else                   std::cout << "NO" << std::endl;
  
}

int main(void){

  solve();
  
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  bool flag = false;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == s.at(i + 1))
      flag = true;
  }
  if (flag == true) 
    cout << "Bad" << endl;
  else
    cout << "Good" << endl;
} 

Measured memory_bytes: 256
#include <stdio.h>
 
int Sort(int n,int *a);
 
int main(){
  int len,i,count,j,a[100];
   
  //input
  scanf("%d", &len);
  for(i=0; i<len; i++){
    scanf("%d", &a[i]);
  }
 
  //sort
  count = Sort(len, &a[0]);
 
  //output
  for(i=0; i<len; i++){
    printf("%d", a[i]);
    if(i != len-1)printf(" ");
    else printf("\n");
  }
  printf("%d\n", count);
   
  return 0;
}
 
int Sort(int len,int *a){
  int i,j;
  int mini,tmp,count=0;
   
  for(i=0; i<len; i++){
    mini = i;

    for(j=i+1; j<len; j++){
      if(a[j] < a[mini]){
	mini = j;
      }
    }

    if(mini != i){
      tmp = a[i];
      a[i] = a[mini];
      a[mini] = tmp;
      ++count;
    }

  }
  return count;
}

Measured memory_bytes: 604
N = int(input())
A = list(map(int, input().split()))
_A = [0] * (N - 1)
for i in range(len(A) - 1):
    if A[i] < A[i + 1]:
        _A[i] = 1
    elif A[i] > A[i + 1]:
        _A[i] = -1

money = 1000
cnt = 0
flag = 0
for i in range(len(_A)):
    if flag == 0 or flag == -1: #下落中
        if _A[i] == 1: #上がりそう
            cnt += money // A[i]
            money -= (money // A[i]) * A[i] #全部買う
            flag = 1
    elif flag == 0 or flag == 1: #上昇中
        if _A[i] == -1:
            money += cnt * A[i]  # 全部売る
            cnt = 0
            flag = -1
    #print(money)

money += cnt * A[N - 1]  # 全部売る
print(money)


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

ll mod = 1000000007;
ll ans = 1<<29;

int main() {
    int N,T;
    cin >> N>>T;
    vector<int> t(N);
    rep(i,N) cin >> t[i];

    int st = t[0]; ans =0;
    rep(i,N){
        if(st <= t[i]) {
             ans += T;
             st = t[i]+T;
    }
        else{
            ans += t[i]+T-st;
            st = t[i]+T;
        }      
}
 cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
int main(){
    int n,r;
    string s,t,u;
    cin >> s >> t >> n >> r >> u;
    if(u == s){
        cout << n-1 << " " << r << endl;
    }
    else{
        cout << n << " " << r-1 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n, m;
    long long int k;
    cin >> n >> m >> k;
    vector<long long int> va(1, 0), vb(1, 0);
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        va.push_back(va.back() + t);
    }
    for (int i = 0; i < m; i++) {
        int t;
        cin >> t;
        vb.push_back(t + vb.back());
    }
    int res = 0;
    int i1 = 0, i2 = vb.size() - 1;
    while (i1 < va.size() && i2 >= 0) {
        if (va[i1] + vb[i2] > k) {
            i2--;
        } else {
            res = max(res, i1 + i2);
            i1++;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 7972
n, a, b = map(int, input().split())

mod = 10**9 + 7

ans = pow(2, n, mod)

ans -= 1

aa = 1
for i in range(1, a+1):
    aa = (aa * (n - i + 1) * pow(i, -1, mod)) % mod

bb = 1
for i in range(1, b+1):
    bb = (bb * (n - i + 1) * pow(i, -1, mod)) % mod

ans = (ans - aa - bb) % mod

print(ans)

Measured memory_bytes: 9020
#include<bits/stdc++.h>
#define ll long long
#define uint unsigned
#define ull unsigned ll
#define db double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define vi vector<int>
#define vpi vector<pii >
#define IT iterator
 
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define y1 wzpakking
#define fi first
#define se second
#define BG begin
#define ED end
 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define sqr(x) (1ll*x*x)
 
#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
#define inf (1<<30)
#define INF (1ll<<58)
using namespace std;
int a[105],n,ans[105];
int main(){
	scanf("%d",&n);
	For(i,1,n) scanf("%d",&a[i]);
	Rep(i,n,1){
		int p=i;
		for (;a[p]!=p;--p);
		if (!p) return puts("-1"),0;
		ans[i]=a[p];
		For(j,p,i) a[j]=a[j+1];
	}
	For(i,1,n) printf("%d\n",ans[i]);
}

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

using namespace std;

const int MAX_LENGTH = 100000, INDEX = 1;

string s, t;

int pss[MAX_LENGTH + INDEX], pst[MAX_LENGTH + INDEX];

int q;

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

    cin >> s >> t;

    pss[0] = 0;
    for (int i = 1; i <= s.length(); i++) {
        if (s[i - 1] == 'A') {
            pss[i] = pss[i - 1] + 1;
        }

        if (s[i - 1] == 'B') {
            pss[i] = pss[i - 1] - 1;
        }
    }

    pst[0] = 0;
    for (int i = 1; i <= t.length(); i++) {
        if (t[i - 1] == 'A') {
            pst[i] = pst[i - 1] + 1;
        }

        if (t[i - 1] == 'B') {
            pst[i] = pst[i - 1] - 1;
        }
    }

    cin >> q;

    for (int i = 1; i <= q; i++) {
        int a, b, c, d;

        cin >> a >> b >> c >> d;

        if (((pss[b] - pss[a - 1]) - (pst[d] - pst[c - 1])) % 3 == 0) {
            cout << "YES" << '\n';
        } else {
            cout << "NO" << '\n';
        }
    }

    return 0;
}


Measured memory_bytes: 1744
import sys
def input(): return sys.stdin.readline().rstrip()
from itertools import combinations
from collections import Counter
def main():
    n=int(input())
    if n==1:
        print(1)
        sys.exit()
    XY=[tuple(map(int,input().split())) for i in range(n)]
    XY.sort()
    PQ=[]
    for i in range(n-1):
        x1=XY[i]
        for j in range(i+1,n):
            x2=XY[j]
            PQ.append((x2[0]-x1[0],x2[1]-x1[1]))
    print(n-Counter(PQ).most_common(1)[0][1])

if __name__=='__main__':
    main()

Measured memory_bytes: 3564
#include<stdio.h>
int main(){
  char s[5];
  scanf("%s",s);
  int ans=0;
  if(s[0]==s[1]){if(s[1]!=s[2]&&s[2]==s[3])ans=1;}
  else if(s[0]==s[2]){if(s[1]==s[3]&&s[0]!=s[1])ans=1;}
  else if(s[0]==s[3]){if(s[1]==s[2]&&s[0]!=s[1])ans=1;}
  puts(ans?"Yes":"No");
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <map>
#include <queue>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;
typedef vector<string> vs;

int main() {
  ll n, x;
  cin >> n >> x;
  ll res = n;
  ll a = x, b = n - x;
  while (b) {
    res += 2*b*(a/b);
    a %= b;
    swap(a, b);
  }
  cout << res - a << endl;
  return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n, s;
  while (cin >> n >> s, n) {
    int c = 0;
    rep(i, 1024) if (bitset<64>(i).count() == n) {
      int t = 0;
      rep(j, 9) if (i >> j & 1) t += j + 1;
      c += t == s;
    }
    cout << c << endl;
  }
}

Measured memory_bytes: 2984
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(100000)

def digsum(x):
  result = 0
  while x != 0:
    result += x % 10
    x //= 10
  return result

ans = 10**6
N = read()
for A in range(1, N):
  B = N - A
  ans = min(ans, digsum(A) + digsum(B))

print(ans)

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


int main() {
int64_t N,K;
  cin >> N >>K;
  int64_t x = N/K;
  int64_t s = N - K*(x+1);
  if(s+K > abs(s)) cout << abs(s) <<endl;
  else cout <<abs(s+K) <<endl;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int thp = sc.nextInt();
		int tat = sc.nextInt();
		int ahp = sc.nextInt();
		int aat = sc.nextInt();
		boolean flag = true;
		while(thp > 0 && ahp > 0) {
			if(flag){
				flag = false;
				ahp -= tat;
			} else {
				flag = true;
				thp -= aat;
			}
		}
		if(thp > 0){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}


	}
}


Measured memory_bytes: 27036
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <set>
using namespace std;
using ll = long long;


int main()
{
    // 整数の入力
    ll N;
    cin >> N;
    ll ans = N*(N+1)*(N+2)/6;
    for(int i = 0;i < N-1;i++){
      ll u,v;
      cin >> u >> v;
      if (u > v){
        swap(u,v);
      }
      ans -= u * (N - v +1);
    }
    cout << ans << endl;
    return 0;
}

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

struct suc {
  char c;
  long long num;
};

int main () {
  string S;
  long long N;
  cin >> S >> N;
  
  long len = S.size();
  vector<suc> V(len);
  
  char tmp = S[0];
  int itr = 0;
  V[itr].c = tmp;
  V[itr].num = 1;;
  
  for(int i=1; i<len; i++) {
    if(S[i]==tmp) {
      V[itr].num++;
    } else {
      itr++;
      tmp = S[i];
      V[itr].c = tmp;
      V[itr].num = 1;
    }
  }
  
  int i=0;
  for(auto v:V) {
    if(v.num==0) {
      break;
    }
    i++; 
  }
  
  long long ans = 0;
  for(auto v:V) {
    ans += v.num/2; 
  }
  V.erase(V.begin()+i, V.begin()+len);
  
  if(V.size()==1) {
    long long ans = (V[0].num * N) / 2;
    cout << ans << endl;
    return 0;
  }
  
  if(V[0].c==V[V.size()-1].c) {
    V[V.size()-1].num += V[0].num;
    V.erase(V.begin());
  }
  
  long long tmp_ans = 0;
  for(auto v:V) {
    tmp_ans += v.num/2;
  }

  ans += tmp_ans * (N-1);
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fir first
#define sed second
#define i64 int64_t
#define mp make_pair
#define pb push_back
const int mod = 1e9+7;

using namespace std;
ifstream fi("");
ofstream fo("");

int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    ll a,b;
    cin>>a>>b;
    cout<<a*b/__gcd(a,b);
}





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

int main() {

    int n;
    cin >> n ;

    vector<int> ans(100000,0);
    vector<vector<vector<int>>> vec(100, vector<vector<int>>(100, vector<int>(100)));

    rep(i,100) rep(j,100) rep(k,100) {
        vec.at(i).at(j).at(k) = i*i + j*j + k*k + i*j + j*k + k*i;
        ans.at(vec.at(i).at(j).at(k))++;
    }
    for(int i = 0; i < n; i++){
        cout << ans.at(i+1) << endl;
    }

}





Measured memory_bytes: 7956
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <queue>
typedef long long lint;
const int N=1e5+5;
const int mod=1e9+7;
int n,m,qs,qt,scnt[N],tcnt[N];
lint totl,sdis[N],tdis[N];

namespace utils{
	template <class T> inline void apn(T &x,const T y){x=x<y?x:y;}
	template <class T> inline void apx(T &x,const T y){x=x>y?x:y;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=c=='-'&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

namespace G{
	int cnt,fir[N];
	struct edge{
		int to,wi,nx;
	}eg[N<<2];
	struct data{
		int x;
		lint v;
		friend bool operator < (const data &a,const data &b){
			return a.v>b.v;
		}
	};

	inline void add(const int a,const int b,const int v){
		eg[++cnt]=(edge){b,v,fir[a]};
		fir[a]=cnt;
	}

	void dij(const int st,lint *dis,int *dcnt){
		static bool vis[N];
		std::priority_queue <data> pq;
		memset(dis+1,10,n*sizeof(dis[0]));
		memset(vis+1,0,n*sizeof(vis[0]));
		dis[st]=0,dcnt[st]=1;
		pq.push((data){st,0});
		while(!pq.empty()){
			const int x=pq.top().x;
			pq.pop();
			if(vis[x]) continue;
			vis[x]=1;
			for(int i=fir[x]; i; i=eg[i].nx){
				const int y=eg[i].to;
				const lint v=dis[x]+eg[i].wi;
				if(dis[y]>v){
					dcnt[y]=0;
					dis[y]=v;
					pq.push((data){y,v});
				}
				if(dis[y]==v){
					dcnt[y]=(dcnt[y]+dcnt[x])%mod;
				}
			}
		}
	}

	int calc(const int x){
		int res=0;
		for(int i=fir[x]; i; i=eg[i].nx){
			const int y=eg[i].to;
			const lint dx=sdis[x],dy=tdis[y];
			if(dx+eg[i].wi+dy==totl&&dx*2<totl&&dy*2<totl){
				int tmp=(lint)scnt[x]*tcnt[y]%mod;
				res=(res+(lint)tmp*tmp)%mod;
			}
		}
		return res;
	}
}

int main(){
	n=nxi(),m=nxi(),qs=nxi(),qt=nxi();
	for(int i=1; i<=m; ++i){
		const int a=nxi(),b=nxi(),v=nxi();
		G::add(a,b,v);
		G::add(b,a,v);
	}
	G::dij(qs,sdis,scnt);
	G::dij(qt,tdis,tcnt);
	assert(sdis[qt]==tdis[qs]);
	totl=sdis[qt];
	int ans=(lint)scnt[qt]*tcnt[qs]%mod;
	for(int i=1; i<=n; ++i){
		if(sdis[i]==tdis[i]&&sdis[i]+tdis[i]==totl){
			int tmp=(lint)scnt[i]*tcnt[i]%mod;
			ans=(ans-(lint)tmp*tmp)%mod;
		}
		ans=(ans-G::calc(i))%mod;
	}
	printf("%d\n",(ans+mod)%mod);
	return 0;
}

Measured memory_bytes: 11348
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>

using namespace std;

string s, S;
string op;

int main(void)
{
  cin >> s;
  S = s;

  while(1){
    string t; char c;
    if(s == "ABC"){
      break;
    }
    if(s.size() < 3){
      cout << "No" << endl;
      return 0;
    }
    bool head = (s.substr(0, 3) == "ABC");
    bool tail = (s.substr(s.size()-3) == "ABC");
    if(head && tail){
      cout << "No" << endl;
      return 0;
    }
    if(head) c = 'A';
    else if(tail) c = 'C';
    else c = 'B';
    op += c;

    for(int i = 0; i < s.size(); i++){
      if(s.substr(i, 3) == "ABC") t += c, i+=2;
      else t += s[i];
    }
    if(s == t){
      cout << "No" << endl;
      return 0;
    }
    s = t;
  }

  reverse(op.begin(), op.end());
  s = "ABC";
  for(int i = 0; i < op.size(); i++){
    string t;
    for(int j = 0; j < s.size(); j++){
      if(s[j] == op[i]) t += "ABC";
      else t += s[j];
    }
    s = t;
  }
  if(s == S)  cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}



Measured memory_bytes: 3240
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin>>s>>t;
    reverse(begin(t),end(t));
    if(s==t){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

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

using namespace std;

using ll = long long;
using ii = std::pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>; //vector<vector<int>>
using vs = vector<string>;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend() 
#define sz(x) (int)((x).size())
#define arrsz(x) (int) (sizeof((x))/sizeof((x)[0]))

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

/* Usage: output_vector(solution), which prints elements with spaces and then new line*/
template<typename T>
void output_vector(const vector<T> &v, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = int(v.size());
 
    for (int i = start; i < end; i++)
        cout << v[i] << " ";
    cout << endl;
}
// FILE I/O
void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
void setIO(string s = "") {
	unsyncIO();
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

int main() 
{
   int x, y;
   cin >> x >> y;
   if (((4 * x) - y) % 2 == 0)
   {
       int cranes = ((4 * x) - y) / 2;
       int turtles = x - cranes;
       if (cranes >= 0 && turtles >= 0)
            cout << "Yes" << endl;
       else
          cout << "No" << endl;
   }
   else
   {
       cout << "No" << endl;
   }
}
   

Measured memory_bytes: 3636
#include <stdio.h>
 
typedef struct shain{
    int bangou;
    double uriage;
}shain;
 
int main(void){
    int data_n,i,j,flag,hyouji;
    int bangou,tanka,suuryou;
    shain men[4001];
     
    while(1){
        scanf("%d",&data_n);
        if(data_n == 0) break;
        hyouji = 0;
        for(i=0;i < 4001;i++){
            men[i].bangou = 0;
            men[i].uriage = 0.0;
        }
        for(i=0;i < data_n;i++){
            scanf("%d %d %d",&bangou,&tanka,&suuryou);
            for(j=0;j <= i;j++){
                if(men[j].bangou == bangou){
                    flag = 1;
                    men[j].uriage += 1.0*tanka*suuryou;
                }
            }
            if(flag != 1){
                men[i].bangou = bangou;
                men[i].uriage = 1.0*tanka*suuryou;
            }
            flag = 0;
        }
        j = i;
        for(i=0;i < j;i++){
            if(men[i].uriage >= 1000000.0){
                printf("%d\n",men[i].bangou);
                hyouji++;
            }
        }
        if(hyouji == 0) printf("NA\n");
    }
    return 0;
}

Measured memory_bytes: 672
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
 
 
 
int main(){
  int n;
  cin >> n;
  int minc = 2000000000;
  REP2(i,1,n){
    int a = i;
    int b = n - a;
    int cnt_a = 0;
    int cnt_b = 0;
    for(int j = 5; j >= 0; --j){
      int x = 1;
      REP(k,j) x *= 10;
      cnt_a += a/x;
      a %= x;
      cnt_b += b/x;
      b %= x;
    }
 
    //cout << cnt_a<<" " << cnt_b << endl;
 
    minc = min(minc, cnt_a + cnt_b);
  }
 
  cout << minc << endl;
  return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	vector<int> c(n-1);
	for(int i=0; i<n; i++){
		int num;
		cin >> num;
		num--;
		a.at(i) = num;
	}
	for(int i=0; i<n; i++){
		cin >> b.at(i);
	}
	for(int i=0; i<n-1; i++){
		cin >> c.at(i);
	}
	int ans = b.at(a.at(0));
	for(int i=1; i<n; i++){
		ans += b.at(a.at(i));
		if(a.at(i)-a.at(i-1)==1){
			ans += c.at(a.at(i-1));
		}
	}

	cout << ans << endl;
}

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

int N;
int A[20];
int x[20][20];
int y[20][20];

int counter(int bits) {
    if (bits == 0) return 0;
    return counter(bits >> 1) + (bits & 1);
}
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can
// remove this line by using your custom template)
int main() {
    // Failed to predict input format
    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
        for (int j = 1; j <= A[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans = 0;
    for (int bits = 1; bits < (1 << N); bits++) {
        bool ok = true;
        for (int i = 1; i <= N; i++) {
            if (!(bits & (1 << (i - 1)))) continue;
            for (int j = 1; j <= A[i]; j++) {
                if (((bits >> (x[i][j] - 1)) & 1) ^ y[i][j]) ok = false;
            }
        }
        if (ok) ans = max(ans, counter(bits));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int x[100];
int y[100];
int h[100];
 
int main(){
    int n;cin>>n;
    int cx_a,cy_a,h_a;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i]>>h[i];
    }
    // cx,cyで全探索
    for(int cx=0;cx<101;cx++){
        for(int cy=0;cy<101;cy++){
            int H;
            for(int i=0;i<n;i++){
                // hが0の時は使わない
                if(h[i]==0) continue;
                // cx,cyのときのhを求める
                H=h[i]+abs(x[i]-cx)+abs(y[i]-cy);
                break;
            }
            for(int i=0;i<n;i++){
                // ありうる点なのか検証。だめだったら最初から
                if(h[i]!=max(H-abs(x[i]-cx)-abs(y[i]-cy),0)) break;
                // 最後まで探索したら
                if(i==n-1){
                    cx_a=cx;
                    cy_a=cy;
                    h_a=H;
                }
            }
        }
    }
    cout<<cx_a<<' '<<cy_a<<' '<<h_a<<endl;
}

Measured memory_bytes: 3576
#include <iostream>
using namespace std;
long long gcd(long long a, long long b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}
long long lcm(long long a,long long b){
	return a * (b / gcd(a, b));
}
int main() {
	int N; 
	cin >> N;
	long long ans = 1;
	for(int i = 0; i < N; i++) {
	    long long t; cin >> t;
	    ans = lcm(ans, t);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/*
 * FileName:     graph
 * CreatedDate:  2020-04-23 17:42:14 +0900
 * LastModified: 2020-04-23 17:48:56 +0900
 */

#include <stdio.h>
#include <string.h>
int main(void){
    int n;
    scanf("%d",&n);
    int matrix[n][n];
    memset(matrix,0,sizeof(matrix));
    for(int i=0;i<n;i++){
        int v,k;
        scanf("%d",&v);
        scanf("%d",&k);
        for(int j=0;j<k;j++){
            int v_k;
            scanf("%d",&v_k);
            matrix[v-1][v_k-1]=1;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(j==0){
                printf("%d",matrix[i][j]);
                continue;
            }
            printf(" %d",matrix[i][j]);
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2108
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class ABC043
    {
        static void Main(string[] args) {
            Console.ReadLine();
            var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long res = long.MaxValue;
            for(int y = -100; y <= 100; y++) {
                long cost = a.Sum(x => (x - y) * (x - y));
                res = Math.Min(cost, res);
            }
            Console.WriteLine(res);
        }
}
}

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

long long  INF=1000000000000000000;
using namespace std;


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


int ans=0;
map<char,int>v;
for(int i=1;i<n;i++){
    bool alpha[26]={};
    int total=0;
    
    for(int k=0;k<i;k++){
        if(v.find(s[k])==v.end()){
        v.insert(make_pair(s[k],k));
        }
    }

    for(int k=i;k<n;k++){
        if(v.find(s[k])!=v.end() && !alpha[s[k]-'a']){
            total++;
            alpha[s[k]-'a']=true;
        }
    }
    v.clear();
    ans=max(ans,total);
}

cout<<ans<<endl;

 return 0;
}

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

int main() { 
    long double a,b,c; 
    cin >> a >> b >> c;  
    long double r = a/c; 
    
    if(r<=b) cout<<"Yes" << endl ; 
    else
     cout << "No" << endl;
    return 0 ;
}

Measured memory_bytes: 3732
import math
import itertools
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

road = [0]*n
for i in range(n):
    road[i] = i

road_list = list(itertools.permutations(road))


def distance(a, b):
    x_a = xy[a][0]
    y_a = xy[a][1]
    x_b = xy[b][0]
    y_b = xy[b][1]
    dist = ((x_a - x_b)**2 + (y_a - y_b)**2)**0.5
    return dist


ans = 0

for i in range(len(road_list)):
    for j in range(len(road_list[i])-1):
        ans += distance(road_list[i][j+1], road_list[i][j])

ans = ans / math.factorial(n)
print(ans)


Measured memory_bytes: 45424
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class F
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		long N = GetLong();

		long cnt = 0;
		var list = divisors(N);
		foreach(var d in list)
		{
			if(d == 1)
				continue;

			long rest = N;
			while(rest % d == 0)
				rest /= d;

			if(rest % d == 1)
				cnt++;
		}
		WriteLine(cnt + divisors(N - 1).Count - 1);
	}

	private List<long> divisors(long N)
	{
		var res = new List<long>();
		for(long i = 1; i * i <= N; i++)
		{
			if(N % i == 0)
			{
				res.Add(i);
				if(i * i != N)
					res.Add(N / i);
			}
		}
		return res;
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 13268
def main():
    from collections import Counter as ct
    fact=[1]
    mod=10**9+7
    n=int(input())
    a=list(map(int,input().split()))
    for i in range(1,n+2):
        fact.append((fact[-1]*i)%mod)
    def inv_n(n,mod=10**9+7):return pow(n,mod-2,mod)
    def nCr(n,r,mod=10**9+7):return inv_n(fact[n-r]*fact[r]%mod,mod)*fact[n]%mod
    c=ct(a).most_common()[0][0]
    p,q=-1,-1
    for i in range(n+1):
        if a[i]==c:
            if p==-1:
                p=i
            else:
                q=i
    x=p+n-q
    for k in range(1,n+2):
        ans=0
        if k-2>=0:
            ans+=nCr(n-1,k-2)
        if k<=n-1:
            ans+=nCr(n-1,k)
        if k<=n:
            ans+=2*nCr(n-1,k-1)
        if k-1<=x:
            ans-=nCr(x,k-1)
        print((ans+mod)%mod)
main()

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

vector<int> G;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	string s;
	int cnt=1;
	long long K, ans=0;
	cin>>s>>K;
	for(int i=1;i<s.size();i++) {
		if(s[i]!=s[i-1]) {
			G.push_back(cnt);
			cnt=1;
		}
		else cnt++;
	}
	G.push_back(cnt);
	if(G.size()==1) ans=G[0]*K/2;
	else if(s[0]==s.back()) {
		ans=G[0]/2+G.back()/2;
		G[0]+=G.back();
		G.pop_back();
		ans+=G[0]/2*(K-1);
		for(int i=1;i<G.size();i++) if(G[i]>1) ans+=G[i]/2*K;
	}
	else {
		for(auto g: G) ans+=g/2*K;
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 256