akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    a = list(map(int, input().split()))
    four_count = 0
    two_count = 0

    for ai in a:
        if ai % 4 == 0:
            four_count += 1
        elif ai % 2 == 0:
            two_count += 1

    if four_count >= n // 2:
        print('Yes')
    else:
        need = n - 2 * four_count

        if two_count >= need:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()


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

int main() {
  int a,b;
  int N = 0;
  int ab =0;
  int ba =0;
  int sum =0;
  string ans;
  cin >> a >> b;
  if(a <= b){
    ab = a;
    sum = a;
    N = b-1;
    rep(i, N) {
    ab *= 10;
    sum += ab;
    }
  } else{
    ba = b;
    sum = b;
    N = a-1;
    rep(i, N) {
    ba *= 10;
    sum += ba;
    }
  }
  ans = std::to_string(sum);
  cout << ans << endl;
}


Measured memory_bytes: 256
var a,b,c,tt:array[1..100000]of longint;
b1:array[0..100000]of int64;
bao,t,w,i,x,n:longint;sum:int64;
procedure sort(l,r: longint);
var i,j,x,y: longint;
begin
i:=l;j:=r;x:=a[(l+r) div 2];
repeat
while a[i]<x do inc(i);
while x<a[j] do dec(j);
if not(i>j) then
  begin
  y:=a[i];a[i]:=a[j];a[j]:=y;
  inc(i);j:=j-1;
  end;
until i>j;
if l<j then sort(l,j);
if i<r then sort(i,r);
end;
begin

readln(n);
for I:=1 to n do read(a[i]);
for i:=1 to n do read(b[i]);
for I:=1 to n do read(c[i]);
sort(1,n);
tt:=a;a:=b;sort(1,n);b:=a;a:=tt;
tt:=a;a:=c;sort(1,n);c:=a;a:=tt;
for i:=1 to n do
  begin
  t:=1;w:=n;bao:=n+1;
  while t<=w do
    begin
    x:=(t+w)div 2;
    if c[x]<=b[i] then t:=x+1
    else
      begin
      bao:=x;w:=x-1;
      end;
    end;
  b1[i]:=n-bao+1;
  end;
for i:=1 to n do b1[i]:=b1[i-1]+b1[i];
for i:=1 to n do
  begin
  t:=1;w:=n;bao:=n+1;
  while t<=w do
    begin
    x:=(t+w)div 2;
    if b[x]<=a[i] then t:=x+1
    else
      begin
      bao:=x;w:=x-1;
      end;
    end;
  sum:=sum+b1[n]-b1[bao-1];
  end;
write(sum);

end.


Measured memory_bytes: 2432
import math 
n = int(input())
lp = list(map(int,input().split()))
lq = list(map(int,input().split()))
def fun(l):
    a = 1 #取り出す
    count = 1
    li = []
    for i in range(n):
        ika = 0
        for j in li:
            if j < l[i]:
                ika += 1
        if l[i] == i+1 and ika == l[i]:
                c = 0
                a = l[i]
        else:
                c = (l[i]-ika-1)*math.factorial(n-i-1)
                a = l[i]
            
        count += c
        li.append(l[i])
    return count
   

print(abs(fun(lp)-fun(lq)))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <climits>
#define ll long long
#define MAX 25 * 1e13
#define N  200010

#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define EB(X) emplace_back(X)
#define REP(i,a) for(int i=0;i<(a);++i)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()
#define VI vector<int>;

using namespace std;
int MOD = 1000000007;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;
  cin >> n >> k;
  ll ret = 0;
  vector<ll> sum(n+1);
  sum[1] = 1;
  for (ll i = 2 ; i <= n ; i++ ) { // range [0,n-1]
    sum[i] = sum[i-1] + i;
    //sum[i] %= MOD;
  }
  for (int l = k ; l <= n+1 ; l++ ) {
    ll mins = 0;
    ll maxs = 0;
    mins = sum[l-1];
    if( l >= n ) maxs = sum[n];
    else {
      maxs = sum[n] - sum[n-l];
    }
    //cout << "max" << maxs << endl;
    //cout << "min" << mins << endl;

    ret += (maxs - mins + 1 );
    ret %= MOD;
  }
  cout << ret << endl;

  return 0;

}



Measured memory_bytes: 4356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a.at(i);
	sort(a.begin(),a.end());
	vector<ll> b(n+1);
	rep(i,n) b.at(i+1)=b.at(i)+a.at(i);
	int ans=1;
	for(int i=n-1;i>0;--i){
		if(b.at(i)*2>=a.at(i)) ans++;
		else break;
	}
	cout << ans << endl;
}

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

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int n, A, B, C;
vector<int> l;

llong solve(int num, int a, int b, int c, int mp){
  if(num == n){
    if(a == 0 || b == 0 || c == 0) return INF;
    return mp + abs(a-A) + abs(b-B) + abs(c-C);
  }
  llong res = INF;
  res = min(res, solve(num+1, a, b, c, mp));
  res = min(res, solve(num+1, a+l[num], b, c, mp+10 * (a != 0)));
  res = min(res, solve(num+1, a, b+l[num], c, mp+10 * (b != 0)));
  res = min(res, solve(num+1, a, b, c+l[num], mp+10 * (c != 0)));
  return res;
}

