akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct {
    /* data */
    char c[15];
    int len;
}haiku;




int main(){
    haiku h[45];
    int n;
    int t[5] = {5,7,5,7,7};
    int i,j,k;
    int sum,ans;
    int flag = 0;

    while(1){
        
        flag = 0;
        scanf("%d",&n);
        if(n== 0){
            break;
        }
        for(i = 1; i <= n; i++){
            scanf("%s",h[i].c);
            h[i].len = strlen(h[i].c);
        }
        /*
        for(i = 1; i <= n; i++){
            printf("%d\n",strlen(h[i].c));
        }*/
        sum = 0;
        k = 0;
        ans = 0;
        for(i = 1; i < n ;i++){
            sum = h[i].len;
            j = i+1;
            ans = i;
            k = 0;
            while(k < 5){
                if(sum == t[k]){
                    sum = 0;
                    k++;
                }
                sum += h[j].len;
                if(sum > t[k]){
                    break;
                }
                if(k == 4 && sum == t[k]){
                    flag = 1;
                    break;
                }
                if(sum == t[k]){
                    sum = 0;
                    k++;
                }
                j++;
            }
            if(flag == 1){
                break;
            }

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


        }
        return 0;
}


Measured memory_bytes: 2044
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    float b = sc.nextFloat();

    int b2 = Math.round(b * 100);

    long total = a * b2 / 100;

    String result = BigDecimal.valueOf(total).toPlainString();

    System.out.println(result);

  }
}


Measured memory_bytes: 37544
#include<iostream>
#include<string>
using namespace std;
string str;
int n,A=0,B=0,O=0,AB=0;

int main(){
	while(cin>>str){
		n=str.size();
		if(n==1)break;
		if(str[n-2]==','){
			if(str[n-1]=='A')A++;
			else if(str[n-1]=='B')B++;
			else O++;
		}else{
			AB++;
		}
	}
	cout<<A<<endl<<B<<endl<<AB<<endl<<O<<endl;
	return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}
Int tmpi = 0;
double tmpd = 0.0;


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

    Int h, w, a, b;
    cin >> h >> w >> a >> b;

    for(Int i=0; i<h; i++){
        for(Int j=0; j<w; j++){
            if(i<b){
                if(j<a){
                    cout << "0";
                }else{
                    cout << "1";
                }
            }else{
                if(j<a){
                    cout << "1";
                }else{
                    cout << "0";
                }
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1280
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)1e5
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	ll n,k,i,s=0;cin>>n>>k;
	for(i=k;i<=n+1;i++){
		ll l=(i*(i-1))/2;
		ll r=(n*(n+1)-(n-i)*(n-i+1))/2;
//		cout<<i<<" "<<l<<" "<<r<<endl;
		s=(s+r-l+1+mod)%mod;
	}cout<<s<<endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N, C, K;
        cin >> N >> C >> K;
        vll T(N);
        rep(i, 0, N) cin >> T[i];
        sort(all(T));

        ll cnt = 0;
        ll right = T[0] + K;
        ll ans = 1;
        rep(i, 0, N) {
                if (cnt >= C or T[i] > right) {
                        ++ans;
                        cnt = 0;
                        right = T[i] + K;
                }
                ++cnt;
        }

        cout << ans << endl;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
long long a,b,r,x,t;
int main(){
    cin>>a>>b;
    x=a*b;
    if(a<b){
        t=a;
        a=b;
        b=t;
    }
    r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    cout<<x/b<<endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

 
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    n, y = MI()
    y = y // 1000
    result = "-1 -1 -1"
    for i in range(n, -1, -1):
        a = i * 10
        if a <= y:
            for j in range(n-i, -1, -1):
                b = a + j * 5
                if b <= y:
                    if b + (n-i-j) == y:
                        result = str(i)+" "+str(j)+" "+str((n-i-j))
                        print(result)
                        sys.exit()
    print(result)

main()

Measured memory_bytes: 39888
import java.util.Scanner;

public class Main {
	static int[] num;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		num = new int[n];
		for(int i = 0; i < n; i++) {
			num[i] = sc.nextInt();
		}
		int count = 0;
		while(isGusu(num)) {
			count++;
			for(int j = 0; j < num.length; j++) {
				num[j] = num[j] / 2;
			}
		}
		System.out.println(count);
	}
	static boolean isGusu(int[] num) {
		for(int i = 0; i < num.length; i++) {
			if(num[i] % 2 == 1) {
				return false;
			}
		}
		return true;
	}
}

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

import math
def is_prime(n):
	if n == 1:
		return False
	
	for k in range(2, int(math.sqrt(n)) + 1):
		if n%k == 0:
			return False
	return True
s = []
for i in range(1,10**6):
	if is_prime(i):
		if i%5 == 1:
			s.append(i)
	if len(s) == n:
		break
print (*s)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 3e3 + 5;
const ll LINF = 1e18 + 5;
int n;
char s[N];
constexpr int mod = 1e9 + 7;
ll dp[N][N], sum[N];
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n >> (s+1);
 	dp[1][1] = 1;
 	sum[1] = 1;
 	for(int i=2; i<=n; i++)
 	{
 		for(int j=1; j<=i; j++)
 		{
 			if(s[i-1]=='>') dp[i][j] = (sum[i-1]-sum[j-1]+mod)%mod;
 			else dp[i][j] = sum[j-1]%mod;
 		}
 		for(int j=1; j<=i; j++) sum[j] = (sum[j-1] + dp[i][j])%mod;
 	}
 	ll ans = sum[n];
 	ans = (ans + mod)%mod;
 	cout << ans;
	return 0;
}


Measured memory_bytes: 69120
d = int(input())
c = list(map(int, input().split()))
s = [[] for _ in range(d)]
for i in range(d):
  s[i] = list(map(int, input().split()))
  
last = [0 for _ in range(26)]

def loss(today):
  sum = 0
  for i in range(26):
    sum += c[i-1] * (today - last[i-1])
  return sum
  
  
v = 0
for today in range(1, d+1):
  t = int(input())
  last[t-1] = today
  v += s[today-1][t-1]
  v -= loss(today)
  print(v)

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

int main(){
	int A, B;
  	string op;
  	cin >> A >> op >> B;
  
  	if(op == "+"){
    	cout << A + B << endl;
    }
  
  	else{
    	cout << A - B << endl;
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
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; }
const int INF = 1e9;
const ll MOD = 1000000007;
const double pi = 3.141592653589;
using Graph = vector<vector<int>>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s,t;cin>>s>>t;
    if (t.size()==s.size()+1) {
        rep(i,s.size()) {
            if (s[i]!=t[i]) {
                ct("No");
                return 0;
            }
        }
        ct("Yes");
    } else {
        ct("No");
        return 0;
    }
}

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

using namespace std;

int n,ans;
int num[200010],num1[200010];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	    scanf("%d",&num[i]);
	num1[1]=num[1];
	for(int i=2;i<=n;i++)
	    num1[i]=min(num[i],num1[i-1]);
	for(int i=1;i<=n;i++)
	    if(num1[i]==num[i])
	        ans++;
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 1792
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	int N;

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		N = nextInt();
		String S = next();
		if(N % 2 == 1) {
			out.println("No");
			return;
		}
		if(S.substring(0,N/2).equals(S.substring(N/2,N))){
			out.println("Yes");
		}else {
			out.println("No");
		}
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}
}

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

