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

int main(){
	int card[4][13], i, j, t, n;
	string s;

	cin >> n;
	
	for(i = 0; i < 4; i++){	
		for(j = 0; j < 13; j++) card[i][j] =1;
	}

	for(i = 1; i <= n; i++){
		cin>>s>>t;
		if(s == "S") card[0][t-1] = 0;
		if(s == "H") card[1][t-1] = 0;
		if(s == "C") card[2][t-1] = 0;
		if(s == "D") card[3][t-1] = 0;
	}

	for(i = 0; i < 4; i++){
		for(j = 0; j < 13; j++){
			if(card[i][j]){
				if(i == 0) cout<<"S "<<j+1<<endl;
				if(i == 1) cout<<"H "<<j+1<<endl;
				if(i == 2) cout<<"C "<<j+1<<endl;
				if(i == 3) cout<<"D "<<j+1<<endl;
			}
		}
	}

	
	return 0;
}


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

int main(void){
	ll A[2];
	cin >> A[0] >> A[1];
	ll ans[2] = {0,0};
	A[0]--;
	for(int i = 0; i < 2; ++i){
		switch(A[i]%4){
			case 0:
				ans[i] = A[i];
				break;
			case 1:
				ans[i] = 1;
				break;
			case 2:
				ans[i] = A[i] ^ 1;
				break;
			case 3:
				ans[i] = 0;
				break;
			default:
				ans[i] = 0;
				break;
		}
	}
	cout << (ans[0]^ans[1]) << endl;
}


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

int main() {
        int N, K,
            result = 1;

        cin >> N >> K;

        for (int i = 0; i < N; i++) {
                if (result <= K) {
                        result *= 2;
                }
                else {
                        result += K;
                }
        }
        cout << result << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());

            int max = b - a;
            int min = Math.Min(a, b);

            for(int i = 2; i < n; i++)
            {
                int input = int.Parse(Console.ReadLine());

                if (input - min > max) max = input - min;
                if (input < min) min = input;
            }

            Console.WriteLine(max);
        }
    }
}

Measured memory_bytes: 9260
class Node:
    def __init__(self, num):
        self.num = num
        self.parent = self
        self.rank = 0
    
def findSet(node):
    tmp = []
    while node.parent != node:
        tmp.append(node)
        node = node.parent
    
    while tmp:
        tmp.pop().parent = node
    return node

def unite(x, y):
    node1 = findSet(nodes[x])
    node2 = findSet(nodes[y])
    if node1.rank == node2.rank:
        node2.parent = node1
        node1.rank += 1
    elif node1.rank > node2.rank:
        node2.parent = node1
    else:
        node1.parent = node2

def same(x, y):
    node1 = findSet(nodes[x])
    node2 = findSet(nodes[y])
    return node1.parent == node2.parent

nums=list(map(int,input().split()))
n = nums[0]
q = nums[1]

nodes = []
for i in range(n):
    nodes.append(Node(i))

for i in range(q):
    nums=list(map(int,input().split()))
    if nums[0] == 0:
        unite(nums[1], nums[2])
    else:
        if same(nums[1], nums[2]):
            print(1)
        else:
            print(0)
        










Measured memory_bytes: 7672
#include <iostream>
#include <iomanip>
#include <unordered_map>
#include <set>
#include <fstream>
#include <cstring>
#include <climits>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

#define ll long long
#define mod 1000000007

ll dp[405][405];

int main() {

	for (int i = 0; i < 405; i++)
		for (int j = 0; j < 405; j++)
			dp[i][j] = 1e18;
	int n;
	cin >> n;
	vector<ll> a(n);
	for (ll &x : a)
		cin >> x;
	std::vector<ll> prefix_sum(n);
	prefix_sum[0] = a[0];
	for (int i = 1; i < n; ++i) {
		prefix_sum[i] = prefix_sum[i - 1] + a[i];
	}
	for (int l = n - 1; l >= 0; l--) {
		for (int r = l; r < n; r++) {
			if (l == r)
				dp[l][r] = 0;
			for (int i = l; i < r; i++)
				if (l == 0)
					dp[l][r] = min(dp[l][r], dp[l][i] + dp[i + 1][r] + prefix_sum[r]);
				else
					dp[l][r] = min(dp[l][r], dp[l][i] + dp[i + 1][r] + prefix_sum[r] - prefix_sum[l - 1]);
		}
	}
	cout << dp[0][n - 1];

	return 0;
}


Measured memory_bytes: 1536
sa = list(input())
sb = list(input())
sc = list(input())
na = 0
nb = 0
nc = 0
nxt = "a"
while True:
    if nxt == "a":
        if na == len(sa):
            print("A")
            exit()
        nxt = sa[na]
        na += 1
    if nxt == "b":
        if nb == len(sb):
            print("B")
            exit()
        nxt = sb[nb]
        nb += 1
    if nxt == "c":
        if nc == len(sc):
            print("C")
            exit()
        nxt = sc[nc]
        nc += 1


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {

        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(f.readLine());

        int N = Integer.parseInt(st.nextToken());
        int W = Integer.parseInt(st.nextToken());

        long[] dp = new long[W + 1]; // default 0ed out

        long[][] items = new long[N][2];

        for (int i = 0; i < N; i++) {
            st = new StringTokenizer(f.readLine());
            items[i][0] = Long.parseLong(st.nextToken());
            items[i][1] = Long.parseLong(st.nextToken());
        }

        // key idea: instead of having to refer to the previous row, simply overwrite the current
        // row but starting from the right (because we need to look backwards)
        for (int i = 1; i < N + 1; i++) {
            for (int j = W; j >= 0; j--) {
                if (j < items[i - 1][0]) {

                } else {
                    dp[j] = Math.max(dp[j], dp[(int) (j - items[i - 1][0])] + items[i - 1][1]);
                }
            }
        }



        System.out.println(dp[W]);
    }
}

