akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

template <class T>
class Node {
private:
  T data;
  Node<T> *prev;
  Node<T> *next;
public:
  Node() {
    data = -1;
    prev = NULL;
    next = NULL;
  }
  ~Node() {
    if (prev) {
      prev->setNext(next);
    }
    if (next) {
      next->setPrev(prev);
    }
  }
  T getData() {
    return data;
  }
  void setData(T val) {
    data = val;
  }
  Node<T> *getPrev() {
    return prev;
  }
  Node<T> *getNext() {
    return next;
  }
  void setPrev(Node<T> *node) {
    prev = node;
  }
  void setNext(Node<T> *node) {
    next = node;
  }
  void insertBefore(Node<T> *node) {
    prev = node->getPrev();
    next = node;

    if (node->getPrev()) {
      node->getPrev()->setNext(this);
    }
    node->setPrev(this);
  }
  void insertAfter(Node<T> *node) {
    prev = node;
    next = node->getNext();

    if (node->getNext()) {
      node->getNext()->setPrev(this);
    }
    node->setNext(this);
  }
};

int main() {
  int n, x;
  bool f;
  string s;
  Node<int> *root, *first, *tmp;

  root = new Node<int>;
  root->setNext(root);
  root->setPrev(root);

  cin >> n;

  while (n--) {
    cin >> s;
    if (s == "insert") {
      cin >> x;
      tmp = new Node<int>;
      tmp->setData(x);
      tmp->insertAfter(root);
    } else if (s == "delete") {
      cin >> x;
      tmp = root;
      f = false;
      while (tmp->getNext() != root) {
        tmp = tmp->getNext();
        if (tmp->getData() == x) {
          f = true;
          break;
        }
      }
      if (f) {
        delete tmp;
      }
    } else if (s == "deleteFirst") {
      delete root->getNext();
    } else if (s == "deleteLast") {
      delete root->getPrev();
    }
  }

  tmp = root;
  while (1) {
    if (tmp->getNext() == root) {
      break;
    }
    tmp = tmp->getNext();
    if (tmp->getNext() == root) {
      cout << tmp->getData();
    } else {
      cout << tmp->getData() << ' ';
    }
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 34320
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N, M, X, Y;
int x[100], y[100];

int main() {
	cin >> N >> M >> X >> Y;
	REP(i, N) scanf("%d", x + i);
	REP(i, M) scanf("%d", y + i);
	
	sort(x, x + N);
	sort(y, y + M);
	
	int ans = max(X, x[N - 1]) + 1;
	
	puts(ans <= min(Y, y[0]) ? "No War" : "War");
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 1000 + 5;
int n;
vector<int> ans;

int main() {
    scanf("%d", &n);
    if(n == 3) {
        puts("2 5 63");
        return 0;
    }
    int last = 0, cnt = 0;
    for(int i = 1; cnt < n/8*8; i++) {
        if(i%6 != 1 && i%6 != 5) {
            ans.push_back(i);
            last = i;
            cnt++;
        }
    }
    int rest = n - cnt;
    // 2 3 4 6 8 9 10 12
    if(rest >= 2) {
        rest -= 2;
        ans.push_back(last+3);
        ans.push_back(last+9);
    }
    if(rest >= 2) {
        rest -= 2;
        ans.push_back(last+2);
        ans.push_back(last+4);
    }
    if(rest >= 2) {
        rest -= 2;
        ans.push_back(last+8);
        ans.push_back(last+10);
    }
    if(rest) {
        ans.push_back(last+6);
    }
    for(int i = 0; i < ans.size(); i++) {
        printf("%d%c", ans[i], " \n"[i+1==ans.size()]);
    }
    return 0;
}


Measured memory_bytes: 512
from copy import copy
N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()
A1 = copy(A)
A2 = copy(A)
B1 = []
B2 = []
i=0
while A1 and A2:
    if i%2 == 0:
        B1.append(A1.pop(0))
        B2.append(A2.pop(-1))
    else:
        B1.append(A1.pop(-1))
        B2.append(A2.pop(0))
    i += 1
B1.append(B1[0])
B2.append(B2[0])
C1 = [abs(B1[i+1]-B1[i]) for i in range(len(B1)-1)]
C2 = [abs(B2[i+1]-B2[i]) for i in range(len(B2)-1)]
print(max(sum(C1)-min(C1),sum(C2)-min(C2)))

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

#define rep(i,a,b)                for(ll i=a;i<b;i++)
#define re(i,b)                for(ll i=0;i<b;i++)
#define repr(i,n)                for(ll i=n-1;i>=0;i--)
#define ll long long
#define ld long double
#define llu long long unsigned
#define vll std::vector<ll>
#define mll std::map<ll, ll>
#define mpll std::map<pair<ll,ll>, ll>
#define sll std::set<ll>
#define msll std::multiset<ll>
#define all(c) c.begin(), c.end()
#define allr(c) c.rbegin(), c.rend()
#define srt(x) sort(all(x))
#define rsrt(x) sort(allr(x))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define s(yy) ll yy;cin>>yy
#define mod 1000000007
#define maxlong 9223372036854775808


/*
###################################################### 
#                                                    #
#                     @author                        #
#                  Parth Lathiya                     #
#      https://www.cse.iitb.ac.in/~parthiitb/        #
#                                                    #
###################################################### 
*/


int main()
{

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

	


//--------------------------------------------------------------------------------------
	
	s(n);
	s(a);
	s(b);
	ll h[n];
	ll sum=0;
	rep(i,0,n){
		cin>>h[i];
		sum+=h[i];
	}
	// sort(h,h+n);
	// reverse(h,h+n);

	ll low=-1;
	// cout<<low;
	ll high=1000000000;
	// cout<<sum/a;
	ll aa[n];
	// cout<<low<<high<<endl;
	while(low<high-1){

		ll mid=(low+high)/2;
		// cout<<low<<high<<endl;;
		ll suma=0;
		ll f=0;
		bool bb;
		rep(i,0,n){
			aa[i]=ceil((h[i]-mid*b)*1.0/(a-b));
			if(aa[i]<0)
				continue;
			// cout<<h[i]<<mid<<b<<a<<aa[i]<<endl;;
			if(aa[i]>(mid-suma)){
				f=1;break;	
			}
			suma+=aa[i];
		// cout<<i<<aa[i]<<endl;
		}
	// cout<<suma;
		if(f==1)bb=false;
		else if(suma<=mid)bb=true;
		else
			bb=false;
		// cout<<mid<<" "<<bb<<endl;
		if(bb)
			high=mid;
		else
			low=mid;
	}


	cout<<high;

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

	return 0;
}


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

int n,k;
int A[10005];

int main(){
  scanf("%d%d",&n,&k);
  for ( int i  = 0; i  < n; i++ ) scanf("%d",&A[i]);
  sort(A,A+n);
  
  int sum = 0;
  for( int i = 0;  i < k; i++ ) sum += A[i];
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 3816
import sys
sys.setrecursionlimit(10**6)
H, N = map(int, input().split())
P = [0]*H
for i in range(N):
    x, y = map(int, input().split())
    P[y] |= 1 << x

memo = [[-1]*16 for i in range(H)]
for i in range(16):
    memo[H-1][i] = 0
def dfs(i, state):
    if memo[i][state] != -1:
        return memo[i][state]
    p = P[i+1]
    s = state | p
    r = dfs(i+1, p)
    if s & 0b0011 == 0:
        r = max(r, dfs(i+1, p | 0b0011) + 1)
    if s & 0b0110 == 0:
        r = max(r, dfs(i+1, p | 0b0110) + 1)
    if s & 0b1100 == 0:
        r = max(r, dfs(i+1, p | 0b1100) + 1)
    if s & 0b1111 == 0:
        r = max(r, dfs(i+1, 0b1111) + 2)
    memo[i][state] = r
    return r
print(dfs(0, P[0]))


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

typedef long long ll;

#define v(T) vector<T>
#define ttt(T) tuple<T, T, T>
#define pb push_back
#define mp make_pair
#define rep(i, s, n) for(int i=s;i<n;i++)
#define repeq(i,s,n) for(int i=s;i<=n;i++)
#define poiu(n) for(int i=0; i < n; i++)
#define MOD 1000000007
#define endl '\n'

template<typename T>
void max_self(T& a, T b) { a=a>b?a:b; }
template<typename T>
void min_self(T& a, T b) { a=a<b?a:b; }

using namespace std;

int n;


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

    cin >> n;
    
    int temp_one = n/500;
    int temp_two = (n%500)/5;
    
    cout << (temp_one*1000)+(temp_two*5) << endl;
    


    return 0;

}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main {
	static PrintStream out = System.out;
	static Scanner in = new Scanner(System.in);

	public static void main(String[] args) {
		int n = in.nextInt();
	    int[] v = new int[n+1];
	    for (int i = 0; i <= n; i++) {
	        v[i] = i;
	    }
	    int q = in.nextInt();
	    
	    for (int i = 0; i < q; i++) {
	        int com = in.nextInt();
	        int x = in.nextInt();
	        int y = in.nextInt();
	        if (x > y) {
	            int tmp = x;
	            x = y;
	            y = tmp;
	        }
	        if (com == 0) {
	            int tmp = v[y];
	            for (int j = 0; j <= n; j++) {
	                if (v[j] == tmp) {
	                    v[j] = v[x];
	                }
	            }
	        } else {
	            out.println(v[x] == v[y] ? 1 : 0);
	        }
	    }
	}
}

Measured memory_bytes: 63520
ABC = sorted([int(n) for n in input().split()])
# N = int(input())
# a = [int(input()) for _ in range(N)]
# S = str(input())
# L = len(S)
# T = str(input())
if ABC[0] == 5 and ABC[1] == 5 and ABC[2] == 7:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 2940
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>

using namespace std;

#define N_MAX 51

int N, K;
int V[N_MAX];

int sim(int l, int r)
{
	if (l + r > N || l+r>K){
		return -1;
	}
	vector<int> table;
	for (int i = 0; i < l; i++){
		table.push_back(V[i]);
	}
	for (int i = N - 1; i >= N - r; i--){
		table.push_back(V[i]);
	}

	sort(table.begin(), table.end());

	int remain = K - (l + r);
	int sum = 0;
	for (int i = 0; i < table.size(); i++){
		if (table[i] < 0 && remain >0){
			remain--;
			continue;
		}
		sum += table[i];
	}

	return sum;
}

void solv()
{
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; i++){
		scanf("%d", V + i);
	}

	int ret = 0;
	for (int left = 0; left <= K; left++){
		for (int right = 0; right <= K; right++){
			ret = max(ret, sim(left, right));
		}
	}

	printf("%d", ret);

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 256
using static System.Console;
class Program
{
    static void Main(string[] args)
    {
        string s = ReadLine();
        int cout = 1;
        string ans = "";
        foreach(char a in s)
        {
            if(cout % 2 == 1)
            {
                ans += a;
            }
            cout++;
        }
        WriteLine(ans);
    }
}

Measured memory_bytes: 34772
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
#include <assert.h>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

vector<string> answers;
vector<int> group;
map<vector<int>, int> dp;
int total_questions;
int total_ppl;

int dfs(const vector<int>& current,int used){
  if(current.size() <= 0) return -1;
  if(current.size() == 1) return 0;

  if(dp.count(current)) return dp[current];

  int res = INF;
  for(int question_i=0;question_i<total_questions;question_i++){
    if(used & (1<<question_i)) continue;

    vector<int> next[256];
    for(int i = 0; i < current.size(); i++){
      int ppl_i = current[i];
      char ans = answers[ppl_i][question_i];
      next[ans].push_back(ppl_i);
    }

    int cost = max(dfs(next['0'],
                       used | (1<<question_i)) + 1,
                   dfs(next['1'],
                       used | (1<<question_i)) + 1);
    res = min(res,cost);
  }
  return (dp[current] = res);
}

int main(){
  while(~scanf("%d %d",&total_questions,&total_ppl)){
    if(total_questions == 0 && total_ppl == 0) break;
    group.clear();
    answers.clear();
    dp.clear();

    for(int ppl_i = 0; ppl_i < total_ppl; ppl_i++){
      string ans;
      cin >> ans;
      answers.push_back(ans);
      group.push_back(ppl_i);
    }
    
    printf("%d\n",dfs(group,0));
  }
}

Measured memory_bytes: 3384
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 
string S;
map<char,int> st;
int main(){
    cin >> S;
    bool flag = true;
    rep(i,sz(S)){
        st[S[i]]++;
        if(st[S[i]] > 1) flag = false;
    }
    if(flag) cout << "yes" << '\n';
    else cout << "no" << '\n';
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;


int main(void) {

    int n;
    while(cin >> n, n){
        vs s(n);
        rep(i,n) cin >> s[i];

        int co[26] = {};
        int c[26] = {};//leading zeros
        rep(i,n){
            if(s[i].size()>1)c[s[i][0]-'A']++;
            int t[26] = {};
            rep(j,s[i].size()){
                rep(k,26)t[k]*=10;
                t[s[i][j]-'A']++;
            }
            if(i+1<n)rep(j,26)co[j] += t[j];
            else rep(j,26)co[j] -= t[j];
        }
        int a[26] = {};
        rep(i,n)rep(j,s[i].size())a[s[i][j] - 'A']++;

        vi v;
        rep(i,26)if(a[i])v.push_back(i);

        while(v.size()<10)v.push_back(-1);
        sort(all(v));
        int ans = 0;

        do{
            int alph[26];
            rep(i,26) alph[i] = -1;
            rep(i,v.size())if(v[i] >= 0)alph[v[i]]=i;

            if(v[0] >= 0 && c[v[0]])continue;

            int sum = 0;
            rep(i,26)if(alph[i]>=0){
                sum += co[i] * alph[i];
            }

            if(sum == 0){
                ans++;
            }
        }while(next_permutation(all(v)));

        cout << ans << endl;

    }
}



Measured memory_bytes: 3008
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        int k = in.nextInt();
        int[] vals = in.nextIntArr(n);
        int[] dp = new int[n];
        dp[0] = 0;
        for (int i = 1; i < n; i++) {
            dp[i] = dp[i - 1] + Math.abs(vals[i] - vals[i - 1]);
            for (int j = i - 1; j >= Math.max(0, i - k); j--) {
                dp[i] = Math.min(dp[i], dp[j] + Math.abs(vals[i] - vals[j]));
            }
            //out.println(dp[i]);
        }
        out.println(dp[n - 1]);
        out.close();

    }


    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(InputStream i) {
            br = new BufferedReader(new InputStreamReader(i));
            st = new StringTokenizer("");
        }
        public String next() throws IOException {
            if (st.hasMoreTokens()) {
                return st.nextToken();
            }
            else
                st = new StringTokenizer(br.readLine());
            return next();
        }
        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }
        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
        public String nextLine() throws IOException {
            if (!st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
                return nextLine();
            }

            String ret = "";
            while (st.hasMoreTokens()) {
                ret += st.nextToken();
            }
            return ret;
        }
        public int[] nextIntArr(int size) throws IOException {
            int[] arr = new int[size];
            for (int i = 0; i < arr.length; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }
        public long[] nextLongArr(int size) throws IOException {
            long[] arr = new long[size];
            for (int i = 0; i < arr.length; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
        public double[] nextDoubleArr(int size) throws IOException {
            double[] arr = new double[size];
            for (int i = 0; i < arr.length; i++) {
                arr[i] = nextDouble();
            }
            return arr;
        }
    }
}

Measured memory_bytes: 43716
function Main(input){
  var inp = input.split('\n');
  var N = parseInt(inp[0].trim());
  var D = parseInt(inp[1].trim().split(' ')[0]);
  var X = parseInt(inp[1].trim().split(' ')[1]);
  
  var A = [];
  for(var i = 2; i < inp.length; i++){
    var a = parseInt(inp[i].trim());
    A.push(a);
  }
  
  var chocoCount = 0;
  for(var i = 0; i < A.length; i++){
    var temp = count(A[i]);
    chocoCount += temp;
  }

  console.log(chocoCount + X);

  function count(c){
    var day = 0;
    var i = 0; 
    while(true){ 
      day = i * c + 1;
      if(day <= D){
        i++;
      } else {
        break;
      }
    }
    return i;
  }


}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}



///////////////////////////


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

	vector<vector<ll>> A(N + 1, vector<ll>(N + 1));

	repn(i, N)repn(j, N) cin >> A[i][j];

	ll ans = 0;
	repn(i, N) for (ll j = i + 1; j <= N; j++) {

		if (ans == -1) { continue; }

		ll b = 1;
		repn(k, N) {
			if (k == i || k == j){continue; }
			if (A[i][k] + A[k][j] == A[i][j]) { b = 0; }
			if (A[i][k] + A[k][j]<A[i][j]) { b = -1; }
		}
		if (b == 1) { ans += A[i][j]; }
		if (b == -1) { ans = -1; }
	}

	cout << ans;

}


Measured memory_bytes: 1024
use std::io::{BufRead, BufWriter, Write};

fn main() {
    let stdin = std::io::stdin();
    let stdout = std::io::stdout();
    solve(&mut stdin.lock(), &mut BufWriter::new(stdout.lock()));
}

fn solve<R: BufRead, W: Write>(stdin: &mut R, stdout: &mut BufWriter<W>) {
    let (n, k): (u64, u64) = stdin.gets().split(' ').values();
    if k % 2 == 1 {
        writeln!(stdout, "{}", (n / k).pow(3)).unwrap();
    } else {
        let t = ((n + k / 2) / k).pow(3) + (n / k).pow(3);
        writeln!(stdout, "{}", t).unwrap();
    }
}

trait Gets { fn gets(&mut self) -> String; }
impl<T: std::io::BufRead> Gets for T {
    fn gets(&mut self) -> String { self.lines().next().unwrap().unwrap() } }

trait Values<T> { fn values(&mut self) -> T; }
impl<'a, I, T1, T2> Values<(T1, T2)> for I
    where I: Iterator<Item=&'a str>,
          T1: std::str::FromStr, T1::Err: std::fmt::Debug,
          T2: std::str::FromStr, T2::Err: std::fmt::Debug {
    fn values(&mut self) -> (T1, T2) {
        (self.next().unwrap().parse().unwrap(),
         self.next().unwrap().parse().unwrap())
    }
}

Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

typedef long long ll;

int main() {

	string s;
	cin >> s;

	ll ans = 0;
	ll wpos = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'W') {
			ans += i - wpos;
			wpos++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    vector<vector<int>> C(3, vector<int>(3));
    rep(i, 3) {
        rep(j, 3) cin >> C[i][j];
    }
    int a[3], b[3];
    a[0] = 0;
    b[0] = C[0][0] - a[0];
    b[1] = C[0][1] - a[0];
    b[2] = C[0][2] - a[0];
    a[1] = C[1][0] - b[0];
    a[2] = C[2][0] - b[0];
    rep(i, 3) {
        rep(j, 3) {
            if(C[i][j] != a[i] + b[j]) {
                puts("No");
                return 0;
            }
        }
    }
    puts("Yes");
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
   int n,k,i,count=0;
   scanf("%d%d",&n,&k);

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

   for(i=0;i<n;i++){
      if(h[i]>=k) count++;
   }

   printf("%d\n",count);

   return 0;
}

Measured memory_bytes: 512
<STDIN>;
my @p = map{$_-0}split / /, <STDIN>;
my %s=();
map { $s{$_}++; } @p;
my $c = 0;
foreach(keys(%s)){
    if($s{$_} >= $_){
        $c+=$s{$_}-$_;
    }else{
        $c+=$s{$_};
    }
}
print $c;

Measured memory_bytes: 31468
import copy
S = input()
S = S[::-1]
dp = [0 for _ in range(13)]
dp[0] = 1

mod = int(1e9+7)

def calc(dp,i,k):
  dpw = [0 for _ in range(13)]
  if S[i] == '?':
    X = [i for i in range(10)]
  else:
    X = [int(S[i])]
  for j in range(13):
    for x in X:
      dpw[(j+x*k)%13] += dp[j]  
      dpw[(j+x*k)%13] %= mod
  return dpw

keta = 1
for i in range(len(S)):
  dp = calc(dp,i,keta)
  keta = keta * 10 % 13

#print(dp)
print(dp[5])
#print(sum(dp))

Measured memory_bytes: 75096
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

namespace CSharp_Shell
{

    public static class Program 
    {
        public static void Main() 
        {
        	int N = int.Parse(Console.ReadLine());
        	int b = 10;
        	if(1000>=N){b = 1000-N;}
        	for(int i=1; N>=i*1000; i++)
        	{
        		if(1000*i==N){b=0;}
        		else {b = 1000*(i+1) - N;}
        		//Console.WriteLine(i);
        	}
        	Console.WriteLine(b);
        }
    }
}

Measured memory_bytes: 27408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = LLONG_MAX;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */

int main() {
    int n,k;cin >> n >> k;
    string s;
    cin >> s;
    rep(i, k-1)cout << s[i];
    cout << (char)tolower(s[k-1]);
    for(int i = k;i<n;i++) cout << s[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 3508
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N + 1];
		
		for(int i = 1; i <= N; i++) {
			a[i] = sc.nextInt();
		}
		
		int x = 1;
		int count = 0;
		int check = 0;
		
		for(int i = 1; i <= N; i++) {
			x = a[x];
			count++;
			if(x == 2) {
				System.out.println(count);
				check++;
				break;
			}
		}
		if(check == 0) {
			System.out.println(-1);
		}
	}
}


