akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n, m;
    cin >> n >> m;
    priority_queue<P, vector<P>, greater<P>> que;
    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        que.push(P(a, b));
    }
    ll ret = 0;
    while (!que.empty())
    {
        P p = que.top();
        que.pop();
        if (p.second < m)
        {
            ret += p.first * p.second;
            m -= p.second;
            continue;
        }
        ret += p.first * m;
        break;
    }
    cout << ret << endl;
}


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    intl cnt = n - (n > m);
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,*H = map(int,read().split())

dp = [0]*N
for i in range(1,N):
    x = dp[i-1] + abs(H[i]-H[i-1])
    if i > 1:
        y = dp[i-2] + abs(H[i]-H[i-2])
        if x>y: x=y
    dp[i] = x

answer = dp[-1]
print(answer)

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

int main() {

  int i,j=0, len, a[26];
  char s[1200];

  for(i = 0; i < 26; i++) {
    a[i] = 0;
  }

  while(scanf("%c", &s[j])==1) j++; 
  len = j;
  
  for(i = 0; i < len; i++) {
    if((s[i] >= 'A' && s[i] <= 'Z') || (s[i] >= 'a' && s[i] <= 'z')) {
      
      if(s[i] >= 'A' && s[i] <= 'Z') {
	s[i] += (int)'a' - (int)'A';
      }

      a[(int)s[i]-'a'] += 1;

    }
  }

  for(i = 0; i < 26; i++) {
    printf("%c : %d\n", (char)('a'+i),a[i]);
  }

  return 0;

}

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

using namespace std;

int main(){
  int flag=1;
  string s;
  cin>> s;
  
  for(int i=0;i<s.size();i++){
    if(i%2==0 && s[i]=='L') flag=0;
    if(i%2==1 && s[i]=='R') flag=0;
  }

  if(flag) cout<< "Yes" <<endl;
  else cout<< "No" <<endl;
  
}


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

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;

    vector<int> taste(N);
    for (int i = 0; i < N; i++)
    {
        cin >> taste.at(i);
    }

    int energy = 0;
    for (int i = 0; i < N - 1; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            energy += (taste.at(i) * taste.at(j));
        }
    }
    cout << energy << endl;
    return 0;
}


Measured memory_bytes: 256
///I am Groot |*|
///19.09.2020>>01.59 PM
#include <bits/stdc++.h>
#include <iostream>
using namespace std;

int main()
{
    long long int a,b,c,d,x[3],max;
    cin>>a>>b>>c>>d;
    max=a*c;
    x[0]=a*d;
    x[1]=b*c;
    x[2]=b*d;
    for(int i=0; i<3; i++)
    {
        if(max<x[i])
        {
            max=x[i];
        }
    }
    cout<<max;
}


Measured memory_bytes: 3536
N=int(input())

ans = 0
def dfs(s, target):
  global ans
  target = target + s

  if int(target) > N:
    return False

  if target.count("3") >= 1 and target.count("5") >= 1 and target.count("7") >= 1:
    ans += 1
  
  if dfs("3", target):
    return True
  
  if dfs("5", target):
    return True
  
  if dfs("7", target):
    return True
  
  
dfs("0" ,'')
print(ans)

  

Measured memory_bytes: 3060
import java.util.*;
import java.io.*;