Measured memory_bytes: 23252
#n, m, k = gets.split.map(&:to_i)

s = gets.chomp

hh = {}
hh["SUN"] = 7
hh["MON"] = 6
hh["TUE"] = 5
hh["WED"] = 4
hh["THU"] = 3
hh["FRI"] = 2
hh["SAT"] = 1

puts hh[s]


Measured memory_bytes: 14360
#include<iostream>

using namespace std;

int main()
{	
	int a, b, c, x;
	cin >> a >> b >> c >> x;

	int cnt = 0;
	for (int p = 0; p <= a; p++) {
		for (int q = 0; q <= b; q++) {
			for (int r = 0; r <= c; r++) {
				if (500 * p + 100 * q + 50 * r == x) cnt++;
			}
		}
	}

	cout << cnt << endl;

    return 0;
}



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

using namespace std;

void Main() {
    char a;
    cin >> a;

    bool small = false;
    for (int i = 0; i < 26; ++i) {
        if (a == 'a' + i) {
            small = true;
        }
    }
    cout << (small ? 'a' : 'A') << endl;
}

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


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

int main() {
  int n;
  cin >> n;
  vector<int> data(n);
  for (int i=0; i<n; i++) {
    cin >> data.at(i);
  }

  bool is_able = true;
  for (int i=n-2; i>0; i--) {
    if (data.at(i) - 1 == data.at(i+1)) {
      data.at(i)--;
    }
    else if (data.at(i) - 1 > data.at(i+1)) {
      is_able = false;
      break;
    }
  }

  if (is_able) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define fori(x,a,b) for (int x=a;x<=b;x++)
using namespace std;
const int maxn  = 3010;
double p;
double f[maxn];
int main()
{
    int n;
    cin>>n;
    // khi m tinh i thi may phai nhan them 1-i;
    // dp[heads]
    // if we had i tosses, then tails=i-heads
    f[0] = 1;
fori(c,0,n-1)
{
    cin>>p;

    for (int i = c+1; i>=0;i--)
    {
      f[i] = (i == 0 ? 0 : f[i-1] * p) + f[i] * (1 - p);
    }
}
    double kq=0;
    fori(h,0,n)
    {
        int t = n-h;
        if (h > t)
        kq+=f[h];
    }
    cout<<fixed<<setprecision(10)<<kq;

}


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



int main() {
    int a,b,c;
    cin >>a >>b >>c;
    if(a+b>=c) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define forn(i,n) for(int i=0;i<n;++i)
#define repn(i,n) for(int i=1;i<=n;++i)
#define TC(n) while(n--)
#define forb(i,n) for(int i=n-1;i>=0;--i)
#define repb(i,n) for(int i=n;i>=1;--i)
#define print(a) cout << a << endl
#define prin(a) cout << a
#define scan(a) cin >> a 
#define scan2(a,b) cin >> a >> b
#define scan3(a,b,c) cin >> a >> b >> c
#define scan4(a,b,c,d) cin >> a >> b >> c >> d
typedef vector<int> vi;
typedef vector<pair <int,int> > vpii;
typedef map<int,int > mapii;
typedef set<int> si;

typedef long long LL;
typedef unsigned long long ULL;

const int aMAX = 1e6+6;
const LL LLMAX = 1e18;
const int MAX = 1e9;
const int mMAX = 1e3 + 3;
int arr[aMAX];
int mat[mMAX][mMAX];

vi v;
int n,a;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	scan2(n,a);

	int st = n%500;

	if(a >= st)print("Yes");
	else print("No");
	return 0;
}

Measured memory_bytes: 256
n = int(input())
robot = []
for _ in range(n):
    x, l = map(int, input().split())
    left = x - l
    right = x + l
    robot.append((left, right))
sor = sorted(robot, key=lambda x:x[1])

cnt = 1
owari = sor[0][1]
for r in sor[1:]:
    if owari <= r[0]:
        owari = r[1]
        cnt += 1
print(cnt)

Measured memory_bytes: 19020
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    vector<int64_t> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }

    rep(i, n - 1)
    {
        a[i + 1] += a[i];
    }

    int64_t result = numeric_limits<int64_t>::max();
    rep(i, n - 1)
    {
        int64_t l = a[i];
        int64_t r = a[n - 1] - a[i];

        result = min(result, abs(l - r));
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	int a,b;
	cin>>a>>b;
    char d='A';
	V<V<string>> c(a,V<string>(b));
	fo(i,a){
	  fo(j,b)
	  cin>>c[i][j];
	}
	fo(i,a){
	  fo(j,b){
	  if(c[i][j]=="snuke"){
        d+=j;
	  	cout<<d<<i+1<<endl;
	}
      }
}
}


Measured memory_bytes: 256
n = gets.to_i
s = []
n.times do
  s << gets.to_i
end
notten = s.select{|i| i%10 != 0}.sort
sum = s.inject(:+)
if sum % 10 == 0
  if notten.empty?
    puts 0
  else
    puts sum - notten[0]
  end
else
  puts sum
end

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

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

void solve(void){
  ll n, k; cin >> n >> k;
  vector<ll> p(n, 0);
  rep(n, i) cin >> p[i];

  sort(p.begin(), p.end());
  ll res = 0;
  rep(k, i) res += p[i];

  cout << res << endl;
}

int main(void) {
  solve();
  return 0;
}


Measured memory_bytes: 3632
/**
 *    author:  math2do
 *    created: 04.09.2020 17:20:44 IST
**/

#include <bits/stdc++.h>

