akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::FromStr;
use std::cmp::max;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let k :i64 = read();
    let q: i64 = read();
    let mut p: Vec<i64> = (0..n).map(|_| 0).collect();

    for _ in 0..q {
        let a: usize = read::<usize>() - 1;
        p[a] += 1;
    }

    for &p1 in &p {
        if p1 > q - k {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}


Measured memory_bytes: 4732
while True:
    e = int(input())
    if e == 0:
        break
    ans = float('inf')
    max_z = int(e ** (1 / 3) + 1e-6)
    for z in range(max_z, -1, -1):
        y = int((e - z ** 3) ** 0.5 + 1e-6)
        ans = min(ans, e - y ** 2 - z ** 3 + y + z)
    print(ans)

Measured memory_bytes: 7692
#include <bits/stdc++.h>
#define dbg(x) cerr<<#x<<" = "<<x<<endl;
#define dbg_v(v,n) {cerr<<#v<<" = [";for(int III=0;III<=n;III++)cerr<<v[III]<<(III!=n?",":"]\n");}
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define MOD 1000000007
#define zeros(x) x&(x-1)^x
#define fi first
#define se second
#define Nmax 200005
using namespace std;

template<typename T = int>
struct AIB{
    #define INIT_VALUE (type == 2 ? INF : (type == 1 ? -INF : 0))
    unordered_map<int,T> A;
    int N, type;
    bool isReversed;
    const T INF = 0;
    const int OFF = 4;
 
    // type 0 = sum, 1 = max, 2 = min
    AIB(int _N = Nmax + 5,int _type = 0, bool _isReversed = false) : N(_N), type(_type), isReversed(_isReversed){
        assert(type >= 0 && type <= 2);
        //A.resize(N+5, INIT_VALUE);
    }
 
    void operation(T &A, T B){
        if (type == 0) A += B;
        else if (type == 1) A = max(A, B);
        else A = min(A, B);
    }

    void add(T pos, T val){
        for (pos=(isReversed ? N-pos-OFF : pos+OFF);pos < N; pos += pos & (-pos))
            operation(A[pos], val);
    }
 
    T sum(T pos){
        T ans = INIT_VALUE;
        for (pos=(isReversed ? N-pos-OFF : pos+OFF);pos > 0; pos -= pos & (-pos))
            operation(ans, A[pos]);
        return ans;
    }
 
    T sum(T L, T R){
        return sum(R) - sum(L-1);
    }
 
    T lowerBound(T val){
        long long p = 1, st = 0;
        for (;p<N;p<<=1);
        for (;p>=1;p>>=1) if (st + p < N && A[st+p] < val) {st += p;val -= A[st];}
        return st + 1 - OFF;
    }
    #undef INIT_VALUE
};
AIB<long long> aib(2e8, 1, false);

int x,y,x2,y2,n,ok;
pii P[Nmax];

int main(){
    ios::sync_with_stdio(false);
    
    cin >> x >> y >> x2 >> y2;
    cin >> n;
    if (x2 < x){
    	swap(x,x2);
    	swap(y,y2);
    }
    for (int i=1;i<=n;i++){
    	cin >> P[i].fi >> P[i].se;
    	
    	if (x <= P[i].fi && P[i].fi <= x2 && y <= P[i].se && P[i].se <= y2){
    		ok = 1;
    	}
    	if (y2 < y){
    		P[i].se = 1e8 - P[i].se;
    	}
    }
	if (y2 < y){
		y2 = 1e8 - y2;
		y = 1e8 - y;
	}

	if (x == x2 || y == y2){
		long double ans = (x2 - x) + (y2 - y);
		ans *= 10;
		if (ok) ans += -2 + acos(-1) * 1;
		cout << fixed << setprecision(9) << ans * 10 << '\n';
		return 0;
	}
	sort(P+1,P+n+1);

	for (int i=1;i<=n;i++){
		if (P[i].fi < x) continue;
		if (P[i].se < y) continue;
		if (P[i].fi > x2) break;
		int crt = aib.sum(P[i].se);
		aib.add(P[i].se, crt+1);
	}

	long double xx = 1,ans = (x2 - x) + y2 - y;
	ans *= 10;
	if (aib.sum(y2) == (x2 - x + 1) || aib.sum(y2) == (y2 - y + 1)){
		ans += xx * (-2 + acos(-1) / 2.0) * (aib.sum(y2) - 1);
		ans += (-2 + acos(-1));
	}
	else ans += xx * ((-2) + acos(-1) / 2.0) * aib.sum(y2);
	// cout << aib.sum(y2) << '\n';
	cout << fixed << setprecision(9) << ans * 10 << '\n'; 


    return 0;
}

Measured memory_bytes: 69200
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());

        var xx = new List<long>();
        var yy = new List<long>();
        var hh = new List<long>();

        for(int i=0; i<n; i++) {
            var spl   = input.ReadLine().Split(' ');
            xx.Add(long.Parse(spl[0]));
            yy.Add(long.Parse(spl[1]));
            hh.Add(long.Parse(spl[2]));
        }

        int p = 0;
        for (int i = 0; i < n; i++) {
            if (hh[i] != 0) {
                p = i;
                break;
            }
        }

        for(var cx=0; cx<=100; cx++) {
            for(var cy=0; cy<=100; cy++) {
                var ng = false;
                var H = hh[p] + Math.Abs(xx[p] - cx) + Math.Abs(yy[p] - cy);

                for (var i=0; i<xx.Count; i++) {
                    if(hh[i] > 0) {
                        long h = hh[i] + Math.Abs(xx[i] - cx) + Math.Abs(yy[i] - cy);
                        if (H != h) ng = true;
                    } else {
                        if (H - Math.Abs(xx[i] - cx) - Math.Abs(yy[i] - cy) > 0)
                            ng = true;
                    }
                }
                if (!ng) return cx + " " + cy + " " + H;
            }
        }

        System.Threading.Thread.Sleep(2100);

        return "XXXXX";
    }
}


