akhauriyash/Code-Regression huggingface dataset:
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.sizes = [0]*n

    def find(self, x):
        if x == self.par[x]:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            retrn;
        if self.sizes[x] < self.sizes[y]:
            x,y = y,x

        self.par[y] = x;
        self.sizes[x] += self.sizes[y]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, a):
        return sizes[self.find[x]]

class Edge:
    def __init__(self, s, t, w):
        self.s = s
        self.t = t
        self.w = w
    def __lt__(self, other):
        return self.w < other.w

def kruskal(edges, n):
    edges = sorted(edges)
    uf = UnionFind(n)
    min_cost = 0

    for edge in edges:
        if not uf.same(edge.s, edge.t):
            min_cost += edge.w
            uf.unite(edge.s, edge.t)

    return min_cost

v, e = map(int, input().split())
es = []
for i in range(e):
    s, t, w = map(int, input().split())
    es.append(Edge(s, t, w))
print(kruskal(es, v))



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

int main() {
    string s, t;
    cin >> s >> t;

    vector<char> u, v;
    for (int i = 0; i < s.size(); i++) {
        u.push_back(s[i]);
    }
    sort(u.begin(), u.end());

    for (int i = 0; i < t.size(); i++) {
        v.push_back(t[i]);
    }
    sort(v.begin(), v.end(), greater<char>());

    if (u < v) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int) (n); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
char r[11] = {'y', 'u', 'i', 'o', 'p', 'h', 'j', 'k', 'l', 'n', 'm'};

int main(){
  string n;
  while(cin >> n and n != "#"){
    int res = 0;
    int code = 0;
    REP(i, n.size()){
      bool isright = false;
      REP(j, 11) if(n[i]==r[j]) isright = true;
      if((code == -1 and isright == true) or (code == 1 and isright == false)) res++;
      code = (isright ? 1 : -1);
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int N;
  cin >> N;
  if (N<1000) {
    cout << "ABC" << endl;
  }
  else {
    cout << "ABD" << endl;
  }
}


Measured memory_bytes: 3560
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	int flag=0,ans=0;
	cin>>s;
	int a=s.length();
	for(int i=0;i<a;i++)
	{
		if(s[i]=='S')
		flag++;
		if((flag)&&s[i]=='T')
		{
			flag--;
			ans+=2;
		}
	}
	cout<<a-ans<<endl;
}


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

using namespace std;

const int N = 200005;

int n;
char s[N];

int main() {
	scanf("%s", s);
	n = (int)strlen(s);
	for(int i = 0; i < n; i++) {
		if(s[i] == '?') s[i] = 'D';
	}
	printf("%s\n", s);
}


Measured memory_bytes: 3852
parseInt(x) = parse(Int, x)

fare(a,b) = abs(a-b)

function diff(i,j,k)
	if i <= j <= k || k <= j <= i
		return(0)
	elseif abs(i-j) > abs(j-k)
		return(2*fare(j,k))
	else
		return(2*fare(i,j))
	end
end

function main()
	n = parseInt(readline())
	a = map(parseInt, split(readline()))
	b = Array{Int}(n+2)
	b[1] = 0
	b[2] = fare(0,a[1])
	for i in 2:n
		b[i+1] = b[i] + fare(a[i-1],a[i])
	end
	b[n+2] = b[n+1]+fare(a[n],0)
	println(b[n+2]-diff(0,a[1],a[2]))
	for i in 2:n-1
		println(b[n+2]-diff(a[i-1],a[i],a[i+1]))
	end
	println(b[n+2]-diff(a[n-1],a[n],0))
end

main()

Measured memory_bytes: 154204
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  double ans=N*2.0*M_PI;
  printf("%.10lf\n",ans);
  }


Measured memory_bytes: 3752
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

import numpy as np

n = int(readline())
graph = np.array([list(map(int, readline().split())) for _ in range(n)])
inf = 10 ** 10
ans = 0
for i in range(n):
    graph[i][i] = inf
for i in range(n):
    for j in range(i + 1, n):
        v = np.min(graph[i] + graph[j])
        if graph[i][j] > v:
            print(-1)
            exit()
        elif graph[i][j] < v:
            ans += graph[i][j]
print(ans)


Measured memory_bytes: 16336
a,b = map(int, input().split())
s = input()
f = 0
for i in range(a):
    if s[i]=="-":
        f = 1
if s[a]!="-":
    f = 1
for i in range(a+1,a+b+1):
    if s[i]=="-":
        f = 1
if f==0:
    print("Yes")
else:
    print("No")

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

using namespace std;

#define N 300000
#define INF 0x3f3f3f3f

