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

using namespace std ;

#define N 3000

int a[N][N] , Vis[N] ;
int n , ans ;

void check(){
    for(int i = 1 ; i <= n ; i++ ){
        for(int j = 1 ; j <= n ; j++ ){
            if( a[i][j] == -1 ) continue ;
            if( Vis[i] == 1 && Vis[j] == 1 && a[i][j] == 0 ) return ;
            if( Vis[i] == 1 && Vis[j] == 0 && a[i][j] == 1 ) return ;
        }
    } int res = 0 ;
    for(int i = 1 ; i <= n ; i++ ) res += Vis[i] ;
    ans = max( ans , res ) ;
}

void dfs(int x){
    if( x == n + 1 ){ check() ; return ; }
    Vis[x] = 0 ;
    dfs( x + 1 ) ;
    Vis[x] = 1 ;
    dfs( x + 1 ) ;
}

int main()
{
    cin >> n ;
    memset( a , -1 , sizeof( a ) ) ;
    for(int i = 1 ; i <= n ; i++ ){
        int m ;
        scanf("%d" , &m ) ;
        for(int j = 1 ; j <= m ; j++ ){
            int x , y ;
            scanf("%d%d" , &x , &y ) ;
            a[i][x] = y ;
        }
    }
    dfs( 1 ) ;
    cout << ans ;
}

Measured memory_bytes: 35456
#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
//#pragma GCC target ("sse4")
#pragma optimize("fast-math")

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define endl '\n'
#define ull unsigned long long
#define si short int
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define piii pair<pair<int, int>, int>
#define all(vec) (vec).begin(), (vec).end()
#define rall(vec) (vec).rbegin(), (vec).rend()
#define piiii pair<pair<int, int>, pair<int, int>>
struct kek{
    int a,b,c,d;
};


ld pwm(ld xx, ll pow) {
    ld mlt = 1;
    while (pow) {
        if (pow & 1) {
            mlt *= xx;
        }
        xx *= xx;
        pow >>= 1;
    }
    return mlt;
}



void solve() {
    ll x;
    cin>>x;
    int n=3761;
    vector<ll> kek(n);
    kek[0]=100;
    for(int i=1;i<n;i++){
        kek[i]=kek[i-1]+kek[i-1]/100;
        if(kek[i]>=x){
            cout<<i;
            return;
        }
    }
}

void testcases(int n) {
    n = 1 - n;
    if (!n) cin >> n;
    for (int i = 0; i < n; i++) {
        solve();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //f=fopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w");
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);

    unsigned int beg_time = clock();
    testcases(0);
    // 0 - no t, 1 - with t

    unsigned int end_time = clock();
    //cout << endl << endl << end_time - beg_time;
    return 0;
}

Measured memory_bytes: 3712
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N, K;
	in >> N >> K;
	std::vector<LL>A(N), B(N);
	rep(i, N) in >> A[i] >> B[i];

	LL ans = 0;
	for (LL i = 30; i >= 0; --i)
	{
		if (K&(1LL << i))
		{
			LL max = (K ^ (1LL << i)) | ((1LL << i) - 1), res = 0;
			rep(j, N)
			{
				bool flag = true;
				rep(k, 31)
				{
					if ((A[j] & (1LL << k)) && !(max&(1LL << k)))
					{
						flag = false;
						break;
					}
				}
				if (flag) res += B[j];
			}
			ans = std::max(ans, res);
		}
	}
	LL res = 0;
	rep(i, N)
	{
		bool flag = true;
		rep(j, 31)
		{
			if ((A[i] & (1LL << j)) && !(K&(1LL << j)))
			{
				flag = false;
				break;
			}
		}
		if (flag) res += B[i];
	}
	ans = std::max(ans, res);

	out << ans << std::endl;
}


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

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main()
{
	int n;
	cin >> n;
	ll a[3*n];

	for (int i = 0; i < 3*n; i++) {
		cin >> a[i];
	}
	sort(a, a+(3*n), greater<int>());
	ll ret = 0;
	ll idx = 1;
	for (int i = 0; i < n; i++) {
		ret += a[idx];
		idx+=2;
	}
	cout << ret << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main() {
     int a,b,c;
     cin >> a >> b >> c;
     if(a == b && b == c) cout << '1' << endl;
     else if(a == b || b == c || c == a) cout << '2' << endl;
     else cout << '3' << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
C = [[] for i in range(N)]
for i in range(N):
    C[i] = list(map(int, input().split()))

C = sorted(C, key=lambda x: x[0], reverse=False)
i = 0
ans = 0
while M>0:
    if M-C[i][1]>=0:
        ans += C[i][0]*C[i][1]
        M -= C[i][1]
        i += 1
    else:
        ans += M*C[i][0]
        M = 0
print(ans)

Measured memory_bytes: 29792
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	char C = getcha();
	int A = C - '0';
	while ((C = getcha()) >= '0') A = A * 10 + C - '0';
	return A;
}

const ll q = ((ll)1000000000 << 30);

int P[100001];
int D[100001];
ll Find(int A) {
	if (P[A] < 0) return q + A;

	ll k = Find(P[A]);
	int d = (k >> 30) - 1000000000;
	int p = k & ((1 << 30) - 1);
	D[A] += d;
	P[A] = p;

	return ((ll)(D[A] + 1000000000) << 30) + p;
}

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


	int N = getint();
	int M = getint();
	rep1(i, N) P[i] = -1;

	int OK = 1;
	rep(i, M) {
		int L = getint();
		int R = getint();
		int d = getint();

		ll k = Find(L);
		int dl = (k >> 30) - 1000000000;
		int l = k & ((1 << 30) - 1);
		k = Find(R);
		int dr = (k >> 30) - 1000000000;
		int r = k & ((1 << 30) - 1);

		if (l != r) {
			if (P[l] <= P[r]) {
				P[l] += P[r];
				P[r] = l;
				D[r] = dl - dr + d;
			}
			else {
				P[r] += P[l];
				P[l] = r;
				D[l] = dr - dl - d;
			}
		}
		else {
			if (dl + d != dr) {
				OK = 0;
				break;
			}
		}
	}
	if (OK) printf("Yes");
	else printf("No");

	Would you please return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <atcoder/dsu>
using namespace std;
using namespace atcoder;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);
	cin.exceptions(cin.failbit);

	int n;
	cin >> n;

	vi xs(n), ys(n), sy(n);
	rep(i,0,n){
		cin >> xs[i] >> ys[i];
		--xs[i], --ys[i];
	}
	dsu uf(n);
	vector<pii> cur(n);
	rep(i,0,n) cur[xs[i]] = {ys[i], ys[i]};
	vi st;
	rep(i,0,n){
		st.push_back(i);
		while(sz(st) >= 2){
			int a = st.back(), b = st[sz(st)-2];
			if(cur[a].second >= cur[b].first){
				uf.merge(a, b);
				cur[b].first = min(cur[b].first, cur[a].first);	
				cur[b].second = max(cur[b].second, cur[a].second);	
				st.pop_back();
			} else {
				break;
			}
		}
	}
	rep(i,0,n) cout << uf.size(xs[i]) << endl;
}


