akhauriyash/Code-Regression huggingface dataset:
program test
  implicit none
  integer :: n, a(100), k, l, i
  a=0
  k=0
  l=0
  read(*,*) n
  read(*,*) a(1:n)
  call quick_sort(a(1:n))
  do i=1,n
  	if(mod(i,2)==1)then
    	k=k+a(n-i+1)
    else
    	l=l+a(n-i+1)
    end if
  end do
  write(*,*)k-l
  stop
contains
  recursive subroutine quick_sort(a)
    implicit none
    integer, intent(inout) :: a(:)
    integer :: p, c
    integer :: n, l, r
    n = size(a)
    l = 1
    r = n
    p = a((l+r)/2)+a(l)+a(r)-max(a((l+r)/2),a(l),a(r))-min(a((l+r)/2),a(l),a(r))
    do
      do while (a(l).lt.p)
        l = l+1
      end do
      do while (a(r).gt.p)
        r = r-1
      end do
      if (l.ge.r) exit
      c = a(l)
      a(l) = a(r)
      a(r) = c
      l = l+1
      r = r-1
    end do
    if (l.gt.2) call quick_sort(a(1:l-1))
    if (n.gt.r+1) call quick_sort(a(r+1:n))
  end subroutine quick_sort
end program test

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

#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)

#define ll long long
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)

#define xx first
#define yy second
#define mp make_pair
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define pdd pair<double,double>
#define ALL(v) (v).begin(), (v).end()

const ll MOD=1e9+7;
const ll inf=1e10;

#define MODSET(d) if ((d) >= MOD) d %= MOD;
#define MODNEGSET(d) if ((d) < 0) d = ((d % MOD) + MOD) % MOD;


ll power(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a);
        n>>=1;
        a=(a*a);
    }
    return ans;
}


ll powerMod(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%MOD;
        n/=2;
        a=(a*a)%MOD;
    }
    return ans;
}