public class Main {	
	private static void solve(){
		//Implement solution here.
		int N = ni();
		int[] A = na(N);
		Arrays.sort(A);
		int tmp = -1;
		for(int i = 0; i < N; i++) {
			if(A[i] == tmp) {
				System.out.println("NO");
				return;
			} else {
				tmp = A[i];
			}
		}
		System.out.println("YES");
	}
	
	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define RREP(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define ALL(vector) vector.begin(), vector.end()

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin>>N;
    vector<ll> A(N,-1);
    REP(i,N){
        cin >> A[i];
    }
    ll B = 0;
    REP(i,N){
        if(i==0 || i==1){
            continue;
        }
        B ^= A[i];
    }
    ll C = A[0] + A[1];
    int n_bits = 50;
    vector<ll> bits(n_bits,-1);
    bool carry=false;
    RREP(i,n_bits){
        ll _C = (C >> i) & 1;
        ll _B = (B >> i) & 1;
        if (carry){
            if (_C==0 && _B==0){
                bits[i] = 1;
                carry = false;
            }else if (_C==1 && _B==1){
                cout<<-1<<endl;
                return 0;
            }else if (_C==1 && _B==0){
                bits[i] = 1;
                carry = true;
            }else if (_C==0 && _B==1){
                bits[i] = -1;
                carry = true;
            }
        }else{
            if (_C==0 && _B==0){
                bits[i] = 0;
                carry = false;
            }else if (_C==1 && _B==1){
                bits[i] = -1;
                carry = false;
            }else if (_C==1 && _B==0){
                bits[i] = 0;
                carry = true;
            }else if (_C==0 && _B==1){
                cout<<-1<<endl;
                return 0;
            }
        }

    }

    if (carry==true){
        cout<<-1<<endl;
        return 0;
    }
    
    ll A0 = 0;
    REP(i,n_bits){
        ll targ = bits[i];
        if (targ == -1) continue;
        A0 += targ<<i;
    }

    RREP(i,n_bits){
        ll targ = bits[i];
        if (targ != -1) continue;
        ll tmp = A0 + (((ll) 1)<<i);
        if (tmp <= A[0]) A0 = tmp;
    }
    if (0<A0 && A0 <= A[0]){
        cout<< A[0] - A0 <<endl;
    }else{
        cout<<-1<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
//repマクロ定義
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
//allマクロ定義
#define all(v) v.begin(),v.end()
using namespace std;

bool ans=true;

void check_Palindrome(string s){
  int len = s.length();
  string s_rev = s;
  reverse(all(s_rev));
  for(int i=0;i<len;i++){
    if(s.at(i)!=s_rev.at(i)){
      ans = false;
      break;
    }
  }
}

int main(){
  string s;
  cin >> s;
  int n = s.length();
  check_Palindrome(s);
  check_Palindrome(s.substr(0,(n-1)/2));
  check_Palindrome(s.substr((n+3)/2-1,(n-1)/2));

  if(ans) puts("Yes");
  else    puts("No");

}


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

int main (){
  long long N, A, B;
  cin >> N >> A >> B;
  if (N != 1 && A <= B){
    cout << (N - 2) * (B - A) + 1 << endl;
  }
  else if (N == 1 && A == B) cout << 1 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int n,l,t[202];
int main(){
	scanf("%d%d",&n,&l);
	int ans=10000;int sum=0,t;
	for(int i=1;i<=n;i++){
		if(abs(l+i-1)<ans){
			ans=abs(l+i-1);
			t=i;
		};
		sum+=l+i-1;
	}
	printf("%d\n",sum-(l+t-1));
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
ll A[5000001],bin[5000001];
vector<ll>v;
map<int,int>myMap;
set<int>mySet;
vector<pair<ll,ll> >vp;
/* Precode Start Here *\



     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll r;
 cin>>r;
 cout<<r*r<<endl;
return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];

    reverse(all(h));
    int mn = 1010101010;
    bool f = 1;
    rep(i, n){
        chmin(mn, h[i]);
        if(h[i]-mn >= 2) f = 0;
    }
    cout << (f ? "Yes" : "No") << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
#include <cassert>

using namespace std;

#define y1 roman_kaban
#define rank oryshych_konb
#define ull unsigned long long
const int mod = int(1e9) + 7;
const long long infLL = 2e18;
const int MX = 200105;


int main()
{
    //init();
    //cerr << delta << endl;
    //freopen("/Users/ozzy/Documents/in.txt","r", stdin);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    map<int,int> m;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        m[x]++;
    }
    int to_destroy = 0;
    for(auto it = m.begin(); it != m.end(); it++){
        to_destroy += it->second - 1;
    }
    if(to_destroy & 1) to_destroy++;
    cout << n - to_destroy << endl;
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    int n; cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    int EVEN = (n+1)/2;
    int ODD = n/2;

    int const inf = 1<<29;
    int ans = inf;
    rep(bit, 1<<n) {
        vector<pair<int, int>> even, odd;
        rep(i, n) {
            if (bit>>i&1) {
                if (i&1) even.emplace_back(b[i], i);
                else odd.emplace_back(b[i], i);
            } else {
                if (i&1) odd.emplace_back(a[i], i);
                else even.emplace_back(a[i], i);
            }
        }

        if (even.size() != EVEN || odd.size() != ODD) continue;
        sort(even.begin(), even.end());
        sort(odd.begin(), odd.end());

        vector<pair<int, int>> vec;
        rep(i, ODD) {
            vec.push_back(even[i]);
            vec.push_back(odd[i]);
        }
        if (n&1) vec.push_back(even.back());

        bool ok = true;
        repr(i, 1, n) if (vec[i].first < vec[i-1].first) { ok = false; break; }
        if (!ok) continue;
        int cnt = 0;
        rep(i, n) repr(j, i+1, n) if (vec[i].second > vec[j].second) ++cnt;
        chmin(ans, cnt);
    }
    cout << (ans==inf? -1:ans) << endl;

    

    return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
l = [tuple(map(int, input().split())) for _ in range(n)]
l.sort(key=lambda x:-x[1])
dic = dict()
tr = list()
curd = 0
curt = 0
for t,d in l[:k]:
  curd += d
  if t not in dic:
    curt += 1
    dic[t] = d
  elif dic[t] < d:
    tr.append(dic[t])
    dic[t] = d
  else:
    tr.append(d)
ans = curt**2 + curd
tr.sort(reverse=True)
for t,d in l[k:]:
  if t in dic: continue
  if not tr: break
  curt += 1
  dic[t] = d
  curd += d - tr.pop()
  cur = curt**2 + curd
  if ans < cur: ans = cur
print(ans)

Measured memory_bytes: 22368
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
using namespace std;
#define sci(n) scanf("%lld", &(n))
#define scd(n) scanf("%Ld", &(n))
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> pll;
int main(void)
{
	LL n, h, w,ret=0;
	sci(n);
	sci(h);
	sci(w);
	for (int i = 0; i < n; i++) {
		LL a, b;
		sci(a); sci(b);
		if (a >= h&&b >= w)ret++;
	}
	cout << ret;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)


int main(){
	int n,m;
	while(cin>>n>>m&&(n||m)){
		double table[101][101];
		rep(i,n) rep(j,n) cin>>table[i][j];
		
		double dp[101][101];
		rep(i,101)rep(j,101)dp[i][j] = -1;
		rep(i,n) dp[0][i] = 1;
		
		for(int i=1;i<m;i++){
			rep(j,n){
				rep(k,n){
					dp[i][j] = max( dp[i-1][k]*table[k][j] , dp[i][j] );
				}
			}
		}
		
		double ans = -1;
		rep(i,n){
			ans = max(ans,dp[m-1][i]);
		}
		printf("%.2lf\n",ans);
	}
}

Measured memory_bytes: 3364
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;

int main() {long N, T;
cin >> N >> T;
vector<long> a(N + 1); vector<long> f(N + 1); vector<long> b(N + 1);
vector<long> sub(N + 1); vector<long> submemo(N + 1);
erep(i, N) cin >> a.at(i);
f.at(1) = a.at(1);
erep(i, N - 1){
    f.at(i + 1) = min(f.at(i), a.at(i + 1));
}
b.at(N) = a.at(N);
for(long i = N; i >= 2; i--){
    b.at(i - 1) = max(b.at(i), a.at(i - 1));
}
erep(i, N){
    sub.at(i) = b.at(i) - f.at(i);
    submemo.at(i) = sub.at(i);
}
sort(sub.begin(), sub.end());
reverse(sub.begin(), sub.end());
long submax = sub.at(0);
long tmp = -1;
long ans = 0;
erep(i, N){
    if(submemo.at(i) == submax && f.at(i) != tmp){
        ans++;
        tmp = f.at(i);
    }
}
// erep(i, N) cout << submemo.at(i) << ' ';
// cout << endl;
// erep(i, N) cout << f.at(i) << ' ';
// cout << endl;
// erep(i, N) cout << sub.at(i) << ' ';
// cout << endl;




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



Measured memory_bytes: 4224
n = int(input())
h = list(map(int,input().split()))
ans = [0] * n
count_m = 0
count = 0
for i in range(n):
    if i == n-1:
        continue
    if h[i] >= h[i+1]:
        count += 1
    else:
        count_m = max(count_m,count)
        count = 0
count_m = max(count_m,count)
print(count_m)

Measured memory_bytes: 14252
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
#include<stdio.h>
using namespace std;
int main(){
    while (1){
        int m,f,r;
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1){break;}
        if(m == -1 or f == -1){
            cout << "F" << endl;
        }else if(m + f > 79){
            cout << "A" << endl;
        } else if(m + f < 80 && m + f > 64){
            cout << "B" << endl;
        } else if(m + f < 65 && m + f > 49){
            cout << "C" << endl;
        } else if(m + f < 50 && m + f > 29 && r > 49){
            cout << "C" << endl;
        } else if (m + f < 50 && m + f > 29 ){
            cout << "D" << endl;
        } else{
            cout << "F" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
int main(){
	set<int> data;
	int n,q,t;
	cin>>n;
	rep(i,n){
		cin>>q;
		data.insert(q);
	}
	cin>>t;
	int cnt=0;
	rep(i,t){
		cin>>q;
		if(data.count(q))cnt++;
	}
	cout<<cnt<<endl;
} 

Measured memory_bytes: 3216
n = int(input())
b = list(str(input()))
ln = [chr(i) for i in range(65,65+26)]
#小文字ならば　[chr(i) for i in range(97,97+26)]
ans = []
for i in range(len(b)):
    for j in range(len(ln)):
        if b[i] ==  ln[j]:
            if (25 - j) >= n:
                ans.append(ln[j + n])
            else:
                ans.append(ln[j + n - 26])
print(''.join(ans))

Measured memory_bytes: 40688
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cctype>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
#include <bitset>
using namespace std;
const int INF=1<<30;

typedef pair<int,int> P;

int n,c;
int a[31],b[31];
int dp[31][1<<16];
void solve(){
	memset(dp,-1,sizeof(dp));
	dp[0][0]=0;
	
	for(int i=0;i<n;i++){
		for(int j=0;j<(1<<16);j++){
			if(dp[i][j]==-1) continue;
			
			int nj=(j|a[i]);
			
			for(int k=0;k<c;k++){
				int cal = (nj&b[k]);
				int pop=0;
				int t=cal;
				for(int o=0;o<16;o++){
					pop += t >> o& 1;
					}
				
				dp[i+1][nj-cal]=max(dp[i+1][nj-cal],dp[i][j]+pop);
			}
		}
	
	}
	int ans=0;
	for(int i=0;i<(1<<16);i++){
		ans=max(ans,dp[n][i]);
	}
	cout<<ans<<endl;
	
	
	
}



int main(){
	
	while(cin>>n>>c,!(n==0&&c==0)){
		for(int i=0;i<n;i++){
			a[i]=0;
			for(int j=0;j<16;j++){
				int x;
				cin>>x;
				a[i]=(a[i]<<1)+x;
			}
		}
		
		for(int i=0;i<c;i++){
			b[i]=0;
			for(int j=0;j<16;j++){
				int x;
				cin>>x;
				b[i]=(b[i]<<1)+x;
			}
		}
		solve();
		
	}
	
	
	
}

Measured memory_bytes: 11012
#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mem(a,b) memset((a),(b),sizeof(a))
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define _GLIBCXX_PERMIT_BACKWARD_HASH
#include <ext/hash_map>
using namespace __gnu_cxx;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
struct str_hash{size_t operator()(const string& str)const{return __stl_hash_string(str.c_str());}};
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-4;
const int MAX=2e5+10;
const ll mod=1e9+7;
/***************************************  head  **********************************************/
int main()
{
	string s;
	while(cin>>s)
	{
		int x;
		cin>>x;
		string ans="";
		for(int i=0;i<s.length();i++)
		{
			if(i%x==0) ans+=s[i];
		}
		cout<<ans<<"\n";
	}
	return 0;
}

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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;

const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int n;
bool vis[N];
int col[N];
const int M = 2e5+5;
vector<pair<int,int>>adj[M];
void dfs(int parent ,int cur,int color){
    if(vis[cur])return;
    vis[cur]=1;
    col[cur]=color;
    for(int i=0;i<adj[cur].size();i++){
        auto node = adj[cur][i];
        if(node.first==parent)continue;
        dfs(cur,node.first,color^node.second);
    }
}
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int from,to,w;
        scanf("%d%d%d",&from,&to,&w);
        adj[from].push_back({to,w%2});
        adj[to].push_back({from,w%2});
    }
    dfs(-1,1,0);
    for(int i=1;i<=n;i++){
        printf("%d\n",col[i]);
    }
    return 0;
}

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

int main() {
  int N, K; cin >> N >> K;
  vector<int> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }
  sort(p.begin(), p.end());
  int sum = 0;
  for (int i = 0; i < K; i++) {
    sum += p[i]; 
  }
  cout << sum << endl;
}

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

using Cost = ll; // time
struct Edge{
    Cost cost;
    int to;
    int fee;
    bool operator>(const Edge &right)const{
        return cost > right.cost;
    }
};

#define MAX_N 50
#define MAX_C 10000
#define INF ((ll)1e16)

int main(void){
    int n, m, s;
    cin >> n >> m >> s;
    s = min(s,MAX_C);
    vector<vector<Edge>> g(n);
    rep(i,m) {
        ll u,v,fee,cost;
        cin >> u >> v >> fee >> cost;
        u--, v--;
        g[u].push_back((Edge){cost, (int)v, (int)fee});
        g[v].push_back((Edge){cost, (int)u, (int)fee});
    }
    rep(i,n) {
        ll c, d;
        cin >> c >> d;
        g[i].push_back(Edge{d, i, -(int)c});
    }

    // 運賃 Ai <= 50, M = 100 -> 必要最高枚数 = 10000
    // dp[頂点][残り枚数] = かかった時間
    vector<vector<Cost>> dp(n);
    rep(i,n) dp[i] = vector<Cost>(MAX_C+1, INF);

    dp[0][s] = 0;
    priority_queue<Edge,vector<Edge>,greater<Edge>> qu;
    qu.push(Edge{dp[0][s], 0, s});
    while (qu.size()) {
        Edge cur = qu.top(); qu.pop();
        int v = cur.to;
        int rem = cur.fee;
        if (dp[v][rem] < cur.cost) continue;
        for (Edge e : g[v]) {
            Cost next_cost = cur.cost + e.cost;
            int next_rem = min(MAX_C, rem - e.fee);
            if (rem - e.fee >= 0 && dp[e.to][next_rem] > next_cost){
                dp[e.to][next_rem] = next_cost;
                qu.push({next_cost, e.to, next_rem});
            }
        }
    }

    vector<Cost> res(n, INF);
    rep1(i,n-1)rep(j,MAX_C+1){
        res[i] = min(res[i], dp[i][j]);
    }
    rep1(i,n-1){
        cout << res[i] << endl;
    }
    
    return 0;
}


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

using namespace std;

#define MOD 1000000007
#define ll long long

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

    int n;
    cin>>n;
    int arr[n];
    for (int i = 0; i < n; ++i) {
        cin>>arr[i];
    }
    int sum=0;
    for (int j = 0; j < n; ++j) {
        for (int i = j+1; i < n; ++i) {
            sum=sum+arr[j]*arr[i];
        }
    }
    cout<<sum;
}

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

using namespace std;


int main()
{

	int n;
	cin >> n;
	int max = -1;
	int answer = 0;
	int h;

	for (int i = 0; i < n; i++) {
		cin >> h;
		if (h >= max) {
			answer++;
			max = h;
		}
	}

	cout << answer << endl;

    return 0;
}


Measured memory_bytes: 256
//include tourist
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 60);

