akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
 
const long INF = (1l << 30);
const long LINF = (1l << 60);

long n;
long sum[200005];
std::string s;

int main(){
	scanf("%ld", &n);
	std::cin >> s;
	for(int i = 0; i < n; i++){
		if(s[i] == '#'){
			sum[i+1] = sum[i]+1;
		}else{
			sum[i+1] = sum[i];
		}
	}
	long ans = LINF;
	for(int i = 0; i <= n; i++){
		ans = std::min(ans, sum[i] + (n-i)-(sum[n]-sum[i]));
	}
	printf("%ld\n", ans);
	return 0;
}


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

int cnt,hen = 0,sum = 0;
bool used[1000];
vector<int> G[1000];

void dfs(int v){
	used[v] = true;
	cnt++;
	for(int to : G[v]){
		if(!used[to]) dfs(to);
	}
}

void win(){
	if((sum - hen) % 2) cout << "Taro" << endl;
	else cout << "Hanako" << endl;
}

void lose(){
	if((sum - hen) % 2 == 0) cout << "Taro" << endl;
	else cout << "Hanako" << endl;
}

signed main(){
	int n,guu = 0,ki = 0;
	cin >> n;
	for(int i = 0;i < n;i++){
		string s;
		cin >> s;
		for(int j = 0;j < n;j++){
			if(s[j] == 'Y'){
				G[i].push_back(j);
				hen++;
			}
		}
	}
	hen /= 2;
	for(int i = 0;i < n;i++){
		if(!used[i]){
			cnt = 0;
			dfs(i);
			if(cnt % 2) ki++;
			else guu++;
			sum += cnt * (cnt - 1) / 2;
		}
	}
	if(ki % 4 == 1 || !ki) win();
	else if(ki % 4 == 3) lose();
	else if(ki == 2){
		if(!guu) win();
		else if(guu == 1) cout << "Taro" << endl;
		else lose();
	}else if(ki % 4 == 0) win();
	else lose();
	return 0;
}

Measured memory_bytes: 3240
N = int(raw_input())

s = [int(raw_input()) for _ in xrange(N)] 
s.sort()

ans = sum(s)
k = 0

for i in range(N):
    if s[i] % 10 != 0:
        k = s[i]
        break

if ans % 10 == 0 and k == 0:
    print 0
elif ans % 10 != 0:
    print ans
else:
    print ans-k

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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    int index = 1, num = 0;
    while(1)
    {
        index = a[index - 1];
        if(index == 2)
        {
            cout << num + 1;
            return 0;
        }
        if(num > N + 1)
        {
            cout << -1;
            return 0;
        }
        num++;
    }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n,k; cin >> n >> k;
    vint a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    int res=0;
    rep(i,k) res+=a[i];
    cout<<res<<endl;
}

Measured memory_bytes: 3620
#include <stdio.h>

