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

using namespace std;

typedef long long ll;
typedef long double ld;

#define EPS 1e-12
//#define B 1000000

bool isPrime(ll n) {
	if (n == 1) return false;
	if (n == 2) return true;

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

ll MOD = 4294967311LL;
ll mod(ll x) {
	return (x % MOD + MOD) % MOD;
}

ll mul(ll x, ll n) {
	ll ret = 0;
	ret += mod( x * (n % (1 << 16)) ); n >>= 16;
	ret += mod( mod( x * (n % (1 << 16)) ) << 16 ); n >>= 16;
	ret += mod( mod( mod( x * (n % (1 << 16)) ) << 16 ) << 16 ); n >>= 16;
	return ret;
/*
	ll ret = 0;

	if (x <= (1LL << 31) && n <= (1LL << 32)) {
		return x * n % MOD;
	}

	for (ll i = 0, k = 1; k <= n; ++i, k <<= 1) {
		if (n & k) {
			ret = mod(ret + x);
		}
		x = mod(x + x);
	}
	return ret;
*/
}
ll power(ll x, ll n) {
	ll ret = 1;
	for (ll i = 0, k = 1; k <= n; ++i, k <<= 1) {
		if (n & k) {
			ret = mul(ret, x);
		}
		x = mul(x, x);
	}
	return ret;
}

ll Div(ll x, ll n) {
	return mul(x, power(n, MOD-2));
}
ll cal(vector<ll> op, vector<ll> Y) {
	ll Z = 1;
	ll X = 0;
	int N = op.size();
	bool zf = false;
	for (int i = N-1; i >= 0; --i) {
		bool f = zf ^ (Y[i] < 0);
		ll y = abs(Y[i]);
		switch (op[i]) {
			case 2: f = !f;
			case 1:
				X = mod(X + (f ? -1 : 1) * mul(Z, y));
				break;

			case 3: Z = mul(Z, y); zf = f; break;
			case 4: Z = Div(Z, y); zf = f; break;
		}
	}
	return X;
}

int main() {
//	while ( !isPrime(MOD) ) ++MOD;
//	cout << MOD << endl;
//	return 0;
	ll X = 0;

	int N; cin >> N;
	vector<ll> op(N), Y(N);
	for (int i = 0; i < N; ++i) {
		cin >> op[i] >> Y[i];
	}

	ll ans = cal(op, Y);

	if (ans >= (1LL << 31)) cout << ans-MOD << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 4164
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> X(N), Y(N);
    for(int i = 0; i < N; i++) {
        int x;
        cin >> x;
        X.at(i) = x;
        Y.at(i) = x;
    }
    sort(Y.begin(), Y.end());
    
    for(int i = 0; i < N; i++) {
        if(X.at(i)<=Y.at(N/2-1)) cout << Y.at(N/2) << endl;
        else cout << Y.at(N/2-1) << endl;
    }
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;

signed main() {
    int N, M;
    map<string, int> bm, rm;
    cin >> N;
    rep(i, N) {
        string s;
        cin >> s;
        bm[s]++;
    }
    cin >> M;
    rep(i, M) {
        string t;
        cin >> t;
        rm[t]++;
    }

    int res = 0;
    for(auto& p: bm) {
        string s = p.fi;
        res = max(res, p.se-rm[s]);
    }

    cout << res << endl;
    return 0;
}

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

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	int res = 0;
	map<int, int> mp;
	int sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		mp[A[i]]++;
		sum += A[i];
	}
	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int b, c;
		cin >> b >> c;
		sum += (c - b) * mp[b];
		mp[c] += mp[b];
		mp[b] = 0;
		cout << sum << "\n";
	}
	return 0;
}

Measured memory_bytes: 9908
#![allow(non_snake_case)]
#![allow(unused_imports)]
 
use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;

#[derive(Debug)]
struct Board {
    board: Vec<Vec<char>>,
    queue: VecDeque<(i32, i32)>,
    dist: Vec<Vec<i64>>,
}

impl Board {
    fn bfs(&mut self, start: (i32, i32)) {
        let x: Vec<i32> = vec![0, 0, 1, -1];
        let y: Vec<i32> = vec![1, -1, 0, 0];

        self.queue.push_back(start);
        self.dist[start.0 as usize][start.1 as usize] = 0;
        
        while !self.queue.is_empty() {
            // dbg!(&self.queue);
            let v = self.queue.pop_front().unwrap();
            // dbg!(&v);

            for i in 0..4 {
                let next_start = (v.0 + x[i], v.1 + y[i]);
                // dbg!(next_start);
                if next_start.0 < 0 
                    || next_start.1 < 0 
                    || next_start.0 >= self.board.len() as i32 
                    || next_start.1 >= self.board[0].len() as i32 {
                    continue;
                }
                if self.dist[next_start.0 as usize][next_start.1 as usize] != -1 {
                    continue;
                }
                if self.board[next_start.0 as usize][next_start.1 as usize] == '#' {
                    continue;
                } 
                
                self.dist[next_start.0 as usize][next_start.1 as usize] = self.dist[v.0 as usize][v.1 as usize] + 1;
                self.queue.push_back(next_start);
            }
        }
    }
}