int main(){ 
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());
  vector<ll> cum(n+1,0);
  rep(i,n) cum[i+1] = cum[i] + a[i];
  ll cnt = 0, sum = 0;
  auto ok = [&](ll x) {
    cnt = 0;
    sum = 0;
    for (int i = 0; i < n; i++) {
      int itr = lower_bound(a.begin(), a.end(), x - a[i]) - a.begin();
      cnt += (n - itr);
      sum += cum[n] - cum[itr] + a[i] * (n - itr);
    }
    return cnt >= m;
  };

  ll l = 0, r = 1e13;
  while (r - l > 1) {
    ll mid = (l + r) / 2;
    if (ok(mid)) l = mid;
    else r = mid;
  }
  ll res = sum - (cnt - m) * l;
  cout << res << endl; 
  return 0; 
} 

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define double long double
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = a; i < (int)(b); ++i)
#define all(x) x.begin(), x.end()
const int mod = 1000 * 1000 * 1000 + 7;
using namespace std;

double d[301][301][301];

int32_t main() {
    int n;
    cin >> n;  
    int od = 0, dv = 0, t = 0, a;
    FOR(i, 1, n + 1) {
        cin >> a;
        if (a == 1) {
            ++od;
        }
        else if (a == 2) {
            ++dv;
        }
        else {
            ++t;
        }
    }

    FOR(z, 0, n + 1) {
        FOR(y, 0, n + 1) {
            FOR(x, 0, n + 1) {
                d[z][y][x] = n;
                if (!(z || y || x)) {
                    d[z][y][x] = 0;
                    continue;
                }
                if (x) {
                    d[z][y][x] += d[z][y][x - 1] * x;
                }
                if (y && x != n) {
                    d[z][y][x] += d[z][y - 1][x + 1] * y;
                }
                if (z && y != n) {
                    d[z][y][x] += d[z - 1][y + 1][x] * z;
                }
                d[z][y][x] /= (x + y + z);
                // cout << d[z][y][x] << " ";
            }
            // cout << endl;
        }
        // cout << endl;
    }
    cout << fixed << setprecision(10) << d[t][dv][od];
    return 0;
}

