akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
string op(string x) {
    if (x == "Sunny") {
        return ("Cloudy");
    }
    if (x == "Cloudy") {
        return ("Rainy");
    }
    if (x == "Rainy") {
        return ("Sunny");
    }
    return 0;
}

int main() {
    long long a, b, c;
    cin >> a >> b;
    if ((a + b) % 2 == 0) {
        cout << (a + b) / 2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple

ll M = 998244353;


int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	
	ll h,a; cin>>h>>a;
	ll ans=h/a;
	if(h%a!=0) ans++;
	cout<<ans;
	
	
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define setp(x) setprecision(x)
using namespace std;
using ull = unsigned long long;
using ll = long long;


int f(int x){
    if(x%2 == 0) return x/2;
    else return 3*x+1;
}

int main(){
    int s; cin>>s;
    map<int,bool> M; M[s]=true;
    int c = 1;
    while(1){
        c++;
        s = f(s);
        if(M.find(s) == M.end()) M[s]=true;
        else break;
    }
    cout<<c<<endl;
}

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


int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   // freopen("input.txt","r",stdin);
    string w;
    cin >> w;
    map<char,int> a;
    for(int i =0;i<w.size();i++){
        a[w[i]]++;
    }
    bool poss = true;
    for(auto x:a){
        if(x.second%2 != 0){
            poss = false;
        }
    }
    if(poss){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }

}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  double n;
  cin >> n;
  int odd = (n + 1) / 2;
  cout << fixed << setprecision(10) << odd / n << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define p push
#define p1 pop
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair<ll,ll>
#define e 1000000007
using namespace std;
ll dp[100002],arr[100002];
ll solve(ll n)
{
    dp[1]=0;
    dp[2]=abs(arr[2]-arr[1]);
    //sum+=dp[]
    for(int i=3;i<=n;++i)
        dp[i]=min(abs(arr[i]-arr[i-2])+dp[i-2],abs(arr[i]-arr[i-1])+dp[i-1]);
    return dp[n];
}
int main()
{
   // memset(dp,0,sizeof(dp));
    ll n;cin>>n;
    for(int i=1;i<=n;++i)
        cin>>arr[i];
    cout<<solve(n);
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
ll mod = 1000000007;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll T;
    T=1;
    start:
    while(T--)
    {
        ll n;
        cin>>n;
        double a[n];
        for(ll i=0;i<n;++i)
        {
            cin>>a[i];
        }
        double dp[n][n+1];
        dp[0][0]=1-a[0];
        dp[0][1]=a[0];
        for(ll i=2;i<=n;i++)
        {
            dp[0][i]=0;
        }
        double p = 1;
        for(ll i=0;i<n;i++)
        {
            p = p*(1-a[i]);
            dp[i][0] = p;
        }
        for(ll i=1;i<n;i++)
        {
            for(ll j=1;j<=n;j++)
            {
                dp[i][j] = (a[i]*dp[i-1][j-1])+((1-a[i])*dp[i-1][j]);
            }
        }
        /*for(ll i=0;i<n;i++)
        {
            for(ll j=0;j<=n;j++)
            {
                cout<<dp[i][j]<<" ";
            }
            cout<<endl;
        }*/
        double ans = 0;
        for(ll i=(n+1)/2;i<=n;i++)
        {
            ans+=dp[n-1][i];
        }
        cout<<setprecision(10)<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 70528
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

//++時計回り --反時計回り
// int dx[4] = {1, 0, -1, 0};
// int dy[4] = {0, 1, 0, -1};

int main() {
  int N, D;
  cin >> N >> D;
  int X[N][D];
  REP(i, N) REP(j, D) cin >> X[i][j];
  int count = 0;
  REP(i, N) {
    for (int j = i + 1; j < N; j++) {
      int dist = 0;
      REP(k, D) { dist += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]); }
      REP(i, 1000) {
        if (dist == i * i)
          count++;
      }
    }
  }
  cout << count << '\n';
}


Measured memory_bytes: 256
n=int(input())
if n<105:
	print(0)
elif 105<=n<135:
	print(1)
elif 135<=n<165:
	print(2)
elif 165<=n<189:
	print(3)
elif 189<=n<195:
	print(4)
elif 195<=n:
	print(5)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define numa(x,a) for(auto x: a)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define pf push_front
#define sec second
#define sz(x) ((int)(x).size())
#define ALL( c ) (c).begin(), (c).end()
#define gcd(a,b) __gcd(a,b)
#define mem(x,n) memset(x,n,sizeof(x))
#define endl "\n"
using namespace std;
template <int POS, class TUPLE> void deploy(std::ostream &os, const TUPLE &tuple){}
template <int POS, class TUPLE, class H, class ...Ts> void deploy(std::ostream &os, const TUPLE &t){ os << (POS == 0 ? "" : ", ") << get<POS>(t); deploy<POS + 1, TUPLE, Ts...>(os, t); }
template <class T,class U> std::ostream& operator<<(std::ostream &os, std::pair<T,U> &p){ os << "(" << p.first <<", " << p.second <<")";return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::vector<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::set<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T, class K> std::ostream& operator<<(std::ostream &os, std::map<T, K> &mp){ int remain = mp.size(); os << "{"; for(auto e: mp) os << "(" << e.first << " -> " << e.second << ")" << (--remain == 0 ? "}" : ", "); return os; }
#define DEBUG1(var0) { std::cerr << (#var0) << "=" << (var0) << endl; }
#define DEBUG2(var0, var1) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG1(var1); }
#define DEBUG3(var0, var1, var2) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG2(var1,var2); }
#define DEBUG4(var0, var1, var2, var3) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG3(var1,var2,var3); }
using ll = long long;



int main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  cout << max(A*B, C * D) << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
#include<math.h>
#include<list>
#include<map>
using namespace std;
typedef long long ll;
#define PI 3.14159265358979323846  
typedef pair<int, int> P;

int main() {
	vector<P> p;
	vector<int> v;
	int n, m,a,b,ans=0;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		p.push_back(P(a, b));
	}
	for (int i = 2; i <= n; i++) {
		v.push_back(i);
	}
	do {
		int now = 1;
		bool flag = true;
		for (int i = 0; i < n - 1&&flag; i++) {
			flag = false;
			for (int j = 0; j < m; j++) {
				if ((p.at(j).first == now && p.at(j).second == v.at(i))|| (p.at(j).first == v.at(i) && p.at(j).second == now)) {
					flag = true;
				}
			}
			/*if (!flag) {
				cout << now << v.at(i) << endl;
			}*/
			now = v.at(i);
		}
		if (flag) {
			ans++;
		}
	} while (std::next_permutation(v.begin(), v.end()));
	cout << ans << endl;
}


Measured memory_bytes: 256
// 失敗するからこそ そこから立ち向かって行く強さがあって そんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/pavan/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

ll dfs(ll n){
	if(n == 1)return 1;
	else return 1 + 2*dfs(n/2);
}
int main(){
	FIO
	
	ll n;cin >> n;
	cout << dfs(n);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
    int n;
    string str;
    cin >> n;
    cin >> str;
    for(int i=0; i<(int)(str.length()); i++){
        str[i] = (char)((str[i]+n-'A') % ('Z'-'A'+1)+'A');
    }
    cout << str << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
using ll = long long;
int MOD = 1e9 + 7;
using namespace std;
int main()
{
    int h,w;
    cin >> h >> w;
    vector<pair<int,int>> reg;
    vector<vector<char>> vec(h+2,vector<char>(w+2));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> vec[i+1][j+1];
            if(vec[i+1][j+1]=='#'){
                reg.push_back(make_pair(i+1,j+1));
            }
        }
    }
    for(int i=0;i<reg.size();i++){
        int y=reg[i].first;
        int x=reg[i].second;
        bool h=true;
        if(vec[y-1][x]=='#')h=false;
        if(vec[y+1][x]=='#')h=false;
        if(vec[y][x+1]=='#')h=false;
        if(vec[y][x-1]=='#')h=false;
        if(h){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


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

using namespace std;
using ll=long long;

int main()
{
   int r,g,b,n;
   cin >>r>>g >>b >> n;
   int ans=0;
   for(int i=0;i<=3000;i++){
    for(int j=0;j<=3000;j++){
        if((n-r*i-g*j)<0)continue;
        if((n-r*i-g*j)%b==0)ans++;
    }
   }
   cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define lint long long

using namespace std;

int main()
{
  int n;
  cin >> n;
  bool flag = true;

  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    if(a%2==0){
      if(a%3!=0&&a%5!=0){
        flag = false;
        break;
      }
    }
  }

  if(flag){
    cout << "APPROVED" << endl;
  }else{
    cout << "DENIED" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

bool solve(string s){
    int n = s.size();
    if(s[0] != 'A') return false;

    int ct = 0;
    for(int i=2; i<n-1; ++i)if(s[i] == 'C') ++ct;
    if(ct != 1) return false;

    rep(i,n)if(s[i]!='A' && s[i]!='C'){
        if(isupper(s[i])) return false;
    }
    return true;
}

int main(){
    string s;
    cin >>s;
    cout << (solve(s)?"AC":"WA") << endl;
    return 0;
}


Measured memory_bytes: 384
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ x, y ] <- map ( read :: String -> Integer ) . words <$> getLine
	print $ solve x y

solve x y
	| x <= y = 1 + solve ( x * 2 ) y
	| otherwise = 0


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

int main(){
    ll i,j;
    ll a,b;
    cin>>a>>b;
    ll m=max(a-b,a+b);
    m=max(a*b,m);
    cout<<m<<endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

N = int(sys.stdin.readline())
IN = sys.stdin.readline().split(' ')

D = int(IN[0])
X = int(IN[1])

X2 = N

for i in range(N):
	A = int(sys.stdin.readline())
	X2 += int((D - 1) / A)

print(str(X2 + X))


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <stdio.h>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cfloat>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <iomanip>

using namespace std;

#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
// #define req(j, n) for (ll j = 1; j < (n+1); j++)
// #define rer(k, n) for (ll k = 1; k < (n+1); k++)


int main()
{
    char N;
    cin >> N;
    if (isupper(N)) {
        cout << "A" << endl;
    } else
    {
        cout << "a" << endl;
    }
    
}


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

using ll = long long;
#define ALL(obj) (obj).begin(), (obj).end()
#define rep(i,n) for(int i=0; i<n; i++)

#define pb push_back
//const int INF = 100100100;

#define INF 100100100;

const int MOD = (int) 1e9 + 7;
const double EPS = 1e-9;

int main()
{
  int N;
  cin >> N;
  vector<int> a;
  
  int in = INF;
  int ax = -INF;
    int tmp;
  rep(i,N) {
    cin >> tmp;
    in = min(in, tmp);
    ax = max(ax, tmp);
    
    //a.pb(tmp);
  }
  cout << ax - in << endl;
}

Measured memory_bytes: 256
import math
S = int(input())
s = S//3
count = 0
goukei = 0
if S == 1 or S == 2 :
  print('0')
else:
  for i in range(1, s+1):
    count = math.factorial((S - 3*i) + i-1)//math.factorial(S - 3*i)//math.factorial(i-1)
    goukei = goukei + count

  goukei = goukei % (10**9 + 7)
  print(goukei)

Measured memory_bytes: 73640
def solve():
    A, B, C, D = input()
    op = '+-'
    
    for op1 in op:
        for op2 in op:
            for op3 in op:
                left_hand = A + op1 + B + op2 + C + op3 + D
                if eval(left_hand) == 7:
                    return left_hand + '=7'

print(solve())

Measured memory_bytes: 2940
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.stdio;
import std.string;
import std.range;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    string s;
    while ((s = readln.chomp).length > 0) {
        if (s == "0")
            break;

        int sum = s.map!(e => e - '0').sum;
        writeln(sum);
    }
}

Measured memory_bytes: 2460
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  int k; cin >> k;
  map<char,int> mp;
  cin >> mp['s'] >> mp['p'] >> mp['r'];
  string s; cin >> s;
  int ans = 0;
  for(int i = 0; i < n; ++i){
    if(i < k){
      ans += mp[s[i]];
    } else {
      if(s[i] == s[i-k]){
        s[i] = 'a';
      } else {
        ans += mp[s[i]];
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
#define rint register int
#define rep(i,a,b) for (rint i=(a),_E=(b); i<=_E; ++i)
#define per(i,a,b) for (rint i=(a),_E=(b); i>=_E; --i)
#define REP(i,n) for (rint i=(0),_E=(n); i<_E; ++i)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

const int N = 105;
const char t[11] = "AKIHABARA#";
char s[N];
int n, cur;

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	cur = 0;
	rep (i, 1, n)
		if (s[i] == t[cur]) ++ cur;
		else if (t[cur] == 'A') ++ cur, -- i;
		else return puts("NO"), 0;
	if (cur == 8 || cur == 9) puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace ABC174
{
    class Program
    {
        static void Main(string[] args)
        {
            //var NK = Console.ReadLine().Split().Select(long.Parse).ToArray();
            //var p = Console.ReadLine().Split().Select(long.Parse).OrderBy(x => x).ToArray();
            // var CA = Enumerable.Repeat(0, (int)N).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
            var K = long.Parse(Console.ReadLine());
            var x = 7L;
            for (long i = 0; i <= 1000000; i++)
            {
                if (x % K == 0) { Console.WriteLine(i + 1); return; }
                x = (10 * x + 7) % K;
            }
            Console.WriteLine(-1);
        }
    }
}


Measured memory_bytes: 27452
#include <vector>
#include <iostream>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	vector<int> a(N), c(N + 1), s(N + 1);
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		++c[a[i]];
		if (a[i] - c[a[i]] >= 0) {
			if (s[a[i] - c[a[i]]] == 0) {
				++ans;
			}
			++s[a[i] - c[a[i]]];
		}
	}
	for (int i = 0; i < M; ++i) {
		int x, y;
		cin >> x >> y; --x;
		if (a[x] - c[a[x]] >= 0) {
			if (s[a[x] - c[a[x]]] == 1) {
				--ans;
			}
			--s[a[x] - c[a[x]]];
		}
		--c[a[x]];
		a[x] = y;
		++c[a[x]];
		if (a[x] - c[a[x]] >= 0) {
			if (s[a[x] - c[a[x]]] == 0) {
				++ans;
			}
			++s[a[x] - c[a[x]]];
		}
		cout << N - ans << '\n';
	}
	return 0;
}

Measured memory_bytes: 3840
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long


struct Edge{
	int src;
	int dst;
	int cost;
	Edge(int src = -1, int dst = -1, int cost = 1)
	: src(src), dst(dst),cost(cost){};
	bool operator<(const Edge &e) const {
		return this -> cost < e.cost;
	}
	bool operator>(const Edge &e) const{
		return this -> cost > e.cost;
	}
};
using Graph = vector<vector<Edge>>;

void solve(){
	int n;
	cin >> n;
	Graph graph(n);
	for(int i = 0 ; i < n - 1; i++){
		int u,v;
		cin >> u >> v;
		u--;v--;
		graph[u].emplace_back(u,v);
		graph[v].emplace_back(v,u);
	}

	vector<int> par(n,-1);
	vector<int> paths(n,0);
	queue<int> que;
	que.push(n-1);
	par[n-1] = n-1;
	while(!que.empty()){
		int v = que.front();
		que.pop();

		for(auto e : graph[v]){
			int u = e.dst;
			if(par[u] >= 0){
				continue;
			}
			par[u] = v;
			paths[u] = (paths[v] | (1LL << u));
			que.push(u);
		}
	}
	int m;
	cin >> m;

	vector<int> ss(m);
	for(auto &s : ss){
		int u,v;
		cin >> u >> v;
		u--;v--;
		s = (paths[u] ^ paths[v]);
	}

	int ans = 0;
	for(int b = 0 ; b < (1 << m); b++){
		int sign = (__builtin_popcount(b) % 2 == 0 ? 1 : -1);

		int s = 0;
		for(int i = 0 ; i < m ; i++){
			if((b >> i) & 1){
				s |= ss[i];
			}
		}
		int free = n - 1 - __builtin_popcountll(s);
		ans += sign * (1LL << free);
	}
	cout << ans << endl;
}

signed main(){

	solve();
	return 0;
} 

Measured memory_bytes: 384
#include <iostream>
#include <vector>

int main(){
	int n;
	std::cin >> n;
	std::vector<int> co(200000,0),dp(n,0),da(n);
	int c;
	std::cin >> c;
	da[0]=c;
	dp[0]=1;
	co[c-1]=1;
	for(int i=1;i<n;i++){
		std::cin >> c;
		da[i]=c;
		dp[i]=dp[i-1];
		if(da[i]!=da[i-1]){
			dp[i]=(co[c-1]+dp[i])%1000000007;
			co[c-1]=(dp[i-1]+co[c-1])%1000000007;
		}
	}
	std::cout << dp[n-1] << std::endl;
}

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

struct bustimetable{
  int hour;
  int minute;
  int grade;
};

int partition (vector<bustimetable>& V, int p, int r)
{
  int x = V[r].grade;
  int i = p - 1;
  for (int j = p; j < r; j++){
      if (V[j].grade <= x){
	  i = i + 1;
	  //swap(V[i],V[j]);
    bustimetable tmp;
    tmp = V[i];
    V[i] = V[j];
    V[j] = tmp;
	  }
  }
  //swap(V[i+1],V[r]);
  bustimetable tmp;
  tmp = V[i+1];
  V[i+1] = V[r];
  V[r] = tmp;
  return i + 1;
}

void quicksort (vector<bustimetable>& V, int p, int r)
{
  if (p < r)
    {
      int q = partition (V, p, r);
      quicksort (V, p, q - 1);
      quicksort (V, q + 1, r);
    }
}

int main(){

    int tablesum,h,m;
    vector<bustimetable> vec;

    for(int i=0;i<2;i++){
      cin >> tablesum;
      for(int i=0;i<tablesum;i++){
        cin >> h >> m;
        bustimetable tmp;
        tmp.hour = h;
        tmp.minute = m;
        tmp.grade = h*60+m;
        vec.push_back(tmp);
      }
    }

    quicksort(vec,0,vec.size()-1);

    bustimetable lastupdate;

    if(vec[0].minute > 9){
      cout << vec[0].hour << ':' << vec[0].minute;
    }
    else{
      cout << vec[0].hour << ":0" << vec[0].minute;
    }
    lastupdate = vec[0];

    for(int i=1;i<vec.size();i++) {
      if(vec[i].grade != lastupdate.grade){
        if(vec[i].minute > 9){
          cout << ' ' << vec[i].hour << ':' << vec[i].minute;
        }
        else{
          cout << ' ' << vec[i].hour << ":0" << vec[i].minute;
        }
        lastupdate = vec[i];
      }
    }

    cout << endl;

    return 0;
}

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

using namespace std;

const int L = 1e4;
const int D = 1e2;
const int MOD = 1e9+7;

string k;
int l, d;
int total[L][2][D];

int solve(int p, bool state, int re) {
	if(p == l) {
		if(re == 0) return 1;
		return 0;
	}
	
	int &ref = total[p][state][re];
	if(ref != -1) return ref;
	
	int curr = 0, up = (state) ? (k[p]-'0') : 9;
	for(int i = 0; i < up; i++) curr = (curr + solve(p+1, false, (re+i) % d)) % MOD;
	curr = (curr + solve(p+1, state, (re+up) % d)) % MOD;
	
	ref = curr;
	return curr;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	memset(total, -1, sizeof(total));
	
	cin >> k >> d;
	l = k.length();
	cout << ((solve(0, true, 0)-1) + MOD) % MOD;
}

Measured memory_bytes: 8832
#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<ll,ll>
#define vint vector<ll>
#define pb push_back
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
ll read(){
	ll g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const ll N=2e3+5;
const ll M=2e3+5;
const ll mod=1e9+7;
struct Edge{ll x,y,w,opt;}e[M];
vector<pii>G[N];
ll f[N],st[N][15],sw[N][15],n,m,ans,mi,d,dep[N],power[M],tot,cnt;
ll get(ll x){return f[x]==x?x:f[x]=get(f[x]);}
void kruskal(){
	sort(e+1,e+m+1,[](Edge a,Edge b){return a.w<b.w;});
	for(ll i=1;i<=n;i++)f[i]=i;
	for(ll i=1;i<=m;i++){
		ll x=e[i].x,y=e[i].y,w=e[i].w;
		if(get(x)==get(y))continue;
		e[i].opt=1;f[get(x)]=get(y);mi+=e[i].w;
		G[x].pb(pii(y,w)),G[y].pb(pii(x,w));
	}
}
void dfs(ll x,ll fa){
	st[x][0]=fa;dep[x]=dep[fa]+1;
	for(ll i=1;i<=10;i++)st[x][i]=st[st[x][i-1]][i-1],sw[x][i]=max(sw[x][i-1],sw[st[x][i-1]][i-1]);
	for(auto y:G[x])if(y.first^fa)sw[y.first][0]=y.second,dfs(y.first,x);
}
ll lca(ll x,ll y){
	ll re=0;
	if(dep[x]<dep[y])swap(x,y);
	for(ll i=10;~i;i--)if(dep[st[x][i]]>=dep[y])re=max(re,sw[x][i]),x=st[x][i];
	if(x==y)return re;
	for(ll i=10;~i;i--)if(st[x][i]^st[y][i])re=max(re,max(sw[x][i],sw[y][i])),x=st[x][i],y=st[y][i];
	return max(re,max(sw[x][0],sw[y][0]));
}
void solve1(){
	ans=(ans+1ll*(power[n-1]-2)*power[m-n+1]%mod)%mod;
}
void solve2(){
	for(ll i=1;i<=m;i++)if(mi-lca(e[i].x,e[i].y)+e[i].w==d&&!e[i].opt)tot++;
	for(ll i=1;i<=m;i++)if(mi-lca(e[i].x,e[i].y)+e[i].w<=d)cnt++;
	ans=(ans+2ll*(power[tot]-1)%mod*power[m-cnt]%mod)%mod;
}
signed main(){
	n=read(),m=read(),d=read();
	power[0]=1;for(ll i=1;i<=m;i++)power[i]=(1ll*power[i-1]<<1)%mod;
	for(ll i=1;i<=m;i++)e[i]=Edge{read(),read(),read()};
	kruskal();dfs(1,0);
	if(d<mi)return cout<<0,signed();
	if(d==mi)solve1();solve2();return cout<<ans,signed();
}
/*
3 3 2 1 2 1 2 3 1 3 1 1
3 3 3 1 2 1 2 3 1 3 1 2
5 4 1 1 2 3 1 3 3 2 4 6 2 5 8
8 10 49 4 6 10 8 4 11 5 8 9 1 8 10 3 8 128773450 7 8 10 4 2 4 3 4 1 3 1 13 5 2 2
*/

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

    int ans = 0;
    rep(i, n)
    {
        rep2(j, i + 1, n)
        {
            int res = 0;
            rep(k, d)
            {
                res += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            bool flag = false;
            for (int i = 1; i * i <= res; i++)
            {
                if (i * i == res)
                {
                    flag = true;
                }
            }
            if (flag)
            {
                ans++;
            }
        }
    }

    cout << ans << '\n';
    return (0);
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	ll N;
	ll A, B;
	cin >> N >> A >> B;
	vector<ll> h(N);
	rep(i,N) cin >> h[i];
	ll l, r;
	l = 0; r = 0;
	rep(i,N) r += h[i]/B + 1;
	ll res = 0;
	while(l <= r) {
		ll m = (l+r)/2;
		ll cnt = 0;
		rep(i,N) {
			if(h[i] > B*m) {
				ll tmp = (h[i]-B*m);
				cnt += tmp/(A-B) + !!(tmp%(A-B));
			}
		}
		if(cnt <= m) {
			res = m;
			r = m-1;
		}
		else {
			l = m+1;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
	int a, b, i;
  	scanf("%d %d",&a, &b);
	if(a > b){
      for(i=0; i<a; i++){
          printf("%d",b);
      }
    }if(a <= b){
    	for(i=0; i<b; i++){
          printf("%d",a);
        }
    }
	return 0;
}

Measured memory_bytes: 128
#n回じゃんけん
#i回目とi+k回目は違うもの
n,k=map(int,input().split())
#R：グーで買ったら(相手がｓ)
#S：チョキで買ったら（相手がｐ）
#P：パーで買ったら（相手がｒ）
r,s,p=map(int,input().split())

point={}
point["r"]=p
point["p"]=s
point["s"]=r

#t：相手の手
t=input()
len_t=len(t)

tt=[[] for _ in range(k)]
for i in range(len_t):
    tt[i%k].append(t[i])

result=0
for item in tt:
    back_number=item[0]
    cnt=1
    for item2 in item[1:]:
        if item2 == back_number:
            cnt+=1
        else:
            result+=point[back_number]*((cnt*(-1))//2)*(-1)
            cnt=1
            back_number=item2
    result+=point[back_number]*((cnt*(-1))//2)*(-1)  

print(result) 


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

const int maxn=2e5+10;
int n,m,cnt,a[maxn<<1],b[maxn<<1],t[maxn<<1],xx;
char s[maxn];
vector<pair<int,int> > g[4][maxn];
int vis[maxn<<1];

inline void ae(int u,int v){
	++cnt;
	a[cnt]=u;b[cnt]=v;
	if(s[u]=='A')
		if(s[v]=='A')
			g[0][u].push_back(make_pair(v,cnt)),t[cnt]=0;
		else
			g[1][u].push_back(make_pair(v,cnt)),t[cnt]=1;
	else
		if(s[v]=='A')
			g[3][u].push_back(make_pair(v,cnt)),t[cnt]=3;
		else
			g[2][u].push_back(make_pair(v,cnt)),t[cnt]=2;
}
void dfs(int id){
	if(!vis[id])
		vis[id]=1;
	else if(vis[id]!=1)
		return;
	else{
		puts("Yes");
		exit(0);
	}
	for(int i=0,nxt=(t[id]+1)%4;i<g[nxt][b[id]].size();++i)
		dfs(g[nxt][b[id]][i].second);
	vis[id]=-1;
}

int main(){
	cin>>n>>m>>(s+1);
	for(int i=1,u,v;i<=m;++i){
		cin>>u>>v;
		ae(u,v);ae(v,u);
	}
	for(int i=1;i<=cnt;++i)
		if(!vis[i])
			dfs(i);
	puts("No");
	return 0;
}

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

int main()
{
	int n, m, c, t = 0;
	int b[20];

	cin >> n >> m >> c;
	
	for (int i = 0; i < m; i++)
		cin >> b[i];

	for (int i = 0; i < n; i++) {
		int k = c;
		for (int j = 0; j < m; j++) {
			int a;

			cin >> a;
			k += a * b[j];
		}

		if (k > 0)
			t++;
	}

	cout << t << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**5)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


import numpy as np


def main():
    N, M = geta(int)
    A = np.array(list(geta(int)))
    A.sort()

    def c(x):
        """
        @return  # of handshake where hapiness >= x
        """
        X = np.searchsorted(A, x - A)
        return N * N - X.sum()

    left, right = 0, 2 * A[-1] + 1

    while left + 1 < right:
        middle = (left + right) // 2
        if c(middle) >= M:
            left = middle
        else:
            right = middle

    ans = 0
    Acum = np.zeros(N + 1, np.int64)
    Acum[:-1] = np.cumsum(A[::-1])[::-1]
    X = np.searchsorted(A, right - A)

    ans = Acum[X].sum() + (A * (N - X)).sum()

    ans += left * (M - (N * N - X.sum()))

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 21436
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define inf1 INT_MAX
#define inf2 LLONG_MAX
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define sbit __builtin_popcount
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define rit(it,x) for(auto it=x.begin();it!=x.end();it++)
#define cases(t) int t; cin>>t; rep(casn,1,t+1)
#define fill(a,b) memset(a,b,sizeof(a))
#define dbg(x) cerr<<#x<<" "<<x<<endl;
#define dbga(arr,n) cerr<<#arr<<": "; rep(tt,0,n)cerr<<arr[tt]<<" "; cerr<<endl;
#define infile ifstream fin; fin.open("input.txt")
#define outfile ofstream fout; fout.open("output.txt")
#define vec vector<int>
#define pii pair<int,int>
#define plii pair<ll,int>
#define pll pair<ll,ll>
#define p_queue priority_queue< plii,vector< plii >,greater< plii > > 
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define si(x) scanf("%d",&x)
#define sc(x) scanf("%c",&x)
#define sl(x) scanf("%lld",&x)
#define sst(x) scanf("%s",x)
#define pl(x) printf("%lld\n",x)
#define pi(x) printf("%d\n",x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

inline ll binex(ll a,ll b)
{
    ll ans=1,temp=a%mod;
    while(b!=0){
        if(b&1) ans=(ans*temp)%mod;
        temp=(temp*temp)%mod;
        b=b>>1;
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n;
    int arr[n][3],dp[n][3];
    rep(i,0,n){
        rep(j,0,3) cin>>arr[i][j];
    }
    dp[0][0]=arr[0][0]; dp[0][1]=arr[0][1]; dp[0][2]=arr[0][2];
    rep(i,1,n){
        dp[i][0]=arr[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=arr[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=arr[i][2]+max(dp[i-1][1],dp[i-1][0]);
    }
    cout<<max3(dp[n-1][0],dp[n-1][1],dp[n-1][2])<<endl;
}

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

int main() {
  string S;
  int sum=0;
  cin >> S;
  for (int i=0;i<S.size();i++) {
    if (i == S.size()-1) {break;}
    else {
      if (S.at(i) == S.at(i+1)) {
        if  (S.at(i) == '0') {
          S.at(i+1) = '1';
        } else {
          S.at(i+1) = '0';
        }
        sum++;
      } else {continue;}
    }
  }
  cout << sum <<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define vec vector<ll>
#define pi pair<ll,ll>
#define changeline cout<<endl
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define mod2 998244353
#define NO cout << "NO" <<endl
#define YES cout << "YES" <<endl
#define mem(arr,val) memset(arr,val,sizeof(arr));
const ll mod=1e9+7;
#define piii 3.14159265358979323846264338327950
#define print(a, n, m)     for (ll i = n; i < m; i++) {  cout << a[i] << " "; }  cout << endl
#define con continue

bool prime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
bool isPerfectSquare(ll x) {   
  long double sr = sqrt(x); 
  return ((sr - floor(sr)) == 0); 
} 
bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}
bool cmp(const pair<int,int> &a,  const pair<int,int> &b) 
{ 
    if(a.ff == b.ff)
        return a.ss < b.ss;
    return (a.ff > b.ff); 
}
//////////////////////////////////////////////////// Lets Do It ////////////////////////////////////////////////////////



void solve()
{

    // ll n;
    // cin>>n;
    // if(n%2==0)
    // {
    //     cout<<-1; return;
    // }

    // cout<<prime(101);

    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll c1=0,c2=0,c3=0;
    deque<ll> v;
    
    loop(i,0,n)    
    {
        if(s[i]=='R')c1++;
        else c2++;
    }

    ll ans=min(c1,c2);
    
    loop(i,0,c1){
        if(s[i]=='W')
        {
            c3++;
        }
    }

    cout<<min(c3,ans);
    return;
}
 
int main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
    IOS;
    ll t;
    //cin>>t;
    t=1;

    while(t--){
        solve();
        //cout<<endl;
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
} 

Measured memory_bytes: 3796
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import Counter

n = ni()
a = list(li())

cnt = Counter(a)

lst = []
for k,v in cnt.items():
    lst.append((k,v))

lst.sort(reverse=True)

first = 0
second = 0

for k,v in lst:
    if v >= 4 and first == 0:
        first = k
        second = k
        break
    
    elif v >= 4:
        second = k
        break
        
    elif v >= 2 and first != 0:
        second = k
        break
    
    elif v >= 2:
        first = k
        
print(first*second)

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    ll A;
    cin >> N >> A;

    if(N%500 <= A){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//This is getting accepted!
#include<bits/stdc++.h>
#define ll long long
#define oo 1000000009
#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define INA(a,n) for (int i = 1; i <= (n); ++i) cin >> a[i];
#define ITE(x) for(auto it = (x).begin(); it != (x).end(); ++it)
#define isset(x, i) (((x)>>(i))&1)
#define setbit(x, i) ((x)^(1ll<<(i)))
#define clearbit(x, i) ((x)&(~(1ll<<(i))))
#define twoexp(i) (1ll<<(i))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) >= 0 ? (a) : -(a))
#define FI first
#define SE second
#define son1 (id*2)
#define son2 (id*2+1)

using namespace std;

const int MOD = 1000000007;
const double EPS = 1e-8;
const double PI = 2 * acos(0);
const int MAXN = 1e6 + 6;

int n, k;
deque< pair<int, pair<int, int> > > dict[106];

void input() {
	int u, v, w, x, y, qtype;
	
	cin >> n >> k;
	
}


void preprocess() {
	
	dict[1].push_back({1, {1, n}});
	
}

void process(int itest) {
	int u, v, w, x, y, qtype;
		
	FOR(i, 2, k) {
		int idx = 0;
		auto it = dict[i-1][idx];
		ll cumu = 0;
		
		for (int u = n; u > 0; --u) {
			int maxv = n / u;
			int minu = n / (maxv+1) + 1;
			
			ll res = cumu;
			
			while(true) {
				res = (res + 1ll * it.SE.FI * (MIN(it.SE.SE, maxv) - it.FI + 1)) % MOD;
				if (it.SE.SE < maxv) {
					cumu = (cumu + 1ll * it.SE.FI * (it.SE.SE - it.FI + 1)) % MOD;
					it = dict[i-1][++idx];
				}
				else
					break;
			}
			
			dict[i].push_front({minu, {res, u}});
			u = minu;
			
		}
		
		
	}
	ll ans = 0;
	for (auto it : dict[k]) {
		ans = (ans + 1ll * it.SE.FI * (it.SE.SE-it.FI+1)) % MOD;
	}
	
	cout << ans << endl;
	
}

void oneTest() {
	
	input();
	preprocess();
	process(0);
	
}

void multiTest() {
	
	int t;
	cin >> t;
	
	for (int it = 1; it <= t; ++it) {
		input();
		preprocess();
		process(it);
	}
}

int main(){
    #ifndef ONLINE_JUDGE
//    freopen("../out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	oneTest();
//	multiTest();

    return 0;

}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


int main() {
    string s;
    cin >> s;

    pl(s.substr(0,s.size()-8))

    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    ll n,k;
    cin >> n >> k;
    vector<P> v(n);
    rep(i,n){
        int a,b;
        cin >> a >> b;
        v[i] = P(a,b);
        }
    sort(v.begin(),v.end());
    ll now = 0;
    for(auto i:v){
        now+=i.second;
        if(now>=k){
            cout << i.first<<endl;
            return 0;
        }
    }
    return 0;
}

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


#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);  ///for fasting input and output using cin,cout(only)
#define endl '\n'

int main()

{
    optimize();
    int n,m;
    cin>>n>>m;
    if( n == m )
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
 return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007

int main(){
    int n,m,ans=0;
    cin>>n>>m;
    if(n>1)ans+=n*(n-1)/2;
    if(m>1)ans+=m*(m-1)/2;
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

int main() {
  int k;
  cin >>k ;
  ll sum=0;


  for(int a=1;a<=k;a++){
    for(int b=1;b<=k;b++){
      for (int c=1;c<=k;c++) {
        int cat=1;
        for(int i =1;i<=min(a,min(b,c));i++){
          if(a%i==0 && b%i==0 && c%i==0){
            cat=i;
          }
        }
        sum+=cat;
      }
    }
  }


  cout <<sum ;
  return 0;
}


Measured memory_bytes: 3596
o = list(input())
e = list(input())
oe = []
for i in range(len(e)):
         oe.append(o[i])
         oe.append(e[i])
if len(o) != len(e):
         oe.append(o[len(o)-1])
ans = ''.join(oe)
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF 100000000
#define MAX 100001
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<ll, ll>
#define pb push_back
#define mp make_pair
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d)<< "\n";
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(a)-1;i>=(b);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))

signed main(){ INIT;
    VAR(int, n);
    VEC(char, s, n);
    REP(i, n) {
        if(s[i] == 'Y'){
            OUTL("Four"); RET;
        }
    }
    OUTL("Three");
RET;}


Measured memory_bytes: 256