akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int s;
  cin>>s;
  map<int,int> mp;
  int tmp =1,ans;
  mp[s]=tmp;
  while(true){
    tmp++;
    if(s%2==0){
      s/=2;
      if(mp.count(s)){
        ans=tmp;
        break;
      }
      mp[s]=tmp;
    }else{
      s=3*s+1;
      if(mp.count(s)){
        ans=tmp;
        break;
      }
      mp[s]=tmp;
    }
  } 
  cout<<ans<<endl;
}

Measured memory_bytes: 256
N,*A = `dd`.split.map &:to_i
box = Array.new(N, 0)
(1..N).reverse_each{ |i|
  x = A[i-1]
  j = 2*i
  while j <= N do
    x += box[j-1]
    j += i
  end
  box[i-1] = x % 2
}
ans = (1..N).select{ |i| box[i-1] == 1 }
puts ans.size, ans * " "


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  while(1) {
    int n, m; cin >> n >> m;
    if(n == 0) break;
    vi user(n);
    vector<vector<P>> record(m);

    int r; cin >> r;
    REP(i, r) {
      int tr, nr, mr, sr; cin >> tr >> nr >> mr >> sr;
      if(sr) {
        user[nr-1] = tr;
      } else {
        record[mr-1].pb(make_pair(user[nr-1], tr));
      }
    }



    int q; cin >> q;
    REP(i, q) {
      int ts, te, mq; cin >> ts >> te >> mq;
      int ans = 0;
      FOR(i, ts, te) {
        REP(j, SZ(record[mq-1])) {
          P p = record[mq-1][j];
          if(p.first <= i && i < p.second) {
            ans++;
            break;
          }
        }
      }
      cout << ans << endl;
    }
  }

}



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

int main(){
    
    int n,q;
    string s;
    cin >> n >> q >> s;
    
    vector<int> pos_ac(n,0);
    for(int i = 0; i < n - 1; i++){
        if(s.at(i) == 'A' && s.at(i + 1) == 'C'){
            if(i == 0){
                pos_ac.at(0) = 1;
                pos_ac.at(1) = 2;
            }else {
                pos_ac.at(i) = pos_ac.at(i - 1) + 1;
                pos_ac.at(i + 1) = pos_ac.at(i) + 1;
            }
        }else{
            if(i == 0)pos_ac.at(0) = 0;
            else if(pos_ac.at(i) != pos_ac.at(i - 1) + 1)pos_ac.at(i) = pos_ac.at(i - 1);
        }
    }
    
    if(pos_ac.at(n - 1) != pos_ac.at(n - 2) + 1)pos_ac.at(n - 1) = pos_ac.at(n - 2);
    
    
    for(int i = 0; i < q; i++){
        int l,r,answer;
        cin >> l >> r;
        
        l--;
        r--;
        
        
        if(pos_ac.at(l) % 2 == 1){
            if(pos_ac.at(r) % 2 == 1){
                answer = (pos_ac.at(r) - pos_ac.at(l)) / 2;
            }else{
                answer = (pos_ac.at(r) - pos_ac.at(l) + 1) / 2;
            }
        }else{
            if(pos_ac.at(r) % 2 == 1){
                answer = (pos_ac.at(r) - pos_ac.at(l) - 1) / 2;
            }else{
                answer = (pos_ac.at(r) - pos_ac.at(l)) / 2;
            }
        }
        
        cout << answer << endl;
        
    }
    
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

int main() {
  string S, T, U;
  int A, B;
  cin >> S >> T >> A >> B >> U;
  if (S == U) {
    A--;
  } else {
    B--;
  }
  cout << A << " " << B << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  
  int ans = 0;
  
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    
    if (K - x < x)
      ans += K - x;
    else
      ans += x;
  }
  cout << ans * 2 << endl;
}

Measured memory_bytes: 3620
import java.util.Scanner;

