akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000001;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N;
    cin >> N;
    string A,B,C;
    cin >> A >> B >> C;
    int ret = 0;
    for(int i = 0;i < N;i++) {
        if(A.at(i) == B.at(i) && B.at(i) == C.at(i)) {
            ret = ret;
        }
        else if(A.at(i) == B.at(i)) {
            ret++;
        }
        else if(B.at(i) == C.at(i)) {
            ret++;
        }
        else if(A.at(i) == C.at(i)) {
            ret++;
        }
        else {
            ret += 2;
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0, _n = (int)(n); i < _n; ++i)
const int N = (int) 30, mod = (int) 0;
int cnt[N];
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        string x;
        cin >> x;
        cnt[x[0] - 'A']++;
    }
    int res = 0;
    while (true) {
        sort(cnt, cnt + 26);
        reverse(cnt, cnt + 26);
        int flag = 1;
        for (int i = 0; i < k; ++i) {
            if (!cnt[i])
                flag = 0;
            cnt[i]--;
        }
        res += flag;
        if (!flag) break;
    }
    cout << res << endl;
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i=0;i<(int)(n);++i)
template <typename T> ll gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> ll lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> inline void chmin(T &a, const T& b){if(a>b)a=b;}
template <typename T> inline void chmax(T &a, const T& b){if(a<b)a=b;}

int main() {
  ll ans = 0, b = 0;
  string s;
  cin >> s;
  int n = s.size();
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'B') ++b;
    else ans += b;
  }
  cout << ans << '\n';
}


Measured memory_bytes: 640
import math
def issquare(res):
	ans = math.sqrt(res)
	return (ans - math.floor(math.sqrt(res))) == 0

a, b = map(str, input().split())
t = a + b
res = int(t)
ans = issquare(res)
if ans:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 9188
#include<stdio.h>
#include<string.h>
int main() {
	char s[100000];
	scanf("%s",s);
	int a[100000]= {0},i,j;
	for(i=0; i<strlen(s); i++) {
		if(s[i]=='d'&&s[i+1]=='r'&&s[i+2]=='e'&&s[i+3]=='a'&&s[i+4]=='m') {
			a[i]=1,a[i+1]=1,a[i+2]=1,a[i+3]=1,a[i+4]=1;
		}
		if(s[i]=='d'&&s[i+1]=='r'&&s[i+2]=='e'&&s[i+3]=='a'&&s[i+4]=='m'&&s[i+5]=='e'&&s[i+6]=='r') {
			a[i]=1,a[i+1]=1,a[i+2]=1,a[i+3]=1,a[i+4]=1,a[i+5]=1,a[i+6]=1;
		}
		if(s[i]=='e'&&s[i+1]=='r'&&s[i+2]=='a'&&s[i+3]=='s'&&s[i+4]=='e') {
			a[i]=1,a[i+1]=1,a[i+2]=1,a[i+3]=1,a[i+4]=1;
		}
		if(s[i]=='e'&&s[i+1]=='r'&&s[i+2]=='a'&&s[i+3]=='s'&&s[i+4]=='e'&&s[i+5]=='r') {
			a[i]=1,a[i+1]=1,a[i+2]=1,a[i+3]=1,a[i+4]=1,a[i+5]=1;
		}
	}
	int f=0;
	for(i=0; i<strlen(s); i++) {
		if(a[i]==0) {
			f=1;
			break;
		}
	}
	if(f==1)
		printf("NO");
	else
		printf("YES");
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
	for(int n,m,a,b,i;scanf("%d%d",&n,&m),n|m;printf("%d\n",a)){
		int f[510][510]={0};
		for(i=m;i--;f[a][b]=f[b][a]=1)
			scanf("%d%d",&a,&b);
		for(a=i=0;i<=n;i++)
			if(f[1][i])
				for(f[505][i]=b=1;b<=n;b++)
					f[i][b]?f[505][b]=1:0;
		for(;--i>1;)
			f[505][i]?a++:0;
	}
}

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

