akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fo(i,s,e) for( i=s;i<e;i++)
#define rfo(i,s,e) for(i=s;i>e;i--)
#define LL long long int 
const LL MOD=1e9+7;
#define pb push_back
#define pob pop_back()
#define sp " "
#define ff first
#define ss second
//            When something is important enough, you do it even if the odds are not in your favor.

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    // code goes here
    int t=1;//cin>>t;
    while(t--){
      LL n,i;cin>>n;
      LL a=0,w=0,t=0,r=0;
      fo(i,0,n){
        string s;cin>>s;
        if(s=="AC") a++;
        else if(s=="TLE") t++;
        else if(s=="WA") w++;
        else r++;
      }
      cout<<"AC"<<sp<<"x"<<sp<<a<<endl;
      cout<<"WA"<<sp<<"x"<<sp<<w<<endl;
      cout<<"TLE"<<sp<<"x"<<sp<<t<<endl;
      cout<<"RE"<<sp<<"x"<<sp<<r<<endl;
    }
    return 0;
}

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

string a;
long long b[500010];
long long out;
queue < long long > q;

int main()
{
    cin>>a;
    int n = a.size();
    a += "  ";
    if(a[0] == '<')
        q.push(0);
    if(a[n - 1] == '>')
        q.push(n);
    for(int i = 1;i < n;i++)
    {
        if(a[i - 1] == '>' && a[i] == '<')
        {
            q.push(i);
            b[i] = 0;
        }
    }

    while(!q.empty())
    {
        int f = q.front();
        q.pop();
        if(a[f] == '<' && b[f] >= b[f + 1])
        {
            q.push(f + 1);
            b[f + 1] = b[f] + 1;
        }
        if(a[f - 1] == '>' && b[f] >= b[f - 1])
        {
            q.push(f - 1);
            b[f - 1] = b[f] + 1;
        }
    }

    for(int i = 0;i <= n;i++)
    out += b[i];

    cout<<out;

    return 0;
}

Measured memory_bytes: 6404
#include <stdio.h>
#include <stdlib.h>
#define inf (int)(1e9)

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

int max(int a, int b){
	return a >= b ? a : b;
}

int main(){
	int A, B, i, j, x, y, N = 100;
	scanf("%d%d", &A, &B);
	int **d = (int **)malloc(sizeof(int *) * (A + 1));
	int **D = (int **)malloc(sizeof(int *) * (A + 1));
	for(x = 1; x <= A; x++){
		d[x] = (int *)malloc(sizeof(int) * (B + 1));
		D[x] = (int *)malloc(sizeof(int) * (B + 1));
		for(y = 1; y <= B; y++){
			scanf("%d", &d[x][y]);
			D[x][y] = inf;
		}
	}
	int **f = (int **)malloc(sizeof(int *) * (N + 1));
	for(i = 0; i <= N; i++){
		f[i] = (int *)malloc(sizeof(int) * (N + 1));
		for(j = 0; j <= N; j++){
			f[i][j] = 0;
			for(x = 1; x <= A; x++){
				for(y = 1; y <= B; y++){
					f[i][j] = max(f[i][j], d[x][y] - (x * i + y * j));
				}
			}
		}
	}
	for(x = 1; x <= A; x++){
		for(y = 1; y <= B; y++){
			for(i = 0; i <= N; i++){
				for(j = 0; j <= N; j++){
					D[x][y] = min(D[x][y], x * i + y * j + f[i][j]);
				}
			}
			if(d[x][y] != D[x][y]){
				printf("Impossible\n");
				return 0;
			}
		}
	}
	printf("Possible\n");
	printf("%d %d\n", 2 * (N + 1), 2 * N + (N + 1) * (N + 1));
	for(i = 1; i <= N; i++){
		printf("%d %d X\n", i, i + 1);
		printf("%d %d Y\n", N + 1 + i, N + 2 + i);
	}
	for(i = 0; i <= N; i++){
		for(j = 0; j <= N; j++){
			printf("%d %d %d\n", i + 1, 2 * N + 2 - j, f[i][j]);
		}
	}
	printf("%d %d\n", 1, 2 * (N + 1));
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    int[] dx = {1, 0};
    int[] dy = {0, 1};
    int h = sc.nextInt();
    int w = sc.nextInt();
    char[][] arr = new char[h][w];


    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        for (int i=0; i<h; i++) arr[i] = sc.next().toCharArray();

//        int res = Integer.MAX_VALUE;

//        bfs(new Pair(0, 0));

        int[][] dp = new int[h+1][w+1];

        for (int i=0; i<w+1; i++) {
            dp[0][i] = (int)1e9;
        }

        for (int i=0; i<h+1; i++) {
            dp[i][0] = (int)1e9;
        }

        if (arr[0][0] == '#') dp[1][1] = 1;

        for (int i=1; i<=h; i++) {
            for (int j=1; j<=w; j++) {
                if (i == 1 && j == 1) continue;
                if (arr[i-1][j-1] == '.') {
                    dp[i][j] = Math.min(dp[i-1][j], dp[i][j-1]);
                } else {
                    if (2 <= i && arr[i-2][j-1] == '.') {
                        if (2 <= j && arr[i-1][j-2] == '.') {
                            dp[i][j] = Math.min(dp[i-1][j]+1, dp[i][j-1]+1);
                        } else {
                            dp[i][j] = Math.min(dp[i-1][j]+1, dp[i][j-1]);
                        }
                    } else {
                        if (2 <= j && arr[i-1][j-2] == '.') {
                            dp[i][j] = Math.min(dp[i][j-1]+1, dp[i-1][j]);
                        } else {
                            dp[i][j] = Math.min(dp[i][j-1], dp[i-1][j]);
                        }
                    }
                }
            }
        }

        for (int i=0; i<=h; i++) {
            for (int j=0; j<=w-1; j++) {
//                System.out.print(dp[i][j] + " ");
            }
//            System.out.println(dp[i][w]);
        }

        System.out.println(dp[h][w]);

    }

    void bfs(Pair pair) {
        Queue<Pair> queue = new ArrayDeque<>();
        queue.add(pair);
        while (!queue.isEmpty()) {
            Pair p = queue.peek();
            for (int i=0; i<dx.length; i++) {
                int nx = p.x + dx[i];
                int ny = p.y + dy[i];
                if (h <= nx || w <= ny) continue;

            }
        }
    }


    class Pair {
        int x;
        int y;
        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }


}


