akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<=b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;



int main(){
    INIT;
    int n;
    cin >> n;
    int ans = 0;
    REP(i,n) {
        int l, r;
        cin >> l >> r;
        ans += r-l+1;
    }
    cout << ans;
}


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

int main()
{
  int n,m;
  cin>>n>>m;
  vector<string> a(n),b(m);bool flag;
  for(auto &i:a) cin>>i;
  for(auto &i:b) cin>>i;

  for(int i=0;i+m<=n;i++)
    for(int j=0;j+m<=n;j++)
      {
        flag=true;
        for(int k=0;k<m;k++)
          if(a[i+k].substr(j,m)==b[k])
            continue;
          else
            {flag=false;break;}
        if(flag)
          {
            cout<<"Yes\n";return 0;
          }
      }

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


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[110];
    rep(i, N) cin >> a[i];
    int Alice = 0, Bob = 0;
    sort(a, a + N, greater<int>());
    rep(i, N) {
        if (i % 2 == 0) Alice += a[i];
        else Bob += a[i];
    }
    cout << Alice - Bob << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

signed main() {
    int n;
    cin >> n;
    vector<pair<int, int> > v;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        v.emplace_back(make_pair(a, i + 1));
    }
    sort(v.begin(), v.end());
    for(auto&& p: v) {
        cout << p.second << "\n";
    }
}

Measured memory_bytes: 2544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

int main() {
    int N, M;  cin >> N >> M;
    vector<pair<ll, int>> v;
    rep(i, N) {
        int a, b;  cin >> a >> b;
        v.push_back(make_pair(a, b));
    }
    sort(v.begin(), v.end());

    int cnt = 0;
    ll ans = 0;
    rep(i, N) {
        if (cnt + v[i].second < M) {
            ans += v[i].first * v[i].second;
            cnt += v[i].second;
        } else if (cnt < M) {
            ans += v[i].first * (M-cnt);
            cnt += M - cnt;
        } else break;
    }
    print(ans);

}




Measured memory_bytes: 2420
#include <stdio.h>
#include <math.h>
#define P 3.141592




typedef struct{
  double x;
  double y;
}za;
za S(za, za);
za T(za, za);
za U(za, za);
void co(int,za,za);
int main(){
  za p1 = {0,0};
  za p2 = {100.0};
  int o;
  scanf("%d",&o);
  printf("%lf %lf", p1.x, p1.y);
  printf("\n");
  co(o,p1,p2);
  printf("%lf %lf", p2.x, p2.y);
  printf("\n"); 
  return 0;
}


za S(za p1,za p2) {
  za s;
  s.x = (2 * p1.x + p2.x) / 3;

	
    s.y = (2 * p1.y + p2.y) / 3;
    return s;
  }
  za T(za p1, za p2) {
    za t;
    t.x = (p1.x + 2 * p2.x) / 3;

	
    t.y = (p1.y + 2 * p2.y) / 3;
    return t;
  }
  za U(za t,za s) {
    za u;
    double en = 60*P/180.0;
	
    u.x = (t.x - s.x) * cos(en) - (t.y - s.y) * sin(en) + s.x;

	
    u.y = (t.x - s.x) * sin(en) + (t.y - s.y) * cos(en) + s.y;
    return u;
  }
  void co(int n, za p1, za p2) {
    za s, t, u;
    if (n == 0)	return;
    s = S(p1, p2);
    
    t = T(p1, p2);
    
    u = U(t, s);
    
    co(n - 1, p1, s);
   printf("%lf %lf\n", s.x,s.y);
    co(n - 1, s, u);
    printf("%lf %lf\n", u.x, u.y);
    co(n - 1, u, t);
    printf("%lf %lf\n", t.x, t.y);
    co(n - 1, t, p2);
  }



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

bool is_prime(int x){
    if(x<=1) return  false;
    for(int i=2;i*i<=x;i++){
        if(x%i==0) return false;}
        return true;

}
signed main()
{
    int x;
    cin>>x;
    int p=x;
    while(!is_prime(p)) p++;
    cout<<p<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <string>
using namespace std;

int main(){
	int n;
	double xa, ya, xb, yb, xc, yc;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> xa >> ya >> xb >> yb >> xc >> yc;
		double a, b, c;
		a = (xb - xc) * (xb - xc) + (yb - yc) * (yb - yc);
		b = (xc - xa) * (xc - xa) + (yc - ya) * (yc - ya);
		c = (xa - xb) * (xa - xb) + (ya - yb) * (ya - yb);
		double px, py, r;
		px = a * (b + c - a) * xa + b * (c + a - b) * xb + c * (a + b - c) * xc;
		py = a * (b + c - a) * ya + b * (c + a - b) * yb + c * (a + b - c) * yc;
		px /= a * (b + c - a) + b * (c + a - b) + c * (a + b - c);
		py /= a * (b + c - a) + b * (c + a - b) + c * (a + b - c);
		a = sqrt(a);
		b = sqrt(b);
		c = sqrt(c);
		r = a * b * c / sqrt((a + b + c) * (-a + b + c) * (a - b + c) * (a + b - c));
		cout << fixed << setprecision(3) << px << ' ' << py << ' ' << r << endl;
	}
	return 0;
}

Measured memory_bytes: 1288
#include <stdio.h>