ll powerMod1(ll a,ll n,ll mod){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%mod;
        n>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

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

ll sumdigit(ll n){
    ll sum=0;
    while(n){
        sum+=n%10;
        n=n/10;
    }
    return sum;
}

ll countSetBit(ll a){
    return __builtin_popcount(a);
}
ll countBit(ll a){
    ll sum=0;
    while(a){
        sum++;
        a>>=1;
    }
    return sum;
}

ll length(ll a){
    ll ans=0;
    while(a){
        ans++;
        a=a/10;
    }
    return ans;
}

int main()
{
    fast;
    ll t;
    //cin>>t;
    t=1;

    while(t--){
        string s,t;
        cin>>s>>t;
        ll ans=0;
        for(int i=0;i<3;i++)
            if(s[i]==t[i])
                ans++;
        cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 256
// Problem : C - A x B + C
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


#include<bits/stdc++.h>
#define 	ll		    long long
#define 	rep(i,a,n)  for(int i=a;i<n;i++)
#define		rof(i,a,n)	for(int i=a;i>=n;i--)
#define 	MOD 		1000000007
#define 	ff 			first
#define 	ss 			second
#define 	pb 			push_back
#define 	all(x) 		(x).begin(),(x).end()
#define 	dg(x)		cerr << x << endl;
#define 	endl		"\n"


using namespace std;
const int N = 1e5 + 5;
ll ar[N];

int divs[1000002] = {0};


void solve(){
	int n; cin >> n;
	n--;
	
	for(int i = 1; i * i <= n; i++){
		for(int j = i; i * j <= n;j++){
			if(i == j)
				divs[(i * j)]++;
			else
				divs[(i * j)] += 2;
		}
	}
	
	ll sum = 0;
	rep(i, 1, n + 1)
		sum += 	divs[i];
	cout << sum;
		
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
}


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

int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size()/2;i++){
    if(s.at(i)==s.at(s.size()-1-i)) continue;
    else{
      cout<<"No"<<endl;
      return 0;
    }
  }
  for(int i=0;i<(s.size()-1)/4;i++){
    if(s.at(i)==s.at((s.size()-1)/2-1-i)) continue;
    else{
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <map>
#include <set>
#include <queue>

#define LL long long

using namespace std;

int n, y;
int a,b,c;

void gg(){
	puts("-1 -1 -1");
	exit(0);
}

int main()
{
	//freopen("test_in.txt", "r", stdin);
	//freopen("test_out.txt", "w", stdout);
	cin>>n>>y; y/=1000;
	for(int i = 0; i <= n; i++)
		for(int j = 0; j <= n-i; j++)
		{
			int k = n-i-j;
			if(i+5*j+10*k==y)
			{
				printf("%d %d %d\n", k, j, i);
				exit(0);
			}
		}
	gg();
}


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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

int black[200010];
int white[200010];

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

  bool flag = false;
  for (int i = 0; i < N; i++) {
    if (s[i] == '#') flag = true;
    if (!flag) continue;

    if (s[i] == '#') black[i] = 1;
    if (i > 0) black[i] += black[i-1];
  }
  flag = false;
  for (int i = N - 1; i >= 0; i--) {
    if (s[i] == '.') flag = true;
    if (!flag) continue;

    if (s[i] == '.') white[i] = 1;
    if (i < N - 1) white[i] += white[i+1];
  }

  int ans = 0;
  for (int i = 0; i < N; i++) if (s[i] == '.') ans++;
  // ".......##########"の形にする境界線を全探索
  for (int i = 0; i < N; i++) {
    ans = min(ans, black[i] + white[i+1]);
  }

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


Measured memory_bytes: 2180
n, k = map(int, input().split())
s = input()

RL = s.count("RL")
KADO = 0
if s[0] == "L":
    KADO += 1
if s[-1] == "R":
    KADO += 1

if k < RL:
    RL -= k
elif k > RL and KADO == 2:
    RL = 0
    KADO -= 1
else:
    RL = 0

if RL + KADO == 0:
    KADO =1

print(n-(RL*2 + KADO))


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

int main() {
	int k,a,b;
	cin >> k >> a >> b;
	string kk = "NG";
	if(b / k > a / k)
	{
		kk = "OK";
	}
	else if(b % k == 0 || a% k==0)
	{
		kk = "OK";
	}
	cout << kk << endl;
	return 0;
}


Measured memory_bytes: 3620
s = input()
q = int(input())
r = False
top = []
end = []


for i in range(q):
    t = list(input().split())
    if t[0] == "1":
        r = not r
    else:
        if t[1] == "1":
            if r == False:
                top.append(t[2])
            else:
                end.append(t[2])
        else:
            if r == True:
                top.append(t[2])
            else:
                end.append(t[2])

if r == False:
    print("".join(top)[::-1] + s + "".join(end))
else:
    print("".join(end)[::-1] + s[::-1] + "".join(top))

Measured memory_bytes: 5704
n = int(input())

nodes = []
for i in range(n):
    tmp_nodes = [int(x) for x in  input().split()]

    tmp = 2
    j = 1
    while j <= n:
        if j != 1:
            print(" ", end = "")
        if tmp < len(tmp_nodes) and j == tmp_nodes[tmp]:
            print(1, end = "")
            tmp += 1
        else:
            print(0, end = "")
        j += 1
        

    print("")


Measured memory_bytes: 5628
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class S, class T> void map_init(map<S, T> &m, S k, T v){if(!m.count(k)) m[k] = v;}
int main() {
    int n;
    cin >> n;
    cout << (n * n * n) << endl;
    return 0;
}

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

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

    map<int, int> m;
    for (int i = 0; i < 3; i++)
    {
        int tmp;
        cin >> tmp;
        m[tmp]++;
    }

    if(m.size()==2)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  if(n==1){
    cout<<"Hello World"<<endl;
    return 0;
  }
  
  else{
    int b,c;
    cin>>b>>c;
    cout<<b+c<<endl;
    return 0;
  }
}

Measured memory_bytes: 256
def resolve():
    n = int(input())
    x = input()
    dict = {}
    for i in range(len(x)):
        if x[i] in dict:
            dict[x[i]] += 1
        else:
            dict[x[i]] = 1
    dictvalue = list(dict.values())
    ans = 1
    for i in dictvalue:
        ans *= (i+1)
        ans %= 10**9+7
    print(ans-1)
resolve()

Measured memory_bytes: 9184
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int mod=998244353,N=1e7+5;
int fac[N],inv[N],pw[N],n,tot;

int fpow(int x,int y){
	int res=1;
	for(;y;y>>=1,x=x*x%mod) if(y&1) res=res*x%mod;
	return res;
}

int C(int n,int m){
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}

signed main(){
	read(n);
	fac[0]=1;for(int i=1;i<=n;i++) fac[i]=fac[i-1]*i%mod;
	pw[0]=1;for(int i=1;i<=n;i++) pw[i]=(pw[i-1]+pw[i-1])%mod;
	inv[n]=fpow(fac[n],mod-2);for(int i=n-1;~i;i--) inv[i]=inv[i+1]*(i+1)%mod;
	for(int i=n/2+1;i<=n;i++) tot=(tot+pw[n-i]*C(n,i)%mod)%mod;
	write((fpow(3,n)-tot-tot+mod+mod)%mod);
}

Measured memory_bytes: 237800
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	String s;

    public void solve() {
    	s = next();

    	//先頭と末尾の文字が同じなら最終的なsの長さは奇数
    	if(s.charAt(0) == s.charAt(s.length() - 1)){
    		//最初のsの長さが偶数なら奇数回ターンが経過しているということ
    		if(s.length() % 2 == 0){
    			out.println("First");
    		}else{
    			out.println("Second");
    		}
    	}else{
    		if(s.length() % 2 == 0){
    			out.println("Second");
    		}else{
    			out.println("First");
    		}
    	}
    }

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 9172
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n,k=I()
a = l()
town = []
num = [0]*(n+1)
cnt = 1
num[0]=1

for i in range(n):
    num[a[cnt-1]] += 1
    if num[a[cnt-1]] == 2:
        ans = a[cnt-1]
        p = town.index(ans)
        b = town[p:]
        x = len(town)
        y = len(b)
        q = k-x+y
        if y == 0:
            print(town[n-1])
            sys.exit()
        if q < 0:
            print(town[k-1])
            sys.exit()
        z = q%y
        if z == 0:
            print(town[z-1])
        else:
            print(b[z-1])
        sys.exit()
        break
    town.append(a[cnt-1])
    cnt = a[cnt-1]


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



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

  string s;
  int c;
  cin >> s >> c;

  int cnt = 0;
  vector<int> v;
  repr(i, s.length() - 1) {
    if (s[i] == '1') {
      ++cnt;
    }
    else {
      v.push_back(cnt);
      cnt = 0;
    }
  }
  v.push_back(cnt);
  rep(i, s.length()) {
    cnt += s[i] - '0';
  }
  chmin(c, cnt);
  vector<vector<vector<ll>>> dp(v.size() + 1, vector<vector<ll>>(c + 1, vector<ll>(c + 1, 0)));
  dp[0][0][0] = 1;
  rep(i, v.size()) {
    rep(j, c + 1) {
      rep(k, c + 1) {
        if (!dp[i][j][k]) continue;
        rep(l, 1000) {
          int nxtj = j + v[i] - l;
          if (nxtj > c) continue;
          if (nxtj < 0) break;
          int nxtk = k + max(0, v[i] - l);
          if (nxtk > c) continue;
          dp[i + 1][nxtj][nxtk] = (dp[i + 1][nxtj][nxtk] + dp[i][j][k]) % mod;
        }
      }
    }
  }
  ll ans = 0;
  rep(k, c + 1) ans = (ans + dp[v.size()][0][k]) % mod;
  cout << ans << '\n';
  
  


  




  
  return 0;
}

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

int main()
{
	int n;
	int r[100];
	int ans = 0;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> r[i];
	}
	sort(r,r+n );
	//for (auto i : r)cout << i << " ";

	int last = 0;
	for (int i =0;i<n;i++)
	{
		if (r[i] == last)continue;
		else
		{
			last = r[i]; ans++;
			
		}

	}

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

Measured memory_bytes: 256
// atc.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <string>
#include    <algorithm>
using namespace std;

int main()
{
    string s, o;

    cin >> s;
    sort(s.begin(), s.end());
    int count = 1;

    for (int i = 0; i < s.size(); i++) {
        if (s[i] == s[i + 1]) {
            count++;
        }
        else {
            if (count % 2 != 0) {
                cout << "No";
                return 0;
            }
            count = 1;
        }
    }

    cout << "Yes";

    return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;


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

		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		String ss = sc.next();


        int N = Integer.parseInt(s);
        int R = Integer.parseInt(ss);

        if (N > 10) N = 10;
		System.out.println(R + (100*(10-N)));
	}
}

Measured memory_bytes: 22740
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


int main(void){
	int a, b;
	cin >> a >> b;
	if(a * b % 2 == 0){
		cout << "Even" << endl;
	} else {
		cout << "Odd" << endl;
	}
}


Measured memory_bytes: 256
N=int(input())
A=[]
tmp=-1
ltor=[]
rtol=[]
for i in range(N):
    A.append(int(input()))
    tmp=max(tmp,A[i])
    ltor.append(tmp)
ltor=[0]+ltor
ltor.append(0)

tmp=-1
for i in range(N):
    tmp=max(tmp,A[N-1-i])
    rtol.append(tmp)
rtol=[0]+rtol
rtol.append(0)
rtol.reverse()

for i in range(1,N+1):
    print(max(ltor[i-1],rtol[i+1]))

Measured memory_bytes: 17160
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int count = 0;

        if(s.charAt(0) == '1') count++;
        if(s.charAt(1) == '1') count++;
        if(s.charAt(2) == '1') count++;

        System.out.println(count);

    }
}


