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

/* typedef */
/* long系 */
typedef long long ll;	// long long
typedef long double ld;	// long double
/* vector系 */
typedef vector<int> vint;	// intのvector
typedef vector<double> vdouble;	// doubleのvector
typedef vector<ll> vll;	// llのvector
typedef vector<ld> vld;	// ldのvector
typedef vector<pair<int, int>> vi_i;	// i_iのvector
typedef vector<pair<double, double>> vd_d;	// d_dのvector
typedef vector<pair<ll, ll>> vl_l;	// l_lのvector
typedef vector<pair<ld, ld>> vld_ld;	// ld_ldのvector
typedef vector<string> vstring;	// stringのvector
/* pair系 */
typedef pair<int, int> i_i;	// int同士のpair
typedef pair<double, double> d_d;	// double同士のpair
typedef pair<ll, ll> l_l;	// ll同士のpair
typedef pair<ld, ld> ld_ld;	// ld同士のpair

/* define */
#define pb push_back	// push_back
#define all(v) v.begin(),v.end()	// コンテナ全体
#define PI (acos(-1))  // 円周率pi

/* 変数入出力 read, write */
template <typename T>	// 1変数
void read(T& x) {
	cin >> x;
}
template <typename T, typename T0>	// 2変数
void read(T& x, T0& y) {
	cin >> x >> y;
}
template <typename T, typename T0, typename T1>	// 3変数
void read(T& x, T0& y, T1& z) {
	cin >> x >> y >> z;
}
template <typename T, typename T0, typename T1, typename T2>	// 4変数
void read(T& x, T0& y, T1& z, T2& w) {
	cin >> x >> y >> z >> w;
}
template <typename T>	// 1変数
void write(T& x) {
	cout << x << endl;
}
template <typename T, typename T0>	// 2変数
void write(T& x, T0& y) {
	cout << x << " " << y << endl;
}
template <typename T, typename T0, typename T1>	// 3変数
void write(T& x, T0& y, T1& z) {
	cout << x << " " << y << " " << z << endl;
}
template <typename T, typename T0, typename T1, typename T2>	// 4変数
void write(T& x, T0& y, T1& z, T2& w) {
	cout << x << " " << y << " " << z << " " << w << endl;
}
// vectorの出力
template <typename T>
void printvec(const vector<T> &data) {
    		    for (const auto elm : data) {
      		    	cout << elm << " ";
    		    }
    		    cout << endl;
}


int main(int argc, char const *argv[]) {
    int n; cin >> n;
    string s = to_string(n);
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3692
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;


int main() {

    lli A, B, C;
    cin >> A >> B >> C;

    lli answer = C - (A - B);
    if (answer < 0) {
        cout << 0 << endl;
    } else {
        cout << answer << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  long double R, A;
  cin >> R;
  long double pie = 2.0 * (long double)asin(1.0);
  cout << R * 2 * pie << endl;
}

Measured memory_bytes: 3804
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
    auto N = readln.split[0].to!ulong;
    auto A = readln.split.to!(ulong[]);
    auto grps = sort(A.dup).group;
    size_t[ulong] nums;
    
    //grps.array.writeln;
    
    foreach (tup; grps) {
        nums[tup[0]] = tup[1];
    }
    //nums.writeln; 
    
    ulong all_num = grps.map!(a => a[1] * (a[1]-1)).sum / 2;
    ulong all_num_true = nums.values.dup.map!(a => a*(a-1)).sum / 2;
    
    int[] re; re.length = N;
    if (all_num > all_num_true) {
        if (
            equal(
                 sort(grps.map!(a => a[1] * (a[1]-1)).array),
                 sort(nums.values.dup.map!(a => a*(a-1)).array)
             )
        ) re[N] = 1;    // run-time error
    }
    //else if (all_num < all_num_true) writeln("WA");
    
    foreach (k; 0 .. N) {
        writeln( all_num_true - (nums[A[k]] - 1) );
    }
}



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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

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

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<pair<T, T>>& vp) {
	for (int i = 0; i < vp.size(); ++i) {
		s << "(" << vp[i].first << "," << vp[i].second << ")" << ( i+1 == vp.size() ? "" : ",\t" );
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
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);
}

//main code