Measured memory_bytes: 429868
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
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 T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s, t;
	cin >> s >> t;
    int ans = INF;
    int sizet = t.size(), n = s.size() - sizet + 1;
    rep(i,n) {
        int cnt = 0;
        rep(j,sizet) if(s[i+j]!=t[j]) ++cnt;
        mins(ans, cnt);
    }
    cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3644
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>

#define for0(i, N)    for (int i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (int i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (int i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (int i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (int i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (int i = (x), a = 0; a < (N);  \
                              i = (i + 1) % (N), ++a)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;


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

    string s;

    cin >> s;

    int l = s.size();

    int result = 0;

    for (int i = 0; i < l / 2; ++i) {
        if (s[i] != s[l - i - 1]) {
            ++result;
        }
    }

    cout << result;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main
{
	
public static void main(String[]args) throws IOException{
	Scanner sc =new Scanner(System.in);
	int A = sc.nextInt();
	int B = sc.nextInt();
	int sum = A;
	int count = 0;
	while(true) {
		count++;
		sum = sum -B;
		if(sum <=0) {
			break;
		}
	}
	System.out.println(count);
}
}

Measured memory_bytes: 35972
/*=================================*\
								   
	  Md. Shahidul Islam		   
		 CSE, BRUR				 
	  Rangpur, Bangladesh		  
 mail: shahidul.cse.brur@gmail.com 
 FB  : fb.com/shahidul.brur		
 Blog: shahidul-brur.blogspot.com(in Bengali),
	   shahidul-brur-en.blogspot.com(in English) 
\*=================================*/
#include<bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
*/
using namespace std;

