akhauriyash/Code-Regression huggingface dataset:
open Batteries

let scan fmt f =
  Scanf.sscanf (read_line ()) fmt f

let scan_list cnv =
  read_line ()
  |> String.split_on_char ' '
  |> List.map cnv

let scan_array n m e conv =
  let arr = Array.make_matrix n m e in
  Enum.Labels.iter (0 --^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list conv);
  arr

let rec zip xs ys =
  match xs, ys with
  | [], _ -> []
  | _, [] -> []
  | x::xs, y::ys ->
    (x, y) :: zip xs ys

let dbg x = Printf.printf "%s\n" @@ dump x; x

let s = scan "%s" identity

let () =
  let n = String.length s in
  Enum.Labels.map (0 --^ n)
    ~f:(fun i ->
        Enum.Labels.map (1 -- n) ~f:(fun j ->
            if i < j then
              let sub = String.slice ~first:i ~last:j s  in
              if Enum.for_all (String.contains "AGTC") @@ String.enum sub then
                j - i
              else 0
            else
              0))
  |> Enum.concat
  |> Enum.reduce max
  |> Printf.printf "%d\n"


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

using namespace std;
#define BUF (200005)
#define ll long long 
#define INF 1000000000000000005

int n;
int m;
int s;
int t;
 
struct edge
{
	int to;
	ll cost;
};
typedef pair<ll,ll> P; 
vector<edge> edges[100010];
 ll dp_t[BUF]; 
 ll dp_s[BUF];
	
int main()
{
	cin >> n >> m;
	cin >> s >> t;
	for(int i = 0;i < m;i++)
	{
		int u,v;
		ll d;
		cin >> u >> v >> d;
		edges[u].push_back({v,d});
		edges[v].push_back({u,d});
	}
 
	ll dist[BUF];	
	for(int i=0;i<=n;i++)dist[i]=INF;
 
	{
		priority_queue<P,vector<P>,greater<P>> que;
		dist[s] = 0;
		que.push({dist[s],s});
 
		while(!que.empty())
		{
			int v = que.top().second;
			ll d = que.top().first;
			que.pop();
 
			if(dist[v] < d) continue;
 
			for(auto& e : edges[v])
			{
				if(dist[e.to] > d + e.cost)
				{
					dist[e.to] = d + e.cost;
					que.push({dist[e.to],e.to});
				}
			}
		}
	}
 
	dp_t[s] = 1;
	dp_s[t] = 1;
 
 
	vector<P> vec;
	for(int i = 1;i <= n;i++) vec.push_back({dist[i],i});
	sort(vec.begin(),vec.end());
	ll MOD = 1e9 + 7;
 
	// --> t
	for(int i = 0;i < n;i++)
	{
		for(auto & e : edges[vec[i].second])
		{
			if(dist[e.to] == dist[vec[i].second] + e.cost)
				(dp_t[e.to] += dp_t[vec[i].second]) %= MOD;
		}
	}
	for(int i = n - 1;i >= 0;i--)
	{
		for(auto & e : edges[vec[i].second])
		{
			if(dist[vec[i].second] == dist[e.to] + e.cost)
				(dp_s[e.to] += dp_s[vec[i].second]) %= MOD;
		}
	}
 
	ll result = dp_t[t] * dp_t[t];
	result %= MOD;
 
	auto mod = [MOD](ll num){
		return num % MOD;
	};
 
	for(int i = 1;i <= n;i++)
	{
		if(dist[i] * 2 == dist[t])
		{
			 (result += MOD - mod(mod(dp_t[i] * dp_t[i]) * mod(dp_s[i] * dp_s[i]))) %= MOD;
		}
	}
 
	for(int i = 1;i <= n;i++)
	{
		for(auto & e : edges[i])
		{
			int u = i;
			int v = e.to;
			if(dist[u] > dist[v]) continue;
			if(2 * dist[u] < dist[t] && 2 * dist[v] > dist[t] && dist[u] + e.cost == dist[v])
			{
				(result += MOD - mod(mod(dp_t[u] * dp_t[u]) * mod(dp_s[v] * dp_s[v]))) %= MOD;
			}
 
		}
	}
 
	cout << result << endl;
 
 
 
}
 

Measured memory_bytes: 18772
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;

