akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
vector<i64> v, c;
int main() {
  cin >> n;
  read_n(v, n);
  read_n(c, n);
  i64 s = 0;
  for (i64 i = 0; i < n; ++i) {
    s += max(v[i] - c[i], i64(0));
  }
  cout << s << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)
const i64 INF = 1LL << 60;

int main() {
  int N;
  cin >> N;
  vector<i64> A(N);
  for (auto& x : A) {
    cin >> x;
  }
  vector<vector<int>> adj(N);
  REP(i, N - 1) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  vector<int> answer(N);
  vector<i64> lis(N + 1, INF);
  auto solve = [&](auto rec, int node, int pnode = -1) -> void {
    assert(answer[node] == 0);
    auto it = lower_bound(lis.begin(), lis.end(), A[node]);
    assert(it != lis.end());
    const int j = distance(lis.begin(), it);
    answer[node] = 1 + j;
    if (pnode != -1) {
      answer[node] = max(answer[node], answer[pnode]);
    }
    i64 backup = lis[j];
    lis[j] = A[node];
    for (int cnode : adj[node]) {
      if (cnode != pnode) {
        rec(rec, cnode, node);
      }
    }
    lis[j] = backup;
  };
  solve(solve, 0);

  for (int x : answer) {
    cout << x << "\n";
  }
}


Measured memory_bytes: 38016
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, s, e) FOR(i, e, s) cout << a[i] << ' '


using namespace std;


int main()
{
    int n; cin >> n;
    cout << n * n * n;
    return 0;
}
//1 2 20 10 5 15 14


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define Check system("pause")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

map<ll,ll> re;

ll quick(ll k)
{
	ll ans=1,b=5;
    while(b>0)
    {
    	if(b&1)
    	{
    		ans=ans*k;
        }
        k=k*k;
        b>>=1;
    }
    return ans;
}


int main()
{
	ios::sync_with_stdio(false);
	ll x,k=0,w,now,t;
	cin>>x;
	while(1)
	{
		now=quick(k);
		re[now]=k;
		w=now-x,t=1;
		if(w<0) w*=-1,t=-1;
		if(re[w] || w==0)
		{
			cout<<k<<' '<<re[w]*t;
			break;
		}
		k++;
	}
	return 0;
}




Measured memory_bytes: 3652
#!/usr/bin/env python3
import sys


def solve(N: int, Q: int, S: str, l: "List[int]", r: "List[int]"):
    c = [0 for i in range(N+1)]
    for i in range(N):
        c[i+1] = c[i] + (1 if S[i:i+2] == "AC" else 0)
    for q in range(Q):
        print(c[r[q]-1] - c[l[q] - 1])

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    l = [int()] * (Q)  # type: "List[int]" 
    r = [int()] * (Q)  # type: "List[int]" 
    for i in range(Q):
        l[i] = int(next(tokens))
        r[i] = int(next(tokens))
    solve(N, Q, S, l, r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 15836
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int main() {
    ll n;
    std::cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        if(i>0){
            if( a[i] - a[i-1] >= 2 ){
                std::cout << -1 << std::endl;
                return 0;
            }
        }else{
            if( a[i] >= 1){
                std::cout << -1 << std::endl;
                return 0;
            }
        }
    }
    ll result = 0;

    result = a[n-1];
    for (int i = n-2; i >= 0; i--) {
        if( a[i+1]-a[i] == 1 ){
            continue;
        }
        result += a[i];
    }
    
    std::cout << result << std::endl;
    
    /*
    0000100000
    
    
    0000120000
    0000123000
    1つず情報する形って感じかな。1以上差があいてしまうと達成不能
    
    12301234444534
    とかは
    
    123は3書いでつくる。
    なるほど同じ数字が連続していると、作れるけどめんどい。
    1233なら
    1
    12
    123
    1234
    
    になるから
    
    0100
    0120
    0123
    1123
    1223
    1233
    
    みたいな形で上げる必要がありそう。
    
    一番みぎにあるやつ優先であげる。
    
    まず判定して作るか
    
    1234を無駄に作る方法
    
    0001
    0011
    001
    
    */
}


Measured memory_bytes: 1920
/*
 *  Author : Jun_SH
 *  Solution for ABC 147 A
 */
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
    int f=1,x=0;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 f*x;
}

main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22)puts("bust");
    else puts("win");

}


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

using namespace std;

