akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

signed main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    ll sum = 0;
    for(auto& x : a){
        cin >> x;
        sum += (x > 0 ? x : 0);
    }
    vector<ll> rui(n + 1, 0);
    for(ll i = 0; i < n; ++i)
        rui[i + 1] = rui[i] + (a[i] < 0 ? a[i] : 0);
    vector<ll> inv(n + 1, 0);
    for(ll i = 0; i < n; ++i)
        inv[i + 1] = inv[i] + (a[i] > 0 ? a[i] : 0);

    ll ans = 0;
    for(ll i = 0; i < n - k + 1; ++i){
        ll diff = rui[i + k] - rui[i];
        ll diff2 = inv[i + k] - inv[i];
        ans = max(ans, sum + diff);
        ans = max(ans, sum - diff2);
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
INF = Float::INFINITY
N, W = gets.chomp.split.map(&:to_i)

max_v = 100_100

dp = []
(N+1).times do |n|
  dp << [INF] * (max_v + 1)
end

dp[0][0] = 0

N.times do |i|
  w_i, v_i = gets.chomp.split.map(&:to_i)
  0.upto(max_v) do |v|
    if v - v_i >= 0
      dp[i+1][v] = dp[i][v - v_i] + w_i if dp[i+1][v] > dp[i][v - v_i] + w_i
    end

    dp[i+1][v] = dp[i][v] if dp[i+1][v] > dp[i][v]
  end
end

result = 0
0.upto(max_v) do |v|
  result = v if dp[N][v] <= W
end

puts result

Measured memory_bytes: 93432
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld double
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pll pair <ll,ll>
#define nl "\n"
ld dp[3000][3000];
int main()
{
	ios_base::sync_with_stdio(false);
	cout.precision(10);
	ll n,i,j;
	cin>>n;
	ld p[n+2],ans=0;
	for(i=0;i<n;i++)
		cin>>p[i];
	dp[0][0] = 1;
	for(i=1;i<=n;i++)
		for(j=0;j<=i;j++)
		{
			dp[i][j] = dp[i-1][j]*(1-p[i-1]); 
			if(j)
				dp[i][j] += dp[i-1][j-1]*p[i-1];
			if(i==n && j>=(n+1)/2)
			ans += dp[i][j];
		}
	cout<<ans<<nl;
	return 0;
}

Measured memory_bytes: 49852
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
using namespace std;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	string a,b;
	cin>>a>>b;
	if(a==b)
	cout<<"H";
	else
	cout<<"D";
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9+7;

int main(void){
  int a,b;
  cin >> a >> b;
  for(int c = 1;c <= 3;++c){
    if((a * b * c) % 2 == 1){
      puts("Yes");
      return 0;
    }
  }
  puts("No");
  return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return input().split()
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    a, b, m = LI()
    a = LI()
    b = LI()
    xym = LIR(m)
    ans = min(a) + min(b)
    for x, y, m in xym:
        ans = min(ans, a[x - 1] + b[y - 1] - m)
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 77528
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define PI 3.1415926535897
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


int N;


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


signed main(){
	int a;
	int ans;
	cin >> N;
	cin >> ans;
	rep(i, 1, N) cin >> a, ans = gcd(ans, a);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_7_B&lang=ja

int main(){
    int n, x;
    while(1){
        cin >> n >> x;
        if (n==0 and x==0) return 0;
        int ans = 0;
        for(int i=1; i<=n-2; i++){
            for (int j=i+1; j<=n-1; j++){
                for (int k=j+1; k<=n; k++){
                    if (i+j+k==x) ans++;
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
double kakuritu(int M,int N){ //初期得点M　目標得点N
    double i = 1;
    while(1){
        if(M*i>=N){
            break;
        }else{
            i *= 2;
        }
    }
    return (1/i);
}
int main(){
    int N,K;
    double answer=0;
    cin >> N >> K;
    for(int i=1; i<=N; i++){
        answer += kakuritu(i,K);
    }
    answer /= N;
    printf("%.10lf",answer);
    return 0;
}

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

using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("http://in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long
#define pb push_back
#define pll pair<ll,ll>
#define ff first
#define ss second
#define N 2000001
#define M 1000000007
#define INF 1000000000000000


int main()
{
 ll x,k,d;
 cin>>x>>k>>d;
 if(x>=0)
 {ll p=x/d;
 ll remain=x-p*d;
 if(p>k){cout<<x-k*d;}
 else
 {
     k=k-p;
     if(k%2)
     {
         cout<<min(remain+d,abs(remain-d));
     }
     else
     cout<<remain;
 }}
 else
 {
     ll p=abs(x)/d;
         ll remain=x+p*d;
         if(p>k){cout<<abs(x+k*d);}
         else
         {
             k=k-p;
             if(k%2)
             {
                 cout<<min(abs(remain+d),abs(remain-d));
             }
             else
             cout<<abs(remain);
         }
 
 }
}

Measured memory_bytes: 3632
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from fractions import gcd
from functools import reduce

N,*A = map(int,read().split())

MOD = 10 ** 9 + 7

lcm = reduce(lambda x,y: x*y//gcd(x,y), A)

answer = sum(lcm//x for x in A)
answer %= MOD
print(answer)


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

int main(){
    int N;
    cin >> N;
    string S;
    const char *s = NULL;
    cin >> S;
    s = S.c_str();
    vector<char> A;
    A.assign(s, s + S.length());
    vector<char>::iterator IA;
    int n, i, counta = 0;
    char a[3];
    a[3] = 'X';
    for(n = 0; n <= 999; n++){
        a[2] = '0' + (n % 10);
        a[1] = '0' + ((n / 10) % 10);
        a[0] = '0' + (n / 100);
        i = 0;
        for(IA = A.begin(); IA != A.end(); ++IA){
            if(i == 3){
                break;
            }else if(*IA == a[i]){
                i++;
            }
        }
        if(i == 3){
            counta++;
        }
    }
    cout << counta << endl;
    system("pause");
    return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i);
        sum += a.at(i);
    }
    for (int i = 0; i < n; i++)
    {
        if (a.at(i) >= (double)sum / (double)(4 * m))
        {
            cnt++;
        }
    }
    if (cnt >= m)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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



int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    string s, t; cin >> s >> t;
    if (s.length() + 1 != t.length()) {
        cout << "No\n";
        return 0;
    }

    for (int i = 0; i < s.length(); i++) {
        if (s[i] != t[i]) {
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes\n";

    return 0;
}


Measured memory_bytes: 3636
a,b,k=map(int,input().split())

if b-a+1<=2*k:
            for i in range(a,b+1):
                        print(i)
else:
            for i in range(a,a+k):
                        print(i)
            for i in range(b-k+1,b+1):
                        print(i)

"""
for i in range(a,b+1):
            #print("i",i)
            if i<a+k:
                        print(i)
            elif b-k<i:
                        print(i)
"""                    
            
                        


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


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


int main(){
    ll X;
    cin>>X;
    ll N = X/100;
    if(N >= 20)cout<<1;
    else{
        ll a = X%100;
        if(a > 5*N)cout<<0;
        else cout<<1;
    }
    return 0;
}

Measured memory_bytes: 3476
#include <iostream>
#include <climits>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

int top;
int S[1000];

void push(int x)
{
  S[++top] = x;
}

int pop()
{
  top--;
  return S[top + 1];
}

int main()
{
  int a, b;
  top = 0;
  char s[100];

  while (scanf("%s", s) != EOF)
  {
    if (s[0] == '+')
    {
      a = pop();
      b = pop();
      push(a + b);
    }
    else if (s[0] == '-')
    {
      b = pop();
      a = pop();
      push(a - b);
    }
    else if (s[0] == '*')
    {
      a = pop();
      b = pop();
      push(a * b);
    }
    else
    {
      push(atoi(s));
    }
  }
  printf("%d\n", pop());
  return 0;
}


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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N, std::vector<ll> A) {
  ll sum = 0;
  ll mx = A.at(0);

  rep(i, N) {
    if (A.at(i) < mx) {
      sum += mx - A.at(i);
    }
    if (A.at(i) > mx) {
      mx = A.at(i);
    }
  }

  cout << sum << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  std::vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 4840
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll n, l;
    cin >> n >> l;
    vector<ll> a(n);
    rep(i, n)cin >> a[i];
    ll mx = 0;
    ll pos;
    rep(i, n-1)if(a[i]+a[i+1] > mx){
        pos = i+1;
        mx = a[i] + a[i+1];
    }
    if(mx >= l)cout << "Possible\n";
    else {
        cout << "Impossible\n";
        return 0;
    }

    for(ll i = 1; i < pos; ++i)cout << i << endl;
    for(ll i = n-1; i >= pos; --i)cout << i << endl;


}

Measured memory_bytes: 1664
import java.util.*;

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

        int N = sc.nextInt();
        double D = sc.nextDouble();
        double X[] = new double[N];
        double Y[] = new double[N];
        for (int i = 0; i < N; i++) {
            X[i] = sc.nextDouble();
            Y[i] = sc.nextDouble();
        }

        int ans = 0;
        for (int i = 0; i < N; i++) {
            if (Math.sqrt(X[i]*X[i] + Y[i]*Y[i]) <= D) {
                ans++;
            }
        }

        System.out.println(ans);
        
    }
}


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

int main(){
    int k=0,u=0,p=0,c=0;
    char t;
    while(t=getchar(),t!='\n'){
        k+=t=='K';
        u+=t=='U';
        p+=t=='P';
        c+=t=='C';
    }
    cout << min({k,u,p,c}) << endl;
}

Measured memory_bytes: 1124
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <iostream>
#include <string>

#include <algorithm>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define PB push_back
#define MP make_pair

#define FOR(i, b, e) for(int i=(b);i<(e);i++)
#define REP(i, n) FOR(i,0,n)

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VPII;

const int MOD = 1000000009;
const int INF = 1e9;

const double EPS = 1e-9;
const double PI = acos(-1.0);

LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }

int N, M;
int k[11], s[11][11], p[11];

int main() {
    cin >> N >> M;
    REP (i, M) {
        cin >> k[i];
        REP (j, k[i]) {
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    REP (i, M) {
        cin >> p[i];
    }
    int ans = 0;
    REP (state, 1 << N) {
        int flag = 1;
        REP (i, M) { // 電球
            int acc = 0;
            REP (j, k[i]) { // スイッチ
                acc += (state >> s[i][j]) & 1;
            }
            if ((acc & 1) != p[i]) {
                flag = 0;
                break;
            }
        }
        if (flag) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	int n;
	public static void main(String[] args) {
		//new AOJ0039().run();
		new Main().run();
	}
	
	void run(){
		Scanner sc=new Scanner(System.in);
		
		while(sc.hasNext()){
		String str=sc.next();
		n=str.length();
		System.out.println(roman(str.toCharArray(),0,0,0));
		}
	}
	//IVXLCDM
	int roman(char ch[],int i,int k,int sum){
		
		//System.out.println(i+" "+sum);
		
		if(i==n){
			return sum;
		}
		
		if(ch[i]=='I'){
			return roman(ch,i+1,1,sum+1);
		}else if(ch[i]=='V'){
			if(k<5){
				return roman(ch,i+1,5,sum+(5-k)-k);
			}
			return roman(ch,i+1,5,sum+5);
		}else if(ch[i]=='X'){
			if(k<10){
				return roman(ch,i+1,10,sum+(10-k)-k);
			}
			return roman(ch,i+1,10,sum+10);
		}else if(ch[i]=='L'){
			if(k<50){
				return roman(ch,i+1,50,sum+(50-k)-k);
			}
			return roman(ch,i+1,50,sum+50);
		}else if(ch[i]=='C'){
			if(k<100){
				return roman(ch,i+1,100,sum+(100-k)-k);
			}
			return roman(ch,i+1,100,sum+100);
		}else if(ch[i]=='D'){
			if(k<500){
				return roman(ch,i+1,500,sum+(500-k)-k);
			}
			return roman(ch,i+1,500,sum+500);
		}else if(ch[i]=='M'){
			if(k<1000){
				return roman(ch,i+1,1000,sum+(1000-k)-k);
			}
			return roman(ch,i+1,1000,sum+1000);
		}

		return -1;
	}
}

Measured memory_bytes: 15312
#abc161 d 
k=int(input())

lunlun=[1,2,3,4,5,6,7,8,9]

def lunlun_generate(p):
    last=p%10
    if last-1>=0:
        yield p*10+last-1
    yield p*10+last
    if last+1<=9:
        yield p*10+last+1


p=0
while len(lunlun)<k:
    for new_lunlun in lunlun_generate(lunlun[p]):#３つ目のyieldが判定されるとfor文を抜ける
        lunlun.append(new_lunlun)
    p+=1
    
print(lunlun[k-1])

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

int main() {
	int W,H,N,x,y,a,bx1,bx2,by1,by2;
	cin >> W >> H >> N;

	bx1=W, bx2=0; by1=H, by2=0;

	rep(i,N) {
		cin >> x >> y >> a;
		if(a == 1)
			bx2 = max(bx2, x);
		else if(a == 2)
			bx1 = min(bx1, x);
		else if(a == 3)
			by2 = max(by2, y);
		else
			by1 = min(by1, y);
	}

	int dx=bx1-bx2, dy=by1-by2;
	dx = max(dx, 0);
	dy = max(dy, 0);

	cout << dx * dy << endl;
}

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

int main() {
    int H, W;
    cin >> H >> W;

    char ent[H][W];
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> ent[i][j];
        }
    }

    char sharp[H + 2][W + 2];
    for (int i = 0; i < H + 2; i ++) {
        for (int j = 0; j < W + 2; j++) {
            sharp[i][j] = '#';
        }
    }

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            sharp[i][j] = ent[i - 1][j - 1];
        }
    }

    for (int i = 0; i < H + 2; i++) {
        for (int j = 0; j < W + 2; j++) {
            cout << sharp[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
const int maxn = 1e5+5;
int n,m,a[maxn];
struct Op{
	int b,c;
	bool operator <(Op b)const{return c>b.c;}
}p[maxn];
long long ans;
int main(){
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;++i)
		scanf("%d",&a[i]),ans += a[i];
	for(int i=1;i<=m;++i)
		scanf("%d %d",&p[i].b,&p[i].c);
	std :: sort(a+1,a+n+1);
	std :: sort(p+1,p+m+1);
	for(int i=1,j=0;i<=m;++i){
		while(p[i].b && a[j+1] < p[i].c && j < n)
			++j,--p[i].b,ans += p[i].c - a[j];
		if(p[i].b)break;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 2884
//============================================================================
// Name        : c
// Date        : Mon Apr  8 18:59:49 CST 2019
// Author      : landcold7
// Description : Actions speak louder more than words
//============================================================================
#include "bits/stdc++.h"
using namespace std;

#define x first
#define y second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mst(x, y) memset(x, y, sizeof(x))
#define pvar(x) cout << #x << ": "
#define output(v) cout << (v) << '\n'
#define fori(i, a, b) for (int i = a; i < b; ++i)
#define jam(x, n) cout << "Case #" << x << ": " << n << "\n"
#define prt(x, a, n) { cout << x[a]; if (a < n - 1) cout << " "; }
#define par(x, s, n, v) if(v) pvar(x); fori(y, s, n) prt(x, y, n) cout << "\n"
template<class T> inline void amin(T &x, const T &y) { if (y < x) x = y; }
template<class T> inline void amax(T &x, const T &y) { if (x < y) x = y; }

#ifndef _has_trace
#define trace(...)
#define dbstream ostream
#endif
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

void solve() {
  int n; cin >> n;
  map<int, int> mp[2];
  for (int i = 0; i < n; ++i) {
    int x; cin >> x;
    mp[i & 1][x]++;
  }
  vpii v[2];
  for (int u = 0; u < 2; ++u) {
    for (auto& p : mp[u]) {
      v[u].pb({p.y, p.x});
    }
    if (sz(v[u]) == 1) {
      v[u].pb({0, -1});
    }
    sort(rall(v[u]));
  }
  int ret = 0;
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < 2; ++j) {
      if (v[0][i].y != v[1][j].y) {
        amax(ret, v[0][i].x + v[1][j].x);
      }
    }
  }
  output(n - ret);
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}



Measured memory_bytes: 6140
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    LL n;cin >> n;
    LL a,b;cin >> a >> b;
    LL t = n / (a + b);
    LL ans = t * a + min(a, n % (a + b));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int> ;
using vl = vector<ll>;

int main(){
    int n,c,k;
    cin >> n >> c >> k;
    vi vec(n);
    rep(i,n) cin >> vec[i];
    sort(vec.begin(),vec.end());
int cnt = 0;
    rep(i,n){
        rep(j,c){
            if(vec[i] + k < vec[i+j+1]){
                cnt++;
                i += (j);
                break;
            }
            if(j == c-1){
                i += c-1;
                cnt++;
            }
        }
    }

    cout << cnt << endl;
    return 0;
}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N, M;
    cin >> N >> M;

    vector<long long> x(N);
    vector<long long> y(N);
    vector<long long> z(N);
    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i] >> z[i];
    }

    long long ans = -1e18;
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < 2; j++){
            for(int k = 0; k <2; k++){
                vector<long long> s(N);
                for(int l = 0; l < N; l++){
                    if(i == 0) s[l]+= x[l];
                    else s[l] -= x[l];

                    if(j == 0) s[l]+= y[l];
                    else s[l] -= y[l];

                    if(k == 0) s[l]+= z[l];
                    else s[l] -= z[l];
                }

                sort(s.rbegin(), s.rend());

                long long ansTmp = 0;
                for(int i = 0; i < M; i++)ansTmp += s[i]; 

                if(ansTmp > ans) ans = ansTmp;
            }
        }
    }

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


Measured memory_bytes: 256
n = int(input())
a = []
for i in range(n):
  ai, bi = list(map(int, input().split()))
  a.append((ai, bi, ai+bi))
a.sort(key = lambda x: x[2], reverse=True)
tak = 0
aok = 0
for i in range(n):
  if i%2 == 0:
    tak += a[i][0]
  else:
    aok += a[i][1]
print(tak - aok)

Measured memory_bytes: 22144
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 1e5 + 10;
int n , a[N];

int main(){
  ll sum = 0;
  cin >> n;
  rep(i,0,n) cin >> a[i] , sum += a[i];
  ll one = ll(n) * (n + 1) / 2;
  if(sum % one != 0) {
    cout << "NO" << endl;
    return 0;
  }
  ll times = sum / one;
  rep(i,0,n) {
    ll dif = (a[i] - a[(i-1+n)%n]);
    // (times - t) - t * (n - 1) = dif
    // t * n = times - dif
    if((times - dif) % n != 0 || times - dif < 0){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
using pll = pair<ll, ll>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll x; cin >> x;
    if(400 <= x && x <= 599){
        cout << 8 << endl;
    }
    if(600 <= x && x <= 799){
        cout << 7 << endl;
    }
    if(800 <= x && x <= 999){
        cout << 6 << endl;
    }
    if(1000 <= x && x <= 1199){
        cout << 5 << endl;
    }
    if(1200 <= x && x <= 1399){
        cout << 4 << endl;
    }
    if(1400 <= x && x <= 1599){
        cout << 3 << endl;
    }
    if(1600 <= x && x <= 1799){
        cout << 2 << endl;
    }
    if(1800 <= x && x <= 1999){
        cout << 1 << endl;
    }

}



Measured memory_bytes: 3632
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
count=0
lis=[[A,((A%10)-1)%10],[B,((B%10)-1)%10],[C,((C%10)-1)%10],[D,((D%10)-1)%10],[E,((E%10)-1)%10]]
lis.sort(key=lambda x:x[1], reverse=True)
#print(lis)

for i in range(len(lis)):
    if not(i==len(lis)-1):
        count=count+lis[i][0]+(10-(lis[i][0])%10)%10
    else:
        count=count+lis[i][0]
print(count)

Measured memory_bytes: 38256
def myAnswer(A:int,B:int,C:int,K:int) ->int :
   return B-A if(K %2 == 1) else -1*(B-A)
def modelAnswer():
   tmp=1
def main():
   A,B,C,K = map(int,input().split())
   ans = myAnswer(A,B,C,K)
   if(abs(ans) >= 10**18):
      print("Unfair")
   else:
      print(ans)

if __name__ == '__main__':
   main()

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, ans, l, r;

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <limits>
#include <numeric>
#include <iomanip>
#include <cstdlib>
#include <iterator>
#include <functional>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef unsigned                    ui;
typedef int                         si;
typedef long                        sl;
typedef long long                   ll;
typedef unsigned long long          ull;

#ifdef LOCALHOST
std::ifstream in("input.txt", std::ifstream::in);
#endif // LOCALHOST

#ifdef LOCALHOST
#define is in
#else
#define is cin
#endif // LOCALHOST

int main(int argc, char *argv[])
{
    std::ios_base::sync_with_stdio(false);

    ll n, m;
    cin >> n >> m;

    vector<bool> ok(n + 1, false);
    vector<ll> pens(n + 1, 0);

    ll pen = 0;
    ll ans = 0;
    for (int i = 0; i < m; ++i) {
        int task;
        cin >> task;

        string v;
        cin >> v;

        if (v == "WA") {
            if (!ok[task]) {
                pens[task] += 1;
            }
        } else {
            if (!ok[task]) {
                ok[task] = true;

                ans += 1;
                pen += pens[task];
            }
        }
    }

    cout << ans << " " << pen << endl;

    return 0;
}


Measured memory_bytes: 1024
using System;
 
namespace  Rextester 
{
    public class Program
    {
       public static void Main(string[] args)
      {
           int a, b;
           string[] str = Console.ReadLine().Split(' ');
           a = int.Parse(str[0]);
           b = int.Parse(str[1]);
           Console.WriteLine(a*b + " " + 2*(a+b));
       }
    }
 }


Measured memory_bytes: 17952
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

const int N = 1e5 + 10, LOG_A = 60;

ll basis[LOG_A];

vector <ll> shifts;

void insertVector(ll mask) {
    for (ll i = LOG_A - 1; i >= 0; i--) {
        if ((mask & shifts[i]) == 0) continue;

        if (!basis[i]) {
            basis[i] = mask;
            return;
        }

        mask ^= basis[i];
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    ll x=0;
    shifts.resize(60);
    shifts[0]=1;
    for(ll i=1;i<=59;i++)
        shifts[i]=shifts[i-1]*2;

    ll data[n];
    for(int i=0;i<n;i++) {
        cin >> data[i];
        //insertVector(data[i]);
        x ^= data[i];
    }
    
    for(int i=0;i<60;i++) {
        if (x & shifts[i]) {
            for(int j=0;j<n;j++) {
                if (data[j] & shifts[i]) data[j] -= shifts[i];
            }
        }
    }
    
    for(int i=0;i<n;i++) insertVector(data[i]);

    ll ans = 0;

    for (ll i = LOG_A - 1; i >= 0; i--) {
        if (!basis[i]) continue;

        if (ans & shifts[i]) continue;

        ans ^= basis[i];
    }
    //cout<<ans<<endl;

    ll test=x;
    
    for(ll i=59;i>=0;i--)
    {
        if(!(x&shifts[i])&&ans&shifts[i])
            test+=(power(2,i+1,2e18));
    }

    cout << test << endl;
   //cout << (ans + (x ^ ans)) << endl;
    
    
    return 0;   
}


 
 


Measured memory_bytes: 1024
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define M 1000000007LL
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(v) ((ll)v.size())
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pii pair<ll,ll> 
#define mod 1000000007LL
#define MAXN 300002
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
ll a[200002],b[200002];
ll dp[2002][2002];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,i,j,m;
    cin>>n>>m;
    for(i=1;i<=n;i++) cin>>a[i];
    for(i=1;i<=m;i++) cin>>b[i];
    for(i=1;i<=n;i++) for(j=1;j<=m;j++){
        dp[i][j]=(dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1])%mod;
        if(a[i]==b[j]) dp[i][j]=(dp[i][j]+dp[i-1][j-1]+1)%mod;
    }
    cout<<(dp[n][m]+1+mod)%mod;
}


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

int main()
{
	int n;
	cin >> n;
	vector<double> p(n);
	for(int i=0;i<n;i++)
		cin >> p[i];
	// double ans=0;
	
	vector<double> ab(n+1);
	vector<vector<double> >dp(n+1,ab);

	//dp[i][j] represents probability of j heads till i coins
	for(int j=0;j<=n;j++)
		dp[0][j]=0;

		dp[0][0]=1;

	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=i;j++)
		{
			if(j==0)
				dp[i][0]=dp[i-1][0]*(1-p[i-1]);
			else
				dp[i][j]=dp[i-1][j-1]*p[i-1]+dp[i-1][j]*(1-p[i-1]);
		}
	}
	double ans=0;
	
		for(int j=n/2+1;j<=n;j++)
			ans+=dp[n][j];
	
// cout<<dp[n][n/2+1+1];
	cout<<fixed<<setprecision(10)<<ans;
	return 0;
}

Measured memory_bytes: 70656
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
 
VI e[100000], c[100000];
int par[100000][18], depth[100000];
ll dist[100000];
 
void dfs(int now, int past){
    REP(i,e[now].size()){
        int next = e[now][i];
        if (next == past) continue;
        dist[next] = dist[now] + c[now][i];
        par[next][0] = now;
        depth[next] = depth[now] + 1;
        dfs(next, now);
    }
}
 
int lca(int x, int y){
    if (depth[y] > depth[x]) swap(x,y);
    int d = depth[x] - depth[y];
    REP(i,18){
        if ((d>>i) & 1){
            x = par[x][i];
        }
    }
    if (x == y) return x;
    FORR(i,17,0){
        if (par[x][i] != par[y][i]){
            x = par[x][i];
            y = par[y][i];
        }
    }
    return par[x][0];
}
 
int main(){
    int n, q, k;
    cin >> n;
    REP(i,n-1){
        int x, y, z;
        scanf("%d %d %d", &x, &y, &z);
        x--; y--;
        e[x].push_back(y);
        e[y].push_back(x);
        c[x].push_back(z);
        c[y].push_back(z);
    }
    cin >> q >> k;
    k--;
    par[0][0] = 0;
    depth[0] = 0;
    dfs(k, -1);
 
    FOR(i,1,17){
        REP(j,n){
            par[j][i] = par[par[j][i-1]][i-1];
        }
    }
 
    while (q--){
        int x, y;
        scanf("%d %d", &x, &y);
        x--; y--;
        // int z = lca(x, y);
        ll ans = dist[x] + dist[y];
        printf("%lld\n", ans);
    }
 
 
    return 0;
}

Measured memory_bytes: 28800
#include<bits/stdc++.h>
#define ll long long int
#define F first
#define S second
#define pb push_back
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y);
#define sdl(x) scanf("%lld",&x)
#define sd2l(x,y) scanf("%lld%lld",&x,&y);
#define sz(x) (int)(x.size())
#define nax 200010
#define inf 1001000100
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define mp make_pair
#define pc pair<char ,int>
#define pi pair<int ,int>
#define pii pair <int,pi>
#define ull unsigned long long int
using namespace std;
int main() {

   //freopen("input.txt","r",stdin);
   //freopen("output.txt","w",stdout);
   int a,b,c,d;
   cin >> a >> b >> c >> d;
   int ans = a * b - (c * b + d * a - c * d);
   cout << ans << '\n';
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define testcase int t;cin>>t;while(t--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<long long int,long long int>
typedef long long int ll;
typedef unsigned long long int ull;
#define M 1000000007
using namespace std;
int main()
{
    fast

        ll n,a,b;
  cin>>n>>a>>b;//a for blue, b for red
  ll count=n/(a+b);
  ll rem=n%(a+b);
  if(rem>a)
    rem=a;
  ll star=count*a+rem;
  cout<<star<<endl;
return 0;
}







Measured memory_bytes: 256
#include<iostream>
int main() {
	int a;

	std::cin >> a;

	if (a % 3 == 0) {
	a = a / 3;
		if (a % 3 == 0) {
			a = a / 3;
		}
		else if (a % 2 == 0) {
			a = a / 2;
		}
	}
	else if (a % 2 == 0) {
		a = a / 2;
		
		if (a % 2 == 0) {
			a = a / 2;

			if (a % 2 == 0) {
				a = a / 2;
			}
		}
	}

	else if (a % 5 == 0) {
		a = a / 5;
	}
	else if (a % 7 == 0) {
		a = a / 7;
	}

	if (a<10) {
		std::cout << "Yes";
	}
	else {
		std::cout << "No";
	}
	return(0);
}

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

words = {"":0}
for i in range(n):
  s = input()
  if s not in words:
    words[s] = 1
  else:
    words[s] += 1
  
m = int(input())
for i in range(m):
  s = input()
  if s not in words:
    words[s] = -1
  else:
    words[s] -= 1

print(max(words.values()))

Measured memory_bytes: 3060
import sys
import math

X,Y=map(int,input().split())
ans=0
if X==1:   ans+=300000
elif X==2: ans+=200000
elif X==3: ans+=100000

if Y==1:   ans+=300000
elif Y==2: ans+=200000
elif Y==3: ans+=100000

if X==1 and Y==1: ans+=400000
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h> 
using namespace std; 
long long int setBitNumber(long long int n) 
{ 
   
    int k = (int)(log2(n)); 
  
    // To return the the value 
    // of the number with set 
    // bit at k-th position 
    return (long long int)(pow(2, k+1)); 
} 
int setindex(long long int n) 
{ 
   
    int k = (int)(log2(n)); 
  
    // To return the the value 
    // of the number with set 
    // bit at k-th position 
    return k;
} 

int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
        int n,m;
        cin>>n>>m;
        int height[n];
        for(int i=0;i<n;i++){
          cin>>height[i];
         
        }
        
        vector<int> v[n];
        while(m--){
          int x,y;
          cin>>x>>y;
          v[x-1].push_back(y-1);
          v[y-1].push_back(x-1);
        }
        int good=0;
        for (int i = 0; i < n; i++) { 
              int count=0;
            for (auto it = v[i].begin();it != v[i].end(); it++){ 
                  if(height[i]<=height[*it])
                    count++;}
                  if(count==0)
                    good++;
                }

          cout<<good<<"\n";
  
        
        
        return 0; 
     }
      
            
        




Measured memory_bytes: 9192
def solve():
    INF = float('inf')

    def max2(x, y): return x if x >= y else y

    N = int(input())
    As = list(map(int, input().split()))

    dp = [[[-INF]*(2) for j in range(3)] for i in range(N+1)]
    dp[0][2][0] = dp[0][2][1] = 0
    for i, A in enumerate(As):
        if i&1:
            for k in range(2):
                for j in range(3):
                    dp[i+1][j][0] = max2(dp[i+1][j][0], dp[i][j][k])
            for j in range(2):
                dp[i+1][j+1][1] = max2(dp[i+1][j+1][1], dp[i][j][0] + A)
        else:
            for j in range(3):
                dp[i+1][j][1] = max2(dp[i+1][j][1], dp[i][j][0] + A)
            for k in range(2):
                for j in range(1, 3):
                    dp[i+1][j-1][0] = max2(dp[i+1][j-1][0], dp[i][j][k])

    if N&1:
        print(max(dp[-1][1]))
    else:
        print(max(dp[-1][2]))


solve()


Measured memory_bytes: 130008
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

a,b=map(str,input().split())
n=int(a+b)
ans="No"
for i in range(1000):
    if i**2==n:
        ans="Yes"
print(ans)

Measured memory_bytes: 10360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
int d=365, n=26, score;
int c[27];
int s[366][27];
int a[366];
int sat[366]={};
int last[27]={};
ofstream fout("out.txt"), flog("log.txt");
uint64_t get_rand_range( uint64_t min_val, uint64_t max_val ) {

    srand((int)time(NULL));
    static mt19937_64 mt64(rand());

    uniform_int_distribution<uint64_t> get_rand_uni_int( min_val, max_val );

    return get_rand_uni_int(mt64);
}

int calcdiff(int t, int q){
    int p=a[t];
    int lp=0,rp=d+1,lq=0,rq=d+1;
    For(i,1,d+1){
        if(a[i]==p){
            if(i<t) lp=max(lp,i);
            else if(i>t) rp=min(rp,i);
        }
        else if(a[i]==q){
            if(i<t) lq=max(lq,i);
            else if(i>t) rq=min(rq,i);
        }
        if(i==t) a[i]=q;
    }
    int diff=s[t][q]-s[t][p];
    diff -= (t-lp) * (rp-t) * c[p];
    diff += (t-lq) * (rq-t) * c[q];
    return diff;
}

void greedy(){
    For(i,1,d+1){
        int mx = -(1<<30), acc = -1;
        For(con,1,n+1){
            int sati = sat[i-1] + s[i][con];
            For(j,1,n+1){
                if(j != con) sati -= (i-last[j]) * c[j];
            }
            if(mx<sati){
                mx = sati;
                acc = con;
            }
        }
        last[acc] = i;
        sat[i] = mx;
        a[i]=acc;
        flog << sat[i] << endl;
    }    
    score = sat[d];
}

void Main(){
    clock_t start = clock();
    cin >> d;
    For(i,1,n+1) cin >> c[i];
    For(i,1,d+1) For(j,1,n+1) cin >> s[i][j];
    greedy();
    double time = static_cast<double>(clock() - start) / CLOCKS_PER_SEC * 1000.0;
    /*while(time < 1950){
        int t = get_rand_range(1,d);
        int q = get_rand_range(1,n);
        int diff = calcdiff(t,q);
        //flog << diff << endl;
        if(diff>0){
            a[t] = q;
            score += diff;
            flog << t << " " << q << " " << score << endl;
        }
        time = static_cast<double>(clock() - start) / CLOCKS_PER_SEC * 1000.0;
    }*/
    For(i,1,d+1) cout << a[i] << endl;

}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h> 
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;
using P = std::pair<int, int>;
 
int main(int argc, char *argv[])
{
    int A, B;
    std::cin >> A >> B;

    if (B % A == 0) {
        std::cout << A+B << std::endl;
    } else {
        std::cout << B-A << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int N, K, A[100005];
ll DP[105][100005], Sum[105][100005];

int main(){
  scanf("%d %d", &N, &K);
  for (int i = 1; i <= N; i++) scanf("%d", A + i);
  DP[0][0] = 1;
  for (int j = 0; j <= K; j++) Sum[0][j] = 1;

  for (int i = 1; i <= N; i++){
    for (int j = 0; j <= K; j++){
      if (j - A[i] <= 0){
        DP[i][j] = Sum[i - 1][j];
      }else{
        DP[i][j] = Sum[i - 1][j] - Sum[i - 1][j - A[i] - 1];
        DP[i][j] %= nmax;
        if (DP[i][j] < 0) DP[i][j] += nmax;
      }
    }

    Sum[i][0] = DP[i][0];
    for (int j = 1; j <= K; j++){
      Sum[i][j] = DP[i][j] + Sum[i][j - 1];
      Sum[i][j] %= nmax;
    }    
  }
  printf("%lld\n", DP[N][K]);

  return 0;
}


Measured memory_bytes: 160000