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

using namespace std;

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

void Main(){
  int h,w;
  cin>>h>>w;
  char S[55][55];
  rep(j,1,w+1){
    rep(i,1,h+1)cin>>S[j][i];
  }

  int cnt=0;
  rep(j,1,h+1){
    rep(i,1,w+1){
      if (S[i][j] == '#' && S[i][j - 1] != '#' && S[i - 1][j] != '#' && S[i][j + 1] != '#' && S[i + 1][j] != '#') cnt++;
    }
  }

  if(0){
    rep(j,0,h){
      rep(i,0,w){
        cout<<S[j][i];
      }
      cout<<endl;
    }
  }

  cnt==0 ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  Main();
}

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


int main(){
    int K[35]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    printf("%d\n",K[k-1]);

    return 0;
}

Measured memory_bytes: 256
//By TheOneYouWant
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
// #define int unsigned long long int
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i=0;i<e;++i)
#define forsn(i,s,e) for(int i=s;i<e;++i)
#define rforn(i,s) for(int i=s;i>=0;--i)
#define rforsn(i,s,e) for(int i=s;i>=e;--i)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define ln '\n'
#define getcurrtime() cerr<<"Time = "<<((double)clock()/CLOCKS_PER_SEC)<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int mul1 = 1003, mul2 = 5, mul3 = 8;
const int MOD3 = 179424673, MOD2 = 982451653, MOD1 = 1190494759;
const ld EPS = 1e-9;
 
#include <bits/extc++.h>
using namespace __gnu_pbds;

int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=10*xx+ch-'0';ch=getchar();}
    return xx*ff;
}
 
ull hasher(ull a, ull b) {
    return 14831553208299411291ull * (a ^ 16184882973064831860ull) + b;
}
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int n;
const int LIM = 2e5+5;
string s[LIM];
gp_hash_table<ull, int> m;
 
int main(){
    fastio;
 
    cin>>n;
 
    ll ans = -n;
 
    forn(i,n){
        cin>>s[i];
        reverse(s[i].begin(), s[i].end()); 
        
        ull h1 = 0;
        forn(j,s[i].length()){
            h1 = hasher(h1, s[i][j]);
        }
        ++m[h1];
    }


    forn(i,n) {
        int num[26] = {0};
        forn(j,s[i].length()){
            ++num[s[i][j]-'a'];
        }

        ull h1 = 0;
        forn(j,s[i].length()){
            forn(k,26){
                if (num[k]) {
                    ull n1 = hasher(h1, k+'a');
                    
                    auto it = m.find(n1);
                    if (it != m.end())
                        ans += (*it).second;
                }
            }
            h1 = hasher(h1, s[i][j]);
            --num[s[i][j]-'a'];
        }
    }
 
    cout<<ans<<ln;
    return 0;
}


Measured memory_bytes: 27972
import java.util.Scanner;
import java.util.regex.Pattern;

public class Main {

    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        int n = Integer.parseInt(stdin.nextLine());
        long[] p = Pattern.compile(" ").splitAsStream(stdin.nextLine()).mapToLong(Long::parseLong).toArray();


        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                long[] q = p.clone();
                long temp = q[i];
                q[i] = q[j];
                q[j] = temp;
                if (isSorted(q)) echo("YES");
            }
        }
        echo(isSorted(p) ? "YES" : "NO");
    }

    private static boolean isSorted(long[] p) {
        for (int i = 0; i < p.length - 1; i++) {
            if (p[i] > p[i + 1]) return false;
        }
        return true;
    }

    private static void echo(String msg) {
        System.out.println(msg);
        System.exit(0);
    }

}

Measured memory_bytes: 27220
d, g = map(int, input().split())
p_c = [0] + [list(map(int, input().split())) for _ in range(d)]