int main(){
  string s; cin >> s;
  char a, b, c;
  a = s[0]; b = s[1]; c = s[2];
  if(a=='7') cout << "Yes" << endl;
  else if(b == '7') cout << "Yes" << endl;
  else if(c == '7') cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

string dp[10020];

const int MAX_N = 55;

ll pascal[MAX_N][MAX_N];

void initFact() {
  for (int i = 1; i <=MAX_N; i++) {
      for (int j = 1; j <= MAX_N; j++) {

          if (j == 1)                 // 行の左端は 1
              pascal[i][j] = 1;

          else if (j == i) {          // 行の右端も 1
              pascal[i][j] = 1;
              break;        // 右端まで計算したので内側のループから抜ける
          }
          else              // 行の途中は一つ上の二つの要素の合計
              pascal[i][j] = pascal[i - 1][j - 1] + pascal[i - 1][j];
      }
  }
}

ll combi(int n, int k) {
  return pascal[n+1][k+1];
}

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

  long n, a, b;
  cin >> n >> a >> b;

  vector<long> v(n);
  fillLong(v, n);

  long res = 0;
  sortvinv(v);

  long mn = v[a-1];
  long minCnt = 0;
  long minCntUse = 0;
  rep(i, a) {
    res += v[i];
    if(v[i] == mn) minCntUse++;
  }
  rep(i, n) {
    if(v[i] == mn) minCnt++;
  }
  initFact();

  long cnt = 0;
  if (mn == v[0]) {
    for(int i = a; i <= b; i++) {
      cnt += combi(minCnt, i);
    }
  } else {
    cnt = combi(minCnt, minCntUse);
  }

  printf("%.10f\n", (double)res/a);
  cout << cnt << endl;
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

ll MOD = 1000000007LL;

vector<int> G[100001];
bool visited[100001];
ll dp[100001][2];

void dfs(int n){
  visited[n] = true;
  for(int i = 0; i < G[n].size(); i++){
    if(!visited[G[n][i]]){
      dfs(G[n][i]);
      dp[n][0] *= (dp[G[n][i]][0] + dp[G[n][i]][1]);
      dp[n][0] %= MOD;
      dp[n][1] *= dp[G[n][i]][0];
      dp[n][1] %= MOD;
    }
  }
}

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

  for(int i = 0; i < N - 1; i++){
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }

  fill(dp[0], dp[100001], 1LL);
  fill(visited, visited + N, false);

  dfs(0);

  cout << (dp[0][0] + dp[0][1]) % MOD << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const lb PI=3.14159265359;

int main(){

  ll n;cin>>n;
  string s;cin>>s;

  ll ans=0;
  rep(i,2,n){
    if(s[i-2]=='A'&&s[i-1]=='B'&&s[i]=='C')ans++;
  }

  out(ans);

  return 0;
}


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

#define PI 3.14159265359
//2の累乗数かどうか
bool hantei(int N) {
	bool flag = false;
	while (1) {
		if (N % 2 == 0) N /= 2;
	}
	if (N == 1) flag = true;

	return flag;
}
int main() {
	string S;
	cin >> S;
	if (S == "ABC") cout << "ARC" << endl;
	else cout << "ABC" << endl;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int find(int i,int k)
{
   if(k>i||k<0||i<0)
      return 0;
   if(i==0)
      return 1;
   int ans=0;
       if(k==2)
         ans+=((i*(i-1))/2)*(pow(9,k));
      else if(k==1)
      {
         ans+=(i)*pow(9,k);
      }
      else
         ans++;  
   // cout<<ans<<'\n';
   return ans;
}

signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif
 
// -------------------------------------Code starts here---------------------------------------------------------------------     

   string s;
   cin>>s;
   int n=s.length();
   s="#"+s;
   int k;
   cin>>k;
   int ans=0;
   for(int i=k-1;i<=n-2;i++)
   {
      if(k==3)
         ans+=((i*(i-1))/2)*(pow(9,k));
      else if(k==2)
      {
         ans+=(i)*pow(9,k);
      }
      else
      {
         ans+=9;
      }      
   }
   // cout<<ans<<'\n';
   ans+=find(n-1,k-1)*(s[1]-'0'-1);
   // cout<<ans<<'\n';
   int cnt=1;
   for(int i=2;i<=n;i++)
   {
      if(s[i]-'0'!=0)
      {
         ans+=(s[i]-'0'-1)*find(n-i,k-cnt-1)+find(n-i,k-cnt);
         cnt++;
         // cout<<ans<<" ";
      }
   }
   if(cnt==k)
      ans++;
   cout<<ans;

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }


Measured memory_bytes: 256
function main(input){
  input = input.split('\n');
  let [X, K, D] = input[0].split(' ').map(BigInt);

  let n = X/D;
  if(n < 0n) n = -n;

  if(K >= n){
    if(X > 0n)X -= n*D;
    else X += n*D;
    K -= n

    if (K%2n != 0n){
      if(X >= 0n){
        X -= D;
      }else{
        X += D;
      }
    }
  }else {
    if(X > 0n)X -= K*D;
    else X += K*D;
    K -= n
  }

  console.log(X >= 0n? String(X) : String(-X))
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim());


Measured memory_bytes: 29588
#include<bits/stdc++.h>
#define WR "txt"
#define N 100000

void Open() { freopen(WR".in", "r", stdin); freopen(WR".out", "w", stdout); }
void Close() { fclose(stdin); fclose(stdout); }
using namespace std;
int Read()  {
	int val = 0, opt = 1; char ch;
	while (!isdigit(ch = getchar() )) if (ch == '-') opt = -1;
	while (isdigit( ch )) (val *= 10) += ch - '0', ch= getchar();
	return val * opt;
}

long long f[N + 10], n, C, Ans;

void work()  {
	n = Read(), C = Read();
	for (int i = 1;i <= N; i++)	f[i] = C + 1;
	for (int i = 1;i <= n; i++)  {
		int w, v;
		w = Read(), v = Read();
		for (int j = N;j - v >= 0; j--)	
			f[j] = min(f[j], f[j - v] + w);
	}
	for (int i = 0;i <= N; i++)
		if (f[i] <= C) Ans = i;
	printf("%d\n", Ans);
}

int main(void)  {
	//Open();
	work();
	//Close();
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
  
  int b = 0;
  int c = 0;
  
  for(int i=0; i<N; i++){
    b = a.at(c);
    
    if(b == 2){
      cout << i+1 << endl;
      break;
    }
    else if(b == 0){
      cout << "-1" << endl;
      break;
    }
    
    a.at(c) = 0;
    c = b;
    c--;
  }
}


Measured memory_bytes: 3728
process.stdin.resume();
process.stdin.setEncoding('utf-8');
var input_string = '';

process.stdin.on('data', function(chunk) {
    input_string += chunk;
});

process.stdin.on('end', function() {
    var lines = input_string.split('\n');
    main(lines.slice(0, lines.length-1));
});

function main(lines) {
    var arr = lines[0].split(' ').map(function(x) {return parseInt(x);});
    if (arr[0] < arr[1]) {
        console.log("a < b");
    }
    if (arr[0] > arr[1]) {
        console.log("a > b");
    }
    if (arr[0] == arr[1]) {
        console.log("a == b");
    }
}

Measured memory_bytes: 15544
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
  
  while(true){
   int t;
 cin>>t;
   if(t==0){
   break;
   }
    
  
 int s=1000-t;
 int w=s/500;
 int e=(s%500)/100;
  int r=((s%500)%100)/50;
  int y=(((s%500)%100)%50)/10;
  int u=((((s%500)%100)%50)%10)/5;
  int o=(((((s%500)%100)%50)%10)%5);
  cout<< w+e+r+y+u+o <<endl;
}
}


Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    vector<int> v(4);
    rep(i,4)cin >> v[i];
    sort(v.begin(),v.end());
    if(v[0]==1&&v[1]==4&&v[2]==7&&v[3]==9){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

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

#ifdef LOCAL
  #include "debug.h"
#endif

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int a, b, h;
  cin >> a >> b >> h;
  cout << (a + b) * h / 2 << '\n';    
  return 0;
}

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