int main(void) {

  long n;
  scanf("%ld", &n);
  char s[n][11];
  for (long i = 0; i < n; i++) {
    scanf("%s", s[i]);
  }
  long count[5];
  for (long i = 0; i < 5; i++) {
    count[i] = 0;
  }
  for (long i = 0; i < n; i++) {
    if (s[i][0] == 'M') {
      count[0]++;
    }
    if (s[i][0] == 'A') {
      count[1]++;
    }
    if (s[i][0] == 'R') {
      count[2]++;
    }
    if (s[i][0] == 'C') {
      count[3]++;
    }
    if (s[i][0] == 'H') {
      count[4]++;
    }
  }
  long answer = 0;
  for (int i = 0; i < 5; i++) {
    for (int j = i+1; j < 5; j++) {
      for (int k = j+1; k < 5; k++) {
        answer += count[i]*count[j]*count[k];
      }
    }
  }
  printf("%ld\n", answer);

  return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <math.h>
#include <cstdlib>

using namespace std;

int h, w, matrix[51][51], currentCnt;

struct Point
{
    int x;
    int y;
};

Point searchFree()
{
    Point ans;
    ans.x = -1;
    ans.y = -1;
    for (int i = 1; i <= h; i++)
        for (int j = 1; j <= w; j++)
            if (matrix[i][j] == 1)
            {
                ans.x = i;
                ans.y = j;
                return ans;
            }
    return ans;
}

void deleteTile(int x, int y)
{
    if (matrix[x][y] == 1)
    {
        currentCnt++;
        matrix[x][y] = 0;
        deleteTile(x - 1, y);
        deleteTile(x + 1, y);
        deleteTile(x, y - 1);
        deleteTile(x, y + 1);
    }
}

int main()
{
    cin >> h >> w;
    for (int i = 1; i <= h; i++)
        for (int j = 1; j <= w; j++) 
        {
            char c;
            cin >> c;
            if (c == '#') matrix[i][j] = 1; else matrix[i][j] = 0;
        }
    
    Point fpoint;
    fpoint = searchFree();
    while (fpoint.x != -1)
    {
        currentCnt = 0;
        deleteTile(fpoint.x, fpoint.y);
        if (currentCnt < 2) 
        {
            cout << "No";
            return 0;
        }
        fpoint = searchFree();
    }
    cout << "Yes";
    return 0;
}


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

using namespace std;

template<class T>
class BinaryIndexedTree {
    public:
        BinaryIndexedTree(int size) : mData(size+1) {}
        
        void add(int i, T x){
            for(; i <= mData.size(); i += i & -i){
                mData[i] += x;
            }
        }

        T sum(int i){
            T sum = 0;
            for(; i > 0; i -= i & -i){
                sum += mData[i];
            }
            return sum;
        }
    private:
        vector<T> mData;
};

int main(){
    int n,q,c,x,y;
    cin >> n >> q;
    BinaryIndexedTree<int> bit(n);
    for(int i = 0; i < q; ++i){
        cin >> c >> x >> y;
        if(c==0){
            bit.add(x,y);
        } else {
            cout << bit.sum(y) - bit.sum(x-1) << '\n';
        }
    }
    return 0;
}





Measured memory_bytes: 3096
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char const *argv[]) {
  int m,d;
  int d1,d10;
  int count=0;

  scanf("%d %d",&m ,&d );

  for(int i=1;i<=m;i++){
    for (int j = 11; j <= d; j++) {
      d1 = j % 10;
      d10 = (j - d1) / 10;
      if(d1 < 2 || d10 < 2)continue;
      if( i == (d1 * d10)){
        count++;
      }
    }
  }

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

  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

int dp[110][4][4][4];

int check(int a,int b,int c){
  return (a==1 && b==2 && c==3);
}

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

  int N=in();
  // 'T','A','G','C'
  // "AGC" "ACG" "GAC" "A*GC" "AG*C"
  dp[0][0][0][0] = 1;
  for(int i=0;i<N;i++){
    for(int a=0;a<4;a++){
      for(int b=0;b<4;b++){
        for(int c=0;c<4;c++){
          for(int d=0;d<4;d++){
            if(check(b,c,d) || check(c,b,d) || check(b,d,c)) continue;
            if(check(a,c,d) || check(a,b,d)) continue;
            dp[i+1][b][c][d] = (dp[i+1][b][c][d] + dp[i][a][b][c])%1000000007;
          }
        }
      }
    }
  } 
  ll sum=0;
  for(int a=0;a<4;a++){
    for(int b=0;b<4;b++){
      for(int c=0;c<4;c++){
        sum += dp[N][a][b][c];
        sum %= 1000000007;
      }
    }
  }
  cout << sum<< endl;
  return 0;
}


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