Measured memory_bytes: 22100
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int K,N; cin>>K>>N;
	vector<int> A(N);
	for (int i=0; i<N; i++) cin>>A[i];
	for (int i=0; i<N; i++)
		A.push_back(A[i]+K);
	int ret=INT_MAX;
	for (int i=0; i<N; i++) {
		// i => i+1 => ... => i-1
		// i => i-1 => ... => i+1
		ret=min({ret,A[i-1+N]-A[i],A[i+N]-A[i+1]});
	}
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 1804
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long hxtype;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=200005;
pii p[N];
int nxt[N];ll f[N];
int main(){
	int n,d,a,i,j,x,y;ll ans=0ll,t=0ll;
	scanf("%d%d%d",&n,&d,&a);
	rep(i,1,n){
		scanf("%d%d",&x,&y);
		p[i]=mp(x,(y-1)/a+1);
	}
	sort(p+1,p+n+1);
	d<<=1;j=1;
	rep(i,1,n){
		while(j<=n&&p[i].fi+d>=p[j].fi)++j;
		nxt[i]=j;
	}
//	rep(i,1,n)printf("%d ",nxt[i]);printf("\n");
	rep(i,1,n){
		t-=f[i];
		if((j=p[i].se-t)>0){
			ans+=j;
			t+=j;
			f[nxt[i]]+=j;
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 4096
a, b, c, x, y = map(int, input().split())
if a+b <= 2*c:
    print(a*x + b*y)
else:
    if x < y:
        if b >= 2*c:
            print(2*y*c)
        else:
            print(b*(y-x)+2*x*c)
    else:
        if a >= 2*c:
            print(2*x*c)
        else:
            print(a*(x-y)+2*y*c)


Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef double db;
db a,p,ans;
int i,j,k,l,t,n,m;
int main(){
    scanf("%d%lf%lf",&n,&a,&p);
    a-=p;
    t=2*n;
    l=n;
    fo(i,1,n){
        ans+=(db)(a*t+p*t*(t+1)/2)/t;
        a=a+a/l+3*p/(2*l);
        p=p+2*p/l;
        l--;
        t-=2;
    }
    printf("%.15lf\n",ans);
}

Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
#include <algorithm>

constexpr int ORD(int n){
  int res = 1;
  for(int i=0; i < n; i++){
    res *= 10;
  }
  res++;
  return res;
}

int xs[ORD(6)];

using namespace std;

int gcd_many(int* xs, int n){
  int res = xs[0];
  for(int i=0; i < n; i++){
    res = __gcd(res, xs[i]);
  }
  return abs(res);
}

int main(){
  int N, X;
  scanf("%d %d", &N, &X);
  for(int i=0; i < N; i++){
    scanf("%d", xs + i);
    xs[i] -= X;
  }

  int res = gcd_many(xs, N);
  printf("%d\n", res);
  
  return 0;
}


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

int main() {
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  if(a<e){
    if(e-a<=k) cout<<"Yay!"<<endl;
    else cout<<":("<<endl;
  }
  else{
    if(a-e<=k)cout<<"Yey!"<<endl;
    else cout<<":("<<endl;
  }
}
  

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

using namespace std;

int main()
{
	int n, l;
	string s, out = "";
	
	scanf("%d %d", &n, &l);
	
	vector<string> v;
	
	for(int i = 0; i < n; i++)
	{
		cin >> s;
		v.push_back(s);
	}
	
	sort(v.begin(), v.end());
	
	for(int i = 0; i < v.size(); out += v[i], i++);
	
	cout << out << "\n";
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,i;
  int ans=0;
  cin >> a >> b;
  for(i=0;i<2;i++){
    if(a>=b){
      ans=ans+a;
      a--;
    }
    else{
      ans=ans+b;
      b--;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a + b) * h / 2 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

void func(char* s){
    int a = 7;
    while(a >= 0){
        int buf = a;
        int sum = *s - '0';
        for(int i=1; i<4; i++){
            if(buf%2 == 1){
                sum += *(s+i) - '0';
            }else{
                sum -= *(s+i) - '0';
            }
            buf = buf/2;
        }
        if(sum == 7){
            printf("%c", *s);
            for(int i=1; i<4; i++){
                if(a%2 == 1){
                    printf("+");
                }else{
                    printf("-");
                }
                a = a/2;
                printf("%c", *(s+i));
            }
            printf("=7");
            return;
        }
        a--;
    }
    return;
}

int main(){
    char str[5];
    scanf("%s", str);
    func(str);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
 
using namespace std;
 
 
#define IOS ios::sync_with_stdio(0); cin.tie(0), cout.tie(0)
 
 
#define ll long long int
#define ld long double
 
#define fr first
#define se second
 
 
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) (int)v.size()
#define sunq(v) sort(all(v));v.resize(distance(v.begin(),unique(all(v))))
 
 
#define pb push_back
#define mp make_pair
 
 
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define emla(a, val) memset(a, val, sizeof(a))
#define easm(a, b) (a + b - 1) /b 
 
#define PI 3.141592653589793238
 
 
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

 

//bool valid(int i, int j){return i >= 0 && i < n && j >= 0 && j < m;}

char a[111][111];
int n , m;

int main() {
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  //clock_t z = clock();
  cin >> n >> m;
  for(int i = 1; i <= n; i++)
    for(int j = 1; j <= m; j++)
      cin >> a[i][j];
  for(int i = 0; i <= n+1; i++)
    for(int j = 0; j <= m+1; j++)
      if(i == 0 || j == 0 || i == n+1 || j == m+1)
        a[i][j] = '#';
  for(int i = 0; i <= n+1; i++)
    cout << a[i] << endl;
  //debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
  /*
  *try tricky test cases:
    -bounds
    -small input (0, 1)
    -big input
    -random tests
  */
  return 0;
}

Measured memory_bytes: 256
from scipy.sparse.csgraph import dijkstra

H, W = map(int,input().split())
c = [[0 for i in range(10)] for j in range(10)]
for i in range(10):
    c[i] = list(map(int, input().split()))
t = dijkstra(c)
ans = 0
for i in range(H):
    for k in map(int, input().split()):
        if k == 1 or k == -1: continue
        ans += t[k][1]
print(int(ans))


Measured memory_bytes: 17792
#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)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);


int main(){
  int R,G;
  cin >> R >> G;
  cout << 2*G-R << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
#define end getchar();getchar();return 0
int inf = 1000000000;
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int cnt=1;
	if (x == 0)return 1;
	cnt = kai(x - 1);
	return x * cnt;
}
int prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
void prime_factor(int n){
	int cnt = 1;
	map<int, int>res;
	int m = n;
	for (int i = 2; i<= n; i++) {
		if(prime(i)){
			while (m%i == 0) {
				++res[i];
				m /= i;
			}
		}
	}
	cout << n <<":"<< endl;
	for (int i = 2; i<= n; i++) {
		if (res[i]) {
			cout << i << " " << res[i] << endl;
		}
	}
	cout << endl;
}
/*Library End!*/

signed main() {
	string s;
	map<char, int>m;
	cin >> s;
	int ans = inf;
	for (int j = 0; j < 26; j++) {
		int b[105], d = 0, e = 0;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == 'a' + j) {
				b[d] = i;
				d++;
			}
		}
		b[d] = s.size();
		for (int i = d; i >= 0; i--) {
			if (i)b[i] -= b[i - 1] + 1;
			e = Max(e, b[i]);
		}
		ans = Min(e, ans);
	}
	cout << ans << endl;
	end;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
#define y1 yyy1
#define y2 yyy2
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef double db;
const int maxn=200000+10,mx=100000000;
const db pi=acos(-1);
struct dong{
	int x,y;
	friend bool operator<(dong a,dong b){
		return a.x<b.x||a.x==b.x&&a.y<b.y;
	}
} a[maxn];
int b[maxn],p[maxn];
int lis[maxn];
int i,j,k,l,t,n,m,x1,y1,x2,y2,z1,z2,top;
db ans;
int main(){
	scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
	scanf("%d",&n);
	fo(i,1,n) scanf("%d%d",&a[i].x,&a[i].y);
	if (x1>x2){
		swap(x1,x2);
		swap(y1,y2);
	}
	if (y1>y2){
		y1=mx-y1;
		y2=mx-y2;
		fo(i,1,n) a[i].y=mx-a[i].y;
	}
	a[++n].x=x1;
	a[n].y=y1;
	a[++n].x=x2;
	a[n].y=y2;
	fo(i,1,n) b[i]=a[i].y;
	sort(b+1,b+n+1);
	top=unique(b+1,b+n+1)-b-1;
	fo(i,1,n) a[i].y=lower_bound(b+1,b+top+1,a[i].y)-b;
	z1=y1;z2=y2;
	y1=lower_bound(b+1,b+top+1,y1)-b;
	y2=lower_bound(b+1,b+top+1,y2)-b;
	p[0]=y1;
	fo(i,1,n) p[i]=n+1;
	sort(a+1,a+n+1);
	fo(i,1,n){
		if (a[i].x<x1||a[i].y<y1||a[i].y>y2) continue;
		if (a[i].x>x2) break;
		if (a[i].x==x1&&a[i].y==y1){
			lis[i]=0;
			continue;
		}
		lis[i]=upper_bound(p,p+n+1,a[i].y)-p;
		p[lis[i]]=a[i].y;
		if (a[i].x==x2&&a[i].y==y2) break;
	}
	k=lis[i]-1;
	ans=(x2-x1)+(z2-z1);
	ans*=100;
	ans+=(pi-4)*5*k;
	if (k==min(x2-x1+1,z2-z1+1)&&k) ans+=pi*5;
	printf("%.12lf\n",ans);
}

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

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] a = new int[n];

		for (int i = 0; i <= n - 1; i++) {
			a[i] = sc.nextInt();
		}

		sc.close();

		int count = 0;
		Arrays.sort(a);

		for (int j = 0; j <= n - 2; j++) {
			if (a[j] == a[j + 1]) {
				count++;
			}
		}

		if (count % 2 > 0) {
			count++;
		}

		System.out.println(n - count);
	}
}


Measured memory_bytes: 51436
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <stack>
#include <cctype>
#include <cmath>

using namespace std;

/* typedef */

typedef long long ll;

/* constant */

const int INF = 1 << 30;
const int mod = 1000000007;
const double pi = acos(-1); // cos(pi) = -1 <=> pi = arccos(-1)

/* global variables */

/* function */

/* main */
int main() {

    double a, b, degree;
    cin >> a >> b >> degree;

    double radian = degree / 180 * pi;

    //cout << radian << '\n';
    //cout << sin(radian) << '\n';
    double S = 1.0 / 2.0 * a * b * sin(radian);
    double c = sqrt(abs(pow(a, 2) + pow(b, 2) - 2.0 * a * b * cos(radian)));
    double L = a + b + c;
    double h = S * 2.0 / a;
    cout << fixed << setprecision(6) << S << ' ' << L << ' ' << h << '\n';

}



Measured memory_bytes: 3596
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
using namespace std;
int  gcd(int a, int b) {
	if (a < b) gcd(b, a);
	int r;
	while ((r = a%b)) {
		a = b;
		b = r;
	}
	return b;
}
long long lcm(long long a, long long b) {
	return a / gcd(a, b) * b;
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	int a[100005];
	int b[100005];
	int sa[100005];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
		sa[i] = a[i] - b[i];
	}
	sort(sa, sa + n);
	int now = 0;
	int t = n - 1;
	int s = 0;
	int judge = 0;
	while (1) {
		while (now >= -sa[s]&&sa[s]<0) {
			now += sa[s];
			s += 1;
		}
		if (sa[s] >=0) { judge = 1; break; }
		if (sa[t] <= 0)break;
		now += sa[t];
		t -= 1;
	}
	if (judge == 0)cout << -1;
	else cout << n - 1 - t+s;
}

Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#define INF 0x3f3f3f3f
#define mod 1000000009
#define e  2.718281828459045
#define eps 1.0e18
#define PI acos(-1)
#define lowbit(x) (x&(-x))
#define memset(x,y) memset(x,y,sizeof(x))
#define lson i << 1,l,m
#define rson i << 1 | 1,m + 1,r
#define ll long long
using namespace std;
pair <float,float> pt[1001],t;
map <pair<float,float>,int> mp;
struct Piont{
	float x,y;
}p[1001];
const int N =4e5+5;
vector <int> a;
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("text1.in","r",stdin);
	//freopen("text1.out","w",stdout);
	int n,k;
	cin>>k>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		a.push_back(x);
		a.push_back(x-k);
	}
	sort(a.begin(),a.end());
	int maxn=0x3f3f3f3f;
	for(int i=0;i<n;i++){
		maxn=min(maxn,a[i+n-1]-a[i]);
//		cout<<a[i]<<" ";
	}
	cout<<maxn<<endl;
	return 0;
}

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

