akhauriyash/Code-Regression huggingface dataset:
// 20:44 - 21:13
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define lch (o << 1)
#define rch (o << 1 | 1)

typedef double db;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> pint;

const int N = 2e5 + 5;
const int INF = 0x3f3f3f3f;
const ll INF_LL = 0x3f3f3f3f3f3f3f3f;

struct Point {
	int x, y, dir;
};
Point p[N];
vector<Point> diag[N * 2][4], sdiag[N * 2][4], xaxis[N * 2][4], yaxis[N * 2][4];

const int DIR[] = {3, 2, 1, 0};

int main() {
	ios::sync_with_stdio(0);

	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int x, y;
		char c;
		cin >> x >> y >> c;
		int dir = 0;
		if (c == 'U')
			dir = 0;
		else if (c == 'R')
			dir = 1;
		else if (c == 'D')
			dir = 2;
		else
			dir = 3;
		p[i] = (Point){x, y, dir};

		diag[y - x + N][dir].push_back(p[i]);
		sdiag[x + y][dir].push_back(p[i]);
		if (dir % 2 == 1)
			xaxis[y][dir].push_back(p[i]);
		else
			yaxis[x][dir].push_back(p[i]);
	}

	auto CmpByX = [](Point a, Point b) {
		return a.x < b.x;
	};
	auto CmpByY = [](Point a, Point b) {
		return a.y < b.y;
	};

	for (int d = 0; d < 4; d++) {
		for (int i = 0; i < 2 * N; i++) {
			sort(diag[i][d].begin(), diag[i][d].end(), CmpByX);
			sort(sdiag[i][d].begin(), sdiag[i][d].end(), CmpByX);
			sort(xaxis[i][d].begin(), xaxis[i][d].end(), CmpByX);
			sort(yaxis[i][d].begin(), yaxis[i][d].end(), CmpByY);
		}
	}

	ll minT = INF_LL;
	for (int i = 1; i <= n; i++) {
		int x = p[i].x, y = p[i].y;
		int dir = p[i].dir;
		int ndir = (dir + 2) % 4;
		int diagDir = DIR[dir];
		int sdiagDir = (diagDir + 2) % 4;

		auto o = lower_bound(diag[y - x + N][diagDir].begin(), diag[y - x + N][diagDir].end(), p[i], CmpByX);
		auto q = lower_bound(sdiag[x + y][sdiagDir].begin(), sdiag[x + y][sdiagDir].end(), p[i], CmpByX);

		if ((diagDir == 2 || diagDir == 3) && o != diag[y - x + N][diagDir].end())
			minT = min(minT, abs(o->x - x) * 10LL);
		if ((diagDir == 0 || diagDir == 1) && o != diag[y - x + N][diagDir].begin())
			minT = min(minT, abs((o - 1)->x - x) * 10LL);

		if ((sdiagDir == 3 || sdiagDir == 0) && q != sdiag[x + y][sdiagDir].end())
			minT = min(minT, abs(q->x - x) * 10LL);
		if ((sdiagDir == 1 || sdiagDir == 2) && q != sdiag[x + y][sdiagDir].begin())
			minT = min(minT, abs((q - 1)->x - x) * 10LL);

		// parallel to x axis
		if (dir % 2 == 1) {
			auto r = lower_bound(xaxis[y][ndir].begin(), xaxis[y][ndir].end(), p[i], CmpByX);
			if (dir == 1 && r != xaxis[y][ndir].end())
				minT = min(minT, abs(r->x - x) * 5LL);
			if (dir == 3 && r != xaxis[y][ndir].begin())
				minT = min(minT, abs((r - 1)->x - x) * 5LL);
		}

		// parallel to y axis
		if (dir % 2 == 0) {
			auto r = lower_bound(yaxis[x][ndir].begin(), yaxis[x][ndir].end(), p[i], CmpByY);
			if (dir == 0 && r != yaxis[x][ndir].end())
				minT = min(minT, abs(r->y - y) * 5LL);
			if (dir == 2 && r != yaxis[x][ndir].begin())
				minT = min(minT, abs((r - 1)->y - y) * 5LL);
		}
	}

	if (minT == INF_LL)
		cout << "SAFE";
	else
		cout << minT << endl;

	return 0;
}


Measured memory_bytes: 174704
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-8;


#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod

