akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;

ll a[200000],b[200000];
ll sa[200000]={},sb[200000]={};

int main(void){
    ll n,m,k;
    cin>>n>>m>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(i==0) sa[i]=a[i];
        else sa[i]=a[i]+sa[i-1];
    }
    for(int i=0;i<m;i++){
        cin>>b[i];
        if(i==0) sb[i]=b[i];
        else sb[i]=b[i]+sb[i-1];
    }
    ll ans=0;
    for(ll i=-1;i<n;i++){
        if(i>=0&&sa[i]>k) break;
        ll now;
        if(i==-1){
            now = upper_bound(sb,  sb+m, k) - sb;
        }
        else{
            now = upper_bound(sb,  sb+m, k-sa[i]) - sb;
        }
        if(now==-1) break;
        ans=max(ans,i+1+now);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 9916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int *arr = new int[n]();
    for(int i=0;i<n;i++) cin >> arr[i];
    int *dp = new int[n];
    for(int i=0;i<n;i++)
    {
        if (i==0) dp[i] = 0;
        else if (i==1) dp[i] = abs(arr[i]-arr[i-1]);
        else dp[i] = min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2]) + dp[i-2]);
    }
    /*for(int i=0;i<n;i++)
    {
        cout << dp[i] <<" ";
    }*/
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1024
# coding: utf-8
# Here your code !

def func():
    result = ""
    try:
        index = 0
        while (True):
            line = input().rstrip()
            num = int(line)
            if (num == 0):
                break

            index += 1
            result += "Case "+str(index)+": "+str(num)+"\n"
            
    except:
        print("input error")
        return -1
        
    print(result.rstrip())

func()

Measured memory_bytes: 7888
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int N, K;
const int MAX_N = 50;
ll V[MAX_N];

