akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(){
	long long s;
	cin>>s;
	int ans=0;
	bool nine=0;
	while(s>=10){
		if(s%10<9)nine=1;
		s/=10;
		ans+=9;
	}
	ans+=s;
	if(nine)ans--;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X, Y; cin >> X >> Y;

  for (int i = 0; i < X + 1; i++) {
	int j = X - i;

    if (i * 2 + j * 4 == Y) {
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
}

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

int main() {
	int N;
	cin >> N;
	vector<string> vecs(N);
	for (int i = 0; i < N; i++) {
		cin >> vecs.at(i);
	}
	int M;
	cin >> M;
	vector<string> vect(M);
	for (int j = 0; j < M; j++) {
		cin >> vect.at(j);
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		int tmp = 0;
		for (int j = 0; j < N; j++) {
			if (vecs.at(i) == vecs.at(j)) {
				tmp++;
			}
		}
		for (int k = 0; k < M; k++) {
			if (vecs.at(i) == vect.at(k)) {
				tmp--;
			}
		}
		if (ans < tmp) {
			ans = tmp;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
ary = []
n.times do
    ary << gets.chomp.split.map(&:to_i)
end

hash = {}
ary.each do |i|
    ary.each do |j|
        if i==j
            next
        end
        tmpx = i[0] - j[0]
        tmpy = i[1] - j[1]
        if hash.has_key?([tmpx, tmpy])
            hash[[tmpx, tmpy]] += 1
        else
            hash[[tmpx, tmpy]] = 1
        end
    end
end
# p hash
if n==1
    puts 1
else
    p n - (hash.max{ |x, y| x[1] <=> y[1] })[1]
end
    

Measured memory_bytes: 2044
import numpy as np

N, K = map(int, input().split())
A = np.sort(np.array(input().split(),np.int64))
z = A[A == 0]
p = A[A > 0]
n = A[A < 0]



def check(x):
    # x以下の数がK個以上ある時、Trueを返す
    count = 0 #最後に２で割る
    if x >= 0:
        count += len(z) * N
    count += (np.searchsorted(A, x//p, side='right')).sum()
    count += (N - np.searchsorted(A, (-x-1)//(-n), side='right')).sum()
    count -= np.count_nonzero(A * A <= x) #ペアなので自分自身は駄目
    assert count % 2 == 0
    count //= 2
    return count >= K

left = - 10 ** 19 # NG
right = 10 ** 19 # OK
while right > left + 1:
    mid = (left+right) // 2
    if check(mid):
        right = mid
    else:
        left = mid

print(right)


Measured memory_bytes: 34664
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

short dp[1010][1010];

int main(void)
{
    int q;
    cin >> q;
    while (q)
    {
        string X, Y;
        cin >> X >> Y;
        int Xs = X.size(), Ys = Y.size();
        for (int i = 0; i < Xs; i++) dp[i][0] = 0;
        for (int j = 0; j < Ys; j++) dp[0][j] = 0;
        for (int i = 0; i < Xs; i++)
        {
            for (int j = 0; j < Ys; j++)
                dp[i + 1][j + 1] = ((X[i] == Y[j]) ? dp[i][j] + 1 : max(dp[i + 1][j], dp[i][j + 1]));
        }
        cout << dp[Xs][Ys] << endl;
        q--;
    }
    return 0;
}



Measured memory_bytes: 5052
a1=int(input())
a2=int(input())
a3=int(input())
a4=int(input())
a5=int(input())
a6=int(input())
a7=int(input())
a8=int(input())
a9=int(input())
a10=int(input())

b=a1+a2+a3+a4+a5+a6+a7+a8+a9+a10    
print(b)



Measured memory_bytes: 5588
import java.util.Scanner;

public class Main {
	static char ch1[];
	static char ch2[];
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n,temp1,temp2;
		n=sc.nextInt();
		for(int i=0;i<n;i++){
			ch1=sc.next().toCharArray();
			ch2=sc.next().toCharArray();
			temp1=ch_int(ch1);
			temp2=ch_int(ch2);
			int sum=temp1+temp2;
			char ans[]=int_ch(sum);
			System.out.println(ans);
		}
	}
	static int ch_int(char ch[]){
		int i=0,sum=0;;
		while(i<ch.length){
			if('2'<=ch[i] && ch[i]<='9'){
				int temp=ch[i]-'0';
				i++;
				if(ch[i]=='m'){
					sum+=temp*1000;
				}
				else if(ch[i]=='c'){
					sum+=temp*100;
				}
				else if(ch[i]=='x'){
					sum+=temp*10;
				}
				else if(ch[i]=='i'){
					sum+=temp;
				}
			}
			else if(ch[i]=='m'){
				sum+=1000;
			}
			else if(ch[i]=='c'){
				sum+=100;
			}
			else if(ch[i]=='x'){
				sum+=10;
			}
			else if(ch[i]=='i'){
				sum+=1;
			}
			i++;
		}
		return sum;	
	}
	static char[] int_ch(int n){
		int i=0;
		char ch[]=new char[8];
		while(true){
			if(n==0) break;
			if(1000<=n){
				if(n/1000!=1){
					ch[i]=(char) (n/1000);
					ch[i]+='0';
					i++;
					ch[i]='m';
				}
				else{
					ch[i]='m';
				}
				n%=1000;
			}
			else if(100<=n){
				if(n/100!=1){
					ch[i]=(char) (n/100);
					ch[i]+='0';
					i++;
					ch[i]='c';
				}
				else{
					ch[i]='c';
				}
				n%=100;
			}
			else if(10<=n){
				if(n/10!=1){
					ch[i]=(char) (n/10);
					ch[i]+='0';
					i++;
					ch[i]='x';
				}
				else{
					ch[i]='x';
				}
				n%=10;
			}
			else if(1<=n){
				if(n!=1){
					ch[i]=(char)n;
					ch[i]+='0';
					i++;
					ch[i]='i';
				}
				else{
					ch[i]='i';
				}
				n%=1;
			}
			i++;
		}
		char ans[]=new char[i];
		for(int j=0;j<i;j++){
			ans[j]=ch[j];
		}
		return ans;
	}
}

Measured memory_bytes: 12000
#include<cstring> 
#include<iostream> 
using namespace std;
int main()
{
	int flag=0,count=0;
	char a[100005];
	cin>>a;
	(a[0]==a[strlen(a)-1])?(flag=1):0;
	count+=flag+strlen(a);
	cout<<((count&1)?"First":"Second");
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
using P = pair<ll, ll>;

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;}

const ll mod = 1000000007;
const int INF = 1<<29;

int main(){
  string S; cin >> S;
  int N = S.size();

  string res;
  rep(i, N) res += "x";
  cout << res << endl;
}


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

struct Edge
{
  i64 to, cost;
};

int main()
{
  i64 n;
  cin >> n;
  vector<Edge> edge[n];
  for (i64 i = 0; i < n - 1; i++)
  {
    i64 v1, v2, w;
    cin >> v1 >> v2 >> w;
    v1--;
    v2--;
    edge[v1].push_back({v2, w});
    edge[v2].push_back({v1, w});
  }
  vector<i64> ans(n, -1);
  queue<pair<i64, i64>> que;
  que.push({0, 0});
  ans[0] = 0;
  while (que.size())
  {
    pair<i64, i64> p = que.front();
    que.pop();
    for (Edge j : edge[p.first])
      if (ans[j.to] == -1)
      {
        if ((p.second + j.cost) % 2 == 0)
        {
          ans[j.to] = 0;
          que.push({j.to, p.second + j.cost});
        }
        else
        {
          ans[j.to] = 1;
          que.push({j.to, p.second + j.cost});
        }
      }
  }
  for (i64 i = 0; i < n; i++)
    cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 10496
#include <stdio.h>

int main(void){
  int D,T,S;
  scanf("%d%d%d",&D, &T, &S);
  
  int a = T*S;
  
  if(a >= D){
    printf("Yes");
  }
  else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int count=0,ans=0;
  cin >> s;
  for(int i=0;i<s.size();i++){
    if (s[i]=='A' || s[i]=='T' || s[i]=='G' || s[i]=='C'){
      count++;
    }
    else count=0;
    ans=max(ans,count);
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	double weight;
	while(1) {
		if(scanf("%lf",&weight)==-1)break;
		if(weight<=48.00)printf("light fly\n");
		else if(weight<=51.00)printf("fly\n");
		else if(weight<=54.00)printf("bantam\n");
		else if(weight<=57.00)printf("feather\n");
		else if(weight<=60.00)printf("light\n");
		else if(weight<=64.00)printf("light welter\n");
		else if(weight<=69.00)printf("welter\n");
		else if(weight<=75.00)printf("light middle\n");
		else if(weight<=81.00)printf("middle\n");
		else if(weight<=91.00)printf("light heavy\n");
		else printf("heavy\n");
	}
	return 0;
}

Measured memory_bytes: 0
r,c=map(int,input().split())
sheet=[list(map(int,input().split())) for i in range(r)]
for i in range(r):
    sheet[i].append(sum(sheet[i]))
Column_sum=[0]*(c+1)
for j in range(c+1):
    for i in range(r):
        Column_sum[j]+=sheet[i][j]
        
for i in range(r):
    print(*sheet[i])
print(*Column_sum)



Measured memory_bytes: 6236
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

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

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

std::string S;

int main()
{
  std::cin >> S;

  ll ans = 0;

  rep( i, S.size() )
    ans += (S[i]=='+'?1:-1);

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

  return 0;
}

Measured memory_bytes: 256
/*Bismillahir Rahmanir Rahim */
#include <stdio.h>
#include <string.h>
int main ()
{
    char s[101];
    int n,i;
    while (scanf("%s",s)   !=EOF)
    {
        n=0;
        n=strlen(s);
       printf("%c%d%c\n",s[0],n-2,s[n-1]);
    }
    return 0;
}


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

int main(){
    int N;
    int tmp;
    cin >> N;
    tmp = N % 10;
    if(tmp == 0 || tmp == 1||
       tmp == 6 || tmp == 8 ){
           cout << "pon" << endl;
       }else if(tmp == 3){
           cout << "bon" << endl;
       }else{
           cout << "hon" << endl;
       }
    return 0;
}

Measured memory_bytes: 3624
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c for j in range(b)] for i in range(a)]
def list3d(a, b, c, d): return [[[d for k in range(c)] for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e for l in range(d)] for k in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10**9)
INF = 10**19
MOD = 998244353
EPS = 10**-10

class BIT:
    """ Binary Indexed Tree """

    def __init__(self, n):
        self.n = n
        # 0-indexed
        n += 1
        nv = 1
        while nv < n:
            nv *= 2
        self.size = nv
        self.tree = [0] * nv

    def sum(self, i):
        """ [0, i]を合計する """
        s = 0
        i += 1
        while i > 0:
            s += self.tree[i-1]
            s %= MOD
            i -= i & -i
        return s

    def add(self, i, x):
        """ 値の追加：添字i, 値x """
        i += 1
        while i <= self.size:
            self.tree[i-1] += x
            self.tree[i-1] %= MOD
            i += i & -i

    def query(self, l, r):
        """ 区間和の取得 [l, r) """
        return (self.sum(r-1) - self.sum(l-1)) % MOD
    
    def get(self, i):
        """ 一点取得 """
        return self.query(i, i+1)

    def update(self, i, x):
        """ 値の更新：添字i, 値x """
        self.add(i, x - self.get(i))

    def print(self):
        for i in range(self.n):
            print(self.get(i), end=' ')
        print()

N, K = MAP()
LR = []
for i in range(K):
    l, r = MAP()
    LR.append((l, r))

dp = BIT(N+1)
dp.add(1, 1)
for i in range(2, N+1):
    for l, r in LR:
        cnt = dp.query(max(i-r, 0), max(i-l+1, 0))
        dp.add(i, cnt)
ans = dp.get(N)
print(ans)


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

#define ld long double
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vl vector<ll>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >

using namespace std;

int main() {

    string S;
    cin >> S;

    string ans;

    /**
     * 以下の３つの条件を満たすか
     */
    bool doseBeginA = false;
    bool doesIncludeC = false;
    bool isSmallLetter = true;

    // 1個目
    if (S[0] == 'A') {
        doseBeginA = true;
    }

    // 2,3個目
    for (int i = 1; i < S.length(); ++i) {
        char temp = S[i];
        if (temp == 'C' && i > 1 && i != S.length() - 1) {
            if (doesIncludeC){
                doesIncludeC = false;
                break;
            }
            doesIncludeC = true;
        } else if (isupper(temp)) {
            isSmallLetter = false;
        }

    }

    ans = "WA";
    if (doesIncludeC && doseBeginA && isSmallLetter) {
        ans = "AC";
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n, m;
int a[200000];
int b[500000];
signed main() {
	cin >> n >> m;
	int r = 0, k = m;
	for (int i = 2; i * i <= k; i++) {
		if (m % i == 0) {
			while (m % i == 0) {
				m /= i;
				a[r]++;
			}
			r++;
		}
	}
	if (m >= 2) a[r++] = 1;
	b[0] = 1;
	for (int i = 1; i < 500000; i++) {
		b[i] = b[i - 1] * i % Mod;
	}
	int ans = 1;
	for (int i = 0; i < r; i++) {
		ans = ans * b[a[i] + n - 1] % Mod * mod_pow(b[a[i]], Mod - 2, Mod) % Mod * mod_pow(b[n - 1], Mod - 2, Mod) % Mod;
		ans %= Mod;
	}
	cout << ans << endl;
}

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

#define ll long long 
using namespace std;


int main(){
    ll N, cnt = 0;
    cin >> N;
    vector <ll> p(N), x(N);
    for(int i = 0; i < N; i++){
        cin >> p[i];
        x[i] = p[i];
    }
    sort(x.begin(), x.end());
    for(int i = 0; i < N; i++){
        if(p[i] != x[i]){
            cnt++;
        }
    }
    if(cnt == 0 || cnt == 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

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


int main() {
  int k, s, z;
  int combination = 0;
  cin >> k >> s;
  for (int x = 0; x <= k; x++)
    for (int y = 0; y <= k; y++) {
      z = s - x - y;
      if (0 <= z && z <= k)
        combination++;
    }
  cout << combination << endl;
}

Measured memory_bytes: 256
#include<cmath>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cstdio>
#define rep(i,n) for(int i=0;i<n;i++)
#define fori(i,k,n) for(int i=k;i<n;i++)
using namespace std;
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
const int dX[8] = { 0, 1, 1, 1, 0, -1, -1, -1 }, dY[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };



int main()
{
	int n = -1;
	cin >> n;
	while (1)
	{

		vector<int> ten;
		for (int i = 0; i < n; i++)
		{
			int x;
			cin >> x;
			ten.push_back(x);
		}
		sort(ten.begin(), ten.end());
		int poi = 0;
		for (int i = 1; i < ten.size() - 1; i++)
		{
			poi += ten[i];
		}
		cout << poi/(n-2) << endl;
		cin >> n;
		if (n==0)break;
	}
	
	




	return 0;
}

Measured memory_bytes: 1220
primes = (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97)
fct = [0 for p in primes]

def factorize(n):
    result = [0 for p in primes]
    for i, p in enumerate(primes):
        while n % p == 0:
            n = n // p
            result[i] += 1

    return result


def main():
    N = int(input())
    for n in range(1, N+1):
        fct_n = factorize(n)
        for i in range(len(fct_n)):
            fct[i] += fct_n[i]
    c75 = len([f for f in fct if f >= 74])
    c25 = len([f for f in fct if f >= 24])
    c15 = len([f for f in fct if f >= 14])
    c5 = len([f for f in fct if f >= 4])
    c3 = len([f for f in fct if f >= 2])

    result = 0
    result += c75
    result += c25 * (c3 - 1)
    result += c15 * (c5 - 1)
    result += (c5 * (c5 - 1)) // 2 * (c3 - 2)

    print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
t,s,e,w,n,b = [1,2,3,4,5,6]
def north():
    global t,s,e,w,n,b
    t,n,b,s = s,t,n,b
def east():
    global t,s,e,w,n,b
    t,e,b,w = w,t,e,b
def west():
    global t,s,e,w,n,b
    t,w,b,e = e,t,w,b
def south():
    global t,s,e,w,n,b
    t,s,b,n = n,t,s,b
def right():
    global t,s,e,w,n,b
    e,n,w,s = n,w,s,e
def left():
    global t,s,e,w,n,b
    e,s,w,n = s,w,n,e
dic = {"North":north,"East":east,
       "West":west,"South":south,
       "Right":right,"Left":left}
while True:
    N = input()
    if N == 0:
        break
    t,s,e,w,n,b = [1,2,3,4,5,6]
    ans = 1
    for i in xrange(N):
        dic[raw_input().strip()]()
        ans += t
    print ans

Measured memory_bytes: 4284
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

int n,k;
int A[505];

int solve(int a){
    int cost = 0;
    int B[n];
    REP(i,n){
        B[i] = A[i] % a;
    }
    sort(B,B+n);
    int mae = 0 ,usiro = n - 1;
    while(B[mae] ==0) mae ++;
    
    while(mae < usiro){
        cost += B[mae];
        int hoge = B[mae];
        while(hoge> 0){
            int tmp = min( hoge, a - B[usiro]);
            hoge -= tmp;
            B[usiro] += tmp;
            if(B[usiro] == a) usiro --;
        }
        mae ++;
    }

    return cost;
}



signed main(){
    cin >> n >> k;
    int wa = 0;
    REP(i,n){
        cin >> A[i];
        wa += A[i];
    }


    int res = 1;
    int tmp = 1;
    while(tmp * tmp <= wa){
        if(wa % tmp ==0){
            if(solve(tmp) <= k){
                res = max(tmp,res);
            }
            if(solve(wa / tmp) <= k){
                res = max(wa / tmp,res);
            }
        }
        tmp ++;
    }
    cout << res << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    int h,w,k,cnt=0;
    cin>>h>>w>>k;
    char c[h][w],d[h][w];
    rep(i,h){
        rep(j,w){
            cin>>c[i][j];
        }
    }

    for(int bit=0;bit<(1<<h+w);++bit){
        rep(a,h){
            rep(b,w){
                d[a][b]=c[a][b];
            }
        }
        for(int i=0;i<(h+w);++i){
            if(bit&(1<<i)){
                if(i<h){
                    rep(x,w){
                        d[i][x]='1';
                    }
                }
                else{
                    rep(y,h){
                        d[y][i-h]='1';
                    }
                }
            }
        }
        int b_cnt=0;
        rep(a,h){
            rep(b,w){
                if(d[a][b]=='#')b_cnt++;
            }
        }
        if(b_cnt==k){
            cnt++;
        }
    }

    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 3632
N, W = gets.split.map{|i|i.to_i}
v = Array.new(4){[]}
w0 = nil
N.times{|n|
	wn, vn = gets.split.map{|i|i.to_i}
	unless w0
		w0 = wn
	end
	v[wn - w0] << vn
}
v.each{|a|a.sort_by!{|i|-i}}
warn w0
warn v.inspect
max = 0
([W / (w0 + 3), v[3].size].min + 1).times{|i3|
	w3 = W - (w0 + 3) * i3
	([w3 / (w0 + 2), v[2].size].min + 1).times{|i2|
		w2 = w3 - (w0 + 2) * i2
		([w2 / (w0 + 1), v[1].size].min + 1).times{|i1|
			w1 = w2 - (w0 + 1) * i1
			i0 = [w1 / w0, v[0].size].min
			a0 = v[0][0, i0]
			s = 0
			s += v[3][0, i3].inject(0, :+)
			s += v[2][0, i2].inject(0, :+)
			s += v[1][0, i1].inject(0, :+)
			s += v[0][0, i0].inject(0, :+)
			if s > max
				max = s
			end
		}
	}
}
puts max


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	cout<<min(min(max(x,y)*c*2,x*2*c+abs(y-x)*b),min(y*2*c+abs(x-y)*a,a*x+b*y));
	return 0;
}


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

int main(){
  int n;
	cin >> n;
	vector<int> v(n);
	r(i,n) cin >>v.at(i);
  int m;
	cin >> m;
	vector<int> v2(m);
	r(i,m) cin >>v2.at(i);
	cout << lexicographical_compare(v.begin(), v.end(), v2.begin(), v2.end())<< endl;
}


Measured memory_bytes: 3116
import numpy as np

N = int(input())
a = np.array(sorted([int(num) - i for i, num in enumerate(input().split())]))

if N % 2 == 0:
    center = center = int(N/2-1) if a[int(N/2-1)] >= a[int(N/2)] else int(N/2)
else:
    center = int((N-1)/2)

a = np.abs(a - a[center])
print(sum(a))

Measured memory_bytes: 34212
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)	
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long
#define pb(a) push_back(a)
const ll INF = 0x3f3f3f3f;
const ll inf = pow(10,18);
ll modulo = pow(10,9)+7  ;
#define ld long double
#define MAX (int)(pow(10,5)+ 10)

 
void deal(){
	ll n , k;
	cin>>n>>k;
	vector<ll> arr(n);
	fori(n)
		cin>>arr[i];
	vector<ll> dp(n);
	dp[0] = 0;
	for(ll i =1; i<n; i++){
		dp[i] = inf;
		for(ll j=max((ll)0, i-k); j<i; j++)
			dp[i] = min(dp[j] + (ll)fabs(arr[j]- arr[i]), dp[i]);
	}
	cout<<dp[n-1];
}
 
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}
 
/*
 
5 1
1 2 3 4 5


*/

Measured memory_bytes: 1792
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll n,k; cin >>n>>k;
  vector<vector<ll>> v(n,vector<ll>(2));
  ll count=0;
  rep(i,n){
    ll a,b; cin >>a>>b;
    v[i][0]=a;
    v[i][1]=b;
  }
  sort(all(v));
  rep(i,n){
    count+=v[i][1];
    if(count>=k) {
      cout<< v[i][0]<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 5760
import math
mod = 10 ** 9 + 7

def f(num):

    i = 2
    d = dict()

    while i * i <= num:
        if num % i == 0:
            num //= i
            d[i] = d.get(i, 0) + 1
        else:
            i += 1
    
    
    d[num] = d.get(num, 0) + 1

    return d

n = int(input())

ans = []
for k, v in f(n).items():
    for _ in range(v):
        ans.append(k)

print(str(n)+":", *ans)


Measured memory_bytes: 5660
int main(void){

	int a,b,c,t=0;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b){
		t=a;
		a=b;
		b=t;
	}if(b>c){
		t=b;
		b=c;
		c=t;
	}if(a>b){
		t=a;
		a=b;
		b=t;
	}
	printf("%d %d %d\n",a,b,c);
return 0;
}



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

#define F first
#define S second
#define pii pair<int, int>
#define pb push_back

using namespace std;

typedef long long ll;

const int N = 5e5 + 10, mod = 7 * 17 * (1 << 23) + 1;

int fact[N], rev[N];

int power(int a, int b)
{
	if(b == 0)return 1;
	ll res = power(a, b/2);
	res *= res, res %= mod;
	if(b & 1) res *= a, res %= mod;
	return res;
}

int comb(int n, int k)
{
	if(k > n || k < 0)return 0;
	ll res = fact[n];
	res *= rev[k], res %= mod;
	res *= rev[n - k], res %= mod;
	return res;
}


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, k; cin >> n >> k;

	fact[0] = 1;
	for(int i=1; i<N; i++)
		fact[i] = (1LL * fact[i - 1] * i) % mod;

	rev[N - 1] = power(fact[N - 1], mod - 2);
	for(int i=N-2; i>=0; i--)
		rev[i] = (1LL * rev[i + 1] * (i + 1)) % mod;

	ll ans = 0;
	
	/*
	if(n == 1)
	{
		int ans = 1;
		for(int i=0; i<k-1; i++)
			ans = (ans * 2) % mod;
		cout << ans << endl;
		return 0;
	}*/


	if(n > k)return cout << 0 << endl, 0;

	for(int R=0; R<=k; R++)
	{
		int B = k - R;
		if(R < B)continue;
		if(R - B >= n)
			ans += comb(k, R), ans %= mod;
		else 
		{
			int t = R - B;
			t = n - t;
			if(B < t)continue;
			if(t != n)
			{
				ans += comb(k, R); ans %= mod;
				ans += mod - comb(k, t - 1);
				ans %= mod;
			}else
			{
				ans += comb(k - 1, R);
				ans += mod - comb(k - 1, t - 2);
				ans %= mod;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 4224
#include <functional>
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <cctype>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <stdio.h>
#include <stack>
#include <ctime>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define TR(i,x) for(__typeof(x.begin()) i=x.begin();i!=x.end();i++)
#define ALL(x) x.begin(),x.end()
#define SORT(x) sort(ALL(x))
#define CLEAR(x) memset(x,0,sizeof(x))
#define FILL(x,c) memset(x,c,sizeof(x))
#define PB push_back
#define MP make_pair

using namespace std;

const double eps = 1e-8;

typedef map<int,int> MII;
typedef map<string,int> MSI;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long double> VD;
typedef pair<int,int> PII;
typedef long long int64;
typedef long long LL;
typedef unsigned int UI;
typedef long double LD;

unordered_map<LL, LL> m;

LL helper(LL x) {
    if (m.find(x) != m.end()) return m[x];
    if (x == 1) return 1;
    return m[x] = 1 + helper(floor(x / 2)) + helper(floor(x / 2));
}

int main() {
    LL h, a = 0;
    cin >> h;

    a = helper(h);

    cout << a << endl;
    return 0;
}



Measured memory_bytes: 256
# author:  Taichicchi
# created: 19.09.2020 00:14:21

import sys

N = int(input())

S = input()

ans = S.count("R") * S.count("G") * S.count("B")


for i in range(N - 2):
    for j in range(i + 1, N - 1):
        try:
            k = 2 * j - i
            if (S[i] != S[j]) & (S[j] != S[k]) & (S[k] != S[i]):
                ans -= 1
        except:
            continue

print(ans)


Measured memory_bytes: 68304
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

map<int, char> m;

int32_t main()
{
	IOS;
	int n, mm;
	cin>>n>>mm;
	string a, b;
	cin>>a>>b;
	int l=__gcd(n, mm);
	l=n*mm/l;
	for(int i=0;i<=n-1;i++)
	{
		int idx=(i * (l/n) + 1);
		m[idx]=a[i];
	}
	for(int i=0;i<=mm-1;i++)
	{
		int idx=(i * (l/mm) + 1);
		if(m.find(idx)!=m.end() && m[idx]!=b[i])
		{
			cout<<"-1";
			return 0;
		}
	}
	cout<<l;
	return 0;
}

Measured memory_bytes: 6144
#include<iostream>
#include<cstdio>
#define neko 200010
#define chkmax(a,b) ((a)>(b)?(a):(b))
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~i))
#define rf(i,a,b) for(register int i=(a);i>=(b);i=~(-i))
int n;
long long ans,c,x[neko],v[neko],pre[neko],nex[neko],preans[neko],nexans[neko],presum[neko],nexsum[neko];
int main()
{
	scanf("%d%lld",&n,&c);
	f(i,1,n)scanf("%lld%lld",&x[i],&v[i]),presum[i]=presum[i-1]+v[i];
	rf(i,n,1)nexsum[i]=nexsum[i+1]+v[i];x[n+1]=c;
	preans[1]=v[1]-x[1],pre[1]=1; 
	f(i,2,n)
	{	
//		printf("%lld %lld %lld %lld %lld\n",preans[i-1],pre[i-1],x[i]-x[pre[i-1]],presum[i],presum[pre[i-1]]);
		if(preans[i-1]>preans[i-1]-(x[i]-x[pre[i-1]])+(presum[i]-presum[pre[i-1]]))preans[i]=preans[i-1],pre[i]=pre[i-1];
		else preans[i]=preans[i-1]-(x[i]-x[pre[i-1]])+(presum[i]-presum[pre[i-1]]),pre[i]=i;
	}
	nexans[n]=-(c-x[n])+v[n],nex[n]=n;
	rf(i,n-1,1)
	{
		if(nexans[i+1]>nexans[i+1]-(x[nex[i+1]]-x[i])+(nexsum[i]-nexsum[nex[i+1]]))nexans[i]=nexans[i+1],nex[i]=nex[i+1];
		else nexans[i]=nexans[i+1]-(x[nex[i+1]]-x[i])+(nexsum[i]-nexsum[nex[i+1]]),nex[i]=i;
	}ans=chkmax(ans,chkmax(preans[n],nexans[1]));
//	f(i,1,n)printf("%lld %lld %lld %lld\n",preans[i],nexans[i],nex[i],pre[i]);
	f(i,1,n)
	{
		ans=chkmax(ans,chkmax(preans[i]+nexans[i+1]-x[i],nexans[i]+preans[i-1]-(c-x[i])));
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 11776
#include <stdio.h>
#include<math.h>
using namespace std;

int main(){

	int count[101],tmp,max=-1;
	for(int i=0;i < 101;i++)count[i] = 0;

	while(scanf("%d",&tmp)!=EOF){
		count[tmp]++;
		max = (max >= count[tmp])?max:count[tmp];
	}

	for(int i=0;i<101;i++){
		if(count[i] == max)printf("%d\n",i);
	}
    return 0;
}

Measured memory_bytes: 2592
#include<iostream>
#include<cmath>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<cstdlib>
using namespace std;

int main(){
    stack<int> s;
    int a, b;
    string str;
    
    while(cin>>str){
        if(str=="+"){
            a=s.top(); s.pop();
            b=s.top(); s.pop();
            s.push(a+b);
        }else if(str=="-"){
            a=s.top(); s.pop();
            b=s.top(); s.pop();
            s.push(b-a);
        }else if(str=="*"){
            a=s.top(); s.pop();
            b=s.top(); s.pop();
            s.push(a*b);
        }else s.push(atoi(str.c_str()));
    }
    cout<<s.top()<<endl;
}



Measured memory_bytes: 3196
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<int, int> qii;
typedef pair<int, int> pii;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repz(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


int main() {
	int a, b;
	cin >> a >> b;
	int c = b - a;

	vi memo(1200, 0);
	for (int i = 1; i <= c; ++i) {
		memo[i] += i + memo[i-1];
	}
	//cout << c << endl;
	//cout << memo[c] << endl;
	cout << memo[c] - b << endl;
	
	
	system("pause");
	return 0;
}

Measured memory_bytes: 504
import Foundation

private func readWords<T>(_ f: (Substring) -> T) -> [T] {
    return readLine()!.split(separator: " ").map(f)
}

prefix operator *
private prefix func *<T>(a: inout IndexingIterator<[T]>) -> T {
    return a.next()!
}

func mainA() {
    let a  = Int(readLine()!)!
    print(a + a*a + a*a*a)
}

mainA()


Measured memory_bytes: 13144
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

answer = 1
answer_t = T - H[0] * 0.006

for i in range(1, N):
    t = T - H[i] * 0.006
    if abs(A - answer_t) > abs(A - t):
        answer = i + 1
        answer_t = t
print(answer)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
using namespace std;
int N;
void fill4(int K,vector<string>&ans)
{
	ans[K][K]='a';
	ans[K][K+1]='a';
	ans[K+1][K]='b';
	ans[K+1][K+1]='b';
	ans[K+2][K+2]='a';
	ans[K+2][K+3]='a';
	ans[K+3][K+2]='b';
	ans[K+3][K+3]='b';
	ans[K][K+2]='c';
	ans[K+1][K+2]='c';
	ans[K][K+3]='d';
	ans[K+1][K+3]='d';
	ans[K+2][K]='c';
	ans[K+3][K]='c';
	ans[K+2][K+1]='d';
	ans[K+3][K+1]='d';
}
void fill5(int K,vector<string>&ans)
{
	ans[K][K]='a';
	ans[K+1][K]='a';
	ans[K][K+1]='b';
	ans[K+1][K+1]='b';
	ans[K][K+2]='c';
	ans[K+1][K+2]='c';
	ans[K+2][K+3]='a';
	ans[K+2][K+4]='a';
	ans[K+3][K+3]='b';
	ans[K+3][K+4]='b';
	ans[K+4][K+3]='c';
	ans[K+4][K+4]='c';
	ans[K+2][K]='d';
	ans[K+3][K]='d';
	ans[K+2][K+1]='e';
	ans[K+2][K+2]='e';
	ans[K+3][K+2]='f';
	ans[K+4][K+2]='f';
	ans[K+4][K+1]='g';
	ans[K+4][K]='g';
}
main()
{
	cin>>N;
	vector<string>ans(N,string(N,'.'));
	if(N==2)
	{
		cout<<-1<<endl;
		return 0;
	}
	if(N%3==0)
	{
		for(int i=0;i<N;i+=3)
		{
			ans[i][i]='a';
			ans[i][i+1]='a';
			ans[i+1][i+2]='a';
			ans[i+2][i+2]='a';
		}
	}
	else if(N==7||N==11)
	{
		ans[0][0]='a';
		ans[1][0]='a';
		ans[1][1]='b';
		ans[2][1]='b';
		ans[2][2]='c';
		ans[3][2]='c';
		ans[3][0]='a';
		ans[4][0]='a';
		ans[4][1]='b';
		ans[5][1]='b';
		ans[5][2]='c';
		ans[6][2]='c';
		ans[6][0]='d';
		ans[6][1]='d';
		ans[0][2]='d';
		ans[0][3]='d';
		ans[0][4]='e';
		ans[1][4]='e';
		ans[2][3]='f';
		ans[2][4]='f';
		ans[3][3]='g';
		ans[3][4]='g';
		ans[4][5]='e';
		ans[4][6]='e';
		ans[5][5]='f';
		ans[5][6]='f';
		ans[6][5]='g';
		ans[6][6]='g';
		if(N==11)fill4(7,ans);
	}
	else
	{
		int start;
		if(N%9==1)
		{
			if(N==1)return 1;
			fill5(0,ans);
			fill5(5,ans);
			start=10;
		}
		else if(N%9==2)
		{
			if(N==2||N==11)return 1;
			fill4(0,ans);
			fill4(4,ans);
			fill4(8,ans);
			fill4(12,ans);
			fill4(16,ans);
			start=20;
		}
		else if(N%9==4)
		{
			fill4(0,ans);
			start=4;
		}
		else if(N%9==5)
		{
			fill5(0,ans);
			start=5;
		}
		else if(N%9==7)
		{
			if(N==7)return 1;
			fill4(0,ans);
			fill4(4,ans);
			fill4(8,ans);
			fill4(12,ans);
			start=16;
		}
		else if(N%9==8)
		{
			fill4(0,ans);
			fill4(4,ans);
			start=8;
		}
		for(int i=start;i<N;i+=9)
		{
			fill4(i,ans);
			fill5(i+4,ans);
		}
	}
	for(int i=0;i<N;i++)cout<<ans[i]<<endl;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9 + 7;
const int INT_MOD=1e9+7;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 0; i <= n; i++)
#define rrep(i,n) for(int i=n;i>0;i--)
#define RREP(i,n) for(int i=n;i>=0;i--)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
signed main(){
    int n;cin>>n;
    int d[n]={},maxd=0;
    rep(i,n) {
        cin>>d[i];
        maxd=max(maxd,d[i]);
    }
    int ans[maxd*maxd+5]={};
    rep(i,n)for(int j=i+1;j<n;j++){
        ans[d[i]*d[j]]++;
    }
    int ret=0;
    rep(i,maxd*maxd+5){
        if(ans[i]>0) ret+=i*ans[i];
    }
    cout<<ret<<endl;
    return 0;
}

Measured memory_bytes: 256
def count(lst):
    count = 0
    for i in lst:
        for j in i:
            if j == "#": count += 1
    return count

def main(n, m, k, lst):
    ways = 0
    for i in range(2**(n+m)):
        binS = "0" * ((n+m) - len(str(bin(i))[2:])) + str(bin(i))[2:]
        lst1 = lst.copy()
        ind, ind1 = 0, 0
        for j in range(len(binS)):
            if binS[j] == "1":
                if j+1 <= m:
                    for r in range(len(lst1)):
                        lst1[r] = lst1[r][:j-ind] + lst1[r][j+1-ind:]
                    ind += 1
                else:
                    c = j - m - ind1
                    lst1 = lst1[:c] + lst1[c+1:]
                    ind1 += 1
        if count(lst1) == k:
            ways += 1
    return ways

lst = []
n, m, k = [int(x) for x in input().split()]
for _ in range(n):
    s = input()
    lst.append(s)
print(main(n, m, k, lst))


Measured memory_bytes: 9260
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;

int main(){
    while(1){
        string s;
        cin>>s;
        if(s=="0") return 0;
        int n=s.size();
        int a=count(s.begin()+1,s.end(),'A');
        int b=n-a-1;
        if(a>b) ++a;
        else ++b;
        cout<<a<<' '<<b<<endl;
    }
    return 0;
}


Measured memory_bytes: 3208
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<double>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  cin >> n ;
  string s;
  vi x(n);
  double ans=0.0;
  REP(i,n){
	  cin>>x[i]>>s;
	  if (s=="JPY"){
		  	ans+=x[i];
	  }else{
			ans+=380000.0*x[i];
	  }
  }

  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Collections;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String A = "Sunny";
    String B = "Cloudy";
    String C = "Rainy";
    if (S.equals(A)) {
      System.out.println(B);
    } else if (S.equals(B)) {
      System.out.println(C);
    } else {
      System.out.println(A);
    }
  }
}


Measured memory_bytes: 21716
#include<iostream>
#include<sstream>
using namespace std;
int main(){
    while (1){

        char num[1002];
        cin >> num ;
        // cout << num[0] << endl;
        if (num[0] == '0'){
            break;
        }else{
            int sums = 0;
            for(int i = 0; num[i] != '\0'; i++){
                int one_num;
                one_num = num[i] - '0';
                sums += one_num;

            }
            cout << sums << endl;

        }


    }
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;
const int INF = 1<<29;

int main()
{
    while (1) {
        int n; cin >> n;
        if (!n) break;
        int t[20][20];
        loop (n, i) loop (n+1, j) cin >> t[i][j];
        int cost[20][100000];
        loop (n+1, i) loop (2<<n, j) cost[i][j] = INF;
        loop (n, i) cost[1][1<<i] = t[i][0];
        loop (n+1, i) {
            loop (1<<n, j) {
                if (__builtin_popcount(j) != i) continue;
                loop (n, k) if (j>>k&1) {
                    int c = t[k][0];
                    loop (n, l) if (j>>l&1 && l != k) {
                        c = min(c, t[k][l+1]);
                    }
                    cost[i][j] = min(cost[i][j], cost[i-1][j^(1<<k)] + c);
                }
            }
        }
        cout << cost[n][(1<<n)-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 8488
S = input()
reverse = 0
front = []
end = []
n = int(input())
for _ in range(n):
  List = list(input().split())
  if List[0] == '1':
    reverse += 1
  else:
    if List[1] == '1':
      if reverse % 2 == 1:
        end.append(List[2])
      else:
        front.append(List[2])
    else:
      if reverse % 2 == 1:
        front.append(List[2])
      else:
        end.append(List[2])
if reverse %2 == 1:
  S = S[::-1]
  front, end = end, front
Answer = ''.join(front[::-1]) + S + ''.join(end)
print(Answer)

Measured memory_bytes: 6252
using System;

namespace AOJ.ITP
{
    public class SimpleCalculator
    {
        public static void Main()
        {
            while (true)
            {
                var input = Console.ReadLine().Split(' ');
                int a = int.Parse(input[0]);
                int b = int.Parse(input[2]);
                string op = input[1];
                if (op == "?") { break; }

                int ans = 0;
                switch (op)
                {
                    case "+":
                        ans = a + b;
                        break;
                    case "-":
                        ans = a - b;
                        break;
                    case "*":
                        ans = a * b;
                        break;
                    case "/":
                        ans = (int)Math.Floor((decimal)a / b);
                        break;
                }
                Console.WriteLine(ans);
            }
        }
    }
}

Measured memory_bytes: 5744
def fizzbuzz_sum(n):
    if n % 3 == 0 and n % 5 == 0:
        return 0
    elif n % 3 == 0:
        return 0
    elif n % 5 == 0:
        return 0
    else:
        return n


if __name__ == '__main__':
    n = int(input())
    sum = 0

    for i in range(1, n+1):
        sum += fizzbuzz_sum(i)

    print(sum)

Measured memory_bytes: 9180
import std.stdio;
import std.conv;
import std.array;
import std.algorithm;

struct Item {
    int w;
    int v;
}

void main()
{
    auto buf = readln.split;
    int N = buf[0].to!int;
    int W = buf[1].to!int;
    Item[] items = new Item[N];
    foreach (i; 0..N){
        buf = readln.split;
        items[i].w = buf[0].to!int;
        items[i].v = buf[1].to!int;
    }

    long[] sum_v = new long[W + 1];
    foreach (i; 0..N){
        int v = items[i].v;
        int w = items[i].w;
        for (uint j = W; j > 0; j--){
            if (j < items[i].w) break;
            
            long sum_i = sum_v[j - w] + v;
            if (sum_i > sum_v[j]) sum_v[j] = sum_i;
        }
    }

    writeln(sum_v[W]);
}



Measured memory_bytes: 3068
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		int N = S.Length;
		int min1 = N;
		for(int i=0;i<N;i++){
			if(S[i] == '0') continue;
			min1 = Math.Min(min1,Math.Max(i, N - i - 1));
		}
		int min0 = N;
		for(int i=0;i<N;i++){
			if(S[i] == '1') continue;
			min0 = Math.Min(min0,Math.Max(i, N - i - 1));
		}
		Console.WriteLine(Math.Max(min1,min0));
		
		
	}
	String S;
	public Sol(){
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13116
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void) {
    char* str = calloc(13,sizeof(char));
    char t[14];
    scanf("%s",str);
    strncpy( t, str, 4 ); //strの先頭+3の位置から5文字をtにコピー
    t[4] = ' ';
    strncpy(t+5,str+4,8);
	t[13]='\0';
    printf( "%s\n", t );
	return 0;
}

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

void solve()
{
	ll l,r,d;
	cin>>l>>r>>d;
	l = ((l+d-1)/d)*d;
	cout<<(r-l+d)/d<<endl;
}

int main()
{
	ll t = 1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  string S;
  cin >> S;
  int N = S.size();
  int start,end;
  rep(i,N)
  {
    if(S[i]=='A')
    {
      start = i+1;
      break;
    }
  }
  for(int i=N-1;i>-1;i--)
  {
    if(S[i]=='Z')
    {
      end = i+1;
      break;
    }
  }
  cout << end - start + 1 << endl;
  return 0;
}


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

int main()
{
	int n,i;
	double x1,y1,x2,y2,x3,y3;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);

		double a1 = 2*(x2 - x1);
		double b1 = 2*(y2 - y1);
		double c1 = x1*x1 - x2*x2 + y1*y1 - y2*y2;

		double a2 = 2*(x3 -x1);
		double b2 = 2*(y3 - y1);
		double c2 = x1*x1 - x3*x3 + y1*y1 - y3*y3;

		double x = (b1*c2 - b2*c1) / (a1*b2 - a2*b1);
		double y = (c1*a2 - c2*a1) / (a1*b2 - a2*b1);

		double r_2 = (x1 - x)*(x1 - x) + (y1 - y)*(y1 - y);
		double r = sqrt(r_2);

		printf("%.3lf %.3lf %.3lf\n",x,y,r);
	}
	return 0;
}

Measured memory_bytes: 664
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int k = sc.nextInt();
    int sum;

    if (a<=k) {
      if (b<=k-a) {
        c = k-a-b;
        sum = a-c;
      } else {
        sum = a;
      }
    } else {
      sum = k;
    }

	System.out.println(sum);
  }
}


Measured memory_bytes: 27076
#include <stdio.h>
#include <string.h>

int main()
{
    char str[100000];
    int a, b, i;
    scanf("%d", &a);
    scanf("%s", str);

    b = strlen(str);

    if (b <= a)
        printf("%s", str);
    if (b > a)
    {
        for (i = 0; i < a; i++)
        {
            printf("%c", str[i]);
        }
        printf("...");
    }
}


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

int main(){
  int ans = 0;
  int N,M,C;
  cin>>N>>M>>C;
  int *B;
  B = new int[M];
  int A;

  for(int i = 0;i < M;i++){cin>>B[i];}
  for(int i = 0;i < N;i++){
    int tmp = C;
    for(int j = 0;j < M;j++){
      cin>>A;
      tmp += A * B[j];
    }
    if(tmp >0)ans++;
  }
cout<<ans;
  return 0;
}

Measured memory_bytes: 256