akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define forn(i, n) for(int i=0;i<(int)(n);i++)
#define for1(i, n) for(int i=1;i<=(int)(n);i++)
#define fore(i, l, r) for(int i=(int)(l);i<=(int)(r);i++)
#define ford(i, n) for(int i=(int)(n)-1;i>=0;i--)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"
#define MAX 1000000007
using namespace std;
typedef int64_t ll;
typedef vector<int> vi;
typedef vector<int64_t> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
int cost;
int h[100001];
vector<int> dp(100001,-1);
int f(int i,int n,int k){
	int mn=INT_MAX;

	//cout<<i;
if(i==n)
return 0;
if(dp[i]!=-1) return dp[i];
for(int l=1;l<=k;l++){
if(i+l<=n){
cost=abs(h[i+l]-h[i])+f(i+l,n,k);
mn=min(mn,cost);
}
}
return dp[i]=mn;}
int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
	cin>>h[i];
	}
int ans=f(1,n,k);
cout<<ans;
	return 0;
}



Measured memory_bytes: 13376
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  string s;
  cin >> s;
  int ans = 0;
  int n = s.size();

  for (int i = 0; i < n / 2; i ++) {
    if (s[i] != s[n - 1 - i]) ans ++;
  }

  cout << ans << endl;
}

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


public class MyProgram
{	
  
    public static void Main()
	{
        int[] n = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int N = n[0];
        int K = n[1]-1;
        
        int[] trees = new int[N];
        for(int i = 0 ; i < N ; i++)
        {
            trees[i] = int.Parse(Console.ReadLine());
        }
        Array.Sort(trees);
        
        int min = 999999999;
        int height = 0;
        for(int i = 0 ; i < N - K ; i++)
        {
            height = trees[i+K] - trees[i];
            min = Math.Min(height, min);
        }
        
        Console.WriteLine(min);        
    }
    
}

Measured memory_bytes: 17632
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)
//typedef pair < int, int> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> divnum(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
int digiter(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p.size();
}
vector<int> convertstring(string s) {
	vector<int> d;
	ll n = s.size();
	rep(i, n) {
		d.push_back(s[i] - '0');
	}
	return d;
}
map< int64_t, int > prime_factor(int64_t n) {
	map< int64_t, int > ret;
	for (int64_t i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}
vector<ll> divisor(ll n) {
	vector<ll>res;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i != 0)continue;
		res.push_back(i);
		if (i * i != n)res.push_back(n / i);
	}
	return res;
}