int main()
{
    string s;
    int flag=0;

    cin>>s;

    for(int i=0;i<s.size();i++)
    {
        if(i%2!=0 && s[i]=='R')
        {
            cout<<"No"<<endl;
            return 0;
        }

        if(i%2==0 && s[i]=='L')
        {
            cout<<"No"<<endl;
            return 0;
        }
    }

    cout<<"Yes"<<endl;

    return 0;
}


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


int main(){
  int n,x;
  cin>>n>>x;
  int a[n];
  int sum=0;
  int cnt=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
    if(sum<=x)cnt++;
    else break;
  }
  cout<<cnt+1;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
#include<random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  double r;
  cin >> r;
  cout << 2 * r * 3.14 << endl;

	return 0;
}

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

#define MOD 1000000007
typedef unsigned long long ull;

int n, k, q;
int main() {
  cin >> n >> k >> q;
  int a;
  vector<int> points(n, k - q);
  for (int i = 0; i < q; i++) {
    cin >> a;
    points[a - 1]++;
  }

  for (int i = 0; i < n; i++) {
    if (points[i] <= 0) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
const int Inf = 1e9 + 5;
 
int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int x, n;
    cin >> x >> n;
    if (n == 0) {
        cout << x;
        return 0;
    }
    vector<int> a(n);
    int mn = Inf;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int idx = lower_bound(a.begin(), a.end(), x) - a.begin();
    int p1 = idx, p2 = idx;
    int ans1 = x, ans2 = x;
    while (p1 >= 0) {
        if (a[p1] == ans1) {
            ans1--;
            p1--;
        } else {
            break;
        }
    }
    while (p2 < n) {
        if (a[p2] == ans2) {
            ans2++;
            p2++;
        } else {
            break;
        }
    }
    if (abs(ans1 - x) <= abs(ans2 - x)) {
        cout << ans1;
    } else {
        cout << ans2;
    }
    return 0;
}

Measured memory_bytes: 3656
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    println!("{}", if s.trim().len() == 3 {s.chars().filter(|&c| char::is_numeric(c)).fold(1, |p, x| p * (x as i32 - '0' as i32))} else { -1 });
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<long int> h(N);
  for (int i = 0; i < N; i++) cin >> h.at(i);
  
  sort(h.begin(), h.end());
  
  long int m = 1000000000;
  for (int i = 0; i < N - K + 1; i++) {
    m = min(h.at(i + K - 1) - h.at(i), m);
  }
  
  cout << m << endl;
}

