akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define mod2 998244353
#pragma GCC optimize("-O2")
#define mod3 127
#define mod 1000000007
#define MAXN 1000000000
#define v32 vector<int>
#define v64 vector<lli>
#define v1024 vector<vector<int>>
#define v4096 vector<vector<lli>>
#define vt vector
#define f(x, y, z) for (lli x = y; x < z; x++)
#define fd(x, y, z) for (lli x = y; x > z; x--)
#define lb lower_bound
#define ld long double
#define m64 map<lli, lli>
#define m32 map<int, int>
#define m64it map<lli, lli>::iterator
#define m32it map<int, int>::iterator
#define fastio                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define ist insert
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define p_q priority_queue
#define min_p_q priority_queue<int, vt<int>, greater<int>>
using namespace std;
using namespace __gnu_pbds;
lli tmod(lli x, lli y)
{
    return (x % y + y) % y;
}
template <typename T>
void DEBUG_ARR(vt<T> a)
{
    f(i, 0, a.size()) cout << a[i] << " ";
    cout << "\n";
}
lli power(lli x, lli y) 
{
    lli res = 1;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x); 
        y = y>>1; 
        x = (x*x);
    }
    return res; 
}


int main()
{
    fastio;
    lli n,m;cin>>n>>m;
    lli a[n];f(i,0,n)cin>>a[i];
    lli b[n];
    memset(b,0,sizeof b);
    f(i,0,n){
        while(a[i]%2==0){
            b[i]++;
            a[i]/=2;
        }
    }
    if(*min_element(b,b+n)!=*max_element(b,b+n)){
        cout<<0<<"\n";
        return 0;
    }
    m=m/(1<<(b[0]-1));
    lli val=1;
    f(i,0,n){
       val=(val*a[i])/__gcd(val,a[i]);
       if(val>MAXN){
           cout<<0;
           return 0;
       }     
    }
    m/=val;
    lli ans=m;
    if(m%2==0){
        ans=m/2;
    }
    else ans=m/2+1;
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int n;cin>>n;
    int tmp,result=0;
    REP(i,n){
        cin>>tmp;
        result+=tmp-1;
    }
    cout<<result<<endl;
    return 0;
}


Measured memory_bytes: 888
n=gets.to_i
a=gets.split.map(&:to_i)

cnt = {}
a.each do |v|
  cnt[v] ||= 0
  cnt[v] += 1
end

r = 0
cnt.each do |k, c|
  if c >= k
    r += c - k
  else
    r += c
  end
end
p r


Measured memory_bytes: 14468
h = int(input())
w = int(input())
n = int(input())
if h>w:
    if n%h==0:
        ans = n//h
    else:
        ans = n//h + 1
else:
    if n%w==0:
        ans = n//w
    else:
        ans = n//w + 1
print(ans)

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;
typedef pair<int,int> pii;
ll gcd(ll a,ll b){
  if (a%b==0) return(b);
  else return(gcd(b,a%b));
}
ll lcm(ll a,ll b){
  return a*b/gcd(a,b);
}