int main(){
    ll N,K; cin>>N>>K;
    vec d(N);
    rep(i,N) cin>>d[i];
    vec L(N+1,0), R(N+1,0);
    rep(i,N) L[i+1]=L[i]+d[i];
    for(int i=N-1;i>=0;i--) R[i]=R[i+1]+d[i];
    reverse(ALL(R));
    
    vec minus;
    ll ans=-INF;
    rep(i,N+1) {
        if(i>K) break;
        if(i>0) if(d[i-1]<0) minus.pb(d[i-1]);
        vec Min;
        rep(k,minus.size()) Min.pb(minus[k]);
        rep(j,N+1-i){
            if(i+j>K) break;
            ll X=L[i]+R[j], Y=K-i-j;
            if(j>0) if(d[N-j]<0) Min.pb(d[N-j]);
            sort(ALL(Min));
            rep(k,min(Y,(ll)Min.size())) X-=Min[k];
            //cout<<i<<' '<<j<<':'<<X<<endl;
            //rep(k,min(Y,(ll)Min.size())) cout<<Min[k]<<','<<endl;
            ans=max(ans,X); 
        }    
    }
    cout<<ans<<endl;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

ll gcd(ll a,ll b){
	if(a<b){
		swap(a,b);
	}

	while(ll r=(a%b)){
		a = b;
		b = r;
	}
	return b;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in();
	vector<int> V=vecin(N);
	int M=1<<N;
	set<ll> S;
	REP(i,M){
		if(!i) continue;
		int T=i;
		ll P=1;
		int index=0;
		while(T){
			if(T&1){
				P = lcm(P,V[index]);
			}
			index++;
			T>>=1;
		}
		S.insert(P);
	}
	out(S.size());
	return 0;
}


Measured memory_bytes: 4120
import numpy as np
# S*8% = A 切り捨て np.floor(S*8%) = A
# S*10% = B　切り捨て
A,B = map(int, input().split())
S = B*10
C = 0
for i in range(S+9,S-1,-1):
    if np.floor(i*0.08) == A:
        C = i
if C == 0:
    print(-1)
else:
    print(C)

Measured memory_bytes: 12496
from heapq import heapify, heappush, heappop

inf = float("inf")
def dijkstra(start):  # graphは隣接リスト(繋がっている先, コスト)
    vsize = len(graph)
    dist = [inf] * vsize
    seen = [False] * vsize
    prev = [None] * vsize
    pq = []
    heapify(pq)

    dist[start] = 0
    heappush(pq, (0, start))  # heapではtuple[0]で比較されるのでこの順番で追加する
    while pq:
        cost, u = heappop(pq)
        seen[u] = True
        if dist[u] < cost:
            continue
        for v, w in graph[u]:
            temp_cost = dist[u] + w
            if not seen[v] and temp_cost < dist[v]:
                dist[v] = temp_cost
                prev[v] = u
                heappush(pq, (dist[v], v))
    return dist, prev
N, M, R = map(int, input().split())
rlist = list(map(int, input().split()))
graph = [[] for _ in range(N)]
for _ in range(M):
    A, B, C = map(int, input().split())
    graph[A-1].append((B-1, C))
    graph[B-1].append((A-1, C))
shortest_path = [dijkstra(i) for i in range(N)]
from itertools import permutations
ans = 10**9

for path in permutations(rlist):
    cost = 0
    for i in range(R-1):
        cost += shortest_path[path[i]-1][0][path[i+1]-1]
    ans = min(ans, cost)
print(ans)

Measured memory_bytes: 72792
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(a,b)<<" "<<max(a+b-n,0)<<endl;
    return 0;
}

Measured memory_bytes: 256
def algorithm():
    while True:
        budget = int(input())
        if budget == 0:
            break

        total, months = 0, 0
        for _ in range(12):
            income, outcome = map(int, input().split())
            total += income - outcome
            if total >= budget and months == 0:
                months = _ + 1

        print('NA' if total < budget else months)


def main():
    algorithm()


if __name__ == '__main__':
    main()

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

