akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<ld> vld;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define TS to_string
#define ALL(v) (v).begin(), (v).end()
#define endl "\n"

ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
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;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

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

//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll n;
  cin >> n;
  set<ll> s;
  ll x;
  REP(i,n) { cin >> x; s.insert(x);}
  IREP(i,s){
    if(i != s.begin()) cout << " ";
    cout << (*i);
  }
  cout << endl;
  return 0;
}




Measured memory_bytes: 7920
/*
 * b.c
 *
 *  Created on: 2014/07/03
 *      Author: nana
 */


#include<stdio.h>

int left(int i){
	return 2*i;
}
int right(int i){
	return 2*i+1;
}
int parent(int i){
	return i/2;
}

int a[500000];
int heapSize;
void buildMaxHeap(void);
int main(){

	int i;

	scanf("%d",&heapSize);
	for(i=1;i<=heapSize;i++){
		scanf("%d",&a[i]);
	}
	buildMaxHeap();
	for(i=1;i<=heapSize;i++){
		printf(" %d",a[i]);
	}
	printf("\n");
	return 0;
}

void maxHeapify(int i){

	int l=left(i);
	int r=right(i);
	int largest=0,tmp=0;
	if(l<=heapSize && a[l]>a[i]){
		largest = l;
	}else{
		largest = i;
	}
	if(r<=heapSize && a[r]>a[largest]){
		largest = r;
	}
	if(largest != i){
		tmp=a[i];
		a[i]=a[largest];
		a[largest]=tmp;
		maxHeapify(largest);
	}

}
void buildMaxHeap(void){
	int i;
	for(i=heapSize/2;i>=1;i--){
		maxHeapify(i);
	}
}

Measured memory_bytes: 2552
import sys
import os
import math
import bisect

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, X = il()
    L = il()
    ret = 1
    di = 0
    for l in L:
        di += l
        if di <= X:
            ret += 1
        else:
            break
    print(ret)


if __name__ == '__main__':
    main()


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

int main(){
    int64_t w, h, x, y;
    cin >> w >> h >> x >> y;
    double s = double(w * h) / 2.0;
    int judge = 0;
    if( 2 * x == w && 2 * y == h){
        judge = 1;
    }
    
    cout << s << " " << judge << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n;
  cin >> n;
  vector<ll> ya(1000,1);
  for(ll i=1;i<=n;i++){
    ll cp=i;
    for(ll j=2;j*j<=n;j++){
      while(cp%j==0){
        ya.at(j)++;
        cp/=j;
      }
    }
    if(cp!=1){
      ya.at(cp)++;
    }
  }
  ll ans=1,mod=1e9+7;
  rep(i,1000){
    ans*=ya.at(i);
    ans%=mod;
  }
  cout << ans;
}
    
  

Measured memory_bytes: 3620
N, K= map(int, input().split())

dislike_number = set(map(int, input().split()))
num = set([i for i in range(10)])
ok_num = list(num - dislike_number)
ok_num = sorted(ok_num)



max_len = len(str(N))
widths=[str(max(ok_num))]*(max_len+1)
min_value=10**(max_len+1)

for i in range(0,max_len+1):
    if i==0:
        temp=int("".join(widths[1:]))
        if N <= temp < min_value:
            min_value=temp
            widths[0]="0"
            continue
    for num in ok_num:
        widths[i]=str(num)
        temp=int("".join(widths))
        if N <= temp < min_value:
            min_value=temp
            break
print(min_value)



Measured memory_bytes: 3064
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll N) {
  cout << N*(N+1)/2 << endl;
}

int main() {
  ll N;
  cin >> N;
  solve(N);
  return 0;
}


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

int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
  {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());

  int sumA = 0;
  int sumB = 0;
  bool flag = true;
  for (int i = 0; i < N; i++){
    if(flag){
      sumA += a.at(N - i - 1);
      a.pop_back();
      flag = false;
    }
    else
    {
      sumB += a.at(N - 1 - i);
      a.pop_back();
      flag = true;
    }
  }
  cout << sumA - sumB << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define pb push_back