#define pb			  push_back
#define debug(x)	  cerr << "   ## " << #x << " = " << x << " ...\n"
#define mp			  make_pair
#define ff			  first
#define ss			  second
#define sz			  size()
#define all(a)		  a.begin(), a.end()
#define f(i, a, b)	  for(int i=(a);i<=(b);i++)
#define F(i, b, a)	  for(int i=(b);i>=(a);i--)
#define PI			  acos(-1.0)
#define EPS			  1e-6
#define mem(a, b)	  memset(a, b, sizeof(a))

#define sI(a)		  scanf("%d", &a)
#define sL(a)		  scanf("%lld", &a)
#define sC(a)		  scanf("%c", &a)
#define sS(a)		  scanf("%s", a)
#define sF(a)		  scanf("%f", &a)
#define sD(a)		  scanf("%lf", &a)

#define sI2(a,b)	  scanf("%d %d", &a, &b)
#define sL2(a,b)	  scanf("%lld %lld", &a, &b)
#define sC2(a,b)	  scanf("%c %c", &a, &b)
#define sS2(a,b)	  scanf("%s %s", a, b)
#define sF2(a,b)	  scanf("%f %f", &a, &b)
#define sD2(a,b)	  scanf("%lf %lf", &a, &b)

#define sI3(a,b,c)	  scanf("%d %d %d", &a, &b, &c)
#define sL3(a,b,c)	  scanf("%lld %lld %lld", &a, &b, &c)
#define sC3(a,b,c)	  scanf("%c %c %c", &a, &b, &c)
#define sS3(a,b,c)	  scanf("%s %s %s", a, b, &c)
#define sF3(a,b,c)	  scanf("%f %f %f", &a, &b, &c)
#define sD3(a,b,c)	  scanf("%lf %lf %lf", &a, &b, &c)