int main(){
   int N,sum_D;
   cin>>N;
   vector<int> vec(N);
   sum_D=0;
  
   for(int i=0;i<N;i++){
      cin>>vec.at(i);
   }
  
   for(int i=0;i<N-1;i++){
      for(int j=i+1;j<N;j++){
         sum_D+=vec.at(i)*vec.at(j);
      }
   }
   
   cout<<sum_D<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

ll d[200100];

int main(){
  clr(d,0);
  ll n;
  cin>>n;
  vector<ll> v;
  rep(i,0,n){
    ll a;
    cin>>a;
    v.pb(a);
    d[a]++;
  }
  ll total = 0;
  rep(i,0,200100){
    ll a = d[i];
    if(a==0)continue;
    total += a*(a-1)/2;
  }
  rep(i,0,v.sz){
    ll a = d[v[i]];
    if(a<2){
      cout << total << endl;
    }
    else{
      ll b = a*(a-1)/2;
      a--;
      ll c = a*(a-1)/2;
      cout << total-b+c << endl;
    }
  }
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];
    sort(a, a + n, greater<ll>());

    ll ans = a[0];
    int idx = 1, cnt = 0;
    for (int i = 1; i < n - 1; i++) {
        if (cnt == 2) cnt = 0, idx++;
        ans += a[idx];
        cnt++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5196
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1
//#define INFTY 1000000000000000000

int main(){
    LL r;
    LL c;
    LL k;
    cin >> r >> c >> k;
    vector<vector<LL>> v(r, vector<LL>(c, 0));
    LL tmp_r;
    LL tmp_c;
    LL tmp_v;
    for(LL i=0; i<k; i++){
        cin >> tmp_r >> tmp_c >> tmp_v;
        tmp_r--;
        tmp_c--;
        v[tmp_r][tmp_c]=tmp_v;
    }
    vector<vector<vector<LL>>> dp(r, vector<vector<LL>>(c,vector<LL>(4,0)));
    dp[0][0][1]=dp[0][0][0]+v[0][0];
    for(LL i=0; i<r; i++){
        for(LL j=0; j<c; j++){
            for(LL k=0; k<4; k++){
                if(i!=0){
                    dp[i][j][0]=max(dp[i][j][0], dp[i-1][j][k]);
                }
            }
            if(v[i][j]!=0){
                dp[i][j][1]=dp[i][j][0]+v[i][j];
            }
            for(LL k=0; k<4; k++){
                if(j!=0){
                    dp[i][j][k]=max(dp[i][j][k], dp[i][j-1][k]);
                    if(v[i][j]!=0 && k>=1){
                        dp[i][j][k]=max(dp[i][j][k], dp[i][j-1][k-1]+v[i][j]);
                    }
                }
            }
        }
    }

    LL max_ans=0;
    for(LL i=0; i<4; i++){
        max_ans=max(max_ans, dp[r-1][c-1][i]);
    }

    cout << max_ans << endl;

    return 0;
}


Measured memory_bytes: 706820
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	string s; cin >> s;
	vector<int>ans(s.size());
	for (int ri = 0; ri < 2; ri++) {
		int cnt = 0;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == 'R')cnt++;
			else {
				ans[i] += cnt / 2;
				ans[i - 1] += (cnt + 1) / 2;
				cnt = 0;
			}
		}

		reverse(ans.begin(), ans.end());
		reverse(s.begin(), s.end());
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == 'L')s[i] = 'R';
			else s[i] = 'L';
		}
	}
	for (int i = 0; i < s.size(); i++) {
		cout << ans[i] << ' ';
	}
	cout << endl;


	return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	
	static int MOD, N;
	static int[][] table;
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		N = sc.nextInt();
		MOD = sc.nextInt();
		
		table = new int[N + 1][N + 1];
		for (int rem = 0; rem < N + 1 ; rem++) {
			table[N][rem] = rem;
		}
		for (int pos = N - 1; pos >= 1; pos--) {
			for (int rem = 0; rem < N + 1; rem++) {
				table[pos][rem] = table[pos + 1][rem];
				int factor = Math.min(pos, N + 1 - pos);
				if (factor < rem) {
					table[pos][rem] += table[pos][rem-factor];
					table[pos][rem] %= MOD;
				}
			}
		}
		out.println(table[1][N]);
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 168132
#include <iostream>
#include <cstring>
using namespace std;
typedef long long ll;
ll W[110][110];
ll init[110][110];
ll counts[110][110];
struct edge {
	int v1, v2;
	int value;
}edges[1024];
//#define LOCAL
#define INF 0x3f3f3f3f;
void path1(int x, int y, int tx, int ty) {
	for(int i = 0; i < (ty - y); i++)
		cout << "U";
	for(int i = 0; i < (tx - x); ++i)
		cout << "R";
}

void path2(int x, int y, int tx, int ty) {
	for(int i = 0; i < (ty - y); i++)
		cout << "D";
	for(int i = 0; i < (tx - x); ++i)
		cout << "L";
}

void path3(int x, int y, int tx, int ty) {
	cout << "L";
	for(int i = 0; i <= (ty - y); ++i) 
		cout << "U";
		
	for(int i = 0; i <= (tx - x); ++i)
		cout << "R";
	
	cout << "D";
}

void path4(int x, int y, int tx, int ty) {
	cout << "R";
	for(int i = 0; i <= (ty - y); ++i) 
		cout << "D";
		
	for(int i = 0; i <= (tx - x); ++i)
		cout << "L";
	
	cout << "U";
}
void run() {
	int x, y, tx, ty;
	while(cin >> x >> y >> tx >> ty) {
		path1(x, y, tx, ty);
		path2(x, y, tx, ty);
		path3(x, y, tx, ty);
		path4(x, y, tx, ty);
		cout << endl;
	}
}
int main(int argc, char *argv[]) {
	run();
}

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

short N;
ll ans = 0;
string L, R, b, r;
map<pair<string, string>, int> M;

void aff(vector<bool>&vec, short i) {
	if (i == N) {
		for (short j = 0;j < N;j++) {
			if (vec[j])b.push_back(L[j]);
			else r.push_back(L[j]);
		}
		b += 'B';
		r += 'R';
		if (M.find({ b,r }) != M.end()) {
			M.at({ b,r })++;
		}
		else {
			M.insert({ {b,r},1 });
		}
		b = "";
		r = "";
		return;
	}
	aff(vec, i + 1);
	vec[i] = 1;
	aff(vec, i + 1);
	vec[i] = 0;
	return;
}

