akhauriyash/Code-Regression huggingface dataset:
q,h,s,d = map(int, input().split())
n = int(input())
q_perf = q / 0.25
h_perf = h / 0.5
s_perf = s
d_perf = d / 2
list_amo = [0.25,0.5,1,2]
list_price = [q,h,s,d]
list_perf = [q_perf,h_perf,s_perf,d_perf]
cost = 0
ind4 = list_perf.index(min(list_perf))
ind3 = list_perf.index(min(list_perf[0:3]))
ind2 = list_perf.index(min(list_perf[0:2]))
ind1 = list_perf.index(min(list_perf[0:1]))

while n >= 2:
    cost += int((n//list_amo[ind4]) *  int(list_price[ind4]))
    n -= (n//list_amo[ind4]) * list_amo[ind4]
while n >= 1:
    cost += int((n//list_amo[ind3]) *  int(list_price[ind3]))
    n -= (n//list_amo[ind3]) * list_amo[ind3]
while n >= 0.5:
    cost += int((n//list_amo[ind2]) *  list_price[ind2])
    n -= (n//list_amo[ind2]) * list_amo[ind2]

while n >= 0.25:
    cost += int((n//list_amo[ind1]) *  list_price[ind1])
    n -= (n//list_amo[ind1]) * list_amo[ind1]

print(int(cost))

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 200001
#define int ll
int N,D,x,y;
int32_t main(){
	fast;
	cin>>N>>D;
	
	int ans = 0;
	FOR(i,1,N){
		cin>>x>>y;
		if (x * x + y * y <= D * D) ans++;
	}
	cout<<ans;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    string s; cin >> s;
    unordered_map<int, int> cnt;
    cnt[0] = 1;
    int sum = 0, ans = 0;
    reverse(s.begin(), s.end());
    int base = 1;
    for (auto &c : s) {
        sum += (c - '0') * base;
        sum %= 2019;
        ans += cnt[sum];
        cnt[sum]++;
        base *= 10;
        base %= 2019;
    }
    cout << ans << '\n';

}


Measured memory_bytes: 3744
fs = require('fs').readFileSync('/dev/stdin','utf-8');
tmp = fs.split('\n');
N =tmp[0];
A = tmp[1].split(' ');
for(i = 0; i < N; i++) {
  if(A[i] == '0') { console.log(0); return; }
}
B = BigInt(parseInt(A[0],10));
for(i = 1; i < N; i++) {
  B = B * BigInt(parseInt(A[i],10));
  if(B > Math.pow(10,18)) { B = -1; break; }
}
console.log((B + '').replace('n',''));

Measured memory_bytes: 42256
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner s = new Scanner(System.in);
    long k=s.nextLong(),a=s.nextLong(),b=s.nextLong();
    long c=Math.max(0,k-a+1);
    System.out.print(Math.max((b-a)*(c/2)+a+c%2,k+1));
  }
}

Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
typedef long long ll;
using namespace std;

struct Node{
  vector<int> connected;
  vector<int> sib;
  int cnt;
};

void unite(int par,int t,Node node[]){
  for(int i=0;i<node[t].connected.size();i++){
    if(node[t].connected[i]!=par){
      node[t].sib.push_back(node[t].connected[i]);
      node[node[t].connected[i]].cnt+=node[t].cnt;
      unite(t,node[t].connected[i],node);
    }
  }
}

int main(void){
  Node node[200010];
  int i,n,q,a,b,p,x;
  cin>>n>>q;
  node[n].cnt=0;
  for(i=1;i<n;i++){
    cin>>a>>b;
    node[a].connected.push_back(b);
    node[b].connected.push_back(a);
    node[i].cnt=0;
  }
  for(i=0;i<q;i++){
    cin>>p>>x;
    node[p].cnt+=x;
  }

  unite(-1,1,node);

  for(i=1;i<=n;i++){
    cout<<node[i].cnt<<" ";
  }

  return 0;
}


Measured memory_bytes: 41472
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    int a,b;
    cin >> a >> b;
    ll ans = lcm(a,b);
    cout << ans << endl;
}
    



Measured memory_bytes: 256
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;


namespace GraphLib{
	//http://www.prefield.com/algorithm/index.html
  using Weight = int;
  struct Edge{
    int src,dst;
    Weight weight;
    Edge(int src,int dst,Weight weight):
      src(src),dst(dst),weight(weight){}
  };
  bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight :
      e.src != f.src ? e.src < f.src : e.dst < f.dst;
  }
  using Edges = vector<Edge>;
  using Graph = vector<Edges>;
  using Array = vector<Weight>;
  using Matrix = vector<Array>;
}
using namespace GraphLib;
Graph g;
//here begins your code


int K = 0;
map<pair<int,int>,int> rec;
void dfs(int n, int pre, int col){
	for(auto nv : g[n]){
		if(nv.dst == pre) continue;
		col++;
		col = col % K;
		int a = n;
		int b = nv.dst;
		if(a > b) swap(a,b);
		rec[{a,b}] = col;
		dfs(nv.dst,n,col);
	}
}


signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int N;
  cin >> N;
  g.resize(N);
  vector<int> av(N-1);
  vector<int> bv(N-1);
  for(int i = 0 ; i < N-1 ; i++){
  	int a,b;
  	cin >> a >> b;
  	a--;
  	b--;
  	if(a > b){
  		swap(a,b);
  	}
  	av[i] = a;
  	bv[i] = b;
    g[a].eb(Edge(a,b,1));
    g[b].eb(Edge(b,a,1));
  }
  K = g[0].size();
  int idx = 0;
  for(int i = 0 ; i < N ; i++){
  	if(g[i].size() > K){
  		K = g[i].size();
  		idx = i;
  	}
  }
  dfs(idx,-1,0);
  cout << K << endl;
  for(int i = 0 ; i < N - 1; i++){
  	cout << rec[{av[i],bv[i]}] + 1 << endl;
  }
  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 12544
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	string s;
	cin >> s;
	int a = s[0] - '0';
	if (s.size() > 1 && s[s.size() - 1] != '9')cout << (s.size() - 1) * 9 + a - 1 << endl;
	else if (s.size() > 1)cout << (s.size() - 1) * 9+a << endl;
	else cout << a << endl;
	int x;
	cin >> x;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int col[]={0,-1,0,1,-1,0,1,-1,0,1};
bool ok(int left,int right){
  return col[left]<=col[right];
}
typedef vector<vvi> vvvi;
typedef vector<vvvi> vvvvi;
int main(){
  string s;
  while(cin>>s,s!="#"){
    int n=s.size();
    vvvvi dp(2,vvvi(10,vvi(10,vi(2,INT_MAX/10))));
    REP(j,10){
      REP(k,10){
        REP(l,2){
          dp[0][j][k][l]=0;
        }
      }
    }
    REP(i,n){
      REP(j,10){
        REP(k,10){
          REP(l,2){
            dp[(i+1)%2][j][k][l]=INT_MAX/10;
          }
        }
      }
      REP(j,10){
        REP(k,10){
          int p=s[i]-'0';
          if(ok(p,k)){
            REP(l,2){
              dp[(i+1)%2][p][k][0]=min(dp[(i+1)%2][p][k][0],dp[i%2][j][k][l]+(l==0));
            }
          }
          if(ok(j,p)){
            REP(l,2){
              dp[(i+1)%2][j][p][1]=min(dp[(i+1)%2][j][p][1],dp[i%2][j][k][l]+(l==1));
            }
          }
        }
      }
    }
    int ans=INT_MAX;
    /*
    REP(i,n+1){
      REP(j,10){
        REP(k,10){
          REP(l,2){
            cerr<<i<<" "<<j<<" "<<k<<" "<<l<<" "<<dp[i%2][j][k][l]<<endl;
          }
        }
      }
    }
    */
    REP(j,10){
      REP(k,10){
        REP(l,2){
          ans=min(ans,dp[n%2][j][k][l]);
        }
      }
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1340
n,m=map(int,input().split())
A=[[] for _ in range(n)]
for i in range(n):
 A[i] = [_ for _ in map(int,input().split())]
b=[]
for i in range(m):
 b.append(int(input()))
for i in range(n):
 c=0
 for j in range(m):
  c+=A[i][j]*b[j]
 print(c)

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

int main() {
  int A,B;
  cin >> A >> B;
  
  string S;
  cin >> S;
  int countA = 0;
  int countab = 0;
  int countB = 0;
  
  for (int i = 0; i < A ; i++) {
    if (S.at(i) == '1' || S.at(i) == '2' || S.at(i) == '3' || S.at(i) == '4' || S.at(i) == '5' || S.at(i) == '6' || S.at(i) == '7' || S.at(i) == '8' || S.at(i) == '9' || S.at(i) == '0'){
      countA++;
    }
  }
  
  if (S.at(A) == '-'){
    countab++;
  }
  
  for (int i = A + 1; i < A + B + 1 ; i++) {
    if (S.at(i) == '1' || S.at(i) == '2' || S.at(i) == '3' || S.at(i) == '4' || S.at(i) == '5' || S.at(i) == '6' || S.at(i) == '7' || S.at(i) == '8' || S.at(i) == '9' || S.at(i) == '0'){
      countB++;
    }
  }
  
  if (countA == A && countab == 1 && countB == B){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
  



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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,cnt=0,w;
	cin>>n;
	vector<ll>v(n);
	for(int i=0;i<n;i++) cin>>v.at(i);
	for(int i=0;i<n-1;i++){
		if(v.at(i)==i+1){
			w=v.at(i);v.at(i)=v.at(i+1);v.at(i+1)=w;
			cnt++;
		}
	}
	for(int i=n-1;i>=1;i--){
			if(v.at(i)==i+1){
				w=v.at(i);v.at(i)=v.at(i-1);v.at(i-1)=w;
				cnt++;
			}
		}
	cout<<cnt<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr,0,sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9+7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t  main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n, a, b;
        cin >> n >> a >> b;
        int d = n / (a + b);
        int ans = (a * d) + min(a, (n % (a + b)));
        cout << ans << '\n';
    } 
}

Measured memory_bytes: 31488
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var words = input.trim().split(' ');

var f = {};
var maxCnt = 0;
var maxWord;
words.forEach(function(word) {
	var cnt = f[word] || 0;
	cnt++;
	if (cnt > maxCnt) {
		maxCnt = cnt;
		maxWord = word;
	}
	f[word] = cnt;
});

words.sort(function(a,b) {return b.length - a.length;});

console.log(maxWord + ' ' + words[0]);

Measured memory_bytes: 7640
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
// #define mp make_pair
//#define endl '\n'
 
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int x = a - b;
    int y = c - x;
    if(y < 0){
        cout << 0 << endl;
    }
    else{
        cout << y << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int k;cin>>k;
    int a;cin>>a;
    int b;cin>>b;
    int flag = 0;
    for(int i=a;i<=b;i++)
    {
        if(i%k ==0){flag=1;break;}
    }
    if(flag==1)cout<<"OK"<<endl;else cout<<"NG"<<endl;


}


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

using namespace std;

signed main(){
	int n, ans = 0;
	cin >> n;
	int h[n+1], dp[n+1];
	memset(dp, 0, sizeof(dp));
	for (int i=1; i<=n; i++)
	    cin >> h[i];
	dp[1] = 0;
	dp[2] = abs(h[1] - h[2]);
	for (int i=3; i<=n; i++){
		dp[i] = min(dp[i-1] + abs(h[i-1] - h[i]), dp[i-2] + abs(h[i-2] - h[i]));
	}
	cout << dp[n];
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;

int n, m, adj[8][8] = {}, ans = 0;
bool use[8] = {};

// next_permutationを使わずに再帰で書く練習
void dfs(int par, int dep){
    if(dep == n){
        ans++;
        return;
    }
    for(int i = 0; i < n; i++){
        if(use[i] || adj[par][i]==0)  continue;
        use[i] = true;
        dfs(i, dep+1);
        use[i] = false;
    }
}

int main(){
    cin >> n >> m;
    int a, b;
    while(m-- > 0){
        cin >> a >> b;
        a--, b--;
        adj[a][b] = adj[b][a] = 1;
    }
    use[0] = true;
    dfs(0, 1);
    use[0] = false; // いらない
    cout << ans << endl;
    return 0;
}

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

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

Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>

int abs(int a){
	return a < 0 ? -1*a : a;
}

int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	int h[n];
	int i;
	for(i = 0;i < n;i++){
		scanf("%d",&h[i]);
	}

	int c[n];
	c[0] = 0;
	for(i = 1; i < n;i++){
		int min = INT_MAX;
		int j = i-1;
		while(j >= 0 && i-j <= k){
			if(c[j] + abs(h[j]-h[i]) < min){
				min = c[j] + abs(h[j] - h[i]);
			}
			j--;
		}
		c[i] = min;
	}
	printf("%d\n",c[n-1]);
}

Measured memory_bytes: 896
S = input()

l = len(S)
maxv = 0

for i in range(l):
    count = 0
    if 'A' == S[i] or 'C' == S[i] or 'G' == S[i] or 'T' == S[i]:
        count = 1
        for j in range(i+1, l):
            if 'A' == S[j] or 'C' == S[j] or 'G' == S[j] or 'T' == S[j]:
                count += 1
            else:
                break

    if maxv < count:
        maxv = count

print(maxv)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define X first
#define Y second
#define pb push_back
#define pii pair<int, int>
typedef long long ll;
using namespace std;

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const int OFF = (1 << 20);

string s;
int pot[200002];
int post[3000];

int main () {

	cin >> s;
	int n = s.size();
	pot[0] = 1;
	for (int i = 1; i <= n; i++) {
		pot[i] = pot[i-1] * 10;
		pot[i] %= 2019;
	}
	
	ll sol = 0;
	int zbr = 0;
	post[0] = 1;
	for (int i = n-1; i >= 0; i--) {
		zbr += pot[n-1-i]*(s[i]-'0');
		zbr %= 2019;
		//cout << zbr << " " << post[zbr] << endl;
		sol += post[zbr];
		post[zbr] ++;
	}
	
	cout << sol;

	return 0;
}

Measured memory_bytes: 4392
#include <iostream>
#include <vector>
#include <utility>
using namespace std;

bool isWall[300][300];
int isVisited[300][300];

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

int solve(int cx, int cy, int ct){
    int ret = 0;

    if(isVisited[cx][cy] >= ct || ct == -1 || isWall[cx][cy]){
        return 0;
    }

    if(isVisited[cx][cy] == -1){
        ret++;
    }
    isVisited[cx][cy] = ct;

    for(int i=0;i<6;i++){
        int nx = cx + dx[i];
        int ny = cy + dy[i];
        ret += solve(nx, ny, ct-1);
    }

    return ret;
}

int main(){
    while(true){
        int t, n;
        int sx, sy;
        cin >> t >> n;
        if(t == 0 && n == 0){
            break;
        }

        // init
        for(int i=0;i<300;i++){
            for(int j=0;j<300;j++){
                isWall[i][j] = false;
                isVisited[i][j] = -1;
            }
        }

        // input
        for(int i=0;i<n;i++){
            int x, y;
            cin >> x >> y;
            isWall[x+100][y+100] = true;
        }
        cin >> sx >> sy;

        // output
        cout << solve(100+sx, 100+sy, t) << endl;
    }
    return 0;
}

Measured memory_bytes: 3544
import java.lang.reflect.Array;
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        int x = Integer.parseInt(st.nextToken());
        if(x == 1 || x == 2*n - 1){
            System.out.print("No");
            return;
        }
        System.out.println("Yes");
        StringBuilder sb = new StringBuilder();
        int array[] = new int[2*n];
        array[n] = x;
        for(int i = n - 1;i >= 1;i--)
            array[i] = array[i + 1] - 1;
        for(int i = n + 1;i < array.length;i++)
            array[i] = array[i - 1] + 1;
        for(int i = 1;i < array.length;i++){
            if(array[i] <= 0)array[i] += 2*n - 1;
            if(array[i] > 2*n - 1)array[i] -= 2*n - 1;
        }
        for(int i = 1;i < 2*n;i++){
            sb.append(array[i]);
            sb.append('\n');
        }
        System.out.print(sb);
    }
}

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

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

    int n, m;
    cin >> n >> m;
    vector<int> obs(n);
    vector<int> adj[n];
    vector<int> score(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> obs[i];
    }
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
        if (obs[a] > obs[b])
            score[a]++;
        else if (obs[b] > obs[a])
            score[b]++;
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
        if (score[i] == adj[i].size())
            ans++;
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9248
#include <algorithm>
#include <cstdint>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, s, t) for (int i = s; i < t; i++)
#define ALL(obj) obj.begin(), obj.end()

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;
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;
}

template <std::uint_fast64_t Modulus>
class ModInt {
    using u64 = std::uint_fast64_t;

   public:
    u64 a;

    constexpr ModInt(const u64 x = 0) noexcept : a(x % Modulus) {}
    constexpr u64 &value() noexcept { return a; }
    constexpr const u64 &value() const noexcept { return a; }
    constexpr ModInt operator+(const ModInt rhs) const noexcept { return ModInt(*this) += rhs; }
    constexpr ModInt operator-(const ModInt rhs) const noexcept { return ModInt(*this) -= rhs; }
    constexpr ModInt operator*(const ModInt rhs) const noexcept { return ModInt(*this) *= rhs; }
    constexpr ModInt operator/(const ModInt rhs) const noexcept { return ModInt(*this) /= rhs; }
    constexpr ModInt &operator+=(const ModInt rhs) noexcept {
        a += rhs.a;
        if (a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr ModInt &operator-=(const ModInt rhs) noexcept {
        if (a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr ModInt &operator*=(const ModInt rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr ModInt &operator/=(ModInt rhs) noexcept {
        u64 exp = Modulus - 2;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
};

using mint = ModInt<MOD>;

long long modPow(long long x, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }

    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}

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

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

template <typename T>
using Vec = vector<T>;
template <typename T>
using VVec = vector<vector<T>>;
using LL = long long;
int main() {
    int N;
    cin >> N;
    Vec<int> ans(N);
    REP(i, N) {
        int in;
        cin >> in;
        ans[in - 1] = i + 1;
    }

    for (auto x : ans) {
        cout << x << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1152
c = [list(map(int, input().split())) for _ in range(3)]
if c[0][0] - c[0][1] == c[1][0] - c[1][1] == c[2][0] - c[2][1] and c[0][1] - c[0][2] == c[1][1] - c[1][2] == c[2][1] - \
        c[2][2] and c[0][0] - c[1][0] == c[0][1] - c[1][1] == c[0][2] - c[1][2] and c[1][0] - c[2][0] == c[1][1] - c[2][
    1] == c[1][2] - c[2][2]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

typedef struct cir{
  int val;
  int index;
} node;

int cmp(const void *a,const void *b){
  return ((node *)a)->val-((node *)b)->val;
}

int func(int x,int y,int r,int c){
  if(!(x==0 || x==r || y==0 || y==c)) return -1;
  if(x==0) return y;
  if(y==c) return c+x;
  if(x==r) return r+c+(c-y);
  return 2*c+r+(r-x);
}

void run(void){
  int r,c,n;
  scanf("%d%d%d",&r,&c,&n);
  node *array=(node *)malloc(sizeof(node)*2*n);
  int len=0;
  int i;
  for(i=0;i<n;i++){
    int x1,y1,x2,y2;
    scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
    int v1=func(x1,y1,r,c);
    int v2=func(x2,y2,r,c);
    if(v1>=0 && v2>=0){
      array[len].val=v1;
      array[len].index=i;
      len++;
      array[len].val=v2;
      array[len].index=i;
      len++;
    }
  }
  qsort(array,len,sizeof(node),cmp);
  int *stack=(int *)malloc(sizeof(int)*len);
  int top=0;
  for(i=0;i<len;i++){
    int index=array[i].index;
    if(top>0 && stack[top-1]==index){
      top--;
    } else {
      stack[top++]=index;
    }
  }
  printf("%s\n",top==0?"YES":"NO");
}

int main(void){
  run();
  return 0;
}


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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  ll N; cin >> N;
  vector<ll> A(N), B(N);
  for (ll i = 0; i < N; i++) cin >> A.at(i);
  for (ll i = 0; i < N; i++) cin >> B.at(i);

  ll ans = 0;
  for (ll k = 0; k <= 30; k++) {
    vector<ll> C(N), D(N);
    for (ll i = 0; i < N; i++) {
      C.at(i) = A.at(i) & ((1 << (k+1)) - 1);
      D.at(i) = B.at(i) & ((1 << (k+1)) - 1);
    }
    sort(C.begin(), C.end());
    sort(D.begin(), D.end());
    ll p = 0; 
    ll q = 0; 
    ll r = 0; 
    for (ll i = N-1; i >= 0; i--) {
      function<ll(ll,ll)> upd = [&](ll j0, ll t) {
	for (ll j = j0; j < N; j++) {
	  if (C.at(i) + D.at(j) >= (t << k)) return j;
	}
	return N;
      };
      p = upd(p, 1);
      q = upd(q, 2);
      r = upd(r, 3);
      ll x = ((q - p) + (N - r)) % 2;
      ans = ans ^ (x << k);
    }
    DLOG("ans = %lld", ans);
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 6572
const input = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\n/);
for (let i=0; i<input.length; i++) {
    if (input[i] === '-') {break;}
    let time = Number(input[i+1]);
    let shaffle = [];
    let word = input[i].split('')
    for (let j=0; j<time; j++) {
    let num = Number(input[i+2+j]);
    let array = word.splice(num);
    word = array.concat(word);
     }
     i = i + time +1;
     console.log(word.join(''));
}


Measured memory_bytes: 16092
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << endl;}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
template<typename T>
T ncr(T left, T right) {
	right = min(left - right, right);
	T ans = 1;
	for (T i = 1; i <= right; i++) {
		ans = ans * (left - right + i) / i;
	}
	return ans;
}

const lli MOD = 1000000007;
const lli LIMIT = 10000000000000000 * 5;
const int tenfive = 100000;

int main() {
	int N;
	cin >> N;
	string s;
	cin >> s;
	int b = 0, r = 0;
	for (int i = 0; i < N; i++) {
		if (s[i] == 'R') {
			r++;
		}
		else {
			b++;
		}
	}
	cout << (r > b ? "Yes" : "No") << endl;
	return 0;
}


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

int main() {
  int N, K, R, S, P;
  string s;
  cin >> N >> K >> R >> S >> P >> s;
  
  int point = 0;
  for (int i = 0; i < K; i++) {
    string ss;
    int seq = 1;
    for (int j = 0; j*K+i < N; j++) {
      ss += s[j*K+i];
      if (j>0) {
        if (ss[j-1] == ss[j]) seq += 1;
        else {
          if (ss[j-1] == 'r') point += (seq+1)/2*P;
          if (ss[j-1] == 's') point += (seq+1)/2*R;
          if (ss[j-1] == 'p') point += (seq+1)/2*S;
          seq=1;
        }
      }
    }
    int n = ss.size();
    if (ss[n-1] == 'r') point += (seq+1)/2*P;
    if (ss[n-1] == 's') point += (seq+1)/2*R;
    if (ss[n-1] == 'p') point += (seq+1)/2*S;
  }
  cout << point << endl;
}

Measured memory_bytes: 640
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; rd(n);
  auto a=new int[](n);
  foreach(i; 0..n) rd(a[i]);

  auto dp=new int[](n);
  dp[0]=1;
  bool up=true;
  foreach(i; 1..n){
    if(up){
      if(a[i-1]<a[i]) dp[i]=dp[i-1]+1;
      else if(a[i-1]==a[i]) dp[i]=dp[i-1];
      else dp[i]=2, up=false;
    }else{
      if(a[i-1]>a[i]) dp[i]=dp[i-1]+1;
      else if(a[i-1]==a[i]) dp[i]=dp[i-1];
      else dp[i]=2, up=true;
    }
  }

  writeln(reduce!(max)(dp));

}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 3932
N,M,X,Y = map(int,input().split())
x = max(list(map(int,input().split())))
y = min(list(map(int,input().split())))
ans = 'War'
for Z in range(X+1,Y+1):
    if x < Z <= y:
        ans = 'No War'
        break
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define nl printf("\n")
#define YES printf("YES\n")
#define Yes printf("Yes\n")
#define yes printf("yes\n")
#define NO printf("NO\n")
#define No printf("No\n")
#define no printf("no\n")
using namespace std;
int main(){
    string a,b;
    cin>>a;
    cin>>b;
    int al=a.length();
    int bl=b.length();
    int dp[al+1][bl+1];
    for(int i=0;i<=al;i++) dp[i][0]=0;
    for(int i=0;i<=bl;i++) dp[0][i]=0;

    for(int i=1;i<=al;i++){
        for(int j=1;j<=bl;j++){
            if(a[i-1]==b[j-1]) dp[i][j]=dp[i-1][j-1]+1;
            else dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
        }
    }
    string s;
    int i=al;
    int j=bl;
    while(i>0&&j>0){
        if(dp[i][j]==dp[i-1][j]) i--;
        else if(dp[i][j]==dp[i][j-1]) j--;
        else if(dp[i][j]==dp[i-1][j-1]){
            i--; j--;
        }
        else{
            s.pb(a[i-1]);
            i--; j--;
        }
    }
    reverse(s.begin(),s.end());
    cout<<s;
    nl;
}


Measured memory_bytes: 38640
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin >> s;

  if(s[0]==s[1] && s[2]==s[3] && s[1]!=s[2]) cout<<"Yes"<<endl;
  else if(s[0]==s[2] && s[1]==s[3] && s[1]!=s[2])cout<<"Yes"<<endl;
  else if(s[0]==s[3] && s[1]==s[2] && s[0]!=s[1])cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <set>
#include <unordered_set>
#include <vector>
#include<valarray>
#include<map>
#include <bits/stdc++.h>
#include <utility>
#include<bits/stdc++.h>
using namespace std;

int main()
{
long long n;
cin>>n;
long long a[n];
long long counter=0;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
    if(a[i]%2!=0&&i%2!=0)
    {
        counter ++;
    }

}


cout<<counter;
    return 0;
}

Measured memory_bytes: 3548
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

int main(){
    int N;
    cin >> N;
    if(N%10 == 3){
        cout << "bon" << endl;
    }else if(N%10 == 0 || N%10 == 1 || N%10 == 6 || N%10 == 8){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }
    return 0;
}


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

using namespace std;

int main() {
  int n, t, a, x;
  cin >> n;
  cin >> t >> a;
  int res = 0;
  int cc = 100000000;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    int deg = (t * 1000 - x * 6) - a * 1000;
    if (deg < 0) deg = -deg;
    if (deg < cc) cc = deg, res = i;
  }
  cout << res << endl;
  return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int a = 1;
		for (int i = 0; i < n; i++) {
			if (a*2 <= a+k) {
				a = a*2;
			} else {
				a = a+k;
			}
		}
		System.out.println(a);
	}
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
template <class T>void UNIQUE(vector<T> &x){
	sort(all(x));
	x.erase(unique(all(x)), x.end());
}

// }}} End Header
int main() {
	string s;
	cin >> s;
	vector<int> a(4);
	rep(i,4) a[i] = s[i]-'0';

	for(int bit = 0; bit<(1<<3); bit++){
		string t = to_string(a[0]);
		int sum = a[0];
		for(int i = 0; i<3; i++){
			if(bit&(1<<i)){
				sum+=a[i+1];
				t+="+";
				t+=to_string(a[i+1]);
			}else{
				sum-=a[i+1];
				t+="-";
				t+=to_string(a[i+1]);
			}
		}

		if(sum == 7){
			t+="=7";
			cout << t << endl;
			return 0;
		}
	}


	return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
using namespace std;
int main() {

	int N, A, B;
	cin >> N >> A >> B;
	
	if (A == N || B == N)cout << min(A, B) << " " << min(A, B) << endl;
	else if (A == 0 || B == 0) cout << 0 << " " << 0 << endl;
	else if (N >= A + B)cout << min(A, B) << " " << 0 << endl;
	else cout << min(A, B) << " " << abs(N - A - B) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mo=1000000007;
int n,m,S[3][3],P[100005];
struct O{
	int A[3][3];
	void operator*=(O b){
		for (int i=0;i<3;++i)
		for (int j=0;j<3;++j){
			S[i][j]=0;
			for (int k=0;k<3;++k)
			(S[i][j]+=1ll*A[i][k]*b.A[k][j]%mo)%=mo;
		}
		for (int i=0;i<3;++i)
		for (int j=0;j<3;++j)
			A[i][j]=S[i][j];
	}
}E,D;
struct H{
	int A[3];
}W;
H operator*(H a,O b){
	H c;
	for (int i=0;i<3;++i){
		c.A[i]=0;
		for (int j=0;j<3;++j)
		(c.A[i]+=1ll*a.A[j]*b.A[j][i]%mo)%=mo;
	}
	return c;
}
O qiu(int x){
	O A=E,B;
	for (int i=0;i<3;++i)
	for (int j=0;j<3;++j)
		B.A[i][j]=i==j;
	for (;x;x>>=1,A*=A)
	if (x&1) B*=A;
	return B;
}
int main(){
	E.A[0][0]=2; E.A[0][1]=1; E.A[0][2]=1;
	E.A[1][0]=2; E.A[1][1]=1; E.A[1][2]=2;
	E.A[2][0]=1; E.A[2][1]=0; E.A[2][2]=1;
	D.A[0][0]=1; D.A[0][1]=0; D.A[0][2]=0;
	D.A[1][0]=2; D.A[1][1]=1; D.A[1][2]=2;
	D.A[2][0]=1; D.A[2][1]=0; D.A[2][2]=1;
	for (int i=0;i<3;++i) W.A[i]=1;
	scanf("%d%d",&m,&n);
	for (int i=1;i<=n;++i) scanf("%d",&P[i]);
	for (int i=1;i<=n;++i){
		if (P[i]-P[i-1]>1) W=W*qiu(P[i]-P[i-1]-1);
		W=W*D;
	}
	if (m-P[n]>1) W=W*qiu(m-P[n]-1);
	printf("%d\n",W.A[0]);
	return 0;
}


Measured memory_bytes: 640
N, Q = map(int, input().split())
S= input()

#S[i]までの"AC"の数を計算して、countリストに保存するための処理
count=[]
ans=0
for i in range (N):
  if i!=0 and S[i-1]=="A" and S[i]=="C":
    ans+=1
    count.append(ans)
  else:
    count.append(ans)
#print(count)

#countリストから答えを呼び出すための処理
for _ in range(Q):
  l, r=map(int, input().split())
  print(count[r-1]-count[l-1])

"""
最初思ついた処理（TLEになった）
for _ in range(Q):
  l, r= map(int, input().split())
  SP= S[l-1:r]
  print(SP.count("AC"))
"""

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


int main(){
    int p;
    cin >> p;
    vector<int> a(p);
    for (int i = 0; i < p; i++) cin >> a[i];
    vector<int> comb(p, 0);
    comb[0] = 1;
    for (int i = 1; i < p; i++) {
        comb[i] = 1;
        for (int j = i-1; j >= 1; j--) {
            comb[j] = (comb[j]+comb[j-1])%p;
        }
        comb[0] = 1;
    }
    
    vector<int> ans(p, 0);
    for (int i = 0; i < p; i++) {
        if (a[i] == 0) continue;
        ans[0] += 1;
        int d = 1;
        for (int j = p-1; j >= 0; j--) {
            ans[j] = (ans[j]-d*comb[j])%p;
            d = d*(-i)%p;
        }
    }
    for (int i = 0; i < p; i++) {
        cout << (ans[i]%p+p)%p;
        if (i < p-1) cout << ' ';
        else cout << endl;
    }
    return 0;
}

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

#define MOD 1000000007
#define int long long

int n;
int a[100010];
set<int> st;

int bit[100010];

int sum(int i){
	int s = 0;
	i++;
	while(i > 0){
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(int i, int x){
	i++;
	while(i <= n){
		bit[i] += x;
		i += i & -i;
	}
}

int kai[100010];

int solve(int i){
	if(i == n-1) return 0;
	add(a[i], 1);
	int ans = kai[n-i-1] * (a[i] - sum(a[i]-1));
	ans = (ans + solve(i+1)) % MOD;
	return ans;
}


signed main(){

	kai[0] = 1;
	for(int i = 1;i <= 100000;i++) kai[i] = (kai[i-1] * i) % MOD;
	kai[0] = 1;

	while(cin >> n,n != 0){
		for(int i = 0;i < n;i++){
			a[i] = i;
			bit[i] = 0;
		}

		int r; cin >> r;
		for(int i = 0;i < r;i++){
			int s, t; cin >> s >> t;
			s--; t--;
			swap(a[s], a[t]);
		}
		cout << solve(0) << endl;
	}
	return 0;
}


Measured memory_bytes: 7004
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
using namespace std;
typedef long long LL;
const int f[]={0,1,2,4,7,12,20,29,38,52,73};
int n,now;LL mx,w[11][11];bool vis[11];
void dfs(int k1,LL k2,int k3){
	if(k1>now){
		if(k2>mx)mx=k2;
		return;
	}
	rep(i,1,n)if(!vis[i]&&w[k1][i]){
		vis[i]=1;
		dfs(k1+1,k2+w[k3][i],i);
		vis[i]=0;
	}
}
int main(){
	scanf("%d",&n);
	rep(i,1,n){
		rep(j,1,i-1)w[i][j]=w[j][i]=1LL*f[j]*(mx+1);
		now=i;
		rep(j,1,i)dfs(j,0,0);
	}
	rep(i,1,n){rep(j,1,n)printf("%lld ",w[i][j]),assert(w[i][j]<=1e12);puts("");}
	return 0;
}

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

int main(){
    map <string, int> mp;
    int n; cin >> n;
    for(int i=0; i<n; ++i){
        string tmp; cin >> tmp;
        if(mp.count(tmp) == 0) mp[tmp] = 1; 
        else ++mp[tmp];
    }
    cin >> n;
    for(int i=0; i<n; ++i){
        string tmp; cin >> tmp;
        if(mp.count(tmp) == 0) mp[tmp] = -1; 
        else --mp[tmp];
    }
    int max = 0;
    for(auto x : mp){
        if(max < x.second)max = x.second;
    }
    cout << max << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <chrono>
#include <complex>
#include <cstdint>
#include <cstring>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <ostream>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = int64_t;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll n;
        in >> n;
        ll lo, hi;
        ll i = 1, sum = 1;
        while (i * (i + 1) < 2 * n) {
            i++;
            sum += i;
        }
        for (int j = 1; j <= i; j++) {
            if (sum - j != n) {
                out << j << '\n';
            }
        }
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


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


signed main(){
    ll a,b,c;
    cin>>a>>b>>c;
    ll m=max({a,b,c});
    if(a==m)cout<<"A\n";
    if(b==m)cout<<"B\n";
    if(c==m)cout<<"C\n";
}






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

int main(){
    long long int a, b, c;
    cin >> a >> b >>c;
    long double ansA,ansB;
    ansA = sqrtl((long double)a);
    ansB = sqrtl((long double)b);

    if (a + b + 2*(ansA*ansB) < c) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
def insertionSort(A, N):
    for i in range(N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print(" ".join(map(str, A)))
N = int(input())
A = list(map(int, input().split(' ')))
insertionSort(A, N)


Measured memory_bytes: 5604
n=int(input())
abc='abcdefghijklmnopqrstuvwxyz'
s=[]
t=[51]*len(abc)
#print(t)
for i in range(n):
    u=input()
    for j in range(len(abc)):
        v=u.count(abc[j])
        t[j]=min(t[j],v)
ans=''
for j in range(len(abc)):
    ans+=t[j]*abc[j]
print(ans)

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<char> pic(H*W);

  for (int i = 0; i < W+2; i++) {
    cout << '#';
  }
  cout << endl;

  for (int i = 0; i < H; i++) {
    cout << '#';
    for (int j = 0; j < W; j++){
      cin >> pic.at(W*i+j);
      cout << pic.at(W*i+j);
    }
    cout << '#' << endl;
  }
  for (int i = 0; i < W+2; i++) {
    cout << '#';
  }
  cout << endl;  
}


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

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

    string s;
    cin >> s;
    int n = s.size();
    vector<int> rl;
    for (int i = 1; i < n; i++) {
        if (s[i - 1] == 'R' && s[i] == 'L') {
            rl.push_back(i - 1);
        }
    }
    vector<int> ans(n);
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') {
            // i以上の最小
            auto it = lower_bound(rl.begin(), rl.end(), i);
            assert(it != rl.end());
            int dist = *it - i;
            if (dist & 1) {
                ans[*it + 1]++;
            } else {
                ans[*it]++;
            }
        } else {
            // i未満の最大
            auto it = lower_bound(rl.begin(), rl.end(), i);
            assert(it != rl.begin());
            it--;
            int dist = i - *it;
            if (dist & 1) {
                ans[*it + 1]++;
            } else {
                ans[*it]++;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        cout << ans[i] << ' ';
    }
}


Measured memory_bytes: 1232
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
using namespace std;
using ll = long long int;

ll N, A[100010], X[100010];

const int SIZE = 1 << 17;
struct SegmentTree {
    int node[2*SIZE];
    SegmentTree() { fill(node, node + 2*SIZE, 0); }
    void reset()  { fill(node, node + 2*SIZE, 0); }
    void update(int x, int val) {
        x += SIZE - 1; node[x] += val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = node[2*x+1] + node[2*x+2];
        }
    }
    int query(int a, int b, int l=0, int r=SIZE, int k=0) {
        if(b <= l || r <= a) return 0;
        if(a <= l && r <= b) return node[k];
        int mid = (l + r) / 2;
        int vl = query(a, b, l, mid, 2*k+1);
        int vr = query(a, b, mid, r, 2*k+2);
        return vl + vr;
    }
};

SegmentTree seg;
bool solve(ll K) {
    seg.reset();
    vector< pair<int, int> > val_idx;
    for(int i=0; i<N; i++) {
        X[i] = (i == 0 ? 0 : X[i-1]) + (A[i] < K ? -1 : 1);
        val_idx.emplace_back(X[i], i);
    }
    val_idx.emplace_back(0, -1);
    sort(val_idx.begin(), val_idx.end());

    ll sum = 0;
    for(int i=N; i>=0; i--) {
        int val, idx; tie(val, idx) = val_idx[i];
        // fprintf(stderr, "K = %lld, val = %d, idx = %d\n", K, val, idx);
        sum += seg.query(idx, N);
        if(idx >= 0) seg.update(idx, 1);
    }
    // fprintf(stderr, "# K = %lld, sum = %lld\n", K, sum);
    return 2 * sum >= N * (N + 1) / 2;
}

int main() {
    cin >> N;
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }

    if(N == 1) {
        cout << A[0] << endl;
    }
    else {
        ll ub = 1e9 + 10, lb = -1;
        while(ub - lb > 1) {
            ll mid = (ub + lb) / 2;
            if(solve(mid)) {
                lb = mid;
            }
            else {
                ub = mid;
            }
        }
        cout << lb << endl;
        return 0;
    }
}


Measured memory_bytes: 4696
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
const ll MOD = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//

int main(){
    int a; cin>>a;
    string s; cin>>s;
    if(a>=3200){
        cout<<s<<endl;
    }else{
        cout<<"red"<<endl;
    }
}

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

using namespace std;

int a[40000], b[40000];

void solve(){
  int answer = 0;
  for(int i=0;i<9;i++){
    cout << i+1 << endl;
    string ans;
    cin >> ans;
    if(ans == "Yes"){
      return;
    }
    else if(ans == "Near"){
      answer |= 1<<i;
    }
  }
  string ans;
  //  cout << "answer" << endl;
  //  cout << bitset<9>(answer) << endl;
  cout << answer + 10 << endl;
  cin >> ans;
  return;
}

int main(){
  int N, K;    
  cin >> N >> K;
  if(N <= 10){
    cout << 0 << endl;
  }else{
      int M = 0;
      for(int j=9;j<N;j++){
	int n_idx = j-9;
	for(int k=0;k<9;k++){
	  //	  cout << bitset<9>(n_idx) << " AND " << bitset<9>(1<<k) << " = " << bitset<9>(n_idx & (1<<k)) << endl;
	  if(n_idx & (1<<k)){
	    a[M] = k;
	    b[M] = j;
	    M++;
	  }
	}
      }
      cout << M << endl;
      for(int i=0;i<M;i++){
	cout << a[i] + 1 << " " << b[i] + 1<< endl;
      }
  }    

  for(int i=0;i<K;i++){
    if(N <= 10){
      for(int j=0;j<N;j++){
	cout << j+1 << endl;
	string answer;
	cin >> answer;
	if(answer == "Yes"){
	  break;
	}
      }
    }else{
      solve();
    }
  }
  return 0;
}



Measured memory_bytes: 3340
hoge=list(input())
hoge_a=[]
hoge_b=[]
for i in range(len(hoge)):
  if(i%2==0):
    hoge_a.append(hoge[i])
  else:
    hoge_b.append(hoge[i])
    
ans=min(len(hoge_a)-hoge_a.count("0")+
        len(hoge_b)-hoge_b.count("1"),
        len(hoge_a)-hoge_a.count("1")+
        len(hoge_b)-hoge_b.count("0"))

print(ans)

Measured memory_bytes: 4744
#include<bits/stdc++.h>
using namespace std;
void pre(){}
void solve(){
    long long int x,y,a,b,c,d;cin>>x>>y>>a>>b>>c;
    priority_queue<long long int>pq;
    long long int arr[a+b+100000];
    for(long long int i=0;i<a;i++) cin>>arr[i];
    sort(arr,arr+a,greater<long long int>());
    for(long long int i=0;i<x;i++){
        pq.push(arr[i]);
    }
    a=b;
    for(long long int i=0;i<a;i++) cin>>arr[i];
    sort(arr,arr+a,greater<long long int>());
    for(long long int i=0;i<y;i++){
        pq.push(arr[i]);
    }
    for(long long int i=0;i<c;i++){
        cin>>d;
        pq.push(d);
    }
    long long int ans = 0;
    for(long long int i=0;i<x+y;i++){
        ans+=pq.top();
        pq.pop();
    }
    cout<<ans<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    //cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}


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

int main() {
  int h, n;
  cin >> h >> n;
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    sum += a;
  }
  cout << (sum >= h ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256