akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define vi vector < ll  int >
#define CLR(a) memset((a),0,sizeof(a))
#define mp make_pair
#define hell 1000000007
using namespace std;

#define MAXN 1000005
int spf[MAXN];
void sieve()
{
    spf[1] = 1;
    for (int i=2; i<MAXN; i++)
        spf[i] = i;
    for (int i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for (int i=3; i*i<MAXN; i++)
    {
        if (spf[i] == i)
        {
            for (int j=i*i; j<MAXN; j+=i)

                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}


vector<int> gf(int x)
{
    vector<int> ret;
    while (x != 1)
    {
        ret.push_back(spf[x]);
        x = x / spf[x];
    }
    return ret;
}
int BIT[100050]; //fenwick
void upd(int x) { ++x;  while(x<=MAXN)  {  BIT[x]++;  x+=(x&-x);  } }
int cal(int x) {  ++x;  int res=0;  while(x>0)  {  res+=BIT[x];  x-=(x&-x);  } return res; }
ll Com[1051][1051];
void pre()
{

    ll i,j,n=1051;
    rep(i,0,n) Com[i][0]=Com[i][i]=1;
    rep(i,2,n)
    {
        rep(j,1,i)
        {
            Com[i][j]=Com[i-1][j]+Com[i-1][j-1];
            Com[i][j]%=hell;
        }
    }

}
ll mod=998244353;
ll pr( ll x , ll y)
{
    ll ans=1;
    if(y==0) return ans;
    while(y>1)
    {
        if(y&1) ans*=x;
        x*=x;
        y/=2;
        x%=mod;
        ans%=mod;
    }
    ans*=x;
    ans%=mod;
    return ans;
}
ll inv(ll n)
{
    return pr(n,mod-2);
}
ll stoi(string s)
{
    int n=s.size();
    ll k=0; int i;
    rep(i,0,n)
    {
        k+=s[i]-'0';
        k*=10;
    }
    return k/10;
}
string to_string(ll n)
{  if(!n) return "0";
    string s=""; int a,b;
    while(n>0)
    {
        b=n%10;
        s+=(b+'0');
        n/=10;
    }
    reverse(all(s));
    return s;
}


void solve()
{
ll i,j=0,r=200,p,q,k=0,d,y=0,n,h=100000000000000,flag=0,m=0,a=hell,b=hell,id,h1,h2,a1,b1,a2,w,x,u,f,l,c=0,e,ans=0;
cin>>m;
rep(i,1,m+1)
{
    rep(j,1,m+1)
    {
        rep(k,1,m+1)
        {
            d=__gcd(i,j);
            d=__gcd(d,k);
            y+=d;
        }
    }
}
cout<<y;
}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //sieve();
    //cin>>t;
    while(t--)
    solve();
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (const string& e_) { return "\"" + e_ + "\""; }
string to_string (char e_) { return "\'" + string(1, e_) + "\'"; }
string to_string (bool e_) { return e_ ? "true" : "false"; }
template <typename T> string to_string (T e_) {
	string s_ = "[ ";
	for (const auto& x_ : e_) s_ += to_string(x_) + " ";
	return s_ + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e_) {
	return "(" + to_string(e_.first) + ", " + to_string(e_.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
const int N = 100010;
int feven[N], fodd[N], a[N];

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	int n, x;
	cin >> n;

	for(int i = 0; i < n; i++){
		cin >> x;
		if(i&1) fodd[x]++;
		else feven[x]++; 	 
	}
	int ans = 0, maxe = 0, maxo = 0, io, ie, maxe1 = 0, maxo1 = 0;
	for(int i = 0; i < 100010; i++){
		if(maxe < feven[i]){
			maxe1 = maxe;
			maxe = feven[i];
			ie = i;
		}
		else if(maxe1 < feven[i]) maxe1 = feven[i];
	}

	for(int i = 0; i < 100010; i++){
		if(maxo < fodd[i]){
			maxo1 = maxo;
			maxo = fodd[i];
			io = i;
		}
		else if(maxo1 < fodd[i]) maxo1 = fodd[i];
	}
	if(ie == io) ans = min(n - maxe - maxo1, n - maxo - maxe1);
	else ans = (n - maxe - maxo);
	
	cout << ans;
}	

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

using namespace std;

int lcs(string s1, string s2) {
    s1 = ' ' + s1;
    s2 = ' ' + s2;
    vector<vector<int>> v(s1.length(), vector<int>(s2.length(), 0));

    for (int i = 1; i < s1.length(); ++i) {
        for (int j = 1; j < s2.length(); ++j) {
            if (s1[i] == s2[j])
                v[i][j] = v[i - 1][j - 1] + 1;
            else
                v[i][j] = max(v[i - 1][j], v[i][j - 1]);
        }
    }

    return v[s1.length() - 1][s2.length() - 1];
}

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

    string s1, s2;
    for (int i = 0; i < n; ++i) {
        cin >> s1 >> s2;
        cout << lcs(s1, s2) << '\n';
    }
}



Measured memory_bytes: 6824
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 05/31/20 18:19:57
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  vector<ll> A(n); for (auto& a:A) cin>>a;
  ll ans = 1;
  for (auto a:A) {
    if (a == 0) {
      ans = 0;
      break;
    }
  }
  constexpr ll MAX = 1e18;
  if (ans == 1) {
    for (auto a:A) {
      if (a > MAX/ans) {
        ans = -1;
        break;
      }
      ans *= a;
    }
  }
  cout << ans << endl;

  return 0;
}


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;


signed main() {
    string S, T;
    cin >> S >> T;
    int ans = 0;
    rep(i, S.length()) {
        ans += (S[i] != T[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3832
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;

int a[1010];
int b[1010];

int main(void){

	int W,H,N;
	cin >> W >> H >> N;
	REP(i,N){
		cin >> a[i] >> b[i];
	}

	int ans=0;
	REP(i,N-1){
		if((a[i]-a[i+1])*(b[i]-b[i+1])<0){
			ans+=abs(a[i]-a[i+1])+abs(b[i]-b[i+1]);
		}else{
			ans+=abs(a[i]-a[i+1])+abs(b[i]-b[i+1])-min(abs(a[i]-a[i+1]),abs(b[i]-b[i+1]));
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
  int n;
  std::cin >> n;
  std::vector<int64_t> a(n);
  for (auto &i : a) {
    std::cin >> i;
  }
  int64_t diff = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      diff = std::max(diff, std::abs(a[i] - a[j]));
    }
  }

  std::cout << diff << std::endl;
  return 0;
}


Measured memory_bytes: 256
n,q = map(int,input().split())

s = input()


cnt = 0
d = [0]*len(s)
i = 0
while i<=(len(s)-2):
    if s[i]=='A' and s[i+1] == 'C':
        d[i] = cnt
        cnt += 1
        d[i+1] = cnt
        i+=2
    else:
        d[i]=cnt
        i+=1    
d[len(s)-1] = cnt
for i in range(q):
    l,r = map(int,input().split())
    print(d[r-1]-d[l-1])


Measured memory_bytes: 6212
#include<bits/stdc++.h>
using namespace std;
int a[55];
int main(){
    int n,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            ans+=a[i]*a[j];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define ld          long double
#define endl        "\n"

const int mod = 1e9+7;

inline int add(int a, int b) { int res = a + b; if(res >= mod) res -= mod;  return res; }
inline int sub(int a, int b) { int res = a - b; if(res < 0) res += mod; return res;}
inline int mul(int a, int b) { return (a * b)%mod; }



void solve() {  
    int a, b, c; cin >> a >> b >> c;
    swap(a, b); swap(a, c);
    cout << a << " " << b << " " << c << endl;
}

signed main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(12);

    int T = 1;
    //cin >> T;

    while(T--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    int a,b,c;
    a = n % 10;
    n = n / 10;
    b = n % 10;
    n = n / 10;
    c = n % 10;
    if( a == 7 || b == 7 || c == 7 ){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}



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

using namespace std;

const int N = 52;


long long p2[N];

int main() {
	int n, p;
	cin >> n >> p;
	p2[0] = 1;
	for (int i = 1; i < N; ++i) {
		p2[i] = 2LL*p2[i-1];
	}
	int odd = 0, even = 0;
	for (int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		if(x&1) odd++;
		else even++;
	}
	if(odd == 0 && p == 1) {
		printf("%lld\n", 0);
	} else {
		printf("%lld\n", p2[even+max(0,odd-1)]);
	}



}

Measured memory_bytes: 256
class Integer
  def value
    self.to_i
  end
end

class MInt < Numeric
  
  attr_reader :value, :mod
  @@mod = 10 ** 9 + 7
  @@h = Hash.new
  # delegate :to_i, :to_f, :to_s, to: :value
  
  def to_i
    @value
  end
  
  def initialize(value)
    @value = value
  end
  
  def +@
    MInt.new(value.to_i % @@mod)
  end

  def -@
    MInt.new(-value.to_i % @@mod)
  end
  
  def +(other)
    MInt.new((value + other.value.to_i) % @@mod)
  end
  
  def -(other)
    MInt.new((value - other.value.to_i) % @@mod)
  end
  
  def *(other)
    MInt.new((value * other.value.to_i) %@@mod)
  end
  
  def /(other)
    @@h[other.value] ||= other.value.to_i.pow(@@mod-2, @@mod)
    MInt.new(self.value.to_i * @@h[other.value.to_i])
  end
  
  def ==(other)
    ( value % @@mod ) == ( other.value % @@mod )
  end
  
  def abs
    value %= @@mod
    self 
  end
  
  def to_s
    (value % @@mod).to_s
  end
  
  def inspect
    (value % @@mod).to_s
  end
  
  def coerce(other)
    [MInt.new(other), self]
  end
end

# a = MInt.new(54)
# b = MInt.new(10**9+6)

# p  a + b
# p -b
# p MInt.new(54) + (10**9+6)

nn, kk = gets.to_s.split.map{|e|e.to_i}

n = MInt.new(nn)
k = MInt.new(kk)

ans = (kk..nn+1).map{|i| i * (n + n - i + 1) / 2 - i * ( i - 1 ) / 2 + 1 }.sum

puts ans
# puts ans % (10 ** 9 + 7)

Measured memory_bytes: 30312
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
using namespace std;
int main(){
	
	int h,m,s;
	int a[2],b[2],c[2];
	while(cin>>h>>m>>s,h!=-1||m!=-1||s!=-1){
		int t1=3600*2;
		int t2=t1;
		int sum1=h*3600+m*60+s;
		t1-=sum1;
		t2 =t1*3;
		a[0]=t1/3600;
		b[0]=(t1-a[0]*3600)/60;
		c[0]=(t1-(a[0]*3600+b[0]*60));
		a[1]=t2/3600;
		b[1]=(t2-a[1]*3600)/60;
		c[1]=(t2-(a[1]*3600+b[1]*60));
		
		for(int i=0;i<2;i++)
		printf("%02d:%02d:%02d\n",a[i],b[i],c[i]);
		
		
	}
	
}

Measured memory_bytes: 1160
fun main(args: Array<String>) {
    abc067b()
}

fun abc067b() {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val lList = readLine()!!.split(" ").map { it.toInt() }

    val answer = lList.sortedDescending().take(k).sum()

    println(answer)
}


Measured memory_bytes: 37876
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <queue>

#define fr first
#define sc second
#define mk make_pair

using namespace std;

long long n;
vector<int> vec;

int main()
{
    deque<int> ans;
    cin >> n;
    while(n)
    {
        if(n % 2 == 1)
        {
            vec.push_back(1);
            n = n / 2;
        }else
        {
            vec.push_back(0);
            n--;
        }
    }

    int p = 1;
    for(int i = vec.size() - 1; i >= 0; i--)
    {
        if(vec[i] == 1)
        {
            ans.push_back(p);
        }else
        {
            ans.push_front(p);
        }
        p++;
    }
    cout << ans.size() * 2 << endl;
    while(!ans.empty())
    {
        cout << ans.front() << " ";
        ans.pop_front();
    }

    for(int i = 1; i < p; i++)
        cout << i << " ";
    return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    int i , n ,ans = 0;
    string s;
    cin >> s;
    n = s.size();
    for(i=0;i<n;i++)
    {
        if(i%2 == 0)
        {
            if(s[i] == 'p')
                ans--;
        }
        else
        {
            if(s[i] == 'g')
                ans++;
        }
    }
    cout << ans ;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,sum = 0;
  cin >> a >> b;
  for (int i = a;i<=b;i++){
    if(i/10000 == i%10 && (i%10000)/1000 == (i/10)%10){
      sum++;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long,long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int A,B; cin >> A >> B;
    cout << (A-1)*(B-1) << endl;
}



Measured memory_bytes: 384
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int a[200010],s[200010];
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n=read(),m=read();
    for(int i=1;i<=n;i++)a[i]=read();
    while(m--)
    {
    	bool bk=true;
    	for(int i=1;i<=n;i++)if(a[i]<n){bk=false;break;}
    	if(bk==true)break;
    	for(int i=1;i<=n;i++)s[max(1,i-a[i])]++,s[min(i+a[i]+1,n+1)]--;
    	int sum=0;
    	for(int i=1;i<=n;i++){sum+=s[i],a[i]=sum;s[i]=0;}
    }
    for(int i=1;i<=n;i++)pr1(a[i]);
    puts("");
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int w,h,x,y,r; cin>>w>>h>>x>>y>>r;
    if (0<=x-r && x+r<=w && 0<=y-r && y+r<=h){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}



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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

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

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  llong N, K;
  vector<llong> p;
  vector<ldbl> rui{0};

  cin >> N >> K;
  p.resize(N);
  for (auto &in: p) {
    cin >> in;
    rui.push_back(rui.back() + in * (in + 1) / ldbl(2 * in));
  }

  ldbl ans = 0;
  for (int i = K; i <= N; ++i) {
    ans = max(ans, rui[i] - rui[i - K]);
  }

  cout << fixed << setprecision(30) << ans << endl;

  return 0;
}

Measured memory_bytes: 8132
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin >> N;
  N = '0' + N;
  int n = N.size();
  int ans = 0;
  for (int i = n-1; i >= 0; i--) {
    int ni = N[i] - '0';
    if (ni < 5 || (ni == 5 && N[i-1] - '0' < 5)) {
      ans += ni;
    } else {
      ans += 10 - ni;
      N[i-1]++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2436
using System;
using System.Collections.Generic;

namespace Unhappy_Hacking_ABC_Edit
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var s = Console.ReadLine().ToCharArray();

            var text = new List<char>();
            foreach (var c in s)
            {
                if (c != 'B')
                {
                    text.Add(c);
                    continue;
                }
                if (text.Count == 0)
                {
                    continue;
                }
                // 末尾削除
                text.RemoveAt(text.Count - 1);
            }

            Console.WriteLine(string.Join("",text));
        }
    }
}


Measured memory_bytes: 13268
# https://atcoder.jp/contests/abc045/tasks/arc061_a
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    s = input()

    def build(sub):
        if len(sub) == 1:
            return [sub]
        top = sub[0]
        rest = build(sub[1:])

        ret = []
        for r in rest:
            ret.append(top + r)
            ret.append(top + '+' + r)
        return ret

    ans = sum(map(lambda inp: eval(inp), build(s)))
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
INF = 10 ** 12
N, K = gets.split.map(&:to_i)
lists = []
N.times do
  lists << gets.to_i
end
lists.sort_by!{|x|x}
# p lists
ans = INF
(N - K + 1).times do |i|
  dist = lists[i + K - 1] - lists[i]
  ans = dist if ans > dist
end
puts ans

Measured memory_bytes: 6192
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
		
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		scan.close();
		
		// 0がaになり、1大きい数が渡されるけど、アルファベットだけの26進数にしてね
		System.out.println(convertOriginalShinsuStr(n, 'a', 1, 26));
		
	}
	
	/**
	 * 10進数をオリジナル進数(アルファベット)文字列に変換
	 * @param dNum 変換する10進数
	 * @param origin 10進数の0をオリジナル進数で変換した後の文字
	 * @param offset オリジナル変数の0に何を足せば10進数の0になるか？
	 * @param baseNumber 何進数に変換するの
	 * @return オリジナル進数(アルファベット)文字列
	 */
	public static String convertOriginalShinsuStr(
			long dNum, final char origin, final int offset, final int baseNumber) {
		
		// よくわからんワンちゃん
		if(dNum <= 0) {
			return "";
		}
		
		// 邪魔なのでオフセットは消化
		dNum -= offset;
		
		// char型とintの足し算で文字を求める
		String ret = String.valueOf((char)(origin + dNum % baseNumber));
		// 小数点以下は切り捨てられる
		dNum /= baseNumber ; 
		
		// 次の位も頼みます
		return convertOriginalShinsuStr(dNum, origin, offset, baseNumber) + ret;
		
	}

}


Measured memory_bytes: 39568
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

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

signed main(){
    ll h,w,n;
    cin >> h >> w >> n;
    map<P, int> mp;
    ll a,b;
    REP(i,n){
        cin >> a >> b;
        a--;
        b--;
        REP(j,9){
            if(!(a + dy[j] < 1 || h - 2 < a + dy[j] || b + dx[j] < 1 || w - 2 < b + dx[j])){
                mp[P(a + dy[j], b + dx[j])]++;
            }
        }
    }
    ll ans[10] = {};
    ans[0] = (h - 2) * (w - 2);
    for(auto i : mp){
        ans[i.second]++;
        ans[0]--;
    }
    for(int i = 0; i <= 9; i++){
        cout << ans[i] << endl;
    }
    return 0;
}

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

int solve(int s, int d, int x) {
    
    if (s == d) {
        return x;
    }
    
    if (s % 2 != 0) {
        x++;
        s++;
    }
    
    if (d % 2 != 0) {
        x++;
        d--;
    }
    
    return solve(s/2, d/2, x);
}

int main()
{
    int n;
    cin >> n;
    int a[n];
    
    for (int i=0; i<n; i++) {
        int s, d;
        cin >> s >> d;
        a[i] = solve(s, d, 0);
    }
    
    for (int i=0; i<n; i++) {
        cout << a[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3088
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007; 
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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






int main(){
    int H, W; std::cin >> H >> W;
    std::vector<std::string> a(H);
    for(int i(0); i < H; ++i) std::cin >> a[i];
    std::vector<std::vector<int>> dp(H, std::vector<int>(W, 0));
    dp[0][0] = 1;
    for(int i(0); i < H; ++i){
        for(int j(0); j < W; ++j){
            if(a[i][j] == '#'){
                dp[i][j] = 0; continue;
            }
            if(i) dp[i][j] = (dp[i][j] + dp[i-1][j]) % MOD;
            if(j) dp[i][j] = (dp[i][j] + dp[i][j-1]) % MOD;
        }
    }
    std::cout << dp[H-1][W-1] << std::endl;
    return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
const int INF=1e9+5;
const int N=2e3+5;
const int mod=998244353;

int main(){
	ios::sync_with_stdio(0);
	vector<int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin>>k;
	cout<<a[--k];
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define powerof2 ()
#define mp make_pair
#define pi acos(-1)
using ll = long long;
const ll M = 1000000007;
const ll M1= 998244353;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
ll power(ll x,ll y){
	if(y==0)
		return 1;
	ll res=power(x,y/2);
	res=(res*res);
	if(y&1)
		res=(res*x);
	return res;
}
 
ll powermod(ll x,ll y,ll mod){
	if(y==0)
		return 1;
	ll res=powermod(x,y/2,mod);
	res=(res*res)%mod;
	if(y&1)
		res=(res*x)%mod;
	return res;
}
/*ll binarysearch(ll va)
{
	ll n=1;
	ll l=va+1,u=n;
	ll st=num.order_of_key(va);
	while(l+1<u)
	{
		m=(l+u)/2;
		ll in=num.order_of_key(m);
		if(in-st==m-va)
		{
			l=m;
		}
		else
		{
            u=m;
		}
	}
	if(num1.find(l)==num1.end())
		return l;
	return u;
}*/
void solve(){
	int n;
	cin>>n;
	int ans[10007]={0};
	for(int i=1;i<=100;i++){
		for(int j=1;j<=100;j++){
			for(int k=1;k<=100;k++){
				ll q=(i*i+j*j+k*k+(i*j)+(j*k)+(k*i)); if(q<10007) ans[q]++;
			}
		}}
		for(int i=1;i<=n;i++) cout<<ans[i]<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
 
    for(int i=1;i<=t;i++)
    {//cout<<"Case #"<<i<<": ";
    solve();}
    return 0;
}


Measured memory_bytes: 3580
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)

//小文字=大文字+32

int main() {
	int n;
	cin >> n;
	vector<ll>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	
	ll ans=0;
	for(int i=1;i<n;i++) {
		if (a[i - 1] > a[i]) {
			ans+= a[i - 1] - a[i];
			a[i] = a[i-1];

		}
		
	}
	cout << ans;


}
	



Measured memory_bytes: 4784
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include <stdexcept>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
int ceil(int a,int b){
    return (a+b-1)/b;
}
int main(void){
   int n;
   cin>>n;
   int sum=0,max=0,a=1;
   FOR(i,1,n+1){
       sum=0;
       int j=i;
       while(j%2==0){
           if(j==0) break;
           if(j%2==0){
               sum++;
               j=j/2;
           } 
       }
       if(sum>=max) {
           a=i;
           max=sum;
       }
   }
   cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=5e5;

  int n,z,A;
  char s[N];
int main()
{
  scanf("%s",s);
  n=strlen(s);
  for (int i=n;~--i;)
    if (s[i]=='T') ++z;
    else A+=!!z*2,z=max(z-1,0);
  cout<<n-A;
  exit(0);
}

Measured memory_bytes: 384
N, K = map(int, input().split())
P = [int(p) for p in input().split()]
P_kitai = [(1 + p)/2 for p in P]

max_kitai = 0
res = 0
for i in range(N - K + 1):
    if i == 0: 
        res = sum(P_kitai[i:i+K])
    else:
        res = res - P_kitai[i-1] + P_kitai[i+K-1]
    max_kitai = max(max_kitai, res)
print(max_kitai)

Measured memory_bytes: 25188
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

vector<pair<ll, int>> factorrize(ll n) {
  vector<pair<ll, int>> res;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i) continue;
    res.emplace_back(i, 0);
    while (n % i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n, 1);
  return res;
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  auto f = factorrize(g);
  int anser = f.size() + 1;
  cout << anser << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

typedef struct{
  char mark;
  int number;
}Card;

int main(){
  int i, j, n, v = 0, min;
  Card B[36], S[36], C;
  char space;

  scanf("%d%c",&n, &space);

  for(i = 0; i < n; i++){
    if(i != n - 1) scanf("%c%d%c",&B[i].mark, &B[i].number, &space);
    else scanf("%c%d",&B[i].mark, &B[i].number);
  }

  for(i = 0; i < n; i++) S[i] = B[i];

  // Bubble
  for(i = 0; i < n; i++){
    for(j = n - 1; j > i; j--){
      if(B[j - 1].number > B[j].number){
      C = B[j];
      B[j] = B[j - 1];
      B[j - 1] = C;
      }
    }
  }
  
  for(i = 0; i < n; i++){
    printf("%c%d",B[i].mark, B[i].number);
    if(i != n - 1) printf(" ");
  }
  printf("\nStable\n");

  // Selection
  for(i = 0; i < n; i++){
    min = i;
    for(j = i; j < n; j++){
      if(S[j].number < S[min].number) min = j;
    }

    if(i != min){
      C = S[min];
      S[min] = S[i];
      S[i] = C;
    }
    printf("%c%d",S[i].mark, S[i].number);
    if(i != n - 1) printf(" ");
  }
  printf("\n");

  // is prime
  for(i = 0; i < n; i++){
    if(B[i].mark != S[i].mark) v++;
  }
  if(v != 0) printf("Not stable\n");
  else printf("Stable\n");

  return 0;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, k,  m, y, q ;
string s, t;
ld w;

// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> m;
	cout<<max(0ll,n - 2*m);
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
using namespace std;

int n;
int a[10];

signed main() {
	int i, j;
	int pow3[15];
	
	pow3[0] = 1;
	for (i = 1; i < 15; i++) pow3[i] = pow3[i - 1] * 3;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> a[i];
	
	int ans = 0;
	for (i = 0; i < pow3[n]; i++) {
		int mul = 1;
		for (j = 0; j < n; j++) {
			int t = (i / pow3[j]) % 3;
			mul *= a[j] + t - 1;
			mul %= 2;
		}
		if (mul % 2 == 0) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

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

int main(){
  long int a,b;
  cin >> a >> b;
  
  long int i = 1;
  while(true){
    long int kari = i * a;
    //cout << a << endl;
    if(kari%b==0)break;
    i++;
  }
  cout << a*i << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int a,b,c,d,e,k; cin>>a>>b>>c>>d>>e>>k;
    if(e-a<=k){
        cout<<"Yay!"<<endl;
    }else{
        cout<<":("<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>

T calcgcd(T x, T y)
{
    if (x < y)
    {
        std::swap(x, y);
    }
    T r = x % y;
    while( r != 0 )
    {
        x = y;
        y = r;
        r = x % y;
    }
    return y;
}

vector<pair<ll, ll>> PrimeFactorization(long long n)
{
    vector<pair<ll, ll>> res;
    for(long long i = 2; i * i <= n; ++i)
    {
        if (n % i) continue;
        res.emplace_back(i, 0);
        while (n % i == 0)
        {
            ++res.back().second;
            n = n / i;
        }
    }
    if (n != 1)
    {
        res.emplace_back(n, 1);
    }
    return res;
}

int main()
{
    ll a, b;
    cin >> a >> b;
    ll g = calcgcd(a, b);

    auto res = PrimeFactorization(g);

    ll ans = res.size() + 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner(os.Stdin)
	N := sc.NextInt()
	V := make([]int, N)
	C := make([]int, N)
	for i := range V {
		V[i] = sc.NextInt()
	}
	for i := range V {
		C[i] = sc.NextInt()
	}
	ans := 0
	for i := range V {
		if V[i]-C[i] > 0 {
			ans += V[i] - C[i]
		}
	}
	fmt.Println(ans)
}

func vmin(v []int) int {
	mn := math.MaxInt32
	for i := 0; i < len(v); i++ {
		mn = min(mn, v[i])
	}
	return mn
}

func lcm(x, y int) int {
	x, y = max(x, y), min(x, y)
	if y == 0 {
		return x
	}
	return lcm(y, x%y)
}

func max64(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

// scanner
type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner(r io.Reader) *Scanner {
	rdr := bufio.NewReaderSize(r, 1024)
	return &Scanner{r: rdr}
}

func (s *Scanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		line, isp, err := s.r.ReadLine()
		if err != nil {
			os.Exit(1)
		}
		s.buf = append(s.buf, line...)
		if !isp {
			break
		}
	}
}

func (s *Scanner) NextInt64() int64 {
	i, err := strconv.ParseInt(s.Next(), 10, 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextInt() int {
	i, err := strconv.Atoi(s.Next())
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextFloat64() float64 {
	i, err := strconv.ParseFloat(s.Next(), 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	next := string(s.buf[start:s.p])
	s.p++
	return next
}

func (s *Scanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}


Measured memory_bytes: 640
n, m = [int(i) for i in input().split()]
vec = []
for i in range(n):
    vec.append([int(j) for j in input().split()])
c = []
for i in range(m):
    c.append(int(input()))
for i in range(n):
    sum = 0
    for j in range(m):
        sum += vec[i][j]*c[j]
    print(sum)

Measured memory_bytes: 8092
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N; cin >> N;
  LL sum = 0;
  for (LL i = 1; i < N; ++i) sum += i;
  cout << sum << endl;
}


Measured memory_bytes: 3588
import java.util.*;
 public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);

      int N = sc.nextInt();
      int count = 0;
     
      while(N > 0){
      N -= 2;
      count++;
     }

      System.out.print(count);
   }
 }

Measured memory_bytes: 35632
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
int main(){
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  int x[N];
  int y[M];

  for(int i=0;i<N;i++) cin >> x[i];
  sort(x, x+N);

  for(int j=0;j<M;j++) cin >> y[j];
  sort(y, y+M);

  int xright = max(X, x[N-1]);
  int yleft = min(Y, y[0]);

  if(xright < yleft) cout << "No War" <<endl;
  else cout << "War" <<endl;

  return 0;
}

Measured memory_bytes: 256
INF = 10**18

def choice(c):
    for i in range(c):
        for j in range(c):
            if i == j:
                continue
            for k in range(c):
                if (i != k) and (j != k):
                    yield i,j,k

def solve(n, c, D, C):
    P = [{},{},{}]
    for y in range(n):
        for x in range(n):
            i = (x+y) % 3
            k = C[y][x] - 1
            if not k in P[i]:
                P[i][k] = 0
            P[i][k] += 1
    best = INF
    for v in choice(c):
        cur = 0
        for i in range(3):
            t = v[i]
            for s, num in P[i].items():
                cur += D[s][t] * num
        best = min(best, cur)
    return best

n, c = map(int, input().split())
D = [list(map(int, input().split())) for i in range(c)]
C = [list(map(int, input().split())) for i in range(n)]
print(solve(n, c, D, C))

Measured memory_bytes: 5620
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("C:\\Users\\BOG\\Desktop\\path.txt");ofstream out("C:\\Users\\BOG\\Desktop\\crd.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main(){
    fast;
    int a; cin>>a;
    str x,y; cin>>x>>y;
    for(int q=0; q<a; q++) cout<<x[q]<<y[q];
}

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

int main(){
  int N; cin >> N;
  int mod=0;
  int a;
  for(int i=0; i<N; i++){
    cin >> a;
    mod+=(a%2);
  }
  cout << (mod%2==0?"YES":"NO") << endl;
}

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

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

using ll = long long;

using namespace std;

ll gcd(ll C, ll D) {
	if (C < D) gcd(D, C);

	if (C%D == 0)return D;
	else return gcd(D, C%D);
}

const int MOD = 1000000007;

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	ll sum = 0;
	rep(i, N) {
		cin >> A[i];
		sum += A[i];
	}
	ll ans = 0;

	rep(i, N) {
		sum -= A[i];
		ans += ((A[i]%MOD) * (sum%MOD))%MOD;
		ans %= MOD;
	}

	cout << ans << endl;
	return 0;
}






Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  if (a <= b) {
    for (int i = 0; i < b; i++) {
      cout << a;
    }
  }
  else {
    for (int i = 0; i < a; i++) {
      cout << b;
    }
  }
  cout << endl;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

const char* words[4]={"dream","dreamer","erase","eraser"};
int lens[4]={5,7,5,6};
char buf[100010];
bool dp[100010];

bool cmp(const char* word,int len,int pos) {
    for (int i=len-1,j=pos;i>=0;i--,j--) {
        if (word[i]!=buf[j]) return false;
    }
    return true;
}

int main() {
    memset(buf,0,sizeof(buf));
    scanf("%s",buf);
    memset(dp,0,sizeof(dp));
    dp[0]=true;
    int len=strlen(buf);
    for (int i=1;i<=len;i++) {
        for (int j=0;j<4;j++) {
            if (i>=lens[j]&&dp[i-lens[j]]) {
                if (cmp(words[j],lens[j],i-1)) {
                    dp[i]=true;
                    break;
                }
            }
        }
    }
    if (dp[len]) printf("YES\n");
    else printf("NO\n");
}

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

int main() {
  vector<int> a(32);
  a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  
  int K;
  cin >> K;
  
  cout << a.at(K-1) << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        
        char[][] boarda = new char[n][n];
        for (int i = 0; i < n; i++) {
            String str = sc.next();
            for (int j = 0; j < n; j++) {
                boarda[i][j] = str.charAt(j);
            }
        }
        char[][] boardb = new char[n][n];
        for (int i = 0; i < m; i++) {
            String str = sc.next();
            for (int j = 0; j < m; j++) {
                boardb[i][j] = str.charAt(j);
            }
        }
        
        boolean ok = true;
        for (int offseti = 0; offseti <= n - m; offseti++) {
            for (int offsetj = 0; offsetj <= n - m; offsetj++) {
                ok = true;
                for (int i = 0; i < m; i++) {
                    for (int j = 0; j < m; j++) {
                        if (boardb[i][j] != boarda[i+offseti][j+offsetj]) {
                            ok = false;
                        }
                    }
                }
                
                if (ok) {
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <math.h>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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


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

    int X;
    cin >> X;

    if(X == 3 || X == 5 || X == 7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int W, a, b;
    cin >> W >> a >> b;

    if (a > b) swap(a, b);

    int ans = 0;
    while (1) {
        if ((a + W) >= b) {
            break;
        }
        ans++;
        a++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
n = int(input())
b = list(map(int, input().split()))
a = [0] * n
a[0] = b[0]
for i in range(n - 2):
    a[i + 1] = min(b[i], b[i + 1])
a[n - 1] = b[n - 2]
print(sum(a))

Measured memory_bytes: 3188
/*
 *  Lang    : C++
 *  Author  : little_angel
 */
#include <bits/stdc++.h>

using namespace std;
#define int long long
const int mod = 1e9 + 7;

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

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

struct mat {
    vector<vector<int>> m;
    int n;

    explicit mat(int n) : n(n) {}

    explicit mat(vector<vector<int>> &m) : m(m), n(m.size()) {}

    mat operator*(const mat &a) const {
        mat c = mat(a.n);
        c.m.resize(a.n, vector<int>(a.n));
        for (int i = 0; i < c.n; ++i) {
            for (int j = 0; j < c.n; ++j) {
                for (int k = 0; k < c.n; ++k) {
                    add(c.m[i][j], mul(m[i][k], a.m[k][j]));
                }
            }
        }
        return c;
    }

    mat operator^(int y) {
        mat x = mat(m);
        mat res = mat(n);
        res.m.resize(res.n, vector<int>(res.n));
        for (int i = 0; i < res.n; ++i) res.m[i][i] = 1;
        while (y) {
            if (y & 1)res = res * x;
            y >>= 1;
            x = x * x;
        }
        return res;
    }
};

istream &operator>>(istream &in, mat &a) {
    a.m.resize(a.n, vector<int>(a.n));
    for (int i = 0; i < a.n; ++i) {
        for (int j = 0; j < a.n; ++j) {
            in >> a.m[i][j];
        }
    }
    return in;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n, k;
    cin >> n >> k;
    mat a = mat(n);
    cin >> a;
    a = a ^ k;
    int ans = 0;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            add(ans, a.m[i][j]);
    cout << ans << endl;
}

Measured memory_bytes: 384
//Comentary AC
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

string divide[4] = {"dream", "dreamer", "erase", "eraser"};
int main(){
    string S; cin >> S;

    reverse(S.begin(),S.end());
    for (int i=0;i<4;++i) reverse(divide[i].begin(),divide[i].end());
    
    bool can = true;
    for (int i=0;i<S.size();){
        bool can2 = false;
        for (int j=0;j<4;++j){
            string d = divide[j];
            if (S.substr(i,d.size())==d) {
                can2 = true;
                i += d.size();
            }
        }
        if (!can2) {
            can = false;
            break;
        }
    }

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

Measured memory_bytes: 512
from collections import defaultdict

S = input()

cnt = defaultdict(bool)
for s in S:
  cnt[s] = True

if (cnt["S"] and cnt["N"]) and (cnt["E"] and cnt["W"]):
  print("Yes")
elif (cnt["S"] and cnt["N"]) and not (cnt["E"] or cnt["W"]):
  print("Yes")
elif not (cnt["S"] or cnt["N"]) and (cnt["E"] and cnt["W"]):
  print("Yes")
else:
  print("No")


Measured memory_bytes: 64940