#define pI(a)		  printf("%d", a)
#define pL(a)		  printf("%lld", a)
#define pC(a)		  printf("%c", a)
#define pS(a)		  printf("%s", a)
#define pF(a)		  printf("%f", a)
#define pNL		   printf("\n")

#define pI2(a,b)	  printf("%d %d", a, b)
#define pL2(a,b)	  printf("%lld %lld", a, b)
#define pC2(a,b)	  printf("%c %c", a, b)
#define pS2(a,b)	  printf("%s %s", a, b)
#define pF2(a,b)	  printf("%f %f", a, b)

#define pI3(a,b,c)	  printf("%d %d %d", a, b, c)
#define pL3(a,b,c)	  printf("%lld %lld %lld", a, b, c)
#define pC3(a,b,c)	  printf("%c %c %c", a, b, c)
#define pS3(a,b,c)	  printf("%s %s %s", a, b, c)
#define pF3(a,b,c)	  printf("%f %f %f", a, b, c)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<float> vf;
typedef pair<int, int> ii;
typedef vector<ii> vii;

//			  0123456789
const int MOD = 1000000007;
const int MAX = 100002;

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	//ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, a, b;
	while(cin>>n>>a>>b)
	{
		if(a>b) swap(a, b);
		if((b-a-1)%2==0)
			cout << "Borys\n";
		else cout << "Alice\n";
	}
	return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N;
