akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long int
#define ipair pair<ll, ll>
#define debug(a, st, en){for(ll i = st; i <= en; i++){cout << a[i] << " "; } cout << endl;}
#define debuga(a) cout << #a << " = " << a << endl;
#define mp make_pair
#define pb push_back
#define is insert
#define endl "\n"
#define FOR(i, a, b) for(ll i = a; i <= b; i++)
#define FORD(i, a, b) for(ll i = a; i >= b; i--)
#define EACH(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define cins(_x, a, b) {for(ll $i = a; $i <= b; $i++) cin >> _x[$i];}
#define EPS 0.0000000001
#define fl float
#define db double
#define MOD 1000000007
#define MAX 1000007

using namespace std;

ll n, a, b;

int main() {
    cin >> n >> a >> b;
    cout << min(a, b) << " " << max(0LL, a+b-n) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;

#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))
#define LLONG_MAX numeric_limits<long long>::max()
#define INT_MAX numeric_limits<int>::max()

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " " << p.second << "}";
	return os;
}

template <typename T>
void say(vector<T>& vec, string pad = " ") {
	for (const T& elem : vec)
		cout << elem << pad;
}


/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	yn(A <= C && C <= B);

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<list>
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
#define _GLIBCXX_DEBUG

using namespace std;


int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> P(M);
    vector<int> d; 
    rep(i, M) {
        cin >> P[i].first >> P[i].second;
    }
    rep(x, 1000) {
        int keta = 1;
        int nx = x / 10;
        d.push_back(x % 10);
        while (nx > 0) {
            keta++;
            d.push_back(nx % 10);
            nx = nx / 10;
        }
        bool ans = true;
        if (keta != N) continue;
        reverse(d.begin(), d.end());
        rep(i, M) {
            if (d[P[i].first - 1] != P[i].second) ans = false;
        }
        if (ans) {
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <climits>

class Graph{
public:
	std::vector< std::vector<std::vector<int> > > A;
	int n;

	Graph(int n);

	void SetEdge(int a, int b, int weight);
	void SortEdge();
	void SortEdge_Rec1(int left, int right);
	void SortEdge_Rec2(int left, int mid, int right);

	std::vector<int> Dijkstra();

};

Graph::Graph(int n){
	A.resize(n);
	this->n = n;
}

void Graph::SetEdge(int a, int b, int weight){
	std::vector<int> x(2);
	x[0] = b; x[1] = weight;
	A[a].push_back(x);
	return;
}

std::vector<int> Graph::Dijkstra(){
	std::vector<int> d(n, INT_MAX), prev(n, -1), Q(n, 0);
	d[0] = 0;
	for (int i = 0; i < n; i++) Q[i] = i;

	while (!Q.empty()){
		int mini, minu;
		for (int i = 0; i < (int)Q.size(); i++){
			if (i == 0 || d[Q[i]] < d[minu]){
				minu = Q[i];
				mini = i;
			}
		}
		Q.erase(Q.begin() + mini);
		for (int i = 0; i < (int)A[minu].size(); i++){
			if (d[A[minu][i][0]] > d[minu] + A[minu][i][1]){
				d[A[minu][i][0]] = d[minu] + A[minu][i][1];
				prev[A[minu][i][0]] = minu;
			}
		}
	}
	return d;
}

int main(){
	int n, u, k, v, c;
	scanf("%d", &n);
	Graph G(n);
	for (int i = 0; i < n; i++){
		scanf("%d%d", &u, &k);
		for (int j = 0; j < k; j++){
			scanf("%d%d", &v, &c);
			G.SetEdge(u, v, c);
		}
	}
	std::vector<int> result = G.Dijkstra();
	for (int i = 0; i < n; i++) printf("%d %d\n", i, result[i]);

	return 0;
}


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

using namespace std;

void Main() {
    int S, W;
    cin >> S >> W;

    cout << (S <= W ? "unsafe" : "safe") << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3592
import math

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

total_manipulation =  sum(B) - sum(A)

manipulation_A = 0
manipulation_B = 0

for i in range(N):
    if A[i] < B[i]:
        manipulation_A += math.ceil((B[i] - A[i]) / 2)
        manipulation_B += (B[i] - A[i]) % 2
    elif A[i] > B[i]:
        manipulation_B += A[i] - B[i]

if total_manipulation - max(manipulation_A, manipulation_B) >= 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 4596
n = int(input())

ans = 1e5
for i in range(1, int(n/2)+1, 1):
    tmp = 0
    a = i
    b = n - i
    while(a != 0):
        tmp += a % 10
        a -= a % 10
        a /= 10
    while(b != 0):
        tmp += b % 10
        b -= b % 10
        b /= 10
    if(ans > tmp): ans = tmp

print(int(ans))

Measured memory_bytes: 3064
// Problem : B - Multiplication 2
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


/* Author VS_CODE */

#include<bits/stdc++.h>
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define TCI int t;cin>>t;while(t--)
#define cinl for(int i=0;i<n;i++)
#define ln "\n"
#define vpair vector< pair <ll , ll > >
#define fr first 
#define sc second 
#define pb emplace_back
#define vll vector<ll>
using namespace std;


/* CODE STARTS HERE */

const int N=1e5;

void solve()
{
	ll inf=1e18;
	ll n;
	cin>>n;
	ll A[n];
	cinl cin>>A[i];
	ll prod=1;
	ll zero=count(A,A+n,0);
	if(zero>0)
	{
		cout<<0<<ln;
		return;
	}
	for(ll i=0;i<n;i++)
	{		
		if(A[i]<=inf/prod)
		{
			prod=prod*A[i];
		}
		else
		{
			cout<<-1<<ln;
			return;
		}
	}   
	cout<<prod;
}



/* CODE ENDS HERE AND MAIN STARTS */

int main()
{
	FIO;
	//TCI
	solve();
}


Measured memory_bytes: 4448
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
#define MAX_N 420
#define INF 1000000000000000000
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
ll dp[MAX_N][MAX_N]={};
ll sum[MAX_N]={};
ll n;
ll a[MAX_N];
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
ll solve(ll i,ll j){
  if(dp[i][j]!=-1) return dp[i][j];
  if(i==j){
    return dp[i][j] = 0;
  }else if(i+1==j){
    return dp[i][j] = a[i] + a[j];
  }
  ll res = INF,add=sum[j+1]-sum[i];
  for(int k=i;k!=j;k++){
    res = min(res,solve(i,k)+solve(k+1,j));
  }
  return dp[i][j] = res+add;
}
signed main(){
  init_io();
  cin >> n;
  fill(dp[0],dp[MAX_N],-1);
  fill(sum,sum+MAX_N,0);
  sum[0] = 0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum[i+1] = a[i];
    sum[i+1] += sum[i];
  }
  solve(0,n-1);
  /*
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cout << dp[i][j]<<" ";
    }
    cout << endl;
  }
  */
  cout << dp[0][n-1]<<endl;
}


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

int main() {
  string s;
  cin >> s;
  
  int l = s.size();
  long long ans = 0, cnt = 0;
  bool ok = false;
  for(int i = 0; i < l; i++){
    char now = s.at(i);
    if(ok){
      if(now == 'C') ans += cnt, ok = 0;
      else if(now == 'A') cnt = 1, ok = 0;
      else cnt = 0;
    }
    else{
      if(now == 'A') cnt++;
      else if(now == 'B') ok = true;
      else cnt = 0;
    }
  }
  
  cout << ans << endl;
}

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

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    ll set = a+b;
    ll ans = 0;
    ans += (n/set)*a;
    ans += min(n%set,a);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<int> L(N);
  for(int i=0;i<N;++i) cin>>L[i];
  sort(L.begin(), L.end());
  int sum = 0;
  for(int i=0;i<N-1;++i) sum += L[i];
  if(sum>L[N-1]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



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

typedef long long int ll;

vector<ll>x,y,z;
ll sign[2]={1,-1};

ll absSum(int pos,int i,int j,int k){
    return (x[pos]*sign[i]+y[pos]*sign[j]+z[pos]*sign[k]);
}

int main(){
    int n, m;
    scanf("%d %d",&n,&m);
    for (int i = 0; i < n; i++){
        ll a,b,c;
        scanf("%lld %lld %lld",&a,&b,&c);
        x.push_back(a);
        y.push_back(b);
        z.push_back(c);
    }

    ll res = 0;

    for (ll i=0;i<2;i++){
        for (ll j=0;j<2;j++){
            for (ll k=0;k<2;k++){
                vector<ll>temp;
                for (int l=0;l<n;l++) temp.push_back(absSum(l,i,j,k));
                sort(temp.begin(),temp.end());
                ll maxx = 0;
                for (int l = n-1,o=0; l >=0 and o<m; l--,o++) maxx += temp[l];
                res = max(res,maxx);
            }
        }
    }
    printf("%lld\n",res);
    return 0;
}

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

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

Node root;

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

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

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

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  /* 削除する節点yを決定する */
  if(z->left == NIL || z->right == NIL) 
    y = z; /* zが子を最大１つ持つ場合は入力節点のz */
  else 
    y = treeSuccessor(z); /* z が子を2つ持つ場合はzの次節点 */
  
  /*xをyのNILではない子またはyが子を持たない場合はNILに設定 */
  if(y->left != NIL)
    x = y->left;
  else 
    x = y->right;
  
  /*yの親とxのポインタを変更しyを削除する*/
  
  if(x != NIL)
    x->parent = y->parent; /* yが子を１つ持つ場合 */
  if(y->parent == NIL)
    root = x; /* yが根のときの境界条件を処理*/
  else if(y == y->parent->left) /* y が左の子の場合 */
    y->parent->left = x;
  else                  /* y が右の子の場合 */
    y->parent->right = x;
  
  /* zの次節点が削除されたときにyの内容をzに移動する*/
  if(y != z)
    z->key = y->key;
  
}
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y=x;
    if(z->key<x->key)
      x=x->left;
    else
      x=x->right;
  }
  z->parent=y;
  if(y==NIL)
    root=z;
  else if(z->key<y->key)
    y->left=z;
  else
    y->right=z;
}

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


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

