akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pi pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define in1(x) int x; cin>>x;
#define in2(x, y) int x, y; cin>>x>>y;
#define in3(x, y, z) int x, y, z; cin>>x>>y>>z;
#define in4(x, y, z, w) int x, y, z, w; cin>>x>>y>>z>>w;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;

//bool primes[1000001];vi prime;
//void seive(){memset(primes, true, sizeof(primes));primes[0] = primes[1] = false;for(int i = 2; i*i<=1000000;i += 1){
//if(primes[i]){for(int j = i*i; j <= 1000000;j += i) primes[j] = false;}}rep(i, 2, 1000001){if(primes[i]) prime.pb(i);}}

//int gcd(int a, int b){return b==0 ? a : gcd(b, a%b);}

int32_t main(void){
	IOS;
	
	in1(k);
	string s;
	cin>>s;
	int n = s.length();
	if(n <= k) cout<<s<<endl;
	else
	{
		rep(i, 0, k) cout<<s[i];
		cout<<"...";
	}
}

Measured memory_bytes: 3656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    
		int[] count = new int[26];
		String x = "";
		
		for (int i = 0; i < count.length; i++) {
			count[i] = 0;
		}
		
		try {
			while ((x = in.readLine()) != null) {
				for (int i = 0; i < x.length(); i++) {
					char c = x.charAt(i);
					if ((c < 'A') || (c > 'z')) continue;
					
					if (c < 'a') {
						count[c - 'A']++;
					} else {
						count[c - 'a']++;
					}
				}
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		for (int i = 0; i < count.length; i++) {
			char c = (char)(i + 'a');
			System.out.println(c + " : " + count[i]);
		}
	}
}

