akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define REV(i,a,n) for(int i=a;i>=n;i--)
#define all(a) a.begin(),a.end()
const int NUM = 2e5 + 5;
int weight[105],val[105];
int dp[1000005];
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int num_tests=1; 
    //cin >> num_tests;
    while(num_tests-->0){
        int n,w; cin >> n >> w;
        FOR(i,0,n){
            cin >> weight[i] >> val[i];
        }
        memset(dp,-1e18,sizeof(dp));
        dp[0] = 0;
        FOR(i,0,n){
            REV(j,1e5,0)
            {   
                if(dp[j] != -1e18)
                    dp[j+weight[i]] = max(dp[j+weight[i]],dp[j]+val[i]);
            }
        }
        cout << dp[w];
    }   
}

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

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

  if (N < 10)
  {
    cout << N << endl;
  }
  else if (N >= 10 && 100 > N)
  {
    cout << 9 << endl;
  }
  else if (N >= 100 && 1000 > N)
  {
    cout << (N - 100 + 10) << endl;
  }
  else if (N >= 1000 && 10000 > N)
  {
    cout << 909 << endl;
  }
  else if (N >= 10000 && 100000 > N)
  {
    cout << N - 10000 + 910 << endl;
  }
  else
  {
    cout << 90909 << endl;
  }

  return 0;
}

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

using namespace std;

int main()
{
  string s, t;
  cin >> s >> t;

  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());

  for(int i = 0;
      i < min(s.length(), t.length());
      ++i)
    {
      if(s[i] < t[i])
        {
          cout << "Yes" << endl;
          return 0;
        }
      else if (s[i] > t[i])
        {
          cout << "No" << endl;
          return 0;
        }
    }

  if(s.length() < t.length())
    {
      cout << "Yes" << endl;
    }
  else
    {
      cout << "No" << endl;
    }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdtr1c++.h>
#define pb push_back
#define fi first
#define sc second
#define inf	1000000000LL
#define MP make_pair
#define N 300005
#define MOD 1000000007 
#define orta ((a+b)/2)
using namespace std;
typedef long long int lint;
typedef pair<int,int> ii;

