akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e18;
int inf = 1e9;
ll MOD = 1e9+7;

struct Dijkstra {
    struct Edge {
        ll to;
        ll c;
    };

    int V;
    vector<vector<Edge>> e;
    vector<ll> d;

    Dijkstra(int V): V(V) {
        e.resize(V);
        d.resize(V);
    }

    void add_edge(int from, int to, ll cost) {
        e[from].pb({to, cost});
    }

    void operator()(ll s) {
        priority_queue<Pll, vector<Pll>, greater<>> q;

        REP(i, V) d[i] = INF;
        d[s] = 0;
        q.push({0, s});

        while(!q.empty()) {
            Pll n = q.top(); q.pop();
            ll v = n.se;
            if (d[v] < n.fi) continue;

            REP(i, e[v].size()) {
                Edge cur = e[v][i];
                ll cost = d[v] + cur.c;
               if (d[cur.to] > cost) {
                    d[cur.to] = cost;
                    q.push({cost, cur.to});
                }
            }
        }
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, M;
    cin >> N >> M;

    Dijkstra graph(3 * N);

    REP(i, M) {
        int u, v; cin >> u >> v;
        --u; --v;
        graph.add_edge(3 * u, 3 * v + 1, 1);
        graph.add_edge(3 * u + 1, 3 * v + 2, 1);
        graph.add_edge(3 * u + 2, 3 * v, 1);
    }

    int s, t;
    cin >> s >> t;
    --s; --t;

    graph(s * 3);
    print(graph.d[3 * t] == INF ? -1 : graph.d[3 * t] / 3);
    
}


Measured memory_bytes: 21888
n = int(input())
a = []
for i in range(n):
    a.append(list(map(int,input().split())))
a = sorted(a, key=lambda x: x[1])
ans = 'Yes'
x = 0
for s in a:
    x += s[0]
    if x > s[1] :
        ans = 'No'
        break
print(ans)

Measured memory_bytes: 90200
#include <bits/stdc++.h>
using namespace std;
int n, Q;
string s;
int sum[100000];
int main()
{
    cin >> n >> Q;
    cin >> s;
    for (int i = 1; i < n; i++)
    {
        if (s.substr(i - 1, 2) == "AC")
        {
            sum[i] = sum[i - 1] + 1;
        }
        else
        {
            sum[i] = sum[i - 1];
        }
    }
    for (int i = 0; i < Q; i++)
    {
        int l, r;
        cin >> l >> r;
        cout << sum[r - 1] - sum[l - 1] << endl;
    }
    return 0;
}

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


int main()
{
	int n,m;
	char a[55][55],b[55][55];
	bool flag=true;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>a[i][j];
		}
	}
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<m;j++)
		{
			cin>>b[i][j];
		}
	}
	for(int i=0;i<=n-m;i++)
	{
		for(int j=0;j<=n-m;j++)
		{
			flag=true;
			for(int k=i;k<i+m;k++)
			{
				for(int l=j;l<j+m;l++)
				{
					if(a[k][l]!=b[k-i][l-j])flag=false;
				}
			}
			if(flag)
			{
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[][] a = new int[3][3];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                a[i][j] = sc.nextInt();
            }
        }
        boolean[][] bingo = new boolean[3][3];
//        Arrays.fill(bingo,false);
        int N = sc.nextInt();
        int[] b = new int[N];
        for (int i = 0; i < N; i++) {
            b[i] = sc.nextInt();
        }
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    if(a[j][k]==b[i]){
                        bingo[j][k] = true;
                    }
                }
            }
        }

        if(bingo[0][0] && bingo[0][1] && bingo[0][2]){
            System.out.println("Yes");
            return;
        }
        if(bingo[1][0] && bingo[1][1] && bingo[1][2]){
            System.out.println("Yes");
            return;
        }
        if(bingo[2][0] && bingo[2][1] && bingo[2][2]){
            System.out.println("Yes");
            return;
        }
        if(bingo[0][0] && bingo[1][0] && bingo[2][0]){
            System.out.println("Yes");
            return;
        }if(bingo[0][1] && bingo[1][1] && bingo[2][1]){
            System.out.println("Yes");
            return;
        }if(bingo[0][2] && bingo[1][2] && bingo[2][2]){
            System.out.println("Yes");
            return;
        }
        if(bingo[0][0] && bingo[1][1] && bingo[2][2]){
            System.out.println("Yes");
            return;
        }
        if(bingo[0][2] && bingo[1][1] && bingo[2][0]){
            System.out.println("Yes");
            return;
        }

        System.out.println("No");


    }
}

Measured memory_bytes: 24020
let id x = x
let n = 19
let repeat f =
  let rec loop acc = function
    | 0 -> List.rev acc
    | n -> loop (f () :: acc) (n-1) in
  loop []

