akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>

//using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

using ll =  long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
template<typename T> void chadd(T& a, T b) { a = a + b; }

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

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


}


int main() {

	int n;
	std::cin >> n;
	std::vector<int> p(n), q(n);
	rep(i, n) std::cin >> p[i];
	rep(i, n) std::cin >> q[i];

	// a, bを求める
	// 順列
	std::vector<int> arr(n);
	rep(i, n) arr[i] = i + 1;

	int a, b;

	int cnt = 0;

	do {
		// 一致するか
		bool match_p = true;
		bool match_q = true;
		rep(i, n) {
			if (arr[i] != p[i]) match_p = false;
			if (arr[i] != q[i]) match_q = false;
		}

		if (match_p) a = cnt;
		if (match_q) b = cnt;

		++cnt;
	} while (std::next_permutation(arr.begin(), arr.end()));

	std::cout << std::abs(a - b) << std::endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.Math;

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

		int c = sc.nextInt();
		int d = sc.nextInt();

		int e = sc.nextInt();

		int f = sc.nextInt();

		int w = 100 * a;
		int s = 0;
		double density = 0;
		double maxD = (double)100 * e / (100 + e);

		int an = f / (a * 100);
		int bn = f / (b * 100);
		for(int i = 0; i <= an; i++) {
			for(int j = 0; j <= bn; j++) {
				int tmpW = 100 * (a * i + b * j);
				if(tmpW > f) {
					break;
				}
				int limE = e * (a * i + b * j);
				int cn = limE / c;
				int dn = limE / d;
				for(int k = 0; k <= cn; k++) {
					if(tmpW + c * k > f) {
						break;
					}
					for(int l = 0; l <= dn; l++) {
						int sum = c * k + d * l;
						if(sum + tmpW > f) {
							break;
						}
						if(sum > limE) {
							break;
						}
						double tmpD = (double) (100 * sum) / (sum + tmpW);
						if(density < tmpD && tmpD <= maxD) {
							s = sum;
							w = tmpW;
							density = tmpD;
							// System.out.println("i:" + i + ", j:" + j + ", k:" + k + ", l:" + l);
							// System.out.println("s = " + s + ", w = " + w + ", density = " + density);
							// System.out.println();
						}
					}
				}
			}
		}

		System.out.println((s + w) + " " + s);
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#include<algorithm>
#define int long long
#define what_is(x) cerr << #x << " is " << x << endl;
const int MOD = 1e9 + 7;
using namespace std;
int powmod(int a, int b, int MOD = MOD){
    if(!a and !b)    return 1ll;
    if(!a)    return a;
    int res = 1ll;
    b %= (MOD - 1ll), a %= MOD;
    while(b){
        if(b%2 == 1)    res = (res * a) % MOD;
        a = (a * a) % MOD;
        b /= 2;
    }
    return res;
}
int popcount(uint32_t n)
{
    n = n - ((n >> 1) & 0x55555555);
    n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
    return ((n + (n >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}

void solve() {
   int n;
   cin>>n;
   int cnt=0;
   for(int i=1;i<=n;++i)
   {
      if((int)floor(log10(i)+1)%2!=0) cnt++;
   }
   cout<<cnt<<"\n";
    
}

int32_t main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    //cout<<"Hello World"<<"\n";
    //int t;cin>>t;while(t--)
    solve();
   
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//#include <boost/lexical_cast.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define pb push_back
#define mp make_pair
#define endl '\n'
#define PI acos(-1)
#define P pair<int,int>
typedef tree<int,null_type,less_equal <int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

long mod=1e9+7;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int a,p;
	cin>>a>>p;
	cout<<(3*a+p)/2;
	return 0;
}

Measured memory_bytes: 256
def gcd(i, j):
	return i * j / lcm(i, j)
def lcm(i, j):
	if j > i:
		return lcm(j, i)
	if i % j == 0:
		return j
	k = i % j
	return lcm(j, k)

N = input()
print gcd(2, N)



Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
constexpr ll mod = 1e9 + 7;
#define endl '\n'
 
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  ll n;
  cin >> n;
  string s;
  cin >> s;
  int i = -1;
  int ans = 0;
  while (i < n) {
    i = s.find("ABC", i+1);
    if (i == string::npos) break;
    ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3648
/// Author: Sarfaraz Alam
# include <bits/stdc++.h>
# define pb push_back
# define ll long long

# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define DEBUG
typedef unsigned long long int ull;
using namespace std;
#include<string>
#include<cmath>
const int N = 1e5 + 7;
const int mod = 1e9 + 7;


int main()
{
    speed;
    #ifdef DEBUGfd
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // DEBUG

    //Code begins
    int n;
    cin>>n;
    int a[n][2];
    ull sum = 0;
    for(int i = 0; i<n;i++)
{
  cin>>a[i][0]>>a[i][1];
   sum += a[i][1] - a[i][0] + 1;
}

cout<<sum<<endl;



    return 0;
}


Measured memory_bytes: 256
/*
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2")  //Enable AVX
*/
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define all(a) begin(a),end(a)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int mod=1e9+7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int mul(int a,int b){
  return ((a)*1ll*(b))%mod;
}

void add(int &a,int b){
  a+=b;
  if(a>=mod)a-=mod;
}

int sub(int a,int b){
  a-=b;
  if(a<0){
    a+=mod;
  }
  return a;
}

int powz(int a,int b){
  int res=1;
  while(b){
    if(b&1){
      res=mul(res,a);
    }
    b/=2;
    a=mul(a,a);
  }
  return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
  input>>x.F>>x.S;
  return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}

template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}

template<typename T>
vector<pair<T,int>> getvec(int n){
  vector<pair<T,int>>a(n);
  for(int i=0;i<a.size();i++){
    cin>>a[i].F;
    a[i].S=i;
  }
  return a;
}

const int N=200005;
ll A,B,C,D;

map<ll,ll>an;

ll rec(ll N){
  if(an.count(N)){
    return an[N];
  }
  if(N==0){
    return an[0]=0;
  }
  if(N==1){
    return an[N]=D;
  }
  ll ans=1e18*7;
  if(N*1.0*D<1e18){
    ans=N*1ll*D;
  }
  ans=min(ans,C+rec(N/5)+(N%5)*D);
  ans=min(ans,B+rec(N/3)+(N%3)*D);
  ans=min(ans,A+rec(N/2)+(N%2)*D);
  if(N%5)
  ans=min(ans,C+rec((N/5)+1)+(5-(N%5))*D);
  if(N%3)
  ans=min(ans,B+rec((N/3)+1)+(3-(N%3))*D);
  if(N%2)
  ans=min(ans,A+rec((N/2)+1)+(2-(N%2))*D);
  return an[N]=ans;
}

void solve(){
  an.clear();
  ll N;
  cin>>N>>A>>B>>C>>D;
  cout<<rec(N);
  
}

signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc=1;
  cin>>tc;
  for(int _=0;_<tc;_++){
    // cout<<"Case #"<<_+1<<": ";
    solve();
    if(_!=tc-1){
      cout<<'\n';
    }
  }
}



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

const int INF = 1'000'000'000;

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

  vector<int> h(n);
  for (int i = 0; i < n; ++i)
    cin >> h[i];

  vector<int> dp(n);
  dp[0] = 0;
  for (int i = 1; i < min(n, k); ++i) {
    dp[i] = abs(h[0] - h[i]);
  }

  for (int i = k; i < n; ++i) {
    dp[i] = INF;
    for (int j = 1; j <= k; ++j) {
      int x = i - j;
      if (x < 0)
        continue;
      int tmp = dp[x] + abs(h[x] - h[i]);
      dp[i] = min(dp[i], tmp);
    }
  }
  cout << dp.back() << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define _rep(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
#define ll long long
typedef std::pair<int,int> pii;
inline bool up(int&x,const int y){return x<y?x=y,1:0;}
inline bool down(int&x,const int y){return x>y?x=y,1:0;}
#define N 1000005
int fa[N],n,m;
std::set<int> s;
inline int ancestor(int x){return x==fa[x]?x:fa[x]=ancestor(fa[x]);}
int main(){
	std::ios::sync_with_stdio(0);
	std::cin>>n>>m;
	rep(i,1,n) fa[i]=i;
	rep(i,1,m){
		int u,v; std::cin>>u>>v;
		u=ancestor(u),v=ancestor(v);
		if(u!=v) fa[v]=u;
	}
	rep(i,1,n) s.insert(ancestor(i));
	std::cout<<(int)s.size()-1<<'\n';
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define x first
#define y second

#ifdef LOCAL
#include "/Users/swad/Desktop/CP/debug.h"
#endif

const int N = int(1e5) + 10;

int n;
int a[N], b[N];

int main() {
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif

	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d %d", &a[i], &b[i]);

	vector<pii> v(2 * n);
	for (int i = 1; i <= n; i++) {
		v[2 * (i - 1)] = make_pair(a[i], i);
		v[2 * (i - 1) + 1] = make_pair(b[i], i);
	}
	sort(v.begin(), v.end());

	vector<pii> p(n + 1);
	for (int i = 0; i < 2 * n; i++) {
		swap(p[v[i].y].x, p[v[i].y].y);
		p[v[i].y].y = i;
	}

	ll ans = LLONG_MAX;

	ll sum = 0LL;
	for (int i = 1; i <= n; i++) sum += a[i];
	ans = min(ans, sum);
	sum = 0LL;
	for (int i = 1; i <= n; i++) sum += b[i];
	ans = min(ans, sum);

	sum = 0LL;
	for (int i = 0; i < n - 2; i++) sum += v[i].x;
	for (int i = 1; i <= n; i++) {
		ll curr = sum + a[i] + b[i];
		if (p[i].x < n - 2) curr -= v[p[i].x].x, curr += v[n - 2].x;
		if (p[i].y < n - 1) curr -= v[p[i].y].x, curr += v[n - 1].x;
		ans = min(ans, curr);
	}

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

	return 0;
}

Measured memory_bytes: 3328
s = input()
a = int(s[:2])
b = int(s[2:])

def y(x):
    return 0<=x<=99
def m(x):
    return 0<x<=12

if 12<a and 12<b:
    print("NA")
elif a==0 and b==0:
    print("NA")
elif (12<a and b==0) or (a==0 and 12<b):
    print("NA")
elif m(a) and m(b):
    print("AMBIGUOUS")
elif y(a) and m(b):
    print("YYMM")
elif m(a) and y(b):
    print("MMYY")


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(){
  int N,T,ans=1001;
  cin >> N >> T;
  vector<int> c(N),t(N);
  
  for(int i=0;i<N;i++){
    cin >> c.at(i) >> t.at(i);
  }

  for(int i=0;i<N;i++){
    if(t.at(i)<=T){
      ans=min(c.at(i),ans);
    }
  }

  if(ans==1001){
    cout << "TLE" << endl;
  }
  else{
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int const NMAX = 1e5;
int v[1 + NMAX];

int main() {

  int n, pos = 1, p = 1e9, ans = 1e9;
  string bigG;
  cin >> n;
  cout << 1000 * (n / 500) + 5 * ((n % 500) / 5);
  return 0;
}


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

int bubbleSort(int A[], int N) {
  int sw = 0;
  bool flag = true;
  for (int i = 0; flag; i++) {
    flag = false;
    for (int j = N-1; j >= i+1; j--) {
      if (A[j] < A[j-1]) {
        swap(A[j], A[j-1]);
        flag = true;
        sw++;
      }
    }
  }
  return sw;
}

int main() {
  int A[100], N, sw;
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];

  sw = bubbleSort(A, N);

  for (int i = 0; i < N; i++) {
    if (i) cout << " ";
    cout << A[i];
  }
  cout << endl;
  cout << sw << endl;
}



Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin >> s;
  ll y = 0;
  y = stoll(s.substr(0,4));
  ll m = 0;
  m = stoll(s.substr(5,2));
  if((y == 2019 && m >= 5) || y >= 2020)cout << "TBD" << endl;
  else cout << "Heisei" << endl; 
}

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

int main(void){
    vector<int> x(5);
    for (int i = 0; i < 5; i++){
        cin >> x[i];
        if(x[i] == 0){
            cout << i+1 << endl;
            break;
        }
    }
}

Measured memory_bytes: 3592
def examA():
    S, W = LI()
    if S<=W:
        print("unsefe")
    else:
        print("safe")
    return

def examB():
    A, B, C, D = LI()
    while(True):
        C -= B
        if C<=0:
            print("Yes")
            break
        A -= D
        if A<=0:
            print("No")
            break
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int,readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examB()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 10104
<?php
fscanf(STDIN,"%d",$n);
for ($i=0; $i < $n; $i++)
	fscanf(STDIN, "%d %d",$a[$i][0],$a[$i][1]);
$result=0;
for($i=$n; $i > 0; $i--)
{
	if(($a[$i-1][0]+$result)%$a[$i-1][1]!=0)
		$result+=$a[$i-1][1]-(($a[$i-1][0]+$result)%$a[$i-1][1]);
}

echo($result);

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

using namespace std;

using ll = long long;


int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int a, b, c;
    cin >> a >> b >> c;
    for (int i = 0; i <= 1000 * 1000; i++) {
        if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
            cout << i << endl;
            return 0;
        }
        int ha = a / 2, hb = b / 2, hc = c / 2;
        a = hb + hc, b = ha + hc, c = ha + hb;
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys

# import itertools
# import math

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
INF = 10 ** 9

N, *H = map(int, read().split())
dp = [INF] * N
dp[0] = 0

for i in range(0, N):
    if i + 1 <= len(H)-1:
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i] - H[i + 1]))
    if i + 2 <= len(H) - 1:
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i] - H[i + 2]))