int main(void){
	int n;
	int r=0, b=0;
	string s;
	cin >> n >> s;
	for(int i = 0; i < n; ++i){
		if(s[i] == 'R'){
			r++;
		}else{
			b++;
		}
	}
	if(r>b){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
S = input()
n = len(S)
K = 1
i = 1
while i < n:
    if S[i-1] == S[i]:
        if i == n - 1:
            i += 1
        elif i == n - 2:
            i += 2
            K += 1
        else:
            i += 3
            K += 2
    else:
        i += 1
        K += 1

print(K)


Measured memory_bytes: 3500
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--) 
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
typedef pair<int, int> pii;
#define x first
#define y second
const int N = 20, M = N * N, mod = 1e9 + 7;

int d[N];
struct edge{ int to, pre; } e[M]; int u[N], l = 0;
void ins(int a, int b) { e[++l] = (edge){b, u[a]}, u[a] = l; d[a]++; }
#define v e[i].to
#define reg(i,a) for(int i = u[a]; i; i = e[i].pre)

int n, m, level[N], ans = 0;
int Cnt[N][N], Pre[N][N], Suf[N][N];
void dfs(int x, int l, int t) {
	if (x == 2) {
		ans = (ans + 1LL * t * (1 << (d[1] + d[2]))) % mod;
		static int c1[N], c2[N];
		rep(i,0,l) c1[i] = c2[i] = 0;
		reg(i,1) if (v != 2) c1[level[v]]++;
		reg(i,2) c2[level[v]]++;
		int *pre = Pre[2], *suf = Suf[2];
		pre[0] = ((1 << c1[0]) - 1) * ((1 << c2[0]) - 1);
		rep(i,1,l) pre[i] = 1LL * pre[i - 1] * ((1 << c1[i]) - 1) * ((1 << c2[i]) - 1) % mod;
		suf[l + 1] = 1;
		dep(i,l,0) suf[i] = 1LL * suf[i + 1] * (1 << (c1[i] + c2[i])) % mod;
		rep(i,0,l) {
			int tmp = 1LL * (i ? pre[i - 1] : 1) * suf[i + 1] % mod;
			ans = (ans - 1LL * t * tmp) % mod;
		}
	} else {
		int *cnt = Cnt[x], *pre = Pre[x], *suf = Suf[x];
		rep(i,0,l) cnt[i] = 0;
		reg(i,x) cnt[level[v]]++;
		pre[0] = (1 << cnt[0]) - 1; 
		rep(i,1,l) pre[i] = 1LL * pre[i - 1] * ((1 << cnt[i]) - 1) % mod;
		suf[l + 1] = 1;
		dep(i,l,0) suf[i] = 1LL * suf[i + 1] * (1 << cnt[i]) % mod;
		rep(i,0,l) {
			level[x] = i;
			int tmp = 1LL * (i ? pre[i - 1] : 1) * suf[i + 1] % mod;
			if (tmp) dfs(x - 1, (i == l) ? l + 1 : l, 1LL * t * tmp % mod);
		}
	}
}

int main() {
	scanf("%d%d",&n,&m);
	rep(i,1,m) {
		int a, b; scanf("%d%d",&a,&b);
		ins(a, b);
	}
	dfs(n, 0, 1);
	if (ans < 0) ans += mod;
	printf("%d\n",ans);
	return 0;
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 4e5 + 5;

int n,m;
ll a[maxn],b[maxn];

multiset<pair<ll,ll>> s;

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

  cin>>n>>m;
  for (int i=0; i<n; i++) {
    cin>>a[i]>>b[i];
    s.insert({a[i],b[i]});
  }

  ll tot=0;
  while (m>0) {
    auto pr = *s.begin();
    s.erase(s.begin());
    ll cost = pr.first;
    ll amt = pr.second;
    amt = min(amt, 1LL*m);
    tot += amt*cost;
    m -= amt;
  }
  cout<<tot<<endl;
  return 0;
}


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

using namespace std;

#define boost                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for (auto &z : v)
#define sp << ' ' <<
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353
#define PI_2 1.57079632679489661923

vi spf(1e7 + 3, 0);

int main()
{
    boost;
    time_t tic, toc;

    ll tt = 1, n, m, k = 0, i, j, p, q;
    ll a, b, h, w, u, v, x, y;
    ll l = 0, r = 0;
    ll ans = 0;

    bool poss = true;

    string s, t, tmp;

    // cin >> tt;
    tic = clock();
    for(int _ = 1; _ <= tt; _++){
        // cout << "Case #" << _ << ": ";
        cin >> n;

        for(i = 1; i <= n; i++) spf[i] = i;

        for(i = 2; i*i <= n; i++){
            if(spf[i] != i) continue;
            for(j = i*i; j <= n; j += i){
                if(spf[j] != j) continue;
                spf[j] = i;
            }
        }

        ans = 0;
        ll mult = 1;
        for(i = 1; i <= n; i++){
            l = i;
            mult = 1;

            ll lst = spf[l];
            r = 1;
            while(l > 1){
                l /= spf[l];
                if(lst == spf[l]){
                    r++;
                }
                else{
                    lst = spf[l];
                    mult *= (r + 1);
                    r = 1;
                }
            }

            ans += i*mult;
        }
        cout << ans << nl;
    } 
    // cerr << (clock() - tic*1.0) / CLOCKS_PER_SEC << nl;
    return 0;
}

Measured memory_bytes: 81208
#include <bits/stdc++.h>
using namespace std;
int main() {
string S;
  cin >> S;
  if(S == "SSS")cout << "0" << endl;
  if(S == "SSR")cout << "1" << endl;
  if(S == "SRS")cout << "1" << endl;
  if(S == "SRR")cout << "2" << endl;
  if(S == "RSS")cout << "1" << endl;
  if(S == "RSR")cout << "1" << endl;
  if(S == "RRS")cout << "2" << endl;
  if(S == "RRR")cout << "3" << endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=100;i>=0;i--){
    int sum=0;
    for(int j=0;j<n;j++){
      if(a[j]>=i)sum++;
    }
    if(sum>=i){
      cout<<i<<endl;
      break;
    }
  }
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fio ios_base::sync_with_stdio(false)
#define pdl cout << "*" << endl
#define MOD 1000000007
#define INF 1000000000
#define INFLL 1000000000000000000ll
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define long int64_t
using namespace std;
using namespace __gnu_pbds;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef priority_queue<pii, vector<pii>, greater<pii>> min_pq;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OST;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<> dis(0, INF<<1);
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char* name, Arg1&& arg1){ cerr << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args)
{ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma+1, args...); }