int main(){
  cin >> N >> K;
  REP(i, N) cin >> V[i];

  ll ans = 0;
  
  REP(l, min(N, K) + 1) {
    REP(r, min(N, K) + 1 - l) {
      ll s = 0;
      vll tmp;
      REP(i, l) {
        s += V[i];
        tmp.pb(V[i]);
      }
      REP(j, r) {
        s += V[N - 1 - j];
        tmp.pb(V[N - 1 - j]);
      }
      sort(ALL(tmp));
      REP(i, min(K - l - r, int(tmp.size()))) {
        if(tmp[i] < 0) {
          s -= tmp[i];
        }
      }

      ans = max(ans, s);
    }
  }

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


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

typedef long long ll;
typedef unsigned long long int ull;
#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MOD 1000000007
#define PI 3.141592653589793238
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

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

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n)
    {
        if(n & 1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return result;
}

const int N=3e5;

//Use Segment Tree for fuck sake

struct item {
	ll v;
};

struct segtree 
{
	int size;
	vector<item> values;

	void init(int n)
	{
		size=1;
		while(size<n)
			size<<=1;

		values.assign(2*size,NEUTRAL_ELEMENT);
	}

	item NEUTRAL_ELEMENT={0};

	item single(int v)
	{
		return {v};
	}

	item merge(item a,item b)
	{
		return {
			max(a.v,b.v)
		};
	}

	void build(vector<int> &a,int x,int lx,int rx)
	{
		if(rx-lx == 1)
		{
			if(lx<a.size())
				values[x]=single(a[lx]);
			return;
		}

		int m=(lx+rx)/2;

		build(a,2*x+1,lx,m);
		build(a,2*x+2,m,rx);

		values[x]=merge(values[2*x+1],values[2*x+2]);
	}

	void build(vector<int> &a)
	{
		build(a,0,0,size);
	}

	void set(int i,int v,int x,int lx,int rx)
	{
		if(rx-lx == 1)
		{
			values[x]=single(v);
			return;
		}

		int m=(lx+rx)/2;

		if(i<m)
			set(i,v,2*x+1,lx,m);
		else
			set(i,v,2*x+2,m,rx);

		values[x]=merge(values[2*x+1],values[2*x+2]);
	}

	void set(int i,int v)
	{
		set(i,v,0,0,size);
	}

	item calc(int l,int r,int x,int lx,int rx)
	{
		if(lx>=r || rx<=l)
			return NEUTRAL_ELEMENT;

		if(lx>=l && rx<=r)
			return values[x];

		int m=(lx+rx)/2;

		item s1=calc(l,r,2*x+1,lx,m);
		item s2=calc(l,r,2*x+2,m,rx);

		return merge(s1,s2);
	}

	item calc(int l,int r)
	{
		return calc(l,r,0,0,size);
	}
};

int32_t main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    IOS

    int n,k;
    cin>>n>>k;

    segtree st;
    st.init(N+1);
    int ans=0;
    for(int i=0;i<n;i++)
    {
    	int x;
    	cin>>x;

    	int l=max(x-k,0),r=min(x+k,N);
    	int temp=st.calc(l,r+1).v + 1;
    	ans=max(ans,temp);
    	st.set(x,temp);
    }

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

Measured memory_bytes: 11392
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#pragma GCC optimize ("O3")
	#define NDEBUG
#endif
// #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n;
	while(cin >> n) {
		vector<LL> h(n);
		REP(i, n) cin >> h[i];
		h[0]--;
		bool ans = true;
		REP(i, n - 1) {
			if(h[i] > h[i +1]) {
				ans = false;
			} else if(h[i] < h[i + 1]) {
				h[i + 1]--;
			}
		}
		if(ans) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<tuple<string,int,int>>a;
  for(int i= 1;i<=n;i++){
    string s;
    int p;
    cin >> s >> p;
        p = -p;
    a.push_back(tie(s,p,i));
  }
  sort(a.begin(),a.end());
  for(int i = 0;i<n;i++){
    string s;
    int p;
    int id;
    tie(s,p,id) = a.at(i);
    cout << id << endl;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define RANGE(i,n) for(int i=0;i<n;i++)
typedef long long ll;
struct P{
    ll var1;
    ll var2;
};
bool operator< ( const P &one, const P &two){
    return one.var1 < two.var1;
};
bool operator> ( const P &one, const P &two){
    return one.var1 > two.var1;
};

using namespace std;

signed main() {
    int P,Q,R;
    cin >> P>>Q>>R;
    cout << P+Q+R-max(max(P,Q),R) << endl;
}


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

using namespace std;

int a[200010],b[200010],c[200010];

int main()
{
    //freopen("input.txt","r",stdin);
    int n;scanf("%d",&n);
    for (int i=1;i<=n;i++) {scanf("%d",&a[i]);b[a[i]]=i;}
    int k=n;
    while (k>1&&b[k-1]<b[k]) k--;
    int i=0;c[0]=k;
    while (c[i]>1)
    {
        int k=c[i]-1;
        while (k>1)
        {
            if (b[c[i]]<b[k-1]&&b[k-1]<b[k]||b[k-1]<b[k]&&b[k]<b[c[i]]||b[k]<b[c[i]]&&b[c[i]]<b[k-1]) {k--;continue;}
            break;
        }
        c[++i]=k;
    }
    printf("%d\n",i);
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
using namespace std;
class Dice{
private:
	int dice[6];
/*	int direction[4][6]={
		{3,1,0,5,4,2},
		{1,5,2,3,0,4},
		{4,0,2,3,5,1},
		{2,1,5,0,4,3}};
*/
	int direction[4][6];
public:
	Dice(int dice[6]);
	void rotate(string cmd);
	void rotate(char cmd);
	int rotate(int top,int front);
	int getTop();
};

Dice::Dice(int dice[6]){
	for(int i=0;i<6;i++){
		this->dice[i]=dice[i];
	}
	int tmp[4][6]={
		{3,1,0,5,4,2},
		{1,5,2,3,0,4},
		{4,0,2,3,5,1},
		{2,1,5,0,4,3}};
	for(int i=0;i<4;i++){
		for(int j=0;j<6;j++){
			direction[i][j]=tmp[i][j];
		}
	}
}

void Dice::rotate(string cmd){
	int length=cmd.length();
	for(int i=0;i<length;i++){
		rotate(cmd[i]);
	}
}

void Dice::rotate(char cmd){
	int tmp[6];
	int index;
	switch(cmd){
		case 'E':index=0;break;
		case 'N':index=1;break;
		case 'S':index=2;break;
		case 'W':index=3;break;
		default:return;
	}
	for(int i=0;i<6;i++){
		tmp[i]=dice[i];
	}
	for(int i=0;i<6;i++){
		dice[i]=tmp[direction[index][i]];
	}
}

int Dice::rotate(int top,int front){
	if(front==dice[3]||front==dice[2]){
		rotate('W');
	}
	while(front!=dice[1]){
		rotate('S');
	}
	while(top!=dice[0]){
		rotate('W');
	}
	return dice[2];
}
int Dice::getTop(){
	return dice[0];
}

int main(){
	int tmp[6];
	for(int i=0;i<6;i++){
		cin>>tmp[i];
	}
	Dice dice(tmp);
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int top,front;
		cin>>top>>front;
		cout<<dice.rotate(top,front)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    x=int(input())
    ans=0
    for i in range(1,33):
        for j in range(2,11):
            y=i**j
            if y<x:
                ans=max(y,ans)
            elif y==x:
                ans=max(y,ans)
                break
            else:
                break
    print(ans)
resolve()


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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int N;
int D, X;
VI A;
int main() {
    std::cin >> N;
    std::cin >> D >> X;
    A.resize(N);
    REP(i, N) {
        std::cin >> A[i];
    }

    long sum = 0;
    REP(i, D) {
        REP(j, N) {
            if( i % A[j] == 0 ) {
                ++sum;
            }
        }
    }
    std::cout << sum + X << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  int N;
  cin >> N;
  vector<int> l(N), r(N);
  rep(i, N) cin >> l[i] >> r[i];

  int ans = 0;
  rep(i, N) { ans += r[i] - l[i] + 1; }
  cout << ans << endl;
}

Measured memory_bytes: 256
// use std::cmp;
// use std::collections::HashMap;
// use std::collections::HashSet;
// use std::collections::VecDeque;


// const INF: i64 = 1_000_000_000;


fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let n = sc.read();
    let mut last = 0;
    let mut ans = 0;
    for _ in 0..n {
        let a = sc.read();
        if a == last {
            last = -1;
            ans += 1;
        } else {
            last = a;
        }
    }
    println!("{}", ans);
}

// thanks, ir5
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
#define  MAX_H 10
using namespace std;

map<string, int> mp;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

string s[MAX_H];
int h, w;

int mystrcmp(string a, string b) {
    if (a.size() > b.size()) return 1;
    if (a.size() < b.size()) return -1;

    for (int i = 0; i < a.size(); i++) {
        if (a[i] < b[i]) return 1;
        if (a[i] > b[i]) return -1;
    }
    return 0;
}

void dfs(int x, int y, int xnow, int ynow, int k, string str) {
    int xnext = (xnow + dx[k] + h) % h;
    int ynext = (ynow + dy[k] + w) % w;

    mp[str]++;

    if (x == xnext && y == ynext) return;
    
    string str2;
    str2.push_back(s[xnext][ynext]);
    dfs(x, y, xnext, ynext, k, str + str2);
}

int main() {
    while (true) {
        for (int i = 0; i < MAX_H; i++) {
            s[i].erase();
        }
        mp.clear();

        cin >> h >> w;
        if (h == 0 && w == 0) return 0;
        for (int i = 0; i < h; i++) {
            cin >> s[i];
        }
    
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                for (int k = 0; k < 8; k++) {
                    string str;
                    str.push_back(s[i][j]);
                    dfs(i, j, i, j, k, str);
                }
            }
        }
        
        string ans;
        for (map<string, int>::const_iterator itr = mp.begin(); itr != mp.end(); ++itr) {
//            cout << itr->first << " " << itr->second << endl;
            if (itr == mp.begin()) {
                ans += itr->first;
                continue;
            }
            if (itr->second > 1 && mystrcmp(itr->first, ans) > 0) {
                ans.erase();
                ans += itr->first;
            }
        }

        if (ans.size() >= 2) cout << ans << endl;
        else cout << 0 << endl;
    }
}

Measured memory_bytes: 37916
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(ll i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const int INF=2*1e9;
int main()
{
    ll n,ans=0;
    cin>>n;
    rep1(i,n)
    {
        if(i%3&&i%5) ans+=i;
    }
    cout<<ans;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { -1, 0, 1, 0 };

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	ll n, a, b;
	cin >> n >> a >> b;

	if (a > b) {
		cout << 0 << endl;
	} else if (n == 1 && a == b) {
		cout << 1 << endl;
	} else if (n == 1 && a != b) {
		cout << 0 << endl;
	} else {
		cout << (n - 2) * (b - a) + 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())

color = []
colorStorage = []
for i in range(N):
    color.append(i)
    colorStorage.append([i])

for _ in range(M):
    p,q = map(int,input().split())
    p -= 1
    q -= 1
    if color[p] == color[q]:
        continue
    else:
        x = color[p]
        y = color[q]
        if len(colorStorage[x]) >= len(colorStorage[y]):
            for elem in colorStorage[y]:
                color[elem] = x
                colorStorage[x].append(elem)
            colorStorage[y] = []
        else:
            for elem in colorStorage[x]:
                color[elem] = y
                colorStorage[y].append(elem)
            colorStorage[x] = []
maxL = 0
for colorList in colorStorage:
    if maxL < len(colorList):
        maxL = len(colorList)
print(maxL)



Measured memory_bytes: 119884
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

const vector<vector<int>> moves{{0,  1},
                                {0,  -1},
                                {1,  0},
                                {-1, 0}};
const int INF = 1145141919;
int h, w;

bool inRange(int x, int y) {
    return 1 <= x && x <= h && 1 <= y && y <= w;
}

int main() {
    cin >> h >> w;
    vector<vector<int>> ban(h + 2, vector<int>(w + 2, INF));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> ban[i + 1][j + 1];
        }
    }

    vector<vector<int>> count(h + 2, vector<int>(w + 2));
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            bool isPool = true;
            for (auto m:moves) {
                if (ban[i][j] > ban[i + m[0]][j + m[1]]) isPool = false;
            }

            if (isPool) {
                vector<vector<bool>> visited(h + 2, vector<bool>(w + 2));
                visited[i][j] = true;
                queue<vector<int>> que;
                que.push({i, j});
                while (!que.empty()) {
                    auto now = que.front();
                    que.pop();

                    int x = now[0], y = now[1];

                    for (auto m:moves) {
                        int nx = x + m[0], ny = y + m[1];
                        if (inRange(nx, ny) && !visited[nx][ny] && ban[x][y] < ban[nx][ny]) {
                            visited[nx][ny] = true;
                            que.push({nx, ny});
                        }
                    }
                }

                for (int k = 1; k <= h; k++) {
                    for (int l = 1; l <= w; l++) {
                        count[k][l] += visited[k][l];
                    }
                }
            }
        }
    }

    int ret = 0;
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if (count[i][j] >= 2)ret++;
        }
    }
    cout << ret << endl;
    return 0;
}


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

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}



