akhauriyash/Code-Regression huggingface dataset:
'use strict';
function Main(stdin){
  const input = stdin.trim().split(/\r?\n/g);
  const [h,w,k] = input.shift().split(' ').map(Number);
  const c = input;
  let result = 0;
  for(let is = 0; is < 1 << h; is++){
    for(let js = 0; js < 1 << w; js++){
    let sum = 0;
      for(let i = 0; i < h; i++){
        if((is >> i) & 1) continue;
        for(let j = 0; j < w; j++){
          if((js >> j) & 1) continue;
          if(c[i][j] === "#") sum++;
        }
      }
      if(sum === k) result++;
    }
  }
  console.log(result);
}
// 固定
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 32372
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

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

    long long a[n + 1];
    long long b[n + 1];
    b[n] = 0;
    for (int i = 0; i <= n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];

    long long res = 0;
    if (a[0] < b[0]) {
        res += a[0];
        b[0] -= a[0];
        a[0] = 0;
    } else {
        res += b[0];
        b[0] = 0;
    }

    for (int i = 1; i < n; i++) {
        // cout << "i = " << i << ", a[i] = " << a[i] << ", b[i - 1] = " << b[i - 1] << ", b[i] = " << b[i] << endl;
        // i - 1 の処理
        if (b[i - 1] > 0) {
            if (a[i] <= b[i - 1]) {
                res += a[i];
                b[i - 1] -= a[i];
                a[i] = 0;
            } else {
                res += b[i - 1];
                a[i] -= b[i - 1];
            }
        }

        // i の処理
        if (a[i] > 0) {
            if (a[i] <= b[i]) {
            res += a[i];
            b[i] -= a[i];
            a[i] = 0;
        } else {
            res += b[i];
            a[i] -= b[i];
            b[i] = 0;
        }
        }
    }

    // n - 1の処理
    if (b[n - 1] > 0) {
        if (a[n] <= b[n - 1]) {
            res += a[n];
            b[n - 1] -= a[n];
            a[n] = 0;
        } else {
            res += b[n - 1];
            a[n] -= b[n - 1];
            b[n - 1] = 0;
        }
    }

    // n の処理
    if (a[n] > 0) {
        if (a[n] <= b[n]) {
            res += a[n];
        } else {
            res += b[n];
        }
    }

    cout << res << endl;
}


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

using namespace std;

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    long long a, b, k;
    cin >> a >> b >> k;

    if(k <= a) cout << a-k << " " << b << '\n';
    else if(k <= a + b) cout << 0 << " " << a + b - k << "\n";
    else cout << 0 << " " << 0 << '\n'; 

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  
using namespace std;  
// Important header files   
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
#include <iostream>  
using namespace __gnu_pbds;  
using namespace std;  
  
// Declaring ordered_set 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update>  
    ordered_set; 
#define rep(i,n) for(li i=0;i<n;i++)
#define li long long int
#define ll long long int
#define pb push_back
#define all(v) sort(v.begin(),v.end())
const int N = 40043;
const ll mod = 1e9 + 7;
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f first
#define s2 second
const ll INF=(1LL<<60)-1;


li gcd(li a,li b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
li lcm(li a,li b)
{
    return (a*b)/gcd(a,b);
}
li power(li a,li b)
{
    li res=1;
    while(b)
    {
        if(b&1)
        res=(res*a);
        a=((a)*(a));
        b>>=1;
    }
    return res;
}
 
li xx,yy,dd;
void equation(li a,li b)
{
    if(b==0)
    {
        xx=1;
        yy=0;
        dd=a;
    }
    else
    {
        equation(b,a%b);
        li temp=xx;
        xx=yy;
        yy=temp-(a/b)*yy;
    }
}
li inverse(li a,li m)
{
    equation(a,m);
    return(xx%m+m)%m;
}
bool compare(const pair<li,li> &i, pair<li,li> &j)
{
    if(i.f==j.f)
    return i.s2 > j.s2;
    else
    return i.f<j.f;
    
}

void solve()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  int i=0,j=n-1;
  int ans=0;
  while(i<j)
  {
      if(s[i]=='W' && s[j]=='R')
      {
          s[i]='R';
          s[j]='W';
          ans++;
          i+=1;
          j-=1;
      }
      else if(s[i]=='W')
      j-=1;
      else
      i+=1;
  }
  rep(i,n)
  {
      if(s[i]=='R' && s[i-1]=='W')
      ans++;
  }
  cout<<ans;
}
signed main()
{
   //seive();
   //cout<<prime.size();
   FAST_IO;
   int t;
   t=1;
   while(t--)
   {
       solve();
       
   }
}

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

