akhauriyash/Code-Regression huggingface dataset:
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;

static class MainClass
{
    public static void Main(string[] args)
    {


        var X = Console.ReadLine().ToInt32();
        var A = Console.ReadLine().ToInt32();
        var B = Console.ReadLine().ToInt32();
        var XA = X - A;
        var num = XA / B;
        Console.WriteLine(X - A - num * B);

        Console.ReadLine();
    }
    


    
   

    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<long> SplittedStringToInt64List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    public const int INF = int.MaxValue / 2;
    public const long LONGINF = long.MaxValue / 2;

    public static int Max(params int[] values)
    {
        var maxes = -1;
        for (int i = 0; i < values.Length; i++)
        {
            maxes = Math.Max(values[i], maxes);
        }
        return maxes;
    }

    #endregion
}



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

int main(){
  
  int n;
  cin>>n;
  int a[n],b[n][n];
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
        b[i][j]=-1;
    }
  }
  for(int i=0;i<n;i++){
    cin>>a[i];
    int x[a[i]],y[a[i]];
    for(int j=0;j<a[i];j++){
      cin>>x[j]>>y[j];
      b[i][x[j]-1]=y[j];
    }
  }
  
  int c[n];
  bool flg=1;
  int count=0,ans=0;
  for(int bit=(1<<n)-1;bit>=0;bit--){
  
    for(int i=0;i<n;i++) c[i]=-1;
    
    for(int i=0;i<n;i++){
      if(bit&(1<<i)){
        for(int j=0;j<n;j++){
          if(b[i][j]==1){
            if(c[j]==0) c[j]=10;
            else c[j]=1;
          }
          else if(b[i][j]==0){
            if(c[j]==1) c[j]=10;
            else c[j]=0;
          } 
        }
      }
    }
 
    flg=1;
    for(int i=0;i<n;i++){
      if(c[i]==10){
        flg=0;
        break;
      }
      else if(c[i]==-1) flg=1;
      else if(c[i]==1&&(bit&(1<<i))) flg=1;
      else if(c[i]==0&&!(bit&(1<<i))) flg=1;
      else{
        flg=0;
        break;
      }
    }
    
    if(flg){
      for(int i=0;i<n;i++){
        if(bit&(1<<i)) count++;
      }
      ans=max(ans,count);
      count=0;
    }
  }
  
  cout<<ans<<endl;
  
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int a, b, c, tmp=0;
    scanf("%d %d %d",&a, &b, &c);
    if(a > b){
        tmp = a;
        a = b;
        b = tmp;
    }
    
    if(a > c){
        tmp = a;
        a = c;
        c = tmp;
    }
    
    if(b > c){
        tmp = b;
        b = c;
        c = tmp;
    }
    printf("%d %d %d\n",a, b, c);
    return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>

using namespace std;
#define REP(i,m,n) for(long long i=m;i<n;++i)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair

int main() {
	ll ans, n, m;
	cin >> n >> m;
	ans = 1900 * m + 100 * (n - m);
	REP(i, 0, m) {
		ans *= 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define rep(i,a,b) for(i=a;i<b;i++)
#define tr(container,it)   for(auto it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mod 998244353
#define fs first
#define sc second
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
void solve()
{
  int n,k,i,j;
  cin>>n>>k;
  int a[n];
  rep(i,0,n)cin>>a[i];
  int dp[n][k+1], p[n][k+1];
  memset(dp,0,sizeof(dp));
  memset(p,0,sizeof(p));
  for(i=0;i<n;i++)
  {
      dp[i][0]=1;
      p[i][0]=1;
  }
  for(j=0;j<=k;j++)
  {
    if(j<=a[0])
      dp[0][j]=1;
    else
      dp[0][j]=0;
  }
  for(j=1;j<=k;j++)
  {
    p[0][j]=p[0][j-1]+dp[0][j];
    p[0][j]%=hell;
  }
  for(i=1;i<n;i++)
  {
    for(j=1;j<=k;j++)
     {
       int l=j-a[i];
       if(l<0)
        l=0;
       if(l==0)
        dp[i][j]= p[i-1][j]%hell;
       else
        dp[i][j]= (p[i-1][j]-p[i-1][l-1]+hell)%hell;
       p[i][j]=(p[i][j-1]+dp[i][j])%hell;   
     }
  }
  cout<<dp[n-1][k]%hell;
}
signed main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t;
  t=1;
  //cin>>t;
  while(t--)
  solve();
  TIME
  return 0;
}

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

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

 if(n==0)break;
 
 int  len[40];
 for(int  i=0;i<n;i++){
	string w;
	cin>>w;

	len[i]=w.size();
 }

 for(int i=0;i<n;i++){
	bool flg=false;
	int sta=0;
	int sum=0;

	for(int j=i;j<n;j++){
		sum+=len[j];

		if(sum==5||sum==12||sum==17||sum==24||sum==31){
			sta++;
		}
		if(sta==5){
			flg=true;
			break;
		}else if(sum>=31){
			break;
		}
	}
 	if(flg){
		cout<<i+1<<endl;
		break;
	}
 }
}
return 0;
} 
			

 