void aff2(vector<bool>&vec, short i) {
	if (i == N) {
		for (short j = 0;j < N;j++) {
			if (vec[j])b.push_back(R[j]);
			else r.push_back(R[j]);
		}
		b += 'B';
		r += 'R';
		if (M.find({ b, r }) != M.end()) {
			ans += (ll)M.at({ b,r });
			//cout << b << " " << r << endl;
			//cout << ans << endl;
		}
		b = "";
		r = "";
		return;
	}
	aff2(vec, i + 1);
	vec[i] = 1;
	aff2(vec, i + 1);
	vec[i] = 0;
	return;
}

int main(){
	cin >> N;
	string S;
	cin >> S;
	for (short i = 0;i < N;i++) {
		L += S[i];
	}
	for (short i = 0;i < N;i++) {
		R += S[i + N];
	}
	reverse(R.begin(), R.end());
	vector<bool> vec(N, false);
	aff(vec, 0);
	aff2(vec, 0);
	cout << ans << endl;
}

Measured memory_bytes: 47488
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using i64 = int64_t;
#define rep(i, s, n) for (i64 i = (s); i < (n); ++i)

void run() {
  const i64 mod{998244353};
  i64 n, k;
  cin >> n >> k;
  vector<i64> ls(k), rs(k);
  rep(i, 0, k) { cin >> ls[i] >> rs[i]; }
  vector<i64> counts(n + 1);
  vector<i64> incs(n + 1);
  incs[1] = 1;
  incs[2] = -1;
  rep(i, 1, n + 1) {
    counts[i] = (counts[i - 1] + incs[i]) % mod;
    rep(ik, 0, k) {
      i64 il{i + ls[ik]}, ir{i + rs[ik] + 1};
      if (il < n + 1) {
        incs[il] += counts[i];
        incs[il] %= mod;
        if (ir < n + 1) {
          incs[ir] -= counts[i];
          incs[ir] %= mod;
          if (incs[ir] < 0) {
            incs[ir] += mod;
          }
        }
      }
    }
  }
  cout << counts[n] << endl;
}

int main() {
  cin.tie(nullptr);
  run();
  return 0;
}


Measured memory_bytes: 5976
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long int N;
    cin >> N;
    long long int S[N];
    for(long int i = 0; i < N; i++)
    {
        cin >> S[i];
    }
    sort(S, S+N);
    int x = 1;
    int y = 0;
    for(long int k = 1; k < N - 1; k++)
    {
        if(S[k] == S[k - 1])
        {
            x = x + 1;
        }
        else if(x % 2 == 1)
        {
            y = y + 1;
            x = 1;
        }
        else
        {
            x = 1;
        }
    }
    if(S[N-1] == S[N-2])
    {
        x = x + 1;
        if(x % 2 == 1)
        {
            y = y + 1;
        }
        else
        {
        }
    }
    else if(x % 2 == 1)
    {
        y = y + 2;
    }
    else
    {
        y = y + 1;
    }

    cout << y << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
#define INT_SIZE 32
#define me(x) memset(x,0,sizeof(x))
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
int main()
{
    int n,d;
    cin>>n>>d;
    int i=0,ans=0;
    while(i<n)
    {
        i+=(2*d+1);
        ans++;
    }
    cout<<ans;
}


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

// macros
#define overload_rep(va_0, va_1, va_2, name, ...) name
#define rep_0(i, n) for(int i = 0; i < (n); ++i)
#define rep_1(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// libraries

// declarations
bool make[7][100001];

// solve
int main(){

    int X;
    cin >> X;

    make[0][0] = true;
    rep(i, 6){
        int use = 100 + i;
        rep(j, 0, 100000){
            if(make[i][j])make[i + 1][j] = true;
            if(j - use >= 0 && make[i + 1][j - use])make[i + 1][j] = true;
        }
    }

    cout << make[6][X] << '\n';

}


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

int R,C,H,W,D;
int A[505][505];
long long Sum;

int main(){
	int i,j;
	scanf("%d%d%d%d",&R,&C,&H,&W);
	D=(H*W>1?999999999/(H*W-1):1000000000);
	for(i=1;i<=R;i++)
		for(j=1;j<=C;j++){
			A[i][j]=(i%H||j%W?D:-(H*W-1)*D-1);
			Sum+=A[i][j];
		}
	if(Sum<=0)
		puts("No");
	else{
		puts("Yes");
		for(i=1;i<=R;i++){
			for(j=1;j<=C;j++)
				printf("%d ",A[i][j]);
			puts("");
		}
	}
	return 0;
}

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