int main() {
	int n, m, a, t = 0;
	vector<int>x;
	cin >> n >> m;
	rep(i, n) {
		cin >> a;
		t = t + a;
		x.push_back(a);
	}
	sort(x.begin(), x.end(),greater<int>());
	//rep(i, m)cout << x[i] << endl;
	rep(i, m) {
		if (x[i] < ((t -1)/ (4 * m))+1) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cmath>
using namespace std;
int f[100010];
int n;
int ans;
int cnt;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>f[i];
		if(f[i]<=f[i-1])
		{
			cnt++;
			ans=max(ans,cnt);
		}
		else cnt=0;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A;
    int B;
    cin >> A;
    cin >> B;
    
        if (A - 2*B >= 0){
            cout << A - 2*B << endl;
        }
        if (A < B || A - 2*B < 0){
            cout << 0 << endl;
        }
            
        
}

Measured memory_bytes: 256
#include<stdio.h>

void cal(int a, int b){
  int c, i;
  c = a%b;
  for (i=c; i>0; i--) {
    if (c%i==0 && b%i==0) {
      printf("%d\n", i);
      break;
    }
  }
}

int main(){
  int x, y;
  scanf("%d %d", &x, &y);
  if (x>y) {
    cal(x, y);
  } else if (y>x) {
    cal(y, x);
  } else {
    printf("%d\n", x);
  }
  return 0;
}

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(lint i = x ; i < n ; ++i)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

lint dp[15][100010];

int main(){
    lint n;
    cin >> n;
    vector<lint> v;
    lint now = 1;
    while(now <= n){
        v.push_back(now);
        now *= 6LL;
    }
    now = 9;
    while(now <= n){
        v.push_back(now);
        now *= 9LL;
    }
    rep(i, v.size() + 1){
        rep(j, n + 1){
            dp[i][j] = LLINF;
        }
        dp[i][0] = 0;
    }
    REP(i, 1, v.size() + 1){
        rep(j, n + 1){
            if(j >= v[i - 1]){
                dp[i][j] = min(dp[i - 1][j], dp[i][j - v[i - 1]] + 1);
            }else{
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    cout << dp[v.size()][n] << endl;
    return 0;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll H,W,D;
    cin >> H >> W >> D;
    vector<vector<ll> >  grid(H, vector<ll>(W));
    vector<pair<ll,ll> > grid_state(H * W + 1);
    rep(i,H){
        rep(j,W){
            cin >> grid[i][j];
            grid_state[grid[i][j]].first = i + 1;
            grid_state[grid[i][j]].second = j + 1;
        }
    }
    ll Q;
    cin >> Q;
    vector<pair<ll,ll> > test(Q);
    rep(i,Q){
        cin >> test[i].first >> test[i].second;
    }
    vector<ll> magic_power(H * W + 1);
    for (ll i = 0; i <= D; i++){
        magic_power[i] = 0;
    }
    for (ll i = D + 1; i <= H * W; i++){
        magic_power[i] = magic_power[i - D] + abs(grid_state[i].first - grid_state[i - D].first) + abs(grid_state[i].second - grid_state[i - D].second);
    }
    rep(i,Q){
        cout << magic_power[test[i].second] - magic_power[test[i].first] << endl;
    }
}


Measured memory_bytes: 7684
#include<bits/stdc++.h>
using namespace std;
#define F(i,L,R) for(int i=L;i<R;i++)
#define FE(i,L,R) for(int i=L;i<=R;i++)
#define RF(i,l,r) for(int i=r;i>l;i--)
#define RFE(i,l,r) for(int i=r;i>=l;i--)
#define getI(i) scanf("%d",&i)
#define getII(i,j) scanf("%d%d",&i,&j)
#define getIII(i,j,k) scanf("%d%d%d",&i,&j,&k)
#define VgetI(i) int (i);scanf("%d",&(i));
#define VgetII(i,j) int (i),(j);scanf("%d%d",&(i),&(j));
#define VgetIII(i,j,k) int (i),(j),(k);scanf("%d",&(i),&(j),&(k));
#define EoF(n) int(n);while(~getI(n))
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define abs(n) (n>0?n:(-n))
#define INF 2147483647
#define nINF -2147483648
int cnt[200005],arr[200005];
bool cmp(int a,int b){
	return a<b;
}
int main(){
	int n,k;
	while(~getII(n,k)){
		F(i,0,n) getI(arr[i]);
		F(i,0,n+3) cnt[i]=0;
		sort(arr,arr+n,cmp);
		int index=0,ans=0;
		cnt[0]=1;
		F(i,1,n){
			if(arr[i]!=arr[i-1]){
				index++;
				cnt[index]++;
			}
			else cnt[index]++;
		}
		sort(cnt,cnt+index+1,cmp);
		F(i,0,index+1-k) ans+=cnt[i];
		printf("%d\n",ans);
	}
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int M1,D1,M2,D2;
	cin>>M1>>D1;
	cin>>M2>>D2;
	if (D2==1){
		cout<<1<<endl;
	}else{
		cout<<0<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>

using namespace std;
const double eps=1e-6;
const double SQRT32=0.8660254037844386;
const double SQRT3=1.7320508075688772;
const double PI=3.141592653589793;

int col[100][100];
int inv[10];
int f[10];

int check(double x,double goal)
{
    if(x-goal>eps) return 1;
    if(goal-x>eps) return -1;
    return 0;
}

void print()
{
    int p=20;
    for(int i=0;i<p;i++)
    {
        for(int j=i;j<p-1;j++) printf("  ");
        for(int j=0;j<i*2+1;j++) printf("%d ",col[i][j]);
        printf("\n");
    }
    return;
}

int init()
{
    inv[1]=3,inv[2]=4,inv[3]=1,inv[4]=2;
    
    col[0][0]=1;
    col[1][0]=2;
    col[1][1]=3;
    col[1][2]=4;
    for(int i=2;i<36;i++)
    {
        int len=(i<<1)|1;
        int mid=i;
        if(i&1)
        {
            col[i][i]=inv[col[i-1][i-1]];
            col[i][i+1]=col[i-1][i];          
        }
        else
        {
            col[i][i]=col[i-1][i-1];
            col[i][i+1]=inv[col[i-1][i]];    
        }
        for(int j=i+2;j<len;j+=2) col[i][j]=inv[col[i][j-2]];
        for(int j=i-2;j>=0 ;j-=2) col[i][j]=inv[col[i][j+2]];
        for(int j=i+3;j<len;j+=2) col[i][j]=inv[col[i][j-2]];
        for(int j=i-1;j>=0 ;j-=2) col[i][j]=inv[col[i][j+2]];
    }
    return 0;
}

int getans(int d,int l)
{
    //printf("d=%d l=%d\n",d,l);
    double x=l*sin((double)(d-30)/180.0*PI),y=l*cos((double)(d-30)/180.0*PI);
    //printf("x=%lf y=%lf\n",x,y);
    int xx=0;
    while(check((xx+1)*SQRT32,y)<0) xx++;
    
    int yy=0;
    double dis;
    if(xx&1) dis=(xx+1)/2.0-y/SQRT3;
    else dis=y/SQRT3-xx/2.0;
    
    //printf("dis=%lf\n",dis);
    
    if(check(abs(x),dis)>0)
    {
        yy=1;
        double curx=dis;
        double tmpx=1.0-dis*2;
        while(check(curx+tmpx,abs(x))<0)
        {
            yy++;
            curx+=tmpx;
            tmpx=1-tmpx;
        }
    }
    
    if(check(x,0)>=0)
    {
        //printf("(%d,%d)\n",xx,xx+yy);
        return col[xx][xx+yy];
    }
    else
    {
        //printf("(%d,%d)\n",xx,xx-yy);
        return col[xx][xx-yy];
    }
}    

int ans[2];
        
int main()
{
    
    init();
    char s[10];
    int d,l;
    for(int i=0;i<2;i++)
    {
        cin>>s>>d>>l;
        
        if(s[0]=='B')
        {
            f[1]=1;
            f[2]=2;
            f[3]=3;
            f[4]=4;
        }
        if(s[0]=='C')
        {
            f[1]=4;
            f[2]=1;
            f[3]=3;
            f[4]=2;
        }
        if(s[0]=='D')
        {
            f[1]=2;
            f[2]=4;
            f[3]=3;
            f[4]=1;
        }
        ans[i]=f[getans(d,l)];
        //printf("ans[%d]=%d\n",i,ans[i]);
    }
    
    if(ans[0]==ans[1]) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;
}


Measured memory_bytes: 3352
#include<iostream>
using namespace std;
struct ant{int x,d,s,i;};
int main(){
  int n,l;
  cin >> n >> l;
  while(n!=0){
    int i,j,k;
    ant as[30];
    bool f[30];
    char c;
    for(i=0;i<n;i++){
      cin >> c >> as[i].x;
      if(c=='R') as[i].d=1;
      else as[i].d=-1;
      as[i].s=1;
      as[i].i=i;
      f[i]=false;
    }
    k=1;
    bool fl=true;
    while(fl){
      fl=false;
      for(i=0;i<n;i++) {
	if(!f[i]) {
	  as[i].x+=as[i].d;
	  if(as[i].x<=0||as[i].x>=l) f[i]=true;
	  else as[i].s++;
	  fl=true;
	}
      }
      for(i=0;i<n;i++) {
	if(f[i]) continue;
	for(j=i+1;j<n;j++) {
	  if(f[j]) continue;
	  if(as[i].x==as[j].x) swap(as[i].i,as[j].i);
	}
      }
    }
    int o=0,id=0;
    for(i=0;i<n;i++) {
      //cout << o << as[i].d << ":" << as[i].i<<endl;
      if(o<=as[i].s){
	if(o==as[i].s&&as[i].d==1) continue;
	
	o=as[i].s;id=as[i].i;
      }
    }
    cout << o <<" " << id+1 << endl;
    cin >> n >> l;
  }

}

Measured memory_bytes: 1160
#include<cstdio>
#define LL long long
#define mod 1000000007
#define half 2000
#define mx 4000
#define Max_Sum 8000
int n;LL ans=0;
int a[200002],b[200002];
LL fac[8002],inv[4002];
LL f[4002][4002]={};
template<class T>void read(T &x)
{
	x=0;int f=0;char ch=getchar();
	while(ch<'0' || ch>'9')f|=(ch=='-'),ch=getchar();
	while(ch>='0' && ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	x=f? -x:x;return ;
}
inline LL pow(LL a,int b)
{
	if(!b)return 1;
	if(b==1)return a;
	LL c=pow(a,(b>>1));
	c=(c*c)%mod;
	if(b&1)c=(c*a)%mod;
	return c;
}
inline void init()
{
	fac[0]=1;
	for(int i=1;i<=Max_Sum;++i)
		fac[i]=(fac[i-1]*i)%mod;
	inv[mx]=pow(fac[mx],mod-2);
	for(int i=mx;i;--i)
		inv[i-1]=(inv[i]*i)%mod;
	read(n);
	for(int i=1;i<=n;++i)
		read(a[i]),read(b[i]),++f[half-a[i]][half-b[i]];
}
inline void dp()
{
	for(int i=1;i<=mx;++i)
	{
		f[0][i]=(f[0][i]+f[0][i-1])%mod;
		f[i][0]=(f[i][0]+f[i-1][0])%mod;
	}
	for(int i=1;i<=mx;++i)
		for(int j=1;j<=mx;++j)
			f[i][j]=(f[i][j]+f[i-1][j]+f[i][j-1])%mod;
	for(int i=1;i<=n;++i)
		ans=(ans+f[half+a[i]][half+b[i]]-(fac[2*(a[i]+b[i])]*((inv[2*a[i]]*inv[2*b[i]])%mod))%mod)%mod;
	if(ans<0)ans+=mod;if(ans&1)ans+=mod;printf("%lld",(ans>>1));
}
int main()
{
	init(),dp();
	return 0;
}

Measured memory_bytes: 126976
#include<iostream>
using namespace std;
int main(int argc, char const *argv[])
{
   int a, b;
   cin >> a >> b;
   if((a + b)%2 == 1)
   {
      cout << "IMPOSSIBLE" << endl;
   }
   else
   {
      cout << (a + b)/2 << endl;
   }
   return 0;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    loop {
        let mut line = String::new();
        io::stdin().read_line(&mut line).ok();

        if line == "0\n" { break; }

        let sum = line.trim().chars().map(|c| c.to_digit(10).unwrap()).sum::<u32>();
        println!("{}", sum);
    }
}



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

int main()
{
    int K, T;
    cin >> K >> T;

    priority_queue<pair<int, int>> q;
    int ai;
    for (int i = 0; i < T; i++)
    {
        cin >> ai;
        q.push(make_pair(ai, i + 1));
    }

    int res = 0;
    int prev = 0;
    for (int i = 0; i < K; i++)
    {
        pair<int, int> p0 = q.top();
        q.pop();

        if (p0.second == prev)
        {
            if (q.empty())
            {
                res += p0.first;
                break;
            }
            else
            {
                pair<int, int> p1 = q.top();
                q.pop();
                p1.first--;
                prev = p1.second;
                if (p1.first > 0)
                {
                    q.push(p1);
                }
            }
        }
        else
        {
            p0.first--;
            prev = p0.second;
        }

        if (p0.first > 0)
        {
            q.push(p0);
        }
    }
    cout << res << endl;
}

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

int k[1000][1000][2];
int m[1000];
int o[1000];
int v[36];
string L;

int main(){
	int n,e,MIN,MIN2,sum=0;
	char T[11]="0123456789";
	char S[5]="SHCD";

	cin>>n;
	for(int i=0;i<n;i++){
		cin>>L;
		for(int j=0;j<10;j++){
			if(L[1]==T[j]){
				k[0][i][0]=j;
			}
		}
		for(int j=0;j<4;j++){
			if(L[0]==S[j]){
				k[0][i][1]=j;
			}
		}
	}
	e=0;
	for(int i=1;i<=9;i++){
		for(int j=0;j<n;j++){
			if(k[0][j][0]==i){
				m[e]=i*4+k[0][j][1];
				e++;
			}
		}
	}

	for(int i=0;i<n;i++){
		cout<<S[m[i]%4]<<T[m[i]/4];
		if(i<n-1){
			cout<<' ';
		}
		else{
			cout<<endl;
		}
	}
	cout<<"Stable"<<endl;

	//sort.

	for(int i=0;i<n-1;i++){
		MIN=1000000;
		MIN2=0;
		for(int j=i+1;j<n;j++){
			if(k[i][j][0]<MIN){
				MIN=k[i][j][0];
				MIN2=j;
			}
		}
		for(int j=0;j<n;j++){
			k[i+1][j][0]=k[i][j][0];
			k[i+1][j][1]=k[i][j][1];
		}
		if(MIN<k[i][i][0]){
			k[i+1][i][0]=k[i][MIN2][0];
			k[i+1][MIN2][0]=k[i][i][0];
			k[i+1][i][1]=k[i][MIN2][1];
			k[i+1][MIN2][1]=k[i][i][1];
		}
	}
	for(int i=0;i<n;i++){
		cout<<S[k[n-1][i][1]]<<T[k[n-1][i][0]];
		o[i]=k[n-1][i][0]*4+k[n-1][i][1];
		if(i==n-1){
			cout<<endl;
		}
		else{
			cout<<' ';
		}
	}
	for(int i=0;i<n;i++){
		if(o[i]!=m[i]){
			cout<<"Not stable"<<endl;
			goto Exit2;
		}
	}
	cout<<"Stable"<<endl;
	goto Exit2;
Exit2:;
	return 0;
}



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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int a,b,c,d,ans=0;
  cin>>a>>b>>c>>d;
  ans=min(b,d)-max(a,c);
  if(ans<=0){
    cout<<0<<endl;
  }else{
    cout<<ans<<endl;
  }
}
///////////////////////////

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String, Integer> map = new TreeMap<>();
		int max = 0;
		for (int i = 0; i < N; i++) {
			String s = sc.next();
			if (map.containsKey(s)) {
				map.put(s,map.get(s) + 1);
			} else {
				map.put(s,1);
			}
			max = Math.max(max, map.get(s));
		}
		for (String key : map.keySet()) {
			if (map.get(key) == max) {
				System.out.println(key);
			}
		}
	}
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int n;
  cin >> n;
  vector<int> v(n), c(n);
  for(int i = 0; i < n; ++i) cin >> v[i];
  for(int i = 0; i < n; ++i) cin >> c[i];

  int ans = 0;
  for(int i = 0; i < n; ++i)
  {
    ans += max(0, v[i] - c[i]);
  }
  cout << ans;

}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {
    static final long MOD = 998244353;
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] X = new int[N];
        int[] D = new int[N];
        TreeMap<Integer, Node> mp = new TreeMap<>();
        for(int i=0;i<N;i++){
            X[i] = sc.nextInt();
            D[i] = sc.nextInt();
            mp.put(X[i], new Node(X[i]+D[i]));
        }
        PriorityQueue<Integer> pq = new PriorityQueue<>();
        for(Integer x : mp.descendingKeySet()){
            Node now = mp.get(x);
            while(!pq.isEmpty()){
                if(pq.peek() >= now.pos){
                    break;
                }else{
                    now.children.add(mp.get(pq.poll()));
                }
            }
            pq.add(x);
        }
        long ans = 1;
        while(!pq.isEmpty()){
            int target = pq.poll();
//            System.out.println(mp.get(target));
            ans *= mp.get(target).cnt();
            ans %= MOD;
        }
        System.out.println(ans);
    }

    private static class Node{
        public List<Node> children = new ArrayList<>();
        public int pos;
        Node(int p){
            pos = p;
        }

        long cnt(){
            if(children.size() == 0){
                return 2;
            }
            long ans = 1;
            for(Node c:children){
                ans *= c.cnt();
                ans %= MOD;
            }
            ans ++;
            ans %= MOD;
            return ans;
        }
        @Override
        public String toString(){
            return pos + children.toString();
        }
    }
}


Measured memory_bytes: 173720
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int n, m;
double calc(vector<int> &cnt){
	double res = 0;
	for (double x : cnt){
		if(x) res -= x / n*log(x / n);
	}
	return res;
}

tuple<int, int, int> bf(vector<int> &v){
	pair<double, tuple<int, int, int>> ans;
	ans = MP(1e9, MT(-1, -1, -1));
	rep(s, 16) rep(a, 16) rep(c, 16){
		vector<int> cnt(256);
		int r = s;
		rep(i, v.size()){
			r = (a*r + c) % m;
			++cnt[(v[i] + r) % m];
		}
		ans = min(ans, MP(calc(cnt), MT(s, a, c)));
		ans.first -= 1e-9;
	}
	return ans.second;
}

int main(){
	m = 256;
	while (cin >> n, n){
		vector<int> v(n);
		rep(i, n) cin >> v[i];
		int s, a, c;
		tie(s, a, c) = bf(v);
		cout << s << ' ' << a << ' ' << c << '\n';
	}

	return 0;
}

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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int S = sc.nextInt();
        int W = sc.nextInt();


        if (S <= W) {
            System.out.println("unsafe");
        } else {
            System.out.println("safe");
        }

    }
}