//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}


int main() {
	int N, H, W;
	int ans = 0;
	cin >> N >> H >> W;

	for (int i = 0; i < N; i++)
	{
		int a, b;
		cin >> a >> b;
		if (a >= H) {
			if (b >= W) {
				ans++;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main()
{
	int r, c, a[101][101] = {0};

	cin >> r >> c;
	//DWORD start = GetTickCount();//スタート時間

	for(int i = 0; i < r; i++){
		for(int j = 0; j < c; j++){
			cin >> a[i][j];
			a[i][c] += a[i][j];
			a[r][j] += a[i][j];
		}
		a[r][c] += a[i][c];
	}


	for(int i = 0; i <= r; i++){
		for(int j = 0; j <= c; j++){
			cout <<  a[i][j];
			if(j < c){
				cout << ' ';
			}
		}
		cout << endl;
	}

	//DWORD end = GetTickCount();//終了時間
	//cout << "time = " << (double)(end - start) / 1000 << "sec.\n";

	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i, N) cin >> d.at(i);

    vector<int> num(100);
    rep(i, N) num.at(d.at(i)-1)++;

    int ans = 0;
    for (int i : num) if (i) ans++;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int64_t const INF = 1e18;

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<int64_t> A(N), S(N+1, 0);
  for(int i = 0; i < N; ++i) std::cin >> A[i];
  for(int i = 0; i < N; ++i) S[i+1] = S[i] + A[i];
  auto split = [&](auto b, auto e)-> std::pair<int64_t,int64_t> {
    int64_t V = (*e + *b)/2;
    auto m = std::upper_bound(b, e, V);
    int64_t mi = INF;
    std::pair<int64_t, int64_t> res;
    for(auto i: {m-1, m, m+1}) if(b < i && i < e) {
      int64_t cur = std::abs((*i-*b) - (*e-*i));
      if(cur < mi) { mi = cur; res = std::make_pair(*i-*b, *e-*i); }
    }
    return res;
  };
  auto isOK = [&](int64_t k)->bool {
    int64_t vmi = (S[N]+1)/2 - k, vma = S[N]/2 + k;
    auto lb = std::lower_bound(S.begin()+2, S.end()-3, vmi);
    auto ub = std::upper_bound(S.begin()+2, S.end()-2, vma);
    for(auto it = lb; it != ub; ++it) {
      auto L = split(S.begin(), it);
      if(std::abs(L.first - L.second) > k) continue;
      auto R = split(it, S.end()-1);
      if(std::abs(R.first - R.second) > k) continue;
      if(std::abs(L.first - R.first) > k) continue;
      if(std::abs(L.first - R.second) > k) continue;
      if(std::abs(L.second - R.first) > k) continue;
      if(std::abs(L.second - R.second) > k) continue;
      return true;
    }
    return false;
  };
  
  int64_t ng = -1, tmp[6];
  tmp[0] = std::abs(S[N] - S[3] - A[0]);
  tmp[1] = std::abs(S[N] - S[3] - A[1]);
  tmp[2] = std::abs(S[N] - S[3] - A[2]);
  tmp[3] = std::abs(A[0] - A[1]);
  tmp[4] = std::abs(A[0] - A[2]);
  tmp[5] = std::abs(A[1] - A[2]);
  int64_t ok = *std::max_element(tmp, tmp+6);
  while(ok - ng > 1) {
    int64_t mid = (ok+ng)/2;
    if(isOK(mid)) ok = mid; else ng = mid;
  }
  fin(ok);
  return 0;
}


Measured memory_bytes: 3456
import sys
input = sys.stdin.readline
from collections import deque

N = int(input())
A = [int(input()) for _ in range(N)]
INF = 10**18
arr = deque([])
for a in A:
    l, r = -1, len(arr)
    while (r-l) > 1:
        mid = (r+l)//2
        if arr[mid] < a:
            l = mid
        else:
            r = mid
    if l == -1:
        arr.appendleft(a)
    else:
        arr[l] = a
print(len(arr))

Measured memory_bytes: 13788
import fractions
a,b=map(int, input().split())
n = fractions.gcd(a,b)


def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            ass.append(n//i)
    return ass

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


divs = divisor(n)
ans = 0

for d in divs:
    ans += is_prime(d)


print(ans+1)

Measured memory_bytes: 5304
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, [ $t:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    a: [i64; n],
  }
  let mut a: Vec<_> = a.into_iter().enumerate().collect();
  a.sort_by_key(|&(_, a)| a);
  let mut parity = 0;
  for (j, &(i, _)) in a.iter().enumerate() {
    if i % 2 != j % 2 {
      parity += 1;
    }
  }

  puts!("{}\n", parity / 2);
}


Measured memory_bytes: 8444
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto ab = readln.split.to!(int[]);
    auto A = ab[0];
    auto B = ab[1];
    if (A >= 13) {
        writeln(B);
    } else if (A >= 6) {
        writeln(B/2); 
    } else {
        writeln(0);
    }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }


int N, M;
vector<int> _link[100001];
int S, T;

int _flg1[100001];
int _flg2[100001];
int _flg3[100001];
queue<int> q1;
queue<int> q2;
queue<int> q3;

signed main()
{
	cin >> N >> M;
	REP(i, M)
	{
		int u, v;
		cin >> u >> v;
		_link[u].push_back(v);
	}
	cin >> S >> T;

	REP(i, N + 1)
	{
		_flg1[i] = LLONG_MAX;
		_flg2[i] = LLONG_MAX;
		_flg3[i] = LLONG_MAX;
	}
	//memset(_flg1, LLONG_MAX, sizeof(_flg1));
	//memset(_flg2, LLONG_MAX, sizeof(_flg2));
	//memset(_flg3, LLONG_MAX, sizeof(_flg3));

	q1.push(S);
	_flg1[S] = 0;
	int s = 1;

	while (q1.size() > 0)
	{
		while (q1.size() > 0)
		{
			int n = q1.front();
			q1.pop();

			for (int l : _link[n])
			{
				if (_flg2[l] > s)
				{
					_flg2[l] = s;
					q2.push(l);
				}
			}
		}

		while (q2.size() > 0)
		{
			int n = q2.front();
			q2.pop();

			for (int l : _link[n])
			{
				if (_flg3[l] > s)
				{
					q3.push(l);
					_flg3[l] = s;
				}
			}
		}

		while (q3.size() > 0)
		{
			int n = q3.front();
			q3.pop();

			for (int l : _link[n])
			{
				if (_flg1[l] > s)
				{
					q1.push(l);
					_flg1[l] = s;
				}
			}
		}

		s++;
	}

	if (_flg1[T] == LLONG_MAX) 
		cout << -1 << endl;
	else
		cout << _flg1[T] << endl;
}



Measured memory_bytes: 10876
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner a = new Scanner(System.in);
		int N = a.nextInt();
		int x = N * 800;
		int y = (N / 15) * 200;
		int s = x-y;
		System.out.print(s);
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
/* Long Longと書くのは長いのでtypedefしている */
typedef long long ll;

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

  /**
   * ソートされた文字列とその登場回数を格納するmapを作る
   *
   * string sにソートされた文字列が入る
   * mp[s]にその文字列の登場回数が入る
   */
  map<string, int> mp;
  rep(i, n) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    mp[s]++;
  }

  ll ans = 0;
  // auto&で型推論される
  for (auto& p : mp) {
    int s = p.second;
    // 全てのアナグラム回数を計算する
    ans += (ll)s * (s - 1) / 2;
  }

  // 結果を出力する
  cout << ans << endl;

  return 0;
}


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

