akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>


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

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

    std::sort(a.begin(), a.end());
    bool f = true;

    for (int i = 0; i < n - 1; i++)
    {
        if(a[i] == a[i + 1]) {
            f = false;
        }
    }

    std::string ans = f ? "YES" : "NO";

    std::cout << ans << "\n";
}

Measured memory_bytes: 1024
/*
ЗАПУСКАЕМ
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░
 */
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>

using namespace std;
template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; }
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define left left224
#define right right224
#define next next224
#define rank rank224
#define prev prev224
#define y1 y1224
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define files(FILENAME) read(FILENAME), write(FILENAME)
#define pb push_back
#define mp make_pair
const string FILENAME = "input";





int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //read(FILENAME);
    long long s;
    cin >> s;
    //x * y1 - x1 * y = s
    long long f = (1000000000 - s % 1000000000) % 1000000000;
    cout << 0 << ' ' << 0 << ' ' << (s + f) / 1000000000 << ' ' << 1 << ' ' << f << ' ' << 1000000000  << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
#define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);
using namespace std;
int N;
vector<int> G[200001];
int par[200001],dep[200001],num[200001];
void makegraph(){
	string s;
	cin>>s;
	int v=-1;
	for(char c:s){
		if(c=='('){
			if(v>=0) G[v].pb(N),dep[N]=dep[v]+1;
			par[N]=v;
			v=N;
			N++;
		}else{
			num[v]=1;
			for(int u:G[v]) num[v]+=num[u];
			v=par[v];
		}
	}
}
bool dfs(int v,int w,int s){
	if(G[v].size()==0&&G[w].size()==2) return false;
	if(G[v].size()==0&&G[w].size()==0) return true;
	if(G[v].size()==2&&G[w].size()==2) return dfs(G[v][0],G[w][0],s)&&dfs(G[v][1],G[w][1],s);
	return dfs(v,s,s);
}
bool ok(int v){
	return dfs(0,v,v);
}
int main(){
	BEGIN_STACK_EXTEND(128*1024*1024);
	makegraph();
	vector<int> ds;
	int v=0;
	rep(i,N) if(dep[i]>dep[v]) v=i;
	v=par[v];
	while(v>=0){
		if((N-1)%(num[v]-1)==0){
			if(ok(v)) ds.pb(num[v]-1);
		}
		v=par[v];
	}
	int K=ds.size();
	int dp[161]={};
	rep(i,K) dp[i]=1e9;
	dp[0]=0;
	rep(i,K){
		rep(j,i){
			if(ds[i]%ds[j]==0){
				chmin(dp[i],dp[j]+ds[i]/ds[j]-1);
			}
		}
	}
	cout<<dp[K-1]<<endl;
	END_STACK_EXTEND;
}

Measured memory_bytes: 16152
from collections import deque
N,Q = map(int,input().split())
edge = [[] for i in range(N+1)]
for i in range(N-1):
    a,b = map(int,input().split())
    edge[a].append(b)
    edge[b].append(a)
check = [0]*(N+1)
point = [0]*(N+1)
for i in range(Q):
    p,x = map(int,input().split())
    point[p] += x
q = deque([])
q.append(1)

while len(q)>0:
    nn = q.popleft()
    check[nn] = 1
    for i in edge[nn]:
        if check[i] == 0:
            point[i] += point[nn] 
            q.append(i)

print(" ".join(map(str, point[1::])))



Measured memory_bytes: 131164
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

struct Pair
{
public:
  Pair( int a, int b )
  :mA( a )
  ,mB( b )
  {}

  bool operator<( const Pair& pair )
  {
    return mB < pair.mB;
  }

  int mA;
  int mB;
};

int main()
{
  int M, N;
  cin >> M >> N;

  vector< Pair > pairs;
  for( int i = 0; i < N; ++i )
  {
    int a, b;
    cin >> a >> b;
    Pair pair( a, b );
    pairs.push_back( pair );
  }

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

  int cutNum = 0;
  int lastCut = -1;

  for( const auto& pair : pairs )
  {
    if( pair.mA >= lastCut )
    {
      ++cutNum;
      lastCut = pair.mB;
    }
  }

  cout << cutNum << endl;

  return 0;
}


Measured memory_bytes: 1400
/*
ABC153-E AC
https://atcoder.jp/contests/abc153/tasks/abc153_e
動的計画法 DP
*/

#include <bits/stdc++.h>
using namespace std;

int main(){
  int h, n;
  cin>>h>>n;
  int INF = 1<<29;

  //必要なdp配列をとって初期化する
  vector<int> dp(h+10010, INF);
  //初期値を入れる
  dp[0] = 0;

  int a, b;
  for(int rp=0; rp<n; rp++){
    cin>>a>>b;
    for(int i=0; i<=h; i++){
      //端からi++しながらdpを見ていく
      //ここがメインの漸化式
      dp[i+a] = min(dp[i+a], dp[i]+b);
    }
  }

  //問題の条件から最小値を引っ張る
  //範囲がdp[h]以降
  int ans = *min_element(dp.begin()+h, dp.end());
  cout<<ans<<endl;
}

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

typedef long long ll;
typedef pair<int, int> P;

const int INF = 1000000007;

int main(){
	ll n,k; cin>>n>>k;
	int a[110000]={0}, b[110000]={0};
	ll c[110000]={0};
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
		c[a[i]] += b[i];
	}
	ll cnt=0;
	for(int i=1;i<=100000;i++){
		cnt += c[i];
		if(cnt >= k){
			cout<< i <<endl;
			break;
		}
	}



	return 0;
}