Measured memory_bytes: 35788
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

max_count = sum(B) - sum(A)

count1, count2 = 0, 0

for i in range(N):
  if A[i] > B[i]:
    count1 += A[i] - B[i]
  else:
    count2 += (B[i] - A[i]) // 2
    if (B[i] - A[i]) % 2 == 1:
      count2 += 1
      
if count1 <= max_count:
  if count2 <= max_count:
    print("Yes")
    quit()
print("No")

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

int n, ans, d[15][15];
int main() {
	int i, j, k;
	cin >> n;
	for(i=1; i<=n; i++) {
		for(k=i; k>=10; k/=10);
		d[k][i%10]++;
	}
	for(i=1; i<=9; i++) for(j=1; j<=9; j++) ans += d[i][j] * d[j][i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n,x,m,s,t=1000,i;
    scanf("%d%d",&n,&x);
    s=n;
    for(i=0;i<n;i++){
        scanf("%d",&m);
        if(t>m)t=m;
        x-=m;
    }
    s+=x/t;
    printf("%d",s);
    return 0;
}

Measured memory_bytes: 128
while(1):
  H,W = map(int, raw_input().split())
  if H == 0 and W == 0:
    break
  for i in range(H):
    if i%2 == 0:
      if W%2 == 0:
        print "#."*(W/2)
      else:
        print "#."*(W/2) + "#"
    else:
      if W%2 == 0:
        print ".#"*(W/2)
      else:
        print ".#"*(W/2) + "."
  print ""

Measured memory_bytes: 6444
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	var x, a int
	x, _ = strconv.Atoi(next())
	a, _ = strconv.Atoi(next())
	var y int = 2 * a - x
	fmt.Println(y)
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define ff first
#define ss second

using namespace std;
using pii=pair<int,int>;
using ll=long long;

int n;
vector<vector<vector<double>>> dp;

double f(int c1, int c2, int c3, int sum)
{
    double &ret=dp[c1][c2][c3];
    if(ret>=0) return ret;
    ret=0;
    if(c3>0) ret+=f(c1,c2+1,c3-1,sum)*c3/(double)sum;
    if(c2>0) ret+=f(c1+1,c2-1,c3,sum)*c2/(double)sum;
    if(c1>0) ret+=f(c1-1,c2,c3,sum-1)*c1/(double)sum;
    ret+=n/(double)sum;
    return ret;
}

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

    cin>>n;
    dp.resize(n+1,vector<vector<double>>(n+1,vector<double>(n+1,-1)));
    dp[0][0][0]=0;
    int c[3]={0};
    for(int i=0; i<n; i++){
        int tmp;
        cin>>tmp;
        c[tmp-1]+=1;
    }
    cout.precision(9);
    cout<<fixed;
    cout<<f(c[0],c[1],c[2],n);

    return 0;
}


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