Measured memory_bytes: 22612
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;


static class P
{
    static void Main()
    {
        var nab = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(Min(nab[2], nab[0] * nab[1]));
    }
}


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

int main() {
	int	n;
  	cin >> n;
  	set<string> s;
  	for (int i=0;i<n;i++) {
    	string str;
      	cin >> str;
      	s.insert(str);
    }
  	cout << s.size() << endl;
}

Measured memory_bytes: 19236
#include<iostream>
#include<vector>
#include<tuple>
#include<set>
#include<cmath>
#include<algorithm>
using namespace std;

const char NONE = '.';
const char START = 'S';
const char GOAL = 'G';

const int INF = 1000000000;

enum {ID, X, Y};
typedef tuple<int, int, int> Character;

enum{MOVE, SELECT};
typedef tuple<int, int> Result;

int x, y;
int n;
Character hero, rival;
vector<set<Character>> creature(5, set<Character>());

int cost(const Character& c1, const Character& c2) {
    return abs(get<X>(c1) - get<X>(c2)) + abs(get<Y>(c1) - get<Y>(c2));
}

Result solve() {
    Result result(INF, -1);
    for(int e = 0; e < 5; ++e) {
        vector<vector<int>> dp(5, vector<int>(n, INF));
        for(const auto& c: creature[(e + 1) % 5]) dp[0][get<ID>(c)] = cost(hero, c);
        for(int i = 0; i < 3; ++i) {
            for(const auto& c1: creature[(e + 1 + i) % 5]) {
                for(const auto& c2: creature[(e + 2 + i) % 5]) {
                    int v1 = get<ID>(c1);
                    int v2 = get<ID>(c2);
                    dp[i + 1][v2] = min(dp[i + 1][v2], dp[i][v1] + cost(c1, c2));
                }
            }
        }
        for(const auto& c: creature[(e + 4) % 5]) {
            int v1 = get<ID>(c);
            int v2 = get<ID>(rival);
            dp[4][v2] = min(dp[4][v2], dp[3][v1] + cost(c, rival));
        }
        int move = INF;
        for(const auto& d: dp[4]) move = min(move, d);
        if(move < get<MOVE>(result)) result = Result(move, e);
    }
    return result;
}

