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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

void solve(long long N, long long M, std::vector<long long> s, std::vector<long long> c) {

    vector<ll> ans(N, -1);
    rep(i, M) {
        int idx = (s[i] - 1);
        if (ans[idx] == -1 or ans[idx] == c[i]) {
            ans[idx] = c[i];
        } else {
            cout << -1 << endl;
            return;
        }
    }
    if (N == 1 and M == 0) {
        cout << 0 << endl;
        return;
    }
    if (N > 1 and ans[0] == 0) {
        cout << -1 << endl;
        return;
    }
    if (ans[0] == -1) ans[0] = 1;
    for (int i = 1; i < N; i++) {
        if (ans[i] == -1) ans[i] = 0;
    }
    rep(i, N) {
        cout << ans[i];
    }
    cout << endl;
    return;
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> s(M);
    std::vector<long long> c(M);
    for (int i = 0; i < M; i++) {
        scanf("%lld", &s[i]);
        scanf("%lld", &c[i]);
    }
    solve(N, M, std::move(s), std::move(c));
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))
a=sorted(a)
ans=0
cnt=1
for i in range(n-1):

    if a[i]==a[i+1]:
        cnt+=1
    else:
        if cnt%2==1:ans+=1
        cnt=1
if cnt%2==1:ans+=1
print(ans)


Measured memory_bytes: 81324
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main()
{
    io
    int grid[3][3];
    for(int i = 0; i < 3; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            cin >> grid[i][j];
        }
    }
    int n;
    cin >> n;
    bool visited[3][3] = {false};
    for(int i = 0; i < n; i++)
    {
        int num;
        cin >> num;
        for(int j = 0; j < 3; j++)
        {
            for(int k = 0; k < 3; k++)
            {
                if(num == grid[j][k])
                {
                    visited[j][k] = true;
                    break;
                }
            }
        }
    }
    int win = 0;
    for(int i = 0; i < n; i++)
    {
        if(visited[i][0] && visited[i][1] && visited[i][2])
        {
            win = 1;
            break;
        }
        else if(visited[0][i] && visited[1][i] && visited[2][i])
        {
            win = 1;
            break;
        }
    }
    if(visited[0][0] && visited[1][1] && visited[2][2])
        win = 1;
    else if(visited[2][0] && visited[1][1] && visited[0][2])
        win = 1;
    if(win == 1)
        cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
from collections import deque
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

table = [0] * 45

table[0] = 1
table[1] = 1

N = int(input())

for i in range(2,N+1):
    table[i] = table[i-1]+table[i-2]


print("%d"%(table[N]))



Measured memory_bytes: 6372
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m, k = list(map(int, input().split()))
uf = UnionFind(n)
like = [[] for i in range(n)]
dislike = [[] for i in range(n)]
for i in range(m):
  a, b = list(map(int, input().split()))
  a -= 1
  b -= 1
  like[a].append(b)
  like[b].append(a)
  uf.union(a, b)
for i in range(k):
  a, b = list(map(int, input().split()))
  a -= 1
  b -= 1
  dislike[a].append(b)
  dislike[b].append(a)

for i in range(n):
  team = uf.find(i)
  ans = uf.size(team) - len(like[i])
  for j in dislike[i]:
    if uf.find(j) == team:
      ans -= 1
  print(ans - 1, " ", end ="")
  

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

using namespace std;

int main(void) {
	int num, i, ans = 0;
	cin >> num;
	num <<= 1;
	vector<int> d(num);
	for (i = 0; i < num; i++)
		scanf("%d", &d[i]);
	sort(d.begin(), d.end());
	for (i = 0; i < num; i += 2)
		ans += d[i];
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
ll a,b,c,d;
cin >> a >> b >> c >> d;
while(a>0&&c>0){
    c -= b;
    if(c<=0){
        cout << "Yes" << endl;
        return 0;
    }
    a -= d;
    if(a<=0){
        cout << "No" << endl;
    }
}}