Int A[100000+10];
Int X[100000+19];

int main(void) {
    cin>>N;

    Int sum = 0;
    for(int i = 1;i <= N;i++) {
        cin>>A[i];
        sum += (i&1 ? A[i] : -A[i]);
    }

    X[1] = sum/2;
    for(int i = 2;i <= N;i++) {
        Int a = A[i-1];
        X[i] = a - X[i-1];
    }

    for(int i = 1;i <= N;i++) {
        cout<<2*X[i]<<" ";
    }
    cout<<endl;

    return 0;
}




Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define maxn 100000
using namespace std;
typedef long long LL;

int n,k;
int ar[maxn];
int dp[maxn];

int main() {
	scanf("%d%d",&n,&k);
	for( int i = 0 ; i < n ; i++ )
		scanf("%d",&ar[i]);
	for( int i = 1 ; i < n ; i++ ) {
		dp[i] = INT_MAX;
		for( int j = 1 ; j <= min(i,k) ; j++ )
			dp[i] = min( dp[i] , dp[i-j] + abs( ar[i] - ar[i-j] ) );
	}
	printf("%d\n",dp[n-1]);
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)

void solve(){
    ld k;
    cin>>k;
    printPrec((k*k*k)/(ld)27);
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
  
}


Measured memory_bytes: 640
#include <sstream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <string>
#include <queue>
#include <bitset>

using namespace std;

#define fto(i,a,b) for (int i = (a); i <= b; i++)
#define fdw(i,a,b) for (int i = (a); i >= b; i--)
#define rep(i,a) for(int i = 0; i < a; i++) 
#define read(a) cin >> a
#define read2(a, b) cin >> a >> b
#define read3(a, b, c) cin >> a >> b >> c
#define read4(a, b, c, d) cin >> a >> b >> c >> d
#define write(a, b) cout << a << b
#define writeln(a) cout << a << "\n"

#define PI 3.14159265
#define oo 1000000000
#define ooLL 100000000000000000
#define log(a) cerr << #a << " = " << a << endl

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define next thongdeptrai
#define prev thongbachuthegioi
#define y1 thongsieucapvutru
#define y0 thongnotgay

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

#define maxn 100005

using namespace std;

int n, a[maxn], res;