Measured memory_bytes: 3216
using System;
using System.Linq;
public class Hello{
    //imit
    static int A,B,C,N;
    
    static int[] l;
    
    public static void Main(){
        var s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        N = s[0];
        A = s[1];
        B = s[2];
        C = s[3];
        
        l = new int[N];
        
        for(var i = 0;i < N;i++){
            l[i] = int.Parse(Console.ReadLine());
        }
        
        Console.WriteLine(Calc(0,0,0,0));
    }
    
    static int Calc(int cnt,int a,int b,int c){
        if(cnt == N){
            return a == 0 || b == 0 || c == 0 ? 1000000 : Math.Abs(A - a) + Math.Abs(B - b) + Math.Abs(C - c) - 30;
        }
        
        var pattern = new int[4];
        pattern[0] = Calc(cnt + 1,a,b,c);
        pattern[1] = Calc(cnt + 1,a + l[cnt],b,c) + 10;
        pattern[2] = Calc(cnt + 1,a,b + l[cnt],c) + 10;
        pattern[3] = Calc(cnt + 1,a,b,c + l[cnt]) + 10;
        
        return pattern.Min();
    }
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

signed main() {
    int N;
    cin >> N;
    vint A(N);
    int k = 1;
    double K = 1;
    rep(i, N) {
        cin >> A[i];
        k *= A[i], K *= A[i];
    }
    int b = 1e18;
    if (k > b || K > b) { cout << -1 << endl; }
    else { cout << k << endl; }
}


Measured memory_bytes: 4060
#include <bits/stdc++.h>
using namespace std;
constexpr int MOD = 1000000007;
int main()
{
    int n;
    cin >> n;
    vector<long long> a(n);
    for(int i = 0; i < n; i++)
        cin >> a[i];
    
    long long ans = 0, dgt = 1, cnt = 0; 
    for(int i = 0; i <= 60; i++) {
        cnt = 0;
        for(int j = 0; j < n; j++) {
            if ((a[j] >> i) & 1)
                cnt++;
        }
        // cout << ans << " " << cnt << " " << dgt << '\n';
        ans += ((cnt * (n - cnt)) % MOD) * dgt % MOD;
        dgt = dgt * 2 % MOD;
    }
    cout << ans % MOD << '\n';
    return 0;
}

Measured memory_bytes: 2560
let rec read t n =
  if n = 0 then ()
  else
    begin
      let a, b = Scanf.scanf "%d %d\n" (fun x y -> (x, y)) in
      if Hashtbl.mem t a then
        Hashtbl.replace t a (Hashtbl.find t a + b)
      else
        Hashtbl.replace t a b;
      read t (n-1)
    end

let rec solve k c = function
    [] -> 0
  | (x, y) :: rs -> if k <= c + y then x else solve k (c+y) rs
    
let () =
  let n, k = Scanf.scanf "%d %d\n" (fun x y -> (x, y)) in
  let tbl = Hashtbl.create n in
  read tbl n;
  let l = List.sort compare @@ Hashtbl.fold (fun a b c -> (a,b)::c) tbl [] in
  Printf.printf "%d\n" @@ solve k 0 l


Measured memory_bytes: 10752
#include <iostream>
using namespace std;
int main(void){
    long long int H,W;
    cin>>H>>W;
    if(H>1 & W>1 & H*W%2==0){
        cout<<H*W/2<<endl;
    }
    else if(H>1 & W>1 & H*W%2==1){
        cout<<H*W/2+1<<endl;
    }
    else if (H==1){
        cout<<1<<endl;
    }
    else if(W==1){
        cout<<1<<endl;
    }
    
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
 
#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to
#define mp(a, b) make_pair(a, b)
 
using namespace std;

typedef long long LL;
const int N = 100010;

struct Edge{ int to, next, c;} edge[N * 2];
int head[N], num;
void add_edge(int a, int b, int c) { edge[++ num] = (Edge){b, head[a], c}, head[a] = num;}

bool vis[N], flag;
int col[N], cnt[4], cn, cm;
void dfs(int x)
{
	vis[x] = true, cnt[col[x]] ++, cn ++;
	RepG(i, x) {
		cm ++;
		int cv = (col[x] + edge[i].c + 3) % 3;
		if (!vis[v]){ col[v] = cv; dfs(v);}
		else if (col[v] != cv) flag = true;
	}
}

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	Rep(i, m) {
		int a, b;
		scanf("%d%d", &a, &b);
		add_edge(a, b, 1); add_edge(b, a, -1);
	}
	
	LL ans = 0;
	
	Rep(i, n) if (!vis[i]) {
		cnt[0] = cnt[1] = cnt[2] = cn = cm = 0, flag = false;
		dfs(i);
	//	printf("%d %d %d %d\n", cnt[0], cnt[1], cnt[2], flag);
		if (flag) ans += 1ll * cn * cn;
		else if (!cnt[1] || !cnt[2]) ans += cm / 2;
		else ans += 1ll * cnt[0] * cnt[1] + 1ll * cnt[0] * cnt[2] + 1ll * cnt[1] * cnt[2];
	}
	
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 6528
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;

vector <int> vd, vt;

int main(){
	int i, j, n, m;

	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d", &j), vd.push_back(j);
	scanf("%d", &m);
	for (i = 0; i < m; i++) scanf("%d", &j), vt.push_back(j);

	if (n < m) {
		printf("NO\n");
		return 0;
	}

	sort(vd.begin(), vd.end());
	vector<int>::iterator it;
	for (it = vt.begin(); it != vt.end(); it++) {
		vector<int>::iterator lit = lower_bound(vd.begin(), vd.end(), *it);
		vector<int>::iterator uit = upper_bound(vd.begin(), vd.end(), *it);
		if (uit - lit == 0) {
			break;
		} else {
			vd.erase(lit);
		}
	}

	if (it == vt.end()) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}

	return 0;
}


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

int main(){

    int a, b;
    cin >> a >> b;

    if (a>b) rep(i,a) cout << b;
    else rep(i, b) cout << a;
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second

int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};



main(){
  int n;
  while(cin>>n){
    int p[n];
    rep(i,n)cin>>p[i];
    sort(p,p+n);

    int ans=0;
    int time=0;
    rep(i,n){
      time+=p[i];
      ans+=time;
    }
      
    cout<<ans<<endl;
  }
}

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

int main(){
    ll K;
    
    cin>>K;
    
    ll rem=7%K;
    unordered_set<ll> st;
    st.insert(rem);
    ll count=1;
    int f=0;
    ll MAX=1e6 +5;
    while(count<MAX){
        if(rem==0){
            cout<<count<<"\n";
            f=1;
            break;
        }
        
            st.insert(rem);
            rem=((rem*10)+7)%K;
        count++;
    }
   if(f==0)
   cout<<-1<<"\n";
    return 0;
}

Measured memory_bytes: 42524
s = input()
q = int(input())
c = 0
t = ""
u = ""
for i in range(q):
    qy = list(input().split())
    if qy[0] == "1":
        c += 1
    else:
        if (qy[1] == "1" and c % 2 == 0) or (qy[1] == "2" and c % 2 == 1):
            t = qy[2] + t
        else:
            u = u + qy[2]
ans = t + s + u
if c % 2 == 0:
    print(t + s + u)
else:
    print(ans[::-1])

Measured memory_bytes: 4852
module Main where

main :: IO ()
main = do
  steps <- getLine
  putStrLn $ isEasyDance steps

isEasyDance :: [Char] -> String
isEasyDance steps = isEasyOdd steps

isEasyEven :: [Char] -> String
isEasyEven [] = "Yes"
isEasyEven (x:xs) = if x == 'L' || x == 'U' || x == 'D'
  then isEasyOdd xs
  else "No"

isEasyOdd :: [Char] -> String
isEasyOdd [] = "Yes"
isEasyOdd (x:xs) = if x == 'R' || x == 'U' || x == 'D'
  then isEasyEven xs
  else "No"

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////
	int a,b;
	char o;
	cin >> a >> o >> b;
	cout << (o=='+' ? a+b : a-b) << endl;

	
//////////////////////////////////////////////
}


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