int main(int argc, char const* argv[])
{
	string s, t;
	cin >> s >>t;
	map<char, set<char>> mp;
	map<char, set<char>> mp2;
	for (int i = 0; i < s.size(); i++) {
		mp[s[i]].insert(t[i]);
		mp2[t[i]].insert(s[i]);
	}
	for (auto&& var : mp) {
		if (var.second.size() > 1) {
			cout << "No" << endl;
			return 0;
		}
	}
	for (auto&& var : mp2) {
		if (var.second.size() > 1) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


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


long long int Exp(long long int exp_n,long long int exp_e, long long exp_mod);


int main(){
  int L,R,d;
  
  cin >> L >> R >> d;
  
  cout << (R/d - (L-1)/d) <<endl;
  
  return 0;
}


long long int Exp(long long int exp_n,long long int exp_e, long long int exp_mod){
  long long int exp_o = 1;
  long long int exp_x=exp_n;
  long long int exp_tmp;
  
  while(0<exp_e){
    exp_tmp = exp_e/2;
    if(exp_e - exp_tmp*2 == 1){
      exp_o = exp_o*exp_x;
      if(exp_o>exp_mod){
        exp_o=exp_o%exp_mod;
      }
    }
    
    exp_x = exp_x*exp_x;
    if(exp_x>exp_mod){
      exp_x=exp_x%exp_mod;
    }
    exp_e = exp_tmp;
  }
  return exp_o;
}


Measured memory_bytes: 3592
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc *bufio.Scanner

func init() {
	// 100MB
	bufsize := 100 * 1024 * 1024
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, bufio.MaxScanTokenSize), bufsize)
	sc.Split(bufio.ScanWords)
}
func readInt() int              { return readIntArray(1)[0] }
func readInt2() (int, int)      { a := readIntArray(2); return a[0], a[1] }
func readInt3() (int, int, int) { a := readIntArray(3); return a[0], a[1], a[2] }
func readIntArray(n int) []int {
	s := readStringArray(n)
	a := make([]int, n)
	for i := range a {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}
func readString() string            { return readStringArray(1)[0] }
func readString2() (string, string) { a := readStringArray(2); return a[0], a[1] }
func readStringArray(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i] = sc.Text()
	}
	return a
}
func max(ns ...int) int {
	max := ns[0]
	for _, n := range ns {
		if n > max {
			max = n
		}
	}
	return max
}
func min(ns ...int) int {
	min := ns[0]
	for _, n := range ns {
		if n < min {
			min = n
		}
	}
	return min
}
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	// 200000
	N := readInt()
	P := readIntArray(N)

	var count int
	min := math.MaxInt64
	for i := range P {
		if P[i] < min {
			min = P[i]
		}

		if P[i] <= min {
			count++
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 6912
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def slv2(N, K, A):
    ans = (-1, -1)
    for k in range(K+1):
        tmp = 0
        for a in A:
            tmp += k ^ a
        if ans[0] < tmp:
            ans = (tmp, k)
    
    print(ans)
    return ans[0]


@mt
def slv(N, K, A):
    max_k_A = max(max(A), K)
    # print(max_k_A)
    mi = int(math.ceil(math.log2(max_k_A)))
    # print('----', mi, math.log2(max_k_A))

    ans = 0
    ak = 0
    for i in range(mi-1, -1, -1):
        s0 = 0
        s1 = 0
        i1 = 1 << i
        for a in A:
            if ak + i1<= K:
                s1 += (a & i1) ^ i1
            s0 += (a & i1) ^ (0)
        ans += max(s0, s1)
        if s1 > s0:
            ak |= i1
    #     print(i, s0 - s1)
    # print(ak)
    return ans


def main():
    N, K = read_int_n()
    A = read_int_n() 
    print(slv(N, K, A))

    # N = 10
    # K = random.randint(0, 100)
    # A = [random.randint(0, 100) for _ in range(N)] 
    # print(N, K)
    # print(' '.join(map(str, A)))
    # print(slv2(N, K, A))
    # print(slv(N, K, A) == slv2(N, K, A))   


if __name__ == '__main__':
    main()


Measured memory_bytes: 17012
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll multbig(ll a,ll b,ll mod){
    if(a==0 or b==0) return 0;
    if(a==1 or b==1) return (a*b)%mod;
    ll cur=multbig(a,b/2,mod);
    cur=(2*cur)%mod;
    if(b%2) cur=(cur+a)%mod;
    return cur;
}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}


#define N 	 100005
void solve(){
	int n, start;
	cin>>n;
	int A[n]= {0};
	rep(i,0,n){
		int t; 
		cin>>t; 
		A[t]++;
	}
	if(n%2 && A[0] != 1){
		cout<<0<<endl;
		return;
	}
	if(n%2) start = 2;
	else start = 1;
	rep(i,start,n){
		if(A[i] != 2){
			cout<<0<<endl;
			return;
		}
		i++;
	}
	if(start == 1) cout << fpow(2, n/2) << endl;
	else cout<< fpow(2, (n-1)/2) << endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
     t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
int main(){
  int h,w;cin>>h>>w;
  char a[110][110];
  rep(i,h+2){
    rep(j,w+2){
      a[i][j]='#';
    }
  }
  rep1(i,h){
    rep1(j,w){
      cin>>a[i][j];
    }
  }
  rep(i,h+2){
    rep(j,w+2){
      cout<<a[i][j];
    }
    cout<<"\n";
  }

  


  


  

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define p pair<int,int>
int N, M, S, T;
vector<int> G[100010];
int dp[3][100010];

struct edge{
    int n, m, cost;

    bool operator < (const edge& e) const {
        return cost < e.cost; 
    }

    bool operator > (const edge& e) const {
        return cost > e.cost; 
    }
};

void dij(){
    for(int i = 0; i < 3; i++){
        for(int j = 0; j <= N; j++){
            dp[i][j] = 1 << 30;
        }
    }

    priority_queue<edge, vector<edge>, greater<edge>> pq;
    pq.push(edge{S, 0, 0});
    dp[0][S] = 0;

    while(!pq.empty()){
        edge e = pq.top();
        int n = e.n, m = e.m, cost = e.cost;
        pq.pop();
        
        if(dp[m][n] < cost) continue;

        cost++;

        for(auto& u : G[n]){
            if(dp[(m + 1) % 3][u] > cost){
                dp[(m + 1) % 3][u] = cost;
                pq.push(edge{u, (m + 1) % 3, cost});
            }
        }
    }
}

int main(){
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int u, v;
        cin >> u >> v;
        G[u].push_back(v);
    }
    cin >> S >> T;
    dij();
    cout << (dp[0][T] != 1 << 30 ? dp[0][T] / 3 : -1) << endl;
    return 0;
}


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

int main() {
	string s;
	cin >> s;
	string S = "";
	for (int i = 0; i < 3; i++) {
		if (s[i] == '1') {
			S += '9';
		} else if (s[i] == '9') {
			S += '1';
		} else {
			S += s[i];
		}
	}
	cout << S << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int n;

    cin >> n;
    int temp =n;
    int s[105] = {0};
    int l = 0;
    if (n == 0) cout << 0;
    while (temp != 0)
    {
        int r = temp % (-2);
        temp = temp / -2;
        if (r < 0)
        {
            r += 2;
            temp += 1;
        }
         s[l++] = r;
    } 

    for (int i = l-1; i >= 0; --i)
        cout << s[i];
    cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int M1,D1,M2,D2;
  if(scanf("%d%d",&M1,&D1)<2) return 1;
  if(scanf("%d%d",&M2,&D2)<2) return 1;
  
  if(M1==M2){
    printf("0\n");
  }
  else{
    printf("1\n");
  }
  return 0;
}

Measured memory_bytes: 128
/*
6
3 14 159 2 6 53
58 9 79 323 84 6
2643 383 2 79 50 288
:87

3
1 1 1
2 2 2
3 3 3
:27

2
1 5
2 4
3 6
:3
*/

#include <bits/stdc++.h>
using namespace std;

int main() {
	//freopen("084C.cpp", "r", stdin);
	int n; scanf("%d", &n);
	int a[n], b[n], c[n];
	for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
	for (int i = 0; i < n; ++i) scanf("%d", &b[i]);
	for (int i = 0; i < n; ++i) scanf("%d", &c[i]);
	sort(a, a+n);
	sort(c, c+n);
	using ll = long long;
	ll ans = 0;
	for (int j = 0; j < n; ++j) {
		int i = lower_bound(a, a+n, b[j]) - a;
		int k = c+n - upper_bound(c, c+n, b[j]);
		ans += (ll)i * k;
	}
	printf("%lld\n", ans);
}


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

int main() {
    int64_t N,K;
    cin >> N >> K;

    int64_t min1, min2;
    min1 = N%K;
    min2 = K-(N%K);

    cout << min(min1,min2) << endl;

    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST
import Data.Char
import Data.Bits

main :: IO ()
main = do
  n <- readLn :: IO Int
  xys <- replicateM n readxy :: IO [[[Int]]]
  print $ solve n xys

solve :: Int -> [[[Int]]] -> Int
solve n xys = if null ans then 0 else (maximum ans)
  where
    ans = map sum . filter isPossible $ candidate n
    isPossible candidate = go candidate xys
      where
        go :: [Int] -> [[[Int]]] -> Bool
        go [] _ = True
        go _ [] = True
        go (c:cs) (xy:xys)
          | isOK = go cs xys
          | otherwise = False
          where
            isOK = foldl' g True xy
            g acc (x:y:_) = acc && (f x y)
            f x y = if c == 1 
              then candidate!!(x-1) == y
              else True
              -- (c == 1) `xor` (candidate!!(x-1) /= y)

readxy = do
  a <- readLn :: IO Int
  xy <- replicateM a $ map read . words <$> getLine :: IO [[Int]]
  return xy

candidate n = replicateM n [0, 1]

Measured memory_bytes: 4348
import sys

readline = sys.stdin.buffer.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    def calc(x):
        for i in range(100):
            if 2 ** (i + 1) > x:
                return i

    from collections import defaultdict

    l = int(input())
    n = calc(l) + 1
    edge = []
    for u in range(1, n):
        edge.append((u, u + 1, 0))
        edge.append((u, u + 1, 2 ** (u - 1)))

    mx = 2 ** (n - 1) - 1
    rem = (l - 1) - mx
    bit = format(rem, "b")
    bit = bit[::-1]

    cur = mx

    for u, o in enumerate(bit, 1):
        if o == "1":
            edge.append((u, n, cur + 1))
            cur += 2 ** (u - 1)

    print(n, len(edge))

    for u, v, w in edge:
        print(u, v, w)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include<bits/stdc++.h>
using namespace std;
string s;
string t;
int length(int n,int m)
{
   vector<vector<int>>dp(n+1,vector<int>(m+1,0));

   for(int i=0;i<n+1;i++)
   { 
       for(int j=0;j<m+1;j++)
       {
           if(i==0||j==0)
           dp[i][j]=0;
           else if(s[i-1]==t[j-1])
               dp[i][j]=1+dp[i-1][j-1];
           else
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
               
       }
   }
    int index = dp[n][m]; 
  

   char lcs[index+1]; 
   lcs[index] = '\0';

   int j = m, i = n; 
   while (i > 0 && j > 0) 
   { 
     
      if (s[i-1] == t[j-1]) 
      { 
          lcs[index-1] = s[i-1]; 
          i--; j--; index--;     
      } 
  

      else if (dp[i-1][j] > dp[i][j-1]) 
         i--; 
      else
         j--; 
   } 
  

   cout <<  lcs; 
}



int main()
{
  
   cin>>s>>t;
  
     int n=s.size();
   int m=t.size();
  
  length(n,m);
  
    return 0;
}


Measured memory_bytes: 35584
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define dbgi(x) cout << #x << " = " << (x) << "\n";
#define dbgvi(x) cout << #x << " = "; for(int i = 0; i < (x.size()); ++i) cout << x[i] << " ";
#define mrk() cout << "HERE\n"
#define vi vector < int >
#define vs vector < string >
#define int long long
#define vii vector < vi >
#define viii vector < vii >
#define viiii vector < viii >
#define pii pair < int, int >
#define foru(i, a, b) for(int i = a; i < b; ++i)
#define ford(i, b, a) for(int i = b; i > a; --i)
using namespace std;


signed main(){
    int n;
    cin >> n;
    vi c(n), s(n), f(n);
    foru(i, 0, n - 1){
        cin >> c[i] >> s[i] >> f[i];
    }
    vi ans(n);
    ans[n - 1] = 0;
    ford(i, n - 2, -1){
        int cur = 0;
        foru(j, i, n - 1){
            int nxt = ((cur % f[j] == 0) ? cur : (cur - cur % f[j] + f[j]));
            cur = max(nxt, s[j]) + c[j];
        }
        ans[i] = cur;
    }
    foru(i, 0, n){
        cout << ans[i] << "\n";
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        long N = sc.nextLong();
        long ans = 0;

        for(long n=1; n*n < N;n++){
            long candidate = N / n -1;
            //System.out.println(candidate);
            if(N / candidate == N % candidate){
                ans += candidate;
            }
        }

        System.out.println(ans);

    }
}


Measured memory_bytes: 22868
#include "cstdio"
#include "cmath"
#include "iostream"
#include "cstring"
#include "algorithm"
using namespace std;
int read(){
	int k=0;char c=getchar();
	while(c<'0'||c>'9')c=getchar();
	while(c>='0'&&c<='9'){k=k*10+c-'0';c=getchar();}
	return k;
}
int main(){
    int a,b,c;
    a=read();b=read();c=read();
    if(a-b==b-c) printf("YES");
    else printf("NO");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n=0;
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(s[i]=='+')
            n++;
        else
            n--;
    }
    cout<<n<<endl;

    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示

void solve(long long a, std::string s){
  cout << (a >= 3200 ? s : "red" ) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long a;
    scanf("%lld",&a);
    std::string s;
    std::cin >> s;
    solve(a, s);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))


int main(){
  int n;
  cin>>n;
  vector<int>t(n+1);
  vector<int>x(n+1);
  vector<int>y(n+1);
 
  t[0]=0;x[0]=0;y[0]=0;
  for(int i=1;i<=n;i++){
    cin>>t[i]>>x[i]>>y[i];
  } 
  bool f=true;
  rep(i,n){
    if((t[i+1]-t[i]<abs(x[i+1]-x[i])+abs(y[i+1]-y[i]))||((t[i+1]-t[i])%2!=(abs(x[i+1]-x[i])+abs(y[i+1]-y[i]))%2)){
      f=false;
      break;
    }
  }
  if(f)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
  int n,b,f,r,v;
  cin >> n;
  int room[4][3][10] = {0};
  REP(i,n) {
    cin >> b >> f >> r >> v;
    room[b-1][f-1][r-1] += v;
  }
  
  REP(i,4) {
    REP(j,3) {
      REP(k,10) {
        cout << " " << room[i][j][k];
      }
      cout << endl;
    }
    if(i!=3) {
      REP(l,10) cout << "##";
      cout << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3096
W,H,N = map(int, input().split())
xya = [list(map(int, input().split())) for i in range(N)]

ld = [0,0]
ru = [W,H]

flag = True
for x,y,a in xya:
    if a == 1:
        if ld[0] < x: ld[0] = x
    if a == 2:
        if ru[0] > x: ru[0] = x
    if a == 3:
        if ld[1] < y: ld[1] = y
    if a == 4:
        if ru[1] > y: ru[1] = y
    tate = ru[1] - ld[1]
    yoko = ru[0] - ld[0]
    if tate <= 0 or yoko <= 0:
        flag = False
        break

if flag:
    print(tate*yoko)
else:
    print(0)


Measured memory_bytes: 3064
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define int long long
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t;
int cev;
string s;
vector<int> v;

int32_t main(void){
	scanf("%lld",&n);
	FOR{
		for(int j=1;j<=n;j++){
			for(int jj=1;jj<=n;jj++)cev+=__gcd(i,__gcd(j,jj));
		}
	}
	printf("%lld\n",cev);
	return 0;
}



Measured memory_bytes: 3824
#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;
}

ll dp[3005][3005];

inline ll solve(int n,ll arr[],int l,int r)
{
    if(dp[l][r]!=(-1)*inf2) return dp[l][r];
    if(l==r) return dp[l][r]=arr[l];
    return dp[l][r]=max(arr[l]-solve(n,arr,l+1,r),arr[r]-solve(n,arr,l,r-1));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n;
    ll arr[n];
    rep(i,0,n) cin>>arr[i];
    rep(i,0,n){
        rep(j,0,n) dp[i][j]=(-1)*inf2;
    }
    cout<<solve(n,arr,0,n-1)<<endl;
    
    /*rep(i,0,n){
        rep(j,0,n) cerr<<dp[i][j]<<" "; cerr<<endl;
    }*/
}

Measured memory_bytes: 70912
#include<bits/stdc++.h>
using namespace std;
#define MAX 1000000007
int main(){
  long long int N,M,x;
  cin>>N>>M;
  int arr[N+1];
  unsigned long long int sum[N+1];
  memset(arr,1,sizeof arr);memset(sum,0,sizeof sum);
  while(M--) {cin>>x;arr[x]=0;}
  sum[0]=1;
  if(arr[1]) sum[1]=1;
  for(long long int i=2;i<=N;i++)
    if(arr[i]) sum[i]=(sum[i-1]+sum[i-2])%MAX;
  cout<<sum[N]%MAX;
}

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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp make_pair
#define pb push_back

const long long MOD = 1000000007;
const long long INF = 1LL<<60;


vector<vector<int>> graph;
vector<ll> dis;
vector<int> before;

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(12);

    int n, m;
//    cin >> n >> m;
    scanf("%d%d", &n, &m);
    graph.assign(n+1, vector<int>());
    dis.assign(n+1, INF);
    before.assign(n+1, -1);
    rep(i, m){
        int a, b;
        scanf("%d%d", &a, &b);
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    queue<int> q;
    dis[1] = 0;
    q.push(1);
    while(!q.empty()){
        auto e = q.front();
        q.pop();
        for(auto next: graph[e]){
            if(before[next] == -1){
                before[next] = e;
                q.push(next);
            }
        }
    }

//    priority_queue<pair<int, int>> p;
//    dis[1] = 0;
//    p.push(mp(0,1));
//    while(!p.empty()){
//        auto e = p.top();
//        p.pop();
//        int v = e.second;
//        if(dis[v] < e.first){
//            continue;
//        }
//        for(auto next: graph[v]){
//            if(dis[next] > dis[v]+1){
//                dis[next] = dis[v]+1;
//                before[next] = v;
//                p.push(mp(dis[next], next));
//            }
//        }
//    }

    bool can = true;
    for(int i = 2; i < n+1; i++){
        if(before[i] == -1){
            can = false;
        }
    }
    if(can){
        cout << "Yes" << endl;
        for(int i = 2; i < n+1; i++){
            printf("%d\n", before[i]);
        }
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 10880
MOD = 10**9+7
def solve(n):
    """
    0: {}
    1: {0}
    2: {9}
    3: {0,9}
    """
    dp = [[0]*4 for i in range(n+1)]
    dp[0][0] = 1
    x = [1,0,0,0]
    for i in range(n):
        x = [
            (8*x[0]) % MOD,
            (9*x[1] + x[0]) % MOD,
            (9*x[2] + x[0]) % MOD,
            (10*x[3] + x[2] + x[1]) % MOD
        ]
    return x[3]

n = int(input())
print(solve(n))

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Vec  =vector<int>;

int		main(void)
{
	int n;
	string s;
	string t;

	cin >> n >> s >> t;
	for (int i = 0; i < n; i++)
		cout << s[i] << t[i];
	cout << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void){

	char c[11], c1[11], c2[21], *p, *p1;
	int cnt = 0, n, a1;
	
	scanf("%s",c);
	fflush(stdin);
	scanf("%d",&n);
	
	for(a1 = 1; a1 <= n; a1++){
		scanf("%s",c1);
		strcpy(c2, c1);
		strcat(c2, c1);
		p = &c2[0];
		p1 = strstr(p, c);
		if(p1 != NULL)
			cnt++;
	}
	
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main() {
    int n,y,i,j,k;
    cin >> n >> y;

    for(i=0;i<=n;i++){
        for(j=0;j<=n-i;j++){
            if((i*10000) + (j*5000) + ((n-i-j)*1000) == y){
                cout << i << ' ' << j << ' ' << (n-i-j) << endl;
                return 0;
            }
        }
    }
    cout << -1 << ' ' << -1 << ' ' << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var D int
	fmt.Scan(&D)

	switch D {
	case 25:
		fmt.Println("Christmas");
	case 24:
		fmt.Println("Christmas Eve");
	case 23:
		fmt.Println("Christmas Eve Eve");
	case 22:
		fmt.Println("Christmas Eve Eve Eve");
	}
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
vector<int>g[100005];
int n;
inline int dfs(int x, int fa)
{
    int l1=g[x].size();
    int res=0;
    for(int i=0;i<l1;i++) 
	{
        int v=g[x][i];
        if(v!=fa)
            res+=dfs(v,x);
    }
    if(res>=2) 
	{
        printf("First\n");
        exit(0);
    }
    if(res==0) 
		return 1;
    return 0;
}
int main() 
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
    if(dfs(1,-1)) 
        printf("First\n");
    else
        printf("Second\n");
	return 0;
}

Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
typedef long long ll;
typedef double db;
const int MX=3000;
int dp[MX+5][MX+5],ssz,tsz;
string s,t,ans;
int ok(int l, int r)
{
    if(l==ssz||r==tsz) return 0;
    if(~dp[l][r]) return dp[l][r];
    int mx=0;
    if(s[l]==t[r]) mx=1+ok(l+1,r+1);
    else mx=max(ok(l+1,r),ok(l,r+1));
    return dp[l][r]=mx;
}
void path(int l, int r, int res)
{
    if(l==ssz||r==tsz) return;
    if(dp[l][r]==res&&s[l]==t[r])
    {
        ans+=s[l];
        path(l+1,r+1,--res);
    }
    else
    {
        if(dp[l+1][r]==res) path(l+1,r,res);
        else path(l,r+1,res);
    }
}
int main()
{
    FasterIO;
    int i,j,k,W,x,y;
    cin>>s>>t;
    ssz=s.size();
    tsz=t.size();
    mem(dp,-1);
    int res=ok(0,0);
    ans="";
    path(0,0,res);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 35840
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>

#include<map>
#include<set>
#include<iomanip>
#include<cstdio>
#include<sstream>
#include<cstring>

#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<bitset>
#include<numeric>
#include<utility>
#include<cstdlib>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	string s;
	cin >> s;
	int a, b;
	for(int i = 0; i < s.size(); ++i) {
		if(s[i] == 'A') {
			a = i;
			break;
		}

	}
	for(int i = 0; i < s.size();++i) {
		if(s[s.size()-i] == 'Z') {
			b = s.size()-i;
			break;
		}
	}
	cout << b - a +1<< endl;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>  
using namespace std;  
#define INF 0x3f3f3f3f  
typedef long long ll;  
const int N = 1e5 + 10; 
int rec[3*N];
void area(ll n, ll m, ll &ans)
{
    ll w = m>>1;
    for (int i = 1; i < n; i++)
    {
        ll x = m;
        ll y = m - w;
        ll z = i;
        ll mx = max(x*(n-i), max(y*z, z*w));
        ll mi = min(x*(n-i), min(y*z, z*w));
        ans = min(ans, mx - mi);
        
    }
}
void area2(ll n, ll m, ll &ans)
{
    ll w = n/3;
    ll t = n - w;
    t >>= 1;
    ll z = n - w - t;

    ans = min(ans, (n - w - t - w)*m);
}
int main()  
{  
   //freopen("in.txt", "r", stdin);
   ll n, m;
   while (cin >> n >> m)
   {
       ll t = n * m;
       if (t % 3 == 0)
       {
            puts("0");
            continue;
       }
 
       ll ans = 1LL<<60;
       area(n, m, ans);
       area(m, n, ans);
       area2(n, m, ans);
       area2(m, n, ans);
       cout<<ans<<endl;
   }
   return 0;  
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)

int main() {
    string s; cin >> s;
    bool flag = 1;
    rep(i, s.size()) {
        if (s.at(i) != s.at(s.size()-1-i)) flag = 0;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#include <atcoder/all>

// #include <boost/multiprecision/cpp_int.hpp>

// #LIB#

using namespace std;
using namespace atcoder;
using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#ifdef ONLINE_JUDGE
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');
#endif

// using lll = boost::multiprecision::int256_t;

int main() {
  ll n;
  cin >> n;
  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }
  map<ll, ll> ps;
  ll n_ = n * 2;
  while (n_ > 1) {
    bool prime = true;
    for (ll i = 2; i * i <= n_; ++i) {
      if (n_ % i == 0) {
        ++ps[i];
        n_ /= i;
        prime = false;
        break;
      }
    }
    if (prime) {
      ++ps[n_];
      break;
    }
  }
  vector<pair<ll, ll>> psv;
  itr(x, ps) psv.emplace_back(x.first, x.second);
  ll ans = 2 * n;
  ll psn = psv.size();
  rep(i, 1 << psn) {
    ll t = 1;
    rep(j, psn) if ((i >> j) & 1) t *= pow(psv[j].first, psv[j].second);
    ll u = 2 * n / t;
    ll p = inv_mod(t, u);
    ll q = (t * p - 1) / u;
    while (t * p - 1 <= 0) {
      p += u;
      q -= t;
    }
    if (t * p - u * q == 1 && q > 0) updatemin(ans, t * p - 1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 4124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;
typedef tuple<ll,ll,ll,ll> T;


ll i,j,k;


int main(){
   ll N,M;
   cin>>N>>M;
   V H(N);
   rep(i,N)cin>>H[i];
   V A(M),B(M);
   rep(i,M)cin>>A[i]>>B[i];

   vector<V> tonari(N);
   rep(i,M){
       tonari.at(A[i]-1).push_back(B[i]-1);
       tonari.at(B[i]-1).push_back(A[i]-1);
   }
   ll ans=0;
   rep(i,N){
       bool jud=true;
       rep(j,tonari.at(i).size()){
          if(H[i]<=H[tonari[i][j]])jud=false;
       }
       if(jud)ans++;

   }
   cout<<ans<<endl;

   
}


Measured memory_bytes: 11444
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner cin = new Scanner(System.in);
		boolean[] isPrime = new boolean[1000000];
		Arrays.fill(isPrime, true);
		isPrime[0]=isPrime[1]=false;
		for(int i = 2; i < isPrime.length; i++){
			if(isPrime[i]){
				for(int j = i+i; j < isPrime.length; j+=i){
					isPrime[j]=false;
				}
			}
		}
		while(cin.hasNext()){
			int n = cin.nextInt();
			int count = 0;
			for(int i=0; i <= n; i++){
				if(isPrime[i]){
					count++;
				}
			}
			System.out.println(count);
		}
	}

}

Measured memory_bytes: 13000
day = input()

if day == "SUN":
    print(7)
elif day == "MON":
    print(6) 
elif day == "TUE":
    print(5)
elif day == "WED":
    print(4)
elif day == "THU":
    print(3)
elif day == "FRI":
    print(2)
else:
    print(1)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    string ans="";
    for(ll i=0;i<n;++i)
    {
        ans+=s[i];
        ans+=t[i];
    }
    cout<<ans;

    return (0);
}


Measured memory_bytes: 256
#include <algorithm>
        #include <bitset>
        #include <cassert>
        #include <chrono>
        #include <cmath>
        #include <complex>
        #include <cstdio>
        #include <cstdlib>
        #include <cstring>
        #include <ctime>
        #include <deque>
        #include <functional>
        #include <iomanip>
        #include <iostream>
        #include <iterator>
        #include <limits>
        #include <climits>
        #include <list>
        #include <map>
        #include <numeric>
        #include <queue>
        #include <random>
        #include <ratio>
        #include <set>
        #include <sstream>
        #include <stack>
        #include <string>
        #include <unordered_map>
        #include <unordered_set>
        #include <utility>
        #include <vector>
        using namespace std;
         
        typedef long long ll;
        typedef long double LD;
        #define int ll
        #define double LD
        #define pb push_back
        #define mp make_pair
        #define REP(i,n) for (int i = 0; i < n; i++)
        #define loop(i,n) for (int i = 0; i < n; i++)
        #define FOR(i,a,b) for (int i = a; i < b; i++)
        #define REPD(i,n) for (int i = n-1; i >= 0; i--)
        #define FORD(i,a,b) for (int i = a; i >= b; i--)
        #define remax(a,b) a = max(a,b)
        #define remin(a,b) a = min(a,b)
        #define mem(a, b) memset(a, b, sizeof a)
        #define append push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define print(x) cout << (x) << endl
        #define PRECISION(x) cout << fixed << setprecision(x)
        #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
        #define Test(){int t;cin >> t;for(int i=1;i<=t;i++){cout << "Case #" << i << ": ";solve();}}
        #define test(){int t; cin>>t; for(int i=1;i<=t;i++){solve();}}
        #define vi vector<int>
        #define vii vector<pair<int,int> > 
        #define vci vector<pair<char,int> >
        #define vic vector<pair<int,char> > 
        #define N 200005
        #define pb push_back
        const double PI=acos(-1);
        const int MOD = 1000000007;
        const int FMOD = 998244353;
	
		void solve()
		{
			int n;
			cin>>n;
			
			int a[n];
			loop(i,n)
			cin>>a[i];
			
			int mx=0,ans=0;
			FOR(i,1,n)
			{
				mx=max(mx,a[i-1]);
				if(a[i]<mx)
				{
					ans+=mx-a[i];
					a[i]=mx;
				}
			}
			cout<<ans;
		}
		signed main()
		{
		//	test();
		solve();
		}

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

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

    int ch = 0;
    for(int i=1;i<n;++i){
        if(s[i-1] != s[i]) ++ch;
    }
    cout << n-1 - max(0, ch-2*k) << endl;

    return 0;
}


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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

int main()
{    
    

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li a,b,c,d;

    cin>>a>>b>>c>>d;

    while(a>0 && c>0)
    {
        c-=b;

        if(c<=0)
            break;

        a-=d;
    }

    if(a>0)
    {
        cout<<"Yes";
    }
    else
        cout<<"No";

    return 0;
}

Measured memory_bytes: 3648
// BEGINNING WITH NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
// ATCODER BEGINNERS PROBLEMS
//#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.flush();
   	string s;
    cin >> s; string t; cin >> t;
    int ans=0;
  	for(int i=0;i<(int)s.size();i++)
      if(s[i]==t[i]) ans++;
    cout<<ans<<endl;
    return 0;
    // Bye Bye 2019
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <climits>
using namespace std;

#define REP(i,n,m) for(int i=n;i<m;i++)
#define rep(i,n) REP(i,0,n)

int n;
int dp[1002][1002];
pair<int,int> p[1002];

void solve(){
  rep(i,n+1) rep(j,n+1) dp[i][j] = INT_MAX;
  dp[0][0] = 0;

  rep(i,n){
    rep(j,n+1){
      if(dp[i][j] != INT_MAX){
        if(dp[i][j] + p[i].second <= p[i].first){
          dp[i+1][j+1] = min(dp[i+1][j+1],dp[i][j]+p[i].second);
        }
        dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
      }
    }
  }

  for(int i=n;i>=0;i--){
    if(dp[n][i] != INT_MAX){
      cout<<i<<endl;
      return;
    }
  }
}

int main(){
  while(cin>>n){
    rep(i,n){
      cin>>p[i].second>>p[i].first;
    }
    sort(p,p+n);
    solve();
  }
  return 0;
}

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

	rep(i,3){
		rep(j,3){
			cin >>a[i][j];
		}
	}
	cin >> n;
	vector<int>b(n);
	rep(i,n){
		cin >> b[i];
		rep(j,3){
			rep(k,3){
				if (a[j][k]==b[i]){
					a[j][k]=0;
				}
			}
		}
	}
	//yoko
	string ans="No";
	rep(i,3){
		if (a[i][0]==0&&a[i][1]==0&&a[i][2]==0){
			ans ="Yes";
		}
	}
	rep(i,3){
		if (a[0][i]==0&&a[1][i]==0&&a[2][i]==0){
			ans ="Yes";
		}
	}
	if (a[0][0]==0&&a[1][1]==0&&a[2][2]==0){
		ans="Yes";
	}
	if (a[0][2]==0&&a[1][1]==0&&a[2][0]==0){
		ans="Yes";
	}
	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 256