#[fastout]
fn main() {
    input!{
        H: usize,
        W: usize,
        board: [Chars; H],
    }

    let dist: Vec<Vec<i64>> = vec![vec![-1; W]; H];

    let mut obstacle_num: usize = 0;
    for b in board.iter() {
        for c in b.iter() {
            if *c == '#' { obstacle_num += 1 }
        }
    }

    let not_obstacle_num = H * W - obstacle_num;

    let mut graph = Board {
        board: board,
        queue: VecDeque::new(),
        dist: dist,
    };

    graph.bfs((0, 0));
    dbg!(&obstacle_num, &not_obstacle_num);
    if graph.dist[H-1][W-1] == -1 {
        println!("{}", -1)
    } else {
        println!("{}", not_obstacle_num - graph.dist[H-1][W-1] as usize - 1);
    }
}


Measured memory_bytes: 2180
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//



//----------//

int main(){
  int N; cin >> N; int a[N];
  rep(i, N){
    cin >> a[i];
  }
  int left = 0, right = 0, bits=0; ll ans = 0;
  rep(left, N){
    while(right<N && (bits^a[right])==(bits+a[right])){
      bits^=a[right]; right++;
    }
    ans+=right-left;
    if(right==left) right++;
    else bits^=a[left];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<set>
#include<queue>
#include<algorithm>
#define maxn 100005
using namespace std;
typedef pair<int,int> PII;
typedef set<int>::iterator siter;
int n,fa[maxn],cnt;
queue<PII> q;
set<int> G1[maxn],G2[maxn];
int find(int x)
{
	if(fa[x]==x) return x;
	return fa[x]=find(fa[x]);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		G1[u].insert(v); G1[v].insert(u);
	}
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		G2[u].insert(v); G2[v].insert(u);
		if(G1[u].find(v)!=G1[u].end()) q.push(PII(u,v));
	}
	while(!q.empty())
	{
		int u=q.front().first,v=q.front().second; q.pop();
		u=find(u),v=find(v);
		if(u==v) continue;
		if(G1[u].size()+G2[u].size()>G1[v].size()+G2[v].size()) swap(u,v);
		fa[u]=v;
		G1[u].erase(v); G1[v].erase(u);
		G2[u].erase(v); G2[v].erase(u);
		for(siter it=G1[u].begin();it!=G1[u].end();it++)
		{
			int x=*it;
			G1[x].erase(u); G1[x].insert(v);
			G1[v].insert(x);
			if(G2[x].find(v)!=G2[x].end()) q.push(PII(x,v));
		}
		for(siter it=G2[u].begin();it!=G2[u].end();it++)
		{
			int x=*it;
			G2[x].erase(u); G2[x].insert(v);
			G2[v].insert(x);
			if(G1[x].find(v)!=G1[x].end()) q.push(PII(x,v));
		}
	}
	int cnt=0;
	for(int i=1;i<=n;i++)
		if(find(i)==i) cnt++;
	printf("%s\n",cnt==1?"YES":"NO");
}


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

