akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>

#include<vector>
#include<string>

#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
const ll INF = 1e12+1;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}

ll dp[51][51][2501];

int main() {
    //plan1 全探索ベースで枝刈りを考える
    //A よりも大きい数での 和のデータベースを作っておく
    //A より小さい数で全状態探索
    
    int N, A;
    cin >> N >> A;
    vector<int> x(N);
    
    for (int i = 0; i < N; i++) cin >> x[i];
    
    int X = -1;
    
    for (int i = 0; i < N; i++) chmax(X,x[i]);
    
    chmax(X,A);
    
    
    dp[0][0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= N; j++) {
            for (int k = 0; k <= N * X; k++) {
                    if (x[i] > k) {
                        dp[i+1][j][k] = dp[i][j][k];
                    } else if (j >= 1) {
                        dp[i+1][j][k] = dp[i][j][k] + dp[i][j-1][k-x[i]];
                    }
                
            }
        }
    }
    ll res = 0;
    for (int k = 1; k <= N; k++) {
        res += dp[N][k][k*A];
    }
    
    cout << res << endl;
}


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

void maxHeapfy(int *,int);
void buildMaxHeap(int *);

int h;

int main(){
  int *A;
  int i;

  scanf("%d",&h);
  A=(int*)malloc((h+1)*sizeof(int));
  for(i=1;i<=h;i++){
    scanf("%d",&A[i]);
  }

  buildMaxHeap(A);

  for(i=1;i<=h;i++){
    printf(" %d",A[i]);
  }
  printf("\n");

  free(A);

  return 0;
}

void buildMaxHeap(int* A){
  for(int i=h/2;i>0;i--){
    maxHeapfy(A,i);
  }
}

void maxHeapfy(int* A,int i){
  int l=i*2;
  int r=(i*2)+1;
  int largest;
  int temp;

  if(l<=h && A[l]>A[i]){
    largest=l;
  }
  else{
    largest=i;
  }
  if(r<=h && A[r]>A[largest]){
    largest=r;
  }

  if(largest!=i){
    temp=A[i];
    A[i]=A[largest];
    A[largest]=temp;
    maxHeapfy(A,largest);
  }
}



Measured memory_bytes: 3304
#include <stdio.h>
 
int main(void){
  int P, Q, R, X, Y, Z;
  int min;
 
  scanf("%d %d %d", &P, &Q, &R);
  
  X = P + Q;
  Y = Q + R;
  Z = R + P;
  
  min = X;
  if(Y < min) min = Y;
  if(Z < min) min = Z;
  
  printf("%d", min);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main()
{
  lli i,j,q,n,m,x,t,ans,sum = 0;
  string str;
  cin >> str;
  for(i=0;i<str.length();i++)
  {
    sum = sum + (lli)(str[i] - '0');
  }
  if(sum % 9 == 0)
  {
    cout << "Yes";
  }
  else
  {
    cout << "No";
  }
  return 0;
}

Measured memory_bytes: 3668
def main():
    n, m = map(int, input().split())
    a, b = [], []
    from_1 = set()
    to_n = set()
    for _ in range(m):
        x, y = map(int, input().split())
        if x == 1:
            from_1.add(y)
            continue
        if y == n:
            to_n.add(x)
            continue
    ans = from_1 & to_n
    if ans:
        return "POSSIBLE"

    return 'IMPOSSIBLE'


print(main())

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

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

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int K; cin >> K;

    for (int i = 0; i < N; i++) {
        if (S.at(i) != S.at(K - 1)) {
            S.at(i) = '*';
        }
    }

    cout << S << endl;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
using namespace std;
int n;
vector<int> h(100000);
vector<int> cost(100000);

int ans(int n)
{
    if (cost.at(n) != -1)
        return cost.at(n);
    cost.at(n) = min(ans(n - 1) + abs(h.at(n) - h.at(n - 1)),
                     ans(n - 2) + abs(h.at(n) - h.at(n - 2)));
    return cost.at(n);
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> h.at(i);
        cost.at(i) = -1;
    }
    cost.at(0) = 0;
    cost.at(1) = abs(h.at(1) - h.at(0));
    cout << ans(n - 1) << endl;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int Sum(const string&s){
  int n = (int)s.size();
  int sum = 0;
  for(int i = 0; i < n; ++i)sum += s[i] - '0';
  return sum;
}

int main(){
  int a,b; cin >> a >> b;
  cout << max({a+b,a-b,a*b}) << endl;
}


Measured memory_bytes: 3564
#include<stdio.h>

int main(){
	
	long long x;
	scanf("%lld",&x);
	
	int i = 0;
	char str[100];
	
	while(x > 0){
		int temp = x % 26;
		
		if(temp == 0){
			str[i++] = 'z';
			x = (x/26) - 1;
		}else{
			str[i++] = (temp - 1) + 'a';
			x = x/26;
		}
	}
	str[i] = '\0';
	
	int j = 0;
	for(j = i - 1;j >= 0;j--){
		printf("%c",str[j]);
	}
	
	
	return 0;
}

Measured memory_bytes: 1644
#include<cstdio>
#include<iostream>
#include<vector>
#include<tuple>
#include<queue>
#include<algorithm>
#include<string.h>

using namespace std;

int main(int argc, char* argv[]){
  int a,b;
  scanf("%d%d",&a,&b);
  int diff=b-a;
  int tou =0;
  for(int i=1;i<=diff;i++){
    tou+=i;
  }
  int ans=tou-b;
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A,B,C;
  cin>>A>>B>>C;
  int k;
  cin>>k;
  int num_of_turns = 0;
  while(B<=A){
    B*=2;
    num_of_turns++;
  }
  while(C<=B){
    C*=2;
    num_of_turns++;
  }
  if(num_of_turns>k)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int x, k, d;
    cin >> x >> k >> d;
    if (abs(x) < d) {
        if (k % 2 == 0) {
            cout << abs(x) << "\n";
        } else {
            cout << d - abs(x) << "\n";
        }
    } else {
        int cnt = abs(x) / d, amari = abs(x) % d;
        if (k <= cnt) {
            cout << abs(x) - k * d << "\n";
        } else {
            if ((k - cnt) % 2 == 0) {
                cout << amari << "\n";
            } else {
                cout << d - amari << "\n";
            }
        }
    }
}

Measured memory_bytes: 3616
import java.util.Scanner;

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

        Scanner sc = new Scanner(System.in);

        long A = sc.nextLong();
        long B = sc.nextLong();
        long K = sc.nextLong();

        if (A >= K) {
            A = A - K;
        } else {
            if (B >= (K-A)){
                B = B - (K - A);
                A = 0;
            } else {
                B = 0;
                A = 0;
            }
        }
        System.out.println(A + " " + B);
    }
} 

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