def function(g, i):
    if i == 0:
        return 1e9
    n = min(g // (i * 100), p_c[i][0])
    s = n * i * 100
    if n == p_c[i][0]:
        s += p_c[i][1]
    if s < g:
        n += function(g-s, i-1)
    return min(n, function(g, i-1))


print(function(g, d))

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

int main()
{
  int n; cin >> n;
  vector<int> a(n);
  double ans=0;
  for(int i=0; i<n; i++){
    cin >> a[i];
    ans += 1.0/a[i];
  }

  cout << fixed << setprecision(10) << 1.0/ans << endl;  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#define go(i,a,b) for(int i=a;i<=b;i++)
#define og(i,a,b) for(int i=a;i>=b;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define Pi acos(-1)
#define eps 1e-8
using namespace std;
typedef long long int ll;
const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
int main()
{
    string a;
    cin>>a;
    int c=0,l=a.length();
    ll ans=0;
    for(int i=l-1;i>=0;i--)
    {
        if(a[i]=='B') ans+=c;
        else c++;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){
    double an=0,n,k,count;

    scanf("%lf %lf",&n,&k);
    for(int i=1;i<=n;i++){
        count=1;
        for(int t=i;t<k;t=t*2){
            count=count/2;
        }
        an=an+count/n;
    }
    printf("%.9f",an);
}

Measured memory_bytes: 128
#include<cstdio>
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
#include<vector>
#include<float.h>
#include<map>
#include<iomanip>
using  ll = long long;
using namespace std;
const ll M = 1000000007;

int main(){
  int h, w; cin >> h >> w;
  vector<string> s(h);
  for(int i = 0; i < h; i++){
    cin >> s[i];
  }

  int count = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(s[i][j] == '.'){
        count = 0;
        for(int k = max(0, i-1); k < min(h, i+2); k++){
          for(int l = max(0, j-1); l < min(w, j+2); l++){
            if(s[k][l] == '#'){
              count++;
            }
          }
          s[i][j] = count+'0';
        }
      }
    }
  }

  for(int i = 0; i < h; i++){
    cout << s[i] << endl;
  }
}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 998244353;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll dp[2][90010] = {};
ll dp2[2][90010] = {};
ll power(ll x, ll n){
    if(n == 0) return 1LL;
    ll res = power(x * x % MOD, n/2);
    if(n % 2 == 1) res = res * x % MOD;
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll a[310];
    rep(i,0,N) cin >> a[i];
    dp[0][0] = 1;
    ll sum = 0;
    rep(i,0,N) sum += a[i];
    ll cur = 0, nxt = 1;
    rep(i,0,N){
        rep(j,0,sum + 1){
            dp[nxt][j] = 0;
            if(j - a[i] >= 0) dp[nxt][j] += dp[cur][j - a[i]];
            (dp[nxt][j] += 2 * dp[cur][j]) %= MOD;
        }
        cur ^= 1;
        nxt ^= 1;
    }

    dp2[0][0] = 1;
    cur = 0, nxt = 1;
    rep(i,0,N){
        rep(j,0,sum+1){
            dp2[nxt][j] = 0;
            if(j - a[i] >= 0) dp2[nxt][j] += dp2[cur][j - a[i]];
            (dp2[nxt][j] += dp2[cur][j]) %= MOD;
        }
        cur ^= 1;
        nxt ^= 1;
    }

    ll ans = 0;
    rep(i,(sum+1)/2, sum+1){
        (ans += dp[cur][i]) %= MOD;
    }
    if(sum % 2 == 0){
        ans -= dp2[cur][sum/2];
        ans = (ans + MOD) % MOD;
    }
    ans *= 3;
    ans %= MOD;

    ans = (power(3,N) - ans + MOD) % MOD;
    print(ans);

}

Measured memory_bytes: 3072
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include<map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef unsigned int ui;
typedef unsigned short us;
typedef unsigned long long ull;

using namespace std;


int inputValue() {
  int a;
  scanf("%d", &a);
  return a;
};
void inputVector(vector<int>* v) {
  //cin.tie(0);
  //ios::sync_with_stdio(false);
  int a;
  while (cin >> a) {
    if (a == -1)break;
    v->push_back(a);
  }
};

void inputVector(vector<int> * p, int a) {
  p->clear();
  p->shrink_to_fit();
  rep(i, a) {
    int input;
    cin >> input;
    p->push_back(input);
  }
}

void inputVector2(vector<vector<int>>& v, ui r, ui c) {
  int temp;
  for (size_t i = 0; i < r; i++)
  {
    for (size_t j = 0; j < c; j++)
    {
      scanf("%d", &temp);
      v[i][j] = temp;
    }
  }
}
void inputVector3(vector<int>* v0, vector<int>* v1) {
  int a;
  unsigned short count = 0b0;
  while (cin >> a) {
    if (a == -1)break;
    if (count)v0->push_back(a); else v1->push_back(a);
    count = count ^ 1;
  }
};

template <typename T>
void output(T a, int precision) {
  if (precision > 0) {
    cout << setprecision(precision) << a << "\n";
  }
  else {
    cout << a << "\n";
  }
}

template<template <class...> class Map, typename T_0, typename T_1, typename... Args>
void inputMap(Map<T_0, T_1, Args...>& mp) {
  T_0 a;
  T_1 b;
  while (cin >> a && a != -1) {
    cin >> b;
    mp.insert(make_pair(a, b));
  }
}

template<template <class...> class Vec, typename T, typename U, typename... Args>
void numberToBoolenVector(Vec<T, Args...>& vec, U a) {
  ui i = 0;
  T amari;
  do {
    if (a % (ull)pow(2, i+1)) {
      amari = 1;
      vec.push_back(amari);
      a -= (ull)pow(2, i);
    }
    else {
      amari = 0;
      vec.push_back(amari);
    }
    i++;
  } while (a);
}

template<template <class...> class Vec, typename T, typename... Args>
ull boolenVectorToNumber(Vec<T, Args...>& vec) {
  ull r = 0;
  for (size_t i = 0; i < vec.size(); i++)
  {
    r += vec[i] * (ull)pow(2, i);
  }
  return r;
}

int main(int argc, const char * argv[]) {
  ull a;
  ull b;
  ui keta = 45;
  vector<bool> a2;
  vector<bool> b2;
  vector<bool> r2;
  
  ull r;
  scanf("%lld %lld", &a, &b);
  numberToBoolenVector(a2, a);
  numberToBoolenVector(b2, b);

  ll min_amari;
  ll max_amari;
  bool min_bool;
  bool max_bool;

  max_amari = (b + 1) % 4;
  min_amari = a % 4;
  min_bool = (min_amari >= 2);
  max_bool = (max_amari >= 2);
  r2.push_back(min_bool ^ max_bool);

  for (size_t i = 1; i < b2.size(); i++)
  {
    max_amari = (b + 1) % (ull)pow(2, i+1);
    min_amari = a % (ull)pow(2, i+1);
    min_bool = (min_amari >= (ull)pow(2, i) && min_amari%2);
    max_bool = (max_amari >= (ull)pow(2, i) && max_amari%2);
    r2.push_back(min_bool ^ max_bool);
  }

  r = boolenVectorToNumber(r2);
  printf("%lld", r);
  return 0;
}

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

int main() {
  vector<int> x(5);
  for (int& xi : x) {
    cin >> xi;
  }
  for (int i = 0; i < 5; ++i) {
    if (x[i] == 0) {
      cout << (i + 1);
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;

int main() {
	string S;
	cin >> S;
	map<string, int> d;
	d["SUN"] = 0;
	d["MON"] = 1;
	d["TUE"] = 2;
	d["WED"] = 3;
	d["THU"] = 4;
	d["FRI"] = 5;
	d["SAT"] = 6;
	cout << 7 - d[S] << endl;
}


Measured memory_bytes: 768
N, M, X, Y =map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
if X >= Y:
  print('War')
elif max(x) >= Y:
  print('War')
elif X >= min(y):
  print('War')
elif max(x) >= min(y):
  print('War')
else:
  print('No War')

Measured memory_bytes: 3064
n = int(input())
f = []
ans = -10**9

for i in range(n):
    a = "".join(input().split())
    a = int(a, 2)
    f.append(a)

p = [list(map(int, input().split())) for i in range(n)]

for i in range(1, 2**10):
    ref = 0
    for j in range(n):
        cnt = bin(i&f[j]).count("1")
        ref += p[j][cnt]
    else:
        ans = max(ans, ref)

print(ans)

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

public class Main {
    public static void main(String[] args) {
        Scanner std  = new Scanner(System.in);
        String s = std.next();
        String[] split = s.split("");
        long count = Arrays.stream(split).distinct().count();
        String rest = s.replaceAll(split[0], "");
        boolean isSame = rest.length() == 2;
        if (count == 2 && isSame) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26964
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc095/tasks/arc096_a

int main() {
    int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
    int ab = A*X+B*Y;
    int abc = (X>Y)?(C*2*Y+(X-Y)*A):(C*2*X+(Y-X)*B);
    int cc = C*2*(max(X, Y));
    int ans = min(cc, min(ab, abc));
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
N,M=[int(s) for s in input().split()]
WAls=[0 for _ in range(N)]
ACls=[0 for _ in range(N)]
wa=0
for i in range(M):
  a,b=input().split()
  a=int(a)-1
  if b=='AC':
    if ACls[a]==0:
      wa+=WAls[a]
      ACls[a]=1
  else:
    if ACls[a]==0:
      WAls[a]+=1
ans=[sum(ACls),wa]
print(*ans)


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

#ifdef TEST
struct test {
    int ans;
} td[] = {
    {},
};
#endif

void
solver(int a, int b)
{
    int i;
    double da, db;
    int s;

    da = (double)a / 0.08;
    db = (double)b / 0.10;

    if(da > db)
        s = (int)db;
    else {
        s = (int)da;
    }

    i = s;
    while(1) {
        if((int)((double)i * 0.08) == a && (int)((double)i * 0.1) == b) {
            printf("%d\n", i);
            return;
        }
        i++;
        if((int)((double)i * 0.08) > a && (int)((double)i * 0.1) > b)
            break;
    }

    printf("-1\n");
}

int
main(int argc, char *argv[])
{
#ifdef TEST
    int tt;
    for(tt = 0; tt < sizeof(td) / sizeof(struct test); tt++) {
        solver();
        printf("%d\n", td[tt].ans);
    }
#endif
    int A, B;
    scanf("%d %d", &A, &B);
    solver(A, B);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N;
int A[200005],B[200005];
signed main(){
	cin>>N;
	rep(i,N)cin>>A[i]>>B[i];
	sort(A,A+N);sort(B,B+N);
	if(N%2){
		cout<<B[N/2]-A[N/2]+1<<endl;
	}else {
		int mn=(A[N/2]+A[N/2-1]);
		int mx=(B[N/2]+B[N/2-1]);
		cout<<mx-mn+1<<endl;
	}
}


Measured memory_bytes: 6760
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
using namespace std;
typedef long long ll;

int main(){
    int n; cin>>n;
    if(n%2==0) cout<<n/2<<endl;
    else cout<<n/2+1<<endl;
}

Measured memory_bytes: 256
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;

struct Data{
    int A;
    string S;
    
    bool operator<( const Data& right ) const {
        return A == right.A ? S < right.S : A < right.A;
        //return A < right.A;
    }
};

int Func(){
    int x = 0;
    return x;
}

int main(){
    int N;
    string S, T;
    
    // 入力
    cin >> N;
    cin >> S;
    cin >> T;
    
    for (int i=0;i<N;i++) {
        cout << S[i];
        cout << T[i];
    }
    cout << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	int r, D, x;
	cin >> r >> D >> x;
	for(int i = 1; i <= 10; i++){
		x = x * r - D;
		cout << x << endl;
	}
	return 0;
}

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

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
#define all(v) (v).begin(), (v).end()
#define sz(v) (int) (v).size()

const int MAXN = 100005;

int main(int argc, char* argv[]) {
  ios::sync_with_stdio(0); cin.tie(0);
  // oh fuck v is small 
  int n, w;
  cin >> n >> w;
  vector<ll> a(n), b(n);
  for (int i = 0; i < n; i++)
    cin >> a[i] >> b[i];
  vector<ll> dp(MAXN + 1, 1e9 + 7);
  dp[b[0]] = a[0];
  for (int i = 1; i < n; i++) {
    vector<ll> new_dp = dp;
    for (int j = 0; j <= MAXN - b[i]; j++) 
      if (dp[j] + a[i] <= w) 
        new_dp[j + b[i]] = min(new_dp[j + b[i]], dp[j] + a[i]);
    swap(dp, new_dp);
    dp[b[i]] = min(dp[b[i]], a[i]);
  }
  int res = 0;
  for (int i = 0; i <= MAXN; i++)
    if (dp[i] <= w)
      res = i;
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 4772
#include "math.h"
#include <algorithm>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
#include <set>

#define ifor(i, a, b) for (int i = (a); i < (b); i++)
#define rfor(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long double ld;
typedef long long int lli;
typedef complex<double> P;
const double eps = 1e-11;
int vex[4] = {1, 0, -1, 0};
int vey[4] = {0, 1, 0, -1};
typedef vector<double> Vec;
typedef vector<int> vec;
typedef vector<Vec> MAT;
typedef vector<vec> mat;
lli MOD = 1000000007;
int main() {
    lli n,t;
    cin >> n >> t;
    lli a[100005];
    lli b[100005];
    lli c[100005];

    c[n] = 0;
    rep(i,n)cin >> a[i];

    b[0] =  a[0];
    rep(i,n-1)b[i+1] = min(b[i],a[i+1]);
    rrep(i,n)c[i] = max(c[i+1],a[i]);
    rep(i,n-1){
        cerr << b[i] << ' ' << c[i+1] << endl;
    }
    vector<pair<lli,pair<lli,lli>>> data;
    rep(i,n-1)data.push_back(make_pair(c[i+1]-b[i],make_pair(c[i+1],b[i])));
    sort(data.begin(),data.end());
    reverse(data.begin(),data.end());
    map<lli,lli> map1,map2;
    rep(i,n-1){
        if(data[0].first == data[i].first) {
            map1[data[i].second.first]++;
            map2[data[i].second.first]++;
        }else{
            break;
        }
    }
    cout << min(map1.size(),map2.size())<<endl;
}

Measured memory_bytes: 11752
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>


using namespace std;
#define INF 100100100100

#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,a,n) for(int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;
typedef pair<ll, ll> PI;

int main() 
{
    int n; cin >> n;
    vector<ll> v(n);

    rep(i,n) { cin >> v[i]; }
    
    ll ans = 0;
    for(auto a : v) { 
        ans += a-1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
public class Main{
  static int infi = 1000001;
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int t, n, k;
    int i, j, l, joint, sum, tmp;
    int[] x, d;

    t = sc.nextInt();
    for(i = 0;i < t;i++){
      n = sc.nextInt(); k = sc.nextInt();
      if(n <= k){
        for(j = 0;j < n;j++)tmp = sc.nextInt();
        out.println("0");
      }else{
        x = new int[n]; d = new int[n - 1];
        x[0] = sc.nextInt();
        for(j = 1;j < n;j++){
          x[j] = sc.nextInt();
          d[j - 1] = x[j] - x[j - 1];
        }
        joint = n - k; sum = 0;
        mergesort(d, 0, n - 1);

        for(j = 0;j < joint;j++)sum += d[j];
        out.println(sum);
      }
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static void mergesort(int[] x, int l, int r){
    int m, c;
    if(l + 1 >= r)return;
    else{
      m = (l + r) / 2;
      mergesort(x, l, m);
      mergesort(x, m, r);
      merge(x, l, m, r);
      return;
    }
  }
  private static void merge(int[] x, int l, int m, int r){
    int nl, nr, count;
    int i, j, k;
    int[] xl, xr;

    nl = m - l; nr = r - m;
    xl = new int[nl + 1]; xr = new int[nr + 1];
    for(i = 0;i < nl;i++)xl[i] = x[l + i];
    for(i = 0;i < nr;i++)xr[i] = x[m + i];
    xl[nl] = infi; xr[nr] = infi;

    i = 0;j = 0;count = 0;

    for(k = l;k < r;k++){
      if(xl[i] < xr[j])x[k] = xl[i++];
      else x[k] = xr[j++];
    }
    return;
  }
}

Measured memory_bytes: 152736
use std::io::Read;
use std::str::SplitWhitespace;
use std::str::FromStr;

pub fn read_stdin() -> String {
    let mut s = String::new();
    ::std::io::stdin().read_to_string(&mut s).unwrap();
    s
}

pub trait Parse<T> {
    fn parse(&mut self) -> T;
}

impl<'a, T> Parse<T> for SplitWhitespace<'a>
where
    T: FromStr,
{
    fn parse(&mut self) -> T {
        let word = self.next().unwrap();
        word.parse().ok().unwrap()
    }
}

fn main() {
    let source = read_stdin();
    let mut iter = source.split_whitespace();
    let n: u64 = iter.parse();
    let v: Vec<u64> = (0..5).map(|_| iter.parse()).collect();
    let min = v.into_iter().min().unwrap();

    println!("{}", (n + min - 1) / min + 4);
}

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

int main()
{
    int n; cin >> n;
    string s;
    map<string, int> abc;
    rep(i, n){
        cin >> s;
        abc[s]++;
    };

    cout << abc.size() << endl;
    return 0;
}


Measured memory_bytes: 19204
x = list(map(int,input().split()))
N = x[0]
X = x[1]
Y = x[2]

ans = [0] * N

for i in range(1,N+1):
    for j in range(i,N+1):
        k = min(abs(i-j),abs(X-i)+1+abs(j-Y),abs(Y-i)+1+abs(j-X))
        ans[k] += 1

[print(int(x)) for x in ans[1:]]

Measured memory_bytes: 3444
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include<set>
#include<bitset>
#include<stdio.h>
#include<deque>
#include<iomanip>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    ll a,b;
    cin >> a >> b;
    int ans = 0;
    while(1){
        if(a <= b){
            a *= 2;
            ans++;
        }
        else break;
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

int dist[25][105][105], cost[105][105];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  while(true) {
    int n, m, com, s, g;
    cin >> n >> m >> com >> s >> g;
    if(!n) break;
    REP(i, 25) REP(j, 105) REP(k, 105) dist[i][j][k] = j==k?0:INF;
    VI x(m), y(m), d(m), c(m);
    REP(i, m) {
      cin >> x[i] >> y[i] >> d[i] >> c[i];
      x[i]--, y[i]--, c[i]--;
      chmin(dist[c[i]][x[i]][y[i]], d[i]);
      chmin(dist[c[i]][y[i]][x[i]], d[i]);
    }
    VI p(com);
    REP(i, com) cin >> p[i];
    VVI q(com), r(com);
    REP(i, com) {
      q[i] = VI(p[i]-1), r[i] = VI(p[i]);
      REP(j, p[i]-1) cin >> q[i][j];
      REP(j, p[i]) cin >> r[i][j];
    }

    // 会社lで移動するときの最短距離をWFで求める
    REP(l, com) REP(k, n) REP(i, n) REP(j, n) {
      chmin(dist[l][i][j], dist[l][i][k] + dist[l][k][j]);
    }

    REP(i, 105) REP(j, 105) cost[i][j] = i==j?0:INF;
    REP(l, com) {
      // cout << "company:" << l << endl;
      // cout << p[l] << endl << q[l] << endl << r[l] << endl;
      REP(i, n) REP(j, n) {
        // 会社lで距離dist[i][j]を移動するときにかかる運賃
        int tmp = 0;
        REP(k, p[l]-1) {
          if(dist[l][i][j] < q[l][k]) {
            tmp += (dist[l][i][j] - (k==0?0:q[l][k-1])) * r[l][k];
            break;
          } else {
            tmp += (q[l][k] - (k==0?0:q[l][k-1])) * r[l][k];
          }
        }
        // cout << tmp << endl;
        if(p[l] == 1) {
          tmp = dist[l][i][j] * r[l][0];
        } else if(dist[l][i][j] > q[l].back()) {
          tmp += (dist[l][i][j] - q[l].back()) * r[l].back();
        }
        // cout << dist[l][i][j] << " " << tmp << endl;
        chmin(cost[i][j], tmp);
      }
    }

    // cout << "b" << endl;

    REP(k, n) REP(i, n) REP(j, n) chmin(cost[i][j], cost[i][k] + cost[k][j]);

    if(cost[s-1][g-1] >= INF) cout << -1 << endl;
    else cout << cost[s-1][g-1] << endl;
  }

  return 0;
}



Measured memory_bytes: 5544
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
  string a,b,c;
  cin>>a>>b>>c;
  char A=a[0]-0x20;
  char B=b[0]-0x20;
  char C=c[0]-0x20;
  cout<<A<<B<<C<<endl;
}

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

#define int long long int
#define mp make_pair
using namespace std;

int n;
vector <int> v[100002];
int dp[100002][4];
int fun(int pos1 , int pos2)
{
    if(pos1 == n){
        return 0;
    }
    if(dp[pos1][pos2] != -1){
        return dp[pos1][pos2];
    }
    for (int i = 0; i < 3; ++i) {
        if(i == 0){
            dp[pos1][i] = max(v[pos1][i] + fun(pos1 + 1 , 1) , v[pos1][i] + fun(pos1 + 1 , 2));
        }
        if(i == 1){
            dp[pos1][i] = max(v[pos1][i] + fun(pos1 + 1 , 0) , v[pos1][i] + fun(pos1 + 1 , 2));
        }
        if(i == 2){
            dp[pos1][i] = max(v[pos1][i] + fun(pos1 + 1 , 0 ) , v[pos1][i] + fun(pos1 + 1 , 1));
        }
    }
    return max(dp[pos1][pos2] , max(dp[pos1][pos2+1] , dp[pos1][pos2+2]));
}


int32_t main() {
    scanf("%lld", &n);
    int a,b,c;
    for (int i = 0; i < n; ++i) {
        dp[i][0] = dp[i][1] = dp[i][2] = -1;
    }
    for (int i = 0; i < n; ++i) {
        scanf("%lld", &a);
        scanf("%lld", &b);
        scanf("%lld", &c);
        v[i].push_back(a);
        v[i].push_back(b);
        v[i].push_back(c);
    }
    int ans = fun(0 ,0);
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 19712
import java.util.*;

public class Main {
    public static void main(String[] args) {
        int ans = 0;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        Integer[] p = new Integer[n];
        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }
        Arrays.sort(p);
        for (int i = 0; i < k; i++) {
            ans += p[i];
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 38952
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N, Y;
    cin >> N >> Y;
    for (ll i = 0; i <= N; ++i) {
        for (ll j = 0; i + j <= N; ++j) {
            ll k = N - i - j;
            if (i * 10000 + j * 5000 + k * 1000 == Y) {
                cout << i << ' ' << j << ' ' << k << endl;
                return 0;
            }
        }
    }
    cout << -1 << ' ' << -1 << ' ' << -1 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int h[10];
  int i,j,tmp;
  for(i=0;i<10;i++){
    scanf("%d",&h[i]);
  }
  for(i=0;i<3;i++){
    for(j=9;j>0;j--){
      if(h[j]>h[j-1]){
        tmp=h[j-1];
        h[j-1]=h[j];
        h[j]=tmp;
      }
    }
  }
  printf("%d\n%d\n%d\n",h[0],h[1],h[2]);
  return 0;
}

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

using namespace std;

typedef long long ll;
long long MOD = 1e9+7, LIM = 3e5;
vector<ll> fact(LIM), invfact(LIM);
long long ncr(long long n, long long c) {
  return (((fact[n] * invfact[c]) % MOD) * invfact[n-c]) % MOD;
}

ll inv(ll x) {
  ll x_b = x;
  ll ret = 1;
  ll pow = MOD - 2;
  while(pow) {
    if(pow % 2 == 1) ret = (ret * x) % MOD;
    x = (x * x) % MOD;
    pow /= 2;
  }
  assert((x_b * ret) % MOD == 1);
  return ret;
}

int main() {
  // Y: dp[i][j] (where grid[i][j] is a wall) is the number
  // of ways to get from (i, j) to (H, W) without passing
  // through any other walls on the way there.  It turns out
  // that dp[i][j] = #ways to get from (i, j) to (H, W) without
  // walls - sum over all walls that could be in the way of
  // the path (#ways to get from (i, j) to wall * dp[wall])
  cin.tie(0);
  cin.sync_with_stdio(0);
  
  // I love combinatorics in O(1) with moduli
  ll* inv = new ll[LIM] - 1; inv[1] = 1;
  for(int i = 2; i<LIM; ++i)
    inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD;

  fact[0] = 1;
  fact[1] = 1;
  invfact[0] = 1;
  invfact[1] = 1;
  for(int i = 2; i<LIM; ++i) {
    fact[i] = (fact[i-1] * i) % MOD;
    invfact[i] = (invfact[i-1] * inv[i]) % MOD;
  }

  int H, W, n; cin >> H >> W >> n;
  vector<pair<int, int> > walls(n);
  for(int i = 0; i<n; ++i) {
    cin >> walls[i].first >> walls[i].second;
  }
  pair<int, int> tl = {1, 1};
  walls.push_back(tl);

  sort(walls.rbegin(), walls.rend());
  long long dp[walls.size()];
  for(int i = 0; i<(int)walls.size(); ++i) {
    // Combinatorics: paths from (a, b) to (H, W) is the number
    // of paths with (H-a) downs and (W-b) rights, so the
    // number of ways is (H-a+W-b) choose (W-b).
    int a = walls[i].first;
    int b = walls[i].second;
    dp[i] = ncr(H-a+W-b, W-b);

    for(int j = 0; j<i; ++j) {
      // Due to the sort, only walls with index <i can block
      // wall i's path to the end
      if(walls[j].first >= walls[i].first && walls[j].second >= walls[i].second) {
        int c = walls[j].first;
        int d = walls[j].second;
        dp[i] = ((dp[i] - (dp[j] * ncr(c-a+d-b, d-b))%MOD)+MOD)%MOD;
      }
    }
  }

  cout << dp[walls.size()-1] << endl;
}


Measured memory_bytes: 7424
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
typedef long long ll;
const ll P = 1e9+7;
int N,A,B,C,D;
ll fact[1010];
ll dp[1010][1010];

ll ext_gcd(ll a, ll b, ll &x, ll &y){
    if(b == 0){
        x = 1;
        y = 0;
        return a;
    }
    ll nx, ny;
    ll g = ext_gcd(b, a%b, nx, ny);
    x = ny;
    y = nx - a/b*ny;
    return g;
}

ll inv(ll a){
    ll x, y;
    ext_gcd(a, P, x, y);
    while(x < 0) x += P;
    return x%P;
}

ll pow(ll a, int n){
    if(n == 0) return 1;
    if(n == 1) return a;
    if(n%2==1){
        return a*pow(a,n-1)%P;
    }
    else{
        ll b = pow(a,n/2);
        return b*b%P;
    }
}


int main(){
    cin >> N >> A >> B >> C >> D;
    fact[0] = fact[1] = 1;
    for(int i=2; i<1010; i++){
        fact[i] = fact[i-1]*i%P;
    }

    for(int x=0; x<=B-A; x++) dp[0][x] = 1;
    for(int m=0; m<=N; m++) {
        if(m%A == 0 && C <= m/A && m/A <= D){
            dp[m][0] = fact[m]*inv(pow(fact[A], m/A)*fact[m/A]%P)%P;
        }
    }
    for(int m=1; m<=N; m++){
        for(int x=1; x<=B-A; x++){
            dp[m][x] = dp[m][x-1];
            for(int y=C; y<=D; y++){
                if((A+x)*y > m) break;
                ll t = fact[m]*inv((fact[m-y*(A+x)]*pow(fact[A+x],y)%P)*fact[y]%P)%P;
                dp[m][x] += dp[m-y*(A+x)][x-1]*t%P;
                dp[m][x] %= P;
            }
        }
    }

/*
    for(int m=0; m<=N; m++){
        for(int x=0; x<=B-A; x++){
            cout << dp[m][x] << " ";
        }
        cout << endl;
    }
    */

    cout << dp[N][B-A] << endl;

    return 0;
}


Measured memory_bytes: 8192
import java.io.*;

public class Main {
	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try {
			String line = reader.readLine();
			double r = Double.parseDouble(line);
			System.out.printf("%.6f %.6f\n", (Math.PI * r * r), (2 * Math.PI * r));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

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



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

	string s;
	int x;
	list<int> l;
	int N; cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> s;
		if (s == "insert") {
			cin >> x;
			l.push_front(x);
		}
		else if (s == "deleteFirst") {
			l.pop_front();
		}
		else if (s == "deleteLast") {
			l.pop_back();
		}
		else {
			int n = l.size();
			cin >> x;
			int a = 0;
			for (int j = 0; j < n; j++) {
				int y = l.front();
				l.pop_front();
				if (x != y) {
					l.push_back(y);
				}
				else if (a == 1) {
					l.push_back(y);
				}
				else {
					a = 1;
				}
			}
		}
	}
	N = l.size();
	for (int i = N - 1; i >= 0; i--) {
		if (i == 0)cout << l.front() << endl;
		else cout << l.front() << " ";
		l.pop_front();
	}
}


Measured memory_bytes: 34420
import math
L=list(map(int,input().split()))
temp=0
count=0
for i in L:
    if i%2==0:
        temp+=1
if temp==0 or temp==2:
    #even is even
    for i in range(len(L)):
        if L[i]%2==0:
            L[i]+=1
            count+=1/2
    count//=1
    L.sort()
    count+=(L[1]-L[0])//2
    count+=(L[2]-L[1])
else:
    #even is odd
    for i in range(len(L)):
        if L[i]%2!=0:
            L[i]+=1
            count+=1/2
    count//=1
    L.sort()
    count+=(L[1]-L[0])//2
    count+=(L[2]-L[1])
print(math.ceil(count))



    

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int count = 0;
		int[] key = new int[n];
		for(int i = 1; i <=n; i++) {
			key[i-1] = i;
		}
		int judge1 = -1;
		int judge2 = Integer.MAX_VALUE;
		for(int i = 0; i < m; i++) {
			int temp1 = sc.nextInt();
			int temp2 = sc.nextInt();
			if(temp1 > judge1) {
				judge1 = temp1;
			}
			if(temp2 <judge2) {
				judge2 = temp2;
			}
		}
		for(int i = 0; i < n; i++) {
			if(key[i] >= judge1 && key[i] <= judge2) {
				count++;
			}
		}
		System.out.println(count);
	}
}

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

int main(){
	char a;
	cin >> a;
	if(a=='A'){
		cout << 'T' <<endl;
	}else if(a=='T'){
		cout << 'A' <<endl;
	}else if(a=='C'){
		cout << 'G' <<endl;
	}else if(a=='G'){
		cout << 'C' <<endl;
	}
	return 0;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {

string S;
  cin>>S;
  ll max=0;
  ll count=0;
  for(ll i=0;i<S.size();i++) {
if(count==0&&S[i]=='A') {
count++;
  continue;
}
    if(count>0) {
count++;
    }
    
    if(S[i]=='Z') {
max=count;
    }
  }
  
  cout<<max<<endl;
}
  
  

  
  
  
  
  


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    a--; b--; c--; d--;
    string s;
    cin >> s;
    int x, y;
    x = b;
    y = min(c, d);

    bool ok1 = false;
    for(int i = x; i <= y; i++){
        if (s[i-1] == '.' && s[i] == '.' && s[i+1] == '.') ok1 = true;
    }

    int u, v;
    u = a;
    v = max(c, d);
    bool ok2 = true;
    for(int i = u; i < v; i++){
        if (s[i] == '#' && s[i+1] == '#') ok2 = false;
    }

    if (!ok2){
        cout << "No" << endl;
    }
    else{
        if (c > d && !ok1) cout << "No" << endl;
        else cout << "Yes" << endl; 
    } 
    return 0;
}

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

alias real F;

F cross(F x1, F y1, F x2, F y2)
{
    return x1*y2-y1*x2;
}

void main()
{
    foreach(s;stdin.byLine())
    {
        auto m = s.split().map!(to!F);
        immutable x1=m[0], y1=m[1], x2=m[2], y2=m[3], x3=m[4], y3=m[5], xp=m[6], yp=m[7];
        immutable c1 = cross(x2-x1,y2-y1,xp-x1,yp-y1);
        immutable c2 = cross(x3-x2,y3-y2,xp-x2,yp-y2);
        immutable c3 = cross(x1-x3,y1-y3,xp-x3,yp-y3);
        writeln((c1>=0&&c2>=0&&c3>=0)||(c1<=0&&c2<=0&&c3<=0)?"YES":"NO");
    }
}

Measured memory_bytes: 1084
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll N = inl(), W = inl();
        vl w(N), v(N);
        vvl wv(4);
        vl w_ac(4);
        rep(i, N) {
            cin >> w[i] >> v[i];
            if (i == 0) wv[0].eb(v[0]), w_ac[0] = w[0];
            else {
                wv[w[i] - w[0]].eb(v[i]);
                w_ac[w[i] - w[0]] = w[i];
            }
        }
        rep(i, 4) sort(all(wv[i]), greater<>());
        vvl dp(4);
        rep(i, 4) {
            dp[i].eb(0);
            repone(j, wv[i].size()) {
                dp[i].eb(dp[i][j - 1] + wv[i][j - 1]);
            }
        }

        ll ans = 0;
        rep(i, wv[0].size() + 1) {
            rep(j, wv[1].size() + 1) {
                rep(k, wv[2].size() + 1) {
                    rep(l, wv[3].size() + 1) {
                        if (i * w_ac[0] + j * w_ac[1] + k * w_ac[2] + l * w_ac[3] > W) continue;
                        ans = max(ans, dp[0][i] + dp[1][j] + dp[2][k] + dp[3][l]);
                    }
                }
            }
        }
        cout << ans << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
import sys

n, *a = map(int, sys.stdin.read().split())

def main():
  s = sum(a)
  if s % 10: ans = s
  else: 
    m = min([101] + [x for x in a if x % 10])
    if m == 101: ans = 0
    else: ans = s - m
  print(ans)

if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(){

	string s;
	cin >> s;
	bool xp = false;
	bool xm = false;
	bool yp = false;
	bool ym = false;
	for(int i=0;i<s.size();i++){
		if( s[i] == 'N' ) yp = true;
		else if( s[i] == 'S' ) ym = true;
		else if( s[i] == 'E' ) xp = true;
		else if( s[i] == 'W' ) xm = true;
	}

	if( yp && ym && !xp && !xm ) cout << "Yes" << endl;
	else if( !yp && !ym && xp && xm ) cout << "Yes" << endl;
	else if( yp && ym && xp && xm ) cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

int main(){
  ll a,b,k;
  cin >> a >> b >> k;
  if(a<k){
    if(a+b<k){
      cout << 0 << ' ' << 0;
    }else{
      cout << 0 << ' ' << b+a-k;
    }
  }else{
    cout << a-k << ' ' << b;
  }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long int ll;
ll N1097 = 1000000007LL;

int H,N;
int A[10000], B[10000];
ll M[10001];

ll rec(int h){
    if(h<=0){
        return 0;
    }else if(M[h]!=-1){
        return M[h];
    }
    ll m = N1097;
    for(int i=0;i<N;i++){
        m = min(m, rec(h-A[i])+B[i]);
    }
    M[h] = m;
    return m;
}

int main(){
    cin >> H >> N;
    for(int i=0;i<N;i++){
        cin >> A[i] >> B[i];
    }
    for(int i=0;i<=H;i++){
        M[i] = -1;
    }
    cout << rec(H) << endl;
}


Measured memory_bytes: 768
using System;
using System.Collections.Generic;

class Program
{
    #region library
    static long n = 0;
    static long r = 0;
    static long c = 0;
    static long x = 0;
    static long y = 0;
    static string s = "";
    static string[] ss;
    static long sum = 0;
    static long cnt = 0;
    static long max = -1;
    static long min = 2147483647;
    static bool flg = false;
    static bool flg2 = false;
    static string alpha = "abcdefghijklmnopqrstuvwxyz";
    static long[] arr;
    static char[,] map;
    static long[,] imap;
    static string rl()
    {
        return Console.ReadLine();
    }
    static string[] rls()
    {
        return Console.ReadLine().Split();
    }
    static void wl(object obj = null)
    {
        Console.WriteLine(obj);
    }
    static void w(object obj)
    {
        Console.Write(obj);
    }
    static long Int(string s)
    {
        return long.Parse(s);
    }
    static void yes()
    {
        wl("YES");
    }
    static void no()
    {
        wl("NO");
    }
    static void Sum()
    {
        wl(sum);
    }
    static void Cnt()
    {
        wl(cnt);
    }
    static void setarray(long num = -1)
    {
        if (n == 0)
        {
            n = Int(rl());
        }
        arr = new long[n];
        if (num == -1) ss = rls();
        for (int i = 0; i < n; i++)
        {
            if (num == -1)
                arr[i] = Int(ss[i]);
            else
                arr[i] = num;
        }
    }
    static void setmap(char def = '@')
    {
        if (r == 0 && c == 0)
        {
            ss = rls();
            r = Int(ss[0]);
            c = Int(ss[1]);
        }
        map = new char[r, c];
        for (int i = 0; i < r; i++)
        {
            if (def == '@') s = rl();
            for (int j = 0; j < c; j++)
            {
                map[i, j] = (def == '@') ? s[j] : def;
            }
        }
    }
    static void setimap(long def = -1)
    {
        if (r == 0 && c == 0)
        {
            ss = rls();
            r = Int(ss[0]);
            c = Int(ss[1]);
        }
        imap = new long[r, c];
        for (int i = 0; i < r; i++)
        {
            if (def == -1) s = rl();
            for (int j = 0; j < c; j++)
            {
                imap[i, j] = (def == -1) ? Int(s[j].ToString()) : def;
            }
        }
    }
    #endregion

    static void Main(string[] args)
    {
        n = Int(rl());
        s = rl();
        if(n < 3200)
        {
            wl("red");
        }
        else
        {
            wl(s);
        }
    }
        

}



Measured memory_bytes: 11092