using namespace std;

const int T = 0;
const int L = 1;
const int D = 2;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string a, b;
  cin >> a >> b;
  int n = a.length();
  int m = b.length();
  vector <vector <int> > dp(n, vector <int>(m));
  vector <vector <int> > from(n, vector <int>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      vector <pair <int, int> > which = {{-1, T}, {-1, L}, {-1, D}};
      if (a[i] == b[j]) {
	dp[i][j] = max(dp[i][j], 1 + (i - 1 < 0 || j - 1 < 0 ? 0 : dp[i - 1][j - 1]));
	which[2].first = 1 + (i - 1 < 0 || j - 1 < 0 ? 0 : dp[i - 1][j - 1]);
      } 
      dp[i][j] = max(dp[i][j], j - 1 < 0 ? 0 : dp[i][j - 1]);
      dp[i][j] = max(dp[i][j], i - 1 < 0 ? 0 : dp[i - 1][j]);
      
      which[1].first = j - 1 < 0 ? 0 : dp[i][j - 1];
      which[0].first = i - 1 < 0 ? 0 : dp[i - 1][j];
      
      sort(which.begin(), which.end());
      from[i][j] = which[2].second;
    } 
  } 
  
  int i = n - 1, j = m - 1;
  string ans = "";
  while (i >= 0 && j >= 0) {
    if (from[i][j] == D) {
      ans += a[i];
      i--; 
      j--;
    } else if (from[i][j] == L) {
      j--;
    } else if (from[i][j] == T) {
      i--;
    } 
  } 
  reverse(ans.begin(), ans.end());
  // cout << dp[n - 1][m - 1] << endl;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 73688
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main(){
  char a;
  string x,y;
  while(cin >> a >> x >> y){
    vector<int> xint,yint;
    int depth = 0;
    for(int i = 0; i < x.size() ;i++){
      if(x[i] == '('){
        depth++;
      }else if(x[i] ==')'){
        depth--;
      }else{
        xint.push_back(depth);
      }
    }
    depth = 0;
    for(int i = 0; i < y.size(); i++){
      if(y[i] == '('){
        depth++;
      }else if(y[i] ==')'){
        depth--;
      }else{
        yint.push_back(depth);
      }
    }
    vector<int> result;
    if(a == 'i'){
      int i,j;
      i = 0;
      j = 0;
      while(i < xint.size() && j < yint.size()){
        if(xint[i] < yint[j]){
          j++;
        }else if(yint[j] < xint[i]){
          i++;
        }else{
          result.push_back(xint[i]);
          i++;
          j++;
        }
      }
    }else{
      int i,j;
      i = 0;
      j = 0;
      while(i < xint.size() && j < yint.size()){
        if(xint[i] < yint[j]){
          result.push_back(yint[j]);
          j++;
        }else if(yint[j] < xint[i]){
          result.push_back(xint[i]);
          i++;
        }else{
          result.push_back(xint[i]);
          i++;
          j++;
        }
      }
      while(i < xint.size()){
        result.push_back(xint[i]);
        i++;
      }
      while(j < yint.size()){
        result.push_back(yint[j]);
        j++;
      }
    }
    depth = 0;
    for(int i = 0; i < result.size();i++){
      if(depth < result[i]){
        while(depth != result[i]){
          cout << '(';
          depth++;
        }
        cout << ',';
      }else{
        while(depth != result[i]){
          cout << ')';
          depth--;
        }
        cout << ',';
      }
    }
    while(depth > 0){
      cout << ')';
      depth--;
    }
    cout << endl;
  }
return 0;
}

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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
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; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