Measured memory_bytes: 7952
pronunciation = {0: 'pon', 1: 'pon', 2: 'hon', 3: 'bon', 4: 'hon', 5: 'hon', 6: 'pon', 7: 'hon', 8: 'pon', 9: 'hon'}
input = input()
if len(input) > 1:
  input = int(input[-1])
if type(input) != int:
    input = int(input)
print(pronunciation[input])




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

void maxHeapify(vector < int > &A, int n, int i ) {
	int L = i * 2;
	int R = i * 2 + 1;

	int largest=i;
	if( L <= n && A[largest] < A[L] ) largest = L;
	if( R <= n && A[largest] < A[R] ) largest = R;
    
    if( largest != i ) {
    	swap( A[i], A[largest] );
        maxHeapify( A, n, largest );
    }
}
void  insertKey( vector< int > &priorityQ, int key ) {
	priorityQ.push_back( key );
	int n = priorityQ.size() - 1; 
	 while ( n > 1 && priorityQ[n] > priorityQ[n/2] ) {
	 	swap(  priorityQ[n], priorityQ[n/2] );
	 	n = n / 2;
	 }
}
int main() {
	string op;
	int key;
	vector < int > priorityQ;
	priorityQ.push_back( -1 );
	while( cin >> op ) {
		if ( op == "insert" ) {
			cin >> key;
			insertKey ( priorityQ, key );
		} else if ( op == "extract" ) {
		 if(priorityQ.size() > 1 ) {
           cout << priorityQ[1] << endl;
           swap( priorityQ[1], priorityQ[priorityQ.size()-1]);
           priorityQ.erase( priorityQ.end()-1 );
           maxHeapify( priorityQ, priorityQ.size()-1, 1 );
         
       }

		} else if ( op == "end" ) break;
	}
}


Measured memory_bytes: 7024
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;

int main(){
int N,K,X,Y;
cin>>N>>K>>X>>Y;
ll ans=0;
if(N>=K){
  ans+=K*X;
  N-=K;
  ans+=N*Y;

}
else{
  ans+=N*X;
}
cout<<ans<<endl;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    string s;
    cin >> s;
    
    int happy = 0;
    for(int i=0; i<N-1; i++) {
        if(s[i] == s[i+1]) happy++;
    }

    happy = min(happy+2*K, N-1);

    cout << happy << endl;
    return 0;
    
}

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

// aにbが含まれているか
bool isInclude(int a, int b) {
  for (;a > 0; a /= 10) {
    if (a % 10 == b) return true;
  }
  return false;
}

// aにbのリストの要素が含まれるか
bool isIncludeList(int a, vector<int> b, int bLength) {
  for (int i = 0; i < bLength; i++) {
    if (isInclude(a, b.at(i))) return true;
  }
  return false;
}

int main() {
  int n, k;
  cin >> n >> k;

  vector<int> vd(k);
  for (int i = 0; i < k; i++)
    cin >> vd.at(i);

  int payMoney;
  for (payMoney = n; isIncludeList(payMoney, vd, k); payMoney++) {}

  cout << payMoney << endl;

  return 0;
}

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

using namespace std;

