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

int main(){

 	#ifndef ONLINE_JUDGE
 	freopen("input.txt", "r", stdin);
 	freopen("output.txt", "w", stdout);
 	#endif

 	int ans=0,n,k,f[1000];
 	cin>>n>>k;
 	for (int i = 0; i < n; ++i)
 	{
 		cin>>f[i];
 	}
 	sort(f,f+n);
 	for (int i = 0; i < k; ++i)
 	{
 		ans+=f[i];
 	}
 	cout<<ans;
 	return 0;
}


Measured memory_bytes: 3612
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Contest with Drinks Easy
            int n = int.Parse(Console.ReadLine());
            var t = ReadLine();
            int sum = t.Sum();

            int m = int.Parse(Console.ReadLine());

            for(int i = 0; i < m; i++)
            {
                var line = ReadLine();
                int p = line[0];
                int x = line[1];

                Console.WriteLine(sum + x - t[p - 1]);
            }            
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
    int n;
    double t, a;
    vector<double> h;

    cin >> n;
    cin >> t >> a;

    h.resize(n);

    // T - x * 0.006 = A
    // A - T = -x*0.006
    // T - A = x*0.006
    // (T - A) / 0.006 = x;

    double aHeight = (t - a) / 0.006f;

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

    int idx = 0;
    for(int i = 1; i < n; ++i)
    {
        if(abs(h[i] - aHeight) < abs(h[idx] - aHeight))
        {
            idx = i;
        }
    }

    cout << idx + 1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main()
{
 
char c;
int i,count[26]={0};
 
    while(scanf("%c",&c) != EOF)
    {
        if(c >= 'a'&& c <='z')
        {
           ++count[c-'a'];
        }

    else if(c >= 'A' && c <= 'Z')
    {
        ++count[c - 'A'];
    }
     
}
 
for(i=0 ; i < 26 ; i++)
{
    printf("%c : %d\n", 'a' + i, count[i]);
}

return 0;  
}


Measured memory_bytes: 2056
N = int(input())
res = N;
for i in range(N + 1):
    cc = 0
    t = i
    while t:
        cc += t % 6; t //= 6
    t = N - i
    while t:
        cc += t % 9; t //= 9
    if res > cc:
        res = cc
print(res)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define MAX 100000
using namespace std;

//init
vector<pair<char, int>> A; //can later resize this vector u know
map<int, string> Q1, Q2; //for comparing 2 vecs for stability
int q, n;

int isStable()
{
    for(int i=0; i<n; i++)
    {
        if(Q1[A[i].second] != Q2[A[i].second]) return 0;
    }
    return 1;
}

int partition(int p, int r)
{
    int x = A[r].second;
    int i = p-1;
    for(int j=p; j <= r-1; j++)
    {
        if(A[j].second <=x)
        {
            i +=1;
            swap(A[i], A[j]);
        }
    }
    swap(A[i+1], A[r]);
    return i+1;
}

void quickSort(int p, int r)
{
    if(p < r)
    {
        q = partition(p, r);
        quickSort(p, q-1);
        quickSort(q+1, r);
    }
}

int main()
{
    //input
    cin >> n;
    A.resize(n);
    for(auto &i: A) cin >> i.first >> i.second;
    //calc
    for(int i=0; i<n; i++)
    {
        Q1[A[i].second] += A[i].first;
    }
    quickSort(0, n-1);
    for(int i=0; i<n; i++)
    {
        Q2[A[i].second] += A[i].first;
    }
    //output
    if(isStable() == 1) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
    for(int i=0; i<n; i++) 
        cout << A[i].first << " " << A[i].second << endl;
    return 0;
}


Measured memory_bytes: 9184
/**
*    created: 01.07.2020 21:03:05
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const int MOD = 1000000007;
// const int MOD = 998244353;
const long double pi = acos(-1.0);
const int INF = 1LL << 60;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << s1[0] << s2[1] << s3[2] << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;


int main(){
  int H, W; cin >> H >> W;
  int h, w; cin >> h >> w;

  int ans = (H-h) * (W-w);
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# a〜z
l=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

def main():
  s=S()
  if s=='zyxwvutsrqponmlkjihgfedcba':
    return -1

  for x in s:
    if l.count(x)==0:
      return -1
    l.remove(x)

  if len(l)>0:
    return ''.join(s)+l[0]

  nakama=[]
  for i in range(len(s))[::-1]:
    nakama.sort()
    b=s[i]
    for a in nakama:
      if a>b:
        return s[:i]+a
    nakama.append(b)

# main()
print(main())


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

int main() {
  string c;
  cin >> c;
  
  if(c == "a" || c == "i" || c == "u" || c == "e" || c == "o") {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main {
  private static boolean debug = false;
  private static boolean elapsed = false;
 
  private static PrintWriter _err = new PrintWriter(System.err);
 
  private void solve(Scanner sc, PrintWriter out) {
    String s = sc.next();
    char ch = s.charAt(0);
    if (ch == 'a' || ch == 'i' || ch == 'u' || ch == 'e' || ch == 'o') {
      out.println("vowel");
    } else {
      out.println("consonant");
    }
  }
  private long C(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    for (long i = r; i > 1; --i) {
      res /= i;
    }
    return res;
  }
  private long P(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    return res;
  }
  /*
   * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
   * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
   */
  public static void main(String[] args) {
    long S = System.currentTimeMillis();
 
    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    new Main().solve(sc, out);
    out.flush();
 
    long G = System.currentTimeMillis();
    if (elapsed) {
      _err.println((G - S) + "ms");
    }
    _err.flush();
  }
}

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

