akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
#define all(x) (x).begin(),(x).end()

int main() {
	int n;
    cin>>n;
    
  	vector <int> a(n);
  	int t[n];
  	rep(i,n){
      cin>>a[i];
    }
  
   vector<int> rev(n);
  for(int i=0;i<n;i++)rev[a[i]-1]=i+1;
  for(int i=0;i<n;i++)cout<<rev[i]<<endl;
    	
  
}

Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  for(int i=0;i<n;i++)
    cin>>a.at(i);
  for(int i=0;i<n;i++)
    cin>>b.at(i);
  for(int i=1;i<n;i++)
    cin>>c.at(i);
  int s=b.at(a.at(0)-1);
  for(int i=1;i<n;i++){
    s+=b.at(a.at(i)-1);
    if(a.at(i)==a.at(i-1)+1)
      s+=c.at(a.at(i)-1);
  }
  cout<<s<<endl;
}

Measured memory_bytes: 256
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/icl/interval_map.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
namespace icl = boost::icl;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> D;

  invec<int> c(26);
  vector<vector<int>> s(D, vector<int>(26));
  for (auto&& i : s)
    for (auto&& j : i)
      cin >> j;
  invec<int> t(D);
  int last[26] = {0};
  int r = 0, cost = 0;

  REP(i, 26)
    cost += c[i];
  const int tier = cost;
  REP(i, D) {
    const int plan = t[i] - 1;
    r += s[i][plan];
    cost -= c[plan] * (i + 1 - last[plan]);
    last[plan] = i + 1;
    r -= cost;
    cost += tier;
    cout << r << endl;
  }
}

template<typename T> void plot(const T& func) { cout << setprecision(9) << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}



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

