akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<stdio.h> 
#include<bitset> 
#include<iomanip> 
#define ll long long
using namespace std;
ll gcd(ll a, ll b) {
	while (b) {
		ll mod = a % b; a = b; b = mod;
	}
	return a;
}

bool cmp(pair<int, ll> A, pair<int, ll> B) {
	return A.second < B.second;
}
int main() {
	int n;
	cin >> n;
	vector < pair <int, int> > a;
	for (int i = 0; i < n; i++) {
		int temp;
		cin >> temp;
		a.push_back(make_pair(temp, i));
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < n; i++) {
		cout << a[i].second + 1<<" ";
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int X;
  int T;
  cin >> N;
  cin >> X;
  cin >> T;
  if (N%X==0) {
    cout << ( N / X ) * T << endl;
  }
  else {
    cout << ( ( N / X ) + 1 ) * T << endl;
  }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

template<class T> inline bool cmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool cmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MOD=1000000007;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll MAXN = 1003;
const ll MAXW = 20003;
const ll MAXLG=__lg(MAXN)+2;
ll n;
struct Block {
    ll w,s,v,id;
}blocks[MAXN];
ll dp[MAXN][MAXW];
/********** Good Luck :) **********/
int main()
{
    IOS();
    cin >> n;
    REP (i,n) {
        cin >> blocks[i].w >> blocks[i].s >> blocks[i].v;
        blocks[i].id = i + 1;
    }

    sort(blocks,blocks+n,[&](const Block &b1,const Block &b2){
        return b1.w + b1.s < b2.w + b2.s;
    });

    MEM(dp,-1);
    
    REP (i,n) {
        if (i == 0) {
            dp[i][0] = 0;
            dp[i][blocks[i].w] = blocks[i].v;
        } else {
            for (ll j=0;j<MAXW;j++) {
                if (j-blocks[i].w >= 0 && j-blocks[i].w <= blocks[i].s && dp[i-1][j-blocks[i].w] != -1) {
                    dp[i][j] = dp[i-1][j-blocks[i].w] + blocks[i].v;
                }
                dp[i][j] = max(dp[i][j],dp[i-1][j]);
            }
        }
    }

    ll ans = 0;
    REP (i,MAXW) {
        ans = max(ans,dp[n-1][i]);
    }

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

Measured memory_bytes: 157056
#include <stdio.h>
int main()
{
    int i, n,arr[10], temp,sum=0,k;

    scanf("%d", &n);

    for(i = 0; i < n; ++i)
    {
       scanf("%d", &arr[i]);
    }

    for(i = 1; i < n; ++i)
    {

       if(arr[0] < arr[i])
       {
           temp = arr[0];
           arr[0] = arr[i];
           arr[i] = temp;
       }

    }
    for(i=0;i<n;i++){
        sum=sum+arr[i];
    }
    k=sum-arr[0];
    if(k>arr[0]){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string.h>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

int main(void)
{
	int x, y;
	int flag_x, flag_y;
	cin >> x >> y;
	
		if (x == 4 || x == 6 || x == 9 || x == 11) {
			flag_x = 1;
		
	}
	else if (x == 2) {
		flag_x = 2;
		
	}
	else {
			flag_x = 3;
	
	}
	
		if (y == 4 || y == 6 || y == 9 || y == 11) {
			flag_y = 1;
	
	}
	else if (y == 2) {
				flag_y = 2;
		
	}
		else {
			flag_y = 3;
		
	}

			if (flag_x == flag_y) {
			cout << "Yes" << endl;
		
	}
		else {
			cout << "No" << endl;
		
	}
	
		
			return (0);
	}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9 + 7 ;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e5+3;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int a,b;
      cin>>a>>b;
      int k=(a+b)/2;
      if(abs(k-a)!=abs(k-b))
      {
            cout<<"IMPOSSIBLE";
      }
      else cout<<k;
}
// a+b/2=k
// a+b/2=k
// 
// I never lose. I either win or I learn

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))

for i in range(0,n):
    v = A[i]
    j = i -1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j-=1
    A[j+1] = v

    print(*A,sep=" ")




Measured memory_bytes: 5984
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <malloc.h>
#include <stack>
#include <cstring>
#include <string>
#include <unordered_map>
#define INT long long int
#define MOD 1000000007
#define oo 987654321
using namespace std;

int n, a[100010], cnt;

int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i = 0 ; i < n ; i++ ) cin>>a[i];
    for(int i = 0 ; i < n ; i++ ) if( a[i]%2 == 1 ) cnt++;
    cout<<(cnt%2?"NO":"YES")<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod (1000000007)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
//B=lcm*(1/Aの和)
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    vector<ll>lcm(1000010,0);
    ll n,ans=0;cin>>n;
    ll a[n];REP(i,n)cin>>a[i],(ans+=power(a[i],mod-2))%=mod;//ans=Aの逆元の和
    REP(i,n){
        ll tmp=a[i];
        for(int j=2;j*j<=tmp;j++){//lcmを素因数分解してからansに掛け算
            if(tmp==1)break;
            if(tmp%j==0){
                ll cnt=0;
                while(tmp%j==0)tmp/=j,cnt++;
                while(lcm[j]<cnt)(ans*=j)%=mod,lcm[j]++;
            }
        }
        while(tmp&&!lcm[tmp])(ans*=tmp)%=mod,lcm[tmp]++;//a[i]は素数
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 8192
t = [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(t[int(input())-1])

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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

ll pCount(int x){
  if(x==0) return 1;
  return pCount(x-1)*2 + 1;
}

ll allCount(int x){
  if(x==0) return 1;
  return allCount(x-1)*2 + 3;
}


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

  unordered_map<int,int> even;
  unordered_map<int,int> odd;

  int v;
  for(int i=0;i<n;i++){
    cin >> v;
    if(i%2==0) even[v]++;
    else odd[v]++;
  }
  multimap<int,int,greater<int>> invEven;
  multimap<int,int,greater<int>> invOdd;
  for(auto e:even){
    invEven.insert(make_pair(e.second,e.first));
  }
  
  for(auto o:odd){
    invOdd.insert(make_pair(o.second,o.first));
  }

  int maxCount = 0;
  for(auto ie:invEven){
  	for(auto io:invOdd){
      if(ie.second!=io.second){
        maxCount = max(maxCount,ie.first+io.first);
        break;
      }
    }
  }
  if(maxCount==0)maxCount=n/2;

  cout << n-maxCount << endl;
  return 0;
}



Measured memory_bytes: 11976
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
#include <cstring>
using namespace std;
#define N 105
int n,map[N][N],k,now;
int a[N][N],siz[N],used[N];
int main()
{
	scanf("%d",&n);
	int sum=n*(n+1)>>1;
	for(int i=2;i<=n;i++)if(sum%i==0){k=i;break;}
	for(int i=1;i<=k;i++)
	{
		now=sum/k;
		for(int j=n;j;j--)if(!used[j]&&now>=j)a[i][++siz[i]]=j,now-=j,used[j]=1;
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(i!=j)map[i][j]=1;
	for(int i=1;i<=k;i++)
		for(int j=1;j<=siz[i];j++)
			for(int l=1;l<=siz[i];l++)
				map[a[i][j]][a[i][l]]=0;
	now=0;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			now+=map[i][j];
	printf("%d\n",now);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(map[i][j])printf("%d %d\n",i,j);
}

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

int main(void)
{
	char str[21], rev[21];
	int i, len;
	
	scanf("%s", str);
	
	len = strlen(str);
	
	rev[len] = '\0';
	for (i = 0; i < len; i++){
		rev[len - 1 - i] = str[i];
	}
	
	printf("%s\n", rev);
	
	return (0);
}

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

using namespace std;

#define rep(i,x) for (int i = 0 ; i < x; ++i)
#define rrep(i,x) for (int i = x - 1; i >= 0; --i)
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sqr(x) ((x) * (x))
#define re return

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;


void GO(){
#ifdef DOD
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

const int INF = 1e9 + 1;
const ll mod = 1e9 + 7;






//Var
//
 void input() {
     string a, b; cin>> a >> b;
     int ans = 0;
     rep(i,sz(a)){ if(a[i] != b[i]) ans++;}
     cout << ans;
 }

void solve(){
     
}








///Я призер Всеросса
int main() {
    GO();
    int Q = 1;
    while(Q--){ input(); solve(); } re 0;
}
///Я Кондедат в мастера


Measured memory_bytes: 3800
#include<stdio.h>

int main(){
	int i,j,c=0,x=0,n[10]={512,256,128,64,32,16,8,4,2,1};
	while(scanf("%d",&x)!=EOF){
	int a=0,b=0,B=0,N[10]={};
		for(i=0;i<10;i++){
			if(n[i]<=x && a+n[i]<=x){
				a=a+n[i];
				N[i]=n[i];
				b++;
			}
			if(a==x){
				break;
			}
		}
		for(i=0;i<10-1;i++){
			for(j=10-1;j>i;j--){
				if(N[j-1]>N[j]){
				c=N[j];
				N[j]=N[j-1];
				N[j-1]=c;
				}
			}
		}
		for(i=0;i<10;i++){
			if(N[i]!=0){
			printf("%d",N[i]);
			B++;
			if(B!=b){
			printf(" ");
			}
			}
		}
		printf("\n");
	}
return 0;
}

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

using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint operator-() const { return mint(-x); }

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const { return mint(*this) += a; }

    mint operator-(const mint a) const { return mint(*this) -= a; }

    mint operator*(const mint a) const { return mint(*this) *= a; }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }

    mint &operator/=(const mint a) { return *this *= a.inv(); }

    mint operator/(const mint a) const { return mint(*this) /= a; }
};

istream &operator>>(istream &is, const mint &a) { return is >> a.x; }

ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }

    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

struct UnionFind {
    vector<int> d;

    UnionFind(int n = 0) : d(n, -1) {}

    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }

    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }

    bool same(int x, int y) { return find(x) == find(y); }

    int size(int x) { return -d[find(x)]; }
};

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

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