Measured memory_bytes: 1920
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
using Plant = pair<double,string>;

int main(){
    int N;
    while(cin>>N,N){
        vector<Plant> V;
        V.clear();
        for(int i=0;i<N;i++){
            string L;
            cin>>L;
            int P,A,B,C,D,E,F,S,M;
            cin>>P>>A>>B>>C>>D>>E>>F>>S>>M;
            double value, t;
            value = -P + M*F*S;
            t = A+B+C+M*(D+E);
            V.emplace_back(-value/t,L);
        }
        sort(V.begin(), V.end());
        for(auto &v:V){
            cout<<v.second<<endl;
        }
        cout<<'#'<<endl;
    }
    return 0;
}

Measured memory_bytes: 3228
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(size_t i=0;i<(b);i++)
#define rREP(i,b) for(size_t i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(size_t i=(b)-1;i>=0;i--)
#define Foreach(item,collection) for(auto item:collection)
#define mod(i) ((i) % (ll)(1e9 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9 + 5))))
#define INF INT_MAX/2

int main(){
	int N;
	cin >> N;
	string S, ANS;
	cin >> S;
	ANS = S;
	size_t index = 0;
	int leftcnt = 0;
	while (index<S.size()) {
		if (S[index] == '(') {
			leftcnt++;
		}
		else {
			if (leftcnt) {
				leftcnt--;
			}
			else {
				ANS = '(' + ANS;
			}
		}
		index++;
	}
	if (leftcnt > 0) {
		REP(i, leftcnt) ANS += ')';
	}
	out(ANS);
}



Measured memory_bytes: 256
import java.util.Scanner;


public class Main {


	public static void main(String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		int[] cnt = new int[n];
		UnionFindTree uft = new UnionFindTree(n);
		for(int i = 0 ; i < n ; i++) {
			uft.makeSet(i);
		}

		for(int i = 0 ; i < m ; i++) {
			int a = Integer.parseInt(sc.next());
			int b = Integer.parseInt(sc.next());
			uft.union(a-1, b-1);
		}
		
		int max = 0;
		for(int i = 0 ; i < n ; i++) {
			cnt[uft.find(i)]++;
			max = Math.max(max, cnt[uft.find(i)]);
		}
		
		System.out.println(max);
	}
}

/**<h1>素集合データ構造 (Disjoint Set Forest)</h1>
 * <p>互いに素な集合。
 * <br>内部的には配列で定義されている。</p>
 */
class UnionFindTree {

    private int[] parent;    //親ノード
    private int[] rank;      //高さ or 次数

    /**<h1>コンストラクタ</h1>
     * <p></p>
     * @param size ： ノード数
     */
    public UnionFindTree(int size) {
        parent = new int[size];
        rank = new int[size];

        for (int i = 0; i < size; i++) {
            makeSet(i);
        }
    }

    /**<h1>ノードを作成する</h1>
     * <p>作成されたノードはルートとなる。
     * <br>元のサイズより大きいノードを指定した場合エラー。</p>
     * @param x ： ノード
     */
    public void makeSet(int x) {
        parent[x] = x;
        rank[x] = 0;
    }

    /**<h1>x, y の属している木を結合する</h1>
     * <p>同じ木の場合は何もしない。</p>
     * @param x ： ノード1
     * @param y ： ノード2
     */
    public void union(int x, int y) {
        final int xRoot = find(x);
        final int yRoot = find(y);

        if (rank[xRoot] > rank[yRoot]) {
            parent[yRoot] = xRoot;        //x の木に結合
        }
        else if(rank[xRoot] < rank[yRoot]) {
            parent[xRoot] = yRoot;        //y の木に結合
        }
        else if (xRoot != yRoot) {        //同じ高さで根が違うとき
            parent[yRoot] = xRoot;        //x の木に結合
            rank[xRoot]++;                //x の木の高さを加算
        }
    }

    /**<h1>属している木のルートを返す</h1>
     * <p>検索したノードは経路圧縮が行われる。</p>
     * @param x ： ノード
     * @return<b>int</b> ： ルートのノード
     */
    public int find(int x) {
        if (x != parent[x]) {    //根でないとき
            parent[x] = find(parent[x]);    //直接、根に繋ぐ(経路圧縮)
        }
        return parent[x];
    }

    /**<h1>同じ木に属しているかどうかを返す</h1>
     * <p>同じルートを持っているかで判別する。</p>
     * @param x ： ノード1
     * @param y ： ノード2
     * @return<b>boolean</b> ： true = 同じ木に属している
     */
    public boolean same(int x, int y) {
        return find(x) == find(y);
    }
}

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

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

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