Measured memory_bytes: 19364
/*
 AtCoder ABC 089
 */
 
#include <stdio.h>
 
int main(void){
	
	unsigned long long  m,a,r,c,h;
	int i,n;
	char name[10];
	unsigned long long num = 0;
	
	scanf("%d",&n);
	
	for(i=0,m=0,a=0,r=0,c=0,h=0; i<n; i++){
		scanf("%s",name);
		
		switch(name[0]){
			case 'M': m++; break;
			case 'A': a++; break;
			case 'R': r++; break;
			case 'C': c++; break;
			case 'H': h++; break;
		}
	}
	
	num += m*a*r;
	num += m*a*c;
	num += m*a*h;
	num += m*r*c;
	num += m*r*h;
	num += m*c*h;
	num += a*r*c;
	num += a*r*h;
	num += a*c*h;
	num += r*c*h;
	
	printf("%llu\n",num);
	
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
long long a[500001],n,q,x,s;
int main(){
    scanf("%lld",&n);
    for(int i=1;i<=n;i++)scanf("%lld",&x),a[x]++,s+=x;
    scanf("%lld",&q);
    for(int i=1;i<=q;i++){
        long long y;scanf("%lld%lld",&x,&y);
        s-=x*a[x]-y*a[x],a[y]+=a[x],a[x]=0;
        printf("%lld\n",s);
    }
}

Measured memory_bytes: 2488
def add(Stack):
    tmp = Stack[-1] + Stack[-2]
    Stack.pop(-1)
    Stack.pop(-1)
    Stack.append(tmp)
    return Stack

def subtract(Stack):
    tmp = Stack[-2] - Stack[-1]
    Stack.pop(-1)
    Stack.pop(-1)
    Stack.append(tmp)
    return Stack

def multiple(Stack):
    tmp = Stack[-1] * Stack[-2]
    Stack.pop(-1)
    Stack.pop(-1)
    Stack.append(tmp)
    return Stack

A = input().split()
Stack = []

for i in range(len(A)):
    if A[i] == '+':
        add(Stack)
    elif A[i] == '-':
        subtract(Stack)
    elif A[i] == '*':
        multiple(Stack)
    else:
        Stack.append(int(A[i]))

print(str(Stack[0]))

Measured memory_bytes: 7768
#include<stdio.h>
#include<iostream>
#include<string>
#include<queue>

#define MAX_N 100000
//dequeue的最大长度
#define MAX 100000

using namespace std;

struct Process{
    string name="";
    int remainTime=0;
    Process(){}
    Process(string name, int remainTime){
        this->name=name;
        this->remainTime=remainTime;
    }
    Process(const Process& process){
        this->name=process.name;
        this->remainTime=process.remainTime;
    }
};

int main(){
    int N, Q, clock=0;
    queue<Process> readyQue;
    cin>>N>>Q;
    for(int i=0; i<N; i++){
        string name;
        int remainTime;
        cin>>name>>remainTime;
        readyQue.push(Process(name, remainTime));
    }
    while(!readyQue.empty()){
        Process currentProcess=readyQue.front();
        readyQue.pop();
        if(currentProcess.remainTime<=Q){
            clock+=currentProcess.remainTime;
            cout<<currentProcess.name<<" "<<clock<<endl;
            continue;
        }
        currentProcess.remainTime-=Q;
        readyQue.push(currentProcess);
        clock+=Q;
    }
    return 0;
}



Measured memory_bytes: 6336
#include<iostream>

bool isinRectangle(int W, int x, int r){
  if(x >= r && x <= W - r) return true;
  else return false;
}

int main(){
  int W, H, x, y, r;
  std::cin >> W >> H >> x >> y >> r;
  if(isinRectangle(W, x, r) && isinRectangle(H, y, r)) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
}


Measured memory_bytes: 3096
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
using namespace std;
int main()
{ 
    int n;
    cin>>n;
    int d[n];
    for(int i=0;i<n;i++){
        cin>>d[i];
    }
    long long int cnt;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            cnt=cnt+(d[i]*d[j]);
        }
    }
     cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn.readInt