ll dfs(int n, ll x, ll p, ll b, vector<pair<ll, ll>> &A) {
    if (n < 0)return p;
    ll pp = A[n - 1].first, bb = A[n - 1].second;
    cout << n << " " << p << " " << b << " " << pp + bb + 2 << endl;
    ll res;
    if (x < p + b + pp + bb + 2)res = dfs(n - 1, x, p, b, A);
    else res = dfs(n - 1, x, p + pp + 1, b + bb + 1, A);
    return res;
}


int main() {
    ll n;
    cin >> n;
    vector<ll> A(n + 10);
    map<ll, ll> m;
    m[0]++;

    ll sum = 0, ans = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> A[i];
        sum += A[i];
        m[sum]++;
    }
    
    sum = 0;
    for (int i = 0; i <= n; ++i) {
        sum += A[i];
        m[sum]--;
        ans += m[sum];
    }
    
    cout << ans << endl;
    
    return 0;
}


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	vector<ll> c(n-1);
	vector<ll> s(n-1);
	vector<ll> f(n-1);
	REP(i, n-1){cin >> c[i] >> s[i] >> f[i];}
	vector<ll> ans(n);
	REP(i, n-1){
		ll t = s[i]+c[i];
		FOR(j, i+1, n-1){
			if (s[j]>t){
				t = s[j] + c[j];
			} else if ((t-s[j])%f[j] == 0){
				t += c[j];
			} else {
				t = t + (f[j]-(t-s[j])%f[j]) + c[j];
			}
		}
		cout << t << endl;
	}
	cout << 0 << endl;
}