ii d[N];
int main()
{
	int n;
	cin >> n;

	for (int i = 0; i < n; ++i)
	{
		cin >> d[i].sc >> d[i].fi;
	}
	sort(d,d+n);
	int t=0;
	for (int i = 0; i < n; ++i)
	{
		t+=d[i].sc;
		if(t>d[i].fi)
		{
			cout << "No";
			return 0;
		}
	}
			cout << "Yes";
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
int main() {
  char s[200], p[200];
  int i, k, cnt = 0, j = 0;
  scanf("%s %s", s, p);
  for(i = 0; i < strlen(s); i++) {
    k = i;
      while(cnt != strlen(p)) {
        k = k % strlen(s);
        if(s[k] == p[j]) {
          cnt++;
          k++;
          j++;
        }else {
          j = 0;
          cnt = 0;
          break;
        }
      }
  }
    if(cnt == strlen(p)) {
    printf("Yes\n");
  }else {
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 524
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	ans := "Yes"
	for i := 0; i < len(s); {
		if i+1 < len(s) {
			if s[i:i+2] != "hi" {
				ans = "No"
				break
			} else {
				i += 2
			}
		} else {
			ans = "No"
			break
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
#include <chrono>
#include <random>
#include <ctime>
#include <complex>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = acosl(-1.0);
const ll MOD = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	srand(time(0));
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll x, d, s;
	cin >> x >> s >> d;
	x = abs(x);
	ll can = min(s, x / d);
	x -= can * d;
	s -= can;
	if (s % 2 == 0) {
		cout << abs(x) << "\n";
	}
	else {
		cout << abs(x - d) << "\n";
	}
}

Measured memory_bytes: 3624
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n, x = LI()
    a = LI()
    a.sort()
    ans = 0
    for ai in a:
        x -= ai
        if x < 0:
            print(ans)
            return
        ans += 1
    print(ans - (x != 0))
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define REP(i, n) for (LL i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (LL i = m; i n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define int long long
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main()
{
    int m,n,x,ans=100000000;
    cin >> n >> m >> x;
    vector<vector<int>> a(n, vector<int>(m));
   vector<int>c(n);  
  REP(i,n){
      cin>>c[i];
    REP(j,m)cin >>a[i][j];
    }
      int all = 1<<n;
 REP(mask,all){
       vector<int> level(m);
        int cost = 0;
     REP(i,n){
         if(mask>>i&1){
           cost += c[i];
            for(int j = 0; j < m; j++){
                    level[j] += a[i][j];
                }
         }
     }
 bool ok = true;
        for(int j = 0; j < m; j++){
            if(level[j] < x) ok = false;
        }
        if(ok) ans = min(ans,cost);
    }
    if(ans == 100000000) cout << -1 << endl;
    else cout << ans << endl;

}

Measured memory_bytes: 3640
import java.util.Scanner;

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

		int n = sc.nextInt();
		int t = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}

		long[][] dp1 = new long[n + 1][t + 1];
		long[][] dp2 = new long[n + 1][t + 1];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= t; j++) {
				dp1[i + 1][j] = Math.max(dp1[i][j], j - a[i] >= 0 ? dp1[i][j - a[i]] + b[i] : 0);
			}
		}

		for (int i = n; i > 0; i--) {
			for (int j = 0; j <= t; j++) {
				dp2[i - 1][j] = Math.max(dp2[i][j],
						j - a[i - 1] >= 0 ? dp2[i][j - a[i - 1]] + b[i - 1] : 0);
			}
		}

		long answer = 0;
		for (int i = 1; i <= n - 1; i++) {
			for (int j = 0; j < t; j++) {
				answer = Math.max(answer, dp1[i][j] + dp2[i + 1][t - 1 - j] + b[i]);
			}
		}

		System.out.println(answer);
	}
}


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

int main() {
    int N;
    cin >> N;
    int max=0;
    int max_i=1;

    for(int i=1; i<=N; ++i){
        int cnt=0;
        int num = i;
        while(true){
            bool flag = false;
            if(num%2==0){
                num = num/2;
                ++cnt;
            }
            else {flag = true;}
            if (flag) break;
        }
        if (cnt > max) {
            max = cnt;
            max_i = i;
        }
    }
    cout << max_i << endl;
}

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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef string S;
typedef queue<int> qi;

int main(){
    S n;
    cin >> n;
    bool ans=false;
    ll cnt=0;
    if(n.size()==1){
        cout << n << endl;
        return 0;
    }
    rep(i,1,n.size()-1){
        if(n.at(i)=='9'){
            cnt++;
        }
    }
    if(cnt==n.size()-1){
        ans=true;
    }
    if(ans){
        cout << n.at(0)-'0'+9*(n.size()-1) << endl;
    }else{
        cout << n.at(0)-1-'0'+9*(n.size()-1) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import heapq

n, m = map(int, input().split()) 
al = list(map(int, input().split())) 

al = [v*(-1) for v in al]
heapq.heapify(al)

for _ in range(m):
    p = heapq.heappop(al)
    heapq.heappush(al, ((-1)*p//2)*(-1) )

print(sum(al)*(-1))

Measured memory_bytes: 14180
#include<bits/stdc++.h>
#define PI acos(-1)
using namespace std;
int main()
{
    int a,b,h,m;
    cin>>a>>b>>h>>m;
    double x,y,z,v;
    x=0.5*((60*h)+m);
    y=6*m;
    z=abs(x-y);
    v = z * PI / 180.0;
    double ans = a * a + b * b - 2 * a * b * cosl(v);
    cout << setprecision(14)<<sqrt(ans)<<endl;
}

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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;
        private static Dictionary<string,int> dic = new Dictionary<string, int>();

        static void Solve()
        {
            var o = ReadAndParseIntArr();
            int n = o[0];
            int k = o[1];
            int ans = 0;
            if (n % k == 0)
            {
                ans = 0;
            }
            else
            {
                ans = 1;
            }
            Console.WriteLine(ans);
        }
#region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
#endregion
    }
}

Measured memory_bytes: 13152
# 最大公約数
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


n = int(input())
A = list(map(int, input().split()))

L = [0 for _ in range(n)]
R = [0 for _ in range(n)]
L[0] = A[0]
R[-1] = A[-1]

for i in range(1, n):
    L[i] = gcd(L[i-1], A[i])
    R[n - i - 1] = gcd(R[n - i], A[n - i - 1])
ans = 1
for i in range(n):
    if i == 0:
        ans = R[i + 1]
    elif i == n-1:
        ans = max(ans, L[i-1])
    else:
        ans = max(ans, gcd(L[i - 1], R[i+1]))

print(ans)



Measured memory_bytes: 14436
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vi vector<int>
using namespace std;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;

bool prime(int n){
    for(int i = 2 ; i <= sqrt(n) ; ++i){
        if(n % i == 0) {
            return 0 ; 
        }
    }

    return 1 ; 
}

int main() {
    int  n , k ; 
    cin >> n >> k ; 
    int p[n] ; 
    for(int i = 0;  i < n ; ++i)
        cin >> p[i] ; 
    sort(p, p + n) ; 
    ll ans = 0 ;
    for(int i = 0 ;i  <k ; ++i)
        ans += p[i] ; 
    cout << ans ; 
    

    return 0 ; 
}

Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main(void) {
    long long a,b,c,d = 0;
    
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;

    if( b > 0 && d > 0 ) {
        long long tmp1 = b * d;
        long long tmp2 = a * c;
        if( tmp1 >= tmp2 ) {
            cout << tmp1;
        }
        else {
            cout << tmp2;
        }
    }
    else if( b > 0 && d < 0 ) {
        if( a >= 0 ) {
            cout << a * d;
        }
        else {
            cout << a * c;
        }
    }
    else if( b < 0 && d >= 0 ) {
        if( c >= 0 ) {
            cout << b * c;
        }
        else {
            cout << a * c;
        }
    }
    else if( b < 0 && d < 0 ) {
        cout << a * c;
    }
    //b or d = 0
    else if( b == 0 && d > 0 ) {
        if( c >= 0 ) {
            cout << b * c;
        }else {
            cout << a * c;
        }
    }
    else if( b == 0 && d < 0 ) {
        cout << a * c;
    }
    else if( b > 0 && d == 0 ) {
        if( a >= 0 ) {
            cout << d * a;
        }else {
            cout << c * a;
        }
    }
    else if( b < 0 && d == 0 ) {
        cout << a * c;
    }
    else if( b == 0 && d == 0 ) {
        cout << a * c;
    }


    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
using namespace std;
class Dice{
public:
    int f[6];
    void roll(string s){
        for(int i = 0; i < s.size(); i++){
            if(s[i] == 'E'){
                int tmp = f[0];
                f[0] = f[3];
                f[3] = f[5];
                f[5] = f[2];
                f[2] = tmp;
            }
            else if(s[i] == 'N'){
                int tmp = f[0];
                f[0] = f[1];
                f[1] = f[5];
                f[5] = f[4];
                f[4] = tmp;
            }
            else if(s[i] == 'S'){
                int tmp = f[0];
                f[0] = f[4];
                f[4] = f[5];
                f[5] = f[1];
                f[1] = tmp;
            }
            else if(s[i] == 'W'){
                int tmp = f[0];
                f[0] = f[2];
                f[2] = f[5];
                f[5] = f[3];
                f[3] = tmp;
            }
        }
    }
};
int main(){
    Dice d;
    for(int i = 0; i < 6; i++){
        cin >> d.f[i];
    }
    string cmd;
    cin >> cmd;
    d.roll(cmd);
    cout << d.f[0] << endl;
}



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

int main() {
    int n; cin >> n;
    vector<int> a(n+1);
    rep(i, n+1) cin >> a[i];
    long long ans = 0;
    rep(i, n) {
        int b; cin >> b;
        int n1 = min(b, a[i]);
        b -= n1;
        a[i] -= n1;
        ans += n1;
        int n2 = min(b, a[i+1]);
        a[i+1] -= n2;
        ans += n2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
n, k, s = map(int, input().split())
F = 1000000000
A = []
if s == F:
    for i in range(k):
        A.append(s)
    for i in range(n-k):
        A.append(1)
else:
    for i in range(k):
        A.append(s)
    for i in range(n-k):
        A.append(s+1)

print(*A)

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

char ah(char x ,int n){
  char ss;
  if(x =='r')ss ='p';
  if(x =='s')ss ='r';
  if(x =='p')ss ='s';
  return ss;
}

ll gp(char x ,int anspoint,int r,int s,int p){
  if(x =='r')anspoint += r;
  if(x =='s')anspoint += s;
  if(x =='p')anspoint += p;
  return anspoint;
}

int main(){
  int n ,k;
  cin >>n>>k;
  int r,s,p;
  cin >>r>>s>>p;
  string tt ;
  cin >>tt;
  vector <char> t(n);
  vector <string> u(n);
  vector <char> ans(n);
  rep(i,n)t.at(i) = tt[i];
  ll sumpoint = 0;


  //k回までは勝つ手を出していく
  for(int i = 0;i<k;++i){
    ans.at(i)=ah(t.at(i),i);
    sumpoint = gp(ans.at(i),sumpoint,r,s,p);

  }
//k回目以降
  for (int i = k;i<n;i++){
    //k回前の手が出したい手と違うときは出したい手を出す
    if(ans.at(i-k)!=ah(t.at(i),i) ||ans.at(i-k)=='n'){
      ans.at(i)=ah(t.at(i),i);
      sumpoint =gp(ans.at(i),sumpoint,r,s,p);
      continue;
    }
    //ここからはk回前と手がかぶってしまったとき
    ans.at(i) ='n';
  }
  cout <<sumpoint<<endl;

}

Measured memory_bytes: 1408
using System;
using System.Linq;
namespace AtCoder_Begginer_Contest1
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());
            int ans = 0;
            if (num == 2) ans = 2;
            else if (num % 2 == 0) num++;
            while (ans == 0)
            {
                double sqrtNum = Math.Sqrt(num);
                for (int i = 3; i <= sqrtNum; i += 2)
                {
                    if (num % i == 0)
                    {
                        // 素数ではない
                        break;
                    }
                    if (i >= sqrtNum-2) ans = num;
                }
                num+=2;
            }
            // 素数である
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
def c_AtCoDeer_and_ElectionReport(N, R):
    from math import ceil
    from decimal import Decimal
    t = 1  # 高橋の票数
    a = 1  # 青木の票数
    for x, y in R:
        n = Decimal(max(ceil(t / x), ceil(a / y)))
        t = n * x
        a = n * y
    return t + a

N = int(input())
R = [[int(i) for i in input().split()] for j in range(N)]
print(c_AtCoDeer_and_ElectionReport(N, R))

Measured memory_bytes: 5588
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<unsigned long long> vull;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define ULLINF 1e19
vint y;
vull sum;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,x;
    cin >> n >> x;
    vint y(n,0);
    vull sum(n+1,0);
    REP(i,n) {
        cin >> y[i];
        sum[i+1] = sum[i]+(ull)y[i];
    }
    ull ans = (ull)n*(ull)x;
    ull cost = ULLINF-1;
    for(int k=1;k<=n;k++){
        ull tmp = (ull)k*(ull)x;
        tmp+=5*(sum[n]-sum[n-k]);
        int f = n-k;
        ull c = 5;
        while(f>=0){
            if(f-k<0){
                tmp+=(sum[f]-sum[0])*c;
            }else{
                tmp+=(sum[f]-sum[f-k])*c;
            }
            c+=2;
            f-=k;
        }
        cost = min(cost,tmp);
    }
    ans+=cost;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

ll roc=0;
string s;

char letter();
string str();
string cipher();

char letter() {
	int ofs=0;
	while(!((s[roc]>='A'&&s[roc]<='Z')||s[roc]=='?')) {
		if(s[roc]=='+') ofs++;
		else ofs--;
		roc++;
	}
	if(s[roc]=='?') return '?';
	return 'A'+(((int)(s[roc]-'A')+ofs)%26+26)%26;
}

string str() {
	if(s[roc]=='[') {
		roc++;
		string ret=cipher();
		roc++;
		reverse(ALL(ret));
		return ret;
	} else {
		string ret="";
		ret+=letter();
		roc++;
		return ret;
	}
}

string cipher() {
	string ret="";
	while(roc<(ll)s.size()&&s[roc]!=']') {
		ret+=str();
	}
	return ret;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(1) {
		roc=0;
		cin>>s;
		if(s==".") break;
		string ret=cipher();
		REP(i,(ll)ret.size()) {
			if(ret[i]=='?') ret[i]='A';
		}
		cout<<ret<<endl;
	}
}

Measured memory_bytes: 3228
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
#define N 200002
const int p=1e9+7;
struct node
{
    int s[2][2];
    friend node operator*(node a,node b)
    {
        node ret;memset(ret.s,0,sizeof(ret.s));
        for(int i=0;i<2;i++)for(int j=0;j<2;j++)for(int k=0;k<2;k++)
        ret.s[i][j]=(ret.s[i][j]+1ll*a.s[i][k]*b.s[k][j]%p)%p;return ret;
    }
}dw,md,st;
int n,m;
ll k;
char ch[1002][1002],s[1002][1002];
inline int ksm(int d,ll tk){int ret=1;while(tk){if(tk&1)ret=1ll*ret*d%p;d=1ll*d*d%p;tk>>=1;}return ret;}
inline node ksmm(node d,ll tk){node ret=dw;while(tk){if(tk&1)ret=ret*d;d=d*d;tk>>=1;}return ret;}
int main()
{
    scanf("%d%d%lld",&n,&m,&k);
    for(int i=1;i<=n;i++)scanf("%s",ch[i]+1);
    bool ud=false,lr=false;
    for(int i=1;i<=m;i++)if(ch[1][i]=='#'&&ch[n][i]=='#')ud=true;
    for(int i=1;i<=n;i++)if(ch[i][1]=='#'&&ch[i][m]=='#')lr=true;
    int ct=0,s1=0,s2=0;
    for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)if(ch[i][j]=='#')ct++;
    if((!ud)&&(!lr)){printf("%d\n",ksm(ct,k-1));return 0;}
    if(ud&&lr){puts("1");return 0;}
    if(ud)
    {
        for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)s[j][i]=ch[i][j];
        swap(n,m);
        for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)ch[i][j]=s[i][j];
    }dw.s[0][0]=dw.s[1][1]=1;
    for(int i=1;i<=n;i++)for(int j=1;j<m;j++)if(ch[i][j]=='#'&&ch[i][j+1]=='#')s1++;
    for(int i=1;i<=n;i++)if(ch[i][1]=='#'&&ch[i][m]=='#')s2++;
    md.s[0][0]=ct,md.s[0][1]=s1,md.s[1][1]=s2;st.s[0][0]=ct,st.s[0][1]=s1;
    if(k==1){puts("1");return 0;}
    md=ksmm(md,k-2);st=st*md;
    printf("%d\n",(st.s[0][0]-st.s[0][1]+p)%p);
}


Measured memory_bytes: 5716
/*************************************
 * problem:      id_name.
 * user ID:      63720.
 * user name:    Jomoo.
 * time:         2019-mm-dd.
 * language:     C++.
 * upload place: Luogu.
*************************************/ 

#include <bits/stdc++.h>
using namespace std;
#define puts_return(x) { puts(x); return 0; }
#define write_return(x) { write(x); return 0; }

typedef signed char          int8;
typedef unsigned char       uint8;
typedef short                int16;
typedef unsigned short      uint16;
typedef int                  int32;
typedef unsigned            uint32;
typedef long long            int64;
typedef unsigned long long  uint64;

template <typename Int>
inline Int read()       
{
    Int flag = 1;
    char c = getchar();
    while ((!isdigit(c)) && c != '-') c = getchar();
    if (c == '-') flag = -1, c = getchar();
    Int init = c & 15;
    while (isdigit(c = getchar())) init = (init << 3) + (init << 1) + (c & 15);
	return init * flag;
}

template <typename Int>
inline void write(Int x)
{
    if (x < 0) putchar('-'), x = ~x + 1;
    if (x > 9) write(x / 10);
    putchar((x % 10) | 48);
}  

template <typename Int>
inline void write(Int x, char nextch)
{
    write(x);
    putchar(nextch);
}

int n;
int a[4][100003];
int id[100003], cnt[2];

#define FOR_IN_ROW(i) for (int i = 1; i <= 3; i++)
#define FOR_IN_COL(j) for (int j = 1; j <= n; j++)
#define FOR_IN_GRID(i, j) FOR_IN_ROW(i) FOR_IN_COL(j)
#define ReNo() puts_return("No");
#define ReYes() puts_return("Yes");
#define ifReNo(x) { if (x) ReNo(); }

int main()
{
    n = read<int>();
    FOR_IN_GRID(i, j) {
        a[i][j] = read<int>();
    }
    FOR_IN_COL(i) {
        ifReNo(a[2][i] % 3 != 2); 
        ifReNo(abs(a[1][i] - a[2][i]) != 1 || abs(a[1][i] - a[2][i]) != 1); 
        ifReNo(((a[2][i] % 6 / 3) & (i & 1)));
        id[i] = (a[2][i] + 1) / 3;
        cnt[i & 1] ^= a[1][i] > a[3][i];
    }
    FOR_IN_COL(i) {
        while (id[i] != i) {
            cnt[(i & 1) ^ 1] ^= 1;
            swap(id[i], id[id[i]]);
        }
    }
    ifReNo(cnt[0] || cnt[1]);
    ReYes();
    return 0;
}

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

int main() {

    int n;

    cin >> n;

    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);

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

    for ( int i = 0; i < n; i++ ) {
        cin >> b[i];
    }

    for ( int i = 0; i < n; i++ ) {
        cin >> c[i];
    }

    int manzoku = 0;
    for ( int i = 0; i < n; i++ ){
//        cout << b[a[i] - 1] << endl;
        if ( i == 0 ) {
            manzoku = b[a[i]-1];
        }
        else if ( a[i] == a[i-1] + 1 ) {
            manzoku += b[a[i]-1] + c[a[i]-2];
        }
        else {
            manzoku += b[a[i]-1]; 
        }
//        cout << manzoku << endl;
    }

    cout << manzoku << endl;

    return 0;
}

Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
#include <climits>  // A/Bを計算するときA==LLONG_MIN && B==-1のみ(1ull<<63)で代用
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;				// VVL v(100,VL(100,0));
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<LL, pair<P, P> > PP;

#define INF 999999999999999997		// 少し加算したらオーバーフローする
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) if(dbgF){FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定
string Replace(string S, string from, string to) { auto p = S.find(from); while (p != string::npos) { S.replace(p, from.size(), to); p = S.find(from, p + to.size()); }return S; }

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

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

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL N;
	cin >> N;
	VL A;
	LL sum = 0;
	A.push_back(0);
	FOR(i, 0, N) {
		LL t;
		cin >> t;
		A.push_back(t);
	}
	A.push_back(0);

	FOR(i, 1, A.size()) {
		sum += abs(A[i] - A[i - 1]);
		//O(A[i - 1]);
	}

	FOR(i, 1, N+1) {
		// A[i]を除外
		//cout << "a=" << A[0] << ",b=" << A[1];
		//cout << "1="<<abs(A[i - 1] - A[i]) << ", 2=" << abs(A[i] - A[i + 1]) << ", 3=" << abs(A[i - 1] - A[i + 1]) << endl;;
		LL nowans = sum - abs(A[i - 1] - A[i]) - abs(A[i] - A[i + 1]) + abs(A[i - 1] - A[i + 1]);
		O(nowans);
	}

	return 0;
}