int n,m,a[N],b[N],c[N],d[N],f1[N],f2[N],xb1,xb2,ans,tot,tmp,now,vis[N];
long long s1;
vector<int> g[N];

void gg(){
	puts("-1");
	exit(0);
}

int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;++i){
		scanf("%d%d%d",a+i,b+i,c+i);
		++d[a[i]]; ++d[b[i]];
		g[a[i]].push_back(i);
	}
	for (int i=1;i<=n;++i){
		if (!vis[i]){
			int x=i; bool flag=0;
			vector<int> q;
			while (1){
				q.push_back(x);
				if (vis[x]==1||g[x].size()!=1||d[x]!=2){
					flag=1; break;
				}
				x=b[g[x][0]];
				if (x==i) break;
			}
			if (flag){
				for (int y:q) vis[y]=1;
				continue;
			}
			x=i;
			int sum=0,num=0;
			while (1){
				++num;
				vis[x]=2;
				x=b[g[x][0]];
				sum+=c[g[x][0]]-1;
				if (x==i) break;
			}
			if (num>1){
				++tot; ++ans;
				s1+=sum;
			}
			else{
				if (sum>1) f1[++xb1]=sum-1;
			}
		}
	}
	for (int i=1;i<=m;++i){
		if (a[i]!=b[i]){
			if (!c[i]) gg();
			++ans;
		}
		if (vis[a[i]]==1){
			if (c[i]>1){
				if (a[i]!=b[i]) now+=c[i]-1;
				else f2[++xb2]=c[i]-1;
			}
		}
	}
	sort(f1+1,f1+xb1+1,greater<int>());
	sort(f2+1,f2+xb2+1,greater<int>());
	for (int i=1;i<=xb1;++i) f1[i]+=f1[i-1];
	for (int i=1;i<=xb2;++i) f2[i]+=f2[i-1];
	tmp=INF;
	for (int i=0,j=xb1;i<=xb2;++i){
		int t=now+f2[i];
		if (t==0&&tot) continue;
		t+=s1;
		for (;j&&t+f1[j-1]>=tot;--j);
		if (t+f1[j]>=tot) tmp=min(tmp,i+j*2); 
	}
	if (tmp>=INF) gg();
	printf("%d\n",ans+tmp);
	
	return 0;
}
			

Measured memory_bytes: 16020
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n=scan.nextInt();
		int a=scan.nextInt();
		int b=scan.nextInt();
		scan.close();

		int ans=0;
		for(int i=1;i<=n;i++) {
			String s=String.valueOf(i);
			int sum=0;
			for(int j=0;j<s.length();j++) {
				sum += Character.getNumericValue(s.charAt(j));
			}
			if(a<=sum&&sum<=b) {
				ans+=i;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i=1,i##_len=(n); i<=i##_len; ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for(int i=(s);i<(t);++i)
#define rng(obj) (obj).begin(), (obj).end()
#define maxs(x,y) (x=max((x),(y)))
#define mins(x,y) (x=min((x),(y)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T>>
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<pii>;
template <class T> inline istream& operator>>(istream&i,v(T)&v)
{ rep(j,sz(v))i>>v[j];return i;}
template <class T> string join(const v(T)&v)
{ stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)
{ if(sz(v))o<<join(v); return o;}
template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)
{ return i>>v.fi>>v.se;}
template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)
{ return o<<v.fi<<","<<v.se;}
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const double eps = 1e-10;
bool comp(pii a,pii b){
  return a.se<b.se;
}
//----------------------------------------------------------------

#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}
#define fastio ios_base::sync_with_stdio(false);
#define MOD 1000000007
//----------------------------------------------------------------
void Main(){
  string s;
  cin>>s;
  int cs=0;int ct=0;
  rep(i,s.length()){
    if(s[i]=='S'){cs++;}
    else{if(cs!=0) cs--;else ct++;}
  }
  cout<<cs+ct<<endl;
} int main(int argc,char* argv[]){ 
    fastio; fileio; Main();}

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

const int maxn = 19;
int n;
string s;

map< pair<string, string>, int> mp;
int ans;
int32_t main() {
	cin >> n >> s;
	reverse(s.begin() + n, s.end());
	for(int mask = 0; mask < (1LL << n); mask++) {
		string s1 = "", t1 = "";
		for(int i = 0; i < n; i++) {
			int bit = (mask >> i) & 1;
			if(bit)
				s1 += s[n + i];
			else
				t1 += s[n + i]; 
		}
		mp[{s1, t1}]++;
	}
	
	for(int mask = 0; mask < (1LL << n); mask++) {
		string s1 = "", t1 = "";
		for(int i = 0; i < n; i++) {
			int bit = (mask >> i) & 1;
			if(bit)
				s1 += s[i];
			else
				t1 += s[i];
		}
		ans += mp[{s1, t1}];
	}
	cout << ans << '\n';
}