int main(){

  
  cin >> n >> A >> B >> C;
  REP(i,n){
    int tmp;
    cin >> tmp;
    l.pb(tmp);
  }
  
  cout << solve(0, 0, 0, 0, 0) << endl;;
  return 0;
}



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

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> xs;
	for(int i = 0;i < M;i++){
		int x;
		cin >> x;
		xs.push_back(x);
	}
	sort(xs.begin(), xs.end());
	vector<int> ds;
	for(int i = 1;i < M;i++){
		ds.push_back(xs[i] - xs[i - 1]);
	}
	sort(ds.begin(), ds.end());
	if(N > M) {
		cout << 0 << endl;
		return 0;
	}
	cout << accumulate(ds.begin(), ds.begin() + (M - N), 0) << endl;
	return 0;
}


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

int main() {
    string S;
    int N, sN=0;
    int tmp, minNum=1e9, maxNum=-1e9;
    cin >> S;
    N = stoi(S);
    
    for (int i=0; i < S.size(); i++){
	sN += S[i]-'0';
    }
    
    cout << (N%sN==0 ? "Yes": "No") << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N; cin>>N;
    vi a(N);
    rep(i,N) cin>>a.at(i);
    int counter=0;
    rep(i,N) counter+=a.at(i);
    cout<<counter-N<<endl;
}

Measured memory_bytes: 256
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

#include <bits/stdc++.h>
using namespace std;

using i64 = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

