akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

using ll = long long;

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

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

template<class T>
void print(vector<T> a) {
  cout << "[ ";
  REP(i, a.size()) cout << a[i] << " ";
  cout << "]" << endl;
}

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

ll n;
vector<ll> m;
vector<vector<ll>> table;

#define DP table[left][right]
ll dfs(ll left=0, ll right=n + 1) {
  if (DP != -1) return DP;

  if (right - left <= 2) return DP = 0;
  ll minv = 1ll << 60;
  FOR(c, left + 1, right - 2) {
    minv = min(minv, dfs(left, c + 1) + dfs(c, right) + m[left] * m[c] * m[right - 1]);
  }
  return DP = minv;
}

int main() {
  cin >> n;
  m = vector<ll>(n + 1);
  REP(i, n) {
    cin >> m[i] >> m[i + 1];
  }

  table = vector<vector<ll>>(n + 2, vector<ll>(n + 2, -1));

  cout << dfs() << endl;
}



Measured memory_bytes: 3232
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;


void main() {
    int n;
    scan(n);
    writeln(800*n - (n/15)*200);
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


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

int main() {
    string S; cin >> S;
    long long a = 0, b = 0, c = 0;
    for (long long i = 0; i < S.size(); i++) {
        if (S.at(i) == 'a') a++;
        else if (S.at(i) == 'b') b++;
        else c++;
    }
    long long num = min({a,b,c});
    a -= num;
    b -= num;
    c -= num;
    if (a <= 1 && b <= 1 && c <= 1) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3744
#include<stdio.h>
int main(void)
{
	int w, h, x, y, r;
	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

	if (0<=x - r && x + r <= w && 0<=y-r&&y+r<=h)
	{
		printf("Yes\n");
	}

	else
	{
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 2104
from itertools import accumulate
n,k = map(int,input().split())
a = list(map(int,input().split()))
a = [(a[i]+1)/2 for i in range(n)]
acc = [0]+list(accumulate(a))
ans = 0
for i in range(n-k+1):
  ans = max(ans,acc[i+k]-acc[i])
print(ans)

Measured memory_bytes: 25152
#include <iostream>
#include <cstdint>
#include <array>
#include <vector>

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v)
{
  for (typename std::vector<T>::size_type i = 0; i < v.size(); ++i) {
    os << v[i];
    if (i + 1 < v.size()) { os << ' '; }
  }
  return os;
}

const uint64_t Undefined = static_cast<uint64_t>(-1);

int main()
{
  uint64_t N, W;
  std::cin >> N >> W;
  
  std::vector<uint64_t> w(N), v(N);
  for (uint64_t n = 0; n < N; ++n) {
    std::cin >> w[n] >> v[n];
  }
  
  uint64_t base_weight = w[0];
  for (uint64_t n = 0; n < N; ++n) {
    w[n] -= base_weight;
  }
  
  std::vector< std::array< std::array<uint64_t, 301> , 101> > dp(N + 1);
  for (uint64_t n = 0; n <= N; ++n) {
    for (uint64_t k = 0; k <= 100; ++k) {
      for (uint64_t i = 0; i <= 300; ++i) {
        dp[n][k][i] = Undefined;
      }
    }
  }
  dp[0][0][0] = 0;
  
  for (uint64_t n = 0; n < N; ++n) {
    for (uint64_t k = 0; k <= 100; ++k) {
      for (uint64_t i = 0; i <= 300; ++i) {
        if (dp[n][k][i] != Undefined) {
          uint64_t current_weight = k * base_weight + i;
          uint64_t new_weight = current_weight + (w[n] + base_weight);
          uint64_t new_value = dp[n][k][i] + v[n];
          if (new_weight <= W) {
            if (dp[n + 1][k + 1][i + w[n]] == Undefined) {
              dp[n + 1][k + 1][i + w[n]] = new_value;
            } else {
              dp[n + 1][k + 1][i + w[n]] = std::max(new_value, dp[n + 1][k + 1][i + w[n]]);
            }
          }
          
          if (dp[n + 1][k][i] == Undefined) {
            dp[n + 1][k][i] = dp[n][k][i];
          } else {
            dp[n + 1][k][i] = std::max(dp[n][k][i], dp[n + 1][k][i]);
          }
        }
      }
    }
  }
  
  uint64_t max = 0;
  for (uint64_t k = 0; k <= 100; ++k) {
    for (uint64_t i = 0; i <= 300; ++i) {
      if (dp[N][k][i] != Undefined) {
        max = std::max(dp[N][k][i], max);
      }
    }
  }
  std::cout << max << std::endl;
  
  return 0;
}

Measured memory_bytes: 24448
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String op = sc.next();
		String b = sc.next();
		sc.close();
		if (op.equals("+")) {
			System.out.println(Integer.valueOf(a) + Integer.valueOf(b));; 
		} else {
			System.out.println(Integer.valueOf(a) - Integer.valueOf(b));; 
		}
	}

}

Measured memory_bytes: 9680
import sys
fin = sys.stdin.readline

s1 = fin()[:-1]
s2 = fin()[:-1]
len_s1 = len(s1)
len_s2 = len(s2)

def c_replace(x, y, i, j):
    if x[i] == y[j]:
        return 0
    else:
        return 1

# prefix dp
# dp[i][j] is the edit distance between x[i:] and y[j:].
dp = [[0] * (len(s2) + 1) for _ in range(len_s1 + 1)]

# base cases
for i in range(len_s1):
    dp[i][len_s2] = len_s1 - i
for j in range(len_s2):
    dp[len_s1][j] = len_s2 - j

for i in reversed(range(len(s1))):
    for j in reversed(range(len(s2))):
        dp[i][j] = min(dp[i][j+1] + 1, dp[i+1][j] + 1, dp[i+1][j+1] + c_replace(s1, s2, i, j))

print(dp[0][0])



Measured memory_bytes: 43084
#include<bits/stdc++.h>
using namespace std;
int n,m;
int a[110][110];
int main()
{
	cin>>n>>m;
	cout<<100<<" "<<100<<endl;
	for(int i=1;i<=50;i++)
	  for(int j=1;j<=100;j++)a[i][j]=1;
	for(int i=1;i<n;i++)
	{
		int x=(i-1)/50+1;
		int y=(i-1)%50+1;
		a[x*2-1][y*2-1]=0;
	}
	for(int i=1;i<m;i++)
	{
		int x=(i-1)/50+1;
		int y=(i-1)%50+1;
		a[x*2-1+51][y*2-1]=1;
	}
	for(int i=1;i<=100;i++)
	{
		for(int j=1;j<=100;j++)
		if(a[i][j])putchar('#');
		  else putchar('.');
		putchar(10);
	}
	return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

ll n, a, b, c, d;

bool check(ll l, ll r) {
    ll dist, act, i;

    for (i = 0; i <= n; i++) {
        act = a + 1LL * i * c;
        act -= 1LL * (n - i) * c;

        if (l <= act && act <= r) return true;
        if (act < l) {
            dist = l - act;
            if (dist <= (d - c) * i) return true;
        } else {
            dist = act - r;
            if (dist <= (d - c) * (n - i)) return true;
        }
    }


    return false;

}

int main()
{
  //  freopen("test.in","r",stdin);

    cin >> n >> a >> b >> c >> d; n -= 2;
    if (a > b) swap(a, b);
    if (c > d) swap(c, d);

    if (check(b - d, b - c)) {
        cout << "YES";
        return 0;
    }

    if (check(b + c, b + d)) {
        cout << "YES";
        return 0;
    }

    cout << "NO";


    return 0;
}


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

using namespace std;
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.12lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define mod 1000 * 1000 * 1000 + 7
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;

const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265359;

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

int main()
{
    int k,s;
    cin>>k>>s;
    int cnt=0;
    for(int i=0;i<=k;++i){
        for(int j=0;j<=k;++j){
            if(s-(i+j)>=0 and s-(i+j)<=k){
                cnt+=1;
                //cout<<i<<" "<<j<<" "<<s-(i+j)<<endl;
            }
        }
    }
    
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int n;

void clc(int i, string str){
    if(i == n){
        cout << str << endl;
    } else {
        char cmax = 'a' - 1;
        for(auto c:str){
            if(cmax < c) cmax = c;
        }
        for(char c = 'a'; c <= cmax + 1; c++){
            clc(i+1,str+c);
        }
    }
}

int main(){
    cin >> n;
    clc(0, "");
    return 0;
}



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

using ll=long long;
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    int alice=0;
    int bob=0;
    rep(i,n) cin>>a[i];
    sort(a.begin(),a.end(),greater<int>());
    
    rep(i,n){
        if(i%2==0) alice+=a[i];
        else bob+=a[i];
    }
    
    cout<<alice-bob<<endl;
    return 0;
}

Measured memory_bytes: 3636
/*  ex5_3 Grid Compression
    pandacodeb  */

#include <stdio.h>

int main(void){
    int height, width;
    int i, j;
    scanf("%d %d", &height, &width);
    char a[height][width];

    int rowDel[height], colDel[width];
    for (i = 0; i < height; i++){
        rowDel[i] = 0;
    }
    for (j = 0; j < width; j++){
        colDel[j] = 0;
    }

    for (i = 0; i < height; i++){
        for (j = 0; j < width; j++){
            scanf(" %c", &a[i][j]);
        }
    }
    for (i = 0; i < height; i++){
        for (j = 0; j < width; j++){
            if (a[i][j] == '#'){
                break;
            }
            else if (a[i][j] == '.' && j == width - 1){
                rowDel[i] = 1;
            }
        }
    }
    for (j = 0; j < width; j++){
        for (i = 0; i < height; i++){
            if (a[i][j] == '#'){
                break;
            }
            else if (a[i][j] == '.' && i == height - 1){
                colDel[j] = 1;
            }
        }
    }

    /*
    for (i = 0; i < height; i++){
        printf("%d ", rowDel[i]);
    }
    printf("\n");
    for (j = 0; j < width; j++){
        printf("%d ", colDel[j]);
    }
    printf("\n");*/
    

    for (i = 0; i < height; i++){
        if (rowDel[i] == 1)
            continue;
        for (j = 0; j < width; j++){
            if (colDel[j] == 1){
                continue;
            }
            printf("%c", a[i][j]);
            //printf("  index: %d %d\n", i+1, j+1);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 128
=begin
  1, gets(nil)でEOF受け取り(readlineとの違いは改行で配列化しない)
    1.1 downcase で小文字, split 要素を全て配列化
  2, a-z のみを each して count で出力
=end

s = gets(nil).downcase.split('')

('a'..'z').each{|alfa|
  puts "#{alfa} : #{s.count(alfa)}"
}


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

int main()
{
int w, h, x, y, r;

scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

if( (x + r <= w && y + r <= h) && (x - r >= 0 && y - r >= 0) )
{
	printf("Yes\n");
}
else
printf("No\n");
 
 return 0;
}


Measured memory_bytes: 2692
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int cnt = 0;
  int i;
  for(i=0;i<s.length();i++){
    if(s[i]=='N'&&cnt%2==0)cnt+=1;
    if(s[i]=='S'&&cnt%4<2)cnt+=2;
    if(s[i]=='E'&&cnt%8<4)cnt+=4;
    if(s[i]=='W'&&cnt%16<8)cnt+=8;
  }
  if(cnt==3||cnt==12||cnt==15)cout<<"Yes";
  else cout << "No";
}


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

int main() {
    int n;
    int dif = 0; 
    cin >> n;
    vector<int> p(n);
    for (int i=0;i<n;i++){
        cin >> p.at(i);
        if (p.at(i) != (i+1)){
            dif ++;
        }
    }
    if (dif <= 2){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const double PI=3.14159265358979323846;
int main(){
  int r;
  cin>>r;
  double ans=2*PI*r;
  printf("%.3f",ans);
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define pb push_back
#define xx first
#define yy second
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define repp(i,k,n) for(int i=k;i<n;i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> iv;
typedef pair<int,int> iip;
typedef map<int,int> mii;
template <typename T>
void dbg(T t){cerr<<t<<endl ;}
template<typename T, typename... Args>
void dbg(T t, Args... args) {cerr << t <<" ";dbg(args...) ;}
int main(){	
	ll a,b;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i+=2)
		printf("%c",s[i]);
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
typedef pair<pii,ll> piii;
typedef pair<ll,pii> ipii;
#define MOD 998244353 
#define mod(a) ((a)%MOD)
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define dbg(x) cout<<#x<<" = "<<x<<"\n"
#define dbg2(x,y) cout<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<"\n"
#define dbg3(x,y,z) cout<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<" , "<<#z<<" = "<<z<<"\n"
#define INF (1LL<<60)
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;*/
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(v) v.begin(),v.end()
#define endl '\n'
ll gcd(ll a,ll b){if(a==0) return b; return gcd(b%a,a);}
ll powm(ll base,ll exp,ll mod=MOD) {base%=mod;ll ans=1;while(exp){if(exp&1LL) ans=(ans*base)%mod;exp>>=1LL,base=(base*base)%mod;}return ans;}


ll h[100005];
ll dp[100005];
int main(){
      sync;
      ll n,k;
      cin>>n>>k;
       for(ll i=1; i<=n; i++){
             cin>>h[i];
             dp[i]=INF;
         }
         dp[1]=0;
      for(ll i=1; i<=n; i++){
            for(int j=i+1;j<=min(n,i+k);j++)
            	dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
      }
       
 
        cout<<dp[n]<<endl;

} 


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // 一年の秒数
  double genzai = 0,mokuhyou =0;
  cin >>genzai>>mokuhyou;
  
  int heikinn =(mokuhyou+genzai)/2;
  

     
  if((mokuhyou+genzai)/2-heikinn   > 0)
    {
      cout << heikinn+1 << endl;
    }
    else
    {cout << (mokuhyou+genzai)/2 << endl;
    }  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



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

  int s, w;
  cin >> s >> w;

  cout << (s <= w ? "unsafe" : "safe") << '\n';




  
  return 0;
}

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

int main() {
	int d;
	cin >> d;
	if(d==
25)
 cout << "Christmas" << endl;
	if(d==
24)
 cout << "Christmas Eve" << endl;
	if(d==
23)
 cout << "Christmas Eve Eve" << endl;
	if(d==
22)
 cout << "Christmas Eve Eve Eve" << endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
as = gets.split.map(&:to_i)

hash = {}

as.each do |a|
  if hash.include?(a)
    hash[a] += 1
  else
    hash[a] = 1
  end
end

if hash[0] == n
  puts 'Yes'
  exit
end

if hash.size == 3
  x, y, z = hash.to_a

  if x[1] == y[1] && y[1] == z[1] && x[0] == y[0] ^ z[0]
    puts 'Yes'
    exit
  end
end

if hash.size == 2
  x, y = hash.to_a

  if x[0] == 0 && x[1] * 2 == y[1]
    puts 'Yes'
    exit
  end

  if y[0] == 0 && y[1] * 2 == x[1]
    puts 'Yes'
    exit
  end
end

puts 'No'


Measured memory_bytes: 11916
// F.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <cstdio>


using lolo=long long;
using namespace std;
using vec=vector<lolo>;
using vvec=vector<vec>;
using vecb=vector<bool>;
#define FOR(i,n) for (lolo i=0; i<n; ++i)
#define FORN(i,a,b) for (lolo i=a; i<b; ++i)
#define REV(i,a,b) for (lolo i=a; i>b; --i)
#define ALL(x) x.begin(), x.end()

lolo myPow(lolo x, lolo n, lolo m)
{
	if ( n == 0 )
		return 1;
	if ( n % 2 == 0 )
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}


int main()
{
	lolo M, K;
	cin >> M >> K;


	
		lolo N = myPow(2, M, lolo(1e13));
		if ( M != 1 )
		{
			if ( K >= N )
			{
				cout << -1 << endl;
				exit(0);
			}
			FOR(i, N)
			{
				if ( i == K ) continue;
				cout << i << " ";
			}
			cout << K << " ";
			REV(i, N - 1, -1)
			{
				if ( i == K ) continue;
				cout << i << " ";
			}
			cout << K << endl;
		} else
		{

			if ( K == 0 )
			{
				FOR(i, N)
					cout << i << " ";
				REV(i, N-1, -1)
					cout << i << " ";

			} else
			{
				cout << -1 << endl;
			}
		}

	
}



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

using namespace std;
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define i64 int64_t
#define tos(x) to_string(x)

int main() {
	i64 n;
	cin >> n;
	i64 a = 0, b = 0;
	ff(i, 1, sqrt(n) + 1) {
		if (n % i == 0) {
			a = i;
			b = n / i;
		}
	}
	cout << a + b - 2 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;


public class Main {
	public static void main(String args[])throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		if(n >= 30) System.out.println("Yes");
		else System.out.println("No");
	}
}


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

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> P(m);
    vector<string> S(m);
    for (int i = 0; i < m; i++)
        cin >> P[i] >> S[i];

    vector<bool> acccepted(n);
    vector<int> wa(n);
    int ans = 0;
    int pena = 0;
    for (int i = 0; i < m; i++){
        if (acccepted[P[i] - 1])
            continue;
        if (S[i] == "WA")
            wa[P[i] - 1]++;
        else{
            ans++;
            pena += wa[P[i] - 1];
            acccepted[P[i] - 1] = true;
        }
    }

    cout << ans << " " << pena << endl;
}

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

namespace aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            string input;
            while((input = Console.ReadLine()) != null) {
                int num = int.Parse(input) + 1;
                var check = new bool[num];
                for(int i=0; i < num; ++i) {
                    if(i < 2) {
                        check[i] = true;
                        continue;
                    }
                    if(!check[i]) {
                        for(int l=2; l * i < num; ++l) {
                            check[l * i] = true;
                        }
                    }
                }
                Console.WriteLine(check.Count(p => !p));
            }
        }
    }
}

Measured memory_bytes: 8968
//This program is written by Brian Peng.
#pragma GCC optimize("Ofast","inline","no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define Rd(a) (a=read())
#define Gc(a) (a=getchar())
#define Pc(a) putchar(a)
int read(){
	int x;char c(getchar());bool k;
	while(!isdigit(c)&&c^'-')if(Gc(c)==EOF)exit(0);
	if(c^'-')k=1,x=c&15;else k=x=0;
	while(isdigit(Gc(c)))x=(x<<1)+(x<<3)+(c&15);
	return k?x:-x;
}
void wr(int a){
	if(a<0)Pc('-'),a=-a;
	if(a<=9)Pc(a|'0');
	else wr(a/10),Pc((a%10)|'0');
}
signed const INF(0x3f3f3f3f),NINF(0xc3c3c3c3);
long long const LINF(0x3f3f3f3f3f3f3f3fLL),LNINF(0xc3c3c3c3c3c3c3c3LL);
#define Ps Pc(' ')
#define Pe Pc('\n')
#define Frn0(i,a,b) for(int i(a);i<(b);++i)
#define Frn1(i,a,b) for(int i(a);i<=(b);++i)
#define Frn_(i,a,b) for(int i(a);i>=(b);--i)
#define Mst(a,b) memset(a,b,sizeof(a))
#define File(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
int n,w(10),ans;
signed main(){
	Rd(n);
	for(;w<=n;w*=100)ans+=w-w/10;
	if(n>=w/10)ans+=n-w/10+1;
	wr(ans),exit(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define sc(x) scanf("%d", &x)
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define ALL(x) x.begin(), x.end()
#define SZ(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define ABS(x) ((x)>=0?(x):(-(x)))
#define fastio ios::sync_with_stdio(0),cin.tie(0)
template<class T>T gcd(T a, T b){return b?gcd(b, a%b):a;}

int main()
{
    int n, m, x, y;
    sc(n); sc(m); sc(x); sc(y);
    int mx = -1e9, mn = 1e9;
    for(int i = 0; i < n; i++){
        int u; sc(u);
        mx = max(mx, u);
    }
    for(int i = 0; i < m; i++){
        int u; sc(u);
        mn = min(mn, u);
    }
    int u = max(mx, x)+1;
    int v = min(mn, y);
    if(u <= v)puts("No War");
    else puts("War");
    return 0;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();

    int[] l = new int[n];
    for(int i = 0; i < n; i++){
      l[i] = sc.nextInt();
    }
    int answer = 0;
    for(int i = 0; i < n - 2; i++){
      for(int j = i + 1; j < n - 1; j++){
        for(int k = j + 1; k < n; k++){
          int[] t = new int[3];
          t[0] = l[i];
          t[1] = l[j];
          t[2] = l[k];
          Arrays.sort(t);
          if(t[0] != t[1] && t[1] != t[2] && t[2] < (t[0] + t[1])){
            answer++;
          }
        }
      }
    }
    System.out.println(answer);
  }
}

Measured memory_bytes: 41632
#include <cstdio>

int main(){
	int h, w;
	while(1){
		scanf("%d %d", &h, &w);
		if(h==0 && w==0){
			break;
		}
		for(int j=0; j<h; j++){
			for(int i=0; i<w; i++){
				if(i!=0 && i!=w-1 && j!=0 && j!=h-1){
					printf(".");
				}
				else{
					printf("#");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2604
x, y = input().split()
s = 0
if int(x) == 1:
    s += 300000
elif int(x) == 2:
    s += 200000
elif int(x) == 3:
    s += 100000
else:
    s += 0
if int(y) == 1:
    s += 300000
elif int(y) == 2:
    s += 200000
elif int(y) == 3:
    s += 100000
else:
    s += 0
if int(x) == 1 and int(y) == 1:
    s += 400000
print(s)

Measured memory_bytes: 3060
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    int c=sc.nextInt();
    if ((b-a)==(c-b)) {
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define F first
#define S second
#define int long long
using namespace std;
typedef long long int64;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int64 n, m, v, p;
    cin >> n >> m >> v >> p;
    vector<int64> a(n);
    for (int i = 0; i < n; ++ i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int64 special = a[n - p];
    int64 low = 0, high = n - 1;
    while (low < high) {
        int64 mid = (low + high) >> 1;
        if (a[mid] >= special) {
            high = mid;
            continue;
        }
        if (a[mid] + m < special) {
            low = mid + 1;
        }
        else if (a[mid] + m == special) {
            auto temp = a;
            temp[mid] += m;
            int64 left = m * (v - 1);
            for (int i = 0; i < n; ++ i) {
                if (left == 0) break;
                if (i == mid) continue;
                if (temp[i] == special) continue;
                if (temp[i] > special) {
                    temp[i] += min(m, left);
                    left -= min(m, left);
                }
                else {
                    int64 y = min({m, left, special - temp[i]});
                    temp[i] += y;
                    left -= y;
                }
            }
            if (left) low = mid + 1;
            else high = mid;
        }
        else {
            auto temp = a;
            temp[mid] += m;
            int64 left = m * (v - 1);
            for (int i = 0; i < n; ++ i) {
                if (left == 0) break;
                if (i == mid) continue;
                if (temp[i] > special) {
                    temp[i] += min(m, left);
                    left -= min(m, left);
                }
                else {
                    int64 y = min({m, left, temp[mid] - temp[i]});
                    temp[i] += y;
                    left -= y;
                }
            }
            if (left) low = mid + 1;
            else high = mid;
        }
    }
    cout << ((n - 1) - low + 1);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define mp make_pair
#define ft first
#define sd second
#define ue printf("what?\n");
#define pb push_back
#define oo 0x3F3F3F3F	
#define OO 3000000000000000000LL
#define EPS 0
#define maxn 200000
#define pi acos(-1)
#define mod 1000000007
#define mdc __gcd
#define N 600005
#define M 20
using namespace std;
typedef long long ll;
typedef vector<vector<ll> > mat;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

main()
{
	int n, i;
	scanf("%d", &n);
	for(i=0; i<=100 && n - (i * 4) >= 0; i++)
		if(((n - (i * 4)) % 7) == 0)
		{
			printf("Yes\n");
			return 0;
		}
	printf("No\n");
}
		


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

int main() {
	char c;
	int flg;
	string sr[2] = { "vowel","consonant" };
	cin >> c;
	if (c == 'a'||c=='i'||c=='e') { flg = 0; }
	else if (c == 'o' || c == 'u') { flg = 0; }
	else { flg = 1; }
	cout << sr[flg] << endl;
	return 0;
}

Measured memory_bytes: 764
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstring>
#include <string>
#include <bitset>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <assert.h>
using namespace std;
#define e exp(1.0)
typedef long long ll;
#define MAXN 1005
#define mod 998244353
#define INF 0x3f3f3f3f3f3f3f
#define fe(i,st,en) for(i = (st);i <= (en);++i)
#define fne(i,st,en) for(i = (st);i < (en);++i)
#define ri register int
#define db double
int main() {
	ll r, d, x;
	cin >> r >> d >> x;
	for (int i = 1; i <= 10; ++i) {
		x = r * x - d;
		cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int c, a, b, f = 0;
    scanf("%d %d %d", &a, &b, &c);
    if(a==b && b==c)
    {
        f = 0;
    }
    else if(a==b || b==c || c==a)
    {
        f = 1;
    }
    switch(f)
    {
    case 0:
        printf("No\n");
        break;
    case 1:
        printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 128
import bisect
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
idx = bisect.bisect_left(A,0)
ans = 0
if idx%2 == 0:
  ans += abs(sum(A[0:idx]))
  if N > idx:
    ans += sum(A[idx:])
else:
  ans += abs(sum(A[0:idx-1]))
  if idx < N:
    ans += abs(A[idx-1]+A[idx])
  elif idx == N:
    ans += A[idx-1]
  if idx + 1 < N:
    ans += sum(A[idx+1:])
print(ans)

Measured memory_bytes: 14480
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

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

using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

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

    int N;
    cin >> N;
    ll A[300100] = {};

    for (int i = 1; i <= N; i++)
    {
        cin >> A[i];
    }

    int cumsum[300100][60];
    for (int i = 0; i < 60; i++)
    {
        cumsum[0][i] = 0;
    }
    
    for (int i = 1; i <= N; i++)
    {
        for (int j = 0; j < 60; j++) {
            cumsum[i][j] = cumsum[i-1][j] + (A[i] >> j & 1l);
            //cout << cumsum[i][j] << " ";
        }
        //cout << "\n";
    }

    ll res = 0;
    for (int i = 1; i < N; i++)
    {
        for (int j = 0; j < 60; j++)
        {
            ll tmp;
            if (A[i]>>j & 1l)  {
                tmp =  (1l << j) % mod * (N - (cumsum[N][j] - cumsum[i][j]) - i);
                res = (res + tmp) % mod;
            }
            else {
                tmp = (1l << j) % mod * (cumsum[N][j] - cumsum[i][j]);
                res = (res + tmp) % mod;
            }
            res %= mod;
            //cout << res << " ";
        }
        //cout << "\n";
        
    }
    cout << res << "\n";
    
}

Measured memory_bytes: 72960
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ll 				long long
#define int             long long int
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define modp            998244353
#define inf             (ll)1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define FIO           	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl 			'\n'
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int a[200001];
int n, k;

bool check(int len)
{
	int cnt = 0;
	for(int i = 0; i < n; i++)
	{
		// if(len != 0)
			cnt += ((a[i]+len-1)/len - 1);
	}
	return cnt <= k;
}

void solve()
{
	cin >> n >> k;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a, a+n);
	if(k == 0)
		cout << a[n-1] << endl;
	else
	{
		int l = 1, r = a[n-1];
		int mn = 0;
		while(l <= r)
		{
			int mid = l + (r-l)/2;
			if(check(mid))
			{
				mn = mid;
				r = mid-1;
			}
			else
				l = mid+1;
		}
		cout << mn;
	}
}
 
int32_t main()
{
	FIO
    // w(t)
    {
    	solve();
    }
    return 0;
}
	

	

Measured memory_bytes: 5152
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	f = 0
	k = 0
	while f==0
		t = 0
		for i in 1:n
			t += div(a[i],n)
		end
		z = 0
		for i in 1:n
			a[i] += t-(n+1)*div(a[i],n)
			if a[i]<=n-1
				z += 1
			end
		end
		k += t
		if z == n
			f = 1
		end
	end
	println(k)
end

main()

Measured memory_bytes: 164932
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String s = br.readLine();
        int r = 0;
        for(int i = 0; i < n; i++){
            r += s.charAt(i)=='R' ? 1 : 0;
        }
        int x = 0;
        for(int i = 0; i < r; i++){
            x += s.charAt(i)=='R' ? 0 : 1;
        }
        System.out.println(Math.min(x, Math.min(r, n-r)));
    }
}


Measured memory_bytes: 35904
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define INF 1000000000000000LL
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl

signed main(){
	IO_STREAM;
	int N;
	cin>>N;
	vi A(N);
	map<ll,ll>mp;
	rep(i,0,N){
		cin>>A[i];
		mp[A[i]]++;
	}
	ll ans=0;
	for(auto v:mp){
		if(v.second>=2){
			ans+=v.second*(v.second-1)/2;
		}
	}
	rep(i,0,N){
		ll tmp1=0,tmp2=0;
		tmp1= mp[A[i]]   *(mp[A[i]]-1)/2;
		tmp2=(mp[A[i]]-1)*(mp[A[i]]-2)/2;
		cout<<ans-tmp1+tmp2<<endl;
	}
	DBG("","","","");
	return 0;
}


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

int main()
{
  int m, n, cnt = 0;
  int i, j;
  
  cin >> n >> m;
  
  for (i = 0; i < n - 1; i++) {
    for (j = i + 1; j < n; j++) {
      	cnt++;
    }
  }
  
  for (i = 0; i < m - 1; i++) {
    for (j = i + 1; j < m; j++) {
      	cnt++;
    }
  }
  
  cout << cnt << endl;
}

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

const int INF = 1e9;

bool compare(pair<int, int> p1, pair<int, int> p2) {
  return p1.second <= p2.second;
}
int main() {
  int n;
  cin>>n;
  int a[n];
  for (int i=0; i<n; i++) cin>>a[i];
  map<int, int> b;
  for (int i=0; i<n; i++) {
    ++b[a[i]];
    ++b[a[i]-1];
    ++b[a[i]+1];
  }
  auto e = max_element(b.begin(), b.end(), compare);
  cout<<e->second<<endl;

}

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

using namespace std;

#define FAST_IO ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define endl "\n"
typedef long long ll;
 
int main(){ 
	
	FAST_IO;
   
	int n,W;
	cin>>n>>W;

	int V = 100007;

	ll w[n],v[n];

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

	ll dp[n+1][V];
	ll inf = 1e10;

	fill(dp[0],dp[n+1],inf);

	dp[0][0] = 0;

	for(int i=1; i<=n; i++){
		for(int j=0; j<V; j++){
			if(j-v[i-1] >= 0){
				dp[i][j] = min(dp[i][j], w[i-1]+dp[i-1][j-v[i-1]]);
			}
			dp[i][j] = min(dp[i][j],dp[i-1][j]);
		}
	}

	ll ans = 0;
	for(int i=0; i<V; i++){
		if(dp[n][i] <= W)
			ans = i;
	}

	cout<<ans<<endl;

}
 

Measured memory_bytes: 79232
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N,K;
  cin>>N>>K;
  long double ans=0;
  for(int i=1;i<=N;i++){
    long double a=1;
    for(int j=i;j<K;j*=2)
      a/=2;
    ans+=a;
  }
  cout<<fixed<<setprecision(16)<<ans/N<<endl;
}

Measured memory_bytes: 3692
n, k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort(reverse=True)
time = []
for i in range(n):
    time.append(a[i]*f[i])

left = -1
right = 10**12 + 1
while right - left > 1:
    mid = (left + right)//2
    count = 0
    flag = True
    for i in range(n):
        if time[i] <= mid:
            continue
        sa = time[i] - mid
        if sa % f[i] == 0:
            count += sa // f[i]
        else:
            count += sa // f[i] + 1
        if count > k:
            flag = False
            break
    if flag:
        right = mid
    else:
        left = mid
print(right)

Measured memory_bytes: 122020
#pragma GCC target("avx2")
#pragma GCC optimize("O3")

# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
pair <int, int> a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;



int main () {
   SpeedForce;
	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i].F;
		a[i].S = i;
	}
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; i ++)
		cout << a[i].S << ' ';
   return Accepted;
}

// B...a

Measured memory_bytes: 19328
import fractions
a,b,c,d = map(int,input().split())

def div(x,y,z):
    x_r = x % z
    y_r = z - y % z
    tmp = ((y + y_r) - (x - x_r)) // z + 1
    if x_r != 0:
        tmp -= 1
    if y_r != 0:
        tmp -= 1
    return tmp

print(b-a+1-(div(a,b,c)+div(a,b,d)-div(a,b,c*d//fractions.gcd(c,d))))

Measured memory_bytes: 68460
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
#include<cassert>
using namespace std;
#include<atcoder/all>
using namespace atcoder;


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

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 4000001;
const long double eps = 1E-14;

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

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

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

using mint = modint998244353;

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

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

int main() {
	ll N;
	cin >> N;
	
	ll M = 2 * N;

	ll ans = INF;

	ll a = 1100144;
	//cout << gcd(a, M) << " " << gcd(a + 1, M) << " " << gcd(a, M) * gcd(a + 1, M) << endl;

	for (ll i = 1; i * i <= M; i++) {
		if (M % i != 0) { continue; }

		ll j = M / i;

		vll r = { 0,-1 };
		vll m = { i,j };

		auto p = crt(r, m);

		if (p.second == 0) { continue; }
		if (p.first == 0) { p.first += p.second; }

		ans = min(ans, p.first);

		r = { 0,-1 };
		m = { j,i };

		p = crt(r, m);

		if (p.second == 0) { continue; }
		if (p.first == 0) { p.first += p.second; }

		ans = min(ans, p.first);
	}

	cout << ans << endl;
}


Measured memory_bytes: 3668
#include "bits/stdc++.h"
using namespace std;
int main() {
	string S;
	cin >> S;
	stack<char>A;
	for (int i = 0; i < S.size(); i++) {
		if (S.at(i) == 'S') A.push(S.at(i));
		else {
			if (A.empty()) A.push(S.at(i));
			else if (A.top() == 'T') A.push(S.at(i));
			else A.pop();
		}
	}
	cout << A.size() << endl;
}


Measured memory_bytes: 644
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#define Mod 1000000007
typedef long long int ll;
int main()
{
  int a;
  cin>>a;
  string s;
  cin>>s;
  if(a>=3200)
  {
      cout<<s;
  }
  else
  {
      cout<<"red";
  }
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    n, m, d = map(int, input().split())

    if d == 0:
        f = n
    else:
        f = 2 * (n - d)
    ans = (m - 1) * f / (n ** 2)

    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a
#define lcoutln(a) cout << a << endl
#define lcerr(a) cerr << a
#define lcerrln(a) cerr << a << endl
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007

signed main()
{
	init();
	solve();
}

ll x, a, b;

void init()
{
	cin >> a >> b >> x;
}

void solve()
{
	if(a == 0) a = -x;
	else a--;
	cout << b / x - a / x << endl;
}



Measured memory_bytes: 256
H, N = map(int, input().split())
M = [tuple(map(int, input().split())) for _ in range(N)]
dp = [float('inf')] * (H + 1)
dp[0] = 0
for h in range(H):
    if dp[h] == float('inf'):
        continue
    for a, b in M:
        idx = min(H, h + a)
        dp[idx] = min(dp[idx], dp[h] + b)
print(dp[H])


Measured memory_bytes: 42972
N,M = map(int,input().split())
if(min(N,M)==1):
    if(max(N,M)==1):
        print(1)
    else:
        print(max(N,M)-2)
elif(min(N,M)==2):
    print(0)
else:
    print(N*M - (N*2+M*2 - 4))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF = 0x3f3f3f3f;
const ll mod  = 1e9 + 7;
const ll N = 1e6 + 5;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    string s;
    cin>>n>>s;
    cout<<count(s.begin(),s.begin()+(count(s.begin(),s.end(),'R')),'W');
    return 0;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define int long long int
#define IOS ios_base::sync_with_stdio(false), cin.tie(NULL);
#define fr(i,a,b)  for(int i=a;i<=b;i++)
#define rf(j,b,a)  for(int j=b;j>=a;j--)
#define frr(k,a,b) for(int k=a;k<=b;k++)
#define mp make_pair
#define pb push_back
#define MOD 1000000007
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
signed main()
{   
	IOS
  /* #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif*/
int n,W;
cin>>n>>W;
int wt[n],val[n];
for(int i=0;i<n;i++)
{
 cin>>wt[i]>>val[i];	
}
int K[n+1][W+1];
   for (int i = 0; i <= n; i++) 
   { 
       for (int w = 0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (wt[i-1] <= w) 
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   } 
  
cout<<K[n][W]<<endl;

}









Measured memory_bytes: 79232
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
	char a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a==b&&b==c)cout<<"Yes"<<endl;
	else if(b==c&&c==d)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


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

int main()
{
	string a,b;
	cin>>a;
	cin>>b;
	if(a.size()==b.size())
	{
	    if(a>b)cout<<"GREATER"<<endl;
	    else if(a<b)cout<<"LESS"<<endl;
	    else if(a==b)cout<<"EQUAL"<<endl;
	}
	else if(a.size()>b.size())cout<<"GREATER"<<endl;
	else if(a.size()<b.size())cout<<"LESS"<<endl;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n, 0);
  rep(i, m) {
    int s;
    cin >> s;
    a.at(s) = 1;
  }
  vector<int> dp(n+2);
  dp.at(n+1) = 0;
  dp.at(n) = 1;

  for (int i = n-1; i >= 0; i--) {
    if (a.at(i)) {
      dp.at(i) = 0;
    } else {
      dp.at(i) = dp.at(i+1) % mod + dp.at(i+2) % mod;
    }
  }

  int ans = dp.at(0) % mod;
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t N,K;
  cin>>N>>K;
  vector<int64_t> H(N);
  for(int i=0; i<N; i++){
    cin>>H.at(i);
  }
  sort(H.begin(), H.end());
  if(N>K){
    int64_t x=0;
    for(int i=0;i<(N-K);i++){
      x+=H.at(i);
    }
    cout<<x<<endl;
  }
  else{
    cout<< 0 <<endl;
  }
}

Measured memory_bytes: 1792
import java.util.Scanner;

//Battle Town
public class Main{

	int[][] move = {{-1,0},{0,1},{1,0},{0,-1}};
	char[] c = {'^', '>', 'v', '<'};
	int h, w;
	char[][] map;
	
	void run(){
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		for(int t=0;t<T;t++){
			if(t>0)System.out.println();
			h = sc.nextInt(); w = sc.nextInt();
			map = new char[h][];
			for(int i=0;i<h;i++)map[i]=sc.next().toCharArray();
			sc.nextInt();
			int pi = -1, pj = -1, d = -1;
			for(int i=0;i<h;i++)for(int j=0;j<w;j++){
				if(map[i][j]=='^'||map[i][j]=='>'||map[i][j]=='v'||map[i][j]=='<'){
					for(d=0;d<4;d++)if(map[i][j]==c[d])break;
					map[i][j] = '.';
					pi = i; pj = j;
				}
			}
			for(char cmd:sc.next().toCharArray()){
				if(cmd=='S'){
					int ni = pi, nj = pj;
					while(0<=ni&&ni<h&&0<=nj&&nj<w){
						if(map[ni][nj]=='*'){
							map[ni][nj] = '.'; break;
						}
						else if(map[ni][nj]=='#')break;
						ni += move[d][0]; nj += move[d][1];
					}
				}
				else{
					d = cmd=='U'?0:cmd=='R'?1:cmd=='D'?2:3;
					int ni = pi+move[d][0], nj = pj+move[d][1];
					if(0<=ni&&ni<h&&0<=nj&&nj<w&&map[ni][nj]=='.'){
						pi = ni; pj = nj;
					}
				}
			}
			map[pi][pj] = c[d];
			for(int i=0;i<h;i++)System.out.println(new String(map[i]));
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

using namespace std;

#define ll long long
#define pi pair<int, int>
#define mkp make_pair
#define pb push_back
#define fr first
#define sc second
#define endl '\n'

const int mxn = 1e6 + 5;
const ll MOD =  1e9 + 7;
int arr[mxn];
vector<int> graph[mxn];
int n, m, k;
ll l, r;
string s;

ll POW(ll A,ll B,ll R=1)
{while(B){if(B&1)R=R*A%MOD;A=A*A%MOD;B>>=1;}return R;}

void read(){
    cin >> n >> m;
    for(int i = 1, u, v; i <= n; i++){
        cin >> arr[i];
    }
    for(int i = 0, u, v; i < m; i++){
        cin >> u >> v;
        graph[u].pb(v);
        graph[v].pb(u);
    }
}


void solve(){
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        bool flag = true;
        for(auto x : graph[i]){
            flag &= (arr[i] > arr[x]);
        }
        cnt += flag;
    }
    cout << cnt << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    //cin >> T;
    while(T--) read(), solve();
    return 0;
}


Measured memory_bytes: 30252