int main()
{
  string s;
  cin >> s;
  int sum = 0;
  int num = 0;
  int k = 1;
  for (int i = 1; i < (int)s.size(); i++) k *= 10;
  for (int i = 0; i < (int)s.size(); i++) {
    sum += (int)(s[i] - '0');
    num += (int)(s[i] - '0') * k;
    k /= 10;
  }
  if (num % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main(){
    int N;
    cin >> N;
    int A[N];
    int i,j;
    for(i=0; i<N; i++){
        cin >> A[i];
    }
    bool safe[1000001];
    for(i=1; i<1000000; i++){
        safe[i]=1;
    }
    sort(A,A+N);
    for(i=0; i<N; i++){
        if(i<N-1){
            if(A[i]==A[i+1]){
                safe[A[i]]=0;
                continue;
            }
        }
        for(j=2*A[i]; j<=1000000; j+=A[i]){
            safe[j]=0;
        }
    }
    int counta=0;
    for(i=0; i<N; i++){
        if(safe[A[i]]==1){
            counta++;
        }
    }
    cout << counta << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 5388
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;
typedef pair<ll, ll> PL;
int main() {
  int n;
  ll W;
  cin >> n >> W;
  vector<ll> v(n), w(n);
  rep(i,n) cin >> v[i] >> w[i];
  int m = n - n / 2;
  n /= 2;

  vector<PL> p; 
  vector<ll> idx;
  
  for (int s = 0; s < (1 << n); s++) {
    ll sumv = 0, sumw = 0;
    for (int i = 0; i < n; i++) {
      if (s & (1 << i)) {
        sumv += v[i];
        sumw += w[i];
      }
    }
    idx.emplace_back(sumw);
    p.emplace_back(make_pair(sumw, sumv));
  }
  
  sort(idx.begin(), idx.end());
  idx.erase(unique(idx.begin(), idx.end()), idx.end());
  vector<ll> cum(idx.size() + 2, 0);
  
  for (int i = 0; i < p.size(); i++) {
    int j = lower_bound(idx.begin(), idx.end(), p[i].first) - idx.begin();
    cum[j + 1] = max(cum[j], p[i].second);
  }
  for (int i = 0; i < idx.size(); i++) {
    cum[i + 1] = max(cum[i], cum[i + 1]);
  }

  ll res = 0;
  
  for (int s = 0; s < (1 << m); s++) {
    ll sumw = 0, sumv = 0;
    for (int i = 0; i < m; i++) {
      int j = i + n;
      if (s & (1 << i)) {
        sumw += w[j];
        sumv += v[j];
      }
    }
    ll x = W - sumw;
    if (x < 0) continue;
    int r = upper_bound(idx.begin(), idx.end(), x) - idx.begin();
    res = max(res, sumv + cum[r]);
  }
  
  cout << res << endl;
  return 0;
} 


Measured memory_bytes: 35520
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
typedef pair<int,int> pii;
const int mod = (int) 1000000007;
const int inf = (int) 2e18;
 
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int n;
    cin >> n;
    int t = (n+1000-1) / 1000;
    int ans = 1000*t-n;
    cout << ans << "\n";
}

Measured memory_bytes: 3648
use std::io;

fn main() {
    let (d, n) = {
        let i = read::<i32>();
        (i[0], i[1])
    };

    let mut ans = (100f64.powi(d) as i32) * n;
    if n == 100 {
        if d == 0 { ans = 101; }
        if d == 1 { ans = 10100; }
        if d == 2 { ans = 1010000; }
    }
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
/*

 Remember, Hope is a good thing... May be the best of things... and No Good thing ever Dies !!!

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios::sync_with_stdio(0); cout.tie(0);
#define endl "\n"
#define MOD 1000000007
const ll inf=(1LL<<60)-1;
int dx[]= {-1,1,0,0};
int dy[]= {0,0,-1,1};
void solve()
{
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
   ll n,sum=0;
   cin>>n;
   vector<ll>a(n);
   for(ll i=0;i<n;i++)
    cin>>a[i];
   for(ll i=0;i<n-1;i++)
   {
       if(a[i]>a[i+1])
       {
           sum+=(a[i]-a[i+1]);
           a[i+1]=a[i];
       }
   }
   cout<<sum<<endl;
}
int main()
{
    IOS;
    //ll t;
    //cin>>t;
    //while(t--)
    solve();
    return 0;
}


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

using namespace std;

string N;
int A, B, C, D;

int calc(int a, int b)
{
    if (0 == a)
    {
        return b;
    }else
    {
        return -1 * b;
    }
    
}

char op(int a)
{
    if (0 == a)
    {
        return'+';
    }else
    {
        return'-';
    }
    
}

int main(int argc, char const *argv[])
{
    
    cin >> N;
    A = (int)(N[0] - '0');
    B = (int)(N[1] - '0');
    C = (int)(N[2] - '0');
    D = (int)(N[3] - '0');

    int sum;
    for (int i = 0; i < 2; i++)
    {
        for (int j = 0; j < 2; j++)
        {
            for (int k = 0; k < 2; k++)
            {
                sum = A + calc(i, B) + calc(j, C) + calc(k, D);
                if (7 == sum)
                {
                    cout << A << op(i) << B << op(j) << C << op(k) << D << "=7" << endl;
                    return 0;
                }
                
            }
               
        }
        
    }
    
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}


// end of Template

int n,ans;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

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

    cin>>n;
    for(int i=1;i<=n;i++){
        int l,r;cin>>l>>r;ans+=(r-l+1);
    }
    cout<<ans<<newl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int s[100000], t[50000], n, q, i, j, count = 0, left, right, mid;
  
  scanf("%d",&n);
  
  for(i = 0; i < n; i++)
    {
      scanf("%d",&s[i]);
    }

  scanf("%d",&q);

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

  for(i = 0; i < q; i++)
    {
      left = 0;
      right = n;
      while(left < right)
	{
	  mid = (left + right)/2;
	  if(s[mid] == t[i])
	    {
	      count++;
	      break;
	    }
	  else if(t[i] < s[mid])right = mid;
	  else left = mid + 1;
	}
    }

  printf("%d\n",count);
  
  return 0;
}



Measured memory_bytes: 2380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long int
#define pii pair<int,int>
#define pll pair<ll,ll>
#define plll pair<ll,pll>
#define Pb push_back
#define Mp make_pair
#define ff first
#define ss second
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN
#define MOD (ll)1000000007


signed main()
{
    IOS;
    int k,x;
    cin >> k >> x;
    if(k*500 >= x) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i ,a, n) for (long long int i=a;i<=n;i++)
#define pb  push_back
#define mp make_pair
#define fp first
#define sp second
#define be(v) v.begin(),v.end()
typedef long long ll;
typedef vector<ll> vi ;
typedef vector<pair<ll , ll > >  vpi ;
const int ma1=3e5+5;
string no="NO",yes="YES";
const unsigned int MOD = 1000000007;
int max_char=26;



int main()
    {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;

    while(t--)
    {
        ll n,m;
        cin>>n>>m;
        ll sum=0;
        for(ll i=0;i<n;i++)
        {
            ll x,y;
            cin>>x>>y;
            if(sqrt(x*x+y*y)<=m)
                sum++;
        }
        cout<<sum;
    }
}











Measured memory_bytes: 3696
#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>

#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
#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 bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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


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

  int MAX = 19;
  int dp[MAX][MAX];
  REP(i, MAX) REP(j, MAX) dp[i][j] = 0;

  REP(i, N){
    string a;
    cin >> a;
    int pos = a.find('.');
    if(pos == -1){
      a += "000000000";
    }else{
      a = a.substr(0, pos)+a.substr(pos+1);
      int M = 9-(a.size()-pos);
      REP(i, M){
        a += "0";
      }
    }

    int A = stoll(a);

    int two = 0;
    while(A%2 == 0){
      two++;
      A /= 2;
    }
    int five = 0;
    while(A%5 == 0){
      five++;
      A /= 5;
    }
    chmin(two, 18ll); chmin(five, 18ll);
    dp[two][five]++;
  }

  int ans = 0;
  REP(i, MAX) REP(j, MAX) REP(k, MAX) REP(l, MAX){
    if(i == k && j == l) continue;
    if(i+k >= 18 && j+l >= 18){
      ans += dp[i][j]*dp[k][l];
    }
  }
  ans /= 2;

  REP(i, MAX) REP(j, MAX){
    if(i*2 >= 18 && j*2 >= 18){
      ans += dp[i][j]*(dp[i][j]-1)/2;
    }
  }
  
  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  int n, k, s = 0; cin >> n >> k;
  v1i v(n); rep(i, n) cin >> v[i];
  sort(v.begin(), v.end());
  rep(i, k) s += v[i];
  cout << s << "\n";
  return 0;
}

Measured memory_bytes: 3628
n = int(input())
s = [int(input()) for i in range(0, n)]

if sum(s) % 10 != 0:
    print(sum(s))
else:
    flag = False
    for si in sorted(s):
        if si % 10 != 0:
            flag = True
            print(sum(s) - si)
            break
    if not flag:
        print(0)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define FastRead

using namespace std;
int main()
{
    FastRead
    long long int n,i,last,num,first,sum=0,j,c[10][10]={0};
    cin>>n;

    for(i=1;i<=n;i++)
    {
        last=i%10;
        num=i;
        while(num!=0)
        {
            first=num%10;
            num=num/10;
        }
        c[first][last]++;
    }
    for(i=0;i<10;i++)
    {
        for(j=0;j<10;j++)
        {
            sum=sum+(c[i][j]*c[j][i]);
        }
    }
    cout<<sum;
    return 0;
}


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

using namespace std;
#define MOD 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define popb pop_back()
#define popf pop_front()
#define ff first
#define ss second
#define vl vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vll vector< pair<ll,ll> >
#define vii vector< pair<int,int> >
#define viii vector< tuple <int,int,int> >
#define vlll vector< tuple <ll,ll,ll> >
#define vvl vector<vector<ll>>
#define vv vector<vector<int>>
#define all(v) v.begin(),v.end()
#define sqrt sqrtl
#define cbrt cbrtl
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mapcl map<char,ll>
#define mapci map<char,int>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define seti set<int>
ifstream fin("input.txt");
ofstream fout("output.txt");

int gcd(int a,int b){while (a&&b)a>b?a%=b:b%=a;return a+b;}
ll pows(int a , int b){ll res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}

vi vis(100001,0);
vi adj[100001];

int main()
{	
    std::ios::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);
    int n;cin>>n;
    vi a(n),b(n-1);
    for(int i=0; i<n-1; ++i)
    	cin>>b[i];
    a[0]=b[0];
    for(int i=0; i<n-1; ++i)
    {
    	a[i+1]=b[i];
    	if(a[i]>a[i+1])
    		a[i]=a[i+1];
    }
    int sum=0;
    for(int i=0; i<n; ++i)
    	sum+=a[i];
    cout<<sum<<"\n";
}

Measured memory_bytes: 2944
import Foundation

let ND = readLine()!.split(separator: " ").compactMap { Int($0) }
let n = ND[0]
let d = ND[1]
let XYN = (1...n).map { _ in readLine()!.split(separator: " ").compactMap { Int($0) } }

var count = 0
for i in 0..<XYN.count {
    let x = Double(XYN[i][0])
    let y = Double(XYN[i][1])
    if pow(pow(x, 2) + pow(y, 2), 0.5) <= Double(d) {
        count += 1
    }
}
print(count)


Measured memory_bytes: 27664
#include<iostream>
#include<algorithm>
#include<cmath>
#define int long long
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
int gcd(int a,int b){
	while(a>1||b>1){
		a=a%b;
		if(a%b==0){
			return b;
			break;
		}	
		b=b%a;
		if(b%a==0){
			return a;
			break;
		}
	}
	return 1;
}
signed main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int cb=(b/c)-((a-1)/c);
	int db=(b/d)-((a-1)/d);
	int lgn=c*d/gcd(c,d);
	int cdb=(b/lgn)-((a-1)/lgn);
	c(b-a+1-cb-db+cdb)
}	


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A,B;
    cin >> A >> B;
    if(A > B) swap(A,B);
    if(A == 1 && B == 2){
        print(3);
    }else if(A == 1 && B == 3){
        print(2);
    }else{
        print(1);
    }
    


}

Measured memory_bytes: 256
public class B
{
  public static void Main()
  {
    System.Console.ReadLine();
    string[] s = System.Console.ReadLine().Split();
    int[] num = new int[s.Length];
    for(int i = 0; i < num.Length; i++)
    {
      num[i] = int.Parse(s[i]);
    }
    int count = 0;
    bool isOdd = false;
    while(true)
    {
      for(int i = 0; i < num.Length; i++)
      {
        if(num[i] % 2 == 1){
          isOdd = true;
          break;
        }
      }
      if(isOdd)break;
      for(int i = 0; i < num.Length; i++)
      {
        num[i] = num[i] >> 1;
      }
      count++;
    }
    System.Console.WriteLine(count);
  }
}

Measured memory_bytes: 11092
import java.io.*;
import java.util.*;
public class Main
{
  public static void main (String[] args)
  {
    int count =0;
    Scanner reader = new Scanner(System.in);
    int a=reader.nextInt();
for(int i=0;i<3;i++){
if(a%2==1)
count++;
  a=a/10;
  }
  System.out.print(count);
}
}

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

int main(){
  char a[3];
  cin >> a;
  
  bool ans = true;
  for(int i=0; i<3; i++){
    if(a[i]=='7'){
      cout << "Yes" << endl;
      ans = false;
      break;
    }
  }
  if(ans) cout << "No" << endl;
}

Measured memory_bytes: 3556
#include <iostream>
int main(){
  int h,w;std::cin>>h>>w;
  char g[101][101];
  for(int i=0;i<h;++i){
    for(int j=0;j<w;++j){
      std::cin >> g[i][j];
    }
  }
  int hv[101]={},wv[101]={},f;
  for(int i=0;i<h;++i){
    f=0;
    for(int j=0;j<w;++j){f=(g[i][j]=='#'?1:f);}
    hv[i]=f;
  }
  for(int i=0;i<w;++i){
    f=0;
    for(int j=0;j<h;++j){f=(g[j][i]=='#'?1:f);}
    wv[i]=f;
  }
  for(int i=0;i<h;++i){
    for(int j=0;j<w;++j){if(hv[i]&wv[j]){std::cout<<g[i][j];}}
    if(hv[i]){std::cout<<"\n";}
  }
}
    

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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; }
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;}

int main(){
  ll X, K, D; cin >> X >> K >> D;
  X = abs(X);
  ll pt = X/D;
  ll mt = X/D+1;
  ll ans;
  if(pt<=K){
    if(pt%2==K%2 || mt>K) ans = X-pt*D;
    else ans = abs(X-mt*D);
  }
  else{
    ans = X-K*D;
  }
  cout << abs(ans) << endl;
  return 0;
}


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

int min(int a, int b){
	return a <= b ? a : b;
}

int grundy(int X, int K){
	if(X < K){
		return 0;
	}
	else if(X % K == 0){
		return X / K;
	}
	else{
		int fl = X / K;
		int t = (X - K * fl) / (fl + 1);
		return grundy(min(X - fl - 1, X - t * (fl + 1)), K);
	}
}

int main(){
	int N, A, K, i, g = 0;
	scanf("%d", &N);
	for(i = 0; i < N; i++){
		scanf("%d%d", &A, &K);
		g ^= grundy(A, K);
	}
	if(g == 0){
		printf("Aoki\n");
	}
	else{
		printf("Takahashi\n");
	}
	return 0;
}

Measured memory_bytes: 128
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())

k = I()
a = 7
if k%2 == 0:
    print(-1)
    exit()
for i in range(10**6):
    if a%k == 0:
        print(i+1)
        exit()
    a = (a*10 + 7)%k

print(-1)


Measured memory_bytes: 72768
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

string maxstr(string S,string T) {
  if (S.size() > T.size()) return S;
  else if (S.size() < T.size()) return T;
  else {
    rep(i,S.size()) {
      if (S[i] > T[i]) return S;
      else if (S[i] < T[i]) return T;
    }
    return S;
  }
}

int W,H;
vector<string> C;
vector<vector<bool>> check;

string dfs(string str, int y, int x) {
  check[y][x] = true;
  str.push_back(C[y][x]);
  string S = str;
  if (y + 1 < H) {
    if (C[y+1][x] - '0' >= 0 && C[y+1][x] - '0' < 10) S = dfs(str,y+1,x);
  }
  if (x + 1 < W) {
    if (C[y][x+1] - '0' >= 0 && C[y][x+1] - '0' < 10) S = maxstr(S,dfs(str,y,x+1));
  }
  return S;
}

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); //入出力高速化
  int N; cin >> N;
  vector<int> A(N);
  rep(i,N) cin >> A[i];
  
  bool flag = true;
  ll count = 0;
  for (int i = N-1; i >= 0; i--) {
    if (i == 0) {
      if (A[i] > 0) flag = false;
    } else {
      if (A[i] > A[i-1] + 1) {
        flag = false;
        break;
      } else if (A[i] <= A[i-1]) count += A[i];
      else count++;
    }
  }
  cout << (flag ? count : -1) << endl;
}

Measured memory_bytes: 1024
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 998244353;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    string s;
    cin >> s;
    vector<int> r, b;
    rep(i, SZ(s)){
        if(s[i] == '0'){
            r.push_back(i);
            r.push_back(i);
        }
        if(s[i] == '1'){
            r.push_back(i);
            b.push_back(i);
        }
        if(s[i] == '2'){
            b.push_back(i);
            b.push_back(i);
        }
    }

    auto dp = initVec2<int>(SZ(r) + 1, SZ(b) + 1);
    dp[0][0] = 1;
    rep(i, SZ(r) + 1){
        rep(j, SZ(b) + 1){
            if(i < SZ(r) && r[i] <= i + j){
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %= MOD;
            }
            if(j < SZ(b) && b[j] <= i + j){
                dp[i][j+1] += dp[i][j];
                dp[i][j+1] %= MOD;
            }
        }
    }
    cout << dp[SZ(r)][SZ(b)] << endl;

    return 0;
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

int N, T, now;

int main()
{
    cin >> N >> T;
    lint ans = 0;
    int prev = -T;
    for (int i=0; i<N; i++)
    {
        cin >> now;
        ans += min(T, now-prev);
        prev = now;
    }
    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <ll, ll> dl;
typedef pair <int, int> ii;
typedef pair <ll, ll> dll;
typedef vector <ii> vii;
typedef vector <vii> graph;

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

    int n;
    cin >> n;
    ll a[n];
    ll b[n];
    for (int i = 0; i < n; ++i)
    {
    	cin >> a[i];
    }
    for (int i = 0; i < n; ++i)
    {
    	cin >> b[i];
    }
    int dir[n];
    ll suma = 0;
    for (int i = 0; i < n; ++i)
    {
    	dir[i] = a[i] - b[i];
    	suma += dir[i];
    }
    if (suma >= 0) {
    	sort(dir, dir + n);
    	suma = 0;
    	int cont = 0;
    	for (int i = 0; i < n; ++i)
    	{
    		if (dir[i] >= 0) break;
    		suma += dir[i];
    		cont++;
    	}
    	for (int i = n - 1; suma < 0 && i > 0; --i)
    	{
    		cont++;
    		suma += dir[i];
    	}
    	cout << cont << "\n";
    } else {
    	cout << "-1\n";
    }
	return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e6+5;
const ll mod=1e9+7;
ll F[N],I[N];
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
ll f(ll a,ll b)
{
    ll k=0;
    while(b)
    {
        if(b&1) k=(k+a)%mod;
        a=(a+a)%mod;
        b>>=1;
    }
    return k;
}

void init(){
    F[0]=1;
    ll s=1;
    for(int i=1;i<=N;i++){
        s=f(s,i);
        F[i]=s;
    }
    I[N]=power(F[N],mod-2);
    for(int i=N;i--;){
        I[i]=f(I[i+1],i+1);
    }
}

ll C(ll n, ll k){
    return f(f(F[n],I[n-k]),I[k]);
}

main(){
    init();
    ll k;
    string s;
    cin>>k>>s;
    ll len=s.size(),sum=k+len,ans=0;
    for(ll i=len;i<=sum;i++) ans=(ans+C(sum,i)*power(25,sum-i))%mod;
    cout<<ans;
}


Measured memory_bytes: 36568
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll mod = 1e9 + 7;

ll powll(ll x, ll y){
    x %= mod;
    ll res = 1LL;
    while(y){
        if (y & 1LL)
            res *= x;
        res %= mod;
        x = (x*x) % mod;
        y >>= 1LL;
    }
    return res;
}

ll divll(ll x, ll y){
    x %= mod;
    return (x * powll(y,mod-2)) % mod;
}

int main(void){
    int n, k;
    cin >> n >> k;
    vector<PL> p(n);
    int z = 0;
    REP(i,n){
        ll x;
        cin >> x;
        if (x == 0) z++;
        p[i] = PL(abs(x), x);
    }
    sort(ALL(p));
    reverse(ALL(p));
    int sgn = 1;
    ll ans = 1;
    REP(i,k){
        ll x = p[i].second;
        if (x == 0){
            cout << 0 << endl;
            return 0;
        }
        ans = (ans * abs(x)) % mod;
        if (x < 0) sgn *= -1;
    }
    if (sgn == 1){
        cout << ans << endl;
        return 0;
    }
    ll posm = mod, negm = mod;
    ll posn = mod, negn = mod;
    FORR(i,k-1,0){
        ll x = p[i].second;
        if (x > 0 && posm == mod) posm = x;
        if (x < 0 && negm == mod) negm = abs(x);
    }
    FOR(i,k,n-1){
        ll x = p[i].second;
        if (x > 0 && posn == mod) posn = x;
        if (x < 0 && negn == mod) negn = abs(x);
    }
    // cout << posm << " " << negm << endl;
    bool n2p = (negm != mod) && (posn != mod);
    bool p2n = (posm != mod) && (negn != mod);
    ll ansn2p = (divll(ans, negm) * posn) % mod;
    ll ansp2n = (divll(ans, posm) * negn) % mod;
    // cout << ans << endl;
    // cout << ansn2p << " " << ansp2n << endl;
    if (n2p && p2n){
        if (posn * posm > negn * negm) ans = ansn2p;
        else ans = ansp2n;
    }else if (n2p){
        ans = ansn2p;
    }else if (p2n){
        ans = ansp2n;
    }else if (z > 0){
        ans = 0;
    }else{
        ans = 1;
        REP(i,k) ans = (ans * p[n - 1 - i].first) % mod;
        ans = (mod - ans) % mod;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6424
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
double EPS=1e-10;
int INF=1e9;
double dp[100][5001];
int v[100],e1[100],e2[100];
int main(){
      int x,y,z;
      while(cin>>x>>y>>z&&(x||y||z)){
            REP(i,x)cin>>v[i];
            REP(i,100)e1[i]=e2[i]=0;
            REP(i,z){
                  int a,b,c;
                  cin>>a>>b>>c;
                  e1[a]=b;
                  e2[a]=c;
            }
            REP(i,y+1)REP(j,5001)dp[i][j]=0.0;
            dp[0][0]=1.0;
            int t,s;
            REP(i,y){
                  REP(j,5001){
                        if(dp[i][j]==0.0)continue;
                        REP(k,x){
                              t=min(y,i+v[k]);
                              s=j;
                              if(e1[t]==1){
                                    t=min(y,t+e2[t]);
                              }else if(e1[t]==2){
                                    s+=e2[t];
                              }else if(e1[t]==3){
                                    s=max(0,s-e2[t]);
                              }

                              dp[t][s]+=dp[i][j]*(1.0/x);
                        }
                  }
            }
            double ans=0.0;
            /*REP(i,50){
                  REP(j,100)cout<<dp[i][j]<<" ";cout<<endl;
            }*/
            REP(i,5001)ans+=dp[y][i]*(double)i;
            cout<<(int)ans<<endl;
      }
}

Measured memory_bytes: 3148
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

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

    int tmp = k;
    int ans = 1;

    while(tmp < n) {
        tmp += (k-1);
        ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
package main

import (
	"fmt"
)

var D, G int
var ps, cs []int

func main() {
	fmt.Scan(&D, &G)
	ps = make([]int, D)
	cs = make([]int, D)
	for i := range ps {
		fmt.Scan(&ps[i], &cs[i])
	}
	search()
}

func search() {
	ans := 1 << 60

	for bit := 0; bit < (1 << uint(D)); bit++ {
		pts := 0
		qs := 0
		left := make([]int, 0, D)
		// complete
		for i := 0; i < D; i++ {
			if (bit>>uint(i))&1 == 1 {
				qs += ps[i]
				pts += pt(i)*ps[i] + cs[i]
			} else {
				left = append(left, i)
			}
		}
		if pts >= G {
			chmin(&ans, qs)
			continue
		}
		// incomplete by greedy
		for j := len(left) - 1; j >= 0; j-- {
			i := left[j]
			for k := 1; k < ps[i]; k++ {
				qs++
				pts += pt(i)
				if pts >= G {
					break
				}
			}
			if pts >= G {
				break
			}
		}
		if pts >= G {
			chmin(&ans, qs)
		}
	}
	fmt.Println(ans)
}

func pt(i int) int {
	return 100 * (i + 1)
}

func chmin(a *int, b int) {
	if *a > b {
		*a = b
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef signed long long ll;
typedef vector<int> vi;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a) (a).begin(), (a).end()
#define out(x) cout << (x) << endl


int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> n >> s;
	vi a(n+1, 0), b(n+1, 0);
	REP(i,1,n){
		a[i] = a[i-1];
		b[n-i-1] = b[n-i];
		if(s[i-1] == 'W') ++a[i];
		if(s[n-i] == 'E') ++b[n-i-1];
	}
	
	f = 1e6;
	rep(i, n){
		f = min(f, a[i] + b[i]);
	}
	out(f);
}

Measured memory_bytes: 3076
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    char S[4];
    scanf("%s",S);
    if(!strcmp(S,"AAA")||!strcmp(S,"BBB"))
    {
        printf("No");
    }
    else
    {
        printf("Yes");
    }
    return 0;
}


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

int main(void){
    int N,cnt=0;
    cin>>N;

    for(int i=1;i<=N;i++){
        if(i%2==0)
            continue;
        int ec=0;
        for(int j=1;j<=i;j++){
            if(i%j==0)
                ec++;
        }
        if(ec==8)
            cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> dct;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define size(a) int(a.size())

const ll mod = 1e9 + 7;
const ll inf = ll(1e18);
const double PI = acos(-1);

ll modexp(ll x,ll n,ll md){
    if(n==0)return 1;
    if(n%2==0)return modexp((x*x)%md,n/2,md);
    return (x*modexp((x*x)%md,n/2,md))%md;
}

bool compare(pll a,pll b){
    return a.first*b.second>a.second*b.first;
}

int main(){
    fastio;
    //clock_t tm = clock();
    ll h,n,a,b;
    cin>>h>>n;
    vll p;
    f(i,0,n){
        cin>>a>>b;
        p.pb({a,b});
    }
    sort(all(p),compare);
    vvl dp(n,vl(h+1,ll(1e14)));
    ll x=p[0].first,w=p[0].second;
    dp[0][0]=0;
    while(x<=h){
        dp[0][x]=w;
        x+=p[0].first;w+=p[0].second;
    }
    f(i,1,n){
        dp[i][0]=0;
        f(j,1,h+1){
            if(j<p[i].first)
                dp[i][j]=dp[i-1][j];
            else{
                dp[i][j]=min(min(dp[i][j-p[i].first],dp[i-1][j-p[i].first])+p[i].second,dp[i-1][j]);
            }
        }
    }
    ll ans=inf;
    f(i,0,h+1){
        if(dp[n-1][i]>=ll(1e14))
            continue;
        else{
            ll temp=dp[n-1][i];
            //cout<<i<<" "<<temp<<endl;
            ll r=h-i;
            ll z=inf;
            f(j,0,n){
                ll l=p[j].second*ll(ceil((r*1.0)/p[j].first));
                z=min(z,l);
            }
            //cout<<z<<endl;
            temp+=z;
            ans=min(ans,temp);
        }
    }
    cout<<ans<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 78592
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define ll long long
#define pb push_back 
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod 1000000007
#define mod1 998244353
#define INT_MAX1 900000000


void solve()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    string xx = "ABC";
    int k  = 0;
    for(int i=0; i<s.size()-2; i++)
    {
       if(s[i]=='A' and s[i+1]=='B' and s[i+2]=='C')
         k++, ans++;
    }

    cout << ans << endl;
}

signed main()
{
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

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

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> B(M);
  for (int i = 0; i < M; i++) cin >> B.at(i);
  int ans = 0;
  while(N--) {
    vector<int> A(M);
    for (int i = 0; i < M; i++) cin >> A.at(i);
    int tmp = 0;
    for (int i = 0; i < M; i++) tmp += A.at(i) * B.at(i);
    if (tmp + C > 0) ans++;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
	int a, b, ans = 0;
	scanf("%d%d", &a, &b);
	for (int i = a; i <= b; i++)
	{
		if (i % 10 == i / 10000 && (i % 100) / 10 == (i / 1000) % 10) {
			ans++;
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-10;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

ll Pow_mod(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

int n;

int main(){
	cin>>n;
	vi a((n+1)/2);
	if(n%2==1) a[0]++;
	for(int i=0;i<n;i++){
		int t;
		cin>>t;
		a[t/2]++;
	}
	for(int i=0;i<(n+1)/2;i++) if(a[i]!=2){
		cout<<0<<endl;
		return 0;
	}
	cout<<Pow_mod(2,n/2)<<endl;
}

Measured memory_bytes: 512
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final long MOD =  1000000007L;
	public static void main(String[] args) {
		int i,j,k,l;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		char[] s = sc.next().toCharArray();
		sc.close();
		int mx=0;
		int x=0;
		for (i = 0; i < s.length; i++) {
			if(s[i]=='I')x++;
			if(s[i]=='D')x--;
			if(mx<x)mx=x;
		}
		out.println(mx);
	}
}


Measured memory_bytes: 21844
/*
a     			a
ab				ab
ba              ab
bac             cab
dbac			cabd
cabd		    

*/

#include <bits/stdc++.h>

using namespace std;

int main(){
	string s;
	int q, num_rev = 0;
	cin>>s;
	cin>>q;
	while(q--){
		int t;
		cin>>t;
		if(t==1){
			num_rev++;
		}
		else{
			int f;
			char c;
			cin>>f>>c;
			if(f==1){
				if(num_rev%2 == 0){
					s.insert(s.begin(), c);
				}
				else{
					s.append(1, c);
				}
			}
			else{
				if(num_rev%2 == 0){
					s.append(1, c);
				}
				else{
					s.insert(s.begin(), c);
				}
			}
		}
	}
	if(num_rev%2 == 0)
		cout<<s<<"\n";
	else{
		reverse(s.begin(), s.end());
		cout<<s<<"\n";
	}
	return 0;
}

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

int main(void){
    int n;
    cin >> n;
    string s;
    set<string> set;
    unordered_map<string, int> map;
    ll res = 0;
    rep (i, n) {
        cin >> s;
        sort(s.begin(), s.end());
        set.insert(s);
        map[s]++;
    }
    for (auto itr = set.begin(); itr != set.end(); ++itr) {
        ll n = map[*itr];
        res += n*(n-1)/2;
    }
    cout << res << endl;
}

Measured memory_bytes: 18332
#include <bits/stdc++.h>
#define rep(i,s,t) for(int i=s;i<=(t);++i) 
using namespace std; 

const int N=1e5+50; 

bool vis[N]; 
int n,m,a[N],b[N],p[N],id[N]; 
long long sum[N],f[N]; 
vector<int> g[N];

int find(int x){ return p[x]==x?x:p[x]=find(p[x]); }

int main(int argc,char *argv[]){
	scanf("%d%d",&n,&m); 
	rep(i,1,n){
		scanf("%d%d",&a[i],&b[i]); 
		a[i]=max(0,a[i]-b[i]); 
		sum[i]=b[i];
	}
	rep(i,1,m){
		int u,v; 
		scanf("%d%d",&u,&v); 
		g[u].push_back(v);
		g[v].push_back(u);
	}
	rep(i,1,n)p[i]=i,id[i]=i;
	sort(id+1,id+n+1,[](int x,int y){ return a[x]<a[y]; }); 
	rep(k,1,n){
		int v=id[k]; 
		vis[v]=true;
		vector<int> son;
		for(int d:g[v])if(vis[d]&&find(d)!=find(v)){
			sum[v]+=sum[find(d)];
			son.push_back(find(d)); 
			p[find(d)]=find(v); 
		}
		f[v]=sum[v]+a[v];
		
		for(int d:son){
			f[v]=min(f[v],sum[v]-sum[d]+max(1ll*a[v],f[d])); 
		}
	}
	printf("%lld\n",f[id[n]]);
	return 0; 
}


Measured memory_bytes: 9468
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  ll n,k;
  cin>>n>>k;
  ll a[n];
  ll past[n+1];
  ll point[n+1];
  for(int i=0;i<n;i++) {
    cin>>a[i];
    a[i]--;
    past[i]=0;
  }
  past[n]=false;
  past[0]=1;
  point[1]=0;
  vector<ll> S;
  S.push_back(0);
  int temp=0;
  int rep_f,rep_e;
  for(int i=2;;i++){
    //cout<<a[temp]<<endl;
    if(past[a[temp]]==0){
      S.push_back(a[temp]);
      past[a[temp]]=i;
      point[i]=a[temp];
      temp=a[temp];
      continue;
    }
    else{
      rep_e=i-1;
      rep_f=past[a[temp]];
      break;
    }
  }
  if(k+1<=rep_e)cout<<point[k+1]+1<<endl;
  else{
    if(rep_e==rep_f) cout<<point[rep_f]+1<<endl;
    else{
      ll cnt=(k+1-rep_f)%(rep_e-rep_f+1);
      cout<<point[rep_f+cnt]+1<<endl;
    }
  }
  //cout<<rep_f<<' '<<rep_e<<endl;
  return 0;
}

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

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

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

	map<int,int> freq;

	for(int i =0;i<n;i++){
		freq[a[i]]++;
	}

	if(freq.size()<=k){
		cout<<0;
		return 0;
	}

	vector<int> num;
	for(auto it = freq.begin();it!=freq.end();it++){
		num.push_back(it->second);
	}

	sort(num.begin(),num.end());


	int i =0;
	int j = num.size() - 1;

	if(j - i  +1 <=k){
		cout<<0;
		return 0;
	}

	int ans  = 0;
	while(i <= j && j-i+1 > k){
		ans+=num[i];
		num[j]+=num[i];
		i++;
	}

	cout<<ans;
	return 0;


}

Measured memory_bytes: 11516