int distance(short ax, short ay, short bx, short by);

short X[100];
short Y[100];
int H[100];

int main(){
	short N, i;
	short is;
	if(scanf("%hd", &N));
	short A = -1;
	for(i=0; i<N; i++){
	if(scanf("%hd%hd%d", &X[i], &Y[i], &H[i]));
		if(A==-1 && H[i]!=0){A=i;}
	}
	short CX=0, CY=0;
	int CH=0;
	for(CX=0; CX<=100; CX++){
		for(CY=0; CY<=100; CY++){
			CH = H[A]+distance(CX, CY, X[A], Y[A]);
			is = 1;
			for(i=0; i<N; i++){
				if(H[i] == 0){
					if(distance(CX, CY, X[i], Y[i]) < CH){
						is = 0;
						break;
					}
				}else{
					if(H[i]+distance(CX, CY, X[i], Y[i]) != CH){
						is = 0;
						break;
					}
				}
			}
			if(is){break;}
		}
		if(is){break;}
	}
	printf("%d %d %d\n", CX, CY, CH);
	return 0;
}

int distance(short ax, short ay, short bx, short by){
	return (ax>bx?ax-bx:bx-ax)+(ay>by?ay-by:by-ay);
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
  long long n,d,c=0,x,y;
  cin>>n>>d;
  while(n--)
  {
      cin>>x>>y;
      if((x*x+y*y)<=(d*d))
        c++;
  }
  cout<<c<<endl;
  return 0;
}