Measured memory_bytes: 13268
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define MAX_N (1000)
#define INF (1000000000)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  int N, M;
  long xs[MAX_N], ys[MAX_N], zs[MAX_N];
  scanf("%d %d", &N, &M);
  for (int i = 0; i < N; i++) {
    scanf("%ld %ld %ld", &xs[i], &ys[i], &zs[i]);
  }

  // solve dp
  long ans = 0;
  long dp[MAX_N + 1][MAX_N + 1] = {};
  for (int nx = 0; nx < 2; nx++) {
    for (int ny = 0; ny < 2; ny++) {
      for (int nz = 0; nz < 2; nz++) {
        for (int i = 0; i < N; i++) {
          const long x = nx ? xs[i] : -xs[i], y = ny ? ys[i] : -ys[i],
                     z = nz ? zs[i] : -zs[i];
          for (int j = 0; j < i; j++) {
            dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i][j] + x + y + z);
          }
          dp[i + 1][i + 1] = dp[i][i] + x + y + z;
        }
        ans = max(ans, dp[N][M]);
      }
    }
  }
  printf("%ld\n", ans);

  return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<cmath>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
#define x first
#define y second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define newline cout<<"\n"
#define yes cout<<"Yes"<<"\n"
#define no cout<<"No"<<"\n"
#define INF (ll)1e14+5
#define nax (ll)5e4+3
#define eps (double)1e-9
#define all(x) x.begin(),x.end()
#define MAX_N 3005
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pdbs;
// look for  all edge cases
//search for a pattern




int main(){
	fast;
	ll x;
	cin >> x;
	ll a = 100;
	//ll in = 1;
	ll ans =0;
	while(a < x){
		ans++;
		a = a + 1*(a/100);
	}
	cout<<ans;
 	
	return 0;
}

	


