akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define dl double long
const int INF=0x3fffffff;
const ll MOD=1000000007;
const ll MODD=998244353;
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }

int main()
{
  ll N, L, sum, minabs=INF;
  cin >> N >> L;
  sum = (2*L+N-1)*N/2;
  REP(i, L, N+L){
    if(abs(minabs) > abs(i)) minabs = i;
  }
  cout << sum-minabs << "\n";
}


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);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < m; i++)
        cin >> b[i];
    int cnt = 0;
    for (int i = 0; i < max(n - m,1); i++)
    {
        for (int j = 0; j < max(n - m,1); j++)
        {
            bool ans = true;
            for (int k = 0; k < m; k++)
            {
                for (int l = 0; l < m; l++)
                {
                    if (a[i + k][j + l] != b[k][l])
                        ans = false;
                }
            }
            if (ans)
                cnt++;
        }
    }
    cout << (cnt ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int A, B, K;
	cin >> A >> B >> K;
	if (B - A + 1 <= 2 * K) {
		for (int i = A; i <= B; i++) {
			cout << i << endl;
		}
	}
	else {
		for (int i = A; i < A + K; i++) {
			cout << i << endl;
		}
		for (int i = B - K+1; i <= B; i++) {
			cout << i << endl;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, c) for(long long i=0; i<(long long)c; i++)
const ll INF=1000000000000001;
int main() {
	ll n,d,ans,x,y;
	ans=0;
	cin >>n>>d;
	rep(i,n){
		double m;
		cin >>x>>y;
		m=sqrt(x*x+y*y);
//		cout <<"m="<<m<<endl;
		if (m<=d) ans++;
	}
	cout <<ans<<endl;
	return 0;
}


Measured memory_bytes: 3700
/*input
1
1
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    int mini = INT_MAX;
    int cnt = 0;
    for(int i = 0; i < n; i++)
    {
    	int a; cin >> a;
    	if(a <= mini)
    	{
    		cnt++;
    		mini = a;
    	}
    }
    cout << cnt;

    return 0;
}

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


using namespace std;

int main() {
	int n;
	cin >> n;
	
	vector<int>d(n,0);
	
	for(int i = 0; i < n; i++) {
		cin >> d.at(i);
		
	}
	
	long long ans = 0;
	
	for(int i = 0; i < n; i++) {
		for(int j = i+1; j < n; j++) {
			ans += d.at(i)*d.at(j);
		}
	}
	
	cout << ans << endl;
	


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fast cin.tie(0);cout.tie(0);
#define order ios::sync_with_stdio(0);
using namespace std;
int t;
ll n,m,sm,a[1009];
int main()
{
    cin>>n>>m;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)
    {
        sm+=a[i];
    }
    if(sm%(4*m))sm+=4*m-sm%(4*m);
    sm/=(4*m);
    int c=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]>=sm)c++;
    }
    if(c>=m)cout<<"Yes";
    else cout<<"No";
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main()
{
	int N;
	scanf("%d", &N);
	if (N % 1000 == 0) {
		printf("%d\n", 0);
		return 0;
	}
	else {
		printf("%d\n", ((N / 1000 + 1) * 1000) - N );
		return 0;
	}
	return 0;
}

Measured memory_bytes: 1736
N = int(input())
A = list(map(int, input().split()))
# N = 7
# A = [1,1,1,1,1,1,1]
A.sort(reverse=True)
idx = N // 2
ans = 2 * sum(A[0:idx])
if N % 2 == 1:
    ans += A[idx]
ans = ans - A[0]
print(ans)


Measured memory_bytes: 31572
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 1000001;
const int MOD = 1000000007;
   
        signed main() {
           int n;
           
           cin>>n;
          int a[n];
          for(int i=0;i<n;i++)cin>>a[i];
          sort(a,a+n);
          cout<<a[n-1]-a[0];
           

        }


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=100005;

int N,Q,tp;
long long q[MAXN],stk[MAXN];
long long sum[MAXN],cnt[MAXN];

int main()
{
    scanf("%d%d",&N,&Q);
    for(int i=1;i<=Q;i++)
        scanf("%lld",&q[i]);
    stk[tp=1]=N;
    for(int i=1;i<=Q;i++)
    {
        while(tp&&stk[tp]>=q[i])
            tp--;
        stk[++tp]=q[i];
    }

	cnt[tp]=1;
	for(int i=tp;i>0;i--)
	{
		long long k=stk[i];
		int p=i-1;
		while(p)
		{
			cnt[p]+=(k/stk[p])*cnt[i];
			k%=stk[p];
			p=lower_bound(stk+1,stk+p,k)-stk;
			p--;
		}
		sum[1]+=cnt[i];
		sum[k+1]-=cnt[i];
		//printf("Add(1,%lld)\n",k);
	}
	long long ans=0;
	for(int i=1;i<=N;i++)
	{
		ans+=sum[i];
		printf("%lld\n",ans);
	}

    fclose(stdin);
    fclose(stdout);
    return 0;
}


Measured memory_bytes: 4736
#include<iostream>

int main(int argc, char const *argv[]) {
  int input;
  std::cin >> input;
  if( input >= 0 && input <= 86400){
    int hour = input / 3600;
    input -= hour * 3600;
    int minute = input / 60;
    int second = input - minute * 60;
    std::cout << hour << ":" << minute << ":" << second << "\n";
  }
  return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define M 1000000007
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define f first
#define s second
#define b begin
#define e end
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a;i<b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define itfr(it,x) for(it=x.begin();it!=x.end();it++)
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main()
{
    flash;
    //sieve();
    ll T=1,t,n,m,q,k,i,j;
    // cin>>T;
    while(T--)
    {
        cin>>n;
        int ans=0;
        if(n>=400&&n<=599)
        ans=8;
        if(n>=600&&n<= 799)
        ans= 7;
        if(n>=800&&n<= 999)
        ans= 6;
        if(n>=1000&&n<= 1199)
        ans= 5;
        if(n>=1200&&n<= 1399)
        ans= 4;
        if(n>=1400&&n<= 1599)
        ans= 3;
        if(n>=1600&&n<= 1799)
        ans= 2;
        if(n>=1800&&n<= 1999)
        ans= 1;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3664
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <cmath>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
const ll MOD = 998244353;

int main() {
    ll l;
    cin >> l;
    double t = ((double)l)/((double)3);
    auto b = t * t * t;
    cout << setprecision(17) << b << endl;
}


Measured memory_bytes: 256
a,b,c=map(int,input().split())
K=int(input())

# B > A
# C > B
import sys
for i in range(K+1):
    A=a
    B=b*(2**i)
    C=c*(2**(K-i))
    #print(i,K-i,A,B,C)
    if B>A and C>B:
        print('Yes')
        sys.exit()
else:
    print('No')

Measured memory_bytes: 9100
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <set>
#include <utility>
using namespace std;

int main() {
  string s; cin >> s;
  int ap = 0;int zp = s.length()-1;
  while (s[ap] != 'A')
    ap++;
  while (s[zp] != 'Z')
    zp--;
  cout << zp-ap+1 << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n,k; cin >> n >> k;
  COUT(n%k?1:0);
  return 0;
}

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

int main()
{
    int n,m,ans;

    cin >> n >> m;
    vector<int> x(m);
    rep(i, m) {
        cin >> x[i];
    }
    //sort
    sort(x.begin(), x.end());
    //差を求める
    vector<int> sa(m - 1);
    rep(i, m - 1) {
        int t = x[i + 1] - x[i];
        sa[i] = x[i + 1] - x[i];
    }
    //sort
    sort(sa.begin(), sa.end(), greater<int>());
    //ans計算
    ans = 0;
    for (int i = n - 1;i < m-1;++i) {
        ans += sa[i];
    }

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


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

#define int long long
#define fi first
#define se second
#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 rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

#define P pair<int,int>

int n,x,y,max_min=INF,min_max,MIN=INF,MAX,ans;
vector<P> v;

signed main() {
    cin >> n;
    rep(i,n) {
        cin >> x >> y;
        if (x > y) swap(x,y);
        v.pb(mp(x,y));
        MIN = min(MIN,x);
        MAX = max(MAX,y);
        max_min = min(max_min,y);
        min_max = max(min_max,x);
    }
    ans = (min_max - MIN) * (MAX - max_min);
    sort(all(v));
    int ma = max(v[0].se, v[n-1].fi), mi = v[0].se;
    rep11(i,n) {
        ans = min(ans, (MAX-MIN) * (ma - min(mi,v[i].fi)));
        ma = max(ma, v[i].se);
        mi = min(mi, v[i].se);
    }
    cout << ans << endl;
}



Measured memory_bytes: 6384
#![allow(unused_imports)]
#![allow(unused_variables)]

use itertools::Itertools;
use proconio::{fastout, input};
use std::collections::HashMap;

#[fastout]
fn main() {
    input! {
        n: usize,
        s: [String; n],
    }
    // annotate for rust-analyzer
    let n: usize = n;
    let s: Vec<String> = s;

    let mut map = HashMap::new();
    for k in s {
        *map.entry(k).or_insert(0) += 1;
    }

    println!("{}", map.len());
}


Measured memory_bytes: 28000
//include
//------------------------------------------
#include <bits/stdc++.h> // only for GCC

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

//container util
//------------------------------------------
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

//repetition
//------------------------------------------
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

//constant
//--------------------------------------------
const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

// output vector
// ------------------------------------------
namespace std {
    template<typename T>ostream&operator<<(ostream&os, vector<T>const&v){
        iter(it,v) os<<*it<<(it+1==v.end()?"":",");
        return os;
    }
    template<typename T, typename U>ostream&operator<<(ostream&os,const pair<T,U>&p){
        return os << "[" << p.dirst << "," << p.second << "]";
    }
}

//clear memory
// ------------------------------------------
#define clr(a,i) memset((a), (i) ,sizeof(a))

int main(){
   int n,m;
   vector<pii> x;
   char c;
   while(cin >> n >> c >> m && n|m){
      x.pb(mp(m,n));
   }
   sort(all(x));
   reverse(all(x));
   int r=1, tmp;
   rep(i,x.size()){
      if(i==0){
         tmp=x[i].first;
         x[i].first=r;
      }else if(x[i].first<tmp){
         tmp=x[i].first;
         r++;
         x[i].first=r;
      }else x[i].first=r;
   }
   while(cin >> n){
      rep(i,x.size()) if(x[i].second==n) cout << x[i].first << endl;
   }
}

Measured memory_bytes: 1200
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
	    Scanner std = new Scanner(System.in);
	    int a = Integer.parseInt(std.next());
	    int b = Integer.parseInt(std.next());
	    int c = Integer.parseInt(std.next());
	    boolean res = a<b && b<c;
	    if (res){
	    	System.out.println("Yes");
	    }else{
	    	System.out.println("No");
	    }
	}
}

Measured memory_bytes: 26224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long X;
  cin >> X;
  long long e = 100;
  int ans = 0;
  while(true){
    ans++;
    e += e/100;
    if(e >= X) break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int n,i,j,cnt=0;
    cin>>n;
    long long int a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    for(i=0;i<n-1;i++){
        if(a[i]>a[i+1]){
            j=a[i]-a[i+1];
            cnt=cnt+j;
            a[i+1]=a[i+1]+j;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 5164
n,k=map(int,input().split())
count=0
point=0
if k%2!=0:
    while k*(count+1)<=n:
        count +=1
    print(count**3)
else:
    for i in range(1,n+1):
        if i%k==0:
            point +=1
        elif 2*i%k==0:
            count +=1
    print(count**3+point**3)

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

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

constexpr int MAXN = 100000, MAXLOGA = 40;

ll A[MAXN + 2];

int main() {
	int N;
	ll K;
	cin >> N >> K;
	for(int i = 0; i < N; i++)
		cin >> A[i];
	ll ans = 0;
	bool ul = false;
	for(int i = MAXLOGA - 1; i >= 0; i--) {
		int o = 0, z = 0;
		for(int j = 0; j < N; j++)
			o += A[j] >> i & 1;
		z = N - o;
		if(z > o && (ul || K >> i & 1)) {
			ans += ((ll)z << i);
		} else {
			ans += ((ll)o << i);
			if(K >> i & 1)
				ul = true;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define PI 3.14159265358979323846264338327950L
using namespace std;
using P = pair<int,int>;
using ll = long long;
using namespace std;
char in[120];
pair<pair<string,int>,int> p[110];
int main(){
    int n, l;
    cin >> n >> l;
    int mini= 10000000;
    for(int i = l; i < l+n; ++i){
        mini = min(abs(i), mini);
    }
    int sum = 0;
    for(int i = l; i < l+n; ++i){
        if(i == mini){continue;}
        sum += i;
    }
    if(l+n<=0){cout << sum-(l+n-1) << endl;}
    else{cout << sum << endl;}
    return 0;
}

Measured memory_bytes: 3608
//#pragma GCC target("avx2,avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#include <atcoder/all>
//using namespace atcoder;
//using mint = modint998244353;
//using mint = modint1000000007;
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//using i128 = __int128_t;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
constexpr char ln = '\n';
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) {if (a < b) {a = b; return true;} return false;}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) {if (a > b) {a = b; return true;} return false;}
inline int topbit(int x) {return x == 0 ? -1 : 31-__builtin_clz(x);}
inline int topbit(long long x) {return x == 0 ? -1 : 63-__builtin_clzll(x);}
inline int botbit(int x) {return x == 0 ? 32 : __builtin_ctz(x);}
inline int botbit(long long x) {return x == 0 ? 64 : __builtin_ctzll(x);}
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
inline int kthbit(long long x, int k) {return (x>>k)&1;}
inline void print() {cout << "\n";}
template<class T>
inline void print(const vector<T> &v) {
    for (auto itr = v.begin(); itr != v.end(); ++itr) cout << *itr << " ";
    print();
}
template<class T, class... Args>
inline void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
#ifdef MINATO_LOCAL
#define dump(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
inline void debug() {cerr << endl;}
template<class T>
inline void debug(const vector<T> &v) {
    for (auto itr = v.begin(); itr != v.end(); ++itr) cerr << *itr << " ";
    debug();
}
template<class T, class... Args>
inline void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
#else
#define dump(x) void(0)
inline void debug() {}
template<class T> inline void debug(const vector<T> &v) {}
template<class T, class... Args> inline void debug(const T &x, const Args &... args) {}
#endif
struct Fast_ios {Fast_ios() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);};} fast_ios;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ll N,X,M; cin >> N >> X >> M;
    vector<vector<ll>> nex(61, vector<ll>(M));
    auto S = nex;
    rep(i,M) S[0][i] = i;
    rep(i,M) nex[0][i] = (ll)i*i%M;
    rep(bit,60) {
        rep(i,M) {
            nex[bit+1][i] = nex[bit][nex[bit][i]];
            S[bit+1][i] = S[bit][i] + S[bit][nex[bit][i]];
        }
    }

    //N++;
    ll ans = 0;
    int cur = X;
    int bit = 0;
    while (N) {
        if (N&1) {
            ans += S[bit][cur];
            cur = nex[bit][cur];
        }
        bit++;
        N>>=1;
    }

    cout << ans << ln;
}


Measured memory_bytes: 98704
/// Code by Leonardo16
///   “It is not the strength of the body, but the strength of the spirit.”   —  J.R.R. Tolkien
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
/// Macros
#define int long long
#define ll long long
#define sz size
#define ull unsigned long long
#define ld long double
#define ii pair<int,int>
#define fst first
#define scd second
#define vi vector<int>
#define vii vector<ii>
#define pb push_back
#define pf push_front
#define fl '\n'
#define el endl
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
/// Functions
#define db(x) cerr << #x << ": " << (x) << '\n';
#define random() __builtin_ia32_rdtsc()
#define lg2(x) 31-__builtin_clz(x)
#define lg2ll(x) 63-__builtin_clzll(x)
#define pi acos(-1)
#define YN(x) cout<<((x)?("YES"):("NO"))<<fl;
#define yn(x) cout<<((x)?("Yes"):("No"))<<fl;
/// Red-Black Tree Template
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
//#define less_than(n) order_of_key(n)
//#define en_pos(n) find_by_order(n)
/// Prime numbers  173,179,311,331,737,1009,2011,2027,3079,4001,100003
///=====================================================================


main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin>>n;
    vi v;
    v.pb(0);
    int sum=0;
    map<int,int>mp;
    for(int i =0;i<n;i++){
        int x;
        cin>>x;
        mp[x]++;
        sum+=x;
    }

    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        int b,c;
        cin>>b>>c;
        sum-=b*mp[b];
        sum+=c*mp[b];
        mp[c]+=mp[b];
        mp[b]=0;
        cout<<sum<<fl;
    }


return 0;}







Measured memory_bytes: 9516
#include<iostream>
#include<vector>
#include<string>
#include <algorithm>
#include <queue>
#include <climits>
#include<cmath>
#include <sstream>
#include <iomanip>

bool sort_pair( std::pair< int64_t, std::string > origin, std::pair< int64_t, std::string > another )
{
    return origin.first < another.first;
}


int main()
{

    int64_t n,k;

    std::cin>> n;
    std::cin>> k;

    std::vector< int64_t > list( n );
    //std::vector< double > value( n );

    for( int i = 0; i < n; i++ )
    {
        std::cin>> list[i];
    }

    int a = 0;
    int b = 0;
    int f = n - 1;
    int64_t all = -1000000;

    for( int a = 0; a <= std::min( n, k ); a++ )
    {
        for( int b = 0; b <= std::min( n, k ) - a; b++ )
        {            
            std::priority_queue< int64_t, std::vector< int64_t >, std::greater< int64_t > >  current;
            //std::cout<< a << " " << b <<"\n";
            
            for( int i = 0; i < a; i++ )
            {
                current.push( list[i] );
            }
            
            for( int i = 0; i < b; i++ )
            {
                current.push( list[f-i] );
            }
            
            for( int i = 0; i < k - ( a + b ); i++ )
            {
                if( !current.empty()
                    && current.top() < 0 )
                {
                    current.pop();
                }
                else
                {
                    break;
                }
            }
            
            int64_t r = 0;
            
            while( !current.empty() )
            {
                r += current.top();
                current.pop();
            }
            
            if( all < r )
            {
                all = r;
            }
        }
    }

    std::cout<< all;

}


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


class Program {
    internal static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        int[] inp = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var D = inp[0];
        var X = inp[1];
        int cnt = 0;

        for (int i = 0; i < N; i++) {
            var Ai = int.Parse(ReadLine());
            cnt++;

            int hoge = Ai;
            while (hoge + 1 <= D) {
                cnt++;
                hoge += Ai;
            }
        }

        WriteLine(cnt + X);
    } 
}

Measured memory_bytes: 13396
/**
*	created: 11.08.2020 23:12:01
**/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    int n, x, y; cin >> n >> x >> y;
    x--; y--;
    vector<int> v(n);
    rep(i,n) {
        vector<int> dist(n,INF);
        queue<int> q;
        auto pushin = [&] (int v, int d) {
            if (dist[v] != INF) return;
            dist[v] = d;
            q.push(v);
        };
        pushin(i,0);
        while (!q.empty()) {
            int v = q.front(); q.pop();
            int d = dist[v];
            if (v - 1 >= 0) pushin(v-1,d+1);
            if (v + 1 < n) pushin(v+1,d+1);
            if (v == x) pushin(y,d+1);
            if (v == y) pushin(x,d+1);
        }
        rep(j,n) v[dist[j]]++;
    }
    rep2(i,1,n) cout << v[i] / 2 << endl;
    return 0;
}

Measured memory_bytes: 3648
/* author: Tarek */ 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
int main()
{
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
int a,b;
cin>>a>>b;
if(a*500>=b)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
       	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>

#define ll long long
#define PII pair<int ,int>

using namespace std;

int dp[100005] = { 1 };

int main() {
	string x; cin >> x;
	bool ans = true;
	for (int i = 0; i < x.length(); i++) {
		if (x[i] == 'e') {
			string y = x.substr(i, 6);
			string z = x.substr(i, 5);
			if (y == "eraser")
				dp[i + 6] |= dp[i];
			if (z == "erase") {
				dp[i + 5] |= dp[i];
			}
		}
		else if (x[i] == 'd') {
			string y = x.substr(i, 7);
			string z = x.substr(i, 5);
			if (y == "dreamer")
				dp[i + 7] |= dp[i];
			if (z == "dream")
				dp[i + 5] |= dp[i];
		}
	}

	if (dp[x.length()]) cout << "YES\n";
	else cout << "NO\n";
	return 0;
}

Measured memory_bytes: 1024
import * as fs from "fs";
const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const [n] = input[0].split(" ").map((x: string): number => +x);

// const n = 15

var sum = 0
for(var i=1; i<=n; i++) {
    if (i%3 !== 0 && i%5 !==0) {
        sum += i
    }
}

console.log(sum)

Measured memory_bytes: 35148
def main():
    N, H = map(int, input().split())
    ab = [
        [i] + list(map(int, input().split()))
        for i in range(N)
    ]

    # solve(N, H, ab)
    editorial(H, ab)


def editorial(H, ab):
    """
    max_a より大きいbを使う方針はOK
    max_a を持ち max_aより大きいbを持つ刀をどうするか？

    基本は合っていた
    投げた後のことを考えていたが
    投げるのは倒すときでよいので、それまでは切り続ける
    というのが解説の投げた後も使って良いということ
        b ... b + (a_max ... a_max + b_last)
        b ... b + (b_last + a_max ... a_max)
    """
    sorted_a = sorted(ab, key=lambda x: x[1], reverse=True)
    sorted_b = sorted(ab, key=lambda x: x[2], reverse=True)
    max_a = sorted_a[0][1]

    ans = 0
    for _, _, b in sorted_b:
        if max_a > b:
            break

        H -= b
        ans += 1
        if H <= 0:
            print(ans)
            return

    ans += (H + max_a - 1) // max_a
    print(ans)

if __name__ == "__main__":
    main()


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

int main() {
  int n,m,c=0,x=0;

  cin >>n>>m;
  vector<int> vec(n);
  
  for(int i=0;i<n;i++){
    int y;
    cin >> y;
    vec[i]=y;
    x +=y;
  }
  
  for(int i=0;i<n;i++){
    if(vec[i]*4*m>=x) c++;
  }
  
  if(c>=m) cout << "Yes" <<endl;
  else cout << "No" <<endl;

  return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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; }

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

ll h[100010][3];
ll dp[100010][3];

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

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			cin >> h[i][j];
		}
	}

	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k < 3; k++)
			{
				if (j == k) continue;

				chmax(dp[i + 1][k], dp[i][j] + h[i][k]);
			}
		}
	}

	ll res;
	for (int i = 0; i < 3; i++) res = max(res, dp[n][i]);

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 4992
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)