Measured memory_bytes: 256
# C - Distinct or Not
# https://atcoder.jp/contests/abc154/tasks/abc154_c

num = int(input())
p = list(map(int, input().split()))
list.sort(p)

ret = "YES"
for i in range(num-1):
    if p[i] == p[i+1]:
        ret = "NO"
        break

print("{}".format(ret))

Measured memory_bytes: 30984
#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define PII pair<int,int>
#define ls x<<1
#define rs x<<1|1
#define fi first
#define se second
#define pb push_back
#define cwk freopen("D:\\c++\\in.txt","r",stdin),freopen("D:\\c++\\out.txt","w",stdout)
using namespace std;
const int N=1e6+10;
int t,n;
int main()
{
	//cwk;
	scanf("%d%d",&t,&n);
	for(int i=1;i<=n;i++) {
		int x;
		scanf("%d",&x);
		t-=x;
	}
	if(t>=0)
	printf("%d\n",t);
	else puts("-1");
	return 0;
}

Measured memory_bytes: 3828
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
  int N;
  double K, probability = 0;
  cin >> N >> K;
  int rep[N];
  for(int i = 1; i <= N; i++) {
    if(log2(K / i) > 0) rep[i] = ceil(log2(K / i));
    else rep[i] = 0;
  }
  for(int i = 1; i <= N; i++) probability += pow(0.5, rep[i]);
  cout << setprecision(11) << probability / N;
  return 0;
}

Measured memory_bytes: 640
def main():
    N = int(input())
    A = sorted([int(_) for _ in input().split()])
    B = [0] * (N+1)
    for i in range(N):
        B[i+1] = A[i]+B[i]
    output = 1
    for i in range(N-1)[::-1]:
        if 2*B[i+1] >= A[i+1]:
            output += 1
            continue
        else: break
    print(output)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 14276
R, G, B, N = map(int, input().split())

C = sorted([R, G, B], reverse=True)