#define ff first
#define ss second
#define all(v) (v).begin(), (v).end()
#define mod (int)(998244353)
#define debugCont(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << " | ";
    err(++it, args...);
}
int ans, n, m, x;
vector<vector<int>> a;
vector<int> pos, cost; 
signed main(){

    fastIO
    
    cin >> n >> m >> x;
    a = vector<vector<int>> (n);
    cost.assign(n, 0);
    for (int i = 0; i < n; i++){
        cin >> cost[i];
        for(int j = 0, b;j < m; j++){
            cin >> b;
            a[i].pb(b);
        }
    }
    int ans = 1e9;
    int all = (1ll)<<n;

    for (int mask = 0; mask < all; mask++){
        pos.assign(m, 0);
        int tmp = 0;
        for (int i = 0; i < n; i++){
            if ((mask>>i)&(1ll)){
                tmp += cost[i];
                for (int j = 0; j < m; j++){
                    pos[j] += a[i][j];
                }
            }
        }
        bool ok = true;
        for (int i = 0; i < m; i++){
            ok &= (pos[i] >= x);
        }
        if (ok){
            ans = min(ans, tmp);
        }
    }
    if (ans == (int)1e9){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 400010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int n, a[MAXN], sum;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
  FOR(i,1,n) cin >> a[i];
  sort(a+1, a+n+1);
  FOR(i,1,n-1) sum += a[i];
  sum += a[n] / 2;
  cout << sum;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
main(){
  int x,sum=0,i,n,a,b;
  char s[110];
  int stack[110];
  int stack_top=0;
   
  while( scanf("%s",s) != EOF ){
    if( s[0] == '+' ){
      --stack_top;
      a = stack[stack_top];
      --stack_top;
      b = stack[stack_top];
      sum = a + b;
      stack[stack_top] = sum;
      stack_top++;
    }
    else if ( s[0] == '-' ){
      n =  stack[--stack_top];
      sum = stack[--stack_top] - n;
      stack[stack_top] = sum;
      stack_top++;
    }
    else if ( s[0] == '*' ){
      --stack_top;
      a = stack[stack_top];
      --stack_top;
      b = stack[stack_top];
      sum = a * b;
      stack[stack_top] = sum;
      stack_top++;
    }
    else {
      x = atoi(s);
      stack[stack_top] = x;
      stack_top++;
    }
  }
  for( i=0 ; i<stack_top ; i++) printf("%d\n",stack[i]);
  return 0;
}

Measured memory_bytes: 548
#include<iostream>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define arep(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;

const string s[3] = {"Sunny", "Cloudy", "Rainy"};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    if (S[0] == 'S') cout << s[1];
    else if (S[0] == 'C') cout << s[2];
    else cout << s[0];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
/**
*    author:  yuya1234
*    created: 24.06.2020 17:18:18
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int n;
    string s;
    cin>>n>>s;

    int cnt=0;
    REP(i,n-2)
    {
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
#define loop(i,N,M) for(int i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

//変数
ll N,M;

//解法
void solve() {

	cin >> N;

	double ans = 0;

	rep(i, N) {
		double val = 0;
		cin >> val;
		string str;
		cin >> str;
		if (str == "JPY") {
			ans += val;
		}
		else {
			ans += val * 380000;
		}
	}

	cout << ans;

	return;
}

int main() {

	//入力

	solve();
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
var input = ""
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
 
process.stdin.on('end', function() {
  input = input.split("\n");
  i = 0;
  var n = parseInt(input[i].split(" ")[0], 10);
  var m = parseInt(input[i].split(" ")[1], 10);
  var l = parseInt(input[i].split(" ")[2], 10);

  var a = new Array(n)
  for (i = 0; i < n; i++) {
    a[i] = input[i + 1].split(" ");
  }

  var b = new Array(m)
  for (i = 0; i < m; i++) {
    b[i] = input[i + n + 1].split(" ");
  }

  var c = new Array(l)
  for (i = 0; i < n; i++) {
    c[i] = [];
    for (j = 0; j < l; j++) {
      c[i][j] = 0;
      for (k = 0; k < m; k++) {
        c[i][j] += a[i][k] * b[k][j];
      }
    }
    console.log(c[i].join(" "));
  }
});

Measured memory_bytes: 14620
from collections import deque

def main():
    k = int(input())

    q = deque()

    for i in range(9):
        q.append(i+1)

    count = 0

    a = 0

    while(count < k):

        a = q.popleft()

        if (a%10 != 0):
            q.append(10*a + (a%10) - 1)

        q.append(10*a + (a%10))

        if (a%10 != 9):
            q.append(10*a + (a%10) + 1)

        count += 1

    print(a)

main()


Measured memory_bytes: 40560
/*
h s, d't skp th si tll i's svedclTabCtrl
 * ABC141 E
 * ABC145 D
 * ABC147 F
 * ABC174 F
*/
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int vc[1000000+5]={};
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
vc[a[i]]+=1;
}
int ans=0;
for(int i=0;i<n;i++)
{
bool ok=1;
vc[a[i]]--;
for(int j=1;j<=sqrt(a[i]);j++)
{
if(a[i]%j==0)
{
if(vc[j] || vc[a[i]/j])
{
ok=0;
break;
}
}
}
vc[a[i]]++;
ans+=ok;
}
cout<<ans<<endl;
}
/*
 *||||

 */


Measured memory_bytes: 8272
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>

typedef long long int ll;


using namespace std;

string s;

int main(){
	while(cin>>s){
		for(int i=0; i<s.size(); i++){
			if(s[i]=='@'){
				for(int j=0; j<(s[i+1]-'0'); j++){
					cout<<s[i+2];
				}
				i+=2;
			}else{
				cout<<s[i];
			}
		}
		cout<<endl;
	}
}

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