using ll = long long;

int main() {
    int N, ans = 0;
    string A, B, C;
    cin >> N >> A >> B >> C;
    rep(i, N) {
        if (A[i] == B[i]) {
            if (A[i] != C[i]) ans++;
        } else if (A[i] == C[i]) {
            ans++;
        } else if (B[i] == C[i]) {
            ans++;
        } else {
            ans += 2;
        }
    }
    cout << ans << "\n";
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

ll div2(ll x){
  if(x < 0 && (x %(-2) != 0)){
    return x / (-2) + 1;
  }else{
    return x / (-2);
  }
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll n; cin >> n;
  if(n == 0){
    cout << 0 << endl;
    return 0;
  }
  string ans = "";
  while(n != 0){
    if(n %2 == 0) ans += '0';
    else ans += '1';
    n = div2(n);
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}

Measured memory_bytes: 380
#include <iostream>
#include <vector>
#include <list>
#include <deque>
#include <string>
#include <set>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#define ll long long
#define INF 0x3f3f3f3f
#define SIS std::ios::sync_with_stdio(false)
using namespace std;

int main()
{
    SIS;
    deque <char> ans;
    string s;
    char c;
    cin>>s;
    for(int i=0;i<s.size();i++)
        ans.push_back(s[i]);
    int q,re=1,cnt=s.size(),t;
    cin>>q;
    for(int i=0;i<q;i++)
    {
        cin>>t;
        if(t==1)
            re*=-1;
        else
        {
            int f;
            cin>>f;
            if(f==1)
            {
                cin>>c;
                if(re==1)
                    ans.push_front(c);
                else
                    ans.push_back(c);
            }
            else
            {
                cin>>c;
                if(re==1)
                    ans.push_back(c);
                else
                    ans.push_front(c);
            }
            cnt++;
        }
    }
    if(re==1)
        for(int i=0;i<cnt;i++)
            cout<<ans[i];
    else
        for(int i=cnt-1;i>=0;i--)
            cout<<ans[i];
    cout<<endl;
    return 0;
}


Measured memory_bytes: 976
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll X,K,D;
    cin >> X >> K >> D;
    X = abs(X);
    ll q = abs(X)/D;
    if(K < q){
        cout << abs(X) - K*D << endl;
        return 0;
    }
    K -= q;
    X -= q*D;
    if(K % 2 == 0){
        cout << X << endl;
    }else{
        cout << abs(X-D) << endl;
    }
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    // A, B, C -> A+x , A, Bとして考える
    //常に締め出される変数はxこれがA側B側のどちらかで必ず1つ締め出される

    if(K % 2 == 0){
        cout << A - B << endl;
    }else{
        cout << B - A << endl;
    }

}

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

#include <iostream>
#include <cmath>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;


int main() {
    int N, K, score;
    double prob, tmp;
    cin >> N >> K;
    prob = 0;
    for (int i =1; i<N+1;i++){
        tmp = 1/double(N);
        score = i;
        while(score < K){
            tmp = tmp/2;
            score = score*2;

        }
        prob += tmp;

    }
    cout << fixed << setprecision(12);
    cout << prob << endl;
}





Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>
#include <sstream>

#define all_range(C) std::begin(C), std::end(C)


struct Tree{
	char ope_type = '\0';
	std::unique_ptr<Tree> node1, node2;
	Tree(){}
	const char* construct(const char* str)
	{
		if (*str == '[') {
			++str;
			ope_type = *str++;
			node1 = std::make_unique<Tree>();
			str = node1->construct(str);
			node2 = std::make_unique<Tree>();
			str = node2->construct(str);
			assert(*str == ']');
			return ++str;
		}
		else {
			ope_type = *str;
			return ++str;
		}
	}
	unsigned hash(const int value[4])
	{
		if (!node1) {
			return value[ope_type - 'a'];
		}
		if (ope_type == '+') {
			return node1->hash(value) | node2->hash(value);
		}
		if (ope_type == '*') {
			return node1->hash(value) & node2->hash(value);
		}
		if (ope_type == '^') {
			return node1->hash(value) ^ node2->hash(value);
		}
		assert(false);
		return 0;
	}
};

int main()
{
	using std::endl;
	using std::cout;
	using std::cin;

	while (true)
	{
		std::string function;
		cin >> function;
		if (function == ".") {
			break;
		}
		std::string pass;
		cin >> pass;

		Tree tree;
		tree.construct(function.c_str());
		int pass_int[4];
		for (int i = 0; i < 4; i++)
		{
			pass_int[i] = pass[i] - '0';
		}
		int count = 0;
		unsigned hash_my = tree.hash(pass_int);
		for (int i = 0; i < 10000; i++)
		{
			pass_int[0] = i;
			pass_int[3] = pass_int[0] % 10; pass_int[0] /= 10;
			pass_int[2] = pass_int[0] % 10; pass_int[0] /= 10;
			pass_int[1] = pass_int[0] % 10; pass_int[0] /= 10;

			if (tree.hash(pass_int) == hash_my) {
				++count;
			}
		}

		cout << hash_my << ' ' << count << std::endl;
	}

	return 0;
}
#endif



Measured memory_bytes: 3156
s = input()
import re
if "keyence" == s:
    print("YES")
    exit()

if re.fullmatch(".*keyence",s) is not None:
    print("YES")
    exit()

if re.fullmatch("k.*eyence",s) is not None:
    print("YES")
    exit()
if re.fullmatch("ke.*yence",s) is not None:
    print("YES")
    exit()
if re.fullmatch("key.*ence",s) is not None:
    print("YES")
    exit()
if re.fullmatch("keye.*nce",s) is not None:
    print("YES")
    exit()
if re.fullmatch("keyen.*ce",s) is not None:
    print("YES")
    exit()
if re.fullmatch("keyenc.*e",s) is not None:
    print("YES")
    exit()
if re.fullmatch("keyence.*",s) is not None:
    print("YES")
    exit()
print("NO")

Measured memory_bytes: 3188
FB = (1..10000).map{|x|a=[[:Fizz][x%3],[:Buzz][x%5]]*'';a==''?x.to_s: a}
loop do
  m, n = gets.split.map(&:to_i)
  break if m == 0
  pos = []
  ret = Array.new(m){|i|i+1}
  FB[0,n].zip(n.times.map{gets.chomp}).map.with_index{|(a,b),i| i if a!=b}.compact.unshift(0).each_cons(2).each_with_object([]).with_index{|(a,arr),i| arr << (a[1]-a[0])%(m-i)}[0,m-1].reduce(0){|s,t| ret.slice!(t=(s+t)%ret.size); t-1}
  puts ret.join(' ')
end

Measured memory_bytes: 10996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
using vec = vector<vector<int>>;
int N, M;
bool isexist(vec &a, int *ans, bool *v)
{
    vector<int> parent(1, 1);
    vector<int> newparent;
    while (parent.size() > 0)
    {
        // cout << parent.size() << ' ';
        rep(p, 0, parent.size())
        {
            rep(i, 0, a[parent[p]].size())
            {
                int dst = a[parent[p]][i];
                if (v[dst] == false)
                {
                    v[dst] = true;
                    ans[dst] = parent[p];
                    newparent.push_back(dst);
                }
            }
        }
        // cout << newparent.size() << '\n';
        parent.resize(newparent.size());
        // rep(i, 0, newparent.size()) parent[i] = newparent[i];
        parent = newparent;
        newparent.resize(0);
    }
    rep(i, 1, N + 1) if (v[i] == false) return false;
    return true;
}
void func()
{
    cin >> N >> M;
    vec room(N + 1, vector<int>(0));
    int ans[N + 1] = {};
    bool isvisited[N + 1] = {};
    isvisited[1] = true;
    rep(i, 0, M)
    {
        int tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        room[tmp1].push_back(tmp2);
        room[tmp2].push_back(tmp1);
    }
    bool istrue = isexist(room, ans, isvisited);
    if (istrue)
    {
        cout << "Yes" << endl;
        rep(i, 2, N + 1) cout << ans[i] << '\n';
    }
    else
    {
        cout << "No" << endl;
    }
}
int main()
{
    func();
}

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

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
*/

using namespace std;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<vector<int> > vvi;
typedef vector<vector<ii> > vvii;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define ff first
#define ss second
#define trav(a, x) for(auto& a : x) 
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
const ll INF = 1e18;
const int mod =  1e9 + 7;
const int N = 1e5;
ll gcd(ll a,ll b){if (a==0) return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return a*(b/gcd(a,b));}
ll Abs(ll a){if(a>0)return a;return -a;}
ll Ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
double Abs(double a){if(a>0)return a;return -a;}

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
*/

inline int pow_(ll x, ll y,ll p){
  int r = 1; while(y){if(y & 1) r = r * x % p; y >>= 1; x = x * x % p;} return r;
}
inline int inv_(int x){return pow_(x, mod - 2, mod);}
inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int mul(int a, int b){return a * 1LL * b % mod;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}



int main()
{
	#ifdef LOCAL_TEST
    freopen("in.txt","r",stdin);
    //freopen("out.txt", "w", stdout);
    #else
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    #endif
   	ll n;
   	cin>>n;
   	ll a[405] = {0};
   	for(int i=1;i<=n;i++)cin>>a[i];

   	ll dp[405][405] = {0};
   	ll val[405][405] = {0};

   	for(int i=1;i<=n;i++)val[i][i] = a[i]; 
	for(int i=1;i<n;i++)
	{
		int j = i+1;
		dp[i][j] = a[i] + a[j];
		val[i][j] = a[i] + a[j];
	}

   	for(int l=2;l<=n;l++)
   	{
   		for(int i=1;i<=n-l;i++)
   		{
   			int j = i+l;
   			dp[i][j] = INF;
   			for(int k=i;k<j;k++)
   			{
   				if(dp[i][j] > dp[i][k] + dp[k+1][j] + val[i][k] + val[k+1][j])
   				{
   					dp[i][j] = dp[i][k] + dp[k+1][j] + val[i][k] + val[k+1][j];
   					val[i][j] = val[i][k] + val[k+1][j];
   				}
   			}

   			//cout << dp[i][j] << " ";
   		}
   		//cout << "\n";
   	}

   	cout << dp[1][n] << "\n";
	return 0;
}

Measured memory_bytes: 2816
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std;

const int maxn = 1e5 + 5;
long long a[maxn],n,x;
long long ans;

int main()
{
    while(scanf("%lld%lld",&n,&x) != EOF)
    {
        ans = 0;
        for(int i = 1;i <= n;i++)
        {
            scanf("%lld",&a[i]);
        }
        for(int i = 2;i <= n;i++)
        {
            int k = a[i] + a[i - 1];
            if(k <= x)
            {
                continue;
            }
            if(a[i - 1] <= x)
            {
                ans = ans + a[i] - (x - a[i - 1]);
                a[i] = x - a[i - 1];
            }
            else
            {
                ans += k - x;
                a[i] = 0;
            }

        }
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(){

  char w[12];
  char t[1001];
  //  char e[12]={'E','N','D','_','O','F','_','T','E','X','T'};
  char e[] = "END_OF_TEXT";
  int ans=0,i;

  scanf("%s",w);
  for(i=0;w[i]!='\0';i++){
    //    if(islower(w[i])!=0){
    if(islower(w[i])){
      w[i] = toupper(w[i]);
    }
  }


  for(;;){
    
    scanf("%s",t);
    if(strcmp(t,e)==0){
      break;
    }  


    for(i=0;t[i]!='\0';i++){
      if(islower(t[i])!=0){
	t[i] = toupper(t[i]);
      }
    }
    
  
    
    if(strcmp(w,t)==0){
      ans++;
    }
  }

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

  return 0;
}

Measured memory_bytes: 976
#include <iostream>
#include<iomanip>

using namespace std;

int main() {
    
    int n;
    while (cin >> n) {
    
    if(n == 0)
    break;
    
    int A[51][51] = {};
    
    for(int i=0;i<n;i++) { 
    for(int j=0;j<n;j++) {
    	
    	cin >> A[i][j];
    	
    	A[i][n] += A[i][j];
    	A[n][j] += A[i][j];
	}
	A[n][n] += A[i][n];
}

	for(int i=0;i<=n;i++) { 
    for(int j=0;j<n;j++) {
    	
    	cout << setw(5)<< A[i][j];
    }
	cout << setw(5)<< A[i][n];
	cout << "\n";
}
}
    return 0;
}


Measured memory_bytes: 2968
//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
//#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
//Using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> Ordered_set;

#define ll              long long
#define int             long long
#define ld             long double
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define vii             vector<vi>
#define vip            vector<pii>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int> 
#define all(v)          v.begin(),v.end()  
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define lb(x)           (x&(-x))
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define itr(it,v)          for(auto it:v)
#define show(arr,n)     for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fir(i,k,n)       for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ff               first 
#define ss               second
#define deb(x) cout << #x << "=" << x << endl
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define check(x) (x && cout<<"Yes\n")||(cout<<"No\n");
#define fin(s)          freopen(s,"r",stdin);  
#define fout(s)         freopen(s,"w",stdout);

const ld pi = 3.141592653589793238462643383279502884;
const int xd[]={-1,0,1,0};
const int yd[]={0,-1,0,1};
int XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[] = { -1, 0,  1, -1, 1, -1, 0, 1 };

int expo(int a,int b,int m);
int mmi(int a,int m);
void ipgraph(int m);

const int N=5*(1e5)+10;
vii adj(N);
ld a[N];

void  solve(){

}
int32_t main()
{
    FIO
    ld n,k; cin>>n>>k;
    fi(i,n) cin>>a[i];
    ld maxz=a[0];
    fi(i,n) maxz=max(maxz,a[i]);
    ld ans=maxz;
    ld l=0.1,r=maxz;
    while(r-l>=0.0000000001){
        ld m=l+(r-l)/2.0;
        // cout<<l<<" "<<r<<" "<<m<<"\n";
        ld cuts=0;
        for(int i=0;i<n;i++){
            ld c=ceil(a[i]/m);
            cuts+=max((long double)0.0,c-(long double)1.0);
        }
        if(cuts<=k){
            ans=min(ans,m);
            r=m;
        }
        else l=m;
    }
    int c=ceil(l);
    cout<<c<<"\n";
    return 0;

}

void ipgraph(int m){
    int i, u, v;
    while(m--){
          cin>>u>>v;
         u--, v--;
    adj[u].pb(v);
    adj[v].pb(u);
    }
}
int expo(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return a;
    int val=(expo(a,b/2,m)*expo(a,b/2,m))%m;
    if(b & 1) return (val*a)%m;
    else return val;
}
int mmi(int a,int m){
    return expo(a,m-2,m);
}

Measured memory_bytes: 18108
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace ARC096D
{
    public class Program
    {
        struct XVPair
        {
            public long X;
            public long V;

            public XVPair(long x, long v)
            {
                X = x;
                V = v;
            }
        }

        int N;
        long C;
        XVPair[] XV;

        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            N = ss.Next(int.Parse);
            C = ss.Next(long.Parse);
            XV = ss.Next(long.Parse, 2, N).Select(a => new XVPair(a[0], a[1])).ToArray();

            var tr1 = GetMaxValuesOfDist(true, 1);
            var tr2 = GetMaxValuesOfDist(true, 2);
            var tl1 = GetMaxValuesOfDist(false, 1);
            var tl2 = GetMaxValuesOfDist(false, 2);

            var max = 0L;
            for (var i = 0; i <= N; i++)
            {
                max = Math.Max(max, tr1[i] + tl2[N - i]);
                max = Math.Max(max, tr2[i] + tl1[N - i]);
            }

            sw.WriteLine(max);
            //---------------------------------
        }

        long[] GetMaxValuesOfDist(bool isRight, int walkCost)
        {
            var ret = new long[N + 1];
            var sum = 0L;
            for (var i = 1; i <= N; i++)
            {
                var cur = isRight ? i - 1 : N - i;
                var dist = isRight ? XV[cur].X : C - XV[cur].X;

                sum += XV[cur].V;
                ret[i] = Math.Max(ret[i - 1], sum - dist * walkCost);
            }
            return ret;
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}

Measured memory_bytes: 33224
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


int main()
{

	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	int sum = 0;
	int first;
	int maxim = 0;

	for (int i = -1; i < n - 1; i++) {
		int kyori;
		cin >> kyori;
		if (i == -1) {
			sum = kyori;
			first = kyori;
			continue;
		}
		
		a[i] = kyori - sum;
		maxim = max(maxim, a[i]);
		sum = kyori;

	}

	a[n - 1] = first + k - sum;
	maxim = max(maxim, a[n - 1]);

	cout << k - maxim << endl;
}

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

double sub1(int* x, int* y, int n, int p) {
  double temp = 0;
  for(int i = 0; i < n; ++i) {
    temp += pow(abs(x[i]-y[i]), p);
  }
  return pow(temp, 1.0/p);
}
  

int main() {

  int x[128];
  int y[128];

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

  printf("%.10lf\n", sub1(x, y, N, 1));
  printf("%.10lf\n", sub1(x, y, N, 2));
  printf("%.10lf\n", sub1(x, y, N, 3));

  double ans = 0;
  for(int i = 0; i < N; ++i) {
    if( ans < abs(x[i]-y[i]) ) {
      ans = abs(x[i]-y[i]);
    }
  }
  printf("%.10lf\n", ans);
  
  return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
    int n;
    int value;
    int count = 0;
    
    cin >> n;
    for(int i = 0; i < n; i++){
        
        cin >> value;

        if(value != i + 1){
            count++;
        }

    }

    if(count > 2){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const ll MOD=1000000007;
int H,W,A,B;
ll res=0,n[200005][2]={{1,1}};

ll pp(ll x,ll p,ll mod)
{
	ll r=1;
	for(ll i=p;i>0;i>>=1)
	{
		if(i&1)r=(r*x)%mod;
		x=x*x%mod;
	}
	return r;
}

int main()
{
	scanf("%d%d%d%d",&H,&W,&A,&B);
	for(int i=1;i<200005;i++)
	{
		n[i][0]=(n[i-1][0]*i)%MOD;
		n[i][1]=pp(n[i][0],MOD-2,MOD);
	}
	for(int i=B;i<W;i++)
	{
		ll a=(n[(H-A)+i-1][0]*n[i][1]%MOD*n[H-A-1][1])%MOD;
		ll b=(n[A-1+(W-i-1)][0]*n[W-i-1][1]%MOD*n[A-1][1])%MOD;
		res=(res+a*b)%MOD;
	}
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
//#pragma GCC optimize ("-O3")

using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//const long double PI = 3.14159265358979323846;  /* pi */

int main() {
    //ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    long long n, k;
    cin >> n >> k;
    vector<double> ar(n);
    for (long long i = 0; i < n; i++)
    {
        cin >> ar[i];
    }
    double lo = 0.000001, hi = 1e9;
    while (hi - lo >= 0.0001)
    {
        double mid = lo + (hi - lo)/2;
        // count req
        long long req = 0;
        for (long long i = 0; i < n; i++)
        {
            req += ceill(ar[i] / mid) - 1;
        }
        if (req > k)
        {
            // increase length
            lo = mid;
        }
        else
            hi = mid;
        // cout << lo << " " << hi << " " << req << "\n";

    }
    cout << (long long) ceil(lo) << "\n";
    return 0;
}


Measured memory_bytes: 4884
import sys
s = int(input())
N = [s]
while True:
  if s % 2 == 0:
    s = s // 2
    N.append(s)
  else:
    s = 3 * s + 1
    N.append(s)
  if N.count(s) > 1:
    print(len(N))
    sys.exit()

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


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

  int n;
  cin>>n;
  vi a(n);
  rep(i,n){
    cin>>a[i];
  }

  int ans=0;
  rep(i,n){
    rep(j,n){
      ans=max(ans,abs(a[i]-a[j]));
    }
  }

  cout<<ans<<endl;


}

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

bool fun(pair<pair<string,ll>,ll>p1, pair<pair<string,ll>,ll>p2)
{
    if(p1.first.first==p2.first.first)
        return p1.first.second>p2.first.second;
    return p1.first.first<p2.first.first;
}

int main()
{
    ll n,i;
    cin>>n;
    vector<pair<pair<string,ll>,ll> >v;
    for(i=0;i<n;i++)
    {
        ll a;
        string s;
        cin>>s>>a;
        v.push_back(make_pair(make_pair(s,a),i));
    }
    sort(v.begin(),v.end(),fun);
    for(i=0;i<n;i++)
    {
        cout<<v[i].second+1<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define DEBUG(x) cerr << #x << " = " << x << endl
struct UnionFind {
  vector<int> data;
  UnionFind(int n) : data(n, -1) { }
  int root(int x) {
    return data[x] < 0 ? x : (data[x] = root(data[x]));
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  void merge(int x, int y) {
    x = root(x); y = root(y);
    if(x != y) {
      if(size(y) > size(x)) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
  }
  int size(int x) {
    return -data[root(x)];
  }
  int count_union() {
    int res = 0;
    for(int v : data) if(v < 0) ++res;
    return res;
  }
};
struct Edge {
  int from, to, cost;
  Edge(int from_, int to_, int cost_) : from(from_), to(to_), cost(cost_) { }
  bool operator <(const Edge &rhs) const {
    return cost < rhs.cost;
  }
};
int main() {
  int N, M; cin >> N >> M;
  vector<Edge> G;
  for(int i = 0; i < M; ++i) {
    int from, to, cost;
    cin >> from >> to >> cost;
    --from; --to;
    G.emplace_back(from, to, cost);
  }
  sort(G.begin(), G.end());
  vector<int> need;
  long long mincost = 0;
  {
    UnionFind uf(N);
    for(int i = 0; i < M; ++i) {
      if(uf.same(G[i].from, G[i].to) == false) {
        mincost += G[i].cost;
        uf.merge(G[i].from, G[i].to);
        need.push_back(i);
      }
    }
  }
  int ansnum = 0;
  long long anscost = 0;
  for(int e : need) {
    long long cost = 0;
    UnionFind uf(N);
    for(int i = 0; i < M; ++i) {
      if(i == e) continue;
      if(uf.same(G[i].from, G[i].to) == false) {
        cost += G[i].cost;
        uf.merge(G[i].from, G[i].to);
      }
    }
    if(cost == mincost && uf.count_union() == 1) {
    }
    else {
      ++ansnum;
      anscost += G[e].cost;
    }
  }
  cout << ansnum << " " << anscost << endl;
}

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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

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

// UnionFind
// coding: https://youtu.be/TdR816rqc3s?t=726
// comment: https://youtu.be/TdR816rqc3s?t=6822
//
// UnionFind uf(n) で初期化
struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  // 木を作る動作
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

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

  ll n, m;
  cin >> n >> m;
  vector<int> a(m), b(m);
  rep(i, m) {
    cin >> a[i] >> b[i];
    --a[i]; --b[i];
  }
  int ans = 0;
  rep(i, m) {
    UnionFind uf(n);
    rep(j,m) {
      if (i == j) continue;
      uf.unite(a[j], b[j]);
    }
    rep(j, n) {
      if (uf.size(j) != n) {
        //cout << "node: " << j << ", size: " << uf.size(j) << endl;
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
 
int main(){
    int k,s;
    cin >> k >> s;
    int count=0;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            if((s-i-j)>=0&&(s-i-j)<=k) count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    string S;

    cin >> S;

    if (S[0] == S[1]) {
        if (S[0] != S[2] && S[2] == S[3]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else {
        if (S[0] == S[2] && S[1] == S[3]) cout << "Yes" << endl;
        else if (S[0] == S[3] && S[1] == S[2]) cout << "Yes" << endl;
        else cout << "No" << endl;
    } 
    
    
    return 0;
}

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

using namespace std;

using Weight = long long;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) : src(src), dst(dst), weight(weight) {}
};

auto operator<(const Edge &e, const Edge &f) {
  if (e.weight != f.weight)
    return e.weight > f.weight;
  else if (e.src != f.src)
    return e.src < f.src;
  else
    return e.dst < f.dst;
}

using Edges = vector<Edge>;
using Graph = vector<Edges>;

pair<Weight, int> sweep(int p, int v, const Graph &g) {
  pair<Weight, int> r(0, v);
  for (auto e : g[v]) {
    if (e.dst != p) {
      pair<Weight, int> t = sweep(v, e.dst, g);
      t.first += e.weight;
      if (r.first < t.first) r = t;
    }
  }
  return r;
}

Weight double_sweep(const Graph &g, int s) {
  pair<Weight, int> r = sweep(-1, s, g);
  pair<Weight, int> t = sweep(-1, r.second, g);
  return t.first;  // (r.second, t.second) is farthest pair.
}

int main() {
  int n;
  while (cin >> n, n) {
    Graph g(n);
    vector<int> p(n - 1), d(n - 1);
    for (int i = 0; i < n - 1; ++i) {
      cin >> p[i];
      p[i]--;
    }
    int ans = 0;
    for (int i = 0; i < n - 1; ++i) {
      cin >> d[i];
      ans += 3 * d[i];
    }
    for (int i = 1; i < n; ++i) {
      g[i].emplace_back(i, p[i - 1], d[i - 1]);
      g[p[i - 1]].emplace_back(p[i - 1], i, d[i - 1]);
    }
    vector<int> f(n, 0);
    int s;
    for (int i = 0; i < n; ++i) {
      if (g[i].size() == 1) {
        ans -= 2 * g[i][0].weight;
        f[i] = 1;
      } else
        s = i;
    }
    Graph gg(n);
    for (int i = 1; i < n; ++i) {
      if (f[i] || f[p[i - 1]]) continue;
      gg[i].emplace_back(i, p[i - 1], d[i - 1]);
      gg[p[i - 1]].emplace_back(p[i - 1], i, d[i - 1]);
    }
    ans -= double_sweep(gg, s);
    cout << ans << endl;
  }
}


Measured memory_bytes: 3172
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>

#define Maxn 400010
#define LL long long

using namespace std;

inline LL read() {
    LL x = 0, f = 1;
    char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while('0' <= c && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

LL x, y, a, b, c, tot;

struct Node {
    LL val, col;
}
node[Maxn];

int cmp(Node fir, Node sec) {return fir.val > sec.val;}

int main() {
    x = read(); y = read(); a = read(); b = read(); c = read();
    for(int i = 1; i <= a; ++i) node[++tot].val = read(), node[tot].col = 1;
    for(int i = 1; i <= b; ++i) node[++tot].val = read(), node[tot].col = 2;
    for(int i = 1; i <= c; ++i) node[++tot].val = read(), node[tot].col = 3;
    sort(node + 1, node + tot + 1, cmp);
    int ad = 0, bd = 0, cd = 0; LL ans = 0;
    for(int i = 1; i <= tot; ++i) {
        if(node[i].col == 1 && ad < x) ++ad, ans += node[i].val;
        if(node[i].col == 2 && bd < y) ++bd, ans += node[i].val;
        if(node[i].col == 3) ++cd, ans += node[i].val;
        if(ad + bd + cd == x + y) break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6400
#include <iostream>
#include <algorithm>
using namespace std;
     
int main() {
    int N;
    cin >> N;
    char dir[N];
    int ans = 1145141919;
    int nans = 0;
    for (int i = 0;i < N;i++) {
        cin >> dir[i];
    }
    for (int i = 0;i < N;i++) {
        if (i == 0) {
            for (int j = 0;j < i;j++) {
              if (dir[j] == 'W') nans++;
            }
            for (int k = i+1;k < N;k++) {
                if (dir[k] == 'E') nans++;            }
            if (ans > nans) ans = nans;
       } else {
            if (dir[i] == 'E') nans--;
            if (dir[i-1] == 'W') nans++;
            if (ans > nans) ans = nans;
       }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.*;
import java.lang.Math;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x1 = sc.nextInt();
        int y1 = sc.nextInt();
        int x2 = sc.nextInt();
        int y2 = sc.nextInt();
        double x3 = x2 + ((x1-x2)*Math.cos(-Math.PI/2) - (y1-y2)*Math.sin(-Math.PI/2));
        double y3 = y2 + ((x1-x2)*Math.sin(-Math.PI/2) + (y1-y2)*Math.cos(-Math.PI/2));
        double x4 = x1 + ((x2-x1)*Math.cos(Math.PI/2) - (y2-y1)*Math.sin(Math.PI/2));
        double y4 = y1 + ((x2-x1)*Math.sin(Math.PI/2) + (y2-y1)*Math.cos(Math.PI/2));
        System.out.println((int)Math.rint(x3)+" "
                          +(int)Math.rint(y3)+" "
                          +(int)Math.rint(x4)+" "
                          +(int)Math.rint(y4));
        sc.close();
    }
}


Measured memory_bytes: 23124
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}
static const long long MOD_NUM = 1000000007LL;

static void C_task();

int main()
{
	C_task();
	fflush(stdout);
	return 0;
}

static void C_task()
{
	int N;
	get1int(N);

	auto B = new int[N];
	for (int i = 0; i < N - 1; i++) {
		get1int(B[i]);
	}

	auto A = new int[N];
	memset(A, 0, sizeof(int) * N);
	int ans = 0;
	A[0] = A[1] = B[0];
	for (int i = 1; i < N - 1; i++) {
		if (tp_max(A[i], A[i - 1]) < B[i]) {
			A[i + 1] = B[i];
		}
		else {
			A[i] = A[i + 1] = B[i];
		}
	}

	for (int i = 0; i < N; i++) {
		ans += A[i];
	}

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

	delete[] B;
	delete[] A;
}


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

ll k;
vector<ll> a;
bool ok(ll c){
    ll sum = 0;
    for(ll x:a){
        sum += (x-1)/c;
    }
    return sum<=k;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;cin>>n>>k;
    a = vector<ll>(n);
    rep(i,n)cin>>a[i];

    ll l = 0, r = 2000000000LL;
    while(l+1<r){
        ll c = (l+r)/2;
        //c以下にできるか
        if(ok(c))r=c;
        else l=c;
    }
    cout<<r<<endl;
    return 0;
}

Measured memory_bytes: 4696
#include <iostream>
#include <list>
#include <algorithm>
#include <map>
#include <math.h>
#include <set>
#include <string>
#include <algorithm>
#include <list>
#include <string.h>
#include <unordered_map>
#include <ctype.h>
#include <queue>
#include <numeric>
#include <vector>
#include <iomanip>
#include <cstdlib>
#include <stack>
#include <ctime>
#define  lld long long int
#define rep(i,start,end) for(lld i = start;i<end;i++)
#define newline cout << endl
#define fastio ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define in insert
#define mp make_pair
#define se second
#define fi first
#define starttime chrono::time_point<chrono::system_clock> start, end; start = chrono::system_clock::now()
#define showtime end = chrono::system_clock::now();  chrono::duration<double> elapsed_seconds = end - start; time_t end_time = chrono::system_clock::to_time_t(end); cout << "elapsed time: " << elapsed_seconds.count() << "s\n"
#define INF 1e17
lld MOD =  (lld)(1e9+7);
#define mh make heap
#define ph push_heap
#define poph pop_heap
#define openf   freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout);
using namespace std;
lld add(long long a, long long b){return ((a%MOD)+(b%MOD))%MOD;}
lld mul(long long a, long long b){return ((a%MOD)*(b%MOD))%MOD;}
lld sub(long long a, long long b){lld ans = ((a%MOD-b%MOD))%MOD; if(ans<0) ans += MOD; return ans;}
lld modInverse(lld a ){   lld m = MOD,m0 = m, y = 0, x = 1;  if (m == 1) return 0;   while (a > 1) {  lld q = a / m, t = m;  m = a % m, a = t, t = y;          y = x - q * y, x = t;   } if (x < 0)  x += m0; return x; } 
lld gcd(lld a, lld b){if (b == 0) return a; return gcd(b, a % b);}
void MAIN(lld i,lld t);
int get(){lld t;cin>>t; ; return t;}
int log(string name){cout<<name<<endl; return 0;}
void test(int t) { for(lld i = 0;i<t;i++){MAIN(i,t); cout <<endl;} }
lld power(lld x, lld y) { lld res = 1; x = x%MOD; if(x==0) return 0;   while (y > 0) {   if (y & 1)      res = (res*x)%MOD; y = y>>1; x = (x*x)%MOD;} return res; }
#define all(v) (v).begin(),(v).end()
lld popcount(lld x){return __builtin_popcount(x);}
lld lcm(lld a,lld b){ return (a*b)/gcd(a,b);}
lld n,x;
vector<lld> v;
void MAIN(lld current_test_case,lld total_test_cases){
    lld n; cin >> n;
    map<string,int> m;
    for(int i = 0;i<n;i++){
        string s; cin >> s; 
        m[s]++;}
    cout << "AC x " << m["AC"] << endl << "WA x " << m["WA"] << endl <<"TLE x " << m["TLE"] << endl << "RE x " << m["RE"] << endl;
}   
int main(){  
    fastio;
    #ifndef ONLINE_JUDGE 
     openf
    #endif
    test(1);
    return 0;
}


Measured memory_bytes: 3636
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let n : usize = get_one();
    let mut vs : Vec<Vec<usize>> = Vec::new();
    for i in 0..n {
        let v : Vec<char> = get_one::<String>().chars().collect();
        let mut vv : Vec<usize> = vec!(0;26);
        for c in v {
            vv[c as usize - 'a' as usize] += 1;
        }
        vs.push(vv);
    }

    //for v in &vs {
    //    println!("{:?}", v);
    //}
    let mut ans = String::new();
    for i in 0..26 {
        let mut x = 50;
        for v in &vs {
            x = std::cmp::min(x, v[i]);
        }
        for _j in 0..x {
            ans.push((('a' as u8) + i as u8) as char);
        }
        //println!("{:?}", ans);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352