using namespace std;

typedef long long int ll;

#define FOR(i,l,r) for(i=l;i<r;i++)

#define REP(i,n) FOR(i,0,n)

#define ALL(x) x.begin(),x.end()

#define P pair<ll,ll>

#define F first

#define S second

signed main(){

  ll x=3,i=0;
  while(x!=0){
    cin>>x;i++;
  }
  cout<<i<<endl;

  return 0;

}

Measured memory_bytes: 3584
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int maxn = 1e5;
int cnt[maxn + 10];
int n, a, ans;
int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a);
		cnt[a + 1]++;
		cnt[a]++;
		cnt[a + 2]++;
	}
	for(int i = 1; i <= maxn + 1; i++)ans = max(ans, cnt[i]);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#define MAXN 200005
#define ll long long
using namespace std;
ll read(){
	char c;ll x=0,y=1;while(c=getchar(),(c<'0'||c>'9')&&c!='-');
	if(c=='-') y=-1;else x=c-'0';while(c=getchar(),c>='0'&&c<='9')
	x=x*10+c-'0';return x*y;
}
ll n,a[MAXN],tot,ans;
int main()
{
	n=read();
	for(ll i=1;i<=n;i++) a[i]=read()-i;
	sort(a+1,a+1+n);
	tot=a[(n+1)/2];
	for(ll i=1;i<=n;i++) ans+=abs(a[i]-tot);
	printf("%lld",ans);
	return 0;
}

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