using namespace std;

int const N = 1e3 + 10;

char s[N];

map <char, int> Map;

int main ()
{	
		scanf (" %s", s);

		int n = strlen (s);

		for (int i = 0; i < n; i++)
			Map[s[i]]++;

		if ((!Map['N'] && Map['S']) || (!Map['S'] && Map['N']))
			printf ("No\n");
		else
			if ((!Map['E'] && Map['W']) || (!Map['W'] && Map['E']))
				printf ("No\n");
			else
				printf ("Yes\n");

		return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long K = sc.nextLong();
		int[] A = new int[N];
		for(int i = 0;i < N;i++){
			A[i] = sc.nextInt();
		}

		//訪れた頂点のメモ
		List<Integer> s = new ArrayList<>();
		//頂点に割り振る数字
		int[] ord = new int[N+1];
		Arrays.fill(ord, -1);
		int cycle = 1;
		int l = 0;
		{
			int v = 1;
			while(ord[v] == -1){
				ord[v] = s.size();
				s.add(v);
				v = A[v-1];
			}
			cycle = s.size() - ord[v];
			l = ord[v];
		}
		if(K < l){
			System.out.println(s.get((int) K));
		}else{
			K -= l;
			K %= cycle;
			System.out.println(s.get(l+(int)K));
		}
	}
}

Measured memory_bytes: 60896
#include <stdio.h>
#include <string.h>

int t[1002][1002];
int dp[1002][1002];

int main(void){
  int i,j,ti,tj;
  int w,h,n;
  int d,gx,gy;

  while(scanf("%d%d%d",&h,&w,&n) && (h||w||n)){
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        scanf("%d",&t[i][j]);
      }
    }

    memset(dp,0,sizeof(dp));
    dp[0][0] = n;
    gx = 0, gy = 0;

    for(tj=0;tj<w && gx<w && gy<h;tj++){
      for(i=0;i<h && 0<=tj-i && gx<w && gy<h;i++){
        d = 0;
        j = tj - i;

        if(dp[i][j] % 2 == 0){
          d = !t[i][j];
          dp[i][j+1] += dp[i][j] / 2;
          dp[i+1][j] += dp[i][j] / 2;
        }
        else{
          d = t[i][j];
          dp[i][j+1] += dp[i][j] / 2 + d;
          dp[i+1][j] += dp[i][j] / 2 + !d;
        }
        if(gx == j && gy == i){
          gx += d;
          gy += !d;
        }
      }
    }

    for(ti=1;ti<h && gx<w && gy<h;ti++){
      for(tj=0;tj<w && ti+tj<h && gx<w && gy<h;tj++){
        d = 0;
        i = ti + tj;
        j = w - tj - 1;

        if(dp[i][j] % 2 == 0){
          d = !t[i][j];
          dp[i][j+1] += dp[i][j] / 2;
          dp[i+1][j] += dp[i][j] / 2;
        }
        else{
          d = t[i][j];
          dp[i][j+1] += dp[i][j] / 2 + d;
          dp[i+1][j] += dp[i][j] / 2 + !d;
        }
        if(gx == j && gy == i){
          gx += d;
          gy += !d;
        }
      }
    }

    printf("%d %d\n",gy+1,gx+1);
  }

  return 0;
}