Measured memory_bytes: 3628
import * as fs from 'fs';

namespace AtCoder.abc118 {

    export class Program {
        /**
         * in
         * 4 12
         * out
         * 16
         */
        static main(inp: string):
            void {
            const [a, b]: number[] = inp.split(' ').map(Number);

            if (b % a === 0) {
                console.log(a + b);
            } else {
                console.log(b - a);
            }
        }
    }
}

AtCoder.abc118.Program.main(fs.readFileSync('/dev/stdin', 'utf8').trim());


Measured memory_bytes: 7372
import java.io.IOException;
import java.util.Scanner;


public class Main{


	public static void main(String args[]) throws IOException{
		Scanner stdin = new Scanner(System.in);
		int tyo = 0;
		int hishi = 0;
		while(stdin.hasNext()){

			String tmp = stdin.nextLine();
			String[] str = tmp.split(",");
			int a = Integer.parseInt(str[0]);
			int b = Integer.parseInt(str[1]);
			int c = Integer.parseInt(str[2]);

			if(a == b) {
				hishi++;
			} else if((a * a) + (b * b) == (c * c)) {
				tyo++;
			} 
		}
		System.out.println(tyo);
		System.out.println(hishi);
	}
}

Measured memory_bytes: 26064
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


int main(){
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;

    if(u == s) a--;
    if(u == t) b--;

    cout << a << " "<< b << endl;
}