int main() {

int N;
cin >> N;
vector<int> p(N), q(N);
for(int i = 0; i < N; i++) cin >> p[i], p[i]--;
for(int i = 0; i < N; i++) cin >> q[i], q[i]--;

map<vector<int>, int> ord;
int itata = 0;

vector<int> v(N);
for(int i = 0; i < N; i++) v[i] = i;

do{
    itata++;
ord[v] = itata;

} while (next_permutation(v.begin(), v.end()));

cout << abs(ord[p] - ord[q]) << endl;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
const int m=200000;

int main(){
  long long n,k,r,s,p;
  string t;
  cin>>n>>k>>r>>s>>p>>t;
  long long ans=0;
  vector<int> mem(m,-1);
  for(int i=0;i<n;i++){
    if(i<k){
      if(t[i]=='r') {ans+=p; mem[i+k]=1;}
      if(t[i]=='s') {ans+=r; mem[i+k]=2;}
      if(t[i]=='p') {ans+=s; mem[i+k]=3;}
    }
    if(i>=k){
      if(t[i]=='r'&&mem[i]!=1) {ans+=p; mem[i+k]=1;}
      else if(t[i]=='s'&&mem[i]!=2) {ans+=r; mem[i+k]=2;}
      else if(t[i]=='p'&&mem[i]!=3) {ans+=s; mem[i+k]=3;}
    }
  }
  cout<<ans<<endl;
}
  

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

int main() {
  int n; cin >> n;
  set<int> s;
  rep(i, n) {
    int temp; cin >> temp;
    if(s.find(temp) != s.end()) {
      cout << "NO" << endl;
      return 0;
    } else {
      s.insert(temp);
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 9600
#pragma GCC optimize("O3")
 #pragma GCC optimize("unroll-loops")
 #pragma GCC optimize("fast-math")
#include<bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define int long long
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

void accell() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}



signed main() {
    accell();
    int n, x;
    cin >> n >> x;
    if (x == 1 || x == 2 * n - 1) {
        cout << "No";
        return 0;
    }
    if (n == 2) {
        cout << "Yes\n1\n2\n3\n";
        return 0;
    }
    set<int>st;
    vector<int>a(2 * n - 1);
    vector<bool>used(2 * n - 1);
    n = n * 2 - 1;
    if (x >= 3) {
        a[n / 2] = x + 1;
        a[n / 2 + 1] = x;
        a[n / 2 + 2] = x - 1;
        a[n / 2 - 1] = x - 2;
    } else {
        a[n / 2 - 1] = x + 2;
        a[n / 2] = x - 1;
        a[n / 2 + 1] = x;
        a[n / 2 + 2] = x + 1;
    }
    for (int i = 1; i <= n; ++i)
        st.insert(i);
    for (int i = n / 2 - 1; i <= n / 2 + 2; ++i) {
        st.erase(a[i]), used[i] = true;
    }
    n = (n + 1) / 2;
    for (int i = 0; i < 2 * n - 1; ++i) {
       // cout << *st.begin() << ' ';
        if (!used[i]) {
            a[i] = *st.begin();
            st.erase(a[i]);
        }
    }
    cout << "Yes\n";
    for (auto &i : a)
        cout << i << '\n';
    return 0;
}


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

int main(void){
    // Your code here!
    int n;cin>>n;
    vector<int> a(n),b(n),c(n);
    vector<vector<int>> hap(n+1,vector<int>(4,0));
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    for(int i=0;i<n;i++){
        hap[i+1][0]=max(hap[i][1]+a[i],hap[i][2]+a[i]);
        hap[i+1][1]=max(hap[i][0]+b[i],hap[i][2]+b[i]);
        hap[i+1][2]=max(hap[i][0]+c[i],hap[i][1]+c[i]);
            
            
        hap[i+1][4]=max(hap[i+1][0],max(hap[i+1][1],hap[i+1][2]));
    }
    cout<<hap[n][4]<<endl;
    
}


Measured memory_bytes: 6912
using System;

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            String Input = Console.ReadLine();
            Char[] input = Input.ToCharArray();
            for (int i = 0; i < input.Length; i++)
            {
                if (char.IsUpper(input[i]))
                {
                    input[i] = char.ToLower(input[i]);
                    Console.Write(input[i]);
                }
                else if (char.IsLower(input[i]))
                {
                    input[i] = char.ToUpper(input[i]);
                    Console.Write(input[i]);
                }
                else
                {
                    Console.Write(input[i]);
                }
            }
            Console.WriteLine("");
        }
    }
}

Measured memory_bytes: 9036
import math
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

def get_prime(n): 
    X = [i for i in range(2,n+1)] 
    prime = []
    mx = math.sqrt(n) + 1 

    while True:
        p = min(X) 
        if mx <= p:
            prime.extend(X) 
            break
        prime.append(p) 
        X = [i for i in X if i % p != 0]

    return prime




INF=10**20
def main():
    N = ii()
    P = set(get_prime(55555))

    ans = [2]
    p = 2
    while len(ans) < N:
        p += 5
        while p < 55555 and not p in P:
            p += 5
        
        ans.append(p)
    
    # print(sum(ans))
    print(*ans,sep=' ')
        






if __name__ == "__main__":
    main()

Measured memory_bytes: 77000
N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7
sum_a = 0
for a in A:
    a = a % mod
    sum_a = (sum_a + a) % mod