int main()
{
    long Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;

    long Q4 = Q * 4;
    long H2 = H * 2;

    long amount = 0;

    if (D <= 2 * S && D <= 2 * Q4 && D <= 2 * H2) {
        long c = N / 2;
        amount += D * c;
        N -= 2 * c;
    }

    if (S <= H2 && S <= Q4) {
        amount += N * S;
    } else if (H2 <= S && H2 <= Q4) {
        amount += N * H2;
    } else {
        amount += N * Q4;
    }

    cout << amount << '\n';

    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll N;
    cin >> N;
    vl L(N);
    rep(i, N){
        cin >> L[i];
    }
    ll ans = 0;
    if(N < 3){
        cout << 0;
        return 0;
    }
    rep(i, N){
        FOR(j, i+1, N){
            FOR(k, j+1, N){
                if(L[i] + L[j] > L[k] && L[j] + L[k] > L[i] && L[k] + L[i] > L[j] && L[i] != L[j] && L[j] != L[k] && L[k] != L[i]){
                    ans++;
                }
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 3640
N, X, Y = map(int, input().split())
X -= 1
Y -= 1

def dist(a, b):
    return min(abs(b-a), abs(X-a) + 1 + abs(b-Y), abs(Y-a) + 1 + abs(b-X))

ANS = [0] * N
for i in range(N):
    for j in range(i):
        ANS[dist(i, j)] += 1

for a in ANS[1:]:
    print(a)

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

int main() {
  int N,t,a,ans;
  float diff;
  cin >> N >> t >> a;
  vector<int> s(N);
  vector<float> kion(N);
  vector<float> dif(N);

  for(int i=0;i<N;i++){
  cin >> s[i];
  kion[i] = t-s[i]*0.006;
  dif[i] = abs(a-kion[i]);
  }

  diff = dif[0];

  for(int i=0;i<N;i++){
       if(dif[i] < diff ){
       diff = dif[i];
       ans =i;
       }
  }


  if(diff == dif[0]){
  ans =0;
  }

  cout << ans+1 << endl;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n;
  string s;
  cin >> n >> s;
  ll ans = 1;
  for (int i = 1; i < n; ++i)
    if (s[i] != s[i - 1]) ans++;

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


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

int main(void)
{
    char s[10001];
	int ic, jc, i;
     
    while (scanf("%s", s) != EOF){
        ic = jc = 0;
         
        for (i = 0; i <= strlen(s) - 3; i++){
            if (strncmp(s + i, "JOI", 3) == 0){
                jc++;
            }
			else if (strncmp(s + i, "IOI", 3) == 0){
                ic++;
            }
        }
        printf("%d\n%d\n", jc, ic);
    }
     
    return (0);
}

Measured memory_bytes: 552
import std.conv, std.stdio;
import std.algorithm, std.array, std.range, std.string;
void main()
{
    switch (readln.chomp[$-1])
    {
        case '0', '1', '6', '8':
            return "pon".writeln;
        case '2', '4', '5', '7', '9':
            return "hon".writeln;
        default:
            return "bon".writeln;
    }
}


Measured memory_bytes: 2584
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  string str[n];
  int a[n];
  for(int i=0; i<n; i++){
    cin >> str[i];
    a[i] = str[i].length();
  }

  int ans=0;

  for(int i=0; i<n-1; i++){
    if(str[i][a[i]-1]!=str[i+1][0]){
      ans = 1;
    }
  }

  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      if(str[i]==str[j]){
	ans = 1;
      }
    }
  }

  if(ans==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0; 
}


Measured memory_bytes: 256
while True:
    try:
        a1,a2,a3,a4=map(int,input().split())
        b1,b2,b3,b4=map(int,input().split())

        A=[a1,a2,a3,a4]
        B=[b1,b2,b3,b4]

        b=0
        h=0
        for i in A:
            if i in B:
                b+=1
            else:
                continue
        for i in range(4):
            if A[i]==B[i]:
                h+=1
            else:
                continue
        print(h,b-h)
    except EOFError:
        break


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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define all(c) begin(c),end(c)

template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}

enum {
    NONE = 0,
    LU,
    U,
    L
};


auto solve() {
    string s, t;
    cin >> s >> t;
    int N = s.size();
    int M = t.size();

    vector<vi> dp(N + 1, vi(M + 1, 0));
    vector<vi> res(N + 1, vi(M + 1, 0));

    FOR(i, 1, N + 1) {
        FOR(j, 1, M + 1) {
            if (s[i - 1] == t[j - 1]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
                res[i][j] = LU;
            } else if (dp[i - 1][j] >= dp[i][j - 1]) {
                dp[i][j] = dp[i - 1][j];
                res[i][j] = U;
            } else {
                dp[i][j] = dp[i][j - 1];
                res[i][j] = L;
            }
        }
    }

    stringstream ss;
    int r = N, c = M;
    while (r != 0 && c != 0 && dp[r][c] != 0) {
        if (res[r][c] == LU) {
            ss << t[c - 1];
            r--, c--;
        } else if (res[r][c] == U) {
            r--;
        } else {
            c--;
        }
    }
    string a = ss.str();
    reverse(all(a));
    return a;
}


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

    cout << solve() << endl;
//    solve();

    return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> vec(M*2);
  
  for (int i=0; i<M*2; i++){
    cin >> vec.at(i);
  }
  
  for (int i=0; i<N; i++){
    int count=0;
    for (int j=0; j<M*2; j++){
      if (vec.at(j) == i+1){
        count++;
      }
    }
    cout << count << endl;
  }
} 

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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF ((1LL<<62)-1)
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME ((1ll<<61)-1)

#define len length()
#define pushb push_back
#define fi first
#define se second

#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

template<class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

template<class T>
inline void out(T a) {
	cout<<a<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


ll D,T,S;

void input() {
	cin>>D>>T>>S;
}

void solve() {
	if(D<=T*S) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 3684
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		n: usize,
		y: usize,
	}

	for i in 0..=n {
		for j in 0..=n-i {
			let k = n-i-j;
			if i*10000 + j*5000 + k*1000 == y {
				println!("{} {} {}", i, j, k);
				return;
			}
		}
	}
	println!("-1 -1 -1");
}



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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k,s;
    cin >> k >> s;
    int c=0;
    for(int i=0;i<=k;i++)
        for(int j=0;j<=k;j++)
            if(s-(i+j)<=k && s-(i+j)>-1)
                c++;
    cout << c;
    return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    int res = (100 * n + 1800 * m) * (1 << m);
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <functional>
#include <bitset>
#include <utility>
#include <sstream>
#include <fstream>
#include <stack>
#include <cstdlib>
#include <complex>
#include <set>

using namespace std;

#define INF 1070000000LL
#define pb push_back
#define irep(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) irep(i,0,n)

typedef long long lint;
typedef pair<int, int> pint;
struct Edge{
    int to,weight;
};
typedef vector<vector<Edge> > Graph;


int main(){
    int a[5];
    rep(i,5)cin >> a[i];
    int k;
    cin >> k;
    if(a[4] - a[0] > k){
	cout << ":(" << endl;
    }
    else{
	cout << "Yay!" << endl;
    }
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define loop(i,b,n) for(int i=b;i<(n);++i)
#define each(e,v) for(auto &&e : v)

#define all(v) (v).begin(),(v).end()
#define sz(v) (int)v.size()

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const double EPS = 1e-9;
const ll MOD = 1e+9 + 7;

template<typename A,typename B> inline void chmin(A &a,B b){ if(a>b) a=b; }
template<typename A,typename B> inline void chmax(A &a,B b){ if(a<b) a=b; }
template <typename T> inline void print(const T& x) { cout << x << endl; }

int main() {
    int n,k;
    cin >> n >> k;

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

    for(int i=k; i<n; ++i){
        if(a[i-k] < a[i]) print("Yes");
        else print("No");
    }

    return 0;
}


Measured memory_bytes: 4048
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;


public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n=sc.nextInt(),p=sc.nextInt();
			if(n==0&&p==0) break;
			int[] person = new int[n];
			Arrays.fill(person, 0);
			int p_inBox=p;
			int result=0;
			LAST:for(;;){
				for(int i=0;i<n;i++){
					if(person[i]==p) {
						result=i;
						break LAST;
					}
					if(p_inBox==0){
						if(person[i]!=0){
							p_inBox=person[i];
							person[i]=0;
						}
					}else{
						p_inBox--;
						person[i]++;
					}
				}
			}
			System.out.println(result);
		}
	}
}