int main(){
    string s;
    cin >> s;
    cout << (s[0] == s[2] ? "Yes\n" : "No\n");
}



Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int N, M;
  while (cin >> N >> M) {
    map<int, int> mp;
    for (int i = 0; i < N; i++) {
      int x;
      cin >> x;
      ++mp[x];
    }
    vector<int> g(M, 0), m(M, 0);
    for (auto e : mp) {
      int x = e.first % M, cnt = e.second;
      m[x] += cnt;
      g[x] += cnt / 2;
    }
    int res = 0;
    for (int i = 0; i <= M - i; i++) {
      int j = (M - i) % M;
      if (i == j) {
        res += m[i] / 2;
      } else {
        int best = 0;
        for (int lower = 0, upper = min(m[i], m[j]); lower <= upper; lower++) {
          int ai = min(g[i], (m[i] - lower) / 2);
          int aj = min(g[j], (m[j] - lower) / 2);
          best = max(best, ai + aj + min(m[i] - 2 * ai, m[j] - 2 * aj));
        }
        res += best;
      }
    }
    cout << res << endl;
  }
  return 0;
}


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

int mid;

int binary_search(int i,int a,int num[],int t[]){
    int left=0,right=a;
    while(left<right){
        mid=(left+right)/2;
        if(num[mid]==t[i]){
            return 1;
        }else if(num[mid]<t[i]){
            left=mid+1;
        }else{
            right=mid;
        }
    }
    return 0;
}

int main(){
  int a,b,count=0;
  cin>>a;
  int num[a];
  for(int i=0;i<a;i++){
      scanf("%d",&num[i]);
  }
  cin>>b;
  int t[b];
  for(int i=0;i<b;i++){
      scanf("%d",&t[i]);
  }
  for(int i=0;i<b;i++){
      count+=binary_search(i,a,num,t);
  }
  cout<<count<<endl;
}


Measured memory_bytes: 3716
/**
*   @Author : MeGaCrazy
*   @InitTime : Fri Jan 04 17:30:08 2019
*   @Idea :
*
*
*
*
*
*  Happy Solving :)
**/
#include <bits/stdc++.h>
using namespace std;
int main(){
#ifndef ONLINE_JUDGE
   //freopen("in","r",stdin);
   //freopen("out","w",stdout);
#endif
   int n;
   cin>>n;
   set<int>v;
   int cnt=0;
   for(int i=0;i<n;i++){
       int a;
       cin>>a;
       if(a<400)v.insert(1);
       else if(a<800)v.insert(2);
       else if(a<1200)v.insert(3);
       else if(a<1600)v.insert(4);
       else if(a<2000)v.insert(5);
       else if(a<2400)v.insert(6);
       else if(a<2800)v.insert(7);
       else if(a<3200)v.insert(8);
       else{
       cnt++;
       }
   }
   if(v.size()==0){
    v.insert(1);
    cnt--;
   }
   cout<<v.size()<<" "<<cnt+(int)v.size()<<endl;
 
 
 
 
}

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


struct Node{
	int key;
	struct Node *right, *left , *parent;
};

struct Node *root , *NIL;

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

struct Node * find(struct Node *u , int k)
{
	while( u != NIL && k != u->key)
	{
		if( k < u->key)u = u->left;
		else u = u ->right;
	}
	return u;
}

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

void treeDelete(struct Node *z)
{
	struct Node *y;
	struct Node *x;
	
	if(z->left == NIL || z->right == NIL) y = z;
	else y = treeSuccessor(z);
	
	if( y->left != NIL)
	{
		x = y->left;
	}
	else{
		x = y->right;
	}
	
	if( x != NIL)
	{
		x->parent = y->parent;
	}
	
	if(y->parent == NIL)
	{
		root = x;
	}
	else{
		if( y == y->parent->left)
		{
			y->parent->left = x;
		}
		else{
			y->parent->right = x;
		}
	}
	
	if(y != z)
	{
		z->key = y->key;
	}
	
	free(y);
}	