int main(){
  long long N, K;
  cin >> N >> K;
  long long ans = 0;
  if (K%2 == 1){
    ans = (N/K)*(N/K)*(N/K);
  }
  else {
    ans = (N/K)*(N/K)*(N/K);
    ans += ((N+K/2)/K)*((N+K/2)/K)*((N+K/2)/K);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)
from numba import njit


@njit
def sum_g(N):
    res = 0
    for i in range(1,N+1):
        end = N // i
        res += end * (end + 1) * i // 2
    return res


def main():
    N = int(input())

    res = sum_g(N)

    print(res) 


main()


Measured memory_bytes: 108856
var
    n,i,j,k,tmp: Integer;
    d:array[1..100] of Integer;
    flag:Boolean;
begin
    readln(n);
    for i := 1 to n do
    begin
        readln(tmp);
        flag:=false;
        for j := 1 to k do
        begin
            if (d[j]=tmp) then
            begin
                flag:=true;
                break;
            end;
        end;
        if not flag then
        begin
            inc(k);
            d[k]:=tmp;
        end; 
    end;
    writeln(k);
    readln;
end.

Measured memory_bytes: 128
def main():
  import sys
  input = sys.stdin.readline
  n,m=map(int,input().split())
  mod=pow(10,9)+7
  ans=[1]*(n+1)
  for _ in [0]*m:
    ans[int(input())]=0
  for i in range(2,n+1):
    if ans[i]>0:
      ans[i]=(ans[i-1]+ans[i-2])%mod
  print(ans[-1])
if __name__ == '__main__':
    main()

Measured memory_bytes: 6900
#include "bits/stdc++.h"
using namespace std;
int main() {
	int N, L, i, total = 0, ans = 0;
	int apples[300], temp[300];
	
	cin >> N >> L;
	for (i = 0; i < N; i++) {
		apples[i] = L + i;
		total += apples[i];
	}
	for (i = 0; i < N; i++) {
		temp[i] = abs(total - apples[i]);
		if (ans < temp[i]) ans = total - apples[i];
		if (abs(total) == temp[i]) {
			ans = total;
			break;
		}
	}
	cout << ans <<  endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 0x7fffffff
typedef long long ll;
typedef long double ld;

typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<ld> vld;

#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()

const int N = 2e5 + 100;
int f[N], s[N];

int Find(int x)
{
	stack<int> stk;
	while(f[x] != -1) stk.push(x), x = f[x];
	while(!stk.empty()) f[stk.top()] = x, stk.pop();
	return x;
}

int main()
{
	fastIO;

	int n, m; cin >> n >> m;
	int ans = 1;

	for(int i = 1; i <= n; i++) f[i] = -1, s[i] = 1;
	for(int i = 0; i < m; i++)
	{
		int a, b; cin >> a >> b;
		a = Find(a); b = Find(b);
		if(a == b) continue;
		f[a] = b; s[b] += s[a];
		ans = max(ans,s[b]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5208
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  int n;
  cin>>n;
  vector<int> v(1000009,0);
  //vector<int> v1(1000009,0)
  int ans=0;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  sort(all(a));
  rep(i,n){
    if(v[a[i]]!=0) continue;
    int now=1;
    while(now*a[i]<1000001){
      v[now*a[i]]=1;
      now++;
    }
    if(a[i]==a[i+1]) continue;
    ans++;
  }
  
  cout<<ans<<endl;
}
    

Measured memory_bytes: 8796
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

ll H, W;
ll c[11][11] = {};
ll A[200][200] = {};
ll N = 10;
void wf() {
	rep(k, 0, N) {
		rep(i, 0, N) {
			rep(j, 0, N) {
				c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
			}
		}
	}
}

int main() {
	cin >> H >> W;

	rep(i, 0, N) {
		rep(j, 0, N) {
			c[i][j] = 1 << 29;
		}
	}

	rep(i, 0, N) {
		rep(j, 0, N) {
			cin >> c[i][j];
		}
	}
	rep(i, 0, H) {
		rep(j, 0, W) {
			cin >> A[i][j];
		}
	}

	wf();

	ll sum = 0;
	rep(h, 0, H) {
		rep(w, 0, W) {
			if (A[h][w] != -1 && A[h][w] != 1) {
				sum += c[A[h][w]][1];
			}
		}
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int abs(int a) {
  return a > 0 ? a : -a;
}

int main(void) {
  int i, j, k, l, d, n, max = 0;
  scanf("%d%d", &d, &n);
  int dp[d][n], t[d], a[n], b[n], c[n];
  for(i = 0; i < d; ++i) for(j = 0; j < n; ++j) dp[i][j] = 0;
  for(i = 0; i < d; ++i) scanf("%d", &t[i]);
  for(i = 0; i < n; ++i) scanf("%d%d%d", &a[i], &b[i], &c[i]);
  for(i = 0; i < n; ++i) if(!(a[i] <= t[0] && t[0] <= b[i])) dp[0][i] = -200;
  for(i = 1; i < d; ++i) {
    for(j = 0; j < n; ++j) if(a[j] <= t[i] && t[i] <= b[j]) {
      for(k = 0; k < n; ++k) {
        if(dp[i - 1][k] + abs(c[j] - c[k]) > dp[i][j]) dp[i][j] = dp[i - 1][k] + abs(c[j] - c[k]);
      }
    }
  }
  /*for(i = 0; i < d; ++i) {
    for(j = 0; j < n; ++j) printf("%d ", dp[i][j]);
    printf("\n");
  }*/
  for(i = 0; i < n; ++i) if(dp[d - 1][i] > max) max = dp[d - 1][i];
  printf("%d\n", max);
  return 0;
}


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

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

  
  if(p.at(0)!=p.at(1)&&p.at(1)!=p.at(2)&&p.at(2)!=p.at(0)){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }

}

Measured memory_bytes: 256
N=int(input())
d=list(input())
do=""
if N==1:
  print(3)
  exit()
if d[0]==d[1]:
  ans=6
  flag=0
  do+=d[0]*2+","
else:
  ans=3
  flag=1
  do+=d[0]+","
for i in range(1,N-1):
  if flag==1:
    if d[i]==d[i+1]:
      ans*=2
      flag=0
      do+=d[i]*2+","
    else:
      ans*=2
      flag=1
      do+=d[i]+","
  elif flag==2:
    if d[i]==d[i+1]:
      ans*=3
      flag=0
      do+=d[i]*2+","
    else:
      ans*=1
      flag=1
      do+=d[i]+","
  elif flag==0:
    flag=2
if flag==1:
  ans*=2
  do+=d[N-1]
elif flag==2:
  ans*=1
  do+=d[N-1]
  
print(ans%(10**9+7))
  
      
    

Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    multiset<ll> clr;
    rep(i, n) {
        if (sz(clr) == 0) {
            clr.insert(a[i]);
            continue;
        }
        auto it = clr.lower_bound(a[i]);
        if (it == clr.begin()) {
            clr.insert(a[i]);
        }
        else {
            it--;
            clr.erase(it++);
            clr.insert(a[i]);
        }
    }
    cout << sz(clr) << endl;
    return 0;
}


Measured memory_bytes: 5760
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
const int MAX_N = 2010;
const ll LL_INF = 1LL << 50;
ll dp[MAX_N][MAX_N][2];
ll N,Z,W;
vector<ll> A;
ll res;
void init(){
  for (int i = 0; i < MAX_N; i++){
    for (int j = 0; j < MAX_N; j++){
      for (int k = 0; k < 2; k++){
        dp[i][j][k] = -1;
      }
    }
  }
}

ll memo(int pos, int idx, bool turn){
  if (pos >= N - 1){
    return abs(A[N - 1] - A[idx]);
  }

  ll &res = dp[pos][idx][turn];
  if (res >= 0){
    return res;
  }

  if (turn){//X
    res = 0;
    for (int i = pos; i < N - 1; i++){
      res = max(res, memo(i + 1, i, !turn));
    }
    res = max(res, abs(A[N - 1] - A[idx]));
  }else{//Y
    res = LL_INF;
    for (int i = pos; i < N - 1; i++){
      res = min(res, memo(i + 1, i, !turn));
    }
    res = min(res, abs(A[N - 1] - A[idx]));
  }
  // cerr << pos << " " << idx << " " << turn << " " << res << endl;
  return res;
}
int main() {
  init();
  cin >> N >> Z >> W;
  A.resize(N);
  for (auto &val : A){
    cin >> val;
  }
  A.push_back(W);
  res = 0;
  res = max(res, memo(0, N, true));
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 63992
/*
 * main.cpp
 *
 *  Created on: 2020/04/12
 *      Author: SkAaO
 */
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;

int main(){
	int N, M, C;
	cin >> N >> M >> C;
	int A[N][M];
	int B[M];
	for(int i = 0; i < M; i++){
			cin >> B[i];
	}
	for(int i = 0; i < N; i++){
		for(int j = 0; j < M; j++){
			cin >> A[i][j];
		}
	}


	int result[N] = {0};
	int count = 0;

	for(int i = 0; i < N; i++){
		for(int j = 0; j < M; j++){
			result[i] += A[i][j] * B[j];
		}
		if(result[i] + C > 0){
			count++;
		}
	}

	cout << count << endl;

	return 0;
}





Measured memory_bytes: 256
#include<iostream>
#include <algorithm>

using namespace std;
int main() {
	int n,m,a,b;
	bool miss=false;
	cin>>n>>m;
	int ans=m;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		m+=a-b;
		if(m<0)miss=true;
		ans=max(ans,m);
	}
	if(miss)ans=0;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1160
/*
 * created by: Osmel Lavalier
 *
*/

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

#define deb(x) cout << #x << x << endl

int main() {
	
	int n;
	cin >> n;
	
	string ans = "";
	while(n--)
		ans += "ACL";
	
	cout << ans << endl;
	
	
	return 0;
}

Measured memory_bytes: 3596
N=int(input())
A=list(map(int,input().split()))

l=0
r=0
ans=0
p=A[l]
while r<N:
  if r==l:
    if r<N-1:
      if p^A[r+1]==p+A[r+1]:
        r+=1
        p+=A[r]
      else:
        r+=1
        p+=A[r]
        p-=A[l]
        ans+=r-l
        l+=1
    else:
      r+=1
      p-=A[l]
      ans+=r-l
      l+=1
  else:
    if r<N-1:
      if p^A[r+1]==p+A[r+1]:
        r+=1
        if r<N:
          p+=A[r]
      else:
        p-=A[l]
        ans+=r-l+1
        l+=1
    else:
      p-=A[l]
      ans+=r-l+1
      l+=1


print(ans)


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

using namespace std;

long long n, a, b;

int main() {
//	freopen("in", "r", stdin);
//	freopen("out", "w", stdout);

	scanf("%lld%lld%lld", &n, &a, &b);
	if (a > b) swap(a, b);
	if ((b - a) % 2 == 0) {
		printf("%lld\n", (b - a) / 2);
		return 0;
	}

	printf("%lld\n", min(a - 1, n - b) + 1 + (b - a) / 2);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
  
long long co(vector<int> &A) {
    // 2 pointer solution
    
    long long ans = 0, n = A.size(), num = pow(10, 9) + 7;
    
    if(!n){
        return ans;
    }
    
    sort(A.begin(), A.end());
    
    for(int k = n - 1; k >= 0; k--){
        int i = 0, j = k - 1;
        while(i < j){
            long int miniSum = A[i] + A[j], maxi = A[k];
            if(miniSum > maxi){
                ans = (ans + (j - i));
                j--;
            }   
            else{
                i++;    
            }
        }
    }
    
    return ans;
}  
int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0; i<n; i++)
        cin >> v[i];
    cout << co(v);
    return 0;
}

Measured memory_bytes: 256
// Problem : B - Iroha Loves Strings (ABC Edition)
// Contest : AtCoder - AtCoder Beginner Contest 042
// URL : https://atcoder.jp/contests/abc042/tasks/abc042_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
const long long int  modu=1e9+7;
#define endl '\n'
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define inp(x)  for(auto &t:x) cin>>t;
#define itr     vector<int>::iterator
#define debug(a) cout << #a << "=" << a << ' '<<endl;
#define out(x)  for(auto &t:x) cout<<t; cout<<endl;
#define ff first
#define ss second
#define pb push_back
#define initialize(a,v)  for(int i=0;i<a.size();++i) a[i]=v;
#define all(x) x.begin(),x.end()
#define mpt(mp) for(auto it=mp.begin();it!=mp.end();it++)
#define trav(x) for(int i=0;i<(int)x.size();++i)
#define mkp(a,b) make_pair(a,b)
#define sz(x)  (int)x.size()

int noofdig(int N)
{
	return floor(log10(N))+1;
}


ll f(ll a)
{

return 0;

}



void pre()
{

}



void solve()
{
	int n,l;
	cin>>n>>l;
   vector<string>s;
   
   for(int i=0;i<n;++i)
   {
   	string x;
   	cin>>x;
   	s.pb(x);
   }
   
   sort(all(s));
   out(s);





}



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

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


Measured memory_bytes: 3620
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const int MOD=1e9+7;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}

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

  int a, b, c;
  string s;

  cin >> a >> b >> c;

  if(a+b+c >= 22) cout << "bust" << endl;
  else cout <<  "win" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
int col[114514];
vector< pair<int,int> > nex[114514];
int dfs( int pos, int par, int co ){
	int cur = 1;
	for(int i=0;i<nex[pos].size();i++){
		int nx = nex[pos][i].first;
		int e_id = nex[pos][i].second;
		if( nx != par ){
			if( cur == co ) cur ++;
			col[ e_id ] = cur;
			cur ++;
			dfs( nx, pos, col[e_id] );
		}
	}
}
signed main(){
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		nex[a].pb(mp(b,i));
		nex[b].pb(mp(a,i));
	}
	dfs(1,-1,-1);
	int ma = -1;
	for(int i=0;i<n-1;i++){
		ma = max( ma, col[i] );
	}
	cout<<ma<<endl;
	for(int i=0;i<n-1;i++){
		cout<<col[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <algorithm>
#include <functional>
#define int long long
using namespace std;

typedef pair<int, int> P;

signed main() {
    int n, W;
    cin >> n >> W;
    int w[n], v[n];
    for (int i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
    }
    int count[4];
    for (int i = 0; i < 4; i++) {
        count[i] = 0;
    }
    int res[4][100];
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 100; j++) {
            res[i][j] = 0;
        }
    }
    int w0 = w[0];
    count[0]++;
    res[0][0] = v[0];
    for (int i = 1; i < n; i++) {
        res[w[i] - w0][count[w[i] - w0]] = v[i];
        count[w[i] - w0]++;
    }

    for (int i = 0; i < 4; i++) {
        sort(res[i], res[i] + 100, greater<int>());
    }

    int value = 0;
    for (int i = 0; i <= count[0]; i++) {
        for (int j = 0; j <= count[1]; j++) {
            for (int k = 0; k <= count[2]; k++) {
                for (int l = 0; l <= count[3]; l++) {
                    if (i * w0 + j * (w0 + 1) + k * (w0 + 2) + l * (w0 + 3) > W) continue;
                    int temp = 0;
                    for (int m = 0; m < i; m++) {
                        temp += res[0][m];
                    }
                    for (int m = 0; m < j; m++) {
                        temp += res[1][m];
                    }
                    for (int m = 0; m < k; m++) {
                        temp += res[2][m];
                    }
                    for (int m = 0; m < l; m++) {
                        temp += res[3][m];
                    }
                    value = max(value, temp);
                }
            }
        }
    }

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


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

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

    int r = N+L-1;
    int l = L;
    int rem;
    if(r <= 0) rem = r;
    else if (l >= 0) rem = l;

    cout << (r+l)*(r-l+1)/2 - rem << endl;

    return 0;
}

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

int main() {
  
  int N, K;
  cin >> N >> K;
  
  if (N%K == 0) {
    cout << 0 << endl;
  }
  else {
    cout << 1 << endl;
  }
 
return 0;
}

Measured memory_bytes: 3628
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr double BIGP = 1000000007L;
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //
    ll N, D;
    cin >> N >> D;
    using Vec = vector<ll>;
    vector<Vec> vs(N);
    rep(i, N)
    {
        Vec v(D);
        rep(j, D) cin >> v[j];
        vs[i] = v;
    }
    ll ans = 0;
    rep(i, N)
    {
        rep(j, N)
        {
            if (i == j)
                continue;

            // 距離を計算する
            auto& v0 = vs[i];
            auto& v1 = vs[j];
            ll disqr = 0;
            rep(k, D)
            {
                disqr += (v0[k] - v1[k])* (v0[k] - v1[k]);
            }
            // 累乗かをチェック
            rep(k, disqr+1)
            {
                if (k * k == disqr)
                {
                    ++ans;
                    break;
                }
            }
        }
    }
    cout << ans/2;

    //
    return 0;
}

Measured memory_bytes: 3652
def cal_single(S,N):
    output = 0
    for i in range(N):
        output += S[i].count("AB")
    return output

def cal_cont(S,N):
    a,b,ab = 0,0,0
    for i in range(N):
        if S[i][0] == "B" and S[i][-1] == "A":
            ab += 1
        elif S[i][0] == "B":
            b += 1
        elif S[i][-1] == "A":
            a += 1

    if ab == 0:
        return min(a,b)
    elif a + b == 0:
        return ab-1
    else:
        return ab + min(a,b)

def main():
    N = int(input())
    S = [input() for _ in range(N)]

    ans = cal_single(S,N)+cal_cont(S,N)

    print(ans)

if __name__ == "__main__":
    main()


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

int main() {
	// your code goes here
	int m,n,q,i,j;
	cin>>m>>n>>q;
	int *a = (int*)malloc(sizeof(int)*q);
	int s[100 ][100];
	for(i=0;i<q;i++)
		cin>>a[i];
		int k = 0;
	for(i = 0;i<m;i++)
	{
		if(i%2==0){
			for(j = 0;j<n;j++)
		{
				if(a[k]!=0)
					s[i][j]=k+1;
				else if(a[k]==0)
				{
					k++; 
						s[i][j]=k+1;
				}
				a[k]--;
				
		}
		}
		else
		{
			for(j = n-1;j>=0;j--)
			{
				if(a[k]!=0)
					s[i][j]=k+1;
				else if(a[k]==0)
				{
					k++; 
					s[i][j]=k+1;
				}
				a[k]--;
				
		}
		}
	}
	for(i = 0;i<m;i++)
	{
		for(j = 0;j<n;j++)
			cout<<s[i][j]<<" ";
		cout<<endl;
	}
	return 0;
}

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

using namespace std;
int main(){
  int N;
  string S;
  cin >> N;
  cin >> S;
int a = 1;
  for(int i=0;i<N-1;++i){
  if(S.at(i)!=S.at(i+1)){
    ++a;
                        }
  }
   cout<< a <<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;
 
    vvpll G(n);
    rep(i, n-1) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(make_pair(b, 1));
        G[b].pb(make_pair(a, 1));
    }
    
    vl dist1(n, -1);
    queue<ll> Q1;
    dist1[0] = 0;
    Q1.push(0);
    while(!Q1.empty()) {
        ll v = Q1.front();
        Q1.pop();
        for(auto p : G[v]) {
            ll u = p.first;
            ll cost = p.second;
            if(dist1[u] != -1) {
                continue;
            }
            dist1[u] = dist1[v] + cost;
            Q1.push(u);
        }
    }

    vl distN(n, -1);
    queue<ll> QN;
    distN[n-1] = 0;
    QN.push(n-1);
    while(!QN.empty()) {
        ll v = QN.front();
        QN.pop();
        for(auto p : G[v]) {
            ll u = p.first;
            ll cost = p.second;
            if(distN[u] != -1) {
                continue;
            }
            distN[u] = distN[v] + cost;
            QN.push(u);
        }
    }
 
    ll cnt1 = 0, cntN = 0;
    rep(v, n) { 
        if(dist1[v] <= distN[v]) {
            cnt1++;
        }
        else {
            cntN++;
        }
    }
 
    if(cnt1 > cntN) {
        out("Fennec");
    }
    else {
        out("Snuke");
    }
    
    re0;
}

Measured memory_bytes: 9216
n = int(input())
v = list(map(int, input().split()))
do = {0:0}
de = {0:0}
for i in range(n):
    if i % 2:
        do[v[i]] = do.get(v[i], 0) + 1
    else:
        de[v[i]] = de.get(v[i], 0) + 1
o = max(do, key=do.get)
e = max(de, key=de.get)
if o != e:
    print(n-do[o]-de[e])
else:
    vo = do.pop(o)
    ve = de.pop(e)
    vo2 = max(do.values())
    ve2 = max(de.values())
    print(n - max(vo+ve2, ve+vo2))

Measured memory_bytes: 17056
#include <iostream>
#include <iterator>
#include <list>
#include <vector>

using namespace std;

int main(){
    int n, q;
    cin >> n >> q;
    vector<list<int>> L(n);
    int x, y, z;
    for(int i = 0; i < q; i++){
        cin >> x;
        if(x == 0){
            cin >> y >> z;
            L[y].push_back(z);
        }else if(x == 1){
            cin >> y;
            for(auto itr = L[y].begin(); itr != L[y].end(); ++itr){
                if(itr != L[y].begin()) cout << " ";
                cout << *itr;
            }
            cout << "\n";
        }else{
            cin >> y >> z;
            L[z].splice(L[z].end(), L[y]);
        }
    }

    return 0;
}


Measured memory_bytes: 18724
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
using namespace std;
//#define int long long

signed main() {
#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	int n;
	cin >> n;
	deque <int> q;
	int p = 0;
	for (int i = 1; i <= n; ++i) {
		int cur;
		cin >> cur;
		if (!p) {
			q.push_back(cur);
		}
		else {
			q.push_front(cur);
		}
		p ^= 1;
	}
	if (!p) {
		while (q.size()) {
			cout << q.front() << ' ';
			q.pop_front();
		}
	}
	else {
		while (q.size()) {
			cout << q.back() << ' ';
			q.pop_back();
		}
	}
}

Measured memory_bytes: 2944
#include <stdio.h>
#include <iostream>
using namespace std;


#define abs(N) ((N>0)?N:-1*N)
#define lt(A,B) ((A>B)?B:A)
#define gt(A,B) ((A<B)?B:A)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

typedef struct {
	char sym;
	int num;
} card;


void BubbleSort(card *cd,int n){
  for (int i = 0; i < n; ++i) {
    for (int j = n-1; j >= i+1; --j) {
      if( cd[j].num < cd[j-1].num){
        card c;
        c = cd[j];
        cd[j] = cd[j-1];
        cd[j-1] = c;
      }
    }
  }
}

void SelectSort(card *cd,int n){
	for (int i = 0; i < n; ++i) {
		int mini = i;
		for (int j = i; j < n; ++j) {
			if( cd[j].num < cd[mini].num){
				mini = j;
			}
		}
		if(i!=mini){
			card c;
			c = cd[i];
			cd[i] = cd[mini];
			cd[mini] = c;
		}
	}
}

bool isStable(card *cd_mst,card *cd, int n){
	for (int i = 1; i < 10; ++i) {
		char syms[4];
		int symi = 0;
		for (int j = 0; j < n; ++j) {
			if(cd_mst[j].num == i){
				syms[symi++] = cd_mst[j].sym;
			}
		}
		symi = 0;
		for (int j = 0; j < n; ++j) {
			if(cd[j].num == i){
				if(cd[j].sym != syms[symi]){
					return false;
				}
				symi++;
			}
		}
	}
	return true;
}


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

	card cd_mst[n],cd[n];
	for (int i = 0; i < n; ++i) {
		string buf;
		cin >> buf;
		cd_mst[i].num = buf[1]-'0';
		cd_mst[i].sym = buf[0];
	}

	for (int i = 0; i < n; ++i) {
		cd[i] = cd_mst[i];
	}

	BubbleSort(cd,n);
	for (int i = 0; i < n; ++i) {
		if(i > 0) cout << " ";
		cout << cd[i].sym << cd[i].num;
	}
	cout << endl;
	string stb = (isStable(cd_mst,cd,n))? "Stable" : "Not stable";
	println(stb);



	for (int i = 0; i < n; ++i) {
		cd[i] = cd_mst[i];
	}

	SelectSort(cd,n);
	for (int i = 0; i < n; ++i) {
		if(i > 0) cout << " ";
		cout << cd[i].sym << cd[i].num;
	}
	cout << endl;
	stb = (isStable(cd_mst,cd,n))? "Stable" : "Not stable";
	println(stb);


	return 0;
}