Measured memory_bytes: 50924
/**
 *    author:  math2do
 *    created: 09.09.2020 00:48:18
**/

#include <bits/stdc++.h>

using namespace std;

template <typename T>
class fenwick {
 public:
  vector <T> bit;
  vector <T> arr;
  int init = 0;
  int n;
  fenwick(int _n) : n(_n + 1) { 
    arr = vector <T>(n, init);
    bit = vector <T>(n, init);
  }

  fenwick(vector <int>& nums) : fenwick(nums.size()) {
    int len = nums.size();
    for (int i = 0; i < len; i++) {
      modify(i, nums[i]);
    }                      
  }

  void modify(int i, T val) { 
    int idx = i + 1;
    while (idx < n) {
      bit[idx] = max(bit[idx], val);
      idx = idx + (idx & -idx);
    }
    arr[i] = val;
  }

  T get(int i) {
    T res = init;
    int idx = i + 1;
    while (idx > 0) {
      res = max(res, bit[idx]);
      idx = idx - (idx & -idx);
    }
    return res;
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector <int> h(n);
  vector <int> b(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  } 
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  } 
  vector <long long> dp(n + 1, 0);
  fenwick <long long> fn(n + 1);
  for (int i = 0; i < n; i++) {
    long long good = fn.get(h[i] - 1);
    long long dec = max(dp[h[i]], good + b[i]);
    if (dec > dp[h[i]]) {
      fn.modify(h[i], dec);
      dp[h[i]] = dec;
    } 
  }