ans = 0
for a in A:
    sum_a = (sum_a - a) % mod
    ans += (a % mod) * sum_a
    ans = ans % mod
print(ans % mod)

Measured memory_bytes: 31432
t = input().split()

W = int(t[0])
H = int(t[1])
x = int(t[2])
y = int(t[3])
r = int(t[4])

if x - r >= 0 and y - r >= 0 and x + r <= W and y + r <= H :
    print('Yes')
else :
    print('No')

Measured memory_bytes: 6728
#include <stdio.h>

int main(void){
  int a1,a2,a3;
  scanf("%d %d %d",&a1,&a2,&a3);
  
  int a;
  a = a1+a2+a3;
  if(a>=22){
    printf("bust");
  }else{
      printf("win");
  }
    
    return 0;
}

Measured memory_bytes: 128
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        int M = scan.nextInt();
        int need = 0;

        for(int i = 0; i < M; i++) {
            need += scan.nextInt();
        }

        if(N >= need)
            os.println(N-need);
        else
            os.println(-1);
    }

}

Measured memory_bytes: 39920
#include <iostream>
#include <vector>

using namespace std;

int n;
vector<vector<int> > tree;
vector<int> t;

void dfs(int now, int pre, int sum) {
	for (auto v : tree[now]) {
		if (v == pre) continue;
		dfs(v, now, sum + t[now]);
	}
	t[now] += sum;
}