const int N = 10000000;
int lp[N+1];
vector<int> pr;


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    for (int i=2; i<=55000; ++i) {
        if (lp[i] == 0) {
            lp[i] = i;
            pr.push_back (i);
        }
        for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
            lp[i * pr[j]] = pr[j];
    }
    VI ans;
    for (auto i : pr) {
        if (SZ(ans) >= 55) break;
        if (i % 10 == 1) {
            ans.pb(i);
        }
    }
    int N;
    cin >> N;
    REP(i, N) {
        cout << ans[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 39424
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
    int x, y, z;
    cin >> x >> y >> z;

    int tmp;

    tmp = x;
    x = y;
    y = tmp;

    tmp = x;
    x = z;
    z = tmp;

    printf("%d %d %d\n", x, y, z);
 
    return 0;
}


Measured memory_bytes: 256
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    s = collections.Counter(str(input().rstrip('\n')))
    t = 1
    for k, v in s.items():
        t = (t * (v + 1)) % (10 ** 9 + 7)
    print(t - 1)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 39280
#include <stdio.h>
#include <math.h>

typedef struct Zahyou{
  double x;
  double y;
}Zahyou;

int Ans(Zahyou,Zahyou,int);
main(){
int n;
  Zahyou p1,p2;

  p1.x=0.0;
  p1.y=0.0;
  p2.x=100.0;
  p2.y=0.0;
  
  scanf("%d",&n);
  printf("%f %f\n",p1.x,p1.y);
  Ans(p1,p2,n);
  printf("%f %f\n",p2.x,p2.y);
  return 0;
}


int Ans(Zahyou p1,Zahyou p2,int n){
  Zahyou s,u,t;

  if(n==0)return 0;

  s.x=(p2.x-p1.x)/3.0+p1.x;
  s.y=(p2.y-p1.y)/3.0+p1.y;
  
  t.x=2*((p2.x-p1.x)/3.0)+p1.x;
  t.y=2*((p2.y-p1.y)/3.0)+p1.y;

  u.x=(t.x-s.x)*(1.0/2.0)-(t.y-s.y)*(sqrt(3.0)/2.0)+s.x;
  u.y=(t.x-s.x)*(sqrt(3.0)/2.0)+(t.y-s.y)*(1.0/2.0)+s.y;

  Ans(p1,s,n-1);
  printf("%f %f\n",s.x,s.y);
  Ans(s,u,n-1); 
  printf("%f %f\n",u.x,u.y);
  Ans(u,t,n-1);
  printf("%f %f\n",t.x,t.y);
  Ans(t,p2,n-1);
 
}

Measured memory_bytes: 636
import itertools
import copy

def delete_g(board, gyou, retu, w):
  for i in gyou:
    board[i] = [0] * w
  for i in retu:
    for j in range(len(board)):
      board[j][i] = 0
  k = 0
  for b in board:
    k += b.count("#")
  return k
      


H, W, K = list(map(int,input().split()))
ans = 0
board = []
for i in range(H):
  board.append(list(input()))

gyou = [i for i in range(H)]
retu = [i for i in range(W)]

g = []
r = []
for i in range(H+1):
  for subset in itertools.combinations(gyou, i):
    g.append(list(subset))
    
for i in range(W+1):
  for subset in itertools.combinations(retu, i):
    r.append(list(subset))
    
for i in g:
  for j in r:
    board_cp = copy.deepcopy(board)
    k = delete_g(board_cp, i, j,W)
    if k == K:
      ans += 1
print(ans)
    

Measured memory_bytes: 71824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

constexpr auto INF = INT_MAX/2;
constexpr auto MOD = 1000000007;

int main() {

	string s;
	cin >> s;

	vi md(2019, 0);
	vi md2(2019, 0);

	ll ans = 0;

	rep(i, s.size()) {
		int k = s[i] - '0';

		rep(j, 2019) {
			md[(10 * j + k) % 2019] = md2[j];
		}

		ans += md[0];

		rep(j, 2019) {
			md2[j] = md[j];
		}

		md[k]++;md2[k]++;
	}

	cout << ans << endl;

}

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int a=0,b=0,c=0,d=0,n=0,count=0,ans=0;
  string s;
  cin>>n>>a>>b;
  for(int i=1;i<=n;i++){
    if(a<=int_sum(i) && int_sum(i)<=b) ans+=i;
  }
  cout<<ans<<endl;
}
///////////////////////////

Measured memory_bytes: 512
import math
import itertools
def gcd(lst):
  return math.gcd(math.gcd(lst[0],lst[1]), lst[2])

k = int(input())
lst = [i for i in range(1,k+1)]
itr = itertools.combinations_with_replacement(lst, 3)
ans = 0

for i in itr:
  st = set(i)
  num = len(st)
  if num == 1:
    ans += i[0]
  elif num == 2:
    a,b = st
    ans += math.gcd(a,b) * 3
  else:
    ans += math.gcd(math.gcd(i[0],i[1]), i[2]) * 6

print(ans)

Measured memory_bytes: 9220
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <limits.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;

signed main(){
    int n;
    cin>>n;
    cout<<n*n*n<<endl;
    return 0;
}


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

using namespace std;

int main() {
    int k;
    string s;
    cin >> k >> s;
    if (s.size() <= k) {
        cout << s << endl;;
    } else {
        cout << s.substr(0, k) << "..." << endl;
    }
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int ans = min(a, b) + min(c, d);
  cout << ans << endl;
}


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


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

    int n;
    cin >> n;

    double arr[n];

    for(int i = 0; i<n; i++){
        cin >> arr[i];
    }

    double dp[n+1][n+1];

    for(int i = 0; i<=n; i++){
        dp[0][i] = 0;
    }

    dp[0][0] = 1;

    for(int i = 1; i<=n; i++){
        dp[i][0] = dp[i-1][0] * (1-arr[i-1]);
    }

    dp[0][0] = 1;

    for(int i = 1; i<=n; i++){
        for(int j = 1; j<=n; j++){

            if(j>i){
                dp[i][j] = 0;
            }

            dp[i][j] = dp[i-1][j]*(1-arr[i-1]) + dp[i-1][j-1]*arr[i-1];
        }
    }

    double ans = 0;

    for(int i = n/2+1; i<=n; i++){
        ans += dp[n][i];
    }

    cout << setprecision(10) <<  ans << "\n";

    return 0;
}

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

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

  int c = 1, max_h = 1, h;
  for (int i = 0; i < n; ++i){
    cin >> h;
    if (i > 0 && max_h <= h) c++;
    max_h = max(h, max_h);
  }

  cout << c << endl;
  
  return 0;
}


Measured memory_bytes: 256
import numpy as np
N,K = list(map(int, input().split()))
A = list(map(int, input().split()))
A_diff = np.diff(A)
A_diff_sum = np.sum(A_diff)
max_diff = np.max([np.max(A_diff), (N - A[-1] + A[0])])
ans = A_diff_sum - max_diff + (N - A[-1] + A[0])
print(ans)

Measured memory_bytes: 42692
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    internal static class Program
    {
        private static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            List<int> nbrs = Array.ConvertAll(Console.ReadLine().Split(), int.Parse).ToList();

            int res = 0;

            for(int i = 0; i < N; i++)
            {
                int max = nbrs.Max();

                if (i % 2 == 0)
                    res += max;
                else
                    res -= max;
                nbrs.Remove(max);
            }

            Console.WriteLine(res);
        }
    }
}

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

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

  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if (S == "Y") {
      cout << "Four" << endl;
      break;
    }
    else if (S != "Y") {
      if (i != N - 1) {
        continue;
      }
      else {
        cout << "Three" << endl;
      }
    }
  }
  
}


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