object Main {
  val r = Array(2,3,5,7)

  def twoPow(d:Int,s:Int):(Int,Int) = {
    if(d%2 == 1) (d,s)
    else twoPow(d>>1,s+1)
  }

  def maybePrime(i:Int,d:Int,s:Int, n:Int):Boolean = {
    if(i>3) true
    else {
      val a = r(i)
      val x = BigInt(a).modPow(d,n).toLong

      if(x==1 || x==n-1) maybePrime(i+1,d,s,n)
      else repeat(s-1,BigInt(x).modPow(2,n).toLong, i, d, s, n)
    }
  }

  def repeat(j:Int, x:Long, i:Int, d:Int, s:Int, n:Int):Boolean = {
    if(j==0) false
    else if(x==1) false
    else if(x==n-1) maybePrime(i+1,d,s,n)
    else repeat(j-1,BigInt(x).modPow(2,n).toLong,i,d,s,n)
  }

  def isPrime(n:Int):Boolean = {
    if(n<5500) (2 to Math.sqrt(n).toInt).forall(n%_ != 0)
    else if(n%2==0) false
    else {
      val (d,s) = twoPow(n-1,0)
      maybePrime(0,d,s,n)
    }
  }

  def main(args:Array[String]) = {
    val n = readInt
    println((0 until n).count{ _=> {
        val m = readInt; isPrime(m)
      }
    })
  }
}