#define int long long
#define ll long long
#define ffor(i,n) for(int i = 0;i < (n); ++i)
#define fro(i,j,n) for(int i = (j);i < (n); ++i)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pii>
#define ff first
#define ss second
const int mod = 1e9 + 7;
int add(int a,int b){
	return (a + b)%mod;
}
int sub(int a,int b){
	return add(a,mod - 1);
}
int mul(int a,int b){
	return (a*b)%mod;
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    int x;
    cin >> x;
    int p = 100;
    int ans = 0;
    while(p < x){
    	p = p + p/100;
    	ans++;
    }
    cout << ans;
}

Measured memory_bytes: 3652
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

int dy[5] = { 0,0,1,-1,0 };
int dx[5] = { 1,-1,0,0 ,0 };




int main(void) {
	long long int n, m;
	long long int a, b;
	long long int count = 0;
	long long int money = 0;

	cin >> n >> m;
	vector< pair <long long int, long long int> > pa(n);
	FOR(i, 1, n) {
		cin >> a >> b;
		pa[i - 1].first = a;
		pa[i - 1].second = b;
	}

	sort(pa.begin(), pa.end());
	FOR(i, 0, n - 1) {
		if (count + pa[i].second <= m) {
			count += pa[i].second;
			money += pa[i].first*pa[i].second;
		}
		else {
			money += pa[i].first*(m - count);
			count = m;
		}

		if (count >= m) {
			break;
		}
	}

	cout << money << endl;


	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  signed long N,D;
  cin >> N >> D;

  int a = 0;
  for (int i=0; i<N; i++) {
    signed long X,Y;
    cin >> X >> Y;
    
    double d = sqrt(X*X + Y*Y);
    if (d <= D) {
      a++;
    }
  }
  
  cout << a << endl;
}




Measured memory_bytes: 3668
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    class Program
    {
        static void Main(string[] args)
        {
            var vals = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var A = vals[0];
            var B = vals[1];
            if (B % A == 0)
            {
                Console.WriteLine(A + B);
            }
            else
            {
                Console.WriteLine(B - A);
            }
        }

    }
}
//A

Measured memory_bytes: 11348
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<random>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s; cin >> s;
    // vector<char> s(n); cin >> s;
    int q; cin >> q;
    for(int h = 0; h < q; h++){
        int k; cin >> k;
        int ms = 0, cs = 0;
        ll num = 0, ans = 0;
        for(int i = 0; i < k - 1; i++){
            if(s[i] == 'M'){
                ms++;
            }else if(s[i] == 'C'){
                cs++;
                num += ms;
            }
        }
        for(int i = 0; i < n; i++){
            if(i + k - 1 < n){
                if(s[i + k - 1] == 'M'){
                    ms++;
                }else if(s[i + k - 1] == 'C'){
                    cs++;
                    num += ms;
                }
            }
            if(s[i] == 'D'){
                ans += num;
                // printde(i, ans, num);
            }else if(s[i] == 'M'){
                ms--;
                num -= cs;
            }else if(s[i] == 'C'){
                cs--;
            }
        }
        if(num){
            return 1;
        }
        cout << ans << '\n';
    }
}


Measured memory_bytes: 1948
class SegmentTree():

    def __init__(self,init_val,n): #init_valは長さnの配列 O(2*n)
        self.n=n
        self.ide_ele=0
        self.num=pow(2,n-1).bit_length() #n以上の最小の2のべき乗
        self.seg=[self.ide_ele]*2*self.num #セグメントツリー本体
        
        for i in range(n):
            self.seg[i+self.num-1]=init_val[i] 
        
        for i in range(self.num-2,-1,-1):
            self.seg[i]=(self.seg[2*i+1])|(self.seg[2*i+2])        
        
      
    def update(self,k,x): #k番目の要素をxに変更する O(logN)
        k+=self.num-1
        self.seg[k]=x
        while k:
            k=(k-1)//2
            self.seg[k]=(self.seg[2*k+1])|(self.seg[2*k+2])
    
    def query(self,p,q): #[p,q)のクエリに答える O(logN)
        if q<=p:
            return self.ide_ele

        p+=self.num-1
        q+=self.num-2
        res=self.ide_ele

        while q-p>1:

            if (p&1)==0:
                res|=self.seg[p]

            if (q&1)==1:
                res|=self.seg[q]
                q-=1
            p//=2
            q=(q-1)//2
        
        if p==q:
            res|=self.seg[p]
        else:
            res=(res|self.seg[p])|self.seg[q]
        
        return bin(res).count('1')