int main() {
    long long int ans = 0;
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int min = a[0];
    for(int i = 1; i < n; ++i) {
        if(a[i] <= min) ans += min - a[i];
        else min = a[i];
    }
    cout << ans << '\n';
}


Measured memory_bytes: 4404
//var S=readLine()!.characters.map{String($0)},a=[0,0];for i in 0..<2{for(j,c)in S.enumerate(){if j%2^i != Int(c){a[i]++}}};print(min(a[0],a[1]))
var S=readLine()!.characters.map{String($0)},a=[0,0];for i in 0..<2{for j in 0..<S.count{if j%2^i != Int(S[j]){a[i]++}}};print(min(a[0],a[1]))

Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main() 
{
  char a,b,c; cin >> a >> b >> c;
  int ans = 0;
  if(a == '1')ans++;
  if(b == '1')ans++;
  if(c == '1')ans++;
  cout << ans << endl;
  system("pause");
}

Measured memory_bytes: 504
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int a,b,c;
int x;
vector<int> y;

bool input(){
  int n;
  cin>>n>>a>>b>>c>>x;
  if(n==0&&a==0&&b==0&&c==0&&x==0)return false;
  y.clear();
  for(int i=0;i<n;i++){
    int tmp;cin>>tmp;
    y.push_back(tmp);
  }
  return true;
}

