akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
using namespace std;

int main(void){
    int S, h, m, s;
    cin >> S;
    h =  S/3600;
    m = (S-h*3600)/60;
    s = S-(h*3600+m*60);
    cout << h;
    cout << ":";
    cout << m;
    cout << ":";
    cout << s;
    cout << endl;
    
}


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

int main()
{
    int a, b, c;
    bool f = 0;

    cin >> a >> b >> c;

    if(a == b && a != c) f = 1;
    else if(a == c && a != b) f = 1;
    else if(b == c && b != a) f = 1;

    if(f == 1) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i=1;i <= n;i++){
            if(i%3 == 0){
                System.out.printf(" %d",i);
            }else if((int)(i%10) == 3){
                System.out.printf(" %d",i);
            }else if((int)(i%100) == 3){
                System.out.printf(" %d",i);
            }else if((int)(i%1000) == 3){
                System.out.printf(" %d",i);
            }else if((int)(i/10) == 3){
                System.out.printf(" %d",i);
            }else if((int)(i/100) == 3){
                System.out.printf(" %d",i);
            }else if((int)(i/1000) == 3){
                System.out.printf(" %d",i);
            }else if((int)(i/10)%10 == 3){
                System.out.printf(" %d",i);
            }else if((int)(i/10)%100 == 3){
                System.out.printf(" %d",i);
            }else if((int)(i/100)%10 == 3){
                System.out.printf(" %d",i);
            }else{

            }
        }
        System.out.printf("\n");
    }
}


Measured memory_bytes: 39636
#include<bits/stdc++.h>
using namespace std;
int main(){

string S ,T ,U ;
int A,B ;
cin >> S >>T ;
cin >> A>>B ;
cin >> U ;
if (S==U)
{
    cout << A-1<< " "<<B ;

}
else if (T==U)
    cout << A << " " <<B-1 ;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
char mat[1001][1001];
long dp[1001][1001];
int main(){
    int r,c;
    cin >> r >> c;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            cin >> mat[i][j];
        }
    }
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            if(i==0 && j==0){
                dp[i][j]=1;
            }
            else if(i==0){
                if(mat[i][j]=='.')
                dp[i][j]= dp[i][j-1];
            }
            else if(j==0){
                if(mat[i][j]=='.')
                dp[i][j]= dp[i-1][j];
            }
            else{
                if(mat[i][j]=='.')
                dp[i][j]= dp[i-1][j]+dp[i][j-1];
                dp[i][j]%=MOD;
            }
        }
    }
    cout << dp[r-1][c-1];

    return 0;
}

Measured memory_bytes: 9088
def main():
    N = int(input())
    S = input()
    ans = 0
    for i in range(10):
        for j in range(10):
            for k in range(10):
                flag_i = False
                flag_j = False
                flag_k = False
                for t in range(N):
                    if not flag_i and S[t] == str(i):
                        flag_i = True
                    elif flag_i and not flag_j and S[t] == str(j):
                        flag_j = True                           
                    elif flag_i and flag_j and not flag_k and S[t] == str(k):
                        flag_k = True
                if flag_i and flag_j and flag_k:
                    ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 41948
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;
typedef vector<Edge> vE;
typedef priority_queue<Edge, vector<Edge>, greater<Edge> > pqlE;


int main() {
	int Q;
	cin >> Q;
	rep(q, Q) {
		string x, y;
		cin >> x >> y;
		vvi dp(x.size() + 1, vi(y.size() + 1, 0));
		repl(i, 1, x.size() + 1) {
			repl(j, 1, y.size() + 1) {
				if (x[i - 1] == y[j - 1]) {
					dp[i][j] = dp[i - 1][j - 1] + 1;
				}
				else {
					dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
				}
			}
		}
		cout << dp[x.size()][y.size()] << endl;
	}

	return 0;
}

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

int main()
{
    int b1,b2,b3;
    cin>>b1>>b2>>b3;
    if((b1==1&&b2==1)||b3==1)
        cout<<"Open"<<endl;
    else
        cout<<"Close"<<endl;
    
    return 0;
}

Measured memory_bytes: 1160
def fur(n, r):
    return  math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
import math
n, p = map(int, input().split())
A = list(map(lambda x:int(x)%2, input().split()))
from collections import Counter
c = dict(Counter(A))
a, b = 0, 0
if c.get(0) != None:
    a = c[0]
if c.get(1) != None:
    b = c[1]
result = 0
piyo = 1
for i in range(1, a+1):
    piyo += fur(a, i)
for i in range(0, b+1, 2):
    result += fur(b, i) * piyo
if p == 0:
    print(result)
else:
    hoge = 0
    for i in range(n+1):
        hoge += fur(n, i)
    print(hoge - result)


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

using namespace std;