Measured memory_bytes: 3620
#include<stdio.h>
#include<string.h>
int main(){
  char str1[100];
  char str2[100],str3[100];
  char str4[100];
  scanf("%s %s",str1,str4);
  strcpy(str2,str1);
  strcpy(str3,str1);
  strcat(str1,str2);
  strcat(str1,str3);
  if(strstr(str1,str4)==NULL) printf("No\n");
  else printf("Yes\n");
  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#define MAX_N 86
using namespace std;

int main(){
  int n;
  cin >> n;
  long long l[MAX_N + 1];
  l[0] = 2;
  l[1] = 1;
  for(int i = 2; i <= MAX_N; i++){
    l[i] = l[i - 1] + l[i - 2];
  }
  cout << l[n] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll maxn=1e18+7;
ll dp[500][500]; // dp[i][j] represents total cost from i to j;
vector<ll>v;
ll sum(ll l ,ll r)
{
	ll s=0;
	for(ll i=l;i<=r;i++)	
		s+=v[i];
		
	return s;
}
int main()
{
	ll n,i,j;
	cin >> n;
	for(i=0;i<n;i++)
	{
		ll x;
		cin >> x;
		v.push_back(x);
	}
	for(ll l=n-1;l>=0;l--)
	{
		for(ll r=l;r<n;r++)
		{
			if(l==r)
			{
				dp[l][r]=0;
				continue;
			}
			dp[l][r]=maxn;
			ll s=sum(l,r);
			for(i=l;i<r;i++)
				dp[l][r]=min(dp[l][r],dp[l][i]+dp[i+1][r]+s);
				
		}
	}
	cout<<dp[0][n-1]<<"\n";
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#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 RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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



int main() {
	int n, m;
	while (cin >> n >> m, n | m){
		int count = 0;
		vector<int>  vn;
		vector<int>  vm;
		vn.push_back(0);
		vm.push_back(0);
		map<int, int> ma;
		int x = 0;
		REP(i, n){
			int a;
			cin >> a;
			x += a;
			vn.push_back(x);
		}
		x = 0;
		REP(i, m){
			int a;
			cin >> a;
			x += a;
			vm.push_back(x);
		}

		REP(i, n + 1){
			REP(j, m + 1){
				ma[vn[i] - vm[j]]++;
			}
		}
		for (map<int, int>::iterator it = ma.begin(); it != ma.end(); it++){
			count += it->second*(it->second - 1) / 2;
		}


		cout << count << endl;

	}
}

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

int main(){
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i, s.size()){
        if(s.at(i) != t.at(i)){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3920
/* ITP1_8_A */
#include <stdio.h>

#define MAX_LENGTH 1201
#define TOGGLING 32

void toggling_char(char str_array[]);

int main(void)
{
	char in_str_array[MAX_LENGTH];
	
	short ii;
	for( ii = 0; ii < MAX_LENGTH; ii++ )
	{
		in_str_array[ii] = '\0';
	}
	
	// ??\????????????
	gets(in_str_array);
	
	// ??§????????¨?°????????????\????????????
	toggling_char(in_str_array);
	
	// ???????????????
	ii = 0;
	while( in_str_array[ii] != '\0' )
	{
		printf("%c", in_str_array[ii]);
		ii++;
	}
	printf("\n");
	
	return 0;
}

/* ??§????????¨?°????????????\???????????? */
void toggling_char(char str_array[])
{
	short ii;
	while( '\0' != str_array[ii] )
	{
		// ??§???????????´???????°????????????\????????????
		if( 'A' <= str_array[ii] && 'Z' >= str_array[ii] )
		{
			str_array[ii] += TOGGLING;
		}
		// ?°????????????´????????§???????????\????????????
		else if( 'a' <= str_array[ii] && 'z' >= str_array[ii] )
		{
			str_array[ii] -= TOGGLING;
		}
		ii++;
	}
}

Measured memory_bytes: 524
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        --a[i];
    }
    vector<int> kon(n, -1);
    for (int i = 0; i < n; ++i)
    {
        if (a[i] == 0 || kon[a[i] - 1] == -1)
            kon[a[i]] = 1;
        else
            kon[a[i]] = kon[a[i] - 1] + 1;
    }
    int odp = n;
    for (int i = 0; i < n; ++i)
        odp = min(odp, n - kon[i]);
    cout << odp;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
//　min
int main(void){
  int a;
  char s[11];

  scanf("%d%s", &a, s);

  if(a >= 3200){
    printf("%s\n", s);
  }else{
    printf("red\n");
  }
  
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S;
    cin >> N >> S;
    rep(i, 0, S.size()) {
        S[i] = char(((int)(S[i] - 'A') + N) % 26 + 'A');
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, A, B;
  cin >> N >> A >> B;
  int sum = 0;
  for(int i = 1; i < N+1; i++){
    int P = i;
    int x = 0;
    while(P != 0){
    x += P % 10;
    P = P / 10; 
    }
    if(A<=x &&x<= B){
      sum+= i ;
    }
  }
cout << sum << endl;
}

Measured memory_bytes: 256
n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
s = 0
maxbooks = 0
for i in range(n):
    if s + a[i] <= k:
        s += a[i]
        continue
    else:
        i -= 1
        break
for j in range(m):
    if s + b[j] <= k:
        s += b[j]
        continue
    else:
        j -= 1
        break
maxbooks = i + j + 2
nowbooks = i + j + 2
#i, j: 読めたもの
while i >= 0 and j < m:
    s -= a[i]
    i -= 1
    nowbooks -= 1
    while j + 1 < m:
        if s + b[j+1] <= k:
            s += b[j+1]
            j += 1
            nowbooks += 1
            if nowbooks > maxbooks:
                maxbooks = nowbooks
            
            continue
        else:
            break
last = 0
s = 0
for j in range(m):
    if s + b[j] <= k:
        s += b[j]
        continue
    else:
        j -= 1
        break
if j > maxbooks:
    maxbooks = j
print(maxbooks)

Measured memory_bytes: 111096
#include<iostream>
#include<string>
#include <vector>
#include<algorithm>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define vsort(v) sort(v.begin(), v.end())
#define ll long long
const ll MOD = 1e9 + 7;

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i += 2) {
		cout << s[i];
	}
	cout << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
    vector<int> vec;
    int n,m;
    int x,y,z;
    while(1){
        vec.clear();
        cin >> n >> m;
        if(n == 0 && m == 0)break;
        for(int i = 0;i < n;i++){
            vec.push_back(i+1);
        }
        for(int i = 0;i < m;i++){
            cin >> x >> y;
            vector<int>::iterator ite = vec.end() - (x+y-1);
            for(int j = 0;j < y;j++){
                z = *ite;
                vec.erase(ite);
                vec.push_back(z);
            }
        }
        cout << vec.back() <<endl;
    }
    return 0;
}

Measured memory_bytes: 1220
n=int(input())
h=list(map(int,input().split()))
dp=[0]*(n+1)
h.insert(0,0)
dp[2]=abs(h[2]-h[1])
for i in range(3,n+1):
    dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2])
print(dp[n])



Measured memory_bytes: 13980
#include<iostream>
#include<cstdlib>
#include<iomanip>
#include<cmath>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;


int f(int x)
{
	int res = 0;
	while (x % 2 == 0) {
		x /= 2;
		res++;
	}
	return res;
}

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

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

int a[100000];

int main()
{
	int n, m;

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

	for (int i = 0; i < n; i++) {
		a[i] /= 2;
	}

	int t = f(a[0]);
	for (int i = 0; i < n; i++) {
		if (f(a[i]) != t) {
			cout << 0 << endl;
			return 0;
		}
	}

	for (int i = 0; i < n; i++) {
		a[i] >>= t;
	}
	m >>= t;

	long long com = 1;

	for (int i = 0; i < n; i++) {
		com = lcm(com, a[i]);
	}

	m /= com;

	cout << (m+1)/2 << endl;
}

Measured memory_bytes: 640
S = input()

pat0 = 0  # 010101010...
pat1 = 0  # 101010101...

for i, c in enumerate(S):
    if i % 2 == 0:
        if c == '0':
            pat0 += 1
        else:
            pat1 += 1
    else:
        if c == '0':
            pat1 += 1
        else:
            pat0 += 1

N = len(S)
print(min(N - pat0, N - pat1))


Measured memory_bytes: 3188
n = int(input())
s = input()

ans = 0

for i in range(1,n):
    x = list(set(s[:i]))
    y = list(set(s[i:]))
    cnt = 0
    for j in range(len(x)):
        for k in range(len(y)):
            if x[j] ==  y[k]:
                cnt += 1

    ans = max(cnt ,ans)

print(ans)


Measured memory_bytes: 3060
using System;

namespace ConsoleApp10
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int w = int.Parse(str[0]);
            int h = int.Parse(str[1]);
            int x = int.Parse(str[2]);
            int y = int.Parse(str[3]);
            int r = int.Parse(str[4]);
            if (x - r >= 0 && y - r >= 0 && x + r <= w && y + r <= h)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 9008
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());

        // 主処理
        String strN = Long.toString(n);

        int sum = 0;
        for (int i = 0; i < strN.length(); i++) {
            sum += Integer.parseInt(String.valueOf(strN.charAt(i)));
        }

        int head = Integer.parseInt(String.valueOf(strN.charAt(0))) - 1;
        int lowerSum = (strN.length() - 1) * 9 + head;

        int result = Math.max(sum, lowerSum);

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>