Measured memory_bytes: 2164
#include<iostream>

using namespace std;

int main()
{
	int k;
	cin >> k;
	if (k == 1 || k == 2 || k == 3 || k == 5 || k == 7 || k == 11 || k == 13 || k == 15 || k == 17 || k == 19 || k == 23 || k == 29 || k == 31) {
		cout << 1 << endl;
	}
	else if (k == 4 || k == 6 || k == 9 || k == 10 || k == 14 || k == 22 || k == 21 || k == 25 || k == 26) {
		cout << 2 << endl;
	}
	else if (k == 28 || k == 30)cout << 4 << endl;
	else if (k == 8 || k == 12 || k == 18 || k == 20 || k == 27) {
		cout << 5 << endl;
	}
	else if (k == 16)cout << 14 << endl;
	else if (k == 24)cout << 15 << endl;
	else cout << 51 << endl;
    return 0;
}


Measured memory_bytes: 888
#include<stdio.h>

int main(){

int Min, Max, n, i=0;
long long int Sum;

scanf("%d", &n);
int a[n];
for(i=0;i<n;i++) scanf("%d", &a[i]);

Max = a[0];
Min = a[0];
Sum = 0;

for(i=0;i<n;i++){
   if(Max <= a[i])
      Max = a[i];
   Sum = Sum + a[i];
   if(Min >= a[i])
    Min = a[i];
}

printf("%d %d %lld\n", Min, Max, Sum);

return 0;
}


 
     