/**
 * https://abc059.contest.atcoder.jp/tasks/arc072_a
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		long[] a = new long[N];
		for(int i=0; i<N; i++) a[i] = sc.nextLong();
		sc.close();
		
		long ans = 0;
		long ans2 = 0;
		long sum = 0;
		for(int i=0; i<N; i++){
			if(i%2==0 && sum+a[i]>=0){
				ans = ans + (a[i]+sum) +1;
				sum = -1;
			}else if(i%2==1 && sum+a[i]<=0){
				ans = ans - (a[i]+sum) +1;
				sum = 1;
			}else{
				sum = sum + a[i];
			}
		}
		
		sum = 0;
		for(int i=0; i<N; i++){
			if(i%2==1 && sum+a[i]>=0){
				ans2 = ans2 + (a[i]+sum) +1;
				sum = -1;
			}else if(i%2==0 && sum+a[i]<=0){
				ans2 = ans2 - (a[i]+sum) +1;
				sum = 1;
			}else{
				sum = sum + a[i];
			}
		}
		
		System.out.println(Math.min(ans, ans2));

	}

}

Measured memory_bytes: 50880
#include<iostream>
#include<vector>
using namespace std;
int main(){
    for(;;){
        int n;
        cin>>n;
        if(n==0)break;
        vector<string> ms(n);
        string ins;
        for(int i=0;i<n;i++){
            cin>>ins;
            ms[i]=ins;
        }
        vector<vector<int> > sq(n,vector<int>(n,0));
        for(int i=0;i<n;i++){
            if(ms[0][i]=='.')sq[0][i]=1;
            if(ms[i][0]=='.')sq[i][0]=1;
        }
        int ma=0;
        for(int i=1;i<n;i++){
            for(int j=1;j<n;j++){
                if(ms[i][j]=='.'){
                    sq[i][j]=min(min(sq[i-1][j],sq[i][j-1]),sq[i-1][j-1])+1;
                    ma=max(ma,sq[i][j]);
                }
            }
        }
        cout<<ma<<endl;
    }
}

Measured memory_bytes: 0
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

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

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

LL modinv(LL a) {
    LL b = MOD, u = 1, v = 0;
    while (b) {
        LL t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

LL moddev(LL a, LL b){
	return a * modinv(b) % MOD;
}

void Main()
{
    string s; cin>>s;

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

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 256
import collections
N, K = map(int, input().split())
a = list(map(int,input().split()))
def v_c(l):
    values, counts = zip(*c.most_common())
    return values, counts
c = collections.Counter(a)
ans = 0
if len(c) > K:
    dif = len(c) - K
    values, counts = zip(*c.most_common())
    for i in range(len(c)-dif, len(c)):
        ans += counts[i]
print(ans)

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

int main(){
  int n, m, k; cin >> n >> m >> k;
  vector<ll> a(n+1), b(m+1);
  int p = n, q = m;
  for(int i = 0; i < n; i++){
    int x; cin >> x;
    a.at(i+1) = a.at(i) + x;
    if(a.at(i+1) > k) p = i;
  }
  for(int i = 0; i < m; i++){
    int x; cin >> x;
    b.at(i+1) = b.at(i) + x;
    if(b.at(i+1) > k) q = i;
  }
  int ans = 0;
  for(int i = 0; i <= p; i++){
    while(q >= 0){
      if(a.at(i) + b.at(q) <= k){
        ans = max(i + q, ans);
        break;
      }
      else q--;
    }
  }
  cout << ans << endl;
}
    
      

Measured memory_bytes: 6432
#include <stdio.h>
int main()
{
	int a, b, soma, sub, mul, maior;
	scanf("%d %d\n", &a, &b);
	soma = a + b;
	sub = a - b;
	mul = a * b;
	maior = soma;
	if (maior < sub)
	{
		maior = sub;
	}
	if (maior < mul)
	{
		maior = mul;
	}
	printf("%d\n", maior);
return 0;
}

Measured memory_bytes: 128
from fractions import Fraction as F

for _ in xrange(input()):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(F, raw_input().split())
    if x1 == x2 and x3 == x4:
        print 'YES'
    elif x1 == x2 or x3 == x4:
        print 'NO'
    else:
        print 'YES' if F(y2-y1, x2-x1) == F(y4-y3, x4-x3) else 'NO'

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

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

    int n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> ab(n);
    rep(i, 0, n) {
        ll a, b;
        cin >> a >> b;
        ab[i] = make_pair(a, b);
    }
    sort(ab.begin(), ab.end());
    priority_queue<ll> pq;
    int j = -1;
    ll ans = 0;
    rep(i, 1, m + 1) {
        while (j < n-1 && ab[j + 1].first <= i) {
            j++;
            pq.push(ab[j].second);
        }
        if (pq.size() < 2)
            pq.push(0);
        ans += pq.top();
        pq.pop();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2936
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = [I() for _ in range(n)]
    t = set(a)

    return len(t)

print(main())




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

int main(){
  int A,B,C,K;
  cin>>A>>B>>C>>K;
  for(;K>0;K--){
    if(A>=B)B*=2;
    else C*=2;
  }
  if(A<B&&B<C)puts("Yes");
  else puts("No");
}

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

int main()
{
    int A, B;
    cin >> A >> B;
    if(A == 1 && B == 2)
        cout << 3 << endl;
    else if(A == 1 && B == 3)
        cout << 2 << endl;
    else if(A == 2 && B == 1)
        cout << 3 << endl;
    else if(A == 2 && B == 3)
        cout << 1 << endl;
    else if(A == 3 && B == 1)
        cout << 2 << endl;
    else if(A == 3 && B == 2)
        cout << 1 << endl;
}

Measured memory_bytes: 256
EGARA = ['S', 'H', 'C', 'D']

table = [[False]*14 for i in range(4)]

N = int(input())

for loop in range(N):
    mark, num = input().split()
    num = int(num)
    
    if mark == 'S':
        table[0][num] = True
    elif mark == 'H':
        table[1][num] = True
    elif mark == 'C':
        table[2][num] = True
    else:
        table[3][num] = True

for i in range(4):
    for j in range(1, 14):
        if table[i][j]==False:
            print(EGARA[i], j)


Measured memory_bytes: 5604
#!/usr/bin/env python3
N = int(input())

MOD = 1000000007
cache = {0: 1, 1: 2}


def f(n):
    if n in cache:
        return cache[n]
    if n % 2 == 0:
        result = 2 * f(n // 2 - 1) + f(n // 2)
    else:
        result = f(n // 2 - 1) + 2 * f(n // 2)
    result %= MOD
    cache[n] = result
    return result


print(f(N))


Measured memory_bytes: 3060
#include <cstdio>
#include <utility>
using namespace std;

int main(){
    int c[3],n;
    scanf("%d%d%d%d",&c[0],&c[1],&c[2],&n);
    int a[6000];
    a[0] = 1;
    for(int k = 0;k <= 2;k++){
        for(int j = 0;j < n+1-c[k];j++){
            a[j+c[k]] += a[j];
        }
    }
    printf("%d",a[n]);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(void)
{
  int bl=1;
  long long n,count=0,k=1;
  cin>>n;
  long long a[200005];
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  for(int i=1;i<=n;i++){
    if(a[i]==1)break;
    if(i==n)bl=0;
  }
  int l=1,i=1;
    for(int k=l;k<=n;k++){
      //cout<<k<<endl;
      if(a[k]==i){
        i++;
        continue;
      }else{
        count++;
        continue;
      }
    }
  
  if(bl==0)count=-1;
  cout<<count<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    int A, B, C, D, res = 0;
    cin>>A>>B>>C>>D;
    if(A>B)
    {
        res+=B;
    }
    if(A<B)
    {
        res+=A;
    }
    if(A==B)
    {
        res+=A;
    }
    if(C>D)
    {
        res+=D;
    }
    if(C<D)
    {
        res+=C;
    }
    if(C==D)
    {
        res+=C;
    }
    cout<<res<<endl;
    return 0;
}


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

long long N, K, b, i, r, m, n, a[40];
bool f[40];

main(){
    scanf("%lld%lld", &N, &K);
    for(i = 0; i < N; ++i){
        scanf("%lld", a + i);
        if(m < a[i]){
            ++r;
            m = a[i];
        }
        f[i] = (i < K);
    }
    if(r > K){return 0&puts("0");}
    n = 1099511627774;
    do{
        r = 0;
        m = *a;
        for(i = 1; i < N; ++i){
            if(m >= a[i]){
                if(f[i]){
                    ++m;
                    r += m - a[i];
                }
            }else{
                m = a[i];
            }
        }
        n = min(r, n);
    }while(prev_permutation(f, f + N));
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
#define Max_N 100001
#define INF 1000000001
long long n,ans=0,mini=INF,res=0;
long long a[Max_N];
void Solve(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]<=0) res++;
        if(abs(a[i])<mini) mini=abs(a[i]);
    }
    for(int i=0;i<n;i++)
        ans+=abs(a[i]);
    if(res%2==1){
        ans-=2*mini;
    }
    cout<<ans<<endl;
}
int main(){
    Solve();
    return 0;
}

Measured memory_bytes: 1024
# O(n) algorithm
def isPrime_naive(x):
    if x <= 1:
        return False
    for i in xrange(2, x):
        if x % i == 0:
            return False
    return True

# Fast algorithm
def isPrime(x):
    if x == 2:
        return True
    if x < 2 or x % 2 == 0:
        return False
    i = 3
    while i*i <= x:
        if x % i == 0:
            return False
        i += 2
    return True

cnt = 0
N = int(raw_input())
for _ in range(N):
    x = int(raw_input())
    if isPrime(x):
       cnt += 1
print cnt


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

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main/*Change to Main When Submitting*/ {
    static BufferedReader __in;
    static PrintWriter __out;
    static StringTokenizer input;

    public static void main(String[] args) throws IOException {
        __in = new BufferedReader(new InputStreamReader(System.in));
        __out = new PrintWriter(new OutputStreamWriter(System.out));

        read();
        int S =  nextInt(), W = nextInt();
        println(W >= S ? "unsafe" : "safe");

        close();
    }

    static final int IBIG = 1000000007;
    static final int IMAX = 2147483647;
    static final long LMAX = 9223372036854775807L;
    static void read() throws IOException {input = new StringTokenizer(__in.readLine());}
    static String readLine() throws IOException {return __in.readLine();}
    static int nextInt() {return Integer.parseInt(input.nextToken());}
    static int readInt() throws IOException {return Integer.parseInt(__in.readLine());}
    static long nextLong() {return Long.parseLong(input.nextToken());}
    static void print(String s) {__out.print(s);}
    static void println(String s) {__out.println(s);}
    static void print(Object o) {__out.print(o);}
    static void println(Object o) {__out.println(o);}
    static void printy() {__out.println("Yes");}
    static void printY() {__out.println("YES");}
    static void printn() {__out.println("No");}
    static void printN() {__out.println("NO");}
    static void printyn(boolean b) {__out.println(b ? "Yes" : "No");}
    static void printYN(boolean b) {__out.println(b ? "YES" : "NO");}
    static void println(int... a) {for(int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), i++); __out.println(a[a.length - 1]);}
    static void println(long... a) {for(int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), i++); __out.println(a[a.length - 1]);}
    static void println() {__out.println();}
    static void close() {__out.close();}
}