int main(){
  int N;
  cin >> N;
  int p[N];
  rep(i,N) cin >> p[i];
  int ans=0;
  rep(i,N-2){
    if(p[i]<p[i+1] and p[i+1]<p[i+2]) ans++;
    if(p[i]>p[i+1] and p[i+1]>p[i+2]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    ll A[4],N,sum = 0;
    ll arr[] = {1,2,4,8};
    cin >> A[0] >> A[1] >> A[2] >> A[3] >> N;
    for(int i = 0;i < 4;i++)A[i] *= 4;
    N *= 4;
    for(int i = 1;i < 4;i++){
        A[i] = min(A[i-1]*2,A[i]);
    }
    for(int i = 3;i >= 0;i--){
        if(N)sum += A[i] * (N / arr[i]);
        N -= N / arr[i] * arr[i] ;
    }
    cout << sum/4 << endl;
}

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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int l = a + b;
  int r = c + d;
  if (l > r) {
    cout << "Left" << endl;
  } else if (l < r) {
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
a,b=map(int,input().split())
s=input()
lst=["1","2","3","4","5","6","7","8","9","0"]
if len(s)==a+b+1:
    if s[a]=="-":
        switch=1
        for i in range(a+b+1):
            if i!=a:
                if not s[i] in lst:
                    switch=0
                    break
        if switch==1:
            print("Yes")
            exit()
        
print("No")

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

int main(){
    int n;
    cin >> n;

    vector<int> a(n);
    vector<vector<int>> div(n);
    for(int k=0; k<n; k++){
        cin >> a[k];
        for (int i=1; i*i<=a[k]; i++){
            if (a[k] % i == 0){
                div[k].push_back(i);

                int j = a[k] / i;// counterpart
                if (j != i) div[k].push_back(j);
            }
        }
        sort(div[k].begin(), div[k].end());
    }
    sort(a.begin(), a.end());

    int ans = 0;
    for(int i=0; i<n; i++){
        bool flag = true;
        for(int d : div[i]){
            int num = upper_bound(a.begin(), a.end(), d) - lower_bound(a.begin(), a.end(), d);
            if(d == div[i][div[i].size()-1]){
                if(num >= 2) flag = false;
            }
            else if(num >= 1) flag = false;
            //cout << d << " " << num << endl;
        }
        //cout << endl;
        if(flag == true) ans += 1;
    }
    cout << ans << endl;
    return 0;
}

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

#define lli long long int
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define INF 1000000007
#define endl "\n"

lli a,b;
string s,t,u;

int main(){
	cin>>s>>t>>a>>b>>u;
	if(u==s){
		cout<<a-1<<" "<<b;
	}
	else{
		cout<<a<<" "<<b-1;
	}
	//system("pause");
}

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

int N;
int M;
int Q;
int a[100], b[100], c[100], d[100];
int ans = 0;

void dfs(deque<int> now) {
    if (now.size()==N) {
        int ans_cand = 0;
        rep(i, Q) {
            if (now[b[i]-1]-now[a[i]-1]==c[i]) ans_cand += d[i];
        }
        ans = max(ans, ans_cand);
        return;
    }
    
    int la = now.back();
    for (int i=la; i<=M; i++) {
        now.push_back(i);
        dfs(now);
        now.pop_back();
    }
}

signed main() {
    cin >> N >> M >> Q;
    rep(i, Q) cin >> a[i] >> b[i] >> c[i] >> d[i];
    deque<int> now;
    now.push_back(1);
    dfs(now);
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define mod 998244353
using namespace std;
map<string,int> F,G,H;
string s;
int f(string);
int g(string);
int h(string);
int dp(string);

int main(){
	cin>>s;
	cout<<dp(s)<<endl;

	return 0;
}

int f(string s){
	if(F[s]) return F[s];
	int res=0,len=s.size();
	int r=s[0]-'0'+1;
	for(int i=1;i<len;i++){
		(res+=1ll*r*(g(s.substr(i))+h(s.substr(i)))%mod)%=mod;
		if(s[i]=='1') r=2*r%mod;
	}
	(res+=r)%=mod;
	return F[s]=res;
}

int g(string s){
	if(G[s]) return G[s];
	int res=0,len=s.size();
	if(len==1) return 0;
	for(int i=1;i<len;i++) (res+=1ll*h(s.substr(0,i))*dp(s.substr(i))%mod)%=mod;
	return G[s]=res;
}

int h(string s){
	if(H[s]) return H[s];
	int res=0,len=s.size();
	if(len==1) return 0;
	for(int i=1;i<len;i++){
		if(len%i==0){
			string t;t.empty();
			for(int j=1;j<=i;j++){
				int flag=1;
				for(int k=0;k<len/i;k++) if(s[k*i+j-1]=='0') flag=0;
				if(flag) t+='1';else t+='0';
			}
			(res+=dp(t))%=mod;
		}
	}
	return H[s]=res;
}

int dp(string s){
	int res=0;
	(res+=f(s))%=mod;
	(res+=g(s))%=mod;
	(res+=h(s))%=mod;
	return res;
}

Measured memory_bytes: 16512
#include<iostream>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main()
{
    // 文字列の入力
    string s;
    cin >> s;

    // 出力
  	rep(i,s.size()){
      if(i % 2 == 0){
        if(s.at(i) == 'L'){
          cout << "No" << endl;
          return 0;
        }
      }
	  else if(i % 2 == 1){
        if(s.at(i) == 'R'){
          cout << "No" << endl;
          return 0;
        }
      }
    }
   cout << "Yes" << endl;

    return 0;
}

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

namespace Aizu
{
    class Program
    {
        static void Main(string[] args)
        {
            var firstLine = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray();
            var n = firstLine[0];
            var m = firstLine[1];
            var coins = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray();

            var numbers = new int[m + 1, n + 1];

            for (var i = 0; i <= m; i++)
            {
                for(var j = 0; j <= n; j++)
                {
                    if (j == 0)
                    {
                        numbers[i, j] = 0;
                    }
                    else
                    {
                        numbers[i, j] = int.MaxValue - 2;
                    }
                }
            }

            for (var i = 1; i <= m; i++)
            {
                for (var j = 1; j <= n; j++)
                {
                    if (j  >= coins[i - 1])
                    {
                        numbers[i, j] = Math.Min(numbers[i - 1, j], numbers[i, j - coins[i - 1]] + 1);
                    }
                    else
                    {
                        numbers[i, j] = numbers[i - 1, j];
                    }
                }
            }

            Console.WriteLine(numbers[m, n]);
        }
    }
}



Measured memory_bytes: 21996
#include <bits/stdc++.h>
using namespace std;
int max(int a,int b,int c){
  int t=a;
  if(t<b){
    t=b;
  }
  if(t<c){
    t=c;
  }
  return t;
}

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

  
    

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

int main() {
	while (1) {
		int a, b;
		cin >> a >> b;
		if (a + b == 0)
			break;
		if (a <= b)
			cout << a << " " << b << endl;
		else
			cout << b << " " << a << endl;
	}
}



Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans = 0;
ll dp[100100][13]={};
int main()
{
string s;
cin >> s;
int len=(int)(s.length());
dp[0][0]=1;
ll jyu=1;
rep(i,len){
    if(s[len-1-i]=='?'){
        rep(k,10){
            ll num=k;
            rep(j,13){
                ll p=num*jyu+j;
                p%=13;
                dp[i+1][p]+=dp[i][j];
                dp[i+1][p]%=mo;
        }
        }
    }
    else{
        rep(j,13){
            ll num=s[len-1-i]-'0';
            ll p=num*jyu+j;
            p%=13;
            dp[i+1][p]+=dp[i][j];
            dp[i+1][p]%=mo;
        }
    }
    jyu*=10;
    jyu%=13;
}

cout << dp[len][5] << endl;
return 0;
}


Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

int main() {
    int n, m;
    while (cin >> n >> m) {
        vector<int> liked(m);
        rep(i, n) {
            int k;
            cin >> k;
            rep(j, k) {
                int x;
                cin >> x;
                ++liked[x-1];
            }
        }
        cout << count(all(liked), n) << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl;

typedef long long ll;
const ll INF = 99999999999999;
const ll MOD = 1000000007;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll number1, ll number2)
{
    return number1 * number2 / gcd(number1, number2);
}
template <class T>
bool contain(const std::string &s, const T &v)
{
    // contain(to_string(N), '3')
    return s.find(v) != std::string::npos;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
        return c - '0';
    return 0;
}
using namespace std;

void transpose(vector<vector<char>> &b)
{
    if (b.size() == 0)
        return;

    vector<vector<char>> trans_vec(b[0].size(), vector<char>());

    for (int i = 0; i < b.size(); i++)
    {
        for (int j = 0; j < b[i].size(); j++)
        {
            trans_vec[j].push_back(b[i][j]);
        }
    }

    b = trans_vec; // <--- reassign here
}
int main()
{

    ll n, k, ans = 0;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];

    rep(i, n)
    {
        if (h[i] >= k)
        {
            ans++;
        }
    }

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

Measured memory_bytes: 1024
import java.io.InputStream;
import java.io.PrintStream;
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) throws Exception {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    // Your code here!
    Scanner scan = new Scanner(is);
    long A = scan.nextLong();
    Double B = scan.nextDouble();
    BigDecimal BB = new BigDecimal(B.toString());
    BigDecimal BD = BB.multiply(new BigDecimal(A));

    os.println(BD.longValue());
  }
}


Measured memory_bytes: 29220
// Red or Not
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>

using namespace std;

int main()
{
    int a;
    string s;
    cin >> a >> s;
    cout << (a >= 3200 ? s : "red");
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>

#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
  int n;
  cin >> n;
  int a = 64;
  for (int i = 0; i < 7; i++) {
    if (a > n) {
      a /= 2;
    } else {
      cout << a << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include<stack>
#include <unordered_map>

using namespace std;

#define MAX(A,B) (A)>(B)?(A):(B)
#define MIN(A,B) (A)<(B)?(A):(B)

int main() {
	int A, B, C;
	int max, min,mid;
	cin >> A;
	max = A;
	min = A;
	cin >> B;
	if (B > max)max = B;
	else if (B < min)min = B;
	cin>>C;
	if (C > max)max = C;
	else if (C < min)min = C;
	mid = A + B + C - max - min;
	cout << max * 10 + mid + min;



	return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;

template<int Size>
struct UF{
	UF(){
		for(int i=0;i<Size;i++){
			rep[i]=i;
			full[i]=false;
		}
	}
	int find(int a){
		while(a!=rep[a]){
			a=rep[a]=rep[rep[a]];
		}
		return a;
	}

	int rep[Size];
	bool full[Size];
	bool uni(int a,int b){
		a=find(a);
		b=find(b);
		if(a==b){
			return false;
		}
		rep[a]=b;
		full[b]|=full[a];
		return true;
	}
};
const int L=2e5+1;
typedef array<LL, 3> E;
E e[L];
UF<L> uf;
void solve(long long N, long long H, long long W, std::vector<long long> R, std::vector<long long> C, std::vector<long long> A){
	LL ret=0;
	for(int i=0;i<A.size();i++){
		e[i]=E{{A[i],R[i],C[i]+H}};
	}
	sort(e,e+A.size());
	for(int i=A.size()-1;i>=0;i--){
		//cerr << e[i][1] << e[i][2] << endl;
		int r=uf.find(e[i][1]);
		int c=uf.find(e[i][2]);
		if(uf.full[r]&&uf.full[c])continue;
		if(r==c){
			uf.full[r]=true;
			ret+=e[i][0];
		}
		else{
			uf.uni(r,c);
			ret+=e[i][0];
		}
		//cerr << e[i][1] << " " << e[i][2] << endl;
	}
	cout << ret << endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    std::vector<long long> R(N);
    std::vector<long long> C(N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&R[i]);
		R[i]--;
        scanf("%lld",&C[i]);
		C[i]--;
        scanf("%lld",&A[i]);
    }
    solve(N, H, W, std::move(R), std::move(C), std::move(A));
    return 0;
}


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

typedef long long ll;
typedef long double ld;
#define size(a) int((a).size())
#define present(c, x) (c.find(x) != c.end()) 
#define printArray(arr) for (int i = 0; i<size(arr); i++) cout << arr[i] << " ";cout << '\n'
#define printVerdict(verdict) cout << (verdict ? "Yes": "No") << '\n'
#define printDecimal(d) printf("%.9f\n", d)
#define inrange(val, start, end) (val >= start && val <= end)

const ll inf = 0x3f3f3f3f;

template <class T1, class T2, class T3> 
void printTuple(tuple<T1, T2, T3> t) {cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << '\n';}
template <class T1, class T2>
void printPair(pair<T1, T2> p) {cout << p.first << " " << p.second << '\n';}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a,b,c,k; cin >> a >> b >> c >> k;
	bool possible = true;
	while (k > 0 && b <= a) {
		b *= 2;
		k--;
	}
	if (b <= a) possible = false;
	while (possible && k >0 && c <= b) {
		c *= 2;
		k--;
	}
	if (c <= b) possible = false;
	printVerdict(possible);
}



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

long long n, m, t, a[100005], dp[100005];
int main(){
    cin >> n >> m;
    for(int i = 0; i < m; i++){ cin >> t; a[t] = 1; }
    dp[0] = 1;
    for(int i = 1; i <= n; i++){
        if(!a[i]){
            if(i-2 >= 0) dp[i] += dp[i-2];
            dp[i] += dp[i-1];
        }
        dp[i] %= 1000000007LL;
    }
    cout << dp[n];
}


Measured memory_bytes: 1792
#define M 30100
J,T[M],t[M];main(I,i,j,k,L,r){
for(i=2;i<M;i++)if(!T[i])for(j=i*2;j<M;j+=i)T[j]=1;
for(i=2;i<M;i++)if(!T[i])t[J++]=i;
for(;scanf("%d",&L),L;printf("%d\n",r))for(r=I=0;(i=t[I])<L;I++)for(J=I;(j=t[J])<=(k=L-i-j);J++)if(!T[k]&&j-i<k&&k<j+i)r++;
exit(0);}

Measured memory_bytes: 728
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.List

main = do
  BS.getLine
  li <- BS.getLine
  let ans = compute li
  print ans

compute :: BS.ByteString -> Int
compute bs = loop bs 0 0 (BS.length bs - 1)

loop bs cnt i j
  | i >= j = cnt
  | BS.index bs i == 'R' = loop bs cnt (succ i) j
  | BS.index bs j == 'W' = loop bs cnt i (pred j)
  | otherwise = loop bs (succ cnt) (succ i) (pred j)
{-
R赤を全て左に寄せればよい。
Rが極端に少なければ、それを塗り替えて終わることも可能かも。でも同じ手数でぜんぶ左に寄せられるので考える必要なし。
W白が極端に少なければ、同様に。
右の方のRを塗り替えると、1つだけRが助かる。
左に接しているRの列の末尾の次のWと、離れたところのRを入れ替えることで、1つ以上のRが助かる。
Wを塗り替えることでも同様の効果がなくもないが、それは同等なので考える必要がない。
結局、配列の書き換えとか考えなくても、左右からポインタを動かして、好ましくないのが揃ったら入れ替える、を繰り返して、
両方が出会ったらおしまい、でいいのか。
-}


Measured memory_bytes: 4236
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N,M;
int a[105],b[105];
vector<P> g[100100];
vector<P> rev[100100];
bool used[100100];
int d[100100];
bool dfs(int v){
	used[v]=true;
	bool res = true;
	for(int i=0;i<g[v].size();i++){
		int to = g[v][i].fi, cost = g[v][i].sec;
		if(!used[to]){
			d[to]=d[v]+cost;
			res &= dfs(to);
		}else{
			if(d[to]!=d[v]+cost){
				res &= false;
			}
		}
	}
	return res;
}
int main(){
	scanf("%d %d",&N,&M);
	for(int i=0;i<M;i++){
		int L,R,D;
		scanf("%d %d %d",&L,&R,&D);
		L--;R--;
		g[L].pb(P(R,D));
		g[R].pb(P(L,-D));
	}
	bool ans = true;
	for(int i=0;i<N;i++){
		if(!used[i]){
			ans &= dfs(i);
			if(!ans)break;
		}
	}
	if(ans)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 14464
N = int(input())
e = [0] * (N + 1)
for i in range(2, N + 1):
    cur = i
    for j in range(2, i + 1):
        while cur % j == 0:
            e[j] += 1
            cur //= j


def num(m):
    return len(list(filter(lambda x: x >= m - 1, e)))


res = (num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1)
       + num(5) * (num(5) - 1) * (num(3) - 2) // 2)
print(res)


Measured memory_bytes: 80356
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int 	     	  long long   // [9,223,372,036,854,775,807 to -9.....808] 19 digits
#define pb                push_back 
#define all(x)            (x).begin(),(x).end()
#define mp                make_pair
#define vi                vector<int> 
#define vpi               vector<pair<int,int>>
#define mii               map<int,int>
#define x                 first
#define y                 second 
#define mem(a,x)          memset(a,x,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define sz(x)             (int)((x).size())

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // find_by_order()  // order_of_key

//const int32_t hellhsh = 444440583533; const double pi=2*acos(0.0); 
const int32_t mod = 1e9+7;
const int32_t maxn=2e5+5;
int inf=1e18;

void solve(){
    int n,x=0,y=0,z=0;cin>>n;
    int a[n];rep(i,0,n) cin>>a[i];
    rep(i,0,n){
        if(a[i]==3) x++;
        if(a[i]==2) y++;
        if(a[i]==1) z++;
    }
    double dp[n+1][n+1][n+1];

    rep(i,0,n+1){
        rep(j,0,n+1){
            rep(k,0,n+1){
                if(i+j+k>n) break;
                if(!i and !j and !k) {
                    dp[i][j][k]=0;
                    continue;
                }
                double tot=1,p0=0;
                if(i){
                    tot+=dp[i-1][j+1][k]*(1.0*i/n);
                }
                if(j){
                    tot+=dp[i][j-1][k+1]*(1.0*j/n);
                }
                if(k){
                    tot+=dp[i][j][k-1]*(1.0*k/n);
                }
                if(n-i-j-k){
                    p0=1.0*(n-i-j-k)/n;
                }
                dp[i][j][k]=tot/(1-p0);
            }
        }
    }

    cout<<fixed<<setprecision(14)<<dp[x][y][z];

}

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int tc=1,k=1;                                                                                                                  
    //cin>>tc;
    while(tc--){
        //cout<<"Case #"<<k++<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 111140
s = input()

s_odd = s[::2]
s_even = s[1::2]

if all(list(map(lambda x: x in ['R', 'U', 'D'], s_odd))) and all(list(map(lambda x: x in ['L', 'U', 'D'], s_even))):
    print("Yes")
else:
    print("No")

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, k, a[1010];
void solve(){
	cin >> n >> k;
	i64 ans = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		ans += min(a[i], k-a[i])*2;
	}
	
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
use std::cmp;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let k: usize = sc.read();
    let mut a: Vec<usize> = sc.read_vec(n);
    a.sort();

    let mut needed = n;
    let mut no_need = 0;
    while needed - no_need > 1 {
        let m = (no_need + needed) / 2;
        if is_needed(&a, k, m) {
            needed = m;
        } else {
            no_need = m;
        }
    }

    if is_needed(&a, k, 0) {
        println!("0");
    } else {
        println!("{}", no_need + 1);
    }
}

fn is_needed(a: &Vec<usize>, k: usize, pos: usize) -> bool {
    if a[pos] >= k {
        return true;
    }

    let mut reachable = vec![false; k + 1];
    reachable[0] = true;
    for i in 0..a.len() {
        if i == pos {
            continue;
        }
        for from in (0..reachable.len()).rev() {
            if !reachable[from] {
                continue;
            }
            reachable[cmp::min(from + a[i], k)] = true;
        }
    }

    for i in (k - a[pos])..k {
        if reachable[i] {
            return true;
        }
    }
    return false;
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        (0..n).map(|_| self.read()).collect()
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


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

int main(){
    int64_t W,H,x,y;
    cin>>W>>H>>x>>y;
    double D=(W*H)/2.0;
    int T=0;
    if(W%2==0 && H%2==0){
        if(x==W/2 && y==H/2){
            T=1;
        }
    }
    cout<<D<<' '<<T<<endl;

}


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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N,H,W;
    cin >> N;
    cin >> H;
    cin >> W;
    cout << (N - H + 1) * (N - W + 1) << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main()
{
    char S[3];
    int i;
    int count;

    scanf("%s\n",S);

    count=0;

    for(i=0;i<3;i++){
        if(S[i]=='R'){
            count++;
        }
    }

    if(count==2){
        if(S[1]=='S'){
            count--;
        }
    }

    printf("%d\n",count);

    return 0;
}

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

int main(){
	int a, b;
	
	for(int i = 1; true; i++){
		cin >> a >> b;

		if(a == 0 && b == 0) break;

		if( a < b){
			cout << a << " " << b << endl;
		}else{
			cout << b << " " << a << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>

int n;
int main(){
  while(std::cin >> n, n){
    int sum = 0;
    for(int i = 0; i < n / 4; ++i){
      int tmp;
      std::cin >> tmp;
      sum += tmp;
    }
    std::cout << sum << std::endl;
  }
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n; cin >> n;
    ll ans = 0;

    rep(i,n){
        int l, r; cin >> l >> r;
        ans += r-l+1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

bool isKisuuDigit(int num) {
	int digit = 0;
	while (num != 0) {
		num /= 10;
		digit++;
	}
	if (digit % 2 != 0) return true;
	else return false;
}

int main()
{
	int n; cin >> n;
	int cnt = 0;
	for (int i = 0; i <= n; i++)
	{
		if (isKisuuDigit(i)) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <sstream>
#include <fstream>
#include <cstring>


using namespace std;
#define int long long

int dp[2501][50][50];
int x[10010];
int N, A;

int rec(int sum, int a, int b) // a = 何番目か, b = 何枚選んだか
{
	if (dp[sum][a][b] != -1) return dp[sum][a][b];
	int res = 0;

	for (int i = a; i < N; ++i) {
		res += (sum + x[i]) == A * b;
		res += rec(sum + x[i], i + 1, b + 1);
	}

	return dp[sum][a][b] = res;
}

signed main()
{
	memset(dp, -1, sizeof dp);
	cin >> N >> A;
	for (int i = 0; i < N; ++i) cin >> x[i];

	int sum = rec(0, 0, 1);
	cout << sum << endl;
}

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

int main(){
    string s,t;
    cin>>s>>t;
    bool ans=true;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]){
            ans=false;
            break;
        }
    }
    if(ans){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <unordered_map>
#include <utility>
#include <algorithm>
#define llint long long

using namespace std;

llint n;
string s;
unordered_map<string, llint> mp1, mp2;

void get(string s, unordered_map<string, llint> &mp)
{
	int N = 1 << n;
	string t, u;
	for(int i = 0; i < N; i++){
		t = u = "";
		for(int j = 0; j < n; j++){
			if(i & (1<<j)) t += s[j];
			else u += s[j];
		}
		mp[t+"#"+u]++;
	}
}

int main(void)
{
	cin >> n;
	cin >> s;
	
	get(s.substr(0, n), mp1);
	reverse(s.begin(), s.end());
	get(s.substr(0, n), mp2);
	
	llint ans = 0;
	for(auto it = mp1.begin(); it != mp1.end(); it++){
		ans += it->second * mp2[it->first];
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 86772
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int N;
int A[18], B[18];
unsigned char dp[36][1 << 18];
int keisan(int b, bool n, int k) {
	if (dp[k][b] != 255) return dp[k][b];
	if (b == (1 << N) - 1) return 0;

	int saishou = 254;
	int num2 = 0;
	rep(i, N) {
		if (!(b >> i & 1)) {
			if (A[i] < k && B[i] < k) return dp[k][b] = 254;
			if ((n + i) & 1) {
				if (B[i] >= k) {
					chmin(saishou, keisan(b + (1 << i), !n, B[i]) + num2);
				}
			}
			else {
				if (A[i] >= k) {
					chmin(saishou, keisan(b + (1 << i), !n, A[i]) + num2);
				}
			}
			num2++;
		}
	}
	return dp[k][b] = saishou;
}

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


	cin >> N;
	rep(i, N) cin >> A[i];
	rep(i, N) cin >> B[i];

	pair<int, int> kari[36];
	rep(i, N) kari[i] = mp(A[i], i);
	rep(i, N) kari[i + N] = mp(B[i], i + N);
	sort(kari, kari + N * 2);
	int k = 0;
	int mae = kari[0].first;
	rep(i, N * 2) {
		if (mae != kari[i].first) k++;
		mae = kari[i].first;
		if (kari[i].second < N) A[kari[i].second] = k;
		else B[kari[i].second - N] = k;
	}

	if (k == 0) {
		co(0);
		return 0;
	}

	rep(i, k + 1) rep(j, 1 << N) dp[i][j] = 255;

	int kotae = keisan(0, 0, 0);
	if (kotae == 254) co(-1);
	else co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 8448
using System;

namespace AtCoder{
    public static class AtCoder{
        public static void Main(){
            int n = int.Parse(Console.ReadLine());
            var boss = new int[n + 1];
            var input = Console.ReadLine().Split(' ');
            for(int i = 0; i < n - 1; i++){
                boss[int.Parse(input[i])]++;
            }
            for(int i = 1; i <= n; i++)
            {
                Console.WriteLine(boss[i]);
            }
        }
    }
}

Measured memory_bytes: 41704
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<ctype.h>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<math.h>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<stdio.h>
#include<stdlib.h>
#include<streambuf>
#include<string.h>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
typedef long long LL;
LL a[100010],b[100010];
int main(void){
	int n;
	scanf("%d",&n);
	LL res=0,lst=0;
	for (int i=1;i<=n;i++){
		scanf("%lld%lld",&a[n-i+1],&b[n-i+1]);
	}
	for (int i=1;i<=n;i++){
		LL tmp=((max(b[i],a[i]+lst)+b[i]-1)/b[i])*b[i]-a[i];
		if (a[i]+lst==0) tmp=0;
		res+=tmp-lst;
		lst=tmp;
	}
	printf("%lld",res);
	return 0;
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
"""



"""
import sys


from collections import deque
from functools import lru_cache

@lru_cache(maxsize=None)
def dig_left(n, q):
    res = [0]
    for di in range(1, min(n, len(q))+1):
        bu = n - di
        dig = list(q[:di])
        dig.sort()
        while bu and dig and dig[0] < 0:
            dig.pop(0)
            bu -= 1
        res.append(sum(dig))
    return max(res)


@lru_cache(maxsize=None)
def dig_right(n, q):
    res = [0]
    for di in range(1, min(n, len(q))+1):
        bu = n - di
        dig = list(q[-di:])
        dig.sort()
        while bu and dig and dig[0] < 0:
            dig.pop(0)
            bu -= 1
        res.append(sum(dig))
    return max(res)


def solve(N, K, V):
    ans = [0]
    limit = sum([v for v in V if v > 0])
    for left in range(K+1):
        q = deque(V)
        right = K - left
        l_dig = dig_left(left, tuple(V))
        r_dig = dig_right(right, tuple(V))
        ans.append(min(limit, l_dig+r_dig))
    return max(ans)


def main(args):
    N, K = map(int, input().split())
    V = [int(v) for v in input().split()]
    ans = solve(N, K, V)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
using Graph = vector<vector<ll>>;
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);


int main(){
    ll n, ans = 0; cin >> n;
    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    reverse(all(a));
    reverse(all(b));
    rep(i, n){
        if((a[i] + ans) % b[i] == 0) continue;
        ans += b[i] - (a[i] + ans) % b[i];
        // cout << ans << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4824
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

ll dp[81];

int main() {
	int N;
	cin >> N;
	
	vector<int> A(N);
	REP(i, N) cin >> A[i];
	
	memset(dp, -1, sizeof(dp));
	dp[0] = 1000;
	REP(i, N) {
		if (dp[i] == -1) continue;
		ll c = dp[i] / A[i];
		FOR(j, i + 1, N) {
			chmax(dp[j], dp[i] % A[i] + A[j] * c);
		}
		chmax(dp[i + 1], dp[i]);
	}
	cout << dp[N] << endl;
	return 0;
}


Measured memory_bytes: 3628
function Main(input) {
	var str = input;
	const n = str.split('\n');
	var k  =Number(n[0]);
	var p = n[1].split(" ");	
	var a = Number(p[0]); 
	var b = Number(p[1]);
	var ans = "";
	
	for(var i = a; i <= b; i++){
		if(i%k===0){
			ans = "OK";
		}
	}
if(ans !== "OK"){
	ans = "NG"
}
 console.log(ans);
 }
 
 
//*おまじない
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29428
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

int main() {
	int N, M;
	while(cin >> N >> M, N) {
		vi h(N), w(M);
		REP(i, N) {
			cin >> h[i];
		}
		REP(i, M) {
			cin >> w[i];
		}

		map<int, int> tate;
		REP(i, N) {
			REP(j, N-i) {
				int tmp = 0;
				REP(k, i+1) {
					tmp += h[k+j];
				}
				tate[tmp]++;
			}
		}
		map<int, int> yoko;
		REP(i, M) {
			REP(j, M-i) {
				int tmp = 0;
				REP(k, i+1) {
					tmp += w[k+j];
				}
				yoko[tmp]++;
			}
		}

		map<int, int>::iterator it = tate.begin();
		int ans = 0;
		while(it != tate.end()) {
			ans += (*it).second * yoko[(*it).first];
			it++;
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 32460
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;

template <typename T> inline constexpr bool chmin(T &a, T b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <typename T> inline constexpr bool chmax(T &a, T b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}
template <typename ite>
void print_ite(ite start, ite end, char sp = ' ', char en = '\n') {
  for (auto i = start; i != end; i++)
    cout << *i << sp;
  cout << en;
}
template <typename ite> void scan_ite(ite start, ite end) {
  for (auto i = start; i != end; i++)
    cin >> (*i);
}
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

int main() {
  double long r;
  cin >> r;
  cout << setprecision(10) << 2 * r * M_PI << endl;
}


Measured memory_bytes: 3172
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
vector<vector<bool> > graph;

const int INF = 1LL << 30;


int main(){
    int H, W, K;
    cin >> H >> W >> K;

    graph.assign(H, vector<bool>());


    for(int h=0; h<H; ++h){
        string s;
        cin >> s;
        for(int w=0; w<W; ++w){
            int flag = s[w] - '0';
            graph[h].push_back(flag);
        }
    }

    //答え
    int ans = INF;

    //横の切り方はbit全探索2^H通り
    for(int bit=0; bit< (1 << (H-1)); ++bit){
        int group = 0;
        vector<int> id(H);
        //どのグループに属するかを決める
        for(int h=0; h<H; ++h){
            id[h] = group;
            if(bit >> h & 1){
                group++;
            }
        }
        group++;

        //各グループに今何個入っているか
        vector<vector<int>> group_nums(group, vector<int>(W));
        for(int h=0; h<H; ++h){
            for(int w=0; w<W; ++w){
                int group = id[h];
                if(graph[h][w] == true){
                    group_nums[group][w]++;
                }
            }
        }

        //縦に何回切るかを貪欲に計算
        bool skip = false;
        vector<vector<int>> group_cumsum(group, vector<int>(W));
        //縦の累積を初期化
        for(int i=0; i<group; ++i){
            group_cumsum[i][0] = group_nums[i][0];
        }

        //もし事前にグループがそもそも閾値を超えてたらそのbitの横の切り方はできないので、
        //調べない。
        for(int i=0; i<group; ++i){
            for(int w=0; w<W; ++w){
                if(group_nums[i][w] > K){
                    skip = true;
                }
            }
        }


        if(!skip){
            int tate = 0;
            int w=1;
            //一個ずつ切るか見ていく
            for(w=0; w< W; ++w){
                bool is_cut = false;
                for(int i=0; i<group; ++i){
                    long long next_num = group_cumsum[i][w-1] + group_nums[i][w];
                    if(next_num > K){
                        is_cut = true;
                    }
                }

                if(is_cut == true){
                    //カットする
                    tate++;
                    //そうすると次の累積和はgraph[g][w]に初期化される.
                    for(int i=0; i<group; ++i){
                        group_cumsum[i][w] = group_nums[i][w];
                        
                    }                    
                }else{
                    //カットしない場合は累積和を増やす
                    for(int i=0; i<group; ++i){
                        group_cumsum[i][w] = group_cumsum[i][w-1] + group_nums[i][w];
                        
                    }
                }
            }
            //グループの分ける切り方はgroup-1,
            int cut_num = tate + (group-1);
            ans = min(ans, cut_num);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
#define sz 10010
#define MOD 1000000007
#define ll long long

ll adm[55][55];
ll id[55][55];
ll tmpid[55][55];

inline ll mul(ll a, ll b)
{
    a = ((a % MOD) + MOD) % MOD;
    b = ((b % MOD) + MOD) % MOD;
    return (a * b) % MOD;
}

inline ll add(ll a, ll b)
{
    a = ((a % MOD) + MOD) % MOD;
    b = ((b % MOD) + MOD) % MOD;
    return (a + b) % MOD;
}

ll temp, K;
int N;

void mulid()
{
    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < N; ++j)
        {
            tmpid[i][j] = 0;
            for (int k = 0; k < N; ++k)
            {
                tmpid[i][j] = add(tmpid[i][j], mul(id[i][k], adm[k][j]));
            }
        }
    }
    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < N; ++j)
        {
            id[i][j] = tmpid[i][j];
        }
    }
}

void muladm()
{
    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < N; ++j)
        {
            tmpid[i][j] = 0;
            for (int k = 0; k < N; ++k)
            {
                tmpid[i][j] = add(tmpid[i][j], mul(adm[i][k], adm[k][j]));
            }
        }
    }
    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < N; ++j)
        {
            adm[i][j] = tmpid[i][j];
        }
    }
}

void power(ll k)
{
    while (k)
    {
        if (k & 1)
            mulid();
        muladm();
        k >>= 1;
    }
}

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


    scanf("%d", &N);
    scanf("%lld", &K);

    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < N; ++j)
        {
            id[i][j] = (i == j);
        }
    }

    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < N; ++j)
        {
            scanf("%lld", &adm[i][j]);
        }
    }

    ll ans = 0;

    power(K);

    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < N; ++j)
        {
            ans = add(ans, id[i][j]);
        }
    }

    cout << ans;




    return 0;
}

Measured memory_bytes: 384
beki = [1]
for b in range(2,32):
    for p in range(2,10):
        if b ** p <= 1000:
            beki.append(b ** p)
beki.sort()
def inf(x,l):
    for i in range(len(l)):
        if l[i] > x:
            return l[i-1]
x = int(input())
if x == 1000:
    print(1000)
    exit()
print(inf(x,beki))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std; 
int n,v[25],c[25],num;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>v[i];
    for(int i=1;i<=n;i++) cin>>c[i];
    for(int i=1;i<=n;i++)
    	if(v[i]>c[i]) num+=v[i]-c[i];
	cout<<num;
	return 0;
} 

Measured memory_bytes: 256