Measured memory_bytes: 67672
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<ctime>
#include<bitset>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const long long int inf = 1e18+7;
const int mod = 1e9+7;

inline ll max(ll a,ll b) { return a>b?a:b; }
inline ll min(ll a,ll b) { return a<b?a:b; }
inline ll abs1(ll a) { return a>0?a:-a; }

//const int maxn=
ll dp[2005];

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	dp[0]=1;
	dp[1]=1;
	dp[2]=1;
	for(int i=3;i<=2000;i++)
		dp[i]=(dp[i-1]+dp[i-3])%mod;
	
	int s;
	while(cin>>s)
	{
		if(s<3)
			cout<<0<<endl;
		else
			cout<<dp[s-3]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>

//using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

using ll =  long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
template<typename T> void chadd(T& a, T b) { a = a + b; }

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	// 最小公倍数
	ll lcm(ll a, ll b) {
		return a / gcd(a, b) * b;
	}


}


int main() {

	int n, m;
	std::cin >> n >> m;
	std::vector<int> p(m);
	std::vector<std::string> s(m);
	rep(i, m) std::cin >> p[i] >> s[i];

	int ac_sum = 0;
	int wa_sum = 0;

	std::vector<std::vector<bool>> res(n, std::vector<bool>());

	rep(i, m) {
		bool ac = (s[i] == "AC");
		res[p[i] - 1].push_back(ac);
	}

	rep(i, n) {
		int wa = 0;
		bool ac = false;
		rep(j, res[i].size()) {
			if (!res[i][j]) ++wa;
			else {
				++ac_sum;
				ac = true;
				break;
			}
		}
		if (ac) wa_sum += wa;
	}

	std::cout << ac_sum << " " << wa_sum << std::endl;

	return 0;
}

Measured memory_bytes: 13184
#include <stdio.h>
int main(void){
    // Your code here!
    int N,x;
    int a[100000];
    long long cnt = 0;
    
    scanf("%d%d",&N,&x);
    
    for(int i = 0;i < N;i++){
        scanf("%d",&a[i]);
    }
    
    for(int i = 0; i < N-1;i++){
        int sum = a[i] + a[i+1];
        if(sum <= x){
            continue;
        }
        int change = sum -x;
        if(a[i+1]-change < 0){
            change -= a[i+1];
            cnt += a[i+1];
            a[i+1] = 0;
            cnt += change;
            a[i] -= change;
        }
        else{
            cnt += change;
            a[i+1]-=change;
        }
    }
    
    printf("%lld\n",cnt);
}


Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
using namespace std;

int		main(void)
{
	vector<string> ABC(3);
	vector<int> ABCCnt(3, 0);
	vector<int> ABCLength(3);
	for (int i = 0; i < 3; i++)
		cin >> ABC.at(i), ABCLength.at(i) = ABC.at(i).size();
	for (int position = 0; ; )
	{
		if (ABCCnt.at(position) == ABCLength.at(position))
		{
			cout << char('A' + position) << endl;
			break ;
		}
		position = ABC.at(position).at(ABCCnt.at(position)++) - 'a';
	}
	return 0;
}

Measured memory_bytes: 256
import sys
s=list(input())
s.sort()
count=1
for i in range(1,len(s)):
    if s[i]==s[i-1]:
        count+=1
    else:
        if count%2==0:
            count=1
        else:
            print("No")
            sys.exit()
if count%2!=0:
    print("No")
    sys.exit()
print("Yes")

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

using namespace std;

// Prioridade
typedef long long   ll;
typedef pair<ll,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(int i = a; i < (b); i++)
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define endl '\n'
#define mdc(a, b) (__gcd((a), (b)))
#define mmc(a, b) (((a)/__gcd(a, b)) * b)

// fim da Prioridade
double dp[3002][3002];
double v[3002];
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	REP(i,0,n){
		cin >> v[i];
	}
	dp[0][1] = v[0];
	dp[0][0] = 1-v[0];
	REP(i,1,n){
		dp[i][0] = dp[i-1][0] * (1-v[i]);
		REP(j,1,n+1){
			dp[i][j] = dp[i-1][j-1] * v[i] + dp[i-1][j] * (1-v[i]);
		}
	}
	double ans = 0;
	
	REP(i,n/2 + 1, n+1){
		ans += dp[n-1][i];
	}
	ans += 1e-11;
	cout << setprecision(10) << fixed <<  ans << endl;
	return 0;
}