Measured memory_bytes: 20176
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] t = new int[n + 1];
    int[] x = new int[n + 1];
    int[] y = new int[n + 1];
    for(int i = 0; i < n; i++) {
      t[i + 1] = sc.nextInt();
      x[i + 1] = sc.nextInt();
      y[i + 1] = sc.nextInt();
    }
    String ans = "Yes";
    for(int i = 0; i < n; i++) {
      int td = t[i + 1] - t[i];
      int xd = Math.abs(x[i + 1] - x[i]);
      int yd = Math.abs(y[i + 1] - y[i]);
      int s = xd + yd;
      if((((s - td) % 2) != 0) || (s > td)) ans = "No";
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 90648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1000000007;

ll F(int x){
	ll dp[100000] = {0};
	dp[0] = 1;
	dp[1] = 1;
	for(int i = 2; i <= x; i++){
		dp[i] = dp[i-1] + dp[i-2];
    dp[i]%=INF;
	}
	return dp[x];
}

int main() {
 int n,m; cin >> n >> m;
 if(m==0){
   cout << F(n) << endl;
   return 0;
 }
 vector<int> s(m);
  cin >>s[0];
 for(int i=1;i<m;i++){
   cin >> s[i];
    if(s[i]-s[i-1]==1){
      cout << 0 << endl;
      return 0;
    }
 }

 ll ans=F(s[0]-1);ans%=INF;
 for(int i=1;i<m;i++){
   ans*=F(s[i]-s[i-1]-2);
   ans%=INF;

 }
 ans*=F(n-s[m-1]-1);
 ans%=INF;
 cout << ans << endl;
}


Measured memory_bytes: 1280
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int n,a,b,h[100010];

int main()
{
    cin>>n>>a>>b;
    a-=b;
    for(int i=0;i<n;i++)scanf("%d",&h[i]);
    sort(h,h+n);
    int l=1,r=(h[n-1]+b-1)/b,mid,tmp;
    long long sum;
    while(l<r)
    {
        mid=(l+r)/2;
        tmp=mid*b;
        sum=0;
        for(int i=0;i<n;i++)
            if(h[i]>tmp) sum+=(h[i]-tmp+a-1)/a;
        if(sum>mid)l=mid+1;
        else r=mid;
    }
    printf("%d",l);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <string>
#include <tuple>
#include <vector>
#include <set>
#include <map>
#include <iterator>
#include <random>
#include <cmath>

using namespace std;
using lint = long long int;

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

	pair<int, int>* xy = new pair<int, int>[n];
	vector<int> indices;
	
	for (int i = 0; i < n; i++) {
		cin >> xy[i].first >> xy[i].second;
		indices.push_back(i);
	}

	map<pair<int, int>, double> distance;
	for (int i = 0; i < n-1; i++) {
		for (int j = i + 1; j < n; j++) {
			double d = sqrt(pow(xy[i].first - xy[j].first, 2) + pow(xy[i].second - xy[j].second, 2));
			distance[make_pair(i, j)] = d;
			distance[make_pair(j, i)] = d;
		}
	}

	double sum = 0;
	int count = 0;
	do {
		for (int i = 0; i < n-1; i++) {
			auto key = make_pair(indices[i], indices[i + 1]);
			sum += distance[key];
		}
		count++;
	} while (next_permutation(indices.begin(), indices.end()));

	cout << fixed << setprecision(10) << sum / count;

	return 0;

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define INF 9876543219876
#define PI 3.14159265358979323846264
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
ll MOD = 1000000009;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,-1,1,0 }, dy[] = { 1,0,0,-1 };
int ddx[] = { 0,0,1,1,1,-1,-1,-1 }, ddy[] = { 1,-1,1,0,-1,1,0,-1 };

Pll p[100000], rev[100000];
ll max1[100000], max2[100000];
int main() {
	int n;
	ll c;
	scanf("%d%lld", &n, &c);
	fup(i, 0, n - 1, 1)scanf("%lld%lld", &p[i].X, &p[i].Y);
	fup(i, 0, n - 1, 1)rev[i] = mp(c - p[n - i - 1].X, p[n - i - 1].Y);
	ll temp = 0;
	fup(i, 0, n - 1, 1)
	{
		temp += p[i].Y;
		if (i == 0)max1[i] = max(0LL,temp - p[i].X);
		else max1[i] = max(max1[i-1], temp - p[i].X);
	}
	temp = 0;
	fup(i, 0, n - 1, 1)
	{
		temp += rev[i].Y;
		if (i == 0)max2[i] = max(0LL,temp - rev[i].X);
		else max2[i] = max(max2[i - 1], temp - rev[i].X);
	}
	ll ans = max(max1[n - 1], max2[n - 1]);
	temp = 0;
	fup(i, 0, n - 2, 1)
	{
		temp += p[i].Y;
		ans = max(ans, max2[n - i - 2] + temp - p[i].X * 2);
	}
	temp = 0;
	fup(i, 0, n - 2, 1)
	{
		temp += rev[i].Y;
		ans = max(ans, max1[n - i - 2] + temp - rev[i].X * 2);
	}
	printf("%lld", ans);
}

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

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)