int main() {
  int n; cin >> n;
  vector<int> a(n+1), b(n);
  rep(i, n+1) cin >> a[i];
  rep(i, n) cin >> b[i];
  ll ans = 0;
  rep(i, n) {
    if (a[i] >= b[i]) {
      ans += b[i];
    }
    else {
      ans += a[i] + min(a[i+1], (b[i]-a[i]));
      a[i+1] = max(a[i+1] - (b[i] - a[i]), 0);
    }
  }
  cout << ans << endl;
}

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

int main() {
  vector<int> abc(3);
  for(int i=0;i<3;i++){
    cin>>abc.at(i);
  }
  sort(abc.begin(),abc.end());
  int a=abc.at(0), b=abc.at(1), c=abc.at(2);
  int ans=0;
  
  while(c-a>1){
    a+=2;
    ans++;
  }
  while(c-b>1){
    b+=2;
    ans++;
  }
  if((c-a==1)&&(c-b==1))
    ans++;
  else if((c-a==1)||(c-b==1))
    ans+=2;
  cout<<ans<<endl;
}


Measured memory_bytes: 3588
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter, deque
#from scipy.misc import comb

N = int(input())
S = []

for _ in range(N):
    s = int(input())
    S.append(s)

S.sort()

A = sum(S)
B = 0
for s in S:
    if s%10:
        B = s
        break

if A%10:
    print(A)
else:
    if B:
        print(A-B)
    else:
        print(0)

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


long long int jump(int n,int h[],int start,int end,long long int y[])
{

    if(y[n]!=-1)
    {
    	return y[n];
    }
	if(end==start+1)
	{
        int k = abs(h[end] - h[start]);
        y[n] = k;
		return y[n]; 
	}
	if(end==start)
	{
		return 0;
	}
	int d = abs(h[start+2]-h[start]);
	int e = abs(h[start+1]-h[start]);
	y[n] = min(d + jump(n-2,h,start+2,end,y),e + jump(n-1,h,start+1,end,y));
	return y[n];
}