print(dp[N - 1])


Measured memory_bytes: 12356
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long X;
    cin >> X;
    for(long long A=-1000; A<=1000; A++){
      for(long long B=-1000; B<=1000; B++){
        if(X == pow(A, 5) - pow(B, 5)){
          cout << A << " " << B << endl;
          return 0;
        }
      }
    }
}

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

int main(){
 double a,b,ave;
  int c;
  cin >> a >> b;
  ave = (a+b)/2;
  c = (ave +1 -0.1)/1.0;
  cout << c << endl;
  
  }

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

int main()
{
    int i, n, input, sum, max, min;
    while (1) {
        cin >> n;
        if (n == 0) break;
        sum = 0;
        max = 0;
        min = 1000;
        for (i = 1; i <= n; i++) {
            cin >> input;
            sum += input;
            if (input > max) max = input;
            if (input < min) min = input;
        }
        cout << (sum - max - min) / (n - 2) << endl;
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.14159265
#define M 998244353 
#define inf 5e6
 
 int powerm(int x, unsigned int y, int p)  
{  
    int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
 
int power(int x, unsigned int y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y % 2 == 0) 
        return power(x, y / 2) * power(x, y / 2); 
    else
        return x * power(x, y / 2) * power(x, y / 2); 
} 
 
 
 int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
 
 int gcdExtended(int a, int b, int *x, int *y) 
{ 
    // Base Case 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    int x1, y1; // To store results of recursive call 
    int gcd = gcdExtended(b%a, a, &x1, &y1); 
  
    // Update x and y using results of recursive 
    // call 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
} 
 
int modInverse(int a, int m) 
{ 
    int x, y; 
    int g = gcdExtended(a, m, &x, &y); 
    if (g != 1) 
        cout << "Inverse doesn't exist"; 
    else
    { 
        // m is added to handle negative x 
        int res = (x%m + m) % m; 
        
        return res;
        //cout << "Modular multiplicative inverse is " << res; 
    } 
}

int vis[200001];

int  dps[200001];
int  dpt[200001];

int par[200001];
int tin[200001];
int tout[200001];
int t=0;
//int a[200001];

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

void dfs(int i,int p,vector<int>adj[],int &c)
{
        vis[i]=1;
        
        for(int j=0; j<adj[i].size();j++)
        {
                if(adj[i][j]==p)continue;
                int v=adj[i][j];
                
                if(vis[v]==1&&v!=p)
                {
                        c=1;
                }
                
                if(vis[v]==0)
                dfs(v,i,adj,c);
        }
}


struct setcmp {
bool operator() (int x, int  y) 
{
       
         
   return x<y;
         
 

}
};


const int maxn=5000001;

int isPrime[maxn];



void solve()
{

 int n;
 cin>>n;
 
  cout<<n+n*n+n*n*n;
  
 
 
}







int32_t  main()
{
       // ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	int qq=1;
       // cin>>qq;

 
	while(qq--)
	{
	        
       
       solve();
     
       cout<<"\n";
       
   
    
	}

   
      
  
}
     



 

Measured memory_bytes: 3608
N = int(input())
B = [int(x) - 1 for x in input().split()]
#  print('b', B)
ans = []
while B:
    popped = -1
    for i in reversed(range(len(B))):
        if B[i] == i:
            ans.append(i + 1)
            popped = B.pop(i)
            break
    if popped == -1:
        print(-1)
        quit()
print(*ans[::-1], sep="\n")


Measured memory_bytes: 3060
N = int(input())

a = list(map(int, input().split()))
b = []
for i in range(N):
    ans = 0
    odd = 0
    while odd == 0:
        if a[i] % 2 == 0:
            a[i] = int(a[i]/2)
            ans += 1
        else:
            odd += 1
    b += [ans]

print(min(b))

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

int main()
{
    ll n;
    cin>>n;
    ll ar[n+2];
    for(ll i=1;i<=n;i++)
        cin>>ar[i];
    ll sum=0;
    for(ll i=2;i<=n;i++)
    {
        if(ar[i-1]>ar[i])
        {
            sum+=(ar[i-1]-ar[i]);
            ar[i]=ar[i-1];
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 5164
#include <stdio.h>
#define MAX_LEN 100

void printArray(int *array, int len)
{
	for (int i = 0; i < len; i++)
	{
		printf("%d", array[i]);
		if (i != len - 1)
		{
			printf(" ");
		}
	}
	printf("\n");
}

int array[MAX_LEN];

int main()
{
	int len;
	scanf("%d", &len);
	for (int i = 0; i < len; i++)
	{
		scanf("%d", &array[i]);
	}

	printArray(array, len);

	for (int i = 1; i < len; i++)
	{
		int v = array[i];
		int j = i;
		while ((j > 0) && (array[j - 1] > v))
		{
			array[j] = array[j - 1];
			j--;
		}
		array[j] = v;
		printArray(array, len);
	}
}


Measured memory_bytes: 2688
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll A = 1, B = 1, a, b, n;std::cin >> n;
  re(i, n){
    std::cin >> a >> b;
    if(A%a!=0) A = A - A%a + a;
    if(B%b!=0) B = B - B%b + b;
    if(a>b){
      ld t = (ld)B/(ld)A, k = (ld)b/(ld)a;
      if(t>k){
        A = (B/b)*a;
      }else{
        B = (A/a)*b;
      }
    }else{
      ld t = (ld)A/(ld)B, k = (ld)a/(ld)b;
      if(t>k){
        B = (A/a)*b;
      }else{
        A = (B/b)*a;
      }
    }
  }
  std::cout << A + B << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string n;
	cin >> n;
	for(int i=0; i<n.length(); i++){
		if(n[i]=='7'){
			cout << "Yes";
			return 0;
		}
	}
	cout <<"No";
    return 0;
}

Measured memory_bytes: 3652
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return read.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtype!real;
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //
void solve(){
	int n = rint;
	(n * n * n).writeln;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define MAX 6000000
#define INFTY 1

int H,A[MAX+1];

void swap(int *a,int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
}

void maxHeapify(int i){
  int tmp,l,r,largest;
  l=2*i;
  r=2*i+1;
  if(l<=H && A[l]>A[i]){
    largest=l;
  }
  else {
    largest = i;
  }
  if(r<=H&& A[r]>A[largest]){
    largest=r;
  }
  if(largest !=i){
    swap(&A[i],&A[largest]);
    maxHeapify(largest);
  }
}

int extract(){
  int maxv;
  if(H<1){
    return -INFTY;
  }
  maxv=A[1];
  A[1]=A[H--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i,int key){
  int tmp;
  if(key<A[i]){
    return ;
  }
  A[i]=key;
  while(i>1&&A[i/2]<A[i]){
    swap(&A[i],&A[i/2]);
    i=i/2;
  }
}

void insert(int key){
  H++;
  A[H]=-INFTY;
  increaseKey(H,key);
}

int main(){
  int key;
  char com[10];
  while(1){
    scanf("%s",com);
    if(strcmp(com,"end")==0){
      break;
    }
    if(strcmp(com,"insert")==0){
      scanf("%d",&key);
      insert(key);
    }
    else{
      printf("%d\n",extract());
    }
  }
  return 0;
}

Measured memory_bytes: 4692
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>

void output(std::vector<std::vector<int>>& v)
{
	size_t size = v.size();
	for (auto num : v)
	{
		std::cout << num[0] << " " << num[1] << std::endl;
	}
}

int main()
{
	std::vector<std::vector<int>> numbers;
	std::vector<int> num(2);
	std::cin >> num[0] >> num[1];

	while (num[0] != 0 || num[1] != 0)
	{
		std::sort(num.begin(), num.end());
		numbers.push_back(num);
		std::cin >> num[0] >> num[1];
	}
	
	output(numbers);
	return 0;
}


Measured memory_bytes: 3232
#include <stdio.h>

int Comp(int *, int *, int, int);

int main(){
  int snm, tnm, i;
  int S[10000], T[500];

  scanf("%d", &snm);
  for(i=0; i<snm; i++){
    scanf("%d", &S[i]);
  }
  scanf("%d", &tnm);
  for(i=0; i<tnm; i++){
    scanf("%d", &T[i]);
  }

  printf("%d\n", Comp(S, T, snm, tnm));

  return 0;
}

int Comp(int *S, int *T, int snm, int tnm){
  int i, j, nm=0;
  
  for(i=0; i<tnm; i++){
    for(j=0; j<snm; j++){
      if(T[i] == S[j]){
	nm++;
	break;
      }
    }
  }

  return nm;
}


Measured memory_bytes: 2052
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.In.ReadLine();
            var x = int.Parse(input);
            if (x < 1 || 100 < x)
            {
                return;
            }

            var x3 = x * x * x;
            Console.WriteLine(x3);
        }
    }
}


Measured memory_bytes: 15928
#include<bits/stdc++.h>
using namespace std;
 
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define mp make_pair
#define mod 1000000007
#define qmod 998244353
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define mk make_pair 
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const ll LINF = LLONG_MAX;
const int MAX_V = 201;

int main(){
		int s,w;
		cin>>s>>w;
		if(s>w){
			cout<<"safe\n";
		}
		else if(w>=s){
			cout<<"unsafe\n";
		}

}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, k; cin >> n >> k;
	vi a(n); rep(i, n) cin >> a[i];
	vector<ll> s(n + 1);
	rep(i, n) s[i + 1] = s[i] + max(0, a[i]);
	
	ll ans = 0, tmp = s[n];
	for(int i = 0; i < n; i++){
		tmp += a[i];
		if(i < k - 1) continue;
		ans = max(ans, max(s[n], tmp) - s[i + 1] + s[i - k + 1]);
		tmp -= a[i - k + 1];
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <set>

int main() {
  std::string w;

  std::cin >> w;

  std::set<char> st;
  std::multiset<char> mst;
  for (const char ch : w) {
    st.insert(ch);
    mst.insert(ch);
  }

  for (const char ch2 : st) {
    std::size_t count = mst.count(ch2);
    if (count % 2 != 0) {
      std::cout << "No" << std::endl;
      return 0;
    }
  }
  std::cout << "Yes" << std::endl;
  return 0;
}

Measured memory_bytes: 256
import numpy as np
from collections import defaultdict
from functools import reduce

# s = input()
# n = int(input())
# A = list(map(int, input().split()))
p, q, r = map(int, input().split())

print(min(p+q, q+r, r+p))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res



Measured memory_bytes: 22284
#include<bits/stdc++.h>
using namespace std;
long long n,l,r,x,ans,a[200010],s[50];
map<long long,long long>v;
int main()
{
	scanf("%lld",&n);
	for (long long i=1;i<=n;i++) {
		scanf("%lld",&a[i]);
		v[a[i]]++;
	}
	s[0]=1;
	for (int i=1;i<=32;i++)
		s[i]=s[i-1]*2; 
	sort(a+1,a+n+1);
	for (long long i=n;i>=1;i--) {
        if (v[a[i]])  {
			l=0;
			r=32;
		    while (l<r) {
			   	int mid=(l+r)/2;
			   	if (s[mid]>a[i]) r=mid;
				else l=mid+1;
		    }
		    x=s[l]-a[i];
        	if (a[i]==x&&v[x]==1) continue;
        	if (v[x]) {
	        	ans++;
	        	v[x]--;
	        	v[a[i]]--;
			}
		}
	}
	printf("%lld",ans);
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[100005];
ll B[100005];

int main()
{
    ll N;
    cin >> N;
    REP(i, N)
    {
        cin >> A[i];
    }

    B[0] = A[0];
    FOR(i, N, 1)
    {
        B[i] = A[i] - B[i - 1];
    }
    B[N - 1] = B[N - 1] / 2;
    FOR(i, N, 1)
    {
        B[N - 1 - i] = A[N - i] - B[N - i];
    }

    REP(i, N)
    {
        cout << B[(i + N - 1) % N] * 2 << " ";
    }
    cout << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;

int main()
{
  char buf[1024] = { '\0' };
  while (fgets(buf, sizeof(buf), stdin) != NULL) {
    if (buf[0] == '0') { break; }
    int sum = 0;
    for (char* p = buf; isdigit(*p); ++p) {
      sum += (*p - '0');
    }
    fprintf(stdout, "%d\n", sum);
  }
  return 0;
}

Measured memory_bytes: 1112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
   ll ans=0,x;
   cin>>x;
   ans=x/11;
   ans*=2;
   x=x%11;
   if(x==0){
       cout<<ans<<endl;
   }
   else if(x<=6){
       cout<<ans+1<<endl;
   }
   else{
       cout<<ans+2<<endl;
   }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n,i;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        if(i%3==0){
            printf(" %d",i);
        }else if(i%10==3){
            printf(" %d",i);
        }else if((i/10)%10==3){
            printf(" %d",i);
        }else if((i/100)%10==3){
            printf(" %d",i);
        }else if ((i/1000)%10==3){
            printf(" %d",i);
        }if(i==n){
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 600
#include <cmath>
#include <vector>
#include <map>
#include <functional>
#include <queue>
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>

using namespace std;

#define ll long long int
#define ti4 tuple<int,int,int,int>
#define pii pair<ll,ll>
#define REP(x,n) for(int x = 0;x < n;x++)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

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

struct SimpleHash {
    size_t operator()(const std::pair<ll, ll>& p) const {
        return p.first * mod + p.second;
    }
};

ll gcd( ll a, ll b )
{
    ll c;
    while ( a != 0 ) {
        c = a; a = b%a;  b = c;
    }
    return b;
}

ll lcm( ll m, ll n )
{
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    
    return ((m / gcd(m, n)) * n);
}

int m[100000];

int main()
{
    Fill(m, -1);
    int n;
    cin >> n;
    int count = 0;
    for(int i = 1;i <= n;i++)
    {
        int t;
        cin >> t;
        if(t < i)
        {
            if(m[t] == i)
            {
                count++;
            }
        }
        m[i] = t;
    }
    cout << count << endl;
    
    return 0;
    
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < 3; i++) {
        if(s[i] == t[i]) ans ++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

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 N, M, C;
vector<int> B;
vector<vector<int>> A;

//解法
void solve() {

	ll ans = 0;

	rep(i, N) {
		ll sum = 0;

		rep(j, M) {
			sum += A[i][j] * B[j];
		}
		sum += C;

		if (sum > 0) ans++;

	}

	cout << ans;

	return;
}

int main() {

	//入力
	cin >> N>>M>>C;
	B.resize(M);
	rep(i, M) cin >> B[i];
	A.resize(N, vector<int>(M));
	rep(i, N) rep(j, M) cin >> A[i][j];

	solve();
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxn=1e6+5;
char buff[maxn];
int sum[maxn];
int main() {
    int n;cin>>n>>(buff+1);
    for(int i=1;i<=n;i++) sum[i]=sum[i-1]+(buff[i]=='R');
    int totw=n-sum[n];
    int ans=1e9;
    for(int i=1;i<=n;i++) {
    	int prew=i-1-sum[i-1];
    	int bacr=sum[n]-sum[i];
    	ans=min(ans,max(prew,bacr));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4616
n=int(input())
x=[0]*n
y=[0]*n
for i in range(n):
  x[i],y[i]=map(int, input().split())
d=0
for i,j in zip(x,y):
  for k,l in zip(x,y):
    m1,m2=i-k,j-l
    o=m1**2+m2**2
    d+=o**0.5
print(d/n)

Measured memory_bytes: 3064
while True:
    number = int(input())
    if number == 0:
        break
    point = [int(input()) for n in range(number)]
    point.sort() 
    point.pop(0) 
    point.pop(-1) 
    sumPoint = 0 
    numberSub = int(number) - 3
    while numberSub >= 0:
        sumPoint = sumPoint + int(point[numberSub - 1])
        numberSub = numberSub - 1
    average = sumPoint / (number -2)
    print (int(average))


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

#define ll long long
#define MAX 300005
#define pp pair<int,pair<int,int>>
#define pb push_back
#define mod 1000000007
using namespace std;

/*
 * author: Kruti_20
 */

ll power(ll x, ll y);

ll gcd(ll a, ll b);

string s, t;
int dp[3005][3005];

void pre() {
    for (int i = 1; i <= 3000; i++) {
        for (int j = 1; j <= 3000; j++) dp[i][j] = -1;
    }

}

int lcs(int x, int y) {
    if (dp[x][y] != -1) return dp[x][y];
    if (x < 0 || y < 0) return 0;
    else if (s[x - 1] == t[y - 1]) dp[x][y] = (1 + lcs(x - 1, y - 1));
    else dp[x][y] = max(lcs(x - 1, y), lcs(x, y - 1));
    return dp[x][y];
}

char L[MAX];

void print(int len) {
    int i = s.length(), j = t.length();
    int index = len;
    L[index] = '\0';
    while (i > 0 && j > 0) {
        if (s[i - 1] == t[j - 1]) {
            L[index - 1] = s[i - 1];
            i--, j--, index--;
        } else if (dp[i - 1][j] > dp[i][j - 1]) i--;
        else j--;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> s >> t;
    pre();
    int len = lcs(s.length(), t.length());
    print(len);
    int i = 0;
    while (L[i] != '\0') {
        cout << L[i];
        i++;
    }
    return 0;
}


ll power(ll x, ll y) {
    ll res = 1;
    x = x % mod;
    while (y > 0) {
        if (y & 1) res = (res * x) % mod;
        y = y >> 1;
        x = (x * x) % mod;
    }
    return res;
}

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}


Measured memory_bytes: 35968
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void a_number_of_multiples(void) {
	int l, r, d;
	cin >> l >> r >> d;
	int cnt = 0;
	for (int i = l; i <= r; i++) {
		if (i % d == 0)cnt++;
	}
	cout << cnt << endl;
}


int main()
{
	a_number_of_multiples();
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <queue>
#include <vector>

using namespace std;
typedef pair<int,int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
#define REP(i,n) for (int i = 0; i < n; ++i)
#define PB push_back
#define MP make_pair

const int MAX = 2e5+10;

int H, W, N;
int sr, sc;
string S, T;

bool check(char incr, char decr, int len, int max) {
    REP (i, N) {
        if (S[i] == decr) {
            len--;
            if (len == 0) return true;
        }
        if (T[i] == incr && len < max) len++;
    }
    return false;
}

int main() {
    cin >> H >> W >> N >> sr >> sc >> S >> T;

    bool ans = false;
    ans |= check('L', 'R', W-sc+1, W);
    ans |= check('R', 'L', sc, W);
    ans |= check('U', 'D', H-sr+1, H);
    ans |= check('D', 'U', sr, H);

    if (ans) cout << "NO" << endl;
    else cout << "YES" << endl;
}

Measured memory_bytes: 776
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


int main() {
	
	ll N;
	cin >> N;
	vll A(N), B(N + 1, 0);
	rep(i, N) cin >> A[i];
	ford(i, 0, N) {
		if (A[i] == 0) B[i] = B[i + 1] + 1;
	}

	ll ans = 0;
	rep(i, N) {
		ll j = i, xr = 0, sum = 0, tmp = 0;
		while(j < N) {
			if (B[j] != 0) {
				tmp += B[j];
				j += B[j];
			}
			else {
				xr ^= A[j]; sum += A[j];
				if (xr == sum) ++tmp;
				else break;
				++j;
			}
		}
		ans += tmp;
	}
	cout << ans << endl;
}

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

int main(){
    using namespace std;
    int n;
    cin >> n;
    vector<int> s(n);
    for(int i = 0; i < n; i++) cin >> s.at(i);
    int q;
    cin >> q;
    vector<int> t(q);
    for(int i = 0; i < q; i++) cin >> t.at(i);

    int res = 0;
    for(int i = 0; i < q; i++){
        for(int j = 0; j < n; j++){
            if(t.at(i) == s.at(j)){
                res++;
                break;
            }
        }
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define   pb  push_back
queue<int>q;
int main()
{
    int i,j,n,m,x,y,f,mx=0;
    cin>>n>>m;
    int ind[n+2],dp[n+2];
    vector<int>v[n+2];
    memset(ind,0,sizeof(ind));
    memset(dp,0,sizeof(dp));
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        v[x].pb(y);
        ind[y]++;
    }
    for(i=1;i<=n;i++)
    {
        if(ind[i]==0)
        {
            q.push(i);
        }
    }
    while(!q.empty())
    {
        f=q.front();
        q.pop();
        x=v[f].size();
        for(i=0;i<x;i++)
        {
            y=v[f][i];
            dp[y]=max(dp[y],1+dp[f]);
            mx=max(mx,dp[y]);
            ind[y]--;
            if(ind[y]==0)
            {
                q.push(y);
            }
        }
    }
    cout<<mx<<"\n";
    return 0;
}



Measured memory_bytes: 6528
#pragma GCC optimize("O3")

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <assert.h>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <random>
#include <cmath>
#include <chrono>
#include <bitset>

#define ld long double
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;

const int INF = 2e18;
const int MOD = 1e9 + 7;
const int MB = 20;

void solve() {
	int n;
	cin >> n;
	vector<vector<int>> a(n, vector<int>(n - 1));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n - 1; j++) {
			cin >> a[i][j];
			a[i][j]--;
		}
	}

	vector<int> id(n);
	vector<int> now(n);
	for (int i = 0; i < n; i++) {
		now[i] = a[i][0];
	}

	queue<pair<pair<int, int>, int>> q;
	int res = 0;
	for (int i = 0; i < n; i++) {
		if (now[i] > i && now[now[i]] == i) {
			q.push({ { i, now[i] }, 1 });
		}
	}

	int ans = 0;
	while (!q.empty()) {
		auto pp = q.front();
		auto p = pp.first;
		q.pop();
		id[p.first]++;
		id[p.second]++;
		ans = max(ans, pp.second);
		res++;
		if (id[p.first] != n - 1) {
			now[p.first] = a[p.first][id[p.first]];
		}
		if (id[p.second] != n - 1) {
			now[p.second] = a[p.second][id[p.second]];
		}
		if (id[p.first] != n - 1 && now[now[p.first]] == p.first) {
			q.push({ { now[p.first], p.first }, pp.second + 1 });
		}
		if (id[p.second] != n - 1 && now[now[p.second]] == p.second) {
			q.push({ { now[p.second], p.second }, pp.second + 1 });
		}
	}

	cout << (res == n * (n - 1) / 2 ? ans : -1);
}
signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(12);
	solve();
}

Measured memory_bytes: 8192
#include<stdio.h>
#include<limits.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,m[100][100];

int prim(){
  int i,j,u,min;
  int d[100],p[100],color[100];
  for(i=0;i<n;i++){
    d[i]=INT_MAX;
    p[i]=-1;
    color[i]=WHITE;
  }
  d[0]=0;

  while(1){
    min=INT_MAX;
    u=-1;
    for(i=0;i<n;i++){
      if(min>d[i]&&color[i]!=BLACK){
	u=i;
	min=d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
    for(j=0;j<n;j++){
      if(color[j]!=BLACK&&m[u][j]!=INT_MAX){
	if(d[j]>m[u][j]){
	  d[j]=m[u][j];
	  p[j]=u;
	  color[j]=GRAY;
	}
      }
    }
  }
  int sum=0;
  for(i=0;i<n;i++){
    if(p[i]!=-1)sum+=m[i][p[i]];
  }
  return sum;
}

int main(){
  int i,j,e;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      m[i][j]=(e==-1)?INT_MAX:e;
    }
  }
  printf("%d\n",prim());
  return 0;
}
    



Measured memory_bytes: 2048
#include <stdio.h>
#include <math.h>
#include <string.h>
int main(void) {
	int N;
	scanf("%d", &N);
	int p[10];
	int max = 100;
	int sum = 0;
	int count = 0;
	for (int i = 0; i < N; i++) {
		scanf("%d", &p[i]);
		if (p[i] > max) max = p[i];
	}

	for (int i = 0; i < N; i++) {
		if (p[i] == max&&count==0) {
			count++;
			sum += max / 2;
			p[i] = 0;
		}
		sum += p[i];
	}
	printf("%d\n", sum);

	return 0;

}

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

int main() {
  string S;
  cin >> S;
  size_t len = S.length();

  long total{};
  for (size_t i{}; i < (1 << len-1); ++i) {
    long acc{S[0] & 0xF};
    for (int j{}; j < len-1; ++j) {
      if (i & (1 << j)) {
        total += acc;
        acc = 0;
      }
      acc *= 10;
      acc += S[j+1] & 0xF;
    }
    total += acc;
  }

  cout << total << endl;
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;

int main(){
	int A, B, C;
	cin >> A >> B >> C;
	if(A < C && C < B) cout << "Yes" << endl;
	else if(B < C && C < A) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,k = na()

if k == 1:
    print(0)
else:
    print(n-k)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N=200010;
long long A[N],B[N],s; 
int n;
void solve(){
    s=0;
    for(int i=0;i<n;i++)scanf("%lld",&A[i]),s+=A[i];
    for(int i=0;i<n-1;i++)B[i]=A[i+1]-A[i];
    B[n-1]=A[0]-A[n-1];
    long long t=(long long)n*(n+1)/2;
    if(s%t){puts("NO");return;}
    s/=t; long long cnt=0;
    for(int i=0;i<n;i++){
        if((s-B[i])%n||s-B[i]<0){puts("NO");return;}
        cnt+=(s-B[i])/n;
    }if(cnt!=s){puts("NO");return;}
    puts("YES");
}
int main(){
    while(~scanf("%d",&n))solve();
    return 0;
}

Measured memory_bytes: 1664