using namespace std;

using ll = long long;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}

int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);

    constexpr int L_MAX = 100000;

    int N;
    cin >> N;
    vector<int> V(N), W(N);
    FOR(i, 1, N + 1) cin >> V[i] >> W[i];

    int N_upper = min((1 << 9) - 1, N);
    vector<vector<ll>> dp(N_upper + 1, vector<ll>(L_MAX + 1));
    FOR(i, 1, N_upper + 1) {
        FOR(j, 1, L_MAX + 1) {
            dp[i][j] = dp[i / 2][j];
            if (j >= W[i]) {
                amax(dp[i][j], dp[i / 2][j - W[i]] + V[i]);
            }
        }
    }

    int Q;
    cin >> Q;
    REP(_, Q) {
        int v, L;
        cin >> v >> L;

        vector<int> lowers;
        while (v > N_upper) {
            lowers.push_back(v);
            v /= 2;
        }
        int H = lowers.size();
        ll result = 0;
        REP(bit, 1 << H) {
            ll sum_V = 0;
            ll sum_W = 0;
            REP(i, H) {
                if (bit & (1 << i)) {
                    sum_V += V[lowers[i]];
                    sum_W += W[lowers[i]];
                }
            }
            if (sum_W <= L) {
                amax(result, sum_V + dp[v][L - sum_W]);
            }
        }
        cout << result << '\n';
    }
    cout << flush;

    return 0;
}


Measured memory_bytes: 407316
#include<stdio.h>
int main( )
{
	int n,h,m,s;
	scanf("%d",&n);
	h = n/3600;
	m = (n-h*3600)/60;
	s = n-h*3600-m*60;
    printf("%d:%d:%d\n" ,h,m,s);
    return 0;
}


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

