akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) res = res * x % mod;
	return res;
}

int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	ll ans = 0;
	int before = min(a + b, 2 * c);
	if (x <= y) {
		ans += before * x;
		int after = min(b, 2 * c);
		ans += after * (y - x);
	}
	else {
		ans += before * y;
		int after = min(a, 2 * c);
		ans += after * (x - y);
	}
	cout << ans << endl;
	return 0;
}

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



int main() {
    int r, g, b;
    cin >> r >> g >> b;
    
    if ((100 * r + 10 * g + b) % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int a, b;
  scanf("%d%d", &a, &b);
  int ans = -1;
  for (int i=0; i<=1000; i++) {
    if ((i*8)/100 == a && (i*10)/100 == b) {
      ans = i;
      break;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
mod = 1000000007
mx = max(a)
lst = [3] + [0] * mx
ans = 1
for x in a:
  ans = ans * lst[x] % mod
  lst[x] -= 1
  if x < mx:
    lst[x+1] += 1
print(ans)

Measured memory_bytes: 14276
n=int(input())
a=list(map(int,input().split()))
sm=sum(a)
num=[0]*10**5
for i in a:
    num[i-1] += 1
q=int(input())
l=[]
for _ in range(q):
    l.append(tuple(map(int,input().split())))
for i in range(q):
    b,c=l[i]
    nm=num[b-1]
    sm += (c-b)*nm
    print(sm)
    num[b-1]=0
    num[c-1] += nm

Measured memory_bytes: 28176
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#define mod 1000000007
#define ten5 100005
#define PI 3.1415926
using namespace std;

int num[26];

int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,n1=0,n2=0,n3;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=1,now=1;
    long long int a,a1,a2,a3,a4;
    //float f,g,h;
    //char now,pre;
    string s,s1;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a1>>a2;
        sum+=a2-a1+1;
    }
    cout<<sum;
    return 0;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n=int(input())
s=[input().strip() for _ in range(n)]
from collections import Counter
s=Counter(s).most_common()
a=s[0][1]
ans=[]
for w,k in s:
    if k==a:
        ans.append(w)
ans.sort()
for a in ans:
    print(a)


Measured memory_bytes: 111244
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdint.h>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

vector<bool> is_prime;
vector<bool> is_prime_small;

// エラトステネスの篩 O(n log log n)
vector<ll> sieve(ll n) {
  is_prime.resize(0);
  for (int i = 0; i <= n; i++) {
    is_prime.push_back(true);
  }
  is_prime[0] = is_prime[1] = false;
  vector<ll> prime;
  for (int i = 2; i <= n; i++) {
    if (is_prime[i]) {
      prime.push_back(i);
      for (int j = 2 * i; j <= n; j += i) {
        is_prime[j] = false;
      }
    }
  }
  return prime;
}

// [a, b)の整数に対して篩を行う。is_prime[i - a] = true ⇔ iが素数
void segment_sieve(ll a, ll b) {
  is_prime_small.resize(0);
  for (ll i = 0; i * i < b; i++) {
    is_prime_small.push_back(true);
  }
  is_prime.resize(0);
  for (ll i = 0; i < b - a; i++) {
    is_prime.push_back(true);
  }

  is_prime_small[1] = false;
  if (a == 1) {
    is_prime[0] = false;
  }
  for (ll i = 2; i * i < b; i++) {
    if (is_prime_small[i]) {
      for (ll j = 2 * i; j * j < b; j += i) {
        is_prime_small[j] = false;
      }
      for (ll j = max(2LL, (a + i - 1) / i) * i; j < b; j += i) {
        is_prime[j - a] = false;
      }
    }
  }
}

int main() {
  ll N;
  cin >> N;
  auto v = sieve(N + 2);
  ll count = 0;
  REP(i, v.size() - 1) {
    if (v[i + 1] - v[i] == 2) {
      count++;
    }
  }
  std::cout << 2 * count << std::endl;
}



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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i< n; i++){
  	cin >> h.at(i);
  }
  vector<int> dp(n);
  dp.at(0) = 0;
  int temp;
  for (int i = 1; i < n; i++){
  	temp = 1000000000;
    for (int j = 0; j < min(i, k); j++){
      temp = min(temp, dp.at(i-j-1) + abs(h.at(i) - h.at(i-j-1)));
    }
    dp.at(i) = temp;
  }
  cout << dp.at(n-1) << endl;
}

Measured memory_bytes: 1024
import java.util.*;
import java.lang.*;
 
 //O(100000000)
public class Main {
    public static void main(String[] args) {

        Scanner sc  = new Scanner(System.in);
        long N = Long.parseLong(sc.next());
        long A = Long.parseLong(sc.next());
        long B = Long.parseLong(sc.next());
        
        long ans = N * A ;
        
        long a = Math.min( ans , B );
        
        System.out.print(a);
        System.out.println();
    }

}



Measured memory_bytes: 24916
#include<bits/stdc++.h>
using namespace std;
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>

int a[4];
const int tar[4] = {1, 4, 7, 9};

int main() {
	
	for (int i = 0; i < 4; i++)
		scanf("%d", a + i);
	
	sort(a, a + 4);
	
	bool cool = true;
	
	for (int i = 0; i < 4; i++) {
		cool &= a[i] == tar[i];
	}
	
	printf("%s\n", cool ? "YES" : "NO");
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include <bits/stdc++.h>
#include <vector> 
#include <algorithm> 
#include <string>
#include <cmath>
#include <iomanip> 
#include<climits> 
#include <utility>      
#include <numeric> 
#include <iterator>
#include <map> 
using namespace std; 
#define ll long long int
int main()
{
  int a,b;
    cin>>a>>b;
  cout<<6-a-b<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
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;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 300010;

int main(){
    int n;
    scanf("%d", &n);
    if(n == 0 || n == 2) printf("%d\n", 1);
    else if(n == 1) printf("%d\n", 2);
    else printf("%d\n", 0);
}


Measured memory_bytes: 3232
/*痛みを受け取れ，痛みを知れ*/
#include<bits/stdc++.h>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;
const int N = 5e5 + 5;
int a[N];
int main()
{
	//freopen("in.txt", "r", stdin);
	int n;
	while (cin >> n)
	{
		f(i, 1, n)scanf("%d", &a[i]);
		int ans = 0;
		for (int i = 1;i <= n;i++)
		{
			f(j, i + 1, n)
			{
				f(k, j + 1, n)
				{
					vector<int> v;
					v.emplace_back(a[i]);
					v.emplace_back(a[j]);
					v.emplace_back(a[k]);
					sort(v.begin(), v.end());
					if (v[0] == v[1] || v[1] == v[2])continue;
					if (v[0] + v[1] > v[2])
					{
						//debug(v[0]), debug(v[1]),debug(v[2]);
						ans++;
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
};

Measured memory_bytes: 3704
#AGC014-B Unplanned Queries
"""
今回は各辺の偶奇のみを考えるので、
根付き木を考えた時に、頂点a,bから親側に全部流した時に、
LCAより先は勝手に偶数になるので無視できる。
とした場合に、根をrootとして、各クエリに対して
a-root,b-rootへのパスに1を足すことと考えると、
結局各辺の偶奇はaとbの出現回数の偶奇によると考える事ができる。
よって、クエリに与えられる辺の回数をdictで保持し、
最終的に一つでも奇数回出現する頂点があるならばFalse
そうでないならTrueとなる

"""
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,m = map(int,readline().split())
dic1 = defaultdict(int)
for i in range(m):
    a,b = map(int,readline().split())
    dic1[a] += 1
    dic1[b] += 1

for i in dic1.values():
    if not even(i):
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 47964
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------
def gcd(a,b):
    return a if b == 0 else gcd(b,a%b)

# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
A = list(map(int,input().split()))

ans = A[0]
for i in range(1,N):
    ans = gcd(ans,A[i])
 
print(ans)

Measured memory_bytes: 14168
require 'pp'

def gets; ARGF.gets; end

class Solver

  def initialize
  end

  def main
    n, m = gets.chomp.split.map(&:to_i)

    puts "#{(n - 1) * (m - 1)}"
  end
end

if __FILE__ == $0
  Solver.new.main
end


Measured memory_bytes: 2172
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,i;
    cin>>a;cin>>b;cin>>c;
    for(i=100;0<c;i--){
        if(!(a%i)&&!(b%i)){
            c--;
        }
    }
    cout<<i+1;
    
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
5
0 3 2 3 3 1 1 2
1 2 0 2 3 4
2 3 0 3 3 1 4 1
3 4 2 1 0 1 1 4 4 3
4 2 2 1 3 3

output:
0 0
1 2
2 2
3 1
4 3
"""

import sys
import heapq as hp

WHITE, GRAY, BLACK = 0, 1, 2
D_MAX = int(5e10 + 1)


def generate_adj_matrix(v_info):
    for each in v_info:
        v_index, v_adj_length, *v_adj_list = map(int, each)
        # assert len(v_adj_list) == v_adj_length * 2
        for pair in zip(v_adj_list[::2], v_adj_list[1::2]):
            init_adj_matrix[v_index][pair[0]] = pair[1]

    return init_adj_matrix


def dijkstra_path():
    # path search init
    path_list[init_vertex_index] = 0
    path_heap = []
    # heapq: rank by tuple[0], here ranked by d[u]
    hp.heappush(path_heap, (0, init_vertex_index))
    while len(path_heap) >= 1:
        current_vertex_index = hp.heappop(path_heap)[1]

        color[current_vertex_index] = BLACK

        current_vertex_index_info = adj_table[current_vertex_index]
        for adj_vertex_index in current_vertex_index_info.keys():
            current_adj_weight = current_vertex_index_info.get(adj_vertex_index)
            if color[adj_vertex_index] is not BLACK:
                # alt: d[u] + w[u,v]
                alt_path = path_list[current_vertex_index] + current_adj_weight
                if alt_path < path_list[adj_vertex_index]:
                    # update path_list
                    path_list[adj_vertex_index] = alt_path
                    # update heap
                    hp.heappush(path_heap, (alt_path, adj_vertex_index))
                    parent_list[adj_vertex_index] = current_vertex_index
                    color[adj_vertex_index] = GRAY

    return path_list


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices_num = int(_input[0])
    init_vertices_table = map(lambda x: x.split(), _input[1:])
    # assert len(init_vertices_table) == vertices_num

    parent_list, path_list = [-1] * vertices_num, [D_MAX] * vertices_num
    color = [WHITE] * vertices_num
    init_adj_matrix = tuple(dict() for _ in range(vertices_num))
    init_vertex_index = 0

    adj_table = generate_adj_matrix(init_vertices_table)
    ans = dijkstra_path()
    for i, v in enumerate(ans):
        print(i, v)

Measured memory_bytes: 62836
#include<bits/stdc++.h>
 
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)
 
using namespace std;
 
struct Point { double x,y; };
typedef pair<double,double> Segment;
const int MAX_N = 2010;
const int IINF = INT_MAX;
int N;
double sx[MAX_N],sy[MAX_N],ex[MAX_N],ey[MAX_N],L,R;
 
inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }
inline bool inside(double a,double b,double c) { return LTE(a,c) && LTE(c,b); }
inline double getDist(double x,double y) { return sqrt(x*x+y*y); }
 
int main(){
  scanf("%d",&N);
  vector<Segment> segs(N);
  rep(i,N) {
    scanf("%lf %lf %lf %lf",sx+i,sy+i,ex+i,ey+i);
    vector<Point> vec(4);
    vec[0] = (Point){sx[i],sy[i]};
    vec[1] = (Point){sx[i],ey[i]};
    vec[2] = (Point){ex[i],sy[i]};
    vec[3] = (Point){ex[i],ey[i]};
    segs[i] = Segment(IINF,-IINF);
    rep(j,4){
      double arg = atan2(vec[j].y,vec[j].x) * 180 / M_PI;
      if( LT(arg,0.0) ) arg += 360;
      if( sx[i] > 0 && sy[i] < 0 && ey[i] >= 0 ) {
        if( LTE(0.0,arg) && LTE(arg,91.0) ) arg += 360;
      } 
      segs[i].first  = min(segs[i].first ,arg);
      segs[i].second = max(segs[i].second,arg);
    }
  }
 
  sort(segs.begin(),segs.end());
  rep(i,N) segs.push_back(Segment(segs[i].first+360,segs[i].second+360));
  int ans = N;
  rep(i,N){
    int cost = 0;
    REP(j,i,i+N){
      ++cost;
      L = segs[j].first, R = segs[j].second;
      while( j+1 < i+N && ( inside(L,R,segs[j+1].first) || inside(L,R,segs[j+1].second) ) ){
        L = max(L,segs[++j].first);
        R = min(R,segs[j].second);
      }
    }
    ans = min(ans,cost);
    }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 1444
#include <iostream>
#include <vector>
#include <cmath>
typedef unsigned long long ll;
using namespace std;

int main(void) {
    int N; cin >> N;
    ll L[90];
    
    L[0] = 2;
    L[1] = 1;
    for(int i = 2; i <= N; i++) L[i] = L[i-2] + L[i-1];
    cout << L[N] << endl;
    return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

using ii = pair<int, ll>;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vi h(n), a(n);
  trav(i, h) cin >> i;
  trav(i, a) cin >> i;

  set<ii> best;
  best.insert({0, 0});
  rep(i, 0, n) {
    /*
    cout << "Hi: " << endl;
    cout << "Before adding: " << endl;
    trav(elem, best) cout << elem.first << " " << elem.second << endl;
    */
    auto pit = --best.upper_bound({h[i], 0});
    int ph; ll pval;
    tie(ph, pval) = *pit;
    auto possible = ii{h[i], pval + a[i]};
    set<ii>::iterator it; bool added;
    tie(it, added) = best.insert(possible); assert(added);
    /*
    cout << "After adding: " << endl;
    trav(elem, best)  cout << elem.first << " " << elem.second << endl;
    */
    if (it != begin(best) and prev(it) -> second >= it -> second) {
      // cout << "Redundant Prev: " << prev(it) -> first << " " << prev(it) -> second << endl;
      best.erase(it);
    } else {
      while (next(it) != end(best) and it -> second >= next(it) -> second) {
	// cout << "Redundant Next: " << next(it) -> first << " " << next(it) -> second << endl;
	best.erase(next(it));
      }
    }
  }
  auto res = 0LL;
  trav(elem, best) {
    res = max(res, elem.second);
  }
  cout << res << '\n';
}


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

#include <iostream>
using namespace std;
int main() {
  uint64_t x;
  cin >> x;
  uint64_t year = 0;
  uint64_t total = 100;
  while (true) {
    if (total >= x) {
      break;
    } else {
      total *= 1.01;
      year++;
    }
  }
  cout << year << endl;
  return 0;
}


Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }


int main() {
    int a, b;
    cin >> a >> b;
    if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
        cout << "Possible" << ln;
    else
    {
        cout << "Impossible" << ln;
    }
    
}
    

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

int main(){

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

  bool isApp = true;
  for(int i = 0; i < n;i++){
    if(A[i] % 2 == 0 && (A[i] % 3 != 0 && A[i] % 5 != 0)){
      isApp = false;
      break;
    }
  }

  if(isApp) cout << "APPROVED";
  else cout << "DENIED";

  cout << endl;


  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a[3],b[3],c[3][3],i,j;
  for(i=0;i<3;i++)
    for(j=0;j<3;j++)
      scanf("%d",&c[i][j]);
  a[0]=c[0][0];
  a[1]=c[1][0];
  a[2]=c[2][0];
  if(c[0][1]-a[0]==c[1][1]-a[1]&&c[0][1]-a[0]==c[2][1]-a[2]&&c[0][2]-a[0]==c[1][2]-a[1]&&c[0][2]-a[0]==c[2][2]-a[2])
    printf("Yes\n");
  else
    printf("No\n");
}

Measured memory_bytes: 128
s =input()
a=int(s[:2])
b=int(s[2:])
if a>0 and a<=12:
    if b>0 and b<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if b>0 and b<=12:
        print('YYMM')
    else:
        print('NA')

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
int main()
{
    int A,B;
    char b[10];
    char c[10];
    char d[10];
    scanf("%s %s",b,c);
    scanf("%d %d",&A,&B);
    scanf("%s",d);
    if(strcmp(b,d)==0)
        printf("%d %d",A-1,B);
    if (strcmp(c,d)==0) {
        printf("%d %d",A,B-1);
    }
    
    
    
    
    return  0;
}


Measured memory_bytes: 128
N,A,B,C,D = list(map(int,input().split()))
S = input()

if C==D:
    print("No")
elif C<D:
    count = 0
    flg=True
    for i in range(B,D):
        if S[i]=="#":
            count+=1
        else:
            count=0
        if count>=2:
            flg=False
            break
    count=0
    for i in range(A,C):
        if S[i]=="#":
            count+=1
        else:
            count=0
        if count>=2:
            flg=False
            break

    if flg:
        print("Yes")
    else:
        print("No")
else:
    count = 0
    flg=True
    for i in range(B,D):
        if S[i]=="#":
            count+=1
        else:
            count=0
        if count>=2:
            flg=False
            break
    count=0
    count2 = 0
    flg2=False
    for i in range(A,C):
        if S[i]=="#":
            count+=1
        else:
            count=0
        if count>=2:
            flg=False
            break
        if i>=B-2 and i<=D:
            if S[i]==".":
                count2+=1
            else:
                count2=0
            if count2>=3:
                flg2=True
    if flg and flg2:
        print("Yes")
    else:
        print("No")
        

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

using namespace std;

int main(void){
	int N;
	cin >> N;
	vector<int> D(N);
	rep(i,N)cin >> D[i];
	sort(ALL(D));
	vector<int> c(25);
	c[0]++;
	rep(i,N){
		if(i%2==0){
			c[D[i]]++;
		}else{
			c[(24-D[i])%24]++;
		}
	}
	rep(i,24){
		if(c[i]>=2){
			cout << 0 << endl;
			return 0;
		}
	}
	int ans = 24;
	rep(i,24)rep(j,24){
		if(i==j)continue;
		if(c[i]&&c[j]){
			int dis = min(abs(i-j),min(24-i+j,24-j+i));
			ans = min(ans,dis);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100

void swap(int *, int *);
 
int main(void){

  int i,j,n,a[N],m,c=0;

  scanf("%d", &n);

 for(i=0; i < n; i++){
 scanf("%d", &a[i]);
}
  for(i=0; i < n; i++){
    m = i;
     
    for(j=i; j < n; j++){
      if(a[j] < a[m]) m = j;
    }
     
    if(i != m){
      swap(&a[i], &a[m]);
      c++;
    }
    printf("%d", a[i]);
    if(i < n-1) printf(" ");  
  }
 
 
 printf("\n%d\n", c);
 return 0;

 }
 
void swap(int *a, int *b){

  int temp;

  temp = *a;
  *a = *b;
  *b= temp;
}

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

int main() {
	int N, T, A;
	cin >> N >> T >> A;
	int H[N];
	for (int i=0;i<N;i++) {
		cin >> H[i];
	}

	int min = 2000000000;
	int min_index = 0;
	for (int i=0;i<N;i++) {
		if (abs(1000*T-6*H[i]-1000*A)<min) {
			min_index = i;
			min = abs(1000*T-6*H[i]-1000*A);
		}
	}
	cout << min_index+1 << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long X = sc.nextLong();
        long P = 100;
        int cnt = 0;
        while(P < X){
            P += P/100;
            cnt++;
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 35772
from collections import deque
S=deque(input())
Q=int(input())
rev=False
for i in range(Q):
    A=input().split()
    if A[0]=="1":
        if rev==False:rev=True
        else:rev=False
    else:
        if rev==False:
            if A[1]=="1":
                S.appendleft(A[2])
            else:
                S.append(A[2])
        else:
            if A[1]=="1":
                S.append(A[2])
            else:
                S.appendleft(A[2])
if rev:
    S.reverse()
print(*S,sep="")

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

int n, k;
std::string s;

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> k >> s;
	if (k > 16) {
		std::cout << std::string(n, *std::min_element(s.begin(), s.end())) << '\n';
	} else {
		std::string t = s;
		s = s + std::string(s.rbegin(), s.rend());
		for (int i = 0; i <= n; ++i) t = std::min(t, s.substr(i, n));
		int L = t.find_first_not_of(t[0]), R = std::min(L << k - 1, n);
		std::cout << std::string(R, t[0]) << t.substr(L, n - R) << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N,M = inpl()
aa = inpl()
for i in range(N):
	aa[i] -= 1

yama_height = [0]*(2*M)
yama_num = [0]*(2*M)
SUM = 0
for i in range(1,N):
	na = aa[i]
	ba = aa[i-1]
	if na < ba:
		na += M
	SUM += (na-ba)
	yama_height[na] += na - (ba + 1)
	yama_num[na] -= 1
	yama_num[ba+1] += 1

tmp = 0
for i in range(2*M):
	tmp += yama_num[i]
	yama_num[i] = tmp

ans_list = [0]*(M)
tmp = 0
for i in reversed(range(2*M)):
	tmp += yama_height[i]
	tmp -= yama_num[i]
	ans_list[i%M] += tmp

print(SUM-max(ans_list))


Measured memory_bytes: 25292
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
	cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	cout << head;
	if (sizeof...(tail) != 0) cout << " ";
	print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
	for (auto& a : vec) {
		cout << a;
		if (&a != &vec.back()) cout << " ";
	}
	cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
	for (auto& vec : df) {
		print(vec);
	}
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int n;
	cin >> n;
	vector<i64> a(n);
	for (auto& v : a)
	{
		cin >> v;
	}

	int ans = 0;
	while (true)
	{
		REP(i, n)
		{
			if (a[i] % 2 == 0)
				a[i] /= 2;
			else
			{
				print(ans);
				return 0;
			}
		}
		ans++;
	}
	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
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; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int a[2002];

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n,x,y;
    cin >> n >> x >> y;
    rep(i,n)cin >> a[i];
    int ans = abs(a[n-1] - y);
    if(n>1)chmax(ans,abs(a[n-2]-a[n-1]));
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

ll getC(vl a, vl b){
  ll ans = 0;
  rp(i,sz(a)) if(a[i] == b[i] && a[i] == 1) ans++;
  return ans;
}

vl getV(ll x){
  vl temp;
  while(sz(temp) <= 10){
    temp.pb(x%2);
    x /=2;
  }
  return temp;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    cin >> n;
    vector<vl> f;
    ll temp;
    rp(i,n){
      vl temp1;
      rp(j,10){
        cin >> temp;
        temp1.pb(temp);
      }
      f.pb(temp1);
    }
    ll p[n][10];
    rp(i,n){
      rp(j,11)
        cin >> p[i][j];
    }
    ll ans;
    rep(i,1,1<<10){
      ll curSum = 0;
      vl cur = getV(i);
      rp(j,n){
        curSum += p[j][getC(cur,f[j])];
      }
      if(i == 1) ans = curSum;
      else if(ans < curSum) ans = curSum;
    }

    cout << ans << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>
#include <algorithm>

using namespace std;

int n;
int a[5005];
int nx[5005][5005];
int dp[5005][5005];
unordered_map<int, int> mp;

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	sort(a+1, a+n+1);
	
	if(n <= 2){
		cout << n << endl;
		return 0;
	}
	
	for(int i = 1; i <= n; i++) mp[a[i]] = i;
	
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(j >= i) continue;
			if(mp.count(a[i] + a[i]-a[j])) nx[i][j] = mp[a[i]+a[i]-a[j]];
		}
	}
	
	for(int i = 2; i <= n; i++){
		for(int j = 1; j < i; j++){
			if(nx[i][j]) dp[nx[i][j]][i] = dp[i][j] + 1;
		}
	}
	
	int ans = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j < i; j++){
			ans = max(ans, dp[i][j]);
		}
	}
	cout << ans+2 << endl;
	return 0;
}


Measured memory_bytes: 92132
x,n=map(int,input().split())

if n==0:
    print(x)
else:
    p=list(map(int,input().split()))
    min=1000000000000000
    ans=0
    for i in range(102):
        if i not in p and abs(x-i) < min:
            min = abs(x-i)
            ans = i
    print(ans)


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

int main(void){
    int N=0, L=0;
    int i;
    cin >> N >> L;

    int apple_taste[N+1];
    apple_taste[0] = (int)NULL;
    for(i = 1; i < N+1; i++){
        apple_taste[i] = L + i - 1;
    }
    int abs_min = 2e9;
    int abs_min_index;
    
    for(i = 1; i < N+1; i++){
        if(abs(apple_taste[i]) < abs_min){
            abs_min_index = i;
            abs_min = abs(apple_taste[i]);
        }
    }
    int apple_pie_taste = 0;
    for(i = 1; i < N+1; i++){
        if(i != abs_min_index){
            apple_pie_taste += apple_taste[i];
        }
    }
    cout << apple_pie_taste << endl;
}


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

int main() {
  ll a,b,c; cin >> a >> b >> c;
  ll d=c-a-b;
  if(d>0 && d*d>4*a*b) cout << "Yes" << endl;
  else cout << "No" << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		if ((long) 4 * a * b < (long) (c - a - b) * (c - a - b) && c - a - b > 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


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

int main(){
vector<int> a(101);
vector<int> b(51);
int N,M,i;

cin>>N>>M;

for(i=0;i<M*2;i++){
    cin>>a.at(i);
}
for(i=0;i<M*2;i++){
  if(b.at(a.at(i))==0){
    for(int j=0;j<M*2;j++){   
        if(a.at(i)==a.at(j)){    
            b.at(a.at(i))++;
        }
    }
  }
}

for(i=1;i<=N;i++){
  cout<<b.at(i)<<endl; 
}

}



Measured memory_bytes: 256
#include <stdio.h>
#define M 100001
#define N 200000
#define INFTY 1000000000
long long c;

void merge(int A[], int left, int mid, int right) //merge で統治
{
  int n1, n2, L[M], R[M];
  int i, j, k;
  n1=mid-left;
  n2=right-mid;
  //L[0...n1], R[0...n2] を生成
  for(i=0; i<n1; i++) L[i]=A[left+i];
  for(i=0; i<n2; i++) R[i]=A[mid+i];
  L[n1]=INFTY;
  R[n2]=INFTY;
  i=0;
  j=0;
  for(k=left; k<right; k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i=i+1;
    }
    else{
      A[k]=R[j];
      j=j+1;
      //printf("%d+%d-%d=", c, n1, i);
      c=c+n1-i;
      //printf("%d\n", c);
    }
  }
}

void mergeSort(int A[], int left, int right) //mergeSort で分割. 部分配列の要素数が 1 以下のときは何もせず終了
{
  //部分配列の中央の位置 mid
  //部分配列の前半部分は left から mid （ mid は含まない
  //後半部分は mid から right （ right は含まない）
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main(void)
{
  int n, A[N];
  int i;
  c=0;
  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d", &A[i]);
  mergeSort(A, 0, n);
  
  printf("%ld\n", c);  
  return 0;
}


Measured memory_bytes: 3404
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int h, w, k;
    std::cin >> h >> w >> k;
    std::vector<std::string> board(h);
    std::vector<std::vector<int>> g(h * w);
    constexpr int inf = 1000000000;
    std::vector<int> dist(h * w, inf);
    for (int i = 0; i < h; i++) std::cin >> board[i];

    std::deque<int> q;
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
        int index = i * w + j;
        if (board[i][j] == 'S') {
            q.push_back(index);
            dist[index] = 0;
        }
        if (i > 0) g[index].push_back((i - 1) * w + j);
        if (i + 1 < h) g[index].push_back((i + 1) * w + j);
        if (j > 0) g[index].push_back(i * w + j - 1);
        if (j + 1 < w) g[index].push_back(i * w + j + 1);
    }

    while (!q.empty()) {
        int v = q.front();
        q.pop_front();
        for (int to : g[v]) {
            if (board[to / w][to % w] == '#') continue;
            if (dist[to] > dist[v] + 1) {
                dist[to] = dist[v] + 1;
                q.push_back(to);
            }
        }
    }

    std::vector<int> d(h * w, inf);
    for (int i = 0; i < h * w; i++) if (dist[i] <= k) {
        d[i] = 0;
        q.push_back(i);
    }

    while (!q.empty()) {
        int v = q.front();
        q.pop_front();
        for (int to : g[v]) {
            if (d[to] > d[v] + 1) {
                d[to] = d[v] + 1;
                q.push_back(to);
            }
        }
    }

    int ret = inf;
    for (int i = 0; i < w; i++) ret = std::min({ ret, d[i], d[h * w - 1 - i] });
    for (int i = 0; i < h; i++) ret = std::min({ ret, d[i * w], d[i * w + w - 1] });

    std::cout << (ret + k - 1) / k + 1 << std::endl;

    return 0;
}


Measured memory_bytes: 43648
#include<bits/stdc++.h>
using namespace std;
const int INF = (int)1e9;

int n,W;
vector<int > value;
vector<int > weight;
vector<vector<long long int > >dp;
long long int solve (int i, int w){
	if(w <= 0 or i == n) return 0;
	else if(dp[i][w]!=-1) return dp[i][w];
	else {
		dp[i][w] = solve(i + 1, w); // don't take this object!
		if (weight[i] <= w)
			dp[i][w] = max(dp[i][w], (value[i] + solve(i + 1, w - weight[i]))); 	
	}
	return dp[i][w];
}

	
int main(){
	cin>>n>>W;
	value.assign(n,0);
	weight.assign(n,0);
	for(int i=0;i<n;i++) cin>>weight[i]>>value[i];
	dp.assign(n + 1,vector<long long int>(W + 1,-1));
	cout<<solve(0,W);
}
	


Measured memory_bytes: 80256
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	char a[n+10],b[n+10];
	scanf("%s",a);
	scanf("%s",b);
	for(int i=0;i<n;i++)
	{
		cout<<a[i]<<b[i];
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define endl '\n'

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

int dp[3003][3003];

int main()
{
	IO_OP;

	string s, t;
	cin >> s >> t;
	s = ' ' + s;
	t = ' ' + t;
	for(int i=1;i<s.size();i++) {
		for(int j=1;j<t.size();j++) {
			if(s[i] == t[j]) dp[i][j] = 1 + dp[i-1][j-1];
			else dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
		}
	}
	int len = dp[s.size()-1][t.size()-1];
	int i = s.size()-1, j = t.size()-1;
	string r;
	while(r.size() < len) {
		while(s[i] != t[j]) {
			if(dp[i][j-1] > dp[i-1][j]) j--;
			else i--;
		}
		r += s[i];
		i--, j--;
	}
	reverse(ALL(r));
	cout << r << endl;
}



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

ll gcd(ll a,ll b){
    ll r;
    if( a < b) swap(a,b);
    while((r=a%b)){
        a = b;
        b = r;
    }
    return b;
}

int main(){
    ll a,b; cin>>a>>b;
    cout<<a*b/gcd(a,b)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
	int length;
	cin>>length;
	string in_train;
	for(int i=0;i<length;i++)
	{
		cin>>in_train;
		set<string> combinations;
		for (int i = 1; i < in_train.size(); i++)
		{
			string t1, t2, t_t1, t_t2;
			t_t1=t1 = in_train.substr(0, i);
			t_t2=t2 = in_train.substr(i);
			reverse_copy(t1.begin(), t1.end(), t_t1.begin());
			reverse_copy(t2.begin(), t2.end(), t_t2.begin());
			combinations.insert(t1 + t2);
			combinations.insert(t2 + t1);
			combinations.insert(t_t1 + t2);
			combinations.insert(t1 + t_t2);
			combinations.insert(t_t2 + t1);
			combinations.insert(t2 + t_t1);
			combinations.insert(t_t1 + t_t2);
			combinations.insert(t_t2 + t_t1);
		}
		cout << combinations.size() << endl;
	}
}


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

void fnInput(string& rsLine)
{
  int nSize;
  cin >> nSize;
  cin >> rsLine;
}

int fnAttention(const string& cnrsLine)
{
  int nSum = 0;
  for (int i = 1; i < cnrsLine.size(); i++)
    if (cnrsLine[i] == 'E')  nSum++;

  int nMinSum = nSum;
  for (int i = 1; i < cnrsLine.size(); i++)
  {
    if (cnrsLine[i - 1] == 'W')  nSum++;
    if (cnrsLine[i]     == 'E')  nSum--;

    nMinSum = min(nMinSum, nSum);
  }
  return nMinSum;
}
    
int main()
{
  string sLine;
  
  fnInput(sLine);
  cout << fnAttention(sLine) << endl;

  return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vector<int>>;  // int <=> ll
using P = pair<int, int>;  // int <=> ll
const int INFTY = 1e9+7;

int main() {
  int N, K;
  cin >> N >> K;
  vi A(N);
  int sum = 0;
  rep(i,N) {
    cin >> A[i];
    sum += A[i];
  }

  vector<P> factor;
  vector<bool> prime(22400, true);
  int tmp = sum;
  for (int i=2; i*i<=tmp; i++) {
    if (prime[i]) {
      int count = 0;
      while (tmp%i == 0) {
        tmp /= i;
        ++count;
      }
      if (count != 0) factor.push_back(P(i, count));
      for (int j=2*i; j*j<=tmp; j+=i) {
        prime[j] = false;
      }
    }
  }
  if (tmp != 1) factor.push_back(P(tmp, 1));

  vi div;
  div.push_back(1);
  for (auto p : factor) {
    int sz = div.size();
    int x, y;
    tie(x,y) = p;
    rep(i,sz) {
      int d = div[i];
      rep(j,y) {
        d *= x;
        div.push_back(d);
      }
    }
  }
  sort(div.begin(), div.end(), greater<int>());
  div.pop_back();  // remove 1

  int ans = 1;

  for (auto d : div) {
    vi res(N);
    rep(i,N) res[i] = A[i]%d;
    sort(res.begin(), res.end());
    int j=0, k=N-1;
    int sum_f = 0, sum_b = 0;

    while (j <= k) {
      if (sum_f < sum_b) {
        sum_f += res[j];
        ++j;
      } else {
        sum_b += d-res[k];
        --k;
      }
    }

    if (sum_f <= K) {
      ans = d;
      break;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


// 14, 23, 32, 41
enum L = 5;

int N;
string S;

void main() {
  try {
    for (; ; ) {
      S = readToken();
      N = cast(int)(S.length);
      
      auto dp = new int[][](N + 1, L + 1);
      dp[0][0] = 0;
      foreach (i; 0 .. N) {
        foreach (x; 0 .. L + 1) {
          if (i - x >= 0) {
            foreach (y; 1 .. L + 1) {
              if (i + y <= N) {
                if (S[i - x .. i] != S[i .. i + y]) {
                  chmax(dp[i + y][y], dp[i][x] + 1);
                }
              }
            }
          }
        }
      }
      int ans;
      foreach (x; 0 .. L + 1) {
        chmax(ans, dp[N][x]);
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 11320
def gcd(s, t)
  gcd(t, s) if t > s
  return t if (r = s % t).zero?
  gcd(t, r)
end


N, X = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)

a = []
a << (X-x[0]).abs

(N-1).times do |i|
	a << (x[i].to_i-x[i+1].to_i).abs
end

g = a[0]

(N-1).times do |i|
	g = gcd(g, a[i+1])
end

puts g


Measured memory_bytes: 9348
let ans a b =
  let c =
    let n = String.length a
    and m = String.length b in
    if n > m then 0
    else if n < m then 1
    else
      let rec f i =
        if i = n then 2
        else if a.[i] > b.[i] then 0
        else if a.[i] < b.[i] then 1
        else f (i + 1)
      in f 0
  in match c with
    0 -> "GREATER"
  | 1 -> "LESS"
  | _ -> "EQUAL"

let () =
  let a = read_line ()
  and b = read_line ()
  in print_string (ans a b)


Measured memory_bytes: 2432
import itertools,sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
A = [LI() for _ in range(N)]
dp = [[0]*3 for _ in range(N)]
dp[0] = A[0]
for i,j,k in itertools.product(range(1,N),[0,1,2],[0,1,2]):
    if j==k:
        continue
    dp[i][j] = max(dp[i][j],dp[i-1][k]+A[i][j])
print(max(dp[-1]))


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

void mergesort(long y[], int i, int j);
void merge(long y[], int i, int j);

int main(void)
{
	int k, n;
	long *h, min;
	scanf("%d %d", &n, &k);
	h=(long *)malloc(sizeof(long)*n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%ld", &h[i]);
	}
	mergesort(h, 0, n-1);
	min=h[k-1]-h[0];
	for (int i = 1; i < n-k+1; ++i)
	{
		if (h[k+i-1]-h[i]<min)
		{
			min=h[k+i-1]-h[i];
		}
	}
	printf("%ld\n", min);
	return 0;
}

void mergesort(long y[], int i, int j)
{
	if (i-j == 0)
	{
		return;
	}
	else
	{
		mergesort(y, i, (i+j)/2);
		mergesort(y, (i+j)/2+1, j);
		merge(y, i, j);
		return;
	}
}

void merge(long y[], int i, int j)
{
	int l, r;
	long y2[j];
	l=i;
	r=(i+j)/2+1;
	for (int k = i; k <= j; ++k)
	{
		if (l > (i+j)/2)
		{
			y2[k] = y[r];
			r++;
		} else if (r > j)
		{
			y2[k] = y[l];
			l++;
		} else if (y[l] <= y[r])
		{
			y2[k] = y[l];
			l++;
		} else
		{
			y2[k] = y[r];
			r++;
		}
	}
	for (int k = i; k <= j; ++k)
	{
		y[k]=y2[k];
	}
	return;
}

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int main(){
    ll x, k, d;
    cin >> x >> k >> d;
    ll ans;
    x = abs(x);
    if(LINF / d >= k && x >= k * d){
        ans = x - k * d;
    }else{
        ll c = x / d;
        ans = x - c * d;
        if((k - c) % 2 == 1){
            ans = abs(ans - d);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3616
local mfl = math.floor
local n, q = io.read("*n", "*n")
for i = 1, q do
  local v, w = io.read("*n", "*n")
  if n == 1 then
    print(math.min(v, w))
  else
    while v ~= w do
      if v < w then
        w = mfl((w + n - 2) / n)
      else
        v = mfl((v + n - 2) / n)
      end
    end
    print(v)
  end
end


Measured memory_bytes: 1152
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException{
		
		InputStreamReader isr= new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		
		String strNum = br.readLine();
		String[] strNumList = strNum.split(" ");
		
		Arrays.sort(strNumList);
		
		int intNumSmall = Integer.parseInt(strNumList[0]);
		int intNumMiddle = Integer.parseInt(strNumList[1]);
		int intNumlarge = Integer.parseInt(strNumList[2]);
		
		System.out.println(intNumSmall + " " + intNumMiddle + " " + intNumlarge);
	}
}


Measured memory_bytes: 24472
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
 
	if(s=="SUN") cout<<7<<endl;
	else if(s=="MON") cout<<6<<endl;
	else if(s=="TUE") cout<<5<<endl;
	else if(s=="WED") cout<<4<<endl;
	else if(s=="THU") cout<<3<<endl;
	else if(s=="FRI") cout<<2<<endl;
	else if(s=="SAT") cout<<1<<endl;
 
	return 0;
}

Measured memory_bytes: 256
N, M = map(int,input().split())
P = [list(map(int,input().split())) for i in range(N)]

P.sort()

ans = 0
buy = 0
for i in range(N) :
    if buy + P[i][1] >= M :
        ans += (M-buy) * P[i][0]
        print(ans)
        exit()
    else :
        ans += P[i][0] * P[i][1]
        buy += P[i][1]


Measured memory_bytes: 27756
#include <iostream>

using namespace std;

int main()
{
   char c;

   int a[26] = {0};
   for (;cin >> c;)
   {
       if ('a' <= c && c <= 'z')
       {
           a[c - 'a'] ++;
       }
       if ('A' <= c && c <= 'Z')
       {
           a[c - 'A'] ++;
       }
   }

   for (int i = 0; i < 26; i++)
   {
       cout << (char)('a' + i) << " : " << a[i] << endl;
   }
}


Measured memory_bytes: 3076