Measured memory_bytes: 640
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; 
const int MAXN = 1e5 + 10 ;
const int INF = 1e9 + 10 ; 
int n , m ;
vector<vector<int> > v(MAXN) ; 
vector<int> dist(MAXN,-1) ; 
int dfs(int x){
	if ( (int)v[x].size() == 0 ){
		return 0 ; 
	}
	if ( dist[x] != -1 ) return dist[x] ;
	int ans = 0 ; 
	for(int &c : v[x]){
		ans = max(ans,1+dfs(c));
	}
	debug() << imie(ans) ;
	return dist[x] = ans ; 
}
int main(){
    fastio
    cin >> n >> m ; 
    vector<int> deg(n) ; 
    for(int i=0;i<m;i++){
    	int x , y ; 
    	cin >> x >> y ; 
    	x--, y-- ; 
    	v[x].push_back(y) ; 
    	deg[y]++;
    }
    int ans = 0 ; 
    for(int i=0;i<n;i++){
    	if ( deg[i] == 0 ){
    		ans = max(ans,dfs(i)) ; 
    	}
    }
    cout << ans << endl;
    return 0 ;
}


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

#define endl '\n'
#define ll long long
#define LSB __builtin_ctzll
#define sc(a) scanf("%d",&a)
#define MSB 63-__builtin_clzll
#define scl(a) scanf("%lld",&a)
#define BITS __builtin_popcountll
#define mem(a , v)  memset(a , v , sizeof(a))
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MOD = 1e9+7;
const int MAX = 1e5+55;
const int INF = 1e9+77;
const ll INFINF = 1e18+1e17;
const double PI = acos(-1.0);
vector<int> months = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