#define TC int n;scanf("%d",&n);while(n--)
#define lld long long int

int main()
{
    long long int n=0,k=0,x=0,sz=0,val=0,mn=0;
    cin>>n>>k;
    sz=n;
    vector<int>v;
    vector<long long int>s;
    while(n--)
    {
        cin>>x;
        v.push_back(x);
    }
    for(int i=0;i<=sz-k;i++)
    {
        mn=min(abs(v[i])-0,abs(v[i+k-1])-0);
        val=mn+(v[i+k-1]-v[i]);
        //cout<<val<<endl;
        s.push_back(val);
    }
    sort(s.begin(),s.end());
    cout<<s[0];
    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define P pair<int,int>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define re(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    string s;
    cin>>s;
    if(s=="Sunny"){
        cout<<"Cloudy"<<endl;
    }
    else if(s=="Rainy"){
        cout<<"Sunny"<<endl;
    }
    else{
        cout<<"Rainy"<<endl;
    }
}

Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
*a, = map(int, input().split())
b = defaultdict(int)
for i in range(N):
    b[a[i]] += 1
ans = 0
for i, v in b.items():
    if i > b[i]:
        ans += b[i]
    elif i < b[i]:
        ans += b[i]-i
print(ans)


Measured memory_bytes: 106704
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  char b;
  cin>>b;
  if(b=='A')ou('T');
  if(b=='T')ou('A');
  if(b=='G')ou('C');
  if(b=='C')ou('G');
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int h=1000,w=1000;
	cin>>h>>w;
	while(w!=0&&h!=0){
		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				if(i!=1&&i!=h&&j!=1&&j!=w){
					cout<<".";
				}
				else{
					cout<<"#";
				}
			}
			cout<<endl;
		}
		cout<<endl;	
		cin>>h>>w;	
	}	
}



Measured memory_bytes: 3064
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	vi a(n);
	int co=0;
	rep(i,n)if(abs(in[i])==2){
		a[i]=1;
		if(in[i]==-2)co++;
	}
	if(co%2){
		int t=-1;
		rep(i,n)if(in[i]==-1){
			t=i;
			break;
		}
		if(t+1){
			a[t]=1;
		}else{
			for(int i=n-1;i>=0;i--)if(in[i]==-2){
				a[i]=0;
				break;
			}
		}
	}
	co=0;
	rep(i,n)if(a[i])co++;
	cout<<co<<endl;
	rep(i,n)if(a[i])cout<<i+1<<endl;
}







Measured memory_bytes: 3120
#include <stdio.h>

int t[7][7]={
    {0,3,5,2,4,0},
    {4,0,1,6,0,3},
    {2,6,0,0,1,5},
    {5,1,0,0,6,2},
    {3,0,6,1,0,4},
    {0,4,2,5,3,0}
    };

int main(void){
    int a,b,i,j,n,x,y,dice[10];
    
    for(i=0;i<6;i++){
        scanf("%d",&dice[i]);
    }
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%d%d",&x,&y);
        for(j=0;j<6;j++){
            if(x==dice[j]) a=j;
            if(y==dice[j]) b=j;
        }
        printf("%d\n",dice[t[a][b]-1]);
    }
    return 0;
}


Measured memory_bytes: 1960
#include<cstdio>
using namespace std;
int n,p,x,i;
bool flag=0;
int main()
{
	scanf("%d%d",&n,&p);
	for (i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if (x%2==1) flag=1;
	}
	if (p==1&&!flag) {printf("0\n");return 0;}
	long long ans=1;
	for (i=1;i<=n-1;i++) ans=ans*2ll;
	if (p==0&&!flag) ans=ans*2ll;
	printf("%lld\n",ans);
}

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

using namespace std;

vector<pair<double,double> > point;
vector<pair<double,double> >::iterator it;