int main() {
    while(cin >> x >> y, x | y) {
        n = 0;
        for(auto& c: creature) c.clear();
        for(int i = 0; i < y; ++i) {
            string line;
            cin >> line;
            for(int j = 0; j < x; ++j) {
                if(line[j] == NONE) continue;
                else if(line[j] == START) hero = Character(n++, j, i);
                else if(line[j] == GOAL) rival = Character(n++, j, i);
                else creature[line[j] - '1'].insert(Character(n++, j, i));
            }
        }
        Result answer = solve();
        if(get<MOVE>(answer) == INF) cout << "NA" << endl;
        else cout << get<SELECT>(answer) + 1 << " " << get<MOVE>(answer) << endl;
    }
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int N,A,B;
long long value[51];
long long dp[51][51]; 


bool comp(long long a,long long b)
{
    return a>b?true:false;
}
void init()
{
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	for(int i=1;i<=50;i++)
	{
		dp[i][0]=1;
		for(int j=1;j<=i;j++)
			dp[i][j]=dp[i-1][j-1]+dp[i-1][j];
	}
}
int main()
{
	
	
	cin>>N>>A>>B;
	{
		init();
		
		for(int i=0;i<N;i++)
			cin>>value[i];
		sort(value,value+N,comp);
	//	reverse(value,value+N);//大->小
	    double sum=0;
		for(int i=0;i<A;i++) 
			sum+=value[i];
		sum/=A;
		long long num=0,k=0;
		for(int i=0;i<N;i++)
		{
			if(value[i]==value[A-1])
			{
				num++;
				if(i<A)
					k++;
			}
		}	
		long long ans=0; 
		if(k==A)//前A个相同,可以增加个数 
		{
			for(int i=A;i<=B;i++)
				ans+=dp[num][i];
		}
		else
			ans+=dp[num][k];

 		printf("%.15f\n",sum);
 		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k, t, u, v, l;
    cin >> n >> k >> t >> u >> v >> l;
    vector<int> d(n);
    vector<bool> isNinjin(100001, false);
    for (int i = 0; i < n; i++)
    {
        cin >> d[i];
        isNinjin[d[i]] = true;
    }

    int kasokukyori = 0;
    int stock = 0;
    long double ans = 0.0;

    for (int np = 0; np < l; np++)
    {
        if (isNinjin[np])
        {
            if (stock == k)
            {
                kasokukyori = t * v;
            }
            else
            {
                stock++;
                if (kasokukyori == 0)
                {
                    kasokukyori = t * v;
                    stock--;
                }
            }
            ans += 1.0 / v;
            kasokukyori--;

            if (kasokukyori == 0 && stock > 0)
            {
                kasokukyori = t * v;
                stock--;
            }
        }
        else
        {
            if (kasokukyori > 0)
            {
                ans += 1.0 / v;
                kasokukyori--;
                if (kasokukyori == 0 && stock > 0)
                {
                    kasokukyori = t * v;
                    stock--;
                }
            }
            else
            {
                ans += 1.0 / u;
            }
        }
    }
    cout << fixed;
    cout << setprecision(10) << ans << endl;
}


Measured memory_bytes: 3296
#include<iostream>
typedef long long int ll;
using namespace std;
int main()
{
	ll l,r,k,c=0;
	cin>>l>>r>>k;
	for(ll i=l;i<=r;i++)
	{
		if(i%k==0)
		c++;
	}
	cout<<c<<endl;
}

Measured memory_bytes: 3616
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
s = 10 * ((a + 9) // 10 + (b + 9) // 10 + (c + 9) // 10 + (d + 9) // 10 + (e + 9) // 10)
r = min((a + 9) % 10, (b + 9) % 10, (c + 9) % 10, (d + 9) % 10, (e + 9) % 10)
print(s - 9 + r)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdlib>

typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;

int main(void) {
    int a, b;
    cin >> a >> b;
    int cnt = max(a, b) * 2 - 1;
    if (a == b) cnt++;
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) throws Exception {
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            int n = Integer.parseInt(br.readLine());

            IntStream.range(1, n + 1)
                    .filter(i -> i % 3 == 0 || String.valueOf(i).contains("3"))
                    .forEach(i -> System.out.print(" " + i));

            System.out.println();
        }
    }
}

Measured memory_bytes: 32760
// AGC022_A
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define vl vector<ll>

int main() {
    // input
    string S;
    cin >> S;
    vl alpha(26, 0);
    
    // calculation
    
    if (S.length() < 26) {
        REP(i, S.length()) {
            alpha[(ll)(S[i] - 'a')]++;
        }
        
        REP(i, 26) {
            if (alpha[i] == 0) {
                S += (char)(i + 'a');
                break;
            }
        }
        cout << S << "\n";
    } else {
        if (S == "zyxwvutsrqponmlkjihgfedcba") {
            cout << -1 << "\n";
        } else {
            // 上以外は何かしら次に小さい文字列がある
            char res_ch;
            string sub;
            for (ll i = 26-1; i >= 0; --i) {
                sub = S.substr(i);
                if (next_permutation(sub.begin(), sub.end())) {
                    // 回転できる文字列が見つかった時
                    for (ll j = 0; j <= i; ++j) {
                        alpha[(ll)(S[j]-'a')]++;
                    }
                    
                    REP(j, 26) {
                        if (alpha[j] == 0 && S[i] < (char)(j + 'a')) {
                            res_ch = (char)(j + 'a');
                            cout << S.substr(0, i) << res_ch << "\n";
                            return 0;
                        }
                    }
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

int main() {
    char c[2]; cin >> c;

    if (c[0] == '9' || c[1] == '9') cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  
  int x = a + b;
  int y = a - b;
  int z = a * b;
  
  int ans = max (max (x, y), z);
  
  cout << ans << endl;
  
}

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

int main()
{
    string s;cin>>s;
    if(s == "AAA" || s == "BBB")cout<< "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#define R register
#define IN inline
#define gc getchar()
#define W while
#define MX 2018
template <class T>
IN void in(T &x)
{
    x = 0; R char c = gc;
    W (!isdigit(c)) c = gc;
    W (isdigit(c))
    x = (x << 1) + (x << 3) + c - 48, c = gc;
}
std::bitset <MX * MX> bt;
int num, sum;
int main(void)
{
    bt[0] = true;
    int a;
    in(num);
    for (R int i = 1; i <= num; ++i)
    {
        in(a);
        bt |= bt << a; sum += a;
    }
    int mid = sum + 1 >> 1;
    for (R int i = mid; i <= sum; ++i)
    {
        if(bt[i]) printf("%d", i), exit(0);
    }
}

Measured memory_bytes: 1664
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int k, x; cin >> k >> x;
    cout << (k * 500 >= x ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long int ll;
int main()
{
	int n,i;
	scanf("%d",&n);
	ll a[n+1];
	vector<pair<ll,int> >take;
	for(i=1;i<=n;++i)
	{
		scanf("%lld",&a[i]);
		if(i-a[i]>=2)
		{
			take.push_back(ii(i-a[i],i));
		}
	}
	map<ll,int> res;
	ll ans = 0ll;
	int j = 1;
	for(i=0;i<take.size();i++)
	{
		while(j<=n&&j<take[i].second)
		{
			res[j+a[j]]++;
			j++;
		}
		ans = ans + (ll)res[take[i].first];
	}
	printf("%lld",ans);
}


Measured memory_bytes: 19432
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<cmath>
 
#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
 
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9
#define MOD 1000000007
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}

typedef std::pair<ll, ll> P;
 
using namespace std;

int main(){
    ll n, m;
    cin >> n >> m;
    ll ans;
    if(n == 1){
        if(m==1) ans = 1;
        else if(m>2) ans = m-2;
        else ans = 0;
    }else if(m == 1){
        if(n==1) ans = 1;
        else if(n>2) ans = n-2;
        else ans = 0;
    }else{
        ans = (n-2)*(m-2);
    }
    cout << ans;
}

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

const string a = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
    for (int n; cin >> n, n;) {
        vector<int> k(n);
        for (int& e : k) cin >> e;
        string s, t = ""; cin >> s;
        rep(i, s.size()) {
            t += a[(s[i] - (s[i] < 'a' ? 'A' - 26 : 'a') + 52 - k[i % n]) % 52];
        }
        cout << t << endl;
    }
}

Measured memory_bytes: 3168
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
typedef double D;
typedef complex<D> P;
typedef vector<P> Pol;
struct C{P p;D r;};
int N;
P p[10];
D len[10];
D eps=1e-9;
int large(D x,D y){
	if(abs(x-y)<eps) return 0;
	if(x>y) return 1;
	return -1;
}
Pol intCC(C a,C b){
	int x=large(abs(a.p-b.p),a.r+b.r);
	Pol ret;
	if(x==1) return ret;
	if(x==0){
		ret.pb((a.r*b.p+a.p*b.r)/(a.r+b.r));
		return ret;
	}
	D d=abs(a.p-b.p);
	D theta=acos((a.r*a.r+d*d-b.r*b.r)/(2.0*a.r*d));
	ret.pb(a.p+(b.p-a.p)/d*polar(a.r,theta));
	ret.pb(a.p+(b.p-a.p)/d*polar(a.r,-theta));
	return ret;
}
bool AinB(C a,C b){		//true if touch
	return abs(a.p-b.p)+a.r<b.r+eps;
}
bool can(D h){
	rep(i,N){
		if(h>len[i]) return 0;
	}
	C c[10];
	rep(i,N) c[i].r=sqrt(len[i]*len[i]-h*h),c[i].p=p[i];
	bool iran[10]={};
	rep(i,N) rep(j,N) if(i!=j){
		if(AinB(c[i],c[j])) iran[j]=true;
	}
	vector<C> cs;
	rep(i,N) if(!iran[i]) cs.pb(c[i]);
	if(cs.size()==1) return 1;
	rep(i,cs.size()) rep(j,i){
		Pol ps=intCC(cs[i],cs[j]);
		for(P q:ps){
			bool can=true;
			rep(k,cs.size()){
				if(cs[k].r+eps<abs(cs[k].p-q)) can=0;
			}
			if(can) return true;
		}
	}
	return 0;
}
int main(){
	while(true){
		cin>>N;
		if(N==0) break;
		rep(i,N){
			int x,y;
			cin>>x>>y>>len[i];
			p[i]=P(x,y);
		}
		D ub=300,lb=1;
		while(ub-lb>1e-7){
			D m=(ub+lb)/2;
			if(can(m)) lb=m;
			else ub=m;
		}
		printf("%.7f\n",ub);
	}
}

Measured memory_bytes: 1324
//template start//
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define forn(i, n) for(int i = 0; i < n; ++i)
#define forl(i, n) for(long long i=0;i<n;++i)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define vvl vector<vl>
#define vpi vector<pi>
#define vpl vector<pl>
#define pi pair<int,int>
#define pl pair<ll,ll>
#define all(x) x.begin(),x.end()
typedef long double ld; 
typedef double dd;
typedef long long int  ll;
const int MOD = 998244353; // = (119<<23)+1
const ll INF = 1e18; 
const ld PI = 4*atan((ld)1); 
template<typename T>
void printvector(vector<T>& v){
    for(int i=0;i<v.size();i++){
        cout<<v[i]<<' ';
    }
    cout<<"\n";
}
template<typename T>
void printarray(T a[])
{
    for(int i=0;i<a.size();i++)
    {
        cout<<a[i]<<" "; 
    }
    cout<<"\n";
}
 
void printpairs(vector<pair<int,int>>& v){
    for(int i=0;i<v.size();i++){
        cout<<v[i].F<<','<<v[i].S<<'|';
    }
    cout<<endl;
}
 
void print2d(vector<vector<int>>&v){
    for(int i=0;i<v.size();i++){
        printvector(v[i]);
    }
}
// checks if a number is a perfect square in almost O(1) time
long long sqroot(long long n){
    long double N = n;
    N = sqrtl(N);
    long long sq = N-2;
    sq = max(sq,0LL);
    while(sq*sq<n){
        sq++;
    } 
    if((sq*sq)==n)
        return sq;
    return -1;
}
//exponent in log(m) time
ll exp(ll n, ll m, ll md){
    ll a = 1;
    while (m > 0){
        if (m&1) a = (a * n%md) % md;
        m /= 2;
        n = (n*n) % md;
    }
    return a % md;
}
#define TT int T;cin>>T;for(int tt=1;tt<=T;tt++)
//template ends//


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

Measured memory_bytes: 3696
//#pragma GCC optimize "trapv"
//-D_GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define ii pair<int,int>
#define Max 100000+5
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f first
#define s second
#define pb push_back
int mod = 1000000007;
int mod1 = 998244353;
vector<int> g[Max];
bool vis[Max];
int d, x, y;
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
void ex(int A, int B) {
    if(B == 0) {
        d = A;
        x = 1;
        y = 0;
    }
    else {
        ex(B, A%B);
        int temp = x;
        x = y;
        y = temp - (A/B)*y;
    }
}


void dfs(int u){

	vis[u]=1;
	for(int i=0;i<g[u].size();i++){
		int v=g[u][i];
		if(vis[v]!=1)
			dfs(v);
	}
}



int power(int a,int b){
    if(b==1)return a;
    if(a>mod)a%=mod;
    int r=1;
    while(b){
        if(b&1)r=r%mod*a%mod;
        a=a%mod*a%mod;
        b/=2;
    }
    return r;
}
class uf{
    vector<int> v;
    vector<int> sz;
    
    
    public :
    uf(int n){
        v.resize(n+1);
        iota(v.begin()+1,v.end(),1);
        sz.resize(n+1,1);
        //1 to sz
    }
    int root(int b){
        while(v[b]!=b){
            b = v[b];
        }   
        return b;
    }
    void u(int a, int b){
        //combine a and b
        
        int ra=root(a);
        int rb=root(b);
        if(ra==rb)return ;
        if(sz[ra]<sz[rb]){
            v[ra] = v[rb];
            sz[rb]+=sz[ra];
        }else{
            v[rb]=v[ra];
            sz[ra]+=sz[rb];
        }
    }
    bool f(int a,int b){
        //same set
        return (root(a)==root(b));
    }
   
    
};
vector<int> matmul(vector<int> a,vector<int> b){
    vector<int> c(4,0);
    c[0] = (a[0]%mod*b[0]%mod + a[1]%mod*b[2]%mod)%mod;
    c[1] = (a[0]%mod*b[1]%mod + a[1]%mod*b[3]%mod)%mod;
    c[2] = (a[2]%mod*b[0]%mod + a[3]%mod*b[2]%mod)%mod;
    c[3] = (a[2]%mod*b[1]%mod + a[3]%mod*b[3]%mod)%mod;
    return c;
}
vector<int> id={1,0,0,1};

int32_t main(){
	IO
	//freopen("input.txt","r",stdin);
    	//freopen("output.txt","w",stdout);
	int n;
  	cin>>n;
  	cout<<n*(n-1)/2;
  	
  
  	
  	
  	
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const LL mod = 1e9 + 7;
LL S;
int d[10];

LL pw(LL x , LL y){
	LL res = 1;
	LL z = x;
	for(LL i = y ; i > 0 ; i >>= 1){
		if(i&1) (res *= z) %= mod;
		z = z * z % mod;
	}
	return res;
}

int main(){
	cin >> S;
	LL ans = 0;
	int j = 1;
	int x = 1 , y = 1;
	LL z = 0;
	d[0] = 1;
	repp(i,0,9) d[i+1] = d[i] * 10;
	repp(i,1,1e7){
		if(i == d[x]) ++x;
		while(z < S){
			z += y;
			++j;
			if(j == d[y]) ++y;
		}
		if(z == S) ++ans;
		z -= x;
	}
	for(LL i = 1 ; i * i <= S ; ++i){
		if(S%i) continue;
		if(i >= 8) (ans += 9 * pw(10,i-1) - S/i + 1) %= mod;
		if(S/i >= 8 && i * i < S) (ans += 9 * pw(10,S/i-1) - i + 1) %= mod;
	}
	repp(i,8,S/2+1) (ans += (S-1)/i - (S+i+1)/(i+1) + 1) %= mod;
	if(ans<0) ans += mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main()
{
    int a,b;
    scanf("%d %d", &a,&b);
    if(a < b) {
        printf("a < b\n");
    }
    else if(a > b) {
        printf("a > b\n");
    }
    else if(a == b) {
        printf("a == b\n");
    }
    return(0);
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define N 1005
#define ll long long
#define x first
#define y second
#define all(v) v.begin(),v.end()
using namespace std;

int main() {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
            cout.tie(NULL);
           int h,w,n;
           cin>>h>>w>>n;
           int ma= max(h,w);
           int ans = (n+ ma-1)/ma;
           cout<<ans;
             return 0;
}


Measured memory_bytes: 256
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
ans_max = 0
V_ans=[]
C_ans=[]

for i in range(0,N):
    if V[i]>C[i]:
        V_ans.append(V[i])
        C_ans.append(C[i])

print(sum(V_ans)-sum(C_ans))

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int S = sc.nextInt();
        int h = S/3600;
        int min = (S-h*3600)/60;
        int sec = S-h*3600-min*60;
        System.out.println(h +":"+ min +":"+ sec);
    }    
}


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

for i in range(A, C-1):
    if S[i] == "#" and S[i+1] == "#":
        print("No")
        exit()
for i in range(B, D-1):
    if S[i] == "#" and S[i+1] == "#":
        print("No")
        exit()

if A < B and C < D:
    print("Yes")
elif A > B and C < D:
    flag = False
    for i in range(A-2, C-1):
        if S[i] == "." and S[i+1] == "." and S[i+2] == ".":
            flag = True
    if flag:
        print("Yes")
    else:
        print("No")
elif A < B and C > D:
    flag = False
    for i in range(B-2, D-1):
        if S[i] == "." and S[i+1] == "." and S[i+2] == ".":
            flag = True
    if flag:
        print("Yes")
    else:
        print("No")   
else:
    print("Yes")


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

ll s(ll a, ll c, ll d)
{
    ll l = c * d / __gcd(c, d);
    return a / c + a / d - a/ l;
}

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll e = (b - a + 1);
    ll r = s(b, c, d) - s(a - 1, c, d);
    e -= r;
    cout << e << "\n";
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        int[] A = new int[M];
        int[] B = new int[M];

        List<List<Integer>> to = new ArrayList<>(100005);
        for (int i = 0; i < 100005; i++) {
            to.add(new ArrayList<Integer>());
        }

        for (int i = 0; i < M; i++) {
            A[i] = sc.nextInt();
            B[i] = sc.nextInt();

            A[i]--;
            B[i]--;

            to.get(A[i]).add(B[i]);
            to.get(B[i]).add(A[i]);
        }

        int[] dist = new int[100005];
        Arrays.fill(dist, -1);
        int[] pare = new int[100005];
        Arrays.fill(pare, -1);

        dist[0] = 0;
        Queue<Integer> queue = new LinkedList<Integer>();
        queue.offer(0);
        while (!queue.isEmpty()) {
            int v = queue.poll();

            for (Integer nv : to.get(v)) {
                if (dist[nv] < 0) {
                    dist[nv] = dist[v] + 1;
                    pare[nv] = v;
                    queue.offer(nv);
                }
            }
        }

        for (int i = 0; i < N; i++) {
            if (i == 0) continue;
            if (dist[i] < 0) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
        for (int i = 0; i < N; i++) {
            if (i == 0) continue;
            int p = pare[i];
            p++;
            System.out.println(p);
        }

        return;
    }

}

Measured memory_bytes: 81056
#include<iostream>
#include<map>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<climits>
#include<cstring>
#include<iomanip>

using namespace std;

int main(void) {
    string s;cin>>s;
    int x=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='1'){x++;}
        else{x--;}
    }

    cout<<s.size()-abs(x)<<endl;
    return 0;
}

Measured memory_bytes: 512
#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;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  string SS;
  cin >> SS;
  string T;
  cin >> T;
  int ssize = SS.size();
  int tsize = T.size();
  bool flag = false;
  string S;
  for(int i = ssize - tsize; i >= 0; i--){
    S = SS;
    for(int j = 0; j < tsize; j++){
      if(SS.at(i+j) != '?' && SS.at(i+j) != T.at(j)) break;
      else{
        S.at(i+j) = T.at(j);
        if(j == tsize-1) flag = true;
      }
    }
    if(flag) break;
  }
  for(int i = 0; i < S.size(); i++){
    if(S.at(i) == '?') S.at(i) = 'a';
  }
  if(flag){
    cout << S << endl;
  }
  else cout << "UNRESTORABLE" << endl;
}

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

long N, W;
long w[1000], v[1000];
long memo[200][200000];

// i番目以降の荷物から重さj以下を満たし, 価値最大となる値を返す
long rec(long i, long j){
    if(memo[i][j] != 0) return memo[i][j];
    long res;
    if(i==N) res = 0;
    else if(w[i] > j){
        res = rec(i+1, j);
    }
    else {
        res = max(rec(i+1, j), rec(i+1, j-w[i])+v[i]);
    }
    memo[i][j] = res;
    return res;
}

int main() {
    cin>>N>>W;
    for(int i=0;i<=N;++i){
        for(int j=0;j<=W;++j){
            memo[i][j] = 0;
        }
    }
    for(long i=0;i<N;++i){
        cin>>w[i]>>v[i];
    }
    cout<<rec(0, W)<<endl; 
}


Measured memory_bytes: 157184
while True:
    x,op,y=input().split()
    x=int(x)
    y=int(y)
    if op=='?':
        break
    if op=='+':
        print(x+y)
    elif op=='-':
        print(x-y)
    elif op=='*':
        print(x*y)
    elif op=='/':
        print(x//y)

    
    


Measured memory_bytes: 5596
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int h, n, a;
    cin >> h >> n;
    for(int i=0;i<n;++i) {
        cin >> a;
        h -= a;
    }
    cout << ((h <= 0)?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
ll const MOD=1000000007;

ll N,Y;

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

    ll a=-1, b=-1, c=-1;
    rep(i,N+1){
        ll m=N-i;
        rep(j,m+1){
            ll k=m-j;
            if(10000*i+5000*j+1000*k==Y){
                a=i;
                b=j;
                c=k;
                break;
            }
        }
    }

    cout<<a<<' '<<b<<' '<<c<<endl;
}

Measured memory_bytes: 3680
s = input()
h1, m1, h2, m2, k = s.split(' ')

h = int(h1) - int(h2)
m = 0
if int(m1) >= int(m2):
    m = int(m1) - int(m2)
else:
    h = h -1
    m = 60 + int(m1) - int(m2)
    
t = abs(h * 60 + m) - int(k)

print(t)

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

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

            var c = 0;
            var i = 0;
            while(true){
                if(i + 3 <= s.Length){
                    var sb = s.Substring(i,3);
                    if(sb.Equals("ABC")){
                        c += 1;
                    }
                    i += 1;
                }else{
                    break;
                }
            }

            Console.WriteLine(c);
        }
    }
}


Measured memory_bytes: 13140