ll power(ll x,ll y){
         if(y==0)
         return 1;
         ll s=power(x,y/2);
         s*=s;
         if(y&1)
         s*=x;
         return s;
}

int x[MAX];
ll dp[MAX];
int n;

ll solve(int i){
      if(i==n-1){
         return 0;
      }
      if(i==n-2){
         return abs(x[n-1]-x[i]);
      }

      ll &res=dp[i];
      if(res!=-1){
        return res;
      }

      res=min(  solve(i+1)+abs(x[i+1]-x[i]) ,  solve(i+2)+abs(x[i+2]-x[i])   );


      return res;
}



int main(){

ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//freopen("input.txt" , "r" , stdin);
//freopen("output.txt" , "w" , stdout);





    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x[i];
    }

    mem(dp,-1);
    cout<<solve(0);





     return 0;

}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int N, K;
void imosset(int h, int w, vector<vector<int>> &imos){
    if(w < 0 || h < 0) return;

    ++imos[max(0, h-K+1)][max(0, w-K+1)];
    --imos[max(0, h-K+1)][w+1];
    --imos[h+1][max(0, w-K+1)];
    ++imos[h+1][w+1];
}

int main(){
    cin >> N >> K;

    vector<int> x(N), y(N);
    for(int i=0; i<N; ++i){
        cin >> x[i] >> y[i];
        char c; cin >> c;
        if(c == 'W') x[i] += K;

        y[i] %= 2*K;
        x[i] %= 2*K;
    }

    vector<vector<int>> imos(4*K+5, vector<int>(4*K+5, 0));

    for(int i=0; i<N; ++i){
        int h = y[i], w = x[i];
        imosset(h, w, imos);
        imosset(h+K, w-K, imos);
        imosset(h+K, w+K, imos);
        imosset(h-K, w-K, imos);
        imosset(h-K, w+K, imos);
        imosset(h, w+2*K, imos);
        imosset(h, w-2*K, imos);
    }

    for(int h=0; h<=2*K; ++h){
        for(int w=1; w<=2*K; ++w) imos[h][w] += imos[h][w-1];
    }

    for(int w=0; w<=2*K; ++w){
        for(int h=1; h<=2*K; ++h) imos[h][w] += imos[h-1][w];
    }

    int ans = 0;
    for(int h=0; h<2*K; ++h) for(int w=0; w<2*K; ++w) chmax(ans, imos[h][w]);
    cout << ans << endl;

    // for(int h=2*K-1; h>=0; --h){
    //     for(int w=0; w<2*K; ++w){
    //         if(w) cout << "  ";
    //         printf("%2d", imos[h][w]);
    //     }
    //     cout << endl;
    // }

    return 0;
}