const int N = 200001;

int a[N];

bool check(int k, int n)
{
	unordered_map<int, int> m;
	stack<int> s;
	for(int i=1; i<=n; i++)
	{
		if(a[i] > a[i-1])
			continue;
		if(k == 1)
			return false;
		while(!s.empty() and s.top() > a[i])
		{
			m[s.top()] = 0;
			s.pop();
		}
		int p = a[i];
		while(p)
		{
			m[p]++;
			if(s.empty() or s.top() != p)
				s.push(p);
			if(m[p] == k)
			{
				m[p] = 0;
				s.pop();
				p--;
			}
			else
				break;
		}
		if(p == 0)
			return false;
	}
	return true;
}

int main()
{
	fio;
	int n;
	cin >> n;
	for(int i=1; i<=n; i++)
		cin >> a[i];
	int l = 1, r = n;
	while(l != r)
	{
		int mid = l+r >> 1;
		if(check(mid, n))
			r = mid;
		else
			l = mid + 1;
	}
	cout << l << endl;
	return 0;
}


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

string a;
bool l = 1;

int main()
{
	cin>>a;
	if(a.size() % 2 != 0) l = 0;
	for(int i = 0;i < a.size();i += 2)
	{
		if(l == 0) break;
		if(a[i] != 'h' || a[i + 1] != 'i') l = 0;
	}
	if(l == 1) cout<<"Yes";
	else cout<<"No";
	return 0;
}


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

int		main(void)
{
	int		a, b, c;

	cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);
	cout << a << " " << b << " " << c << endl;
}

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