let r = repeat (fun () -> Scanf.scanf "%c" id) n

let rec makelist = function
  | [] -> []
  | a :: rest ->
     match a with
     | ',' -> ' ' :: makelist rest
     | _   -> a :: makelist rest

let rec list_to_string : char list -> string = fun cl ->
   String.concat "" @@ List.map (String.make 1) cl
	
let ans =
  let a = makelist r in
  list_to_string a

let () = Printf.printf "%s\n" ans

Measured memory_bytes: 384
/***************************************************
 * Problem Name : E.cpp
 * Problem Link :
 * OJ           :
 * Verdict      : Trying
 * Date         : 2020-05-03
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <bitset>
#include <cassert>
#include <map>
#include <set>
#include <cassert>
#include <iomanip>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;

#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define __FileRead freopen ("input.txt", "r", stdin)
#define __FileWrite freopen ("output.txt", "w", stdout)
#define SET(a,v) memset(a,v,sizeof(a))
#define SZ(v) (int)v.size()
#define pii pair<int,int>
#define pil pair <int, ll>
#define pli pair <ll, int>
#define pll pair <ll, ll>
#define debug cout <<"######\n"
#define debug1(x) cout <<"### " << x << " ###\n"
#define debug2(x,y) cout <<"# " << x <<" : "<< y <<" #\n"
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define r_srt(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.rbegin(), v.rend())
#define Sqr(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define MAX 200005
#define INF 1000000009
#define MOD 1000000007

template<class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
template<typename T>
using ordered_set  = tree<T, null_type, less<T>, rb_tree_tag,
      tree_order_statistics_node_update>;

template <typename T> string toString ( T Number ) {
    stringstream ss;
    ss << Number;
    return ss.str();
}
template<typename T> int toInt (T str) {
    stringstream ss;
    ss << str;
    int num;
    ss >> num;
    return num;
}
ll lcm ( ll a, ll b ) {
    return ( a / __gcd ( a, b ) ) * b;
}
/************************************ Code Start Here ******************************************************/
int main () {
    __FastIO;
    //~ cout << setprecision (10) << fixed;
    int n;
    cin >> n;
    map<ll, ll>mp;
    ll cnt = 0;

    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        cnt += mp[i - x];
        mp[i + x]++;
    }

    cout << cnt << "\n";
    return 0;
}


Measured memory_bytes: 26212
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-10, PI = acos(-1);
const int N = 3e5 + 9, M = 1e5 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

ll arr[N], poww[N];

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

ll add(ll a, ll b) {
  a += b;
  while(a > MOD)
    a -= MOD;
  while(a < 0)
    a += MOD;
  return a;
}

ll power(ll a, ll b) {
  ll ret = 1;
  while(b) {
    if(b & 1)
      ret = mul(ret, a);
    b /= 2;
    a = mul(a, a);
  }
  return ret;
}

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n;
  cin >> n;
  ll S = power(2, n - 2), factor = power(2, n);
  poww[n - 1] = power(2, n - 1);
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    if(i)
      poww[n - i - 1] = add(poww[n - i], S);
  }
  sort(arr, arr + n);
  ll total = 0;
  for (int i = 0; i < n; ++i) {
    ll cur = mul(poww[i], arr[i]);
    total = add(total , cur);
  }
  total = mul(total, factor);
  cout << total;
  return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
     
    #define ll long long
     
    using namespace std;
     
    const int maxn = 1e5+50;
     
    int main()
    {
        ll ans = 0;
        int a, b, c, x, y;
        cin >> a >> b >> c >> x >> y;
        if (2*c < a + b)
        {
            int tmp = min(x, y);
            ans += tmp * c * 2;
            x -= tmp;
            y -= tmp;
        }
        else
        {
            ans += x*a + y*b;
            x = y = 0;
        }
        ans += x * min(2*c, a);
        ans += y * min(2*c, b);
        cout << ans << endl;
        return 0;
    }

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
inline int read()
{
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0' && ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*w;
}
int main()
{
	int n=read();
	if(n==1)puts("0");
	else puts("1");
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long l,r,i,j,ans=3000;
	cin>>l>>r;
	if(r/2019!=l/2019)
	{
		cout<<0<<endl;
		return 0;
	}
	l%=2019;
	r%=2019;
	for(i=l;i<=r;i++)
	{
		for(j=i+1;j<=r;j++)
		{
			ans=min(ans,(i*j)%2019);
		}
	}
	cout<<ans<<endl;
}

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