Measured memory_bytes: 63872
#include<stdio.h>
int main(){
    long long int input;
    long long int sum = 0;
    scanf("%lld", &input);
    for(int i = 1; i <= input; i++){
        if(i % 3 != 0 && i % 5 != 0)//jika kedua nya tidak habis dibagi 5 dan 3
        {
            sum = sum + i;//sum dijumlah
        }
    }
    printf("%lld\n", sum);
    return 0;
}

Measured memory_bytes: 3224
w,h,n=map(int,input().split())
x1=0
x2=w
y1=0
y2=h
for i in range(n):
  x,y,a=map(int,input().split())
  if a==1 and x > x1:
    x1 = x
  elif a==2 and x < x2:
    x2 = x
  elif a==3 and y > y1:
    y1 = y
  elif a==4 and y < y2:
    y2 = y
if x1 > x2 or y1 > y2:
  print(0)
else:
  print((x2 - x1)*(y2 - y1))


Measured memory_bytes: 9168
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
const llint mod=1000000007;
const llint big=1e18+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-9;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<int>&ar,int in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<int>&ar,int in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int n,m,i,j;cin>>n>>m;
	llint X;cin>>X;
	vector<tuple<llint,int,int>>go(m);
	for(i=0;i<m;i++){
		int a,b;llint c;cin>>a>>b>>c;a--;b--;
		go[i]=mt(c,a,b);
	}
	SO(go);
	int tyo=0,sku=0;
	for(int sta=0;sta<m;sta++){
		//i banmewo kanarazu tukau
		//union-find
		vector<int>oya(n);
		vector<int>ran(n);
		for(i=0;i<n;i++){oya[i]=i;}
		llint omo=0;
		omo+=get<0>(go[sta]);
		oya[get<2>(go[sta])]=get<1>(go[sta]);
		ran[get<1>(go[sta])]=1;
		for(i=0;i<m;i++){
			int a=get<1>(go[i]);
			int b=get<2>(go[i]);
			while(a!=oya[a]){a=oya[a];}
			while(b!=oya[b]){b=oya[b];}
			if(a==b){continue;}
			omo+=get<0>(go[i]);
			if(ran[a]<ran[b]){swap(a,b);}
			if(ran[a]==ran[b]){ran[a]++;}
			oya[b]=a;
		}
		if(omo<=X){tyo++;}
		if(omo<X){sku++;}
	}
	//cerr<<"t="<<tyo<<"s="<<sku<<endl;
	if(tyo==0){tyo=1;}
	if(sku==0){sku=1;}
	llint ans=0;
	llint gen=1;
	for(i=0;i<1+m-tyo;i++){gen*=2;gen%=mod;}
	ans-=gen;
	gen=1;
	for(i=0;i<1+m-sku;i++){gen*=2;gen%=mod;}
	ans+=gen;
	ans+=mod*100;ans%=mod;
	cout<<ans<<endl;
	return 0;
}

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