Measured memory_bytes: 3596
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
using P = pair<int64, int64>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
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; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
#define bn '\n'
template <typename T>
ostream& operator<<(ostream& os, const vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
    os << "(";
    os << P.first;
    os << " , ";
    os << P.second;
    os << ")";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;


//拡張Euclidの互除法
//ap + bq = gcd(a,b) となる(p,q)を求め、gcd(a,b)を返す
long long exGCD(long long a, long long b, long long &p, long long &q){
    if(b==0){
        p=1; q= 0;
        return a;
    }
    long long d = exGCD(b,a%b,q,p);
    q -= a/b * p;
    return d;
}

//中国の剰余定理
//解がx≡r(mod. M)となるような r,Mをpairで返す
pair<long long,long long> ChineseRem(const vector<long long>& b,const vector<long long>& m){
    if(b.size()!=m.size()){
        cerr << "bとmのサイズが違います" << bn;
        return make_pair(-1,-1);
    }
    long long r = 0, M = 1;
    long long p,q;
    REP(i,b.size()){
        long long d = exGCD(M,m[i],p,q);
        if((b[i]-r)%d != 0) return make_pair(-1,-1); //解無し
        long long tmp = (b[i] - r)/d * p % (m[i]/d);
        r += M * tmp;
        M *= m[i] / d;
    }
    r%=M;
    while(r<0) r+=M;
    return make_pair(r,M);
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int64 N,M;
    cin >> N >> M;
    vector<int64> A(N);
    vector<int64> B(N);
    REP(i,N) cin >> A[i], B[i] = A[i]/2;

    int64 x,m;
    tie(x,m) = ChineseRem(B,A);
    if(x==-1){
        cout << 0 << bn;
    }else{
        int ans = M/m + (x<=(M%m));
        cout << ans << endl;
    }

}

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

#define ll long long
#define llu unsigned long long
#define pb push_back
#define mp make_pair
#define tc int t; cin>>t;while(t--)
#define sfi(x) scanf("%d",&x)
#define sfl(x) scanf("%lld",&x)
#define f(i,a,n) for(int i=a ; i<n; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios:: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

int main()
{
   int n;
   cin>>n;
   int a, b;
   a=n%10;
   if(a==3)
    cout<<"bon";
   else if(a==0 || a==1 || a==6 || a==8)
    cout<<"pon";
   else
    cout<<"hon";
}



Measured memory_bytes: 3636
n = gets.to_i
# dp[i][j] <= i日目に[A,B,C]の活動をしたときの幸福度の最大値
dp = Array.new(n){[0,0,0]}
dp[0] = gets.split.map(&:to_i)
(1..n-1).each do |i|
  gets.split.map(&:to_i).each_with_index do |abc,j|
    dp[i-1].each_with_index do |abc2,k|
      # 異なる活動のときだけ、幸福度を加えたときの最大値を更新する
      next if j == k
      dp[i][j] = [abc + abc2, dp[i][j]].max
    end
  end
end
p dp[n-1].max


Measured memory_bytes: 22444
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

const int N = 333;

string s[N];
int n;

bool check(int x) {
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (s[i][j] != s[j][i]) {
				return 0;
			}
		}
	}
	return 1;
}




int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    n = readInt();
    int ans = 0;
    for (int i = 0; i < n; i++) {
		cin >> s[i];
    }	
   	for (int i = 0; i < n; i++) {
   		for (int j = 0; j < n; j++) {
   			rotate(s[j].begin(), s[j].begin() + 1, s[j].end());
   		}
   		if (check(i)) {
   			ans ++;
   		}	
   	}
   	cout << n * ans;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
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; }

vector< vector < char > > smap(8, vector<char>(8, '.'));
int k;
int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
vector<bool> qcheck(8, false);

bool queencheck(vector< vector < char > > &ssmap, int x, int y) {
    bool flg = true;
    for(int i = 0; i < 8; ++i) {
        int xx = 1;
        while(1) {
            int nx = x+(dx[i]*xx); int ny = y+(dy[i]*xx);
            if(nx >= 0 && nx < 8 && ny >= 0 && ny < 8) {
                if(ssmap[ny][nx] == 'Q') {
                    flg = false;
                    break;
                }
            }else break;
            xx++;
        }
    }
    return flg;
}

void qprint(vector< vector < char > > &qmap) {
    for(int i = 0; i < 8; ++i) {
        for(int j = 0; j < 8; ++j) {
            cout << qmap[i][j];
        }
        cout << endl;
    }
}

void solve(vector< vector < char > > &ssssmap, int h) {
    if(h == 8) {
        qprint(ssssmap);
        return ;
    }else {
        if(!qcheck.at(h)) {
            // まだQが置かれていない
            for(int w = 0; w < 8; ++w) {
                if(ssssmap[h][w] == '.') {
                    if(queencheck(ssssmap, w, h)) {
                        ssssmap[h][w] = 'Q';
                        solve(ssssmap, h+1);
                        ssssmap[h][w] = '.';
                    }
                }
            }
        }else {
            // すでにQが置かれている
            solve(ssssmap, h+1);
        }
    }
}