int N;
int main()
{
	cin >> N;
	ll ans = 0;
	rep(i, N) {
		if ((i + 1) % 3 == 0 || (i + 1) % 5 == 0) {

		}
		else {
			ans += ll(i+1);
		}
	}
	cout << ans << endl;
	
	
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define MOD 1000000007

using namespace std;

#define N 1000005

ll fact[1000005];
ll inv[N];

ll powa(ll a, ll b, ll c)
{
    a%=c;
    ll res = 1;
    while(b>0)
    {
        if(b&1)
            res*=a, res%=c;
        a*=a, a%=c;
        b>>=1;
    }
    return res;
}

ll arr(ll a, ll b)
{
    ll temp = fact[a+b];
    temp*=(inv[a]*inv[b])%MOD;
    temp%=MOD;
    return temp;
}

int main()
{
   FAST/**/
   
   ll x,y;
   cin>>x>>y;
   fact[0] = 1;
   for(ll i=1;i<N;i++)
        fact[i] = (fact[i-1]*i)%MOD;
   
   for(ll i=0;i<N;i++)
        inv[i] = powa(fact[i],MOD-2,MOD);
   
   if((x+y)%3 != 0)
   {
       cout<<0;
       return 0;
   }
   
   ll lam = (x+y)/3;
   ll ans = 0;
   for(ll i=0;i<=min((x/2),lam);i++)
   {
       ll c1 = i;
       ll c2 = lam - i;
       if(c1*2 + c2 != x)
            continue;
       ans+=arr(c1,c2);
       ans%=MOD;
   }
   
   cout<<ans<<"\n";
   
   return 0;
}  
   

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

using namespace std;
using LL = long long;
const int N = 1024 + 4000;
const int INF = 1E9;
const double EPS = 1E-9;

int a[N];
int r[N], g[N], b[N];
int r1[N], g1[N], b1[N];
int n, m;
string s;
int *get(char c) {
    if (c == 'R') {
        return r;
    } else if (c == 'G') {
        return g;
    } else {
        return b;
    }
}

int *get1(char c) {
    if (c == 'R') {
        return r1;
    } else if (c == 'G') {
        return g1;
    } else {
        return b1;
    }
}

int f(int i, char u,  char w) {
    int res = 0;
    int l = 0, r = 0;
    if (i > 0) {
        l = get(u)[i - 1];
    }
    if (i < n - 1) {
        r = get1(w)[i + 1];
    }
    res += l * r;
    if (res == 0)return 0;
    for (int j = 1; j < n; ++j) {
        if (!(i - j >= 0 && i + j < n)) {
            break;
        }
        if (s[i - j] == u && s[i + j] == w) {
            res -= 1;
        }
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);

#ifdef CF_DEBUG
    freopen("../cf/input.txt", "r", stdin);
#endif
    cin >> n;
    cin >> s;

    for (int i = 0; i < n; ++i) {
        char c = s[i];
        string v="RGB";
        for (auto u:v) {
            if (u == c) {
                get(u)[i] = i == 0 ? 1 : get(u)[i - 1] + 1;
            } else {
                get(u)[i] = i == 0 ? 0 : get(u)[i - 1];
            }
        }
    }
    for (int i = n - 1; i >= 0; i--) {
        char c = s[i];
        string v="RGB";
        for (auto u:v) {
            if (u == c) {
                get1(u)[i] = i == n - 1 ? 1 : get1(u)[i + 1] + 1;
            } else {
                get1(u)[i] = i == n - 1 ? 0 : get1(u)[i + 1];
            }
        }
    }
    LL res = 0;
    for (int i = 1; i < n - 1; ++i) {
        string v = "BGR";
        do {
            if (v[1] != s[i]) continue;
            res += f(i, v[0], v[2]);
        } while (next_permutation(v.begin(), v.end()));
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 3704
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	final int N = 10000001;
	boolean prime[];
	LinkedList<Integer> maxp;
	int[] p4;
	
	void run() {
		Scanner sc = new Scanner(System.in);
		prime = new boolean[N];
		maxp = new LinkedList<Integer>();
		prime();
		for(;;) {
			int val = sc.nextInt();
			if(val == 0) break;
			int l = 0; int r = p4.length-1;
			while(l<=r) {
				int c = (l + r) / 2;
				if( p4[c] < val ) l = c+1;
				else if(p4[c] > val) r = c-1;
				else {
					l = c;
					break;
				}
			}
//			debug(p4);
			if(l>p4.length-1)System.out.println(p4[r]);
			else if(r<0) System.out.println(p4[l]);
			else System.out.println(min(p4[l],p4[r]));
		}
		
	}
	
	void prime() {
		prime[0] = prime[1] = true;
		for(int i=2;i<N;i++) if(!prime[i]){
			if(i-8>=0 && (!prime[i-8] && !prime[i-6] && !prime[i-2])) {
				maxp.add(i);
//				debug(i);
			}
			for(int j=i*2;j<N;j+=i) prime[j] = true;
		}
		p4 = new int[maxp.size()];
		int size = maxp.size();
		for(int i=0;i<size;i++) p4[i] = maxp.removeFirst();
		
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

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

int main()
{
  string a, g, b;
  cin >> a >> g >> b;

  string agb = a + g + b;

  int num = stoi(agb);

  if (num % 4 == 0)
    cout << "YES" << endl;
  else 
    cout << "NO" << endl;

}


Measured memory_bytes: 256
def method_name(n, ai)
  max = ai.max
  cnt = ai.count(max)
  size = ai.size

  if cnt == 1
    max_index = ai.index(max)
    for i in 0..size-1
      if i == max_index
        bi = ai.clone
        bi[max_index] = 0
        puts bi.max
      else
        puts max
      end
    end
  else
    size.times{puts max}
  end
end

n = gets.chomp.to_i
ai = []
n.times{ai << gets.chomp.to_i}
method_name(n, ai)

Measured memory_bytes: 7036
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int a[N];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		int num;
		cin>>num;
		a[num]=i;
	}
	for(int i=1;i<n;i++){
		cout<<a[i]<<" ";
	}
	cout<<a[n]<<endl;
}


Measured memory_bytes: 1152
#include <stdio.h>

#define N 100

int main(){
    int n, i, j, num[N], tmp, cnt = 0, min, flg;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        scanf("%d", &num[i]);
    }
    
    for (i = 0; i < n; i++) {
        flg = 0;
        min = i;
        for (j = i; j < n; j++) {
            if (num[j] < num[min]) {
                min = j;
                flg = 1;
            }
        }
        tmp = num[i];
        num[i] = num[min];
        num[min] = tmp;
        if (flg) cnt++;
    }
    
    for (i = 0; i < n - 1; i++) {
        printf("%d ", num[i]);
    }
    printf("%d\n%d\n", num[i], cnt);
    return 0;
}



Measured memory_bytes: 2104
url = "https://atcoder.jp//contests/abc157/tasks/abc157_c"

def main():
    n, m = list(map(int, input().split()))
    cond = {}

    for i in range(m):
        s, c = list(map(int, input().split()))
        if s in cond and cond[s] != c:
            cond[s] = -1
        else:
            cond[s] = c

    for i in range(0, 1000):
        if len(str(i)) != n:
            continue
        flg = True
        for key in cond:
            if int(str(i)[key - 1]) != cond[key]:
                flg = False
                break
        if flg:
            print(i)
            exit()
    print(-1)




if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
n = int(input())
s = input()

ans = float("inf")

r_b = s.count("#")
r_w = s.count(".")

l_b,l_w = 0,0

ans = min(ans,l_b + r_w)

for i in range(n):
  if s[i] == "#":
    r_b -= 1
    l_b += 1
  else:
    r_w -= 1
    l_w += 1

  ans = min(ans,l_b + r_w)

print(ans)

Measured memory_bytes: 3500
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<random>
using namespace std;

//fixed << setprecision(10)
#define Yes(a) a ? "Yes" : "No";
#define YES(a) a ? "YES" : "NO";
#define rep(i,n) for(int i=0;i<n;i++)

int gcd(int a,int b) {
	if (a < b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

map<int, int> prime;
void Prime(long long int n) {
	for (int i = 2; i <= n; i++) {
		int count = 0;
		while (n % i == 0) {
			count++;
			n /= i;
		}
		if (count != 0) {
			prime.insert(make_pair(i, count));
		}
	}
}

int main() {
	int n, s = 0;
	cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a.at(i);
		s += a.at(i);
	}
	int ans = 0;
	rep(i, n) {
		ans += a.at(i) * (s - a.at(i));
	}
	cout << ans / 2 << endl;

}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void MAIN() {
  int n; cin >> n;
  vector<int> a(n + 2);
  a[0] = a[n + 1] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int s = 0;
  for (int i = 1; i <= n + 1; i ++) {
    s += abs(a[i] - a[i - 1]);
  }
  for (int i = 1; i <= n; i++) {
    int t = s - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]);
    cout << t << '\n';
  }
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3992
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	ll k;
	cin >> n >> k;
	vector<int> p(n);
	rep(i,n){
		cin >> p[i];
		--p[i];
	}
	vector<ll> c(n);
	rep(i,n) cin >> c[i];
	ll ans = -INF;
	rep(i,n){
		vector<int> loop;
		int cur = i;
		ll sum = 0;
		while(true){
			cur = p[cur];
			loop.push_back(c[cur]);
			sum += c[cur];
			if(cur == i) break;
		}
		ll sz = loop.size();
		ll score = 0;
		rep(j,sz){
			score += loop[j];
			if(k <= j) break;
			ll cmp = score;
			if(sum >= 0) cmp += sum * ((k - (j+1)) / sz);
			chmax(ans, cmp);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3788
n,q=[int(i) for i in input().split()]
s=input()


dp=[0]*(n)
ans=0
for i in range(1,n):
    if s[i-1]=="A" and s[i]=="C":
        ans=ans+1
    dp[i]=ans

for i in range(q):
    l,r=[int(i) for i in input().split()]
    print(dp[r-1]-dp[l-1])


Measured memory_bytes: 11616
#include<bits/stdc++.h>
using namespace std;
int n;
int d, x;
int a[110];

int main() {
	cin >> n;
	cin >> d >> x;
	int ans = 0;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	for (int i = 1; i <= n; ++i) {
		int j = 1;
		while (j <= d) {
			++ans;
			j += a[i];
		}
	}
	ans += x;
	cout << ans << endl;
	return 0;
}


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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

int main() {
    fast_io;
    int x,y;
    cin>>x>>y;

    string ans;
    ans="No";
    for(int i=1;i<=x;i++) {
        int b;
        b=x-i;

        if((b*4+i*2)==y||(b*2+i*4)==y) {
            ans="Yes";
            break;
        }
    }

    cout<<ans<<endl;
}




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

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

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

#define dump(...) do { \
    fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
    _dump(#__VA_ARGS__, __VA_ARGS__); \
} while (0)

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T, size_t N>
ostream& operator <<( ostream &s, const array<T,N> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
#else
#define dump(...)
#endif

template<typename T>
void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( long long &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }

void R() {}
template<typename T, typename... U>
void R( T& head, U&... tail ) {
    _R(head);
    R(tail...);
}

template<typename T>
void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
template<typename T>
void _W( const vector<T> &x ) {
    for ( auto i=x.cbegin(); i!=x.cend(); i++ ) {
        if ( i!=x.cbegin() ) putchar(' ');
        _W(*i);
    }
}

void W() {}
template<typename T, typename... U>
void W( const T& head, const U&... tail ) {
    _W(head);
    putchar(sizeof...(tail)?' ':'\n');
    W(tail...);
}

#ifdef SHIK
#define FILEIO(...)
#else
#define FILEIO(name) do {\
    freopen(name ".in","r",stdin); \
    freopen(name ".out","w",stdout); \
} while (0)
#endif

// }}}

const int N=1e5+10;
int n;
LL a[N];

bool chk( int m ) {
    LL s=0;
    REP1(i,1,n) {
        if ( i>m && a[i]>s*2 ) return 0;
        s+=a[i];
    }
    return 1;
}

int main() {
    R(n);
    REP1(i,1,n) R(a[i]);
    sort(a+1,a+n+1);
    int l=1,r=n;
    while ( l!=r ) {
        int m=(l+r)/2;
        if ( chk(m) ) r=m;
        else l=m+1;
    }
    int ans=n-l+1;
    W(ans);
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

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

  vector<int> p(m), y(m);
  vector<vector<int>> data(n);
  for (int i = 0; i < m; i++) {
    cin >> p[i] >> y[i];
    p[i]--;
    data[p[i]].push_back(y[i]);
  }

  for (int i = 0; i < n; i++) {
    sort(data[i].begin(), data[i].end());
  }

  for (int i = 0; i < m; i++) {
    int x = lower_bound(data[p[i]].begin(), data[p[i]].end(), y[i]) -
            data[p[i]].begin() + 1;
    printf("%06d%06d\n", p[i]+1, x);
  }

  return 0;
}

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

using namespace std;


int main()
{
    int A,B;
	cin >> A >> B;

    if(A >= 13)
    {
        cout << B << endl;
    }else if(A >= 6 && A <= 12)
    {
        cout << B/2 << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;

}

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

const int MAX_N = 200000;
int k, n;
int a[MAX_N];

void solve() {
    int d[n], drev[n];
    d[0] = a[n - 1] - a[0];
    for (int i = 1; i < n; i++) {
        d[i] = k - a[i] + a[i - 1];
    }

    drev[n - 1] = a[n - 1] - a[0];
    for (int i = 0; i < n - 1; i++) {
        drev[i] = k - a[i + 1] + a[i];
    }

    sort(d, d + n);
    sort(drev, drev + n);

    cout << min(d[0], drev[0]) << endl;
}

int main() {
    cin >> k >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    solve();
}

Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int h, w, a, b;

int main()
{
    cin >> h >> w >> a >> b;
    for (int i = 1; i <= b; i++)
    {
        for (int j = 1; j <= a; j++) cout << 1;
        for (int j = a + 1; j <= w; j++) cout << 0;
        cout << endl;
    }
    for (int i = b + 1; i <= h; i++)
    {
        for (int j = 1; j <= a; j++) cout << 0;
        for (int j = a + 1; j <= w; j++) cout << 1;
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1280
/*
    And I know I may end up failing too
*/




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

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

#define dbg          cout<<"Freak"<<endl;
#define dbgg(i)      cout<<i<<endl;
#define N            1e9+7
#define pb           push_back
#define pf           push_front
#define pi           acos(-1)
#define all(x)       x.begin(),x.end()
#define fast         ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define INF          0x3f3f3f3f

struct hash_pair
{
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1> {}(p.first);
        auto hash2 = hash<T2> {}(p.second);
        return hash1 ^ hash2;
    }
};



ll t;
string ss,tt,ans;
ll dp[3005][3005];

ll solve(ll m,ll n)
{
    if(m<=0||n<=0)return 0;
    if(ss[m-1]==tt[n-1])
    {
        if(dp[m][n]==-1)dp[m][n]=1+solve(m-1,n-1);
        return dp[m][n];
    }
    else
    {
        if(dp[m-1][n]==-1)dp[m-1][n]=solve(m-1,n);
        if(dp[m][n-1]==-1)dp[m][n-1]=solve(m,n-1);
        return dp[m][n]=max(dp[m][n-1],dp[m-1][n]);
    }
}
ll d1[]={-1,-1,0};
ll d2[]={0,-1,-1};
void dfs(ll m,ll n,ll k)
{
    ll a,b,i,j;
    if(k==0)return;
    if(ss[m-1]==tt[n-1])
    {
        ans+=ss[m-1];
        dfs(m-1,n-1,k-1);
    }
    else
    {
        if(dp[m-1][n]>dp[m][n-1])
        {
            dfs(m-1,n,k);
        }
        else dfs(m,n-1,k);
    }
}


int main()
{
    fast;
    ll a,b,c,d,e,f,g,i,j;
    ll n,k;
    memset(dp,-1,sizeof(dp));
    cin>>ss>>tt;
    a=ss.size();
    b=tt.size();
    f=solve(a,b);
    d=1;
    /*for(i=0;i<=a;i++)
    {
        for(j=0;j<=b;j++)
        {
            cout<<dp[i][j]<<' ';
        }
        cout<<endl;
    }*/
    dfs(a,b,f);
    for(i=f-1;i>=0;i--)
    {
        cout<<ans[i];
    }
    cout<<endl;
}


Measured memory_bytes: 71040
#include<stdio.h>
#include<math.h>

int main(){
	int num;
	int ans=0;
	int i,j,k;
	int box[100000];
		
	while(scanf("%d",&num)!=EOF){
		
		for(i=2;i<=80000;i++)box[i]=1;
		
		for(i=2;i<=sqrt(80000);i++){
			if(box[i]==1){
				for(j=2;i*j<=80000;j++){
					box[i*j]=0;
				}
			}
		}
		
		
		for(i=num-1;i>=0;i--)if(box[i]==1){
			printf("%d ",i);
			break;
		}
		for(i=num+1;i<=80000;i++)if(box[i]==1){
			printf("%d\n",i);
			break;
		}
		ans=0;
	}
	return 0;
}

Measured memory_bytes: 916
#include<bits/stdc++.h>
using namespace std;
# define pb push_back
# define FOR(i,a,n) for(int i=a;i<n;i++)
# define mp make_pair
# define RFOR(i,a,n) for(int i=n;i>a;i--)
# define pii pair<long long int,long long int>
#define ub upper_bound
#define lb lower_bound
#define MOD 1000000007
typedef long long int ll;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
        cout.tie(0);
	string s,t;
	cin>>s>>t;
	ll n=s.size();
	ll cnt=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]!=t[i])
		cnt++;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 3816
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <set>
#include <queue>
#include <cstdio>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
#define lrep(i, n) for(long long i=0;i<n;i++)
typedef long long ll;
typedef vector<long long> llv;
typedef vector<vector<long long> > llvv;
#define MAX 100000

int parent(int i){return i/2;}
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}

int main(){
    int H, i, A[MAX+1];
    cin >> H;
    for (int i=1;i<=H;i++) cin >> A[i];
    // rep(i,H) cout << A[i];

    for (i=1;i<=H;i++){
        cout << "node " << i << ": key = " << A[i] << ", ";
        if (parent(i) >= 1) cout << "parent key = " << A[parent(i)] << ", ";
        if (left(i) <= H) cout << "left key = " << A[left(i)] << ", ";
        if (right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
        cout << endl;
    }
}


Measured memory_bytes: 3088
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define N 200100
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
int a[N],n,m;
int main()
{
	n=read(),m=read();
	for(int i=1;i<=2*n;i++)	a[i]=read();
	sort(a+1,a+2*n+1);
	int l=0,r=n,ans=0;
	while(l<=r)
	{
		int mid=l+r>>1; bool tag=1;
		for(int i=1;i<=n-mid;i++)	tag&=(a[mid*2+i]+a[2*n-i+1]>=m);
		if(tag)	r=mid-1,ans=mid;
		else	l=mid+1;
	}
	int fin=0;
	for(int i=1;i<=ans;i++)	fin=max(fin,a[i]+a[ans*2-i+1]);
	for(int i=1;i<=n-ans;i++)	fin=max(fin,a[ans*2+i]+a[2*n-i+1]-m);
	printf("%d\n",fin);
	return 0;
}

Measured memory_bytes: 896
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        a: isize,
        b: isize,
    };

    let res = (a + b).max(a - b).max(a * b);
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2212
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
int main()
{
  int n,m; cin >> n >> m;
  int inf = 1e+9+10;
  vector<vector<int>> edge(n, vector<int>(n, inf));
  vector<int> a(m),b(m),c(m);
  rep(i,m) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--; b[i]--;
    edge[a[i]][b[i]] = c[i];
    edge[b[i]][a[i]] = c[i];    
  }

  rep(k,n){
    rep(i,n){
      rep(j,n){
	edge[i][j]=min(edge[i][j],edge[i][k]+edge[k][j]);
      }
    }
  }
  
  int res = 0;
  rep(i,m) {
    if(edge[a[i]][b[i]] != c[i]) res++;
  }
  cout << res << "\n";
  
  return 0;
}


Measured memory_bytes: 3660
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
satisfaction = 0
for i in range(len(a)):
    if i == 0:
        satisfaction += b[a[i]-1]
    else:
        satisfaction += b[a[i]-1]
        if a[i] == a[i-1]+1:
            satisfaction += c[a[i-1]-1]
print(satisfaction)

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, K;
int A[220000];
signed main() {
    cin >> N >> K;
    reps(i, N) {
        cin >> A[i];
        A[i]--;
    }
    map<int, int> mp;
    mp[0] = 1;
    int ans = 0;
    reps(i, N) {
        A[i] += A[i - 1];
        A[i] %= K;
        if (i >= K) { mp[A[i - K]]--; }
        ans += mp[A[i]];
        mp[A[i]]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
     
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
     
using namespace std;
     
typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <ll> vll;
     
int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int a, b;
  cin >> a >> b;
  string s(a, char(b + '0'));
  string t(b, char(a + '0'));
  (s < t) ? cout << s << '\n' : cout << t << '\n';
  return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d;
    
    cin>>a>>b>>c>>d;
    
    cout<<max(0,min(b,d)-max(a,c))<<endl;
    
   
    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int d[] = new int[N];
		for(int i = 0; i < N; i++){
			d[i] = stdIn.nextInt();
		}
		int ans = 0;

		for(int i = 0; i < N; i++){
			for(int j = i + 1; j < N; j++){
				ans += d[i] * d[j];
			}
		}
		System.out.println(ans);

		stdIn.close();
	}
}


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

int main(){
	int co,a = 0,b = 0,ab = 0,o = 0,i,tmp;
	string str;
	while(cin>>str){
		for(i = 2;i < str.size();i++){
				if(str[i] == 'A'){
					if(str[i+1]=='B'){
						tmp = 2;
						break;
					}
					else
						tmp = 0;
						break;
				}
				else if(str[i] == 'B')
					tmp = 1;
				else
					tmp = 3;
		}
		if(tmp == 0){
			a++;
		}
		else if(tmp == 1){
			b++;
		}
		else if(tmp == 2){
			ab++;
		}
		else{
			o++;
		}
	}
	cout<<a<<endl;
	cout<<b<<endl;
	cout<<ab<<endl;
	cout<<o<<endl;
	return 0;
}

Measured memory_bytes: 1180
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if((a+b)==c||(b+c)==a||(c+a)==b) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 4352
import sys

def lunlun(n0, n,m):
    ans = list()

    if (n<n0 and m-1>=0) :    
        ans.append(m-1)
    ans.append(m)
    if n<n0 and m+1<=9:
        ans.append(m+1)

    if (n==1):
        return ans
    else:
        ans2=list()
        for i in ans:
            ans1=lunlun(n0, n-1, i)
            for j in ans1:
                ans2.append(str(i)+str(j))
        return ans2

K=int(input())

ans=[i for i in range(1,10)]

for j in range(2,11):
    for i in range(1,10):
        add=lunlun(j, j, i)
        ans=ans+add

#print(ans)
print(ans[K-1])
#print(len(ans))

Measured memory_bytes: 19712
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
const mod = 1000000007
func main() {
	scanInit()
	n := scanInt()
	K := scanInt()
	// 全部で 0 ~ NまでのN+1の数列
	mins := make([]int,n+1)
	maxs := make([]int,n+1)
	minsum := 0
	maxsum := 0
	for i:= 0; i<=n; i++ {
		minsum += i
		maxsum += n-i
		maxs[i] += maxsum
		mins[i] += minsum
	}
	sum := 0
	for i:= K-1; i<n; i++ {
		// fmt.Println(i,maxs[i]-mins[i]+1)
		sum += (maxs[i]-mins[i]+1) % mod
		sum %= mod
	}
	sum += 1
	fmt.Println(sum)
}

var sc = bufio.NewScanner(os.Stdin)
func scanInit () {
	sc.Split(bufio.ScanWords)
}
func scanInt () int{
sc.Scan()
	i,_ := strconv.Atoi(sc.Text())
	return i
}
//func scan () string{
//  sc.Scan()
//	return sc.Text()
//}


Measured memory_bytes: 4996
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define EPS 1e-9
using namespace std;

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

int main()
{
//	cut here before submit 
//	freopen ("testcase.SE", "r", stdin );
	string str = "";
	while (getline (cin, str ) ){
		stringstream ss (str );
		int a, b, c, d, e, f;
		ss >> a >> b >> c >> d >> e >> f;
		double x = 0.0, y = 0.0;
		x = (double)(c*e - b*f)/(double)(a*e - b*d);
		y = (double)(c*d - a*f)/(double)(b*d - a*e);

		if (fabs(x) < 1.0e-3){
			x = 0.0;
		} // end if
		if (fabs(y) < 1.0e-3){
			y = 0.0;
		} // end if

		printf ("%.3f %.3f\n", x, y );
	} // end while
		
	return 0;
}

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

int main()
{
    int h, w, n; cin>>h>>w>>n;
    vector<int> a(n); for(int& e: a) cin>>e;

    vector<vector<int>> res(h, vector<int>(w));
    int r=0, c=0, x=0, i=0;
    while (x<h*w) {
        if (a[i]==0) ++i;
        res[r][c]=i+1;
        if (r%2) {
            --c;
            if (c<0) { c=0; ++r; }
        }
        else {
            ++c;
            if (c==w) { c=w-1; ++r; }
        }
        --a[i];
        ++x;
    }
    for(auto& v: res) {
        for(int j=0; j<w; ++j)
            cout<<v[j]<<(j<w-1 ? ' ' : '\n');
    }
}



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

int main(){
    string s;
    string a,b,c;
    int i;
    cin >> s;
    for(i=0;i<5;i++){
        cout << s.at(i);
    }
    cout << ' ';
    for(i=6;i<13;i++){
        cout << s.at(i);
    }
    cout << ' ';
    for(i=14;i<19;i++){
        cout << s.at(i);
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
a = factorization(N)
ans = 0
for i in range(len(a)):
  tmp = a[i][1]
  for j in range(10**10):
    if tmp < j*(j+1)//2:
      break
  ans += (j-1)
if N == 1:
  ans = 0
print(ans)

Measured memory_bytes: 9496
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int n = in.nextInt();
        in.nextLine();
        int[] members = new int[n];
        for (int i = 1; i < n; i++) {
            members[in.nextInt()-1]++;
        }
        for (int i = 0; i < n; i++) {
            System.out.println(members[i]);
        }
    }
}


Measured memory_bytes: 62108
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N=0,A=0,B=0,C=0;
    string str;
    vector<int> vec(3);

    int ans=0;

    cin>>vec[0]>>vec[1]>>vec[2];

    sort(vec.begin(),vec.end());

    ans=abs(vec[2]-vec[1])+abs(vec[1]-vec[0]);

    cout<<ans<<endl;
}

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