void koch(int n,pair<double,double> start,pair<double,double> end){
  if(n==0) return;
  pair<double,double> s,t,u;
  double x_sum=(end.first-start.first)/3;
  double y_sum=(end.second-start.second)/3;
  double distance=sqrt(pow(x_sum,2)+pow(y_sum,2));
  s.first=start.first+x_sum;
  s.second=start.second+y_sum;
  u.first=start.first+x_sum*2;
  u.second=start.second+y_sum*2;
  t.first=(u.first-s.first)*cos(M_PI/3)-(u.second-s.second)*sin((M_PI/3))+s.first;
  t.second=(u.first-s.first)*sin(M_PI/3)+(u.second-s.second)*cos(M_PI/3)+s.second;
  koch(n-1,start,s);
  printf("%.8f %.8f\n",s.first,s.second);
  koch(n-1,s,t);
  printf("%.8f %.8f\n",t.first,t.second);
  koch(n-1,t,u);
  printf("%.8f %.8f\n",u.first,u.second);
  koch(n-1,u,end);
}

int main(){
  int com_n=0;
  cin >> com_n;
  printf("%.8f %.8f\n",0.0,0.0);
  koch(com_n,make_pair(0.0,0.0),make_pair(100.0,0.0));
  printf("%.8f %.8f\n",100.0,0.0);
  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std ;
using V_2 = vector<vector<int>> ;
using Gragh = vector<vector<char>> ;
using P = pair<int,int> ;
using ll = long long ;

ll n ;

int main(){
  ll ans = 0 ;
  cin >> n ;
  ll a[n] ;
  for(int i = 0 ; i < n ; i++) cin >> a[i] ;
  for(int i = 1 ; i < n ; i++){
    if(a[i-1] > a[i]){
      ans = ans + (a[i-1] - a[i]) ;
      a[i] = a[i-1] ;
    }
  }
  cout << ans << endl ;
}

Measured memory_bytes: 5144
//include
//--------------------------------------------------
#include<vector>
#include<list>
#include<map>
#include<set>
#include<deque>
#include<stack>
#include<bitset>
#include<algorithm>
#include<functional>
#include<numeric>
#include<utility>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<string>
#include<cstring>
#include<ctime>

using namespace std;

//conversion
//--------------------------------------------------
inline int toInt(const string &s){
    int v;istringstream sin(s);sin>>v;
    return v;
}
template<class T> inline string toString(T x){
    ostringstream sout;sout<<x;
    return sout.str();
}

//math
//--------------------------------------------------
template<class T> inline T sqr(T x){return x*x;}

//typedef
//--------------------------------------------------
typedef vector<int>VI;
typedef vector<VI>VVI;
typedef vector<string>VS;
typedef pair<int,int>PII;
typedef long long LL;

//container util
//--------------------------------------------------
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------------
const int INF=1e9+7;
const int dx[]={0,-1,0,1};
const int dy[]={-1,0,1,0};

//clear memory
#define CLR(a) memset((a),0,sizeof(a))

//debug
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<"(L"<<__LINE__<<")"<<endl

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


int N,K;
VVI V;
bool T[50][50];
int solve(){
    int cnt=0;
    REP(k,K){
        REP(i,V[k].size()){
            REP(j,V[k].size()){
                if(i==j)continue;
                int a=V[k][i],b=V[k][j];
                if(T[a][b]){
                    cnt++;
                    break;
                }
            }
        }
    }
    return cnt;
}
int main(){
    fill_n(*T,50*50,false);
    cin>>N>>K;
    V.resize(K);
    REP(i,K){
        int m;cin>>m;
        REP(j,m){
            int b;cin>>b;b--;
            V[i].PB(b);
        }
    }
    int R;
    cin>>R;
    REP(i,R){
        int a,b;
        cin>>a>>b;
        a--;b--;
        T[a][b]=T[b][a]=true;
    }
    cout<<solve()<<endl;

    return 0;
}

Measured memory_bytes: 1220
#include <iostream>
using namespace std;
int main(void){
    int N;
    cin >> N ;
    
    int a;
    int buf;
    int a_dn=0, a_num=0, a_up=0;
    cin >> a;
    a_num++;
    for(int i=0; i<N-1; i++){
        cin >> buf;
        if(buf == a){
            a_num++;
        }else if(buf == a+1){
            a_up++;
        }else if(buf == a-1){
            a_dn++;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }

    if(a_dn > 0){
        if(a_up > 0){
            cout << "No" << endl;
            return 0;
        }
    }else if(a_up > 0){
        a_dn = a_num;
        a_num = a_up;
        a++;
    }else{
        if(a*2 <= N){
            cout << "Yes" << endl;
            return 0;            
        }else if(a_num == a+1){
            cout << "Yes" << endl;
            return 0;           
            
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    
    if(a_dn >= a){
        cout << "No" << endl;
        return 0;
    }else{
        if(a + (a - a_dn) > N){
            cout << "No" << endl;
            return 0;            
        }else{
            cout << "Yes" << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
    #include <string>
    #include <set>  
    #include <algorithm>
    #include <vector>
    #include <cmath>
    #include <queue>
    #include <deque>
    #include <cstring>
    #include <cstdio>
    #include <map>
    #include <numeric>
	#include <cassert>
    #include <iomanip>
    #include <sstream>
using namespace std;
int N,K;
long long A[5005];
int main()
{
	cin>>N>>K;
	for(int i=0;i<N;i++)
		cin>>A[i];
	sort(A,A+N);
	long long sum=0;
	int pos=N;
	for(int i=N-1;i>=0;i--)
		if(sum+A[i]<K)
			sum+=A[i];
		else 
			pos=i;
	cout<<pos<<endl;
	return 0;
}

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

int main()
{
ll n , k ;
cin >> n >> k ;
ans=n%k;
ans=min(ans,-1*(n%k-k));
cout << ans << endl;
return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <fstream>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <ctime>
#include <stack>
#include <map>
#include <set>
#if __cplusplus > 199711L
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
//	tree<key, mapped = null_type, cmp = less<key>, rb_tree_tag, tree_order_statistics_node_update> name;
//	order_of_key
//	find_by_order
#endif

using namespace std;

#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fs first
#define sc second
#define abs(a) ((a) < 0 ? -(a) : (a))
#define sqr(a) ((a) * (a))

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

inline pair<pair<bool, bool>, pair<string, bool> > useinout();

void initialization() {
#ifdef SOL
	if (useinout().fs.fs)
		freopen("input.txt", "r", stdin);
	if (useinout().fs.sc)
		freopen("output.txt", "w", stdout);
#else
	srand(time(0));
	const string file = useinout().sc.fs;
	if (!file.empty()) {
		freopen((file + ".in").c_str(), "r", stdin);
		freopen((file + ".out").c_str(), "w", stdout);
	}
	if(useinout().sc.sc) {
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	}
#endif
}

int solve();

void finish(int exitval) {
	fflush(stdout);
#ifdef SOL
	fprintf(stderr, "\nexit value: %d\ntime: %.3lf ms\n", exitval, 1000. * clock() / CLOCKS_PER_SEC);
#endif
}

int main() {
	initialization();
	int exitval = solve();
	finish(exitval);
	return (0);
}

const double eps = 1e-9;
const int mod = (int) 1e+9 + 7;
const double pi = acos(-1.);
const int maxn = 200100;

int a[maxn];
bool pm[maxn];

int solve() {

	int n, x;
	scanf("%d%d", &n, &x);
	int nn = n;
	n = 2 * n - 1;
	if (x == 1 || x == n) {
		printf("No\n");
		return (0);
	}

	if (n == 3) {
		printf("Yes\n1\n2\n3\n");
		return (0);
	}

	bool rev = 0;
	if (x == n - 1) {
		rev = 1;
		x = n - x + 1;
	}
	a[nn] = x;
	pm[x] = 1;
	a[nn + 1] = x - 1;
	pm[x - 1] = 1;
	a[nn - 1] = x + 1;
	pm[x + 1] = 1;
	a[nn + 2] = x + 2;
	pm[x + 2] = 1;

	int id = 1;
	for (int i = 1; i <= n; i++) {
		if (a[i] == 0) {
			while (pm[id])
				id++;
			a[i] = id;
			pm[id] = 1;
		}
	}
	printf("Yes\n");
	for (int i = 1; i <= n; i++) {
		printf("%d\n", rev ? n - a[i] + 1 : a[i]);
	}

	return (0);
}

inline pair<pair<bool, bool>, pair<string, bool> > useinout() {
	return (mp(mp(0, 0), mp("", 0)));
}

// by Andrey Kim


Measured memory_bytes: 2432
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1e+9 + 7;

//マクロ
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

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

ll wgcd(ll x, ll y, ll z)
{
  return gcd(x, gcd(y, z));
}

int main()
{
  ll k;
  cin >> k;
  ll ans = 0;
  for (int i = 1; i <= k; i++)
  {
    for (int j = 1; j <= k; j++)
    {
      for (int l = 1; l <= k; l++)
      {
        ans += wgcd(i, j, l);
      }
    }
  }
  cout << ans << "\n";
  return 0;
}

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

int main(){
    while(1){
        int grade[3] = {};
        for (int i = 0; i < 3; i++){
            cin >> grade[i];
        }

        if (grade[0] == -1 && grade[1] == -1 && grade[2] == -1) break;

        if (grade[0] == -1 || grade[1] == -1) cout << "F" << endl;
        else if (grade[0] + grade[1] >= 80) cout << "A" << endl;
        else if (grade[0] + grade[1] >= 65) cout << "B" << endl;
        else if (grade[0] + grade[1] >= 50) cout << "C" << endl;
        else if (grade[0] + grade[1] >= 30) {
            if (grade[2] >= 50) cout << "C" << endl;
            else cout << "D" << endl;
        } else cout << "F" << endl;
    }    
    return 0;
}


Measured memory_bytes: 3096
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
K,A,B = map(int,input().split())

ans1 = 1 + K
zanturn = K - (A - 1)
AtoB,mod = divmod(zanturn,2)
ans2 = A + (B-A)*AtoB + mod

ans = max(ans1,ans2)

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


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

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

    int rsp[3];
    cin >> rsp[0] >> rsp[1] >> rsp[2];

    string t;
    cin >> t;

    vector< vector<int64_t> > dp(3, vector<int64_t>(n, 0));
    vector<int> ban(n, 0);
    if(t[0] == 'r') {
        dp[2][0] = rsp[2];
        ban[0] = 2;
    } else if(t[0] == 's') {
        dp[0][0] = rsp[0];
        ban[0] = 0;
    } else {
        dp[1][0] = rsp[1];
        ban[0] = 1;
    }

    for(int i = 1; i < n; i++) {
        int m;
        if(t[i] == 'r')      m = 2;
        else if(t[i] == 's') m = 0;
        else                 m = 1;
        
        dp[0][i] = max(dp[0][i - 1], max(dp[1][i - 1], dp[2][i - 1]));
        dp[1][i] = max(dp[0][i - 1], max(dp[1][i - 1], dp[2][i - 1]));
        dp[2][i] = max(dp[0][i - 1], max(dp[1][i - 1], dp[2][i - 1]));

        if(i < k) {
            dp[m][i] += rsp[m];
            ban[i] = m;
        } else {
            if(t[i - k] == t[i] && m == ban[i - k]) {
                ban[i] = -1;
            } else {
                dp[m][i] += rsp[m];
                ban[i] = m;
            }
        }
    }
/*
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < n; j++) {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
*/
    cout << max(dp[0][n - 1], max(dp[1][n - 1], dp[2][n - 1])) << endl;

    return 0;
}

Measured memory_bytes: 3584
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        // AGC 008 Simple Calculator
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.equals("zyxwvutsrqponmlkjihgfedcba")) {
            System.out.println(- 1);
            return;
        }
        if (s.length() == 26) {
            for (int i = 24; i >= 0; i--) {
                char target = s.charAt(i);
                char c = 'z';
                boolean exist = false;
                for (int j = i + 1; j < s.length(); j++) {
                    if (target < s.charAt(j)) {
                        exist = true;
                        if (c > s.charAt(j)) {
                            c = s.charAt(j);
                        }
                    }
                }
                if (exist) {
                    System.out.println(s.substring(0, i) + c);
                    return;
                }
            }
        }
        char last = 'a';
        while (true) {
            if (s.indexOf(last) == - 1) {
                System.out.println(s + last);
                return;
            }
            last++;
        }
    }
}

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

bool linear_search(vector<int> A,int key){
    int n = A.size();
    for(int i=0;i<n;i++){
        if(A[i]==key){
            return true;
        } 
    }
    return false;
}

int main(){
    int n,q;
    cin >> n;
    vector<int> s(n);
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    cin >> q;
    vector<int> t(q);
    int sum = 0;
    for(int i=0;i<q;i++){
        cin >> t[i];
    }
    for(int i=0;i<q;i++){
        if(linear_search(s,t[i])) sum++;
    }
    cout << sum << endl;
    
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i, x, y) for (long long i = x; i <= y; i++)
#define x first
#define y second
using namespace std;

const int N = 3e5 + 10;
typedef pair<int, int> pii;
int w, h, n, ans;
int tag[N << 2], mx[N << 2];
pii p[N], a[N], b[N];

void psd(int x) {
    if (tag[x]) {
        tag[x << 1] += tag[x];
        tag[x << 1 | 1] += tag[x];
        mx[x << 1] += tag[x];
        mx[x << 1 | 1] += tag[x];
        tag[x] = 0;
    }
}

void update(int x, int l, int r, int lx, int rx, int val) {
    if (rx < l || r < lx) return;
    if (lx <= l && r <= rx) {
        tag[x] += val, mx[x] += val; return;
    }
    psd(x);
    int mid = (l + r) >> 1;
    update(x << 1, l, mid, lx, rx, val);
    update(x << 1 | 1, mid + 1, r, lx, rx, val);
    mx[x] = max(mx[x << 1], mx[x << 1 | 1]);
}

void solve() {
    memset(mx, 0, sizeof(mx));
    memset(tag, 0, sizeof(tag));

    sort(p + 1, p + n + 1);

    int l = 0, r = 0;
    rep(i, 1, n - 1) {
        if (p[i].y <= h / 2) {
            int nxt = i - 1;
            while (l && p[i].y > a[l].y) {
                update(1, 1, n, a[l].x, nxt, a[l].y - p[i].y);
                nxt = a[l].x - 1;
                --l;
            }
            if (nxt != i - 1) a[++l] = make_pair(nxt + 1, p[i].y);
        } else {
            int nxt = i - 1;
            while (r && p[i].y < b[r].y) {
                update(1, 1, n, b[r].x, nxt, p[i].y - b[r].y);
                nxt = b[r].x - 1;
                --r;
            }
            if (nxt != i - 1) b[++r] = make_pair(nxt + 1, p[i].y);
        }
        a[++l] = make_pair(i, 0);
        b[++r] = make_pair(i, h);
        update(1, 1, n, i, i, h - p[i].x);
        ans = max(ans, p[i + 1].x + mx[1]);
    }
}

int main() {
    cin >> w >> h >> n;
    rep(i, 1, n) scanf("%d%d", &p[i].x, &p[i].y);
    p[++n] = make_pair(0, 0);
    p[++n] = make_pair(w, h);

    solve();

    rep(i, 1, n) swap(p[i].x, p[i].y);
    swap(w, h);
    solve();

    printf("%d\n", ans << 1);
    return 0;
}


Measured memory_bytes: 15616
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

// 1 種類について、全体
const int SIZE = 2010;
int dp[2][SIZE + 10];
vector<int> books[15];
 
signed main() {
    int N, K; cin >> N >> K;
    for(int i=0; i<N; i++) {
        int A, B; cin >> A >> B;
        books[B-1].push_back(A);
    }

    fill(dp[0], dp[2], -1);
    dp[0][0] = 0;
    for(int x=0; x<10; x++) {
        sort(books[x].begin(), books[x].end(), greater<int>());
        int cur = x % 2, nxt = 1 - cur;

        int sum = 0, cnt = 0;
        for(auto val : books[x]) {
            sum += val; cnt++;
            int total = sum + (cnt - 1) * cnt;
            for(int i=N; i>=cnt; i--) {
                if(dp[cur][i-cnt] < 0) continue;
                chmax(dp[nxt][i], dp[cur][i-cnt] + total);
            }
        }

        for(int i=0; i<SIZE; i++) {
            chmax(dp[nxt][i], dp[cur][i]);
        }
        fill(dp[cur], dp[cur] + SIZE, -1);
    }

    cout << dp[0][K] << endl;
    return 0;
}


Measured memory_bytes: 3216
import sys
sys.setrecursionlimit(200000)

N, s, t = map(int, input().split())
s -= 1; t -= 1
to = [[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    to[a].append(b)
    to[b].append(a)

def calcDist(u):
    dfs(u)
    return dist

def dfs(v, d=0, p=-1):
    dist[v] = d
    for u in to[v]:
        if u == p:
            continue
        dfs(u, d+1, v)

dist = [0 for _ in range(N)]
distS = calcDist(s)
dist = [0 for _ in range(N)]
distT = calcDist(t)

ans = 0
for i in range(N):
    if distS[i] < distT[i]:
        ans = max(ans, distT[i])

print(ans-1)

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

int main(){
	int n, c, in;
	cin >> n >> c;
	vector<vector<int>> cc(c, vector<int>(c));
	vector<vector<int>> gr(3, vector<int>(0));
	rep(i, c) rep(j, c){//900
		cin >> in;
		cc.at(i).at(j) = in;
	}
	rep(i, n) rep(j, n){//250000
		cin >> in;
		in--;
		gr.at((i+j)%3).push_back(in);
	}
	ll mi = 25000000000;
	vector<vector<int>> cos(3, vector<int>(c));
	rep(k, 3){
		rep(i, c){
			ll sum = 0;
			rep(jj, gr.at(k).size()){//250000
				sum += cc.at(gr.at(k).at(jj)).at(i);
			}
			cos.at(k).at(i) = sum;
		}
	}
	rep(i, c) rep(j, c) rep(l, c){//27000
		if(i == j || j == l || l == i) continue;
		ll sum = 0;
		sum += cos.at(0).at(i);
		sum += cos.at(1).at(j);
		sum += cos.at(2).at(l);
		if(sum < mi) mi = sum;
	}
	cout << mi << endl;
	return 0;
}


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

ll C = (1 << 30);
ll CR = C % mo;



std::vector<std::vector<long long>> comb(int n, int r) {
  std::vector<std::vector<long long>> v(n + 1,std::vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

const ll M = mo;


//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod mo) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mo;
        x = x*x % mo;
        n = n >> 1;
    }
    return ans;
}
ll combi(ll n, ll r) {
  if ( r * 2 > n ) r = n - r;
  ll dividend = 1;
  ll divisor  = 1;
  for ( ll i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    dividend %= mo;
    divisor  *= i;
    divisor %= mo;
  }
  return (dividend * mpow(divisor, mo-2)) % mo;
}
/*
ll comb(ll a, ll b){ //aCbをmod計算
    vector<ll> fac(1000000000); //n!(mod M)
    vector<ll> ifac(1000000000); //k!^{M-2} (mod M)
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

ll solve(ll n, ll a, ll b){
    ll nn = n/2;
    if(n == 0){
        return 1;
    }
    if(n % 2 == 0){
        ll s = solve(nn);
        return s*s % mo;
    } else{
        ll s = solve(nn);
        return s*s*2 % mo;
    }
}*/

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    ll q = n / 30;
    ll r = n % 30;

    ll res=1;
    for(int i = 0; i<q; i++){
        res *= CR;
        res %= mo; 
    }
    for(int i = 0; i<r; i++){
        res *= 2;
        res %= mo;
    }
    //cout << res << endl;
    //ll tmp1 = comb(n, a)[n][a];
    //ll tmp2 = comb(n, b)[n][b];
    ll tmp1 = combi(n, a);
    ll tmp2 = combi(n, b);
    //cout << tmp1 << endl;
    tmp1 %= mo;
    tmp2 %= mo;

    res = res - 1 - tmp1 - tmp2;
    while(res < 0) res += mo;
    cout << res % mo << endl;

}


Measured memory_bytes: 256
def o_divisors(n):
    L = [i for i in range(1, int(n**0.5)+5) if n%i == 0]
    L += [n//i for i in L]
    L = sorted(list(set(L)))
    return [l for l in L if n//l % 2]
    
N = int(input())
T = input()
P = 998244353
bt = int(T, 2)
c = 0
ans = 0
L = []
for k in o_divisors(N):
    tt = T[:k]
    tt_ = tt.replace("0", "2").replace("1", "0").replace("2", "1")
    ttf = tt + (tt_ + tt) * ((N//k-1)//2)
    aa = int(tt, 2) + (int(ttf, 2) <= bt)
    for l, cc in L:
        if k % l == 0:
            aa -= cc
    L.append((k, aa))
    c += aa
    ans += k*2*aa
        
ans = (ans + 2 * N * (bt - c + 1)) % P
print(ans)

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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
void debug_out() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H), debug_out(T...);
}

const int MAX=2e3+5,m=1e9+7;
ll dp[MAX];
int n;

ll f(int sum) {
    if(sum==0)return 1;
    if(sum<0)return 0;
    ll &ans=dp[sum];
    if(ans!=-1)return ans;
    ans=0;
    for(int i=3;i<=n;i++)ans=(ans%m+f(sum-i)%m)%m;
    return ans;
}
int main() {
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
#define debug(...) 3
    fastIO;
#endif
    memset(dp,-1,sizeof dp);
    cin>>n;
    ll ans=0;
    cout<<f(n)<<endl;
    return 0;
}


Measured memory_bytes: 3548
/*
    ٭٭UWW٭٭OWO٭٭
    Auto-generated by VS Code's Code Snippet
    «I'm just a starter-coder»
    ▶redmcgn◀
    ٭٭UWW٭٭OWO٭٭
*/

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

// Defines
#define ll long long
#define ld long double
#define pb push_back
#define fup(i, l, h) for (int i = l; i < h; i++)
#define fdw(i, h, l) for (int i = h; i > l; i--)
#define ftms(tms) for (int i = 1; i <= tms; i++)
#define feach(t, i, l) for (t i : l)
#define sz(a) (int)a.size()
#define x first
#define y second
#define b(v) v.begin()
#define e(v) v.end()
#define all(v) b(v), e(v)

// typedefs
typedef pair<int, int> pii;
typedef vector<int> vi;

// Debug tool, f = open input file, D = debug mode
// #define f
// #define debug

// Main function
int main()
{
#ifdef f
    freopen("c.inp", "r", stdin);
#endif
    int n, m;
    cin >> n >> m;
    if (m == 1)
    {
        int l, r;
        cin >> l >> r;
        cout << r - l + 1;
    }
    else
    {
        vi fs;
        vi sc;
        fup(i, 0, m)
        {
            int l, r;
            cin >> l >> r;
            fs.push_back(l);
            sc.push_back(r);
        }
        int mx1 = *max_element(all(fs));
        int mn2 = *min_element(all(sc));
        #ifdef debug
        cout << mx1 << " " << mn2 << " s";
        #endif
        if (mx1 > mn2)
            cout << 0;
        else
            cout << (mn2 - mx1 + 1);
    }
}

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

using namespace std;

int a[100];
int b[100];
int c[100];

int n;
long long ans=0;

int main(){
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)cin>>b[i];
    for(int i=1;i<=n-1;i++)cin>>c[i];

    for(int i=1;i<=n;i++){
        ans += b[a[i]];
        if(i>=2 && (a[i]-1)==a[i-1]){
            ans+=c[a[i-1]];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b,p,m,ml;
    scanf("%d", &a);
    scanf("%d", &b);
    p = a + b;
    m = a - b;
    ml = a * b;
    if(p >= m && p >= ml){
        printf("%d\n", p);
    }
    else if(m > p && m > ml){
        printf("%d\n", m);
    }
    else if(ml > p && ml > m){
        printf("%d\n", ml);
    }
    return 0;
}

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


int main(){
    int a, b, cnt = 0;
    cin >> a >> b;
    rep(i,b-a+1){
        int tmp = a+i;
        int fst = tmp%10;
        tmp /= 10;
        int sec = tmp%10;
        tmp /= 100;
        if(tmp == fst*10 + sec) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする


def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)

def extgcd1(a0,b0):
    u=1
    v=0
    a=a0
    b=b0
    while b:
        t=a//b
        a-=t*b
        a,b=b,a
        u-=t*v
        u,v=v,u
    if a!=1: 
        #print("not 素")
        return -1
    return u%b0 #a0*u=1(mod b0)

def main():
    mod =998244353
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, M, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    # dp=[0]*2
    # ndp=copy(dp)
    # dp[0]=0
    # dp[1]=M
    # for i in range(2,N+1):
    #     if i<=K+1:
    #         ndp[0]=((M-1)*(dp[0]+dp[1])+dp[0])%mod
    #         ndp[1]=dp[1]
    #     else:
    #         ndp[0]=(M*dp[0]+(M-1)*dp[1])%mod
    #         ndp[1]=0

    #     dp=copy(ndp)
    # ans=(dp[0]+dp[1])%mod
    # #print(ans)

    #n0=math.factorial(N-1)
    #ks=[1]*(N-1+1)
    #for k in range(2,N-1+1):
    #    ks[k]=ks[k-1]*k
    ans=0
    c0=1
    c1=pow(M-1,N-1,mod)
    inv=[1,1]+[extgcd1(i,mod) for i in range(2,N)]
    #print("ok1")
    ifac=[1]*(N)
    nfac=1
    for i in range(1,N):
        nfac=(i*nfac)%mod
        ifac[i]=(ifac[i-1]*inv[i])%mod
    #print("ok2")
    #print(ifac)
    
    
    mp=[1]*(N)
    for i in range(1,N):
        mp[i]=(mp[i-1]*(M-1))%mod
    #print("ok3")
    ans=0
    #print(nfac)
    #print(mp)
    
    for k in range(0,K+1):
        #print((n0//ks[k]//ks[N-1-k]))
        ans=ans+(mp[N-1-k]*nfac*ifac[k]*ifac[N-1-k])%mod
        ans%=mod
        #print(ans)
    #print(ks)
    ans=(ans*M)%mod
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 86332
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
	string S, T;
	cin >> S;
	T = S;
	reverse(T.begin(), T.end());
	int n = (int)S.size() / 2; 
	int count = 0;
	for (int i = 0; i < n; i++) {
		if (S[i] != T[i]) count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3596
// https://atcoder.jp/contests/agc024/tasks/agc024_e
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize, k: usize, MOD: usize
    };

   let mut comb = vec![vec![0; n+2]; n+2];
    for i in 0..n+2 {
        comb[i][0] = 1;
        comb[i][i] = 1;
        for j in 1..i {
            comb[i][j] = (comb[i-1][j-1] + comb[i-1][j]) % MOD;
        }
    }

    let mut dp = vec![vec![0; k+1]; n+2];
    for i in 0..k+1 {
        dp[1][i] = 1;
    }


    let mut dp_sum = vec![vec![0; k+2]; n+2];
    for i in 2..n+2 {
        for j in 0..k+1 {
            let p = dp_sum[i-1][j];
            dp_sum[i-1][j+1] = (p + dp[i-1][j]) % MOD;
        }

        for j in 0..k+1 {
            let mut total = 0;
            for w in 1..i {
                total += (MOD + dp_sum[w][k+1] - dp_sum[w][j+1]) % MOD * dp[i-w][j] % MOD * comb[i-2][w-1] % MOD;
                total %= MOD;
            }
            dp[i][j] = total;
            // dp[i][j] = sum(k, c(>j)) { dp[i-k][c] * dp[k][j] )
        }
    }

    println!("{}", dp[n+1][0]);
}


Measured memory_bytes: 6396
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

char s[maxn];
ll pre[maxn];

int main()
{
	scanf("%s",s+1); ll len=strlen(s+1),ans=0;
	rep(i,1,len-1)
	{
		if(s[i]=='A') pre[i]=pre[i-1]+1; else pre[i]=0;
		if(s[i]=='B'&&s[i+1]=='C')
		{
			ans+=pre[i-1];
			pre[i]=pre[i-1]-1;
			pre[i+1]=pre[i-1]; i++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3840
#include <iostream>

using namespace std;

int a, b;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> a >> b;
	if ((a * b) & 1)
		cout << "Odd" << endl;
	else cout << "Even" << endl;

	return 0;
}

Measured memory_bytes: 256