def main():
    n=int(input())
    s=input()

    dic={i:j for i,j in zip('abcdefghijklmnopqrstuvwxyz',[2**i for i in range(26)])}
    l=[0]*n

    for i in range(n):
        l[i]=dic[s[i]]

    st=SegmentTree(l,n)
    
    q=int(input())
    for _ in range(q):
        a=list(map(str,input().split()))
        a[0]=int(a[0])

        if a[0]==1:
            a[1]=int(a[1])
            st.update(a[1]-1,dic[a[2]])
        
        else:
            a[1]=int(a[1])-1
            a[2]=int(a[2])
            print(st.query(a[1],a[2]))
            
if __name__=='__main__':
    main()

Measured memory_bytes: 31384
#include <iostream>
#include <string>
using namespace std;
typedef signed long long ll;


int arr[57];
int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			ans += arr[j] * arr[i];
		}
	}
	cout << ans << endl;
	 return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		String s=scanner.next();
		StringBuilder sb=new StringBuilder();
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i)=='C'||s.charAt(i)=='F') {
				sb.append(s.charAt(i));
			}
		}
		String re=sb.toString();
		if (re.contains("CF")) {
			System.out.print("Yes");
		}else {
			System.out.print("No");
		}
	}
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n ;
    cin >> n;
    ll m = 0,a, ans = 0;
    for(int i=0;i<n;i++){
        cin >> a;
        if(a < m){
            ans += m - a;
        }else{
            m = a;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <sstream>
int main()
{
        for(uint8_t i=0;i<200;i++)
        {
                std::string str;
                getline(std::cin, str);
                if(std::cin.eof())
                        break;
                std::stringstream s(str);
                uint32_t a,b;
                s>>a>>b;
                uint32_t sum=a+b;
                uint8_t count;
                for(count=0;sum>0;count++)
                        sum=sum/10;
                if(count==0)
                        count++;
                printf("%u\n",count);
        }

        return 0;
}

Measured memory_bytes: 3232
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        double r;
        cin >> n >> r;
        if(n == 0)
            return 0;

        vector<double> x(n), y(n);
        for(int i=0; i<n; ++i)
            cin >> x[i] >> y[i];

        vector<double> s(n-1), t(n-1); // y = s * x + t
        for(int i=0; i<n-1; ++i){
            s[i] = (y[i+1] - y[i]) / (x[i+1] - x[i]);
            t[i] = y[i] - s[i] * x[i];
        }

        double ret = 0.0;
        for(int i=0; i<n-1; ++i){
            for(int j=0; j<n-1; ++j){
                double x1 = max(x[i], x[j] - r);
                double x2 = min(x[i+1], x[j+1] - r);
                if(x1 > x2)
                    continue;

                double s1 = s[i];
                double t1 = t[i];
                double s2 = s[j];
                double t2 = t[j] + s[j] * r;

                double a, b, c; // y = a * x^2 + b * x + c
                a = s1 * s2;
                b = s1 * t2 + s2 * t1;
                c = t1 * t2;
                
                ret += a / 3 * pow(x2, 3) + b / 2 * pow(x2, 2) + c * x2;
                ret -= a / 3 * pow(x1, 3) + b / 2 * pow(x1, 2) + c * x1;
            }
        }
        printf("%.10f\n", ret);
    }
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, k, i, h;
  in3(a, b, k);
  i = 1;
  h = __gcd(a, b);
  while(true){
    if(h % i == 0)
      k--;
    if(k == 0){
      i = h / i;
      break;
    }
    i++;
  }
  out(i);
  memi;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define debug(X) cout << #X << " = " << X << endl

using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	#ifdef UTP
	freopen("input.txt", "r", stdin);
	#endif
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
        int x; cin >> x;
        a[i] = x - i - 1;
	}
	sort(a.begin(), a.end());
    int b = a[n / 2];
    long long ans = 0;
    for (int i = 0; i < n; i++)
        ans += abs(a[i] - b);
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
    int A,B,K;
    scanf ("%d %d", &A, &B);
    K = abs (A+B) / 2;
    if (abs (A-K) == abs (B-K))
        printf ("%d", K);
    else
        printf ("IMPOSSIBLE");
    return 0;
}


Measured memory_bytes: 256
main(){double a,b,c,d,e,f,g,h;for(scanf("%f",&a);~scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f,&g,&h);)puts((c-a)*(h-f)-(d-b)*(g-e)?"NO":"YES");return 0;}

Measured memory_bytes: 616
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using P = pair<int, int>;
void chmax(P &a, P b) {
  if (a.first < b.first) {
    a.second = max(a.first, b.second);
    a.first = b.first;
  }
  else
    a.second = max(a.second, b.first);
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(1<<n);
  rep(i, 1<<n) cin >> a[i];
  vector<vector<P>> dp(1<<n, vector<P>(n+1));
  rep(i, 1<<n)
    dp[i][0].first = a[i];
  rep(j, n) {
    rep(i, 1<<n) {
      chmax(dp[i][j+1], dp[i][j]);
      if (i>>j & 1)
        chmax(dp[i][j+1], dp[i^1<<j][j]);
    }
  }
  vector<int> res(1<<n);
  for (int i = 1; i < 1<<n ; i++) {
    res[i] = max(res[i-1], dp[i][n].first+dp[i][n].second);
    cout << res[i] << '\n';
  }
  return 0;
}