int main(void){
	int n, p, rikkouho[50], i, s;

	while (1){
		scanf("%d %d", &n, &p);
		if (n == 0 && p == 0) break;
		for (i = 0; i < n; i++){
			rikkouho[i] = 0;
		}

		i = 0; s = p;
		while (1){
			if (i == n) i = 0;
			if (s != 0){
				s--;
				rikkouho[i]++;
			}
			else{
				s = rikkouho[i];
				rikkouho[i] = 0;
			}
			if (rikkouho[i] == p) break;
			i++;
		}
		printf("%d\n", i);
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int run();
int main() {
// #ifdef Home
//     freopen("i", "r", stdin);
//     freopen("d", "w", stderr);
// #endif
//     cout.precision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    run();
    return 0;
}
ll a[401][401];
ll H,W;
queue<pair<ll,ll> > q;
ll used[401][401];
ll dx[4]={1,-1,0,0};
ll dy[4]={0,0,1,-1};

bool inside(ll x, ll y, ll i) {
    return (x + dx[i] < H && x + dx[i] >= 0 && y + dy[i] >= 0 && y + dy[i] < W);
}

bool check(ll x,ll y, ll i) {
    if (!inside(x, y, i)) return false;
    return a[x + dx[i]][y + dy[i]] != a[x][y];
}

ll solve() {
    ll ans = 0;
    for (ll i = 0; i < H; i++) {
        for (ll j = 0; j < W; j++) {
            if (used[i][j]) continue;
            ll b = 0, w = 0;//b-black a-WHite
            used[i][j] = 1;
            q.push({i, j});
            while (!q.empty()) {
                pair<ll, ll> r = q.front();
                q.pop();
                ll x = r.first;
                ll y = r.second;
                if (a[x][y]) b++;
                else w++;
                for (ll d = 0; d < 4; d++) {
                    if (!check(x, y, d)) continue;//invalid move
                    if (used[x + dx[d]][y + dy[d]]) continue;
                    used[x + dx[d]][y + dy[d]] = 1;
                    q.push({x + dx[d], y + dy[d]});
                }
            }
            ans += b * w;
        }
    }
    return ans;
}

int run() {
    cin>>H>>W;
    for(ll i=0;i<H;i++){
        for(ll j=0;j<W;j++){
            char cH;
            cin>>cH;
            a[i][j]=(cH=='#');
        }
    }
    memset(used,0,sizeof(used));
    ll ans=solve();
    cout<<ans;
}



Measured memory_bytes: 2816
// unolight {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
// }}}
int n;
string a;
void solve() {
	RI(n);
	cin >> a;
	int ans=1;
	REP1(i,1,n-1) {
		if(a[i]==a[i-1]) continue;
		else {
			ans++;
		}
	}
	printf("%d\n", ans);
}

int main( int argc, char *argv[] ) {
	solve();
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
#define asn ans
bool dbg = false;


void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    for (auto& c : s) {
        if (c == '7') {
            Yes();
            return 0;
        }
    }
    No();


    solve();
    return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = -1;
        for (int i = 1 ;; i++){
            n = sc.nextInt();
            sc.nextLine();
            if (n == 0) break;
            System.out.println("Case "+i+": "+n);
        }
        sc.close();
    }
}


Measured memory_bytes: 66228
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<ctime>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<bitset>
#define ll long long 
#define ull unsigned long long 
#define mem(a) memset(a,0,sizeof(a))
#define rint register int 
#define rll register long long 
#define rull register unsigned long long 
#define rchar register char
#define rstring register string 
#define rfloat register float
#define rdouble register double 
#define fio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define For(i,a,b) for(int i=a;i<b;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define cFor(i,a,b) for(int i=a;i>b;i--)
#define cFOR(i,a,b) for(int i=a;i>=b;i--)
#define lFor(i,a,b) for(ll i=a;i<b;i++)
#define lFOR(i,a,b) for(ll i=a;i<=b;i++)
#define lcFor(i,a,b) for(ll i=a;i>b;i--)
#define lcFOR(i,a,b) for(ll i=a;i>=b;i--)
#define watch(a) cout<<#a<<"="<<a<<endl
using namespace std;
int main(){
	double h,a;
	cin>>h>>a;
	cout<<ceil(h/a)<<endl;
} 

Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def main():
    S = input()
    print("Yes" if "AC" in S else "No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

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

  int  ans = 0;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    if ((i % 2 == 1) && (a % 2 == 1)) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <stdio.h>

int main(void){
    int i, n;
    long max, min, sum, temp;
    
    scanf("%d\n", &n);
    
    scanf("%ld", &temp);
    max = temp;
    min = temp;
    sum = temp;
    
    for(i=1;i<n;i++){
        scanf("%ld\n", &temp);
        if (max<temp){max=temp;}
        if (min>temp){min=temp;}
        sum +=temp;
    }
    
    printf("%ld %ld %ld\n", min, max, sum);
    
    return 0;
}


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

using vi = vector<int>;

int main()
{
    int n, k; cin >> n >> k;

    vi v(10);

    for(int i = 0; i < k; i++)
    {
        int d; cin >> d;

        v[d]++;
    }

    while(1)
    {
        int fl = 0;

        for(int x = n; x; x /= 10) fl |= v[x % 10];

        if(!fl)
        {
            cout << n << endl;
            break;
        }

        n++;
    }

    return 0;
}

Measured memory_bytes: 256
function main(input){
  const args = input.split(' ');
  const a = parseInt(args[0], 10);
  const b = parseInt(args[1], 10);
  
  if((a * b) % 2 == 0 ){
    console.log('Even');
  } else {
    console.log('Odd')
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
int D;
int s[367][28], c[28];
int last[28];
ll calc(int day, int item, int after)
{
    ll score = s[day][item];

    //dayまでの満足度を計算する
    rep(k, 1, 27)
    {
        score -= c[k] * (day - (item == k ? day : last[k]));
    }
    //dayからafter日後まで含めた満足度を計算する
    rep(k, 0, after)
    {
        score -= c[item] * ((day + k) - last[item]);
    }
    return score;
}
int main()
{
    cin >> D;

    rep(i, 1, 27)
    {
        cin >> c[i];
    }
    rep(i, 1, D + 1)
    {
        rep(j, 1, 27)
        {
            cin >> s[i][j];
            last[j] = 0;
        }
    }
    vector<int> t(D + 1);
    ll score = 0;
    ll maxi = -100000, tmax = -10000;
    int best_i = 0;

    rep(day, 1, D + 1)
    {
        maxi = -10000000;
        best_i = -1;
        tmax = -10000;
        rep(item, 1, 27)
        {
            rep(k, 1, 27)
            {
                score = calc(day, item, k);
                if (tmax > score)
                {
                    tmax = score;
                }
            }
            if (maxi < tmax)
            {
                maxi = tmax;
                best_i = item;
            }
        }
        t[day] = best_i;
        last[best_i] = day;
    }

    rep(i, 1, D + 1)
    {
        cout << t[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3652
input1 = gets
input2 = gets
array1 = input1.split(" ").map{|item| item.to_i}
array2 = input2.split(" ").map{|item| item.to_i}

N = array1[0]
K = array1[1]

count = 0

for i in 0...N
  if array2[i] >= K
    count += 1
  end
end

p count

Measured memory_bytes: 7940
#include<iostream>
using namespace std;
int main()
{
	int x,a,b,m,n;
	cin >> x >> a >> b;
	if(x>a)
	m=x-a;
	if(x<=a)
	m=a-x;
	if(x>b)
	n=x-b;
	if(x<=b)
	n=b-x;
	if(m>n)
	cout << "B" << endl;
	if(n>m)
	cout << "A" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define read(x) scanf("%d",&x)
using namespace std;

struct R{
	int to,nex;
}r[2002000];
int hea[1001000],cnt=1;
int n,a[1001000],f[1001000],x,y;
bitset<1001000>bo;

void U(int x,int y,int fl){
	f[x]+=fl*(!f[y]&&a[x]>a[y]);
}

void ddd(int x,int fff){
	int y;
	f[x]=0;
	
	for (int i=hea[x];i>0;i=r[i].nex){
		y=r[i].to; if (y==fff) continue;
		ddd(y,x);
		U(x,y,1);
	}
}

void dfs(int x,int fff){
	if (f[x]) bo[x]=1;
	int y;
	for (int i=hea[x];i>0;i=r[i].nex){
		y=r[i].to; if (y==fff) continue;
		U(x,y,-1); U(y,x,1);
		dfs(y,x);
		U(y,x,-1); U(x,y,1);
	}
}

int main(){
	//freopen("C.in","r",stdin); freopen("C.out","w",stdout);
	bo.reset();
	read(n);
	for (int i=1;i<=n;i++) read(a[i]);
	for (int i=1;i<n;i++){
		read(x); read(y);
		r[++cnt]=(R){y,hea[x]}; hea[x]=cnt;
		r[++cnt]=(R){x,hea[y]}; hea[y]=cnt;
	}
	ddd(1,0);
	dfs(1,0);
	for (int i=1;i<=n;i++) if (bo[i])
		printf("%d ",i);
}

Measured memory_bytes: 6656
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;

typedef pair <long long, long long> pii;

const long long MAX_N = 1e3 + 3, inf = 1000000LL * 1000000LL * 1000000LL, MOD = 1e9 + 7;
long long n, m, ans;
long long dp[MAX_N][MAX_N];
string table[MAX_N];

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for (long long i = 0; i < n; i++)
		cin >> table[i];

	dp[0][0] = 1;
	for (long long i = 0; i < n; i++)
		for (long long j = 0; j < m; j++) {
			if (table[i][j] == '#') {
				dp[i][j] = 0;
				continue;
			}

			if (i)
				dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
			if (j)
				dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD;
		}

	cout << dp[n - 1][m - 1] << "\n";
	return 0;
}

Measured memory_bytes: 9216
#include <iostream>
#include <algorithm>
using namespace std;
#define N 100010

int main(){
  int dp[N];
  int n;
  dp[0] = 0;
  for (int i=1; i<=100000; i++){
    dp[i] = N;
    int power = 1;
    while(power <= i){
      dp[i] = min(dp[i], dp[i-power]+1);
      power *= 6;
    }
    power = 9;
    while(power <= i){
      dp[i] = min(dp[i], dp[i-power]+1);
      power *= 9;
    }
  }
  cin >> n;
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 640
import java.util.*;
import java.io.*;
 
public class Main {
	
	
	
	public static void main(String args []) {
		InputReader obj = new InputReader(System.in);
		int m = obj.nextInt();
		int d = obj.nextInt();
		
		if(d<22) {
			System.out.println(0);
			return;
		}
		int cnt=0;
		for(int i=22;i<=d;i++) {
			if(i%10<2) {
				continue;
			}
			if((i%10)*(i/10)<=m) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
	public static class InputReader {
	    public BufferedReader reader;
	    public StringTokenizer tokenizer;
 
	    public InputReader(InputStream stream) {
	        reader = new BufferedReader(new InputStreamReader(stream), 32768);
	        tokenizer = null;
	    }
 
	    public String next() {
	        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }
 
	    public int nextInt() {
	        return Integer.parseInt(next());
	    }
 
	    public long nextLong() {
	        return Long.parseLong(next());
	    }
	    
 
	}
}

Measured memory_bytes: 22996
<?php

class Solver
{
    private $num_x;
    private $num_y;

    public function __construct()
    {
        while (1) {
            $line = fgets(STDIN);
            if ($line == false) {
                break;
            }
            $line = trim($line);
            $lines[] = $line;
        }

        $num_xy = explode(' ', $lines[0]);
        $this->num_x = $num_xy[0];
        $this->num_y = $num_xy[1];
    }

    public function getAnswer()
    {
        echo $this->calculateGCD($this->num_x, $this->num_y), PHP_EOL;
    }

    public function calculateGCD($x, $y)
    {
        list($x, $y) = $x > $y ? [$x, $y] : [$y, $x];

        if ($x==$y) {
            return $x;
        }

        $candidate = $x % $y;
        if (($this->num_x % $candidate) + ($this->num_y % $candidate) >0) {
            return $this->calculateGCD($y, $candidate);
        }
        else {
            return $candidate;
        }
    }
}

$answer = new Solver;
$answer->getAnswer();


Measured memory_bytes: 9412
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main(){
ll N, S = -1, Ans = 0;cin >> N;
vector<ll> V(N + 1);
map<ll, ll> P;

rep(i, 1, N + 1){
  
  cin >> V[i];
  
  P[V[i]]++;
  
}
  
ll M = *max_element(ALL(V));

vector<bool> A(M + 1, 1);

sort(ALL(V));
  
 ll a = 0, b = 0;

rep(i, 1, N + 1){
  
    if(a == 0){
      
      a = V[i];
      
      if(a == b){a = 0;continue;}
      
    }
  
    else{
    
      b = V[i];
      
      if(a == b){a = 0;continue;}
      
      a = 0;
      
    }

    rep(n, 1, floorl(M/V[i])){

        A[(n + 1)*V[i]] = 0;

    } 

}

rep(i, 1, N + 1){

    if(A[V[i]] && P[V[i]] < 2)Ans++;

}

cout << Ans;

}

Measured memory_bytes: 17352
package main

import (
	"fmt"
)

func main() {
	var A, B, C int
	fmt.Scanf("%d %d %d\n", &A, &B, &C)
	r := A + B + C
	if r >= 22 {
		fmt.Println("bust")
	} else {
		fmt.Println("win")
	}
}


Measured memory_bytes: 512
import itertools

def solve(D, G, problems):
    bit_list = list(itertools.product([0, 1], repeat=D))
    
    result_count = 10 ** 8
    for pattern in bit_list:
        score = 0 # スコアの合計
        count = 0  # 解いた問題数
        for i in range(D):
            if pattern[i] == 1: # ビット値が１の難易度の問題は全て解く
                score += problems[i][0] * (i+1) * 100 + problems[i][1]  # 問題のスコア + ボーナス点
                count += problems[i][0]
            
            else:
                max_score_problem = i
    
        # 合計スコアが足りない場合，もっともスコアの高い未着手の問題を必要な分だけ解く
        if score < G:
            for i in range(problems[max_score_problem][0]):
                count += 1
                score += (max_score_problem + 1) * 100
                if score >= G:
                    break
        
        if score >= G:
            result_count = min(result_count, count)
            
    print(result_count)
    

if __name__ == '__main__':
    D, G = map(int, input().split())
    problems = [list(map(int, input().split())) for _ in range(D)]
    solve(D, G, problems)

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
const int N=200100;
long long abs_(long long x)
{
    if(x<0) x=-x;
    return x;
}
long long ans,n,a[N],sum[N],sumd[N];
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;++i) cin>>a[i];
    for(int i=1;i<=n;++i)
        sum[i]=sum[i-1]+a[i];
    for(int i=n;i>=1;--i)
        sumd[i]=sumd[i+1]+a[i];
    ans=0x3fffffffffffffff;
    for(int i=1;i<n;++i)
        ans=min(ans,abs_(sum[i]-sumd[i+1]));
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  int k,a,b;
  cin >> k;
  cin >> a >> b;
  for(int i=a;i<=b;i++){
    if(i%k==0){
      cout<<"OK";
      return 0;
    }
  }
  cout << "NG";
  return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 2019;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

long long powmod(long long a, long long x){
    if(x == 0)return 1;
    long long r = powmod(a, x / 2);
    return (x%2)? (r * r % MOD) * a % MOD : r * r % MOD;
}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	string s; cin >> s;
	ll n = s.size();
	ll v[n];
	ll x = 0;
	rrep(i, n-1, 0){
		ll y = s[i]-'0';
		x += y*powmod(10, n-1-i);
		x %= 2019;
		v[i] = x;	
	}
	
	ll cnt[2019]; memset(cnt, 0, sizeof(cnt));
	cnt[0] = 1;
	ll ans = 0;
	zep(i, 0, n){
		//print(v[i])
		ans += cnt[v[i]];
		cnt[v[i]]++;
	}
	print(ans)
	return 0;
}

Measured memory_bytes: 5328
#include<bits/stdc++.h>
#define N 100005
using namespace std;
struct edge{
    int t,next;
}e[N*2];int ecnt,head[N];
void addedge(int f,int t){
    e[++ecnt]=(edge){t,head[f]};head[f]=ecnt;
    e[++ecnt]=(edge){f,head[t]};head[t]=ecnt;
}

int DFS(int u,int fr){
    int tot=0;
    for(int i=head[u];i;i=e[i].next){
        if(e[i].t!=fr) tot+=DFS(e[i].t,u);
    }
    if(fr==0&&tot==0) return 1;
    else if(fr==0&&tot==1) return 0;
    if(tot>=2) return 2;
    return tot^1;
}

int n;
int main(){
    scanf("%d",&n);
    for(int i=1,f,t;i<n;i++) scanf("%d%d",&f,&t),addedge(f,t);
    if(DFS(1,0)) puts("First");
    else puts("Second");
    return 0;
}

Measured memory_bytes: 2176
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long

typedef long long int64;
typedef vector<int> VI64;
typedef vector<pair<int,int>> VII64;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;

int32_t main()
{
	IOS;
	int T=1;
	//cin>>T;
	while(T--)
	{
		int n,m,i,sm=0,tem;
		cin>>n>>m;
		for(i=0;i<m;i++)
		{
			cin>>tem;
			sm+=tem;
		}
		if(sm>n)
			cout<<-1;
		else
			cout<<n-sm;
	}

	return 0;
}

Measured memory_bytes: 3644
import java.util.*

fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map{it.toLong()}
    val A = readLine()!!.split(" ").map{it.toLong()}.sorted().toTypedArray()
    val F = readLine()!!.split(" ").map{it.toLong()}.sortedDescending()

    var l = -1L
    var u = 1e13.toLong()

    while (u - l > 1) {
        val c = (l + u) / 2

        var k = K
        var ok = true
        for (i in A.indices) {
            val d = Math.max(A[i] - c / F[i], 0L)
            if (d > k) {
                ok = false
                break
            } else {
                k -= d
            }
        }

        if (ok) {
            u = c
        } else {
            l = c
        }
    }

    println(u)
}


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

nList = list(map(int,input().split()))
L2count = 0
L4count = 0

for i in nList:
  if i%4 == 0:
    L4count += 1
  elif i%2 == 0:
    L2count += 1

if L4count >= n//2:
  print("Yes")
elif L2count >=  n-2*L4count:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 15020
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	string s;
	cin >> s;
	if(s == "ABC") cout << "ARC";
	else cout << "ABC";
	return 0;
}

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


int main(void){
   int64_t K,N;
   cin >> K >> N;
   vector<int64_t> A(N);
    for (int i=0;i<N;i++) {
        cin >> A[i];
    }
    int64_t d;
    d=A[0]+K-A[N-1];
    for (int i=0;i<N-1;i++) {
        d=max(d,A[i+1]-A[i]);
    }
   
    cout << K-d << endl;
}




Measured memory_bytes: 4840
while True:
	n = int(input())
	if n == 0:
		break
	data = [map(int,input().split()) for i in range(n)]
	p,q,r,c = map(int,input().split())

	ans = [i for i,pp,qq,rr in data if pp<=p and qq<=q and rr<=r and pp*4+qq*9+rr*4<=c]

	if len(ans):
		for i in ans:
			print (i)
	else :
		print ("NA")

Measured memory_bytes: 8388
#include <bits/stdc++.h>
#define int int64_t
#define rp(i, N) for(int i=0; i<N; i++);
using namespace std;
using pair = pair<int, int>;
using tup  = tuple<int, int, int>;
using vec  = vector<int>;
using vvec = vector<vec>;
const int INF = 100000000;
// " ", ' '

// プロトタイプ宣言
// int myfunc(int, vvec);

// グローバル変数
// int N, M;
// vvec data(N, vec(M));

// 関数：

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int K, X; cin >> K >> X;
	int tp, bn;
	bn = X-K+1;
	tp = X+K-1;

	for(int i=bn; i<=tp; i++) {
		cout << i;
		if(i<tp) cout << ' ';
		else cout << endl;
	}
	
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
using namespace std;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <bitset>

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

	vector<int> a(N + 1);
	rep(i, N) {
		cin >> a.at(i + 1);
	}

	int c = 1, result = 0;

	rep(i, N) {
		if (c == 2) {
			cout << result << endl;
			return 0;
		}

		c = a[c];
		result++;	
	}

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

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define yes "Yes"
#define no "No"
using namespace std;

int main() {
  int x, y, turu, kame,flag;
  cin >> x >> y;
  for (turu = 0; turu <= x; turu++) {
    kame = x - turu;
    flag = (x == kame + turu) && (y == 2 * turu + 4 * kame);
    if (flag) {
      break;
    }
  }
  if (flag) {
    cout  << yes << endl;
  }else{
    cout << no << endl;
  }
}


Measured memory_bytes: 3624
using System;

public class Program
{
	public static int top;
	public static int[] S = new int[1000];

	public static int Main()
	{
		int a, b;
		top = 0;
		string[] line = Console.ReadLine().Split(' ');
		for( int i = 0; i < line.Length; i++){
			if ( line[i] == "+") {
				a = pop();
				b = pop();
				push(a + b);
			} else if ( line[i] == "-") {
				b = pop();
				a = pop();
				push(a - b);
			} else if ( line[i] == "*") {
				a = pop();
				b = pop();
				push(a * b);
			} else {
				push(int.Parse(line[i]));
			}
		}

		Console.WriteLine("{0}", pop());

		return 0;
	}

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

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


}

Measured memory_bytes: 9124
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int h, w, d; cin >> h >> w >> d;
	pair<int, int> a[100000];
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			int k; cin >> k;
			a[k] = make_pair(i, j);
		}
	}
	int cost[100000];
	for (int i = 1; i <= h*w; i++) {
		if (i <= d)cost[i] = 0;
		else {
			int xi = a[i].first - a[i - d].first;
			int yj = a[i].second - a[i - d].second;
			cost[i] = cost[i - d] + abs(xi) + abs(yj);
		}
	}
	int q; cin >> q;
	for (int i = 0; i < q; i++) {
		int l, r; cin >> l >> r;
		cout << cost[r] - cost[l] << endl;
	}
}

Measured memory_bytes: 2304
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        OMatching solver = new OMatching();
        solver.solve(1, in, out);
        out.close();
    }

    static class OMatching {
        long MOD = (int) 1e9 + 7;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            boolean[][] pair = new boolean[N][N];
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {
                    pair[i][j] = (in.nextInt() == 1);
                }
            }
            long[] dp = new long[1 << N];
            dp[0] = 1;
            for (int mask = 0; mask < (1 << N) - 1; mask++) {
                int men_paired = Integer.bitCount(mask);
                // pairing men at index men_paired with some women
                for (int women = 0; women < N; women++) {
                    if (pair[men_paired][women] && ((1 << women) & mask) == 0) {
                        dp[mask + (1 << women)] = (dp[mask + (1 << women)] + dp[mask]) % MOD;
                    }
                }
            }

            out.print(dp[(1 << N) - 1]);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 40148
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pii;
typedef pair<pii,pii> piiii;
typedef vector<pii> vii;
typedef vector<ll> vi;
typedef queue<ll> qi;
typedef queue<char> qc;
typedef queue<string> qs;
typedef vector<char> vc;
typedef vector<string> vs;
typedef map<char,ll> mpci;
typedef map<ll,ll> mpii;
typedef map<string,ll> mpsi;
typedef set<ll> sei;
typedef set<char> sec;
typedef set<string> ses;
typedef stack<ll> si;
typedef stack<char> sc;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pll> vpll;
typedef vector<pdd> vdd;
typedef unsigned int uint;
typedef long double ld;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vii> vvii;
/*=====================================================================*/
#define pb push_back
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define sz(a) (int)(a.size())
#define len(a) (int)(a.length())
#define all(s) (s).begin(),(s).end()
#define fi first
#define se second
#define be begin
#define en end
#define m_p make_pair
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define forn(i,p,n) for(int i=p;i<=n;i++)
#define ford(i,p,n) for(int i=n-1;i>=p;i--)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();++i)
#define zero(a) memset(a,0,sizeof(a))
#define number(a,num) memeset(a,num,sizeof(a))

/*=====================================================================*/

inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
inline void write(long long x) {
  static long long sta[35];
  long long top = 0;
  do {
    sta[top++] = x % 10, x /= 10;
  } while (x);
  while (top) putchar(sta[--top] + 48);
  puts("");
}
/*======================================================================*/
bool prime(int n)
{
	if(n==0||n==1)
	  return false;
	for(int i=2;i*i<=n;i++)
	  if(n%i==0)
	    return false;
	return true;
}
/*======================================================================*/
const int dx[]={-1,0,1,0};
const int dy[]={0,-1,0,1};
/*======================================================================*/
int main()
{
  /*
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
  */
  /*====================================================================*/
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b+c>=22)
    cout<<"bust";
  else
    cout<<"win";
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
a = list(map(int, input().split()))
dp = [False]*(K+1)

for i in range(K+1):
    for ai in a:
        if i-ai>=0:
            dp[i] |= not dp[i-ai]

if dp[K]:
    print('First')
else:
    print('Second')

Measured memory_bytes: 74188
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    s = SS()

    N = len(s)

    # 出す順番関係なし パーを出せるだけ出せば良い
    ans = N // 2 - s.count('p')
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9912
from collections import deque
import copy

h,w = map(int,input().split())
l = [['#']*(w+2)]
for i in range(h):
    l.append(['#']+list(input())+['#'])
l.append(['#']*(w+2))

ans = 0
directions = [(1,0),(0,1),(-1,0),(0,-1)]

for i in range(1,h+1):
    for j in range(1,w+1):
        visited = copy.deepcopy(l)
        if visited[i][j]=='.':
            visited[i][j] = 0
            que = deque([(i,j)])
            while que:
                v = que.popleft()
                for dir in directions:
                    nv = (v[0]+dir[0],v[1]+dir[1])
                    if visited[nv[0]][nv[1]] == '.':
                        times = visited[v[0]][v[1]]+1
                        visited[nv[0]][nv[1]] = times
                        que.append(nv)
                        ans = max(times,ans)
            # print((i,j),ans)

print(ans)

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

using namespace std;

typedef long long ll;

int main(){
	double a,b,x;
	scanf("%lf%lf%lf",&a,&b,&x);
	double v=a*a*b;
	if(x>(v/2)){
		double k=2*(v-x)/a/a;
		printf("%.7lf",atan(k/a)*180/acos(-1.0));
	}
	else{
		double k=2*x/b/a;
		printf("%.7lf",atan(b/k)*180/acos(-1.0));
	}
	return 0;
} 

Measured memory_bytes: 384
n = int(input())
w = list(map(int,input().split()))
ans = 10**9
s1 = 0
s2 = sum(w)

for i in w:
    s1 += i
    s2 -= i
    if  abs(s1-s2) < ans:
        ans = abs(s1-s2)
print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	long long n, a, b, i, j, k, sa, ans, si, x;
	cin >> n >> a >> b;
	vector<long long> v(n), s(n + 1);
	map<long long, long long> ct, ct2;
	for (i = 0; i < n; i++) {
		cin >> v[i];
		ct[v[i]]++;
	}
	sort(v.rbegin(), v.rend());
	s[0] = 0;
	for (i = 1; i <= n; i++) s[i] = s[i - 1] + v[i - 1];
	sa = s[a];

	ans = 0;
	for (i = a; i <= b; i++) {
		si = s[i];
		if (si * a == sa * i) {
			ct2.clear();
			for (j = 0; j < i; j++) ct2[v[j]]++;

			x = 1;
			for (j = 0; j < ct2[v[i - 1]]; j++) {
				x = x * (ct[v[i - 1]] - j) / (j + 1);
			}
			ans += x;
		}
	}

	long double r = 1.0 * sa / a;
	cout << setprecision(10) << fixed << r << "\n" << ans << "\n";


	return 0;
}


Measured memory_bytes: 384
N = gets.to_i
w = gets.chomp
A = []
A.push w
(N-1).times do |i|
    s = gets.chomp
    if w[-1] != s[0] || A.include?(s) then
        puts "No"
        exit
    else
        A.push s
        w = s
    end
end
puts "Yes"

Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

int main() {
	lint A, B;
	char c;
	cin >> A >> c >> B;
	if (c == '+') {
		cout << A + B << endl;
	}
	else {
		cout << A - B << endl;
	}
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;

int main(){
    int n;
    cin>>n;
    if(n==7 || n==5 || n==3) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
n, q = map(int, input().split())
tree = [[] for _ in range(n)]
point = [0] * n
for _ in range(n-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

for _ in range(q):
    p, x = map(int, input().split())
    point[p-1] += x

stack = [[0, 0, -1]]
while stack:
  v, p, parent = stack.pop()
  point[v] += p
  for child in tree[v]:
    if child == parent:
      continue
    stack.append([child,point[v],v])

print(*point)

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

#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define FILL0(x) memset(x,0,sizeof(x))
#define FILL1(x) memset(x,-1,sizeof(x))

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

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 main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int x;
    cin >> x;

    x-=400;
    int kyu = 8;
    rep(i, 100)
    {
        x-=200;
        if(x<0)
        {
            cout << kyu << endl;
            return 0;
        }
        kyu--;
    }
    




    return 0;

}



Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		String[] str = br.readLine().split(" ");
		int sx = Integer.parseInt(str[0]);
		int sy = Integer.parseInt(str[1]);
		int tx = Integer.parseInt(str[2]);
		int ty = Integer.parseInt(str[3]);

		int x = tx - sx;
		int y = ty - sy;
		StringBuilder sbx = new StringBuilder();
		StringBuilder sby = new StringBuilder();
		StringBuilder sbx_ = new StringBuilder();
		StringBuilder sby_ = new StringBuilder();
		for(int i = 0; i < x; i++){
			sbx.append('R');
			sbx_.append('L');
		}
		for(int i = 0; i < y; i++){
			sby.append('U');
			sby_.append('D');
		}


		sb.append(sbx.toString()).append(sby.toString());
		sb.append(sbx_.toString()).append(sby_.toString());
		sb.append('D').append('R').append(sbx.toString()).append(sby.toString()).append('U').append('L');
		sb.append('U').append('L').append(sbx_.toString()).append(sby_.toString()).append('D').append('R');

		System.out.println(sb);
	}
}

Measured memory_bytes: 8404
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String[] args) throws IOException {
		MScanner sc=new MScanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		long a=sc.nextLong(),b=sc.nextLong();
		if(a==1 || b==1) {
			pw.println(1);
			pw.flush();
			return;
		}
		long area=a*b;
		pw.println((area+1)/2);
		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] takearr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] takearrl(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public Integer[] takearrobj(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] takearrlobj(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}
 


 

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

//#define DEBUG

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

int main() {
    string s; cin >> s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import math

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

def judgement(n, pos):
    return (int(pos) - 1) * math.factorial(n - 1)

def position(target, list):
    pos = 0
    for i in list:
        if (int(target) > int(i)):
            pos += 1
    return pos + 1

def calculateRank(list):
    targetNum = 0
    rank = 0
    for i in range(N - 1):
        targetNum = list[0]
        list.pop(0)
        targetPosition = position(targetNum, list)
        rank += judgement(N - i, targetPosition)

    return rank

rankA = calculateRank(P)
rankB = calculateRank(Q)

print(abs(rankA - rankB))

Measured memory_bytes: 3064