int main(void){
  int N,M,ans = 0;
  
  scanf("%d %d", &N, &M);
  
  for (int i = 0; i < M-1; i++){
   for (int j = i+1; j < M; j++){
     ans++;
   }
  }
  for (int i = 0; i < N-1; i++){
    for (int j = i+1; j < N; j++){
      ans++;
    }
  }
  
  printf("%d", ans);
}



Measured memory_bytes: 1732
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(){
  int N,a[100];
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  sort(a,a+N,greater<int>());
  int A=0,B=0;
  for(int i=0;i<N;i++){
    if(i%2==0){
      A+=a[i];}
    else{
      B+=a[i];}
  }
  cout << A-B << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int N;
int X;
int res[200000];
int main(){
  int i;
  int k = 2;
  rd(N);
  rd(X);
  if(X==1 || X==2*N-1){
    wt_L("No");
    wt_L('\n');
    return 0;
  }
  wt_L("Yes");
  wt_L('\n');
  for(i=(0);i<(2*N-1);i++){
    if(i == N-1){
      res[i] = X;
      continue;
    }
    if(i == N-2){
      res[i] = 1;
      continue;
    }
    if(i == N  ){
      res[i] = 2*N-1;
      continue;
    }
    if(k==X){
      k++;
    }
    res[i] = k++;
  }
  {
    int Q5VJL1cS;
    for(Q5VJL1cS=(0);Q5VJL1cS<(2*N-1);Q5VJL1cS++){
      wt_L(res[Q5VJL1cS]);
      wt_L('\n');
    }
  }
  return 0;
}
// cLay varsion 20191125-1

// --- original code ---
// int N, X;
// int res[2d5];
// {
//   int k = 2;
//   rd(N,X);
//   if(X==1 || X==2N-1) wt("No"), return 0;
//   wt("Yes");
//   rep(i,2N-1){
//     if(i == N-1) res[i] = X, continue;
//     if(i == N-2) res[i] = 1, continue;
//     if(i == N  ) res[i] = 2N-1, continue;
//     if(k==X) k++;
//     res[i] = k++;
//   }
//   wtLn(res(2N-1));
// }


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

/*
提出前に確認!
- setとmultisetを間違えない
*/

int mod = 1e9 + 7;

int	main(void)
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	long long ans = 0;
	long long all = 0;
	for (int i = 0; i < n; i++)
	{
		ans += all * a[i] % mod;
		ans %= mod;
		all += a[i];
		all %= mod;
	}
	cout << ans << endl;
	return (0);
}


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

int main(){
  int K , N ; 
  cin >> K >> N ; 
  vector<int> A(N) ,B(N) ; 
  
  for(int i = 0 ; i < N ; i++){
    cin >> A.at(i) ; 
  }
  
  for(int i = 1 ; i < N ; i++){
    B.at(i) = A.at(i) - A.at(i-1) ; 
    //cout << B.at(i) << endl; 
  }
  
   B.at(0) = K - A.at(N-1) + A.at(0) ; 
   //cout << B.at(0) << endl ; 

  
  
  
  sort(B.begin() , B.end()) ; 
  reverse(B.begin(),B.end()) ; 

  //cout << T << endl ; 
  cout << K - B.at(0) << endl ; 
  
}