int main() {
 int A, B, C, K;
  cin >> A >> B >> C >> K;
  if (K-A-B>0) {
    cout << A-(K-A-B) << endl;
  }
  else if(K<A) {
    cout << K << endl;
  }
  else if (A<=K&&K-A-B<=0) {
    cout << A << endl;
  }
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    /*ios::sync_with_stdio(false);
    cin.tie(0);*/
    ll n,t;cin>>n>>t;
    vector<P> ab(n);
    //vector<ll> a(n),b(n);
    rep(i,n){
        //cin>>a[i]>>b[i];
        cin>>ab[i].first>>ab[i].second;
    }
    sort(ab.begin(),ab.end());
    vector<vector<ll>> dp(n+1);
    dp[0]=vector<ll>(t+1,0);
    //dp[i][j]:1~iの料理でj分までに得るおいしさの最大
    //dp[i][t]だけは別
    rep2(i,1,n+1){
        
        dp[i]=dp[i-1];
        rep2(j,ab[i-1].first,t){
            
            dp[i][j]=max(dp[i][j],ab[i-1].second+dp[i-1][j-ab[i-1].first]);
        }
        dp[i][t]=max(dp[i][t],ab[i-1].second+dp[i-1][t-1]);
    }
    cout<<dp[n][t]<<endl;
    return 0;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;
    priority_queue<int> pq;
    REP(i, n)
    {
        int tmp;
        cin >> tmp;
        pq.push(tmp);
    }

    int prev = pq.top();
    pq.pop();
    int cnt = 1;
    int ans = 0;

    while(!pq.empty())
    {

        int cur = pq.top();
        pq.pop();


        if(prev == cur)
        {
            cnt++;
        }else
        {
            if(cnt % 2 == 1) ans++;
            cnt = 1;
        }
        
        prev = cur;
    }
    if(cnt % 2 == 1) ans++;

    cout << ans << endl;
}

Measured memory_bytes: 892
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<string, string> PSS;
static const double EPS = 1e-8;
static const int INF = (int)1e8;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) for (int i=0; i<(int)(n); ++i)
#define FOREQ(i,k,n) for (int i=(k); i<=(int)(n); ++i)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FIND(m,w) ((m).find(w)!=(m).end())