int main(void)
{
    int N;
    cin >> N;
    double x[N];
    string u[N];
    for(int i = 0; i < N; i++){
        cin >> x[i] >> u[i];
    }
    double sum = 0.0;
    for(int i = 0; i < N; i++){
        if(u[i] == "JPY")
            sum += x[i];
        else if(u[i] == "BTC")
            sum += (x[i] * 380000.0);
    }

    printf("%.10lf\n",sum);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(void){
 
  int H,W;
  cin >>H>>W;
 
  int a[H][W];
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >>a[i][j];
    }
  }
  int ans_x[H*W];
  int ans_xd[H*W];
  int ans_y[H*W];
  int ans_yd[H*W];
  int counter=0;
 
  for(int i=0;i<H-1;i++){
    for(int j=0;j<W;j++){
      if(a[i][j]%2!=0){
        a[i+1][j]+=1;
        ans_x[counter]=i+1;
        ans_xd[counter]=i+2;
        ans_y[counter]=j+1;
        ans_yd[counter]=j+1;
        counter++;
      }
    }
  }
 
  for(int i = 0;i < W-1;i++){
    if(a[H-1][i] % 2 != 0){
      a[H-1][i+1]+=1;
      ans_x[counter]=H;
      ans_xd[counter]=H;
      ans_y[counter]=i+1;
      ans_yd[counter]=i+2;
      counter++;
    }
  }
 
  cout << counter <<endl;
  //print
  for(int i = 0;i < counter;i++){
    cout << ans_x[i] << " " << ans_y[i] << " " << ans_xd[i] << " " << ans_yd[i] << endl;
  }
 
 
  return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cstdint>