int main() {
  int h,w;
  cin>>h>>w;
  unordered_map<char,int> mp;
  rep(i,h) {
    string s;
    cin>>s;
    rep(j,w) {
      if(mp.find(s[j])==mp.end()) {
	mp[s[j]]=1;
      } else {
	mp[s[j]]++;
      }
    }
  }
  vector<int> mod(4);
  for(auto& p : mp) {
    mod[(p.second)%4]++;
  }
  if(EVEN(h)&&EVEN(w)) {
    if(mod[1]==0&&mod[2]==0&&mod[3]==0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else if(ODD(h)&&ODD(w)) {
    int c = h+w-2-2*mod[2];
    if(mod[1]==1&&c>=0&&c%4==0&&mod[3]==0) {
      cout << "Yes" << endl;
      return 0;
    }
    c = h+w-2-2*(mod[2]+1);
    if(mod[3]==1&&c>=0&&c%4==0&&mod[1]==0) {
      cout << "Yes" << endl;
      return 0;
    }
    cout << "No" << endl;
  } else if(EVEN(h)&&ODD(w)) {
    int c = h-2*mod[2];
    if(mod[1]==0&&c>=0&&c%4==0&&mod[3]==0) {
      cout<<"Yes"<<endl;
      return 0;
    }
    cout << "No" << endl;
  } else { // ODD(h)&&EVEN(w)
    int c = w-2*mod[2];
    if(mod[1]==0&&c>=0&&c%4==0&&mod[3]==0) {
      cout<<"Yes"<<endl;
      return 0;
    }
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int N;
  string S;
  cin >> N >> S;
  for (int i = 0; i < S.size(); ++i) {
    char new_ch = (S[i] - 'A' + N) % 26 + 'A';
    S[i] = new_ch;
  }
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <algorithm>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
#include <cmath>
#include <stack>
#include <limits>
#include <ctime>

using namespace std;

#define ll long long
#define sc(n) static_cast<ll>(n)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {
	IO;
#ifdef _DEBUG
	ifstream cin("In.txt");
#endif	
	double n, k, x;
	cin >> n >> k;
	double ans = 0, tans = 0;
	vector<double>vc(n);
	for (auto& i : vc) {
		cin >> i;
	}
	for (int i = 0; i < k; i++) {
		x = vc[i];
		tans += (x * (1 + x) / 2.0) / x;
	}
	ans = tans;
	for (int i = k; i < n; i++) {
		x = vc[i-k];
		tans -= (x * (1 + x) / 2.0) / x;
		x = vc[i];
		tans += (x * (1 + x) / 2.0) / x;
		ans = max(ans, tans);
	}
	cout.precision(30);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e6 + 10;
const ll mod = 1e9 + 7;
ll fac[maxn], inv[maxn], facinv[maxn], bin25[maxn], bin26[maxn];
void pre()
{
	fac[0] = 1; for(int i = 1; i < maxn; ++i) fac[i] = fac[i - 1] * i % mod;
	inv[1] = 1; for(int i = 2; i < maxn; ++i) inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	facinv[0] = 1; for(int i = 1; i < maxn; ++i) facinv[i] = facinv[i - 1] * inv[i] % mod;
	bin25[0] = 1; for(int i = 1; i < maxn; ++i) bin25[i] = bin25[i - 1] * 25 % mod;
	bin26[0] = 1; for(int i = 1; i < maxn; ++i) bin26[i] = bin26[i - 1] * 26 % mod;
}
ll C(int n, int m) { return n < m ? 0 : fac[n] * facinv[m] % mod * facinv[n - m] % mod;}
ll ans;
int main()
{
	int k;
	string s;
	cin >> k >> s;
	int n = s.length();
	int m = k + n;
	pre();
	for(int i = 0; i <= k; ++i) ans = (ans + bin26[i] * C(m - i - 1, n - 1) % mod * bin25[m - i - n]) % mod;
	cout << ans << endl; 
	return 0;
}
 

Measured memory_bytes: 82496
package main

import (
	"fmt"
)

func main() {
	var n int32
	fmt.Scan(&n)
	var s string
	fmt.Scan(&s)
	ans := ""
	for _, r := range s {
		if r + n >= 91 {
			r = (r + n) -91 + 65
		} else {
			r = r + n
		}
		ans = ans + string(r)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 6656
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#define rep(i,x) for(int i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 10010010010;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
	if (a < b)swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

int main() {
	ll N, K, X;
	cin >> N >> K >> X;
  if(N == K && K == X)cout << "1" << endl;
  else if(N == K)cout << "2" << endl;
  else if(N == X)cout << "2" << endl;
  else if(K == X)cout << "2" << endl;
  else cout << "3" << endl;
}

Measured memory_bytes: 256
N = int(input())
L = input().split()
L = [int(s) for s in L]
n = int(input())
l = input().split()
l = [int(s) for s in l]
ans = 0
for i in range(n):
    j = 0
    k = N-1
    while(1):
    #for m in range(5):
        a =  int((j + k)/2)
        if l[i] == L[a] or l[i] ==L[j] or l[i] ==L[k]:
            ans += 1
            break
        elif k == j+1:
            break
        elif l[i] > L[a]:
            j = a
        elif l[i] < L[a]:
            k = a
        # print(j,k,a,ans)
        # print(l[i],L[a])
print(ans)


Measured memory_bytes: 16892
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
int e[300006];
int w[300006];
int mincnt=9999999999999;
int cnt;
int main()
{
	cin>>n>>s;
	e[0]=w[0]=0;
	if(s[0]=='E') e[0]=1;
	else w[0]=1;
	for(int i=1;i<s.size();i++)
	{
		if(s[i]=='E')
		{
			e[i]=e[i-1]+1;
			w[i]=w[i-1];
		}
		if(s[i]=='W')
		{
			 w[i]=w[i-1]+1;
			 e[i]=e[i-1];
		}
	}
	/*for(int i=0;i<s.size();i++)
	{
		cout<<e[i]<<" ";
	}
	cout<<endl;
	for(int i=0;i<s.size();i++)
	{
		cout<<w[i]<<" ";
	}
	cout<<endl;*/
	for(int i=0;i<s.size();i++)
	{
		cnt=0;
		if(i==0)
		{
			cnt=e[n-1]-e[0];
			if(cnt<mincnt) mincnt=cnt;
		}
		if(i==n-1)
		{
			cnt=w[n-2];
			if(cnt<mincnt) mincnt=cnt;
		}
		else
		{
			cnt=w[i-1]+e[n-1]-e[i];
			if(cnt<mincnt) mincnt=cnt;
		}
	}
	cout<<mincnt;
}


Measured memory_bytes: 2948
#include <iostream>
using namespace std;
 
int main() {
	int N;
	bool is_prime[1000000];
	is_prime[0]=0; is_prime[1]=0;
	for(int i=2;i<1000000; i++){
		is_prime[i]=1;
	}
 
	for(long s=2; s<1000000; s++){
		if(is_prime[s]==1){	
		for(long long i=s*s; i<1000000; i+=s){
		is_prime[i]=0;	
 
		}
		}
	}
 
	while(cin >> N){
 
		int ans=0;
		for(int i=2; i<N+1; i++){
			ans+=is_prime[i];
		}
		cout << ans <<endl;
 
	}
return 0;
}

Measured memory_bytes: 4048
N,M = map(int,input().split())
C = list(map(int,input().split()))
INF = float('inf')
dp = [INF] * (N+1)
dp[0] = 0
for i in range(M):
  c = C[i]
  for j in range(N+1):
    if j >= c:
      dp[j] = min(dp[j], dp[j-c]+1)

print(dp[N])


Measured memory_bytes: 7520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define pll pair<ll,ll>
#define pii pair<int32_t,int32_t>
#define loop(i,n) for(int64_t i=0; i<n; i++)
#define loop1(i,a,b) for(int64_t i=a; i<=b; i++)
#define rloop(i,n) for(int64_t i=n-1; i>=0; i--) 
#define rloop1(i,a,b) for(int64_t i=a; i>=b; i--) 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define print(val) cout << #val << ": " << val << "\n";
#define print_c(a) cout<<#a<<": ";for(auto it=begin(a);it!=end(a);it++)cout<<*it<<" ";cout<<"\n";
#define fill(c,v) fill(begin(c),end(c),v);
template <typename T> T flip(T val) {reverse(begin(val),end(val)); return val;}

int main() {
  fast_io
  ll n,m,k; cin >> n >> m >> k;
  ll A[n]; ll B[m];

  cin >> A[0];
  loop1(i,1,n-1) {
    cin >> A[i];
    A[i] = A[i]+A[i-1];
  }
  cin >> B[0];
  loop1(i,1,m-1) {
    cin >> B[i];
    B[i] = B[i]+B[i-1];
  }
  ll sums = 0;
  loop(i,n) {
    if(A[i] <= k) {
      ll trem = k - A[i]; 
      auto it = lower_bound(B,B+m,trem);
      if(*it != trem) {
        ll ans = (--it - B) + 1;
        ans+=(i+1);
        sums = max(sums, ans);
      }
      else {
        ll ans = (it - B) + 1;
        ans+=(i+1);
        sums = max(sums, ans);
      }
    }
    else break;
  }

  ll trem = k;
  auto it = lower_bound(B,B+m,trem);
  if(*it != trem) {
    ll ans = (--it - B) + 1;
    sums = max(sums, ans);
  }
  else {
    ll ans = (it - B) + 1;
    sums = max(sums, ans);
  }
  cout << sums << "\n";
}

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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7,inf=mod*mod*3ll;;
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

ll N;

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N;
ll D=N%10; N/=10; 
ll C=N%10; N/=10; 
ll B=N%10; N/=10; 
ll A=N%10;

ll n1=A+B+C+D; 
if(n1==7){
	cout<<A<<'+'<<B<<'+'<<C<<'+'<<D<<'='<<7<<endl; return 0;
}
ll n2=A-B+C+D;
if(n2==7){
	cout<<A<<'-'<<B<<'+'<<C<<'+'<<D<<'='<<7<<endl; return 0;
}
ll n3=A+B-C+D;
if(n3==7){
	cout<<A<<'+'<<B<<'-'<<C<<'+'<<D<<'='<<7<<endl;return 0;
}
ll n4=A+B+C-D;
if(n4==7){
	cout<<A<<'+'<<B<<'+'<<C<<'-'<<D<<'='<<7<<endl; return 0;
}
ll n5=A-B-C+D;
if(n5==7){
	cout<<A<<'-'<<B<<'-'<<C<<'+'<<D<<'='<<7<<endl; return 0;
}
ll n6=A-B+C-D;
if(n6==7){
	cout<<A<<'-'<<B<<'+'<<C<<'-'<<D<<'='<<7<<endl; return 0;
}
ll n7=A+B-C-D;
if(n7==7){
	cout<<A<<'+'<<B<<'-'<<C<<'-'<<D<<'='<<7<<endl; return 0;
}
ll n8=A-B-C-D;
if(n8==7){
	cout<<A<<'-'<<B<<'-'<<C<<'-'<<D<<'='<<7<<endl; return 0;
}

}
	


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n],amax,amin;
  for (int i=0;i<n;i++) {
    cin >> a[i];
    if (i == 0){
      amax = a[i];
      amin = a[i];
    }else if (amax < a[i]){
      amax = a[i];
    }else if (amin > a[i]){
      amin = a[i];
    }
  }
  cout << amax-amin << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
const long long inf=1e9+7;
const long long mod=1e9+7;
const int64_t CYCLES_PER_SEC=2800000000;
//
inline uint32_t Xor128(){
	static uint32_t x=123456789;
	static uint32_t y=362436069;
	static uint32_t z=521288629;
	static uint32_t w=88675123;
	uint32_t t=x^(x<<11);
	x=y;y=z;z=w;
	return w=(w^(w>>19))^(t^(t>>8));
}
struct Timer{
	int64_t start;
	Timer(){reset();}
	void reset(){start=getcycle();}
	void plus(double a){start-=(a*CYCLES_PER_SEC);}
	inline double get(){return (double)(getcycle()-start)/CYCLES_PER_SEC;}
	inline int64_t getcycle(){
		uint32_t low,high;
		__asm__ volatile ("rdtsc":"=a"(low),"=d"(high));
		return ((int64_t)low)|((int64_t)high<<32);
	}
};
int main(){
	int n,m;
	int a[100000];
	cin>>n>>m;
	priority_queue<int> que;
	for(int i=0;i<n;i++){
		cin>>a[i];
		que.push(a[i]);
	}
	for(int i=0;i<m;i++){
		int hoge=que.top();
		hoge/=2;
		que.pop();
		que.push(hoge);
	}
	long long ans=0;
	while(!que.empty()){
		ans+=que.top();
		que.pop();
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1148
X=input()
Y=[0]*len(X)
#Sは0,Tは1
for i in range(len(X)):
    if X[i]=='T':
        Y[i]=1
#print(Y)

from collections import deque

Z=deque([])
for i in range(len(X)):
    c=Y[i]
    if c==0:
        Z.append(c)
    elif Z==deque([]):
        Z.append(c)
    elif Z[-1]==1:
        Z.append(c)
    else:
        Z.pop()

print(len(Z))

Measured memory_bytes: 6760
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;

ll fact[N], inv[N];
int add(int a, int b){
    a = (a + mod) % mod;
    b = (b + mod) % mod;
    return (a + b) % mod;
}

int mul(int a, int b){
    a = (a + mod) % mod;
    b = (b + mod) % mod;
    return 1ll * a* b % mod;
}

ll fp(int b, int p){
    if(!p) return 1;
    ll ret = fp(b, p >> 1) % mod;
    ret = mul(ret, ret);
    if(p&1) ret = mul(ret, b);
    return ret;

}

void pre(){
    fact[0] = inv[0] = 1;
    for(int i = 1; i < N; i++){
        fact[i] = mul(fact[i - 1], i);
        inv[i] = fp(fact[i], mod - 2);
    }

}

ll ncr(ll n, ll r){
    ll ans = 1;
    for(int i = n; i >= n - r + 1; i--){
        ans = mul(ans, i);
    }
    ans = mul(ans, inv[r]);
    return ans;
}



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    pre();
    //ccout << ncr(4, 2) << ' ';
    //creturn 0;
    ll n, a, b, sum;
    cin >> n >> a >> b;
    sum = fp(2, n);
    sum--;
    sum = add(sum, -ncr(n, a));
    sum = add(sum, -ncr(n, b));
    cout << sum;

    return 0;
}


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

int main(){
	int ans=0;
	string s;
	cin>>s;
	for(int i=0;i<4;i++){
		if(s[i]=='+') ans++;
		else ans--;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	string s,t;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    string u;
    cin>>u;
    if(u==s) cout<<a-1<<" "<<b;
    else cout<<a<<" "<<b-1;
}

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

int main() {
	string S;
	char p,pp;
	cin >> S;

	pp=S.at(0), p=S.at(1);
	if(S.size()==2 && pp==p) {
		cout << "1 2" << endl;
		return 0;
	}

	rep(i,S.size()-2) {
		if(S.at(i+2) == p) {
			cout << i+2 << " " << i+3 << endl;
			return 0;
		}
		if(S.at(i+2) == pp) {
			cout << i+1 << " " << i+3 << endl;
			return 0;
		}
		pp=p, p=S.at(i+2);
	}

	cout << "-1 -1" << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cmath>
#include<vector>
#include <algorithm>
using namespace std;

int main()
{
	int N, M, C;
	cin >> N >> M >> C;

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

	int x = 0;
	int y = 0;
	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			x = x + A[i][j]*B[j];
		}
		x = x + C;
		if(x > 0) y++;
		x = 0;
	}

	cout << y << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 int main() {
   char c[3];
   scanf("%s",c);

   if(strcmp(c,"SUN")==0){
       printf("7");
   }else if(strcmp(c,"MON")==0){
       printf("6");
   }else if(strcmp(c,"TUE")==0){
       printf("5");
   }else if(strcmp(c,"WED")==0){
       printf("4");
   }else if(strcmp(c,"THU")==0){
       printf("3");
   }else if(strcmp(c,"FRI")==0){
       printf("2");
   }else if(strcmp(c,"SAT")==0){
       printf("1");
   }
    return 0;
}

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

#define PI 3.14159265358979323846

double A, B, H, M;

int main(void) {

    cin >> A >> B >> H >> M;
    
    H += M / 60;

    double theta = 2 * PI * abs(H/12 - M/60);

    cout << fixed << setprecision(15) <<  sqrt(A*A + B*B - 2*A*B*cos(theta)) << endl;

    return 0;
}

Measured memory_bytes: 4124
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int n,m,x,y,z;
  scanf("%d %d %d %d",&n,&m,&x,&y);
  z=x+1;
  for(int i=0;i<n;i++){
    scanf("%d",&x);
    z=max(z,x+1);
  }
  if(z>y){
    printf("War\n");
    return 0;
  }
  for(int i=0;i<m;i++){
    scanf("%d",&y);
    if(z>y){
      printf("War\n");
      return 0;
    }
  }
  printf("No War\n");
}

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

using namespace std;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
  
	int a, b;
	cin >> a >> b;

	if ((a * b) % 2 == 0) {
		cout << "Even\n";
	}
	else {
		cout << "Odd\n";
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()

{

	int a,b,sum,sub,mul;	scanf("%d %d",&a,&b);

	sum=a+b;

	sub=a-b;

	mul=a*b;

	if(sum>=sub && sum >= mul)

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

	

	else if(sub >=sum && sub >= mul)

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

	

	else

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

	

	return 0;

}

Measured memory_bytes: 128
using System;
using System.Linq;

namespace ALDS1_5_B_MergeSort
{
	class Program
	{
		static void Main ( string[] args )
		{
			int dataCount = int.Parse (Console.ReadLine ());
			int[] numArray = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();

			MergeSort (numArray);

			for (int lp = 0; lp < dataCount - 1; lp++)
			{
				Console.Write (numArray[lp] + " ");
			}
			Console.WriteLine (numArray[dataCount - 1]);
			Console.WriteLine (Count);
		}

		static int Count = 0;

		static void MergeSort ( int[] numArray )
		{
			MergeSort (numArray, 0, numArray.Length);
		}

		static void MergeSort ( int[] numArray, int leftIndex, int rightIndex )
		{
			//3?????\??????????´????????????¨???
			//0~1 ??
			//0~2 ???
			if (leftIndex + 1 < rightIndex)
			{
				int middleIndex = (leftIndex + rightIndex) / 2;
				MergeSort (numArray, leftIndex, middleIndex);
				MergeSort (numArray, middleIndex, rightIndex);
				Merge (numArray, leftIndex, middleIndex, rightIndex);
			}
		}

		static void Merge ( int[] numArray, int leftIndex, int middleIndex, int rightIndex )
		{
			int n1 = middleIndex - leftIndex;
			int n2 = rightIndex - middleIndex;

			int[] leftArray = new int[n1 + 1];
			int[] rightArray = new int[n2 + 1];

			for (int index = 0; index < n1; index++)
			{
				leftArray[index] = numArray[leftIndex + index];
			}
			for (int index = 0; index < n2; index++)
			{
				rightArray[index] = numArray[middleIndex + index];
			}

			//sentinel
			leftArray[n1] = int.MaxValue;
			rightArray[n2] = int.MaxValue;

			int left = 0;
			int right = 0;

			for (int index = leftIndex; index < rightIndex; index++)
			{
				Count++;

				if (leftArray[left] <= rightArray[right])
				{
					numArray[index] = leftArray[left];
					left++;
				}
				else
				{
					numArray[index] = rightArray[right];
					right++;
				}
			}
		}
	}
}

Measured memory_bytes: 87644
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

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

    int cnt = 0;
    for (int i=0; i<n; i++) {
        cin >> a;
        if (a % 2) continue;
        cnt++;
    }

    cout << pow(3, n) - pow(2, cnt) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

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

  for(i=0; i<n; i++){
    scanf("%d", &a[i]);
  }

  for(i=0; i<=n-3; i++){
    if((a[i]<a[i+1]&&a[i+1]<a[i+2])||(a[i]>a[i+1]&&a[i+1]>a[i+2])){
      count++;
    }
  }

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

  return 0;
}


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

using namespace std;

typedef long double ld;
typedef long long ll;

const int mod = 1e9 + 7;

int add(int x, int y) {
  x += y;
  if (x >= mod)
    x -= mod;
  return x;
}

int udd(int &x, int y) {
  return x = add(x, y);
}

int sub(int x, int y) {
  return add(x, mod - y);
}

int uub(int &x, int y) {
  return x = sub(x, y);
}

const int M = 4020;

int d[M][M];
int n, m, k;

void calc() {
  d[0][0] = 1;
  for (int len = 1; len < M; ++len) {
    int cur = 0;
    for (int sum = 0; sum < M; ++sum) {
      cur = add(cur, d[len - 1][sum]);
      if (sum >= k)
        cur = sub(cur, d[len - 1][sum - k]);
      d[len][sum] = cur;
    }
  }
}

void read() {
  cin >> n >> m >> k;
}

void kill() {
  int ans = 0;
  for (int sb = 1; sb <= m; ++sb)
    if (sb % (k - 1) == m % (k - 1)) {
      int len = (n + sb - 1) / (k - 1);
      ans = add(ans, d[len][sb]);
    }

  cout << ans << endl;
}

int main() {
#ifdef LOCAL
  assert(freopen("e.in", "r", stdin));
#endif

  ios_base::sync_with_stdio(false);

  read();
  calc();
  kill();
}



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

using ll = long long;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define rep(i,n) for_(i,0,(n))
#define rrep(i,n) rfor_(i,0,(n))

char T[1001], W[11];
int c;

bool comp(int i) {
    if(T[i]=='\0' && W[i]=='\0')return true;
    if(T[i]=='\0' || W[i]=='\0')return false;
    bool b = T[i] == W[i] || ((T[i]-'A'+'a') == W[i]) || (T[i] == (W[i]-'A'+'a'));
    return b && comp(i+1);
}

int main(){
	cin.tie(0);
	
	cin>>W;
	while(cin>>T,strcmp(T, "END_OF_TEXT")){
	    if(comp(0))c++;
	}
	
	cout<<c<<endl;

	return 0;
}



Measured memory_bytes: 3084