Measured memory_bytes: 3196
#include<iostream>
#include<algorithm>
using namespace std;
#define int long long
int n,num=0,maxi=0,len[200010];
string a[200010],store[200010];

signed main(){
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<n;i++){
		int j=i,cnt=0;num++;
		while(a[j]==a[i]){
			cnt++;j++;
		}len[num]=cnt;store[num]=a[i];i=j-1;if(maxi<cnt)maxi=cnt;
	}
	for(int i=1;i<=num;i++){
		if(len[i]==maxi)cout<<store[i]<<endl;
	}
}

Measured memory_bytes: 17536
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        String[] str = line.split(" ");

        int num = Integer.parseInt(str[0]) + Integer.parseInt(str[1]);

        if(num >= 10){
            System.out.println("error");
        } else {
            System.out.println(num);
        }
    }

}


Measured memory_bytes: 21204
#include <iostream>
#include <cstring>

int main(){
    int n,k;
    std::cin >> n >> k;
    std::string str;
    std::cin >> str;
    int cur = 0;
    for(auto it : str){
        cur ++;
        if (cur == k) std::cout << char(it + 32);
        else std::cout << it;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int count = 1;

		Scanner sc = new Scanner(System.in);

        int inputValue = 0;

        int ninzu = 0;
        String shotokuStr = "";
       int shotoku = 0;
       int shotokuAvg = 0;

       int result = 0;

        // inputValue が 0 でなければループ
       	shotokuStr = sc.nextLine();
//        while (Integer.parseInt(shotokuStr) != 0) {
        while (!"0".equals(shotokuStr)) {
//        	if("0".equals(shotokuStr)) {
//        		break;
//        	}


        	if ( count % 2 == 1) {
        		ninzu = Integer.parseInt(shotokuStr);
        	} else {
        		shotoku = 0;
        		result = 0;
        		String[] shotokuList = shotokuStr.split(" ");
        		for (String shotokuString : shotokuList) {
        			shotoku += Integer.parseInt(shotokuString);
        		}
        		shotokuAvg = shotoku / ninzu;

        		for (String shotokuString : shotokuList) {
        			if (Integer.parseInt(shotokuString) <= shotokuAvg) {
        				result++;
        			}
        		}

        		System.out.println(result);

        	}

            count++;
            shotokuStr = sc.nextLine();
        }

		sc.close();
	}

}