int main() {
  int n;
  std::cin >> n;
  std::vector<int> x(n);
  std::vector<int> y(n);
  std::vector<int64_t> h(n);

  for (int i = 0; i < n; i++) {
    std::cin >> x[i] >> y[i] >> h[i];
  }

  for (int x_p = 0; x_p <= 100; x_p++) {
    for (int y_p = 0; y_p <= 100; y_p++) {
      bool flag = true;
      int64_t h_max_ = -1, esti_h_ = -1;
      for (int num = 0; num < n; num++) {
        if (h[num] == 0) {
          const int64_t h_max
            = std::abs(x_p - x[num]) + std::abs(y_p - y[num]);
          if (h_max_ == -1) {
            h_max_ = h_max;
          } else {
            h_max_ = std::min(h_max, h_max_);
          }

          if (esti_h_ != -1) {
            if (h_max_ < esti_h_) {
              flag = false;
              break;
            }
          }
        } else {
          const int64_t esti_h
            = h[num] + std::abs(x_p - x[num]) + std::abs(y_p - y[num]);

          if (esti_h_ != -1) {
            if (esti_h != esti_h_) {
              flag = false;
              break;
            }
          } else {
            esti_h_ = esti_h;
          }

          if (h_max_ != -1) {
            if (h_max_ < esti_h_) {
              flag = false;
              break;
            }
          }
        }
      }
      if (flag) {
        std::cout << x_p << " " << y_p << " " << esti_h_ << std::endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#coding: utf-8

def getInput():
    in_row = [ int(x) for x in input().split(" ") ]
    return in_row

def gcd(n1, n2):
    while n1 % n2 != 0:
        if n1 < n2:
            n1, n2 = n2, n1
        n1 %= n2
    return n2
            
def judgeTakahashi(in_row):
    A = in_row[0]
    B = in_row[1]
    C = in_row[2]
    D = in_row[3]
    g = gcd(B, D)

    if B > A:
        return False
    if B > D:
        return False
    if C >= B:
        return True
    
    if B-g+(A%g) > C:
        return False
    else:
        return True

if __name__ == "__main__":
    N = int(input())
    assert gcd(1071, 1029) == 21, "error"
    assert not(judgeTakahashi([1, 10, 1, 1])), "error"
    for i in range(N):
        in_row = getInput()
        result = "Yes" if judgeTakahashi(in_row) else "No"
        print(result)


Measured memory_bytes: 3064
n, m = map(int, input().split())
S = []
for _ in range(m):
    S.append(list(map(int, input().split()))[1:])
*p, = map(int, input().split())

ans = 0
for i in range(2**n):
    switch = [i >> j & 1 for j in range(n)]
    c = 0
    for k, s in enumerate(S):
        count = 0
        for s1 in s:
            if switch[s1-1]:
                count += 1
        if count % 2 == p[k]:
            c += 1
    if m == c:
        ans += 1
print(ans)


Measured memory_bytes: 41948
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>

using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;

int main(){

    string s;
    
    cin >>  s;
    int cnt=0;
    
    int n=0;

    if(s[0]=='R'){
        cnt=1;
    }
    if(s[1]=='R'){
        cnt=1;
    }
    if(s[2]=='R'){
        cnt=1;
    }
    if(s[0]=='R'){
        if(s[1]=='R'){
            cnt=2;
        }
    }
    if(s[1]=='R'){
        if(s[2]=='R'){
            cnt=2;
        }
    }
    if(s[0]=='R'){
        if(s[1]=='R'){
            if(s[2]=='R'){
                cnt=3;
            }
        }
    }
    
    cout << cnt << endl;

     return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <stdio.h>
#include <algorithm>
//#include <string>
#include <math.h>
//#include <vector>

using namespace std;


int main() {
  int A, B, N;
  int tmp;
  
  cin >> N >> A >> B; 

  if(A<B){tmp=A;A=B;B=tmp;} 
  
  if(((A-B)%2)==1){
    cout << "Borys";
  }else{
    cout << "Alice";
  }    
  return 0;
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

h,w = na()
ar = []
for i in range(h):
    ar.append(ns())

safe = True
def ex():
    for i in range(len(ar)):
        for j in range(w):
            if ar[i][j] == '#':
                if i == 0:
                    if j == 0:
                        if ar[i][j+1] == "#" or ar[i+1][j] == "#":
                            continue
                        else:
                            return False
                    elif j == w-1:
                        if ar[i][j-1] == "#" or ar[i+1][j] == "#":
                            continue
                        else:
                            return False
                    else:
                        if ar[i][j-1] == "#" or ar[i][j+1] == "#" or ar[i+1][j] == "#":
                            continue
                        else:
                            return False
                elif i == len(ar)-1:
                    if j == 0:
                        if ar[i][j+1] == "#" or ar[i-1][j] == "#":
                            continue
                        else:
                            return False
                    elif j == w-1:
                        if ar[i][j-1] == "#" or ar[i-1][j] == "#":
                            continue
                        else:
                            return False
                    else:
                        if ar[i][j-1] == "#" or ar[i][j+1] == "#" or ar[i-1][j] == "#":
                            continue
                        else:
                            return False
                else:
                    if j == 0:
                        if ar[i][j+1] == "#" or ar[i-1][j] == "#" or ar[i+1][j] == "#":
                            continue
                        else:
                            return False
                    elif j == w-1:
                        if ar[i][j-1] == "#" or ar[i-1][j] == "#" or ar[i+1][j] == "#":
                            continue
                        else:
                            return False
                    else:
                        if ar[i][j-1] == "#" or ar[i][j+1] == "#" or ar[i-1][j] == "#" or ar[i+1][j] == "#":
                            continue
                        else:
                            return False
    return True
if ex() == True:
    print("Yes")
else:
    print("No")


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

int main() {
	int n;cin>>n;
  	vector<int> a(n);
  	int small=101,large=-101,temp=0,ans=200*200*100;
  	for(int i=0;i<n;i++){
    	cin>>a[i];
      	small=min(small,a[i]);
      	large=max(large,a[i]);
    }
  	for (int i=small;i<=large;i++){
    	for(int j=0;j<n;j++){
         	temp+=(i-a[j])*(i-a[j]);
        }
      ans=min(ans,temp);
      temp=0;
    }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>

using namespace std;
#define DEBUG(x) cout<<#x<<": "<<x<<endl

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define INT(a) int((a)+1e-9)
int DX[4]={1,0,-1,0};
int DY[4]={0,1,0,-1};

typedef pair<int,int> Pii;


#define SUPnl 10002

int nl;
int p[SUPnl];

int init(){REP(ni,nl){p[ni]=-1;}}

int getRoot(int a){
	while(true){
		if(p[a]==-1) return a;
		a=p[a];
	}
}

bool same(int a, int b){
	int ra=getRoot(a); int rb=getRoot(b);
	if(ra!=a)p[a]=ra; if(rb!=b)p[b]=rb;
	return ra==rb;
}

void unite(int a, int b){
	a=getRoot(a);
	b=getRoot(b);
	if(a==b) return;
	p[b]=a;
}

int main(){
	int ol;
	cin>>nl>>ol;
	init();
	int ot,a,b;
	REP(oi,ol){
		cin>>ot>>a>>b;
		if(ot==0) unite(a,b);
		if(ot==1) cout<<same(a,b)<<endl;
	}
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) rep2(i,0,n)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
bool x;
int main()
{
	cin>>x;
	re(1-x)
	return 0;}

Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <complex>
#include <cstdlib>

using namespace std;

const double eps = 1e-10;
typedef complex<double> Point;

inline double cross(const Point& a, const Point& b){
    return imag(conj(a) * b);
}

inline double dot(const Point& a, const Point& b){
    return real(conj(a) * b);
}

struct Line : vector<Point> {
    Line(const Point& a, const Point& b):vector<Point>{a, b}{}
};

inline bool parallel(const Line& l, const Line& m){
    return abs(cross(l[1] - l[0], m[1] - m[0])) < eps;
}

inline bool orthogonal(const Line& l, const Line& m){
    return abs(dot(l[1] - l[0], m[1] - m[0])) < eps;
}

int main(){
    int q;
    cin >> q;
    while(q--){
        int x0, y0, x1, y1, x2, y2, x3, y3;
        cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        Line l(Point(x0, y0), Point(x1, y1)), m(Point(x2, y2), Point(x3, y3));
        cout << (parallel(l, m) << 1 | orthogonal(l, m) << 0) << '\n';
    }
    return 0;
}

Measured memory_bytes: 1196
/*
                            ---| APOORVA MITTAL |---
*/
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define endl "\n"
#define nl   "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<pair<int, int>>
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repD(i, a, b) for (int i = a; i >= b; i--)
#define speed                     \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define init(i, k) memset(i, k, sizeof i)

#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define inp(a) rep(i,0,a.size()) cin>>a[i]; 
#define out(a) rep(i,0,a.size()) cout<<a[i]<<" "; \
                cout<<endl;
#define out2d(a)    \
    rep(i,0,a.size())\
    {rep(j,0,a[0].size())\
    cout<<a[i][j]<<" ";\
    cout<<endl;}       

#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define setbit(x)       __builtin_popcountll(x)
#define gcd(a,b)        __gcd(a,b)
#define deb(x) cout<<#x<<" "<<x<<endl;

int lcm(int a, int b) { return (a * (b / __gcd(a, b))); }
int ncr(int n,int r){int res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(int i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}
#define Y				"YES"
#define N 				"NO"
const int mod = 1e9 + 7;
const int inf = 1e18;
const int maxn = 1e3 + 5;
// ====== Useful functions begin ======
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};
// unordered_map<pair<int,int>,int,HASH>m;

inline int add(int a,int b) {return ((a%mod)+(b%mod))%mod;}
inline int sub(int a,int b) {return ((a%mod)-(b%mod)+mod)%mod;}
inline int mul(int a,int b) {return ((a%mod)*(b%mod))%mod;}
int pwr(int x,int n){
    if(!n) return 1;
    if(n&1) return mul(x, pwr(mul(x,x),(n-1)/2));
    else return pwr(mul(x,x),n/2);
}
int modinv(int n){ 
    return pwr(n,mod - 2); 
}

// ====== Useful functions end ======

//--------------------------------------------------------------------------------------------------------------------------------
void solve()
{
    int n; cin>>n;
    int sum=0;
   for(int i=1;i<=n;i++)
   {
       if(i%3==0 || i%5==0) continue;
       sum+=i;

   }
   cout<<sum<<endl;

}
signed main()
{	
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

	speed;
	int t=1;
	// cin>>t;
	
	for(int tt=1;tt<=t;tt++)
	{
		// cout<<"Case #"<<tt<<": ";
		solve();
	}
}


Measured memory_bytes: 3652
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
string a,b;
int main(){
	cin>>a>>b;
	bool f = 1;
	for(int i = 0;i < a.size();i++){
		if(a[i] != b[i]) {f = 0;break;}
	}
	if(f) puts("Yes");
	else puts("No");
	return 0;
}

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

using namespace std ;

const int MAX = 100 ;

int n, m; // number of nodes
vector< vector<int> > adj(MAX); // adjacency list of graph

vector<bool> visited(MAX);
vector<int> tin(MAX), low(MAX);
int timer;

int ans = 0 ;

void dfs(int v, int p = -1) {
    visited[v] = true;
    tin[v] = low[v] = timer++;
    for (int to : adj[v]) {
        if (to == p) continue;
        if (visited[to]) {
            low[v] = min(low[v], tin[to]);
        } else {
            dfs(to, v);
            low[v] = min(low[v], low[to]);
            if (low[to] > tin[v])
                ans++ ;
        }
    }
}

void find_bridges() {
    timer = 0;
    visited.assign(n, false);
    tin.assign(n, -1);
    low.assign(n, -1);
    for (int i = 0; i < n; ++i) {
        if (!visited[i])
            dfs(i);
    }
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>m ;
	for(int i = 0 ; i < m;  ++i)
	{
		int x , y ;
		cin>>x>>y ;
		adj[x].push_back(y) ;
		adj[y].push_back(x) ;
	}
	find_bridges() ;
	return cout<<ans<<"\n" , 0 ;
}

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(){
    int a,b;
    string s;
    cin >> a >> b >>s;
    bool hantei = true;
    rep(i,a+b+1){
        if(i != a){
            if(s[i]-'0'<0 || s[i]-'0' > 9) {
                hantei = false;
        }
        }
        else{
            if(s[i] != '-') hantei = false;
        }
    }
    if(hantei) cout << "Yes"<< endl;
    else cout << "No" <<endl;
}

Measured memory_bytes: 256
a, b, c = map(int, raw_input().split())

if a < b:
    mid = b
    mini = a
    if mid < c:
        maxi = c
    else:
        if mini < c:
            maxi = mid
            mid = c
        else:
            maxi = mid
            mid = mini
            mini = c

else:
    mid = a
    mini = b
    if mid < c:
        maxi = c
    else:
        if mini < c:
            maxi = mid
            mid = c
        else:
            maxi = mid
            mid = mini
            mini = c


print('{} {} {}'.format(mini, mid, maxi))

Measured memory_bytes: 6408
import java.util.*;
import java.util.stream.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static long nCk(int n, int k) {
		long res = 1;
		for (int i=0; i<k; i++) {
			res = res * (n-i) / (i+1);
		}
		return res;
	}

	static void solve() {
		int n = in.nextInt();
		int p = in.nextInt();
		int[] a = new int[n];
		int x = 0;
		int y = 0;
		for (int i=0; i<n; i++) {
			a[i] = in.nextInt();
			if (a[i] % 2 == 0) {
				x += 1;
			} else {
				y += 1;
			}
		}
		long ans = 0;
		for (int i=p; i<=y; i+=2) {
			ans += nCk(y, i);
		}
		ans *= (long)1<<x;
		out.println(ans);
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  ll n,x;
  cin>>n>>x;

  //ll ans=x;
  //ll tmp=n-x,pre=n;
  ll ans=n;
  ll pre=n-x,tmp=x;
  if(pre<tmp) swap(tmp,pre);

  for(;tmp!=0;){
    ans+=(2*(pre/tmp))*tmp;
    //cout<<ans<<endl;

    ll now=pre%tmp;
    pre=tmp;
    tmp=now;
  }
  ans-=pre;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int x[m],dis[m];
    for(int i=0;i<m;i++)
    cin>>x[i];
    if(n>=m)
    {
        cout<<'0'<<endl;return 0;
    }
    sort(x,x+m);
    for(int i=0;i<m-1;i++)
    {
        dis[i]=abs(x[i]-x[i+1]);
    }
    sort(dis,dis+m-1);
    n--;
    int ans=0;
    for(int i=0;i<m-1;i++)
    {
        if(i<n)
        continue;
        ans+=dis[m-i-2];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
//#pragma comment(linker,"/STACK:1024000000,1024000000")
//251103FD
using namespace std;
#define PB pop_back
#define PF pop_front
#define np next_permutation
#define eb emplace_back
#define bf push_front
#define mp make_pair
#define s second
#define f first
#define mt make_tuple
#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)
#define forn(i, a) for(int i=0; i<a; i++)
#define Forn(i, a) for(int i=1; i<=a; i++)
#define read(x) ((scanf("%s", &_), (x) = _))
#define INF 1e9
#define memINF 127
#define inf 1e18
#define all(x) x.begin(), x.end()
#define MOD 1e9+7 
#define HASH 1543 

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<pi,int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef unsigned int uint;

using namespace std;

inline int in() 
{
    int x=0, c;
    for(; (uint)((c=getchar())-'0')>=10;) 
	{ 
		if(c=='-') 
			return -in(); 
		if(!~c)
			throw ~0; 
	}
    do 
	{ 
		x=(x<<3)+(x<<1)+(c^48); 
	} 
	while((uint)((c=getchar())^48)<10);
    return x;
}
inline int gcd(int a, int b){if(a>b) swap(a, b); return a==0?b:gcd(b%a, a);}
inline int lcm(int a, int b){return a*b/gcd(a, b);}

int N, M, par[1000010], ranks[1000010], a, b, c, dist[1000010], all, newNode[1000010], q[500005], l, r;
vector<pi> e[1000010];
vi adj[1000010];
bool used[1000010];

inline int find(int x)
{
	return par[x]==x?x:par[x]=find(par[x]);
}

inline void unite(int x, int y)
{
	x=find(x), y=find(y);
	if(x==y)
		return;
	if(ranks[x]<ranks[y])
		par[x]=y;
	else
	{
		par[y]=x;
		if(ranks[x]==ranks[y])
			ranks[x]++;
	}
}

int main()
{
	while(~scanf("%d %d",&N,&M))
	{
		while(M--)
		{
			a=in(), b=in();
			e[in()].eb(mp(a, b));
		}
		all=N;
		Forn(i, 1000000)
		{
			if(!e[i].size())
				continue;
			int pa;
			foreach(it, e[i])
	        {
	            used[it->f]=used[it->s]=false,
	            newNode[it->f]=newNode[it->s]=-1,
	            ranks[it->f]=ranks[it->s]=0;
	            par[it->f]=it->f;
				par[it->s]=it->s;
	        }
			foreach(it, e[i])
				unite(it->f, it->s);
			foreach(it, e[i])
	        {
	            if(!used[it->f])
	            {
	                used[it->f]=true;
	                pa=find(it->f);
	                if(newNode[pa]<=0)
	                    newNode[pa]=++all;
	                adj[it->f].eb(newNode[pa]);
	                adj[newNode[pa]].eb(it->f);
	            }
	            if(!used[it->s])
	            {
	                used[it->s]=true;
	                pa=find(it->s);
	                if(newNode[pa]<=0)
	                    newNode[pa]=++all;
	                adj[it->s].eb(newNode[pa]);
	                adj[newNode[pa]].eb(it->s);
	            }
	        }
		}
		q[0]=1;
		l=0, r=1;
		memset(dist, -1, sizeof(dist));
		dist[1]=0;
		while(l<r)
		{
			int cur=q[l++];
			foreach(it, adj[cur])
				if(dist[*it]<0)
					dist[*it]=dist[cur]+1, q[r++]=*it;
		}
		if(dist[N]<0)
			puts("-1");
		else
			printf("%d\n", dist[N]>>1);
		forn(i, all+1)
	    {
	    	e[i].clear();
	    	adj[i].clear();
	    	used[i]=0;
	    	newNode[i]=0;
	    }
	}
	return 0;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    int ok=0, ng=N, m;
    m = (ok+ng)/2;
    string res;
    cout << 0 << endl;
    flush(cout);
    cin >> res;
    if(res == "Male"){
        //偶数 -> male 奇数 -> femaleが正しい
        while(res != "Vacant"){
            cout << m << endl;
            flush(cout);
            cin >> res;
            if(res == "Vacant") break;
            if((m % 2 == 0 && res == "Male") || (m % 2 == 1 && res == "Female")) ok = m;
            else ng = m;
            m = (ok+ng)/2;
        }
    }
    else if(res == "Female"){
        //偶数 -> female 奇数 -> male
        while(res != "Vacant"){
            cout << m << endl;
            flush(cout);
            cin >> res;
            if(res == "Vacant") break;
            if((m % 2 == 1 && res == "Male") || (m % 2 == 0 && res == "Female")) ok = m;
            else ng = m;
            m = (ok+ng)/2;
        }
    }
    return 0;
}

Measured memory_bytes: 852
#include <stdio.h>

int main(){
  long long int h, w;  scanf("%lld%lld", &h, &w);
  if(h==1 && w==1){
    printf("1\n");
  }else if(h==1 || w==1){
    printf("%lld\n", (h==1 ? w-2 : h-2));
  }else if(h==2 || w==2){
    printf("0\n");
  }else{
    long long int ans = (h - 2) * (w - 2);
    printf("%lld\n", ans);
  }

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e15;
using Graph = vector<vector<int>>;

signed main() {

  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  for( int i = 0; i < N; i++ ) cin >> A[i] >> B[i];
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());

  if( N%2 == 1 ){
    cout << B[N/2] - A[N/2] +1 << endl;
  }else{
    cout << (B[N/2]+B[N/2-1]) - (A[N/2]+A[N/2-1]) + 1  << endl;
  }
}


Measured memory_bytes: 6432
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;

template <typename t>
void print (const t &v){
        for ( auto i :v){
                cout << i << " " ;
        }
        cout << endl;
} 

inline void saveme(){
        ios_base::sync_with_stdio(false);
        cout.tie(0);
        cin.tie(0);
}

int main (){
        ll a,b;
        cin >> a >> b;
        ll count=0,health=b;

        while (b < a ) {
                b += health;
                count ++ ;
        }

        cout << count+1 << endl;

        return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
using Graph=vector<vector<int>>;
typedef long long ll;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int d[10][10];

void warshall_floyd(int n){
    for(int k=0;k<n;k++){ 
        for(int i=0;i<n;i++){ 
            for(int j=0;j<n;j++){ 
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
}

int main(){
    int h,w;cin>>h>>w;
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            int c;cin>>c;
            d[i][j]=c;
        }
    }
    warshall_floyd(10);
    ll ans=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int a;cin>>a;
            if(a==-1) continue;
            ans+=d[a][1];
        }
    }
    cout<<ans<<endl;
}

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

#define LL long long

LL ara[100000+10];
//vector<LL>v;
LL v[100000+10];

LL abso(LL x)
{
	if(x<0)
		return -1*x;

	else
		return x;
}

int main() {

    LL n,cnt=0,ans=-1,k=1;
    scanf("%lld",&n);

    for(LL i=1;i<=n;i++)
    {
        scanf("%lld",&ara[i]);
    }

    sort(ara+1,ara+n+1);

    for(LL i=1;i<=n;i++)
    {
        if(ara[i]!=ara[i+1])
            cnt=0;

        if(ara[i]==ara[i+1])
        {
            cnt++;

            if(cnt+1==2)
            {
                v[k]=ara[i];
                k++;

            }

            if(cnt+1==4)
            {
                if(ara[i]*ara[i]>ans)
                {
                    ans=ara[i]*ara[i];
                    //cout<<"#*"<<ans<<endl;

                }

            }

        }
    }

    /*for(int i=1;i<=k;i++)
        cout<<v[i]<<" ";
*/
    //vector<LL>::iterator it = v.end();
    LL w = v[k-1];
    LL r = v[k-2];

    //cout<<"*"<<w<<" "<<r<<endl;

    LL ansi=w*r;

    if(ansi>ans)
        printf("%lld\n",ansi);

    else if(ansi<=ans)
        printf("%lld\n",ans);

    else
        printf("0\n");


	return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;
const double PI = 4.0*atan(1.0);

typedef complex<double> Complex;
const Complex I(0, 1);
inline void fft(int n, double theta, Complex a[]) {
  for (int m = n; m >= 2; m >>= 1) {
    int mh = m >> 1;
    for (int i = 0; i < mh; i++) {
      Complex w = exp(i*theta*I);
      for (int j = i; j < n; j += m) {
        int k = j + mh;
        Complex x = a[j] - a[k];
        a[j] += a[k];
        a[k] = w * x;
      }
    }
    theta *= 2;
  }
  int i = 0;
  for (int j = 1; j < n - 1; j++) {
    for (int k = n >> 1; k > (i ^= k); k >>= 1);
    if (j < i) swap(a[i], a[j]);
  }
}

int a[40000], b[40000];
Complex p[1048576];
Complex q[1048576];

vi make(int *a, int n){
	const int N = 1 << 19;
	
	rep(i, N) p[i] = q[i] = 0;
	
	int s = 0;
	p[N / 2] = 1;
	q[N / 2] = 1;
	rep(i, n){
		s += a[i];
		p[N / 2 + s] += 1;
		q[N / 2 - s] += 1;
	}
	fft(N, 2*PI/N, p);
	fft(N, 2*PI/N, q);
	rep(i, N) p[i] *= q[i];
	fft(N,-2*PI/N, p);
	
	
	vi res(N / 2);
	rep(i, N / 2){
		p[i] *= 1.0 / N;
		int x = (int)(p[i].real() + 0.5);
		//if(x) cout << "i: "<<i<<" x: "<<x << endl;
		res[i] = x;
	}
	res[0] = 0;
	return res;
}
vector<ll> make2(vi a, vi b){
	assert(a.size() == b.size());
	int n = a.size();
	const int N = 1 << 20;
	rep(i, N) p[i] = q[i] = 0;
	
	rep(i, n){
		p[N / 2 + i] = a[i];
		q[N / 2 - i] = b[i];
	}
	fft(N, 2*PI/N, p);
	fft(N, 2*PI/N, q);
	rep(i, N) p[i] *= q[i];
	fft(N,-2*PI/N, p);
	
	vector<ll> c;
	rep(i, N){
		p[i] *= 1.0 / N;
		ll x = (ll)(p[i].real() + 0.5);
		//if(x) cout << "i: "<<(i >= N / 2 ? i - N : i)<<" x: "<<x << endl;
		c.pb(x);
	}
	return c;
}
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, m, q;
	cin >> n >> m >> q;
	rep(i, n) cin >> a[i];
	rep(i, m) cin >> b[i];
	
	vi A = make(a, n);
	vi B = make(b, m);
	vector<ll> C = make2(A, B);
	
	while(q--){
		int c; cin >> c;
		cout << C[c] + (c ? C[C.size() - c] : 0) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 48940
#include <bits/stdc++.h>
#define int long long
using namespace std;
main(){
  int e;
  while(cin>>e,e){
    int ans=1e9;
    for(int z=0;;z++){
      if(z*z*z>e)break;
      for(int y=0;;y++){
        if(z*z*z+y*y>e)break;
        int a=e-z*z*z-y*y;
        ans=min(ans,a+y+z);
      }
    }
    cout<<ans<<endl;
  }
}



Measured memory_bytes: 3108
#include "bits/stdc++.h"
using namespace std;
#define fst first
#define scd second
long long ac[100001], wa[100001];
int main()
{
	int n, m;
	long long ans1 = 0, ans2 = 0;
	string s;
	cin >> n >> m;
	for(int i = 0, p; i < m; ++i)
	{
		cin >> p >> s;
		if(!ac[p - 1])
		{
			if(s[0] == 'W')
			{
				++wa[p - 1];
			}
			else
			{
				ac[p - 1] = true;
			}
		}
	}
	for(int i = 0; i < n; ++i)
	{
		if(ac[i])
		{
			++ans1;
			ans2 += wa[i];
		}
	}
	printf("%lld %lld\n", ans1, ans2);
}

Measured memory_bytes: 1664
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let mut v = vec![0; n];
    for _ in 1..n {
        v[read::<usize>() - 1] += 1;
    }
    for i in v {
        println!("{}", i);
    }
}

Measured memory_bytes: 2728
#include<bits/stdc++.h>
using namespace std;
using LL = long long;

int main(){
    LL N;
    cin >> N;
    using P = pair<LL, LL>;
    vector<P> a(N), b(N);
    for(int i = 0;i < N;i++){
        LL ai, bi;
        cin >> ai >> bi;
        a[i] = make_pair(bi, ai);
    }
    for(int i = 0;i < N;i++){
        LL ci, di;
        cin >> ci >> di;
        b[i] = make_pair(ci, di);
    }
    sort(a.rbegin(), a.rend());
    sort(b.begin(), b.end());
    LL count = 0;
    for(int i = 0;i < N;i++){
        LL bx = b[i].first;
        LL by = b[i].second;
        for(int j = 0;j < a.size();j++){
            if(by > a[j].first && bx > a[j].second){
                count++;
                a.erase(a.begin()+j);
                break;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 764
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

n = int(input())
d = [int(input()) for _ in range(n)]

d.sort(reverse=True)

last = 101
ans = 0

for i in range(n):
    if last > d[i]:
        ans += 1
        last = d[i]

print(ans)


Measured memory_bytes: 9116
<?php
list($h, $w, $k) = ints();
$n = $h + $w;
for ($i = 0; $i < $h; ++$i) {
    list($s[]) = strs();
}
$ans = 0;
for ($i = 0; $i < 2 ** $n; ++$i) {
    for ($j = 0; $j < $n; ++$j) {
        if ($i >> $j & 1) {
            $ijs[$j] = 1;
        } else {
            $ijs[$j] = 0;
        }
    }
    $cnt = 0;
    for ($ii = 0; $ii < $h; ++$ii) {
        for ($jj = 0; $jj < $w; ++$jj) {
            if ($ijs[$ii] && $ijs[$jj + $h] && $s[$ii][$jj] === '#') {
                ++$cnt;
            }
        }
    }

    if ($cnt === $k) {
        ++$ans;
    }
}
echo $ans;
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 16088
import java.util.Scanner;
 
class Main {
    Scanner sc = new Scanner(System.in);
 
    int[] count = new int[26];
 
    public void run() {
        while(sc.hasNext()){
            String str = sc.nextLine();
            str=str.toLowerCase();
            char[] c = str.toCharArray();
            for (int i = 0; i < c.length; i++) {
                if ('a' <= c[i] && c[i] <= 'z')
                    count[c[i] - 'a']++;
            }
        }
        for (int i = 0; i < count.length; i++) {
            ln(((char) (i + 'a')) + " : " + count[i]);
        }
    }
 
    public static void main(String[] args) {
        new Main().run();
    }
 
    public static void pr(Object o) {
        System.out.print(o);
    }
 
    public static void ln(Object o) {
        System.out.println(o);
    }
 
    public static void ln() {
        System.out.println();
    }
}


Measured memory_bytes: 26140
#include <bits/stdc++.h>
using namespace std;
int main() {
 vector<string> s;
  s.push_back("Sunny");
  s.push_back("Cloudy");
  s.push_back("Rainy");
  string t; cin >> t;
  for (int i = 0; i < 3; i++) {
   if (t == s[i]) {
    cout << s[(i + 1) % 3] << endl; 
   }
  }
}


Measured memory_bytes: 256
module Main where

import Control.Applicative
import Numeric

main :: IO ()
main = loop

loop :: IO ()
loop = do
  { [n , x] <- getInts
  ; if n == 0 && x == 0 then return ()
  ; else print (length (filter (( x ==) . sum) (comb [1 .. n] 3))) >> loop
  }

comb :: [Int] -> Int -> [[Int]]
comb ns 0 = [[]]
comb ns k = if length ns  == k then [ns]
           else map  (head ns :) (comb (tail ns) (k - 1))
                ++ comb (tail ns) k

--

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn .  unwords . map show

getDoubles :: IO [Double]
getDoubles = map read . words <$> getLine

putDoubles :: [Double] -> IO ()
putDoubles = putStrLn . unwords . map showDouble

showDouble :: Double -> String
showDouble d = showFFloat Nothing d ""



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


int main()
{
	auto& in = cin;

	string S, T;
	in >> S >> T;
	int diff = S.length() - T.length();
	int minD = T.length();
	for (int i = 0; i <= diff; ++i) {
		int d = 0;
		for (size_t j = 0; j < T.length(); ++j) {
			if (S[i + j] != T[j])
				++d;
		}
		if (d < minD)
			minD = d;
	}
	cout << minD;

	return 0;
}


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

int main(){
  int q,h,s,d;
  long long n;
  cin >> q >> h >> s >> d >> n;
  
  int x=min(min(4*q,2*h),s);
  long long ans=min(x*n,d*(n/2)+x*(n%2));
  cout << ans << endl;
}


Measured memory_bytes: 256
s = input()
n = len(s)
k = 1
for i in range(n):
  if s[i] == "D" or s[i] == "U":
    continue
  elif i % 2 == 0:
    if s[i] != "R":
      k = 0
  else:
    if s[i] != "L":
      k = 0
r = ["No","Yes"]
print(r[k])

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20
#define INF 1e12+20

typedef long long ll;
using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    if((a*b)%2) puts("Odd");
    else  puts("Even");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long N;
    cin >> N ;
    string S;
    cin >> S;
    long long count = 1;
    for (long long i = 0; i < N-1; i++){
        if (S.at(i) != S.at(i+1)){
            count++;
        }
    }
    printf("%lld\n", count);
    
}

Measured memory_bytes: 512
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int N = in.nextInt();
        int K = in.nextInt();
        List<Log> list = new ArrayList<>();
        long sum = 0;
        for (int n = 0; n < N; n++) {
            int i = in.nextInt();
            list.add(new Log(i));
            sum += i;
        }
        int k = 0;
        int ave = (int) (sum / Math.max(K, 1));
        if (ave == 0) {
            out.println(1);
        } else {
            TreeSet<Log> set = new TreeSet<>();
            for (Log log : list) {
                int d = Math.max(1, log.A / ave);
                log.D = d;
                set.add(log);
                k += d - 1;
            }
            for (; k < K; k++) {
                Log log = set.pollFirst();
                if (log.length() == 1) {
                    set.add(log);
                    break;
                }
                log.D++;
                set.add(log);
            }
            out.println(set.first().length());
        }

        out.flush();
    }

    static class Log implements Comparable<Log> {
        int A, D;
        Log (int A) {
            this.A = A;
            D = 1;
        }
        int length() {
            return 1 + (A - 1) / D;
        }
        @Override
        public int compareTo(Log o) {
            if (o.length() == length())
                return 1;
            return o.length() - length();
        }
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}



Measured memory_bytes: 82592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int n,m,seen[60],a[60],b[60];

void dfs(int s,int e){
    seen[s]=1;
    for(int i=0;i<m;i++){
        if(i==e)continue;
        if(a[i]==s&&!seen[b[i]]){
            dfs(b[i],e);
        }else if(b[i]==s&&!seen[a[i]]){
            dfs(a[i],e);
        }
    }
}

int main(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        a[i]--;
        b[i]--;
    }
    int ans=0;
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++)seen[j]=0;
        dfs(0,i);
        for(int j=0;j<n;j++){
            if(!seen[j]){
                ans++;
                break;
            }
        }
    }
    cout<<ans<<endl;
}


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

using namespace std;


template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s)
{
    return '"' + s + '"';
}

string to_string(const char* s)
{
    return to_string((string) s);
}

string to_string(bool b)
{
    return (b ? "true" : "false");
}

string to_string(vector<bool> v)
{
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v)
{
    string res = "";
    for (size_t i = 0; i < N; i++)
    {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v)
{
    bool first = true;
    string res = "{";
    for (const auto &x : v)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out()
{
    cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
const int MAXN = 30;
long long a[MAXN][MAXN];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    long long ans = 0;
    for (int i = 1; i <= n; i++)
    {
        if (i % 3 != 0 && i % 5 != 0)
        {
            ans += i;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3644
#!/usr/bin/env ruby
# require 'pry'

# N
# a_1 b_1
# ...
# a_N b_N
# ↑を[[a_1,..a_N],[b_1,..b_N]]にする
# N = gets.to_i
# a, b = N.times.map{gets.split.map(&:to_i)}.transpose

n = gets.to_i
s = gets.chomp.split('')
abc = ['A','B','C']
count = 0
(n-2).times do |i|
  3.times do |j|
    break if s[i+j] != abc[j]
    count += 1 if j == 2
  end
end
puts count

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

using namespace std;

using ll = long long;
const ll mod=1000000007;

int main(){
    int n,w;cin>>n>>w;
    vector<ll>v(n),s(n+1);
    for(int i=0;i<n;++i){
        cin>>v[i];
    }
    sort(v.begin(),v.end(),greater<int>());
    v.push_back(0);
    ll ans=0,sum=0;
    for(int i=n;i>=0;--i){
        sum+=v[i];
        s[i]=sum;
    }
    //????°?????±???????
    for(int i=n;i>=0;--i){
        ll w1=w-s[i]+v[i];
        if(w1<0)break;
        vector<vector<ll>>dp(i+1,vector<ll>(w1+1,0));
        //????????????id
        for(int j=i;j>=0;--j){
            //???????????????
            for(int k=0;k<=w1;++k){
                if(j == i){
                    if(k < v[i])dp[j][k]=1;
                }
                else if(k-v[j]<0)dp[j][k]=dp[j+1][k];
                else dp[j][k]=dp[j+1][k-v[j]]+dp[j+1][k];
                dp[j][k]%=mod;
            }
        }
        ans+=dp[0][w1];
        ans%=mod;
    }
    if(!ans)ans=1;
    cout<<ans<<endl;
}

Measured memory_bytes: 18652
sa = list(input())
sb = list(input())
sc = list(input())
mode = "a"
while True:
    if mode == "a":
        if len(sa) == 0:
            print("A")
            exit()
        mode = sa.pop(0)
    elif mode == "b":
        if len(sb) == 0:
            print("B")
            exit()
        mode = sb.pop(0)
    elif mode == "c":
        if len(sc) == 0:
            print("C")
            exit()
        mode = sc.pop(0)


Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
int q; unsigned x;
int main() {
	cin >> q;
	while(q--) {
		scanf("%x", &x);
		int f = 0;
		if(x >= 2147483648) x -= 2147483648, f = 1;
		long long r1 = x / 128, r2 = x % 128;
		if(f) cout << "-";
		cout << r1 << '.';
		int c = 0;
		while(r2 % 128 != 0) r2 *= 10, c++;
		string s = to_string(r2 / 128);
		while(s.size() < c) s = "0" + s;
		cout << s << endl;
	}
}

Measured memory_bytes: 3320