Measured memory_bytes: 24152
#include <bits/stdc++.h>
using namespace std;
int adddig(int num)
{
    int m = 0;
    while (num > 0)
    {
        m += num % 10;
        num /= 10;
    }
    return m;
}
int main()
{
    int n;
    cin >> n;
    int f = adddig(n);
    if (n % f == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
 public static void main(String[] args){
  int i = 1;
  Scanner sc = new Scanner(System.in);
  while(true){
   int x = sc.nextInt();
   if ( !( x == 0)  ){
    System.out.println("Case " + i + ": " + x);
    i++;
   }else{
    break;
   }
  }
 }
}


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

using namespace std;
typedef long long ll;
 
ll digits(ll n){
    ll sum = 0;
    while(n != 0){
        sum += n % 10;
        n /= 10;
    }
    return sum ;
}
ll ans;
int main(){
    ll n,a,b;
    cin>>n>>a >>b;
    for(ll i = 1; i <= n; i++){
        if(digits(i) >= a && digits(i) <= b){
            ans += i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

void solve()
{
	ll n,k,ans=1e9;
	cin>>n>>k;
	ll a[k+1];
	for(ll i=0;i<k;i++) cin>>a[i];
	sort(a,a+k);
	for(ll i=0;i<k;i++)
	{
		if(i==k-1)  ans=min(ans,n-(a[(i+1)%k]+(n-a[i])));
		else ans=min(ans,n-abs(a[(i+1)%k]-a[i]));
	}
	cout<<ans;
}

int main() 
{
	FAST
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++) solve();
	return 0;
}

Measured memory_bytes: 1792
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int a, b;
	cin >> a >> b;

	for(int i = (b * 10); i < ((b + 1) * 10); i++) {
		if((i * 8) / 100 == a) {
			cout << i << '\n';
			return 0;
		}
	}

	cout << -1 << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll f[110][15],p[110][15];
int main(){
    ll n,x=-1e9;
    cin>>n;
    rep(i,0,n){rep(j,0,10)cin>>f[i][j];}
    rep(i,0,n){rep(j,0,11)cin>>p[i][j];}

    for(int mask = 1; mask < (1 << 10); mask++){
      ll ans=0;
      rep(i,0,n){
        ll k=0;
        rep(j,0,10){
          if(mask&(1<<j)&&f[i][j])k++;
        }
        ans+=p[i][k];
      }
      x=max(x,ans);
      //cout<<ans<<" "<<mask<<endl;
    }
  cout<<x;
}

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

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(std::string S){
  ll ans = 0;
  for(int i=0; i<S.size()/2; i++) {
    if(S[i]!=S[S.size()-(i+1)])
      ans++;
  }
  std::cout << ans << std::endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main(){
  int K;
  char S[10010];
  char ans[10010];
  char dot[]  = "..." ;
  scanf("%d", &K);
  scanf("%s",S);
  
  strncpy(ans, S, K);
  strcat(ans, dot);
  int len = strlen(S);
  if(len <= K){
    printf("%s\n", S);
  }else {
     printf("%s\n", ans);
  }
  //printf("%d", len);
return 0;
}

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

#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;

typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> mat;

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

vi ans, cost;
vector<vi> tree;
int n, q, sum = 0;

void dfs(int c, int root) {
  ans[c] = ans[root] + cost[c];
  if (tree[c].empty()) {
    sum = 0;
  } else {
    int k = tree[c].size();
    rep(i, 0, k) { dfs(tree[c][i], c); }
  }
}

void solve() {
  cin >> n >> q;

  tree.resize(n + 1);
  ans.resize(n + 1);
  cost.resize(n + 1);

  rep(i, 0, n - 1) {
    int a, b;
    cin >> a >> b;
    tree[a].pb(b);
  }
  rep(i, 0, q) {
    int p, x;
    cin >> p >> x;
    cost[p] += x;
  }
  cost[0] = 0;

  dfs(1, 0);
  rep(i, 1, n + 1) { cout << ans[i] << ' '; }
  cout << endl;
}

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

  // cout << fixed << setprecision(10);

  solve();

  return 0;
}


Measured memory_bytes: 25856
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
#define _for(i,a,b) for(int i = (a);i<(b);i++)
#define endl  '\n'
using namespace std;
const int mod=1e9+7;
const int MAX=1e6+7;
// ll a[MAX];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0), cout.tie(0);
   char c;
   cin>>c;
   if(c>='A'&&c<='Z')cout<<'A';
   else cout<<'a'; 
   
    return 0;
}


Measured memory_bytes: 3632
n = int(input())
arr = list(map(int, input().split()))
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if arr[i] != arr[j] and arr[i] != arr[k] and arr[j] != arr[k]:
                if (arr[i] + arr[j]) > arr[k] and (arr[i] + arr[k]) > arr[j] and (arr[j] + arr[k]) > arr[i]:
                    ans += 1
print(ans)


Measured memory_bytes: 9124
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <vector>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
typedef  long long ll;
const int maxn=1e5+50;
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
const int HASH=131;


int main()
{
    int t;
    cin>>t;
    if(t==0) printf("1\n");
    else printf("0\n");
    return 0;
}


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

typedef long long ll;
const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main() {
  ll x, y;
  cin >> x >> y;
  if ((x + y) % 3) {
    puts("0");
    return 0;
  }
  int n = (x + y) / 3;
  x -= n, y -= n;
  if (x < 0 || y < 0) {
    puts("0");
    return 0;
  }
  combination c(x + y);
  mint ans = c(x + y, x);
  cout << ans.x << endl;

  return 0;
}


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

const int maxn = 15;

int main()
{
    char str[maxn];
    while(scanf("%s",str) != EOF)
    {
        int len = strlen(str);
        int n = 1 << (len - 1);
        long long ans = 0;
        for(int i = 0;i < n;i++)
        {
            long long t = str[0] - '0';
            for(int j = 0;j < n;j++)
            {
                if(j == len - 1 || i & 1 << j)
                {
                    ans += t;
                    t = 0;
                    if(j == len - 1)
                        break;
                }
                t *= 10;
                t += str[j + 1] - '0';
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i<N; i++)
#define RVROOP(i, N) for(int i=N; i>=0; i--)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  int N, M; cin>>N>>M;
  vector<vector<int>> vec(M);
  for(int i=0; i<M; i++){
    int k; cin>>k;
    vec[i].resize(k);
    for(int j=0; j<k; j++){
      cin>>vec[i][j];
      vec[i][j]--;
    }
  }
  vector<int> p(M);
  for(int i=0; i<M; i++){
    cin>>p[i];
  }
  int ans=0;
  for (int i = 0; i < (1 << N); i++) {
    bool ok=true;
    for(int j=0; j<M; j++){
      int c=0;
      for(int id : vec[j]){
        if((i >> id) & 1){
          c++;
        }
      }
      c%=2;
      if(c!=p[j]){
        ok=0;
        break;
      }
    }
    if(ok){
      ans++;
    }
  }
  cout<<ans<<endl;
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int x, a;
    cin >> x >> a;
    cout << (x < a ? 0 : 10) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main() {
	while(1) {
		int n, t_total, h_total, min, flag;
		int t[201], h[201];
		t_total = 0;
		h_total = 0;
		for(int i = 0; i < 201; i++) {
			t[i] = 0;
			h[i] = 0;
		}
		cin >> n;
		if(n == 0) {
			break;
		}
		for(int i = 0; i < n; i++) {
			int num;
			cin >> num;
			t_total += num;
			t[num]++;
		}
		for(int i = 1; i <= 2 * n; i++) {
			if(t[i] == 0) {
				h_total += i;
				h[i]++;
			}
		}
		min = 0;
		flag = 0;
		while((t_total != 0)&&(h_total != 0)) {
			if(flag == 1) {
				for(int i = min; i <= 2 * n; i++) {
					if((min == 0)&&(h[i] == 1)) {
						min = i;
						h[i] = 0;
						h_total -= i;
						flag = 0;
						break;
					} else if((h[i] == 1)&&(min < i)) {
						min = i;
						h[i] = 0;
						h_total -= i;
						flag = 0;
						break;
					}
				}
				if(flag == 1) {
					flag = 0;
					min = 0;
				}
			} else {
				for(int i = min; i <= 2 * n; i++) {
					if((min == 0)&&(t[i] == 1)) {
						min = i;
						t[i] = 0;
						t_total -= i;
						flag = 1;
						break;
					} else if((t[i] == 1)&&(min < i)) {
						min = i;
						t[i] = 0;
						t_total -= i;
						flag = 1;
						break;
					}
					if(flag == 0) {
						flag = 1;
						min = 0;
					}
				}
			}
		}
		int tp = 0, hp = 0;
		for(int i = 0; i <= 2 * n; i++) {
			hp += t[i];
			tp += h[i];
		}
		cout << tp << endl;
		cout << hp << endl;
	}


	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <string.h>
char S[4]={};
int main(){
	scanf("%s",S);
  	int len=strlen(S);
  	if(len==2) printf("%s",S);
  	else if(len==3) printf("%c%c%c",S[2],S[1],S[0]);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>

typedef struct {
	int a;
	int b;
	int abBetween;

	double c;
	double length;
	double height;
	double area;
} Triangle;

void InputTriangle(Triangle* tri);
void GetUnknown(Triangle* tri);
void GetLength(Triangle* tri);
void GetHeight(Triangle* tri);
void GetArea(Triangle* tri);

double DegToRad(int deg);
double DegSin(int deg);
double DegCos(int deg);

int main(void) {
	Triangle tri;

	InputTriangle(&tri);

	GetUnknown(&tri);
	GetLength(&tri);
	GetHeight(&tri);
	GetArea(&tri);

	printf("%lf\n", tri.area);
	printf("%lf\n", tri.length);
	printf("%lf\n", tri.height);
}

void InputTriangle(Triangle* tri) {
	int a;
	int b;
	int abBetween;
	do {
		scanf("%d %d %d", &a, &b, &abBetween);
	} while(
			(a < 0) ||
			(b < 0) ||
			(abBetween <0 || abBetween > 180)
	);

	tri->a = a;
	tri->b = b;
	tri->abBetween = abBetween;
}

void GetUnknown(Triangle* tri) {
	double c = 0;

	c += (tri->a) * (tri->a);
	c += (tri->b) * (tri->b);
	c -= 2 * (tri->a) * (tri->b) * DegCos(tri->abBetween);

	tri->c = sqrt(c);
}

void GetLength(Triangle* tri) {
	tri->length = tri->a + tri->b + tri->c;
}

void GetHeight(Triangle* tri) {
	tri->height = tri->b * DegSin(tri->abBetween);
}

void GetArea(Triangle* tri) {
	tri->area = tri->a * tri->height * 0.5;
}

double DegToRad(int deg) {
	double rad;
	const double PI = acos(-1);

	rad = (deg * PI) / 180;
	return rad;
}

double DegSin(int deg) {
	return sin(DegToRad(deg));
}

double DegCos(int deg) {
	return cos(DegToRad(deg));
}


Measured memory_bytes: 2072
using System;
 
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
      int[] groupA={1,3,5,7,8,10,12};
      int[] groupB={4,6,9,11};
      string[] str=Console.ReadLine().Split(' ');
      int x=int.Parse(str[0]);
      int y=int.Parse(str[1]);
      int flgB=0;
      int flgAns=0;
      for(int i=0;i<=3;i++){
        if(x==groupB[i]){
          flgB=1;
          break;
        }else if((x==2)||(y==2)){
          flgAns=1;
          break;
        }
      }
      
    if(flgB==1){
       for(int i=0;i<=6;i++){
        if(y==groupA[i]){
          flgAns=1;
          break;
        }
      }
    }else{
        for(int i=0;i<=3;i++){
        if(y==groupB[i]){
          flgAns=1;
          break;
        }
        }
    }
    if(flgAns==0)
    {Console.WriteLine("Yes");
    }else{
      Console.WriteLine("No");
    }   
  }
  }
}

Measured memory_bytes: 11092
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define endl '\n'
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

int N, C;
int a[32], b[32];
int dp[32][1 << 17];

signed main()
{
    cin.tie(nullptr); ios::sync_with_stdio(false);
    while(cin >> N >> C, N && C) {
        memset(a, 0, sizeof(a));
        memset(b, 0, sizeof(b));

        for (int i = 0; i < N; ++i) {
            for (int k = 0; k < 16; ++k) {
                int n; cin >> n;
                a[i] |= (n << k);
            }
        }
        for (int i = 0; i < C; ++i) {
            for (int k = 0; k < 16; ++k) {
                int n; cin >> n;
                b[i] |= (n << k);
            }
        }

        memset(dp, ~INF, sizeof(dp));
        dp[0][0] = 0;
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < (1 << 16); ++j) {
                const int tmp = j | a[i];
                chmax(dp[i+1][tmp], dp[i][j]);

                for (int k = 0; k < C; ++k) {
                    const int pushed = (tmp & ~(tmp & b[k]));
                    chmax(dp[i+1][pushed], dp[i][j] + __builtin_popcount(tmp & b[k]));
                }
            }
        }
        cout << *max_element(begin(dp[N]), end(dp[N])) << endl;
    }

    return 0;
}



Measured memory_bytes: 19588
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include <math.h>
using namespace std;

int main()
{
    int X, num;
    cin >> X;
    num = X / 100;
    if(X > (num * 105)) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}
 

Measured memory_bytes: 256
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
//dp[i]=max(dp[i-1],dp[j](1<=j<i)+a[i])
int n,treen;
LL seg_tree[200000*8];
LL dp[200000+10]; 
int h[200000+10],a[200000+10];
LL query(int now,int l,int r,int a,int b){
	if(l>=a&&r<=b){
		return seg_tree[now];
	}
	if(l>=b||r<=a){
		return -INF;
	}
	int mid=(l+r)>>1;
	return max(query(now<<1,l,mid,a,b),query((now<<1)+1,mid,r,a,b));
}
LL maxi(int l,int r){
	if(l==r) return 0;
	return query(1,1,treen+1,l,r);
}
void change(int pos,LL val){
	pos+=treen-1;
	seg_tree[pos]=val;
	pos>>=1;
	while(pos){
		seg_tree[pos]=max(seg_tree[pos<<1],seg_tree[(pos<<1)+1]);
		pos>>=1;
	}
}
int main(){
	scanf("%d",&n);
	rb(i,1,n)
		scanf("%d",&h[i]);
	rb(i,1,n)
		scanf("%d",&a[i]); 
	treen=int(ceil(log2(double(n))));
	treen=1<<treen;
	LL res=0;
	rb(i,1,n){
		dp[i]=maxi(1,h[i])+(LL)(a[i]),change(h[i],dp[i]),res=max(res,dp[i]);
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 8448
function main()
    s = readline() |> chomp
    a = zeros(Int, 26)
    for c in s
        a[c - 'A' + 1] += 1
    end
    ans = "Yes"
    for v in a
        if v != 2 && v != 0
            ans = "No"
        end
    end
    println(ans)
end

main()

Measured memory_bytes: 109552
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	string S;
	cin >> S;
	vector< vector< int > > dp(N + 1, vector< int >(N, 0));
	dp[0][0] = 1;
	vector< vector< int > > sum(N + 1, vector< int >(N + 1, 0));
	rep(j, N + 1) sum[0][j] = 1;
	rep(i, N) rep(j, N - i) {
		if (i == 0)
			dp[i + 1][j] = 1;
		else {
			if (S[i - 1] == '<') {
				(dp[i + 1][j] = sum[i][j + 1]);
			} else {
				if (N - (i - 1) >= j + 1)
					dp[i + 1][j] = (sum[i][N - (i - 1)] - sum[i][j + 1] + MOD) % MOD;
			}
		}
		(sum[i + 1][j + 1] += (sum[i + 1][j] + dp[i + 1][j]) % MOD) %= MOD;
	}
	//cout << dp << endl;
	//cout << sum << endl;
	cout << dp[N][0] << endl;
	return 0;
}

Measured memory_bytes: 141184
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mod 1000000000
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pi 3.14159
ll power(ll a,int n){
  if(n==0)
    return 1;
  if((n%2)==0)
    return power(a*a,n/2);
  else
    return a*power(a*a,n/2);    
}
vector<bool> mark;
void seive(ll N){
    mark.resize(N+1);
  for(ll i=2;i*i<=N;i++){
    if(!mark[i]){
       for(ll j=i*i;j<=N;j+=i){
         mark[j]=1;
       }
      }
  }
}
//vector<int> a1(150002),a2(150002);
int main(){
FASTIO
ll a,b,c,k;
cin>>a>>b>>c>>k;
ll ans=0;
ans+=min(a,k);
if(a<k){
  k-=a;
  k-=b;
  if(k>0){
    ans-=min(c,k);
  }
}
cout<<ans;
return 0;
}


Measured memory_bytes: 3656
#include <iostream>//約数だけ考えればよいですね。O(sqrt(n))で解けます。
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <complex>
#define INF 1000
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main() {
	int n, m,ans=0;
	cin >> n >> m;
	
	vector<int> num(n,0),check(n,0);
	if (n > 1)	num[0] = 1;
	else num[0] = 0;
	rep(i, m) {
		int s, c;
		cin >> s >> c;
		if (check[s - 1] == 0) {
			num[s - 1] = c;
			check[s - 1] = 1;
		}
		else if(num[s-1]!=c){
			cout << -1 << endl;
			return 0;
		}
	}
	if (n > 1 && num[0] == 0) {
		cout << -1 << endl;
		return 0;
	}
	rep(i, n)ans = ans * 10 + num[i];
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7
N = gets.to_i
T = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
H = Array.new(N, -1)

H[0] = T[0]

if H[-1] != -1 && H[-1] != A[-1]
  puts 0
  exit
end

H[-1] = A[-1]

1.upto(N - 1) do |i|
  if T[i - 1] < T[i]
    if H[i] != -1 && H[i] != T[i]
      puts 0
      exit
    end

    if T[i] > A[i]
      puts 0
      exit
    end

    H[i] = T[i]
  end
end

(N - 2).downto(0) do |i|
  if A[i] > A[i + 1]
    if H[i] != -1 && H[i] != A[i]
      puts 0
      exit
    end

    if A[i] > T[i]
      puts 0
      exit
    end

    H[i] = A[i]
  end
end

ans = 1

T.zip(A).each_with_index do |(t, a), i|
  next if H[i] != -1

  ans = ans * [t, a].min % MOD
end

puts ans


Measured memory_bytes: 21148
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;

inline int gcd(int x,int y)
{
	while(y)
	{
		int k=x%y;
		x=y; y=k;
	}
	return x;
}

int main()
{
	int n,x;
	scanf("%d %d",&n,&x);
	int ans,y;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&y);
		if(i==1)
			ans=abs(x-y);
		else
			ans=gcd(ans,abs(x-y));
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(){
	int n;
	cin>>n;
	int t[n];
	int sum=0;
	REP(i,n){
		cin>>t[i];
		sum+=t[i];
	}
	
	int m;
	cin>>m;
	REP(i,m){
		int p,x;
		cin>>p>>x;
		
		cout<<sum-t[p-1]+x<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register
#define int long long
using namespace std;

inline int read(){
	re int ans = 0;re bool f = 1;re char ch = getchar();
	while(ch<'0'||ch>'9'){if (ch=='-')f = 0;ch = getchar();}
	while(ch>='0'&&ch<='9'){
		ans = (ans<<3)+(ans<<1)+(ch^48);
		ch = getchar();
	}
	return f?ans:~(ans-1);
}
int mp[256][256];
int ggcd(int a,int b){
	return b==0?a:ggcd(b,a%b);
}
signed main(void){
	for(re int i=1;i<=212;++i){
		for(re int j=1;j<=212;++j){
			mp[i][j] = ggcd(i,j);
		}
	}
	int k = read();
	int ans = 0;
	for(re int i=1;i<=k;++i){
		for(re int j=1;j<=k;++j){
			for(re int h=1;h<=k;++h){
				ans+=mp[i][mp[j][h]];
				/*cout<<mp[i][mp[j][h]]<<' ';*/
				/*cout<<ans<<' ';*/
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4188
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : map(int, stdin.readline().split())

def main():
  n = ni()
  a = list(na())
  d = {}
  for i, a in enumerate(a):
    d[a] = i+1
  res = []
  for i in range(n):
    res.append(d[i+1])
  print(*res)

main()

Measured memory_bytes: 20452
#include<bits/stdc++.h>
using namespace std;
int main(){
	int h,w;cin>>h>>w;
  vector<vector<char > >mat(h,vector<char >(w,'.'));
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)cin>>mat[i][j];
  for(int i=0;i<h;i++){
  if(i==0){for(int l=0;l<w+2;l++)cout<<'#';cout<<'\n';}
  cout<<'#';
  	for(int j=0;j<w;j++)
    cout<<mat[i][j];
  cout<<"#\n";
  if(i==h-1){for(int l=0;l<w+2;l++)cout<<'#';cout<<'\n';}

  }
}

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

int main(){
  int i,j,cnt=0;
  string s;
  cin>>s;
  int n=s.size();
  for(i=0;i<=(n-1)/2;i++){
    if(i!=n-1-i && s[i]!=s[n-1-i])cnt++;
  }
  cout<<cnt;
}

Measured memory_bytes: 256
#include <stdio.h>
struct TREE{
  int parent;
  int left;
  int right;
};
struct TREE tree[25];
void Preorder(int node){
  printf(" %d",node);
  if(tree[node].left!=-1)
    Preorder(tree[node].left);
   if(tree[node].right!=-1)
    Preorder(tree[node].right);
}
void Inorder (int node){
  if(tree[node].left!=-1)
    Inorder(tree[node].left);
  printf(" %d",node);
  if(tree[node].right!=-1)
    Inorder(tree[node].right); 
}
void Postorder (int node){
  if(tree[node].left!=-1)
    Postorder(tree[node].left);
  if(tree[node].right!=-1)
    Postorder(tree[node].right);
  printf(" %d",node);
}
int main(){
  int i;
  int n;
  int m,l,r;
   scanf("%d",&n);
  for(i=0;i<n;i++){
    tree[i].parent=-1;
    tree[i].left=-1;
    tree[i].right=-1;
  }
 
  for(i=0;i<n;i++) {
    scanf("%d %d %d",&m,&l,&r);
    tree[m].left=l;
    tree[m].right=r;
    if(l!=-1)
    tree[l].parent=m;
    if(r!=-1)
    tree[r].parent=m;
  }
  for(i=0;i<n;i++){
    if(tree[i].parent==-1)
    break;
    //printf("node%d parent%d left%d right%d\n",i,tree[i].parent,tree[i].left,tree[i].right);
  }
  
  printf("Preorder\n");
  Preorder(i);
  printf("\n");
  printf("Inorder\n");
  Inorder(i);
  printf("\n");
  printf("Postorder\n");
  Postorder(i);
  printf("\n");
  return 0;
}

Measured memory_bytes: 616
#include <iostream>
#include <algorithm>
#include <string>
#include <cctype>
using namespace std;
int main()
{
    while(1)
    {
            string t;
            cin >> t;
            if(t == "-")
            {
                return 0;
            }
            int m ;
            cin >> m;
            for(int i = 0;i < m;i++)
            {
                int h;
                cin >> h;
                string u = t.substr(0,h);
                t.erase(t.begin(),t.begin() + h);
                t += u;
            }
            cout << t << endl;
    }
}

Measured memory_bytes: 1232
N = int(input())
a = []
for i in range(N):
  a.append(input())
a = sorted(a)
count = 0
count_list=[]
b = []
for i,k in enumerate(a):
  if i == 0:
    continue
  if k == a[i-1]:
    count+=1
  else:
    count_list.append(count)
    b.append(a[i-1])
    count = 0
  if i==N-1:
    count_list.append(count)
    b.append(a[i])
maxi = 0
maxi_list =[]
for i,k in enumerate(count_list):
  if maxi <k:
    maxi_list.clear()
    maxi_list.append(b[i])
    maxi = k
  elif maxi == k:
    maxi_list.append(b[i])
  else:
    continue
for i in maxi_list:
  print(i)
    
         


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


li num_b[200100];


int main() {
    string s;
    cin >> s;
    li n = sz(s);

    li res = 0;
    li numb = 0;
    rin{
        if (s[i] == 'W') {
            res += numb;
        } else{
            numb++;
        }
    }
    cout << res << endl;


    return 0;
}

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

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

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

	int count=0;
	for (int i = 0; i < s.size(); ++i){
		if(s[i]=='0')
			count++;
	}

	int n=s.size()-count;
	int mm=min(count,n);
	cout<<mm*2<<endl;

}

Measured memory_bytes: 512
N = int(input())


ans = N
for i in range(N+1):
    cc = 0
    t = i
    while t > 0:
        cc += t % 6
        t //= 6

    t = N-i
    while t > 0:
        cc += t % 9
        t //= 9

    if ans > cc:
        ans = cc

print(ans)


Measured memory_bytes: 2940
s = input()
t = input()

ss,tt = sorted(s),sorted(t,reverse=True)
for i in range(min(len(ss),len(tt))):
    if ss[i] < tt[i]:
        print("Yes")
        break
    elif ss[i] > tt[i]:
        print("No")
        break
else:
    if len(tt) <= len(ss):
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define SZ(c)       int(c.size())
#define FOR(i,a,b)  for (int i=a; i<(b); ++i)
#define DOWN(i,a,b) for (int i=(a)-1; i>=(b); --i)
using namespace std;
using i64 = long long;

const int MAXN=100010;

int n,m;
int a[MAXN];
vector<int> adj[MAXN];
int cc;
int c[MAXN];
multiset<int> s[MAXN];

void dfs(int v) {
  c[v]=cc;
  for (int u:adj[v]) if (c[u]==-1) { dfs(u); }
}

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

  cin>>n>>m;
  FOR(i,0,n) cin>>a[i];
  FOR(i,0,m) {
    int x,y;
    cin>>x>>y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }

  memset(c,~0,sizeof(c));
  FOR(i,0,n) {
    if (c[i]==-1) {
      cc+=1;
      dfs(i);
    }
  }


  FOR(i,0,n) { s[c[i]].insert(a[i]); }

  vector<int> d;
  FOR(i,1,cc+1) { d.push_back(i); }
  sort(d.begin(), d.end(), [](int x,int y) {
    return SZ(s[x])>SZ(s[y]);
  });

  int k=d[0];
  i64 res=0;
  FOR(i,1,SZ(d)) {
    int j=d[i];
    assert(!s[j].empty());
    if (s[k].empty()) {
      cout<<"Impossible"<<endl;
      return 0;
    }

    res += *s[j].begin() + *s[k].begin();

    s[j].erase(s[j].begin());
    s[k].erase(s[k].begin());
    for (int x:s[j]) { s[k].insert(x); }
  }

  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 16256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i, n) for(ll i=(ll)(n-1);i>=0;i--)
#define FOR(i, a, b) for(ll i=(ll)(a); i<=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a);i>=(ll)(b); i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main()
{
	REP(i, 5){
		int x;
		cin >> x;
		if(x == 0){
			cout << i+1;
		}
	}
	cout << endl;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define int long long 
//けんちょん写経


const int MOD = 1e9+7;
int num[1100000];
int dp[110][1100000];
int sum[1100000];

signed main(void){ 
  
  int N,K; cin >> N >> K;
  
  int m = 0;
  for(int i = 1; i <= N; ){ 
    int j = N/i; 
    if( i <= j ){ num[m] = 1; i++; m++;}
    else{ num[m] = (N/j-i+1)%MOD; i = N/j+1; m++;} 
  }
  
  //ここまでおk
  dp[0][0] = 1;
  
  for(int i = 0; i < K; i++){  
    memset(sum,0,sizeof(sum));
    for(int l = 0; l <= m; l++){ sum[l+1] = (sum[l]+dp[i][l])%MOD;}
    for(int j = 0; j < m; j++){ 
      dp[i+1][j] = (sum[m-j]*num[j])%MOD;
    }
  }
  
  int ans = 0;
  
  for(int i = 0; i <= m; i++){ ans += dp[K][i]; ans %= MOD;}
  
  cout << ans << endl;
  
  return 0;
} 
    
  
  

Measured memory_bytes: 268544
//MD. HASNAIN ALI (UNSOLVED)
#include <iostream>
#include <stddef.h>

#define ll long long
#define pii pair<int,int>

#define distance(a,b) (sq(a.x-b.x) + sq(a.y-b.y))
#define MAX3(a,b,c) max(a,max(b,c))
#define SQ(x) ((x) * (x))
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define end "\n";



using namespace std;

int main()
{
    int x,n,i,a,b,c,d=1;
    cin>>x>>n;
    int p[n];
    for(i=0;i<n;i++)
    {
        cin>>p[i];
    }
    if(n==0) cout<<x<<endl;
    else
    {
        for(i=0;i<n;i++)
        {
            if(p[i]==x) d=0;
        }
        if(d){
            cout<<x<<endl;
            goto A;
        }
        a=x;
        b=x;
        while(1)
        {
            a=a-1;
            c=1;
            for(i=0;i<n;i++)
            {
                if(p[i]==a)
                {
                    c=0;
                    break;
                }
            }
            if(c)
            {
                cout<<a<<endl;
                break;
            }
            b=b+1;
            c=1;
            for(i=0;i<n;i++)
            {
                if(p[i]==b)
                {
                    c=0;
                    break;
                }
            }
            if(c)
            {
                cout<<b<<endl;
                break;
            }
        }
    }
    A:

    return 0;
}


Measured memory_bytes: 3620
N, M = map(int,input().split())
KS = [list(map(int,input().split())) for _ in range(M)]
P = list(map(int,input().split()))

ans = 0
for i in range(1 << N):
  tmp = 1
  for j, b in enumerate(KS):
    if sum([1 for bb in b[1:] if (i >> (bb - 1)) & 1 == 1])%2 != P[j]:
      tmp = 0
      break
  if tmp:
    ans += 1
print(ans)

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

int main()
{
	ll N, A, B;
	cin >> N >> A >> B;
	if (A > N || B > N) {
		cout << -1 << endl;
		return 0;
	}
	if (N + 1 < A + B) {
		cout << -1 << endl;
		return 0;
	}
	if (N + 1 == A + B) {
		vector<int> res(N);
		for (int i = 0; i < A; i++) {
			res[i] = B + i;
		}
		for (int i = 0; i < B - 1; i++) {
			res[A + i] = B - 1 - i;
		}
		for (int i = 0; i < N; i++) {
			cout << res[i] << " \n"[i + 1 == N];
		}
		return 0;
	}
	bool flag = false;
	if (A > B) swap(A, B), flag = true;
	if (A == 1 && B != N - 1) {
		if (B != N - 1) {
			cout << -1 << endl;
			return 0;
		}
		vector<int> res(N);
		for (int i = 0; i < N; i++) {
			res[i] = N - i;
		}
		if (flag) reverse(res.begin(), res.end());
		for (int i = 0; i < N; i++) {
			cout << res[i] << " \n"[i + 1 == N];
		}
		return 0;
	}
	if (A + B - 1 <= N && N <= A * B) {
		vector<int> res(N);
		for (int i = 0; i < A; i++) {
			res[i] = N - A + i + 1;
		}
		vector<int> sp(B - 1);
		for (int i = 0; i < B - 1; i++) {
			sp[i] = (N - A + i) / (B - 1);
		}
		int sum = A;
		for (int i = 0; i < B - 1; i++) {
			sum += sp[i];
		}
		assert(sum == N);
		int tmp = N - A, pos = A;
		for (int i = 0; i < B - 1; i++) {
			for (int j = 0; j < sp[i]; j++) {
				res[pos++] = tmp - sp[i] + j + 1;
			}
			tmp -= sp[i];
		}
		if (flag) reverse(res.begin(), res.end());
		for (int i = 0; i < N; i++) {
			cout << res[i] << " \n"[i + 1 == N];
		}
		return 0;
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 3968
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

const int mod = 998244353;

inline void add(int &a, int b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}

inline int mul(int a, int b) {
  return (int)((long long)a * b % mod);
}

const int N = 309;

int a[N];
int f[4][N * N];
int nf[4][N * N];

int main() {
  int n;
  scanf("%d", &n);
  int tot = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    tot += a[i];
  }
  memset(f, 0, sizeof f);
  f[0][0] = 1;
  for (int i = 0; i < n; ++i) {
    memset(nf, 0, sizeof nf);
    for (int j = 0; j <= tot; ++j) {
      for (int k = 0; k <= 3; ++k) {
        if (f[k][j] == 0) {
          continue;
        }
        if (j + a[i] <= tot) {
          add(nf[k][j + a[i]], f[k][j]);
        }
        add(nf[k | 1][j], f[k][j]);
        add(nf[k | 2][j], f[k][j]);
      }
    }
    memcpy(f, nf, sizeof f);
  }
  int ans = 1;
  for (int i = 0; i < n; ++i) {
    ans = mul(ans, 3);
  }
  add(ans, mod - 3);
  {
    int sub = 1;
    for (int i = 0; i < n; ++i) {
      sub = mul(sub, 2);
    }
    add(sub, mod - 2);
    sub = mul(sub, 3);
    add(ans, mod - sub);
  }
  {
    int sub = 0;
    for (int i = 1; i < tot; ++i) {
      if (tot - i <= i) {
        add(sub, f[3][i]);
      }
    }
    sub = mul(sub, 3);
    add(ans, mod - sub);
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 3328
#include <iostream>
#include <cstdint>
#include <string>
#include <vector>
#include <array>

char next_animal(const char prev_animal, const char curr_animal, const char answer) {
  static std::array<char, 8> pattern = {'S', 'W', 'W', 'S', 'W', 'S', 'S', 'W'};
  return pattern[(prev_animal == 'W' ? 4 : 0) | (curr_animal == 'W' ? 2 : 0) | (answer == 'x' ? 1 : 0)];
}

int main() {
  std::int_fast64_t n;
  std::string s;
  std::cin >> n >> s;

  std::vector<std::vector<char>> possible_patterns(4);
  possible_patterns[0].push_back('S');
  possible_patterns[0].push_back('S');
  possible_patterns[1].push_back('S');
  possible_patterns[1].push_back('W');
  possible_patterns[2].push_back('W');
  possible_patterns[2].push_back('S');
  possible_patterns[3].push_back('W');
  possible_patterns[3].push_back('W');
  for (std::vector<char>& possible_pattern : possible_patterns) {
    for (const char& answer : s) {
      possible_pattern.push_back(next_animal(*(possible_pattern.rbegin() + 1), possible_pattern.back(), answer));
    }
    if (possible_pattern.front() == *(possible_pattern.rbegin() + 1) && *(possible_pattern.begin() + 1) == possible_pattern.back()) {
      std::cout << std::string(possible_pattern.begin() + 1, possible_pattern.end() - 1) << std::endl;
      return 0;
    }
  }
  std::cout << -1 << std::endl;
  return 0;
}

Measured memory_bytes: 1024
S = str(input())
red = int(S[0:2])
blue = int(S[2:4])
if 1<=red<=12:
    if 1<=blue<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1<=blue<=12:
        print("YYMM")
    else:
        print("NA")
    


Measured memory_bytes: 38384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(ll i=(x);i<(y);i++)
#define RREP(i,x,y) for(ll i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(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();}

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class BCommonRaccoonVsMonster {
public:
    void solve(std::istream& in, std::ostream& out) {
        ll H, N;
        in >> H >> N;
        vector<int> A(N);
        REP(i,0,N) in >> A[i];
        REP(i,0,N) H -= A[i];
        out << ((H<=0) ? "Yes" : "No") << "\n";
    }
};


signed main() {
    BCommonRaccoonVsMonster solver;
    std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

using namespace std;
typedef long long ll;
const int MAXN = 1000100;

int H, W;
int N;
int arr[MAXN];
int res[110][110];

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

    cin >> H >> W >> N;
    for (int i = 0; i < N; i++)
        cin >> arr[i];

    int cloc = 0;
    for (int i = 0; i < H; i++)
        for (int j = 0; j < W; j++)
        {
            int cj = j;
            if (i % 2) cj = (W - 1 - j);
            res[i][cj] = cloc;
            arr[cloc]--;
            if (!arr[cloc]) cloc++;
        }

    for (int i = 0; i < H; i++)
    {
        for (int j =0 ; j < W; j++)
            cout << res[i][j] + 1 << " ";
        cout << "\n";
    }
}

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(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 MIN(x) *min_element(ALL(x)) //最小値を求める

#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)

#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(void)
{
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,n) cin >> a.at(i);
    FORD(i,n - 1, 1) cout << a.at(i) << ' ';
    cout << a.at(0) << endl;
    return 0;
}



Measured memory_bytes: 3088
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop

import collections

a = int(input())
b = int(input())
c = int(input())
d = int(input())
ac = a + c
ad = a + d
bc = b + c
bd = b + d
ans = min(ac,ad)
ans = min(ans,bc)
ans = min(ans,bd)
print(ans)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string A,B;
  cin >> A >> B;
  if(A.at(0)==B.at(0))
    cout << "=" << endl;
  else if(A.at(0)<B.at(0))
    cout << "<" << endl;
  else if(A.at(0)>B.at(0))
    cout << ">" << endl;                                                                         
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>
#include<functional>

using namespace std;

int n, k;
int dis[100];
bool f = false;
int nowdis[100];
vector<vector<pair<int,int>>> edge;//to cost

int djk(int start, int end) {
	priority_queue < pair<int, int>, vector < pair<int, int>>, greater<pair<int, int>>> pq;// cost pos
	for (int i = 0; i < n; i++) {
		dis[i] = 100000000;
	}
	pq.push(make_pair(0, start));
	while (pq.size()) {
		pair<int, int> tmp = pq.top();
		pq.pop();
		if (tmp.first < dis[tmp.second]) {
			dis[tmp.second] = tmp.first;
			for (int i = 0; i < edge[tmp.second].size(); i++) {
				pq.push(make_pair(tmp.first + edge[tmp.second][i].second, edge[tmp.second][i].first));
			}
		}
	}
	if (dis[end] == 100000000)return -1;
	return dis[end];
}

int main() {
	while (cin >> n >> k, n * k) {
		edge.resize(n);
		for (int i = 0; i < k; i++) {
			int a;
			cin >> a;
			if (a == 0) {
				int b, c;
				cin >> b >> c;
				cout << djk(b - 1, c - 1) << endl;
			}
			else {
				int b, c, d;
				cin >> b >> c >> d;
				edge[b - 1].push_back(make_pair(c - 1, d));
				edge[c - 1].push_back(make_pair(b - 1, d));
			}
		}
		edge.clear();
	}
	return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

lli n;
vector<lli> a;

lli dp[3010][3010];
bool vis[3010][3010];

lli func(lli left,lli right){
	if(left>right)return 0;
	if(vis[left][right])return dp[left][right];

	vis[left][right] = true;
	lli diff = left + (n-1)-right;

	lli res = INF;
	if(diff % 2==0){
		res *= -1;
		res = max(res,func(left+1,right)+a[left]);
		res = max(res,func(left,right-1)+a[right]);
	}
	else{
		res = min(res,func(left+1,right)-a[left]);
		res = min(res,func(left,right-1)-a[right]);
	}
	vis[left][right]=true;
	return dp[left][right] = res;
}

signed main(){

	cin>>n;
	a.resize(n);
	REP(i,0,n)cin>>a[i];

	cout<<func(0,n-1)<<endl;
	return 0;
}

Measured memory_bytes: 78464