int main()
{
     // #ifndef ONLINE_JUDGE
     // freopen("input.txt","r",stdin);
     // freopen("output.txt","w",stdout);
     // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;int g=n;
    int h[n];
    long long int y[1000001];
    memset(y, -1, sizeof(y));
    for(int i=0;i<n;i++)
    {
    	cin>>h[i];
    }   
    int f = jump(n,h,0,g-1,y);
    cout<<f;

    // #ifndef ONLINE_JUDGE
    //     cout<<"\nTime Elapsed : "<< 1.0*clock() / CLOCKS_PER_SEC << " s\n";
    // #endif
    
    return 0;
}

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

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;

const char nl = '\n' ;
const ll MOD = 1e9 + 7;

bool check(string s)
{
   int k = s.size()/2;
   for(int i = 0; i <k; i++)
   {
      if(s[i] != s[i+k])
         return false;
   }
   return true;
}
int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
   string s; cin >> s;
   s[0] == s[2] ? cout << "Yes" : cout << "No";
   return 0;
}


Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int x, a, b;
    cin >> x >> a >> b;
    
    if(b <= a)
        cout << "delicious" << endl;
    else if(b - a <= x)
        cout << "safe" << endl;
    else
        cout << "dangerous" << endl;

    return 0;
}


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

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

    std::string ans = "No";
    if(s.at(2) == s.at(3) && s.at(4) == s.at(5)){
        ans = "Yes";
    }

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

    return 0;
}

Measured memory_bytes: 888
n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))

def binarysearch(x, i):
    left = 0
    right = len(x)
    while left < right:
        mid = (left + right) // 2
        if x[mid] == i:
            return True
        elif x[mid] < i:
            left = mid + 1
        else:
            right = mid
    return False
    
cnt = 0
for i in t:
    if binarysearch(s, i):
        cnt += 1
print(cnt)


Measured memory_bytes: 16708
N, X = map(int, input().split())

a = [2**(i+2) - 3 for i in range(N+1)]
p = [2**(i+1) - 1 for i in range(N+1)]

ans = 0

def calc(n, x):
    if n == 0:
        return 1
    if x == 1:
        return 0
    elif 1 < x < a[n-1]+2:
        return calc(n-1, x-1)
    elif x == 2 + a[n-1]:
        return p[n-1] + 1
    elif 2 + a[n-1] < x < 3 + 2*a[n-1]:
        return p[n-1] + 1 + calc(n-1, x-2-a[n-1])
    elif x == 3 + 2*a[n-1]:
        return 2*p[n-1] + 1


ans = calc(N, X)
print(ans)

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

ll N, M;
vector<ll> S, T;

// 数列（もしくは文字列） s, t に存在する共通部分列の数 % mod を返す
// 「何もない部分列」もカウントする
// s.size() + t.size() <= 10^6 程度まで可能
ll ccs(const vector<ll>& s, const vector<ll>& t, ll mod) {
    vector< vector<ll> > dp(s.size() + 1, vector<ll>(t.size() + 1, 1));
    for(int i = 1; i <= s.size(); ++i) {
        for(int j = 1; j <= t.size(); ++j) {
            if(s[i-1] == t[j-1]) { dp[i][j] = (dp[i][j-1] + dp[i-1][j]) % mod; }
            else { dp[i][j] = (dp[i][j-1] + dp[i-1][j] + mod - dp[i-1][j-1]) % mod; }
        }
    }
    return dp[s.size()][t.size()] % mod;
}

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

    cin >> N >> M;
    S.resize(N);
    T.resize(M);
    REP(i, N) { cin >> S[i]; }
    REP(i, M) { cin >> T[i]; }

    ll ans = ccs(S, T, MOD);
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 31616
'''A - Multiple of 2 and N
https://atcoder.jp/contests/abc102/tasks/abc102_a

>>> main(3)
6
>>> main(10)
10
>>> main(999999999)
1999999998'''


def main(n):
    if n % 2 == 0:
        print(n)
    else:
        print(n*2)


if __name__ == "__main__":
    n = int(input())

    main(n)


Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
using namespace std;



int main(){
    int n;
    cin>>n;
    int a[n]{0},b[n]{0},c[n-1]{0};
    pan(i,n) cin>>a[i];
    pan(i,n) cin>>b[i];
    pan(i,n) cin>>c[i];
    // pan(i,n-1) cout<<a[i]<<b[i]<<c[i]<<endl;
    int s=0;
    pan(i,n){
        s+= a[i]-a[i-1]!=1 ?  b[a[i]-1]:b[a[i]-1]+c[a[i]-2];
        // cout<<s<<endl;
    }   
    cout<<s;
}


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

using namespace std;

const char en = '\n';
using  ll =          long long;
using ull = unsigned long long;

#define REP(i  ,n) for(int i=0;i<n;i++)
#define FOR(i,s,g) for(int i=s;i<g;i++)

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

	int buf;
	REP(i, 3){
		int s=0,t=0;

		cin>>buf;	s+=buf*3600;
		cin>>buf;	s+=buf*60;
		cin>>buf;	s+=buf;

		cin>>buf;	t+=buf*3600;
		cin>>buf;	t+=buf*60;
		cin>>buf;	t+=buf;

		buf=t-s;
		cout<<buf/3600<<' ';
		buf%=     3600;
		cout<<buf/  60<<' ';
		buf%=       60;
		cout<<buf     <<en;
	}
	return 0;
}

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