bool eql(string s1,string s2){
  REP(i,s1.size()){
    if(s1[i]!=s2[i]&&s2[i]!='?'&&s1[i]!='?'){
      return false;
    }
  }
  return true;
}
struct Ans{
  string s1,s2,s3;
  Ans (string s1,string s2,string s3) : s1(s1),s2(s2),s3(s3) {}
};
int main(void){
  int n,m;
  while(cin>>n>>m,(n||m)){
    bool pord[1025];
    PSS adress[1025];
    REP(i,n){
      string tmp1,tmp2;
      cin>>tmp1;
      if(tmp1=="permit") pord[i] = true;
      else pord[i] = false;
      cin>>tmp1>>tmp2;
      adress[i] = PSS(tmp1,tmp2);
    }
    vector<Ans> ans;
    REP(i,m){
      string s1,s2,s3;
      cin>>s1>>s2>>s3;
      bool ligal = false;
      REP(i,n){
        if(eql(s1,adress[i].first)&&eql(s2,adress[i].second)){
          ligal = pord[i];
        }
      }
      if(ligal){
        ans.push_back(Ans(s1,s2,s3));
      }
    }
    cout<<ans.size()<<endl;
    REP(i,ans.size()){
      cout<<ans[i].s1<<" "<<ans[i].s2<<" "<<ans[i].s3<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1044
# coding: utf-8
from sys import stdin

x1,y1,x2,y2 = map(int,stdin.readline().rstrip().split())

def main():
    print("{} {} {} {}".format(x2 - y2 + y1, y2 + x2 - x1, x1 - y2 + y1, y1 + x2 - x1 ))
    
    
if __name__ == '__main__':
    main()

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

#define pb push_back
#define fst first
#define snd second
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll;
using namespace std;

int main() {FIN;
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c >= 22) cout<<"bust\n";
    else cout<<"win\n";
    return 0;
}



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

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var N = int.Parse(ReadLine());
            var raw = ReadLine().Split().Select(int.Parse).ToArray();

            var ans = 0;
            for (int i = 0; i < N - 2; i++)
            {
                if (raw[i + 1] == raw.Skip(i).Take(3).OrderBy(s => s).ToList()[1]) ans++;
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
/*input
0
*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll sub(ll a,ll b){
    ll x=a-b;
    while(x<0) x+=MOD;
    while(x>MOD) x-=MOD;
    return x;
}
ll mult(ll a,ll b){
    return a*b%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=(res*a)%MOD;
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
const int maxn=1e5+5;
int main(){
	string s;
	cin>>s;
	stack<char> st;
	REP(i,sz(s)){
		if(sz(st) and s[i]=='1' and st.top()=='0'){
			st.pop();
		}
		else if(sz(st) and s[i]=='0' and st.top()=='1'){
			st.pop();
		}
		else{
			st.push(s[i]);
		}
	}
	cout<<sz(s)-sz(st);
}

Measured memory_bytes: 512
#include <stdio.h>

#define N 8

void putQueen(int);
void printBoard(void);

int col[8] = {};
int row[8];
int dpos[15] = {};
int dneg[15] ={};

int main(){
    int k,r,c;
    int i;

    // init
    for(i=0;i<N;i++){
        row[i]=-1;
    }

    scanf("%d", &k);
    for(i=0;i<k;i++){
        scanf("%d %d", &r,&c);
        row[r]=c;
        col[c]=dpos[r+c]=dneg[r-c+N-1]=1;
    }

    putQueen(0);

    return 0;

}

void putQueen(int i){
    int j;

    if(i==N) {
        printBoard();
    }
    else if(row[i]!=-1) putQueen(i+1);
    else{
        for(j=0;j<N;j++){
            if(col[j]==1 || dpos[i+j]==1 || dneg[i-j+N-1]==1) continue;
            // put a queen at (i, j)
            row[i] = j;
            col[j]=dpos[i+j]=dneg[i-j+N-1]=1;
            // try the next row
            putQueen(i+1);
            // remove the queen at (i,j) for backtracking
            row[i]=-1;
            col[j]=dpos[i+j]=dneg[i-j+N-1]=0;
        }
    }
}

void printBoard(void){
    int i,j;

    for(i=0;i<N;i++){
        for(j=0;j<N;j++){
            if(row[i]==j) printf("Q");
            else printf(".");
        }
        printf("\n");
    }
}


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

using namespace std;

typedef long long ll;

ll x[100001];

int main(int, char**)
{
	string s;
	ll n, q, ans = 0;
	cin >> n >> q >> s;
	for (ll j = 0; j < n - 1; ++j) {
		if (s[j] == 'A') {
			if (s[j + 1] == 'C') {
				++ans;
			}
		}
		x[j + 1] = ans;
	}
	for (ll i = 0; i < q; ++i) {
		ll l, r, ans = 0;
		cin >> l >> r;
		cout << (x[r-1] - x[l-1]) << endl;
	}

	return 0;
}


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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(10);
  double n = 0, m;
  int d;
  std::cin >> n >> m >> d;
  std::cout << (m - 1.0) * ((d != 0) + 1) / n * (n - d) / n << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using T = tuple<ll,int,int>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9 + 7;

int main(void){
  int n,d;
  int p[10][10];
  cin >> n >> d;
  for(int i = 0;i < n;++i){
    for(int j = 0;j < d;++j){
      cin >> p[i][j];
    }
  }
  int res = 0;
  for(int i = 0;i < n;++i){
    for(int j = i+1;j < n;++j){
      int calc = 0;
      for(int a = 0;a < d;++a){
        int delta = p[i][a] - p[j][a];
        calc += delta * delta;
      }
      for(int i = 1;i * i <= calc;++i){
        if(i * i == calc){
          ++res;
          break;
        }
      }
    }
  }
  cout << res << endl;
  return 0;
}


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


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define COUT(x) cout<<x<<"\n"

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = lcm(a, v[i]);} return a;}


void Main()
{
	char str[222];
	scanf("%s",str);
	int  n=strlen(str);
	for(int  i=n-2;i;i-=2){
		if(strncmp(str,str+i/2,i/2) ==0){
			printf("%d\n",i);
			return;
		}
	}
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


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

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    int n,ans=0,t1[26];
    char s[105];
    scanf("%d",&n);
    scanf("%s",s);
    for(int i=0;i<n;i++)
    {
        memset(t1,0,sizeof(t1));
        for(int j=0;j<=i;j++)
            t1[s[j]-'a']=1;

        int t=0;
        for(int j=i+1;j<n;j++)
        {
            if(t1[s[j]-'a']==1)
            {
                t++;
                t1[s[j]-'a']=0;
            }
            ans=max(ans,t);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
def kakuketawa(num: int):
    return sum(list(map(int, list(str(num)))))


if __name__ == '__main__':
    N, A, B = map(int, input().split())
    # N, A, B = 100, 4, 16
    s = 0
    for i in range(N):
        if A <= kakuketawa(i + 1) <= B:
            s += i + 1
    print(s)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
namespace my_header {
#define pb push_back
#define mp make_pair
#define pir pair<int, int>
#define vec vector<int>
#define pc putchar
#define clr(t) memset(t, 0, sizeof t)
#define pse(t, v) memset(t, v, sizeof t)
#define bl puts("")
#define wn(x) wr(x), bl
#define ws(x) wr(x), pc(' ')
	const int INF = 0x3f3f3f3f;
	typedef long long LL;
	typedef double DB;
	inline char gchar() {
		char ret = getchar();
		for(; (ret == '\n' || ret == '\r' || ret == ' ') && ret != EOF; ret = getchar());
		return ret; }
	template<class T> inline void fr(T &ret, char c = ' ', int flg = 1) {
		for(c = getchar(); (c < '0' || '9' < c) && c != '-'; c = getchar());
		if (c == '-') { flg = -1; c = getchar(); }
		for(ret = 0; '0' <= c && c <= '9'; c = getchar())
			ret = ret * 10 + c - '0';
		ret = ret * flg; }
	inline int fr() { int t; fr(t); return t; }
	template<class T> inline void fr(T&a, T&b) { fr(a), fr(b); }
	template<class T> inline void fr(T&a, T&b, T&c) { fr(a), fr(b), fr(c); }
	template<class T> inline char wr(T a, int b = 10, bool p = 1) {
		return a < 0 ? pc('-'), wr(-a, b, 0) : (a == 0 ? (p ? pc('0') : p) : 
			(wr(a/b, b, 0), pc('0' + a % b)));
	}
	template<class T> inline void wt(T a) { wn(a); }
	template<class T> inline void wt(T a, T b) { ws(a), wn(b); }
	template<class T> inline void wt(T a, T b, T c) { ws(a), ws(b), wn(c); }
	template<class T> inline void wt(T a, T b, T c, T d) { ws(a), ws(b), ws(c), wn(d); }
	template<class T> inline T gcd(T a, T b) {
		return b == 0 ? a : gcd(b, a % b); }
	template<class T> inline T fpw(T b, T i, T _m, T r = 1) {
		for(; i; i >>= 1, b = b * b % _m)
			if(i & 1) r = r * b % _m;
		return r; }
};
using namespace my_header;

LL n;

deque<int> a, b;

int val;

void solve(LL x) {
	if (x == 0) {
		return ;
	} else if (x == 1) {
		++val;
		a.push_back(val);
		b.push_back(val);
		return ;
	}
	if (x & 1) {
		solve((x - 1) >> 1);
		++val;
		a.push_back(val);
		b.push_back(val);
	} else {
		solve(x - 1);
		++val;
		a.push_front(val);
		b.push_back(val);
	}
}

int main() {
#ifdef lol
	freopen("C.in", "r", stdin);
	freopen("C.out", "w", stdout);
#endif

	fr(n);
	solve(n);
	wt(a.size() * 2);
	for (auto &&i : a)
		ws(i);
	for (auto &&i : b)
		ws(i);
	puts("");


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<complex>
 
#define INF (long long)1000000000
#define MOD 1000000007
#define EPS 1e-8
 
#define REP(i, m) for(long long i = 0; i < m; ++i)
#define FOR(i, n, m) for(long long i = n; i < m; ++i)
#define ALL(v) v.begin(), v.end()
#define pb push_back
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
 
int main() {
	int n;
	cin>>n;
	vector<vector<P> > d(n);
	REP(i,n-1) {
		ll a, b, c;
		cin>>a>>b>>c;
		--a;
		--b;
		d[a].pb(P(b,c));
		d[b].pb(P(a,c));
	}
	int Q,k;
	cin>>Q>>k;
	--k;
	vector<ll> dist(n,INF*INF);
	dist[k]=0;
	priority_queue<P, vector<P>, greater<P> > q;
	q.push(P(0,k));
	while(!q.empty()) {
		P buf = q.top();
		q.pop();
		ll di = buf.first;
		ll p = buf.second;
		if(dist[p]<di) continue;
		REP(i,d[p].size()) {
			ll np = d[p][i].first;
			ll nd = d[p][i].second;
			if(dist[np]>dist[p]+nd) {
				dist[np]=dist[p]+nd;
				q.push(P(dist[np],np));
			}
		}
	}
	REP(i,Q) {
		ll x, y;
		cin>>x>>y;
		--x;
		--y;
		cout<<dist[x]+dist[y]<<endl;
	}
}

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

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size())

#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange

#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

void solve() {
    ll N;
    cin >> N;
    vector<pair<ll, ll>> p(N);
    REP(i, N) {
        ll x, y;
        cin >> x >> y;
        p[i] = MP(x-y, x+y);
    }
    ll ans, max_f, min_f, max_s, min_s;
    ans = LLONG_MIN;
    max_f = LLONG_MIN;
    min_f = LLONG_MAX;
    max_s = LLONG_MIN;
    min_s = LLONG_MAX;
    REP(i, N) {
        chmax(max_f, p[i].F);
        chmin(min_f, p[i].F);
        chmax(max_s, p[i].S);
        chmin(min_s, p[i].S);
    }
    ans = max(max_f - min_f, max_s - min_s);
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 6424
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    ll n,k; cin >> n >> k;
    if(k == 1) {cout << 0 << endl; return 0;}

    if(n > k) n -= k * (n/k);
    cout << min(n, abs(n-k)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
int main(){
    ll n,m;cin>>n>>m;
    vvi from(n),to(n);
    rep(i,m){
        ll a,b;cin>>a>>b;
        a--;b--;
        from[b].pb(a);
        to[a].pb(b);
    }
    vector<double> dp(n);
    dp[n-1]=0;
    for(ll i=n-2;i>=0;i--){
        for(ll x:to[i])dp[i]+=dp[x]+1;
        dp[i]/=to[i].size();
    }
    double ans=dp[0];
    for(ll i=n-2;i>=0;i--){
        double ma=0;
        if(to[i].size()==1)continue;
        vector<double> dp2=dp;
        rep(j,i+1)dp2[j]=0;
        for(ll x:to[i]){
            chmax(ma,dp2[x]+1);
            dp2[i]+=dp2[x]+1;
        }
        dp2[i]-=ma;
        dp2[i]/=to[i].size()-1;
        for(ll j=i-1;j>=0;j--){
            for(ll x:to[j])dp2[j]+=dp2[x]+1;
            dp2[j]/=to[j].size();
        }
        chmin(ans,dp2[0]);
    }
    cout<<fixed<<setprecision(10);
    cout<<ans<<endl;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    int N, A, B;
    cin >> N >> A >> B;

    cout << min(N * A, B) << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<deque>
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#define ll long long
using namespace std;
#define BUF_SIZE 1048576
char _buf[BUF_SIZE],*_is=_buf,*_it=_buf;
inline char rdc(){
	if (_is==_it) _it=(_is=_buf)+fread(_buf,1,BUF_SIZE,stdin);
	return *_is++;
}
inline void rdi(int &x){
	int f=0;
	register char ch=rdc();
	while ((ch<'0' or ch>'9') and (ch^'-')) ch=rdc();
	if (ch=='-') f=1,ch=rdc();
	while (ch>='0' and ch<='9') x=(x<<3)+(x<<1)+(ch^'0'),ch=rdc();
	if(f) x=-x;
}
inline void rdi(ll &x){
	ll f=0;
	register char ch=rdc();
	while ((ch<'0' or ch>'9') and (ch^'-')) ch=rdc();
	if (ch=='-') f=1,ch=rdc();
	while (ch>='0' and ch<='9') x=(x<<3)+(x<<1)+(ch^'0'),ch=rdc();
	if(f) x=-x;
}
inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline void _write(int x){
	write(x);
	putchar(' ');
}
inline void print(int x){
	write(x);
	putchar('\n');
}
inline void write(ll x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline void _write(ll x){
	write(x);
	putchar(' ');
}
inline void print(ll x){
	write(x);
	putchar('\n');
}
#define int ll
int res,n,d;
int a[200005];
int dpl[200005],dpr[200005]; 
signed main(){
	rdi(n),rdi(d);
	int i,j;
	for(i=0;i<n;++i) rdi(a[i]),res+=a[i];
	res+=(n-1)*d;
	dpr[0]=a[0];
	for(i=1;i<n;++i) dpr[i]=min(a[i],dpr[i-1]+d);
	dpl[n-1]=a[n-1];
	for(i=n-2;~i;--i) dpl[i]=min(a[i],dpl[i+1]+d);
	for(i=1;i<n-1;++i) res+=min(dpl[i],dpr[i]);
	print(res);
	return 0;
}


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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int ans;
  rep(i, 5) {
    int x;
    cin >> x;
    if (x == 0) ans = i;
  }

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


Measured memory_bytes: 3632
D, G = map(int, input().split())
problem = []
bonus_score = []
for i in range(D):
    pi, ci = map(int, input().split())
    problem.append(pi)
    bonus_score.append(ci)
total_problem = sum(problem)
dp= [[0 for k in range(total_problem + 1)] for i in range(D+1)]

for i in range(D):
    for k in range(total_problem + 1):
        for j in range(min(problem[i], k) + 1):
            dp[i+1][k] = max(dp[i+1][k], dp[i][k - j] + (i + 1) * 100 * j + (j//problem[i]) * bonus_score[i])
ans = 0
while dp[D][ans] < G:
    ans += 1
print(ans)
            


Measured memory_bytes: 3316
from itertools import accumulate
N, K = map(int, input().split())
A = list(map(int, input().split()))
m = K.bit_length()
b = [sum((a >> k) & 1 for a in A) for k in range(m)]
opt = [0] + list(accumulate(1 << k if 2 * b[k] < N else 0 for k in range(m)))


def f(x):
    return sum(x ^ a for a in A)


def g(k, s):
    if k == 0:
        return f(s)
    r = k.bit_length()
    return max(
      f(s + opt[r - 1]),
      g(k - (1 << (r - 1)), s + (1 << (r - 1)))
    )


ans = g(K, 0)
print(ans)


Measured memory_bytes: 14748
function main(input) {
  const inputs =input.split('\n')
  const [N] = inputs[0].split(' ').map(Number)
  const A = inputs[1].split(' ').map(Number)

  const count = []
  for(let i = 0; i < N; i++) {
    if (count[A[i]] === undefined) {
      count[A[i]] = 0
    }
    count[A[i]] = count[A[i]] + 1
    // console.log(count)
  }

  // console.log(count)
  let all = 0
  for(let i = 1; i <= count.length - 1; i++) {
    if (count[i] === undefined) continue
    all += count[i] * (count[i] - 1) / 2
  }

  for (let i = 0; i < N; i++) {
    const diff = count[A[i]] * (count[A[i]] - 1) / 2 - ((count[A[i]] - 1) * (count[A[i]] - 2) / 2)
    console.log(all - diff)
  }

}

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


Measured memory_bytes: 46120
function Main(input) {
  input = input.split("\n");
  tmp = input[0].split(" ");
  var wmax = parseInt(tmp[0]);
  var hmax = parseInt(tmp[1]);
  var n = parseInt(tmp[2]);
  var wmin =0;
  var hmin =0;
  x=new Array(n).fill(0);
  y=new Array(n).fill(0);
  a=new Array(n).fill(0);
  var ans=0;
  for(i=0;i<n;i++){
    x[i]=parseInt(input[i+1].split(" ")[0]);
    y[i]=parseInt(input[i+1].split(" ")[1]);
    a[i]=parseInt(input[i+1].split(" ")[2]);
  }
  for(i=0;i<n;i++){
    if(a[i]==1&&x[i]>wmin){
      wmin=x[i];
    }else if(a[i]==2&&x[i]<wmax){
      wmax=x[i];
    }else if(a[i]==3&&y[i]>hmin){
      hmin=y[i];
    }else if(a[i]==4&&y[i]<hmax){
      hmax=y[i];
    }
  }
  if(hmax<hmin||wmax<wmin){
    ans=0;
  }else{
    ans=(hmax-hmin)*(wmax-wmin);
  }

  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-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;
}



int main(){
    long long L;
    scanf("%lld",&L);
    long long R;
    scanf("%lld",&R);
    long long d;
    scanf("%lld",&d);
    ll cnt=0;
    for (long long i = L; i <= R; i++) {
        if(i%d==0) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll> >      vpll;
typedef		vector<ll>      vll;
typedef		map<string,ll>      msl;
typedef		map<ll,ll>      mll;
#define MAX 1000005


int main()
{
 //O_O ;
 ll count=0,l;
string a,b;
cin>>a;
b=a;
l=a.length();
reverse(a.begin(),a.end());
for(ll i=0;i<l;i++){
    if(a[i]!=b[i])
    count++;
}
cout<<count/2<<nn;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int n;
int a[300000];
int b[300000];

int main()
{
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(a, a + n, greater<int>());

    for (int i = 0; i < n; i++)
    {
        if (b[i] == a[0])
        {
            cout << a[1] << endl;
        }
        else
        {
            cout << a[0] << endl;
        }
    }
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;

#define rep(i, n) \
for(int i = 0; i <n; i++)
#define REP(i, a, b) \
for(int i = int(a); i <= int(b); i++)
#define TRvi(c, it) \
for(vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for(vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for(msi::iterator it = (c).begin(); it != (c).end(); it++)

#define INF 2000000000

#define MEMSET_INF 127
#define MEMSET_HALF_INF 63

void solve(){
    double n,d;
    cin>>n>>d;
    vector<double> v(n);
    double temp1;
    double temp2;
    int ans = 0;
    rep(i,n){
        cin>>temp1>>temp2;
        v[i] = sqrt(temp1*temp1+temp2*temp2);
        if(v[i]<=d){ans+=1;}
    }
    cout<<ans<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 4840
#include <iostream>
#include <string>
#include <iostream>
#include <string>

using namespace std;

int main(){
  int f1 = 0, f2 = 0;
  string S;
  cin >> S;
  int l = atoi(S.substr(0, 2).c_str());
  int r = atoi(S.substr(2, 2).c_str());
  if (l >= 1 && l <= 12) f1 = 1;
  if (r >= 1 && r <= 12) f2 = 1;
  if (f1 == 0 && f2 == 0) cout << "NA" << endl;
  else if (f1 == 1 && f2 == 0) cout << "MMYY" << endl;
  else if (f1 == 0 && f2 == 1) cout << "YYMM" << endl;
  else cout << "AMBIGUOUS" << endl;
  
  
  return 0;
}

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

int main() {
	int n,ma,mb;cin>>n>>ma>>mb;
	vector<int> a(n),b(n),c(n);
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i]>>c[i];
	}
	vector<vector<int>> v(1000,vector<int>(1000,0));
	int ans=10000;
	v[0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=500;j>=0;j--){
			for(int k=500;k>=0;k--){
				if(v[j][k]){
					int temp=v[j][k]+c[i];
					if(v[j+a[i]][k+b[i]]){
						if(v[j+a[i]][k+b[i]]>temp){
							v[j+a[i]][k+b[i]]=temp;
						}
					}else{
						v[j+a[i]][k+b[i]]=temp;
					}

				}
			}
		}
	}
//	for(int j=0;j<10;j++){
//		for(int k=0;k<10;k++){
//			cout<<v[j][k]<<' ';
//		}
//		cout<<endl;
//	}
	for(int j=1;j<500;j++){
		for(int k=1;k<500;k++){
			if(v[j][k]){
				if(ans>v[j][k]){
					if(j*mb==k*ma){
						ans=v[j][k];
					}
				}
			}
		}
	}
	if(ans!=10000){
	cout<<ans-1<<endl;
	}else{
		cout<<-1<<endl;
	}
	return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s=="Sunny")
    {
        cout<<"Cloudy"<<endl;
    }
    else  if(s=="Cloudy")
    {
        cout<<"Rainy"<<endl;
    }
     else if(s=="Rainy")
    {
        cout<<"Sunny"<<endl;
    }
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n, m, Q; cin>>n>>m>>Q;
    int g[510][510];
    memset(g, 0, sizeof(g));
    for(int i=0; i<m; i++){
        int l, r; cin>>l>>r;
        g[l][r]++;
    }

    for(int i=1; i<=n; i++){
        for(int j=1; j<n; j++){
            g[i][j+1]+=g[i][j];
        }
    }

    for(int i=1; i<=n; i++){
        for(int j=1; j<n; j++){
            g[j+1][i]+=g[j][i];
        }
    }

    for(int i=0; i<Q; i++){
        int p, q; cin>>p>>q;
        cout << g[q][q]-g[p-1][q]-g[q][p-1]+g[p-1][p-1] << endl;
    }
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define endl "\n"
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

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

  int N;
  string S;
  cin >> N >> S;

  int res = 0;
  rep(i, N-2) {
    if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C') res++;
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 256
'use strict'
function Main(input){
  input=input.trim().split(/\s+/);
  var N=input.shift()-0;
  var Q=input.shift()-0;
  var S='';
  var b=/A|T|G|C/;
  while(b.test(input[0]))
    S=S+input.shift();
  S=S.split('');
//  console.log(S);
  var T=[0,0];
  for(let i=1;i<N;i++)
    T[i+1]=T[i]+(S[i-1]==='A'&&S[i]==='C'?1:0);
//  console.log(T);
  var ans=[];
  for(let q=0;q<Q;q++){
    let l=input[2*q]-0,r=input[2*q+1]-0;
    ans[q]=T[r]-T[l];
  }
  console.log(ans.join('\n'));
}

Main(require('fs').readFileSync('/dev/stdin','utf8'));

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

using namespace std;

int main() {
    int N , L;
    cin >> N >> L;
    int abs_Aji[202], Aji[202];

    for(int i = 0; i < N; i++){
        abs_Aji[i] = abs(L + i );
            Aji[i] = L + i ;
    }

    sort(abs_Aji,abs_Aji + N);

    int sum = 0;
    if(abs_Aji[0] == 0){
        for(int j = 0; j < N; j++){
//            cout << Aji[j] << endl;
            sum += Aji[j];
        }
    }else{
        for(int k = 0; k < N; k++){
//            cout << Aji[k] << endl;
            sum += Aji[k];
        }
//        cout << "0::" << abs_Aji[0] << endl; 
        if(sum < 0)
            sum = sum + abs_Aji[0];
        else
            sum = sum - abs_Aji[0];
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		int a = Integer.parseInt(reader.readLine());
		for (int i = 0; i < a; i++) {
			String[] line = reader.readLine().split(" ");
			int[] nums = new int[3];
			for (int j = 0; j < 3; j++) {
				nums[j] = Integer.parseInt(line[j]);
			}
			Arrays.sort(nums);
			if (Math.pow(nums[0], 2) + Math.pow(nums[1], 2) == Math.pow(
					nums[2], 2))
				builder.append("YES\n");
			else
				builder.append("NO\n");
		}
		System.out.print(builder);

	}
}

Measured memory_bytes: 20140
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[100],n,v,j;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    v=a[i];
    j=i-1;
    while(j>=0 && a[j]>v){
      a[j+1]=a[j];
      j--;
      a[j+1] = v;
    }
    for(int k=0;k<n;k++){
      cout<<a[k];
      if(k==n-1) cout<<endl;
      else cout<<" ";
    }
  }
 
  return 0;
}




Measured memory_bytes: 3088