void insert(int k)
{
	struct Node *y = NIL;
	struct Node *x = root;
	struct Node *z;
	
	z = (struct Node *)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(struct Node *u)
{
	if( u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}

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

int main(void)
{
	int  n , i , x;
	char com[100];
	char str1[] = "insert";
	char str2[] = "print";
	char str3[] = "delete";
	scanf("%d",&n);
	
	for( i = 0; i < n; i++)
	{
		while(scanf("%s",com) != EOF)
		
		if(com[0] == 'f')
		{
			scanf("%d",&x);
			struct Node *t = find(root,x);
			if( t != NIL) printf("yes\n");
			else printf("no\n");
		}
		else if(strcmp(com,str1) == 0)
		{
			scanf("%d",&x);
			insert(x);
		}
		else if(strcmp(com,str2) == 0)
		{
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
		else if(strcmp(com,str3) ==0)
		{
			scanf("%d",&x);
			treeDelete(find(root,x));
		}
	}
	return 0;
}



Measured memory_bytes: 20452
#include<stdio.h>
int main()
{
    int a,b,c,d,e,f,i,j,n;
    char x[10];
    gets(x);
    if(x[2]==x[3]&&x[4]==x[5])
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define MAXN	500005
#define EPS	1e-8
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
struct point {double x, y; };
point operator + (point a, point b) {return (point) {a.x + b.x, a.y + b.y}; }
point operator - (point a, point b) {return (point) {a.x - b.x, a.y - b.y}; }
point operator * (point a, double b) {return (point) {a.x * b, a.y * b}; }
double operator * (point a, point b) {return a.x * b.y - a.y * b.x; }
bool equal(double a, double b) {return fabs(a - b) <= EPS; }
point q[MAXN];
point get(point a, point b, double x) {
	point tmp = (b - a) * (1 / (b.x - a.x));
	return a + tmp * (x - a.x);
}
int main() {
	int l = 1, r = 1, n, L;
	q[1] = (point) {0, 0};
	read(n), read(L);
	for (int i = 1; i <= n; i++) {
		point p; read(p.y), read(p.x);
		p.y *= p.x; p = p + q[r];
		q[++r] = p;
		while (p.x - q[l].x > L + EPS) l++;
		if (!equal(p.x - q[l].x, L)) q[l - 1] = get(q[l], q[l - 1], p.x - L), l--;
		while (r - l >= 2 && (q[r] - q[r - 1]) * (q[r] - q[r - 2]) > EPS) q[r - 1] = q[r], r--;
		printf("%.10lf\n", (q[r].y - q[l].y) / L);
	}
	return 0;
}

Measured memory_bytes: 18304
#include<bits/stdc++.h>
using namespace std;
char a[4];
int main()
{
cin>>a;
if(a[0]==a[1]||a[1]==a[2]||a[2]==a[3]||a[3]==a[4])cout<<"Bad"<<endl;
else cout<<"Good"<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n, k;
  cin >> n >> k;
  vl w(n), v(n);
  rep(i, n) cin >> w[i] >> v[i];

  vector<vl> dp(n+1, vl(1e5+1, 1LL<<40));
  dp[0][0] = 0;
  rep(i, n) {
    rep(j, 1e5+1) {
      dp[i+1][j] = dp[i][j];
      if (j >= v[i]) {
        cmin(dp[i+1][j], dp[i][j-v[i]] + w[i]);
      }
    }
  }

  ll ans = 0;
  rep(i, 1e5+1) {
    if (dp[n][i] <= k) ans = i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 80256
def ABC_132_A():
    S = input()
    if S.count(S[0]) != 2 or S.count(S[1]) != 2 or S.count(S[2]) != 2 or S.count(S[3]) != 2:
        print('No')
    else:
        print('Yes')
 
if __name__ == '__main__':
 
    ABC_132_A()

Measured memory_bytes: 9036
#include<stdio.h>
#include<map>
#include<algorithm>
#include<stack>
#include<queue>
#include<string.h>
#include<math.h>
#include<iostream>
using namespace std;
#define inf 1000000007
long long a,b,ans=0,d;
int main()
{
    scanf("%lld%lld",&a,&b);
    if(a>=2){
        ans+=a*(a-1)/2;
    }
    if(b>=2){
        ans+=b*(b-1)/2;
    }
        printf("%lld\n",ans);
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

signed main() {
	int N, K;
	cin >> N >> K;
	vector<int> p(N);
	for (int i = 0; i < N; ++i)
		cin >> p[i];
	vector<int> acc(N + 1, 0);
	for (int i = 1; i <= N; ++i)
		acc[i] = acc[i - 1] + p[i - 1];
	int mx = 0;
	for (int i = 0; i <= N - K; ++i)
		mx = max(mx, acc[i + K] - acc[i]);
	cout << setprecision(10) << ((mx + K) / 2.0) << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007
 
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 main(){
    string s;
    cin >> s;
    
    for (int i = 0; i < s.size(); i++){
        if(i % 2 == 0){
            if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D'){
                continue;
            }else{
                cout << "No" << endl;
                return 0;
            }
        }else{
            if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D'){
                continue;
            }else{
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<cmath>
#include <iomanip>
int main(){
  int a,b,h,m;
  std::cin>>a>>b>>h>>m;
  std::cout<<std::fixed<<std::setprecision(10)<<std::sqrt(a*a+b*b-2*a*b*std::cos(M_PI*(60*h-11*m)/360))<<std::endl;
}

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

int main() {
  long int n;
  cin >> n;
  double rn = sqrt(n);
  double sa = 1000010;
  long int out;
  for(int i = 1; i < 1000010; i++){
    if(n % i == 0){
      if(fabs(rn - i) < sa){
        sa = fabs(rn - i);
        out = i;
      }
    }
  }
  cout << out + (n / out) - 2;
    
}

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


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

class BMinorChange {
public:
	void solve(std::istream& in, std::ostream& out) {
        string s,t;
        in >> s >> t;

        int c=0;
        rep(i,s.size()){
            if(s[i]!=t[i])c++;
        }
        out << c << endl;
	}
};


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


Measured memory_bytes: 3864
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <array>
#include <stack>
#include <queue>
#include <chrono>
#include <numeric>
#include <memory.h>
#include <map>

#pragma warning(disable:4996)
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
typedef long long Int;

using namespace std;

int dx[4] = { 0, -1, 0, 1 };
int dy[4] = { 1, 0, -1, 0 };

const Int M_H(2);
const Int M_W(4);

short tile[M_H][M_W];
int H, W;
short dp[8][8][8][8][8][8][8];

struct point{
	Int x, y, step;
	short tile[M_H][M_W];
	int dx, dy;
	point(Int x_, Int y_, Int s, short tile_[M_H][M_W], int dx_, int dy_) :x(x_), y(y_), step(s), dx(dx_), dy(dy_)
	{
		memcpy(tile, tile_, sizeof(tile));
	}
};

queue<point> que;

bool check(short tile[M_H][M_W])
{

	for (int i = 0; i < 8; ++i){
		if (tile[i / 4][i % 4] != i)
			return false;
	}
	return true;
}

int solve()
{
	while (!que.empty()){
		auto now = que.front();
		que.pop();
		
		if (!dp[now.tile[0][0]][now.tile[0][1]][now.tile[0][2]][now.tile[0][3]][now.tile[1][0]][now.tile[1][1]][now.tile[1][2]])
			dp[now.tile[0][0]][now.tile[0][1]][now.tile[0][2]][now.tile[0][3]][now.tile[1][0]][now.tile[1][1]][now.tile[1][2]] = now.step;
		else
			continue;

		int i(4);
		while (i--){
			int x = now.x + dx[i];
			int y = now.y + dy[i];

			if (x >= M_W || x < 0 || y >= M_H || y < 0)
				continue;

			if (now.dx == -dx[i] && now.dy == -dy[i])
				continue;

			if (check(now.tile))
				return now.step;

			short temp[M_H][M_W];
			memcpy(temp, now.tile, sizeof(temp));
			short temp_2 = temp[y][x];
			temp[y][x] = 0;
			temp[y - dy[i]][x - dx[i]] = temp_2;
			que.emplace(x, y, now.step + 1, temp,dx[i],dy[i]);
		}
	}
	return -1;
}

int main()
{
	cin.tie(0); ios::sync_with_stdio(false);
	//fstream fs("input.txt");
	////////////ここから開始///////////
	//fs >> W >> H;
	int(n);
	while (cin >> n){
		memset(dp,0,sizeof(dp));
		tile[0][0] = n;
		for (int i = 1; i < 8; ++i){
			cin >> tile[i / 4][i % 4];
		}

		que = {};

		REP(i, 2)REP(j, 4){
			if (tile[i][j] == 0){
				que.emplace(j, i, 0, tile,0,0);
			}
		}
		cout << solve() << endl;
	}

	return 0;
}

Measured memory_bytes: 5472
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int h,w,num[26]={0},z=1;
    char a;
    cin>>h>>w;
    rep(i,h)rep(j,w) cin>>a,num[a-'a']++;
    int k=0,m=(h/2)*(w/2);
    rep(i,26) k+=num[i]/4;
    if(k<m) z=0;
    else rep(i,26) while(m>0&&num[i]>=4) num[i]-=4,m--;
    if(h%2||w%2){
        int k=0,m=(h/2)*(w%2)+(h%2)*(w/2);
        rep(i,26) k+=num[i]/2;
        if(k<m) z=0;
    }
    if(z) cout<<"Yes";
    else cout<<"No";
}

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

int main() {
	long x=2,y=1,n;
	cin>>n;
	for(int i=1;i<n;i+=2){
		x+=y;
		y+=x;
	}
	if(n%2==0){
		cout<<x<<endl;
	}
	else{
		cout<<y<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600
#define long long long // for codeforces

int main(){
  int a,b;
  while(cin>>a>>b){
    vector<int> vec(100,0);
    do{
      a--;b--;
      vec[a]++;
      vec[b]++;
    } while(cin>>a>>b, a|b);

    vec[0]++; vec[1]++;
    bool ok=true;
    rep(i,100) if(vec[i]%2==1) ok=false;
    if(ok) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
  }

  return 0;
}

Measured memory_bytes: 3048
#include <iostream>
#include <vector>
 
using namespace std;
 
int main(){
	int n,tg=1;
	cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;++i)cin >> a[i];
	for(int i=0;i<n;++i){
		if(tg==a[i]){
			tg++;
		}
	}
	if(tg!=1)cout << n - tg + 1 << endl;
	else cout << -1 << endl;
}

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

int main(){
  int n,k,m;
  while(cin>>n>>k>>m,n){
    vector<int> vec(n);
    for(int i=0;i<n;i++)
      vec[i]=i+1;
    int index=m-1;
    k--;
    while(n>1){
      n--;
      vec.erase(vec.begin()+index);
      index=(index+k)%n;
    }
    cout<<vec[0]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1252
//--- pC ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	public Solution () {
		reader = new Reader();
		while (reader.hasNext()) {
			run_case();
		}
	}

	private void run_case() {
		long N = Long.parseLong(reader.ns());
		long K = Long.parseLong(reader.ns());

		N %= K;

		long res = Math.min(N, Math.abs(N - K));
		System.out.println(res);

		return;
	}
}


class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public String ns() {return this.next();}
}


Measured memory_bytes: 21076
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second < b.second);}
ll gcd(ll a, ll b){if(a==0)return b;return gcd(b % a, a);}
int main()
{
	chutiyaap;
	ll a,b,k;cin>>a>>b>>k;
	if(a>=k)
	{
		cout<<a-k<<" "<<b;
	}
	else
	{
		cout<<"0"<<" ";
		cout<<max((ll)0,b-(k-a));
	}
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(int),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
double dmax(double a,double b){
    return a>b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
int max(int x,int y){
    if(x>y)return x;
    else return y;
}

int min(int x,int y){
    if(x>y)return y;
    else return x;
}

int main(void){
    int i=0,j,k,l=0,n=in(),x[n],y[n],z,h[n],cx=0,cy=0,height;
    rep(i,n){
        x[i]=in();
        y[i]=in();
        h[i]=in();
    }
    i=0;
    while(1){
        if(h[i]!=0)break;
        i++;
    }
    while(1){
        while(1){
            k=0;
            height=h[i]+abs(x[i]-cx)+abs(y[i]-cy);
            rep(j,n){
                z=h[j]+abs(x[j]-cx)+abs(y[j]-cy);
                if(h[j]!=0){
                    if(z!=height){
                        k=1;
                        break;
                    }
                }
                else if(z<height){
                    k=1;
                    break;
                }
            }
            if(k==0) break;
            else cy++;
            if(cy==101){
                cy=0;
                break;
            }
        }
        if(k==0) break;
        else cx++;
    }
    printf("%d %d %d\n",cx,cy,height);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;

void test();

vector<int> g[N],dist(N,INT_MAX);

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	cin >> n >> m;
	f(i,0,m){
		int x,y;
		cin >> x >> y;
		g[x].pb(y);
	}
	int s,t;
	cin >> s >> t;
	queue<int> q;
	q.push(s);
	dist[s] = 0;
	while(!q.empty()){
		int u = q.front();
		q.pop();
		for(auto &i : g[u]){
			for(auto &j : g[i]){
				for(auto &k : g[j]){
					if(dist[k]==INT_MAX){
						dist[k] = dist[u]+1;
						q.push(k);
						if(k==t){
							cout << dist[k] << "\n";
							return 0;
						}
					}
				}
			}
		}
	}
	cout << "-1\n";
	return 0;
}

Measured memory_bytes: 6144
#include <iostream>
#include <sstream>
#include <regex>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
//const int INF = 100100100;
const int INF = (1LL << 32);
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;

signed main() {
	ios::sync_with_stdio(false);
	int n, m, c;
	cin >> n >> m >> c;
	vector<int> A[100];
	vector<int> B(100);
	rep(i, m) cin >> B[i];
	rep(i, n) {
		rep(j, m) {
			int x;
			cin >> x;
			A[i].pb(x);
		}
	}
	vector<int> ans;
	rep(i, n) {
		int sum = 0;
		rep(j, m) {
			sum += A[i][j] * B[j];
		}
		if (sum + c > 0) {
			ans.pb(i);
		}
	}
	cout << ans.size() << endl;
 	return 0;
}



Measured memory_bytes: 256
# https://atcoder.jp/contests/abc153/tasks/abc153_f
# 座標圧縮、貪欲法、imos法


import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


# まず、何回攻撃すればいいのかを計算する。これがとにかく必要だ(なくてもいいけど)。
#
# 素直な戦略として、左から倒せるギリギリの爆弾を投下して倒すのが最適
# だけどナイーブに実装すると、O(N^2)。だから体力を管理するのが重要。
# どこにどれだけダメージが蓄積したのかはimos法(デルタ関数をおいてから累積和)で管理できる。

from bisect import bisect_left
N, D, A = read_ints()
XH = read_tuple(N)
XH.sort()  # 座標でソート

n_atk = []  # 何回攻撃するのが必要か
X = []  # 座標アクセス用配列
for x, h in XH:
    n_atk.append((h - 1) // A + 1)
    X.append(x)

damege = [0] * (N + 10)  # ダメージ管理用、配列外アクセスがめんどくさいので長めに取る
ans = 0
# j = 0  # 次のxが、今のx+2d以下でもっとも大きなidx
for i, (x, n) in enumerate(zip(X, n_atk)):
    damege[i] += damege[i - 1]  # 積分して、現時点の蓄積回数を表示
    atk = max(0, n - damege[i])  # iには何回攻撃したか
    if atk == 0:
        continue
    ans += atk
    # 攻撃下回数を記録
    damege[i] += atk
    # 効果が切れる点を予約 # 尺取ならO(1)で次に行けるけど二分探索でも間に合うか
    # while j < len(X) and X[j] < x + 2 * D + 1:  # あんま高速化しないね
    #     j += 1
    # damege[j] -= atk  # 効果切れを予約
    damege[bisect_left(X, x + 2 * D + 1, lo=i)] -= atk  # 二分探索で十分速い


print(ans)


Measured memory_bytes: 48636
package main

import (
  "bufio"
  "fmt"
  "os"
  "strconv"
)

var sc = bufio.NewScanner(os.Stdin)


func next() string {
  sc.Scan()
  return sc.Text()
}

func main() {
  sc.Split(bufio.ScanWords)
  s := next()
  t := next()
  a, _ := strconv.Atoi(next())
  b, _ := strconv.Atoi(next())
  u := next()
  
  if s == u {
    a--
  } else if t == u {
    b--
  } else {
    // noting to do
  }
  aStr := strconv.Itoa(a)
  bStr := strconv.Itoa(b)
  answer := aStr + " " + bStr
  fmt.Println(answer)
}

Measured memory_bytes: 640
#include <stdio.h>
#define NUMBER 1000
int main (void){
  int i,n,x,min,count;
  int m[NUMBER];
  scanf("%d %d",&n,&x);
  count = x;
  min = 1000;
  for (i = 1; i <= n; i++){
    scanf("%d",&m[i]);
    if (m[i] < min)
      min = m[i];
    count -= m[i];
  }
  printf("%d\n",n + count / min);
  return (0);
}
  


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

const ll INF = 1LL << 60;
ll N, M;

int main() {
    cin >> N >> M;
    
    vector<ll> s[M];
    rep(i, M) {
        ll k;
        cin >> k;
        rep(j, k) {
            ll tmp;
            cin >> tmp;
            tmp--;
            s[i].push_back(tmp);
        }
    }

    vector<ll> p(M);
    rep(i, M) cin >> p[i];

    // solve
    ll ans = 0;
    for (int i = 0; i < 1 << N; i++) {
        map<ll, ll> on;
        for (int j = 0; j < N; j++) {
            if (i >> j & 1) {
                on[j]++;
            }
        }

        ll tmp = true;
        for (int j = 0; j < M; j++) {
            ll on_cnt = 0;
            for (int k = 0; k < s[j].size(); k++) {
                if (on.count(s[j][k])) {
                    on_cnt++;
                }
            }

            if (on_cnt % 2 != p[j]) {
                tmp = false;
                break;
            }
        }
        if (tmp) {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32

YES = "YES"  # type: str
NO = "NO"  # type: str

def solve(N: int, A: "List[int]"):
    if len(list(set(A))) == N:
        print(YES)
    else:
        print(NO)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


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

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

    ll X;
    cin >> X;
    for (int i = -200; i <= 200; i++) {
        for (int j = -200; j <= 200; j++) {
            ll a = pow(i, 5), b = pow(j, 5);
            if (a - b == X) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3984
S = input()
if S[0] == 'R':
    if S[1] == 'R':
        if S[2] == 'R':
            print(3)
        else:
            print(2)
    else:
        print(1)
else:
    if S[1] == 'R':
        if S[2] == 'R':
              print(2)
        else:
              print(1)
    else:
        if S[2] == 'R':
              print(1)
        else:
              print(0)

Measured memory_bytes: 9116
n,k=map(int,input().split())

a=list(map(int,input().split()))

l=[1]
di={}
di[1]=1

for i in a:
    b=a[l[-1]-1]
    if b in di:
        x=b
        break
    l.append(b)
    di[b]=1
t1=0
for j in l:
    if j==x:
        break
    else:
        t1+=1

t2=len(l)-t1
if k<=t1:
    print(l[k])

else:
    aa=(k-t1)%t2
    print(l[t1+aa])


Measured memory_bytes: 35492
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;

const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
typedef long long ll;

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

    vec r(N);
    for(int i=0;i<N;i++){
        scanf("%d", &r[i]);
    }

    double left = 0, right = 2*r[0];
    vector<double> x(N, 0);
    x[0] = r[0];
    for(int i=1;i<N;i++){
        for(int j=i-1;j>=0;j--){
            x[i] = max(x[i], x[j] + sqrt((r[i]+r[j])*(r[i]+r[j]) - (r[i]-r[j])*(r[i]-r[j])));
        }
        left = min(left, x[i]-r[i]);
        right = max(right, x[i]+r[i]);
    }

    printf("%.6f\n", right - left);

    return 0;
}

Measured memory_bytes: 1260
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <new>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef int64_t i64;

int main() {
	ios_base::sync_with_stdio(false);
	i64 a, b;
	cin >> a >> b;
	if(abs(a - b) <= 1) {
		cout << "Brown" << endl;
	} else {
		cout << "Alice" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<string> w(n);
    for (int i = 0; i < n; i++) {
        cin >> w.at(i);
    }
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (w.at(i) == w.at(j)) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    for (int i = 0; i < n - 1; i++) {
        string r;
        string s;
        r = w.at(i);
        s = w.at(i + 1);
        if (r.at(r.size() - 1) != s.at(0)) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void) {
	int m, d, day;
	string dstr[7] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

	while(true) {
		cin >> m >> d;
		if(m == 0) { break; }
		day = 0;
		switch(m) {
			case 12:
				day += 30;
			case 11:
				day += 31;
			case 10:
				day += 30;
			case 9:
				day += 31;
			case 8:
				day += 31;
			case 7:
				day += 30;
			case 6:
				day += 31;
			case 5:
				day += 30;
			case 4:
				day += 31;
			case 3:
				day += 29;
			case 2:
				day += 31;
			case 1:
				day += d;
				break;
		}
		cout << dstr[(day+9)%7] << endl;
	}

	return 0;
}

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

a = list(map(int,input().split()))

dic = {}

for i in a:

    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1

ans = 0

for i in dic:

    if i > dic[i]:
        ans += dic[i]

    else:
        ans += ( dic[i] - i )

print (ans)


Measured memory_bytes: 17780
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <utility>
#include <algorithm>

using namespace std;

int main(void)
{
    int N;
    cin >> N;
    vector<pair<pair<int, string>, int>> restrans;
    for (int i = 0; i < N; i++)
    {
        string name;
        int point;
        cin >> name >> point;
        pair<pair<int, string>, int> tmp;
        tmp.first.first = point;
        tmp.first.second = name;
        tmp.second = i + 1;
        restrans.push_back(tmp);
    }

    for (int i = 0; i < N; i++)
    {
        for (int i = 0; i < N - 1; i++)
        {
            if (restrans[i].first.first < restrans[i + 1].first.first)
            {
                pair<pair<int, string>, int> tmp;
                tmp = restrans[i];
                restrans[i] = restrans[i + 1];
                restrans[i + 1] = tmp;
            }
        }
    }

    for (int i = 0; i < N; i++)
    {
        for (int i = 0; i < N - 1; i++)
        {
            if (restrans[i].first.second > restrans[i + 1].first.second)
            {
                pair<pair<int, string>, int> tmp;
                tmp = restrans[i];
                restrans[i] = restrans[i + 1];
                restrans[i + 1] = tmp;
            }
        }
    }

    for (int i = 0; i < N; i++)
    {
        std::cout << restrans[i].second << std::endl;
    }
}

Measured memory_bytes: 256
#import <stdio.h>
#import <string.h>
#import <Foundation/Foundation.h>

BOOL match(char *S, char *T, int pos) {
    unsigned long t = strlen(T);
    for (int i=0;i<t;i++) {
        if (S[pos+i]==T[i] || S[pos+i]=='?') {
            continue;
        }
        return NO;
    }
    return YES;
}

void fill(char *S, char *T, char *U, int pos) {
    int s = strlen(S);
    int t = strlen(T);
    for (int i=0;i<s;i++) {
        if (pos<=i && i<pos+t) {
            U[i] = T[i-pos];
        } else {
            U[i] = S[i];
        }
    }
}

NSInteger comparator(NSString *str1, NSString *str2, void *context) {
    return [str1 compare:str2];
}

int main() {
    @autoreleasepool {
        char S[100] = {'\0'};
        char T[100] = {'\0'};
        scanf("%s %s", S, T);
        int s = strlen(S);
        int t = strlen(T);
        
        NSMutableArray *candidates = [NSMutableArray array];
        for(int i=0;i<=s-t;i++) {
            if (match(S, T, i)) {
                char U[100] = {'\0'};
                fill(S,T,U,i);
                NSMutableString *str = [NSMutableString stringWithUTF8String:U];
                [str replaceOccurrencesOfString:@"?" withString:@"a" options:0 range:NSMakeRange(0, [str length])];
                [candidates addObject: str];
            }
        }
        if ([candidates count] > 0) {
            [candidates sortUsingDescriptors:@[[[[NSSortDescriptor alloc] initWithKey:@"self" ascending:NO] autorelease]]];
            NSArray *array = [candidates sortedArrayUsingFunction:comparator context:nil];
            printf("%s", [(NSString*)[array objectAtIndex:0] UTF8String]);
        } else {
            printf("UNRESTORABLE");
        }
    }
}


Measured memory_bytes: 2660