Measured memory_bytes: 91904
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define vl vector<ll>
#define endl endl;cf
#define be begin()
#define sz size()
#define en end()
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0)
#define forn(i,a,b) for(ll i=1;i<=b;++i)
#define forr(i,a,b) for(ll i=0;i<b;++i)
#define rngx mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define cf cout.flush()
int main()
{
    ios;
    ll a , b , x ;
    cin >>a >> b >> x; 
    if(x > a+b or x < a) cout <<"NO\n";
    else cout <<"YES\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cstdlib>
#include <algorithm>
#define WMAX 10000
#define HMAX 10000

//コメントアウトするとdebug()を実行しない
#define DEBUG

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

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

int A,B,C,N,W,H,ans,dp[HMAX][WMAX];
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){
	ans = N * 800 - 200 * (N / 15);
}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	ios::sync_with_stdio(false);
	cin >> N;
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int a,b,c,x; cin>>a>>b>>c>>x;
	ll ans=0;
	rep(i,0,a+1){
		rep(j,0,b+1){
			rep(k,0,c+1){
				if(500*i+100*j+50*k==x)++ans;
			}
		}
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#define m 110000
using namespace std;
 int main(){
  int n,cnt;
  while(1){
    cin>>n;
    if(n==0) break;
    cnt=0;
    vector<bool>a(m+1,true);
    for(int i=2;i*i<=m;i++)
         if(a[i]) for(int j=i+i;j<=m;j+=i)  a[j]=false;   
    long long sum=0;   
    for(int i=2;i<=m;i++){
            if(a[i]!=0 && cnt<n) { sum+=i;cnt++;}
    }
    cout << sum << endl;  
  } 
  return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

void add(ll& a, ll b){a = (a+b) % MOD;}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> V(n),C(n);
    REP(i,n) cin>>V[i];
    REP(i,n) cin>>C[i];
    int ans=0;
    REP(i,n){
        if(V[i]>C[i]) ans+=(V[i]-C[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<string> vs(n);
    REP(i,n) cin >> vs[i];

    set<string> st;
    bool ans = true;
    REP(i,n) {
        auto r = st.insert(vs[i]);
        if (!r.second) {
            ans = false;
            break;
        }
        if (i != 0) {
            if (vs[i-1].back() != vs[i].front()) {
                ans = false;
                break;
            }
        }
    }

    ATYN(ans)

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
    a[i]--;
  }

  vector<ll> seg(m, 0), cost(m, 0);
  rep(i, n - 1) {
    seg[(a[i] + 1) % m]++;
    seg[a[i + 1]]--;
    cost[a[i + 1]] += (a[i + 1] - a[i] + m - 1) % m;
  }
  ll res = 0, cnt = 0;
  rep(i, n - 1) {
    if (a[i] < a[i + 1]) res += a[i + 1] - a[i];
    else {
      res += a[i + 1] + 1;
      if (a[i] != m - 1) cnt++;
    }
  }
  ll ans = res;
  rep(i, m - 1) {
    //cout << cnt << '\n';
    res += cost[i];
    cnt += seg[i];
    res -= cnt;
    chmin(ans, res);
    //cout << res << '\n';
  }
  cout << ans << '\n';


  




  
  return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(){
  int N;
  cin >> N;
 
  int d[300000];
  for(int i=0;i<N;i++){
    cin >> d[i];
  }
 
  int D=0;
 
  for(int i=0;i<N-1;i++){
    D=max(D,d[i]);
 
    if(D<10){
      cout << "no" << endl;
      return 0;
    }
 
    D-=10;
  }
 
  D=0;
 
  for(int i=N-1;i>0;i--){
    D=max(D,d[i]);
 
    if(D<10){
      cout << "no" << endl;
      return 0;
    }
 
    D-=10;
  }
 
  cout << "yes" << endl;
 
  return 0;
}


Measured memory_bytes: 4268
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    a = [int(i) for i in input().split()]
    
    if a[0] == 1:
        a[0]+=13
    if a[1] == 1:
        a[1]+=13


    if a[0] > a[1] :
        print("Alice")
    elif a[0] == a[1]:
        print("Draw")
    else:
        print("Bob")

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);


template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll HIGHINF = (ll)1e18;
const ll LOWINF = (ll)1e15;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	int N; cin >> N;
	string S; cin >> S; S = "."+S;
	V<V<ll>> dp(N+1,V<ll>(1<<3,0));
	dp[0][4] = 1;
	for(int i = 1; i <= N; ++i){
		int bit;
		if(S[i]=='J') bit = 2;
		if(S[i]=='O') bit = 1;
		if(S[i]=='I') bit = 0;
		
		for(int j = 1; j < (1<<3); ++j){
			for(int k = 1; k < (1<<3); ++k){
				if((j&k)==0) continue;
				if( !(k&(1<<bit)) ) continue;
				(dp[i][k] += dp[i-1][j] ) %= 10007;
			}
		}
	}
	cout << accumulate(ALL(dp[N]),0) % 10007 << endl;
	return 0;
}



Measured memory_bytes: 3208
#include <cstdio>
#include <cstdlib>

struct cell
{
  int y;
  int x;
};

int main()
{
  int h, w, d;
  scanf("%d%d%d", &h, &w, &d);
  cell cl[90001];
  for (int i = 0; i < h; ++i)
  {
    for (int j = 0; j < w; ++j)
    {
      int a;
      scanf("%d", &a);
      cl[a].y = i + 1;
      cl[a].x = j + 1;
    }
  }
  long long acc[90001];
  for (int i = 0; i < d; ++i)
  {
    for (int j = i; j <= h * w; j += d)
    {
      acc[j] = (j - d > 0 ? acc[j - d] + std::abs(cl[j - d].x - cl[j].x) + std::abs(cl[j - d].y - cl[j].y) : 0);
    }
  }
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; ++i)
  {
    int l, r;
    scanf("%d%d", &l, &r);
    printf("%lld\n", acc[r] - acc[l]);
  }
  return 0;
}

Measured memory_bytes: 2432
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
//#include <intrin.h>
//#include <chrono>
//#include <random>
//#include <unordered_map>

using namespace std;

typedef long long ll;

int gcd(int a, int b) {
	return b ? gcd(b, a % b) : a;
}

void solve() {
	int x;
	cin >> x;
	cout << 360 / gcd(360, x);
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		cout << '\n';
	}
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
using namespace std;
 
int main() 
{
  double r;
  cin >> r;
  double s,l;
  double pi = 3.14159265358979323846;
  s = r*r*pi;
  l = 2*pi*r;
  printf("%lf %lf\n",s,l);
  return 0;
}


Measured memory_bytes: 3300
/*
    Author: Arham_doshi
    @quote "Code like there's no tommorow!"
     ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
    */
    #include <bits/stdc++.h>
     
    #define int         long long
    #define double      long double
    #define pb          push_back
    #define pf          push_front
    #define pii         pair<int,int>
    #define vi          vector<int>
    #define vii         vector<pii>
    #define mi          map<int,int>
    #define mii         map<pii,int>
    #define all(a)      (a).begin(),(a).end()
    #define rall(a)     (a).rbegin(),(a).rend()
    #define x           first
    #define y           second
    #define sz(x)       (int)x.size()
    #define endl        '\n'
    #define hell        998244353
    #define PI          3.141592653589
    #define bs(v,n)     binary_search(all((v)),(n))
    #define lb(v,n)     lower_bound(all((v)),(n))
    #define ub(v,n)     upper_bound(all((v)),(n))
    #define fo(i,l,u)   for(i=l;i<u;i++)
    #define rfo(i,l,u)  for(i=l;i>=u;i--)
    #define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
    #define _init(b)     memset(b,-1,sizeof(b))
    #define _init0(b)     memset(b,0,sizeof(b))
    #define MOD         1000000007
     
     
     
    using namespace std;
     
    int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }  
    bool mod(double a,double b) {return a/b - floor(a/b);}
    int ceil(int n,int k){if(k%n==0){return k/n;}else return (k/n)+1;}
    int occurs(vi v,int n){
    auto it=lb(v,n);auto it1=ub(v,n);int x=it1-it;return x;}
     
    int logb(int base, int x) {
        return (log(x) / log(base));
    }

    signed main()
    {
        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
        int i,j,x,n,l,r,base;
        cin>>n;
       base=1;
       while(base<=n){
           base*=2;
       }
       vi tree(2*base);
       vi dp(n+1),h(n),b(n);
       
       fo(i,0,n){
           cin>>x;
            h[i]=x;   
       }
       fo(i,0,n){
           cin>>x;
           b[i]=x;
       }
       
       fo(i,0,n){
           x=h[i];
           dp[i]=b[i];
           l=base+x-1;
           r=0;
           while(l>0){
               if(l%2==1){
                  r=max(r,tree[l-1]); 
               }
               l/=2;
           }
           dp[i]+=r;
           
           l=base+x-1;
           while(l>0){
               tree[l]=max(tree[l],dp[i]);
               l/=2;
           }
           
       }
       cout<<tree[1];
        
        
     
        
        
        
   
        return 0;
    }