typedef long long ll;

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

	string s;
	cin >> s;

	int n = (int) s.size();

	int i = 0;
	bool conc = true;

	int ans = 0;
	while(i < n){
		if(conc){
			ans++;
			i++;
			conc = false;
		}else{
			if(s[i-1] != s[i]){
				ans++;
				i++;
				conc = false;
			}else{
				if(i == n-1) break;
				ans++;
				i += 2;
				conc = true;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 720
#include <stdio.h>

const int Mod = 1000000007;

int main()
{
	int N;
	char s[3001];
	scanf("%d", &N);
	scanf("%s", &(s[1]));
	
	int i, j;
	long long dp[3001], sum[3001], ans = 0;
	for (i = 2, dp[1] = 1; i <= N; i++) {
		if (s[i-1] == '<') {
			for (j = 1, sum[0] = 0; j < i; j++) sum[j] = sum[j-1] + dp[j];
			for (j = 1; j <= i; j++) dp[j] = sum[j-1] % Mod;
		} else {
			for (j = i - 1, sum[i] = 0; j >= 1; j--) sum[j] = sum[j+1] + dp[j];
			for (j = 1; j <= i; j++) dp[j] = sum[j] % Mod;
		}
	}
	for (j = 1; j <= N; j++) ans += dp[j];
	printf("%lld\n", ans % Mod);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1780
import sys
input = sys.stdin.readline
from collections import *

H, W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]
ans = []
flag = False

for i in range(H):
    if i%2==0:
        for j in range(W):
            if a[i][j]%2==1:
                if flag:
                    ans.append((pi, pj, i, j))
                    flag = False
                else:
                    flag = True
            else:
                if flag:
                    ans.append((pi, pj, i, j))
                    
            pi, pj = i, j
    else:
        for j in range(W-1, -1, -1):
            if a[i][j]%2==1:
                if flag:
                    ans.append((pi, pj, i, j))
                    flag = False
                else:
                    flag = True
            else:
                if flag:
                    ans.append((pi, pj, i, j))
            
            pi, pj = i, j

print(len(ans))

for a, b, c, d in ans:
    print(a+1, b+1, c+1, d+1)

Measured memory_bytes: 72028
n = int(input())
ans = 0
for i in range(1, n + 1):
    count = 0
    if i % 2 != 0:
        for j in range(1, i + 1):
            if i % j == 0:
                count += 1
        if count == 8:
            ans += 1
    
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
typedef pair<int, int> p;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9

vector<int> V; // 嫌いな数字リスト
int N, K;

bool isLike(int n) { // 0 <= n <= 9
	bool res = true;
	for (int i = 0; i < V.size() && res; i++) {
		if (V[i] == n) res = false;
	}
	return res;
}

bool isAllLike(int n) {
	bool res = true;
	while (n > 0 && res) {
		if (!isLike(n % 10)) res = false; // 1の位の数字が嫌いな数字ではないか
		n /= 10;
	}
	return res;
}

void input() {
	scanf("%d%d", &N, &K);
	for (int i = 0; i < K; i++) {
		int tmp; scanf("%d", &tmp);
		V.push_back(tmp);
	}
}

void solve() {
	int ans = N;
	while (!isAllLike(ans)) ans++;
	printf("%d", ans);
}

int main() {
	input();
	solve();

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        long left = 1000;
        int lastLow = sc.nextInt();
        for (int i = 1; i < n; i++) {
            int today = sc.nextInt();
            if (today > lastLow) {
                long pos = left / lastLow;
                left -= pos * lastLow;
                left += pos * today;
            }
            lastLow = today;
        }
        System.out.println(left);
    }
}

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

int main(){
  ll n;
  cin >> n;
  int ans = 1;
  if(n != 2) ++ans;
  for(ll i=2; i*i<=n; ++i){
    ll x = n;
    if(x%i == 1){
      ans += 2;
      if(i == x/i) --ans;
      continue;
    }
    while(x%i == 0){
      x /= i;
    }
    if(x%i == 1){
      ++ans;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll A,B,C,D,E,F;
	cin >> A >> B >> C >> D >> E >> F;
	bool dp[31][3001] = {false};
	dp[0][0] = true;
	FOR(i,0,31){
		FOR(j,0,3001){
			if(dp[i][j]){
				//cout << i << " " << j << endl;
				if(i+A<31)dp[i+A][j] = true;
				if(i+B<31)dp[i+B][j] = true;
				if(i*E>=j+C)if(j+C<=3000)dp[i][j+C] = true;
				if(i*E>=j+D)if(j+D<=3000)dp[i][j+D] = true;
			}
		}
	}
	P ans = {A,0};
	FOR(i,0,31){
		FOR(j,0,3001){
			if((i*100+j)>F)continue;
			if(dp[i][j]){
				ll w = ans.first*100;
				ll s = ans.second;
				if(s*(i*100+j)<j*(w+s)){
					ans = {i,j};
				}
			}
		}
	}
	cout << ans.first*100+ans.second << " " << ans.second << endl;
}


Measured memory_bytes: 384
/*
        @uthor: Kashish Gilhotra
        user: CodeChef, CodeForces, HackerEarth, HackerRank, SPOJ: kashish001
*/

#include <bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
  
#define int long long int 
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

double EPS = 1e-9; 
int INF = 1000000005; 
long long INFF = 1000000000000000005LL;
const int mod = 1e9 + 7; 

//#define CI cpp_int
string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << " " ;
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define RESET(a, b) memset(a, b, sizeof(a)) 
#define EB emplace_back
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define size(v) (int)v.size() 
#define endl "\n"
#define UMO unordered_map
#define USO unordered_set
#define setBits(n) __builtin_popcountll(n)
#define MX *max_element
#define MN *min_element
#define TC int t; cin >> t; while (t--) 

void Panda() {
    unsigned int a, b, k;
    cin >> a >> b >> k;
    if(a >= k) cout << a - k << " " << b << endl;
    else if(a < k) {
    	k -= a;
    	cout << 0 << " ";
    	if(b >= k) cout << b - k << endl;
    	else cout << 0 << endl;
    } 
}
  
int32_t main() {
 
    FAST;

   
    
    Panda();

    return 0; 
} 

Measured memory_bytes: 3644
N = int(input())
hl = list(map(int,input().split()))

hl[0] = hl[0]-1
for i in range(1,N-1):
    if(hl[i]>hl[i-1]):
        hl[i] = hl[i]-1
    if(hl[i]>hl[i+1]):
        print("No")
        exit(0)

print("Yes")



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

int main(){
    int n,k;
    cin >> n >> k;
    long long a=0,b=0;
    if(k%2==1){
        a=n/k;
    }else{
        a=n/k;
        b=(n+k/2)/k;
    }

    cout << a*a*a+b*b*b << endl;
}


Measured memory_bytes: 256
# Graph

N = int(input())
G = [[0]*N for i in range(N)]

for i in range(N):
    lst = list(map(int, input().split()))
    idx = lst[0]
    for j in range(lst[1]):
        G[idx-1][lst[2:][j]-1] = 1
    print(*G[idx-1])
    


Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
constexpr int nn = 512;
int n, q, v[300005], w[300005], u, l, dp[10][100005], memo[nn][100005];
void dfs(int t, int d){
	rep(i,100005) dp[d][i] = max(dp[d-1][i], i >= w[t] ? dp[d-1][i-w[t]] + v[t] : 0);
	copy(dp[d], dp[d]+100005, memo[t]);
	if(t < nn / 2){
		dfs(t*2,d+1);
		dfs(t*2+1,d+1);
	}
}
int main(){
	scanf("%d", &n);
	rep(i,n) scanf("%d%d", v+i+1, w+i+1);
	dfs(1,1);
	scanf("%d", &q);
	rep(i,q){
		scanf("%d%d", &u, &l);
		int vv[nn], ww[nn], ans = 0;
		fill(vv,vv+nn, 0); fill(ww,ww+nn,0);
		for(int e = 1; u >= nn; u /= 2, e *= 2) rep(i,e){
			vv[i+e] = vv[i] + v[u];
			ww[i+e] = ww[i] + w[u];
		}
		rep(i,nn) if(l-ww[i] >= 0) ans = max(ans, memo[u][l-ww[i]] + vv[i]);
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 209024
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;

int N,M,R;
int r[10]={};
int A,B,C;
int nodes[210][210]={};
int mina=MOD;
bool reached[210];

void dfs(int cnt,int from,int dist){
	if(cnt==R){
		mina = min(mina, dist);
		return;
	}
	REP(j,R)
	if(!reached[r[j]]){
		reached[r[j]]=true;
		dfs(cnt+1,j,dist+nodes[r[from]][r[j]]);
		reached[r[j]]=false;
	}
}
int main() {
	cin >> N >> M >> R;
	REP(i,R) cin >> r[i];
  	REP(i,201)
      REP(j,201) if(i!=j) nodes[i][j]=MOD;
	REP(i,M){
		cin >> A >> B >> C;
		if(nodes[A][B]!=0) C=min(nodes[A][B],C);
		nodes[A][B]=C;
		nodes[B][A]=C;
	}
	FOR(k,1,N+1)
		FOR(i,1,N+1)
			FOR(j,1,N+1)
				if(nodes[i][j]>nodes[i][k]+nodes[k][j])
					nodes[i][j]=nodes[i][k]+nodes[k][j];
	REP(i,R){
		reached[r[i]]=true;
		dfs(1,i,0);
		reached[r[i]]=false;
	}
	cout<<mina<<endl;
	return 0;
}

Measured memory_bytes: 384
n,m,k = map(int, input().split())
A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))

for i in range(n):
    A[i+1] += A[i]

for i in range(m):
    B[i+1] += B[i]

ans = 0
j = m

for i in range(n+1):
    if A[i] > k:
        continue

    while A[i] + B[j] > k:
        j -= 1

    ans = max(ans,j+i)

print(ans)

Measured memory_bytes: 39868
typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
const int MAX = 510000;
 const int MOD = 1000000007;
 
 long long fac[MAX], finv[MAX], inv[MAX];
 
 // テーブルを作る前処理
 void COMinit() {
     fac[0] = fac[1] = 1;
     finv[0] = finv[1] = 1;
     inv[1] = 1;
     for (int i = 2; i < MAX; i++){
         fac[i] = fac[i - 1] * i % MOD;
         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
         finv[i] = finv[i - 1] * inv[i] % MOD;
     }
 }
 
 // 二項係数計算
 long long COM(int n, int k){
     if (n < k) return 0;
     if (n < 0 || k < 0) return 0;
     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
 }
 long long modpow(long long a, long long n) {
      long long res = 1;
      while (n > 0) {
          if (n & 1) res = res * a % MOD;
          a = a * a % MOD;
          n >>= 1;
      }
      return res;
  }
int main() {
    ll s;
    std::cin >> s;
    COMinit();
    ll ans = 0;
    for (int i = 1; 3*i <= s; i++) {
        ll rem = s-3*i;
        ans += COM(rem+i-1,rem);
        ans %= MOD;
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 15572
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ATransfer solver = new ATransfer();
        solver.solve(1, in, out);
        out.close();
    }

    static class ATransfer {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();

            int answer = Math.max(0, c - Math.max(0, a - b));
            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	string s;cin>>s;
	int n=s.size();

	int b[n+1],w[n+1];
	w[n]=0;
	for(int i=n-1;i>=0;i--){
		if(s[i]=='W') w[i]=w[i+1]+1;
		else w[i]=w[i+1];
	}
  /*
	rep(i,n+1) cout<<w[i]<<" ";
	cout<<"\n";
	*/
	ll cnt=0;
	rep(i,n){
		if(s[i]=='B') cnt+=w[i];
	}
	
	cout<<cnt<<"\n";
}

Measured memory_bytes: 1284
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

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

	int p, q, r;
	cin >> p >> q >> r;

	int ma = min({ p + q, q + r, r + p });

	cout << ma << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
//k以上のものの個数を数える関数
ll cnt(ll k,vector<ll> &a){
  ll n= a.size() ;
  ll ans=0 ;
  rep(i,n){
      ll res= k-a[i] ;
      ans+= a.end()-lower_bound(a.begin(),a.end()
      ,res) ;
   }
  return ans ;
}

int main(){
 ll  n, m ;cin>>n>>m ;
 vector<ll> A(n) ;rep(i,n) cin>>A[i] ;
 sort(A.begin(),A.end()) ;
 ll l=0 ;ll r=200005; 
 while(l+1<r){
   ll now= (l+r)/2 ;
   if(cnt(now,A)>=m ) l=now ;
   else r=now ; 
 } 
 //cout<<l<<endl ;
 //l以上のものの和
 ll sum=0 ;
 vector<ll> rui(n+5) ;
 rep(i,n) rui[0]+=A[i] ;
 rep(i,n-1) rui[i+1]=rui[i]-A[i] ;
 ll rcnt =0 ;
 rep(i,n){
     ll res = l-A[i] ;
     ll ki= lower_bound(A.begin(),A.end(),res)
     -A.begin() ;
      ;
     
     sum+= rui[ki] ;
     sum+= (n-ki)*A[i] ;
    rcnt+= n-ki;
     }
     sum-= (rcnt-m)*l ;
 cout<<sum<<endl ;
 return 0 ; 
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n / 2), b(n / 2);
	pair<int, int> am1, am2, bm1, bm2, ta,tb;
	for (int i = 0; i < n / 2; i++)
		cin >> a[i] >> b[i];
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	for (int i = 0; i < n / 2; i++) {
		if (ta.second != a[i]) {
			if (am2.first < ta.first) {
				swap(am2, ta);
				if (am1.first < am2.first)
					swap(am1, am2);
			}
			ta.first = 0;
			ta.second = a[i];
		}
		ta.first++;
		if (tb.second != b[i]) {
			if (bm2.first < tb.first) {
				swap(bm2, tb);
				if (bm1.first < bm2.first)
					swap(bm1, bm2);
			}
			tb.first = 0;
			tb.second = b[i];
		}
		tb.first++;
	}
	if (am2.first < ta.first) {
		swap(am2, ta);
		if (am1.first < am2.first)
			swap(am1, am2);
	}
	if (bm2.first < tb.first) {
		swap(bm2, tb);
		if (bm1.first < bm2.first)
			swap(bm1, bm2);
	}
	int nr;
	if (am1.second == bm1.second)
		nr = max(am1.first + bm2.first, bm1.first + am2.first);
	else
		nr = am1.first + bm1.first;
	cout << n - nr << endl;
}


Measured memory_bytes: 640
use strict;
use warnings;
use feature qw( say );

sub solve {
  my ($A, $B, $T) = @_;
  return $B * int($T / $A);
}

sub main {
  chomp (my $line = <STDIN>);
  my ($A, $B, $T) = $line =~ /\A(\d+) (\d+) (\d+)\Z/;
  say solve($A, $B, $T);
}

main() unless (caller);

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

int main() {
  ll N;
  while (cin >> N) {
    ll x = 0;
    for (ll i = 1; i <= N; ++i) x += i * (i + 1) / 2;
    for (ll i = 1; i < N; ++i) {
      ll a, b;
      cin >> a >> b;
      if (b < a) swap(a, b);
      x -= a * (N - b + 1);
    }
    cout << x << endl;
  }
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw				"\n"
int main(void)
{
	CIN;
	ll tc,l,k,sum=0,x=0,y,z=0,m=1,n=0,ans=0,cnt=0;
	string s;
	ll a,b;
	cin>>a>>b;
	cin>>s;
	l=s.size();
	if(s[a]=='-')x=1;
	for(ll i=0;i<l;i++){
		if(i==a)continue;
		if(!(s[i]>='0'&&s[i]<='9'))return cout<<"No",0;
	}
	if(x==1)cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define o_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
#define trav(it, v) for(auto &it : v)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
 	return r;
}


void solve()
{
	int n;
	cin >> n;
	int a[n];
	ll sum1 = 0, sum2 = 0, cur1 = 0, cur2 = 0;
	rep(i, n){
		cin >> a[i];
		sum1 += a[i];
		sum2 += a[i];
		if(i % 2 == 0){
			ll x = max(1ll, sum1);
			ll del = abs(x - sum1);
			sum1 = x;
			cur1 += del;
			ll y = min(-1ll, sum2);
			del = abs(y - sum2);
			sum2 = y;
			cur2 += del;
		}
		else{
			ll x = max(1ll, sum2);
			ll del = abs(x - sum2);
			sum2 = x;
			cur2 += del;
			ll y = min(-1ll, sum1);
			del = abs(y - sum1);
			sum1 = y;	
			cur1 += del;
		}
	}
	cout << min(cur1, cur2);
}

int main()
{
    Red;
    // freopen("black.in", "r", stdin);
	// freopen("black.out", "w", stdout);
    int T = 1;
    // cin >> T;
    for(int i = 1; i <= T; ++i) {
    	// cout << "Case #" << i << ": ";
    	solve();
  	}
  	return 0;

}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using lint = long long;

const lint MAX = 1e18;

int main(void)
{
    int N;
    cin >> N;
    lint ans = 1;

    int over = 0;
    int zero = 0;
    for(int i = 0; i < N; i++){
        long long x;
        cin >> x;
        if(x == 0){
            zero = 1;
        }
        else if(ans != 0 && MAX / ans < x){
            over = -1;
        }
        ans *= x;
        //cout << ans << endl;
    }
    if(zero == 1) cout << 0 << endl;
    else if (over == 0) cout << ans << endl;
    else cout << over << endl;

}

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

using namespace std;

using ll = long long int;

#define REP(i, N) for (int i = 0; i < (N); ++i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanInt(K);
    cout << static_cast<int>(N % K != 0) << endl;
}

Measured memory_bytes: 384
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
# N,K = 500,10**9
# A = [10**6-1 for i in range(N)]
# A = [10**6 for i in range(N)]

# N,K = 8,7
# A = [1,7,5,6,8,2,6,5]

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

dvs = make_divisors(sum(A))

AA = [None for i in range(N)]
ok = 1
for dv in dvs:
    for i in range(N):
        AA[i] = A[i]%dv
    AA = sorted(AA)
    # print(dv, AA)
    l,r = 0,N-1
    while l < N-1 and AA[l] == 0:
        l+=1
    while r > 0 and AA[r] == 0:
        r-=1
    kcnt = 0
    while l<r and r>0 and l<N-1:
        # print(dv, l,r,AA[l],AA[r], kcnt)
        # print(dv, kcnt, l,r,"===",AA)
        if AA[l] == 0:
            l+=1
        if AA[r]%dv == 0:
            r-=1
        else:
            mv = max(min([AA[l],dv-AA[r],K-kcnt]),0)
            kcnt += mv
            AA[l]-=mv
            AA[r]+=mv
        if mv == 0:
            # print("dame")
            break
    if l>=r:
        ok = max(ok, dv)

# print(len(dvs))

# print("ok")
print(ok)


Measured memory_bytes: 44508
#include<bits/stdc++.h>
using namespace std;
typedef	 long long int lli;
typedef long long ll;
typedef long double ld;
const int mod=1e9+7;
const int MAX=200005;
#define ALL(x) x.begin(),x.end()
#define all(x,k) x.begin(),x.begin()+k


void solve();

string getString(char x) 
{ 
    // string class has a constructor 
    // that allows us to specify size of 
    // string as first parameter and character 
    // to be filled in given size as second 
    // parameter. 
    string s(1, x); 
  
    return s;    
} 
bool sz(ll a, ll b)
{
	return a>b;
}
int main()
{


		
			solve();
		
		
	
	
	

return 0;
}

void solve()
{
	
int a,p;
cin>>a>>p;
cout<<(a*3+p)/2;
	
}



Measured memory_bytes: 3616
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>

using namespace std;


int main(){
    cin.tie(0);
    
    long long N; cin >> N;
    long long a;
    for (long long i = 1; i * i <= N; i++){
        if (N%i == 0) a = i;
    }
    long long b = N/a;
    int ans = 0;
    while (b){
        b /= 10;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
use std::io;


/// https://beta.atcoder.jp/contests/abc079/tasks/abc079_b
fn main() {
    let n = read_one::<usize>();
    let mut lucas = vec![0u64; n + 1];
    lucas[0] = 2;
    lucas[1] = 1;
    for i in 2..(n + 1) {
        lucas[i] = lucas[i - 1] + lucas[i - 2];
    }
    println!("{}", lucas[n]);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

signed main(void) {
    int i,j;
    int n, m;
    cin >> n >> m;
    int a[1000][3];
    rep(i,n)rep(j,3)cin >> a[i][j];
    int ans = 0;
    rep(bit,1<<3){
        vi x(n,0);
        rep(i,n)rep(j,3){
            if(bit & (1<<j)) x[i] += a[i][j];
            else x[i] -= a[i][j];
        }
        sort(all(x));
        int sum = 0;
        rep(i,m){
            sum += x[n-1-i];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import numpy as np
n = int(input())
a = np.array(list(map(int,input().split())))
ans = 0
while a[np.argmax(a)] >= n:
    temp = a[np.argmax(a)] // n
    ans += temp
    a += temp
    a[np.argmax(a)] -= (n+1) * temp
print(ans)

Measured memory_bytes: 21224
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, Z, W;
	cin >> N >> Z >> W;
	vector<int> A(N + 1);
	vector<int> dp1(N, (int)1 << 60);
	vector<int> dp2(N, -1);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	dp1[N - 1] = abs(W - A[N - 1]);
	for (int i = N - 2; i >= 0; i--) {
		for (int j = i + 1; j < N - 1; j++) {
			dp1[i] = min(dp2[j], dp1[i]);
			dp2[i] = max(dp1[j], dp2[i]);
		}
		dp1[i] = min(abs(A[i] - A[N - 1]), dp1[i]);
		dp2[i] = max(abs(A[i] - A[N - 1]), dp2[i]);
	}
	for (int i = 0; i < N; i++) {
		res = max(res, dp1[i]);
	}
	cout << res << endl;
}

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

int main(void){

    long long N;
    cin >> N;

    if(N%2==1){
        cout << 0 << endl;
    }else{
        long long res=0;
        for(long long Nbuf=N/10; Nbuf>0; Nbuf=Nbuf/5){
            res += Nbuf;
        }
        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int pd()
{
	if(s[2]!=s[3])
	return 0;
	if(s[4]!=s[5])
	return 0;
	return 1;
}
signed main()
{
	cin>>s;
	if(pd())
	printf("Yes");
	else
	printf("No");
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    while (true){
        val(h, w) = readLine()?.split(" ")?.map { it.toInt() } ?: return
        if(w == 0 && h == 0) return
        for(i in 1..h) {
            val row = StringBuilder()
            for(j in 1..w) {
                val element = if (i % 2 == 1 && j % 2 == 1 || i % 2 == 0 && j % 2 == 0) "#" else "."
                row.append(element)
            }
            println(row.toString())
        }
        println("")
    }
}


Measured memory_bytes: 33048
n = int(input())
a = sorted([int(input()) for _ in range(n)])
l = 0
r = 0
c = 0
for i in range(1, n):
    if a[l] != a[i]:
        r = i - 1
        if (r - l + 1) & 1:
            c += 1
        l = i
r = n - 1
if (r - l + 1) & 1:
    c += 1
print(c)


Measured memory_bytes: 8280
local N, K = io.read("*n", "*n")
local tricked = {}
for i = 1, N do
	tricked[i] = true
end

for i = 1, K do
	local d = io.read("*n")
	for j = 1, d do
		tricked[io.read("*n")] = false
	end
end

local count = 0
for i = 1, N do
	if tricked[i] then
		count = count + 1
	end
end

print(count)

Measured memory_bytes: 2728
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
using namespace std;

int main(void) {
	double r1, r2;
	double p;
	cin >> r1 >> r2;
	p = (r1*r2) / (r1 + r2);
	printf("%15.8lf\n", p);
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<int,ll>Pil;
typedef pair<P1,ll> P2;
typedef list<int> li;
typedef list<li> lli;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	ll a;
	int b;
};

int main(){

	string s,t;
	cin>>s;
	cin>>t;

	int mi=s.size();
	rep(i,s.size()-t.size()+1){
		int x=0;
		rep(j,t.size()){
			if(s[i+j]!=t[j])x++;
		}
		mi=min(mi,x);
	}
	cout<<mi<<endl;

	return 0;
}


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

int dfs (vector<string> S, int H, int W, int i, int j) {
  int cnt = 0;
  for (int dx = -1; dx <= 1; dx++) {
    for (int dy = -1; dy <= 1; dy++) {
      int nx = i + dx, ny = j + dy;
      if(0 <= nx && nx < H && 0 <= ny && ny < W) {
        if (S.at(nx).at(ny) == '#') {
          cnt++;
        }
      }
    }
  }
  return cnt;
}

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  vector<vector<int>> SS(H, vector<int>(W, 0));
  for (int i = 0; i < H; i++) {
    cin >> S.at(i);
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (S.at(i).at(j) != '#') {
        SS.at(i).at(j) = dfs(S, H, W, i, j);
      }
    }
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (S.at(i).at(j) == '#') {
        cout << S.at(i).at(j);
      }
      else {
        cout << SS.at(i).at(j);
      }
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){
long long N;
cin>>N;
if(N%2==0){
    cout<<N<<endl;
}
else{
    cout<<N*2<<endl;
}
 return 0;
}
/*


*/

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

int main() {
    ll N,K,c1=0,c2=0;
    cin >> N >> K;

    rep(i,N) {
        if((i+1)%K == 0)
            c1++;
        if(K%2==0 && (i+1)%K == K/2)
            c2++;
    }

    cout << setprecision(20) << pow(c1, 3) + pow(c2, 3) << endl;
}

Measured memory_bytes: 256
n=int(input())
v=list(map(int,input().split()))
a=[0]*n
for i in range(n):
    t=0
    for j in range(n):
        if v[i]>v[j]:
            t+=1
    a[t]=v[i]
for i in range(n):
    if a[i]==0:
        a[i]=a[i-1]
m=0
for i in range(1,n):
    m+=a[i]/(2**(n-i))
print(m+(a[0]/(2**(n-1))))

Measured memory_bytes: 64068
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      k: usize,
      ds: [usize; k],
    }
    for v in n.. {
        let mut vs = vec![0; 10];
        let mut temp = v;
        while temp > 0 {
            vs[temp%10] += 1;
            temp /= 10;
        }
        if ds.iter().all(|&d| vs[d] == 0) {
            return println!("{}", v);
        }
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;

int main() {
  string str; cin >> str;
  bool ok = false;
  for (int i = 0; i + 1 < str.size(); ++i) {
	if (str.substr(i, 2) == "AC") ok = true;
  }
  if (ok) puts("Yes");
  else puts("No");
}


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

#define sc1(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define pr1(a) printf("%d\n",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define loop(i,a,b) for(int i=a;i<b;i+=1)
#define ll long long int
#define ld long double
#define lvec vector<long long int> v
#define vec vector<int> v
#define ite1 vector<int>:: iterator it1
#define ite2 vector<int>:: iterator it2
#define ite3 vector<int>:: iterator it3
#define mp make_pair
#define pb push_back
#define pf push_front
#define pff pop_front
#define pbb pop_back
#define ft first
#define sd second

int main()
{
    int t=1;

    //cin>>t;           // comment this line when number of testcases = 1

    while(t--)
    {
        int n;
        cin>>n;
        ll cap;
        cin>>cap;
        ll w[n];
        ll v[n];
        loop(i,0,n)
        {
            cin>>w[i]>>v[i];
        }
        ll dp[n][cap+1];
        loop(i,0,w[0])
        {
            dp[0][i] = 0;
        }
        loop(i,w[0],cap+1)
        {
            dp[0][i] = v[0];
        }

        loop(i,1,n)
        {
            loop(j,0,cap+1)
            {
                dp[i][j] = dp[i-1][j];
            }

            loop(j,w[i],cap+1)
            {
                dp[i][j] = max(dp[i][j],v[i]+dp[i-1][j-w[i]]);
            }
        }

        cout<<dp[n-1][cap];
    }
}


Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    int n;
    cin >> n;
    int v[n],c[n];
    rep(i,n) cin >> v[i];
    rep(i,n) cin >> c[i];
    int ans = 0;
    rep(i,n){
        if(v[i] - c[i] >= 0){
            ans += v[i] - c[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
fun sqrt(n: Long): Long {
    var l = 1L
    var u = 2e9.toLong()

    while (u - l > 1L) {
        val c = (l + u) / 2
        if (c * c <= n) {
            l = c
        } else {
            u = c
        }
    }

    return l
}

fun main(args: Array<String>) {
    val Q = readLine()!!.toInt()

    for (i in 1..Q) {
        val (a, b) = readLine()!!.split(" ").map{it.toLong()}
        val A = Math.min(a, b)
        val B = Math.max(a, b)

        if (B == 1L) {
            println(0)
            continue
        }

        val M = A * B - 1
        val L = sqrt(M)
        var t = 2 * L - if (M / L == L) { 1 } else { 0 }
        if (A <= L) {
            t--
        }

        println(t)
    }
}

Measured memory_bytes: 35992
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		System.out.println((int)(((n - m) * 100 + 1900 * m) * Math.pow(2, m)));
	}
}

Measured memory_bytes: 23764
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,k,h[100010];
	cin >> n >> k;
	for(int i=0; i<n; i++){
	cin >> h[i];
}
	sort(h,h+n);
	int minh = 2e9;
for(int i=0; i<=n-k; i++){
	minh = min(minh,h[i+k-1]-h[i]);
}
	cout << minh << endl;
	return 0;
}

Measured memory_bytes: 640
K = int(input())

import fractions

arr = [[0 for i in range(200)] for j in range(200)]

def gcd(a, b):
    if arr[a-1][b-1] != 0:
        return arr[a-1][b-1]
    else:
        ans = fractions.gcd(a, b)
        arr[b-1][a-1] = ans
        arr[a-1][b-1] = ans
        return ans

lis = []
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            lis.append(gcd(gcd(i, j), gcd(j, k)))


print(sum(lis))

Measured memory_bytes: 196728
#include<iostream>
int a[99]={11,31,41,61,71,101,131,151,181,191,211,241,251,271,281,311,331,401,421,431,461,491,521,541,571,601,631,641,661,691,701,751,761,811,821,881,911,941,971,991,1021,1031,1051,1061,1091,1151,1171,1181,1201,1231,1291,1301,1321,1361,1381};
int main(){int n;std::cin>>n;for(int i=0;i<n;i++){std::cout<<a[i]<<" "; }}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<cmath>
#include<cstring>
using namespace std;
#define maxn 20
#define llg long long 
#define yyj(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout);
llg n,m,d[maxn][maxn],ans,a[maxn],bj[maxn];

void init()
{
	llg x,y;
	cin>>n>>m;
	for (llg i=1;i<=m;i++)
	{
		scanf("%lld%lld",&x,&y);
		d[x][y]=d[y][x]=1;
	}
}

void check()
{
	for (llg i=1;i<n;i++)
		if (d[a[i]][a[i+1]]==0)
			return ;
	ans++;
}

void ss(llg x)
{
	if (x>n)
	{
		check();
		return ;
	}
	for (llg i=1;i<=n;i++)
		if (!bj[i])
		{
			bj[i]=1;
			a[x]=i;
			ss(x+1);
			bj[i]=0;
		}
}

int main()
{
	//yyj("C");
	init();
	a[1]=1;
	bj[1]=1;
	ss(2);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
# D - People on a Line

import sys
sys.setrecursionlimit(10000000)

N, M = map(int, sys.stdin.buffer.readline().split())
LRD = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(M)]

LRD = [[LRD[i][0]-1, LRD[i][1]-1, LRD[i][2]] for i in range(M)]

if N == 1 or M == 0:
    print("Yes")
    exit()

neighbor = [[] for _ in range(N)]
for i in range(M):
    neighbor[LRD[i][0]].append([LRD[i][1], LRD[i][2]])
    neighbor[LRD[i][1]].append([LRD[i][0], -LRD[i][2]])

x = [None] * N

def check(i):
    if x[i] == None:
        x[i] = 0
    for next_point, dist in neighbor[i]:
        if x[next_point] == None:
            x[next_point] = x[i] + dist
            check(next_point)
        elif x[next_point] != x[i] + dist:
            print('No')
            exit()

for i in range(N):
    if x[i] == None:
        check(i)

print('Yes')

Measured memory_bytes: 158252