Measured memory_bytes: 70656
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main() {
  char s[100000];
  scanf("%s", s);
  string S = s;

  // 後ろから解くかわりにすべての文字列を「左右反転」する
  reverse(S.begin(), S.end());
  for(int i = 0; i < 4; ++i)
    reverse(divide[i].begin(), divide[i].end());

  // 端から切っていく
  bool can = true;
  for(int i = 0; i < S.size();){
    bool can2 = false; // 4 個の文字列たちどれかで divide できるか
    for(int j = 0; j < 4; ++j){
      string d = divide[j];
      if(S.substr(i, d.size()) == d){ // d で divide できるか
        can2 = true;
        i += d.size(); // divide できたら i を進める
      }
    }
    if(!can2){ // divide できなかったら
      can = false;
      break;
    }
  }

  if(can)
    printf("YES");
  else
    printf("NO");
  
  return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
#define MAXN 100000
long long Sum[MAXN+5],n,Ans=0;
int main(){
    scanf("%lld",&n);
    for(int i=1;i<=n;i++)
        scanf("%lld",&Sum[i]);
    for(int i=1;i<=n;i++){
        Ans+=Sum[i]/2;
        Sum[i]%=2;
        if(i<n&&Sum[i]>0&&Sum[i+1]>0){
            Ans++;
            Sum[i]--;
            Sum[i+1]--;
        }
    }
    printf("%lld\n",Ans);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main() {
  int64_t N, j=0, ans=0;
  cin >> N;
  vector<int64_t> A(N);
  vector<int64_t> B(N);
  for (int64_t i=0; i<N; i++) {
    cin >> A[i];
    B[i]=0;
  }
  sort(A.begin(),A.end());
  if (N==1) {
    B[0]=1;
  }
  else {
    B[0]=1;
    for (int64_t i=1; i<N; i++) {
      if (A[i-1]==A[i]) {
        B[j]++;
      }
      else {
        j++;
        B[j]++;
      }
    }
  }
  for (int64_t i=0; i<N; i++) {
    if (B[i]%2==1) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4812
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
const int N=2*1e3+5;
int main(){
	int n,m,x;
	cin>>n>>m>>x;
	int temp=0,op=0;
	int mx=max(n,m);
	while(temp<x){
		temp+=mx;
		op++;
	}
	cout<<op;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){
  ll int N,M;
  cin >> N >> M;
  ll int p;
  string S;
  int A[N+1];
  ll int W[N+1];
  rep(i,N){
  A[i]=0;
  W[i]=0;
}
  ll int counterA,counterW;
  counterA = 0;
  counterW = 0;
  
  rep(i,M){
	  cin >> p >> S;
   if(S[0] == 'A'){
	   if (A[p] == 0){
		   counterA += 1;
		   counterW = counterW +  W[p];
		   A[p] =1;
	   }
	   else{}
   }
   else{
	   if(A[p] == 0 ){
		   W[p] += 1;
	   }
	   else{}
   }
  }

  cout << counterA << " " << counterW;











	return 0;

}



Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.20f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

int main() {
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> c(h);
	rep (i, h) cin >> c[i];



	int ans = 0;


	for (int bit = 0; bit < 1<<(h + w); bit++) {
		vector<string> cp = c;
		int cnt = 0;
		for (int i = 0; i < (h + w); i++) {
			if (bit & 1<<i) {


				if (i < h) {
					for (int j = 0; j < w; j++) {
						cp[i][j] = '.';
					}
				}
				else {
					for (int j = 0; j < h; j++) {
						cp[j][i - h] = '.';
					}
				}

			}
		}
		rep (i, h) rep (j, w) if (cp[i][j] == '#') cnt++;
		if (cnt == k) ans++;
	}

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


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define mod 1000000007
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

ll a, b, c, d;
unordered_map<ll, ll> mp;

ll minCoins(ll n)
{
    if (mp.count(n))
    {
        return mp[n];
    }
    if (n == 0)
    {
        return 0;
    }
    ll best = LLONG_MAX;
    if (n == 1)
    {
        return d;
    }

    if (n % 2 == 0)
    {
        best = min(best, a + minCoins(n / 2));
    }
    else
    {
        ll ch = n / 2 * 2;
        best = min(best, a + (n - ch) * d + minCoins(n / 2));
        ch += 2;
        best = min(best, a + (ch - n) * d + minCoins(n / 2 + 1));
    }
    if (n % 3 == 0)
    {
        best = min(best, b + minCoins(n / 3));
    }
    else
    {
        ll ch = n / 3 * 3;
        best = min(best, b + (n - ch) * d + minCoins(n / 3));
        ch += 3;
        best = min(best, b + (ch - n) * d + minCoins(n / 3 + 1));
    }
    if (n % 5 == 0)
    {
        best = min(best, c + minCoins(n / 5));
    }
    else
    {
        ll ch = n / 5 * 5;
        best = min(best, c + (n - ch) * d + minCoins(n / 5));
        ch += 5;
        best = min(best, c + (ch - n) * d + minCoins(n / 5 + 1));
    }

    if (d < LLONG_MAX / n)
    {
        best = min(best, d * n);
    }
    return mp[n] = best;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while (t--)
    {
        ll n;
        cin >> n >> a >> b >> c >> d;
        cout << minCoins(n) << "\n";
        mp.clear();
    }
    return 0;
}

Measured memory_bytes: 4092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x,y,z;cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<queue>
using namespace std;
struct wolf{
	char m[22][22];
	int row;
	int col;
};
int c[22][22];
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int main(){
	int a,b;
	while(scanf("%d%d",&b,&a),a){
		for(int i=0;i<a;i++){
			for(int j=0;j<b;j++){
				scanf("%d",&c[i][j]);
			}
		}
		int ret=999999;
		queue<pair<int,wolf> >Q;
		wolf s;
		for(int i=0;i<a;i++){
			for(int j=0;j<b;j++){
				if(c[i][j]==2){
					s.row=i;
					s.col=j;
					s.m[i][j]=0;
				}
				else s.m[i][j]=c[i][j];
			}
		}
		Q.push(make_pair(0,s));
		while(Q.size()){
			if(ret<99999)break;
			int cost=Q.front().first;
			wolf now=Q.front().second;
			Q.pop();
			if(cost==10)continue;
			for(int i=0;i<4;i++){
				int nr=now.row;
				int nc=now.col;
				int t=0;
				while(1){
					nr+=dx[i];
					nc+=dy[i];
					t++;
					if(nr<0||nr>=a||nc<0||nc>=b){
						break;
					}
					if(now.m[nr][nc]==3){
						ret=min(ret,cost+1);break;
					}
					if(now.m[nr][nc]==1){
						if(t>1){
							wolf to;
							to.row=nr-dx[i];
							to.col=nc-dy[i];
							for(int j=0;j<a;j++)
								for(int k=0;k<b;k++)
									to.m[j][k]=now.m[j][k];
							to.m[nr][nc]=0;
							Q.push(make_pair(cost+1,to));
						}
						break;
					}
				}
			}
		}
		if(ret>99999)printf("-1\n");
		else printf("%d\n",ret);
	}
}

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

int main() {
    int a,b;
    cin>>a>>b;
    double c=(double)(a+b)/2;
    int d=(int)(a+b)/2;
    if(c!=d){
        cout<<(a+b)/2+1<<endl;
    }else{
        cout<<(a+b)/2<<endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
 
/*
--------------------------------------------
 
	type
 
--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;
 
/*
--------------------------------------------
 
	container
 
--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
 
/*
--------------------------------------------
 
	repetition
 
--------------------------------------------
*/
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPS(i,n) for(int i=0; i<(n); i++)
#define REPinit(a,n) for(int i=a; i<(n); i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)
 
//algorithm
//#define SORT(c) sort((c).begin(),(c).end())
 
/*
--------------------------------------------
 
	constant
 
--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
/*
 
	Optimizer
 
*/
//#pragma GCC optimize("Ofast")


/*
 
	Utility Algorithm
 
*/
template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}

LL euclideanAlgorithm(LL a, LL b) {
    LL a_tmp = a;
    LL b_tmp = b;

    if (a_tmp > b_tmp) {
        swapAlgorithm<LL>(a_tmp, b_tmp);
    }

    LL r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

LL getLCM(LL a, LL b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

/*
  Code
*/

double eauclidDistance(pair<double, double>& x1, pair<double, double>& x2) {
  return sqrt((x1.first - x2.first) * (x1.first - x2.first) + (x1.second - x2.second) * (x1.second - x2.second));
}

void swap(int& a, int& b) {
  int tmp;
  tmp = a;
  a = b;
  b = tmp;
}

int main(int argc, char const *argv[])
{
  LL A,B,K;
  cin >> A >> B >> K;

  LL ans;
  for(ans=A; ans<(A+K) && ans<=B; ans++) cout << ans << endl;
  for(LL i=max(ans,B-K+1); i<=B; i++) cout << i << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(raw_input())
w = map(int,raw_input().split())

l = w[0]
r = 0
for a in range(1,len(w)):
  r += w[a]
now = 100*200
for a in range(1,len(w)):
  l += w[a]
  r -= w[a]
  if now > abs(l-r): now = abs(l-r)
print now


Measured memory_bytes: 2568
import sys
input = sys.stdin.readline
A, B, C, X, Y = [int(x) for x in input().split()]
ans_notAB = A * X + B * Y
temp = min(X,Y)
ans_AB = 2 * temp * C
if X > Y:
    X -= Y
    ans_AB += min([X * A, 2 * X * C])
elif Y > X:
    Y -= X
    ans_AB += min([Y * B, 2 * Y * C])
print(min(ans_AB,ans_notAB))

Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <limits>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

const int BIT = 18;

bool used[1 << 18];
int N, K, S1, S2, A[1 << 18], power[20];
int S[1 << 26], cnt;
long long nr[59][59];
vector<int> vec;
vector<pair<int, int>> vec2;

void init() {
	for (int i = 0; i <= 50; i++) {
		for (int j = 0; j <= 50; j++) {
			if (i == 0 || j == 0) nr[i][j] = 1;
			else nr[i][j] = nr[i - 1][j] + nr[i][j - 1];
		}
	}
}

long long solve(int ret, int vs) {
	int t = 0;
	for (int i = 0; i < vec.size(); i++) {
		if ((ret / power[i]) % 3 != 2) t++;
	}

	long long rem = 0;
	for (int i = 1; i <= vs; i++) {
		if (i > K) break;
		rem += nr[i][vs - i];
	}
	if (t % 2 == 1) return -rem;
	return rem;
}

int main() {
	cin >> N >> K >> S1 >> S2; init();
	for (int i = 0; i < 18; i++) {
		int g1 = ((S1 / (1 << i)) % 2);
		int g2 = ((S2 / (1 << i)) % 2);
		if (g1 == 1 && g2 == 0) { cout << "0" << endl; return 0; }
		if (g1 != g2) vec.push_back(i);
		if (g1 == g2) vec2.push_back(make_pair(i, g1));
	}

	for (int i = 0; i < N; i++) {
		cin >> A[i]; int sa = 0;
		for (int j = 0; j < vec.size(); j++) {
			if ((A[i] / (1 << vec[j])) % 2 == 1) sa += (1 << j);
		}
		for (int j = 0; j < vec2.size(); j++) {
			int g1 = (A[i] / (1 << vec2[j].first)) % 2;
			if (g1 != vec2[j].second) used[i] = true;
		}
		A[i] = sa;
	}
	power[0] = 1;
	for (int i = 1; i <= vec.size(); i++) power[i] = 3 * power[i - 1];

	for (int i = 0; i < N; i++) {
		if (used[i] == true) continue;
		int bit[19], base = 0; bit[vec.size()] = 0;
		for (int j = 0; j < vec.size(); j++) bit[j] = (A[i] / (1 << j)) % 2;
		for (int j = 0; j < vec.size(); j++) base += bit[j] * power[j];

		for (int j = 0; j < (1 << vec.size()); j++) {
			S[cnt] = base;
			int cx = j + 1, cp = 0;
			while ((cx & 1) == 0) { cx >>= 1; cp++; }
			base += power[cp] * (2 - bit[cp]);
			for (int k = 0; k < cp; k++) base -= power[k] * (2 - bit[k]);
			cnt++;
		}
	}
	sort(S, S + cnt);

	int vs = 0; long long Answer = 0;
	for (int i = 0; i < cnt; i++) {
		vs++;
		if (i + 1 == cnt || S[i] != S[i + 1]) {
			Answer += solve(S[i], vs);
			vs = 0;
		}
	}
	cout << Answer << endl;
	return 0;
}

Measured memory_bytes: 54832
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>

using namespace std;
int n;
long long a[50];
long long b[50];
long long ans;

bool check(long long k) {
  bool good = true;
  long long ans = 0,q;
  int imax;
  for (int i = 0; i < n; i++) {
    a[i] = b[i];
  }
  while (ans <= k) {
    imax = 0;
    for (int i = 1; i < n; i++) {
      if (a[i] > a[imax]) {
        imax = i;
      }
    }

    if (a[imax] < n) {
      break;
    }

    q = a[imax]/n;
    for (int i = 0; i < n; i++) {
      a[i] += q;
    }
    a[imax] -= q*(n+1);
    ans += q;
  }
  return ans <= k;
}

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

  cin >> n;
  long long mmax = 0;
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    mmax = max(mmax, b[i]);
  }
  // cout << check(1234567894847) << endl;
  // cout << check(1234567894848) << endl;
  // return 0;
  if (mmax >= n) {
    long long l = -1;
    long long r = 500000000000000001;
    long long mid;
    while (r - l > 1) {
      mid = (l+r)/2;
      if (check(mid)) {
        r = mid;
      } else {
        l = mid;
      }
    }
    ans = r;
  }
  cout << ans << "\n";
  return 0;
}


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

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M, 0));
    for (int i = 0; i < N; i++) {
        cin >> C[i];
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }

    ll ans = 1e9;
    for (int i = 0; i < (1 << N); i++) {
        vector<int> choose;
        int n = i;
        for (int j = 0; j < N; j++) {
            if (n % 2 == 1) {
                choose.push_back(j);
            }
            n /= 2;
        }

        ll temp = 0;
        vector<int> skill(M, 0);
        for (int c : choose) {
            temp += C[c];
            for (int j = 0; j < M; j++) {
                skill[j] += A[c][j];
            }
        }

        bool ok = true;
        for (int j = 0; j < M; j++) {
            if (skill[j] < X) {
                ok = false;
            }
        }

        if (ok) {
            ans = min(ans, temp);
        }
    }

    if (ans != 1e9) {
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char c0 = s.charAt(0);
    char c1 = s.charAt(1);
    char c2 = s.charAt(2);
    char c3 = s.charAt(3);
    if (((c0 == c1) && (c1 == c2)) || ((c1 == c2) && (c2 == c3)) || ((c0 == c1) && (c1 == c2) && (c2 == c3))) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }
}

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

typedef long long ll;
const ll N=1e9;
int n,m;
ll sum;

int main()
{
    scanf("%d%d%lld",&n,&m,&sum);
    int f=0,flag=0;
    while(f<n)
    {
        if(f<m)
        {
            printf("%lld ",sum);
        }
        else
        {
            if(sum!=N)
                printf("%lld ",sum+1);
            else
                printf("%lld ",sum-1);
        }
        f++;
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 3796
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    N, X = LI()
    L = LI()
    x = 0
    count = 1
    for i in range(N):
        x += L[i]
        if x > X: break
        count += 1
    print(count)

main()

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

int main() {
    int n, m; cin >> n >> m;
    vector<int> s(m);
    vector<int> c(m);
    rep(i,m){
        int si, ci;
        cin >> si >> ci;
        si--;
        s[i] = si; c[i] = ci;
    }
    vector<int> d(n,-1);
    bool bl = true;
    rep(i,m){
        int si = s[i];
        int ci = c[i];
        int &di = d[si];
        if(di != -1 && ci != di){
            bl = false;
            break;
        }
        di = ci;
    }
    if(n > 1 && d[0] == 0) bl = false;

    if(bl){
        rep(i,n){
            int di = d[i];
            if(di == -1){
                if(i == 0 && n > 1) cout << 1;
                else cout << 0;
            }
            else cout << di;
        }
        cout << endl;
    }
    else{
        cout << -1 << endl;
    }
}


Measured memory_bytes: 256
#参考：https://takeg.hatenadiary.jp/entry/2019/09/14/132409

S = input()
N = len(S)
ans = [0] * N

#R
count = 0
for i in range(N):
    if S[i] == "R":
        count += 1
    else:
        ans[i] += count // 2
        ans[i-1] += count - (count // 2)
        count = 0
#L
count = 0
for i in reversed(range(0,N)):
    if S[i] == "L":
        count += 1
    else:
        ans[i+1] += count - (count // 2)
        ans[i] += count // 2
        count = 0

answer = ' '.join(map(str, ans))
print(answer)



Measured memory_bytes: 10484
#include <stdio.h>
int main(){
  int N, K, i, res=1;
  scanf("%d %d", &N, &K);
  for (i=0; i<N; i++) {
    if (res<=K) res*=2;
    else res+=K;
  }
  printf("%d\n", res);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main(void)
{
    int a,b,c,i;
    scanf("%d %d",&a,&b);
    if( a < b)
    {
        for(i = 0; i < b; i++)
        {
            printf("%d",a);
        }
    }
    else
    {
        for(i = 0; i < a; i++)
        {
            printf("%d",b);
        }
    }
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream> 
using namespace std;
int main(){
    string s,t; cin >> s >> t;
    int n = s.size(),i,j;
    for (i=0; i<n; i++){
        for (j=i; j<n+i; j++){
            if (s[j%n]!=t[j-i]) break;
        }
        if (j==n+i) {puts("Yes"); return 0;}
    }
    puts("No"); 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INFTY 10000000000
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
using ipair = pair<ll,ll>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int main(){

    int x[5];
    rep(i,5){
        cin>>x[i];
        if(x[i]==0){
            cout<<i+1;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
int a[100001],f[100001];
int main()
{
	int n,i,j;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	f[1]=0;
	f[2]=abs(a[2]-a[1]);
	for(i=3;i<=n;i++)
	{
		f[i]=min(f[i-2]+abs(a[i]-a[i-2]),f[i-1]+abs(a[i]-a[i-1]));
	}
	printf("%d",f[n]);
	return 0;  
} 

Measured memory_bytes: 1024
import sys


a = int(input())

cur = 0
for i in range(1, 10 ** 7):
	#b = sum([(7 * (10**x)) for x in range(i + 1)])
    cur *= 10
    cur += 7
    cur %= a
    if cur == 0:
        print(i)
        sys.exit()
print(-1)

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

vector<vector<int>> G;
int N,M;
bool f[100000];
int c[100000];
int par[100000];

int bfs(int n,int d){

}

int main(){
    cin >> N >> M;
    G.resize(N);
    for(int i=0;i<N+M-1;i++){
        int a,b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        c[b-1]++;
    }
    int root = -1;
    for(int i=0;i<N;i++) if(c[i]==0) root = i;
    queue<P> q;
    q.push({root,0});
    while(!q.empty()){
        auto p = q.front();
        q.pop();
        int n = p.first;
        int d = p.second;
        for(auto &e : G[n]){
            c[e]--;
            if(c[e] > 0) continue;
            par[e] = n+1;
            q.push({e,d+1});
        }
    }
    for(int i=0;i<N;i++) cout << par[i] << endl;
    return 0;
}

Measured memory_bytes: 7040
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <deque>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, m, k;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> m >> k;

  vector<ll> a_sum(n + 1), b_sum(m + 1);
  a_sum[0] = 0; b_sum[0] = 0;
  vector<int> a(n), b(m);
  REP(i, n) {
    cin >> a[i];
    a_sum[i + 1] = a[i] + a_sum[i];
  }

  REP(i, m) {
    cin >> b[i];
    b_sum[i + 1] = b[i] + b_sum[i];
  }

  ll ans = 0;
  int ap = 0;
  REP(i, m + 1) {
    if(b_sum[m - i] <= k) {
      while(ap <= n && k - b_sum[m - i] >= a_sum[ap]) {
        ans = max((ll)m - i + ap, ans);
        ap++;
      }
    }
  }

  int bp = 0;
  REP(i, n + 1) {
    if(a_sum[n - i] <= k) {
      while(bp <= m && k - a_sum[n - i] >= b_sum[bp]) {
        ans = max((ll)n - i + bp, ans);
        bp++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 7948
# coding: utf-8
# Your code here!

import numpy as np

def calc_distance(goals):
    dist_list = []
    for i in range(len(goals) - 1):
        dist_list.append(goals[i+1] - goals[i])
    return dist_list

points_num, goal_num = map(int, input().split())

goals = list(map(int, input().split()))
goals = sorted(goals)


dist_list = calc_distance(goals)
dist_list = sorted(dist_list)

if goal_num <= points_num:
    print(0)
else:
    print(sum(dist_list[:goal_num-points_num]))

Measured memory_bytes: 23052
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


a, b = LI()
if (a*b) % 2 == 0:
    print('Even')
else:
    print('Odd')


Measured memory_bytes: 38256