int main() {
	int q; cin >> n >> q;
	tree.assign(n + 1, vector<int>());
	t.assign(n + 1, 0);
	for (int i = 0; i < n - 1; ++i) {
		int a, b; cin >> a >> b;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}
	for (int i = 0; i < q; ++i) {
		int p, x; cin >> p >> x;
		t[p] += x;
	}
	dfs(1, -1, 0);
	for (int i = 0; i < n; ++i) {
		if (i) cout << " ";
		cout << t[i + 1];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 26624
# -*- coding: utf-8 -*-
import numpy as np
import types

# Input
l = list(map(int, input().split()))
_ = l[0]
K = l[1] - 1 # <---!!

#S = list(map(str, input().split()))
S = list(input())

# Process
if K == 0:
    left = list("")
else:
    left = S[:K]

if K == len(S)-1:
    right = list("")
else:
    right = S[K+1:]

output = left + list(str(S[K]).lower()) + right
print( ''.join(output) )


Measured memory_bytes: 21260
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PokerPlaying {
    class Player {
        static void Main(string[] args) {
            int iter = int.Parse(Console.ReadLine());
            int[] score = new int[iter];

            for (int i = 0; i < iter; i++) {
                string[] inning = checkImput();
                score[i] = Baseball.playGame(inning);
            }
            for (int i = 0; i < iter; i++) {
                Console.WriteLine(score[i]);
            }
        }

        public static string[] checkImput() {
            int num_event = 0;
            int outCount = 0;
            string[] data = new string[100];

            while (true) {
                data[num_event] = Console.ReadLine();
                if (data[num_event] == "OUT") {
                    outCount++;
                }
                if (outCount == 3) {
                    break;
                }
                num_event++;
            }
            return data;
        }
    }

    class Baseball {

        public static int playGame(string[] inningData) {
            int scores = 0;
            int eventIdx = 0;
            int[] runnner = new int[3];

            while (!string.IsNullOrEmpty(inningData[eventIdx])) {
                if (inningData[eventIdx] == "HOMERUN") {
                    int numRunners = 0;
                    for (int i = 0; i < runnner.Length; i++) {
                        if (runnner[i] == 1) {
                            numRunners++;
                            runnner[i] = 0;
                        }
                    }
                    scores += numRunners + 1; 
                }
                if (inningData[eventIdx] == "HIT") {
                    if (runnner[2] == 1) {
                        runnner[2] = 0;
                        scores++;
                    }
                    for (int i = 1; i >= 0; i--) {
                        if (runnner[i] == 1) {
                            runnner[i + 1] = 1;
                            runnner[i] = 0;
                        }
                        if (i == 0 && runnner[i] == 0) {
                            runnner[i] = 1;
                        }
                    }
                }
                eventIdx++;
            }
            return scores;
        }
    }
}

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
int main (){
    int N,A;
    cin >> N;
    A=0;
    vector<int> value(N),cost(N);
    for(int i=0;i<N;i++){
        cin >> value.at(i);
    }
    for(int j=0;j<N;j++){
        cin >> cost.at(j);
    }
    for(int k=0;k<N;k++){
        if((value.at(k)-cost.at(k))>0) A+=(value.at(k)-cost.at(k));
    }
    cout << A << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD 998244353
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    char a;
    cin >> a;
    if (a>='a'){
        cout << 'a' << endl;
    }else{
        cout << 'A' << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main(){
  double a[2],b[2],c[2],x[2],m[2][2],ans[2],inv[2][2],det,s,t;
  while(cin >>a[0]>>a[1]>>b[0]>>b[1]>>c[0]>>c[1]>>x[0]>>x[1]){
    m[0][0] = b[0]-a[0];
    m[1][0] = b[1]-a[1];
    m[0][1] = c[0]-a[0];
    m[1][1] = c[1]-a[1];
    ans[0] = x[0]-a[0];
    ans[1] = x[1]-a[1];
    det = m[0][0]*m[1][1]-m[0][1]*m[1][0];
    inv[0][0] = m[1][1]/det;
    inv[0][1] = -m[0][1]/det;
    inv[1][0] = -m[1][0]/det;
    inv[1][1] = m[0][0]/det;
    s = ans[0]*inv[0][0]+ans[1]*inv[0][1];
    t = ans[0]*inv[1][0]+ans[1]*inv[1][1];
    if(s>0 && t>0 && s+t<1){cout <<"YES"<<endl;}
    else{cout <<"NO"<<endl;}
  }
  return 0;
}

Measured memory_bytes: 1220
package main

import "fmt"

func main() {
        var n int
        fmt.Scan(&n)
        if n == 0 {
                fmt.Println(0)
                return
        }

        var v int
        if n > 0 {
                for v = 1; v < n; v = v | v<<2 {
                }
                v = v ^ (v - n)
        }
        if n < 0 {
                for v = 2; v < -n; v = v | v<<2 {
                }
                v = v ^ (v + n)
        }

        s := ""
        for ; v != 0; v >>= 1 {
                s = string(v&1+'0') + s
        }
        fmt.Println(s)
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,C,K;
int T[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>C>>K;
	FOR(i,N) cin>>T[i];
	sort(T,T+N);
	int ret=0;
	int L=0;
	FOR(i,N) {
		if(i-L>=C || T[i]-T[L]>K) {
			ret++;
			L=i;
		}
	}
	cout<<ret+1<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

int main() {
  ll l, r;
  cin >> l >> r;
  int anser = 2018;
  r = min(r, l + 4038);
  for (ll i = l; i <= r; i++) {
    for (ll j = i + 1; j <= r; j++) {
      int x = i * j % 2019;
      anser = min(anser, x);
    }
  }
  cout << anser << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>

using namespace std;

int main(){
	ll N, M;
	
	cin >> N >> M;
	vector<vector<pll> > v(N + 3);

	ll l, r, d;
	while(M--){
		cin >> l >> r >> d;
		v[l].push_back(pll(r, d));
		v[r].push_back(pll(l, -d));
	}

	bool visited[100010];
	ll position[100010];
	memset(visited, 0, sizeof visited);
	bool can = true;

	for(int i = 1; i <= N ; ++i){
		if(!visited[i]){
			queue<ll> q;
			q.push(i);
			position[i] = 0;
			visited[i] = true;
			while(!q.empty()){
				auto idx = q.front(); q.pop();
				for(auto node : v[idx]){
					
					if(!visited[node.first]){
						position[node.first] = position[idx] + node.second;
						q.push(node.first);
						visited[node.first] = true;
					}else if(position[idx] + node.second != position[node.first]){
						can = false;
						goto xgh;
					}
				}
			}
		}
	}

xgh:
	if(can)
		printf("Yes\n");
	else
		printf("No\n");



	return 0;
}


Measured memory_bytes: 14080
#include <bits/stdc++.h>
using namespace std;
int main(){
  char a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  if(a==f && b==e && c==d){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdtr1c++.h>
#include<list>
#include<algorithm>
#include<cstdlib>
using namespace std;

int main(){
    string S;
    cin >> S;
    if (S[0] != S[1] && S[1] != S[2] && S[2] != S[0]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	ll x,y; cin>>x>>y;
	ll ans = 0;
	for(ll t = x; t<=y; t *= 2){
		ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		Set<Integer> map = new HashSet<Integer>();
		map.add(a);
		int count = 0;
		if(map.contains(b)){
			count++;
		}else map.add(b);
		if(map.contains(c)){
			count++;
		}else map.add(c);
		if(count == 1){
			System.out.println("Yes");
		}else System.out.println("No");
		
		// your code goes here
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  string s; cin >> s;
  int n = s.size();

  bool ok = true;
  int cnt = 0;
  rep(i, n){
    if(i == 0 && s[i] != 'A'){ok = false; break;}
    if(1 <= i && 'A' <= s[i] && s[i] <= 'Z'){
      if(2 <= i && i <= n-2 && s[i] == 'C') cnt++;
      else ok = false;
    }
  }

  cout << ((ok && cnt == 1) ? "AC" : "WA") << endl;

  return 0;
}


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

int H,W;
int main() {
	while(true) {
		cin >> H >> W;
		if (H == 0 && W == 0) break;
		for (int i=0; i<H; ++i) {
			for (int i=0; i<W; ++i) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <set>
#include<malloc.h>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
#define ri(n) scanf("%d",&n)
#define oi(n) printf("%d\n",n)
#define rl(n) scanf("%lld",&n)
#define ol(n) printf("%lld\n",n)
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define rep1(i,l,r) for(int i=l;i<r;i++)

int main()
{
    //int n;
    	int n,m;
    	cin>>n>>m;
    	if(n%2==1)
    	{
    	int x=1,y=n;
    	while(m--)
    	{
    		printf("%d %d\n",x,y);
    		x++;
    		y--;
		}
		}
		else
		{
			int x=1,y=n,fg=0;
			while(m--)
			{
				printf("%d %d\n",x,y);
				x++;
				y--;
				if(y-x<=(n/2)&&!fg)
				{
					fg=1;
					x++;
				}
			}
			
			
		}
    return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
# define ll int64_t
#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

int main(){
    ll a,b,m;
    cin>>a>>b>>m;
    vector<ll> A(a),B(b),x(m),y(m),c(m);
    rep(i,a) cin>>A[i];
    rep(i,b) cin>>B[i];
    rep(i,m) cin>>x[i]>>y[i]>>c[i];
    
    vector<ll> d=A,e=B;
    sort(ALL(d));
    sort(ALL(e));
    ll mini = d[0]+e[0];
    
    rep(i,m){
        if(A[x[i]-1]+B[y[i]-1]-c[i]<mini){
            mini = A[x[i]-1]+B[y[i]-1]-c[i];
        }
    }
    cout<<mini<<endl;
    return 0;
}

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

typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> tree(n + 1);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        tree[a].emplace_back(b);
        tree[b].emplace_back(a);
    }
    vector<int> c(n);
    ll m = 0;
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        m += c[i];
    }
    sort(c.begin(), c.end());
    m -= c[c.size() - 1];
    cout << m << endl;
    int start;
    for (int i = 1; i <= n; i++) {
        if ((int)tree[i].size() == 1) {
            start = i;
            break;
        }
    }
    vector<int> d(n);
    d[start - 1] = c[0];
    queue<pair<int, int>> q;
    q.emplace(pair<int, int>{start, 0});
    while (!q.empty()) {
        int cur = q.front().first;
        int parent = q.front().second;
        q.pop();
        for (auto v : tree[cur]) {
            if (v == parent) {
                continue;
            }
            q.push(pair<int, int>{v, cur});
            d[v - 1] = c[c.size() - 1];
            c.pop_back();
        }
    }
    for (auto e : d) {
        cout << e << " ";
    }
    return 0;
}


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	n := nextInt()
	x := make([]int, n)
	for i := 0; i < n; i++ {
		x[i] = nextInt()
	}
	y := make([]int, n)
	for i := 0; i < n; i++ {
		y[i] = x[i]
	}
	sort.Ints(y)
	for i := 0; i < n; i++ {
		if x[i] <= y[n/2-1] {
			fmt.Println(y[n/2])
		} else {
			fmt.Println(y[n/2-1])
		}
	}
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define sec second
#define fir first
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
typedef vector<int> Vec;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

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

	int n, m, k;
	cin >> n >> m >> k;
	UnionFind ut(n); // friends chain
	//ut.init(n);
	int fnum[n] = {}; // friends
	int bch[n] = {}; // blocked ans chained
	int cnum[n] = {}; // chained

	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		ut.merge(a, b);
		fnum[a]++; fnum[b]++;
	}
	rep(i, k) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		if(ut.issame(a, b)) {
			bch[a]++;
			bch[b]++;
		}
	}

	rep(i, n) {
		int sum = ut.size(i) - 1;
		cout << sum - fnum[i] - bch[i] << " ";
	}
	cout << endl;
	return 0;
}

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

int H, W, N, sx, sy;
string S, T;
char U[5] = "URDL";

int main() {
	cin >> H >> W >> N >> sx >> sy;
	cin >> S >> T;

	int lx = 1, ly = 1, rx = H, ry = W;

	for (int i = N - 1; i >= 0; i--) {
		// T についての操作
		if (T[i] == 'L') ry++;
		if (T[i] == 'R') ly--;
		if (T[i] == 'U') rx++;
		if (T[i] == 'D') lx--;
		lx = max(lx, 1); ly = max(ly, 1);
		rx = min(rx, H); ry = min(ry, W);

		// S についての操作
		if (S[i] == 'R') ry--;
		if (S[i] == 'L') ly++;
		if (S[i] == 'D') rx--;
		if (S[i] == 'U') lx++;

		if (lx > rx || ly > ry) {
			cout << "NO" << endl;
			return 0;
		}
	}
	if (lx <= sx && sx <= rx && ly <= sy && sy <= ry) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 776
text=input()
te=list(text)
l={}
s=0
for i in text:
    s=0
    for j in te:
        if (i==j):
            s+=1
    l[i]=s
c=0
for i in text:
    if (l[i]>1):
        c+=1
        break
if (c==0):
    print('yes')
else:
    print('no')

    
        
        
        



    


Measured memory_bytes: 3060