int main(void){
    char c;
    scanf("%c",&c);
    if(c == 'A') printf("T");
    else if(c == 'T') printf("A");
    else if(c == 'G') printf("C");
    else printf("G");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main()
{
    int a, b, q;
    ;
    cin >> a >> b >> q;
    vector<ll> s(a), t(b);
    rep(i, a)
    {
        cin >> s[i];
    }
    rep(i, b)
    {
        cin >> t[i];
    }
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());

    rep(i, q)
    {
        ll x;
        cin >> x;

        ll res = 1e18;

        // 先に s
        int it = lower_bound(s.begin(), s.end(), x) - s.begin();
        for (int i = max(0, it - 1); i < min(a, it + 1); i++)
        {
            ll y = s[i];
            int it2 = lower_bound(t.begin(), t.end(), y) - t.begin();
            for (int j = max(0, it2 - 1); j < min(b, it2 + 1); j++)
            {
                res = min(res, abs(x - y) + abs(y - t[j]));
            }
        }

        // 先に t
        it = lower_bound(t.begin(), t.end(), x) - t.begin();
        for (int i = max(0, it - 1); i < min(b, it + 1); ++i)
        {
            ll y = t[i];
            int it2 = lower_bound(s.begin(), s.end(), y) - s.begin();
            for (int j = max(0, it2 - 1); j < min(a, it2 + 1); ++j)
            {
                res = min(res, abs(x - y) + abs(y - s[j]));
            }
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,m;
  cin>>n>>m;
  ll ans=1;
  for(ll i=1;i<=sqrt(m);i++){
    if(m%i==0){
      ll j=m/i;
      if(j<n&&i<n) continue;
      else if(j<n&&i>=n) ans=max(ans,j);
      else if(j>=n&&i<n) ans=max(ans,i);
      else if(i>=n&&j>=n) ans=max(ans,max(i,j));
    }
  }
  COUT(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll a,b,c; cin>>a>>b>>c;
    if(c-a-b<0) cout<<"No"<<endl;
    else if(4*a*b<(c-a-b)*(c-a-b)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string;
import std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

int DEBUG_LEVEL = 0;
void print()(){ writeln(""); }
void print(T, A ...)(T t, lazy A a){ write(t), print(a); }
void print(int level, T, A ...)(T t, lazy A a){ if(level <= DEBUG_LEVEL) print(t, a); }

void main(string[] args){
	if(args.length > 1 && args[1] == "-debug"){
		if(args.length > 2 && args[2].isNumeric) DEBUG_LEVEL = args[2].to!int;
		else DEBUG_LEVEL = 1;
	}
	
	long n = read.to!long;
	long m = read.to!long;
	
	long a = 1, b = n;
	foreach(i; 0 .. m){
		long l = read.to!long;
		long r = read.to!long;
		if(l > a) a = l;
		if(r < b) b = r;
	}
	
	long ans = b - a + 1;
	if(ans < 0) ans = 0;
	
	ans.writeln;	
}



Measured memory_bytes: 1276
#include<cstdio>
#include<cstring>
int main(void){
	char s[27];
	int box[26];
	int i;
	int n,flg;
	scanf("%s",s);
	n=strlen(s);
	for(i=0;i<26;i++)	box[i]=0;
	for(i=0;i<n;i++)	box[s[i]-'a']++;
	flg=0;
	for(i=0;i<26;i++){
		if(box[i]>=2){
			flg=1;
		}
	}
	if(flg==0)	printf("yes\n");
	else		printf("no\n");
	return 0;
}
		
		

Measured memory_bytes: 128
from collections import Counter
n,m=map(int,input().split())
d=Counter(list(map(int,input().split())))
for i in range(m):
    b,c=map(int,input().split())
    if c in d:
        d[c]+=b
    else:
        d[c]=b
d=sorted(Counter(d).items(),reverse=True)
check=n
ans=0
#print(d)
for i in d:
    if i[1]<check:
        check-=i[1]
        ans+=(i[0]*i[1])
    else:
        ans+=(i[0]*check)
        print(ans)
        break


Measured memory_bytes: 52640
//napsack0-1
#include <iostream>
#include<vector>
#include<algorithm>
#define NMAX 105
#define WMAX 10005
#define DIAGONAL 1
#define TOP 0

using namespace std;

struct Item {
    int value, weight;

};

int N, W;
Item items[NMAX + 1];
int C[NMAX + 1][WMAX + 1], G[NMAX + 1][WMAX + 1];

void compute(int& maxValue, vector<int>& selection){
    for (int w = 0; w <= W; w++) {
        C[0][w] = 0;
        G[0][w] = DIAGONAL;

    }

    for (int i = 1; i <= N; i++)C[i][0] = 0;

    for (int i = 1; i <= N; i++) {
        for (int w = 1; w <= W; w++) {
            C[i][w] = C[i - 1][w];
            G[i][W] = TOP;
            if (items[i].weight > w)continue;
            if (items[i].value + C[i - 1][w - items[i].weight] > C[i - 1][w]) {
                C[i][w] = items[i].value + C[i - 1][w - items[i].weight];
                G[i][w] = DIAGONAL;
            }
        }
    }

    maxValue = C[N][W];
    selection.clear();
    for (int i = N, w = W; i >= 1; i--) {
        if (G[i][w] == DIAGONAL) {
            selection.push_back(i);
            w -= items[i].weight;
        }
    }

    reverse(selection.begin(),selection.end());

}

void input() {
    cin >> N >> W;
    for (int i = 1; i <= N; i++) {
        cin >> items[i].value >> items[i].weight;
    }
}

int main()
{

    int maxValue;
    vector<int> selection;
    input();
    compute(maxValue, selection);

    cout << maxValue << endl;

    return 0;

}




Measured memory_bytes: 9228
using System;
using System.Linq;

namespace ABC058D
{
    class Program
    {
        static void Main(string[] args)
        {
            Solver solver = new Solver();
            solver.Solve();
        }
    }

    class Solver

    {
        private long N;
        private long M;
        private long[] NComb;
        private long[] MComb;
        private long Big;

        public void Solve()
        {
            long[] ints = Console.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
            N = ints[0];
            M = ints[1];
            NComb = new long[N + 1];
            MComb = new long[M + 1];
            setComb();
            Big = (long) Math.Pow(10, 9) + 7;

            long[] x = Console.ReadLine().Split(' ').Select(b => long.Parse(b)).ToArray();
            long[] y = Console.ReadLine().Split(' ').Select(c => long.Parse(c)).ToArray();

            long nLength = 0;

            for (long i = 0; i < N - 1; i++)
            {
                nLength += (x[i + 1] - x[i]) % Big * (NComb[i + 1] % Big);
                nLength %= Big;
            }

            long mLength = 0;

            for (long i = 0; i < M - 1; i++)
            {
                mLength += (y[i + 1] - y[i]) % Big * (MComb[i + 1] % Big);
                mLength %= Big;
            }

            Console.WriteLine(nLength * mLength % Big);
        }

        public void setComb()
        {
            for (long i = 1; i <= N; i++)
            {
                NComb[i] = i * (N - i);
            }

            for (long i = 1; i <= M; i++)
            {
                MComb[i] = i * (M - i);
            }
        }
    }
}

Measured memory_bytes: 41548
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  int n; cin >> n;
  vector<lint> a(n);
  vector<pair<lint, lint>> dat(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    dat[i] = {a[i], i + 1};
  }

  sort(RALL(dat));
  vector<vector<lint>> dp(n + 1, vector<lint> (n + 1, 0));
  for (int i = 1; i <= n; i++) {
    lint score;
    lint x;
    tie(score, x) = dat[i - 1];

    // すでに i - 1 個埋まってる
    for (int l = 0; l < i; l++) {
      // r は (i - 1) - l 個埋まってる
      int r = (i - 1) - l;

      // 左に埋める
      {
        int y = l + 1;
        dp[l + 1][r] = max(dp[l + 1][r], dp[l][r] + (lint)abs(x - y) * score);
      }

      // 右に埋める
      {
        int y = n - r;
        dp[l][r + 1] = max(dp[l][r + 1], dp[l][r] + (lint)abs(x - y) * score);
      }
    }
  }

  lint ans = 0;
  // 合計が n になるやつを探す
  for (int l = 0; l <= n; l++) {
    int r = n - l;
    ans = max(ans, dp[l][r]);
  }

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


Measured memory_bytes: 34684
from collections import Counter

class ModComb:
    def __init__(self, MAX, mod=10 ** 9 + 7):
        fac = [1, 1]
        finv = [1, 1]
        inv = [0, 1]
        for i in range(2, MAX):
            fac.append(fac[i - 1] * i % mod)
            inv.append(mod - inv[mod % i] * (mod // i) % mod)
            finv.append(finv[i - 1] * inv[i] % mod)
        self.fac, self.finv, self.mod = fac, finv, mod

    def nCk(self, n, k):
        if n < k or n < 0 or k < 0:
            return 0
        fac, finv, mod = self.fac, self.finv, self.mod
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod

mod = 10 ** 9 + 7

N, *A = map(int, open(0).read().split())

C = Counter(A)
t = C.most_common()[0][0]
left = A.index(t)
right = A.index(t, left + 1)

mc = ModComb(10 ** 5 + 5, mod=mod)

m = left + N - right
for k in range(1, N + 2):
    print((mc.nCk(N + 1, k) - mc.nCk(m, k - 1)) % mod)


Measured memory_bytes: 28244
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n, k; cin >> n >> k;
    cout << ((n%k == 0) ? "0" : "1") << endl;
}

Measured memory_bytes: 256
import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29

def main():
    n,k = map(int,input().split())
    if n==1:
        print(k)
        return
    ans = k * ((k - 1) ** (n - 1))
    print(ans)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  int cnt=0,last;
  bool f=true;
  cin>>n;
  while(n!=0){
    if(n/10==0) last=n;
    else if(n%10!=9) f=false;
    cnt++;
    n/=10;
  }
  cout<<((cnt-1)*9+(f?last:last-1))<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define MAX 510000
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll n,m,x; cin >> n >> m >> x;
    ll cnt = 0;
    rep(i,m){
        ll a; cin >> a;
        if(a<x) cnt++;
    }
    cout << min(cnt, m-cnt) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>

#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <functional>

#include <sstream>
#include <iostream>

using namespace std;
typedef long long llint;
const llint inf = 1000000000000000000LL;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

#define TRACE(x) cerr << #x << " = " << x << endl
#define _ << " _ " <<

struct HalfDP {
  map<llint,llint> dslope;
  llint shift_x;

  HalfDP() { shift_x = 0; }

  pair<llint,llint> shifted(pair<llint,llint> p) {
    p.first += shift_x;
    return p;
  }
  pair<llint,llint> first() { return shifted(*dslope.begin()); }
  pair<llint,llint> last() { return shifted(*--dslope.end()); }
  
  void shift(llint x) { shift_x += x; }
  void add(llint x, llint y) { dslope[x - shift_x] += y; }
  void pop_first() { dslope.erase(dslope.begin()); }
  void pop_last() { dslope.erase(--dslope.end()); }
};

struct FullDP {
  HalfDP L, R;
  llint min_y;

  void init(llint x) {
    L.dslope[x] = -1;
    R.dslope[x] = +1;
    min_y = 0;
  }

  void apply_min(llint wl, llint wr) {
    L.shift(-wl);
    R.shift(+wr);
  }

  void add_abs(llint x) {
    llint lx = L.last().first;
    llint rx = R.first().first;

    if (x >= lx && x <= rx) {
      L.add(x, -1);
      R.add(x, +1);
    } else if (x > rx) {
      R.add(rx, -1);
      R.add(x, +2);
      L.add(rx, -1);
      min_y += abs(rx - x);
    } else {
      L.add(lx, +1);
      L.add(x, -2);
      R.add(lx, +1);
      min_y += abs(lx - x);
    }

    if (R.first().second == 0) 
      R.pop_first();

    if (L.last().second == 0) 
      L.pop_last();
  }
} dp;


int main(void) 
{
  const int MAXN = 1e5 + 5;
  int N;
  static llint l[MAXN];
  static llint r[MAXN];
  
  scanf("%d", &N);
  REP(i, N) scanf("%lld%lld", l+i,r+i);

  dp.init(l[0]);
  
  FOR(i, 1, N) {
    llint wr = r[i - 1] - l[i - 1];
    llint wl = r[i] - l[i];
    dp.apply_min(wl, wr);
    dp.add_abs(l[i]);
  }

  printf("%lld\n", dp.min_y);

  return 0;
}


Measured memory_bytes: 14336
N = gets.chop.to_i
S = gets.chop.chars
alp = Array('A'..'Z')
code = []
S.each do |s|
  num = (alp.index(s) + 1) + N
	if num >> 26
      code << alp[num - 27]
    else
      code << alp[num]
    end
end

puts code.join

Measured memory_bytes: 2300
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = MAP()

ans = 0
A = [0] * (K+1)
for x in range(K, 1, -1):
    a = K // x
    A[x] = pow(a, N, MOD)
    i = x
    while i + x <= K:
        i += x
        A[x] -= A[i]
    A[x] %= MOD
    ans += A[x] * x
    ans %= MOD
ans += pow(K, N, MOD) - sum(A)
ans %= MOD
print(ans)


Measured memory_bytes: 11176
#! /usr/bin/env python3

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

L, R, d = map(int, readline().split())

cnt = 0
for i in range(L, R + 1):
    if i % d == 0:
        cnt += 1

print(cnt)


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  map<char, ll> mp;
  mp.emplace('M', 0);
  mp.emplace('A', 0);
  mp.emplace('R', 0);
  mp.emplace('C', 0);
  mp.emplace('H', 0);

  rep(i, n) {
    cin >> s[i];
    if (s[i][0] == 'M' || s[i][0] == 'A' || s[i][0] == 'R' || s[i][0] == 'C' ||
        s[i][0] == 'H') {
      if (mp.find(s[i][0]) != mp.end()) mp[s[i][0]]++;
    }
  }
  // cout << mp['M'] << endl;
  // cout << mp['A'] << endl;
  // cout << mp['R'] << endl;
  // cout << mp['C'] << endl;
  // cout << mp['H'] << endl;

  ll ans = 0;
  ans += mp['M'] * mp['A'] * mp['R'];
  ans += mp['A'] * mp['R'] * mp['C'];
  ans += mp['R'] * mp['C'] * mp['H'];
  ans += mp['M'] * mp['R'] * mp['H'];
  ans += mp['M'] * mp['R'] * mp['C'];
  ans += mp['A'] * mp['R'] * mp['H'];
  ans += mp['M'] * mp['C'] * mp['H'];
  ans += mp['M'] * mp['A'] * mp['H'];
  ans += mp['A'] * mp['C'] * mp['H'];
  ans += mp['M'] * mp['C'] * mp['A'];
  cout << ans << endl;
  return 0;
}


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

int main(){
    int a,b,k;
    cin>>a>>b>>k;
    

    for(int i=0; i<k; i++){
        if(a+i>=((double)a+b)/2){
            break;
        }
        cout<<a+i<<endl;
    }

    for(int i=k-1; i>=0; i--){
        if(b-i<((double)a+b)/2){
            continue;
        }
        /*if(b-i==last){
            continue;
        }*/
        cout<<b-i<<endl;
    }
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn get_pair(i: usize, n: usize) -> usize {
    if i <= n {
        i + n
    } else {
        i - n
    }
}

fn main() {
    let n = read::<usize>();
    let mut index = 1;
    while n >= index {
        if n == index {
            println!("No");
            return;
        }
        index *= 2;
    }
    println!("Yes");

    let mut max_full_bit = 1;
    while n >= 2 * max_full_bit - 1 {
        max_full_bit *= 2;
    }
    max_full_bit -= 1;

    let mut pairs = vec![];
    for i in 1..3 {
        pairs.push((i, i + 1));
    }
    pairs.push((1, get_pair(3, n)));
    for i in 1..3 {
        pairs.push((get_pair(i, n), get_pair(i + 1, n)));
    }

    if n % 2 == 1 {
        for i in 4..n + 1 {
            if i % 2 == 0 {
                pairs.push((1, i));
                pairs.push((i, i + 1));
                pairs.push((1, get_pair(i + 1, n)));
                pairs.push((get_pair(i, n), get_pair(i + 1, n)));
            }
        }
    } else {
        for i in 4..n {
            if i % 2 == 0 {
                pairs.push((1, i));
                pairs.push((i, i + 1));
                pairs.push((1, get_pair(i + 1, n)));
                pairs.push((get_pair(i, n), get_pair(i + 1, n)));
            }
        }

        let mut one_pairs = HashSet::new();
        for &(a, b) in pairs.iter() {
            if a == 1 {
                one_pairs.insert(b);
            } else if b == 1 {
                one_pairs.insert(a);
            }
        }

        if one_pairs.contains(&(max_full_bit + 1)) {
            pairs.push((max_full_bit + 1, n));
        } else {
            pairs.push((n + max_full_bit + 1, n));
        }

        if one_pairs.contains(&(n - max_full_bit)) {
            pairs.push((n - max_full_bit, 2 * n));
        } else {
            pairs.push((2 * n - max_full_bit, 2 * n));
        }
    }

    for pair in pairs {
        println!("{0} {1}", pair.0, pair.1);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 15272
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cctype>
#include <ctime>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define eps 1e-9

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

const int INF = 0x7fffffff;
const int maxn = 1e5 + 10;
char s[maxn];

int main() {
#ifdef __AiR_H
    freopen("A.in", "r", stdin);
//    freopen("out.txt", "w", stdout);
#endif // __AiR_H
    scanf("%s", s); int len = strlen(s), l = -1, r = -1;
    for (int i = 0; i < len - 1; ++i) {
        if (s[i] == s[i + 1]) { l = i + 1; r = i + 2; break; }
        if (i < len - 2 && s[i] == s[i + 2]) { l = i + 1; r = i + 3; break; }
    }
    printf("%d %d\n", l, r);
#ifdef __AiR_H
    printf("Time used = %.2fs\n", (double)clock() / CLOCKS_PER_SEC);
#endif // __AiR_H
    return 0;
}


Measured memory_bytes: 384
import sys
N, K = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(K)]
MOD = 998244353

dp = [0] * (N + 1)
dp[1] = 1

def add(k, x):
    while k <= N:
        dp[k] += x
        dp[k] %= MOD
        k += k & -k


def get(k):
    s = 0
    while k:
        s += dp[k]
        k -= k & -k
    return s

for i in range(1, N + 1):
    for l, r in X:
        add(i + l, get(i))
        add(i + r + 1, -get(i))

print(get(N) % MOD)


Measured memory_bytes: 70000
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main(){
    int n;
    cin >> n;
    int a[n];
    REP(i,n)cin >> a[i];
    int gcd = euclidean_gcd(a[0],a[1]);
    FOR(i,2,n){
        gcd = euclidean_gcd(gcd,a[i]);
    }
    cout << gcd << endl;
    return 0;
}

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

int dp[3003][3003];
string a,b,ans="";

void pr(int i,int j){
	if(i<=0 || j<=0)return ;
	
	if(a[i-1]==b[j-1]){
		ans=a[i-1]+ans;
		pr(i-1,j-1);
	}
	else if(dp[i-1][j] > dp[i][j-1]){
		pr(i-1,j);
	}
	else pr(i,j-1);
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	cin>>a>>b;
	
	for(int i=0;i<=a.size();i++){
		for(int j=0;j<=b.size();j++){
			if(i==0 || j==0){
				dp[i][j]=0;
			}
			else if(a[i-1]==b[j-1])
				dp[i][j]=1+dp[i-1][j-1];
			else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	
	pr(a.size(),b.size());
	
	cout<<ans;
	return 0;
}

Measured memory_bytes: 39224
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.Queue;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String line = br.readLine();
		String[] arr = line.split(" ");
		int n = Integer.parseInt(arr[0]);
		int q = Integer.parseInt(arr[1]);

		Queue<Process> queue = new LinkedList<Process>();
		for (int i = 0; i < n; i++) {
			line = br.readLine();
			arr = line.split(" ");
			Process p = new Process();
			p.name = arr[0];
			p.time = Integer.parseInt(arr[1]);
			queue.offer(p);
		}

		int passed = 0;
		while (queue.size() > 0) {
			Process p = queue.poll();
			if (p.time <= q) {
				passed += p.time;
				System.out.println(p.name + ' ' + passed);
			} else {
				passed += q;
				p.time -= q;
				queue.offer(p);
			}
		}

		if (br != null) {
			br.close();
			br = null;
		}
	}

	private static class Process {
		public String name;
		public int time;
	}
}

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

using namespace std;
using ll = long long;


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first;
        a[i].second = i + 1;
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++) {
        cout << a[i].second << " ";
    }
    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	string a,b;
	cin>>a>>b;
	cout<<b+a;
}

Measured memory_bytes: 256
import math

a, b, C = map(float, input().split())

r = math.radians(C)
S = a * b * math.sin(r) / 2
c = ((a ** 2) + (b ** 2) - (2 * a * b * math.cos(r))) ** 0.5
L = a + b + c
h = 2 * S / a

print(S, L, h)


Measured memory_bytes: 5696