int main() {
    cin >> k;
    for(int i = 0; i < 8; ++i) {
        for(int j = 0; j < 8; ++j) {
            smap[i][j] = '.';
        }
    }
    for(int i = 0; i < k; ++i) {
        int r, c;
        cin >> r >> c;
        smap[r][c] = 'Q';
        qcheck.at(r) = true;
    }

    solve(smap, 0);
}


Measured memory_bytes: 3096
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>
#include <stack>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator<< (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

istream& operator>> (istream& a, pii& b) {
    cin >> b.first >> b.second;
    return a;
}

ostream& operator<< (ostream& a, const pii& b) {
    cout << "{" << b.first << ", " << b.second << "}";
    return a;
}

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 &y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 &y) {if (x < y) x = y;}


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 100;
    const int mod = 2600000069;
    // const int p = 10;
    // const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
    const int mod = 2600000069; 
    // const int p = 179;
    // const ld PI = 3.1415926535;
#endif

// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,sse3,sse4")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("avx2")  
// #pragma GCC optimize("section-anchors")
// #pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
// #pragma GCC optimize("vpt")
// #pragma GCC optimize("rename-registers")
// #pragma GCC optimize("move-loop-invariants")
// #pragma GCC optimize("unswitch-loops")
// #pragma GCC optimize("function-sections")
// #pragma GCC optimize("data-sections")

mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

const int MAXN = 2001;

int n;
int dp[MAXN][MAXN];
vector<pii> a;

int cost(int i, int j) {
    return a[i].first * abs(a[i].second - j);
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(all(a));
    reverse(all(a));
    dp[0][0] = cost(0, n - 1);
    dp[0][1] = cost(0, 0);
    for (int i = 0; i < n - 1; i++) {
        for (int j = 0; j <= i + 1; j++) {
            chkmax(dp[i + 1][j], dp[i][j] + cost(i + 1, n - i + j - 2)); // i + 1 - j справа -> pos = n - 1 - (i + 1 - j) = n - i + j - 2
            chkmax(dp[i + 1][j + 1], dp[i][j] + cost(i + 1, j));
        }
    }
    int ans = 0;
    for (int i = 0; i <= n; i++) {
        chkmax(ans, dp[n - 1][i]);
    }
    cout << ans;
}
/*

*/


Measured memory_bytes: 26244
# 素数と個数を求める
def factorize(n):
    res = []
    for i in range(2,n):
        if i*i > n: break
        if n%i: continue
        res += [[i,0]]
        while n%i == 0:
            n //= i
            res[-1][1] += 1
    if n != 1: res += [[n,1]]
    return res

n = int(input())
P = factorize(n)
ans = 0
for p, c in P:
    for i in range(1, c+1):
        pi = p**i
        if n%pi: continue
        n //= pi
        ans += 1
print(ans)


Measured memory_bytes: 9216
# AOJ 0139 Snakes
# Python3 2018.6.19 bal4u

import re

pa = ">'(=+)#(=+)~$"	# A >'======#======~
pb = ">\^(Q=)+~~$"		# B >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~

for i in range(int(input())):
	s = input()
	r = re.match(pa, s)

	if r and r.group(1) == r.group(2): print('A')
	elif re.match(pb, s): print('B')
	else: print('NA')


Measured memory_bytes: 6568
import sys
sys.setrecursionlimit(1000000000)

N = int(input())
u_v_w = [list(map(int, input().split())) for i in range(N-1)]

w = [u_v_w[i][2] for i in range(N-1)]

tree = [[] for i in range(N)]

for i in range(N-1):
    u = u_v_w[i][0]
    v = u_v_w[i][1]
    tree[u-1].append((v,w[i]))
    tree[v-1].append((u,w[i]))

ans = [0] * N
ans[0] = 1
def dfs(now):
    global ans
    for next in tree[now-1]:
        if ans[next[0]-1]:
            continue
        if next[1] % 2 == 0:
            ans[next[0]-1] = ans[now-1]
        else:
            ans[next[0]-1] = ans[now-1] * (-1)
        dfs(next[0])

dfs(1)
for i in range(len(ans)):
    if ans[i] == 1:
        print(0)
    else:
        print(1)



Measured memory_bytes: 165976
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+100;
const ll mod = 1e9+7;
ll q[maxn],h[maxn];
int main() {
    ll n,k,sum=0;
    cin>>n>>k;
    for(int i=1;i<=n+1;i++)
        q[i]=(q[i-1]+(i-1));
    for(int i=1;i<=n+1;i++)
        h[i]=(h[i-1]+(n+1-i));
    for(int i=k;i<=n+1;i++)
        sum+=(h[i]-q[i]+1)%mod;

    cout<<sum%mod<<endl;
}