using namespace std;

int main()
{
    int i;
   string s;
   cin>>s;
   for(i=0;i<s.size();i++){
        if(i%2==0&&s[i]=='L'){
            cout<<"No"<<endl;
            return 0;
        }
        else if(i%2!=0&&s[i]=='R'){
            cout<<"No"<<endl;
            return 0;
        }
   }
   cout<<"Yes"<<endl;

}


Measured memory_bytes: 256
n, k = map(int, input().split())
h = list(map(int, input().split()))

memo = [10**9] * n
memo[0] = 0

for i in range(1, n):
  for j in range(1, k+1):
    if i - j < 0:
      break
    else:
      memo[i] = min(memo[i], memo[i-j] + abs(h[i] - h[i-j]))

print(memo[-1])

Measured memory_bytes: 84636
import numpy as np
n = int(input())
N = 60


d = np.array(list(map(int, input().split())))
nums = (((d[:, None] & (1 << np.arange(N)))) > 0).astype(int)
res = 0
MOD = int(1e9+7)
k = np.full(N, (n*(n-1)/2) % MOD)
n1 = nums.sum(0) % MOD
n0 = (n-nums.sum(0)) % MOD
k -= (n1*(n1-1)//2) % MOD
k -= (n0*(n0-1)//2) % MOD
k %= MOD

res = 0
for i, kk in enumerate(k):
    res += ((1 << i)*kk) % MOD
    res %= MOD


print(int(res))


Measured memory_bytes: 177764
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[n];
        
        // a -> a'
        for (int i = 0; i < n; i++) {
            if (a[i] % 2 == 1) {
                System.out.println(0);
                return;
            }
            a[i] = sc.nextInt() / 2;
        }
        
        int t = f(a[0]);
        
        // a' -> a''
        for (int i = 0; i < n; i++) {
            if (f(a[i]) != t) {
                System.out.println(0);
                return;
            }
            a[i] >>= t;
        }
        
        m >>= t;
        
        long l = 1;
        for (int i = 0; i < n; i++) {
            l = lcm(l, (long)a[i]);
            if (l > m) {
                System.out.println(0);
                return;
            }
        }
        
        int count = ((m / (int)l) + 1) / 2;
        
        System.out.println(count);
    }
    
    public static long lcm(long m, long n) {
        return m * (n / gcd(m, n));
    }
    
    public static long gcd(long a, long b) {
        if (b == 0) return a;
        
        return gcd(b, a % b);
    }
    
    public static int f(int x) {
        int res = 0;
        while (x % 2 == 0) {
            x /= 2;
            res++;
        }
        
        return res;
    }
}


Measured memory_bytes: 50420
// C - Base -2 Number
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N; cin>>N;
	string ans = "";
	while(N != 0){
		if(N%2){
			N--;
			ans = "1" + ans;
		}
		else ans = "0" + ans;
		N /= -2;
	}
	if(ans == "") ans = "0";
	cout<< ans <<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<utility>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#define maxn 1010
#define INF 0x3f3f3f3f
#define LL long long
#define ULL unsigned long long
#define E 1e-8
#define mod 1000000007
#define P pair<int,int>
using namespace std;

int main()
{
    int n,m,x,flag;
    int a[maxn];
    while(scanf("%d%d%d",&n,&m,&x)!=EOF){
        int len1=0,len2=0;
        memset(a,0,sizeof(a));
        for(int i=1;i<=m;++i){
            scanf("%d",&flag);
            a[flag] = 1;
        }
        for(int i=0;i<=x;++i){
            len1 += a[i];
        }
        for(int i=x;i<=n;++i){
            len2 += a[i];
        }
        printf("%d\n",min(len1,len2));
    }
    return 0;
}


Measured memory_bytes: 256
public class
Main
{
  private int swc;

  private void
  sort (
    int[ ] a
    )
  {
    int i, j;

    for ( i = 0; i < a.length; ++i )
    {
      int m = i;

      for ( j = i; j < a.length; ++j )
      {
        if ( a[ j ] < a[ m ] )
          m = j;
      }
      swap ( a, i, m );
    }
  }
  
  private void
  swap (
    int[ ] a,
    int    i,
    int    j
    )
  {
    int t;

    if ( i == j ) return ;

    t      = a[ i ];
    a[ i ] = a[ j ];
    a[ j ] = t;
    ++swc;
  }

  private void
  printArray (
    int[ ] a
    )
  {
    int i;

    for ( i = 0; i < a.length; ++i )
    {
      System.out.print ( a[ i ] );
      if ( i + 1 < a.length )
        System.out.print ( " " );
      else
        System.out.println ( );
    }
  }

  public void
  run (
    java.util.Scanner sc
    )
  {
    int[ ] a;
    int i, j;

    a = new int[ sc.nextInt ( ) ];
    for ( i = 0; i < a.length; ++i )
      a[ i ] = sc.nextInt ( );

    swc = 0;
    sort ( a );
    printArray ( a );
    System.out.println ( swc );
  }

  public static void
  main (
    String[ ] args
    )
  {
    ( new Main ( ) ).run ( new java.util.Scanner ( System.in ) );
  }
}