  long long ans = 0;
  for (int i = 0; i <= n; i++) {
    ans = max(ans, dp[i]);
  } 
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9524
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool chmax(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF 1000000007 //4000000000000000037
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  ll N;
  cin>>N;

  ll lyu[N+1];

  lyu[0]=2; lyu[1]=1;

  reps(i,2,N+1){
    lyu[i]=lyu[i-1]+lyu[i-2];
  }

  cout<< lyu[N] <<"\n";

}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//????¨????
		int sum = 0;
		//??°?????????
		while(true){
			//??????????????? m
			int m = sc.nextInt();
			//??????????????? f
			int f = sc.nextInt();
			//???????¨? r
			int r = sc.nextInt();
			//??????????????????-1?????£????????????
			if(m == -1 && f == -1 && r == -1){
				break;
			}
			//????¨????
			sum = m + f;
			//??????????????¶???
			//???????????????????????????????¬??????????F
			if(m == -1 || f == -1){
				System.out.println("F");
			//??????????????¶???
			}else if(sum >= 80){
				System.out.println("A");
			}else if(80 > sum && sum >= 65){
				System.out.println("B");
			}else if(65 > sum && sum >= 50){
				System.out.println("C");
			}else if(50 > sum && sum >= 30){

				if(r >= 50){
					System.out.println("C");
				}else{
					System.out.println("D");
				}
			}else{
				System.out.println("F");
			}
		}
	}
}