Measured memory_bytes: 256
S=input()
if all(S[i]=="1" for i in range(len(S))):
  print(1)
elif S[0]!="1":
  print(S[0])
else:
  K=int(input())
  i=0
  while S[i]=="1":
    i+=1
  if i<K:
    print(S[i])
  else:
    print(1)

Measured memory_bytes: 3064
def f(a,d,T):
    try:
        return T[d+1:].index(a)+(d+1)
    except ValueError:
        return len(T)

def g(a,d,T):
    try:
        return T[:d].index(a)
    except ValueError:
        return 0

A=26

D=int(input())

C=[0]+list(map(int,input().split())) #減る満足度のベース
S=[0]*(D+1) #S[d][i] :(d+1)日目にコンテストiを開催した時の満足度

for i in range(1,D+1):
    S[i]=[0]+list(map(int,input().split()))

T=[0]
for i in range(D):
    T.append(int(input()))
            
X=0
L=[0]*(A+1)
R=[[0]*(A+1) for _ in range(D+1)]
for d in range(1,D+1):
    X+=S[d][T[d]]
    for j in range(1,A+1):
        if j!=T[d]:
            L[j]+=1
            R[d][j]=R[d-1][j]+1
            X-=C[j]*L[j]
        else:
            L[j]=0

M=int(input())
for _ in range(M):
    d,q=map(int,input().split())
    p=T[d]

    Y=0
    h=R[d-1][p]
    for i in range(d,f(p,d,T)):
        h+=1
        Y+=h-R[i][p]
        R[i][p]=h

    Z=0
    m=0
    for j in range(d,f(q,d,T)):
        Z+=R[j][q]-m
        R[j][q]=m
        m+=1
    
    T[d]=q
    X+=(S[d][q]-S[d][p])+Z*C[q]-Y*C[p]
    print(X)


Measured memory_bytes: 76536
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main() {
    int n;
    cin >> n;
    vector<int> fibo(46);
    fibo[1] = 1;
    for(int i=2;i<=n+1;i++){
        fibo[i] = fibo[i-1]+fibo[i-2];
    }
    cout << fibo[n+1] << endl;
    return 0;
}



Measured memory_bytes: 3068
// Inshallah, Boys played well !!