Measured memory_bytes: 19960
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll N;
  cin >> N;
  vll p(N);
  rep(i, N) {
    cin >> p[i];
  }

  ll ans = 0;
  rep(i, N) {
    if (i == 0 || i == N - 1) {
      continue;
    }
    if (p[i - 1] < p[i] && p[i] < p[i + 1]) {
      ans++;
    }
    if (p[i - 1] > p[i] && p[i] > p[i + 1]) {
      ans++;
    }
  }
  COUT(ans);

  return 0;
}

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

int main()
{
	int loop;
	int a, b, c;
	
	cin >> loop;
	
	for(int i=0; i<loop; i++){
		
		cin >> a >> b >> c;
		
		if(a*a + b*b == c*c){
			cout << "YES" << "\n";
		}else if(a*a + c*c == b*b){
			cout << "YES" << "\n";
		}else if(b*b + c*c == a*a){
			cout << "YES" << "\n";
		}else{
			cout << "NO" << "\n";
		}
	}
	
	return 0;
}

Measured memory_bytes: 1124
import collections

n = int(input())
a = list(map(int, input().split()))

# リストaの要素の出現回数を計算
s = collections.Counter(a)

# 出現回数の最大値を取得
max_s = max(s.values())

if max_s == 1:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 33996
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug "<< i << std::endl

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n,x,ans=LLONG_MAX;
  std::cin>>n>>x;

  std::vector<ll> a(n);
  rep(i,0,n)std::cin>>a[i];
  
  std::vector<std::vector<ll>> min(n,std::vector<ll>(n));

  rep(i,0,n){
    min[i][0]=a[i];
    rep(j,1,n)min[i][j]=std::min(min[i][j-1],a[(i-j+n)%n]);
  }

  rep(i,0,n){
    ll temp=0;
    rep(j,0,n)temp+=min[j][i];
    ans=std::min(ans,i*x+temp);
  }

  std::cout<<ans;

  return 0;
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    
    int n, m;
    cin >> n >> m;
    cout << ((n * (n - 1)) / 2) + ((m * (m - 1)) / 2);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  
  for (int i=0; i<K; i++)
  {
    if (A >= B)
    {
      B *= 2;
    }
    else
    {
      C *= 2;
    }
  }
  
  if ( A < B && B < C)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int a[100005],b[100005];
int main(){
	int A,B,C,M,i,mn1=10000000,mn2=10000000,mn,x,y,z;
	cin>>A>>B>>C;
	for(i=1;i<=A;i++){
		cin>>a[i];
		if(a[i]<mn1) mn1=a[i];
	}
	for(i=1;i<=B;i++){
		cin>>b[i];
		if(b[i]<mn2) mn2=b[i];
	}
	mn=mn1+mn2;
	for(i=1;i<=C;i++){
		cin>>x>>y>>z;
		mn=min(mn,a[x]+b[y]-z);
	}
	cout<<mn;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
ll t[100001];
ll calc(ll a[],ll d,ll n)
{
    if(t[d]!=-1)
    return t[d];
    else if(d>=n)
    return t[d]=0;
    else if(n-d==1)
    return t[d]=abs(a[d]-a[n]);
    else
    return t[d]=min(abs(a[d]-a[d+1])+calc(a,d+1,n),abs(a[d]-a[d+2])+calc(a,d+2,n));
}
int main() 
{
    ll n,i,cost;
    fast
    memset(t,-1,sizeof(t));
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)
    cin>>a[i];
    cout<<calc(a,0,n-1);
    return 0;
}

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

int main(){
	int a,b;
	double c,d;
	cin>>a>>b;
	c=a;
	d=b;
	cout<<a/b<<' '<<a%b<<' ';
	cout.setf(ios::fixed,ios::floatfield);
	cout<<c/d<<endl;
	return 0;
}

Measured memory_bytes: 3264
#include<iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>

unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

#define LOCAL  1
#define UPLOAD 2

using namespace std;

int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int N;
    vector<int> A, B;
    cin >> N;
    A.resize(N);

  for(int i=0;i<N-1;i++){
    int temp;
    cin >> temp;
    B.push_back(temp);
  }

  A[N-1] = B[N-2];
  A[0] = B[0];
  for(int i=N-2;i>0;i--){
    A[i] = min(B[i-1], B[i]);
  }

  int sum = 0;
  for(auto iter:A){
    sum+=iter;
    // cout << iter << endl;
  }
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 256
n, x, m = map(int, input().split())
mod = [-1 for i in range(m)]
sum = [-1 for i in range(m)]
c = [-1 for i in range(m)]

