akhauriyash/Code-Regression huggingface dataset:
#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];
  }
  
  int ans=0;
  
  while(1){
    int x=0;
    for(int i=0;i<N;i++){
      if (A[i]%2 ==1){
        x++;
      }
    }
    if(x==0){
      for(int i=0;i<N;i++){
        A[i] /= 2;
      }
      ans++;
    }
    else{
      break;
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

char rotate(char c, int N) {
    if (c + N > 'Z') {
        return c + N - 26;
    } else {
        return c + N;
    }
}

int main() {
    int N;
    string S;
    cin >> N >> S;
    for (int i = 0; i < S.size(); i++) {
        cout << rotate(S[i], N);
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 256
program prob1
    implicit none
    integer::a(10), b, c, d, e, i
    read(*,*) b, c, d, e
    a = 0
    a(b) = 1
    a(c) = 1
    a(d) = 1
    a(e) = 1
    if(a(1) == 1 .and. a(4) == 1 .and. a(7) == 1 .and. a(9) == 1) then
        write(*,'(a)') "YES"
    else
        write(*,'(a)') "NO"
    end if
    stop
end program

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

const int N = 1e5, K = 45;
int state[N + 5][K + 5];

int k;

int solve(int sisa, int sk) {
	if(sisa == 0) return 2;
	int &res = state[sisa][sk];
	if(res != 0) return res;
	res = 1;
	for(int i = 0;i <= min(9, sk);i++) {
		res = max(res, solve((sisa * 10 + i) % k, sk - i));
	}
	return res;
}

int main() {
	cin>>k;
	for(int i = 1;i <= K;i++) {
		for(int j = 1;j <= 9;j++) {
			if(i - j < 0) break;
			if(solve(j % k, i - j) == 2) {
				cout<<i<<endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 27520
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>


using namespace std;

int main(){
	vector<int> A;
	int a, b, c;
	cin >> a >> b >> c;
	
	A.push_back(a);
	A.push_back(b);
	A.push_back(c);

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

	int sum = A[0] + A[1];

	cout << sum << endl;
 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int main(void){
    // Your code here!
    // Your code here!
    int q;
    cin>>q;
    string x[q],y[q];
   
    //string s[q*2];
    string tmp;
    for(int i=0;i<q;i++){
        cin>>tmp;
        x[i]=tmp;
        cin>>tmp;
        y[i]=tmp;
    }
    for(int i=0;i<q;i++){
        //cout<<sizeof(x)/sizeof(x[0])<<" "<<sizeof(y[i])<<"\n";
        int dp[x[i].length()+1][y[i].length()+1];
        for(int j=0;j<x[i].length()+1;j++){ 
            for(int k=0;k<y[i].length()+1;k++){ 
                if(j==0 || k==0){
                    dp[j][k]=0;
                }
                else if(x[i][j-1]==y[i][k-1]){
                    dp[j][k]=dp[j-1][k-1]+1;
                }
                else{
                dp[j][k]=max(dp[j-1][k],dp[j][k-1]);
                }
            }
        }
        cout<<dp[x[i].length()][y[i].length()]<<"\n";
    }
}


Measured memory_bytes: 7128
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size)scanf("%d",&(name)[i])

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    vector<int> A(5);
    FOR(i,5)cin>>A[i];
    sort(ALL(A),[](const int &l,const int &r){return (l-1)%10>(r-1)%10;});
    int c=0;
    FOR(i,4){
        c+=(A[i]+9)/10*10;
    }
    c+=A[4];
    print(c);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll t;cin>>t;
  ll cnt=1;
  t--;
  ll speed=1;
  ll sum=0;
  while(true){
    sum+=speed*3;
    // cout<<sum<<endl;
    if(sum<=t){
      t-=speed*3;
      speed*=3;
      cnt++;
    }else break;
  }
  t+=speed;
  sum-=speed*3;
  cnt--;
  for(ll i=speed;i>0;i/=3){
    sum-=i;
    // cout<<i<<" "<<t<<" "<<sum<<endl;
    if(i==1){
      cnt+=t;
      t=0;
    }else if(i==3){
      cnt+=t/i;
      t=t%3;
    }else{
      if(t%i < sum){
	cnt+=t/i-1;
	t=i+t%i;
      }else{
	cnt+=t/i;
	t=t%i;
      }
    }
  }
  cout<<cnt<<endl;
  return 0;
}



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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)

int dx[4]={1, -1, 0, 0};
int dy[4]={0, 0, 1, -1};

int main(void) {
    string v = "aiueo";
    char c;
    cin >> c;
    REP (i, v.size()) {
        if (v[i] == c) {
            cout << "vowel" << endl;
            return 0;
        }
    }
    cout << "consonant" << endl;
    return 0;
}


Measured memory_bytes: 256
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define rep(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define min3(a,b,c)     min(a,min(b,c))



int main(){ FastIO;

	int r=0,a=0,w=0,t=0,n;
	cin>>n;
	while(n--){
		string s;cin>>s;
		if(s[0]=='A') a++;
		else if(s[0]=='W') w++;
		else if(s[0]=='T') t++;
		else r++;
	}
	cout<<"AC x "<<a<<endl<<"WA x "<<w<<endl<<"TLE x "<<t<<endl<<"RE x "<<r;	

}

Measured memory_bytes: 3620
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

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

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;

fn main() {
    let s = str2vec(&input_line_str());
    let mut ans = 0;
    for z in s {
        if z == '1' {
            ans += 1;
        }
    }
    p(ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<stdio.h>

using namespace std;

int main(){
    int k,s;
    int ans=0;
    cin >> k >> s;
    for(int x = 0;x<=k;x++){
        for(int y=0;y<=k;y++){
            int z = s - x- y;
            if(0 <= z and z <=k){
                ans++;
            }
        }
    }
    printf("%d",ans);

    return 0;

}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
N,Q=map(int,input().split())
s=input()
move=[input().split() for i in range(Q)]
inf=float('inf')
alive=[inf,-1*inf]
dead=[-1*inf,inf]
def check(i):
    now=i
    for m in move:
        if m[0]==s[now]:
            if m[1]=='L':
                now-=1
            elif m[1]=='R':
                now+=1
        if now<0:
            return 'left'
        if now>N-1:
            return 'right'
    return 'alive'
def search(now,alive,dead):
    if dead[0]+1==alive[0] and dead[1]-1==alive[1] or dead[0]+1==dead[1]:
        return alive,dead
    idx=now[0]*N//now[1]
    res=check(idx)
    if res=='alive':
        if alive[0]>alive[1]:
            alive=[idx,idx]
            alive,dead=search((2*now[0]-1,2*now[1]),alive,dead)
            alive,dead=search((2*now[0]+1,2*now[1]),alive,dead)
        elif idx<alive[0]:
            alive[0]=idx
            if alive[0]-1!=dead[0]:
                alive,dead=search((2*now[0]-1,2*now[1]),alive,dead)
        elif idx>alive[1]:
            alive[1]=idx
            if alive[1]+1!=dead[1]:
                alive,dead=search((2*now[0]+1,2*now[1]),alive,dead)
        elif idx==0 or idx==N-1:
            return alive,dead
    elif res=='left':
        if idx>dead[0]:
            dead[0]=idx
            if dead[0]+1!=alive[0]:
                alive,dead=search((2*now[0]+1,2*now[1]),alive,dead)
    elif res=='right':
        if idx<dead[1]:
            dead[1]=idx
            if dead[1]-1!=alive[1]:
                alive,dead=search((2*now[0]-1,2*now[1]),alive,dead)
    return alive,dead
alive,dead=search((1,2),alive,dead)
if alive[0]>alive[1]:
    print(0)
else:
    print(alive[1]-alive[0]+1)

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

using lint = long long int;


int main(){
    int Q;
    lint A,B;

    cin >> Q;
    for(int i=0;i<Q;i++){
        lint ans = 0;
        cin >> A >> B;
        lint AB = A*B;
        lint rootnumber = sqrt(AB);
        ans += (rootnumber-1)*2;

        if(rootnumber*(rootnumber+1)<AB){
            ans += 2;
            if(A<=rootnumber+1) ans--;
            if(B<=rootnumber+1) ans--;
        }
        else if(rootnumber*rootnumber<AB){
            ans++;
            if(A<=rootnumber) ans--;
            if(B<=rootnumber) ans--;
            if(A==rootnumber && B==rootnumber) ans++;
        }
        else{
            if(A<rootnumber) ans--;
            if(B<rootnumber) ans--;
        }
        cout << ans << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

int a, b, c;

int main() {
scanf("%d %d %d", &a, &b, &c);
if (a == b && b == c) printf("Yes\n"); else printf("No\n");
return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
string s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
     cin>>s;
    int si=s.size();
    int count=0, ans=0;
    for(int i=0;i<si;i++){
        if(s.substr(i,1)=="A"||s.substr(i,1)=="C"||s.substr(i,1)=="G"||s.substr(i,1)=="T"){
            count++;
            if(ans<count){
                ans=count;
            }
        }
        else{
            count=0;
        }
    }
    cout << ans << "\n";
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, c, k;
    cin >> n >> c >> k;
    vector<int> t(n);
    rep(i, n) cin >> t[i];
    int l = 0, ans = 1;
    sort(all(t));
    
    rep(i, n) {
        if ((t[i] > (t[l] + k)) || ((i - l + 1) > c)) {
            ans++;
            l = i;
        }
    }
    
    cout << ans << endl;
    return 0;
}

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

#define ll long long
using namespace std;
const int N = 2e3 + 5, mod = 998244353;
int x, y, a, b, c;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> x >> y >> a >> b >> c;
    int total = x + y;
    vector<pair<int, int> > v;
    for (int i = 1; i <= a; i++) {
        int w;
        cin >> w;
        v.push_back({w, 1});
    }
    for (int i = 1; i <= b; i++) {
        int w;
        cin >> w;
        v.push_back({w, 2});
    }
    for (int i = 1; i <= c; i++) {
        int w;
        cin >> w;
        v.push_back({w, 3});
    }
    sort(v.rbegin(), v.rend());
    int n = v.size();
    ll ans = 0;
    for (auto it : v) {
        if (!total) break;
        if (it.second == 1 && !x) continue;
        if (it.second == 2 && !y) continue;
        ans += it.first;
        if (it.second == 1) x--;
        if (it.second == 2) y--;
        total--;
    }
    cout << ans;
    return 0;
}

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

using namespace std;

int n, pos;
vector<int> pre, in, post;

void rec(int l, int r){
    if(l>= r) return;
    int root = pre[pos++];
    int m = distance(in.begin(), find(in.begin(), in.end(), root)); // inorderにおけるrootの位置
    rec(l,m);
    rec(m+1, r);
    post.push_back(root);
}

void solve(){
    pos = 0;
    rec(0, pre.size());

    for(int i=0; i<n; i++){
        if(i) cout << " ";
        cout << post[i];
    }
    cout << endl;
}

int main(int argc, char const *argv[])
{
    int k;
    cin >> n;
    for(int i=0; i<n;i++){
        cin >> k;
        pre.push_back(k);
    }
    for(int i=0; i<n; i++){
        cin >> k;
        in.push_back(k);
    }

    solve();
    return 0;
}



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

int main() 
{
	long long int n,i;
	cin >> n;
	long long int h[n];
	for(i=0;i<n;i++)
	cin >> h[i];
	long long int dp[n];
	for(i=0;i<n;i++)
	dp[i]=0;
	for(i=1;i<n;i++)
	{
		if(i==1)
		{
			dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
		}
		else
		{
			dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
		}
	}
	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
#define Dev 1000000007

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    string s;
    cin >> s;
    int minn = INT_MAX;
    for (int i= 0; i < s.size() - 2;i++){
        int num = (s[i] - '0') * 100+(s[i+1] - '0') * 10+(s[i+2] - '0') * 1;
        //cout << num << endl;
        minn = min(minn, abs(num - 753));
    }
    cout << minn << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

class program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split();
        long N = long.Parse(input[0]);
        long M = long.Parse(input[1]);
        long ans = 0;

        //Nを使う個数
        long s = Math.Min(N, M / 2);
        M -= 2 * s;

        //残り
        long v = M / 4;

        ans = s + v;

        Console.WriteLine(ans);
    }
}

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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++)
  {
    cin >> vec.at(i);
  }
  //降順ソート
  sort(vec.begin(), vec.end(), greater<int>());
  int AliceScore = 0;
  int BobScore = 0;
  
  for(int i = 0; i < vec.size(); i++)
  {
    //先頭からアリスとボブに交互に入れる
    if(0 == i % 2)
      AliceScore += vec.at(i);
    else
      BobScore += vec.at(i);
  }

  cout << AliceScore - BobScore << endl;
}

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

int main(){
  long long int N;
  long long int mod = 1e9+7;
  cin >> N;
  string s;
  cin >> s;
  if(s[0] == 'W'||s[2*N-1]=='W'){
    cout << 0 << endl;
  }
  else{
    long long int l=1,r=0;//
    long long int sum = 1;
    char a = 'L';
    for(int i = 1; i < 2*N; i++){
      //cout << a << endl;
      if((s[i-1]=='B'&&s[i]=='W')||(s[i-1]=='W'&&s[i]=='B')){
        if(a=='R'){
          r++;
          sum *= l;
          sum = sum%mod;
          l--;
          a = 'R';
        }
        else{
          l++;
          a = 'L';
        }
      }
      else{
        if(a=='R'){
          l++;
          a = 'L';
        }
        else{
          r++;
          sum*=l;
          sum = sum%mod;
          l--;
          a = 'R';
        }
      }
      
    }
    //cout << a << endl;
    //cout << l << r << endl;
    if(l!=0 || r!=N){
      cout << 0 << endl;
    }
    else{
      long long int num = 1;
      for(int i = 1; i <= N; i++){
        num *= i;
        num = num%mod;
      }
      sum *= num;
      sum = sum%mod;
      cout << sum << endl;
    }
  }
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    FOR(i, 1, b) cout << a;
    return 0;
}


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

int main() {
    int a;
    int b;
    cin >> a >> b;
    cout << a/b << ' ' << a%b << ' ' ;
    cout << fixed << setprecision(5);
    cout << (double)a/b;
    return 0;
}


Measured memory_bytes: 3276
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
using namespace std;


int main() {
	int n, k;
	long long sum = 0;
	cin >> n >> k;
	vector<long long> a(n);
	for(int i = 0; i < n; ++i){ 
		cin >> a[i];
		sum += a[i];
	}
	sort(a.begin(), a.end());
	for(int i = n - 1; i > max(-1, n - 1 - k); --i) sum -= a[i];
	cout << sum;
}

Measured memory_bytes: 1792
import io


def gcd(a, b):
    while b > 0 :
        a, b = b, a%b

    return a


K = int(input())
ans = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans += gcd(c, gcd(a, b))

print(ans)

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

using namespace std;

int n;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  vector<long long> a(n);
  const int b = 200;
  for(int i = 0; i < n; i++) {
    double p;
    cin >> p;
    a[i] = p * 1000000000 + 0.5;
  }
  vector<vector<int>> cnt(b, vector<int>(b));
  long long res = 0;
  for(int i = 0; i < n; i++) {
    int two = 0, five = 0;
    while(a[i] % 2 == 0) {
      two++;
      a[i] /= 2;
    }
    while(a[i] % 5 == 0) {
      five++;
      a[i] /= 5;
    }
    res += cnt[18 + b / 2 - two][18 + b / 2 - five];
    for(int u = -30; u <= two; u++) {
      for(int v = -30; v <= five; v++) {
        cnt[b / 2 + u][b / 2 + v]++;
      }
    }
  }
  cout << res;
  return 0;
}


Measured memory_bytes: 5140
import sys

lines = sys.stdin.read().splitlines()
cards = [int(v) for v in lines[1].split(" ")]
cards.sort(reverse=True)
alice = 0
bob = 0
l = len(cards)
for i in range(0, l, 2):
  alice += cards[i]
  if i + 1 < l:
    bob += cards[i+1]
print(alice - bob)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
using namespace std;
int main() {

  int a[3];

  while(1) {
  cin >> a[0] >> a[1] >> a[2];
  if(a[0] + a[1] + a[2] == 0) break;

  sort(a,a+3);
  int n;
  cin >> n;

  int s = a[0]*a[0] + a[1]*a[1];
  for(int i=0;i<n;i++) {
    int r;
    int c;
    cin >> r;
    c = 4*r*r;
    //cout << s <<" " << c<<endl;

    if(s < c) cout <<"OK"<<endl;
    else cout << "NA"<<endl;
  }
  }

  return 0;
    
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
using namespace std;
int a,b;//定义两个数
int main()
{
    //freopen("***.in","r",stdin);
    //freopen("***.out","w",stdout);
    cin>>a>>b;//这里输入a和b
    if(a+b==15)//判断输出“+”的情况
        cout<<"+"<<endl;
    else if(a*b==15)//如果不是输出“+”，则判断输出“*”的情况
            cout<<"*"<<endl;
        else//两种情况都不是的话，则输出“x”
            cout<<"x"<<endl;

    return 0;//最后别忘了华丽的结束\(^o^)/
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}

int main(){
  ll s, e, a, b;
  cin >> s >> e >> a >> b;

  //string ans = "Yes";
  //string ans = "No";
  //string ans = "YES";
  //string ans = "NO";
  ll ans = 0;
  ll g = lcg(a, b);
  ans = (e - (e / a + e / b - e / g)) - ((s - 1) - ((s - 1) / a + (s - 1) / b - (s - 1) / g));

  cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

int main(int argc,char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;cin>>n;
    ll sum = 0;
    rep(i,n)
    {
        ll x;cin>>x;
        sum+=x-1;
    }

    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define popb  pop_back
#define mem(a,b) memset(a,b,sizeof(a))
#define sz size()
#define mp make_pair
#define bs binary_search
using namespace std;
ll m=1000000000+7;

int main()
{
   IOS;
   int t=1;
   //cin>>t;
   while(t--)
   {
      ll n,cnt=0,i,j,p,l,ans=0,d,k=0,mn,id=0;
      cin>>n;
      cnt=0;
      vector<ll>v1(20,0);
      for(i=1;i<20;i++)
      {
        p=1000*i;
        v1.push_back(p);
      }
      auto it=lower_bound(v1.begin(),v1.end(),n);
      ans= (*it)-n;
      cout<<ans<<"\n";

   }

   return 0;
}


Measured memory_bytes: 3660
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

ll D[52][2]; int N, A[52];

void solve(){
	int p;
	scanf("%d%d", &N, &p);
	for(int i=1;i<=N;i++) {
		int x; scanf("%d", &x);
		A[i] = x & 1;
	}
	D[0][0] = 1;
	for(int i=1;i<=N;i++) {
		rep(j, 2) D[i][j] = D[i-1][j];
		rep(j, 2) D[i][j] += D[i-1][(j+A[i])&1];
	}
	printf("%lld\n", D[N][p]);
}

int main(){
	int Tc = 1; // scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		// printf("Case #%d: ", tc);
		solve();
	}
	return 0;
};


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

int main() {
  string s;
  cin >> s;
  if (s[s.length()-1] != 's') {
    cout << s + 's' << endl;
  }
  else {
    cout << s + "es" << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
N, K = map(int, input().split())
X = [int(x) for x in input().split()]
ans = 10 ** 9
for i in range(N - K + 1):
  ans = min(X[i + K - 1] - X[i] + min(abs(X[i]), abs(X[i + K - 1])), ans)
print(ans)

Measured memory_bytes: 14224
cnt = int(input())
concurrency_list = []

for _ in range(cnt):
    concurrency_list.append(int(input()))

minv = concurrency_list[0]
maxv = -100000000000
# 1 から (n-1)
for j in range(1, len(concurrency_list)):
    maxv = max(maxv, concurrency_list[j] - minv)
    
    # jをインクリメントしていくなかで最小値を探していく。
    minv = min(minv, concurrency_list[j])
    
    
print(maxv)


Measured memory_bytes: 13596
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <unordered_set>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<long long int> locx(n, 0), locy(n, 0);
  vector<long long int> cx(m, 0), cy(m, 0);
  for (int i = 0; i < n; i++) { cin >> locx[i] >> locy[i]; }
  for (int j = 0; j < m; j++) { cin >> cx[j] >> cy[j]; }
  for (int i = 0; i < n; i++) {
    int min_dist = abs(locx[i] - cx[0]) + abs(locy[i] - cy[0]);
    int ans = 1;
    for (int j = 1; j < m; j++) {
      int dist = abs(locx[i] - cx[j]) + abs(locy[i] - cy[j]);
      if (dist < min_dist) {
        min_dist = dist;
        ans = j + 1;
      }
    }
    cout << ans << endl;
  }
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef pair<ll, ll> p;

struct dish {
  ll a;
  ll b;
  ll sum;
  ll index;
};

void printstr(vector<dish> v)
{
  for(auto A : v){
    cout << A.a << endl;
    cout << A.b << endl;
    cout << A.sum << endl;
    cout << A.index << endl;
    cout << "=====" << endl;
  }
}

// 照準
bool cmp(const dish &a, const dish &b)
{
    return a.sum < b.sum;
}

int main(){
  ll n;
  cin >> n;
  vector<dish> v(n);
  map<ll, bool> ate;
  for (ll i = 0; i < n; i++) {
    ll tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    v[i].a = tmp1;
    v[i].b = tmp2;
    v[i].sum = tmp1 + tmp2;
    v[i].index = i;
    ate[i] = false;
  }
  sort(rall(v), cmp);
  ll sumA = 0, sumB = 0;
  // printstr(v);

  for (ll i = 0; i < n; i++) {
    if(i % 2 == 0){
      sumA += v[i].a;
    }else{
      sumB += v[i].b;
    }
    ate[i] = true;
  }

  cout << sumA - sumB << endl;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int n, k; cin >> n >> k;
  int res = n % k;
  if (res == 0) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
}

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

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

int main(){
    int n,w[110];
    cin>>n;
    rep(i,n) cin>>w[i];
    int sum=0,sum1=0,m=1000000;
    rep(i,n) sum+=w[i];
    rep(i,n){
        sum1+=w[i];
        m=min(abs(2*sum1-sum),m);
    }
    cout<<m<<endl;
}

Measured memory_bytes: 256
import bisect

# 入力
def read_data():
   N_ = int(input())
   L_ = list(map(int, input().split()))
   return N_, L_

# 探索
def Search(N, L):
   ans = 0
   L.sort()
   # a, b は固定する
   for a_index in range(N):
       for b_index in range(a_index + 1, N):
           sum_of_a_and_b = L[a_index] + L[b_index]
           # c の可動範囲の右端を求める
           c_right_index = bisect.bisect_left(L, sum_of_a_and_b)
           # c の可動範囲は[b_index + 1, c_right_index)
           ans += max(0, c_right_index - b_index - 1)
   print(ans)

N, L = read_data()
Search(N, L)

Measured memory_bytes: 42716
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric> 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<PP> vec;
	int p[m + 1];
    ll y[m + 1];
	for(int i = 0; i < m; i++)
	{
		cin >> p[i] >> y[i];
        vec.push_back(PP(p[i], P(y[i], i)));
	}
    sort(vec.begin(), vec.end());
    int ans[n + 1], cnt = 1;
    for(int i = 0; i < m; i++)
    {
        if(i > 0)
        {
            if(vec[i].first != vec[i - 1].first) cnt = 1;
            else cnt++;
        }
        ans[vec[i].second.second] = cnt;
    }
	for(int i = 0; i < m; i++)
	{
		printf("%06d%06d\n", p[i], ans[i]);
	}
	return 0;
}



Measured memory_bytes: 6256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
ll N;

int main(){

    ll N;
    cin >> N;

    vector<ll > A(N, 0);

    for(ll i = 0; i < N; i++){
        cin >> A[i];
    }

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

    if(N == 2){
        cout << A[1]-A[0] << endl;
        return 0;
    }else{
        ll t1 = 0;
        ll t2 = 0;
        if(N % 2 == 0){
            for(ll i = 0; i < N / 2; i++){
                t1 += A[i];
            }
            for(ll i = N / 2; i < N; i++){
                t2 += A[i];
            }
            //cout << t1 << " " << t2 << endl;
            t1 *= 2;
            t2 *= 2;
            //ll ans = max(, t2 - t1 + A[N/2-1]);
            cout << (t2 - A[N/2]) - (t1 - A[N/2-1])  << endl;

        }else{
            //どっちで分割すると良さそうか
            for(ll i = 0; i <= N / 2; i++){
                t1 += A[i];
            }
            for(ll i = N / 2 + 1; i < N; i++){
                t2 += A[i];
            }
            //cout << t1 << " " << t2 << endl;
            t1 *= 2;
            t2 *= 2;

            ll ans = t2 - (t1 - A[N/2] - A[N/2-1]);

            t1 = 0;
            t2 = 0;

            for(ll i = 0; i < N / 2; i++){
                t1 += A[i];
            }
            for(ll i = N / 2; i < N; i++){
                t2 += A[i];
            }

            t1 *= 2;
            t2 *= 2;

            ans = max(ans, (t2 - A[N/2] - A[N/2+1]) - t1);

            cout << ans << endl;

            //cout << t2 - (t1 - A[N/2] - A[N/2-1])  << endl;
        }
    }

}


Measured memory_bytes: 1024
#include<stdio.h>
#include<cstdio>
using namespace std;

int main() {
  int res = 0;
  for (int i = 0 ; i < 4 ; i++) {
    char c;
    scanf("%c", &c);
    if (c == '+') res++;
    else res--;
  }
  printf("%d\n", res);
}

Measured memory_bytes: 128
# coding: utf-8
from fractions import gcd
from functools import reduce
from math import ceil, floor

def lcm(a, b):
    return a*b // gcd(a, b)

def lcm_list(nums):
    return reduce(lcm, nums)

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

# X = lcm_list(A)
X = A[0]
for i in range(1, N):
    X = lcm(X, A[i])
T = X
cnt = 0
while X % 2 == 0:
    cnt += 1
    X //= 2
# print()
for i in range(N):
    if A[i] % 2**cnt != 0:
        print(0)
        exit()
t_ans = T // 2
if (M // t_ans) % 2 == 0:
    print((M//t_ans) // 2)
else:
    print(((M//t_ans) + 1) // 2)

Measured memory_bytes: 16308
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long

using namespace std;

int solve(vector<vector<int>> &g, vector<vector<int>> &dist, int begin) {
    int n = g.size();
    vector<int> ans(n);
    int otv = 0;
    for (int i = 0; i < n; ++i) {
        ans[i] = dist[i][begin];
        otv = max(otv, ans[i]);
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (g[i][j] == 1) {
                if (abs(ans[i] - ans[j]) != 1) {
                    return -1;
                }
            }
        }
    }
    return otv + 1;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<vector<int>> g(n, vector<int>(n, 0));
    vector<vector<int>> d(n, vector<int>(n, 1e9));
    for (int i = 0; i < n; ++i) {
        d[i][i] = 0;
        string s;
        cin >> s;
        for (int j = 0; j < s.size(); ++j) {
            if (s[j] == '1') {
                g[i][j] = 1;
                d[i][j] = 1;
            }
        }
    }
    for (int k = 0; k < n; ++k)
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < n; ++j)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    int ans = -1;
    for (int i = 0; i < n; ++i) {
        ans = max(ans, solve(g, d, i));
    }
    cout << ans;
}

Measured memory_bytes: 640
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    _ _ 

    dp[i][j][one_of_previous_number_is_lower] = count of remainder j up to i-th digit, 0 <= j < D

    dp[i][(j+digit)%D][True] += dp[i-1][j][True] + dp[i-1][j][False] digit < K[i]
    dp[i][(j+digit)%D][False] += dp[i-1][j][False]        digit == K[i]
    """
    K = list(map(int, input().strip()))
    D = read_int()
    dp = [[[0, 0] for _ in range(D)]
           for _ in range(len(K)+1)]
    dp[0][0][0] = 1
    modulo = 10**9+7
    for i in range(len(K)):
        for j in range(D):
            for digit in range(10):
                dp[i+1][(j+digit)%D][True] += dp[i][j][True]
                if digit < K[i]:
                    dp[i+1][(j+digit)%D][True] += dp[i][j][False]
                if digit == K[i]:
                    dp[i+1][(j+digit)%D][False] += dp[i][j][False]
                dp[i+1][(j+digit)%D][False] %= modulo
                dp[i+1][(j+digit)%D][True] %= modulo
    return (dp[-1][0][0]+dp[-1][0][1]-1)%modulo


if __name__ == '__main__':
    print(solve())


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


int main () {
    int n, l;
    std::cin >> n >> l;

    std::vector<int> ts(n);
    std::vector<int> tsa(n);

    for (int i = 0; i < n; i++) {
        ts[i] = i + l;
        tsa[i] = std::abs(i + l);
    }

    int mina = *std::min_element(tsa.begin(), tsa.end());

    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if(mina != tsa[i]) {
            ans += ts[i];
        }
    }

        std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <cstdio>
typedef long long ll;

const int N=1010,p=1e9+7;
char s[N][N];
int n,m,d,c,S,col,row;
ll k;

inline int qm(int x){return x<0?x+p:x;}

template <typename _tp> inline int qpow(int A,_tp B){
	int res(1);while(B){
		if(B&1)res=1ll*res*A%p;
		A=1ll*A*A%p,B>>=1;
	}return res;
}

int main(){
	scanf("%d%d%lld",&n,&m,&k);
	for(int i=1;i<=n;++i){
		scanf("%s",s[i]+1);
		for(int j=1;j<=m;++j)
			if(s[i][j]=='#')++S;
	}
	for(int i=1;i<=n;++i)if(s[i][1]=='#'&&'#'==s[i][m])++row;
	for(int i=1;i<=m;++i)if(s[1][i]=='#'&&'#'==s[n][i])++col;
	if(!row&&!col){printf("%d\n",qpow(S,k-1));return 0;}
	if(!k||(row&&col)){puts("1");return 0;}
	if(row)
		for(int i=1;i<=n;++i)
		for(int j=1;j<m;++j)
			d+=(s[i][j]=='#'&&s[i][j+1]=='#');
	else 
		for(int i=1;i<n;++i)
		for(int j=1;j<=m;++j)
			d+=(s[i][j]=='#'&&s[i+1][j]=='#');
	
	c=row?row:col;
	
	int ans=qm(qpow(S,k-1)-qpow(c,k-1));
	
	ans=1ll*ans*d%p;
	
	ans=1ll*ans*qpow(qm(S-c),p-2)%p;
	
	printf("%d\n",qm(qpow(S,k-1)-ans));
	return 0;
}

Measured memory_bytes: 1152
using System;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());

            var maxV = int.MinValue;
            for(var i = 1; i * i <= n; i++){
                maxV = Math.Max(maxV, i * i);
            }
            Console.WriteLine(maxV);
        }
    }
}


Measured memory_bytes: 11220
#include <cstdio>

int prime_table[101][101];
int factorial_prime[101];

void init_prime_table()
{
  for (int target = 2; target <= 100; target++) {
    int val = target;
    for (int i = 2; i <= target; i++) {
      while (val % i == 0) {
        prime_table[target][i]++;
        val = val / i;
      }
    }
  }
}

void print_prime_table()
{
  for (int i = 0; i <= 100; i++) {
    for (int prime = 0; prime <= 100; prime++) {
      printf("%d ", prime_table[i][prime]);
    }
    putchar('\n');
  }
}

void print_factorial_prime()
{
  for (int i = 0; i <= 100; i++) {
    printf("%d ", factorial_prime[i]);
  }
  putchar('\n');
}

int main()
{
  int n;
  scanf("%d", &n);
  init_prime_table();
  //print_prime_table();
  for (int prime = 0; prime <= n; prime++) {
    for (int i = 0; i <= n; i++) {
      factorial_prime[prime] += prime_table[i][prime];
    }
  }
  //print_factorial_prime();

  int cnt = 0;
  for (int x = 2; x <= n; x++) {
    if (75 <= factorial_prime[x]+1) {
      cnt++;
    }
  }
  for (int x = 2; x <= n; x++) {
    for (int y = 2; y <= n; y++) {
      if (x == y) {
        continue;
      }
      if (25 <= factorial_prime[x]+1 && 3 <= factorial_prime[y]+1) {
        cnt++;
      }
    }
  }
  for (int x = 2; x <= n; x++) {
    for (int y = 2; y <= n; y++) {
      if (x == y) {
        continue;
      }
      if (15 <= factorial_prime[x]+1 && 5 <= factorial_prime[y]+1) {
        cnt++;
      }
    }
  }
  for (int x = 2; x <= n; x++) {
    for (int y = x+1; y <= n; y++) { // prevent swap case
      for (int z = 2; z <= n; z++) {
        if (x == y || y == z || z == x) {
          continue;
        }
        if (5 <= factorial_prime[x]+1 && 5 <= factorial_prime[y]+1 && 3 <= factorial_prime[z]+1) {
          cnt++;
        }
      }
    }
  }
  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+5;
//int a[N];

int main()

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

    string s;

    cin >> s;

    int n = s.size();

    cout << s[0] << n-2 << s[n-1];

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
#include <cstdlib>
#define INT_MAX 2147483647
#define INT_MIN -2147483646
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;

vector<ll> A(100);

int main() {
	int n;
	cin >> n;
	if (n == 0) cout << 1 << endl;
	else if (n == 1) cout << 1 << endl;
	else {
		A[0] = 1;
		A[1] = 1;
		for (int i = 2;i <= n;i++) {
			A[i] = A[i - 1] + A[i - 2];
		}
		cout << A[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
#include <stdio.h>
#include <iostream>

int main(){
    char ch;
    while(1){
        if(ch == '\n'){
            break;
        }
        else{
            scanf("%c", &ch);
            if('a'<=ch && ch<='z'){
                printf("%c", ch-32);
            }
            else if('A'<=ch && ch<='Z'){
                printf("%c", ch+32);
            }
            else{
                printf("%c",ch);
            }
        }
    }
return 0;
}




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

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

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    for (int i = 0; i < n; ++i){
        if(i == k - 1) {
            char c = s[i] + 0x20;
            cout << c;
        }
        else cout << s[i];
    }
    cout << endl;

}

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

typedef long long ll;
const int maxn = 100000 + 5;
int N;
ll A[maxn];
ll B[maxn];

ll solve()
{
	ll cnt = 0;
	for(int i = 0; i < N; i++)
	{
		if(B[i] >= A[i]) 
		{ 
			cnt += A[i];
			B[i] -= A[i];
		}
		else
		{
			cnt += B[i];
			B[i] = 0;
		}

		int p = i + 1;
		if(B[i] > 0)
		{
			if(B[i] >= A[p])
			{
				cnt += A[p];
				A[p] = 0;
			}
			else 
			{
				cnt += B[i];
				A[p] -= B[i];
				B[i] = 0;
			}
		}
	}
	return cnt;
}

int main()
{
	cin >> N;
	for(int i = 0; i < N+1; i++) cin >> A[i];
	for(int i = 0; i < N; i++) cin >> B[i];
	printf("%lld\n", solve());
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////
int main(){
    string sa,sb,sc;
    getline(cin,sa);
    getline(cin,sb);
    getline(cin,sc);
    
    int a,b,c;
    a = 0; b = 0; c = 0;
    char turn = 'a';
    while(true){
        
        if (turn == 'a'){
            if (a == sa.length()){
                printf("A\n");
                return 0;
            }
            
            turn = sa[a];
            a++;
            continue;
        }
        
        if (turn == 'b'){
            if (b == sb.length()){
                printf("B\n");
                return 0;
            }
            
            turn = sb[b];
            b++;
            continue;
        }
        
         if (turn == 'c'){
            if (c == sc.length()){
                printf("C\n");
                return 0;
            }
            
            turn = sc[c];
            c++;
            continue;
        }
        
        
    }
        
    
   	return 0;
}

Measured memory_bytes: 256
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
typedef pair<Q,ll> R;
ll longinf=1ll<<60;
int inf=1<<29;
//mleしなければぜんぶllでかく。

int main(){
	int n,q;
	cin>>n>>q;
	string s;
	cin>>s;
	s='.'+s;
	int a[n+1];
	fill(a,a+n,0);
	for(int i=1;i<=n-1;i++){
		if(s[i]=='A'&&s[i+1]=='C'){
			a[i+1]=a[i]+1;
		}
		else{
			a[i+1]=a[i];
		}
	}
	while(q--){
		int l,r;
		cin>>l>>r;
		cout<<a[r]-a[l]<<endl;
	}

	return 0;
}

Measured memory_bytes: 1404
#include <iostream>
#include <vector>

using namespace std;

const int MAX_N = 1e5 + 5;
typedef long long ll;

ll ans;
int n;
vector<pair<int, ll>> adj [MAX_N];
int sz [MAX_N];

vector<int> centrs;
void build (int u, int p, ll pw) {
  sz[u] = 1;

  int bigc = 0;
  for (auto nxt : adj[u]) {
    if (nxt.first != p) {
      build(nxt.first, u, nxt.second);

      sz[u] += sz[nxt.first];
      bigc = max(bigc, sz[nxt.first]);
    }
  }

  ans += pw * (ll) min(sz[u], n - sz[u]);
  if (max(bigc, n - sz[u]) <= n / 2) {
    centrs.push_back(u);
  }
}

int main () {
  cin >> n;

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

    adj[u].push_back(make_pair(v, w));
    adj[v].push_back(make_pair(u, w));
  }

  build(1, 0, 0);

  ans *= 2;
  if (centrs.size() == 1) {
    int u = centrs[0];
    ll mne = 1e9;
    for (auto nxt : adj[u]) {
      mne = min(mne, nxt.second);
    }
    ans -= mne;
  } else {
    int u = centrs[0];
    int v = centrs[1];
    for (auto nxt : adj[u]) {
      if (nxt.first == v) {
        ans -= nxt.second;
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 14976
import numpy as np
N, D = map(int, input().split())
P = []
for i in range(N):
  P.append(np.array(list(map(int, input().split()))))
c = 0
for i in range(N):
  for j in range(N-i-1):
    if (np.linalg.norm(P[i] - P[i+j+1])).is_integer():
      c += 1
print(c)

Measured memory_bytes: 12472