Measured memory_bytes: 4840
#include <algorithm>
#include <assert.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

typedef long long ll;

const int MX = 100005;

template <typename T> void read(T &x)
{
	x = 0; char c = getchar(); bool f = 0;
	while(!isdigit(c) && c!='-') c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
	if(f) x = -x;
}

template <typename T> T max(const T &x, const T &y, const T &z)
{
	return max(max(x, y), z);
}

int n;
int opr[MX], seq[MX];
ll f[MX][3];

int main()
{
	read(n);
	opr[1] = +1;
	for(int i=1; i<=n; i++)
	{
		read(seq[i]);
		if(i != n)
		{
			char c = getchar();
			while(c!='+' && c!='-') c = getchar();
			if(c == '+') opr[i+1] = +1;
			else opr[i+1] = -1;
		}
	}
	f[0][1] = f[0][2] = -1e18;
	for(int i=1; i<=n; i++)
	{
		if(opr[i] == +1)
		{
			f[i][0] = max(f[i-1][0]+seq[i], f[i-1][1]+seq[i], f[i-1][2] + seq[i]);
			f[i][1] = max(f[i-1][1]-seq[i], f[i-1][2]-seq[i]);
			f[i][2] = f[i-1][2]+seq[i];
		}
		else
		{
			f[i][0] = -1e18;
			f[i][1] = max(f[i-1][0]-seq[i], f[i-1][1]-seq[i], f[i-1][2]-seq[i]);
			f[i][2] = max(f[i-1][1]+seq[i], f[i-1][2]+seq[i]);
		}
		//cout<<i<<" : "<<f[i][0]<<" "<<f[i][1]<<" "<<f[i][2]<<endl;
	}
	printf("%lld\n", max(f[n][0], f[n][1], f[n][2]));
	return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>

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

using namespace std;

int main(){
	int A, B;
	while(cin >> A >> B){
		cout << (A + B) % 24 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
#define pb push_back
#define mp make_pair
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
 
const int inf = int(1e9);
const int mod = 1e9 + 7;
const int N = 1e6 + 555;
const long double PI = acos(-1.0);
void solve()
{	
	int n;
	cin >> n;
	double a[n];
	rep(i, n) cin >> a[i];
	sort(a, a + n);
	double sum = 0;
	rep(i, n){
		if(!i) sum = a[i];
		else {
			sum = (sum + a[i]) / 2;
		}
	}
	cout << sum;
}
int main()
{
	Red;
	solve();
	return 0;
}

Measured memory_bytes: 256
/*
   Author : tarang
*/
#include<bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with(false); cin.tie(0);cout.tie(0);
#define PI = acos(-1)
using namespace std ;
ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
int main(){
	 ll m = 1000000007;
     ll n ; cin >> n ;
     vector<ll> v(n);
     for(ll i = 0 ; i < n ; i++){
     	cin >> v[i];
	 }
	 ll f[68] = {0};
//	 for(auto x:f) cout << x << " ";
//	 cout << endl;
	 for(ll i = 0 ; i < n ; i++){
	 	  for(ll j = 0 ; j < 63  ; j++){
	 	  	    if((v[i] & (1LL << j)))
	 	  	       f[j]++;
		   }
	 }
	// for(auto x :f) cout << x << " ";
	// cout << endl;
	 ll res = 0 ;
	 for(ll i = 0 ; i < 63 ; i++){
	 	  ll x = f[i];
	 	  ll z = (n-x);
	 	  ll ans = power(2 , i , m);
	 	  //cout << x << " " << z << " " << ans << endl;
	 	  ll ans2 = ( x % m * z % m) % m ;
	 	  ans2 = ( ans2 % m * ans%m) % m ;
	 	  res = ( res % m + ans2%m) %m ;
	 }
	 cout << (res)%m << endl;
}


Measured memory_bytes: 5480
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
#define ALL(a) (a).begin(), (a).end()
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

unsigned GetDigit(unsigned num) { return to_string(num).length(); }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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

ll nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    int N,M,X; cin >> N >> M >> X;
    vector<int> C(N);
    int A[N][M];

    REP(i,N){
        cin >> C[i];
        REP(j,M) cin >> A[i][j];
    }
    
    ll cost=1e18;
    bool flag=false;

    for(int bit=0; bit<(1<<N); ++bit){
        vector<ll> value(M,0);
        bool calcflag=true;
        ll hold=0;
        for(int i=0; i<N; ++i){
            if(bit & (1<<i)){
                hold+=C[i];
                REP(j,M) value[j]+=A[i][j];
            }
        }   
        REP(i,M){
            if(value[i]<X){
                calcflag = false;
                break;
            }
        }
        if(calcflag and cost>hold){
            cost = hold;
            flag = true;
        }
    }

    if(flag) cout << cost << endl;
    else cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 3664
import Control.Applicative

main = do
    x <- fmap (read :: String -> Int) . words <$> getLine
    h1 <- return $ head x
    h2 <- return $ x !! 1
    putStrLn $ show(h1 * h2) ++ " " ++ show(2 * h1 + 2 * h2)

Measured memory_bytes: 3596