Measured memory_bytes: 26384
#include <iostream>
#include <stdlib.h>

int main(void) {
  int a,b;
  std::cin >> a >> b;
  if (a < b) {
    std::cout << "a < b" << '\n';
  } else if (a == b) {
    std::cout << "a == b" << '\n';
  } else {
    std::cout << "a > b" << '\n';
  }
  return EXIT_SUCCESS;
}

Measured memory_bytes: 3024
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const S = arg[1].split("");
    
    let r = 0;
    let g = 0;
    let b = 0;
    
    for(let i=0; i<N; i++) {
        if(S[i] === "R") {
            r++;
        }
        
        if(S[i] === "G") {
            g++;
        }
        
        if(S[i] === "B") {
            b++;
        }
    }
    
    let answer = r * g * b;

    for(let i=0; i<N; i++) {
        for(let j=i+1; j<N; j++) {
            if(S[i] === S[j]) continue;
            
            let k = j + (j - i);
            
            if(k >= N) continue;
            
            // console.log(S[i])
            // console.log(S[j])
            // console.log(S[k])
            // console.log("-----")
            
            // 等差数列になっているものを引く
            if(S[j] !== S[k] && S[i] !== S[k]) {
                answer--;
            }
        }
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 35140
#include<stdio.h>
int main(void)
{
  int h,w,a,b;
  scanf("%d%d%d%d",&h,&w,&a,&b);
  for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
      if((i<b+1&&j>a)||(i>b&&j<a+1)){printf("1");}else{printf("0");}
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 1152
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
//const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

struct edge
{
	int s, t, cost;
	edge(int s, int t, int cost) :s(s), t(t), cost(cost) {}
	edge() :edge(-1, -1, -1) {}
};

edge edges[5010];
vector<int> dedges[3000];
int d[3000];
int V, E, P;
bool op[3000];
bool checked[3000];

int shortest_path(int s)
{
	rep(i, 0, V)d[i] = INF;
	d[s] = 0;

	for(int k=0;;k++)
	{
		bool update = false;

		rep(i, 0, E)
		{
			if (d[edges[i].s] != INF && d[edges[i].t] > d[edges[i].s] + edges[i].cost)
			{
				d[edges[i].t] = d[edges[i].s] + edges[i].cost;
				update = true;
				if (k > V)
				{
					if (k == 3 * V)
					{
						return max(0LL, -d[V - 1]);
					}
					if (op[edges[i].t])
					{
						return INF;
					}
				}
			}
		}

		if (!update)
		{
			break;
		}
	}

	return max(0LL, -d[V - 1]);
}

bool dfs(int v, bool pok)
{
	if (checked[v])return op[v];
	checked[v] = true;
	if (v == V - 1)
	{
		pok = true;
	}
	bool ok = pok;
	for (auto e : dedges[v])
	{
		ok = dfs(e, pok) || ok;
	}
	op[v] = ok;
	return ok;
}

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

	cin >> V >> E >> P;
	int a, b, c;
	rep(i, 0, E)
	{
		cin >> a >> b >> c;
		a--, b--, c -= P;
		edges[i] = edge(a, b, -c);
		if (a != b)dedges[a].push_back(b);
	}

	dfs(0, false);
	int ans = shortest_path(0);

	if (ans == INF)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n;
  cin >> s;
  int ans = 0;
  for(int i=0; i<n-2; i++) {
    if(s.substr(i,3)=="ABC") ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;

struct CHT{
	using D = ll;
	typedef pair<D,D> P;
	vector<P> deq;
	int s,sd,t;
	void init(int N){
		deq.resize(N);
		s=0,sd=0,t=0;
	}
	void add(D a,D b){		//add ax+b     a:(広義)単調減少!!!
		b=-b;
		P p(a,b);
		while(s+1<t&&check(deq[t-2],deq[t-1],p)) t--;
		deq[t++]=p;
	}
	D incr_query(D x){		//x:単調増加の時,これを繰り返し呼ぶ(間にaddが挟まるのはOK)
		x=-x;
		while(s+1<t&&f(deq[s],x)>=f(deq[s+1],x)) s++;
		return -f(deq[s],x);
	}
	D decr_query(D x){		//x:単調減少の時,これを繰り返し呼ぶ(間にaddが挟まるのはOK)
		x=-x;
		if(sd>=t) sd=t-1;
		while(sd+1<t&&f(deq[sd],x)>=f(deq[sd+1],x)) sd++;
		while(sd>0&&f(deq[sd],x)>f(deq[sd-1],x)) sd--;
		return -f(deq[sd],x);
	}
	D query(D x){
		x=-x;
		int lb=s-1,ub=t-1;
		while(ub-lb>1){
			int m=(lb+ub)/2;
			if(isright(deq[m],deq[m+1],x)) lb=m;
			else ub=m;
		}
		return -f(deq[ub],x);
	}

	bool isright(P& a,P& b,D x){
		return f(a,x)>=f(b,x);
	}
	bool check(P& a,P& b,P& c){
		return (b.fs-a.fs)*(c.sc-b.sc)>=(b.sc-a.sc)*(c.fs-b.fs);
	}
	D f(P &p,int x){
		return p.fs*x+p.sc;
	}
}cht;

ll inf=1e18;
const int MN=300000;
int N;
ll T[MN];

ll le[MN+1],ri[MN+1];

ll notuse[MN];
ll use[MN];

void calc(int L,int R){
	if(L==R) return;
	int m=(L+R)/2;
	
	//L<=j<=m<=p<i<=R
	cht.init(m-L+1);
	for(ll j=L;j<=m;j++) cht.add(-j,le[j]+(j*j-j)/2);
	ll mx=-inf;
	for(ll i=R;i>=m+1;i--){
		ll val=cht.incr_query(i)+(i*i+i)/2+ri[N-i];
		chmax(mx,val);
		chmax(use[i-1],mx);
	}

	//L<=j<=p<m<i<=R
	cht.init(R-m);
	for(ll i=m+1;i<=R;i++) cht.add(-i,ri[N-i]+(i*i+i)/2);
	mx=-inf;
	for(ll j=L;j<m;j++){
		ll val=cht.query(j)+(j*j-j)/2+le[j];
		chmax(mx,val);
		chmax(use[j],mx);
	}

	calc(L,m);
	calc(m+1,R);
}
int main(){
	cin>>N;
	rep(i,N) cin>>T[i];

	cht.init(N);
	le[0]=0;
	for(ll i=0;i<N;i++){
		cht.add(-i,le[i]+(i*i-i)/2);
		le[i+1]=max(le[i]+T[i],cht.query(i+1)+(i+1)*(i+2)/2);
	}
	cht.init(N);
	ri[0]=0;
	for(ll i=0;i<N;i++){
		cht.add(-i,ri[i]+(i*i-i)/2);
		ri[i+1]=max(ri[i]+T[N-1-i],cht.query(i+1)+(i+1)*(i+2)/2);
	}
	
	rep(i,N) notuse[i]=le[i]+T[i]+ri[N-1-i];

	ll sum=0;
	rep(i,N) sum+=T[i];

	calc(0,N);

//	rep(i,N) printf("use[%d]=%lld\n",i,use[i]);
//	rep(i,N) printf("notuse[%d]=%lld\n",i,notuse[i]);
	

	int M;
	cin>>M;
	rep(i,M){
		int p;
		ll x;
		cin>>p>>x;
		p--;
		ll ans=max(use[p],notuse[p]-T[p]+x);
		cout<<ans-(sum-T[p]+x)<<endl;
	}
}


Measured memory_bytes: 18944
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>   // popen, pclose, fgets
#include <cstdlib> 
using namespace std;
#define rep0(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>;
using ll = long long; //long longをllだけにした
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll =vector<vvll>;
const double PI=3.14159265358979323846;
//小数点以下を指定したい時　　→→→→  cout << fixed << setprecision();

int main() {
    int n,A[3][3],b[10];
    rep0(i,3){
        rep0(j,3){
            cin>>A[i][j];
        }
    }
    cin>>n;
    rep0(i,n){
        cin>>b[i];
    }
    bool mark[3][3];
    rep0(i,3){
        rep0(j,3){
            mark[i][j]=false;
            rep0(k,n){
                if(b[k]==A[i][j]){
                    mark[i][j]=true;
                }
            }
        }
    }
    string ans="No";
    rep0(i,3){
        if(mark[i][0] and mark[i][1] and mark [i][2]){
            ans="Yes";
        }
        if(mark[0][i] and mark[1][i] and mark [2][i]){
            ans="Yes";
        }
    }
    if(mark[0][0] and mark[1][1] and mark[2][2]){
        ans="Yes";
    }
     if(mark[0][2] and mark[1][1] and mark[2][0]){
        ans="Yes";
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <ctype.h>
#include <cstdio>
using namespace std;

int main ()
{
    string str;
    getline (cin, str);
    for (int i = 0; i < str.size(); i++ )
        putchar(toupper(str[i]));
    cout << endl;

    return 0;
}

Measured memory_bytes: 1164
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

string S;

signed main()
{
	cin >> S;
	if (S == "Sunny") cout << "Cloudy" << endl;
	if (S == "Cloudy") cout << "Rainy " << endl;
	if (S == "Rainy") cout << "Sunny" << endl;
}




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

int main() {
  int n;cin>>n;
  vector<vector<int>> vec(n,vector<int>(n,-1));
  rep(i,n){
    int a;cin>>a;
    rep(j,a){
      int x,y;cin>>x>>y;
      x--;
      vec[i][x]=y;//i番目の人がx番目の人が正直者か不親切な人か言った
    }
  }
  int ans=0;
  rep(bit,1<<n){
    vector<int> d(n);
    //1~n番目の人が正直者か不親切な人かbit全探索
    rep(j,n)if(bit&(1<<j))d[j]=1;//j番目の人が正直者なら1
    bool ok=true;
    rep(j,n)if(d[j]){
      //j番目の人が正直者
      rep(k,n){
        if(vec[j][k]==-1)continue;//相手の証言なし
        if(vec[j][k]!=d[k])ok=false;//自分の証言と相手の証言が矛盾
      }
    }
    if(ok)ans=max(ans,__builtin_popcount(bit));//bitの1の個数、すなわち正直者の人数
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

using namespace std;

constexpr int N = 1e5 + 10;

long long n, m, v, p, a[N], ans;

bool cmp (long long lhs, long long rhs) {
    return rhs < lhs;
}

bool can (long long pos) {
    // pos mitone biad ya na
    if (pos < p)
        return true;
    if (a[pos] + m < a[p - 1])
        return false;
    long long remain = v - (p - 1) - (n - pos);
    if (remain <= 0)
        return true;
    long long saghf = a[pos] + m;
    long long nowcnt = 0;
    long long nowpos = 0;
    for (int i = p - 1; i < pos; i++) {
        long long diff = saghf - a[i];
        if (diff == 0)
            continue;
        if (diff + nowpos >= m)
            nowcnt++;
        nowpos = (diff + nowpos) % m;
    }
    if (nowcnt < remain)
        return false;
    return true;
}

int bin (int b, int e) {
    if (b + 1 == e)
        return e;
    int mid = (b + e) >> 1;
    if (can (mid))
        return bin (mid, e);
    return bin (b, mid);
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m >> v >> p;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort (a, a + n, cmp);
    cout << bin (0, n) << '\n';
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
struct edge {
    int to; 
    int weight;
    edge(int t, int w) : to(t),weight(w) {}
};
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int N, M;
int ans = 0;
void dfs(const Graph &G, int v,int cnt, set<int> seen) {
    seen.insert(v); // v を訪問済にする
    if(cnt == N) ans++;
    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) {
        if (seen.count(next_v)) continue; // next_v が探索済だったらスルー
        int next_cnt = cnt + 1;
        set<int> next_seen = seen;
        dfs(G,next_v,next_cnt,next_seen); // 再帰的に探索
    }
}

int main(){

    // 頂点数と辺数
    cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // 頂点 0 をスタートとした探索
    set<int> seen; // 全頂点を「未訪問」に初期化
    dfs(G,0,1,seen);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = A + B;
		if (C >= 24) {
			C = C - 24;
		}
		// 出力
		System.out.println(C);
	}
}


Measured memory_bytes: 24020
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
using namespace std;
template <class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b<a) {a = b; return 1;} return 0;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    string s;
    cin >> s;
    set<char> st;
    string v = "abcdefghijklmnopqrstuvwxyz";
    rep(i, s.size()) {
        st.insert(s[i]);
    }
    map<char,int> mp;
    rep(i,v.size()) {
        int cnt = 0;
        for(auto sss: st) {
            if (sss == v[i]) cnt++;
        }
        if (cnt==0) {
            cout << v[i] << "\n";
            return 0;
        }
    }
    cout << "None" << "\n";
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); i++)
#define rrep(i, to) for (int i = (to) - 1; i >= 0; i--)
#define repf(i, from, to) for (int i = (from); i < (to); i++)
#define all(v) v.begin(), v.end()
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

int main() {
  int k, s;

  cin >> k >> s;

  int count = 0;
  rep(x, k + 1) rep(y, k + 1) {
    int z = s - x - y;

    if(z >= 0 && z <= k) {
      count++;
    }
  }

  cout << count << endl;
}

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

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

    long long i,j,k,l,m,n,p,q;
    while(cin>>i>>j>>k>>n)
    {
        l=0;
        while(i>=j)
        {
            l++;
            j*=2;
        }
        while(j>=k)
        {
            l++;
            k*=2;
        }
        if(l<=n)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}


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

int main() {
    
    int x[12];
    int y[12];

    scanf("%d %d %d",&x[0],&x[1],&x[2]);
    scanf("%d %d %d",&x[3],&x[4],&x[5]);
    scanf("%d %d %d",&x[6],&x[7],&x[8]);
    
    int n;
    scanf("%d",&n);
    
	for(int i = 1 ; i <= n ; i++)
        scanf("%d",&y[i]);
    
    for(int i = 0 ; i < 9 ; i++){
        for(int j = 1 ; j <= n ; j++){
            if(x[i] == y[j])
                x[i] = 0;
        }
    }
    
    if(x[0] == x[1] && x[1] == x[2])
        cout << "Yes" << endl;
    else if(x[3] == x[4] && x[4] == x[5])
        cout << "Yes" << endl;
    else if(x[6] == x[7] && x[7] == x[8])
        cout << "Yes" << endl;
    else if(x[0] == x[4] && x[4] == x[8])
        cout << "Yes" << endl;
    else if(x[2] == x[4] && x[4] == x[6])
        cout << "Yes" << endl;
    else if(x[0] == x[3] && x[3] == x[6])
        cout << "Yes" << endl;
    else if(x[1] == x[4] && x[4] == x[7])
        cout << "Yes" << endl;
    else if(x[2] == x[5] && x[5] == x[8])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 3688