int main(){
	int n; scanf("%d",&n);
	vector<lint> a(n),b(n);
	rep(i,n) scanf("%lld",&a[i]);
	rep(i,n) scanf("%lld",&b[i]);

	vector<lint> b2[30];
	rep(i,30){
		b2[i]=b;
		rep(j,n) b2[i][j]&=(1LL<<(i+1))-1;
		sort(b2[i].begin(),b2[i].end());
	}

	int ans=0;
	rep(i,30){
		lint cnt=0;
		rep(j,n){
			lint a2=a[j]&((1LL<<(i+1))-1);
			cnt+=lower_bound(b2[i].begin(),b2[i].end(),(1LL<<(i+1))-a2)
				-lower_bound(b2[i].begin(),b2[i].end(),(1LL<<i)-a2);
			cnt+=lower_bound(b2[i].begin(),b2[i].end(),(1LL<<(i+2))-a2)
				-lower_bound(b2[i].begin(),b2[i].end(),(1LL<<(i+1))+(1LL<<i)-a2);
		}
		if(cnt%2==1) ans|=1<<i;
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 50304
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e16;
#define int long long


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k; cin >> n >> k;
	vector<char> d(k); rep(i, k)cin >> d[i];
	for (int i = n; i <= 10 * n; i++) {
		string s = to_string(i);
		bool ok = true;
		rep(j, s.size()) {
			rep(l, k) {
				if (s[j] == d[l]) {
					ok = false;
				}
			}
		}
		if (ok) {
			cout << s << endl; return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define INF 5300000
int main(){
  int t,i,n,p[500],m[500][500],minm=INF,l=0,j=0,k=0,q=0;
  scanf("%d",&n);/*nは行列の数*/
  for(i=0;i<n;i++){
    scanf("%d%d",&p[i],&p[i+1]);
  }
  for(i=1;i<=n;i++){
    m[i][i]=0;
     
  }
  for(l=2;l<n+1;l++){
 
    for(i=1;i<n-l+2;i++){
      j=i+l-1;
      m[i][j]=INF;
 
     for(k=i;k<j;k++){
    q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
      
    if(q<=m[i][j]){
      m[i][j]=q;
 
    }
      }
    }}
  printf("%d\n",m[1][n]);
  return 0;
}



Measured memory_bytes: 2148
import math
while True:
    try:
        x, k, d = map(int, input().split());
        if x == 0:
            k %= 2;
            if k:
                print(abs(x - d));
            else :
                print(0);
        elif abs(x) - k * d > 0:
            print(abs(x) - k * d);
        elif x > 0:
            k -= x // d;
            k %= 2;
            x -= x // d * d;
            if k:
                print(abs(x - d));
            else:
                print(x);
        else:
            num = abs(x) // d + 1;
            x += num * d;
            k -= num;
            k %= 2;
            if k:
                print(abs(x - d));
            else:
                print(x);
    except EOFError:
        break;


Measured memory_bytes: 9204
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 3e5 + 17;

struct range
{
	int l, r;
	range() { }
};

struct fenwick
{
	int n;
	vector<int> F;
	fenwick() { }
	fenwick(int n) : n(n) { F.resize(n); }

	void add(int i, int x)
	{
		for (; i < n; i |= i + 1)
			F[i] += x;
	}

	int sum(int r)
	{
		int res = 0;

		for (; r >= 0; r &= r + 1, --r)
			res += F[r];

		return res;
	}
};

int q, n;
range Q[maxn];

bool read()
{
	if (scanf("%d", &q) != 1)
		return false;

	scanf("%d", &n);

	forn (i, q)
		scanf("%d %d", &Q[i].l, &Q[i].r);

	return true;
}

bool cmp(range a, range b) { return a.r - a.l < b.r - b.l || (a.r - a.l == b.r - b.l && a.l < b.l); }

void solve()
{
	sort(Q, Q + q, cmp);
	int sf = 0;
	fenwick F(n + 2);

	for (int i = 1; i <= n; ++i)
	{
		for (; sf < q && Q[sf].r - Q[sf].l + 1 < i; ++sf)
			F.add(Q[sf].l, 1), F.add(Q[sf].r + 1, -1);

		int res = q - sf;

		for (int j = 0; j <= n; j += i)
			res += F.sum(j);

		printf("%d\n", res);
	}
}

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif

	while (read())
		solve();

	return 0;
}


Measured memory_bytes: 3712
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  if(a < b * 2){
    cout << "0\n";
    return 0;
  }
  cout << a - b * 2 << "\n";
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t a, b;
  std::cin >> a >> b;
  std::cout << std::max<int64_t>(0, a - 2 * b) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
 
#define int long long int
#define pb push_back
#define mp make_pair
#define loop(i,x,n) for(int i=x;i<=n;i++)
#define rloop(i,x,n) for(int i=x;i>=n;i--)
#define ff first
#define ss second
#define N4RUTO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,  
tree_order_statistics_node_update>
ordered_set;
 
int32_t main(){
    N4RUTO;
    int t;
    t=1;
    // cin>>t;
    while(t--){
        int n;
        cin>>n;
        int ans = 0;
        loop(i,1,n){
            if(i%3==0 || i%5==0) continue;
            ans+=i;
        }
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<long long int,long long int>,null_type,less<pair<long long int,long long int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main()
{
    long long int n,ans=0;
    cin>>n;
    vector<long long int> a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    vector<long long int> x(n),y(n);
    map<long long int,long long int> hx,hy;
    for(int i=0;i<n;i++)
    {
        x[i]=i+1-a[i];
        y[i]=i+1+a[i];
        hx[x[i]]++;
        hy[y[i]]++;
    }
    for(int i=0;i<n;i++)
    {
        ans+=hy[x[i]];
        if(x[i]==y[i])
            ans--;
    }
    cout<<ans;
    return 0;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int x, a, b;
  cin >> x >> a >> b;
  int dist_a = abs(x - a), dist_b = abs(x - b);
  if (dist_a < dist_b) {
    cout << "A" << '\n';
  } else {
    cout << "B" << '\n';
  }

  return 0;
}

Measured memory_bytes: 3612
x,y=map(int,input().split())
if x==1 and y==1:
  print(1000000)
elif x<=3 and y>=4:
  print((x-4)*(-100000))
elif x>=4 and y<=3:
  print((y-4)*(-100000))
elif x<=3 and y<=3:
  print((x-4)*(-100000)+(y-4)*(-100000))
else:
  print(0)

Measured memory_bytes: 3060
import math

def append_factors(n, f, p):
    num_factors = 0
    while n % p == 0:
        num_factors += 1
        n //= p
    if num_factors != 0:
        f[p] = num_factors
    return n

def factors(n):
    ret = {}
    n = append_factors(n, ret, 2)
    n = append_factors(n, ret, 3)
    i = 6
    while i*i <= n + 1:
        p1, p2 = i - 1, i + 1
        n = append_factors(n, ret, i - 1)
        n = append_factors(n, ret, i + 1)
        i += 6
    if n != 1:
        ret[n] = 1

    return ret

def minimum_sum(x):
    # find the minimum integer n where n(n+1)/2 <= x
    # n(n+1) <= 2x < (n+1)(n+2)

    n = int(math.sqrt(2 * x))
    while n*(n + 1) > 2*x:
        n -= 1

    return n

def main():
    N = int(input())
    fs = factors(N)
    # print(fs)
    ans = 0
    for f in fs:
        ans += minimum_sum(fs[f])
    print(ans)

if __name__ == '__main__':
    main()


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

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<int> b(m);
    for (int i = 0; i < m; i++) cin >> b[i];
    ll s = accumulate(begin(a), end(a), 0LL);
    int ans = 0;
    int j = 0;
    for (int i = n; i >= 0; i--) {
        while (j < m && s + b[j] <= k) {
            s += b[j];
            j++;
        }
        if (s <= k) ans = max(ans, i + j);
        if (i > 0) s -= a[i - 1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4844
n = int(input())
a = list(map(int, input().split()))
mod = pow(10, 9) + 7
s = sum(a) % mod
ans = s * s % mod
for i in a:
    ans -= i * i
    ans %= mod
ans = ans * pow(2, mod - 2, mod) % mod
print(ans)

Measured memory_bytes: 94276
use std::io::{self, Read};

macro_rules! input {
    ($it: expr) => ($it.next().unwrap().parse().unwrap());
    ($it: expr, $T: ty) => ($it.next().unwrap().parse::<$T>().unwrap());
}

fn main() {
    let mut buf = String::new();
    io::stdin().read_to_string(&mut buf).unwrap();

    let mut it = buf.split_whitespace();

    let a: u64 = input!(it);
    let b: u64 = input!(it);

    println!("{}", a * b);
}


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

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

int main(){
    int N;
    ll x;
    cin >> N >> x;
    vector<ll> a(N);
    rep(i, N){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    a.push_back(0);
    ll rest = x;
    int count = 0; //満足させられた人数
    rep(i, N){
        rest -= a[i];
        if(i == N - 1){
            if(rest == 0){
                count++;
            }
        }else{
            if(rest >= 0){
                count++;
            }else{
                break;
            }
        }
    }

    cout << count << endl;

    return 0;
}

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

using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    
    if(a+b<24) cout<<a+b<<endl;
    else cout<<a+b-24<<endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

        while (true) {
            int n = Integer.parseInt(sc.next());

            if (n == 0)break;

            List<Integer> nums = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                nums.add(Integer.parseInt(sc.next()));
            }

            int max = Integer.MIN_VALUE;
            for (int i = 0; i < nums.size(); i++) {
                int sum = 0;
                for (int j = i; j < nums.size(); j++) {
                    sum += nums.get(j);
                    max = (sum > max)? sum : max;
                }
            }

            System.out.println(max);
        }
    }
}

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

int main(){
  ll n;
  cin >> n;
  if (n % 2 == 1){
    cout << 0 << endl;
    return 0;
  }
  ll ans = 0, div = 10;
  while (div <= n){
    ans += n / div;
    div *= 5;
  }
  cout << ans << endl;

  return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

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

    ll H,W,K;
    ll ans = 0;
    string S;
    cin >> H >> W >> K;

    char c[H + 1][W + 1];
    char d[H + 1][W + 1];

    REP(i,H){
        REP(j,W){
            cin >> c[i][j];
        }
    }

    for (int bit = 0; bit < (1 << H); ++bit)
    {
        for (int bit1 = 0; bit1 < (1 << W); ++bit1)
        {
            REP(i, W)
            {
                REP(j, H)
                {
                    d[j][i]= c[j][i];
                }
            }

            for (int i = 0; i < H; ++i)
            {
                if (bit & (1 << i))
                { 
                    REP(j,W){
                        d[i][j] = 'x';
                    }
                }
            }

            for (int i = 0; i < W; ++i)
            {
                if (bit1 & (1 << i))
                {
                    REP(j, H)
                    {
                        d[j][i] = 'x';
                    }
                }
            }

            /*REP(i, H)
            {
                REP(j, W)
                {
                    cout << d[i][j];
                }
                cout << " " << endl;
            }*/

            ll count = 0;

            REP(i, H)
            {
                REP(j, W)
                {
                    if(d[i][j]=='#'){
                        count++;
                    }
                }
            }

            //cout << bit<<" "<<bit1<<" "<<count << endl;

            if(count==K){
                ans++;
            }
    }
}

cout << ans << endl;
}


Measured memory_bytes: 3644
import std.algorithm,
       std.string,
       std.range,
       std.stdio,
       std.conv;

void main() {
  int N = readln.chomp.to!int;
  string S = readln.chomp;

  char l = '(',
       r = ')';

  int ls,
      rs;
  int als;

  foreach (c; S) {
    if (c == l) { ls++; }
    else        { rs++; }

    if (ls - rs < 0) {
      als++;
      ls = 0;
      rs = 0;
    }
  }

  als.iota.each!(_ => write(l));
  write(S);
  (ls-rs).iota.each!(_ => write(r));
  writeln;
}


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

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

    int x = 7 % k;

    set<int> s;

    int ans = 0;
    while(s.count(x) == 0) {
        ans++;
        if (x == 0) {
            cout << ans << endl;
            return 0;
        }
        s.insert(x);
        x = (x * 10 + 7) % k;
    }

    cout << -1 << endl;
    return 0;
}

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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}


int N;
int A[100010];
int B[100010];
int C[100010];
int dp[100010][4];

int main(){
    cin >> N;
    for(int i = 0; i < N; i++)
        cin >> A[i] >> B[i] >> C[i];
    for(int i = N; i >= 0; i--){
        for(int j = 0; j < 4; j++){
            int res = 0;
            if(i != N){
                int vals[3] = {A[i], B[i], C[i]};
                for(int k = 0; k < 3; k++){
                    if(j == k) continue;
                    res = max(res, dp[i + 1][k] + vals[k]);
                }
            }
            dp[i][j] = res;
        }
    }
    cout << dp[0][3] << endl;


    return 0;
}


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

int main(){
	int a, b;
  	cin >> a >> b;
  	if(a % 2 == 1 && b % 2 == 1 ){
    	cout << "Odd" << endl;
    }
  	else{
    	cout << "Even" << endl;
    }
}

Measured memory_bytes: 256
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import lru_cache, reduce
from math import gcd
from operator import add, itemgetter, mul, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353



r = int(sys.stdin.buffer.readline())
a = r * 2 * math.pi
print(a)


Measured memory_bytes: 27076
import sys
N,M=map(int,input().split())
edge=[]
for i in range(M):
    a,b,c=map(int,input().split())
    edge.append([a-1,b-1,-c])
inf=10**30
dist=[inf]*N
dist[0]=0
for i in range(N):
    for x,y,z in edge:
        if dist[y]<= dist[x]+z:
            continue
        dist[y]=dist[x]+z
ans = dist[N-1]
visit=[False]*N
for i in range(N):
    for x,y,z in edge:
        if visit[x]:
            visit[y]=True
        if dist[y]<= dist[x]+z:
            continue
        visit[y]=True
        dist[y]=dist[x]+z
        
if visit[N-1]:
    print('inf')
else:
    print(-dist[N-1])

Measured memory_bytes: 47192
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

int main(){
    ll h,w;
    cin >> h>> w;
    ll ans1,ans2,ans3,ans4;
    if(h%3==0||w%3==0){
        cout<<0<<endl;
        return 0;
    }else{
        ll hh;
        if(h%3==1){
            hh=h/3;
        }else{
            hh=h/3+1;
        }
        ll s1=w*(hh);
        ll s2=(w/2)*(h-hh);
        ll s3=(w-w/2)*(h-hh);
        cerr<<s1<<' '<<s2<<' '<<s3<<endl;
        ans1=max(s1,max(s2,s3))-min(s1,min(s2,s3));
        s1=w*hh;
        s2=w*((h-hh)/2);
        s3=w*(h-hh-((h-hh)/2));
        ans3=max(s1,max(s2,s3))-min(s1,min(s2,s3));
        ll ww;
        if(w%3==1){
            ww=w/3;
        }else{
            ww=w/3+1;
        }
        s1 =h*(ww);
        s2=(h/2)*(w-ww);
        s3=(h-h/2)*(w-ww);
        cerr<<s1<<' '<<s2<<' '<<s3<<endl;
        ans2=max(s1,max(s2,s3))-min(s1,min(s2,s3));
        s1=ww*h;
        s2=h*((w-ww)/2);
        s3=h*(w-ww-((w-ww)/2));
        ans4=max(s1,max(s2,s3))-min(s1,min(s2,s3));
    }
    ll ans=min(min(ans1,ans4),min(ans2,ans3));
    cout<<ans<<endl;
    return 0;
}

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

if K % 2 == 0 or K % 5 == 0:
    i = -1
else:
    if K % 7 == 0:
        K = K//7
    L = 9*K
    a = 10 % L
    if a == 1:
        i = 1
    else:
        for i in range(2, L+1):
            a = (a*10) % L
            if a == 1:
                break
print(i)

Measured memory_bytes: 9124
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
 
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
   
using namespace std;
   
typedef long long ll;
typedef pair <double,double> P;
typedef pair <int,P> PP;
   
static const double EPS = 1e-12;
   
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

class UnionFindTree {
private:
  int* par;
  int* rank;
  int* weight;
  int* price;
public:
  UnionFindTree(vector<int> prices){
    int n = prices.size();
    par = new int[n]();
    rank = new int[n]();
    price = new int[n]();
    for(int i = 0; i < n; i++){
      par[i] = i;
      rank[i] = 0;
      price[i] = prices[i];
    }
  }

  ~UnionFindTree(){
    delete[] rank;
    delete[] par;
    delete[] price;
  }

  int find(int x){
    if(par[x] == x){
      return x;
    } else {
      return par[x] = find(par[x]);
    }
  }

  void unite(int x,int y){
    x = find(x);
    y = find(y);
    if (x == y) return;

    if(rank[x] < rank[y]){
      par[x] = y;
      price[y] = min(price[x],price[y]);
    } else {
      par[y] = x;
      price[x] = min(price[x],price[y]);
      if (rank[x] == rank[y]) rank[x]++;
    }
  }

  int get_min_price(int x){
    return price[find(x)];
  }
  bool same(int x,int y){
    return find(x) == find(y);
  }
};

int name2idx(map<string,int>& dict, string name){
  if(dict.find(name) == dict.end()){
    int res = dict.size();
    dict[name] = res;
    return res;
  }
  return dict[name];
}

int main(){
  int num_of_foodstuffs;
  while(~scanf("%d",&num_of_foodstuffs)){
    map<string,int> dict;
    vector<int> prices;
    for(int food_stuff_i = 0; food_stuff_i < num_of_foodstuffs; food_stuff_i++){
      string name;
      int price;
      cin >> name >> price;

      // for later str2idx process
      name2idx(dict,name);

      prices.push_back(price);
    }
    int num_of_magics;
    scanf("%d",&num_of_magics);

    UnionFindTree uft(prices);
    for(int magic_i = 0; magic_i < num_of_magics; magic_i++){
      string from_food, to_food;
      cin >> from_food >> to_food;
      uft.unite(name2idx(dict,from_food),name2idx(dict,to_food));
    }

    int res = 0;
    for(int food_stuff_i = 0; food_stuff_i < num_of_foodstuffs; food_stuff_i++){
      res += uft.get_min_price(food_stuff_i);
    }
    printf("%d\n",res);
  }
}

Measured memory_bytes: 1960
// #include <bits/stdc++.h>
// #define ll long long int
// #define vi vector<ll>
// #define vvi vector<vector<ll>>
// #define pii pair<ll, ll>
// #define pb push_back
// #define rep0(i, n) for(ll i = 0;i<n;i++)
// #define rep1(i, n) for(ll i = 1;i<n;i++)
// #define all(v) v.begin(),v.end()
// #define fast                          
//     ios_base::sync_with_stdio(false); 
//     cin.tie(NULL);                    
//     cout.tie(NULL);
// using namespace std;
// const int N = 2e5 + 5;

// vector<int> vis(N, 0);
// vector<int> adj[N];
// int mx = 0;

// int dfs(int u){
//     int ans = 0;
//     if(!vis[u]){
//         vis[u] = true;
//         ans++;
//         for(auto v: adj[u]){
//             ans += dfs(v);
//         }
//     }
//     return ans;
// }

// void solve(){
//     int n, m;
//     cin >> n >> m;
//     for(int i=0; i<m; i++){
//         int x, y;
//         cin >> x >> y;
//         x--;y--;
//         adj[x].push_back(y);
//         adj[y].push_back(x);
//     }
//     for(int i=0; i<n; i++){
//         if(!vis[i]){
//             mx = max(mx, dfs(i));
//         }
//     }
//     cout << mx;
// }
 
// int main()
// {
//     fast;
//     solve();
//     // int t;
//     // cin >> t;
//     // while(t--){
//     //     solve();
//     // }
//     return 0;
// }
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<ll, ll>
#define pb push_back
#define rep0(i, n) for(ll i = 0;i<n;i++)
#define rep1(i, n) for(ll i = 1;i<n;i++)
#define all(v) v.begin(),v.end()
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;
const int N = 1e5 + 5;

vector<int> parent;
vector<int> sizee;

int find(int x){
    if(parent[x] == x){
        return x;
    }
    // path compression
    else{
        int a = find(parent[x]);
        parent[x] = a;
        return a;
    }
}

void connect(int x, int y){
    int a = find(x);
    int b = find(y);
    if(a!=b){
        // union by size
        if(sizee[a]>sizee[b]){
            parent[b] = a;
            sizee[a] += sizee[b];
        }
        else{
            parent[a] = b;
            sizee[b] += sizee[a];
        }
    }
}

void solve(){
    int n, m;
    cin >> n >> m;
    parent.resize(n);
    sizee.resize(n);
    for(int i=0; i<n; i++){parent[i] = i;sizee[i]=1;}
    for(int i=0; i<m; i++){
        int x, y;
        cin >> x >> y;
        x--;y--;
        connect(x, y);
    }
    vector<int> temp(n, 0);
    for(int i=0; i<n; i++){
        temp[find(parent[i])]++;
    }
    cout << *max_element(temp.begin(), temp.end());
}
 
int main()
{
    fast;
    solve();
    // int t;
    // cin >> t;
    // while(t--){
    //     solve();
    // }
    return 0;
}


Measured memory_bytes: 5520
#include <cstdio>
#include <algorithm>

using namespace std;

const int MAXN = 100005;

int n, A[MAXN];

int main() {
    scanf("%d", &n);

    for (int i = 1; i <= n; i++) {
        scanf("%d", A + i);
    }

    int res = 0;
    for (int i = 1; i <= n; i++) {
        if (A[i] != i) continue;
        if (i < n && A[i + 1] == i + 1) {
            res++;
            swap(A[i], A[i + 1]);
        }
        else if (i > 1 && A[i - 1] == i - 1) {
            res++;
            swap(A[i], A[i - 1]);
        }
        else {
            res++;
            swap(A[i], A[i + 1]);
        }
    }

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

    return 0;
}


Measured memory_bytes: 512
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;

public class Main {

  static int mod = 1000000007;

  public static void main(String[] args) throws FileNotFoundException {

   // Scanner cin = new Scanner(new FileReader("input.txt"));
   Scanner cin = new Scanner(System.in);

    int n = cin.nextInt();
    double x = cin.nextDouble();

    double[] burgur = new double[n];
    double[] patty = new double[n];
    burgur[0] = 5;
    patty[0] = 3;
    for (int i=1;i<n;i++) {
      burgur[i] = burgur[i-1]*2+3;
      patty[i] = patty[i-1]*2+1;
    }
    int pos = 0;

    double res = findRes(n, x, burgur, patty, 0);
    System.out.println((long)res);

  }

  public static double findRes(int n, double xNum, double[] burger, double[] patty, double eaten) {
    if (n==0) {
      if (xNum==0) return eaten;
      else if (xNum>0&&xNum<4) return eaten+xNum;
      else return eaten+3;
    }
    else {
      if (xNum==0) return eaten;
      else if (xNum>0&&xNum<=burger[n-1]) return eaten+findRes(n-1, xNum-1, burger, patty, eaten);
      else if (xNum == burger[n-1]+1) return eaten+patty[n-1] + 1;
      else if (xNum > burger[n-1]+1&&xNum<=2*burger[n-1]+1)
        return eaten+patty[n-1]+1+ findRes(n-1, xNum-2-burger[n-1], burger, patty, eaten);
      else return eaten + 2*patty[n-1] + 1;
    }
  }


}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
 
constexpr int INF = 1e9;
constexpr int MOD = 1e9+7;
 
int main() {
    int H,W,M;
    cin >> H >> W >> M;

    vi h(M),w(M);
    map<int,int> hmp,wmp;
    set<P> st;
    rep(i,M){
        cin >> h[i] >> w[i];
        hmp[h[i]]++;
        wmp[w[i]]++;
        st.insert(P(h[i],w[i]));
    }

    int hmax = 0,wmax = 0;
    for(auto x : hmp) hmax = max(hmax,x.second);
    for(auto x : wmp) wmax = max(wmax,x.second);

    vi hh,ww;
    for(auto x : hmp) if(hmax == x.second) hh.push_back(x.first);
    for(auto x : wmp) if(wmax == x.second) ww.push_back(x.first);

    int add = 0;
    for(auto x : hh){
        for(auto y : ww){
            if(st.find(P(x,y))==st.end()){
                add = 1;
                break;
            }
        }
        if(add) break;
    }

    cout << hmax+wmax-1+add << endl;
 
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n,h[20]; cin>>n;
	rep(i,n) cin>>h[i];

	int ans=0;
	rep(i,n){
		bool ok=true;
		rep(j,i) if(h[j]>h[i]) ok=false;
		if(ok) ans++;
	}
	cout<<ans<<endl;

	return 0;
}


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

#define FasterIO  ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0) ;

int main() {
    int h , a ;
    cin >> h >> a ;
    if(h % a == 0) {
        cout << h / a << "\n" ;
    } else {
        cout << h / a + 1 << "\n" ;
    }
    return 0 ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;
// typedef long long int 
typedef long long int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
// typedef pair<ll,ll> pll;
const int modi = 1e9 + 7;
const long long INF = 1e9 + 10;
const ll mxn = 131072*2;
ll t[2*mxn], lz[2*mxn];

void build(pair<ll,ll>* a, int v,int tl,int tr){
	if(tl==tr){
		t[v] = a[tl].se;
		// cout << a[tl].fi << " " << a[tl].se << " " << endl;
	}
	else{
		ll tm = tl+tr>>1;
		build(a,v<<1,tl,tm);
		build(a,v<<1|1,tm+1,tr);
		t[v] = (t[v<<1]+t[v<<1|1]);
	}
}

void update(int v,int tl,int tr, int l , int r, ll val){
	

	if(l>r || tl>r || tr<l) return;

	if(lz[v]!=0){
		t[v]+=(tr-tl+1)*lz[v];
		if(tl!=tr){
			lz[v<<1]+=lz[v];
			lz[v<<1|1]+=lz[v];
		}
		lz[v] = 0;
	}

	if(tl>=l && tr<=r){
		t[v]+=(tr-tl+1)*val;
		if(tl!=tr){
			lz[v<<1]+=val;
			lz[v<<1|1]+=val;
		}
		return;
	}

	ll tm = tl+tr>>1;
	update(v<<1,tl,tm,l,r,val);
	update(v<<1|1,tm+1,tr,l,r,val);
	t[v] = (t[v<<1]+t[v<<1|1]);
}

ll query(int v, int tl,int tr,int l, int r){

	if(l>r || tl>r || tr<l)
		return 0;

	if(lz[v]!=0){
		t[v]+=(tr-tl+1)*lz[v];
		if(tl!=tr){
			lz[v<<1] += lz[v];
			lz[v<<1|1] += lz[v];
		}
		lz[v] = 0;
	}

	if(tl>=l && tr<=r){
		return t[v];
	}

	ll tm = tl+tr>>1;
	return (query(v<<1,tl,tm,l,r)+query(v<<1|1,tm+1,tr,l,r));

}


bool cmp(pii a, pii b){
	return a.fi<b.fi || (a.fi == b.fi && a.se<b.se);
}

void solve(){
	ll n,d,a;
	cin >> n >> d >> a;

	pair<ll,ll> mon[n];
	for(ll i =0;i<n;i++){
		cin >> mon[i].fi >> mon[i].se;
		// nmon[i].fi = -mon[i].fi;
		// nmon[i].se = mon[i].se;
		// cout << nmon[i].fi << " " << nmon[i].se << endl;
	}
	sort(mon,mon+n,cmp);
	// sort(nmon,nmon+n,cmp);
	build(mon,1,0,n-1);
	// for(ll i = mxn;i<mxn+n;i++){
	// 	cout << t[i] << " val of tree" << endl;
	// }
	ll ans = 0;
	for(ll i =0;i<n;i++){
		if(query(1,0,n-1,i,i)<=0LL)continue;
		int l = i;
		int r = lower_bound(mon,mon+n,mp(mon[i].fi + 2*d,INF)) - (mon);
		ll del  = -a;
		ll times = ceil((query(1,0,n-1,l,l)*1.0/a));
		// cout << i << " " << l << " " << r << endl;
		// cout << i << " " << l << " " << r  << "  " << times<< endl;

		ans+=times;
		del = -1*a* times;
		update(1,0,n-1,l,r-1,del);
	}
	// memset(t,0,sizeof(t));
	// memset(lz,0,sizeof(lz));
	// build(nmon,1,0,n-1);
	// ll newans = 0;
	// for(ll i =0;i<n;i++){
	// 	if(query(1,0,n-1,i,i)<=0)continue;
	// 	int l = i;
	// 	int r = upper_bound(nmon,nmon+n,mp(nmon[i].fi + 2*d,INF)) - (nmon);
	// 	ll del  = -a;
	// 	ll times = ceil(query(1,0,n-1,l,l)*1.0/a);
	// 	cout << i << " " << l << " " << r  << "  " << times<< endl;
	// 	newans+=times;
	// 	del *=times;
	// 	update(1,0,n-1,l,r-1,del);
	// }
	// ans = min(ans,newans);
	cout << ans << endl;

}

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

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 11520
import sys
sys.setrecursionlimit(10**7)

def input(): return sys.stdin.readline()[:-1]
mod = 10**9 + 7
def readInt():return int(input())
def readIntList():return list(map(int,input().split()))
def readStringList():return list(input())
def readStringListWithSpace():return list(input().split())
def readString():return input()

x = readInt()
print("Yes" if x >= 30 else "No")

Measured memory_bytes: 9088
#include <iostream>

int main ()
{
	int x, y;
	while ( std::cin >> x >> y ) {
		if ( (x | y) == 0)
			break;
		if (x < y)
			std::cout << x << " " << y << std::endl;
		else
			std::cout << y << " " << x << std::endl;
	}
}

Measured memory_bytes: 2996
//問題URL
    //

    //解き方メモ
    //
    
    #include<iostream>
    #include<string>
    using namespace std;

    int main(){
        string sd,t;

        //sd,t入力
        cin >> sd >> t;

        bool flag;
        for(int i = sd.length()-t.length(); i>=0; i--){ //i:tが当てはまるか試行する部分文字列の先頭位置
            string ts = sd.substr(i,t.length()); //ts:sの部分文字列。tが当てはまるか判定する対象

            //tsにtが当てはまるか判定。当てはならない時にbreak
            flag = true;
            for(int j=0;j<ts.length();j++){
                if(ts[j] != t[j] && ts[j] != '?') {
                    flag = false;
                    break;
                }
            }
            if(flag){ //一致した場合
                sd.replace(i,t.length(),t); //tに置き換え
                break;
            }
        }

        //tが当てはまった場合
        if(flag){
            //?を全てa（辞書順先頭文字）に置換
            for(int i=0;i<sd.length();i++){
                if(sd[i]=='?'){
                    sd[i] = 'a';
                }
            }
        } else {
            sd = "UNRESTORABLE";
        }

        //出力
        cout << sd << endl;

        return 0;
    }

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

int N, L;
string str[110];

int main() {
  cin >> N >> L;
  for (int i = 0; i < N; i++) cin >> str[i];
  // 文字列を昇順に並び替え、前から順に出力していく
  //sort(str, str+N);
  // バブルソートで文字列を昇順に並び替える
  for (int i = 0; i < N-1; i++) {
    for (int j = N-1; j > i; j--) {
      if (str[j] < str[j-1]) {
        swap(str[j], str[j-1]);
      }
    }
  }
  // 昇順に並んでいるので、前から出力していく
  for (int i = 0; i < N; i++) cout << str[i];
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    string s; cin >> s;
    cout << s.substr(0, 3) << endl;
    return 0;
}


Measured memory_bytes: 3600
#!python3

def iim():
    return map(int, input().rstrip().split())

from math import factorial
def calc(a):
    N = len(a)
    aa = []
    bk = [factorial(i) for i in range(N-1, 0, -1)]

    bl = [0] * N
    for i in range(N-1, 0, -1):
        x = a[i]
        for j in range(i):
            if a[j] > x:
                bl[j] += 1

    n = 0
    for i in range(0, N-1):
        n += bk[i] * bl[i]

    return n

def resolve():
    N = int(input())
    P = list(iim())
    Q = list(iim())

    print(abs(calc(P) - calc(Q)))

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3064