int const MAX = 305;
long long dp[MAX][MAX][MAX];
long long MOD = 1000000007;
long long mod_p(long long x, long long y) {
	return (x + y) % MOD;
}
long long mod_m(long long x, long long y) {
	return x * y%MOD;
}

struct condition
{
	int lef; int righ; int x;
};

bool order(condition a, condition b) {
	return a.righ < b.righ;
}
int rights[MAX];
condition a[MAX];
bool ok(int l, int j, int k, int n) {
	int s, t;
	s = lower_bound(rights + 1, rights + n + 1, l) - rights;
	t = upper_bound(rights + 1, rights + n + 1, l) - rights;
	for (int i = s; i < t; i++) {
		if (a[i].x == 1) {
			if (j >= a[i].lef) {
				return false;
			}
		}
		else if (a[i].x == 2) {
			if (j < a[i].lef || k >= a[i].lef) {
				return false;
			}
		}
		else {
			if (k < a[i].lef) {
				return false;
			}
		}
	}
	return true;
}
bool ok_grid[MAX][MAX][MAX];

int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		int s, t, r;
		cin >> s >> t >> r;
		a[i] = { s,t,r };
	}

	sort(a + 1, a + m + 1, order);
	for (int i = 1; i <= m; i++) {
		rights[i] = a[i].righ;
	}
	//dp[i][j][k] = i番目まで決める、2番目の色はj番目に出てくる、3番目の色はk番目に出てくる
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < i; j++) {
			for (int k = 0; k <= j; k++) {
				if (k == j && j > 0) {
					continue;
				}
				ok_grid[i][j][k] = ok(i, j, k, m);
				dp[i][j][k] = 0;
			}
		}
	}
	dp[1][0][0] = ok(1, 0, 0, m);
	for (int i = 1; i <= n - 1; i++) {
		for (int j = 0; j < i; j++) {
			for (int k = 0; k <= j; k++) {
				if (k == j && j > 0) {
					continue;
				}
				dp[i + 1][j][k] = mod_p(dp[i][j][k], dp[i + 1][j][k])*ok_grid[i + 1][j][k];
				dp[i + 1][i][k] = mod_p(dp[i + 1][i][k], dp[i][j][k])*ok_grid[i + 1][i][k];
				if (k != j) {
					dp[i + 1][i][j] = mod_p(dp[i + 1][i][j], dp[i][j][k]) * ok_grid[i + 1][i][j];
				}
			}
		}
	}
	long long ans = 0;
	for (int j = 0; j < n; j++) {
		for (int k = 0; k <= j; k++) {
			if (k == j && j > 0) { continue; }
			if (k == j) {
				ans = mod_p(ans, dp[n][j][k] * 3);
			}
			else {
				ans = mod_p(ans, dp[n][j][k] * 6);
			}
		}
	}
	cout << ans << endl;
}

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

int main(){
    int n;
    cin>>n;
    ll tt;
    cin>>tt;
    vector<ll>t(n);
    rep(i,n)cin>>t[i];
    ll saidai=t[n-1]+tt;
    vector<ll>sa(n-1);
    ll hiku=0;
    for(int i=1;i<n;i++){
        sa[i-1]=t[i]-t[i-1];
        if(sa[i-1]<=tt)sa[i-1]=0;
        else sa[i-1]-=tt;
        hiku+=sa[i-1];
    }
    saidai-=hiku;
    cout<<saidai<<endl;
}

Measured memory_bytes: 3328
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,a,la;
long long mmh=0;
int main(){
	scanf("%d%d",&n,&m);scanf("%d",&la);
	for (int i=1;i<n;i++){
		scanf("%d",&a);
		if (a-la<=m) mmh+=a-la;else mmh+=m;
		la=a;
	}
	printf("%lld\n",mmh+m);
}

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

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)


Measured memory_bytes: 126840
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
using namespace std;


int main() {
    int n;
    cin >> n;
    for (int q=0; q<n; q++) {
        int c,d;
        cin >> c >> d;
        int a=c+1,b=d+1;
        int p;
        cin >> p;
        int dp[b][a];
        vector<pair<int, int> > m(a*b);
        for (int i=0; i<b; i++) {
            for (int j=0; j<a; j++) {
                dp[i][j]=0;
            }
        }
        
        for (int i=0; i<a*b; i++) {
            m[i]={0,0};
        }
        for (int i=0; i<p; i++) {
            int x,y,z,w;
            cin >> x >> y >> z >> w;
            if (y>w) { //??????
                m[z+w*a].first=-1;
            }else{
                if (x>z) {//??????
                    m[z+w*a].second=-1;
                }else{
                    if (y==w) {
                        m[x+y*a].second=-1;//??????
                    }else{
                        m[x+y*a].first=-1;//??????
                    }
                }
            }
        }
        dp[0][0]=1;

        for (int i=1; i<b; i++) {
            if (m[(i-1)*a].first!=-1) {
                dp[i][0]=1;
            }else{
                break;
            }
        }
        
        for (int i=1; i<a; i++) {
            if (m[i-1].second!=-1) {
                dp[0][i]=1;
            }else{
                break;
            }
        }
        
        for (int i=1; i<b; i++) {
            for (int j=1; j<a; j++) {
                if (m[j-1+i*a].second!=-1) {
                    dp[i][j]+=dp[i][j-1];
                }
                if (m[j+(i-1)*a].first!=-1) {
                    dp[i][j]+=dp[i-1][j];
                }
            }
        }
        if (!dp[d][c]){
            cout << "Miserable Hokusai!"<<endl;
        }else{
            cout << dp[d][c] << endl;
        }
    }
}