Measured memory_bytes: 52572
#include <stdio.h>
#define N 100000

int BinarySearch(int, int *, int);

int main()
{
  int i, j;
  int n, q;
  int nl[N], s;
  int count = 0;

  scanf("%d", &n);
  for(i = 0; i < n; i++)
    {
      scanf("%d", &nl[i]);
    }

  scanf("%d", &q);
  for(i = 0; i < q; i++)
    {
      scanf("%d", &s);
      if(BinarySearch(n, nl, s) == 1) 
	{
	  count++;
	}
    }
  printf("%d\n", count);

  return 0;
}

int BinarySearch(int n, int *nl, int s)
{
  int left, mid, right;

  left = 0;
  right = n;
  mid = (left + right) / 2;

  while(nl[mid] != s)
    {
      if(left + 1 == right) return 0;
      if(nl[mid] < s) left = mid;
      else right = mid;

      mid = (left + right) / 2;
    }

  return 1;
}

Measured memory_bytes: 988
#include <stdio.h>

int main(void) {
	int honsuu;
	int genkai;
	int turara[100000];
	int i;
	int nowsum;
	int maxsum;
	int status;
	scanf("%d %d",&honsuu,&genkai);
	for(i=0;i<honsuu;i++)scanf("%d",&turara[i]);
	status=0;
	maxsum=0;
	nowsum=genkai-turara[0];
	for(i=1;i<honsuu;i++) {
		if((turara[i]-turara[i-1])*status<0) {
			if(nowsum>maxsum)maxsum=nowsum;
			nowsum=(genkai-turara[i-1])+(genkai-turara[i]);
		} else nowsum+=genkai-turara[i];
		status=(turara[i]>turara[i-1])?1:-1;
	}
	if(nowsum>maxsum)maxsum=nowsum;
	printf("%d\n",maxsum);
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  n<<=1;
  vector<Int> l(n);
  for(Int i=0;i<n;i++) cin>>l[i];
  Int ans=0;
  sort(l.rbegin(),l.rend());
  for(Int i=0;i+1<n;i+=2) ans+=l[i+1];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env pypy3

import sys
sys.dont_write_bytecode = True
stdin = sys.stdin
input = stdin.readline
#sys.setrecursionlimit(100000)

#import numpy as np
#import scipy as sp

# Python 3 modules: https://docs.python.org/3/library/

import math, itertools, operator
from math import *
from math import factorial as fact
from operator import itemgetter, attrgetter
from itertools import permutations, combinations
from functools import reduce
# Use scipy for stats: https://docs.scipy.org/doc/scipy/reference/stats.html
# Before Python 3.5.  Import from math after it.
from fractions import gcd
from fractions import Fraction as Frac

inf = float('inf')

def lcm(a, b):
    return a * b // gcd(a,b)

def perm(a, b):
    import scipy.special
    return scipy.special.perm(a, b, exact = True)

def comb(a, b):
    import scipy.special
    return scipy.special.comb(a, b, exact = True)

def dfact(n):
    import scipy.special
    return scipy.special.factorial2(n, exact = True)

def prod(l):
    return reduce(operator.mul, l)

def input_ints(func = input, sep = None, conv = int):
    return list(map(conv, func().split(sep = sep)))

################################################################################

P,Q,R = list(map(int, input().split()))

print(P+Q+R-max(P,Q,R))


Measured memory_bytes: 5636
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var s string
	fmt.Fscan(r, &s)

	if s == "ABC" {
		fmt.Println("ARC")
	} else {
		fmt.Println("ABC")
	}

}

// Union-Find
type unionFind struct {
	d []int
}

func newUnionFind(n int) *unionFind {
	uf := new(unionFind)
	uf.d = make([]int, n)
	for i := 0; i < n; i++ {
		uf.d[i] = -1
	}
	return uf
}

func (uf *unionFind) find(x int) int {
	if uf.d[x] < 0 {
		return x
	}
	uf.d[x] = uf.find(uf.d[x])
	return uf.d[x]
}

func (uf *unionFind) unite(x, y int) bool {
	rootX := uf.find(x)
	rootY := uf.find(y)
	if rootX == rootY {
		return false
	}

	if uf.d[rootX] < uf.d[rootY] {
		uf.d[rootX] += uf.d[rootY]
		uf.d[rootY] = rootX
	} else {
		uf.d[rootY] += uf.d[rootX]
		uf.d[rootX] = rootY
	}

	return true
}

func (uf *unionFind) same(x, y int) bool {
	return uf.find(x) == uf.find(y)
}

func (uf *unionFind) size(x int) int {
	return -uf.d[uf.find(x)]
}