int mmm(int X){
  return (a*X+b)%c;
}

bool cc(vector<int> y){
  for(int i=0;i<y.size();i++){
    if(y[i]==0)return 0;
  }
  return 1;
}


int solve(){
  vector<int> check(y.size());
  int t = 0;
  for(int i=0;i<=10000;i++){
    if(y[t] == x){
      t++;
    }
    x = mmm(x);
    if(t == y.size())return i;
  }
  return -1;
}

int main(){
  while(input()){
    cout<<solve()<<endl;
  }
}

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

int main() {

  int N;
  cin >> N;

  map<string, int> m;
  string s;
  for(int i = 0; i < N; i++){
    cin >> s;
    m[s]++;
  }

  cout << m.size() << endl;
}


Measured memory_bytes: 19216
/*|In The Name of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e6+5;

long long n;

int a , b;
map < int , int > cnt;

int main(){
    cin >> a >> b;
    cnt[2] = 1;
    cnt[3] = 2;
    cnt[4] = 3;
    cnt[5] = 4;
    cnt[6] = 5;
    cnt[7] = 6;
    cnt[8] = 7;
    cnt[9] = 8;
    cnt[10] = 9;
    cnt[11] = 10;
    cnt[12] = 11;
    cnt[13] = 12;
    cnt[1] = 13;
    if(cnt[a] > cnt[b]){
        puts("Alice");
    } else if(cnt[a] < cnt[b]) {
        puts("Bob");
    } else {
        puts("Draw");
    }
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;

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



int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a*c <= b){
        cout << c << endl;
    }
    else{
        cout << b/a << endl;
    }


    return 0;
}


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

int main()
{
    string s;
    int k;
    cin >> s;
    cin >> k;

    for (char &c : s)
    {
        if (c == 'a')
            continue;
        int d = 26 - (c - 'a');
        if (d <= k)
        {
            c = 'a';
            k -= d;
        }
    }
    k %= 26;
    s[s.size() - 1] = s[s.size() - 1] + k;
    cout << s << endl;
}

Measured memory_bytes: 3736
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

int main(){
        int d;
        cin>>d;
        if(d==25){
            cout<<"Christmas";
        }else if(d==24){
            cout<<"Christmas Eve";
        }else if(d==23){
            cout<<"Christmas Eve Eve";
        }else{
            cout<<"Christmas Eve Eve Eve";
        }
    return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter

data class Edge(val v: Int, val c: Int)

fun main(args: Array<String>) = with(PrintWriter(System.out)) {
    val n = readLine()!!.toInt()
    val edge = (0 until n).map {
        val tmp = readLine()!!.split(' ')
//            .drop(2)
            .map { it.toInt() }
//            .zipWithNext { v, c -> Edge(v, c) }
        (1..tmp[1]).map { i ->
            Edge(tmp[2*i], tmp[2*i+1])
        }
    }

    val d = IntArray(n) { Int.MAX_VALUE }
    val explored = mutableSetOf<Int>()
    val frontier = mutableSetOf<Int>()

    d[0] = 0
    frontier.add(0)
    while (frontier.isNotEmpty()) {
        val minV = frontier.minBy { d[it] }!!
        explored.add(minV)
        frontier.remove(minV)
        edge[minV].forEach {
            if (!explored.contains(it.v)) {
                if (d[it.v] > d[minV] + it.c) {
                    d[it.v] = d[minV] + it.c
                    frontier.add(it.v)
                }
            }
        }
    }

    d.forEachIndexed { index, i ->
        println("$index $i")
    }

    flush()
}



Measured memory_bytes: 118760
while True:
  m, f, r = map(int, input().split())
  if m == -1 and f == -1 and r == -1:
    break
  
  
  if m == -1 or f == -1:
    print('F')
  elif m + f >= 80:
    print('A')
  elif m + f >= 65:
    print('B')
  elif m + f >= 50:
    print('C')
  elif m + f >= 30:
    if r >= 50:
      print('C')
    else:
      print('D')
  else:
    print('F')


Measured memory_bytes: 5592
#--Bingo
a_11, a_12, a_13 = map(int, input().split(" "))
a_21, a_22, a_23 = map(int, input().split(" "))
a_31, a_32, a_33 = map(int, input().split(" "))
N = int(input())

List = [int(input()) for i in range(N)]

#--horizontal
bingo = [[a_11, a_12, a_13], [a_21, a_22, a_23], [a_31, a_32, a_33], 
        [a_11, a_21, a_31], [a_12, a_22, a_32], [a_13, a_23, a_33],
        [a_11, a_22, a_33], [a_13, a_22, a_31]]

def intersect_list(lst1, lst2):
    arr = []
    lst = lst1.copy()
    for element in lst2:
        try:
            lst.remove(element)
        except ValueError:
            pass
        else:
            arr.append(element)
    return arr

for num in range(8):
  list_diff = intersect_list(bingo[num], List)
  if (int(len(list_diff)) == 3):
    print("Yes")
    exit()
  else:
    pass

print("No")


Measured memory_bytes: 3064
n = gets.chomp.to_i
s = gets.chomp.split(" ")
count = 0
arr = Float::INFINITY
n.times do |i|
    mokuteki = s[i]
    arr = [mokuteki.to_i,arr].min
    if mokuteki.to_i <= arr
        count += 1
    end
end
puts count

Measured memory_bytes: 27020
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double pi = acos(-1);
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
	for (auto &e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

//↑template↑


int main() {
	int a, b;
	cin >> a >> b;
	if (b > ((a - 1)*(a - 2)) / 2) { cout << -1 << endl; return 0; }

	int ans = (a - 1)*(a - 2) / 2 - b, out = 2, out2 = 3;

	cout << a - 1 + ans << endl;
	for (int i = 0; i < a - 1; ++i) {
		cout << 1 << " " << i + 2 << endl;
	}
	while (ans) {
		cout << out << " " << out2 << endl;
		if (out2 == a) { out2 = out + 2; ++out; }
		else { ++out2; }
		--ans;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(ll i=a ; i<=b ; i++)
#define FORD(i,a,b) for(int i=a ; i>=b ; i--)
#define INF 1000000000
#define ll long long int
#define eps (1e-8)
#define sq(x) ( (x)*(x) )
#define all(x) x.begin(),x.end()
#define flog2(n) 64 - __builtin_clzll(n) - 1
#define popcnt(n) __builtin_popcountll(n)
using namespace std;
 
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
 
const ll K=998244353;
ll n,A,B,k;
ll mu(ll a , ll n){
    if (n==0) return 1;
    ll q=mu(a,n/2);
    if (n%2==0) return q*q%K;
    return q*q%K*a%K;
}
ll gt[300005],rev[300005];
ll Combi(ll n, ll k){
    if (n<k) return 0;
    return gt[n]*rev[k]%K*rev[n-k]%K;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    gt[0]=rev[0]=1;
    FOR (i,1,300001){
        gt[i]=gt[i-1]*i%K;
        rev[i]=mu(gt[i],K-2);
    }
    cin>>n>>A>>B>>k;
    ll res=0;
    FOR (a,0,n){
        if ((k-a*A)<0) break;  
        if ((k-a*A)%B) continue;
        ll b=(k-a*A)/B;
        res=(res+Combi(n,a)*Combi(n,b)%K)%K;
    }
    cout<<res<<endl;
 
         return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <stack>
#include <queue>
#include <utility>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	int n;
	string s;
	cin>>n>>s;
	int d[26]={};
	rep(i,0,n){
		if(s[i]=='+') continue;
		d[s[i]-'a']++;
	}
	int k[500]={};
	rep(i,0,26){
		k[d[i]]++;
	}
	int ans=0,cnt=0;
	ans=max(0,2*k[1]-1);
	if(k[1]) cnt++;
	rep(i,2,500){
		if(k[i]){
			cnt++;
			ans+=min(2*k[i]+3,4*k[i]-1);
		}
	}
	o(ans+cnt-1);
}

Measured memory_bytes: 1208
import java.util.Scanner;

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 a1=a*b;
	int a2=a*c;
	int a3=b*c;
	System.out.println((Math.min(a1,Math.min(a2,a3)))/2);

	}}

Measured memory_bytes: 21844
str_list = input().split(' ')
int_list = [int(x) for x in str_list]
A, B = int_list[0], int_list[1]

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

    # divisors.sort()
    return divisors

a_div = make_divisors(A)
b_div = make_divisors(B)

cf = list( set(a_div) & set(b_div) )
cf.remove(1)
cf.sort()

count = 0

import numpy as np
cf = np.array(cf)

count = 0
while len(cf) > 0:
    count += 1
    if len(cf)==1:
        break
    x = int( cf[0] )
    cf = cf[np.where( cf%x!=0 )]
print(count+1)


Measured memory_bytes: 12708
function main(input) {
  // 入力値取得
  const inputValue = input.split(/\s/);
  const apples = formatNum(inputValue[0]);
  const parts = formatNum(inputValue[1]);

  // アップルパイを作る
  const pi = Math.floor(((3 * apples) + parts) / 2);
  console.log(pi);
};

// 文字列を数値に変換
function formatNum(str) {
  return Number(str);
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 4000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;
bool vis[10];
bool judge(int x){
    while(x){
        int temp=x%10;
        if(vis[temp])
            return false;
        x/=10;
    }
    return true;
}
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
 
    memset(vis,false,sizeof(vis));
    for(int i=1; i<=k; i++){
        int x;
        scanf("%d",&x);
        vis[x]=true;
    }
 
    for(int i=n; ; i++){
        if(judge(i)){
            printf("%d\n",i);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
#include<list>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//int型0~9を文字0~9に変換
char int_to_char(int c) {
	if (c == 0) return '0';
	if (c == 1) return '1';
	if (c == 2) return '2';
	if (c == 3) return '3';
	if (c == 4) return '4';
	if (c == 5) return '5';
	if (c == 6) return '6';
	if (c == 7) return '7';
	if (c == 8) return '8';
	if (c == 9) return '9';
	else return'x';
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x, int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / (int)pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}
//ord桁のstring型2進数をint型10進数に変換する
int rep_binary(string x, int ord)
{
	int res = 0;
	for (int i = 0; i < ord; i++)
	{
		if (x[i] == '1') res += (int)pow(2, ord - 1 - i);
	}
	return res;
}
//xとyのビットごとの排他的論理和
template<class T> T XOR(T x, T y)
{
	T n = 0;
	while (max(x, y) > pow(2, n)) n++;
	T ans=0;
	for (int i = 0; i <= n; i++)
	{
		T x1 = (x % (T)pow(2, i + 1)) / (T)pow(2, i);
		T y1 = (y % (T)pow(2, i + 1)) / (T)pow(2, i);
		if (x1 != y1) ans += (T)pow(2, i);
	}
	return ans;
}

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/

int pos[200005];

int main()
{
	int N, P[200005];
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> P[i];
		P[i]--;
		pos[P[i]] = i;
	}

	int L = 1, C = 1, x = 0;
	while (x<N-1)
	{
		if (pos[x] < pos[x + 1])
		{
			C++;
		}
		else
		{
			L = max(L, C);
			C = 1;
		}

		x++;
	}
	L = max(L, C);

	cout << N - L << endl;
		 
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

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

  int64_t N;
  cin >> N;
  int64_t res = 0;
  for (int64_t i = 1; i <= N; i++) {
    if (i % 3 == 0 || i % 5 == 0) {
      continue;
    } else {
      res += i;
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3652
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

a, b = readmi()
if a >= 13:
    print(b)
elif 12 >= a >= 6:
    print(b // 2)
else:
    print(0)


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

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

using namespace std;

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

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

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

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

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

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

string to_string(string s){
    return s;
}

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

void debug_print(){
    cerr<<endl;
}

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

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

void print(){
    cout<<endl;
}

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

int main(){
    GI3(A,B,K);
    for(int i=A;i<min(A+K,B+1);++i){
        print(i);
    }
    for(int i=max(A+K,B-K+1);i<=B;++i){
        print(i);
    }
    return 0;
}

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

int main() {
  int a;
  long long b, n;
  long long ans;
  cin >> a >> b >> n;
  // n>=b-1なら、以下の式でよい
  if(n>=b-1) ans = a*(b-1)/b;
  else ans = a*n/b;
  cout << ans << endl;
}


Measured memory_bytes: 3600
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	static class Number implements Comparable<Number>{
		long x;
		long absx;
		public Number(long v) {
			x = v;
			absx = Math.abs(v);
		}
		@Override
		public int compareTo(Number o) {
			return Long.compare(absx, o.absx);
		}
		@Override
		public String toString() {
			return x + " " + absx;
		}
	}
	static final long MOD = 1000000007;
	static long solve(long A[], int K){
		List<Number> ns = new ArrayList<Number>();
		for(long a : A){
			ns.add(new Number(a));
		}
		Collections.sort(ns);
		Collections.reverse(ns);
		int sign = 1;
		long ret = 1;
		int last_pos = -1;
		int last_neg = -1;
		for(int i = 0 ; i < K ; ++i){
			Number n = ns.get(i);
			ret = (ret * n.absx) % MOD;
			if(n.x > 0){
				last_pos = i;
			}else if(n.x == 0){
				sign = 0;
			}else{
				sign = - sign;
				last_neg = i;
			}
		}
		if(sign > 0){
			return ret;
		}
		if(sign == 0){
			return 0;
		}
		// last_neg >= 0
		int first_pos = -1;
		int first_neg = -1;
		for(int i = K ; i < ns.size() ; ++i){
			Number n = ns.get(i);
			if(n.x >= 0 && first_pos < 0){
				first_pos = i;
			}else if(n.x < 0 && first_neg < 0){
				first_neg = i;
			}
		}
		if(last_pos >= 0){
			if(first_pos >= 0 && first_neg >= 0){
				if(ns.get(first_pos).absx * ns.get(last_pos).absx >= ns.get(first_neg).absx * ns.get(last_neg).absx){
					ret = ns.get(first_pos).x;
					sign = 1;
					for(int i = 0 ; i < K ; ++i){
						if(i == last_neg){
							continue;
						}
						Number n = ns.get(i);
						ret = (ret * n.absx) % MOD;
					}
					return ret;					
				}else{
					ret = ns.get(first_neg).absx;
					sign = 1;
					for(int i = 0 ; i < K ; ++i){
						if(i == last_pos){
							continue;
						}
						Number n = ns.get(i);
						ret = (ret * n.absx) % MOD;
					}
					return ret;		
				}
			}
			if(first_pos >= 0){
				ret = ns.get(first_pos).x;
				sign = 1;
				for(int i = 0 ; i < K ; ++i){
					if(i == last_neg){
						continue;
					}
					Number n = ns.get(i);
					ret = (ret * n.absx) % MOD;
				}
				return ret;				
			}
			if(first_neg >= 0){
				ret = ns.get(first_neg).absx;
				sign = 1;
				for(int i = 0 ; i < K ; ++i){
					if(i == last_pos){
						continue;
					}
					Number n = ns.get(i);
					ret = (ret * n.absx) % MOD;
				}
				return ret;				
			}
			return getNeg(ns, K);
		}
		// 前は全部マイナス , 
		if(first_pos >= 0){
			ret = ns.get(first_pos).x;
			sign = 1;
			for(int i = 0 ; i < K ; ++i){
				if(i == last_neg){
					continue;
				}
				Number n = ns.get(i);
				ret = (ret * n.absx) % MOD;
			}
			return ret;				
		}
		return getNeg(ns, K);
	}
	static long getNeg(List<Number> ns, int K){
		Collections.sort(ns);
		long ret = 1;
		for(int i = 0 ; i < K ; ++i){
			ret = (ret * ns.get(i).absx) % MOD;
		}
		return MOD - ret;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		long A[] = new long[N];
		for(int i = 0 ; i < N ; ++i){
			A[i] = sc.nextLong();
		}
		System.out.println(solve(A, K));
	}
}


Measured memory_bytes: 67892
N=10**5
prime=[1]*(N+1)
prime[0]=prime[1]=0
for i in range(2,int(N**.5)+1):
    if not prime[i]:
        continue
    for j in range(i*2,N+1,i):
        prime[j]=0

check=[0]*(N+1)
for n in range(N+1):
    if n%2==1 and prime[n] and prime[(n+1)//2]:
        check[n]=1

accumulate=[0]*(N+1)
for n in range(1,N+1):
    accumulate[n]=accumulate[n-1]+check[n]

Q=int(input())
for q in range(Q):
    l,r=map(int,input().split())
    print(accumulate[r]-accumulate[l-1])

Measured memory_bytes: 7924