Measured memory_bytes: 1200
import copy

N = int(input())
a = [list(map(int, input().split())) for _ in range(N)]
b = [list(map(int, input().split())) for _ in range(N)]

chk = [0] * (2 * N)
cpchk =[]
pare = [-1] * (2 * N)
ans = 0

d = [[] for _ in range(2 * N)]
for i in range(N):
    for j in range(N):
        if a[i][0] < b[j][0] and a[i][1] < b[j][1]:
            d[i].append(j + N), d[j + N].append(i)

def dfs(v):
    cpchk[v] = 1
    for i in range(len(d[v])):
        u = d[v][i]
        w = pare[u]
        if w < 0 or cpchk[w] == 0 and dfs(w):
            pare[v] = u
            pare[u] = v
            return True
    return False

def bipartite_mattinc():
    global ans
    global cpchk
    for i in range(2 * N):
        if pare[i] < 0:
            cpchk = copy.deepcopy(chk)
            if dfs(i):
                ans += 1
    return ans

print(bipartite_mattinc())

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

using namespace std;
using LL = long long;

constexpr int N = 1e5 + 5;

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

    int n, k;
    cin >> n >> k;
    vector< double> s(n + 1);
    
    double result = 0;
    for (int i = 1; i <= n; i++) {
    	int p; cin >> p;
    	s[i] = (p * (p + 1) / 2) * 1.0 / p;
    	s[i] += s[i - 1];
    	if (i >= k) {
    		result = max(result, s[i] - s[i - k]);
    	}
    }
    cout << setprecision(10) << result << endl;
}

Measured memory_bytes: 1792
use proconio::input;

// x ** n % mods を求める
pub fn mod_pow(x: i64, n: i64, mods: i64) -> i64 {
    if n == 0 {
        return 1;
    }
    let mut res = mod_pow(x * x % mods, n / 2, mods);
    if n % 2 == 1 {
        res = res * x % mods;
    }
    return res;
}

// (1/n) % mods を求める
pub fn mod_inv(n: i64, mods: i64) -> i64 {
    return mod_pow(n, mods-2, mods);
}

// nCk % mods を求める
pub fn mod_comb(n: i64, k: i64, mods: i64) -> i64 {
    let sum1 = (n-k+1..n+1).fold(1, |ac, x| ac * x % mods);
    let sum2 = (1..k+1).fold(1, |ac, x| ac * x % mods);
    return sum1 * mod_inv(sum2, mods) % mods;
}

// nCk の組み合わせを列挙する
pub fn combination(n: usize, k: usize) -> Vec<Vec<usize>> {
    let mut ans = Vec::new();
    if k == 1 {
        for i in 1..n+1 {
            let mut tmp = Vec::new();
            tmp.push(i);
            ans.push(tmp);
        }
    }
    else {
        for iter in combination(n-1, k-1) {
            let max = iter.iter().max().unwrap();
            for j in *max+1..n+1 {
                let mut tmp = iter.clone();
                tmp.push(j);
                ans.push(tmp);
            }
        }
    }
    ans
}


fn main() {
    input!{
        n: usize,
        x: usize,
        t: usize,
    }
    if n % x == 0 {
        println!("{}", (n / x) * t);
    }
    else {
        println!("{}", (n / x + 1) * t);
    }
}


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

int main() {
    string S;
    cin >> S;

    int cnt = 0;
    for (int i = 0; i < 3; i++) {
        if (S[i] == '1') {
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  
  vector<ll> l(n),r(n);
  rep(i,n){
    int a;
    cin >> a;
    if(i-a>=0) l[i-a]++;
    if(i+a<n) r[i+a]++;
  }
  ll ans = 0;
  rep(i,n){
    ans += l[i] * r[i];
  }
  cout << ans << endl;
}


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

long long dp[55][6000];
int xn[55];

int main(){
  int n,a;
  cin >> n >> a;
  
  for(int i=0; i<n; i++){
    cin >> xn[i];
    xn[i] -= a;
  }
  
  for(int i=0; i<n; i++){
    for(int j=0; j<6000; j++){
      dp[i][j] = 0;
    }
  }

  dp[0][3000] = 1;
    
  for(int i=1; i<=n; i++){
    for(int j = 0; j<5500; j++){
     dp[i][j] = dp[i-1][j] + dp[i-1][j-xn[i-1]];
    }
  }

  cout << dp[n][3000] - 1 << endl;
  
}

Measured memory_bytes: 2688
fun main(args: Array<String>) {
  val (n, m) = readLine()!!.split(" ").map { it.toInt() }
  val x = readLine()!!.split(" ").map { it.toInt() }.sorted()
  var mpc = Array(m) { 0 }
  var mc = Array(m) { 0 }
  var p = 0
  for (i in 0 until n) {
    p++
    mc[x[i] % m]++
    if (i < n - 1 && x[i] == x[i + 1]) continue
    mpc[x[i] % m] += p / 2
    p = 0
  }
  var ans = mc[0] / 2
  if (m % 2 == 0) ans += mc[m / 2] / 2
  for (i in 1..(m - 1) / 2) {
    ans += if (mc[i] < mc[m - i]) {
      mc[i] + arrayOf((mc[m - i] - mc[i]) / 2, mpc[m - i]).min()!!
    } else {
      mc[m - i] + arrayOf((mc[i] - mc[m - i]) / 2, mpc[i]).min()!!
    }
  }
  println(ans)
}


Measured memory_bytes: 56248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
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 (a > b) { a = b; return 1; } return 0; }
int dx[] = { 0, 0, -1, 1 };
int dy[] = { 1, -1, 0, 0 };
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }


long long int value(long long int x, long long int A, long long int B) {
	return floor(A * x / B) - A * floor(x / B);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);

	string str;
	cin >> str;
	if (str == "ABC") {
		cout << "ARC";
	}
	else {
		cout << "ABC";
	}

	return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define pf push_front
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	vector<int> a(3);
	int x, y;
	cin >> x >> y;
	x--, y--;
	a[x] = 1, a[y] = 1;
	forn(i, 3) if(a[i] == 0) cout << i+1 << endl;
	return 0;
}



Measured memory_bytes: 3524
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] t = new int[n];
		int sum=0;
		for(int i=0;i<n;i++) {
			t[i] = sc.nextInt();
			sum+=t[i];
		}
		int m = sc.nextInt();
		int[] a = new int[m];
		for(int i=0;i<m;i++) {
			int p = sc.nextInt();
			int x = sc.nextInt();
			a[i]=sum-t[p-1]+x;
		}
		for(int i=0;i<m;i++) {
			System.out.println(a[i]);
		}
	}

}


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

typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using namespace std;


std::vector<bool> IsPrime;

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

int main()
{
	int x,cnt;
	cin >> x;
	cnt = x;

	while (isPrime(cnt) == false) {
		cnt++;
	}

	cout << cnt << endl;

	return 0;
}


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

long long int cou(long long int inp){
    if(inp==1){return 1;}
    return 1+2*cou(inp/2);
}

int main(void){
    // Your code here!
    long long int h;
    cin>>h;
    cout<<cou(h);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<map>

using namespace std;
#define endl '\n'
#define pb push_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define REP(i,n) for(int i = 0;i < (n);i++)
#define FOR(i,a,b) for(int i = (a);i <= (b);i++)
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vii;

template <class T = int> T in() { T x; cin >> x; return (x); }
template <class T = int> void out(T x) { cout << (x) << endl; }

int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

void solve() {

	string n;
	cin >> n;

	REP(i, n.size()) {
		if (n[i] == '1') {
			n[i] = '9';
			continue;
		}
		if (n[i] == '9') {
			n[i] = '1';
			continue;
		}
	}

	cout << n << endl;

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

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

#define rep(i,n) for(int i=0; i<n; i++)
#define fi first
#define se second
typedef pair<int,int> pii;
typedef pair<int, pair<pii, int> > pnode;

struct node {
	pnode p;
	node( pnode pn ) {
		p = pn;
	}
};
bool operator<( const node& l, const node &r ) {
	return l.p.fi > r.p.fi;
}

int main() {
	int w, h;
	while(cin >> w >> h, w||h) {
		bool visit[31][31][4] = {};
		int field[31][31];
		int cost[4];
		rep(y, h) {
			rep(x, w) {
				cin >> field[x][y];
			}
		}
		rep(i,4) {
			cin >> cost[i];
		}
		priority_queue<node> que;
		que.push( node( pnode(0, pair<pii,int>(pii(0,0),0)) ) );
		while( !que.empty() ) {
			node nd = que.top();
			que.pop();
			if( visit[nd.p.se.fi.fi][nd.p.se.fi.se][nd.p.se.se] ) continue;
			visit[nd.p.se.fi.fi][nd.p.se.fi.se][nd.p.se.se] = true;
			if( nd.p.se.fi.fi == w-1 && nd.p.se.fi.se == h-1 ) {
				cout << nd.p.fi << endl;
				break;
			}
//			cout << "visit " << nd.p.se.fi.fi << ", " << nd.p.se.fi.se << ", " << nd.p.se.se << " c:" << nd.p.fi << endl;
			int dx[4] = {1, 0, -1, 0};
			int dy[4] = {0, 1, 0, -1};
			rep(i, 4) {
				int dir = (i+nd.p.se.se)%4;
				int nx = nd.p.se.fi.fi+dx[dir];
				int ny = nd.p.se.fi.se+dy[dir];
				if( 0<=nx && nx<w && 0<=ny && ny<h && !visit[nx][ny][dir] ) {
					int c = (field[nd.p.se.fi.fi][nd.p.se.fi.se] == i) ? 0 : cost[i];
					que.push( node( pnode(nd.p.fi+c, pair<pii,int>(pii(nx, ny), dir)) ) );
//					cout << "reg " << nx << ", " << ny << ", " << dir << " c:" << nd.p.fi+c << endl;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1328