using namespace std;
typedef long long ll;

int main(){

  int N, M;
  cin >> N >> M;

  int res=1;
  for(int i=1;i*i<M+1;i++){
    if(M%i==0){
      if(M/i>=N) res=max(res,i);
      if(i>=N) res=max(res,M/i);
    }
  }
    

  cout << res << endl;

    
  return 0;

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    int count = 0;
    char[][] A = new char[H][W];
    for (int i = 0; i < H; i++) {
      String s = sc.next();
      for (int j = 0; j < W; j++) {
        A[i][j] = s.charAt(j);
        if (A[i][j] == '#') {
          count++;
        }
      }
    }
    if (count != W+H-1) {
      System.out.println("Impossible");
      return;
    }
    
    System.out.println(dfs(A, 0, 0) ? "Possible" : "Impossible");
  }
  
  private static boolean dfs(char[][] A, int i, int j) {
    if (i == A.length-1 && j == A[0].length-1) {
      return A[i][j] == '#';
    }
    if (A[i][j] != '#') {
      return false;
    }
    boolean ok = false;
    if (i+1 < A.length) {
      ok |= dfs(A, i+1, j);
    }
    if (j+1 < A[0].length) {
      ok |= dfs(A, i, j+1);
    }
    return ok;
  }
}

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

bool isPrime(int n){
    if (n == 0) return false;
    else if (n == 1) return false;
    else if (n == 2) return true;
    else{
        for (int i = 2; i*i <= n; i++){
            if (n % i == 0) return false;
        }
        return true;
    }
}