cnt = 0
for p0 in range(N//C[0]+1):
    p0v = p0*C[0]
    for p1 in range((N-p0v)//C[1]+1):
        p1v = p1*C[1]
        if (N - p0v - p1v)%C[2] == 0:
            cnt += 1
print(cnt)


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

typedef long long ll;

ll N,X,M,arr[100100],sum=0,polasum=0,polasize=0,sisasum=0;
vector<ll> v(1,0);

ll f(long long a){
	return a*a%M;
}

void Input(){
	cin>>N>>X>>M;
}

void Solve(){
	for(long long i=1; i<=min(N,M); i++){
		if(arr[X]==0){
			arr[X]=i; v.push_back(X);
			sum+=X;
		}else{
			for(long long j=arr[X]; j<v.size(); j++){
				polasum+=v[j]; polasize++; 
			}
			break;
		}
		X=f(X);
	}
	if(polasum==0){
		cout<<sum<<'\n';
	}else{
		ll size=v.size()-1;
		ll sisa=(N-size)%polasize;
		for(long long j=arr[X]; j<sisa+arr[X]; j++){
			sisasum+=v[j];
		}
		cout<<sum+(N-size)/polasize*polasum+sisasum<<'\n';
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	Input();
	Solve();
}

Measured memory_bytes: 4644
import sys

sys.setrecursionlimit(10 ** 7)

f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    L = input()
    n = len(L)

    res = 0
    cnt = 0
    for i in range(n):
        if L[i] == "1":
            rest = n - (i + 1)
            res += pow(2, cnt, mod) * pow(3, rest, mod) % mod
            res %= mod
            cnt += 1

    res += pow(2, cnt, mod)
    print(res % mod)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<cctype>
using namespace std;

int main(){
    
    string a, b;
    getline(cin, a);
    
    for(int i=0; i<a.size(); i++){
        if(islower(a[i])){
            b += toupper(a[i]);
        }
        else if(isupper(a[i])){
            b += tolower(a[i]);
        }
        else{
            b += a[i];
        }
    }
    cout<<b<<endl;
    
    return 0;
}


Measured memory_bytes: 3188
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int top,s[1000];
void push(int x){
	s[++top]=x;
	
} 
int pop(){
	top--;
	return s[top+1];
}
int main(){
	int a,b;
	top=0;
	char s[100];
	while(scanf("%s",s)!=EOF){
		if(s[0]=='+'){
			a=pop();
			b=pop();
			push(a+b);
		}else if(s[0]=='-'){
			b=pop();
			a=pop();
			push(a-b);
		}else if(s[0]=='*'){		
		    a=pop();
			b=pop();
		    push(a*b);
		}else{
			push(atoi(s));
		}
	}
	printf("%d\n",pop());
	return 0;
}


Measured memory_bytes: 2120
a, b = map(int, input().split())
c = []
if a > b:
    a, b = b, a
if b%a == 0:
    print(a)
else:
    while True:
        for i in range(a):
            x = i + 2
            #print(a, x)
            if a%x == 0:
                if b%x == 0:
                    c.append(x)
                    a = a//x
                    b = b//x
                    #print(c)
                    break
                elif b%(a//x) == 0:
                    c.append(a//x)
                    a = x
                    b = b//(a//x)
                    #print(c)
                    break
            #if x%1000 == 0:
                #print(x)
            if x > a**0.5:
                break
        if x > a**0.5:
            break
    s = 1
    for j in c:
        s = s * j
    print(s)



Measured memory_bytes: 5648
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1000000000
#define mod 1000000007
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
int kaijo(int n){
	int ans=1;
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=mod;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%mod;
	return modpow(a,b/2)*modpow(a,b/2)%mod;
}
int n,a[11];
signed main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	int sum=0;
	rep(i,n-1){
		sum+=a[i];
	}
	if(sum<=a[n-1])puts("No");
	else puts("Yes");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>

using namespace std;

vector<int> sq;
int N, D;
int X[10][10];

void init()
{
	for (int i = 0; i*i <= 16000; ++i)
	{
		sq.push_back(i*i);
	}
}

int main()
{
	init();
	
	scanf("%d %d", &N, &D);
	
	for (int i = 0; i < N; ++i)
	{
		for (int j = 0; j < D; ++j) scanf("%d", &X[i][j]);
	}

	int ans = 0;

	for (int i = 0; i < N; ++i)
	{
		for (int j = i + 1; j < N; ++j)
		{
			int dist = 0;

			for (int k = 0; k < D; ++k) dist += (X[i][k] - X[j][k])*(X[i][k] - X[j][k]);
			auto it = lower_bound(sq.begin(), sq.end(), dist);
			if (*it == dist) ans++;
		}
	}

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

	return 0;
}

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

ans = 0
for i in A:
    sumS = C
    for j in range(M):
        sumS += B[j]* i[j]
    if sumS > 0:
        ans += 1
print(ans)

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

const int inf = 1 << 25;

int cost[100][100][2];
int d[100];
bool used[100];
int m;

int dijkstra(int s, int e, int r) {
  fill(d, d+m, inf);
  fill(used, used+m, false);
  d[s] = 0;

  while(true) {
    int v = -1;

    for(int u = 0; u < m; u++) {
      if(!used[u] && (v == -1 || d[u] < d[v])) v = u;
    }

    if(v == -1) break;

    used[v] = true;

    for(int u = 0; u < m; u++) {
      d[u] = min(d[u], d[v] + cost[v][u][r]);
    }
  }
  return d[e];
}

int main() {
  int n;
  while(cin >> n >> m, n+m) {
    for(int i = 0; i < 100; i++) {
      for(int j = 0; j < 100; j++) {
        cost[i][j][0] = cost[j][i][1] = inf;
      }
    }

    for(int i = 0; i < n; i++) {
      int a, b, c, t; cin >> a >> b >> c >> t;
      a--, b--;
      cost[a][b][0] = cost[b][a][0] = c;
      cost[a][b][1] = cost[b][a][1] = t;
    }

    int k; cin >> k;
    while(k--) {
      int p, q, r; cin >> p >> q >> r;
      cout << dijkstra(p-1, q-1, r) << endl;
    }
  }
}

  

Measured memory_bytes: 1236
//#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

//ifstream cin("x.in"); ofstream cout("x.out");

string s;

int main() {
    cin.sync_with_stdio(false);

    int n;
    cin >> n;

    int ans = 1, ansimp = 1;
    for (int i = 1; i <= n; ++ i) {
        int x;
        cin >> x;

        int sol = 0, sol2 = 0;
        for (int j = -1; j < 2; ++ j) {
            if ((x + j) % 2 == 1)
                ++ sol2;
            ++ sol;
        }
        ans *= sol;
        ansimp *= sol2;
    }
    cout << ans - ansimp << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main{
    final static long mod = 1000000007;
    //
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] boss = new int[n + 1];
        for(int i = 0; i < n - 1; i++){
            boss[sc.nextInt()]++;
        }
        for(int i = 1; i <= n; i++){
            System.out.println(boss[i]);
        }
    }
}


Measured memory_bytes: 70300
#include<iostream>
using namespace std;
int main(){
	int n;
	int a,b,c;
	int i,j,k;
	long long int s=0;
	cin>>n;
	b=1;
	for(i=0;i<n;i++){
		cin>>a;
		if(i==0){
			s+=a-1,b=2;
			continue;
		}
		if(a==b)b++;
		else s+=(a-1)/b;
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
    int a,b,c,d;
    string str1,str2;
    cin >> a >> b;
    c = a;
    d = b;
    rep(i,a-1){
        d *= 10;
        d += b;
    }
    rep(i,b-1){
        c *= 10;
        c += a;
    }
    str1 = to_string(c);
    str2 = to_string(d);
    
    if(str1.compare(str2) < 0){
        cout << str1 <<endl;
    }else{
        cout << str2 <<endl;
    }
} 


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

using namespace std;

int L;

double Volume(double x, double y, double z) {
    return x * y * z;
}

int main() {
    
    cin >> L;
    double answer;

    double x, y, z;
    x = y = z = (double)L / 3.0;

    answer = Volume(x, y, z);

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

    return 0;

}

Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long int ll;
typedef pair<ll,pair<int,int> > T3;
int a[100005],b[100005];
vector<int> G[100005];
ll Min[100005][3];

void bfs(int s){
	queue<T3> pq;
	Min[s][0]=0;
	pq.push(make_pair(0,make_pair(s,0)));
	while(pq.size()){
		auto now=pq.front();pq.pop();
		int p=now.second.first;
		int q=now.second.second;
		if(now.first>Min[p][q])continue;
		for(int i=0;i<G[p].size();i++){
			int next=G[p][i];
			if(Min[next][(q+1)%3]>Min[p][q]+1){
				Min[next][(q+1)%3]=Min[p][q]+1;
				pq.push(make_pair(Min[next][(q+1)%3],make_pair(next,(q+1)%3)));
			}
		}
	}
}

int main(){
	int n,m; cin >> n >> m;
	for(int i=0;i<m;i++){
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		G[a[i]].push_back(b[i]);
	}
	int s,t; cin >> s >> t;
	s--; t--;
	for(int i=0;i<100005;i++){
		for(int j=0;j<3;j++){
			Min[i][j]=1e18;
		}
	}
	bfs(s);
	if(Min[t][0]==1e18){
		cout << -1 << endl;
	}
	else{
		cout << Min[t][0]/3 << endl;
	}
	return 0;
}

Measured memory_bytes: 8832
def rotate(dice,d):
    if d == "N":
        temp = dice[0]
        dice[0] = dice[1]
        dice[1] = dice[5]
        dice[5] = dice[4]
        dice[4] = temp
    elif d == "E":
        temp = dice[0]
        dice[0] = dice[3]
        dice[3] = dice[5]
        dice[5] = dice[2]
        dice[2] = temp
    elif d == "W":
        temp = dice[0]
        dice[0] = dice[2]
        dice[2] = dice[5]
        dice[5] = dice[3]
        dice[3] = temp
    elif d == "S":
        temp = dice[0]
        dice[0] = dice[4]
        dice[4] = dice[5]
        dice[5] = dice[1]
        dice[1] = temp
    elif d == "R":
        temp = dice[1]
        dice[1] = dice[2]
        dice[2] = dice[4]
        dice[4] = dice[3]
        dice[3] = temp
    return dice

dice = input().split()
for j in range(int(input())):
    t,f = map(str, input().split())
    flag = False
    i = 0
    while True:
        if dice[0] == t:
            while True:
                if dice[1] == f:
                    print(dice[2])
                    flag = True
                    break
                else:
                    dice = rotate(dice, "R")
        if flag:
            break
        if i%2 == 0:
            dice = rotate(dice, "N")
        else:
            dice = rotate(dice, "E")
        i += 1

Measured memory_bytes: 7840
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n;
    queue<string> q;
    q.push("a");
    set<string> v;
    string s;
    while(!q.empty()){
        s=q.front();
        q.pop();
        m=s.length();
        if(n==m){
            v.insert(s);
        }else{
            int b=0;
            for(int i=0;i<m;i++){
                b=max(b,(s[i]-'a'));
            }
            for(int i=0;i<=b+1;i++){
                q.push(s+char('a'+i));
            }
        }
    }
    for(auto& i:v){
        cout << i <<endl;
    }
    return 0;
}


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

int main(){
    string s,t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if (s < t){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

vector<pair<int, int>> primeFact(int n) {
  vector<pair<int, int>> res;
  for (int i = 2; i * i <= n; i++) {
    int divcnt = 0;
    if (n % i == 0) {
      do {
        divcnt++;
        n /= i;
      } while (n % i == 0);
      res.emplace_back(i, divcnt);
    }
  }
  if (n != 1)
    res.emplace_back(n, 1);
  return res;
}

signed main() {
  int N;
  cin >> N;

  map<int, int> m;
  FOR(i, 1, N+1){
    auto v = primeFact(i);
    for(auto p : v) m[p.first] += p.second;
  }

  int ans = 1;
  for(auto p : m){
    (ans *= p.second+1) %= MOD;
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
import sys

N = int(sys.stdin.readline())

if N in [1, 2, 4, 8, 16, 32, 64]:
    print(N)
else:
    sorted_list = sorted([1, 2, 4, 8, 16, 32, 64, N])[::-1]
    min_index = sorted_list[sorted_list.index(N) + 1]
    print(min_index)


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int Q;
long a,b,c,d;
long T[31];
main()
{
	cin>>Q;
	T[0]=1;
	for(int i=1;i<=30;i++)T[i]=T[i-1]*3;
	for(;Q--;)
	{
		cin>>a>>b>>c>>d;
		a--,b--,c--,d--;
		if(a>c)swap(a,c);
		if(b>d)swap(b,d);
		long ans=abs(a-c)+abs(b-d);
		long plus=0;
		for(int i=30;i>=1;i--)
		{
			if(a/T[i-1]==c/T[i-1]&&a/T[i-1]%3==1)
			{
				long B=b/T[i-1],D=d/T[i-1];
				if(B>D)swap(B,D);
				while(B%3!=1)B++;
				while(D>=0&&D%3!=1)D--;
				if(B<=D)
				{
					a%=T[i];
					c%=T[i];
					plus=min(min(a,c)+1-T[i-1],2*T[i-1]-max(a,c));
					break;
				}
			}
			if(b/T[i-1]==d/T[i-1]&&b/T[i-1]%3==1)
			{
				long A=a/T[i-1],C=c/T[i-1];
				if(A>C)swap(A,C);
				while(A%3!=1)A++;
				while(C>=0&&C%3!=1)C--;
				if(A<=C)
				{
					b%=T[i];
					d%=T[i];
					plus=min(min(b,d)+1-T[i-1],2*T[i-1]-max(b,d));
					break;
				}
			}
		}
		cout<<ans+plus*2<<endl;
	}
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
using namespace std;

#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, s, n) for (int i = s; i < n; i++)

int main()
{
    int a, b;
    cin >> a >> b;
    if (a <= b)
    {
        cout << a << endl;
    }
    else
    {
        cout << a - 1 << endl;
    }
}

Measured memory_bytes: 256
import Data.List
import Control.Monad

solve n xy = n - m where
  m = maximum . (0:) . map length . group $ sort difs
  difs = [(a-x, b-y) | p@(a,b)<-xy, q@(x,y)<-xy, p/=q]

main = do
  n <- readLn
  xy <- replicateM n read2
  print $ solve n xy

read2 = (\[a,b] -> (a,b)) <$> readWords
readWords = map read . words <$> getLine

Measured memory_bytes: 1532
import sys
#input = sys.stdin.readline

def main():
    s = input()
    l = len(s)
    for i in range(l-1):
        if s[i] == s[i+1]:
            print(i+1,i+2)
            exit()
    
    for i in range(l-2):
        if s[i] == s[i+2]:
            print(i+1,i+3)
            exit()
    
    print(-1,-1)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#include<iostream>
#include<queue>
#include<map>
#define LEN 100
#define BASE 25

using namespace std;

int maps[LEN][LEN];
int off[LEN][LEN];

int checker[4];
int ncheck[4];

map<int, int> points[LEN];

class State {
public:
	char where;
	int enemy;
	int budget;
	int check[4];
	//	State() {}
	State() {check[0]=0;check[1]=0;check[2]=0;check[3]=0;}
	State(char w, int e, int b ) {
		where = w;
		enemy = e;
		budget = b; 
		check[0] = ncheck[0];
		check[1] = ncheck[1];
		check[2] = ncheck[2];
		check[3] = ncheck[3];
	}
};


inline bool operator< ( const State& a, const State& b) {
	if( a.enemy == b.enemy )
		return a.budget > b.budget;
	return a.enemy < b.enemy;
}

inline bool operator> ( const State& a, const State& b) {
	if ( a.enemy == b.enemy )
		return a.budget < b.budget;
	return a.enemy > b.enemy;
}

priority_queue<State, vector<State>, greater<State> > status;

inline void copy ( State now ) {
	checker[0] = now.check[0];
	checker[1] = now.check[1];
	checker[2] = now.check[2];
	checker[3] = now.check[3];
}

inline void ncopy ( ) {
	ncheck[0] = checker[0];
	ncheck[1] = checker[1];
	ncheck[2] = checker[2];
	ncheck[3] = checker[3];
}

inline bool check ( int i ) {
	return 0 == ((1<<(i%25)) & checker[i/BASE]);
}

inline void add ( int i ) {
	ncheck[i/BASE] = ((1<<(i%25)) | checker[i/BASE]);
}

inline void insert ( int i, int e, int b ) {
	
	map<int,int>::iterator itr = points[i].find(e);
	if ( itr == points[i].end() ) {
		points[i][e] = b;
		status.push(State(i,e,b));
	} else if ( (*itr).second < b ) {
		(*itr).second = b;
		status.push(State(i,e,b));
		int min = b;
		while ( itr != points[i].end() ) {
			if ( (*itr).second > min ) {
				min = (*itr).second;
			} else if ( (*itr).second <= min ) {
				(*itr).second = min;
			}
			itr++;
		}
	}
}

int main () {


	while ( true ) {
		int n,m,l;
		cin >> n >> m >> l;

		if ( n == 0 )
			break;

		for ( int i=0; i<n; i++ ) {
			for ( int j=0; j<n; j++ ) {
				maps[i][j] = -1;
				off[i][j] = 0;
			}
			points[i].clear();
		}

		for ( int i=0; i<m; i++ ) {
			int a,b,d,e;
			cin >> a >> b >> d >> e;

			maps[a-1][b-1] = maps[b-1][a-1] = d;
			off[a-1][b-1] = off[b-1][a-1] = e;
		}
		
		for ( int i=0; i<4; i++ ) {
			ncheck[i] = 0;
			checker[i] = 0;
		}

		priority_queue<State, vector<State>, greater<State> > empty;
		status = empty;

		ncheck[0] = 1;
		status.push(State(0,0,l));
		int count = 0;
		while(!status.empty()) {
			State now = status.top();
			status.pop();
			if ( now.where == n-1 ) {
				cout << now.enemy << endl;
				break;
			}

			copy(now);

			for ( int i=0; i<n; i++ ) {
				if ( maps[now.where][i] > 0 ) {

					if ( check( i ) ) {
						ncopy();
						add(i);
						
						int e, b;
						if ( off[now.where][i] == 0 ) {
							e = now.enemy;
							b = now.budget;
							insert(i,e,b);
						} else {
							if ( now.budget - maps[now.where][i] >= 0 ) {
								e = now.enemy;
								b = now.budget - maps[now.where][i];
								insert(i,e,b);
							}
							e = now.enemy + off[now.where][i];
							b = now.budget;
							insert(i,e,b);
						}
					}
				}
			}
		}
	}
}

		

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
const int MAX_V = 101;
const int INF = 1e9;
vector<vector<int>> d(MAX_V, vector<int>(MAX_V,INF));
int V;
struct edge{int from, to, cost;};

void warshall_floyd(){
  rep(k, V){
    rep(i, V){
      rep(j, V) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
  }
}

int main(){
    int n, m;
    cin >> n >> m;
    V = n + 1;
    vector<edge> v;
    rep(i,m){
        int a, b, c;
        cin >> a >> b >> c;
        d[a][b] = c;
        d[b][a] = c;
        v.push_back({a,b,c});
    }
    warshall_floyd();
    int ans = 0;
    rep(i,m) if(d[v[i].from][v[i].to] != v[i].cost) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 50001
#define INF 1e9
 
class YAML{
public:
    string s;
    int state;
    vector<string> next;
};
 
vector<int> space;
YAML yaml[MAX];
 
int getState(string &str,int d,vector<string> &v){
    string now = str.substr(d);
    string s,t;
    int x = -1;
    for(int i = 0 ; i < (int)now.size() ; i++){
	if(now[i] == ':'){ x = d+i+2; break; }
	s += now[i];
    }
    v.push_back(s);
    if(x < (int)str.size()){
	t = str.substr(x);
	v.push_back(t);
	return 1;
    }
    return 0;
}
 
vector<string> make_graph(int cur,int sp){
    int len = space.size();
    vector<string> res;
    if(cur == len || yaml[cur].state == 1) return res;
    int now = cur;
    while(true){
	if(now == len || sp > space[now]) break;
	if(space[now] == INF){ now++; continue; }
	if(sp == space[now]){
	    res.push_back(yaml[now].s);
	    cur = now;
	}else if(sp < space[now]){
	    if(yaml[cur].next.size() == 0){
		yaml[cur].next = make_graph(now,space[now]);
	    }
	}
	now++;
    }
    return res;
}
 
int main(){
    int idx = 1;
    string order,in;
    map<string,int> mp;
    space.push_back(-1);
    yaml[0].s = "->";
    cin >> order; cin.ignore();
    while(getline(cin,in)){
	int cnt = 0;
	for(int i = 0 ; i < (int)in.size() ; i++){
	    if(in[i] == ' '){
		cnt++;
	    }else{ break; }
	}
	space.push_back(cnt);
	vector<string> v;
	yaml[idx].state = getState(in,cnt,v);
	yaml[idx].s = v[0];
	mp[yaml[idx].s] = idx;
	if(yaml[idx].state == 1){
	    yaml[idx].state = 0;
	    yaml[idx].next.push_back(v[1]);
	    idx++;
	    yaml[idx].s = v[1];
	    yaml[idx].state = 1;
	    mp[yaml[idx].s] = idx;
	    space.push_back(INF);
	}
	idx++;
    }
    yaml[0].next = make_graph(1,space[1]);
    string t;
    vector<string> strs;
    for(int i = 0 ; i < (int)order.size() ; i++){
	if(order[i] == '.'){
	    if(!t.empty()){ strs.push_back(t); }
	    t.clear();
	}else{
	    t += order[i];
	}
    }
    strs.push_back(t);
    int now = 0,len = strs.size();
    bool found = true;
    for(int i = 0 ; i < len ; i++){
	vector<string> vec = yaml[now].next;
	bool ok = false;
	for(int j = 0 ; j < (int)vec.size() ; j++){
	    if(vec[j] == strs[i]){
		ok = true;
		break;
	    }
	}
	now = mp[strs[i]];
	if(!ok){
	    found = false;
	    break;
	}
    }
    int size = yaml[now].next.size();
    if(!found || size == 0){
	cout << "no such property" << endl;
    }else{
	if(size != 1){
	    cout << "object" << endl;
	}else{
	    string ans = yaml[now].next[0];
	    if(yaml[mp[ans]].state == 1){
		cout << "string \"" << ans << "\"" << endl;
	    }else{
		cout << "object" << endl;
	    }
	}
    }
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

int main() {
    int N,K;
    cin >> N >> K;
    int cnt = 0;
    REP(i,N){
        int h;
        cin >> h;
        if(h>=K)cnt++;
    }

    cout << cnt << endl;

}



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

int main() {
  long long N,M,V,P;
  cin >> N >> M >> V >> P;
  vector<long long> A(N);
  vector<long long> Asum(N+1);
  for(int i=0;i<N;i++) cin >> A[i];
  A.push_back(1001001001);
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  Asum[0] = 0;
  for(int i=1;i<=N;i++) Asum[i] = A[i]+Asum[i-1];
  
  for(int i=P+1;i<=N;i++){
    if(i!=N) if(A[i]==A[i+1]) continue;
    if(A[P]>A[i]+M || (double)(Asum[i-1]-Asum[P-1]+M*(max((long long)0,V-(N-(i-P)))))/(double)(i-P) > A[i]+M){
      long long ans = i-1;
      while(A[ans]==A[i]) ans--;
      cout << ans << endl;
      return 0;
    }
  }
  
  cout << N << endl;
  return 0;
}


Measured memory_bytes: 2688
r,l=map(int,input().split())
v1,v2=r//2019,l//2019
if v2-v1>=1 or r%2019==0 or l%2019==0:
    print(0)
else:
    ans=2018
    for i in range(r,l):
        for j in range(i+1,l+1):
            ans=min(ans,(i*j)%2019)
    print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int main(){
    int N;
    cin >> N;
    string S[N];
    int P[N];
    string temp_str;
    int temp_int, num;
    Fp(i, 0, N){
        cin >> S[i];
        cin >> P[i];
    }
    Fp(j, 0, N){
        temp_str = "{";
        temp_int = 0;
        num = 0;
        int i = 0;
        while(i != N){
            if(temp_str > S[i]){
                temp_str = S[i];
                temp_int = P[i];
                num = i;
                //cout << j<< ":" << i << ":" << S[i] << endl;
            }else if(temp_str == S[i]){
                if(temp_int < P[i]){
                    temp_int = P[i];
                    num = i;
                    //cout << i << ":" << P[i] << endl;
                }
            }
            i++;
        }
        cout << (num + 1) << endl;
        S[num] = "{{";
        P[num] = 0;
    }
}


Measured memory_bytes: 256
/*氏名：保坂優介, 学籍番号：200441141
  概要：整数を並べ替える*/

#include<stdio.h>

int main(void)
{
    int i, j, k, position[3] = { 0 }, integer[3];       //変数の宣言

    scanf("%d %d %d", &integer[0], &integer[1], &integer[2]);       //入力

    for (i = 0; i < 3; i++)     //3回繰り返す
    {
        for (j = 0; j < 3; j++)     //最大を記録
        {
            if (position[i] < integer[j])       
            {
                k = j;
                position[i] = integer[k];
            }


        }
        integer[k] = 0;     
    }

    printf("%d %d %d\n", position[2], position[1], position[0]);        //出力

    return 0;
}


Measured memory_bytes: 2032
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;

#define MOD 998244353


ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
  
  

int main() {
    string s;
    cin>>s;
    if(s == "AAA" || s == "BBB")puts("No");
    else puts("Yes");
    return 0;
}
    
    



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define out(a) cout<<fixed<<setprecision((a))
typedef long long ll;
int main(){
	ll n,sum=0,mx=-100000000,mn=100000000;
	cin >> n;
	for(int i=0;i<n;i++){
	    ll a;
	    cin >> a;
	    sum += a;
	    mx = max(mx,a);
	    mn = min(mn,a);
	}
	cout << mn << " " << mx << " " << sum << endl;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
const int MAX = 5100000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
signed main(){
  COMinit();
  int A,B,C,D; cin>>A>>B>>C>>D;
  int ans=0;
  REP(i,A,C){
    ans+=COM(i+1+D,D);
    ans%=MOD;
    ans+=MOD;
    ans-=COM(i+B,B-1);
    ans%=MOD;
  }
  cout<<ans<<endl;
  }



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



int main() {
    int n;
    cin >> n;
    
    map<string,ll> m;
    rep(i,n) {
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        
        m[s]++;
    }
    
    ll ans = 0;
    for(auto x : m) {
        if(x.second > 1)
            ans += x.second * (x.second - 1) / 2;
    }
    
    cout << ans << endl;
    
    
    
    return 0;
}




Measured memory_bytes: 11292
import java.util.*;

class Main{
  static Scanner sc = new Scanner(System.in);
  public static void main(String args[]){
    long h=sc.nextInt();
    long w=sc.nextInt();
    if(h%3==0||w%3==0){
      System.out.println(0);
      return;
    }
    long min=Long.MAX_VALUE;
    long dh=h/3;
    min=Long.min(sa(dh,h,w),min);
    dh++;
    min=Long.min(sa(dh,h,w),min);
    long dw=w/3;
    min=Long.min(sa(dw,w,h),min);
    dw++;
    min=Long.min(sa(dw,w,h),min);
    System.out.println(min);
  }
  static long sa(long d,long da, long b){
    return Long.max(sag(d,da,b),sal(d,da,b));
  }
  static long sag(long d,long da,long b){
    return Math.abs(d*b-div2g(da-d,b));
  }
  static long sal(long d,long da,long b){
    return Math.abs(d*b-div2l(da-d,b));
  }
  static long div2g(long h,long w){
    if(h%2==0||w%2==0){
      return h*w/2;
    }
    return (Long.max(w,h)/2+1)*Long.min(w,h);
  }
  static long div2l(long h,long w){
    if(h%2==0||w%2==0){
      return h*w/2;
    }
    return (Long.max(w,h)/2)*Long.min(w,h);
  }
}

Measured memory_bytes: 23764