Measured memory_bytes: 0
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N;
    cin >> N;
    veci H(N);
    REP(i,N) cin >> H[i];
    int ans = 0;
    REP(i,N) {
        bool ok = true;
        for(int j = 0; j < i; j++) {
            if(H[i] < H[j]) ok = false;
        }
        ans += ok;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
using namespace std;
int main(void){
    long n, k;
    cin >> n >> k;
    
    long i, sum = 0;
    
    if(!k){cout << n*n << endl; return 0;}
    
    for(i = k+1; i <=n; i++){
        sum += (n/i)*(i - k);
        if(n%i >= k) sum += n%i - k + 1;
    }
    
    cout << sum <<endl;
    return 0;
}


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

int main(int argc, char *argv[])
{
    int n, a, b;
    int ans;

    std::cin >> n >> a >> b;

    int train = a * n;
    int taxi = b;

    ans = std::min(train, taxi);

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>
 
// #include <unordered_set>
// #include <unordered_map>
 
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
 
#define pb push_back
#define mp make_pair
 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
 
typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;
 
const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
using namespace std;
 
// #define int long long

const int MAX_V=1000;
int memo[1000001]={0};
int dist[MAX_V][MAX_V];



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cin高速化

    int count=0;

    string s;
    cin>>s;

    REP(i,3){
    	if(s[i]=='1')count++;
    }

    cout<<count<<endl;
    return 0;
    
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[99], t[99];int l;
int main(){
	scanf("%s",s);
	l = strlen(s);
	if(l < 26){
		int mask=0;
		for(int i=0; i<l; i++)
			mask|=1<<(s[i]-'a');
		for(int i=0; i<26; i++){
			if(mask&(1<<i))continue;
			s[l] = i+'a';
			break;
		}
		l++;s[l]=0;
		puts(s);
	}else{
		memcpy(t, s, sizeof(char)*l);
		if(!next_permutation(s,s+l)){
			puts("-1");
		}else{
			//puts(s);
			for(int i=0;i<l;i++)
				if (s[i] > t[i]) {
					s[i+1] = 0;
					break;
				}
			/*for(int i=l-1; i>0; i--)
				if(i==l-1 || s[i-1] < s[i])
					s[i] = 0;
				else{
					s[i] = 0;
					break;
				}*/
			puts(s);
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define iFOR(i, a, b) for(int i=(a); i>=(b); --i)
#define make_unique(a) sort(all((a))), (a).resize(unique(all((a)))-(a).begin())

using namespace std;

typedef pair<int,int> PII;
typedef long long LL;
typedef double DD;
typedef long double LD;
typedef pair<LL,LL> PLL;
typedef pair<DD,DD> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;
const int mod = 1000000007;
LL MOD(LL a){
    if(a >= mod) return a%mod;
    if(a<0) return a%mod+mod;
    return a;
}
LL sum(LL l, LL r){
    return r*(r+1)/2 - (l-1)*l/2;
}

int main(){
	int i,j,k,l,a,b,c,d;
	scanf("%d %d",&a,&b);
    LL ans = 0;
    FOR(i, b, a+1){
        ans = MOD(ans+sum(a-i+1, a)-sum(0,i-1)+1);
    }
    printf("%lld",ans);
	return 0;
}
/*
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */


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

int main() {
  ll n; cin >> n;
  vector<ll>v(n);
  ll h = 0;
  rep(i,n){
    cin >> v.at(i);
    h += v.at(i)*v.at(i);
  }
  ll sum = 0;
  rep(i,n){
    rep(j,n){
      sum += v.at(i)*v.at(j);
    }
  }
  cout << (sum-h)/2 << endl;
  
  
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
#define MOD 1000000007
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> 
void __print(const pair<T, V> &x)
{
	cerr << '{'; __print(x.first);
	cerr << ','; __print(x.second);
	cerr << '}';
}

template<typename T>
void __print(const T &x)
{
	int f = 0;
	cerr << '{';
	for (auto &i : x)
		cerr << (f++ ? "," : ""), __print(i);
	cerr << "}";
}

void _print()
{
	cerr << "]\n";
}

template <typename T, typename... V>
void _print(T t, V... v)
{
	__print(t);
	if (sizeof...(v))
		cerr << ", "; _print(v...);
}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    

	string s,t;
	cin >> s >> t;
	cout << t << s << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
from math import factorial


def main():
    n, m = map(int, input().split())

    B = [-1] * n

    ans = 1
    for i in range(m):
        s, c = map(int, input().split())
        if (B[s - 1] == -1):
            B[s - 1] = c
        elif (B[s - 1] != c):
            ans = 0
            break

    if (n > 1):
        if (B[0] == -1):
            B[0] = 1
        if (B[0] == 0):
            ans = 0
    else:
        if (B[0] == -1 or B[0] == 0):
            print(0)
            return 0
    for i in range(1, n):
        if (B[i] == -1):
            B[i] = 0
    if ans == 0:
        print(-1)
    else:
        S = ""
        for i in range(n):
            S += str(B[i])
        print(S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
unittest
{
/*
	assert( [ "0" ].parse.expand.solve == "4\n3 3 3 3" );
	assert( [ "1" ].parse.expand.solve == "3\n1 0 3" );
	assert( [ "2" ].parse.expand.solve == "2\n2 2" );
	assert( [ "3" ].parse.expand.solve == "7\n27 0 0 0 0 0 0" );
	assert( [ "1234567894848" ].parse.expand.solve == "10\n1000 193 256 777 0 1 1192 1234567891011 48 425" );
*/
}



import std.conv;
import std.format;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto k = input.front.to!( long );
	return tuple( k );
}

auto solve( long k )
{
	const N = 50;
	
	if( k == 0 ) return "2\n0 0";
	if( k == 1 ) return "2\n0 2";
	
	long[] anss;
	if( k < N )
	{
		anss = new long[ k ];
		foreach( i, ref ans; anss )
		{
			ans = k - i;
		}
	}
	else
	{
		auto b = k / N;
		auto r = k % N;
		anss = new long[ N ];
		foreach( i, ref ans; anss )
		{
			ans = N + b - i - ( r <= i );
		}
	}
	return format( "%s\n%s", anss.length, anss.to!( string[] ).join( " " ) );
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  int sum=0,sum1=0;
  for(int i=0;i<n;i++)
  {
   cin>>a[i];
    sum=sum+a[i];
  }
  sum=sum-a[0];
  for(int i=0;i<(n-1);i++)
  {
    sum1=sum1+a[i]*sum;
    sum=sum-a[i+1];
  }
  cout<<sum1;
}

Measured memory_bytes: 256
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    let mut iter = line.split_whitespace().map(|s| s.parse::<i32>().unwrap());
    let (a, b) = (iter.next().unwrap(), iter.next().unwrap());
    println!("{} {}", a*b, (a+b)*2);
}


Measured memory_bytes: 5036
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    int result = 0;
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    for(int i = 1; i < n - 1; i++){
        if(p[i - 1] < p[i] && p[i] < p[i + 1]){
            result++;
        }
        else if(p[i + 1] < p[i] && p[i] < p[i - 1]){
            result++;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 256
s=input()

if s=="AKIHABARA":
    print("YES")
elif s=="KIHABARA" or s=="AKIHBARA" or s=="AKIHABRA" or s=="AKIHABAR":
    print("YES")
elif s=="KIHBARA" or s=="KIHABRA" or s=="KIHABAR" or s=="AKIHBRA" or s=="AKIHBAR" or s=="AKIHABR":
    print("YES")
elif s=="KIHBRA" or s=="KIHBAR" or s=="KIHABR" or s=="AKIHBR":
    print("YES")
elif s=="KIHBR":
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
//  0529.cpp
//  2012/12/14.

#if 1

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
    for(int N, M; cin >> N >> M && (N || M); )
	{
		vint points(N);
		
		rep(i, N) cin >> points[i];
		points.push_back(0);
		
		vint pair;
		rep(i, N+1) REP(j, i, N+1) pair.push_back(points[i] + points[j]);
		
		sort(ALL(pair));

		int ans = 0;
		rep(i, pair.size())
		{
			int s = M - pair[i];
			
			int idx = lower_bound(ALL(pair), s) - pair.begin() - 1;
			
			if(0 <= idx && pair[i] + pair[idx] <= M) chmax(ans, pair[i] + pair[idx]);
		}
		
		cout << ans << endl;
	}
}

#endif

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

int mod = 1000000007;
int64_t large = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int X;
    cin >> X;
    int ans = 1;
    while ((ans * (ans + 1)) / 2 < X)
        ans++;
    cout << ans;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
x = list(map(int,input().split()))
ans = float("inf")
for i in range(N-K+1):
    if x[i]*x[i+K-1] >=0:
        ans = min(ans, max(abs(x[i]),abs(x[i+K-1])))
    else:
        ans = min(ans, max(abs(x[i]),abs(x[i+K-1]))+2*min(abs(x[i]),abs(x[i+K-1])))
print(ans)

Measured memory_bytes: 14568
#include <iostream>
#include <string>
using namespace std;
int main(void){
    
    
    string s;
    cin >> s;
    
    bool c['z'-'a'+1] = {};
    
    for(int i = 0; i < s.size(); i++){
        c[s[i]-'a'] = true;
    }
    
    for(int i = 0; i < 'z'-'a'+1; i++){
        if(!c[i]){
            cout << (char)(i+'a') << endl;
            return 0;
        }
    }
    
    cout << "None" << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  cout<<x2+y1-y2<<" "<<y2+x2-x1<<" "
    <<x1+y1-y2<<" "<<y1+x2-x1<<endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		//		new Main().solveB();
		new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numA = 0;
		int numB = 0;
		int numX = 0;

		try {
			scanner = new Scanner(System.in);
			numA = scanner.nextInt();
			numB = scanner.nextInt();
			numX = scanner.nextInt();

			if (numX - numA <= numB && numA <= numX) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {

		try (Scanner scanner = new Scanner(System.in)) {
			int numN = scanner.nextInt();
			int numM = scanner.nextInt();
			int numX = scanner.nextInt();

			Set<Integer> wk = new HashSet<Integer>();

			for (int i = 0; i < numM; i++) {
				wk.add(scanner.nextInt());
			}
			int res1 = 0;
			for (int i = numX; i <= numN; i++) {
				if (wk.contains(i)) {
					res1++;
				}

			}
			int res2 = 0;
			for (int i = 0; i <= numX; i++) {
				if (wk.contains(i)) {
					res2++;
				}

			}

			System.out.println(Math.min(res1, res2));

		}
	}

	private void solveC() {

		try (Scanner scanner = new Scanner(System.in)) {
			int numN = scanner.nextInt();
			//入力値
			long[] wk = new long[numN];
			//中央値算出用の配列
			long[] wk2 = new long[numN];

			for (int i = 0; i < wk.length; i++) {
				wk[i] = scanner.nextInt();
				wk2[i] = wk[i];
			}

			//中央値の算出
			Arrays.sort(wk2);

			//中央値の準備（１：中央値より大きい位置が除外された時の中央値　２：中央値より小さい値が除外された時の中央値）
			long m1 = wk2[(numN / 2) - 1];
			long m2 = wk2[(numN / 2)];

			for (int i = 0; i < wk.length; i++) {
				if (wk[i] <= m1) {
					System.out.println(m2);
				} else {
					System.out.println(m1);
				}
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 97252
N, X = map(int, input().split())

a = [1] * (N + 1)
p = [1] * (N + 1)
for i in range(N):
    a[i + 1] = a[i] * 2 + 3
    p[i + 1] = p[i] * 2 + 1


def func(n, x):
    if n == 0:
        return 0 if x <= 0 else 1
    elif x <= 1 + a[n - 1]:
        return func(n - 1, x - 1)

    return p[n - 1] + 1 + func(n - 1, x - 2 - a[n - 1])


print(func(N, X))


Measured memory_bytes: 62020
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false)

const int mx = 2e5;
int n;
int32_t main(){ fast;
	
	cin>>n;
	vector<int> a(n);
	map<int, int> cnt;
	ll tot = 0;
	rep(i, n){
		cin>>a[i];
		tot += cnt[a[i]];
		cnt[a[i]]++;
	}
	rep(i, n){
		cout<<tot - (cnt[a[i]] - 1)<<" ";
	}
}


Measured memory_bytes: 8320
num = input().split()
num_i = [int(s) for s in num]

if(num_i[0] == num_i[1]):
    print('Draw')
    
elif(num_i[0] != 1 and num_i[1] != 1):
    if(num_i[0] > num_i[1]):
        print('Alice')
    else:
        print('Bob')

else:
    if(num_i[0] == 1):
        print('Alice')
    else:
        print('Bob')

Measured memory_bytes: 3060
k = int(input())
if k == 1 or k == 7:
    print(1)
    exit()
count = 1
tmp = 7
s = [0 for i in range(k+8)]
while True:
    if s[tmp] != 0:
        print(-1)
        exit()
    s[tmp]+=1
    tmp*=10
    tmp+=7
    tmp %= k
    count+=1
    if tmp == 0:
        print(count)
        exit()

Measured memory_bytes: 139996
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = new Date();
  Main();
  var end = new Date() - start;
  
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}


//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var one = nextIntArray();
	var H = one[0];
	var W = one[1];
	var kK = one[2];
	var list = new Array(H);
	for(var i = 0; i < H; i++){
		list[i] = nextCharArray();
	}
	var output = 0;
	for(var i = 0; i < (1 << H); i++){
		var selectH = [];
	        for(var j = 0; j < H; j++){
	                if((i & (1 << j)) != 0){
				selectH.push(j);
	                        //選ぶ
	                }
	        }
		for(var j = 0; j < (1 << W); j++){
			var selectW = [];
		        for(var k = 0; k < W; k++){
		                if((j & (1 << k)) != 0){
					selectW.push(k);
		                        //選ぶ
		                }
		        }
			var newList = JSON.parse(JSON.stringify(list));
			for(var k = 0; k < selectH.length; k++){
				for(var l = 0; l < W; l++){
					newList[selectH[k]][l] = "*";
				}
			}
			for(var k = 0; k < selectW.length; k++){
				for(var l = 0; l < H; l++){
					newList[l][selectW[k]] = "*";
				}
			}
			var kCount = 0;
			for(var k = 0; k < H; k++){
				for(var l = 0; l < W; l++){
					if(newList[k][l] == "#"){
						kCount++;
					}
				}
			}
			if(kCount == kK){
				output++;
			}
		}
	}
	myout(output);
}


Measured memory_bytes: 36412
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int N, K;
int b[2002][2002];
int s[4002][4002];

int get(int x, int y) {
    return s[x + K - 1][y + K - 1] + s[x - 1][y - 1] - s[x - 1][y + K - 1] -
           s[x + K - 1][y - 1];
}
int main() {
    // https://misteer.hatenablog.com/entry/ARC089-D
    // https://pitsbuffersolution.com/compro/atcoder/arc089d.php
    cin >> N >> K;
    REP(i, N) {
        int x, y;
        char c;
        cin >> x >> y >> c;
        if(c == 'W') {
            y += K; //白で塗る条件を黒で塗る条件に変えること
        }
        ++b[x % (2 * K) + 1][y % (2 * K) + 1];
    }

    //累積和
    for(int i = 1; i < 4 * K + 1; i++) {
        for(int j = 1; j < 4 * K + 1; j++) {
            s[i][j] =
                s[i][j - 1] + b[(i - 1) % (2 * K) + 1][(j - 1) % (2 * K) + 1];
        }
    }
    for(int j = 1; j < 4 * K + 1; j++) {
        for(int i = 1; i < 4 * K + 1; i++) {
            s[i][j] += s[i - 1][j];
        }
    }

    int ans = 0;
    for(int i = 1; i < 2 * K + 1; i++) {
        for(int j = 1; j < 2 * K + 1; j++) {
            ans = max(ans, get(i, j) + get(i + K, j + K));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 78464
#include <bits/stdc++.h>
using namespace std;
 
//#define kk
//#define int long long
#define FOR(i, n) for(int i=1; i<=n; i++)
#define ff first
#define ss second
#define ll int
#define inf 1000000000
#define pb push_back
#define mod 1000000007
 
const long long INF=1e18+5;
typedef pair<int, int> pi;

int arr[101];
int dp[100001];

int grundy(int n, int k){
	if(k<arr[1] || k==0) return 0;
	
	if(dp[k]!=-1) return dp[k];
	
	vector<int> v(n+1, 0);
	
	for(int i=1; i<=n; i++){
		if(k>=arr[i]) v[grundy(n, k-arr[i])]++;
	}
	
	int ans=0;
	for(int i=0; i<=n; i++){
		if(v[i]==0){
			ans=i;
			break;
		}
	}
	return dp[k]=ans;
}

void solve(){
	int n, k;
	cin>>n>>k;
	
	for(int i=1; i<=n; i++){
		cin>>arr[i];
	}
	
	memset(dp, -1, sizeof dp);
	if(grundy(n, k)==0) cout<<"Second"<<endl;
	else cout<<"First"<<endl;
}
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cout<<fixed<<setprecision(10);
	
	#ifdef kk
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	
	int T=1;
	//cin>>T;
	
	while(T--){
		solve();
	}
}


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

int main(){
    int a,b;
    cin >>a>>b;
    if(a>0 && b>0) cout <<"Positive"<<endl;
    else if(a <=0 && b>=0) cout << "Zero"<<endl;
    else if(a<0 && b<0) {
      if(abs(a-b)%2==0) cout<<"Negative"<<endl;
      else cout <<"Positive"<<endl;
    }
  }  


Measured memory_bytes: 256
N,x = map(int,input().split())
a = list(map(int,input().split()))
count=0
for i in range(N-1):
    if a[i]+a[i+1] >x:
        if a[i]>x:
            count+=a[i+1]+a[i]-x
            a[i]=x
            a[i+1] = 0
        else:
            count += a[i]+a[i+1]-x
            a[i + 1] -=a[i]+a[i+1]-x
print(count)


Measured memory_bytes: 14588
package main

import "fmt"

func main() {
	var A, B, C, X int
	fmt.Scan(&A, &B, &C, &X)
	num := 0
	for a := 0; a <= A; a++ {
		for b := 0; b <= B; b++ {
			for c := 0; c <= C; c++ {
				if 500*a+100*b+50*c == X {
					num += 1
				}
			}
		}
	}
	fmt.Println(num)
}


Measured memory_bytes: 512
n = int(input())
a = [int(i) for i in input().split()]
count = [0] * 30

for j in range(n):
    t = bin(a[j])[2:].zfill(30)
    for k in range(30):
        count[k] += int(t[29-k])
        count[k] = count[k] % 2

if 1 in count:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 14116
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int N, M, Q, debug = 0;

void zeroclear(int *p);
void oneclear(int *p);
void of(int *p);
int hadd(const int *p);
void genA(const int *ind, int *As);
void next(int *ind);

int main(void)
{
    int cc, score = 0, temp, incind;
    int *a, *b, *c, *d, *ind, *As;
    scanf("%d %d %d", &N, &M, &Q);
    a = (int *)malloc(sizeof(int) * Q);
    b = (int *)malloc(sizeof(int) * Q);
    c = (int *)malloc(sizeof(int) * Q);
    d = (int *)malloc(sizeof(int) * Q);
    ind = (int *)malloc(sizeof(int) * N);
    As = (int *)malloc(sizeof(int) * N);
    zeroclear(ind);
    oneclear(As);
    for (cc = 0; cc < Q; ++cc)
    {
        scanf("%d %d %d %d", a + cc, b + cc, c + cc, d + cc);
    }
    while (1)
    {
        temp = 0;
        genA(ind, As);
        if (ind[N - 1] >= M)
        {
            break;
        }
        for (cc = 0; cc < Q; ++cc)
        {
            if (As[b[cc] - 1] - As[a[cc] - 1] == c[cc])
            {
                temp += d[cc];
            }
        }
        if (temp > score)
        {
            score = temp;
        }
        ++ind[0];
        of(ind);
        if (hadd(ind) > M - 1)
        {
            next(ind);
        }
        ++debug;
    }
    printf("%d", score);
    free(a);
    free(b);
    free(c);
    free(d);
    return 0;
}

void zeroclear(int *p)
{
    int cc;
    for (cc = 0; cc < N; ++cc)
    {
        p[cc] = 0;
    }
}

void oneclear(int *p)
{
    int cc;
    for (cc = 0; cc < N; ++cc)
    {
        p[cc] = 1;
    }
}

void of(int *p)
{
    int cc;
    for (cc = 0; cc < N - 1; ++cc)
    {
        if (p[cc] > M - 1)
        {
            p[cc] = 0;
            ++p[cc + 1];
        }
    }
}

int hadd(const int *p)
{
    int cc, ans = 0;
    for (cc = 0; cc < N; ++cc)
    {
        ans += p[cc];
    }
    return ans;
}

void genA(const int *ind, int *As)
{
    int cc;
    oneclear(As);
    As[0] += ind[0];
    for (cc = 1; cc < N; ++cc)
    {
        As[cc] = As[cc - 1];
        As[cc] += ind[cc];
    }
}

void next(int *ind)
{
    int cc;
    int *temp;
    temp = (int *)malloc(sizeof(int) * N);
    for (cc = 0; cc < N - 1; ++cc)
    {
        memcpy(temp, ind, sizeof(int) * N);
        temp[cc] = 0;
        ind[cc] = 0;
        ++temp[cc + 1];
        of(temp);
        if (hadd(temp) <= M - 1)
        {
            memcpy(ind, temp, sizeof(int) * N);
            break;
        }
    }
    memcpy(ind, temp, sizeof(int) * N);
    free(temp);
}

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

int main() {
    int N, K; cin >> N >> K;
    string S; cin >> S;
    K--;
    
    if (S.at(K) == 'A') {
        S.at(K) = 'a';
    }
    else if (S.at(K) == 'B') {
        S.at(K) = 'b';
    }
    else {
        S.at(K) = 'c';
    }
    cout << S << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////
LL f(vector<LL>& A) {
	LL ans = abs(A[0]) + abs(A[1]) + abs(A[2]);
	return ans;
}

LL fn(vector<LL>& A,int K) {
	LL ans = 0;
	for (int  k= 0; k < 3; ++k) {
		if (K & (1 << k)) {
			ans -= A[k];
		}
		else {
			ans += A[k];
		}
	}
	
	return ans;
}

void V(vector<LL>& t,vector<LL>& A, vector<LL>& B) {
	for (int i = 0; i < 3; ++i) {
		t[i] = A[i] + B[i];
	}
	return;
}
void solve() {
	int N, M;
	cin >> N >> M;
	vector<vector<LL>> X(N,vector<LL>(3));
	for (int i = 0; i < N; ++i) {
		cin >> X[i][0] >> X[i][1] >> X[i][2];
	}
	///N個中M個食べる。
	//合計の絶対値
	vector<LL> AAA = { LINF,LINF,LINF };
	vector<vector<vector<vector<LL>>>> dp(N+1,
		vector<vector<vector<LL>>>(M+1, vector<vector<LL>>(8,
			vector<LL>(AAA))));
	for (int k = 0; k < (1 << 3); ++k) {
		dp[0][0][k] = { 0,0,0 };
	}
	
	for (int i = 1; i <=N; ++i) {
		for (int m = 0; m <=M; ++m) {
			for (int k = 0; k < (1 << 3); ++k) {
				if (dp[i-1][m][k] != AAA) {
					dp[i][m][k] = dp[i-1][m][k];
				}

				if (m > 0 && dp[i - 1][m - 1][k] != AAA) {
					vector<LL> temp(3,0);
					V(temp, dp[i-1][m-1][k], X[i-1]);
					if (dp[i][m][k] == AAA) {
						dp[i][m][k] = temp;
					}
					else if(fn(dp[i][m][k],k)<fn(temp,k)){
						dp[i][m][k] = temp;
					}
				}
			}
		}
	}
	//f
	LL ans = 0;
	for (int k = 0; k < (1 << 3); ++k) {
		if (dp[N][M][k] != AAA) {
			chmax(ans, f(dp[N][M][k]));
		}
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 478336
#include <iostream>
#include <algorithm>

using namespace std;

long long v[200005];
long long i,n,k;
long long s;

int main()
{
    cin>>n>>k;
    for(i=1;i<=n;i++){
        cin>>v[i];
    }
    sort(v+1,v+n+1);
    for(i=1;i<=n-k;i++){
        s+=v[i];
    }
    cout<<s<<'\n';
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	
 double A,B;
scanf("%lf %lf",&A,&B);

if((A>=1)&&(B<=10^100)&&(B!=0)){
if(A>B){

printf("GREATER");}
 if(A<B){
 
printf("LESS");}
if(A==B){

printf("EQUAL");}
}
return 0;
}


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

ll c[2001][2001]; //コンビネーションテーブル,c[n][k] -> nCk,O(n^2);
int mo=1e+9+7;

void comb_table(int n){
    for(int i=0;i<=n;i++){
        for(int j=0;j<=i;j++){
            if(j==0||j==i){
                c[i][j]=1LL;
            }else{
                c[i][j]=(c[i-1][j-1]+c[i-1][j]);
                c[i][j]%=mo;
            }
        }
    }
}

int main(){

    int n,k;
    cin >> n >> k;
    comb_table(2000);
    ll ans;
    for(int i=1;i<=k;i++){
        ans=0L;
        ll e=0L;
        e=c[k-1][i-1]%mo;
        if(i<=n-k+1){
            ans+=((c[n-k+1][i]%mo)*e)%mo;
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 30080