Measured memory_bytes: 1024
def factorials(M):#M!までのリストｘと其の逆元のリストyを返すmod INF
    INF=int(1e9+7)
    fac=[0]*(M+1)
    finv=[0]*(M+1)
    inv=[0]*(M+1)
    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,M+1):
        fac[i]=(fac[i-1]*i)%INF
        inv[i]=INF-(inv[INF%i]*(INF//i))%INF
        finv[i]=finv[i-1]*inv[i]%INF
    return fac,finv
def nCr(n,r):
    INF=int(1e9+7)
    if n<r or r<0 or n<0 :
        return 0
    return fac[n]*(finv[r]*finv[n-r]%INF)%INF

N,M,K=map(int,input().split())
MOD=10**9+7
fac,finv=factorials(N*M)
ans=0
for d in range(1,N):
    ans+=d*nCr(N*M-2,K-2)*(((N-d)*M**2)%MOD)
    ans%=MOD
for d in range(1,M):
    ans+=d*nCr(N*M-2,K-2)*(((M-d)*N**2)%MOD)
print(ans%MOD)


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

using namespace std;
#define ll long long
#define ld long double
const int INF = 1001001001;
const int N=2e5 + 5;
const ll mod = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    int a[n][m];
    for(int i=0;i<n;i++) {
        cin >> c[i];
        for(int j=0;j<m;j++) cin >> a[i][j];
    }
    int res = INF;
    for(int i=0;i<(1<<n);i++) {
        int sum = 0;
        vector<int> b(m);
        for(int j=0;j<n;j++) {
            if(i>>j & 1) {
                sum += c[j];
                for(int k=0;k<m;k++) b[k] += a[j][k];
            }
        }
        bool ok = true;
        for(int j=0;j<m;j++) {
            if(b[j] < x) {
                ok = false;
                break;
            }
        }
        if(ok) res = min(res, sum);
    }
    if(res == INF) cout << -1 << endl; 
    else cout << res << endl;
    return 0;
}


Measured memory_bytes: 3656
H,W = map(int, input().split())
s = [input() for _ in range(H)]

import sys
for j in range(1,H-1):
    for i in range(1,W-1):
        if s[j][i] =='#':
            if s[j][i-1] == '#':
                pass
            elif s[j-1][i] == '#':
                pass
            elif s[j][i+1] == '#':
                pass
            elif s[j+1][i] == '#':
                pass
            else:
                print('No')
                sys.exit()
print('Yes')

Measured memory_bytes: 9136
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <iomanip>

using namespace std;

/********** TEMPLATE STARTS HERE ***********/

#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define gcd __gcd 
#define digits(n) (int)(log10(n) + 1)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vl;
typedef vector <pll> vll;
typedef vector <pii> vii;

const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;

template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

/********** TEMPLATE ENDS HERE ***********/

main()
{
	IOS
	
	int s = 0;
	
	int mx = 0;
	
	for(int i = 1; i <= 3; i++)
	{
		int x;
		cin >> x;
		
		s += x;
		mx = max(mx, x);
	}
	
	int k;
	cin >> k;
	
	s -= mx;
	
	while(k--)
		mx *= 2;
	
	cout << s + mx;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set =
tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
class FT{
private:
    vector<ll>ft;
public:
    FT(int n){
        ft.assign(n+1,0);
    }
    ll sum(int a){
        ll ans=0;
        for(;a;a-=(a&-a))
            ans=max(1LL*ft[a],ans);
        return ans;
    }
    ll rsq(int a,ll b){
        ll x=sum(b)-sum(a-1);
        return x;
    }
    void update(int a,ll b){
        for(;a<(int)ft.size();a+=(a&-a))
            ft[a]=max(ft[a],1LL*b);
    }
};
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int a;
    cin>>a;
    vector<ll>vec(a),ans(a);
    vector<ll>f(a);
    FT x(a);
    for(auto &it:vec)
        cin>>it;
    for(auto &it:ans)
        cin>>it;
    for(int i=0;i<a;i++){
        if(vec[i]==1){
            f[i]=ans[i];
            x.update(vec[i],1LL*ans[i]);
            continue;
        }
        ll s=x.sum(vec[i]-1);
        f[i]=s+ans[i];
        x.update(vec[i],1LL*f[i]);
    }
    cout<<*max_element(f.begin(),f.end());
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define mp make_pair
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define N 1000005  //check the limits, man
const ll INF = 1e18;
int fun(int n,int p)
{
    int x=0;
    while(n>1)
    {
        x+=(n/p);
        n/=p;
    }
    return x+1;
}
int isprime[N];
void sieve()
{
    int i,a;
    fill(isprime+2,isprime+N,1);
    for(i=2;i*i<N;i++)
    {
        if(isprime[i])
            for(a=i*i;a<N;a+=i)isprime[a]=0;
    }
    return ;
}
int main()
{
    ll ans=1;
    int i,n;
    in(n);
    sieve();
    for(i=2;i<=n;i++)
        if(isprime[i])ans=(ans*fun(n,i))%M;
    llout(ans);
}


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

typedef long l;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(t, c) for (auto&& t : c)
#define ALL(c) begin(c), end(c)
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define mp make_pair

const int DX[] = {1, 0, -1, 0, 1, 1, -1, -1}, DY[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

  string s, t;
  cin >> s >> t;

  string t1 = t.substr(0, s.size());

  if (s == t1) {
    cout << "Yes";
  } else {
    cout << "No";
  }

  cout << endl;

}



Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;


int N;
vector<int> A;




int main()
{
	unordered_map<int, int> mp;
	cin >> N;
	

	A = vector<int>(N);

	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
		mp.insert(make_pair(A.at(i),i+1));
	}


	cout << mp[1];
	for (int i = 2; i <= N; i++) {
		cout << " "<< mp[i];

	}

	cout << endl;

	return 0;
}


Measured memory_bytes: 5284
#include<cstdio>
#include<vector>
#define For(i,A,B) for(i=(A);i<=(B);++i)
using namespace std;
const int N=200050;
int G[N],to[N<<1],nxt[N<<1],sz,dep[N],cnt[2],p=-1,tot[3],n,s[N];
inline int newnum(int x){
    if(tot[x]){
        --tot[x];
        return x?tot[x]*3+x:tot[x]*3+3;
    }else return tot[0]--*3;
}
inline int newnum(){
    if(tot[1])return newnum(1);
    else return newnum(2);
}
inline void adde(int u,int v){
    to[++sz]=v;nxt[sz]=G[u];G[u]=sz;
    to[++sz]=u;nxt[sz]=G[v];G[v]=sz;
}
void dfs(int u,int fa,int d){
    int i,v;
    ++cnt[dep[u]=d];
    for(i=G[u];i;i=nxt[i])if((v=to[i])!=fa)dfs(v,u,d^1);
}
void Dfs(int u,int fa){
    int i,v;
    if(dep[u]==p)s[u]=newnum(0);
    else if(p==-1)s[u]=newnum(dep[u]+1);
    else s[u]=newnum();
    for(i=G[u];i;i=nxt[i])if((v=to[i])!=fa)Dfs(v,u);
}
int main(){
    int i,u,v;
    scanf("%d",&n);
    For(i,2,n){
        scanf("%d%d",&u,&v);
        adde(u,v);
    }
    dfs(1,0,0);
    tot[0]=n/3;tot[1]=(n+2)/3;tot[2]=(n+1)/3;
    if(cnt[0]<=n/3)p=0;
    else if(cnt[1]<=n/3)p=1;
    Dfs(1,0);
    For(i,1,n)printf("%d ",s[i]);
    puts("");
    return 0;
}

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

int main() {
	int h,w,t;
	string s;
	cin >> h >> w;
	for(int i=0;i<h;i++){
		cin >> s;
		t=-1;
		for(int j=0;j<w;j++){
			if(s[j]=='c'){
				t=0;
			}else{
				if(t!=-1){
					t++;
				}
			}
			if(j>0){
				cout << ' ';
			}
			cout << t;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

vec kmp_table(string Pattern) {
    ll i = 2, j = 0;
    vec T(Pattern.size(), -1);
    T[1] = 0;

    while (i < Pattern.size()) {
        if (Pattern[i-1] == Pattern[j]) {
            T[i] = j+1;
            i++;
            j++;
        } else if (j > 0) {
            j = T[j];
        } else {
            T[i] = 0;
            i++;
        }
    }

    return T;
}

vec kmp_search (string Text, string Pattern, vec kmptable) {
    vec ret;
    ll m = 0, i = 0;
    while (m+i < Text.size()) {
        if (Pattern[i] == Text[m+i]) {
            i++;
            if (i == Pattern.size()) {
                if (m % 32 == 0) ret.push_back(m/32);
                i--;
                m = m+i-kmptable[i];
                i = kmptable[i];
            }
        } else {
            m = m+i-kmptable[i];
            if (i > 0) i = kmptable[i];
        }
    } 
    return ret;
}

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

    ll N;
    cin >> N;
    vec A(N), B(N);
    Rep (i, N) cin >> A[i];
    Rep (i, N) cin >> B[i];

    vec da(N), db(N);
    stringstream ssa, ssb;
    Rep (i, N) {
        da[i] = A[i] ^ A[(i+1)%N];
        db[i] = B[i] ^ B[(i+1)%N];
        ssa << bitset<32>(da[i]);
        ssb << bitset<32>(db[i]);
    }

    string sa = ssa.str();
    string sb = ssb.str();

    // cout << sa << "\n";
    // cout << sb << "\n";

    sa += sa;
    sa.pop_back();
    vec t = kmp_table(sb);
    t = kmp_search(sa, sb, t);
    Rep (i, t.size()) {
        cout << t[i] << " " << (A[0] ^ B[(N-t[i])%N]) << "\n";
    }

}

Measured memory_bytes: 161468
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=2000005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }
int fact[N],inv[N];
void pre()
{
    fact[0]=1;
    inv[0]=1;
    for(int i=1;i<N;i++)
    fact[i]=(i*fact[i-1])%mod;
    for(int i=1;i<N;i++)
    inv[i]=power(fact[i], mod-2, mod);
}
int nCr(int n, int r) 
{ 
    if(n==r)
    return 1;
    if (r==0) 
    return 1; 
    return (((fact[n]*inv[r]) % mod )*inv[n-r])%mod;
} 

int32_t main()
{
    IOS;
    pre();
    int k;
    string s;
    cin>>k>>s;
    int n=s.size();
    int tot=n+k;
    int ans=0;
    for(int i=n;i<=tot;i++)
    {
        ans+=(nCr(tot, i)*power(25, tot-i, mod))%mod;
        ans%=mod;
    }
    cout<<ans;
}

Measured memory_bytes: 35512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

int main() {
	fast_io;
	int n;
	cin >> n;
	vl a(n);
	for (int i = 0;i < n;i++)
		cin >> a[i];
	sort(all(a));
	ll ans = 1;
	long double ans2 = 1;
	for (int i = 0;i < n;i++) {
		if (ans2 * a[i] > 2e18) {
			cout << "-1\n";
			return 0;
		}
		else {
			ans2 *= a[i];
			ans *= a[i];
			if (ans > 1000000000000000000LL) {
				cout << "-1\n";
				return 0;
			}
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3956
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <set>

using namespace std;

int main(){
    // 引数の受け取り
    int A,B,C;
    scanf("%d %d %d", &A, &B, &C);
    int F = 0;
    set<int> st{A,B,C};
    F= st.size();
    printf("%d", F);
    return 0;
}


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

using LL = long long;

// ABC 114 C
// DFS 

// HOW TO DO 
// 1. input 
//    int N 
//    
// 2. 全探索：もし３、５、７全てが含まれてたら ans++
//    a: 3 が含まれていたら１
//    b: 5 が含まれていたら１
//    c: 7 が含まれていたら１
//    3-> 5-> 7-> の順に*１０で桁増やす

//    ex) 575 
//    x: 3353 a: 1 b:  1 c:  0
//    x: 0 a: 0 b:  0 c:  0
//    x: 3 a: 1 b:  0 c:  0
//    x: 33 a: 1 b:  0 c:  0
//    x: 333 a: 1 b:  0 c:  0
//    x: 3333 a: 1 b:  0 c:  0 -> return 
//    x: 3335 a: 1 b:  1 c:  0 -> return
//    x: 3337 a: 1 b:  0 c:  1 -> return
//    x: 335 a: 1 b:  1 c:  0
//    x: 3353 a: 1 b:  1 c:  0 -> return
//    x: 3355 a: 1 b:  1 c:  0 -> return
//    x: 3357 a: 1 b:  1 c:  1 -> return
//    x: 337 a: 1 b:  0 c:  1
//    x: 3373 a: 1 b:  0 c:  1 -> return
//    x: 3375 a: 1 b:  1 c:  1 -> return
//    x: 3377 a: 1 b:  0 c:  1 -> return
//    x: 35 a: 1 b:  1 c:  0
//    x: 353 a: 1 b:  1 c:  0
//    x: 3533 a: 1 b:  1 c:  0 -> return
//    x: 3535 a: 1 b:  1 c:  0 -> return
//    x: 3537 a: 1 b:  1 c:  1 -> return
//    x: 355 a: 1 b:  1 c:  0
//    x: 3553 a: 1 b:  1 c:  0 -> return
//    x: 3555 a: 1 b:  1 c:  0 -> return
//    x: 3557 a: 1 b:  1 c:  1 -> return
//    x: 357 a: 1 b:  1 c:  1 -----------> ans ++ 
//    x: 3573 a: 1 b:  1 c:  1 -> return
//    x: 3575 a: 1 b:  1 c:  1 -> return
//    x: 3577 a: 1 b:  1 c:  1 -> return
//    x: 37 a: 1 b:  0 c:  1
//    x: 373 a: 1 b:  0 c:  1
//    x: 3733 a: 1 b:  0 c:  1 -> return
//    x: 3735 a: 1 b:  1 c:  1 -> return
//    x: 3737 a: 1 b:  0 c:  1 -> return
//    x: 375 a: 1 b:  1 c:  1 -----------> ans ++ 
\
// 3.  output ans


LL n,ans=0;

void dfs(LL x,LL a,LL b,LL c){ 
  if(x>n) return ;
  if(a&&b&&c) ans++;
  dfs(x*10+3,1,b,c);
  dfs(x*10+5,a,1,c);
  dfs(x*10+7,a,b,1);
  
}
signed main(){
  // input 
  cin>>n;

  // find 753
  dfs(0,0,0,0);

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


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  int n; cin >>n;
  vector<int> A(n); rep(i, n) cin >>A[i];
  sort(all(A));
  // いずれかを書き換えるのを全通り試すが、n*nだと間に合わないので前いくつかと後ろいくつかのgcdをあらかじめ計算しておく
  vector<int> prev(n, A[0]);   // prev[i] := A[0], A[1], ..., A[i] の最大公約数を格納
  for (int i=1; i<n; i++) prev[i] = gcd(prev[i-1], A[i]);
  vector<int> latt(n, A[n-1]); // latt[i] := A[i], A[i+1], ..., A[n-1] の最大公約数を格納
  for (int i=n-2; i>=0; i--) latt[i] = gcd(latt[i+1], A[i]);
  int res = 1;

  // 書き換えた時の最大公約数について全てチェックする
  rep(i, n){
    int buf;
    if (i == 0) buf = gcd(latt[1], A[1]);
    else if (i == n-1) buf = gcd(prev[n-2], A[n-2]);
    else buf = gcd( gcd( prev[i-1], latt[i+1] ), A[i+1] );
    chmax(res, buf);
  }
  cout <<res <<endl;
}


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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 5010, M = 1010;

int n;
string s;

bool check(int len)
{
	map<string, int> h;
	for (int i = 0; i <= n - len; i ++ )
	{
		string t = s.substr(i, len);
		if (h.count(t))
		{
			if (h[t] + len <= i) return true;
		}
		else h[t] = i;
		
	}
	return false;
}

int main()
{
	cin >> n >> s;
	
	int l = 0, r = n;
	while (l < r)
	{
		int mid = l + r + 1 >> 1;
		if (check(mid)) l = mid;
		else r = mid - 1;
	}
	
	cout << r << endl;
	return 0;
}

Measured memory_bytes: 6672
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll maxn = 2e5 + 5;
ll a[maxn];
int main()
{
    ios::sync_with_stdio(false);
    ll k; cin >> k;
    ll n; cin >> n;
    ll ans = 0;
    for (int i = 1 ; i <= n;  i++) {
        cin >> a[i];
    }
    sort(a + 1 , a + 1 + n);
    ll dist = 0;
    for (int i = 1 ; i < n ;i++){
        dist = max(dist , a[i + 1] - a[i]);
        if(i == 1)  dist = max(dist , k - a[n] + a[1]);
    }
    cout << k - dist << endl;
    return 0;
}

Measured memory_bytes: 1792
// J,O,Iはひとまとめで3次元配列にするべきだった。
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0560
#include <iostream>
#include <algorithm>
using namespace std;

int output(int X[1010][1010], int p, int q, int r, int s) {
  return X[r][s] - X[p][s] - X[r][q] + X[p][q];
}

char JOI[1010][1010];
int a[100010], b[100010], c[100010], d[100010];
int J[1010][1010], O[1010][1010], I[1010][1010];

int main() {
  int M, N;
  cin >> M >> N;
  int K;
  cin >> K;
  for (auto i=1; i<=M; i++) {
    for (auto j=1; j<=N; j++) {
      cin >> JOI[i][j];
    }
  }
  for (auto i=0; i<K; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--; b[i]--;
  }
  fill(&J[0][0], &J[0][0]+1010*1010, 0);
  fill(&O[0][0], &O[0][0]+1010*1010, 0);
  fill(&I[0][0], &I[0][0]+1010*1010, 0);
  for (auto i=1; i<=M; i++) {
    for (auto j=1; j<=N; j++) {
      J[i][j] = ((JOI[i][j] == 'J') ? 1 : 0);
      O[i][j] = ((JOI[i][j] == 'O') ? 1 : 0);
      I[i][j] = ((JOI[i][j] == 'I') ? 1 : 0);
    }
  }
  for (auto i=1; i<=M; i++) {
    for (auto j=0; j<=N; j++) {
      J[i][j] += J[i-1][j];
      O[i][j] += O[i-1][j];
      I[i][j] += I[i-1][j];
    }
  }
  for (auto i=0; i<=M; i++) {
    for (auto j=1; j<=N; j++) {
      J[i][j] += J[i][j-1];
      O[i][j] += O[i][j-1];
      I[i][j] += I[i][j-1];
    }
  }
  for (auto i=0; i<K; i++) {
    cout << output(J, a[i], b[i], c[i], d[i])
         << " "
         << output(O, a[i], b[i], c[i], d[i])
         << " "
         << output(I, a[i], b[i], c[i], d[i])
         << endl;
  }
}

Measured memory_bytes: 15652
#include<bits/stdc++.h>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
const int N=1e5+5;
#define ll long long
#define inf 0x3f3f3f3f
#define mem(x) memset(x,0,sizeof(x))
#define sca(x) scanf("%d",&x)
#define scall(x) scanf("%lld",&x)
#define eps 1e-6

int main()
{
	for(int i=1;i<=5;i++)
	{
		int x;sca(x);
		if(x==0)
		cout<<i<<endl;
	}
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    for (int i=1; i<=2000; i++) {
        if ((int)(1.08 * i) - i == a && (int)(1.10 * i) - i == b) {
            cout << i << '\n';
            return 0;
        }
    }
    cout << -1 << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n, m; cin >> n >> m;
	string s; cin >> s;
	int flag;
	VI ans(0);
	for (int i = n; i >= 0; i--) {
		flag = 0;
		for (int j = max(0,i - m); j < i; j++) {
			if (s[j] == '0') {
				ans.push_back(i - j);
				flag = 1;
				if (j == 0) {
					for (int k = ans.size() - 1; k >= 0; k--)
						cout << ans[k] << ' ';
					return 0;
				}
				i = j + 1;
				break;
			}
		}
		if (flag == 0) {
			cout << -1;
			return 0;
		}
	}
}

Measured memory_bytes: 1528
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

print(800*N-N//15*200)


Measured memory_bytes: 5272
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<vector>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#pragma GCC target("avx")
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC diagnostic error "-std=c++14"

#define isNum(a) (a>='0'&&a<='9')
#define SP putchar(' ')
#define EL putchar('\n')
#define ri register int

template<class T>
inline void in(T&);
template<class T>
inline void out(const T&);

typedef long long ll;
using std::min;
using std::max;
using std::abs;
using std::sort;
using namespace std;

ll n,s[200005],a[200005],ans[200005],sum,x[200005],y[200005];

inline ll c(ll n,ll m)
{
	if (n<m) return  0ll;
	if (n==m) return 1ll;
	if (m==1) return n;
	return c(n-1,m-1)+c(n-1,m);
}

int main()
{
    in(n);
    for (ri i=1;i<=n;++i) in(a[i]),++s[a[i]];
    for (ri i=1;i<=n;++i) x[i]=c(s[i],2ll),y[i]=c(s[i]-1ll,2ll),sum+=x[i];
    for (ri i=1;i<=n;++i) out(sum-x[a[i]]+y[a[i]]),EL;
    return 0;
}

template<class T>
void in(T &Re)
{
    T k=0;
    char ch=getchar();
    int flag=1;
    while (!isNum(ch))
	{
        if (ch=='-')
		{
            flag=-1;
        }
        ch=getchar();
    }
    while (isNum(ch))
	{
        k=(k<<1)+(k<<3)+ch-'0';
        ch=getchar();
    }
    Re=flag*k;
}

template<class T>
void out(const T &Wr)
{
    if (Wr<0)
	{
        putchar('-');
        out(-Wr);
    }
	else
	{
        if (Wr<10)
		{
            putchar(Wr+'0');
        }
		else
		{
            out(Wr/10);
            putchar((Wr%10)+'0');
        }
    }
}




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

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


    int count = 0;
    bool flag = 1;

    int minv = 1001001001;


    for (int i = 0; i < n; i++){
        cin >> a;
        if (a < minv){
            count++;
        }
        minv = min(minv, a);
    }

    cout << count << endl;

    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
using datas=pair<ll,ll>;
using tdata=pair<datas,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncrlistp[200000],modncrlistm[200000];

ll modncrs(ll n,ll r){
  ll i,j;
  if(modncrlistp[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistp[i])break;
    }
    if(i<0){
      modncrlistp[0]=1;
      rep1(i,n+1){
        modncrlistp[i]=(modncrlistp[i-1]*i)%mod;
      }
    }else{
      For(j,i+1,n+1){
        modncrlistp[j]=(modncrlistp[j-1]*j)%mod;
      }
    }
  }
  if(modncrlistm[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistm[i])break;
    }
    if(i<0){
      modncrlistm[0]=1;
      rep1(i,n+1){
        modncrlistm[i]=(modncrlistm[i-1]*modinv(i))%mod;
      }
    }else{
      For(j,i+1,n+1)modncrlistm[j]=(modncrlistm[j-1]*modinv(j))%mod;
    }
  }
  return (((modncrlistp[n]*modncrlistm[r])%mod)*modncrlistm[n-r])%mod;
}

ll modncr(ll n,ll r){
  if(r*2>n)return modncr(n,n-r);
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}

int main(){
  ll i,N,ans,bf;
  cin>>N;
  string s,t;cin>>s>>t;
  if(s[0]==t[0]){
    ans=3;
    bf=i=1;
  }else{
    ans=6;
    bf=i=2;
  }
  while(i<N){
    if(s[i]==t[i]){
      if(bf==1){
        ans=(ans*2)%mod;
      }
      bf=1;
    }else{
      if(bf==1){
        ans=(ans*2)%mod;
      }else{
        ans=(ans*3)%mod;
      }
      bf=2;
    }
    i+=bf;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int count = 0,sum = 0;
		float suuryou = 0;
		while(sc.hasNext()){
			String[] line =sc.next().split(",");
			int a = Integer.parseInt(line[0]);
			int b = Integer.parseInt(line[1]);
			sum += a*b;
			suuryou += b;
			count++;
		}
		float average = suuryou/count;
		int res = Math.round(average);
		System.out.println(sum);
		System.out.println(res);
	}

}

Measured memory_bytes: 25868
h,w=gets.split.map &:to_i
arr=Array.new(h){Array.new(w,0)}

# マス目を二次元配列にする
h.times do |i|
  tmp=[]
  tmp=gets.chomp.chars
  w.times do |j|
    arr[i][j]=tmp[j]
  end
end

# マス目を'.'で囲う
arr.map do |i|
  i.push('.')
  i.unshift('.')
end
arr.push(Array.new(w+2,'.'))
arr.unshift(Array.new(w+2,'.'))

# マスを置き換えて出力
1.upto(h) do |i|
  1.upto(w) do |j|
    cnt=0
    cnt+=1 if arr[i-1][j-1] === '#'
    cnt+=1 if arr[i-1][j] === '#'
    cnt+=1 if arr[i-1][j+1] === '#'        
    cnt+=1 if arr[i][j-1] === '#'
    cnt+=1 if arr[i][j+1] === '#'
    cnt+=1 if arr[i+1][j-1] === '#'
    cnt+=1 if arr[i+1][j] === '#'
    cnt+=1 if arr[i+1][j+1] === '#'
    print arr[i][j] === '#' ? '#' : cnt
  end
  print "\n"
end

Measured memory_bytes: 2172
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    static final Scanner     sc = new Scanner(System.in);
    static final PrintStream so = System.out;
    
    public static void main(String[] args) {
        long W = nl();
        long H = nl();
        long x = nl();
        long y = nl();
        so.print((double) (W * H) / 2);
        so.print(" ");
        so.println(x*2 == W && y*2 == H ? 1 : 0); 
    }

    private static int ni() {
        return sc.nextInt();
    }

    private static long nl() {
        return sc.nextLong();
    }

    private static String ns() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0);
    }

    private static long[] nlongs(int n, int padding) {
        long[] a = new long[padding + n];
        for (int i = 0; i < n; i++)
            a[padding + i] = ni();
        return a;
    }
}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
    
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) {
        cin >> h.at(i);
    }
    int ans = 0;
    rep(i,n) {
        if (h.at(i) >= k) ans += 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }
#define int long long
typedef long long LL;

const int N = (int) 3e5 + 5, mod = (int) 0;
int pre[N], suf[N], a[N];
int32_t main() {
	int n;
	cin >> n;
	for (int j = 0; j < 3 * n; ++j)
		cin >> a[j];
	{
		set<pair<int, int>, greater<pair<int, int>>> st;
		long long sum = 0;
		for (int j = 2 * n + 1; j < 3 * n; ++j) sum += a[j], st.insert(mp(a[j], j));
		for (int s = 2 * n; s >= n; --s) {
			st.insert(mp(a[s], s));
			sum += a[s];
			while ((int) st.size() > n) {
				auto cur = *(st.begin());
				sum -= cur.first;
				st.erase(cur);
			}
			suf[s] = sum;
		}
	}
	{
		set<pair<int, int>> st;
		int sum = 0;
		for (int j = 0; j < n - 1; ++j) sum += a[j], st.insert(mp(a[j], j));
		for (int j = n - 1; j < 2 * n; ++j) {
			st.insert(mp(a[j], j));
			sum += a[j];
			while ((int) st.size() > n) {
				auto cur = *(st.begin());
				sum -= cur.first;
				st.erase(cur);
			}
			pre[j] = sum;
		}
	}
	long long res = -1e18;
	for (int j = n - 1; j < 2 * n; ++j) {
		res = max(res, pre[j] - suf[j + 1]);
	}
	cout << res << endl;
}



Measured memory_bytes: 12800
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

 
void solve(){
    string s;
    cin >> s;
    int ans = 1e9;;
    for(int i = 0; i < s.size() - 2; i++){
        int x = (s[i] - 48) * 100 + (s[i + 1] - 48) * 10 + (s[i + 2] - 48);
        ans = min(ans, abs(x - 753));
    }
    cout << ans;
}

 
int main() {
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
//#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
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 n,a;
int main(void) {
    cin >> n >> a;
    if (n % 500 > a) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b = MAP()
print("Odd" if a*b%2 == 1 else "Even")

Measured memory_bytes: 5148