Measured memory_bytes: 63768
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll x;
    cin>>x;

    for (ll i = 0; i < 1e3; ++i) {
        for (ll j = -1e3; j < 1e3; ++j) {
            if ((ll)pow(i, 5) - (ll)pow(j, 5) == x) {
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 4048
use std::io::*;
use std::str::FromStr;
use std::collections::HashSet;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let k:u64 = read();
    let mut x = k;
    let mut s = HashSet::new();
    let mut i = 0;

    while s.contains(&x) == false {
        if x == 0 {
            println!("{}",i);
            return;
        }
        s.insert(x);
        x = (x*10+7)%k;
        i += 1;
    }
    println!("-1");

}


Measured memory_bytes: 29660
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def make_divisors(n: int) -> list:
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

def main():
    n = i_input()

    num_list = make_divisors(n)

    print(len(str(num_list[len(num_list)-1])))

if __name__ == '__main__':
    main()


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n,a,b;
int t[111111];

int main(){
	cin.sync_with_stdio(false);
	cin>>n>>a>>b;
	rep(i,n)cin>>t[i];
	int cnt=0;
	rep(i,n){
		if(t[i]>=a&&t[i]<b)cnt++;
	}
	cout<<n-cnt<<endl;
	return 0;
}


Measured memory_bytes: 256
/*
[ ( ^ _ ^ ) ]
*/
// problem: atc/abc167_d
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1000000000

const int nax = 200012;
vector<int> a(nax);
vector<bool> vis(nax);
vector<int> path;
int n, head;
ll k;

void dfs(int v) {
    if(vis[v]) {
        head = v;
        return;
    }
    vis[v] = true;
    path.push_back(v);
    dfs(a[v]);
}

int main() {
    scanf("%d %lld", &n, &k);
    for(int i=1; i<=n; i++) {
        scanf("%d", &a[i]);
    }
    dfs(1);
    ll l = (ll)size(path);
    int i = 0;
    for(i=0; i<l; i++) {
        if(path[i] == head) break;
    }
    if(k<=i) {
        int t = path[k];
        printf("%d\n", t);
        return 0;
    }
    k -= i;
    int idx = (int)(k%(l-i));
    int t = path[i + idx];
    // for(i=0; i<l; i++) {
    //     cout << path[i] << " -> ";
    // }
    // cout << endl;
    // cout << idx << endl;
    printf("%d\n", t);
}


Measured memory_bytes: 10820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
 
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
 
long double a, b, x;
 
void input() {
    cin >> a >> b >> x;
}
 
long double f(long double a, long double b, long double x) {
    long double ans;
    if(a * a * b / 2.0 <= x) {
        ans = atan(2 * (a * a * b - x) / (a * a * a));
    } else {
        ans = PI / 2 - atan(2 * x / (a * b * b));
    }
    return ans;
}
 
void solve() {
    input();
    cout << fixed << setprecision(10) << f(a, b, x) * 180.0 / PI << endl;
    return;
}
 
int main() {
    solve();
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int u[n-1], v[n-1], w[n-1], a[n+1], l[n+1];
  bool ch[n+1], loop;
  for ( int i = 0; i < n-1; i++ ) {
    cin >> u[i] >> v[i] >> w[i];
  }
  for ( int i = 1; i <= n; i++ ) {
    a[i] = l[i] = 0;
    ch[i] = false;
  }

  ch[u[0]] = true;
  loop = true;
  while ( loop ) {
    for ( int i = 0; i < n-1; i++ ) {
      if ( !ch[u[i]] && !ch[v[i]] ) { continue; }
      if ( !ch[u[i]] ) {
        l[u[i]] = w[i] + l[v[i]];
        ch[u[i]] = true;
      } else if ( !ch[v[i]] ) {
        l[v[i]] = w[i] + l[u[i]];
        ch[v[i]] = true;
      }
    }
    loop = false;
    for ( int i = 1; i <= n; i++ ) {
      if ( !ch[i] ) { loop = true; }
    }
  }
  
  for ( int i = 1; i <= n; i++ ) {
    a[i] = ( l[i]%2 == 0 ) ?  0 : 1;
  }

  for ( int i = 1; i <= n; i++ ) {
    cout << a[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 2432
#include<iostream>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i=0;(int)(i<n);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;

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

  ll n;
  cin >> n;
  vector<ll> a(n),sum(n+1,0);
  rep(i,n)cin >> a[i];
  sort(all(a));
  rep(i,n)sum[i+1] = sum[i] + a[i];

  ll m;
  cin >> m;
  vector<ll> b(m), c(m);
  rep(i,m)cin >> b[i];
  rep(i,m)cin >> c[i];

  rep(i,m){
    int pos = upper_bound(all(a),b[i]) - a.begin();
    if(c[i] <= sum[pos])cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

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

int main() {
  string s;
  cin>>s;
  
  int ans=10000;
  
  for(int i=0;i<s.size()-2;++i){
    string ss=s.substr(i,3);
    int x=stoi(ss);
    int ab=abs(x-753);
    
    ans=min(ans,ab);
  }
  
  cout<<ans<<endl;

}


Measured memory_bytes: 256
taka, aoki = 1, 1
for _ in range(int(input())):
    a, b = map(int, input().split())
    ratio = max(taka//a + [0, 1][taka%a != 0], aoki//b + [0, 1][aoki%b != 0])
    taka = a * ratio
    aoki = b * ratio
print(taka + aoki)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	int N, M;
	cin >> N >> M;
	vector<pair<int, int>>p(M);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		p[i] = { b,a };
	}
	sort(all(p));

	int la = -1;
	int ans = 0;
	for (int i = 0; i < M; i++) {
		int a = p[i].second;
		int b = p[i].first;
		if (la >= a)continue;
		la = b - 1;
		ans++;
	}
	puts(ans);

	return 0;
} 

Measured memory_bytes: 1024