count = 0
a = x
a_p = -1
i = 1
for i in range(1, n+1):
  
  if(mod[a] != -1):
    loop_c = c[a_p] - c[a] + 1
    loop_sum = sum[a_p] - sum[a] + a
    
    bai = (n - c[a_p])//loop_c
    nokori = (n - c[a_p])%loop_c
    
    ans = sum[a_p] + bai*loop_sum
    for j in range(nokori+1):
      ans += a
      a = mod[a]
    print(ans)
    exit()
  
  i += 1
  count += a
  sum[a] = count
  c[a] = i
  
  
    
  a_p = a
  mod[a] = (a*a)%m
  a = mod[a]
  
  
print(count)

Measured memory_bytes: 16284
from itertools import product
N = int(input())
L = len(str(N))
ans = 0
for i in range(3, L+1):
    for p in product([3,5,7], repeat=i):
        if 3 in p and 5 in p and 7 in p:
            n = int("".join(map(str,p)))
            if n <= N:
                ans += 1
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>

using namespace std;

const int P = 1000;

int main() {
    int d, g;
    cin >> d >> g;
    g /= 100;

    int dp[2][P + 1];
    for (int i = 0; i <= P; i++) {
        dp[0][i] = 0;
    }

    int sp = 0;
    for (int i = 1; i <= d; i++) {
        int p, c;
        cin >> p >> c;
        c /= 100;

        for (int j = 0; j <= P; j++) {
            dp[i%2][j] = dp[1-i%2][j];
        }
        for (int j = 1; j < p; j++) {
            for (int k = 0; k <= P - j; k++) {
                dp[i%2][k+j] = max(dp[i%2][k+j], dp[1-i%2][k]+i*j);
            }
        }
        for (int k = 0; k <= P - p; k++) {
            dp[i%2][k+p] = max(dp[i%2][k+p], dp[1-i%2][k]+i*p+c);
        }
    }

    for (int i = 0; i <= P; i++) {
        if (dp[d%2][i] >= g) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,x,ans=1;
    cin>>n>>x;
    int d=0;
    rep(i,n){
        int l;
        cin>>l;
        d+=l;
        if(d<=x) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3612
# 2019/01/27
# NIKKEI Programming Contest 2019 - A

# Input
n, a, b = map(int,input().split())

# Choose Max
if a <= b:
    max = a
else:
    max = b

# Choose Min
if a + b <= n:
    min = 0
else:
    min = (a + b) - n

# Output
print(max, min)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

pair<map<int,ll>, int> dfs(const vector<vecint>& g, const vecint& clr,
    vecll& ans, int i, int p = -1) {
  ll sz = 1;
  map<int,ll> ret;
  for (auto&& to : g[i]) {
    if(to == p) continue;
    auto [cret, csz] = dfs(g, clr, ans, to, i);
    ll icsz = csz - cret[clr[i]];
    if (cret.size() > ret.size()) swap(cret, ret);
    for (auto&& [c, num] : cret) {
      ret[c] += num;
    }
    ans[clr[i]] -= icsz * (icsz + 1) / 2;
    sz += csz;
  }
  ret[clr[i]] = sz;
  return make_pair(move(ret), sz);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin>>n;
  vecint clr(n);
  REP(i,n)cin>>clr[i];
  vector<vecint> g(n);
  REP(i,n-1) {
    int a,b;
    cin>>a>>b;
    --a;--b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vecll ans(n+1, n*(n+1)/2);
  auto [cret, _] = dfs(g, clr, ans, 0);
  FOR(i,1,n+1) {
    ll icsz = n - cret[i];
    ans[i] -= icsz * (icsz+1) / 2;
    cout<<ans[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 82196
function main() {
  var
  i,
  fact = 1,
  n = parseInt(input, 10);
  for(i = 1; i <= n; i++) {
    fact *= i;
  }
  console.log(fact);
}
 
var
input = '';
 
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  main();
});

Measured memory_bytes: 7648
import sys
from fractions import gcd
inputs = sys.stdin.readlines()

n, m = map(int, inputs[0].split())
A = list(set(map(int, inputs[1].split())))

a = A[0]
for i in range(1, len(A)):
    z = gcd(a, A[i])
    x, y = a // z, A[i] // z
    if x % 2 == y % 2 == 1:
        a = x*y*z
    else:
        print(0)
        break
else:
    print(round(((m+1)/a)))

Measured memory_bytes: 13540
#include<stdio.h>
#include<math.h>

struct Point{
 double x,y;
};

void koch(int n, Point a, Point b){
 if(n == 0) return;
 Point s,t,u;
 double th = M_PI * 60.0 / 180.0;
 
 s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
 s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
 t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
 t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
 u.x = (t.x - s.x)*cos(th) - (t.y-s.y)*sin(th)+s.x;
 u.y = (t.x - s.x)*sin(th) + (t.y-s.y)*cos(th)+s.y;
 
 koch(n-1, a, s);
 printf("%.8f %.8f\n", s.x, s.y);
 koch(n-1, s, u);
 printf("%.8f %.8f\n", u.x, u.y);
 koch(n-1, u, t);
 printf("%.8f %.8f\n", t.x, t.y);
 koch(n-1, t, b);
}

int main(){
 Point a,b;
 int n;
 scanf("%d",&n);

 a.x=0;
 a.y=0;
 b.x=100;
 b.y=0;

 printf("%.8f %.8f\n",a.x,a.y);
 koch(n,a,b);
 printf("%.8f %.8f\n",b.x,b.y);

 return 0;
}


Measured memory_bytes: 2732
program uneven_numbers
  implicit none
  integer :: n, ans = 0
  read(*,*) n
  if (n > 0) ans = ans + min(9,n)
  if (n > 99) ans = ans + min(900,n-99)
  if (n > 9999) ans = ans + min(90000,n-9999)
  write(*,'(i0)') ans
  stop
end program uneven_numbers

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

signed main(){
  long long a, b, c, k;
  cin >> a >> b >> c >> k;
  long long sum = 0;
  if(a > k){
    sum += k;
    cout << sum << endl;
    return 0;
  }
  sum += a;
  k -= a + b;
  if(k <= 0){
    cout << sum << endl;
    return 0;
  }
  sum -= min(c, k);
  cout << sum << endl;
}


Measured memory_bytes: 3596
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int a, b, c;

int main(){
	cin >> a >> b >> c;
	cout << a + b + c - max({a, b, c}) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int sosuu[10000];
	int i,j,k;
	int n;
	sosuu[0]=2;
	for(i=3,j=1;j<10000;i+=2) {
		for(k=0;k<j;k++) {
			if(i%sosuu[k]==0)break;
		}
		if(k>=j) {
			sosuu[j]=i;
			j++;
		}
	}
	for(i=1;i<10000;i++)sosuu[i]+=sosuu[i-1];
	while(1) {
		scanf("%d",&n);
		if(n==0)break;
		printf("%d\n",sosuu[n-1]);
	}
	return 0;
}

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

#define PRINT(n) cout << n << "\n";

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

void Main(){
    int N;
    cin >> N;
    PRINT(N * N * N)
}


Measured memory_bytes: 3152
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = 1<<29;
typedef long long int ll;

int main(){
    int N;cin >> N;
    int C[N], S[N], F[N];
    for(int i = 0;i < N - 1;++i)
        cin >> C[i] >> S[i] >> F[i];
    for(int j = 0;j < N;++j){
        int ans[N];
        ans[j] = 0;
        if(j < N - 1) ans[j + 1] = S[j] + C[j];
        for(int i = j;i < N - 1;++i){
            ans[i + 1] = C[i] + ans[i];
            if(ans[i] > S[i]) ans[i + 1] += ((ans[i] % F[i] != 0) ? (F[i] - ans[i] % F[i]) : 0);
            else ans[i + 1] += S[i] - ans[i];
        }
        cout << ans[N - 1] << endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>

typedef long long LL;

const int MN = 305, MK = 305;

int N, K, Mod;
int C[MN][MK], f[MN][MK];

int main() {
	scanf("%d%d%d", &N, &K, &Mod);
	for (int i = 0; i <= N; ++i) C[i][0] = 1;
	for (int i = 1; i <= N; ++i)
		for (int j = 1; j <= i; ++j)
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % Mod; 
	for (int i = 0; i <= K; ++i) f[1][i] = 1;
	for (int i = 2; i <= N + 1; ++i) {
		for (int k = 1; k < i; ++k) {
			int Sum = 0;
			for (int j = K; j >= 0; --j) {
				f[i][j] = (f[i][j] + (LL)f[i - k][j] * Sum % Mod * C[i - 2][k - 1]) % Mod;
				Sum = (Sum + f[k][j]) % Mod;
			}
		}
	}
	printf("%d\n", f[N + 1][0]);
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main(void)
{
    double r, area, len;

    cin >> r;
    
    len = 2 * M_PI * r;
    area = M_PI * r * r;

    cout << fixed << setprecision(6) << area << " " << len << endl;
}


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

int main() {
	string s;cin >> s;
  	int length = s.size();
  	vector<int> surplus(2019,0);
  	
  	int cur = 0;
  	surplus[cur]++;
  	int fac = 1;
  	
  	for(int i = length - 1; i >= 0; i--) {
    	int add = s[i] - '0';
      	cur = (cur + fac * add) % 2019;
      	fac = (fac * 10) % 2019;
      	surplus[cur]++;
    }
  	
  	int result = 0;
  	for(int sur : surplus){
    	result += sur * (sur - 1) >> 1;
    }
    cout << result << "\n";
}

Measured memory_bytes: 3704
N, M = map(int, input().split())
a=[list(map(int,input().split())) for i in range(M)]
p=list(map(int,input().split()))
ans=0
for i in range(2**N):
	b=list(str(bin(i)))
	c=b.pop(0)
	c=b.pop(0)
	b=['0']*(N-len(b))+b
	b=list(map(int,b))
	Light=[]
	for i in range(M):
		light=0
		for j in range(1,N+1):
			if j in a[i][1:]:
				light+=b[j-1]
		if light%2==p[i]:
			Light+=[1]
	if Light==[1]*M:
		ans+=1
print(ans)

Measured memory_bytes: 3064
a, b, c = map(int, input().split())
k = int(input())

ans = 0
for x in range(k+1):
    for y in range(k+1-x):
        for z in range(k+1-x-y):
            if b*2**y > a*2**x and c*2**z > b*2**y:
                ans += 1
#print(ans)

if ans == 0:
    print("No")
else:
    print("Yes")


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

int main() {
  
  int n;
  string s;
  cin >> n >> s;
  
  int m = 0, x = 0;
  
  for ( int i = 0; i < n ; i++){
    if ( s[i] == 'I' ){
      x++;
      if ( m < x ){
        m = x;
      }
    }else{
      x--;
    }
  }
  
  
  cout << m << endl;
  
  
  
  
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
const int MAX = (int)2e5 + 5;

int field[10][10];

int H = 10;
int W = 10;

bool ng(int y, int x) {
	return y < 0 || H <= y || x < 0 || W <= x;
}

int main() {
	int n;
	while (cin >> n) {
		rep(i, 12) {
			int n2 = 1 << i;
			// dump((n >> i) & 1);
			if (((n >> i) & 1) == 0) continue;
			n ^= n2;
			// dump(n);
			if (n == 0) {
				cout << n2 << endl;
				break;
			}
			else cout << n2 << " ";
		}
	}


	return 0;
}

Measured memory_bytes: 3072
def main():
    from collections import deque

    import sys
    input = sys.stdin.readline

    N, M, S = map(int, input().split())

    S = min(S, 50 * 50) #これ以上の枚数はいらない

    G = [[] for _ in range(N + 1)]

    for _ in range(M):
        U, V, A, B = map(int, input().split())
        G[U].append((V, A, B))
        G[V].append((U, A, B))

    CD = [tuple(map(int, input().split())) for _ in range(N)]

    MAX = 10 ** 18
    DP = [[MAX] * (50 * 50 + 1) for _ in range(N + 1)]

    # print (G)
    # print (CD)

    #初期位置のコストを0にする
    for s in range(S + 1):
        DP[1][s] = 0
    for s in range(S + 1, 50 * 50 + 1):
        DP[1][s] = DP[1][max(0, s - CD[0][0])] + CD[0][1]

    que = deque()
    que.append(1)

    while que:
        tmp = que.popleft()
        for v, a, b in G[tmp]:
            flag = False
            for i in range(50 * 49 + 1):
                if DP[v][i] > DP[tmp][i + a] + b:
                    flag = True
                    DP[v][i] = DP[tmp][i + a] + b
            c = CD[v - 1][0]
            d = CD[v - 1][1]
            if flag:
                for i in range(50 * 50 + 1):
                    DP[v][i] = min(DP[v][i], DP[v][max(0, i - c)] + d)
                que.append(v)

    for i in range(2, N + 1):
        print (DP[i][0])

    # print ()            
                
    # for tmp in DP[1:]:
    #     print (tmp[:10])

if __name__ == '__main__':
    main()

Measured memory_bytes: 16192
from collections import deque
N = int(input())
li = list(map(int, input().split()))
d = deque(sorted(li))
while len(d) != 1:
    x = d.popleft()
    y = d.popleft()
    temp = (x+y)/2
    d.appendleft(temp)
print(d[0])

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

int main(){
    string str;
    int n , k;
    //freopen("A.txt","r",stdin);
    while(cin>>n>>k){
        cin>>str;
        str[k-1]=str[k-1]+32;
        cout<<str<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main()
{
       fast;
       ll n,d,cnt=0,sum;
       cin>>n>>d;
       ll arr[n][d];
       for(int i=0;i<n;i++)
    		for(int j=0;j<d;j++)
    			cin>>arr[i][j];
    	for(int i=0;i<n;i++){
    		for(int j=i+1;j<n;j++){
    			sum=0;
    			for(int k=0;k<d;k++)
    				sum+=(arr[i][k] - arr[j][k])*(arr[i][k] - arr[j][k]);
    			// cout<<sum<<endl;
    			if(floor(sqrt(sum))==ceil(sqrt(sum)))
    				cnt++;
    		}
    	}
       cout<<cnt;
       return 0;
}


Measured memory_bytes: 3580