Measured memory_bytes: 32924
#include<bits/stdc++.h>
using namespace std;
int a[100005];
vector<int> dp(100005, INT_MAX);
int32_t main()
{
	int n, k; cin >> n >> k;
	for (int i = 0; i < n; i++) cin >> a[i];
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	for (int i = 2; i < n; i++)
	{
		for (int j = i - 1 , jump = 0 ; j >= 0 && jump < k ; j--, jump++)
			dp[i] = min(dp[i] , abs(a[i] - a[j]) + dp[j]);
	}
	cout << dp[n - 1];
	return 0;
}






Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, a, b;std::cin >> n >> a >> b;
  ll ans = 0;
  for(int i=1;i<=n;i++){
    string s = to_string(i);
    ll S = 0;
    for(int j=0;j<s.size();j++) S+=s[j]-'0';
    if(S>=a&&S<=b) ans+=i;
  }
  std::cout << ans << '\n';
}


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

using namespace std;

using ll = long long int;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	ll n, k;
	cin >> n >> k;

	vl x(n), y(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
	}

	vl xx = x, yy = y;
	sort(xx.begin(), xx.end());
	sort(yy.begin(), yy.end());

	ll res = (xx[n - 1] - xx[0]) * (yy[n - 1] - yy[0]);
	for (ll xi = 0; xi < n; xi++) {
		for (ll xj = xi + 1; xj < n; xj++) {
			for (ll yi = 0; yi < n; yi++) {
				for (ll yj = yi + 1; yj < n; yj++) {
					int num = 0;

					ll left = xx[xi], right = xx[xj];
					ll bottom = yy[yi], top = yy[yj];
					for (int i = 0; i < n; i++) {
						if (left <= x[i] && x[i] <= right && bottom <= y[i] && y[i] <= top) {
							num++;
						}
					}

					if (num >= k) {
						res = min(res, 1LL * (right - left) * (top - bottom));
					}
				}
			}
		}
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
# import sys
# sys.setrecursionlimit(10**5)
# from collections import defaultdict
import sys
readline = sys.stdin.buffer.readline
geta = lambda fn: map(fn, readline().split())
gete = lambda fn: fn(readline())

def main():
    N, W = geta(int)
    cur = [0] * (W+1) 

    for i in range(N):
        w, v = geta(int)
        update = cur[:]
        for j in range(w,W+1):
            tmp = cur[j-w] + v
            if tmp > cur[j]: update[j] = tmp
        
        cur = update

    print(cur[W])

if __name__ == "__main__":
    main()

Measured memory_bytes: 117488
#include <iostream>
#include <string>

using namespace std;

int main() {
  int n, first = 0, second = 0, third = 0, out = 0, point = 0;
  cin >> n;
  for (int inning = 0; inning < n;) {
    string event;
    cin >> event;
    if (event == "HIT") {
      if (third) point++;
      third = second;
      second = first;
      first = 1;
    } else if (event == "HOMERUN") {
      point += first + second + third + 1;
      first = second = third = 0;
    } else if (event == "OUT") {
      out++;
      if (out == 3) {
        inning++;
        cout << point << endl;
        first = second = third = out = point = 0;
      }
    }
  }
}

Measured memory_bytes: 0
import math
n,m=map(int, input().split())
def comb(n,r):
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))
if n == 1 and m == 1:
    print(0)