int binarySearch(int);

int n;
int *S;

int main(){
	int q,C = 0,i;
	int T;

	scanf("%d",&n);
	S = (int *)malloc(sizeof(int) * n);
	for(i = 0;i < n;i++)
		scanf("%d",&S[i]);
	scanf("%d",&q);
	for(i = 0;i < q;i++){
		scanf("%d",&T);
		C += binarySearch(T);
	}

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

	free(S);
	return 0;
}

int binarySearch(int T){
	int mid,left = 0,right = n;

	while(left < right){
		mid = (left + right) / 2;
		if(T == S[mid])
			return 1;
		else if(T > S[mid])
			left = mid+1;
		else if(T < S[mid])
			right = mid;
	}
	return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;


int main(){
    ll N;
    cin >> N;
    vector<pair<ll, ll>> ab(N);
    rep(i, N) cin >> ab[i].second >> ab[i].first;
    sort(ab.begin(), ab.end());
    ll total = 0;
    for(int i = 0; i < N; i++){
        total += ab[i].second;
        if(ab[i].first >= total) continue;
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, cnt=0, ans=0;
  cin >> n;
  int h[n];
    for(int i=0; i<n; i++) cin >> h[i];
    for(int i=0; i<n-1; i++){
      if(h[i] >= h[i+1]) cnt += 1;
      else cnt = 0;
      ans = max(ans, cnt);
    }
    cout << ans << endl;
}

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

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            int ans=m*i+n*j-2*i*j;
            if(ans==k){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;

    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct UnionFindTree{
    vector<int>par,sz;
    UnionFindTree(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0;i<n;i++){
            par[i]=i;
            sz[i]=1;
        }
    }
    int find(int x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return;
        if(sz[x]<sz[y])swap(x,y);
        sz[x]+=sz[y];
        par[y]=x;
    }
    bool areSame(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};

int N;

int memo[1111][1111][2];
int dfs(int o,int e,int p){
    if(o+e==1)return 1;

    int &ret=memo[o][e][p];
    if(ret!=-1)return ret;


    ret=0;
    if(p)ret|=!dfs(o,e,0);
    if(o&&e)ret|=!dfs(o-1+1,e-1,p^1);
    if(o>1)ret|=!dfs(o-2,e+1,p);
    if(e>1)ret|=!dfs(o,e-2+1,p^1);

    return ret;
}

signed main(){
    cin>>N;
    UnionFindTree uf(N);
    int p=0;
    rep(i,N){
        string s;cin>>s;
        rep(j,s.size()){
            if(s[j]=='Y')uf.unite(i,j),p^=i<j;
        }
    }

    int o=0,e=0;
    rep(i,N)if(uf.find(i)==i){
        p^=uf.size(i)%4>=2;
        if(uf.size(i)%2)o++;
        else e++;
    }

    memset(memo,-1,sizeof(memo));
    cout<<(dfs(o,e,p)?"Taro":"Hanako")<<endl;
    return 0;
}

Measured memory_bytes: 22484
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)

int main() {
  string S;
  cin >> S;
  bool ans = true;
  rep(i,S.length()) {
    if(i%2 == 0) {
      if(S[i] == 'L') {
        ans = false;
      }
    } else {
      if(S[i] == 'R') {
        ans = false;
      }
    }
  }
  if(ans == true) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int v[200];
  for (int i=0; i<n; i++) {
    cin >> v[i];
  }
  int a;
  while (1) {
    bool t = false;
    for (int i=0; i<n; i++) {
      if (v[i]%2 == 1) {
        t = true;
      }
    }
    if (t) {
      break;
    }
    a += 1;
    for (int i=0; i<n; i++) {
      v[i] /= 2;
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def input_one_number():
    return int(input())

def input_multiple_number():
    return map(int, input().split())

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

S = input()
T = input()



for i in range(len(S)):
	if S[i] != T[i]:
		print("No")
		exit()

print("Yes")

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(2e3 + 5);
const ll MOD = (ll)(1e9 + 7);

int n;
ll k;
int a[MAX_N];

ll base[MAX_N];
ll duplicate[MAX_N];

ll ans;

int main(void) {
  // Here your code !
  scanf("%d %lld", &n, &k);

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

  // vector<int> tmp;
  // for (int i = 0; i < k; ++i) {
  //   for (int j = 0; j < n; ++j) {
  //     tmp.push_back(a[j]);
  //   }
  // }

  // ll cnt = 0LL;

  // for (int i = 0; i < tmp.size(); ++i) {
  //   for (int j = i + 1; j < tmp.size(); ++j) {
  //     if (tmp[i] > tmp[j]) cnt += 1LL;
  //   } 
  // }

  // printf("%lld\n", cnt);

  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (a[i] > a[j]) base[i] += 1LL;
    }
  }

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i == j) continue;
      if (a[i] > a[j]) duplicate[i] += 1LL;
    }
  }

  ll coef = k * (k - 1LL) / 2LL;
  coef %= MOD;

  ans = 0LL;

  for (int i = 0; i < n; ++i) {
    ans += k * base[i];
    ans %= MOD;

    ans += coef * duplicate[i];
    ans %= MOD;
  }

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

  return 0;
}


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