int main() {
  int n;
  cin >> n;
  bool prev = false;
  int answer = 0;
  int p;
  for (int ni = 0; ni < n; ni++) {
    cin >> p;
    if (p == ni + 1) {
      if (prev) {
        prev = false;
      } else {
        answer++;
        prev = true;
      }
    } else {
      prev = false;
    }
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <algorithm>
#include <cstdio>

using namespace std;
const int MAXN = 210;
const int MOD = 998244353;
int nowarn;

int n, x[MAXN], y[MAXN];
int ans, pw[MAXN];

bool OnLine( int i, int j, int k ) {
	if( y[i] > y[j] ) swap(i, j);
	if( y[k] < y[i] || y[k] > y[j] ) return false;
	if( x[i] > x[j] ) swap(i, j);
	if( x[k] < x[i] || x[k] > x[j] ) return false;
	int vx = x[k] - x[i], vy = y[k] - y[i];
	int wx = x[k] - x[j], wy = y[k] - y[j];
	return vx*wy - vy*wx == 0;
}

int main() {
	nowarn = scanf( "%d", &n );
	for( int i = 0; i < n; ++i )
		nowarn = scanf( "%d%d", x+i, y+i );
	pw[0] = 1;
	for( int i = 1; i <= n; ++i )
		pw[i] = pw[i-1] * 2 % MOD;
	ans = (pw[n] - n + MOD) % MOD;
	for( int i = 0; i < n; ++i )
		for( int j = i+1; j < n; ++j ) {
			int cnt = 0;
			for( int k = 0; k < n; ++k )
				if( k != i && k != j && OnLine(i, j, k) )
					++cnt;
			ans = (ans - pw[cnt] + MOD) % MOD;
		}
	printf( "%d\n", (ans - 1 + MOD) % MOD );
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n, k;
	scanf("%d %d", &n, &k);
	int i, j;
	long long int a[1003];
	for (i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	long long int sum[1003];
	sum[0] = 0;
	for (i = 0; i < n; i++)
		sum[i + 1] = sum[i] + a[i];
	int m = 0;
	long long int b[1000006];
	for (i = 0; i < n; i++)
	{
		for (j = i; j < n; j++)
		{
			b[m] = sum[j + 1] - sum[i];
			m++;
		}
	}
	long long int ans = 0;
	long long int v;
	v = 1;
	while (v <= sum[n])
		v *= 2;
	int count;
	while (v > 0)
	{
		count = 0;
		for (i = 0; i < m; i++)
			if ((b[i] & (ans + v)) == (ans + v))
				count++;
		if (count >= k)
			ans += v;
		v /= 2;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

// 1-indexed BIT (i : [1, len])
template<typename T, int len>
struct BIT
{
    array<T, len + 1> val;
    BIT() { val.fill(0); }
    void add(int pos, T v)
    {
        while (pos > 0 && pos <= len)
        {
            val[pos] += v;
            pos += pos & -pos;
        }
    }
    T sum(int pos)
    {
        T res = 0;
        while (pos > 0)
        {
            res += val[pos];
            pos -= pos & -pos;
        }
        return res;
    }
};


lint N;
vector<lint> a;

// 中央値がn以上になる部分列の個数を返す
lint nibu(lint n)
{
    vector<int> accumSum(N + 1);
    BIT<int, 300000> b;
    lint now = 100001;
    lint ans = 0;
    b.add(now, 1);
    REP(i, N)
    {
        now += (a[i] >= n ? 1 : -1);
        ans += b.sum(now);
        b.add(now, 1);
    }
    return ans;
}

int main()
{
    cin >> N;
    a.resize(N);
    REP(i, N) cin >> a[i];

    lint l = 0, r = 1000000002;
    while (r - l > 1)
    {
        lint c = (l + r) / 2;
        if (nibu(c) < (N * (N + 1) / 2 + 1) / 2) r = c;
        else l = c;
    }
    cout << l << endl;
}


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

int main(){
    int n;
    cin >> n;
    map<int, bool> mp;
    int a;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        if (mp[a])
        {
            cout << "NO" << endl;
            return 0;
        }
        mp[a] = true;
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>  
using namespace std;  
#define INF 0x3f3f3f3f  
typedef long long ll;  
const int N =  1e5 + 10;  
#define FI first
#define SE second
typedef pair<int, int>pii;
 
int main()  
{  
  // freopen("in.txt","r",stdin);
   int a ,b;
   while (~scanf("%d%d", &a, &b))
   {
   	 if (a + b>=10)
   	 	puts("error");
   	 else
   	 	printf("%d\n", a +b);
   }
   return 0;  
}  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  int n;cin >> n;
  vector<int> a(n);
  for(auto &i:a) cin >> i;
  bool flag = true;
  int ans = 0;
  while(1){
    for(auto&i:a){
      if(i&1||i==0) flag = false;
    }
    if(!flag){
      cout << ans << endl;
      return 0;
    }
    rep(i,n) a[i]/=2;
    ans++;
    //rep(i,n) cout << " " << a[i];
    //cout << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,i,j,flg;
	scanf("%d",&n);
	flg=1;
	for(i=1;i<=9;i++){
		for(j=1;j<=9;j++){
			if(n==i*j){
				flg=0;
				break;
			}
		}
	}
	if(flg==0){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 128
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 5010;
const int MAXQ = 200010;

int k, q, n;
ll d[MAXK], m, x, D[MAXK];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> k >> q;
    FOR(i,0,k-1) cin >> d[i];
    while (q--) {
        cin >> n >> x >> m;
        FOR(i,0,k-1) D[i] = d[i] % m;

        ll cnt0 = 0;
        FOR(i,0,k-1) cnt0 += (D[i] == 0);

        ll caseEqual = cnt0 * ((n-1) / k);
        FOR(i,0,(n-1)%k - 1) caseEqual += (D[i] == 0);

        ll caseBigger = x % m;
        ll sumD = 0;
        FOR(i,0,k-1) sumD += D[i];
        caseBigger += (n-1)/k * sumD;
        FOR(i,0,(n-1)%k - 1) caseBigger += D[i];
        caseBigger /= m;

        cout << n-1 - caseEqual - caseBigger << "\n";
    }
    return 0;
}


Measured memory_bytes: 384
// N人目に注意!これだけ分けて考える。
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  int ans = 0;
  for (int i = 0; i < N; i++) cin >> a.at(i);
  sort(a.begin(), a.end());
  for (int i = 0; i < N - 1; i++){
    if (a[i] <= x) {
      ++ans;
      x = x - a[i];
    }
  }
  
  if (a[N-1] == x) ++ans;
  
    
   cout << ans << endl;
}

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

using namespace std;

int main()
{
  int partSum[1001];
  for(int i = 0; i <= 1000; i++) partSum[i] = i;
  partial_sum(partSum, partSum + 1001, partSum);
  
  int N;
  while(cin >> N, N){
    int cnt = 0;
    for(int i = 0; i < 1000; i++){
      for(int j = i + 2; j < 1001; j++){
	if(partSum[j] - partSum[i] == N) cnt++;
      }
    }
    cout << cnt << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using in6 = int64_t;
using ind = double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int a;
  cin >> a;
  cout << (a + 1) / 2 << "\n";
}

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

int main(){
	int a,b,c,N; cin >> N;
	for(int i=0;i<N;i++){
		cin >> a >> b >> c;
		if((a*a + b*b == c*c)||(b*b + c*c == a*a)||(c*c + a*a == b*b)){
			cout << "YES" <<endl;
		}
		else{
			cout << "NO" <<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 2992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    cin >> n;
    rep(i,n+1){
        if((ll)i*(i+1)/2>=n){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define DUMP(v) for(auto& x : v) cerr << x << " "; cerr << endl;
using namespace std;

using ll = long long;

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; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

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

  int n;
  cin >> n;
  vector<int> a(n+1);
  rep(i, n+1) cin >> a[i];

  vector<pair<ll, ll>> nums(n+1);
  rep(i, n+1) {
    nums[i] = {0, (1LL<<i)};
  }

  if (a[0] > 1 || a[n] > (1LL<<n)) {
    cout << -1 << endl;
    return 0;
  }

  nums[0] = {1, 1};
  nums[n] = {a[n], a[n]};

  for (int i = n-1; i > 0; i--) {
    nums[i].first = (nums[i+1].first + 1) / 2 + a[i];
    nums[i].second = nums[i+1].second + a[i];
  }

  for (int i = 0; i < n; i++) {
    chmin(nums[i+1].second, (nums[i].second - a[i]) * 2);
  }

/*
  for (int i = 0; i < n; i++) {
    chmin(nums[i].second, 1LL<<i);
  }
*/
  for (auto& p : nums) {
    if (p.first > p.second) {
      cout << -1 << endl;
      return 0;
    }
  }

  ll ans = 0;
  for (auto& p : nums) ans += p.second;

  cout << ans << endl;

  return 0;
}


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

using namespace std;

typedef pair<long long int, vector<long long int>> PLVL;

int main(){
	long long int A, B, X;
	cin >> A >> B >> X;
	if( A <= X && X <= A + B ){
		cout << "YES" << endl;
	} else{
		cout << "NO" << endl;
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define  ren(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) ren(i,0,(n))
#define  all(a) begin(a),end(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
 
int main()
{
    int x=0,ans=0,n;
    string s;
    cin>>n>>s;
    for(char c:s)if(c=='I')x++,ans=max(x,ans);else if(c=='D')x--;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def nCr(n, r):
    return fac[n] // fac[r] // fac[n - r]

fac = [1]
for i in range(1, 51):
    fac.append(fac[-1] * i)

def main():
    n, a, b = MI()
    vv = LI()
    vv.sort(reverse=True)
    s = sum(vv[:a])
    tot = vv.count(vv[a - 1])
    l = vv[:a].count(vv[a - 1])
    if l == a:
        p = 0
        for r in range(l, min(tot,b) + 1):
            p += nCr(tot, r)
    else:
        p = nCr(tot, l)
    print(s / a)
    print(p)

main()


Measured memory_bytes: 3064
import std.stdio, std.string, std.algorithm, std.conv, std.range, std.array;

void main() {
  auto inp = readln().chomp;
  int max;
  for(int i; i<=(inp.length-1)/2; i++){
    if(inp[0..i]==inp[i..i*2]){max=i*2;}
  }
  max.writeln;
}

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

signed main() {
	string S,T,ans;
	cin >> S>> T;
	ans=S;
	int N=S.size();
	int M=T.size();
	vector<string> A;
	bool tmp=true;
	for(int i=0;i<N-M+1;i++){
		for(int j=0;j<M;j++){
			if(S.at(i+j)=='?')continue;
			else if(S.at(i+j)==T.at(j))continue;
			else {
				tmp=false;
				break;
			}
		}
		if(tmp){
			for(int j=0;j<M;j++){
				ans.at(i+j)=T.at(j);
			}
			for(int k=0;k<N;k++){
				if(ans.at(k)=='?')ans.at(k)='a';
			}
			A.push_back(ans);
			ans=S;
			continue;
		}
		else if(!tmp && i!=N-M){
			tmp=true;
			continue;
		}
	}
	if(A.size()!=0){
		sort(A.begin(),A.end());
		ans=A.at(0);
	}
	else ans="UNRESTORABLE";
	cout<<ans<<endl;
	
	return 0;
}
	

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using i64 = int64_t;
#define rep(i, s, n) for (i64 i = (s); i < (n); ++i)


void run() {
  i64 n;
  cin >> n;
  i64 ret{0};
  rep(a, 1, n){
    ret += (n-1)/a;
  }
  cout << ret << endl;
}

int main() {
  cin.tie(nullptr);
  run();
  return 0;
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define int long long 
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(a) a.begin(),a.end()
#define ld long double
#define ub upper_bound
#define lb lower_bound
#define pii pair<int,int>
using namespace std;
signed main()
{
    fast;
    int n,k,s;
    cin>>n>>k>>s;
    while(k--){
        cout<<s<<" ";
        n--;
    }
    if(s == 1e9){
        while(n--)
            cout<<(s-1)<<" ";
    }
    else{
        while(n--)
        cout<<(int)(1e9)<<" ";
    }
}   

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
const long long MODNUM = 7;

int main() {

    string s; cin >> s;
    rep(i, s.size()) {

    }

    int index = 0;
    int ans=0;
    string prev = "";
    while(index < s.size()) {
        string tmp=s.substr(index,1);
        if(tmp == prev) {
            // 最後の文字だったら前の奴に加えてあげる
            if(index == s.size()-1) {
                cout << ans << endl;
                return 0;
            }
            // それ以外は2つとる
            prev = s.substr(index,2);
            ans++;
            index += 2;
            continue;
        } else {
            prev = tmp;
            ans++;
            index += 1;
            continue;
        }
    }

    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 640
N = int(input())
S = input()
count = 0
for s in S:
    if s == ".":
        count += 1
left = 0
right = count
minimum = left+right
for n in range(N):
    if S[n] == "#":
        left += 1
    else:
        right -= 1
    if left+right < minimum:
        minimum = left+right
print(minimum)


Measured memory_bytes: 3500
#include<iostream>
#include<string.h>
using namespace std;
long long int dp[50][51][2501];
long long int DP(int i, int j, int k);
long long int x[50];
long long int n, a;
int main() {

	//C
	//int n, a;
	cin >> n >> a;
	long long int i;
	memset(dp, -1, sizeof(dp));
	for (i = 0; i < n; i++) {
		cin >> x[i];
	}
	long long int s = 0;
	for (i = 1; i <= n; i++) {
		s = s + DP(0, i, i * a);
	}
	cout << s << endl;
	return 0;



}
long long int DP(int i, int j, int k) {
	//i以降でj枚選び合計kとなる選び方
	long long int b, sum;
	if (k < 0) {
		//cout << i << ' ' << j << ' ' << k << ' ' << 0 << endl;
		return 0;
	}
	if (dp[i][j][k] >= 0) {
		//cout << i << ' ' << j << ' ' << k << ' ' << dp[i][j][k] << endl;
		return dp[i][j][k];
	}

	if (j == 0) {
		//0枚選びは合計0しかない
		if (k == 0) {
			dp[i][j][k] = 1;
			//cout << i << ' ' << j << ' ' << k << ' ' << dp[i][j][k] << endl;
			return 1;
		}
		else {
			dp[i][j][k] = 0;
			//cout << i << ' ' << j << ' ' << k << ' ' << dp[i][j][k] << endl;
			return 0;
		}
	}
	if (n-i < j) {
		dp[i][j][k] = 0;
		//cout << i << ' ' << j << ' ' << k << ' ' << dp[i][j][k] << endl;
		return 0;
	}
	else if (n-i == j) {
		//kが合計なら1通り，そうでないなら0通り
		sum = 0;
		for (b = i; b < n; b++) {
			sum = sum + x[b];
		}
		if (sum == k) {
			dp[i][j][k] = 1;
			//cout << i << ' ' << j << ' ' << k << ' ' << dp[i][j][k] << endl;
			return 1;
		}
		else {
			dp[i][j][k] = 0;
			//cout << i << ' ' << j << ' ' << k << ' ' << dp[i][j][k] << endl;
			return 0;
		}
	}
	else {
		//i採用と不採用で分ける．
		sum = DP(i + 1, j - 1, k-x[i]);
		sum = sum + DP(i + 1, j, k);
		dp[i][j][k] = sum;
		//cout << i << ' ' << j << ' ' << k << ' ' << dp[i][j][k] << endl;
		return sum;
	}
}

Measured memory_bytes: 53476
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

class UnionFind {
public:
	vector<int> par;//親の番号
    vector<int> rank;//木の深さ
 
	UnionFind(int n){//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
		rep(i,n){
            par.push_back(i);
            rank.push_back(0);
        }
	}
 
	int find(int x) {//木の根を求める
		if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
	}
 
	void unite(int x,int y){//xとyの属する集合を併合
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){//木の深さが小さい方を大きい方へ繋げる
            par[x]=y;
        }else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){//xとyが同じ集合に属するか否か
        return find(x)==find(y);
    }
};
//x以下の要素への最小index, ソートしてから使ってね
template <class T> 
int former(const vector<T> &v, T x){
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
//x以上の要素への最小index
template <class T> 
int latter(const vector<T> &v, T x){
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}
//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}
//nCk
template <class T>
T comb(T n,T k){
    T ans=1;
    FOR(i,n-k+1,n+1){
        ans*=i;
    }
    FOR(i,1,k+1){
        ans/=i;
    }
    return ans;
}
//a,bの最大公約数
template <class T>
T gcd(T a,T b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}
//素因数分解
template <class T>
map<T,T> prime_factor(T x){
    map<T,T> ans;
    for(T i=2;i*i<=x;i++){
        while(x%i==0){
            x/=i;
            ans[i]++;
        }
    }
    if (x!=1){
        ans[x]=1;
    }
    return ans;
}
//約数列挙
template <class T>
vector<T> divisor(T x){
    vector<T> res;
    for(T i=1;i*i<=x;i++){
        if(x%i==0){
            res.push_back(i);
            if(i!=x/i){
                res.push_back(x/i);
            }
        }
    }
    return res;
}
//素数判定
template <class T>
bool is_prime(T x){
    for(T i=2;i*i<=x;i++){
        if(x%i==0){
            return false;
        }
    }
    return x!=1;
}

const ll inf=1e9+7;

ll mult(ll n,ll m){//n^m%infを求める
    if(m==1){
        return n%inf;
    }else if(m%2==0){//オーバーフロー防止のためにn^(m/2)*n^(m/2)を考える
        ll t=mult(n,m/2);
        return (t*t)%inf;
    }else{//奇数の時はn^(m-1)*nを考える
        ll t=mult(n,m-1);
        return (t*n)%inf;
    }
}

typedef pair<int,int> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    int ans=1e6;
    FOR(i,0,n+1){//Aをi回, Bをn-i回
        if(pow(2,i)+(n-i)*k<ans){
            ans=pow(2,i)+(n-i)*k;
        }
    }
    cout<<ans<<endl;
}

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

int main( void )
{
    char a[ 11 ];
    char b[ 11 ];
    char c[ 11 ];
    cin >> a >> b >> c;

    cout << (char)(a[ 0 ] - 32) << (char)(b[ 0 ] - 32) << (char)(c[ 0 ] - 32) << endl;
    return 0;
}


Measured memory_bytes: 256
import math
a, b, h, m = map(int, input().split())

h_kaku = 30 * h + (m / 2)
m_kaku = 6 * m

sa_kaku = h_kaku - m_kaku if h_kaku >= m_kaku else m_kaku - h_kaku

if sa_kaku > 180:
    sa_kaku = 360 - sa_kaku

if sa_kaku == 180:
    ans = a + b
elif sa_kaku == 0:
    if a >= b:
        ans = a - b
    else:
        ans = b - a
else:
    ans = a**2 + b**2 - 2*b*a*math.cos(math.radians(sa_kaku))
    ans = math.sqrt(ans)

print(ans)


Measured memory_bytes: 9392
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll N,K;
  cin>>N>>K;
  ll sum=0;

 
  for(ll i=K;i<=N+1;i++){
    ll maxi=0;
    ll mini=0;
    ll i2=i%mod;
    ll N2=N%mod;
    if(i2!=0){
      mini=((i2-1)*i2)/2;
      mini%=mod;
    }
else{
  mini=1;
}
if(N2-i2!=0){

   maxi=(N2*(N2+1))/2-((N2-i2)*(N2-i2+1))/2;
  
}
    else{
      maxi=(N2*(N2+1))/2;
    }
    
    
    sum+=(maxi-mini+1);
    sum%=mod;
 
  }

  cout<<sum<<endl;
}


Measured memory_bytes: 3636
fun main() {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toInt() }

    val oddCount = a.filter { it % 2 == 1 }.size

    val answer = if (oddCount % 2 == 0) "YES" else "NO"

    print(answer)
}

Measured memory_bytes: 52532
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
S = list(rs())
for i in ascii_lowercase:
    if not i in S:
        print(i)
        exit()
print('None')

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

#define forn(l, r) for(int i = l; i < (r); ++i)
#define forj(l, r) for(int j = l; j < (r); ++j)
#define TAM 1000100
#define SYNC ios::sync_with_stdio(0);
#define $ << ' ' <<
#define F first
#define S second
#define endl '\n'


using namespace std;

using ll = long long int;
using ii = pair<int, int>;
using vii = vector<ii>;
using vi = vector<int>;
using graph = vector<vi>;
const int INF = 0x3f3f3f3f;
const int MAXN = 112345;
const ll mod = 1000000007;


int main() {
    //SYNC
    string s;
    int n, k;
    cin >> n >> k >> s;;
    s[k+-1] += 32;
    for (auto i : s) {
        cout << i;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int field[105][105];
int x[105];
int y[105];
int a[105];

int main() {

	int W, H, N;

	scanf("%d %d %d", &W, &H, &N);

	int i,j,k;

	for (i = 0; i < N; i++) {
		scanf("%d %d %d",&x[i],&y[i],&a[i]);
	}

	for (i = 0; i < N; i++) {
		if (a[i] == 1) {
			if (x[i] != 0) {
					for (j = 0; j < H; j++) {
						for (k = 0; k < x[i]; k++) {
						field[j][k] = 1;
					}
				}
			}
		}
		else if (a[i] == 2) {
			if (x[i] != W) {
				for (j = 0; j < H; j++) {
					for (k = x[i]; k < W; k++) {
						field[j][k] = 1;
					}
				}
			}
		}
		else if (a[i] == 3) {
			if (y[i] != 0) {
				int cnt = 0;
				for (j = H-1;; j--) {
					if (cnt == y[i]) { break; }
					for (k = 0; k < W; k++) {
						field[j][k] = 1;
					}
					cnt++;
				}
			}
		}
		else {
			if (y[i] != H) {
				int cnt = H;
				for (j = 0;; j++) {
					if (cnt == y[i]) { break; }
					for (k = 0; k < W; k++) {
						field[j][k] = 1;
					}
					cnt--;
				}
			}
		}
	}
	int ans = 0;
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			if (field[i][j] == 0) { ans++; }
		}
	}
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

int r, c, n;
map<int,char> up,rt,lt,dn;
char w = 'a';

bool C(int a, int b){
	if( (a == 0 || a == r) || (b == 0 || b == c) ) return true;
	return false;
}

bool isEdge(int a, int b, int c, int d){
	return C(a,b) && C(c,d);
}

void addVector(int a, int b){
	if(a == 0) up[b] = w;
	else if(b == c) rt[a] = w;
	else if(a == r) lt[-b] = w;
	else if(b == 0) dn[-a] = w;
}

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

	rep(i,n){
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		if(isEdge(a,b,c,d)){
			addVector(a,b);
			addVector(c,d);
			w++;
		}
	}

	vector<char> al;
	for(auto i : up) al.emplace_back(i.second);
	for(auto i : rt) al.emplace_back(i.second);
	for(auto i : lt) al.emplace_back(i.second);
	for(auto i : dn) al.emplace_back(i.second);

	vector<char> ans;
	rep(i,al.size()){
		//show(al[i])
		if(ans.empty()) ans.emplace_back(al[i]);
		else{
			if(al[i] == ans.back()){
				ans.pop_back();
			}else{
				ans.emplace_back(al[i]);
			}
		}
	}
	if(ans.size() == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 9984
#include <iostream>
#include <vector>
#include <cmath>
#include <typeinfo>
#include <set>
#include <bitset>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;



int main(){
  int n;
  string s;
  cin >> n; 
  cin >> s;
  int count = 0;
  for(int i=0; i<n-2; i++){
    if(s.substr(i,3) == "ABC"){
      count += 1;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
while True:
    n, x = (int(x) for x in input().split())
    if(n == 0 and x == 0): break
    res = 0
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            for k in range(j + 1, n + 1):
                if(i + j + k == x): res += 1
    print(res)


Measured memory_bytes: 5604
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
last=0
t = 0
for j,i in enumerate([A,B,C,D,E]):
    if not i//10 * 10 ==i and last < (i//10 +1) * 10 -i:
        last = (i//10 +1) * 10 -i
        t=j
ans= 0
for j,i in enumerate([A,B,C,D,E]):
        if i//10 * 10 ==i and j!=t:
            #print((i//10 +1) * 10)
            ans += i
        elif  i//10 * 10 !=i and j!=t:
            ans += (i//10 +1) * 10
print(ans+[A,B,C,D,E][t])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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字くらい使った方がいいかも
*/

int main(){
    string s, t; cin >> s >> t;
    bool flg = true;

    map<char, char> mp, mp2;
    for(char c='a'; c<='z'; c++) mp[c] = mp2[c] = '#';

    for(int i=0; i<s.size(); i++){
        if(mp[s[i]] == '#'){
            mp[s[i]] = t[i];
        }
        else if(mp[s[i]] != t[i]){
            flg = false;
        }
    }

    for(int i=0; i<s.size(); i++){
        if(mp2[t[i]] == '#') mp2[t[i]] = s[i];
        else if(mp2[t[i]] != s[i]) flg = false;
    }

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

Measured memory_bytes: 776