elif n < 2 or m < 2:
    if n < 2:
        print(comb(m,2))
    else:
        print(comb(n,2))
else:
    n_comb = comb(n,2)
    m_comb = comb(m,2)
    print(n_comb+m_comb)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int num[15];
int n,m,q;
struct pp{
    int a,b,c,d;
}que[55];
int nct;
ll sum,ma;
void dfs(int h,int k)
{
    if(h==n+1)
    {   sum=0;
        for(int i=1;i<=q;i++)
        {
            if(num[que[i].b]-num[que[i].a]==que[i].c)
                sum+=que[i].d;
        }
        ma=max(ma,sum);
        return;
	}
	for(int i=k;i<=m;i++)
	{    num[h]=i;
	  dfs(h+1,i);
	}
}
int main()
{
    cin >> n >> m >> q;
    for(int i=1;i<=q;i++)
    {
        scanf("%d%d%d%d",&que[i].a,&que[i].b,&que[i].c,&que[i].d);
    }
    dfs(1,1);
    cout << ma;
    return 0;
}

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

int main(){
    int N,M;cin>>N>>M;
    int array1[M];
    char array2[M];
    for(int i=0;i<M;i++){
        cin>>array1[i]>>array2[i];
    }
    int ans=0;
  bool res=0;
    for(int i=0;i<pow(10,N);i++){
        int mk=0;
          for(int j=0;j<M;j++){
            if(to_string(i).size()==N)if(((to_string(i).at(array1[j]-1)==array2[j])))mk++;
        }
        if(mk==M){
            ans=i;
          res=1;
            break;
        }
    }
    if(M==0){
        if(N==1){
            ans=0;
          cout<<ans<<endl;
            return 0;
        }
        else ans=pow(10,N-1);
    }
    if(ans||res)cout<<ans<<endl;
    else cout<<-1<<endl;
}


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

