akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto N = readln.chomp.to!int;
    int[] as;
    int[3] ns;
    foreach (c; readln.chomp) {
        auto a = c - '1';
        ++ns[a];
        as ~= a;
    }

    foreach (ref a; as) {
        if (ns[1] == 0) {
            a /= 2;
        } else if (a == 2) {
            a = 0;
        }
    }

    // Lucas' theorem
    auto ls = new bool[](N);
    ls[0] = true;
    loop: foreach (x; 1..N) {
        static foreach (i; 0..20) if (((N-1)&(1<<i)) < (x&(1<<i))) continue loop;
        ls[x] = true;
    }

    int x;
    foreach (i, a; as) if (ls[i]) x ^= a;
    writeln(x == 1 ? ns[1] > 0 ? 1 : 2 : 0);
}

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

using namespace std;
int main(){
	long long L,R;
	cin>>L>>R;
	if(R-L>2019) cout<<0<<endl;
	else{
		long long ans=1e18;
		for( int i=L;i<=R;i++){
			for(int j=i+1;j<=R;j++){
				ans=min(ans,(long long)((long long)i%2019*(long long)j%2019)%2019);
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

vector<ll>prime_enum(int n){
	vector<bool>is_prime(n+1,true);
	is_prime[0]=is_prime[1]=false;
	vector<ll>res;
	for(int i=2;i<=n;i++){
		if(!is_prime[i])continue;
		res.push_back(i);
		for(int j=2*i;j<=n;j+=i){
			is_prime[j]=false;
		}
	}
	return res;
}
int main(){
	auto prime=prime_enum(100000);
	vector<P>v;
	for(ll i:prime)v.push_back(P(i*i,i));
	int n;scanf("%d",&n);
	ll ans=0;
	bool flag=false;
	map<map<ll,int>,int>mp;
	rep(i,n){
		ll s;scanf("%lld",&s);
		map<ll,int>res;
		for(ll j:prime){
			while(s%j==0){
				res[j]++;
				s/=j;
			}
			if(j>2200)break;
		}
		auto it=lower_bound(prime.begin(),prime.end(),s);
		if(it!=prime.end()&&*it==s){
			res[s]++;
			s=1;
		}
		auto it2=lower_bound(v.begin(),v.end(),P(s,0));
		if(it2!=v.end()&&it2->first==s){
			res[it2->second]+=2;
			s=1;
		}
		if(s!=1){
			ans++;
			continue;
		}
		map<ll,int>m;
		for(auto p:res){
			if(p.second%3)m[p.first]=p.second%3;
		}
		if(m.size()==0){
			flag=true;
		}
		else mp[m]++;
	}
	ans+=flag;
	while(mp.size()){
		auto res=*mp.begin();mp.erase(mp.begin());
		map<ll,int>m;
		for(auto p:res.first){
			m[p.first]=3-p.second;
		}
		auto it=mp.find(m);
		if(it!=mp.end()){
			ans+=max(res.second,it->second);
			mp.erase(it);
		}
		else ans+=res.second;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 21884
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> cnt(n + 1);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        ++cnt[a];
        ++cnt[b];
    }
    for (int k : cnt) {
        if (k & 1) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int n;
	cin >> n;
    vector<P> red(n);
    vector<P> blue(n);
    rep(i,n){
        int a, b;
        cin >> a >> b;
        red[i] = make_pair(a, b);
    }
    rep(i,n){
        int a, b;
        cin >> a  >> b;
        blue[i] = make_pair(b, a);
    }

    sort(red.begin(), red.end());
    sort(blue.begin(), blue.end());
    int result = 0;
    bool red_bool[n];
    bool blue_bool[n];
    rep(i,n){red_bool[i] = false; blue_bool[i] = false;}

    rep(i, n){
        for(int j = n-1; j >= 0; j--){

            if(!red_bool[j] && !blue_bool[i] && red[j].first < blue[i].second && red[j].second < blue[i].first){
                red_bool[j] = true;
                blue_bool[i] = true;
                result++;
            }
        }
    }

	
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
import math
def Fa(x):
    return math.factorial(x)

for i in range(1,k+1):
    if k-i < 0 or n-k+1-i < 0:
        print(0)
    else:
        print((Fa(n-k+1)*Fa(k-1)//(Fa(i-1)*Fa(k-i)*Fa(n-k+1-i)*Fa(i)))%(10**9 +7))

Measured memory_bytes: 3316
import sys
input = sys.stdin.buffer.readline # 入出力高速化

def main():
    N, Q = map(int, input().split())
    tl = [] # イベントタイムライン
    for _ in range(N):
        S, T, X = map(int, input().split())
        tl.append((S-X, 1, X)) # insert
        tl.append((T-X, 0, X)) # erase
    for _ in range(Q):
        D = int(input())
        tl.append((D, 2, 0)) # min
    tl.sort()
    working = set() # 工事中
    wcur = 0 # 工事中の区域の数
    curmin = -1
    flag = False
    for t, c, x in tl:
        if c == 0: # erase
            wcur -= 1
            working.remove(x)
            if x <= curmin:
                curmin = x
                flag = True
        elif c == 1: # insert
            wcur += 1
            working.add(x)
            if curmin < 0 or curmin >= x:
                curmin = x
                flag = False
        else: # min
            if wcur == 0:
                curmin = -1
                flag = False
            elif flag:
                curmin = min(working)
                flag = False
            print(curmin)
    return
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 124084
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    string N;
    cin >> N;
    int check=0;
    rep(i,0,3){
        if(N.at(i)=='7'){
            check = 1;
        }
    }
    if(check==1){
        cout <<"Yes"<<endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int dp[2020][2020];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, x; cin >> N >> x;
    int ans = INF2;
    int A[2020];
    rep(i, N) cin >> A[i];
    rep(i, N) {
        rep(j, N) {
            if (j == 0)
                dp[i][j] = A[i];
            else 
                dp[i][j] = min(dp[i][j - 1], A[(i - j + N) % N]);
        }
    }
    // rep(i, N) {
    //     rep(j, N) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    rep(cnt, N) {
        int tmp = 0;
        rep(i, N) tmp += dp[i][cnt];
        ans = min(ans, tmp + cnt * x);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 31872
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

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

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	REP(i, t) fact[i+1]=fact[i]*(i+1)%MOD;
	fact_inv[t]=power(fact[t], MOD-2);
	FORR(i, 0, t) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
  ll i,j;
  ll ans = 0;
  int n;
  string s; cin >> n >> s;
  int number = 0;

  FOR(i,0,s.length()){
      number = (s[i] - 'A' + n) % 26;
      s[i] = 'A' + number;
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n, d = map(int,input().split())
xy = []
for i in range(n):
    xy.append([int(i) for i in input().split()])

ans = 0
for i in range(n):
    if (xy[i][0] ** 2 + xy[i][1] ** 2) ** 0.5 <= d:
        ans += 1
print(ans)


Measured memory_bytes: 42628
from collections import defaultdict
def main():
    n, k = map(int, input().split())
    D = defaultdict(int)
    for _ in range(n):
        a, b = map(int, input().split())
        D[a] += b
    for d in sorted(D.items(), key = lambda x: x[0]):
        k -= d[1]
        if k <= 0:
            print(d[0])
            break

if __name__ == '__main__':
    main()


Measured memory_bytes: 21244
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:1024000000")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#ifndef _MSC_VER
#pragma GCC target ("sse4.2")
#endif
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#  define __builtin_popcountll __popcnt64
#endif
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <random>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef pair<ll, ll> pll;
typedef vector< pii > vpii;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;


int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	int kk;
	cin >> kk;
	ll res = 0;
	for (int i = 1; i <= kk; i++)
		for (int j = 1; j <= kk; j++)
			for (int k = 1; k <= kk; k++)
				res += gcd(gcd(i, j), k);
	cout << res;
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
const int N=200010,oo=1e9;
int n,a[N];
vector<int> point[N];
int edge_tot,to[N],from[N];
void add_edge(int a,int b){
	point[a].push_back(edge_tot);
	from[edge_tot]=a,to[edge_tot]=b;
	edge_tot++;
	return;
}
int dfn[N],low[N],sta[N],top,timer,tot;
bool ins[N],inc[N];
void tarjan(int k){
	int x;
	sta[top++]=k,ins[k]=1;
	dfn[k]=low[k]=++timer;
	for(int i=0;i<point[k].size();i++){
		x=to[point[k][i]];
		if(!dfn[x]) tarjan(x);
		if(ins[x]) low[k]=min(low[k],low[x]);
	}
	if(dfn[k]==low[k]){
		if(sta[top-1]!=k) while(sta[top]!=k) inc[sta[--top]]=1,ins[top]=0;
		else ins[sta[--top]]=0;
	}
	return;
}
int num[N];
void solve1(int k,bool b){
	vector<int>temp;
	int x,tot=2;
	temp.push_back(oo);temp.push_back(oo);
	for(int i=0;i<point[k].size();i++){
		x=to[point[k][i]];
		if(inc[x]&&b) continue;
		if(num[x]==-1) solve1(x,b);
		temp.push_back(num[x]);
		tot++;
	}
	sort(temp.begin(),temp.begin()+tot);
	for(int i=0;i<tot;i++){
		if(temp[i]!=i){
			num[k]=i;
			return;
		}
	}
}
bool vis[N];
bool pd(int k){
	vector<int>temp;
	int i,x,tot=2;
	temp.push_back(oo);temp.push_back(oo);
	for(i=0;i<point[k].size();i++){
		x=to[point[k][i]];
		if(inc[x]) continue;
		temp.push_back(num[x]);
		tot++;
	}
	sort(temp.begin(),temp.begin()+tot);
	for(i=0;i<tot;i++){
		if(temp[i]!=i){
			num[k]=i;
			break;
		}
	}
	int nxt=a[k],now=k;
	while(nxt!=k){
		solve1(nxt,0);
		now=nxt,nxt=a[now];
	}
	if(num[nxt]!=num[now]) return 1;
	int kk=i;
	for(i=i+1;i<tot;i++){
		if(temp[i]!=i){
			num[k]=i;
			break;
		}
	}
	nxt=a[k],now=k;
	while(nxt!=k){
		solve1(nxt,0);
		now=nxt,nxt=a[now];
	}
	if(num[now]==kk) return 1;
	return 0;
}
int main(){
	int fir;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		add_edge(a[i],i);
	}
	for(int i=1;i<=n;i++)
		if(!dfn[i]) tarjan(i);
	bool flag=0;
	memset(num,-1,sizeof(num));
	for(int i=1;i<=n;i++){
		if(inc[i]) fir=i;
		if(num[i]==-1) solve1(i,1);
	}
	memset(vis,0,sizeof(vis));
	if(pd(fir)) cout<<"POSSIBLE"<<endl;
	else cout<<"IMPOSSIBLE"<<endl;
	return 0;
}

Measured memory_bytes: 26624
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#define ll long long
#define maxn 200005
#define maxx 300005
#include<time.h>
#include<vector>
#include<list>
#define INF 0x7fffffffffffffff
using namespace std;
int n,m;
vector<int> g[maxx];
struct node
{
    int x,y;
}p[maxx];
int pre[maxx];
inline int findd(int x)
{
    return pre[x]==x?x:pre[x]=findd(pre[x]);
}
int out[maxx];
void dfs(int u,int last)
{
    for(int i=0;i<g[u].size();i++)
    {
        int v=g[u][i];
        if(v==last)continue;
        dfs(v,u);
        if(out[v]&1)
            printf("%d %d\n",v,u);
        else
        {
            out[u]++;
            printf("%d %d\n",u,v);
        }
    }
}
int main()
{
    cin>>n>>m;
    for(int i=1;i<=m;i++)
        scanf("%d%d",&p[i].x,&p[i].y);
    if(m&1)
    {
        cout<<-1<<endl;
        return 0;
    }
    for(int i=1;i<=n;i++)pre[i]=i;
    for(int i=1;i<=m;i++)
    {
        int xx=findd(p[i].x);
        int yy=findd(p[i].y);
        if(xx!=yy)
        {
            g[p[i].x].push_back(p[i].y);
            g[p[i].y].push_back(p[i].x);
            pre[xx]=yy;
        }
        else
        {
            printf("%d %d\n",p[i].x,p[i].y);
            out[p[i].x]++;
        }
    }
    dfs(1,0);
    return 0;
}


Measured memory_bytes: 21632
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i, m, n) for (int i = int(m); i < int(n); i++)
#define RREP(i, m, n) for (int i = int(n) - 1; i >= int(m); --i)
#define EACH(i, c) for (auto &(i) : c)
#define all(c) begin(c), end(c)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(begin(c), end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x) cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) \
    do           \
    {            \
    } while (0)
#define dump(x) \
    do          \
    {           \
    } while (0)
#define BR
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int, int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template <class T>
inline T sqr(T x) { return x * x; }

void solve()
{
    LL h, w;
    cin >> h >> w;
    if (h % 3 == 0 || w % 3 == 0)
    {
        cout << 0 << endl;
        return;
    }
    LL ans = h * w / 2;
    REP(i, 0, h)
    {
        LL a = i * w;
        LL b = (h - i) * (w / 2);
        LL c = (h - i) * (w - w / 2);
        LL diff = max({abs(a - b), abs(b - c), abs(c - a)});
        ans = min(ans, diff);
    }
    swap(h, w);
    REP(i, 0, h)
    {
        LL a = i * w;
        LL b = (h - i) * (w / 2);
        LL c = (h - i) * (w - w / 2);
        LL diff = max({abs(a - b), abs(b - c), abs(c - a)});
        ans = min(ans, diff);
    }
    cout << min({ans, h, w}) << endl;
}

int main()
{
    solve();

    return 0;
}

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

int main(){
  int a, b ,c;
  cin >> a >> b >> c;
  int n = 0;
  for (int i=a;i<=b;i++){
    if (c%i==0){
      n++;
    }
  }
  cout << n << endl;
}



Measured memory_bytes: 3104
@inbounds function main()
  h,w,m=parse.(Int,split(readline()))
  hc=Dict{Int,Int}()
  wc=Dict{Int,Int}()
  hw=Set{Tuple{Int,Int}}()
  for i=1:m
    hi,wi=parse.(Int,split(readline()))
    push!(hw,(hi,wi))
    hc[hi]=get(hc,hi,0)+1
    wc[wi]=get(wc,wi,0)+1
  end
  mh=first(findmax(hc))
  mw=first(findmax(wc))
  hs = filter(p->p.second==mh,hc) |> keys
  ws = filter(p->p.second==mw,wc) |> keys
  for i=hs
    for j=ws
      (i, j) ∉ hw && return println(mh+mw)
    end
  end
  println(mh+mw-1)
end
main()

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


    return 0;
}


Measured memory_bytes: 3644
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

k=int(input())
sum=0
for i in range(1,k+1):
    for j in range(i+1,k+1):
        for k in range(j+1,k+1):
            # print('(',i,j,k,')')
            # print(gcd(i,j,k))
            sum+=gcd(i,j,k)*3*2
for i in range(1,k+1):
    for j in range(i+1,k+1):
            # print('(',i,j,j,')')
            # print(gcd(i,j,j))
            sum+=gcd(i,j,j)*3*2
for i in range(1,k+1):
        # print('(',i,i,i,')')
        # print(gcd(i,i,i))
        sum+=gcd(i,i,i)
print(sum)

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

using namespace std;

long long cnt[100001];

int main () {
	string s;
	cin >> s;
	for (int i = 0;i < s.size ();i ++) {
		cnt[s[i] - 'a' + 1] ++;
	}
	long long n = s.size ();
	long long ans = (n * (n - 1)) / 2;
	for (int i = 1;i <= 26;i ++) {
		ans -= (cnt[i] * (cnt[i] -	 1)) / 2;
	}
	cout << ans + 1;
	return 0;
}

Measured memory_bytes: 640
#include"stdio.h"
#include"iostream"
#include"math.h"
#include"algorithm"
#include"vector"
#include"stack"
#include"queue"
#define scanf scanf_s
using namespace std;


long long int N, x;
long long int a[100001];
long long int b[100001];
int main() {
	cin >> N >> x;
	for (long long int i = 0; i < N;i++) {
		cin >> a[i];
	}
	for (long long int i = 0; i < N - 1;i++) {
		b[i] = a[i] + a[i + 1];
	}


	bool complete_flag = false;

	long long int cnt = 0;
	while (!complete_flag) {
		complete_flag = true;
		for (long long int i = 0; i < N-1;i++) {
			long long int sub = b[i] - x;
			if (sub > 0) {
				complete_flag = false;
				cnt += sub;
				if (i == 0 ) {
					if (sub > a[i + 1]) {
						long long int ssub = sub - a[i + 1];
						a[i] -= ssub;
						b[i] -= ssub;
						b[i - 1] -= ssub;
						sub = a[i + 1];
						
					}
					a[i + 1] -= sub;
					b[i] -= sub;
					b[i + 1] -= sub;
				}
				else if(i == N-1 ){
					
					if (sub > a[i]) {
						long long int ssub = sub - a[i];
						a[i + 1] -= ssub;
						b[i] -= ssub;
						b[i + 1] -= ssub;
						sub = a[i];
					}
					a[i] -= sub;
					b[i - 1] -= sub;
					b[i] -= sub;
					
				}
				else {
					if (b[i-1]>b[i]) {
						if (sub > a[i]) {
							long long int ssub = sub -a[i];
							a[i+1]-=ssub;
							b[i] -= ssub;
							b[i + 1] -= ssub;
							sub = a[i];
						}
						a[i] -= sub;
						b[i - 1]-=sub;
						b[i]-=sub;
					}
					else {
						if (sub > a[i+1]) {
							long long int ssub = sub - a[i + 1];
							a[i] -= ssub;
							b[i] -= ssub;
							b[i - 1] -= ssub;
						}
						a[i + 1] -= sub;
						b[i]-=sub;
						b[i + 1]-=sub;
					}
				}
				
			}
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1792
import sys

def mode(list1):
    dic = {}
    for n in list1:
        if n in dic:
            dic[n] += 1
        else:
            dic[n] = 1
    max1 = 0
    num1  = -1
    for key in dic:
        if max1 < dic[key]:
            max1 = dic[key] 
            num1 = key

    max2 = 0
    num2 = -1
    for key in dic:
        if key == num1:
            continue
        if max2 < dic[key]:
            max2 = dic[key] 
            num2 = key
    return max1,num1,max2,num2

n = int(input())
vlist = list(map(int,input().split()))

if min(vlist) == max(vlist):
    print(n//2)
    sys.exit()

alist=[]
blist=[]
for i in range(n//2):
    alist.append(vlist[2*i])
    blist.append(vlist[2*i+1])

amax,ka,amax2,ka2 = mode(alist)
bmax,kb,bmax2,kb2 = mode(blist)

if ka != kb:
    ans = n - amax - bmax
else:
    if amax2 <= bmax2:
        ans =n - amax -bmax2
    else:
        ans =n - bmax -amax2
print(ans)


Measured memory_bytes: 15716
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static final int MOD = (int) (Math.pow(10, 9) + 7);

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        Map<Integer, Set<Integer>> map = new HashMap<>();
        for (int i = 0; i < m; i++) {
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            if (map.containsKey(a)) {
                map.get(a).add(b);
            } else {
                Set<Integer> set = new HashSet<>();
                set.add(b);
                map.put(a, set);
            }
        }
        if (!map.containsKey(1)) {
            System.out.println("IMPOSSIBLE");
            return;
        }
        Set<Integer> nset = map.get(1);
        for (int a : nset) {
            Set<Integer> aset = map.get(a);
            if (aset != null && aset.contains(n)) {
                System.out.println("POSSIBLE");
                return;
            }
        }
        System.out.println("IMPOSSIBLE");
    }
}

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

int main() {
  string n;
  cin >> n;
  
  if((n[0]==n[1]&&n[1]==n[2])||(n[1]==n[2]&&n[2]==n[3])){
	cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, k;
  cin >> n >> k;
  set<ll> d;
  rep(i, k) {
    ll a;
    cin >> a;
    d.insert(a);
  }
  rep2(i, n, 1e6) {
    vl v;
    ll a = i;
    while(a > 0) {
      v.push_back(a % 10);
      a /= 10;
    }
    bool ok = true;
    for(ll u : v)
      if(d.count(u)) ok = false;
    if(!ok) continue;
    cout << i << endl;
    return 0;
  }
}

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

int main(){
  long int N,K;
  long int p[222222];
  cin >> N >> K;
  long long int i;
  for(i=0;i<=N-1;i++)
    cin >> p[i];
  long long int sum[222222];
  long long int max;
  sum[0] = 0;
  for(i=0;i<=K-1;i++)
    sum[0] += p[i];
  max = sum[0];
  
  for(i=0;i<=N-K-1;i++){
    sum[i+1] = sum[i] + p[i+K] - p[i];
    if(sum[i+1] > max) max = sum[i+1];
    }
  if((max + K)%2==0) cout << (max + K) / 2 << ".000000000" << endl;
  else cout << (max + K) / 2 << "." << 500000000 << endl;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	vector<ll> a(n);
	ll sum=0;
	for (int i=0; i<n; i++)
		cin>>a[i], sum+=a[i];
	ll pre=a[0], ret=abs(pre-(sum-pre));
	for (int i=1; i<n-1; i++)
		pre+=a[i], ret=min(ret,abs(pre-(sum-pre)));
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long m = sc.nextLong();
		long d = sc.nextLong();
		
		double tester = 1;
		double cas = (n-d)*2;
		if(d==0)cas=n-d;
		cas*=(m-1);
		cas/=n;
		cas/=n;
//		System.out.printf("%.12f", cas);
		System.out.println(cas);
	}

}


Measured memory_bytes: 25044
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
#define rep(i, s, n) for(int i = s;i<n;i++)

int main(void) {
    vector<long long int> h;
    int N, K;
    cin >> N >> K;
    for (int i = 0; i < N; ++i) {
        long long int temp;
        cin >> temp;
        h.push_back(temp);
    }

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

    long long int m = 9999999999;
    for (int i = 0; i < (N - K + 1); ++i) {
        m = min(h[K + i - 1] - h[i], m);
    }
    cout << m << endl;
}

Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
    double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
    while (cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2) {
        if (yb1 <= ya2 && yb2 >= ya1 && xb1 <= xa2 && xb2 >= xa1) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;
const int INF=1001001001;

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int K,T;
  cin>>K>>T;
  vector<int>a(T);
  for(int i=0;i<T;i++){
    cin>>a[i];
  }
  int cnt=0;
  for(int i=0;i<T;i++){
    if(a[i]-1-(K-a[i])>0){cnt+=(a[i]-1)-(K-a[i]);}
  }
  cout<<cnt<<endl;
  return 0;  
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

int main() {
	char x;
	char alphabet[27] = { "abcdefghijklmnopqrstuvwxyz" };
	int number[27] = { 0 };
	int i, j;

	while ( scanf("%c", &x) != EOF) {	//EOFで抜けてくれない
		x = tolower(x);
		for (j = 0; alphabet[j] != '\0'; j++) {
			if (x == alphabet[j]) {
				number[j]++;
			}
		}
	}

	for (i = 0; alphabet[i] != '\0'; i++) {
		printf("%c : %d\n" ,alphabet[i] ,number[i]);
	}

	return 0;
}


Measured memory_bytes: 2048
s = list(map(ord, input()))
K = int(input())

asca = 97
ascz = 122
start = 0
lens = len(s)

loop = lambda x: asca if x == ascz else x+1

for k in range(K):
    if start == lens - 1:
        for i in range((K-k) % (ascz - asca + 1)):
            s[start] = loop(s[start])
        break
    for i in range(start, lens):
        c = s[i]
        if i == lens - 1:
            s[i] = loop(c)
            break
        if c == asca:
            start += 1
            continue
        v = c + (K-k)
        if v > ascz:
            s[i] = loop(c)
            break
        else:
            continue
print(''.join(map(chr, s)))


Measured memory_bytes: 52000
#include <iostream>

using namespace std;

int main(){
    string str;
    while(true){
        cin >> str;
        if(str.at(0) == '0') break;
        int sum = 0;
        for(int i = 0; i<str.size(); i++){
            sum += int(str.at(i) - '0');
        }
        cout << sum << endl;
    }
    
    return 0;
}



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

#define pb emplace_back
#define fi first
#define se second
#define m_p make_pair
#define vi vector<int>
#define pi pair<int, int>
#define mem(a,b) memset(a,b,sizeof(a))
#define el cout<<endl
#define sz(a) (int)a.size()
const int mod = (int)1e9+7;
typedef long long int ll;

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N = (int)1e5+5;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int k,x;
	cin>>k>>x;
	for(int i=x-k+1;i<=x+k-1;i++) cout<<i<<" ";
	el;	
}

ll power(ll a,ll b, ll md=mod){
	ll r=1;
	while(b){
		if(b%2) 
			r=(r*a)%md;
		a=(a*a)%md;
		b>>=1;
	}
	return r;
}

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

struct node{
	int s,e,m;
	long long v;
	node *l,*r;
	node(int S,int E){
		s=S;e=E;m=(s+e)/2;v=0;
		if(s!=e){
			l=new node(s,m),r=new node(m+1,e);
		}
	}
	void upd(int x,long long nv){
		if(s==e){v=nv;return;}
		if(x<=m)l->upd(x,nv);
		else r->upd(x,nv);
		v=min(l->v,r->v);
	}
	long long qry(int x,int y){
		if(s==x&&e==y)return v;
		if(y<=m)return l->qry(x,y);
		if(x>m)return r->qry(x,y);
		return min(l->qry(x,m),r->qry(m+1,y));
	}
}*root;

int main(){
	int n; long long x;
	scanf("%d%lld",&n,&x);
	root=new node(0,n*2);
	long long arr[n];
	for(int i=0;i<n;i++){scanf("%lld",&arr[i]);root->upd(i,arr[i]);root->upd(i+n,arr[i]);}
	long long ans=1012345678012345678LL;
	for(int i=0;i<n;i++){
		long long cur=0;
		for(int j=0;j<n;j++){
			cur+=root->qry(j,j+i);
		}
		ans=min(ans,cur+(long long)(i)*x);
	}
	printf("%lld",ans);
}


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

typedef pair<int, int> P;

int main() {
  int h, w;
  cin>>h>>w;
  string s[h];
  for (int i=0; i<h; i++) cin>>s[i];

  int l[h][w], r[h][w], u[h][w], d[h][w];
  for (int i=0; i<h; i++) {
    l[i][0] = (s[i][0] == '.');
    r[i][w-1] = (s[i][w-1] == '.');
  }
  for (int i=0; i<w; i++) {
    u[0][i] = (s[0][i] == '.');
    d[h-1][i] = (s[h-1][i] == '.');
  }
  for (int i=0; i<h; i++) {
    for (int j=1; j<w; j++) {
      if (s[i][j] == '.') {
        l[i][j] = l[i][j-1] + 1;
      } else {
        l[i][j] = 0;
      }
    }
  }
  for (int i=0; i<h; i++) {
    for (int j=w-2; j>=0; j--) {
      if (s[i][j] == '.') {
        r[i][j] = r[i][j+1] + 1;
      } else {
        r[i][j] = 0;
      }
    }
  }
  for (int i=1; i<h; i++) {
    for (int j=0; j<w; j++) {
      if (s[i][j] == '.') {
        u[i][j] = u[i-1][j] + 1;
      } else {
        u[i][j] = 0;
      }
    }
  }
  for (int i=h-2; i>=0; i--) {
    for (int j=0; j<w; j++) {
      if (s[i][j] == '.') {
        d[i][j] = d[i+1][j] + 1;
      } else {
        d[i][j] = 0;
      }
    }
  }

  int ans = 0;
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      ans = max(ans, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 66816
#include <stdio.h>

int main(void)
{
	long long A[100][100];
	long long B[100][100];
	long long C[100][100];
	int n;				//表の行列数
	int m;				//表の行列数
	int l;				//表の行列数
	int i;
	int j;
	int k;

	//表を初期化する
	for (i = 0; i < 100; i++)
	{
		for (j = 0; j < 100; j++)
		{
			A[i][j] = B[i][j] = C[i][j] = 0;
		}
	}

	//表の行列数n、m、l、を入力する
	scanf("%d%d%d", &n, &m, &l);

	//行列Aに数値を入力する
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			scanf("%d", &A[i][j]);
		}
	}

	//行列Bに数値を入力する
	for (i = 0; i < m; i++)
	{
		for (j = 0; j < l; j++)
		{
			scanf("%d", &B[i][j]);
		}
	}

	//行列Cに計算結果を入れる
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < l; j++)
		{
			for (k = 0; k < m; k++)
			{
				C[i][j] += (A[i][k] * B[k][j]);
			}
		}
	}

	//結果を出力する
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < l; j++)
		{
			printf("%ld", C[i][j]);
			if (j < l - 1)
				printf(" ");
		}
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 2148
# coding: utf-8


def solve(*args: str) -> str:
    n = int(args[0])
    R = [tuple(map(int, ab)) for ab in map(str.split, args[1:n+1])]
    B = [tuple(map(int, ab)) for ab in map(str.split, args[n+1:2*n+1])]

    R.sort(key=lambda x: (-x[1], x[0]))
    B.sort(key=lambda x: (x[0], x[1]))

    count = 0
    used = [False]*n
    for i in range(n):
        bx, by = B[i]
        for j in range(n):
            if used[j]:
                continue
            rx, ry = R[j]
            if rx < bx and ry < by:
                count += 1
                used[j] = True
                break

    return str(count)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


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

void solve(int TestCase) {
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    
    int cnt = 0;
    auto l = vector<int>(n);
    auto r = vector<int>(n);
    
    for(auto i = 0; i < n; ++i)
    {
        if(s[i] == 'o') {
            l[cnt++] = i;
            i += c;
        }
    }

    cnt = 0;
    for(auto i = n-1; i >= 0; --i)
    {
        if(s[i] == 'o') {
            r[cnt++] = i;
            i -= c;
        }
    }

    for(auto i = 0; i < k; ++i)
    {
        if(l[i] == r[k-1-i])
            cout << (l[i] + 1) << endl;        
    }
}
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    int t = 1;
    //cin >> t;
    for(auto i = 1; i <= t; ++i) {
    //    cout << "Case #"<< i << ": ";
        solve(i);
    }
}

Measured memory_bytes: 3348
#include <stdio.h>

int main()
{
    int a,b,c,cnt,i;
    scanf("%d %d %d", &a, &b, &c);
	for(i=a,cnt=0;i<=b;i++){
		if((c%i)==0){
			cnt++;
		}
	}
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 596
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] d = new int[k];
		int[][] a = new int[k][n];
		for (int i = 0; i < k; i++) {
			d[i] = sc.nextInt();
			for (int j = 0; j < d[i]; j++) {
				a[i][j] = sc.nextInt();
			}
		}
		sc.close();

		Set<Integer> set = new HashSet<>();
		for (int i = 0; i < k; i++) {
			for (int j = 0; j < d[i]; j++) {
				set.add(a[i][j]);
			}
		}
		System.out.println(n - set.size());
	}
}


Measured memory_bytes: 46712
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	N := nextInt()
	M := nextInt()
	wacunter := make([]int, N+1)
	accepted := make([]bool, N+1)
	for i := 0; i < M; i++ {
		p := nextInt()
		s := nextString()
		if s == "AC" {
			accepted[p] = true
		} else if accepted[p] == false {
			wacunter[p]++
		}
	}
	ac_cnt := 0
	wa_cnt := 0
	for i := 1; i < N+1; i++ {
		if accepted[i] {
			ac_cnt++
			wa_cnt += wacunter[i]
		}
	}
	fmt.Println(ac_cnt, wa_cnt)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 2304
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

#define INF 1<<28
#define MAX_N 103
int n;
int b[2][MAX_N];

void input() {
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < n; j++) {
            cin >> b[i][j];
        }
    }
    b[0][n] = b[0][n+1] = b[1][n] = b[1][n+1] = 2;
}

int ts[2][MAX_N];
void init_ts() {
    for (int i = 0; i < 2; i++) for (int j = 0; j < MAX_N; j++) ts[i][j] = INF;
}
void debug() {
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < n; j++) {
            printf("%3d", ts[i][j] == INF ? -1 : ts[i][j]);
        }
        printf("\n");
    }
}

void solve() {
    init_ts();
    for (int d = 0; d < 2; d++) {
        int t = 0;
        int c = d;
        for (int s = 0; ; c = (c+1) % 2, s+=2) {
            if (b[c][s] == 1) {
                while (b[c][s] == 1) s++; 
                s--;
            }
            if (b[c][s] == 2) {
                while (b[c][s] == 2) 
                    s--;
            }
            if (ts[c][s] <= t) {
                break;
            }
            ts[c][s] = t;
            t++;
        }
    }
    int ans = min(ts[0][n-1], ts[1][n-1]);
    if (ans >= INF) {
        cout << "NA" << endl;
    } else {
        cout << ans << endl;
    }
}

int main() {
    while (cin >> n, n) {
        input();
        solve();
    }
    return 0;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define Task ""

using namespace std;
typedef long long ll;

const int maxn = 2e5 + 5;

vector<pair<int, int>> adj[maxn];
int L[maxn], R[maxn], D[maxn];
int x[maxn];
bool vis[maxn];

void dfs(int u)
{
    vis[u] = 1;
    for (auto v : adj[u]){
        if (vis[v.fi] == 0){
            x[v.fi] = x[u] + v.se;
            dfs(v.fi);
        }
    }
}

signed main(void)
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (fopen("A.INP", "r")){
        freopen("A.INP", "r", stdin);
        freopen("A.OUT", "w", stdout);
    }
    if (fopen(Task".INP", "r")){
        freopen(Task".INP", "r", stdin);
        freopen(Task".OUT", "w", stdout);
    }
    int N, M; cin >> N >> M;
    for (int i=1; i<=M; ++i){
        cin >> L[i] >> R[i] >> D[i];
        adj[L[i]].pb(mp(R[i], D[i]));
        adj[R[i]].pb(mp(L[i], -D[i]));
    }
    for (int i=1; i<=N; ++i){
        if (vis[i] == 0){
            dfs(i);
        }
    }
    for (int i=1; i<=M; ++i){
        if (x[R[i]] - x[L[i]] != D[i]){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}


Measured memory_bytes: 15872
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  
  cout << a*b/2 <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+5;
int n,cnt,f[maxn];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++) f[i]=1;
	for(int i=2;i<n;i++){
		for(int j=i;j<n;j+=i) ++f[j];
	}
	for(int i=1;i<n;i++) cnt+=f[i];
	printf("%d",cnt);
	return 0;
}

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

using namespace std;

typedef unsigned long long int ulli;

int main(){
    int n;
    
    map<int,pair<int,int> > mp;
    
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3;j++){
            int in;
            cin >> in;
            mp[in] = {i+1,j+1};
        }
        
    }
    int arr[4][4];
    cin >> n;
    for(int i = 0; i < n; i++){
        int in;
        cin >> in;
        if(mp[in].first == 0 && mp[in].second == 0){continue;}
        arr[mp[in].first-1][mp[in].second-1] = 1;
    }
    for(int i = 0; i < 3; i++){
        int cnt = 0,cnt2 = 0;
        for(int j = 0; j < 3;j++){
            if(arr[i][j] == 1){cnt++;}
            if(arr[j][i] == 1){cnt2++;}
        }
        if(cnt == 3 || cnt2 == 3){cout << "Yes";exit(0);}
    }
    if(arr[0][0] == 1 && arr[1][1] == 1 && arr[2][2]){cout << "Yes";}
    else if(arr[2][0] == 1 && arr[1][1] == 1 && arr[0][2] == 1){cout << "Yes";}
    else{cout << "No";}
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "atcoder/all"
using namespace std;
//using namespace atcoder;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
const long long int sMod = 998244353;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans=-2000000000000000000;
    //chmax(ans,a*b);
    chmax(ans,a*c);
    chmax(ans,a*d);
    chmax(ans,b*c);
    chmax(ans,b*d);
    //chmax(ans,c*d);
    print(ans);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a > b) swap(a, b);
  if (a < c && c < b)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    private static int N;
    private static int[] A;
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        N = sc.nextInt();
        A = new int[N];
        
        for(int i=0; i<N; i++) {
            A[i] = sc.nextInt();
        }
        
        System.out.println(isApproved() ? "APPROVED" : "DENIED");
        
    }

    private static boolean isApproved() {
        
        for(int a :A) {
            if(a % 2 == 0) {
                if(a % 3 == 0 
                        || a % 5 ==0) {
                    continue;
                }else {
                    return false;
                }
            }
        }
        return true;
        
    }
}


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