int main() {
    int x0,y0,x1,y1;
    cin >> x0 >> y0 >> x1 >> y1;
    int x2,y2,x3,y3;
    x2=x1-y1+y0;
    y2=y1+x1-x0;
    x3=x0-y1+y0;
    y3=y0+x1-x0;
    cout << x2 << ' ' << y2 << ' ' << x3 << ' ' << y3 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  ll X;
  cin >> X;

  ll now=100;
  for(int i=1;;i++){
    now=now*1.01;
    if(now>=X){
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 3652
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

H, A = LI()
print(math.ceil(H/A))


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

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

	int x;
	int res = 1;
	cin >> x;

	for(int i=2;i<=x;i++)
	{
		int y = i*i;
		while(y<=x)
		{
			res = max(res,y);
			y*=i;
		}
	}

	cout << res << '\n';

	return 0;	
}


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

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

  if (N % 2 != 0) {
    cout << "No" << endl;
  }
  else {
    string left = S.substr(0, N/2);
    string right = S.substr(N/2, N/2);
    if (left == right) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>

using namespace std;
typedef long long ll;


ll ans,mx,mn=1e8,sum,cnt;
int main(){
	ll a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	ll mx = max(x,y);
	ll mn = min(x,y);
	if(mx == x){
		cnt = mn*2*c;
		cnt += a*(x-y);
	} else {
		cnt = mn*2*c;
		cnt += b*(y-x);
	}
	ll second=(a*x)+(b*y);
	ll third = mx*2*c;
	ll p = min(cnt,second);
	ll q = min(p,third);
	cout<<q<<endl;
}


Measured memory_bytes: 256
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  																						   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;	
const int mod = 1e9+7;																							   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra																													   																				   list<int>::iterator it;																								   
																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS//////////////////////////////////////////////////////


///////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	int x;
	cin >> x;
	if(x == 25){
		cout << "Christmas" << endl;
	}
	else if(x == 24) cout << "Christmas Eve" << endl;
	else if(x == 23) cout << "Christmas Eve Eve" << endl;
	else if(x == 22) cout << "Christmas Eve Eve Eve" << endl;
	
	
	
	
	
	
	
	
	

						
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#define mod 1000000007
#define ten5 100005
#define PI 3.1415926
using namespace std;

int num[51];

int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,n1=0,n2=0,n3;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=1,now=1;
    long long int a,a1;
    //float f,g,h;
    //char now,pre;
    string s,s1;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>a>>a1;
        num[a]++;
        num[a1]++;
    }
    for(i=1;i<=n;i++)
        cout<<num[i]<<endl;
    return 0;
}



Measured memory_bytes: 256