#include <bits/stdc++.h>
using namespace std;
#define author Saurabh
#define pii pair<int,int> 
#define vpi vector<pair<int,int> >
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define ff(i,s,e) for(int i=s;i<=e;i++)
#define fb(i,e,s) for(int i=e;i>=s;i--)
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test int t;scanf("%d",&t);while(t--)
#define setp(x) setprecision(x)
#define int long long
signed main(){
    fast;
    int n,m,x,k;
    cin >> n >> k;
    int s=0;
    int ans=0;
    for(int i=k;i<=n+1;i++){
        ans+=(n*(n+1))/2-((n-i)*(n-i+1))/2+1-((i)*(i-1))/2;
        ans%=1000000007;
       // cout << ans <<" ";
    }
    cout << ans << endl;

}


Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main ()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a<b&&b<c)
    {
      cout << a << " " << b << " " << c << endl;
    }
    else if(a>b&&b>c)
    {
      cout << c << " " << b << " " << a << endl;
    }
    else if(a==b&&b<c)
    {
      cout << a << " " << b << " " << c << endl;
    }
    else if(a==b&&b>c)
    {
      cout << c << " " << a << " " << b << endl;
    }
    else if(a<b&&b==c)
    {
      cout << a << " " << b << " " << c << endl;
    }
    else if(a>b&&b==c)
    {
      cout << b << " " << c << " " << a << endl;
    }
    else if(a==c&&c<b)
    {
      cout << a << " " << c << " " << b << endl;
    }
    else if(a==c&&c>b)
    {
      cout << b << " " << a << " " << c << endl;
    }
    else if(a<c&&c==b)
    {
      cout << a << " " << b << " " << c << endl;
    }
    else if(a>c&&c==b)
    {
      cout << c << " " << b << " " << a << endl;
    }
	else if(a==b&&b==c)
    {
      cout << a << " " << b << " " << c << endl;
    }
    else
	{
		cout << b << " " << c << " " << a << endl;
	}
    return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N, K;
  scanf("%d %d", &N, &K);
  map<int, int> freqs;
  for (int i = 0; i < N; ++i) {
    int val;
    scanf("%d", &val);
    ++freqs[val];
  }
  vector<pair<int, int> > occ;
  for (map<int, int>::iterator iter = freqs.begin(); iter != freqs.end(); ++iter) {
    occ.push_back(make_pair(iter->second, iter->first));
  }
  sort(occ.begin(), occ.end());
  int ans = 0, cnt = occ.size();
  if (cnt > K) {
    for (int i = 0; i < cnt - K; ++i) {
      ans += occ[i].first;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 11768
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int gyou = sc.nextInt();
		int retu = sc.nextInt();

		int[][] hyou = new int[gyou][retu];

		for(int i = 0;i < hyou.length;i++) {
			for(int j = 0;j < hyou[i].length;j++) {
				hyou[i][j] = sc.nextInt();
			}
		}

		int[] gyousum = new int[gyou];
		int[] retusum = new int[retu];
		for(int i = 0;i < hyou.length;i++ ){
			for(int j  = 0;j < hyou[i].length;j++) {
				gyousum[i] += hyou[i][j];
				retusum[j] += hyou[i][j];
			}
		}
		for(int i = 0;i < hyou.length;i++) {
			for(int j = 0;j < hyou[i].length; j++) {
				System.out.print(hyou[i][j] + " ");
			}
			System.out.println(gyousum[i]);
		}
		int sum = 0;
		for(int i = 0;i < retusum.length;i++) {
			System.out.print(retusum[i] + " ");
			sum += retusum[i];
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 42228
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<vector<int>> fr(n, vector<int>());
	int ans = 0;
	rep(i, n){
		int a;
		cin >> a;
		a--;
		if(i < a) fr.at(a).push_back(i);
		else{
			for(int j : fr.at(i)){
				if(j == a){
					ans++;
					break;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4096
n = int(input())
a = list(map(int, input().split()))
ans = 0
flag = True
while flag:
    count = 0
    for i in range(n):
        if a[i] % 2 == 0:
            count += 1
            a[i] = a[i] / 2
        else:
            print(ans)
            flag = False
            break
        if count == n:
            ans += 1


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

typedef long long int ll;

#define endl '\n'

ll n;
long double arr[3000];
long double dp[3000][3000];

long double solve(ll u,ll numberoftails)
{

    if(u==n){
        if(numberoftails<=(n-numberoftails)){
            return 1;
        }
        return 0;
    }

    if(dp[u][numberoftails]==2.0)
    {

        dp[u][numberoftails] = arr[u]*solve(u+1,numberoftails) + (1-arr[u])*solve(u+1,numberoftails+1);

    }

    //cout<<u<<" "<<numberoftails<<" "<<dp[u][numberoftails]<<endl;

    return dp[u][numberoftails];

}

int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(10);
    memset(dp,0.0,sizeof(dp));
    for(ll i=0;i<3000;i++){
        for(ll j=0;j<3000;j++){
            dp[i][j] = 2.0;
        }
    }
    cin>>n;
    for(ll i=0;i<n;i++){
        cin>>arr[i];
    }

    cout<<solve(0,0)<<endl;


}


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

ll mod = 1e9 + 7;

int main(){
    int N;
    cin >> N;
    vector<ll> d(62, 0);
    for (int i = 0; i < N; i++) {
        ll A;
        cin >> A;
        for (int j = 0; j < 62; j++) {
            if (((A >> j) & 1) == 1) d[j]++;
        }
    }
    ll ans = 0;
    for (int i = 0; i < 62; i++) {
        ll t = 1;
        for (int j = 0; j < i; j++) t = (t*2)%mod;
        ans += ((d[i] * (N-d[i]) % mod) * t) % mod;
        ans %= mod;
        //cout << ans << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s1 = sc.next();
		String s2 = sc.next();
		String s3 = sc.next();
		
		String st1 = s1.substring(0,1).toUpperCase();
		String st2 = s2.substring(0,1).toUpperCase();
		String st3 = s3.substring(0,1).toUpperCase();
		
		System.out.println(st1 + st2 + st3);
	}
}

Measured memory_bytes: 23252
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] l = new int[12];
        for (int i = 0; i < 12; i++) {
            l[i] = sc.nextInt();
        }
        Arrays.sort(l);
        boolean f=true;
        for (int i=0;i<12;i+=4) {
            if (l[i]+l[i+2]!=l[i+1]+l[i+3]) {
                f=false;
                break;
            }
        }
        System.out.println(f ? "yes" : "no");
    }
}



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

int main() {
    int n, m; cin >> n >> m;
    vector<int> dg(n, 0);
    
    vector<vector<int>> g(n);

    for(int i = 0; i < m; i += 1) {
        int a, b; cin >> a >> b;
        a -= 1, b -= 1;
        dg[a] += 1;
        dg[b] += 1;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    for(int i = 0; i < n; i += 1) {
        if(dg[i] % 2) {
            cout << "No\n";
            return 0;
        }
    }
    
    vector<int> fours;

    for(int i = 0; i < n; i += 1) {
        if(dg[i] >= 6) {
            cout << "Yes\n";
            return 0;
        } else if(dg[i] == 4) {
            fours.push_back(i);
        }
    }
    
    if(int(fours.size()) >= 3) {
        cout << "Yes\n";
        return 0;
    }

    if(int(fours.size()) < 2) {
        cout << "No\n";
        return 0;
    }

    int source = -1;
    for(int i = 0; i < n; i += 1)
        if(fours[0] != i) {
            source = i;
            break;
        }

    queue<int> q;
    q.push(source);
    vector<int> viz(n, 0);
    viz[source] = 1;

    while(not q.empty()) {
        int node = q.front();
        q.pop();

        for(auto v : g[node]) {
            if(v == fours[0])
                continue;
            if(not viz[v]) {
                viz[v] = 1;
                q.push(v);
            }
        }
    }

    if(accumulate(viz.begin(), viz.end(), 0) < n - 1) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

Measured memory_bytes: 6528
n, k = map(int, input().split())

ab = []
for i in range(n):
    a, b = map(int, input().split())
    ab.append((a, b))

ab.sort(key=lambda x: x[0])

cnt = 0
for a, b in ab:
    if cnt <= k <= cnt+b:
        print(a)
        exit()
    cnt += b


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

using namespace std;

typedef long long ll;

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

    string s;
    cin >> s;
    int n = s.size();
    for (int i = 0; i < n - 1; i++) {
        if (s[i] == s[i + 1]) {
            cout << i + 1 << ' ' << i + 2 << '\n';
            return 0;
        }
        if (i < n - 2 && s[i] == s[i + 2]) {
            cout << i + 1 << ' ' << i + 3 << '\n';
            return 0;
        }
    } 
    cout << "-1 -1\n";
    
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;
 
int main() {
    string s;
    cin >> s;
    int ans=true, cnt=0;
    if(s[0] != 'A')ans = false;
    for(int i = 2; i < s.size()-1; i++){
        if(s[i] == 'C')cnt++;
    }
    for(int i = 1; i < s.size(); i++){
        if(isupper(s[i]) && s[i] != 'C')ans=false;
        if(2 > i && i >= s.size()-1 && isupper(s[i]))ans=false;
    }
    if(cnt != 1)ans=false;
    if(ans)cout << "AC";
    else cout << "WA";
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = Integer.parseInt(sc.next());
		for (int i = 0; i < m; i++) {
			String s = sc.next();
			ArrayList<String> a = new ArrayList<>();
			for (int j = 0; j < s.length(); j++) {
				a.add(s.substring(0, j) + s.substring(j));
				a.add(s.substring(j) + s.substring(0, j));
				a.add(new StringBuilder(s.substring(0, j)).reverse().toString() + s.substring(j));
				a.add(s.substring(0, j) + new StringBuilder(s.substring(j)).reverse().toString());
				a.add(new StringBuilder(s.substring(j)).reverse().toString() + s.substring(0, j));
				a.add(s.substring(j) + new StringBuilder(s.substring(0, j)).reverse().toString());
				a.add(new StringBuilder(s.substring(0, j)).reverse().toString() + new StringBuilder(s.substring(j)).reverse().toString());
				a.add(new StringBuilder(s.substring(j)).reverse().toString() + new StringBuilder(s.substring(0, j)).reverse().toString());
			}
			System.out.println(new ArrayList<String>(new HashSet<>(a)).size());
		}
	}
}


Measured memory_bytes: 61564
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int a[] = new int[26];
        for (int i=0; i<s.length(); i++) {
            a[s.charAt(i)-'a']++;
            if (a[s.charAt(i)-'a'] > 1) {
                System.out.println("no");
                sc.close();
                return;
            }
        }
        System.out.println("yes");
        sc.close();
    }
}

Measured memory_bytes: 35752