i64 read() {
    using namespace _buff;
    i64 ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

using P = pair<int, int>;
#define fi first
#define se second
const int N = 50 << 18 | 1;
const int M = (1 << 25) - 1;

int tot, key[N], nxt[N], head[M + 1]; P val[N];

P& find(int k) {
    int id = k & M;
    for (int i = head[id]; i; i = nxt[i]) {
        if (key[i] == k) {
            return val[i];
        }
    }
    ++tot;
    key[tot] = k;
    nxt[tot] = head[id];
    head[id] = tot;
    return val[tot];
}

int main() {
    int n = read(), k = read();
    vector<vector<i64>> c(n + 1, vector<i64>(n + 1));
    for (int i = 0; i <= n; ++i) {
        c[i][0] = 1;
        for (int j = 1; j <= i; ++j) {
            c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
        }
    }
    vector<i64> coef(n + 1);
    for (int i = 0; i <= n; ++i) {
        coef[i] = accumulate(begin(c[i]) + 1, begin(c[i]) + k + 1, 0LL);
    }


    int s = read(), t = read();
    if ((s & t) != s) {
        return puts("0"), 0;
    }
    vector<int> dig, pw;
    for (int x = s ^ t, y = 1, i = 0; x; ++i, x >>= 1) {
        pw.emplace_back(y); y *= 3;
        if (x & 1) dig.emplace_back(i);
    }
    while (n--) {
        int x = read();
        if ((x & s) == s && (x | t) == t) {
            static int sum[1 << 18], cnt[1 << 18];
            int cur = 0;
            for (int i = 0; i < (int) dig.size(); ++i) {
                int d = dig[i];
                cur += (x >> d & 1) * pw[i];
                sum[1 << i] = (2 - (x >> d & 1)) * pw[i];
                cnt[1 << i] = 1;
            }
            for (int i = 0, _ = 1 << dig.size(); i <_; ++i) {
                sum[i] = sum[i & -i] + sum[i ^ (i & -i)];
                cnt[i] = cnt[i & -i] + cnt[i ^ (i & -i)];
                auto &val = find(sum[i] + cur);
                ++val.fi; val.se = cnt[i];
            }
        }
    }

    i64 ans = 0;
    for (int i = 1; i <= tot; ++i) {
        auto &p = val[i];
        ans += coef[p.fi] * ((dig.size() - p.se) & 1 ? -1 : 1);
    }
    cout << ans;
    return 0;
}


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

int main() {
  std::string x(10, ' ');
  std::string y(10, ' ');
  std::string z(10, ' ');
  scanf("%s", &x[0], x.size());
  scanf("%s", &y[0], y.size());
  scanf("%s", &z[0], z.size());
  printf("%c%c%c", x[0] - 0x20, y[0] - 0x20, z[0] - 0x20);
}


Measured memory_bytes: 256
program answer
  implicit none
  integer :: i, j, N, M, C, ans, sum
  integer, allocatable :: B(:), A(:,:)
  read(*,*) N, M, C
  allocate(B(M))
  allocate(A(N,M))
  read(*,*) B
  do i = 1, N
     read(*,*) A(i,1:M)
  end do
  ans=0
  do i = 1, N
     sum=0
     do j = 1, M
        sum=sum+A(i,j)*B(j)
     end do
     sum=sum+C
     if(sum>0) then
        ans=ans+1
     end if
  end do
  write(*,*) ans
  deallocate(A,B)
  stop
 end program answer

Measured memory_bytes: 2932
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>

using namespace std;
typedef pair<int, int> P;

int h, w, n;
int x1[1005], x2[1005], y1[1005], y2[1005];
vector<int> X, Y;
bool map[2005][2005];
int xsize, ysize;

int compress(int val, vector<int> *vec)
{
	return lower_bound(vec->begin(), vec->end(), val) - vec->begin();
}

void bfs(int x, int y)
{
	int vec_x[] = {-1, 1, 0, 0}, vec_y[] = {0, 0, -1, 1};
	
	queue<P> Q;
	Q.push( make_pair(x, y) );
	map[x][y] = true;
	
	int cx, cy, nx, ny;
	while((int)Q.size() > 0){
		cx = Q.front().first;
		cy = Q.front().second;
		Q.pop();
		for(int i = 0; i < 4; i++){
			nx = cx + vec_x[i], ny = cy + vec_y[i];
			if(nx < 0 || nx >= xsize || ny < 0 || ny >= ysize) continue;
			if(!map[nx][ny]){
				Q.push(make_pair(nx, ny));
				map[nx][ny] = true;
			}
		}
	}
}

int main(void)
{
	while(1){
		cin >> w >> h;
		if(w == 0 && h == 0) break;
		
		cin >> n;
		X.clear(), Y.clear();
		
		for(int i = 0; i < n; i++){
			cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
			X.push_back(x1[i]); if(x2[i] < w) X.push_back(x2[i]);
			Y.push_back(y1[i]); if(y2[i] < h) Y.push_back(y2[i]);
		}
		X.push_back(0), Y.push_back(0);
		
		sort(X.begin(), X.end());
		sort(Y.begin(), Y.end());
		X.erase( unique(X.begin(), X.end()), X.end() );
		Y.erase( unique(Y.begin(), Y.end()), Y.end() );
		
		xsize = (int)X.size(), ysize = (int)Y.size();
		for(int x = 0; x < xsize; x++){
			for(int y = 0; y < ysize; y++){
				map[x][y] = false;
			}
		}
		
		for(int i = 0; i < n; i++){
			int sx = compress(x1[i], &X), sy = compress(y1[i], &Y);
			int tx = compress(x2[i], &X), ty = compress(y2[i], &Y);
			for(int x = sx; x < tx; x++){
				for(int y = sy; y < ty; y++){
					map[x][y] = true;
				}
			}
		}
		
		
		int ans = 0;
		for(int x = 0; x < xsize; x++){
			for(int y = 0; y < ysize; y++){
				if(!map[x][y]){
					bfs(x, y);
					ans++;
				}
			}
		}
		
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 4184
def inv_gcd(a, b):
    a %= b
    if a == 0:
        return (b, 0)
    s = b
    t = a
    m0 = 0
    m1 = 1

    while t:
        u = s // t
        s -= t * u
        m0 -= m1 * u 
        s, t = t, s
        m0, m1 = m1, m0

    if m0 < 0:
        m0 += b // s

    return (s, m0)

def crt(r, m):
    assert len(r) == len(m)
    n = len(r)
    r0 = 0
    m0 = 1
    for i in range(n):
        assert 1 <= m[i]
        r1 = r[i] % m[i]
        m1 = m[i]
        if m0 < m1:
            r0, r1 = r1, r0
            m0, m1 = m1, m0
        if m0 % m1 == 0:
            if r0 % m1 != r1:
                return (0, 0)
            continue
        g, im = inv_gcd(m0, m1)
        u1 = m1 // g
        if (r1 - r0) % g:
            return (0, 0)
        x = (r1 - r0) // g % u1 * im % u1
        r0 += x * m0
        m0 *= u1  # -> lcm(m0, m1)
        if r0 < 0:
            r0 += m0

    return (r0, m0)

def prime_de(number):
    factor = []
    div = 2
    while div*div <= number:
        cnt = 0
        while number % div == 0:
            cnt += 1
            number //= div
        if cnt != 0:
            factor.append((div, cnt))
        div += 1
    if number > 1:
        factor.append((number, 1))
    return factor

N, = map(int, input().split())
p = prime_de(N)
lp = len(p)
R = 10**18
for i in range(2**lp):
    l = []
    for j in range(lp):
        i, m = divmod(i, 2)
        l.append(m)
    r, m = [], []
    for j in range(lp):
        a, b = p[j]
        c = a**b if a!=2 else a**(b+1)
        if l[j]:
            r.append(0)
        else:
            r.append(c-1)
        m.append(c)
    x, y = crt(r, m)
    if x:
        R = min(R, x)
    else:
        R = min(R, y)
print(R)



Measured memory_bytes: 69100
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;

int main(){
	int N, K;
	cin >> N >> K;
	map<int, int> B;
	for(int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		B[a]++;
	}
	vector<int> v;
	EACH(i, B) {
		v.push_back(i->second);
	}
	sort(ALL(v));
	int res = 0;
	int t = v.size() < K ? 0: v.size() - K;
	for(int i = 0; i < t; ++i) {
		res += v[i];
	}
	cout << res << endl;
	return 0;
}


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

int main() {
  //input
  int N;
  cin >> N;
  int a[N],b[N],c[N];
  for(int i=0; i<N; i++){cin >> a[i] >> b[i] >> c[i];}
  
  //main
  int INF = 1e9;
  int memo[N][3];
  
  for(int i=0; i<N; i++){
    for(int j=0; j<3; j++){
      memo[i][j] = -INF;
    }
  }
  memo[0][0] = a[0];
  memo[0][1] = b[0];
  memo[0][2] = c[0];
  
  for(int i=0; i<N-1; i++) {
    memo[i+1][0] = max(memo[i][1]+a[i+1],memo[i][2]+a[i+1]);
    memo[i+1][1] = max(memo[i][0]+b[i+1],memo[i][2]+b[i+1]);
    memo[i+1][2] = max(memo[i][0]+c[i+1],memo[i][1]+c[i+1]);
  }
  
  int ans = max(memo[N-1][0],memo[N-1][1]);
  ans = max(ans,memo[N-1][2]);
  
  //output  
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    int h, a;
    cin >> h >> a;

    int ans = h / a;
    if (h % a == 0) cout << ans << endl;
    else cout << ans + 1 << endl;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		int N = sc.nextInt();

		int[] ans = new int[N];
		
		for(int i=1; i*i<=N; i++) {
			for(int j=1; j*j<=N; j++) {
				for(int k=1; k*k<=N; k++) {
					int n = i*i+j*j+k*k+i*j+j*k+k*i;
					if(n<=N)
						ans[n-1]++;
				}
			}
		}
		for(int i=0; i<N; i++)
			pw.println(ans[i]);

		sc.close();
		pw.close();
	}
}


Measured memory_bytes: 29192
#include<stdio.h>
#define MAX 100

int main(){

  int n,A[MAX+1],B[MAX+1][MAX+1];
  int i,j,k,u,sum;
  scanf("%d",&n);


  for(i=1;i<=n;i++){
    scanf("%d%d",&A[i-1],&A[i]);
  }

  for(i=1;i<=n;i++)B[i][i]=0;
  
    for(u=2;u<=n;u++){
      for(i=0;i<=n-u+1;i++){
	j = i+u-1;
	B[i][j] = (1<<21);
	for(k=i;k<=j-1;k++){
	  sum = B[i][k] + B[k+1][j] + A[i-1] * A[k] * A[j];
	  if(B[i][j] > sum)  B[i][j] = sum;
	  } 
	}
      }
    
  

  printf("%d\n",B[1][n]);

  return 0;

}

Measured memory_bytes: 636
import sys


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

    if not (x in P):
        print(x)
        sys.exit()

    for i in range(101):
        x1 = max(0, x - (i + 1))
        x2 = min(101, x + (i + 1))

        if x1 == 0:
            print(0)
            sys.exit()
            
        if not (x1 in P):
            print(x1)
            sys.exit()

        if x2 == 101:
            print(101)
            sys.exit()
            
        if not (x2 in P):
            print(x2)
            sys.exit()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9212
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    string S;
    cin >> S;
    int l = stoi(S.substr(0, 2)), r = stoi(S.substr(2, 2));
    if (0 < l && l <= 12) {
        if (0 < r && r <= 12) {
            cout << "AMBIGUOUS" << endl;
            return 0;
        } else {
            cout << "MMYY" << endl;
            return 0;
        }
    }
    if (0 < r && r <= 12) {
        cout << "YYMM" << endl;
    } else {
        cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d%= 2019
    counts[num] += 1

ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans) # 答えの出力


Measured memory_bytes: 9384
n=int(input())
l=[]
for i in range(n):
    lt=list(map(str,input().split()))
    l.append(lt)
for i in range(4):
    for j in range(1,13+1):
        if i==0:
            m='S'
        elif i==1:
            m='H'
        elif i==2:
            m='C'
        else:
            m='D'
        temp=[m,str(j)]
        if l.count(temp)==0:
            print(m,j)


Measured memory_bytes: 5592
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll=long long;
using pint=pair<int,int>;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define el '\n'
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
#define $in(v,n) ;rep(II,0,n)cin>>v[II]
inline void IN(void){return;}
template<typename F,typename... R>inline void IN(F& f, R&... r){cin>>f;IN(r...);}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int k, n;
    IN(k, n);
    vector<int> a(n+1);
    int f; cin >> f; a[0] = 0;
    rep(i, 1, n){
        int t; cin >> t;
        t -= f;
        a[i] = t;
    }
    a[n] = k;

    ll tot = 0;
    int maxL = 0;
    rep(i, 1, n+1){
        int t = a[i] - a[i-1];
        chmax(maxL, t);
        tot += t;
    }

    cout << tot-maxL << el;
    return 0;
}


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

int main() {
	int x[5];
	
	int ans = 0;
	for (int i = 0; i < 5; i++) {
		cin >> x[i];
		if (x[i] == 0) {
			ans = i+1;
		}
	}

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

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 666666;
int n,a[N],b[N],c[N];
int main() {
	read(n);rep(i,1,n)read(a[i]);
	int l=1,r=n,res=n;
	while(l<=r){
		int mid=(l+r)>>1;//memset(b,0,sizeof(b));
		bool gg=0;int top=0;
		rep(i,1,n)if(a[i]<=a[i-1]){
			if(mid==1){gg=1;break;}
			while(top&&b[top]>a[i])top--;//WA
			int j=a[i];while(top-(a[i]-j)>0&&b[top-(a[i]-j)]==j&&c[top-(a[i]-j)]==mid-1)j--;
			if(j<1){gg=1;break;}//WA
			while(top&&b[top]>j)top--;
			if(b[top]!=j)b[++top]=j,c[top]=0;c[top]++;
		//	rep(j,1,top)printf("[%d,%d]",b[j],c[j]);puts("");
		}
		if(!gg)res=mid,r=mid-1;else l=mid+1;
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main() {
  int a;
  string s;
  cin >> a >> s;
  if (a >= 3200) cout << s << endl;
  else cout << "red" << endl;
  return(0);
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
s = input()

handstand = [0]
stand = []
isHandstand = True
if s[0] == '0':
  stand.append(0)
  isHandstand = False

for c in s:
  if isHandstand:
    if c == '0':
      stand.append(1)
      isHandstand = False
    else:
      handstand[-1] += 1
  else:
    if c == '0':
      stand[-1] += 1
    else:
      handstand.append(1)
      isHandstand = True

if not isHandstand:
  handstand.append(0)

answer = N

if K < len(stand):
  answer = sum(handstand[:K+1]) + sum(stand[:K])
  prev = answer
  for start in range(1, len(stand) - K + 1):
    prev = prev - handstand[start - 1] - stand[start - 1] + handstand[start + K] + stand[start + K - 1]
    answer = max(answer, prev)    

print(answer)


Measured memory_bytes: 4476
N,M = map(int, input().split())
xyz = [tuple(map(int, input().split())) for _ in range(N)]

cakes = [[] for _ in range(1 << 3)]

for bit in range(1 << 3):
    for i in range(N):
        total = 0
        for j in range(3):
            if bit & (1 << j):
                total += -1 * xyz[i][j]
            else:
                total += xyz[i][j]

        cakes[bit].append((total, xyz[i][0], xyz[i][1], xyz[i][2]))


ans = []
for i in range(1 << 3):
    total = 0
    cakes[i].sort(reverse=True)
    x,y,z = 0,0,0
    #print("-----",cakes[i])
    for j in range(M):
        x += cakes[i][j][1]
        y += cakes[i][j][2]
        z += cakes[i][j][3]


    ans.append(abs(x) + abs(y) + abs(z))

print(max(ans))

#print(ans)


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

	string s;
	cin>>s;

	if(s[2]==s[3] && s[4]==s[5])cout<<"Yes";
	else cout<<"No";

	cout<<endl;

	return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main() {
	llong N;
	vector<P> ab;

	cin >> N;
	ab.resize(N);
	for (int i = 0; i < N; i++)
		cin >> ab[i].second >> ab[i].first;

	sort(ALL(ab));

	bool check = true;
	llong now = 0;
	for (int i = 0; i < N; ++i) {
		if (ab[i].first < ab[i].second + now)
			check = false;
		now += ab[i].second;
	}

	if (check)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

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

int main() {

  string a;
  cin >> a;
  
  if ( (a[0] == a[1] && a[1] == a[2]) || (a[1] == a[2] && a[2] == a[3])){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }


}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    if(A*B < N || A+B > N+1) {cout << -1 << endl; exit(0);};
    //now:=配置した中で最大の整数
    ll now = 0, rem = N-A;
    rep(i, A){
        //ここではx個階段状に並べる
        int x = min(B, rem+1);
        rem -= x-1;
        rep3(j, now+x, now+1){
            cout << j << endl;
        }
        now += x;
    }
}

Measured memory_bytes: 2176
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

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

    int a;cin>>a;
    int out=a-1;
    for(int i=2;i*i<=a;i++)if(a%i==0)
        cmin(out,i-1+a/i-1);
    cout<<out<<endl;
}


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

using namespace std;

#define int long long
int const maxn = 1e5 + 5;
vector < int > G[maxn], g[maxn], go[maxn], cmp[maxn];
int used[maxn], pos[maxn], numb[maxn];
int cur;
vector < int > topsort;
vector < pair < int, int > > to[maxn];

void dfs2(int v) {
    for (auto key : to[v]) {
        if (pos[key.first] == -1) {
            pos[key.first] = pos[v] + key.second;
            dfs2(key.first);
        }
        else if (pos[key.first] != pos[v] + key.second) {
            cout << "No" << '\n';
            exit(0);
        }
    }
}

void dfs1(int v) {
    used[v] = 2;
    for (auto u : go[v]) {
        if (used[u] != 2) dfs1(u);
    }
    topsort.push_back(v);
}

void dfs(int v) {
    used[v] = 1;
    cmp[cur].push_back(v);
    numb[v] = cur;
    for (auto u : G[v]) {
        if (used[u] == 0) dfs(u);
    }
}

main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m, l, r, d;
    cin >> n >> m;
    for (int i = 1; i <= m; ++i) {
        cin >> l >> r >> d;
        to[l].push_back({r, d});
        to[r].push_back({l, -d});
        if (d == 0) {
            G[l].push_back(r);
            G[r].push_back(l);
        }
        else {
            g[l].push_back(r);
        }
    }
    for (int i = 1; i <= n; ++i) {
        if (used[i] == 0) cur++, dfs(i);
    }
    for (int i = 1; i <= cur; ++i) {
        for (auto key : cmp[i]) {
            for (auto elem : g[key]) go[i].push_back(numb[elem]);
        }
    }
    for (int i = 1; i <= cur; ++i) {
        if (used[i] == 1) dfs1(i);
    }
    reverse(topsort.begin(), topsort.end());
    for (int i = 1; i <= n; ++i) pos[i] = -1;
    vector < int > T;
    for (auto key : topsort) {
        for (auto elem : cmp[key]) T.push_back(elem);
    }
    for (int i = 0; i < (int)T.size(); ++i) {
        if (pos[T[i]] == -1) {
            pos[T[i]] = 0;
            dfs2(T[i]);
        }
    }
    for (int i = 1; i <= n; ++i) {
        if (pos[i] < 0 || pos[i] > 1000000000) {
            cout << "No" << '\n';
            exit(0);
        }
    }
    cout << "Yes" << '\n';
    return 0;
}



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

int main() {
  string a,b;
  cin >> a >> b;
  for (int i=0;i<max(a.length(),b.length());i++) {
    if (a.length()>i) cout << a[i];
    if (b.length()>i) cout << b[i];
  }
}

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

namespace ConsoleApplication1
{
  class Program
  {
    static void Main(string[] args)
    {
      string line = Console.ReadLine();
      string[] split = line.Split(' ');
      int n = Int32.Parse(split[0]);

      int[] ai = new int[81];
      line = Console.ReadLine();
      split = line.Split(' ');
      for (int i = 0; i < n; ++i)
      {
        ai[i] = Int32.Parse(split[i]);
      }
      ai[n] = -1;

      long money = 1000;
      long kabu = 0;
      for (int i = 0; i < n; ++i)
      {
        // 翌日が上がるなら買い
        if (ai[i] < ai[i + 1])
        {
          if (money >= ai[i])
          {
            kabu = (money / ai[i]);
            money %= ai[i];
          }
        }
        // 翌日が下がるなら売り
        else if (ai[i] > ai[i + 1])
        {
          if (kabu > 0)
          {
            money += (ai[i] * kabu);
            kabu = 0;
          }
        }
      }

      Console.WriteLine(money);

      int a = 0;
    }
  }
}


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

int dp[100005];

int main() {
	int n,k;
	cin>>n>>k;
	int h[n+1];
	for(int i=1;i<=n;i++)
		cin>>h[i];
	for(int i=n-1;i>0;i--){
		dp[i]=dp[i+1]+abs(h[i]-h[i+1]);
		for(int j=2;j<=min(k,n-i);j++)
			dp[i]=min(dp[i],dp[i+j]+abs(h[i]-h[i+j]));
	}
	cout<<dp[1]<<'\n';
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;

int main(){
    int X,ans=0;
    cin >> X;
    for(int i=1; i<=31;i++){
        for(int j=2; j<=9;j++){
            if(pow(i,j)<=X && pow(i,j) >= ans){
                ans = pow(i,j);
            }
        }
    }
    cout <<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
using namespace std;
int main() {
    int a, b, c, x;
    int ans = 0;
    cin >> a >> b >> c >> x;
    for(int i = 0; i <= a; i++) {
        for(int j = 0; j <= b; j++) {
            for(int k = 0; k <= c; k++) {
                if ((500 * i + 100 * j + 50 * k) == x) ans += 1;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    string s;
    cin >> s;
    int cnt = 0, ans = s.size();
    rep(i, s.size()){
        if(s[i] == 'S')cnt++;
        else{
            if(cnt > 0){
                cnt--;
                ans-=2;
            }
        }
    }
    cout << ans << endl;
}   


Measured memory_bytes: 640
use std::io;


fn main() {
    println!("{}", read_one::<String>().replace(",", " "));
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

using namespace std;

#define fi first
#define se second
typedef pair<int, int> ii;

const int N = 1e3 + 5, mod = 1e9 + 7;
int n, m, cntR[N * N], cntC[N * N], a[N], b[N], row, col, ans = 1;
ii pos[N * N];

int main () {
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", a + i);
        ++cntR[ a[i] ];
        pos[ a[i] ].fi = i;
    }
    for (int i = 1; i <= m; ++i) {
        scanf("%d", b + i);
        ++cntC[ b[i] ];
        pos[ b[i] ].se = i;
    }

    for (int i = 1; i <= n * m; ++i) if (cntC[i] > 1 || cntR[i] > 1) return printf("0"), 0;

    for (int i = n * m; i > 0; --i) {
        if (pos[i].fi && pos[i].se) {

        }
        else if (pos[i].fi) {
            ans = 1LL * ans * col % mod;
        }
        else if (pos[i].se) {
            ans = 1LL * ans * row % mod;
        }
        else {
            ans = 1LL * ans * max(0, row * col - (n * m - i) ) % mod;
        }
        row += (pos[i].fi > 0);
        col += (pos[i].se > 0);
//        cout << "ans = " << ans << '\n';
    }

    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	int beki = 1;

	for (int n = 0; n < N; n++) {
		beki *= 2;
	}

	vector<int> k(M);
	vector<vector<int>> s(M);
	vector<int> p(M);

	for (int m = 0; m < M; m++) {

		cin >> k[m];
		for (int i = 0; i < k[m]; i++) {
			int ss;
			cin >> ss;
			s[m].push_back(ss - 1);
		}
	}

	for (int m = 0; m < M; m++) {
		cin >> p[m];
	}

	int cnt = 0;
	for (int i = 0; i < beki; i++) {
		bool all_on = true;
		vector<int> bin(N);
		int tmp = i;
		for (int n = 0; n < N; n++) {
			bin[n] = tmp % 2;
			tmp /= 2;
		}
		for (int m = 0; m < M; m++) {
			int on_sw = 0;
			for (int j = 0; j < k[m]; j++) {
				on_sw += bin[s[m][j]];
			}
			if ((on_sw % 2) != p[m])
				all_on = false;
		}
		if (all_on) {
			cnt++;
		}
	}

	cout << cnt;

	return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  double W, H, x, y, r;
  scanf("%lf %lf %lf %lf %lf",&W, &H, &x, &y, &r);
  if(H >= y+r && W >= x+r && 0 <= x-r && 0 <= y-0)printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 1812
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int fn(long long x, long long y, long long z){
  return x*x + y*y + z*z + x*y + y*z + z*x;
}
int main(){
  long long n;
  cin >> n;
  vector<long long> h(n);
  rep(i,n) cin >> h.at(i);
  int ans = 0;
  int num = 0;
  rep(i,n-1){
    if(h.at(i) >= h.at(i+1)) num++;
    else if(h.at(i) < h.at(i+1)) {
      if(ans < num ) ans = num;
      num = 0;
    }
  }
  if( ans < num) ans = num;
  cout << ans << endl;
}

Measured memory_bytes: 4044
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#define ll long long
using namespace std;

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0&&c>0)
    {
        c=c-b;
        if(c<=0)
        {
            break;
        }
        a=a-d;
    }
    if(a>0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
int main(void)
{
    double r,a,b;
    scanf("%lf",&r);
    if(r>0&&r<10000)
    {
    a=2*r*3.141592653589;
    b=r*r*3.141592653589;
    printf("%lf %lf\n",b,a);
    }
    return 0;
}


Measured memory_bytes: 2040
N = int(input())
S = [i for i in input()]
alpha=['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
ans=''
for c in S:
    cnt = alpha.index(c)+N
    if cnt > 25:
        cnt=cnt-26
    c = alpha[cnt]
    ans+=c
print(ans)

Measured memory_bytes: 3188
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        if(b/a >= c) System.out.println(c);
        else System.out.println(b/a);
    }
}

Measured memory_bytes: 23252
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
using namespace std;
LL n,a,b;
int main()
{
    cin>>n>>a>>b;
    if(b<a)swap(a,b);
    if((a-b)&1)
    {
        cout<<min(a+(b-1-a)/2,(n-b+1)+(b-a-1)/2)<<endl;
    }
    else
    {
        cout<<(b-a)/2<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import math

a, b, h, m = map(int, input().split())

rada = 0.5 * (h * 60 + m)
radb = 6 * m

rad = rada - radb
rad = rad / 180 * math.pi
    
l = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(rad))
print(l)

Measured memory_bytes: 9560
#include <iostream>
#include <cmath>

using namespace std;

bool check(int n, int m)
{
  if( n>m )
    return false;
  bool c3 = false, c5 = false, c7 = false;
  while( n!= 0 )
    {
      if( n%10 == 3)
	c3 = true;
      else if ( n%10 == 5)
	c5 = true;
      else if ( n%10 == 7)
	c7 = true;
      n = n/10;
    }
  return c3 && c5 && c7;
}

long long dfs(int l, int n, int m)
{
  if( l==0 )
    {
      if(check(n, m))
	{
	  //	  cout << "n=" << n << endl;
	  return 1;
	}
      else
	return 0;
    }
  
  return dfs(l-1, 10*n+3, m)+dfs(l-1, 10*n+5, m)+dfs(l-1, 10*n+7, m);
}

int main()
{
  int N;
  cin >> N;
  int l = int(log10(N));
  long long  out = 0;
  //  cout << l << endl;
  for( int i=0;i<l+2;i++ )
    {
      out += dfs(i, 0, N); 
    }

  cout << out << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int a[100000];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	sort(a, a + N);
	int pos = N - 1;
	long long x1 = -1, x2 = -1;
	while (pos > 0) {
		if (a[pos] == a[pos - 1]) {
			if (x1 == -1) x1 = a[pos];
			else x2 = a[pos];
			pos--;
		}
		pos--;
		if (x2 != -1) break;
	}
	if (x2 == -1) cout << 0 << endl;
	else cout << x1*x2 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;

int a[5][5], b[5][5];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> a[i][j];
        }
    }
    int x;
    cin >> x;
    map<int, int> mp;
    while(x--){
        int n;
        cin >> n;
        mp[n] = 1;
    }
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            if(mp[a[i][j]]) b[i][j] = 1;
        }
    }
    bool found = 0;
    for(int i = 0; i < 3; i++){
        int c = 0;
        for(int j = 0; j < 3; j++){
            if(b[i][j]) c++;
        }
        if(c == 3) found = 1;
        c = 0;
        for(int j = 0; j < 3; j++){
            if(b[j][i]) c++;
        }
        if(c == 3) found = 1;
    }
    int c = 0;
    for(int i = 0; i < 3; i++) if(b[i][i]) c++;
    if(c == 3) found = 1;
    c = 0;
    for(int i = 0, j = 2; i < 3; i++, j--) if(b[i][j]) c++;
    if(c == 3) found = 1;
    if(found) cout << "Yes";
    else cout << "No";



    return 0;
}


Measured memory_bytes: 3648
import sys


def main():
    s, t = sys.stdin.readline().strip().split()
    a, b = [int(s) for s in sys.stdin.readline().strip().split()]
    u = sys.stdin.readline().strip()

    if u == s:
        print(a-1, b)
    else:
        print(a, b-1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include<stdio.h>
int main(void){
        int n,h[100],i,m=1,k;
        scanf("%d",&n);
        for(i=0;i<n;i++)
                scanf("%d",&h[i]);
        k=h[0];
        for(i=1;i<n;i++){
        if(k<=h[i]){k=h[i]; m++;}}
        printf("%d",m);
        return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
long long dp[51][51][2501];//i番目j個とったとき和がkになる個数
int main(){
  int N,A;cin>>N>>A;
  vector<int> x(N);
  for(int i = 0; N > i; i++){
    cin>>x[i];
  }
  dp[0][0][0] = 1;
  dp[0][1][x[0]] = 1;
  for(int i = 1; N > i; i++){
    for(int j = 0; i+1 >= j; j++){
      for(int k = 0; 2500 >= k; k++){
        dp[i][j][k] = dp[i-1][j][k];
        if(j && k >= x[i])dp[i][j][k] += dp[i-1][j-1][k-x[i]];
      }
    }
  }
  long long ans = 0;
  for(int j = 1; N >= j; j++){
    ans += dp[N-1][j][j*A];
  }
  cout << ans << endl;
}

Measured memory_bytes: 48128
# -*- coding: utf-8 -*-
n = int(input())
tl = list(map(int, input().split()))
al = list(map(int, input().split()))

mod = 10**9 + 7

res = 1
for i in range(1,n-1):
    if tl[i-1]<tl[i]:
        if tl[i]>al[i]:
            res = 0
        continue
    elif al[i]>al[i+1]:
        if al[i]>tl[i]:
            res = 0
        continue
    else:
        res *= min(al[i],tl[i])
        res %= mod
if tl[-1]!=al[0]:
    res = 0
print(res)


Measured memory_bytes: 19136
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<map>
#include <algorithm>
#include<cstdlib>
#include<cmath>
#include<deque>
#include <numeric>

typedef long long ll;

ll gcd(ll x, ll y)
{
	ll r;

	if (x == 0 || y == 0)  // 引数チェック
	{
	
	}

	// ユーグリッドの互除法
	while ((r = x % y) != 0) // yで割り切れるまでループ
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll m, ll n)
{
	// 引数に０がある場合は０を返す
	if ((0 == m) || (0 == n))
		return 0;

	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int main() {
	ll n, m;
	std::cin >> n >> m;

	std::string sts;
	std::string stt;
	std::cin >> sts;
	std::cin >> stt;

	ll l = lcm(n, m);
	ll p = gcd(n, m);

	//std::cout << l <<" " << p  << std::endl;

	ll np = n / p;
		ll mp = m / p;

		int flgx = 0;
		ll j = 0;
		while ((np * j < n) && (mp * j  < m)) {
			if (sts[np * j] != stt[mp * j]) {
				//std::cout << j << " " << np * j  << " " << sts[np * j ]  << std::endl;
				//std::cout << j << " " << mp * j  << " " << stt[mp * j ] << std::endl;
				flgx = 1;
				break;
			}
			j++;
		}
		if (flgx == 1) {
			std::cout << "-1" << std::endl;
		}
		else
		{
			std::cout << l << std::endl;
		}


	return 0;
}

Measured memory_bytes: 512
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
    int N, A;
    cin >> N >> A;

    int mod = N % 500;
    if( mod <= A )
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int h[10],l[10],x1[15],x2[15];
int s[10][10];
void print()
{
    for(int i=0;i<8;i++)
        for(int j=0;j<8;j++)
    {
        if(s[i][j]&&h[i]!=j)
            return ;
    }
    for(int i=0;i<8;i++)
    {
        for(int j=0;j<8;j++)
        {
            printf("%c",h[i]==j?'Q':'.');
        }
        printf("\n");
    }
}
void dfs(int i)
{
    if(i==8)
    {
        print();
        return ;
    }
    for(int j=0;j<8;j++)
    {
        if(l[j]||x1[i+j]||x2[i-j+8])
            continue;
        h[i]=j;
        l[j]=x1[i+j]=x2[i-j+8]=1;
        dfs(i+1);
        h[i]=l[j]=x1[i+j]=x2[i-j+8]=0;
    }
}
int main()
{
    int t;
    while(~scanf("%d",&t))
    {
        memset(s,0,sizeof(s));
        memset(h,0,sizeof(h));
        memset(l,0,sizeof(l));
        memset(x1,0,sizeof(x1));
        memset(x2,0,sizeof(x2));
        int x,y;
        for(int i=1;i<=t;i++)
        {
            scanf("%d%d",&x,&y);
            s[x][y]=1;
        }
        dfs(0);
    }
}



Measured memory_bytes: 2108