// mod combination
func modpow(a, n, mod int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % mod
		}
		a = a * a % mod
		n = n / 2
	}
	return res
}

func modcomb(n, a, mod int) int {
	x := 1
	y := 1
	for i := 0; i < a; i++ {
		x = x * (n - i)
		x %= mod
		y = y * (i + 1)
		y %= mod
	}
	return x * modpow(y, mod-2, mod) % mod
}

func modfactorial(n, mod int) int {
	result := 1
	for i := 1; i <= n; i++ {
		result = (result * i) % mod
	}
	return result
}

// Utility

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func primeFactor(x int) map[int]int {
	res := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			res[i]++
			x = x / i
		}
	}
	if x != 1 {
		res[x] = 1
	}
	return res
}

func divisor(x int) []int {
	res := make([]int, 0)
	for i := 1; i*i <= x; i++ {
		if x%i == 0 {
			res = append(res, i)
			if i != x/i {
				res = append(res, x/i)
			}
		}
	}
	return res
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}

func reverseString(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

// Queue ...
type Queue []int

// pop ...
func (q *Queue) empty() bool {
	return len(*q) == 0
}

// push ...
func (q *Queue) push(i int) {
	*q = append(*q, i)
}

// pop ...
func (q *Queue) pop() (int, bool) {
	if q.empty() {
		return 0, false
	} else {
		res := (*q)[0]
		*q = (*q)[1:]
		return res, true
	}
}

// Stack ...
type Stack []int

// pop ...
func (s *Stack) empty() bool {
	return len(*s) == 0
}

// push ...
func (s *Stack) push(i int) {
	*s = append(*s, i)
}

// pop ...
func (s *Stack) pop() (int, bool) {
	if s.empty() {
		return 0, false
	} else {
		index := len(*s) - 1
		res := (*s)[index]
		*s = (*s)[:index]
		return res, true
	}
}


Measured memory_bytes: 1824
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll memo[401][401];
int n,arr[401];
ll solve(int l,int r){
    if(l>=r) {
        return 0;
    }
    ll &cur=memo[l][r];
    if(cur!=-1)
        return cur;
    cur=1e16;
    ll sum=0;
    for(int i=l;i<=r;i++)
        sum+=arr[i];
    for(int i=l;i<=r;i++){
        cur=min(cur,solve(l,i)+solve(i+1,r)+sum);
    }
    return cur;
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    memset(memo,-1,sizeof(memo));
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    cout<<solve(0,n-1);
}

Measured memory_bytes: 1536
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc105_b
{
    class Program
    {
        static bool Solve(int n)
        {
            if (n < 0) return false;
            if (n == 0) return true;
            return Solve(n - 4) || Solve(n - 7);
        }

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            if(Solve(n))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13140
import java.util.*;

public class Main {

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

        double sum = 0;
        for(int i = 0; i < n;i++){
            double num = sc.nextDouble();
            String s = sc.next();
            if(s.equals("JPY")){
                sum += num;
            } else {
                sum += num *  380000.0;
            }
        }
        System.out.println(sum);
    }
}

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

int main(){
  long long w,h,x,y;
  cin >> w >> h >> x >> y;

  int ans=0;
  if((double)x==w/2.0 && (double)y==h/2.0) ans++;

  
   printf("%.10f",w*h/2.0);
//  cout << (double) w*h/2.0;
  cout << " " << ans << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;

#[allow(unused_imports)]
use std::collections::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let N: usize = read();
    let H: Vec<i32> = read_vec();
    let mut tmp_max = 0i32;
    let mut ans = 0i32;
    for i in 0..N {
        if tmp_max <= H[i] {
            ans += 1;
        }
        tmp_max = max(tmp_max, H[i]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <fstream>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

//#define _debug
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc(x) scanf("%d",&x)
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORd(i,a,b) for(int i=a;i>b;i--)
#define ff first
#define ss second
#define sz(x) x.size()
#define pb push_back
//#define _online_judge

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, //data type
        null_type, //
        less<int>, //
        rb_tree_tag, //red-black tree
        tree_order_statistics_node_update> new_data_set;

typedef pair<int,int> pii;
typedef vector<pii> vii;
const int con = static_cast<const int>(1e5 + 2);
const int MOD = 1000000007;

ll gcd(ll a, ll b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);

}

int main (){
	FASTIO
#ifdef _online_judge
	freopen("input.txt" , "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif

    ll a,b,c;cin >> a >> b >> c;
    if(a != 0)
        cout << b/c - (a-1)/c;
    else
        cout << b/c + 1;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define EPS (1e-10)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

float t[100],v[100];
map<int,float>dp[60000];

int main(){
	int n;scanf("%d",&n);
	rep(i,n)cin>>t[i],t[i]*=2;
	rep(i,n)cin>>v[i],v[i]*=2;
	int k=0;
	int sum=t[0];
	dp[0][0]=0;
	rep(i,50000){
		bool flag=false;
		if(i+1>=sum){
			if(k<n-1){
				flag=true;
				k++;sum+=t[k];
			}
		}
		for(auto p:dp[i]){
			int j=p.first;
			if(j&&j-1<=v[k])dp[i+1][j-1]=max(dp[i+1][j-1],dp[i][j]+j-1);
			if(j+1<=v[k]){
				if(flag){
					if(j+1<=v[k-1])dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+j+1);
				}
				else dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+j+1);
			}
			if(j<=v[k])dp[i+1][j]=max(dp[i+1][j],dp[i][j]+j);
		}
		if(i+1>=sum&&k==n-1)break;
	}
	printf("%.12f\n",dp[sum][0]/4);
}


Measured memory_bytes: 199936
#include <iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define g 9.80
#define eps 1e-10
int top;

int n;
double v,xx,yy;
struct rectangle
{
       double l,r,b,t;
}rec[101];

bool judge(double a,double len )
{
     int i;
     double hh = a*xx*(xx-len);
     double hi = -a*len*len/4.0;//抛物&#32447;最高点的y坐&#26631; 
     if ( yy-hh>eps || yy-hi>eps ) return false;//抛物&#32447;&#39134;&#36807;pig下方 
     for ( i=1;i<=n;i++ )
     {
         if ( rec[i].l>xx ) break;//障碍物的左&#36793;界大于pig的x坐&#26631; 
         double h1 = a*rec[i].l*(rec[i].l-len );//左&#36793;界&#23545;&#24212;的高度 
         double h2 = a*rec[i].r*(rec[i].r-len );//右&#36793;界&#23545;&#24212;的高度 
         if ( h1>=rec[i].b && h1<=rec[i].t ) return false;
         if ( h2>=rec[i].b && h2<=rec[i].t ) return false;//撞上&#36793;界 
         if ( h1<rec[i].b && h2<rec[i].b ) //抛物&#32447;从矩形下方&#39134;&#36807; 
              if (  len/2-rec[i].l>eps && rec[i].r-len/2>eps && hi-rec[i].b>eps  ) 
                 return false;//抛物&#32447;最高点在矩形中或者高于矩形 
         if ( rec[i].l<=xx && rec[i].r>=xx  && rec[i].b>yy ) //pig 在一个矩形的下面 
             if ( hh>rec[i].t ) return false;
     }
     return true;
}


void solve()
{
     int i;
     double h,t,vx,vy,len;
     for ( i=1;i<=1000000;i++ )
     {
           vy=double(i)/1000000*v;
           vx=sqrt(v*v-vy*vy);
           t=vy/g;
           h = g*t*t/2;
           len = vx*2*t;
           if ( xx-len>eps ) continue;
           else
           {
               double a = (-2*vy*vy)/(g*len*len);
               if ( judge(a,len) )
               {
                    printf("Yes\n");
                    return ;
               }
           }
     }
     printf("No\n");
}

bool cmp(rectangle a,rectangle b)
{
     return a.l<b.l;
}

int main()
{
    int i;
    while ( scanf("%d %lf %lf %lf",&n,&v,&xx,&yy)!=EOF )
    {
          for ( i=1;i<=n;i++ )
          {
              scanf("%lf %lf %lf %lf",&rec[i].l,&rec[i].b,&rec[i].r,&rec[i].t);
              rec[i].r = min(xx,rec[i].r);
          }
          sort(rec+1,rec+n+1,cmp);
          solve();
    }
    return 0;
}
          
          
          
          

Measured memory_bytes: 884
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main() {
	int n;
	cin>>n;
	vector<double> p(n+1);
	for(int i=1;i<=n;i++) {
		cin>>p[i];
	}
	vector<vector<double>> dp(n+1,vector<double> (n+1));
	dp[0][0] = 1.0;
	for(int i=1;i<=n;i++) {
		dp[i][0] = (1-p[i]) * dp[i-1][0];
		for(int j=1;j<=i;j++) {
				dp[i][j] = dp[i-1][j-1] * p[i] + dp[i-1][j] * (1-p[i]);
		}
	}
	double ans=0.0;
	for(int i=n/2+1;i<=n;i++){
			ans+=dp[n][i];
	}
	cout<<setprecision(10)<<ans;
}



Measured memory_bytes: 73676
#include<iostream>
#define MAXNUM 1000000007
using namespace std;
int main(){
	int n;
	long long int a[200005];
	cin>>n;
	long long int sum=0;
	
	for(int i=0;i<n;i++){
		cin>>a[i];	
	}
	long long int front=0;
	long long int last=0;
	for(int i=1;i<n;i++){
		front=a[i];
		last+=a[i-1];
		last=last%1000000007;
		sum+=(front*last);
		sum=sum%1000000007;
	}
//	long long int cnt=1;
	cout<<sum;

}

Measured memory_bytes: 5136