int main() {

    // checking input file is not available with atCoder
  //  freopen("in.inp", "r", stdin);
    
    read(n);
    for(int i = 1; i <= n; i++) read(a[i]);

    res = 0;
    for(int i = 1; i < n; i++) 
        if (a[i] == i) {
            swap(a[i], a[i + 1]);
            res++;
        }

    if (a[n] == n) res++;

    cout << res << endl;
    

 	#ifndef ONLINE_JUDGE
    	cout << endl;
    	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	#endif
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;

struct Info {
	unsigned long long n;
	int p;
	unsigned long long c;

	Info(unsigned long long nval, int pval, unsigned long long cval) {
		n = nval;
		p = pval;
		c = cval;
	}
};

bool cmpN(const Info& a, const Info& b) {
	return a.n > b.n;
}

int main() {

	int D;
	unsigned long long G;
	cin >> D;
	cin >> G;

	int p;
	unsigned long long c;
	vector<Info> val(D, Info(0, 0, 0));

	for (unsigned long long i = 0; i < D; i++) {
		cin >> p;
		cin >> c;
		val[i] = Info(100 * (i + 1), p, c);
	}

	// bit�t���O���`��
	vector<unsigned int> BIT_FLAG(D, 0);
	for (unsigned long i = 0; i < D; i++) {
		BIT_FLAG[i] = (1 << i);
	}

	// ���_�̏����ɕ��ׂ�
	sort(val.begin(), val.end(), cmpN);

	Info dummy(0, 0, 0);
	bool cnt = false;
	bool jdg = false;
	unsigned long long sum = 0;
	unsigned long long num = 0;
	unsigned long long ans = 0;
	unsigned long long qval = 0;
	// �����l�i�[
	for (unsigned long long i = 0; i < D; i++) {
		ans += val[i].p;
	}
	// ��������v�Z
	for (unsigned long long i = 0; i < pow(2, D) - 1; i++) {
		dummy = Info(0, 0, 0);
		cnt = false;
		sum = 0;
		num = 0;
		// �t���O����
		for (unsigned long j = 0; j < D; j++) {
			jdg = BIT_FLAG[j] & i;
			if (cnt == false && jdg == false) {
				dummy = val[j];
				cnt = true;
			}
			else if (jdg == true) {
				num += val[j].p;
				sum += (val[j].p * val[j].n + val[j].c);
			}
		}
		if (sum < G) {
			sum = G - sum;
			qval = sum / dummy.n;
			if (sum % dummy.n > 0) {
				qval += 1;
			}
			if (dummy.p > qval) {
				num += qval;
				if (num < ans) {
					ans = num;
				}
			}
		}
		else {
			if (num < ans) {
				ans = num;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<ll,ll>&a,const pair<ll,ll>&b)
{
    return (a.second<b.second);
}

int main()
{
    ios;
    int a,b;
    cin>>a>>b;
    int k=a-2*b;
    if(k<=0)
        cout<<0<<endl;
    else
        cout<<k<<endl;



}









Measured memory_bytes: 3648
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int t, tt, n;
    while(true) {
        cin >> t;
        if(t == 0) break;

        cin >> n;
        tt = 0;
        for(int i = 0; i < n; i++) {
            int s,f;
            cin >> s >> f;
            tt += f - s;
        }
        if(tt >= t) cout << "OK" << endl;
        else cout << t - tt << endl;
    }
    
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll int64_t 
#define f(i,s,e) for(i=s;i<e;++i)
#define endl << "\n"
#define sp << " "
#define INF INFINITY
#define mset(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define crap ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846264338327950288419716939937510
#define pb(a) push_back(a)
#define pf(a) push_front(a)

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;

int main()
{
	crap;
	ll i,j,k,n;
	cin >> n; 
	vector <ll> arr(n) ;
	f(i,0,n)
		cin >> arr[i] ;
	sort(all(arr)) ;
	ll count = 1;
	ll sum = arr[n-1];
	for(i=n-2;i>=0;--i)
	{
		if(count==n-1)
			break ;
		sum += arr[i] ;
		count++ ;
		if(count==n-1)
			break ;
		sum += arr[i] ;
		count++ ;
	}
	cout << sum endl ;
	return 0;
}

Measured memory_bytes: 4764
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,a,b = 0;
cin >> N;
vector<int> cure(N);
for(int i = 0; i < N; i++){
    cin >> cure[i];
}
for(int i = 0; i < N; i++){
    for(int j = i + 1; j < N; j++){
        a = cure[i]*cure[j];
        b += a;
    }
}
cout << b << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
class Main {
  public static void main(String args[]) {
    Scanner scanner = new Scanner(System.in);
 
    int a = scanner.nextInt();
    int b = scanner.nextInt();

    if (a < b) {
        System.out.println("a < b");
    }else if(a > b){
        System.out.println("a > b");
    }else if(a == b){
        System.out.println("a == b");
    }
 
    scanner.close();
  }
}


Measured memory_bytes: 26196
using System;

class Program
{
    static void Main(string[] args)
    {
        var a = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();
        if(a >= 3200)
        {
            Console.WriteLine(s);
        }
        else if(a < 3200)
        {
            Console.WriteLine("red");
        }
    }


    public string[] ReadInput()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] ConvertIntArray(string[] x)
    {
        var convertedArray = new int[x.Length];
        for (var i = 0; i < x.Length; i++)
        {
            convertedArray[i] = int.Parse(x[i]);
        }

        return convertedArray;
    }

}


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

int main(void) {
  char S[1024];int q,Q;
  scanf("%s\n",S);
  scanf("%d\n",&Q);
  for (q=0;q<Q;q++) {
    char C[1024]; int c,B,E;
    scanf("%s",C);
    scanf("%d %d",&B,&E);
    if (!strcmp(C,"replace")) {
      scanf("%s",C);
      memcpy(S+B,C,E-B+1);
    }
    else if (!strcmp(C,"reverse")) {
      strncpy(C,S+B,E-B+1);
      for(c=E;c>=B;c--)
        S[c]=C[E-c];
    }
    else if (!strcmp(C,"print")) {
      strncpy(C,S+B,E-B+1);
      C[E-B+1]=0;
      printf("%s\n",C);
    }
  }
  return 0;
}

Measured memory_bytes: 620