akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int i,n,j,k;
  n=s.size();
    int ans=1;
  
  for(i=0;i<n;i++){
    if(s.at(i)!=s.at(n-1-i))
      ans=0;
  }
 // cout << ans << endl;
  k=(n-1)/2;
  for(i=0;i<k;i++){
    if(s.at(i)!=s.at(k-1-i))
      ans=0;
  }
    //cout << ans << endl;
  k=(n+3)/2;
  j=0;
  while(k<n){
 //   cout << ans << endl;
    j++;
    if(s.at(k-1)!=s.at(n-j)){
      ans=0;
    }
    k++;
    //  cout << ans << endl;
  }
  
  if(ans==1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
void outvi(vi v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
void outvvi(vvi v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
int main(){
    int n;cin>>n;
    ll m=(1<<n);
    S s;
    vi v;
    rep(i,m){
        ll k;cin>>k;
        s.insert(k);
    }
    auto it=s.end();it--;
    v.pb(*it);
    s.erase(it);
    rep(i,n){
        ll k=v.size();
        rep(j,k){
            auto it=s.lower_bound(v[j]);
            if(it==s.begin()){
                cout<<"No"<<endl;
                return 0;
            }
            it--;
            v.pb(*it);
            s.erase(it);
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 15352
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> cont(n);
  
  for(int i = 0 ; i < n ; i++){
    cin >> cont.at(i);
  }
  
  int ans = 0;
  int active = 0;
  
  for(int i = 0 ; i < n ; i++){
    if(active >= cont.at(i)){
      active = cont.at(i);
    }
    else{
      ans += cont.at(i) - active;
      active = cont.at(i);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
#define sup 
int main(){
    ll n,a;
    cin >> n >> a;
    ll x[n];
    ll max = a;
    for(ll i =0;i<n;i++){
        cin >> x[i];
        if(max < x[i]){
            max = x[i];
        }
    }
    ll dp[n+1][n+1][(max+1)*(n+1)];

    for(ll j=0;j<=n;j++){
        for(ll k = 0;k<=max*n;k++){
            dp[0][j][k] = 0;
        }
    }
    dp[0][0][0] = 1;
    
    for(ll i=1;i<=n;i++){
        for(ll j=0;j<=n;j++){
            for(ll k=0;k<=max*n;k++){
                if(k < x[i-1]){
                    dp[i][j][k] = dp[i-1][j][k];
                }
                else if(k-x[i-1] >= 0 && j >= 1){
                    dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i-1]];
                }
                else{
                    dp[i][j][k] = 0;
                }
                //cout << "dp[" << i <<"][" <<j<<"][" << k << "]=" << dp[i][j][k] << endl; 
            }
        }
    }
    ll ans =0;
    for(int j=1;j<=n;j++){
        ans += dp[n][j][j*a];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 53120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

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

    vector<P> xp;
    for(int i=0;i<N;i++){
        int x;
        cin >> x;
        xp.emplace_back(x, i+1);
    }
    sort(xp.begin(), xp.end());

    int used = 0, l = 0;
    vector<int> ans(N * N, -1);
    for(P p : xp){
        if(p.second <= p.first - used){
            ans[p.first-1] = p.second;
            for(int i=0;i<p.second-1;i++){
                assert(l < p.first-1);
                if(ans[l] == -1){
                    ans[l++] = p.second;
                }else{
                    l++;
                    i--;
                }
            }
            used += p.second;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    int k = 0;
    queue<int> que;
    for(int i=0;i<N*N;i++){
        if(k < N && xp[k].first == i+1){
            for(int j=0;j<N-xp[k].second;j++){
                que.push(xp[k].second);
            }
            k++;
        }
        if(ans[i] == -1){
            if(que.size() == 0){
                cout << "No" << endl;
                return 0;
            }
            ans[i] = que.front(); que.pop();
        }
    }
    cout << "Yes" << endl;
    for(int i=0;i<N*N;i++){
        if(i != 0) cout << " ";
        cout << ans[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;

int main()
{
    int n;
    string s;
    while(cin >> s)
    {
        int len=s.size();
        int sum=0;
        for(int i=0;i<len;i++)
            sum+=(s[i]-'0');
        int n=0;
        for(int i=0;i<len;i++)
        {
            n+=((s[i]-'0')*pow(10.0,len-1-i));
        }
        if(n%sum==0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

ll cnt;

int main(){
	ll n,d;
	cin >> n >> d;
	ll x[n];
	ll y[n];
	rep(i,n){
		cin >> x[i] >> y[i];
	}
	rep(i,n){
		if(d*d>=x[i]*x[i]+y[i]*y[i])
			cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 6716
#include <stdio.h>
int main(){

  int n,m,l,front[100][100],back[100][100],i,j,k;
  long long x[100][100]={0};
    
  //scan figure
  scanf("%d %d %d",&n,&m,&l);

  //scan matrix
  for(i = 0; i < n; i++){
    
    for(j = 0; j < m; j++){
      
      scanf("%d",&front[i][j]);
      
    }
    
  }
  
  for(i = 0; i < m; i++){
    
    for(j = 0; j < l; j++){
      
      scanf("%d",&back[i][j]);
      
    }

  }

  //calculate and print
  
  for(i = 0; i < n; i++){
    
    for(j = 0; j < l; j++){
      
      for(k = 0; k < m; k++){
	
	x[i][j] += front[i][k]*back[k][j];
	
      }

      if (j == l-1){

      printf("%lld",x[i][j]);	
      
      } else {

	printf("%lld ",x[i][j]);

      }
      
    }

    printf("\n");
    
  }

  return 0;
  
}




 



Measured memory_bytes: 2108
// A

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};

int main(){
  int N,M,X,Y,x[100],y[100];
  cin>>N>>M>>X>>Y;
  for (int i(0);i<N;i++) cin>>x[i];
  for (int i(0);i<M;i++) cin>>y[i];
  int maxx(x[0]);
  for (int i(0);i<N;i++) {
    maxx = max(maxx,x[i]);
  }
  int miny(y[0]);
  for (int i(0);i<M;i++) {
    miny = min(miny,y[i]);
  }
  if (miny > maxx && maxx < Y && miny > X){
    cout << "No War" << endl;
  }else{
    cout << "War" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
int main(){
    string w;
    map<char, int> mp; 
    cin >> w;
    for(int i=0; i<w.size(); i++){
        mp[w[i]]++;
    }
    for(int i=0; i<w.size(); i++){
        if(mp[w[i]] % 2 != 0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main()
{
  bool prime[1048576];
  memset(prime, true, sizeof(prime));

  prime[0] = prime[1] = false;
  for (int i = 0; i < 1024; ++i){
    if (prime[i]){
      for (int j = i * 2; j <= (1 << 20); j += i){
        prime[j] = false;
      }
    }
  }

  int a, d, n;
  while (cin >> a >> d >> n, n){
    int cnt = 0;
    for (int i = 0; ; i++){
      int k = a + (d * i);
      if (prime[k]) cnt++;
      if (cnt == n){
        cout << k << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 4116
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
const ll INF=100000000000000LL;

int main() {
	int a,b;
	cin>>a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0)cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin >> n;
  ll mi = LINF;
  ll ma = -LINF;
  rep(i,n){
      ll tmp; cin >> tmp;
      mi = min(mi,tmp);
      ma = max(ma,tmp);
  }
  cout << ma - mi << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
int main(void){
  char S[100000];
  scanf("%s", S);
  
  int i;
  int cnt[26];
  int num;
  char c;
  
  i = 0;
  while( S[i] != '\0' ){
    num = S[i] - 'a';
    if( cnt[num] == 0 ){
      cnt[num] = 1;
    }
    i++;
  }

  for( i=0; i<26; i++ ){
    if( cnt[i] == 0 ){
      c = 'a' + i;
      printf("%c\n", c);
      return 0;
    }
  }
  
  printf("None\n");
  return 0;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
#define PI 3.14159265358979323846264338327950L
typedef unsigned long long uint64;
using namespace std;
int main(){
  int n;
  cin >> n;
   int ans = 0;
  for(int i= 1;i<=n;i+=2){
     int dd = 0;
     for (int X=1;X<=i;++X){
       if(i%X==0){
         ++ dd;
       }
     }
     if(dd==8){
       ++ans;
      }
  }
cout << ans << endl;
return 0;
}

Measured memory_bytes: 3620
fun main(args: Array<String>) {
    val kinri:Double = 1.01
    var yokin = 100.0
    val mokuhyo = next().toDouble()
    var years = 0;
    while (yokin < mokuhyo){
        years += 1
        yokin = Math.floor(yokin * kinri)
    }
    println(years)
}
fun nextIntList() = next().split(" ").map{ it.toInt() }
fun next() = readLine()!!

Measured memory_bytes: 34724
import queue
h,w=map(int,input().split())
sy,sx=map(int,input().split())
gy,gx=map(int,input().split())
s=[input() for _ in range(h)]
q=queue.deque([[sy-1,sx-1]])
q2=[[sy-1,sx-1]]
q3=[]
inf=10**7
dist=[[inf for _ in range(w)] for _ in range(h)]
d=[[1,0],[0,1],[-1,0],[0,-1]]
dist[sy-1][sx-1]=0

while q:
    y,x=q.pop()
    for dy,dx in d:
        ny,nx=y+dy,x+dx
        if 0<=ny<h and 0<=nx<w and s[ny][nx]!='#' and dist[ny][nx]==inf:
            dist[ny][nx]=min(dist[y][x],dist[ny][nx])
            q.append([ny,nx])
            q2.append([ny,nx])
    if not q:
        for y,x in q2:
            for dy in range(-2,3):
                for dx in range(-2,3):
                    ny,nx=y+dy,x+dx
                    if 0<=ny<h and 0<=nx<w and s[ny][nx]!='#' and dist[ny][nx]==inf:
                        dist[ny][nx]=min(dist[y][x]+1,dist[ny][nx])
                        q.append([ny,nx])
                        q3.append([ny,nx])
        q2=q3
        q3=[]
print(dist[gy-1][gx-1] if dist[gy-1][gx-1]!=inf else -1)

Measured memory_bytes: 122772
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
using namespace std;

long long f(long long x, long long m){
    return (x *x) % m;
}

int main(){
    long long n, x, m;
    cin >> n >> x >> m;

    set<long long> T;
    long long now = x;
    T.insert(now);
    long long start;
    for(long long i = 0; i < m; i++){
        //printf("i %lld %lld\n", i+1, now);
        now = f(now, m);
        if(T.find(now) == T.end()) T.insert(now);
        else{
            start = now;
            break;
        }
    }

    bool find = false;
    vector<long long> loop;
    long long dist = 0;
    //printf("start %lld\n", start);
    now = x;
    for(long long i = 0; i < m; i++){
        //printf("i %lld %lld\n", i+1, now);
        now = f(now, m);
        if(now == start and find == false){
            //printf("find\n");
            find = true;
            dist = i+1;
        }
        else if(now == start and find == true) break;

        if(find == true){
            loop.push_back(now);
        }
    }
    //printf("dist %lld\n", dist);

    long long fre = 0;
    for(long long i = 0; i < loop.size(); i++) fre += loop[i];

    long long ans = 0;
    if(n <= dist) {
        now = x;
        for(long long i = 0; i < n; i++){
            ans += now;
            now = f(now, m);
        }
    }
    else{
        now = x;
        for(long long i = 0; i < dist; i++){
            ans += now;
            now = f(now, m);
        }
        long long r = (n-dist)/((long long)loop.size());
        long long amari = (n-dist) % ((long long)loop.size());

        ans += fre * r;
        for(long long i = 0; i < amari; i++) ans += loop[i];
    }

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

Measured memory_bytes: 6260
import java.util.Scanner;

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

	int N = scan.nextInt();
	int A = scan.nextInt();
	int B = scan.nextInt();

	if(N*A >= B){
	    System.out.println(B);
	}else{
	    System.out.println(N*A);
	}
    }
}


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

int h,n;
int a[1005],b[1005];
int dp[1005][20005];

int main(){

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

    cin>>h>>n;
    memset(dp,0x3f,sizeof(dp));
    dp[0][0]=0;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        for(int j=0;j<=h+10000;j++){//由于可能伤害不是正好杀死，一定要预留一点伤害的量
            if(j+a[i]<=h+10000)dp[i][j+a[i]]=min(dp[i][j+a[i]],dp[i][j]+b[i]);
            dp[i+1][j]=min(dp[i+1][j],dp[i][j]);//此处为计算方便我正着dp了
        }
    }
    int ans=0x3f3f3f3f;
    for(int i=h;i<=h+10000;i++){
        ans=min(ans,dp[n][i]);
    }
    cout<<ans<<endl;

    return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll a(n);
  map<ll,ll> m;
  rep(i,n){
    cin>>a[i];
    m[a[i]]++;
  }
  ll ans=0;
  for(auto e: m){
    if(e.second<2) continue;
    ans+=(e.second)*(e.second-1)/2;
  }
  rep(i,n){
    if(m[a[i]]>1){
      cout<<ans-(m[a[i]])*(m[a[i]]-1)/2+(m[a[i]]-1)*(m[a[i]]-2)/2<<endl;
    }else{
      cout<<ans<<endl;
    }
  }
}

Measured memory_bytes: 12544
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
const int MOD = 1331;
using namespace std;
const int N = 1e5 + 10;
int n;
int main(){
	cin >> n;
	int ans = 1;
	if (n < 600) ans = 8;
	else if (n < 800) ans = 7;
	else if (n < 1000) ans = 6;
	else if (n < 1200) ans = 5;
	else if (n < 1400) ans = 4;
	else if (n < 1600)ans = 3;
	else if (n < 1800) ans = 2;
	cout << ans << endl;
	return 0;
}

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

int main(){
  int n;
  int t[100005] = {};
  int x[100005] = {};
  int y[100005] = {};
  cin >> n;
  for(int i = 1; i <= n; i++) cin >> t[i] >> x[i] >> y[i];
  for(int i = 1; i <= n; i++){
    int dist = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]);
    int tt = t[i] - t[i-1];
    if(dist > tt || (tt % 2 != dist % 2)){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main(){
        int n,m;
        vector<vector<int>> v;
        vector<int> p;
        vector<int> y;
        char s[13];
        int t;

        scanf("%d %d", &n, &m);
        v.resize(n);
        p.resize(m);
        y.resize(m);
        for (int i = 0; i < m; i++){
                scanf("%d %d", &p[i], &y[i]);
                v[p[i]-1].push_back(y[i]);
        }
        for (int j = 0; j < n; j++){
                sort(v[j].begin(),v[j].end());
        } 
        for (int k = 0; k < m; k++){
              t = lower_bound(v[p[k]-1].begin(),v[p[k]-1].end(),y[k]) - v[p[k]-1].begin()  + 1;
              sprintf(s,"%06d%06d",p[k],t);
              printf("%s\n",s);
        }
        return 0;
}


Measured memory_bytes: 7808
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, M;
    cin >> A >> B >> M;
    ll a[A], b[B];
    ll mina = inf;
    ll minb = inf;
    REP(i, 0, A) {
        cin >> a[i];
        mina = min(mina, a[i]);
    }
    REP(i, 0, B) {
        cin >> b[i];
        minb = min(minb, b[i]);
    }
    ll ans = mina + minb;
    REP(i, 0, M) {
        ll x, y, c;
        cin >> x >> y >> c;
        ll num = a[x - 1] + b[y - 1] - c;
        ans = min(ans, num);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
const int N=1e4+5;
const int MOD=1e9+7;
int a[N];

int b[N];
char s[N];
char t[N];
ll f[N];
int used[15];
int cmp1(ll a,ll b)
{
    return b<a;
}

multiset<int> ss;
map<int,int>mp;
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        if(i*i+1+1+i+i+1>n) {

                break;
        }
        for(int j=1;j<=n;j++){
                if(i*i+j*j+1+i*j+i+1>n) break;
            for(int k=1;k<=n;k++){
                if(i*i+j*j+k*k+i*j+i*k+k*j>n) break;
                a[i*i+j*j+k*k+i*j+i*k+k*j]++;
            }
        }
    }
    for(int i=1;i<=n;i++) cout<<a[i]<<endl;
}


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

int main() {
	int a[5], k;
	int maxA = 0;
	int minA = 1e+9;
	
	int i;
	for (i = 0; i < 5; i++) {
		cin >> a[i];
		maxA = max(maxA, a[i]);
		minA = min(minA, a[i]);
	}
	cin >> k;
	
	if (k >= maxA - minA) { cout << "Yay!" << endl; }
	else { cout << ":(" << endl; }
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


N, P = readnums()
A = map(lambda x: x % 2, readnums())

if P:
    if not sum(A):
        print(0)
    else:
        print(2 ** N // 2)
else:
    if not sum(A):
        print(2 ** N)
    else:
        print(2 ** N // 2)


Measured memory_bytes: 3060
private fun solve() {
    val S = readLine()!!
    val (Q) = readInts()

    val text = java.util.ArrayDeque<Char>(100004)
    S.forEach { text.addLast(it) }

    var reversed = false
    Q.repeat {
        val queue = readLine()!!

        if (queue[0] == '1') {
            reversed = !reversed
        } else {
            val (_t, _f, _c) = queue.split(" ")
            val f = _f.toInt()
            val c = _c[0]

            // xor
            if ((f == 1) != reversed) text.addFirst(c) else text.addLast(c)
        }
    }

    println((if (reversed) text.reversed() else text).joinToString(separator = ""))
}

fun main(args: Array<out String>) = solve()
private fun readAtOnce(): List<String> = readLine()!!.split(" ")
private fun readInts(): List<Int> = readAtOnce().map(String::toInt)
private fun readLongs(): List<Long> = readAtOnce().map(String::toLong)
private fun zeroArray(size: Int): IntArray = IntArray(size) { 0 }
private fun Int.repeat(predicate: (Int) -> Unit) = repeat(this, predicate)

Measured memory_bytes: 78384
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	string s;
	cin >> s;
	map<char, int> mp;
	REP(i, 26)
	{
		mp['a' + i]++;
	}
	REP(i, SIZE(s))
	{
		if (mp.count(s[i]) > 0)
			mp.erase(s[i]);
		if (SIZE(mp) < 1)
		{
			print("None");
			return 0;
		}
	}
	print((*mp.begin()).first);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 512
#include<stdio.h>
#include<map>
using namespace std;

const int maxn = 100001;

int main()
{
    int num;  
    scanf("%d", &num);
    map<int, int> mp;
    for (int i = 0; i < num; i++) {
        int a;
        scanf("%d", &a);
        if (mp.find(a) == mp.end())
            mp[a] = 1;
        else
            mp[a] = 1-mp[a];
    }

    int noc = 0;
    for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++)
        if (it->second == 1)
            noc++;
    printf("%d", noc);

    return 0;
}


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

using namespace std;

int main()
{
    //simple approach by using 3*3 matrix and searching the given elements one by one
    int n,a[3][3],c[3][3],i,j,cnd=0;
    for(i=0;i<3;i++){
        for(j=0;j<3;j++)
            scanf("%d",&a[i][j]);
    }
    scanf("%d",&n);
    int b;
    for(i=0;i<3;i++){
        for(j=0;j<3;j++)
            c[i][j]=0;
    }
    while(n--){
        scanf("%d",&b);
        for(i=0;i<3;i++){
            for(j=0;j<3;j++){
               if(b==a[i][j])
                  c[i][j]=1;
            }
        }
    }

    for(i=0;i<3;i++){
        if(c[i][0]==1&&c[i][1]==1&&c[i][2]==1||c[0][i]==1&&c[1][i]==1&&c[2][i]==1){
          cnd=1;
          break;
        }
    }
    if(cnd==1||c[0][0]==1&&c[1][1]==1&&c[2][2]==1||c[0][2]==1&&c[1][1]==1&&c[2][0]==1) printf("Yes\n");
        else printf("No\n");

}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

typedef long long int ll;
#define REP(i, I, N) for (int i = I; i < N; ++i)
#define rep(i, N) REP(i, 0, N)

char pairCh(char t) {
    if (t == 'A' || t == 'T') {
        return t == 'A' ? 'T' : 'A';
    } else if (t == 'C' || t == 'G') {
        return t == 'C' ? 'G' : 'C';
    }
}

int main() {
    char b;
    scanf("%c", &b);

    printf("%c\n", pairCh(b));
    return 0;
}


Measured memory_bytes: 128
local n = io.read("*n")
local h = {}
for i = 1, n do h[i] = io.read("*n") end
local tasks = {}
local tasknum, done = 0, 0
table.insert(tasks, 1 + n * 101)
tasknum = 1

local function getmin(l, r)
  local min, minpos = h[l], l
  for i = l + 1, r do
    if(h[i] < min) then
      min, minpos = h[i], i
    end
  end
  return min, minpos
end

local tot = 0
local curtask = 0
while(done < tasknum) do
  done = done + 1
  local task = tasks[done]
  local left, right = task % 101, task // 101
  local min, minpos = getmin(left, right)
  for i =left, right do
    h[i] = h[i] - min
  end
  if(left < minpos) then
    tasknum = tasknum + 1
    table.insert(tasks, left + (minpos - 1) * 101)
  end
  if(minpos < right) then
    tasknum = tasknum + 1
    table.insert(tasks, minpos + 1 + right * 101)
  end
  tot = tot + min
end
print(tot)


Measured memory_bytes: 760
import sys
sys.setrecursionlimit(100000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *

mod = 10**9+7
S = input()
N = len(S)
D = [None] * N
t = 1
for i in range(N):
    D[i] = t % 13
    t = t * 10 % 13
dp = [[0] * 13 for i in range(N+1)]
if S[N-1] != '?':
    dp[N-1][int(S[N-1])] = 1
else:
    for i in range(10):
        dp[N-1][i] = 1
for k in range(N-1)[::-1]:
    d = D[N-k-1]
    for m in range(13):
        if S[k] != '?':
            dp[k][m] += dp[k+1][(m-d*int(S[k]))%13]
            dp[k][m] %= mod
        else:
            for i in range(10):
                dp[k][m] += dp[k+1][(m-i*d)%13]
                dp[k][m] %= mod
print(dp[0][5])


Measured memory_bytes: 66852
from collections import defaultdict
import heapq


def dijkstra(N, start, adj_nodes, costs):
    INF = 10**15
    dist = [INF for _ in range(N)]
    dist[start] = 0
    frontier = [(0, start)]
    while len(frontier) > 0:
        d, node = heapq.heappop(frontier)
        for next_node in adj_nodes[node]:
            if dist[next_node] > d + costs[(node, next_node)]:
                dist[next_node] = d + costs[(node, next_node)]
                frontier.append((dist[next_node], next_node))
    return dist


def main():
    N = int(input())
    adj_nodes = defaultdict(list)
    costs = defaultdict(int)
    for _ in range(N - 1):
        a, b, c = list(map(int, input().split(' ')))
        a -= 1
        b -= 1
        adj_nodes[a].append(b)
        adj_nodes[b].append(a)
        costs[(a, b)] = c
        costs[(b, a)] = c
    Q, K = list(map(int, input().split(' ')))
    K -= 1
    queries = [list(map(lambda q: int(q) - 1, input().split(' '))) for _ in range(Q)]
    dist = dijkstra(N, K, adj_nodes, costs)
    for query in queries:
        x, y = query
        print(dist[x] + dist[y])


if __name__ == '__main__':
    main()

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> a(n);
    vector<string> b(m);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < m; i++) cin >> b[i];

    for (int i = 0; i < n-m+1; i++) {
        for (int j = 0; j < n-m+1; j++) {
            
            bool flag = false;
            for (int y = 0; y < m; y++) {
                for (int x = 0; x < m; x++) {
                    if (a.at(i+y).at(j+x) != b.at(y).at(x)) {
                        flag = true;
                        break;
                    }
                }
                if(flag) break;
            }
            if (!flag) {
                cout << "Yes" << endl;
                return 0;
            }

        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3564
s= input()
k = int(input())
fn1 = None
kind = -1
for i in range(len(s)):
    if s[i] != "1":
        fn1 = s[i]
        kind = i
        break
if fn1 is None:
    print("1")
else:
    if k <= kind:
        print(1)
    else:
        print(fn1)

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) cin >> B[i];
  for (int i = 0; i < N; i++) cin >> C[i];
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());
  vector<long long> BC(N);
  for (int i = 0; i < N; i++) {
    auto ub = upper_bound(C.begin(), C.end(), B[i]);
    BC[i] = C.end() - ub;
  }
  for (int i = N - 2; i >= 0; i--) {
    BC[i] += BC[i + 1];
  }
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    auto ub = upper_bound(B.begin(), B.end(), A[i]);
    if (ub == B.end()) continue;
    ans += BC[ub - B.begin()];
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 2304
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <list>
using namespace std;

#define INF 99999999

int gcd(int x, int y) {
	if (x % y == 0)return y;
	else return gcd(y, x%y);
}

int lcm(int x, int y) {
	return x*y / gcd(x, y);
}

int c[1001][1001];
int t[1001][1001];
int main() {
	while (1) {
		int n, m;
		cin >> n >> m;
		if (n == 0)break;
		for (int i = 0; i < m + 1; i++)for (int j = 0; j < m + 1; j++) {
			c[i][j] = t[i][j] = INF;
			if (i == j)c[i][j] = t[i][j] = 0;
		}
		for (int i = 0; i < n; i++) {
			int a, b, c_, t_;
			cin >> a >> b >> c_ >> t_;
			c[a][b] = c[b][a] = c_;
			t[a][b] = t[b][a] = t_;
		}
		for (int k = 1; k < m + 1; k++)for (int i = 1; i < m + 1; i++)for (int j = 1; j < m + 1; j++) {
			c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
			t[i][j] = min(t[i][j], t[i][k] + t[k][j]);
		}
		int k;
		cin >> k;
		for (int i = 0; i < k; i++) {
			int p, q, r;
			cin >> p >> q >> r;
			if (r)cout << t[p][q] << endl;
			else cout << c[p][q] << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3840
import java.util.Scanner;
import java.util.Stack;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		String str = sc.next();
		Stack<Character> stack = new Stack<Character>();

		int pair = 0;
		for(int i = 0; i < str.length(); i++){
			char c = str.charAt(i);

			if(!stack.isEmpty() && c == 'T'){
				stack.pop();
				pair++;
			}
			else if(c == 'S'){
				stack.push(c);
			}
		}

		System.out.println(str.length() - pair*2);
	}

}


Measured memory_bytes: 32276
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    int cnt;
    int[] ARR;

    void merge(int l, int m, int r) {
        auto n1 = m-l, n2 = r-m;
        int[] L, R;
        L.length = n1+1;
        R.length = n2+1;
        foreach (i; 0..n1) L[i] = ARR[l+i];
        L[n1] = int.max;
        foreach (i; 0..n2) R[i] = ARR[m+i];
        R[n2] = int.max;
        size_t i, j;
        foreach (k; l..r) {
            ++cnt;
            if (L[i] < R[j]) {
                ARR[k++] = L[i++];
            } else {
                ARR[k++] = R[j++];
            }
        }
    }

    void merge_sort(int l, int r) {
        if (l+1 == r) return;

        auto m = (l+r)/2;
        merge_sort(l, m);
        merge_sort(m, r);
        merge(l, m, r);
    }

    auto N = readln.chomp.to!int;
    ARR = readln.split.to!(int[]);
    merge_sort(0, N);

    writeln(ARR.to!(string[]).join(" "));
    writeln(cnt);
}


Measured memory_bytes: 28296
#include <bits/stdc++.h>
using namespace std;
using in6 = int64_t;
using ind = double;
using vi = vector<in6>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<in6,in6>;
using psi = pair<string,in6>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)
#define mod 1000000007

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  in6 n,m;
  cin >> n >> m;
  vi k(m);
  vii data(m,vi(n));
  rep(i,m) {
    cin >> k[i];
    rep(j,k[i]) cin >> data[i][j];
  }
  vi check(m);
  rep(i,m) cin >> check[i];
  in6 ans = 0;
  rep(i,1<<n) {
    in6 ok = 0;
    rep(j,m) {
      in6 count = 0;
      rep(l,k[j]) {
        if(i & 1<<(data[j][l]-1)) ++count;
      }
      if(count % 2 == check[j]) ++ok;
    }
    if(ok == m) ++ans;
  }
  cout << ans;
  hinata;
}

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

const double INF = 1000000007.0;

int main () {

    int N;
    cin >> N;

    double T, A;
    cin >> T >> A;

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

    int ans;
    double diff = INF;

    for (int i = 0; i < N; i++) {
        double temp = T - 0.006 * H[i];

        if (abs(temp - A) < diff) {
            ans = i + 1;
            diff = abs(temp - A);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int a[4],b[4],x,y,hi=0,br=0;
	while(scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3]) != EOF)
	{
		if (scanf("%d %d %d %d",&b[0],&b[1],&b[2],&b[3]) == EOF) break;
		for(x=0;x<4;x++)
		{
			for(y=0;y<4;y++)
			{
			if(a[x]==b[y])
				//if(x==y) hi++;
				x==y ? (hi++) : (br++);
			}
		}
		printf("%d %d\n",hi,br);
		hi=br=0;
	}
	return 0;
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    
    if(a<b)
        cout << "a < b" << endl;
    else if(a==b)
        cout << "a == b" << endl;
    else
        cout << "a > b" << endl;
        
    return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A,B,C,K;

    cin >> A >> B >> C >> K;
    if(K < A) cout << K << endl;
    else if(K <= A + B) cout << A << endl;
    else cout << A - (K - (A+B)) << endl;

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

long long floor_sum(long long n, long long m, long long a, long long b) {
	long long ans = 0;
	if (a >= m) {
		ans += (n - 1) * n * (a / m) / 2;
		a %= m;
	}
	if (b >= m) {
		ans += n * (b / m);
		b %= m;
	}

	long long y_max = (a * n + b) / m, x_max = (y_max * m - b);
	if (y_max == 0) { return ans; }
	ans += (n - (x_max + a - 1) / a) * y_max;
	ans += floor_sum(y_max, a, m, (a - x_max % a) % a);
	return ans;
}

int main() {
	int T;
	cin >> T;
	vector<long long> ans(T);
	for (int i = 0; i < T; ++i) {
		long long N, M, A, B;
		cin >> N >> M >> A >> B;
		ans[i] = floor_sum(N, M, A, B);
	}

	for (auto v : ans) { cout << v << "\n"; }

	return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main()

{
	string a, b;
	cin >> a >> b;

	int sizea = a.size();

	int sizeb = b.size();

	bool flag = false;


	//並び替え,
	sort(a.begin(),a.end());
	sort(b.begin(),b.end(), greater<char>());

	if (a < b) {
		flag = true;
	}
    
	if (flag)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3608
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		int flag =0;
		for (int k =0; k< n-1;) {
			if (arr[k+1]!=arr[k]) {
				k++;
			}
			else {
				flag =1;
				break;
				
			}
		}
		if (flag==0){
			System.out.println("YES");
		}
		else
			System.out.println("NO");

		
		
		
}
}

Measured memory_bytes: 63428
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>



using namespace std;



int main()
{
	int n, s, sum;
	
	while (cin >> n)
	{
		if (n == 0) break;
		
		vector<int> vi;
		for (int i=0; i<n; i++)
		{
			cin >> s;
			vi.push_back(s);
		}
		
		sort(vi.begin(), vi.end());
		
		/*
		//テスト出力
		for (int i=0; i<vi.size(); i++)
		{
			cout << vi[i] << endl;
		}
		*/
		
		sum = 0;
		for (int i=1; i<vi.size()-1; i++)
		{
			sum += vi[i];
		}
		
		cout << sum / (vi.size() - 2) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1216
N = gets.to_i
H = gets.split.map &:to_i

DP = Array.new(N, nil)
DP[0] = 0

N.times do |i|
    (1..2).each do |j|
        n = i + j
        next if n >= N
        cost = (H[n] - H[i]).abs + DP[i]
        DP[n] = cost if DP[n].nil? || DP[n] > cost
    end
end

p DP[N-1]

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

int main(void)
{
  int n, k, q;
  scanf("%d %d %d", &n, &k, &q);
  int *points = malloc(sizeof(int) * n);
  for (int i = 0; i < q; i++) {
    int j;
    scanf("%d", &j);
    points[j - 1] += 1;
  }
  for (int i = 0; i < n; i++) {
    if (k + points[i] > q) printf("Yes\n");
    else printf("No\n");
  }
}

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

int main() {
    int H, W; cin >> H >> W;
    char b[H][W];
    rep(i,H) rep(j,W) cin>>b[i][j];
    int dp[51][51];
    memset(dp, 0, sizeof(dp));

    for (int i=0;i<=H;++i) {
        for (int j=0;j<=W;++j) {
            if (i==0 && j==0) {
                dp[i][j] = (b[i][j]-'0');
            }
            else {
                if (i==0) dp[i][j] = dp[i][j-1]+(b[i][j]-'0');
                else if (j==0) dp[i][j] = dp[i-1][j] +(b[i][j]-'0');
                else dp[i][j] = min(dp[i-1][j], dp[i][j-1])+(b[i][j]-'0');
            }
        }
    }

    cout << dp[H-1][W-1] << endl;
    return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while( x->left != NIL){
    x = x->left;
  }
  return x;
}


Node treeSearch(Node u, int k){
  if( u == NIL || k == u->key){
    return u;
  }
  if(k < u->key){
    return treeSearch(u->left,k);
  }  
  else
    return treeSearch(u->right,k);     

  while(u != NIL && k != u->key){
    if(k < u->key){
      u = u->left;
    }
    else if(k > u->key){
      u = u->right;
    }
  }
  return u;
  
}


Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL){
    return treeMinimum(x->right);
  }
  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL){
    y = z;
  }
  else 
    y = treeSuccessor(z);

  if(y->left != NIL){
    x = y->left;
  }
  else
    x = y->right;
  
  
  if(x != NIL){
    x->parent = y->parent;
  } 

  if (y->parent == NIL){
      root = x;
  }
  else if( y == y->parent->left){
    y->parent->left = x;
  }
   else                 
     y->parent->right = x;
  if (y != z){
     z->key = y->key;
  }
  

}


void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
     if(z->key <  x->key){
       x = x->left;
     }
     else
       x = x->right;
  }
   z->parent = y;
   if(y == NIL){
     root = z;
   }
   else if(z->key <  y->key){
     y->left = z;
   }
   else
     y->right = z;


  }

void inorder(Node u){
if(u != NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
 }
}

void preorder(Node u){
  printf(" %d",u->key);
  if(u->left != NIL){
     preorder(u->left);
  }
  if(u->right != NIL){
     preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } 
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
	scanf("%d", &x);
	treeDelete(treeSearch(root, x));
	}
  }

  return 0;
}

 

Measured memory_bytes: 19364
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <set>
#include <queue>
using namespace std;
int sum1[105][105],sum2[105][105];
int f[2][105][105][105];
char s[105];
int main(){
    int n,i,j,k,o,p,l,m;
    int tx,ty;
    scanf("%d %d",&n,&m);
    for(i=1;i<=n;i++){
    scanf("%s",s+1);
    for(j=1;j<=m;j++)
    if(s[j]=='E')tx=i,ty=j;
    else if(s[j]=='o')sum1[i][j]=sum1[i][j-1]+1,sum2[i][j]=sum2[i-1][j]+1;
    else sum1[i][j]=sum1[i][j-1],sum2[i][j]=sum2[i-1][j];
    }
    int limu=tx-1,limd=n-tx,liml=ty-1,limr=m-ty;
    for(int u=0;u<=limu;u++)
    for(int d=0;d<=limd;d++)
    for(int l=0;l<=liml;l++)
    for(int r=0;r<=limr;r++){
    int L=max(ty-l,r+1),R=min(ty+r,m-l);
    if(L<=R){
    f[u+1&1][d][l][r]=max(f[u+1&1][d][l][r],f[u&1][d][l][r]+(tx-u-1>=d+1?sum1[tx-u-1][R]-sum1[tx-u-1][L-1]:0));
    f[u&1][d+1][l][r]=max(f[u&1][d+1][l][r],f[u&1][d][l][r]+(tx+d+1<=n-u?sum1[tx+d+1][R]-sum1[tx+d+1][L-1]:0));
    }
    L=max(tx-u,d+1),R=min(tx+d,n-u);
    if(L<=R){
    f[u&1][d][l+1][r]=max(f[u&1][d][l+1][r],f[u&1][d][l][r]+(ty-l-1>=r+1?sum2[R][ty-l-1]-sum2[L-1][ty-l-1]:0));
    f[u&1][d][l][r+1]=max(f[u&1][d][l][r+1],f[u&1][d][l][r]+(ty+r+1<=m-l?sum2[R][ty+r+1]-sum2[L-1][ty+r+1]:0));
    }
    }
    printf("%d\n",f[limu&1][limd][liml][limr]);
    return 0;
}

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

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

    int n,b=0;
  	cin>>n;
    vector<ll>a(n);
    ll ans=0;
    rep(i,n){
        ll x;
        cin>>x;
        a[i]=x;
        if(x<=0)b++;
    }
    rep(i,n)a[i]=abs(a[i]);
    sort(a.begin(),a.end());
    rep(i,n)ans+=a[i];

    if(b%2!=0)ans-=2*a[0];
    
    cout<<ans<<endl;
    
    return 0;
}



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

public class hello
{
    public static void Main()
    {
        var plist = GeneratePrime(50000);
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var count = 0;
            for (int i = 0; plist[i] <= n / 2; i++)
            {
                var w = n - plist[i];
                var s = plist.BinarySearch(w);
                if (s >= 0 && s <= 5132) count++;
            }
            Console.WriteLine(count);
        }
    }
    public static List<int> GeneratePrime(int m)
    {
        var plist = new List<int>();
        int prime;
        var sqrtMax = Math.Sqrt(m);
        var searchList = Enumerable.Range(2, m - 1).ToList();
        do
        {
            prime = searchList.First();
            plist.Add(prime);
            searchList.RemoveAll(n => n % prime == 0);
        }
        while (prime < sqrtMax);
        plist.AddRange(searchList);
        return plist;
    }
}






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

int main(){
    int n, i, a, b, t, u, s=0;
    cin >> n >> a >> b;
    for(i=1; i<=n; i++){
        u = 0;
        t = i;
        while(t > 0){
            u += t%10;
            t /= 10;
        }
        if(u >= a && u <= b){
            s += i;
        }
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long ll;
const int MAXN = 0;

int a[26];
map<int, int> m;
int main()
{
	//freopen("input.in", "r", stdin);
    string s;
    cin >> s;
    int mask = 0;
    m[mask] = 0;

    for (int i = 0; i < s.length(); i++)
    {
        mask ^= 1 << (s[i] - 'a');
        int bestdp = 100000000;
        if (m.find(mask) != m.end())
            bestdp = m[mask];
        for (int i = 0; i < 26; i++)
        {
            int mask2 = mask ^ (1 << i);
            if (m.find(mask2) != m.end())
                bestdp = min(m[mask2], bestdp);
        }
        if (m.find(mask) != m.end())
            m[mask] = min(m[mask], bestdp+1);
        else
            m[mask] = bestdp+1;

        /*
        for (auto it = m.begin(); it != m.end(); it++)
            cout << it->first << " ";
        cout << endl;
        for (auto it = m.begin(); it != m.end(); it++)
            cout << it->second << " ";
        cout << endl << endl;
        */
    }
    cout << max(m[mask], 1);

	return 0;
}


Measured memory_bytes: 9860
#include<stdio.h>

int main(void){
    int n, d, tree, ans=0;
    scanf("%d %d", &n, &d);
    tree = 2 * d + 1;
    if(n % tree == 0) ans = n / tree;
    else ans = n / tree + 1;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128