Measured memory_bytes: 9088
#include <iostream>

using namespace std;

int main(){
	int d, l, num;

	cin >> d >> l;
	num = 0;

	if (d % l == 0){
		num = d / l;
	}
	else {
		num = (d / l) + (d % l);
	}

	cout << num << endl;

}

Measured memory_bytes: 3084
#include <cmath>
#include <cstdio>
using namespace std;
int main(){
	double x, n;
	scanf("%lf", &x);
	n = x / 1.08;
	for (int i = 0; i <= 1000; i++){
		int t = int(n) + i;
		if (floor(t * 1.08) == x){
			printf("%d\n", t);
			return 0;
		}
		t -= 2 * i;
		if (floor(t * 1.08) == x){
			printf("%d\n", t);
			return 0;
		}
	}
	printf(":(\n");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long a,b;
long long gcd(long long x,long long y)
{
	if(x%y==0) return y;
	return gcd(y,x%y);
}
int main() {
	scanf("%lld%lld",&a,&b);
	printf("%lld",a*b/gcd(a,b));
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
    ll n,m;cin>>n>>m;
    if(n==m)cout<<"Yes";
    else cout<<"No";
    return 0;  
} 

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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  sort(d.begin(), d.end());
  int div2 = n / 2;
  if(n % 2 != 0) {
    cout << 0 << endl;
    return 0;
  }
  else {
    if(d[div2] - d[div2-1] == 0) {
      cout << 0 << endl;
      return 0;
    }
    else if(d[div2] - d[div2-1] >= 1) {
      int ans = d[div2] - d[div2-1];
      cout << ans << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3712
#include<iostream>
#include<algorithm>

using namespace std;

class Node {
public:
	int value;
	Node* parent;
	Node* left;
	Node* right;
	Node(int v);
};

Node::Node(int v) {
	value = v;
	parent = NULL;
	left = right = NULL;
}

class Binary_Indexed_Tree {
public:
	int length;
	Node* root;
	Binary_Indexed_Tree(int n);
	void add(int index, int v);
	long long sum(int index);
};

Binary_Indexed_Tree::Binary_Indexed_Tree(int n) {
	Node *nod = new Node(0);
	root = nod;
	length = n;
	for (int i = 1;i <= n;i++) {
		Node* now = root;
		int l = 1;
		int r = n;
		while (r - l >= 1) {
			int mid = (r + l) / 2;
			if (i <= mid) {
				r = mid;
				if (now->left == NULL) {
					Node* nod = new Node(0);
					now->left = nod;
				}
				now = now->left;
			}
			else {
				l = mid + 1;
				if (now->right == NULL) {
					Node* nod = new Node(0);
					now->right = nod;
				}
				now = now->right;
			}
		}

	}

}
void Binary_Indexed_Tree::add(int index, int v) {
	int l = 1;
	int ri = length;
	root->value += v;
	Node* now = root;
	while (ri - l >= 1) {
		int mid = (ri + l) / 2;
		if (index <= mid) {
			ri = mid;
			now = now->left;
			now->value += v;
		}
		else {
			l = mid + 1;
			now = now->right;
			now->value += v;
		}
	}
}
long long Binary_Indexed_Tree::sum(int index) {
	long long ans = 0;
	int l = 1, r = length;
	Node* now = root;
	while (1) {
		if (r == l)break;
		int mid = (r + l) / 2;
		if (mid <= index) {
			ans += now->left->value;
			now = now->right;
			l = mid + 1;
		}
		else {
			now = now->left;
			r = mid;
		}
	}
	if (l <= index)ans += now->value;
	return ans;
}

class query {
public:
	int r, l, num;
};

inline bool operator<=(query a, query b) {
	return a.r <= b.r;
}
inline bool operator<(query a, query b) {
	return a.r < b.r;
}
inline bool operator>=(query a, query b) {
	return a.r >= b.r;
}
inline bool operator>(query a, query b) {
	return a.r > b.r;
}

int main() {
	int n, q;
	cin >> n >> q;
	int* color = new int[n];
	for (int i = 0;i < n;i++) {
		cin >> color[i];
	}
	query* qu = new query[q];
	for (int i = 0;i < q;i++) {
		qu[i].num = i;
		cin >> qu[i].l >> qu[i].r;
	}
	sort(qu, qu + q);
	Binary_Indexed_Tree BIT(n);
	int* good_ball = new int[n + 1];
	for (int i = 0;i <= n;i++) {
		good_ball[i] = -1;
	}
	int index = 0;
	pair<int, int>* ans = new pair<int, int>[q];
	for (int i = 0;i < q;i++) {
		for (;index < qu[i].r;index++) {
			if (good_ball[color[index]] == -1) {
				good_ball[color[index]] = index;
				BIT.add(index + 1, 1);
			}
			else {
				BIT.add(good_ball[color[index]] + 1, -1);
				good_ball[color[index]] = index;
				BIT.add(index + 1, 1);
			}
		}
		ans[i].first = qu[i].num;
		ans[i].second = BIT.sum(qu[i].r) - BIT.sum(qu[i].l-1);
	}
	sort(ans, ans + q);
	for (int i = 0;i < q;i++) {
		cout << ans[i].second << endl;
	}
}




Measured memory_bytes: 64408
#include<stdio.h>
char a[1000][1000];
int main()
{
    int n=0;
    scanf("%s %s",a[1],a[2]);
    for(int i=0; i<3; i++)
    {
        if(a[1][i]==a[2][2-i])
        {
            n=1;
        }
        else
        {
            n=0;
            break;
        }
    }
    if(n==1)
        printf("YES\n");
    else
    {
        printf("NO\n");
    }
   
}


Measured memory_bytes: 128
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
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

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

A, B, K = MAP()

print(max(0, A-K), max(0, min(B, B-(K-A))))


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

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

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

ll A, B, C, N, M, K, X, Y;
string S;
vector<ll> vec;

void solve() {

	cin >> N >> A >> B;

	cout << min(A*N, B);

}

int main() {
	solve();
	cout << endl;
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod=MOD){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}
ll const N=(ll)1e5+111;
ll const LG=(ll)log2(N)+1;


void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
        
        cin>>n;
        ll ans=0;
        map<ll,ll> mp;
        for(i=1;i<=100;i++){
                for(j=1;j<=100;j++){
                        for(k=1;k<=100;k++){
                                ll tt=i*i+j*j+k*k+i*j+i*k+j*k;
                                mp[tt]++;
                        }
                }
        }
        for(i=1;i<=n;i++){
                cout<<mp[i]<<endl;
        }
        
        
        
}       
int main(){
        FS;
        
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        while(q--){
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}


Measured memory_bytes: 6068
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// @@ !! LIM(f:updMaxMin)
// --> f:updMaxMin
// ---- inserted function updMaxMin from util.cc
template<typename T>
bool updMax(T& tmax, const T& x) {
  if (x > tmax) { tmax = x; return true;  }
  else          {           return false; }
}
template<typename T>
bool updMin(T& tmin, const T& x) {
  if (x < tmin) { tmin = x; return true;  }
  else          {           return false; }
}
// ---- end updMaxMin
// @@ !! LIM  -- end mark --

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N, Ma, Mb; cin >> N >> Ma >> Mb;
  vector<ll> A(N), B(N), C(N);
  for (ll i = 0; i < N; i++) cin >> A[i] >> B[i] >> C[i];
  
  ll lim = 400;
  vector cur(lim + 1, vector(lim + 1, LLONG_MAX));
  cur[0][0] = 0;
  for (ll i = 0; i < N; i++) {
    vector prev = move(cur);
    cur = vector(lim + 1, vector(lim + 1, LLONG_MAX));
    for (ll x = 0; x < lim + 1; x++) {
      for (ll y = 0; y < lim + 1; y++) {
	if (prev[x][y] == LLONG_MAX) continue;
	updMin(cur[x + A[i]][y + B[i]], prev[x][y] + C[i]);
	updMin(cur[x][y], prev[x][y]);
      }
    }
  }
  ll ans = LLONG_MAX;
  for (ll k = 1; true; k++) {
    if (Ma * k > lim || Mb * k > lim) break;
    updMin(ans, cur[k * Ma][k * Mb]);
  }
  if (ans == LLONG_MAX) cout << "-1\n";
  else cout << ans << "\n";
  

  return 0;
}



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

const int N = 100010;
typedef long long ll;
int a[N];
ll pre1[N], pre2[N];

int main(){
	int n, k;
	cin>>n>>k;
	for (int i = 1; i <= n; ++ i){
		scanf("%d", &a[i]);
		pre1[i] = pre1[i - 1] + a[i];
		pre2[i] = pre2[i - 1] + std::max(a[i], 0);
	}
	ll ans = 0;
	for (int i = 1; i <= n - k + 1; ++ i){
		ans = std::max(ans, pre1[i + k - 1] - pre1[i - 1] + pre2[i - 1] + pre2[n] - pre2[i + k - 1]);
		ans = std::max(ans, pre2[i - 1] + pre2[n] - pre2[i + k - 1]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n;
  cin >> n;
  vector<ll> h(n),cost(n);
  for(ll i = 0; i < n; ++i) cin >> h[i];
  for(ll i = 1; i < n; ++i){
    cost[i] = cost[i-1]+abs(h[i]-h[i-1]);
    if(i > 1) cost[i] = min(cost[i],cost[i-2]+abs(h[i]-h[i-2]));
  }
  cout << cost[n-1];
  return 0;
}

Measured memory_bytes: 4756
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 2147483647;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 2000005;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[SIZE], finv[SIZE], inv[SIZE];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

double len(int a, int b, int c, int d) {
	return (double)sqrt((a - c) * (a - c) + (b - d) * (b - d));
}

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

long long lcm(long long a, long long b) {
	long long  g = gcd(a, b);
	return a / g * b;
}

int main() {
	ll n, k[200005];
	cin >> n;
	for (int i = 0; i < n; ++i) { cin >> k[i]; }
	ll current = 0;
	for (int i = 0; i < n; ++i) {
		if (k[i] == current + 1) {
			++current;
		}
	}

	if (current == 0) { cout << -1 << endl; return 0; }

	cout << n - current << endl;
}

Measured memory_bytes: 1792
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    ld W, H, x, y;
    cin >> W >> H >> x >> y;
    ld a = W * H / 2;
    int ans;
    if (x == W / 2 && y == H / 2) {
        ans = 1;
    }
    else {
        ans = 0;
    }
    cout << fixed << setprecision(6) << a;
    cout << " " << ans << endl;
}

Measured memory_bytes: 3716
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int SIZ=100;
int r,c;
char maz[SIZ+5][SIZ+5];
bool pri[SIZ+5];
int main(){
	scanf("%d%d",&r,&c);
	int cnt=0;
	for(int i=0;i<r;i++)
	{
		bool flag=false;
		scanf("%s",maz[cnt]);
		for(int j=0;j<c;j++)
			if(maz[cnt][j]=='#')
				flag=true,pri[j]=true;
		if(flag) cnt++;
	}
	for(int i=0;i<cnt;i++)
	{
		for(int j=0;j<c;j++)
			if(pri[j])
				printf("%c",maz[i][j]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 128
def main():
    n=int(input())
    A = list(map(int,input(). split ()))
    if 0 in A:
        print(0)
        return

    ans=1
    for i in A:
        ans*=i
        if ans>1000000000000000000:
            print(-1)
            return

    print(ans)

main()

Measured memory_bytes: 21460
A = input()
a = [int(c) for c in A]
for i in range(2**3):
    tmp = a[0]
    op = []
    for j in range(3):
        if (i >> j) & 1:
            op.append("+")
            tmp += a[j+1]
        else:
            op.append("-")
            tmp -= a[j+1]
    if tmp == 7:
        a = A
        print(a[0]+op[0]+a[1]+op[1]+a[2]+op[2]+a[3]+"=7")
        exit(0)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    string S;
    cin >> S;
    bool flag = true;
    flag = S[0] == 'A';
    ll ct = 0;
    for (ll i = 2; i <= len(S) - 2; ++i) ct += S[i] == 'C';
    rep(i, len(S)){
        if(S[i] != 'C' && S[i] != 'A') flag &= S[i] >= 'a' && S[i] <= 'z';
    }
    flag &= ct == 1;

    if(flag) print("AC");
    else print("WA");


    return 0;
}

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

typedef struct {
  double x;
  double y;
} point;

point FuncSetVector(const point a, const point b);

int main(void)
{
  point p[4];
  point v[2];
  double buf;
  int n;
  int i, j;

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    for ( j = 0; j < 4; j++ ) {
      scanf("%lf %lf", &p[j].x, &p[j].y);
    }
    v[0] = FuncSetVector(p[0], p[1]);
    v[1] = FuncSetVector(p[2], p[3]);
    
    buf = (v[0].x * v[1].y) - (v[0].y * v[1].x);
    if (fabs(buf) < 1e-10) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }

  return 0;
}

point FuncSetVector(const point bp, const point ep)
{
  point buf;

  buf.x = ep.x - bp.x;
  buf.y = ep.y - bp.y;

  return (buf);
}

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

int main() {
	int ans = 0;
	for (int i = 0; i < 4; i++) {
		int s;
		cin >> s;
		ans += s;
	}
	cout << ans / 60 << endl;
	cout << ans % 60 << endl;
	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

int main(int argc, char **argv)
{
	string str;
	ll k;
	cin >> str >> k;

	bool flag{true};
	for (ll i = 1; i < (ll)str.size(); ++i)
	{
		flag &= (str[i-1] == str[i]);
	}

	if (flag)
	{
		std::cout << (str.size() * k) / 2ll << std::endl;
	}
	else if (str.front() != str.back())
	{
		ll res{0};
		for (ll i = 0; i < (ll)str.size();)
		{
			ll j = i + 1;
			while (j < (ll)str.size() && str[i] == str[j]) {++j;}
			res += (j - i) / 2ll;
			i = j;
		}
		std::cout << res * k << std::endl;
	}
	else
	{
		ll l{0}, r{(ll)str.size()-1};
		char f = str.front();
		char b = str.back();
		
		while (l < (ll)str.size() && f == str[l]) {++l;};
		while (r >= 0 && b == str[r]) {--r;}

		// std::cout << "l : " << l << std::endl;
		// std::cout << "r : " << r << std::endl;

		ll res{0};
		for (ll i = l; i <= r;)
		{
			ll j = i + 1;
			while (j < (ll)str.size() && str[i] == str[j]) {++j;}
			res += (j - i) / 2;
			// std::cout << (j-i)/2 << std::endl;
			i = j;
		}

		// std::cout << "left : " << l << std::endl;
		// std::cout << "right : " << str.size()-r-1 << std::endl;
		res *= k;
		ll tmp = (l + str.size()-r-1) / 2;
		res += tmp * (k-1);
		res += l/2;
		res += (str.size()-r-1) / 2;
		std::cout << res << std::endl;
	}
}


Measured memory_bytes: 256
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
INF = float("inf")
num = [INF,2,5,5,4,5,6,3,7,6]
if N==2 and M==9:
    print(1)
    exit()

dp = [0]+[-INF]*N
#dpテーブルを作成
for i in range(1,N+1):
    ins = -INF
    for a in A:
        try:
            tmp = dp[i-num[a]]+1
            ins = max(ins,tmp)
        except:
            continue
    dp[i] = ins

#各桁の数字を決定
A.sort(reverse=True)
digit = ["0"]*dp[N]
mat = 0
for i in range(dp[N]):
    for a in A:
        try:
            t1 = dp[N-mat-num[a]]
            t2 = dp[N-mat]-1
        except:
            continue
        if t1 == t2:
            digit[i] = str(a)
            mat += num[a]
            break
print("".join(digit))


Measured memory_bytes: 3688
import java.util.*;
public class Main {
    static int MOD = 1001;
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int rowNum = sc.nextInt();
        int colNum = sc.nextInt();
        char[][] grid = new char[rowNum][colNum];
        for(int i = 0; i < rowNum; i++)
            grid[i] = sc.next().toCharArray();
        
        Queue<Integer> queue = new LinkedList<>();
        for(int i = 0; i < rowNum; i++) {
            for(int j = 0; j < colNum; j++) {
                if(grid[i][j] == '#') {
                    queue.offer(i * MOD + j);
                }
            }
        }
        
        int steps = bfs(grid, rowNum, colNum, queue);
        System.out.println(steps);
    }

    private static int bfs(char[][] grid, int rowNum, int colNum, Queue<Integer> queue) {
        int[] rows = new int[]{-1, 1, 0 , 0};
        int[] cols = new int[]{ 0, 0, -1, 1};

        int steps = 0;
        while(!queue.isEmpty()) {
            int size = queue.size();
            for(int i = 0; i < size; i++) {
                int pos = queue.poll();
                
                int curRow = pos / MOD;
                int curCol = pos % MOD;
                for(int j = 0; j < rows.length; j++) {
                    int nextRow = curRow + rows[j];
                    int nextCol = curCol + cols[j];
                    if(isValid(grid, nextRow, nextCol)) {
                        queue.offer(nextRow * MOD + nextCol);
                    }
                }
            }
            steps++;
        }
        return steps - 1;
    }

    private static boolean isValid(char[][] grid, int row, int col) {
        if(row < 0 || row >= grid.length || col < 0 || col >= grid[row].length || grid[row][col] == '#')
            return false;
        grid[row][col] = '#';
        return true;
    }
}


Measured memory_bytes: 67612
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//大小比較(大)
long long int big(long long int a, long long int b) {
	if (a >= b) {
		return a;
	}
	else {
		return b;
	}
}

//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}

main() {
	long long int c,d,a,b,n, m,k;
	char str[5];
	scanf("%lld%lld%lld",&a,&b,&c);
	if (c-a<=b&&c>=a) { printf("YES"); }else{ printf("NO"); }
	
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;

int main(){
    int n,k; cin >> n >> k;
    vector<int> a(n);
    rep(i,n){
        int m; cin >> m;
        a[m]++;
    }
    sort(a.begin(),a.end(),greater<>());
    int sum = 0;
    rep(i,k) sum += a[i];
    print(n - sum);
}

Measured memory_bytes: 1152