int main()
{
  int n;
  cin >> n;
  vector<ll> a(n);
  for (auto &e : a)
    cin >> e;
  ll cnt = 0;

  ll num = 0;
  for (int i = 0; i < n; ++i)
  {
    if (a[i] == 0)
    {
      cnt += (num / 2);
      num = 0;
    }
    else
    {
      num += a[i];
    }
  }
  cnt += num / 2;
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>

typedef long double ld;
typedef long long ll;

using namespace std;

#define MAXN 10

int p[MAXN];
int d[MAXN];

vector<int> dig(int n) {
	vector<int> ret;
	if (!n) {
		ret.push_back(0);
		return ret;
	}
	while (n) {
		ret.push_back(n % 10);
		n /= 10;
	}
	reverse(ret.begin(), ret.end());
	return ret;
}

int main() {
	int n, q;
	cin >> n >> q;
	for (int i = 0; i < q; i++) {
		cin >> p[i] >> d[i];
	}
	
	for (int i = 0; i <= 1000; i++) {
		vector<int> v = dig(i);
		if (v.size() != n) {
			continue;
		}
		bool ok = true;
		for (int j = 0; j < q; j++) {
			if (v[p[j] - 1] != d[j]) {
				ok = false;	
			}
		}
		if (ok) {
			cout << i << endl;
			return 0;
		}

	}
	cout << "-1" << endl;
	return 0;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

ll gcd(ll x, ll y)
{
    ll r;
    while((r = x % y) != 0)  
    {
        x = y;
        y = r;
    }
    return y;
}

int main(){
  ll i, j;
  ll n, y;
  cin >> n >> y;
  vector<ll> x(n + 1);
  
  for(i = 0; i < n; i++)
    cin >> x[i];
  x[n] = y;
  sort(ALL(x));
  ll result = x[1] - x[0];
  for(i = 2; i <= n; i++)
    result = gcd(result, x[i] - x[i - 1]);
  cout << result << endl;


  return 0;
}

Measured memory_bytes: 1024
n,g[21][21],i;x,X;D(S,G){int c[21],f[21]={0},t,T;for(memset(c,1,84),c[S]=0;T=S;)for(f[T]=1,S=i=0;++i<=n;S=f[i]|c[i]>c[S]?S:i)t=c[T]+g[T][i],t<c[i]&&(c[i]=t);return c[G];}main(y,Y){for(memset(g,scanf("%d%d",&n,&i),1764);~i--;~i&&(g[x][X]=y,g[X][x]=Y))scanf("%d,%d,%d,%d",&x,&X,&y,&Y);exit(!printf("%d\n",y-Y-D(x,X)-D(X,x)));}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

int ans[300][300];

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

    int H, W, K;
    cin >> H >> W >> K;

    vector<string> S(H);
    rep(i, H) cin >> S[i];

    int k = 1;
    rep(i, H) {
        // cout << "i = " << i << endl;
        int top = i;
        while (S[i].find('#') == string::npos) ++i;
        int bottom = i;
        while (bottom+1 < H && S[bottom+1].find('#') == string::npos) ++bottom;
        // cout << "top = " << top << ", i = " << i << ", bottom = " << bottom << endl;
        int left = 0;
        while (left < W) {
            int right = S[i].find('#', left);
            while (right+1 < W && S[i][right+1] == '.') ++right;
            for (int y = top; y <= bottom; ++y) {
                for (int x = left; x <= right; ++x) {
                    ans[y][x] = k;
                }
            }
            ++k;
            left = right+1;
        }
        i = bottom;
    }

    rep(i, H) {
        rep(j, W) {
            cout << ans[i][j] << (j == W-1 ? '\n' : ' ');
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>

int main(){

    int A = 0;
    int B = 0;

    scanf("%d %d", &A, &B);

    if (A >= 1 && B >= 1 && A <= 9 && B <= 9){
            A = A * B;
            printf("%d", A);
    } else {
        printf("-1\n");
    }

    return 0;
}

Measured memory_bytes: 128
use std::io::*;

static MOD : i64 = 1e9 as i64 + 7;

fn main(){
    let n : usize = input();
    let mut ans : i64 = 1;
    let mut cnt : Vec<i64> = vec![1; n + 1];
    for i in 2..n + 1{
        let mut x = i;
        for j in 2..i + 1 {
            while x > 1 && x % j == 0{
                x /= j;
                cnt[j] += 1;
            }
        }
    }
    for i in 2..n + 1 {
        ans *= cnt[i];
        ans %= MOD;
    }
    println!("{}", ans);
}

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

Measured memory_bytes: 4352
/**
 *    This code has been written by YueGuang, feel free to ask me question. Blog: http://www.yx.telstudy.xyz
 *    created:
 */
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#define REP(i, a, b) for(int i = a; i < b; i++)
#define REP_(i, a, b) for(int i = a; i <= b; i++)
#define sl(n) scanf("%lld", &n);
#define si(n) scanf("%d", &n);
#define RepAll(a) for(auto x: a)
#define cout(ans) cout << ans << endl;
typedef long long ll;

using namespace std;
int main(){
    int a[3], cnt = 0; scanf("%d%d%d", &a[0], &a[1], &a[2]);
    sort(a, a+3);
    while(a[0] != a[2] && a[1] != a[2]){
        cnt++;
        a[0]++;
        a[1]++;
    }
    if(a[0] == a[2] && a[2] == a[3]){
        return printf("%d\n", cnt) * 0;
    }

    if((a[2] - a[0])%2 == 0){
        return printf("%d\n", cnt+(a[2] - a[0])/2) * 0;
    }
    else{
        return printf("%d\n", cnt + 1 + (a[2] - a[0] + 1)/2) *0;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	string S;
	cin >> N >> S;
	vector<int> occ(26, 1);
	for(int i = 0; i < N; i++) occ[S[i]-'a']++;
	cat mod = 1000000007, ans = 1;
	for(int i = 0; i < 26; i++) ans = ans * occ[i] % mod;
	ans = (ans - 1) % mod;
	if(ans < 0) ans += mod;
	cout << ans << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 512
<?php
$n = trim(fgets(STDIN));
$l = trim(fgets(STDIN));
$list = explode( " ", $l );
rsort($list);

$max = $list[0];
$sum = 0;
for( $i=1; $i<$n; $i++ )
{ $sum += $list[$i]; }

echo $max < $sum ? 'Yes' : 'No';

Measured memory_bytes: 4604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  int ssize = (int)s.size();
  vector<ll> md3n;
  ll tp = 1;
  rep(i,101000){
    md3n.pb(tp); tp*=3; tp %= mod;
  }

  int count_ = 0;
  vector<vector<ll>> dp(3,vector<ll>(ssize));
  rep(y,3) rep(x,ssize) dp[y][x]=0;
  ll Acnt = 0;
  rep(i,ssize){
    if(s[i]!='?'){
      if(s[i]=='A') {
        Acnt += md3n[count_];
        Acnt %= mod;
      }
      dp[0][i] = Acnt % mod;

      if(i==0) continue;

      dp[1][i] = dp[1][i-1];
      if(s[i]=='B') dp[1][i] += dp[0][i];
      dp[1][i]%=mod;

      dp[2][i] = dp[2][i-1];
      if(s[i]=='C') dp[2][i] += dp[1][i];
      dp[2][i] %= mod;
    }
    else{

      if(i==0){ dp[0][0]=1; Acnt++; count_++; continue; }
      ll tmp[3][3];
      tmp[0][0] = tmp[0][1] = tmp[0][2] = dp[0][i-1];
      tmp[0][0]+=md3n[count_]; tmp[0][0] %= mod;

      tmp[1][0] = tmp[1][1] = tmp[1][2] = dp[1][i-1];
      tmp[1][1] += tmp[0][1]; tmp[1][1] %= mod;

      tmp[2][0] = tmp[2][1] = tmp[2][2] = dp[2][i-1];
      tmp[2][2] += tmp[1][2]; tmp[2][2] %= mod;

      dp[0][i] = tmp[0][0]+tmp[0][1]+tmp[0][2];
      dp[1][i] = tmp[1][0]+tmp[1][1]+tmp[1][2];
      dp[2][i] = tmp[2][0]+tmp[2][1]+tmp[2][2];
      dp[0][i] %= mod;
      dp[1][i] %= mod;
      dp[2][i] %= mod;

      Acnt = Acnt*3 + md3n[count_];
      Acnt %= mod;
      count_++;
    }
  }

  rep(y,3){
    rep(x,ssize){
      //cout << dp[y][x] << " " ;
    }
    //cout << endl;
  }

  cout << (dp[2][ssize-1])%mod << endl;
  return 0;
}
/*
    ABCBC
  A 11111
 AB 01122 //AB = AB + A
ABC 00113 //ABC = ABC + AB

    A??C A AA AB AC A? A?A A?B A?C A?? A??C
  A ???? 1 12 11 11 14 147 144 144 14F 14FF
 AB ???? 0 00 01 00 01 011 015 011 017 0177
ABC ???8 0 00 00 00 00 000 000 001 001 0018

    ??BC A B C ? ?A ?B ?C ?? ??B ??BC
  A ???? 1 0 0 1 14 11 11 16 166 1666
 AB ???? 0 0 0 0 00 01 00 01 017 0177
ABC ???? 0 0 0 0 00 00 00 00 000 0007

 ??A ? ?? ??A
A    1 16 16F

    ??ABC ? ?? ??A ??A-B  ??A-B-C
  A       1 16 16F 16F F  16F F F
 AB       0 01 011 011 10 011 1010
ABC       0 00 000 000 0  000 0 10

AAABC 3
ABABC 3
ACABC 2
BAABC 2
BBABC 1
BCABC 1
CAABC 2
CBABC 1
CCABC 1

A B C
AA AB AC BA BB BC CA CB CC
*/


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

int division(int n) {
  int count = 0;
  
  while (true) {
    if (n % 2 == 0) {
      n /= 2;
      count ++;
    } else {
      break;
    }
  }
  
  return count;
}

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a.at(i);
  
  int ans = 0;
  
  for (int i : a) ans += division(i);
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {
		
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int[] a = new int[28];
		for(int i = 0; i < 28; i++) {
			a[i] = stdIn.nextInt();
		}
		Arrays.sort(a);
		
		for(int i = 1; i <= 30; i++) {
			if(Arrays.binarySearch(a, i)< 0) {
				System.out.println(i);
			}
		}
	}
}

Measured memory_bytes: 17184
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

#define MOD 1e9+7

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

int main(){
    int n;
    cin >> n;
    vector<ll> cnt(n+1, 1);
    rep2(i, 2, n+1){
        int num = i;
        for (int j = 2; j * j <= i; j++) {
            while(num%j==0){
				cnt[j]++;
				num /= j;
			}
			if(num==1){
				break;
			}
        }
		if(num!=1){
			cnt[num]++;
		}
    }

	ll sum=1ll;
	rep2(i, 2, n+1){
        sum = lldiv(sum * cnt[i], MOD).rem;
	}

	cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		String numberStr = scanner.next();
		

		if (numberStr.charAt(0) == '7' || numberStr.charAt(1) == '7' || numberStr.charAt(2) == '7') {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		scanner.close();

	}

}


Measured memory_bytes: 35552
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <string>
#include <map>
#include <algorithm>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <ctime>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s, t;
    cin >> s >> t;
    int ans = 1e9;
    for (int i = 0; i + t.size() - 1 < s.size(); i++) {
        int cur = 0;
        for (int j = i; j < i + t.size(); j++)
            if (s[j] != t[j - i])
                cur++;
        ans = min(ans, cur);
    }
    cout << ans;
    return 0;
}

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

typedef long long ll;

const long long INF = 1e18;
const int MAX = 100005;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX], cumcom[MAX];

ll modinv(ll a,ll m){
    ll b=m,u=1,v=0;
    while(b){
        ll t=a/b;
        a-=t*b;
        swap(a,b);
        u-=t*v;
        swap(u,v);
    }
    u%=m;
    if(u<0) u+=m;
    return u;
}

void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for (int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i] =MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

ll COM(int n, int k){
    if (n<k)
        return 0;
    if (n<0 || k<0)
        return 0;
    return fac[n]*(finv[k]*finv[n - k]%MOD)%MOD;
}

void CUMinit(ll n){
    cumcom[0]=COM(n,0);
    for(ll i=1;i<=n;++i){
        cumcom[i]=(cumcom[i-1]+COM(n,i))%MOD;
    }
    return;
}

int main(){
    ll N;cin>>N;
    ll K;cin>>K;
    vector<ll> a(N);rep(i,N) cin>>a[i];
    sort(a.begin(),a.end());
    COMinit();
    ll res=0;
    ll mi=0,ma=0;
    rep(i,N){
        mi+=COM(N-i-1,K-1)*a[i]%MOD;
        mi=mi<0 ? mi+MOD : mi;
        mi%=MOD;
        ma+=COM(i,K-1)*a[i]%MOD;
        ma%=MOD;
    }
    res=(MOD+ma-mi)%MOD;
    cout<<res<<endl;
}


Measured memory_bytes: 3328
#include <cstdio>
#include <cmath>

int main(void)
{
	double a, b, c, d, e, f;

	while (scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF){
		double y = (d * c - a * f) / (d * b - a * e);
		double x = (c * e - b * f) / (a * e - b * d);
		if (fabs(x) < 1e-4) x = 0.0;
		if (fabs(y) < 1e-4) y = 0.0;
		printf("%.3f %.3f\n", x, y);
	}

	return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    for(int i=k; i<n; i++){
        if(a[i]>a[i-k]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 4044
N = int(input())
A = [int(input()) for i in range(N)]
A_sorted = sorted(A)
for i in range(N):
    if A[i] != A_sorted[-1]:
        print(A_sorted[-1])
    else:
        j = len(A_sorted) - 1
        count = 0
        while A[i] == A_sorted[j] and count <= 0:
            j -= 1
            count += 1
        print(A_sorted[j]) 

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

class Node {
public:
	Node *next;
	Node *prev;

	void setKey(int k) {
		key = k;
	}

	int getKey() {
		return key;
	}

private:
	int key;
	//string ??????
};

class DLinLis {
public:
	DLinLis() {
		guadman = new Node();
		guadman->next = guadman;
		guadman->prev = guadman;
	}

	void insertKey(int k) {
		Node *node = new Node();
		node->setKey(k);
		//next??¨prev????????????????????????????????????????????????
		node->next = guadman->next;
		guadman->next->prev = node;
		node->prev = guadman;
		guadman->next = node;
	}

	void deleteKey(int k) {
		deleteNode(searchList(k));
	}

	void deleteNode(Node *n) {
		if (n == guadman) return;
		n->prev->next = n->next;
		n->next->prev = n->prev;
		delete n; //?§£???
	}

	void deleteFirst() {
		deleteNode(guadman->next);
	}

	void deleteLast() {
		deleteNode(guadman->prev);
	}

	void printList() {
		Node *node = guadman->next;
		while (node != guadman) {
			cout << node->getKey();
			if (node->next != guadman) cout << " ";
			node = node->next;
		}
		cout << endl;
	}

private:
	//?????¨??§??¢??????????????????
	Node* searchList(int k) {
		Node *node = guadman->next;
		while (node->getKey() != k && node != guadman){
			node = node->next;
		}
		return node;
	}

	Node *guadman;
};

int main() {
	DLinLis *list = new DLinLis();
	string command;
	int numCom;

	cin >> numCom;
	for (int i = 0; i < numCom; i++) {
		cin >> command;
		if (command[0] == 'i') {
			int key;
			cin >> key;
			list->insertKey(key);
		}
		else if (command[0] == 'd') {
			if (command.length() >= 6) {
				if (command[6] == 'F') {
					list->deleteFirst();
				}
				else if (command[6] == 'L') {
					list->deleteLast();
				}
				else {
					int key;
					cin >> key;
					list->deleteKey(key);
				}
			}
		}
	}

	list->printList();

	return 0;
}

Measured memory_bytes: 34400
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iomanip>


#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;


// <<fixed<<setprecision(6)<<


int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}


int Combination(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}


int main(){
  map<int,int> b;
  lint n,k,q,r;
  cin>>n>>k>>q;
  r=k-q;
  for(lint i=0;i<n;i++){
    b[i]=r;
  }
  for(lint i=0;i<q;i++){
    lint j;
    cin>>j;
    b[j-1]++;
  }
  for(lint i=0;i<n;i++){
    if(b[i]<1){
      cout<<"No"<<endl;
    }
    else{
      cout<<"Yes"<<endl;
    }
  }
}

Measured memory_bytes: 5376
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>

using namespace std;

typedef long long ll;

const int N = 5007;

ll dp[N][N];

const ll Inf = 1e18;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int n, a, b;
  cin >> n >> a >> b;
  vector <int> p(n);
  for (int i = 0; i < n; ++i) cin >> p[i];
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= n; ++j) {
      dp[i][j] = Inf;
    }
  }
  dp[0][0] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= n; ++j) {
      if (dp[i][j] == Inf) continue;
      if (p[i] < j) {
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + b);
      } else {
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + a);
        dp[i + 1][p[i]] = min(dp[i + 1][p[i]], dp[i][j]);
      }
    }
  }
  ll ans = Inf;
  for (int i = 0; i <= n; ++i) ans = min(ans, dp[n][i]);
  cout << ans << '\n';
}