#include <algorithm>
#include <cmath>
#include <numeric>

using namespace std;

int main()
{
    int n;
    int p[20];

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }

    int cnt = 0;
    for (int i = 0; i < n - 2; i++)
    {
        bool cond = (p[i + 1] > p[i] && p[i + 1] > p[i + 2]) || (p[i + 1] < p[i] && p[i + 1] < p[i + 2]);
        if (!cond)
        {
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
k = int(input())
list1 = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(list1[k-1])


Measured memory_bytes: 2940
#include<cstdio>
int main(){

int a,b;

while(1){
	scanf("%d %d",&a,&b);
	if((a == 0)&&(b == 0)) break;
	if(a<b){
		printf("%d %d\n",a,b);
	}else{
		printf("%d %d\n",b,a);
		}
	}
return 0;
}
		

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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
// #define LOG(...)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for(int i = (int)(n - 1); i >= 0; --i)
#define RFOR(i, a, b) for(int i = (int)(b - 1); i >= (int)(a); --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)
#define BIT(x, i) (((x) >> (i)) & 1)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vc> vvc;
typedef vector<vll> vvll;

const int INF = (int)1e9;

int main() {
  vi pollock;
  for(int i = 0, v; ( v = i * (i + 1) * (i + 2) / 6) <= 1000000; i++) {
    pollock.push_back(v);
  }

  vi dpall(1000001, INF);
  vi dpodd(1000001, INF);
  dpall[0] = dpodd[0] = 0;
  for (auto m : pollock) {
    for(int i = 0; i + m < dpall.size(); i++) {
      dpall[i + m] = min(dpall[i + m], dpall[i] + 1);
    }
    if (m % 2 == 1) {
      for(int i = 0; i + m < dpodd.size(); i++) {
        dpodd[i + m] = min(dpodd[i + m], dpodd[i] + 1);
      }
    }
  }

  int n;
  while(cin >> n, n) {
    printf("%d %d\n", dpall[n], dpodd[n]);
  }
}

Measured memory_bytes: 10528
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    int N; cin>>N;
    int a[100];
    int tmp=0;
    for(int i=0;i<N;i++){
        cin>>a[i];
        tmp+=a[i];
    }
    double check = (1.0*tmp)/(1.0*N);
    
    double j=10000;
    for(int i=0;i<N;i++){
        double x = abs(1.0*a[i]-check);
        j = min(j,x);
    }
    int ans;
    for(int i=0;i<N;i++){
        double x = abs(1.0*a[i]-check);
        if(j-0.001< x && x<j+0.001){
            ans=i;
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
<?php
$server = "php://stdin";
$local="input.txt";
$handle = fopen($server, "r");
$t = trim(fgets($handle));
$a=explode(" ",$t);
$map=[];
$map2=[];
$map=array_fill(0,$a[0],0);
$p=0;$ans=0;$y=0;
for($i=0;$i<$a[1];$i++)
{
    $x=trim(fgets($handle));
    $h=explode(" ",$x);
    if($map[$h[0]-1]==0 && $h[1]=="WA")
    {
    if(isset($map2[$h[0]-1]))$map2[$h[0]-1]=$map2[$h[0]-1]+1;
    else
    {
        $map2[$h[0]-1]=1;
    }
    }
    if($map[$h[0]-1]==0 && $h[1]=="AC"){$ans++;if(isset( $map2[$h[0]-1])){$y=$y+$map2[$h[0]-1];}$map[$h[0]-1]=1;}
}
echo $ans." ".$y;
?>

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

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

  vector<char> stack;  
  for(int i=0; i<s.size(); i++){
    if(s[i] == 'S') stack.push_back(s[i]);
    else if(s[i] == 'T'){
      if(!stack.empty() && stack.back() == 'S') stack.pop_back();
      else stack.push_back(s[i]);
    }
  }

  cout << stack.size() << endl;
  return 0;
}

Measured memory_bytes: 772
#include <iostream>

using namespace std;

int main()
{
	int W_max = 0;
	int H_max = 0;
	int N = 0;

	cin >> W_max >> H_max >> N;

	int *x = new int[N];
	int *y = new int[N];
	int *a = new int[N];

	for (int i = 0; i < N; i++)
	{
		cin >> x[i] >> y[i] >> a[i];
	}

	int W_min = 0;
	int H_min = 0;

	for (int i = 0; i < N; i++)
	{
		if (a[i] == 1)
		{
			if (W_min < x[i])
			{
				W_min = x[i];
			}
		}
		else if (a[i] == 2)
		{
			if (W_max > x[i])
			{
				W_max = x[i];
			}
		}
		else if (a[i] == 3)
		{
			if (H_min < y[i])
			{
				H_min = y[i];
			}
		}
		else if (a[i] == 4)
		{
			if (H_max > y[i])
			{
				H_max = y[i];
			}
		}
	}

	if (W_min < W_max && H_min < H_max)
	{
		cout << (W_max - W_min) * (H_max - H_min) << endl;
	}
	else
	{
		cout << 0 << endl;
	}

	delete[] x;
	delete[] y;
	delete[] a;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl

ll n,m,a,b,c,x,y,z,aa[10010][10010];
bool r,ra,rb,rc;
string s,sa,sb,sc[100];
char ca,cb,cc,cd[1000][1000];
vector<ll> va,vb,vc;

int main(){
    cin>>n;
    C (n/11)*2+(n%11==0 ? 0:n%11<=6 ? 1:2) E;
    
}

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

public class Program
{

    public void Proc()
    {
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        this.TotalLen = inpt[0];
        int alicePos = inpt[1];
        int bolicePos = inpt[2];
        String ans = "Borys";
        if(bolicePos-alicePos==1&&alicePos==1) {
            ans = "Borys";
        } else if((bolicePos-alicePos)%2==0) {
            ans = "Alice";
        }
        Console.WriteLine(ans);
    }


    private int TotalLen;





    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"



5 2 4



";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 13396
import bisect
N = int(input())
L = list(map(int,input().split()))
L.sort()
ans = 0
for i in range(len(L)-1):
    for j in range(i+1,len(L)-1):
        a = L[i]
        b = L[j]
        c = L[j+1]
        if c-a < b and b < c+a:
            ans += bisect.bisect_left(L,b+a)-j-1
print(ans)

Measured memory_bytes: 3188
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

LL N, A[3], B[3];

LL dp1[5001][3];
LL solve1(LL nokori, int state){
	if(nokori < 0) return INT_MIN;
	if(state == 3) return N;
	if(dp1[nokori][state] != INT_MIN) return dp1[nokori][state];
	return dp1[nokori][state] = max(solve1(nokori, state+1), solve1(nokori-A[state], state)+B[state]-A[state]);
}

LL dp2[25000000][3];
LL solve2(LL nokori, int state){
	if(nokori < 0) return LLONG_MIN/10;
	if(state == 3) return 0;
	if(dp2[nokori][state] != LLONG_MIN) return dp2[nokori][state];
	return dp2[nokori][state] = max(solve2(nokori, state+1), solve2(nokori-B[state], state)+A[state]-B[state]);
}

int main(){
	cin >> N;
	for(int i=0; i<3; i++) cin >> A[i];
	for(int i=0; i<3; i++) cin >> B[i];

	for(int i=0; i<=N; i++){
		for(int j=0; j<3; j++){
			dp1[i][j] = INT_MIN;
		}
	}
	LL ans1 = solve1(N,0);

	for(int i=0; i<=ans1; i++){
		for(int j=0; j<3; j++){
			dp2[i][j] = LLONG_MIN;
		}
	}
	LL ans2 = ans1+solve2(ans1,0);
	
	cout << ans2 << endl;
}


Measured memory_bytes: 662272
#include <vector>
#include <iterator>
#include <iostream>
#include <numeric>

int main() {
    int N;
    std::vector<std::vector<int> > A(3, std::vector<int>(3, 0));

    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            std::cin >> A[i][j];
        }
    }

    std::cin >> N;
    std::vector<int> b(N);

    // O(n)
    for (int i = 0; i < N; ++i) {
        std::cin >> b[i];
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (A[j][k] == b[i]) {
                    A[j][k] = 0;
                    break;
                }
            }
        }
    }


    // 横 O(1)
    for (auto& a : A) {
        int sum_row = std::accumulate(std::begin(a), std::end(a), 0);
        if (sum_row == 0) {
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }

    // 縦 O(1)
    for (int i = 0; i < 3; ++i) {
        int sum_column = A[0][i] + A[1][i] + A[2][i];
        if (sum_column == 0) {
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }

    // 斜め O(1)
    int sum_diagonal;
    sum_diagonal = A[0][0] + A[1][1] + A[2][2];
    if (sum_diagonal == 0) {
        std::cout << "Yes" << std::endl;
        return 0;
    }
    sum_diagonal = A[0][2] + A[1][1] + A[2][0];
    if (sum_diagonal == 0) {
        std::cout << "Yes" << std::endl;
        return 0;
    }

    std::cout << "No" << std::endl;
    return 0;
}

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

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

int main(){
int n;
map<string,int> m;
cin>>n;
string s[n];
rep(i,n){
cin>>s[i];
m[s[i]]++;
}
int count=0;
for(auto i:m){
  count++;
}

cout<<count<<endl;

  return 0;
}


Measured memory_bytes: 25464
#include<bits/stdc++.h>
using namespace std;
#define vite ios_base::sync_with_stdio(false); cin.tie(NULL);
int main()
{
    vite;
    long long int a, b, c, k;
    cin >> a >> b >> c >> k;
    long long int t = 0;
    if(k>a)
    {
        t += a;
        k -= a;
    } 
    else
    {
        t += k;
        cout << t;
        return 0;
    }
    if(k>b)
    {
        k -= b;
    }
    else
    {
        cout << t;
        return 0;
    }
    if(k>c)
    {
        t -= c;
    }
    else
    {
        t -= k;
    }
    cout <<t;

    return 0;
}

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

#define cal(i, p, n) for(int i = p ; i < n ; i++)

using namespace std;

int main(){
    int N;
    int maxcount = 0;
    string S;
    cin >> N;
    cin >> S;
    cal(i, 1, N){
        string s1 = S.substr(0, i);
        string s2 = S.substr(i);
        sort(s1.begin(), s1.end());
        auto n = unique(s1.begin(), s1.end());
        s1.erase(n, s1.end());
        int count = 0;
        cal(j, 0, s1.length()){
            if(s2.find(s1[j])!= string::npos){
                count++;
            }
        }
        maxcount = max(maxcount, count);
    }
    cout << maxcount;
    return 0;
}


Measured memory_bytes: 256
n = int(input())

cnt = [1] * (n + 1)
cnt[0] = 0
cnt[1] = 0

p = 2
while p  <= n // 2:
    for i in range(p*2, n+1, p):
        cnt[i] += 1
    p += 1

ans = 0
for i in range(1, n+1):
    # print(i, cnt[i]+1)
    ans += i * (cnt[i] + 1)

print(ans)



Measured memory_bytes: 151716
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int n,m,l;
char map[1005][1005];
int d[1005][1005];
int i,j,k;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int sx,sy;
int gx,gy;

int bfs(){
  queue<P> que;
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
        d[i][j]=INF;
    }
  }
  que.push(P(sx,sy)); d[sx][sy]=0;
  while(que.size()){
    P p=que.front(); que.pop();
    if(p.first==gx and p.second==gy) break;

    for(i=0;i<4;i++){
      int nx=p.first+dx[i];
      int ny=p.second+dy[i];
      if(0<=nx and nx<n and 0<=ny and ny<m and map[nx][ny]!='#' and d[nx][ny]==INF){
        que.push(P(nx,ny));
        d[nx][ny]=d[p.first][p.second]+1;
      }
    }
  }
  return d[gx][gy];
}

int main(){
  cin>>n>>m;
  sx=sy=0;
  gx=n-1;gy=m-1;
  int count=0


  ;
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      cin>>map[i][j];
      if(map[i][j]=='.') count++;
    }
  }

  int ans=bfs();
  if(ans==INF) cout<<-1<<endl;
  else{
    ans=count-ans-1;
    cout<<ans<<endl;}

}