int main(void){
    int l;
    int num_count = 0;
    while(cin>>l){
        if (isPrime(l)) num_count++;
    }
    
    cout << num_count << endl;
    return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>
#include <math.h>

#define nl '\n'

using namespace std;

int x, a, b;

int main(){

    cin >> x >> a >> b;

    if(abs(x-a) < abs(x-b)){
        cout << "A";
    } else{
        cout << "B";
    }





}

//g++ -std=c++14 comp.cpp -o b; ./b.exealso

Measured memory_bytes: 256
c = [list(map(int,input().split())) for _ in range(3)]
#print(LIST)
# a1 = 0 とする
a,b= [0,0,0],[0,0,0]
for i in range(3):
    b[i] = c[0][i] - a[0]
for j in range(1,3):
    a[j] = c[j][0] - b[0]
for i in range(1,3):
    for j in range(1,3):
        #print(a,b)
        if c[j][i] == a[j] + b[i]:
            pass
        else:
            print('No')
            exit()
print('Yes')


Measured memory_bytes: 3064
# -*- coding:utf-8 -*-

def solve():
    n = int(input())
    P = list(map(int, input().split()))

    def f(a, b, c):
        lst = [a, b, c]
        lst.sort()
        if lst[1] == b:
            return True
        return False

    ans = 0
    for i in range(0, n-2):
        if f(P[i], P[i+1], P[i+2]):
            ans += 1
    
    print(ans)

if __name__ == "__main__":
    solve()


Measured memory_bytes: 3316
/*input
117
*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<long,long>
#define vi          vector<long long>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repi(i,a,b) for(ll i=a;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define fIO         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define tr(it, a)   for(auto it = a.begin(); it != a.end(); it++)
#define clr(x)      memset(x, 0, sizeof(x))
#define deb(x)      cout << #x << "=" << x << endl
#define deb2(x, y)  cout << #x << "=" << x << "," << #y << "=" << y << endl
#define TIME        cerr << "\nTime elapsed: "<<1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; 
//#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update>;

ll sub(ll a, ll b){return (a-b+hell)%hell;}
ll add(ll a, ll b){return (a+b)%hell;}
ll mul(ll a, ll b){return (a*b)%hell;}
vector<ll>adj[100005];
bool vis[100005];
ll siz,edges;
void dfs(ll i)
{
    vis[i]=1;
    //siz++;
    for(ll j=0;j<adj[i].size();j++)
    {        
        edges++;
        if(!vis[adj[i][j]])
            dfs(adj[i][j]);
    }
}
const ll mod = 1000000007;
ll mpow(ll base, ll exp) {
  base %= mod;
  ll result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}
vi v;
vector<bool> isprime(1000005,true);
void seive(){
  rep(i,2,1000005){
    if(isprime[i]){
      for(ll j=2*i;j<1000005;j+=i)isprime[j]=false;
    }
  }
  rep(i,2,1000005){if(isprime[i])v.pb(i);}


}
int main()
{
fIO;
ll n,sum=0,t=1,m,ans;
//cin >> t;
while(t--){
  cin>>n;
  while(n){
    if(n%10==7){cout<<"Yes";return 0;}
    n=n/10;
  }
  cout<<"No";















}
TIME;
    
}

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

using namespace std;

int main()
{
  int K, X;
  cin >> K;
  cin >> X;
  bool first = true;
  for (int i = 1 - K + X; i < X + K; ++i) {
    if (first) {
      first = false;
    } else {
      cout << " ";
    }
    cout << i;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    string a; cin >> a;
    int ans = 700;
    REP(i, 3) if(a[i] == 'o') ans += 100;
    cout << ans << endl;
}

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

int main() {
	int a,b,c;
	while(cin>>a>>b>>c,a,b,c){
		int tool[301]={};
		for(int i=1;i<=a+b+c;i++)tool[i]=2;
		int n;
		cin>>n;
		int num[1001][4];
		for(int i=0;i<n;i++){
			for(int j=0;j<4;j++)cin>>num[i][j];
			if(num[i][3]==1)for(int j=0;j<3;j++)tool[num[i][j]]=1;
		}
		for(int i=0;i<n;i++){
			if(num[i][3]==0){
				int a=num[i][0],b=num[i][1],c=num[i][2];
				if(tool[a]==1&&tool[b]==1)tool[c]=0;
				else if(tool[c]==1&&tool[b]==1)tool[a]=0;
				else if(tool[a]==1&&tool[c]==1)tool[b]=0;
			}
		}
		for(int i=1;i<=a+b+c;i++)cout<<tool[i]<<endl;
	}
}

Measured memory_bytes: 1172
#include <stdio.h>
int main(void){

    char a[1200]={};
    int i=0;
    
    while(1){
        scanf("%c", &a[i]);
        if (a[i]==0){
            break;
        }
        else if (a[i]>='a' && a[i]<='z'){
            a[i]=a[i]-32;
        }
        else if(a[i]>='A' && a[i]<='Z'){
            a[i]=a[i]+32;
        }
        printf("%c", a[i]);
        i++;
    }
    return 0;
}



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

const string S[] = {
    "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"
};

int main() {
    string s; cin >> s;
    int res = 0;
    for (int i=0; i<7; i++) if (s == S[i]) res = i;
    cout << 7 - res << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main {

    final static boolean fileIO = false;
    final static boolean DEBUG = false;
    final static String input = "input.txt";
    final static String output = "output.txt";
    
    public static void main(String args[]) throws Exception {

		InputStream is = null;
		OutputStream os = null;
		if (fileIO) {
			is = new FileInputStream("input.txt");
			os = new FileOutputStream("output.txt");
		} else {
			is = System.in;
			os = System.out;
		}
		InputReader in = new InputReader(is);
		PrintWriter out = new PrintWriter(os);
		new Task().solve(in, out);
		out.close();	

	}
	
	static class Task {
		
		public void solve(InputReader in, PrintWriter out) {
			char s[] = in.nextString("\n").toCharArray();
			char t[] = in.nextString("\n").toCharArray();
			Arrays.sort(s);
			Arrays.sort(t);
			int state = 0;
			for (int i = 0, j = t.length - 1; state == 0 && i < s.length && j >= 0; ++i, --j) {
				if (s[i] < t[j]) {
					state = 1;
				} else if (s[i] > t[j]) {
					state = 2;
				}
			}
			if (state == 0) {
				if (s.length < t.length) {
					state = 1;
				} else {
					state = 2;
				}
			}
			out.println(state == 1 ? "Yes" : "No");


		}
	}

	static class InputReader {
	
		private StringTokenizer tokenizer;
		private BufferedReader reader;

		public InputReader(InputStream is) {
			tokenizer = null;
			reader = new BufferedReader(new InputStreamReader(is), 32768);
		}

		public String nextString(String delim) {
			String ans = null;
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					String line = reader.readLine();
					if (line != null) {
						tokenizer = new StringTokenizer(line, delim);
						ans = tokenizer.nextToken();
					} else {
						ans = null;
					}
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			} else {
				ans = tokenizer.nextToken();
			}
			return ans;
		}
	
		public Integer nextInt() {
			return Integer.parseInt(nextString(" "));		
		}
	}
}


Measured memory_bytes: 23380
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll n = in();
	ll cnt = 1;
	REP(i, n) {
		cnt *= (in() % 2 == 0 ? 2 : 1);
	}
	cout << [n]() {ll ans = 1; REP(i, n)ans *= 3; return ans; }() - cnt << endl;
}

Measured memory_bytes: 256
s=input()
S=s.count("S")
E=s.count("E")
N=s.count("N")
W=s.count("W")
a=0
b=0
if S>0 and N>0:
	a+=1
elif S==N==0:
	a+=1
if E>0 and W>0:
	b+=1
elif E==W==0:
	b+=1
if a==b==1:
	print("Yes")
else:
	print("No")



Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Piza
{
    class Paiza
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int ans = 0;
            for (int i = 0; i < N; i++)
            {
                string[] s = Console.ReadLine().Split(' ');
                ans += int.Parse(s[1])-int.Parse(s[0])+1;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> data(N);
    for (int i = 0; i < N; i++) {
        cin >> data.at(i);
    }
    sort(data.begin(), data.end());
    int ans = 1;
    for (int i = 0; i < N - 1; i++) {
        if (data.at(i) == data.at(i + 1)) {
            continue;
        }
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}


int main (){
    int n;
    cin >> n;
    vector<ll>a(n);
    vector<ll>b(n);
    vector<ll>c(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll ans=0;
    rep(i,n){
        auto ite_a=lower_bound(a.begin(),a.end(),b[i]);
        ll count_a=ite_a-a.begin();
        auto ite_c=upper_bound(c.begin(),c.end(),b[i]);
        ll count_c=c.end()-ite_c;
        ans+=count_a*count_c;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2688
/*	                           
							 * * 
						   *     * 
						 *	       * 
					   *	         * 
                     *     _ooOoo_     * 
                   *      o8888888o      * 
                 *        88" . "88        * 
                *         (| -_- |)         * 
               *       *  0\  =  /0  *       * 
               *       *__0/`---'\0__*       * 
               *     .'  \\|     |//  `.     * 
                *   /  \\|||  :  |||//  \   * 
                 * /  _||||| -:- |||||-  \ * 
                   |   | \\\  -  /// |   |
                   | \_|  ''\---/''  |   |
                   \  .-\__  `-`  ___/-. /
                 ___`. .'  /--.--\  `. . __
              ."" '<  `.___\_<|>_/___.'  >'"".
             | | :  `- \`.;`\ _ /`;.`/ - ` : | |
             \  \ `-.   \_ __\ /__ _/   .-` /  /
        ======`-.____`-.___\_____/___.-`____.-'======
                           `=---='
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                   佛祖保佑       永无BUG
                        author：Richie 
*/

#include<stdio.h>
#include<string.h>	
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#define LOCAL
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define ll long long
#define N 500001
#define mod 1000000007

int cmp(const void *a,const void *b);
void print_array(int *a,int n);
void read_array(int *a,int n);
void init();
ll fast(ll x);
ll exgcd(ll a,ll b,ll *x,ll *y);
ll getInv(int a);
ll gcd(ll a,ll b);

int main(){
    char a[10];
    scanf("%s",a);
    int flag=0;
    for(int i=0;a[i]!='\0';i++){\
    	if(a[i]=='R'){
    		flag=1;
    		while(a[++i]=='R')flag++;
    		break;
		}
	}
	printf("%d",flag);
	return 0;
}







ll gcd(ll a,ll b){
	int t;
	while(b!=0){
		t=a%b;
		a=b;
		b=t;
	}
	return a;
}

ll fast(ll x){									//逆元 费马小定理/欧拉定理 适用范围：一般在mod是个素数的时候用
	int y=mod-2;
	ll res=1;
	while(y){
		if(y&1)res=res*x%mod;
		x=x*x%mod; 
		y>>=1;
	}
	return res;
}

ll exgcd(ll a,ll b,ll *x,ll *y)					//扩展欧几里得算法 
{
    if(b==0)
    {
        *x=1,*y=0;
        return a;
    }
    ll ret=exgcd(b,a%b,y,x);
    *y-=a/b*(*x);
    return ret;
}
ll getInv(int a)						//求a在mod下的逆元，不存在逆元返回-1 
{
    ll x,y;
    ll d=exgcd(a,mod,&x,&y);
    return d==1?(x%mod+mod)%mod:-1;
}

void init(void){
	#ifdef LOCAL
		freopen("P2678_2.in","r",stdin);
		freopen("data.txt","w",stdout);
	#endif
}

int cmp(const void *a,const void *b){
	return *(int*)a-*(int*)b;					//升序排列 
} 

void print_array(int *a,int n){
	FOR(i,1,n){
		if(i!=n)printf("%d ",a[i]);
		else printf("%d",a[i]);
	}
} 

void read_array(int *a,int n){
	FOR(i,1,n)scanf("%d",&a[i]);
}




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

using ll = long long int;

ll n, m;

ll ans;

int main(void) {
    // Here your code !
    scanf("%lld %lld", &n, &m);


    if (m >= 2 * n) {
      ans = n + (m - 2 * n) / 4;
    }
    else {
      ans = m / 2;
    }

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

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath> 
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<unordered_map>
#include<cstring>
#include<stack>
#include<queue>
#include<climits>

using namespace std;

#define ll long long

const int INF = 1e9+7;
const int mod = 1e9+7;
const int MAX = 1e5+5;




int main(){
	//freopen("tree.in","r",stdin);
    //freopen("tree.out","w",stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    string str;
    cin >> str;
    int n = str.size();
    int hugs = 0;
    for(int i = 0; i < n/2; ++i){
        if(str[i] == str[n-i-1])
            continue;
        else
            hugs++;
    }
    cout << hugs << endl;

    
}

Measured memory_bytes: 3620
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s; cin >> s;
  string t;
  REP(i,s.size()){
    if(s[i]=='B'){
      if(i<s.size()-1 && s[i+1]=='C'){
        t.push_back('D');
        i++;
      }else{
        t.push_back('B');
      }
    }else{
      t.push_back(s[i]);
    }
  }
  
  ll ans = 0;
  int cnt = 0;
  REP(i,t.size()-1){
    if(t[i]=='A' && t[i+1]=='D'){
      ans += cnt+1;
      t[i+1] = 'A';
    }else if(t[i]=='A'){
      cnt++;
    }else{
      cnt = 0;
    }
  }
  cout << ans << endl;
      
  return 0;
}


Measured memory_bytes: 3892
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

INF = 10**9

N = int(input())

F = [list(map(int, input().split())) for i in range(N)]
P = [list(map(int, input().split())) for i in range(N)]

ans = -INF
for i in range(1,1<<10):
    tmp = 0
    for j in range(N):
        b_hours = 0
        for k in range(10):
            if i&(1<<k) and F[j][k]:
                b_hours += 1
        tmp += P[j][b_hours]
    ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 14280
#include <iostream>
#include <cmath>
using namespace std;
int main(){
  double x1,x2,x3,x4;
  double y1,y2,y3,y4;
  int n;
  cin >> n;
  while(n--){
    cin >> x1>> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
  if(fabs((x2 - x1)*(y4 - y3) - (y2 - y1)*(x4 - x3) ) < 10e-12) cout << "YES"<<endl;
  else cout << "NO" << endl;
}
  return 0;
}

Measured memory_bytes: 1224
#include <iostream>

using namespace std;
const int nmax=100005;
int a[nmax];
int pos,n,L,i;
int main()
{
    cin>>n>>L;
    for(i=1;i<=n;i++)
        cin>>a[i];
    for(i=1;i<n;i++)
        if(a[i]+a[i+1]>=L)
          pos=i;
    if(!pos) cout<<"Impossible";
    else
    {
        cout<<"Possible\n";
        for(i=1;i<pos;i++)
            cout<<i<<'\n';
        for(i=n-1;i>pos;i--)
            cout<<i<<'\n';
        cout<<pos;
    }
    return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mxn= 1e5+5;
// check for forloop
// intialize variable
// overflow
// go for easy solution
#define mod 1000000007
ll INF = 1000000000000000005LL;
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
   int n;
   cin>>n;
   ll arr[n];
   ll sum=0;
   for(int i=0;i<n;i++){
       cin>>arr[i];
       sum=sum+arr[i];
       sum%=mod;
   }
   ll ans=0,pref=0;
   for(int i=0;i<n;i++){
       pref+=arr[i];
       pref%=mod;
       ans+=arr[i]*(sum-pref+mod)%mod;
       ans%=mod;
   }
   cout<<ans;
}

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

int main() {
        int A, B, C; cin >> A >> B >> C;
        if ((A < C && C < B) || (B < C && C < A)) {
                cout << "Yes" << "\n";
        } else {
                cout << "No" << "\n";
        }
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	vector<ll>a;
	for(ll i=0;i<n;i++){
		ll now;
		cin>>now;
		a.push_back(now);
	}
	sort(a.begin(),a.end());
	double h=a[n-1]/2.0;
	ll ans=a[0],sa=abs(h-a[0]);
	for(ll i=0;i<n;i++){
		ll now=a[i];
		if(abs(h-now)<sa){
			sa=abs(h-now);
			ans=now;
		}
	}
	cout << a[n-1]<<" "<<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1400
A, B, C, X, Y = map(int, input().split())

min_cost = 1e10
for a in range(X+1):
    c = (X-a)*2
    left_b = max(0, Y - (X-a))
    cost = a*A+round(left_b)*B+c*C
    if cost < min_cost:
        min_cost = cost
    # 残り全部をABピザで賄う場合
    left_b = max(X-a, Y)
    cost = a*A + left_b*2*C
    if cost < min_cost:
        min_cost = cost
print(min_cost)

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

int main() {
  int N, K;
  cin >> N >> K;
  
  long long ans = 0;
  
  long long max_num = 0; 
  long long min_num = 0;
  for (int i = 0; i < K-1; i++) {
    max_num += N-i;
    min_num += i;
  }
  
  for (int i = K-1; i < N+1; i++) {
    max_num += N-i;
    min_num += i;
    ans += max_num - min_num+1;
    ans = ans % 1000000007;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin>>s;
    if((s[0]==s[1] && s[1]==s[2])||(s[1]==s[2] && s[2]==s[3]))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	void doIt() {
		double x = 0,y = 0;
		int angle = 90;
		while(true){
			String[] num = sc.next().split(",");
			int des = Integer.valueOf(num[0]);
			int a = Integer.valueOf(num[1]);
			if(des == 0 && a == 0)break;
			x = x + des * Math.cos(Math.toRadians(angle));
			y = y + des * Math.sin(Math.toRadians(angle));
			angle = angle - Integer.valueOf(num[1]);
		}
		System.out.println((int)x);
		System.out.println((int)y);
     }
    public static void main(String[] args) {
    	// TODO Auto-generated method stub
    	new Main().doIt();
    }
}

Measured memory_bytes: 17148
#デフォルト
import itertools
from collections import defaultdict
import collections
import math
import sys
sys.setrecursionlimit(200000)
mod = 1000000007

x, y = map(int, input().split())

flag = False
for i in range(x + 1):
    for j in range((x + 1) - i):
        if (i * 2 + j * 4) == y and i+j== x:
            flag = True

if flag == False:
    print("No")
else:
    print("Yes")

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define iter(v, i) for (__typeof__((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define fast_io_without_cstdio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define all(v) (v).begin(), (v).end()
#define rep(i, s, e) for (int i = s; i < e; i++)

// START for segment tree
#define params int p, int L, int R
#define housekeep int mid = (L + R) >> 1, left = p << 1, right = left | 1
// END

#ifdef __linux__
#define gc getchar_unlocked
#define pc putchar_unlocked
#else
#define gc getchar
#define pc putchar
#endif

#if __cplusplus <= 199711L
template<class BidirIt>
BidirIt prev(BidirIt it, typename iterator_traits<BidirIt>::difference_type n = 1) {
    advance(it, -n);
    return it;
}

template<class ForwardIt>
ForwardIt next(ForwardIt it, typename iterator_traits<ForwardIt>::difference_type n = 1) {
    advance(it, n);
    return it;
}
#endif

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ldouble;

const double EPS = 1e-9;
const double PI = 3.141592653589793238462;

template<typename T>
inline T sq(T a) { return a * a; }

//#ifdef LOCAL_MACHINE
//#endif

int main() {
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);
    if (a + b - 1 > n) {
        puts("-1");
    } else if (( ll )(n - (a + b - 1)) > (a - 1) * 1LL * (b - 1)) {
        puts("-1");
    } else if (a == 1) {
        for (int i = n; i >= 1; i--)
            printf("%d ", i);
        puts("");
    } else if (b == 1) {
        for (int i = 1; i <= n; i++)
            printf("%d ", i);
        puts("");
    } else {
        int num = n - (a + b - 1);
        for (int i = num + 1; i <= num + a - 1; i++)
            printf("%d ", i);
        if (num != 0) {
            deque<int> vec;
            auto it = vec.insert(vec.begin(), 1) + 1;
            int cur = 1;
            int b_cnt = 1;
            for (int i = 2; i <= num; i++) {
                if (cur == a - 1) {
                    it = vec.insert(vec.begin(), i) + 1;
                    cur = 0;
                    b_cnt++;
                } else {
                    it = vec.insert(it, i) + 1;
                }
                cur++;
            }
            assert(b_cnt <= b - 1);
            for (auto it : vec) printf("%d ", it);
        }
        for (int i = n; i >= n - b + 1; i--)
            printf("%d ", i);
        puts("");
    }
    return 0;
}



Measured memory_bytes: 2816
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define itmin(x,y) (x) = min((x),(y));
#define itmax(x,y) (x) = max((x),(y));
#define cotu cout
#define itn int
const int INF = 1e9 + 7;

int main(){
    int n; cin>>n;
    vector<double> v(n+1);
    for(int i = 1; i <= n; i++) cin>>v[i];
    vector<double> dp(n+1);
    dp[0] = 1;
    for(int coin = 1; coin <= n; coin++){
        for(int head = coin; head >= 1; head--){
            dp[head] = dp[head-1] * v[coin] + dp[head] * (1-v[coin]);
        }
    }
    /*for(int i = 0; i <= n; i++){
        cout<<dp[i]<<" ";
    }*/
    cout<<fixed<<setprecision(10)<<dp[n/2+1];
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long     ll;
#define fast          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define last          freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fr            first
#define sc            second
#define lcm(a,b)      (a*b)/__gcd(a,b)
#define com(i,n)      for(int i=0;i<n;i++)
#define dom(i,n)      for(int i=1;i<=n;i++)
#define mom(i,n)      for(int i=n;i>=0;i--)
#define sortI(a,n)    sort(a,a+n)
#define sortD(a,n)    sort(a,a+n,greater<int>())
#define sortvi(a)     sort(a.begin(),a.end())
#define sortvd(a)     sort(a.begin(),a.end(),greater<int>())
#define sumall(a,x)   accumulate(a.begin(),a.end(),x)
#define pi            3.14159265358979323846264338327950
#define endl          '\n'
using namespace std;
int main()
{
     ll n,ans=0;
     cin>>n;
     vector<ll>mp(n+1,0);
     dom(i,n)
     {
          ll sta=i;
          while(sta<=n)
          {
               mp[sta]++;
               sta+=i;
          }
     }
     dom(i,n)
     {
          ans+=i*mp[i];
     }
     cout << ans << endl;
}


Measured memory_bytes: 81404
#include<bits/stdc++.h>
using namespace std;
#define M 1e9
#define C 998244353
#define pi 3.14159265359
#define loop(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
#define rloop(i,a,b) for(ll i = ll(a); i >= ll(b); --i)
#define sloop(i,a) for (std::set<ll>::iterator i = a.begin(); i != a.end(); ++i)
#define pb push_back
typedef long long int ll;
typedef unsigned long long int ull;

void solve(){
    ll n,i,m,b,x,y,ans=0;
    string s,t,sub;
    cin >> s >> t;
    // cout << t.substr(0,s.length()-1) << "\n";   
    if(t.substr(0,s.length()) == s){
        cout << "Yes" << "\n";
    }
    else{
        cout << "No" << "\n";
    }
}

int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    loop(f,0,t){    
        solve();
    }   
}   

Measured memory_bytes: 3576