Measured memory_bytes: 196096
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        int A = sc.nextInt();
        int B = sc.nextInt();
        String U = sc.next();
        if(S.equals(U)) System.out.println(A-1+" "+B);
        else System.out.println(A+" "+(B-1));
    }
}

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

namespace AtCoder_BeginnersC_114
{
    class Program
    {
        static void Main(string[] args)
        {
            int X = int.Parse(Console.ReadLine());

            if(X== 3 || X== 5 || X == 7)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


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

#define int long long

const int inf=1000000007ll;
int mod;

inline void add(int& x,int y)
{
	x+=y;
	if(x>mod) x-=mod;
}

int N,M;
int dp[333][333][333];

signed main()
{
	ios::sync_with_stdio(false);
	
	cin>>N>>M>>mod;
	dp[0][1][0]=1;
	for(int i=0;i<=N;i++)
	{
		for(int j=1;j<=M;j++)
		{
			for(int k=i;k>=0;k--)
			{
				int& cur=dp[i][j][k];
				if(!cur) continue;
				if(!k) add(dp[i][j+1][i],cur);
				else add(dp[i][j][k-1],cur);
				if(i+1<=N) add(dp[i+1][j][k],cur*(k+1)%mod);
			}
		}
	}
	cout<<dp[N][M][0]<<endl;
	return 0;
}












Measured memory_bytes: 239972
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
///////////////////////////////////////////////

ll dp[3][110];

int main() {
    int n; cin >> n;
    vector<vector<int>> a(2,vector<int>(n));
    rep(i,2) rep(j,n) cin >> a[i][j];

    memset(dp, 0, sizeof(dp));
    dp[0][0] = a[0][0];
    
    rep(i,2) rep(j,n) {
        if (i+1<2) chmax(dp[i+1][j], dp[i][j]+a[i+1][j]);
        if (j+1<n) chmax(dp[i][j+1], dp[i][j]+a[i][j+1]);
    }

    cout << dp[1][n-1] << endl;
    
    return 0;
}

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

int main()
{
 int a;
   cin >> a;
   int *num = new int[a];  
   for(int i=0; i < a;i++ ){
    cin >> num[i];
    if(num[i] % 2 == 0){
        if(num[i] %3  != 0 && num[i] %5 != 0 ){
            cout << "DENIED"<<endl;
            return 0;
        }
    }
   }

    cout << "APPROVED"<<endl;
    return 0;
}

Measured memory_bytes: 256
n=eval(input())
taro=[]
hanako=[]
for i in range(n):
    x,y=input().split()
    taro.append(x)
    hanako.append(y)
T=0
H=0
for i in range(n):
    if taro[i]<hanako[i]:
        H=H+3
    elif taro[i]>hanako[i]:
        T=T+3
    else:
        H=H+1
        T=T+1
print(T,H)

Measured memory_bytes: 7404
<?php
fscanf(STDIN, '%d %d', $n, $m);
for ($i  = 0; $i < $m; $i++) {
    fscanf(STDIN, '%d %d', $l[], $r[]);
}

$left = $l[0];
$right = $r[0];
for($i = 1; $i < $m; $i++) {
    $left = max($left, $l[$i]);
    $right = min($right, $r[$i]);
}
$ans = max($right - $left + 1, 0);
echo $ans . PHP_EOL;

Measured memory_bytes: 15988
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP1_4B
{
    class Program
    {
        static void Main(string[] args)
        {
            double R = double.Parse(Console.ReadLine());
            double Pi = 3.14159265359;

            double CircleArea = R * R * Pi;
            double Circumference = 2 * R * Pi;
            Console.WriteLine(CircleArea + " " + Circumference);
        }
    }
}

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

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

int main(){
  long long N,M;
  cin >> N >> M;
  long long temp;
  long long B[N];
  long long MB=1;
  for(int i=0;i<N;i++){
    cin>>temp;
    B[i]=temp/2;
    MB=(MB*B[i])/gcd(MB,B[i]);
    if(MB>M){
      cout<<0<<endl;
      return 0;
    }
  }
  //cout<<MB<<endl;
  for(int i=0;i<N;i++){
    if((MB/B[i])%2==0){
      cout<<0<<endl;
      return 0;
    }
  }
  
  cout<<M/MB-M/(2*MB)<<endl;
  return 0;
}

Measured memory_bytes: 1024