Measured memory_bytes: 2432
use std::io;
use std::io::Read;

fn main() {
    let mut stdin = io::stdin();
    let mut lines_str = String::new();
    let _ = stdin.read_to_string(&mut lines_str);
    let mut lines = lines_str.lines();
    let mut line0itr = lines.next().expect("").split_whitespace();
    let n :usize = line0itr.next().expect("").trim().parse().unwrap();
    let m :usize = line0itr.next().expect("").trim().parse().unwrap();
    let q :usize = line0itr.next().expect("").trim().parse().unwrap();
    //tennha + hennha -
    //honnyakusita yatu
    //let mut map :Vec<i32> = vec![0;(2*n-1)*(2*m-1)];
    //sokoyori hidarino sousuu
    //let mut gyoudots :Vec<i32> = vec![0;(2*n-1)*(2*m-1)];
    //sokoyori hidariueno sousuu
    let mut dots :Vec<i32> = vec![0;(2*n-1)*(2*m-1)];
    //map no shokika
    for i in 0..n {
        let mut linei1itr = lines.next().expect("").chars();
        for j in 0..m {
            let c = linei1itr.next().expect("");
            if c != '1' {
                continue;
            }
            dots[2*i*(2*m-1)+2*j] = 1;
            if j != 0 {
                if dots[2*i*(2*m-1)+2*(j-1)] == 1 {
                    dots[2*i*(2*m-1)+2*j-1] = -1;
                }
            }
            if i != 0 {
                if dots[2*(i-1)*(2*m-1)+2*j] == 1 {
                    dots[(2*i-1)*(2*m-1)+2*j] = -1;
                }
            }
        }
    }
    //gyoudots no shokika
    for k in 0..(2*n-1) {
        for l in 0..(2*m-1) {
            if l == 0 {
                dots[k*(2*m-1)+l] = dots[k*(2*m-1)+l];
            } else {
                dots[k*(2*m-1)+l] = dots[k*(2*m-1)+l-1] + dots[k*(2*m-1)+l];
            }
        }
    }
    //dots no shokika
    for k in 0..(2*n-1) {
        for l in 0..(2*m-1) {
            if k == 0 {
                dots[k*(2*m-1)+l] = dots[k*(2*m-1)+l];
            } else {
                dots[k*(2*m-1)+l] = dots[(k-1)*(2*m-1)+l] + dots[k*(2*m-1)+l];
            }
        }
    }
    //query no shori
    for i in 0..q {
        let mut linein1itr = lines.next().expect("").split_whitespace();
        let x1 :usize = linein1itr.next().expect("").trim().parse().unwrap();
        let y1 :usize = linein1itr.next().expect("").trim().parse().unwrap();
        let x2 :usize = linein1itr.next().expect("").trim().parse().unwrap();
        let y2 :usize = linein1itr.next().expect("").trim().parse().unwrap();
        let x2y2 = dots[(2*(x2-1))*(2*m-1)+(2*(y2-1))];
        let x1y2 = if x1 == 1 {
            0
        } else {
            dots[(2*(x1-1)-1)*(2*m-1)+(2*(y2-1))]
        };
        let x2y1 = if y1 == 1 {
            0
        } else {
            dots[(2*(x2-1))*(2*m-1)+(2*(y1-1)-1)]
        };
        let x1y1 = if x1 == 1 || y1 == 1 {
            0
        } else {
            dots[(2*(x1-1)-1)*(2*m-1)+(2*(y1-1)-1)]
        };
        println!("{}", x2y2+x1y1-x1y2-x2y1);
    }
}


Measured memory_bytes: 76536
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;

int main()
{
	int L, R, d;
	cin >> L >> R >> d;

	int count = 0;
	for (int i = L; i <= R; i++) {
		if (i % d == 0) {
			count++;
		}
	}

	cout << count << endl;
}






Measured memory_bytes: 3616