Measured memory_bytes: 6716
import numpy as np

n, m, c = map(int, input().split())
array = np.array(list(map(int,input().split())))
nm = []
for _ in range(n):
    _ = list(map(int,input().split()))
    nm.append(_)

count = 0
for _ in nm:
    if np.inner(array, _)+c>0:
        count += 1
print(count)

Measured memory_bytes: 27124
import sys
def input(): return sys.stdin.readline().strip()


def main():
    N, K = map(int, input().split())
    D = set([i for i in range(1, N + 1)])
    for _ in range(K):
        _ = int(input())
        A = list(map(int, input().split()))
        for a in A:
            D.discard(a)
    print(len(D))
    


if __name__ == "__main__":
    main()


Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll read() {
    ll x=0,f=1; char ch=getchar();
    for(;ch<'0'||ch>'9';ch=getchar())
        if(ch=='-')f=-f;
    for(;ch>='0'&&ch<='9';ch=getchar())
        x=x*10+ch-'0';
    return x*f;
}
inline void chkmin( int &a,int b ) { if(a>b) a=b; }
inline void chkmax( int &a,int b ) { if(a<b) a=b; }
#define _ read()
int main() {
	int a=_,b=_;
	cout<<max(a*2-1,max(b*2-1,a+b));
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;

template<typename T> bool is_prime(T n)
{
	if (n == 2)
	{
		return true;
	}
	else if ((n == 1) || (n % 2 == 0))
	{
		return false;
	}

	for (T i = 3; i * i <= n; i += 2)
	{
		if (n % i == 0)
		{
			return false;
		}
	}

	return true;
}

int main()
{
	ll x;
	cin >> x;

	ll res = 0;
	for (ll i = x; ; i++)
	{
		if (is_prime(i))
		{
			res = i;
			break;
		}
	}

	println(res);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int n, m;
    cin >> n >> m;
    auto v = make_v(n, m, 0);
    for(auto &&i : v) for(auto &&j : i) scanf("%d", &j), j--;
    int ans = INF<int>;
    vector<int> deleted(m, 0);
    for (int i = 0; i < m; ++i) {
        vector<int> cnt(m);
        for (int j = 0; j < n; ++j) {
            for (int k = 0; k < m; ++k) {
                if(!deleted[v[j][k]]) {
                    cnt[v[j][k]]++;
                    break;
                }
            }
        }
        chmin(ans, *max_element(cnt.begin(), cnt.end()));
        deleted[max_element(cnt.begin(), cnt.end()) - cnt.begin()] = 1;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 640
S = input()
s = {S[0], S[1], S[2], S[3]}

if len(s) != 2:
    print('No')
else:
    num = 1
    for i in range(3):
        if S[i+1] == S[0]:
            num += 1
    
    if num == 2:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 38256
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <vector>

int main() {
	int x = 0;
	int n = 0;
	std::cin >> x >> n;
	std::vector<decltype(x)> vect(n);
	bool vect_contains_x = false;
	for (auto& elem : vect) {
		std::cin >> elem;
		if (elem == x) {
			vect_contains_x = true;
		}
	}
	int num = 0;
	if (!vect_contains_x) {
		num = x;
	}
	else {
		std::sort(vect.begin(), vect.end());
		auto isPresent = [=](auto num) {
			for (const auto& elem : vect) {
				if (num == elem) {
					return true;
				}
			}
			return false;
		};
		while (1) {
			static int i = 1;
			if (!isPresent(x - i)) {
				num = x - i;
				break;
			}
			else if (!isPresent(x + i)) {
				num = x + i;
				break;
			}
			else {
				i += 1;
			}
		}
	}
	std::cout << num << "\n";
	return 0;
}

Measured memory_bytes: 3152
#include <stdio.h>

int main(void){
  int i;

  int n;
  scanf("%d", &n);

  int sum=0, ans=0;
  long h[n];
  for(i=0; i<n; i++){
    scanf("%ld", &h[i]);
    if(i>=1){
      if(h[i] <= h[i-1]){
        sum++;
      }else{
        if(sum > ans){
          ans=sum;
        }
        sum=0;
      }
      if(i == n-1 && sum > ans){
        ans=sum;
      }
    }
  }

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

  return 0;
}


Measured memory_bytes: 896
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = null;
		try{
			scan = new Scanner(System.in);
			while(true){
				int h,w;
				h = scan.nextInt();
				w = scan.nextInt();
				if(h == 0 && w == 0)break;
				for(int i = 1 ;i <= h;i++){
					boolean bool = i%2 == 1?true:false;
					for(int j = 1 ; j <= w;j++){
						if(bool){
							System.out.print("#");
							bool = false;
						}else{
							System.out.print(".");
							bool = true;
						}
					}
					System.out.println();
				}
				System.out.println();
			}
		}finally{
			if(scan != null)scan.close();
		}
	}
}

Measured memory_bytes: 27124
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

Int n, k;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> k;
	Int sl = 0, sr = 0;
	for(Int i=0; i<2*n; ++i)
		sl += k+i;
	for(Int i=2*n; i<3*n; ++i)
		sr += k+i;
	if(sl > sr){
		cout << -1 << "\n";
		return 0;
	}
	vector<Int> a(n), b(n), c(n);
	for(Int i=0; i<n; ++i)
		c[i] = k+3*n-1-i;
	Int cnt = 0;
	for(Int i=0; i<n; i+=2){
		b[i] = k+2*n-1-cnt;
		++cnt;
	}
	for(Int i=1; i<n; i+=2){
		b[i] = k+2*n-1-cnt;
		++cnt;
	}
	cnt = 0;
	for(Int i=1; i<n; i+=2){
		a[i] = k+n-1-cnt;
		++cnt;
	}
	for(Int i=0; i<n; i+=2){
		a[i] = k+n-1-cnt;
		++cnt;
	}
	for(Int i=0; i<n; ++i)
		cout << a[i] << " " << b[i] << " " << c[i] << "\n";
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
int N;
ll L,Q;
int nex[17][100010];
int check(int u, int x){
    rep(k,0,17){
        if(u>>k&1){
            x=nex[k][x];
        }
    }
    return x;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    vector<ll> x(N,0);
    rep(i,0,N) cin>>x[i];
    cin>>L>>Q;
    rep(i,0,N){
        nex[0][i]=ub(x,x[i]+L)-1-x.begin();
    }
    rep(k,0,16){
        rep(v,0,N){
            if(nex[k][v]==N-1) nex[k+1][v]=N-1;
            else nex[k+1][v]=nex[k][nex[k][v]];
        }
    }
    rep(w,0,Q){
        int a,b;
        cin>>a>>b;
        a--; b--;
        if(a>b) swap(a,b);
        int ok=N-1, ng=0;
        while(ok-ng>1){
            int mid=(ok+ng)/2;
            if(check(mid, a)>=b) ok=mid;
            else ng=mid;
        }
        cout <<ok<<"\n";
    }
}

Measured memory_bytes: 8320
#include <iostream>

int main(){
	using namespace std;
	while(1){
	int month,day,year = 2004,mod;
	cin >> month >> day;
	if (month==0) break;
	else if (month<=2) {
		month += 12;
		year -= 1;
	}
	int k = year % 100;
	int j = year / 100;
	mod = (day+(((month+1)*26)/10)+k+(k/4)+(j/4)+5*j)%7;
	if (mod == 0) cout << "Saturday" << endl;
	else if (mod == 1) cout << "Sunday" << endl;
	else if (mod == 2) cout << "Monday" << endl;
	else if (mod == 3) cout << "Tuesday" << endl;
	else if (mod == 4) cout << "Wednesday" << endl;
	else if (mod == 5) cout << "Thursday" << endl;
	else if (mod == 6) cout << "Friday" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
diff = [a - b for a, b in zip(A, B)]
diff.sort()
k = 0
for d in diff:
  if d < 0:
    if d % 2 == 0:
      k += -d // 2
    else:
      k += -(d+1) // 2
  elif d == 0:
    continue
  else:
    k -= d

print(['Yes', 'No'][k<0])

Measured memory_bytes: 4596
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    vint l(n);
    REP(i,n) cin >> l[i];
    sort(rALL(l));
    int ans = 0;
    REP(i,k) ans+=l[i];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言

void solve();

string s[3];

int main() {
  rep(i, 3) cin >> s[i];

  solve();

  return 0;
}

void solve() {
  string S;
         S += s[0][0];
         S += s[1][0];
         S += s[2][0];

  cout << S << endl;

  return;
}


Measured memory_bytes: 256
fn main() {
    let _ = read::<usize>();
    let v = read_vec::<i32>();

    let mut i = 0;
    let mut mi = i32::max_value();
    loop {
        let mut sum = 0;
        for x in v.iter() {
            sum += (x - i) * (x - i);
        }
        if sum < mi {
            mi = sum;
        } else {
            break;
        }
        i += 1;
    }

    println!("{}", mi);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;
#define INF 999999999
#define lint long long
#define rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define rep0(i, n) for(int i = 0; i < (int)(n); i++)
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    lint N, D, P[11][11];
    cin >> N >> D;
    rep(i, N){
        rep(j, D){
            cin >> P[i][j];
        }
    }
    int ans=0;
    for (int i=1; i<=N; ++i){
        for(int j=i+1; j<=N; ++j){
            double dist=0;
            for (int k=1; k<=D; ++k){
                dist += pow(P[i][k]-P[j][k], 2);
            }
            dist = sqrt(dist);
            if (ceil(dist) == floor(dist)){
                ++ans;
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
    int n,y,i,b,t,maxb;
    double sum,r,max;
    for(;max=0,scanf("%d",&n),n;){
        scanf("%d",&y);
        for(i=0;i<n;i++){
            scanf("%d %lf %d",&b,&r,&t);
            switch(t){
                case 1:
                    sum=(1+y*r/100);break;
                case 2:
                    sum=pow((double)(1+r/100),y);break;
            }
            if(max<sum){
                max=sum;
                maxb=b;
            }
        }
        printf("%d\n",maxb);
    }
    return 0;
}

Measured memory_bytes: 720
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define isNum(a) (a>='0'&&a<='9')
#define SP putchar(' ')
#define EL putchar('\n')
#define inf 2147483647
#define File(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout)
template<class T>inline void read(T&);
template<class T>inline void write(const T&);
int main () {
    int n, k;
    read(n), read(k);
    puts(k<=((n+1)>>1)?"YES":"NO");
    return 0;
}
template<class T>void read(T &Re) {
    T k=0;
    char ch=getchar();
    int flag=1;
    while (!isNum(ch)) {
        if (ch=='-') {
            flag=-1;
        }
        ch=getchar();
    }
    while (isNum(ch)) {
        k=(k<<1)+(k<<3)+ch-'0';
        ch=getchar();
    }
    Re=flag*k;
}
template<class T>void write(const T& Wr) {
    if (Wr<0) {
        putchar('-');
        write(-Wr);
    }else {
        if (Wr<10) {
            putchar(Wr+'0');
        }else {
            write(Wr/10);
            putchar((Wr%10)+'0');
        }
    }
}


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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

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

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr ll mod = 1000000007;

int main() {
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<pair<ll, char>> apple;
    apple.reserve(A + B + C);
    rep(i, A) {
        ll num;
        cin >> num;
        apple.emplace_back(num, 'r');
    }
    rep(i, B) {
        ll num;
        cin >> num;
        apple.emplace_back(num, 'g');
    }
    rep(i, C) {
        ll num;
        cin >> num;
        apple.emplace_back(num, 'l');
    }

    sort(all(apple), greater<pair<ll, char>>());

    ll cnt_r = 0;
    ll cnt_g = 0;
    ll cnt_l = 0;
    ll ans = 0;
    for (auto e : apple) {
        if (e.second == 'l') {
            ans += e.first;
            ++cnt_l;
        } else if (e.second == 'r') {
            if (cnt_r >= X) continue;
            ans += e.first;
            ++cnt_r;
        } else if (e.second == 'g') {
            if (cnt_g >= Y) continue;
            ans += e.first;
            ++cnt_g;
        }

        if (cnt_r + cnt_g + cnt_l == X + Y) {
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 7940
#include <stdio.h>

int main(void) {
  int a,num;
  a = 0;
  num = 0;
  while(1){
    char buf[128];
    fgets(buf, 128, stdin);
    sscanf(buf, "%d", &a);
    num = a + a*a + a*a*a;
    printf("%d\n",num);
    break;
  }
}


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

int main() {
  ll h;
  cin >> h;
  
  ll atk = 1;
  ll ans = 0;
  while (h > 0) {
    ans += atk;
    h /= 2;
    atk *= 2;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long res = n / 500 * 1000;
        n %= 500;
        res += n / 5 * 5;
        System.out.println(res);
    }
}


Measured memory_bytes: 21844
import java.util.Scanner;

//AtCoder Beginner Contest 127
//A	Ferris Wheel
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();

		sc.close();

		int ans = 0;
		if (A >= 13) {
			ans = B;
		} else if (A <= 5) {
			ans = 0;
		} else {
			ans = B / 2;
		}

		System.out.print(ans);
	}
}


Measured memory_bytes: 22740
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<(ll)n;i++)
#define repf(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define repr(i,a,b) for(ll i=(ll)a-1;i>=(ll)b;i--)
#define Fi first
#define Se second
typedef pair<ll, ll> pll;
const ll MAX = 1005;
const char END = '\n';

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll N, M, Ans = 0;
	string S;
	cin >> S;

	if (S[0] == 'S')
		cout << "Cloudy" << END;
	else if (S[0] == 'C')
		cout << "Rainy" << END;
	else
		cout << "Sunny" << END;

	//cout << Ans << END;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include <string>
#include <cmath>
#include<queue>
#define PI 3.141592653589793238
#define ll long long
using namespace std;

int main()
{
	int k, x;

	cin >> k >> x;

	if (500 * k >= x) {
		printf("Yes");
	} else {
		printf("No");
	}

	return 0;
}

Measured memory_bytes: 256
def euclid(a, b):
    if a < b:
        a, b = b, a
    while True:
        r = a % b
        if r == 0:
            return b
        a, b = b, r


n = int(input())
a = [int(x) for x in input().split()]
l_gcd, r_gcd = [a[0]], [a[n-1]]
for i in range(1, n-1):
    l_gcd.append(euclid(l_gcd[i-1], a[i]))
    r_gcd.append(euclid(r_gcd[i-1], a[n-1-i]))

ans = max(l_gcd[n-2], r_gcd[n-2])
for i in range(1, n-1):
    ans = max(ans, euclid(l_gcd[i-1], r_gcd[n-i-2]))
print(ans)

Measured memory_bytes: 14400
N, A = map(int, input().split())
X = list(map(int, input().split()))
sum_X = sum(X)
dp = [[[0]*(sum_X+1) for _ in range(N+1)] for _ in range(N+1)]
dp[0][0][0] = 1
for i in range(N):
  for j in range(N):
    for k in range(sum_X):
      if dp[i][j][k] == 0: continue
      # not used
      dp[i+1][j][k] += dp[i][j][k]
      # used
      dp[i+1][j+1][k+X[i]] += dp[i][j][k]
ans = 0
for k in range(1, N+1):
  if k*A <= sum_X:
    ans += dp[N][k][k*A]
print(ans)  

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


    using namespace std;
    typedef long long ll;
    # define M_PI  3.14159265358979323846
    const int MOD=1e9+7;

    void solve(){
        string s;
        cin>>s;
        int n=s.size();
        for(int i=0;i<n;i++){
            if(s[i]=='?' && ((i+1<n && s[i+1]=='P') || (i-1>=0 && s[i-1]=='P'))){
//                cout<<"in";
                s[i]='D';
            }
            else if(s[i]=='?' && i+1<n && s[i+1]=='?'){
                s[i]='P';
                s[i+1]='D';
            }
            else if(s[i]=='?' && i+1<n && s[i+1]=='D')
                s[i]='P';
            else if(s[i]=='?')
                s[i]='D';
//            cout<<s<<"\n";
        }
        cout<<s;
    }

    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }


Measured memory_bytes: 3740
#include <stdio.h>
 
int main(void){
    int n;
    int a,b;
    int aSum, bSum;
    
    while (scanf("%d", &n), n!=0){
        aSum = bSum=0;
        for (int i=0; i<n; i++){
            scanf("%d %d", &a, &b);
            if (a>b) aSum += (a+b);
            else if (a<b) bSum += (a+b);
            else aSum += a, bSum += b;
        }
        printf("%d %d\n", aSum, bSum);
    }
    
    return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <utility>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto&e:c)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif

int main(){
    int n; cin>>n;
    rep(_,n){
        ll x[2][2], y[2][2];
        rep(i,2){
            rep(j,2){
                double x_,y_;
                cin >> x_ >> y_;
                x[i][j] = x_ *1000000;
                y[i][j] = y_ *1000000;
            }
        }
        ll dx1=x[0][0]-x[0][1], dy1=y[0][0]-y[0][1];
        ll dx2=x[1][0]-x[1][1], dy2=y[1][0]-y[1][1];
        dump(dx1,dx2,dy1,dy2);
        puts(dx1*dy2==dx2*dy1 ? "YES" : "NO");
    }
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF INT_MAX
std::vector<int> nums(5, 0);

int main(){
    for (int i = 0; i < 5; ++i){
        cin >> nums[i];
    }
    int temp_min = INF;
    for (int min_idx = 0; min_idx < 5; ++min_idx){
        int sum = 0;
        for (int i = 0; i < 5; ++i){
            if (i == min_idx){
                sum += nums[i];
            }else{
                if (nums[i] % 10 == 0){
                    sum += nums[i];
                }else{
                    sum += 10 * ((nums[i] / 10) + 1);
                }   
            }
        }
        temp_min = min(temp_min, sum);
    }
    cout << temp_min << endl;
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> fib(n + 1);
  fib.at(0) = 1;
  fib.at(1) = 1;
  for (int i = 0; i < n - 1; ++i)
  {
    fib.at(i + 2) = fib.at(i + 1) + fib.at(i);
  }
  cout << fib.at(n) << endl;
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,r=0;
    cin>>n;
    for(ll i=1;i<=n;i++){
        if(!(i%3==0||i%5==0)) r+=i;
    }
    cout<<r<<'\n';
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int a[100005],b[100005];
inline int read()
{int x=0;
char c=getchar();
while (c<'0'||c>'9') c=getchar();
while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
return x;
}
int main (){
	ll res=0;
	int n,k,i,j,l;
	n=read();k=read();k++;
	for (i=1;i<=n;i++)
	{a[i]=read();
	b[i]=read();
	}
	for (j=30;j>=0;j--)
	{if ((1<<j)&k)
	{int mask=(1<<j);
	for (l=30;l>j;l--)
	{if (!(k&(1<<l)))
	{mask|=(1<<l);}
	}
	ll ans=0;
	for (i=1;i<=n;i++)
	{if (a[i]&mask) {continue;}
	ans+=b[i];
	}
	if (ans>res) res=ans;
	}
	}
	printf ("%lld\n",res);
	return 0;
}
	
	
	

Measured memory_bytes: 1148
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, k, n) for (int i = (k); i < (n); i++)
#define rrep(i, k, n) for (int i = (k); i >= (n); i++)
#define pb push_back
#define vec vector
#define ref(a) &(a)

typedef long long ll;

using namespace std;

int a, b;

int solve() {
  return a ^ b;
}

int main() {
  cin >> a >> b;
  cout << solve() << endl;
  return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define Lson L, mid, rt<<1
#define Rson mid+1, R, rt<<1|1
const int maxn=1e5+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
int n,m,k,t,h[maxn],tot,ans[maxn];
set<int>comp[maxn];
struct node
{
    int to,nxt,com;
}e[maxn<<2];
void add(int x,int y,int z)
{
    tot++;
    e[tot].to=y;
    e[tot].com=z;
    e[tot].nxt=h[x];
    h[x]=tot;
}
priority_queue<pair<int,int> >p;
int main()
{
    int i,j;
    memset(ans,inf,sizeof ans);
    scanf("%d%d",&n,&m);
    while(m--)
    {
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        add(a,b,c);
        add(b,a,c);
    }
    p.push({0,1});ans[1]=0;
    while(!p.empty())
    {
        int now=p.top().se,ca=-p.top().fi;
        p.pop();
        if(ans[now]<ca)continue;
        for(i=h[now];i;i=e[i].nxt)
        {
            int to=e[i].to,to_com=e[i].com;
            int to_ca=ca+(!comp[now].count(to_com));
            if(ans[to]>to_ca)
            {
                ans[to]=to_ca;
                p.push({-to_ca,to});
                comp[to].clear();
                comp[to].insert(to_com);
            }
            else if(ans[to]==to_ca)
            {
                comp[to].insert(to_com);
            }
        }
    }
    printf("%d\n",ans[n]==inf?-1:ans[n]);
    return 0;
}

Measured memory_bytes: 20216
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;

const int MAX_A = 300005;

int op(int a, int b) { return max(a, b); }
int e() { return 0; }

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	
	segtree<int, op, e> dp(MAX_A);
	
	rep(i, n) {
		int x = a[i];
		int l = x - k, r = x + k + 1;
		l = max(l, 0);
		r = min(r, MAX_A);
		int now = dp.prod(l, r) + 1;
		dp.set(x, now);
	}
	
	int ans = dp.prod(0, MAX_A);
	cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 9616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll dp[3005][3005];

int main() {
    init();
    ll N;
    string S;
    cin >> N >> S;
    
    
    rep(i, N) dp[0][i] = 1;
    vl acc(N + 1);

    rep(i, N - 1){
        ll r = N - i; //jの右端

        rep(j, r)(acc[j + 1] = acc[j] + dp[i][j]) %= MOD;

        if(S[i]=='<'){
            rep(j, r){
                (dp[i + 1][j] += acc[j + 1]) %= MOD;
            }
        }
        else{
            rep(j, r){
                (dp[i + 1][j] += acc[r] - acc[j + 1] + MOD) %= MOD;
            }
        }
    }

    cout << dp[N - 1][0] << endl;
}

Measured memory_bytes: 49868