using namespace std;

const string keys = "qwertasdfgzxcvb";

int main() {
    for (;;) {
        string s;
        cin >> s;
        if (s == "#") break;

        int res = 0;
        bool cur = keys.find(s.substr(0, 1)) != string::npos;
        for (int i = 1; i < s.size(); i++) {
            bool prev = cur;
            cur = keys.find(s.substr(i, 1)) != string::npos;
            if (cur != prev) {
                res++;
            }

        }

        cout << res << endl;
    }
}

Measured memory_bytes: 1196
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = br.readLine();
		
		int n = Integer.parseInt(input);
		
		String[] tmpArray = br.readLine().split(" ");
		int diff[] = new int[n];
		
		for(int i = 0; i < n; i++){
			diff[i] = Integer.parseInt(tmpArray[i]);
		}
		
		Arrays.sort(diff);
		
		int m = Integer.parseInt(br.readLine());
		
		tmpArray = br.readLine().split(" ");
		int test[] = new int[m];
		
		for(int i = 0; i < m; i++){
			test[i] = Integer.parseInt(tmpArray[i]);
		}
		
		Arrays.sort(test);
		
		int currentDindex = 0;
		for(int i = 0; i < m; i++){
			boolean hit = false;
			for(int j = currentDindex ; j < n; j++){
				if(diff[j] == test[i]){
					currentDindex = j + 1;
					hit = true;
					break;
				}
			}
			
			if(!hit){
				System.out.println("NO");
				return;
			}
		}
		
		System.out.println("YES");
	}

}


Measured memory_bytes: 88064
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    S = input()[:-1]
    T = input()[:-1]

    if S == T[:-1]:
        print("Yes")
    else:
        print("No")
    


if __name__ == '__main__':
    main()

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

int main(){
    int X;
    cin >> X;
    int N[X];
    for(int i = 0; i < X; ++i){
        cin >> N[i];
    }
    vector<int> X_result;
    X_result.assign(&N[0], &N[X]);
    sort(X_result.begin(), X_result.end());
    int counter = 1;
    for(int i = 0; i < X_result.size(); ++i){
        if(i != 0){
            if(X_result.at(i) > X_result.at(i - 1)){
                ++counter;
            }
        }
    }
    cout << counter << endl;
}



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

int main()
{
    long long n;
    cin >> n;
    int ans = 1e9;
    for (long long i = 1; i * i <= n; i++)
    {
        if (n % i) continue;
        ans = min(ans, (int)max(log10(i), log10(n / i)) + 1);
    }
    printf("%d\n",ans);
}


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

const int INF  = 0x3f3f3f3f;
const int MAXN = 1e3+7;

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


Measured memory_bytes: 256