akhauriyash/Code-Regression huggingface dataset:
n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))
c = 0

def binary_search(li, key):
    n = len(li)
    left = 0
    right = n
    while left < right:
        mid = (left+right) // 2
        if key == li[mid]:
            return 1
        if key > li[mid]:
            left = mid + 1
        elif key < li[mid]:
            right = mid
    return 0

for i in range(q):
    if binary_search(s, t[i]):
        c += 1
print(c)


Measured memory_bytes: 16712
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const long long mod = 1e9+7;
long long power(long long a, long long b, long long m = mod) {
    if(b < 0) {
        return power(power(a, -b), mod-2);
    }
    long long x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
const int N = 3e5+9;
signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    

    
    int r; cin >> r;
    cout << fixed << setprecision(15) << 2.l * M_PI * r << endl;

    





    return 0;
    
}


Measured memory_bytes: 3800
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>
using namespace std;

//#include<bits/stdc++.h>


int main() {
	int n;
	vector<int>a, b, c;
	cin >> n;
	vector<long long int>w;
	long long int t = 0;
	//w.push_back(t);
	int x, y, z;
	//a.push_back(0);
	//b.push_back(0);
	//c.push_back(0);
	for (int i = 0; i < n-1; i++) {
		cin >> x >> y >> z;
	//	if (t){
			if (t <= y)t = y;
			else if ((t - y) % z) {
				long long int r = (t - y) % z+1;
				t = y + z*r;
			}
			//cout << t;
	//	}
		t += x;

		//w.push_back(t);
		a.push_back(x);
		b.push_back(y);
		c.push_back(z);
		
	}
//	w.push_back(t);
	
	for (int i = 0; i <n-1; i++)
	{
		t = 0;
		
		for (int j = i; j <n-1; j++) {
			x = a[j]; y = b[j]; z = c[j];
			if (t < y)t = y;
			else if (t % z) {
				t += z - t%z;
			}
			t += x;
		}
		w.push_back(t);
		
	}
	w.push_back(0);
	sort(w.begin(), w.end());
	reverse(w.begin(), w.end());
	for (int i = 0; i <w.size(); i++)
		cout << w[i] << endl;

	return 0;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]

def main():
    n,k = map(int,input().split())
    dp = [[0 for _ in range(k+1)] for _ in range(k+1)]
    dp[0][0] = 1
    for i in range(1,k+1):
        for j in range(1,i+1):
            dp[i][j] = (dp[i-1][j]*(i+j-1)+dp[i-1][j-1]*(n-k-j+2))//i
    for i in range(1,k+1):
        print(dp[-1][i]%mod)

if __name__ == "__main__":
    main()

Measured memory_bytes: 194560
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;


  cin>>a>>b;

  cout<<a+(b/2)<<endl;










}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    string t = "ACGT";
    vector<int> d;
    d.push_back(-1);
    rep(i, 0, n){
        if(t.find(s[i]) == string::npos) d.push_back(i);
    }
    d.push_back(n);
    rep(i, 0, d.size() - 1){
        ans = max(ans, d[i + 1] - d[i] - 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>

using namespace std;

int main() {
    string s;
    cin >> s;
    for (size_t i = 0; i < s.size(); ++i) {
        auto c = s[i];
        if (i % 2 == 0) {
            if (c == 'R' || c == 'U' || c == 'D')
                continue;
        } else {
            if (c == 'L' || c == 'U' || c == 'D')
                continue;
        }
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

AB = LS2()

s = 0
for i in range(len(AB)):
    if AB[i] == ' ':
        s = i
        break
a = ''
for i in range(s):
    a += AB[i]
b = AB[s+1]+AB[s+3]+AB[s+4]

a = int(a)
b = int(b)
print((a*b)//100)

Measured memory_bytes: 9232
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i,N) cin >> a[i];
  sort(a.rbegin(), a.rend());
  double half=a[0]/2.0;
  int r=a[1];
  for(int i=2; i<N; i++){
    if(abs(half-a[i])<abs(half-r))
      r = a[i];
  }
  cout << a[0] << ' ' << r << endl;
  return 0;
}

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

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    long long sum = 0;
    if (A + B > C * 2) {
        if (X < Y) {
            sum += min(X * C * 2 + (Y - X) * B, Y * C * 2);
        }
        else {
            sum += min(Y * C * 2 + (X - Y) * A, X * C * 2);
        }
    }
    else {
        sum += min(X * A + Y * B, max(X, Y) * C * 2);
    }

    cout << sum << endl;
}

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

int main() {
  int N,c;
  cin >>N;
  vector<long int> B(N+1);
  for(int i=1;i<N;i++){
    cin >>B.at(i);
  }
  B.at(0)=100001;
  B.at(N)=100001;
  c=0;
  for(int i=1;i<=N;i++){
    c+=min(B.at(i-1),B.at(i));
  }
  cout <<c<<endl;
}

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

ans=[0]*n

for i in range(n):
  for j in range(i+1,n):
    ans[min(j+1-i-1,abs(i+1-x)+abs(j+1-y)+1)] += 1
for i in range(n-1):
  print(ans[i+1])

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

class Radix {
private:
  const char* s;
  int a[128];
public:
  Radix(const char* s = "0123456789ABCDEF") : s(s) {
    int i;
    for(i = 0; s[i]; ++i)
      a[(int)s[i]] = i;
  }
  std::string to(long long p, int q) {
    int i;
    if(!p)
      return "0";
    char t[64] = { };
    for(i = 62; p; --i) {
      t[i] = s[p % q];
      p /= q;
    }
    return std::string(t + i + 1);
  }
  std::string to(const std::string& t, int p, int q) {
    return to(to(t, p), q);
  }
  long long to(const std::string& t, int p) {
    int i;
    long long sm = a[(int)t[0]];
    for(i = 1; i < (int)t.length(); ++i)
      sm = sm * p + a[(int)t[i]];
    return sm;
  }
};

int main() {
    Radix r;
    int N,K;
    int ans;

    // 10 進数を n 進文字列に
    std::cin >> N >> K ;
    ans = (int)(r.to(N,K).length());
    std::cout << ans << std::endl;
    // std::cout << r.to(255, 10) << std::endl; // => "255"
    // std::cout << r.to(255, 12) << std::endl; // => "193"
    // std::cout << r.to(255, 16) << std::endl; // => "FF"

    // n 進文字列を 10 進数に
    // std::cout << r.to("255", 10) << std::endl; // => 255
    // std::cout << r.to("255", 14) << std::endl; // => 467

    // n 進文字列を m 進文字列に
    // std::cout << r.to("255", 7, 11) << std::endl; // => "116"
    // std::cout << r.to("255", 11, 7) << std::endl; // => "611"
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	string s; cin >> s;
	int n = s.size();
	
	bool ok = s[0] == '1' && s[n - 1] == '0';
	rep(i, n - 1) if(s[i] != s[n - i - 2]) ok = 0;
	if(!ok){
		cout << -1 << endl;
		return 0;
	}
	
	int sz = 0;
	vi v;
	while(sz < n / 2){
		int cnt = 1;
		while(sz < n / 2 && s[sz] == '0') cnt++, sz++;
		sz++;
		v.pb(cnt);
	}
	dbg(sz);
	
	if(s[n / 2 - 1] == '1'){
		if(n % 2) v.pb(1);
		for(int i = v.size() - 1 - n % 2; i >= 0; i--) v.pb(v[i]);
	}
	else for(; sz < n; sz++) ++v.back();
	
	assert(v.size() >= 1);
	
	int cur = v.size() + 1;
	rep(i, v.size() - 1) cout << i+1 << " " << i+2 << endl;
	rep(i, v.size()) rep(j, v[i] - 1) cout << i+1 << " " << cur++ << endl;
	
	return 0;
}

Measured memory_bytes: 1992
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>
#include <stack>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  string s, t;
  cin >> s;
  cin >> t;
  ll n = s.size();
  ll ans = 0;
  rep(i,n) {
    if (s[i] != t[i]) {
      ++ans;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3800
#include<bits/stdc++.h>
#define MM 1000000007
using namespace std;
int main(void){
	int n,m;
	int dp[100001];
	int flg[100001];
	int i;
	int x;
	cin>>n>>m;
	for(i=1;i<=n;i++){
		flg[i]=0;
		dp[i]=0;
	}
	for(i=0;i<m;i++){
		cin>>x;
		flg[x]=1;
	}
	dp[0]=1;
	for(i=0;i<n;i++){
		if(i+1<=n){
			if(flg[i+1]==0){
				dp[i+1]+=dp[i];
				dp[i+1]%=MM;
			}
		}
		if(i+2<=n){
			if(flg[i+2]==0){
				dp[i+2]+=dp[i];
				dp[i+2]%=MM;
			}
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}

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

using namespace std;

int main(){
    int N,ans=0;
    cin >> N;
    vector<vector<pair<int,int>>> xy(N);
    for(int i=0;i<N;i++){
        int A,x,y;
        cin >> A;
        for(int j=0;j<A;j++){
            cin >> x >> y;
            x--;
            xy[i].emplace_back(x,y);
        }
    }

    for(int i=0;i<pow(2,N);i++){
        bool flag = true;
        for(int j=0;j<N;j++){
            if((i>>j) & 1){
                for(int k=0;k<xy[j].size();k++){
                    if(xy[j][k].second!=((i>>xy[j][k].first)&1)){
                        flag = false;
                        break;
                    }
                }
            }
        }
        if(flag){
            int add=0;
            for(int j=0;j<N;j++){
                if((i>>j) & 1){
                    add++;
                }
            }
            ans = max(ans,add);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());

string a="**=*****";
int main(){
	int n;
	bool f=true;
	while(cin>>n){
		if(!f) cout<<endl;
		f=false;
		stringstream ss[8];
		int b=10000;
		rep(i,5){
			int t=n/b;
			n%=b;
			b/=10;
			string ans=a;
			if(t>4) ans[0]=' ';
			else ans[1]=' ';
			ans[3+t%5]=' ';
			rep(j,8){
				ss[j]<<ans[j];
			}
		}
		// cout<<"hoge\n";
		rep(i,8){
			string tmp;
			getline(ss[i],tmp);
			cout<<tmp<<endl;
		}
		// cout<<endl;
	}
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
 
#define ll                    long long int
#define ll_MAX                LLONG_MAX
#define ll_MIN                LLONG_MIN
#define pi                    3.14159265358979323846
#define count_1(n)            __builtin_popcountll(n)
#define MOD                   1000000007
#define MAX                   1e9
#define MIN                   -1e9
#define itoc(c)               ((char)(((int)'0')+c))
#define mid(s,e)              (s+(e-s)/2)
const int MX=10010896;
const int lmt=3164;
const int N=10000001;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
#define print_upto(a,n)        for(int i=0;i<n;i++)    cout<<a[i]<<" "; cout<<endl
#define print(a)        for (auto x : a) cout << x << " "; cout << endl

inline void solve(){
    ll n,k;cin>>n>>k;
    vector<ll> a(n+1);
    for(ll i=1;i<=n;i++){
        cin>>a[i];
    }
    vector<vector<ll>> dp(n+1,vector<ll>(k+1,1));
    for(ll j=1;j<=k;j++){
        dp[0][j]=0;
    }
    vector<ll> pref(k+1);
    for(ll i=1;i<=n;i++){
        vector<ll> pref(k+1);
        pref[0]=dp[i-1][0];
        for(ll j=1;j<=k;j++){
            pref[j]=( pref[j-1]%MOD+dp[i-1][j]%MOD )%MOD;
        }
        for(ll j=1;j<=k;j++){
            if(j<=a[i]){
                dp[i][j]=pref[j];
            }
            else{
                ll ignore_sm=pref[j-a[i]-1];
                dp[i][j]=((pref[j]%MOD-ignore_sm%MOD)+MOD)%MOD;
            }
            //cout<<"dp["<<i<<"]["<<j<<"]:"<<dp[i][j]<<endl;
        }
    }
    cout<<dp[n][k]<<"\n";
}

int main()
{
	cout<<fixed<<setprecision(12);
	fastio;ll  t=1,tc=1;
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout);
	#endif
	//cin>>t;
	while(t--){solve();}return 0;
}

Measured memory_bytes: 83876
#include<iostream>
#include<vector>
int main(){
  std::vector<std::string> s(3);
  std::cin>>s[0]>>s[1]>>s[2];
  int t = 0;
  std::vector<int> i(3);
  while(1){
    if(s[t].size()==i[t]){
      std::cout<< char('A'+t) <<std::endl;
      break;
    }
    t = s[t][i[t]++]-'a';
  }
}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
	
	void run() {
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if(a==b && b==c) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21716
# coding: utf-8
# Your code here!
N = int(input())

sd = {}
ans = 0

for _ in range(N):
    inp = input()
    si = ''.join(sorted(inp))
    
    if not si in sd:
        sd[si] = 1
    else:
        ans += sd[si]
        sd[si] += 1

print(ans)


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

using namespace std;

int n, m;
const int N = 100005;
vector<int> a[N];
bool d[N][2];
int vis[N][2];

void dfs(int pos)
{
	d[pos][0] = true;
	queue< pair<int, int> > q;
	q.push({pos, 0});
	vis[pos][0] = 1;
	while (q.size())
	{
		int u = q.front().first, l = q.front().second;
		q.pop();
		for (int i = 0; i < a[u].size(); i++)
		{
			int v = a[u][i];
			if (!vis[v][(l+1)%2])
			{
				vis[v][(l+1)%2] = 1;
				d[v][(l+1)%2] = true;
				q.push({v, (l+1)%2});
			}
		}
	}
}

signed main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		a[x].push_back(y);
		a[y].push_back(x);
	}
	for (int i = 1; i <= n; i++)
	{
		d[i][0] = d[i][1] = false;
	}
	memset(vis, 0, sizeof(vis));
	dfs(1);
	int cn1, cn2, cn3;
	cn1 = cn2 = cn3 = 0;
	for (int i = 1; i <= n; i++)
	{
		if (d[i][0] & d[i][1])
		{
			cn1 ++;
		} 
		else
		{
			if (d[i][0])
			{
				cn2 ++;
			}
			else
			{
				cn3 ++;
			}
		}
	}
	long long ans = 1ll*cn2*cn3 + 1ll*cn1*cn2 + 1ll*cn1*cn3 + 1ll*cn1*(cn1-1)/2;
	cout << ans - m;
}

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

using namespace std;

map<string, int> mp;
vector<string> v;

int main() {

	int n;
	cin >> n;
	int maxx = -1;
	for (int i = 0; i < n; ++i)
	{
		string s; cin >> s;
		mp[s]++;
		maxx = max(maxx, mp[s]);
	}

	map<string, int>::iterator iter;

	for (iter = mp.begin(); iter != mp.end(); ++iter)
	{
		if (iter->second== maxx) {
			// cout << iter->first << "\n";
			string s = iter->first;
			v.push_back(s);
		}

	}

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

	for (int i = 0; i < v.size(); ++i)
	{
		cout << v[i] << "\n";
	}

	return 0;
}

Measured memory_bytes: 26868
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl '\n';

int main(){
    ios_base::sync_with_stdio(0); cin.tie(nullptr);
    string s; cin>>s;
    ll sum=0;
    while(s.size()){
    	sum+=s[s.size()-1]-'0';
    	s.pop_back();
    }
    cout<<(sum%9==0?"Yes\n":"No\n");
    return 0;
}

Measured memory_bytes: 3768
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 200010

int main(){
    ll n,m;
    cin>>n>>m;
    cout<<(n==m?"Yes":"No")<<endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
		using namespace std;
		
		typedef long long ll;
		#define pi 3.14159265 
		#define EPS 1e-8
		
		#define mod 1000000007
		#define fi first
		#define se second
		#define mp make_pair
		#define pb push_back
		#define endl "\n"

		const ll INF=(ll)2e18;
		
		long long binpow(long long a, long long b, long long m) {
		a %= m;
		long long res = 1;
		while (b > 0) {
			if (b & 1)
				res = res * a % m;
			a = a * a % m;
			b >>= 1;
		}
		return res;
		}
		vector<ll> v;
		void f(ll idx,ll num)
		{
			v.pb(num);
			if(idx==11)
				return;
			
			ll n1=num%10;
			for(ll j=0;j<=9;j++)
			{
				if(abs(j-n1)<=1)
				{
					f(idx+1,num*10+j);
				}
			}
			
		}
		int main()
		{
			 ios_base::sync_with_stdio(false);
			 cin.tie(NULL);
			
			ll k;
			cin>>k;
			
				for(ll j=1;j<=10;j++)
				{
					f(1,j);
				}
			
			
			
			sort(v.begin(),v.end());
			v.erase( unique( v.begin(), v.end() ), v.end() );
			cout<<v[k-1];
		}


Measured memory_bytes: 10476
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

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

int main(void)
{
    int x,y,d;
    cin >> x >> y;
    d = abs(abs(x)-abs(y));
    
    if(signbit(x) == signbit(y)) {
        if(x < y) {
            cout << d << endl;
        } else {
            if(y == 0) {
                cout << d + 1 << endl;
            } else {
                cout << d + 2 << endl;
            }
        }
    } else {
        if(y == 0) {
            cout << d << endl;
        } else {
            cout << d + 1 << endl;
        }

    }
}


Measured memory_bytes: 256
from math import ceil


a, b = map(int, input().split())
w = 52
r1 = ceil((a - 1) / ((w - 2) // 2))
r2 = ceil((b - 1) / (w // 2))
h = 1 + r1 * 2 + r2 * 2
print(h, w)
print('#' * (w - 1) + '.')
a -= 1
for i in range(r1):
    num = min(max(a, 0), (w - 2) // 2)
    print('#' + '.#' * num + '..' * ((w - 2) // 2 - num) + '.')
    print('#' * (w - 1) + '.')
    a -= (w - 2) // 2
b -= 1
for i in range(r2):
    num = min(max(b, 0), w // 2)
    print('.' * w)
    print('#.' * num + '..' * (w // 2 - num))
    b -= w // 2


Measured memory_bytes: 3064
// ITP1_10_D
import java.io.*;

class Main {

   public static void main(String[] args) {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

      try {
         String[] input = br.readLine().split(" ");
         double x1 = Double.parseDouble(input[0]);
         double y1 = Double.parseDouble(input[1]);
         double x2 = Double.parseDouble(input[2]);
         double y2 = Double.parseDouble(input[3]);
         double distance = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
         System.out.println(distance);
      }

      catch (Exception e) {
         System.err.println(e);
      }
   }
}

Measured memory_bytes: 16928
// ABC166D - I hate Factorization

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

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


	for (long long int i = -120; i <= 120; i++) {
		for (long long int j = -120; j <= 120; j++) {
			if (i * i * i * i * i - j * j * j * j * j == X) {
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 3600
# def gcd(a, b):
# 	while a != 0 and b != 0:
# 		if a >= b:
# 			remain = a % b
# 			a = remain
# 		else:
# 			remain = b % a
# 			b = remain
# 	if a >= b:
# 		return a
# 	else:
# 		return b 

import math

k = int(input())
sum = 0

for i in range(1, k+1):
	for j in range(1, i+1):
		for l in range(1, j+1):
			if i == j and j == l:
				sum += i
			elif i == j or j == l:
				a = math.gcd(i, j)
				b = math.gcd(j,l)
				g = math.gcd(a,b)
				sum += g*3

			else:
				a = math.gcd(i, j)
				b = math.gcd(j,l)
				g = math.gcd(a,b)
				sum += g*6

print(sum)


Measured memory_bytes: 9008
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;


int main(int argc, const char * argv[]) {
    int a,b,c;
    cin >> a >> b >> c;
    if((a*100+b*10+c)%4){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
    return 0;
}


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

int main() {
  int N; cin >> N;
  vector<int> vec(N);
  rep(i,N){cin >> vec.at(i); vec.at(i)--;}
  
  int cur=0;
  int ans=0;
  rep(i,N+10){
    cur=vec.at(cur);
    ans++;
    if (cur == 1) {cout << ans << endl; return 0;}
  }
  cout << -1 << endl; 
  return 0;
}

Measured memory_bytes: 3716
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val A = nextLongList()
    val M = A.max()!!
    val N = A.minus(M).reduce { a, b -> a * b }
    println(if (M % 2 == 0L) 0L else N)
}

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

int n,q,a,b,currentAdd;
map<int,vector<int>> children;
map<int,int> counter;
map<int,int> answers;

void builder(int cur)
{
	int s=children[cur].size();
	currentAdd+=counter[cur];
	answers[cur]=currentAdd;
	//cout<<"Vertice "<<cur<<", has a counter of "<<currentAdd<<"\n";
	for (int i=0;i<s;++i)
	{
		builder(children[cur][i]);
	}
	currentAdd-=counter[cur];
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	currentAdd=0;
	cin>>n>>q;
	for (int i=1;i<n;++i)
	{
		cin>>a>>b;
		children[a].push_back(b);
	}
	while (q--)
	{
		cin>>a>>b;
		counter[a]+=b;
	}
	builder(1);
	for (int i=1;i<=n;++i)
	{
		cout<<answers[i]<<" ";
	}
	return 0;
}

Measured memory_bytes: 58624
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define sz(a)			a.size()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD1			998244353
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
using namespace __gnu_pbds;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//find_by_order kth largest  order_of_key <
const int tam = 100010;
const int MOD = 1e9+7;
const double EPS = 1e-9;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	//freopen("qwe.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	int n, a, su = 0;
	cin>>n;
	while(n--)
	{
		cin>>a;
		su += a-1;
	}
	cout<<su<<'\n';
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

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;

/*解説AC*/
const int  mod = 1000000007;
struct mint{
    ll x;
    mint (ll x=0) : x((x%mod+mod)%mod){}//カッコの中で初期化している
    mint& operator+=(const mint a){//operatorは構造体同士の比較に用いられる
        if((x +=a.x)>=mod) x-=mod;
        return *this;//thisとは現在のオブジェクトのこと
    }
    mint& operator-=(const mint a){
        if((x +=mod-a.x)>=mod) x-=mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x*=a.x)%=mod;
        return *this;
    }
    mint operator+(const mint a){
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a){
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a){
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const{
        if(!t) return 1;
        mint a=pow(t>>1);
        a*=a;
        if(t&1) a*=*this;
        return a;
    }
    mint inv() const{
        return pow(mod-2);//逆元
    }
    mint&operator/=(const mint a) {
        return (*this)*=a.inv();
    }
    mint&operator/(const mint a) const{
    mint res(*this);
    return res/=a;
    }
};

struct Eratos {
    vector<int> primes;
    vector<bool> isprime;
    vector<int> min_factor;

    Eratos(int MAX) : primes(),isprime(MAX+1, true),min_factor(MAX+1, -1) {
        isprime[0] = isprime[1] = false;
        min_factor[0] = 0, 
        min_factor[1] = 1;
        for (int i = 2; i <= MAX; ++i) {
            if (!isprime[i]) continue;
            primes.push_back(i);
            min_factor[i] = i;
            for (int j = i*2; j <= MAX; j += i) {
                isprime[j] = false;
                if (min_factor[j] == -1) min_factor[j] = i;
            }
        }
    }

    // prime factorization
    vector<pair<ll,ll>> prime_factorize(ll n) {
        vector<pair<ll,ll> > res;
        while (n != 1) {
            ll prime = min_factor[n];
            ll exp = 0;
            while (min_factor[n] == prime) {
                ++exp;
                n /= prime;
            }
            res.push_back(make_pair(prime, exp));
        }
        return res;
    }
};

int main(void){
    int n;
    cin>>n;
    vector<ll> v(n);
    map<ll, ll> mp;
    rep(i, n) cin>>v[i];
    Eratos er(1100000);
    rep(i, n){
        auto pf = er.prime_factorize(v[i]);
        for(auto p : pf){
            mp[p.first] = max(mp[p.first], p.second);
        }
    }
    mint LCM = 1;
    for(auto p : mp) LCM *=pow(p.first, p.second);
    mint ans = 0;
    rep(i, n){ 
        mint tmp = LCM;
        tmp /= v[i];
        ans += tmp;
    }
    cout<<ans.x<<endl;
    return 0;
}

Measured memory_bytes: 5752
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	int n,y;
	cin>>n>>y;
	
	rep(i,n+1){
		rep(j,n+1){
			int k=n-i-j;
			if(k>=0&&i*10000+j*5000+k*1000==y){
				printf("%d %d %d\n",i,j,k);
				return 0;
			}
		}
	}
	cout<<"-1 -1 -1"<<endl;

	return 0;
}



Measured memory_bytes: 3772
x,n = map(int,input().split())
if n == 0:
  print(x)
else:
  p = list(map(int,input().split()))
  dic = {}
  ans = 0
  for i in range(n):
    dic[p[i]] = abs(x-p[i])
  i = 1
  while ans==0:
    if not x in dic:
      print(x)
      break
    elif (not x+i in dic) and (not abs(x-i) in dic):
      print(x-i)
      break
    elif not abs(x-i) in dic:
      print(x-i)
      break
    elif not x+i in dic:
      print(x+i)
      break
    else:
      i += 1
  



Measured memory_bytes: 9208
#include<cstdio>
#include<cstring>
using namespace std;
char x[55][55],y[55][55];
char st[100],sy[2505],sx[2505];
int m,n;
bool cmp(int a,int b)
{
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(x[i+a-1][j+b-1]!=y[i][j])
			{
				return false;
			}
		}
	}
	return true;
}
int main()
{
	scanf("%d%d",&m,&n);
	for(int i=1;i<=m;i++)
	{
		scanf("%s",st);
		for(int j=0;j<m;j++)
		{
			x[i][j+1]=st[j];
		}
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%s",st);
		for(int j=0;j<n;j++)
		{
			y[i][j+1]=st[j];
		}
	}
	int cha=m-n+1;
	for(int i=1;i<=cha;i++)
	{
		for(int j=1;j<=cha;j++)
		{
			if(cmp(i,j)) 
			{
				printf("Yes");
				return 0;
			}
		}
	}
	printf("No");
	return 0;
}

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

using namespace std;

constexpr int MAXN = 5e3 + 5;

int n, k, ans(-1e18), cyBeg, cyEnd;
array<int, MAXN> to, c, vis, pre, preMax;
vector<int> node;

inline void dfs(int cur) {
    vis[cur] = true;
    node.push_back(cur);
    if (vis[to[cur]]) {
        cyEnd = node.size() - 1; //环终点
        for (int i = 0; i < node.size(); i++)
            if (node[i] == to[cur]) {
                cyBeg = i; //环起点
                break;
            }
    }
    else dfs(to[cur]);
}

inline void search(int st) {
    node.clear();
    fill(vis.begin(), vis.end(), 0);
    fill(pre.begin(), pre.end(), 0);
    fill(preMax.begin(), preMax.end(), -1e18);
    cyBeg = cyEnd = -1;
    dfs(st);
    for (int i = 1; i < node.size(); i++)
        pre[i] = pre[i - 1] + c[node[i]], preMax[i] = max(preMax[i - 1], pre[i]);
    ans = max(ans, preMax[min(k, (int)node.size() - 1)]);
    if (k <= cyEnd || cyBeg == - 1 || cyEnd == -1) return;
    if (cyBeg == 0) { //一开始就有环
        int valC = pre[cyEnd] + c[node[cyBeg]];
        if (valC < 0) return;
        int tim = k / node.size(), res = k % node.size();
        ans = max(ans, tim * valC + max(0LL, preMax[res]));
        ans = max(ans, (tim - 1) * valC + max(0LL, preMax[cyEnd]));
        return;
    }
    int tmp = pre[cyBeg - 1];
    fill(pre.begin(), pre.end(), 0);
    fill(preMax.begin(), preMax.end(), -1e18);
    int valC = 0, cSize = cyEnd - cyBeg + 1, tim, res;
    for (int i = cyBeg; i <= cyEnd; i++) { //环上前缀和
        valC += c[node[i]];
        pre[i] = pre[i - 1] + c[node[i]];
        preMax[i] = max(preMax[i - 1], pre[i]);
    }
    if (valC < 0) return;
    k -= cyBeg - 1, tim = k / cSize, res = k % cSize;
    ans = max(ans, tmp + valC * tim + max(0LL, preMax[cyBeg + res - 1]));
    ans = max(ans, tmp + valC * (tim - 1) + max(0LL, preMax[cyEnd]));
}

signed main() {
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> to[i];
    for (int i = 1; i <= n; i++) cin >> c[i];
    for (int i = 1; i <= n; i++) search(i);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4072
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let k: usize = read();
    let a: Vec<i64> = (0..n).map(|_| read::<i64>()).collect();
    let mut rui: Vec<i64> = vec![0; n + 1];
    for i in 0..n {
        rui[i + 1] = rui[i] + a[i];
    }
    let mut vec: Vec<i64> = Vec::new();
    for i in 0..n + 1 {
        for j in i + 1..n + 1 {
            vec.push(rui[j] - rui[i]);
        }
    }
    vec.sort();
    let mut check: Vec<bool> = vec![true; vec.len()];
    let max = vec[vec.len() - 1];
    let mut po2 = 1;
    let mut cnt = 0;
    while po2 * 2 <= max {
        po2 *= 2;
        cnt += 1;
    }
    let mut ans = 0;
    for i in 0..cnt + 1 {
        let mut cnt2 = 0;
        for j in 0..vec.len() {
            if ((vec[vec.len() - j - 1] >> (cnt - i)) & 1) == 1 && check[vec.len() - j - 1] {
                cnt2 += 1;
            }
        }
        if cnt2 >= k {
            ans += po2;
            for j in 0..vec.len() {
                if !((vec[vec.len() - j - 1] >> (cnt - i)) & 1 == 1) {
                    check[vec.len() - j - 1] = false;
                }
            }
        }
        po2 /= 2;
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


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

int main() {
  int n, a = 1;
  string s;
  cin >> n >> s;
  for(int i = 1; i < n; i++){
    if(s.at(i-1) != s.at(i))
      a++;
  }
  cout << a << endl;
}


Measured memory_bytes: 512
//A?C

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a / __gcd(a, b) * b
#define range(a) (a).begin(),(a).end()
const int inf = 2147483647;

int main (){
    string s;cin>>s;
    cout << (s=="ABC" ? "ARC" : "ABC") << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    long long int a,b;
    cin >> n >> a >> b;
    long long int x[n];
    for(int i = 0;i < n;i++)
    {
        cin >> x[i];
    }
    long long int sum = 0;
    for(int i = 1;i < n;i++)
    {
        sum += min(a * (x[i] - x[i - 1]),b);
    }
    cout << sum;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>

using namespace std; 

typedef unsigned long long ull;

bool tri(ull a, ull b, ull c, ull d, ull e, ull f){

	ull p[6]={a,b,c,d,e,f};

    if( (p[0]< (p[1]+p[2]))&& (p[3]< (p[4]+p[5])) ){return true;}
    if( (p[0]< (p[1]+p[4]))&& (p[2]< (p[3]+p[5])) ){return true;}
    if( (p[0]< (p[1]+p[5]))&& (p[2]< (p[3]+p[4])) ){return true;}
    if( (p[0]< (p[1]+p[3]))&& (p[2]< (p[4]+p[5])) ){return true;}
    if( (p[0]< (p[2]+p[3]))&& (p[1]< (p[4]+p[5])) ){return true;}
    if( (p[0]< (p[2]+p[4]))&& (p[1]< (p[3]+p[5])) ){return true;}
    if( (p[0]< (p[2]+p[5]))&& (p[1]< (p[3]+p[4])) ){return true;}
    if( (p[0]< (p[3]+p[4]))&& (p[1]< (p[2]+p[5])) ){return true;}
    if( (p[0]< (p[3]+p[5]))&& (p[1]< (p[2]+p[4])) ){return true;}
    if( (p[0]< (p[4]+p[5]))&& (p[1]< (p[2]+p[3])) ){return true;}

	
	return false;
}

int main()
{
	int N;

	cin >> N;
	ull* bar = new ull[N];

	bool count = false;
	ull ans=0;

	for(int i=0; i<N; i++){ cin >> bar[i];}

	sort(bar, bar+N, greater<ull>());

	for(int i=0; i<N-5; i++){
		for(int j=i+3; j<N-2; j++){
			if( tri(bar[i],bar[i+1],bar[i+2],bar[j],bar[j+1],bar[j+2]) ){
				ans = ans + bar[i]+bar[i+1]+bar[i+2]+ bar[j]+bar[j+1]+bar[j+2];
				cout << ans << endl;
				delete[] bar;
				return 0;
			}
		}
	}

	delete[] bar;	
	cout << "0" << endl;

	return 0;
}

Measured memory_bytes: 1800
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }

struct UnionFind {
   vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

   UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化，自分自身が根とする
       for(int i = 0; i < N; i++) par[i] = i;
   }

   int root(int x) { // データxの根を再帰で得る：root(x) = {xの木の根}
       if (par[x] == x) return x;
       return par[x] = root(par[x]);
   }

   void unite(int x, int y) { // xとyの木を併合
       int rx = root(x); //xの根をrx
       int ry = root(y); //yの根をry
       if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
       par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
   }

   bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
       int rx = root(x);
       int ry = root(y);
       return rx == ry;
   }
};

int main(int argc, char const *argv[]) {
  int n,m;
  cin >> n >> m;
  vector<int> x(m),y(m),z(m);
  rep(i,m){
    cin >> x[i] >> y[i] >> z[i];
    x[i]--,y[i]--,z[i]--;
  }

  UnionFind uf(n);
  rep(i,m) uf.unite(x[i],y[i]);
  set<int> set;
  rep(i,n) set.insert(uf.root(i));
  cout << set.size() << endl;
  return 0;
}


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

int main() {
  
 string S;
  cin >> S ;
  if (S == "SUN" ) {
    cout << 7 << endl;
  }
  else if (S == "MON" ) {
    cout << 6 << endl;
  }
 else if (S == "TUE" ) {
    cout << 5 << endl;
  }
   else if (S == "WED" ) {
    cout << 4 << endl;
  }
  else if (S == "THU" ) {
    cout << 3 << endl;
  }
   else if (S == "FRI" ) {
    cout << 2 << endl;
  }
   else if (S == "SAT" ) {
    cout << 1 << endl;
  }
} 

Measured memory_bytes: 256
<?php
  
  list($s8, $s10) = explode(" ",trim(fgets(STDIN)));

  $s8min = (int)((($s8 * 100 + 7)/ 8));
  $s8max = (int)(($s8+1) * 100 / 8) - 1;
  $s10min = (int)($s10 * 100 / 10);
  $s10max = (int)(($s10+1) * 100 / 10) - 1;

//  echo $s8min." ".$s8max." ".$s10min." ".$s10max;

  if($s8min > $s10max || $s8max < $s10min){
    echo "-1";
  }
  else{
    if($s8min < $s10min){
      echo $s10min;
    }else{
      echo $s8min;
    }
  }

Measured memory_bytes: 4604
#include <iostream>
 
using namespace std;
 
int main(){
    int h, w;
    while (cin >> h >> w && h) {
        for (int i=0; i<h; i++) {
            for (int j=0; j<w; j++)
                cout << ((i+j)&1 ? '.' : '#');
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include <algorithm>
#include <cstdio>
int A, B;

int main() {
  scanf(" %d%d", &A, &B);
  if (A > B) std::swap(A, B);
  int D = B - A;
  if (D & 1) {
    puts("IMPOSSIBLE");
  } else {
    printf("%d\n", A + D / 2);
  }
  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint comb(lint n, lint r)
{
	if (n <= 0 || n < r)
	{
		return 0;
	}
	lint ans = 1;
	for (int i = n; i > n - r; i--) ans *= i;
	for (int i = r; i > 0; i--) ans /= i;
	return ans;
}

lint N, A, P;
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	lint cnt = 0;
	cin >> N >> P;
	REP(i, N) {
		cin >> A;
		if (A % 2 == 1) {
			cnt++;
		}
	}
	if (cnt == 0) {
		cout << (P ? 0 : (lint)pow(2, N));
	}
	else cout << (lint)pow(2, N - 1);
}


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

using namespace std;

bool check(int target) {
	string s(to_string(target));
	return (
		s.find('3') != string::npos
	 && s.find('5') != string::npos
	 && s.find('7') != string::npos
	);
}

int main(int argc, char *argv[]) {
	int N;
	cin >> N;

	int cur = 0;
	int answer = 0;
	for (int i = 3; i <= 7; i += 2) {
		for (int j = 3; j <= 7; j += 2) {
			for (int k = 3; k <= 7; k += 2) {
				cur = (100 * k) + (10 * j) + i;
				if (check(cur) && cur <= N) answer++;
				for (int l = 3; l <= 7; l += 2) {
					cur = (1000 * l) + (100 * k) + (10 * j) + i;
					if (check(cur) && cur <= N) answer++;
					for (int m = 3; m <= 7; m += 2) {
						cur = (10000 * m) + (1000 * l) + (100 * k) + (10 * j) + i;
						if (check(cur) && cur <= N) answer++;
						for (int n = 3; n <= 7; n += 2) {
							cur = (100000 * n) + (10000 * m) + (1000 * l) + (100 * k) + (10 * j) + i;
							if (check(cur) && cur <= N) answer++;
							for (int o = 3; o <= 7; o += 2) {
								cur = (1000000 * o) + (100000 * n) + (10000 * m) + (1000 * l) + (100 * k) + (10 * j) + i;
								if (check(cur) && cur <= N) answer++;
								for (int p = 3; p <= 7; p += 2) {
									cur = (10000000 * p) + (1000000 * o) + (100000 * n) + (10000 * m) + (1000 * l) + (100 * k) + (10 * j) + i;
									if (check(cur) && cur <= N) answer++;
									for (int q = 3; q <= 7; q += 2) {
										cur = (100000000 * q) + (10000000 * p) + (1000000 * o) + (100000 * n) + (10000 * m) + (1000 * l) + (100 * k) + (10 * j) + i;
										if (check(cur) && cur <= N) answer++;
									}
								}
							}
						}
					}
				}
			}
		}
	}

	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#define LL long long
#define maxn 100005
int n,q,r;
LL a[maxn],cnt[maxn],app[maxn],ans[maxn];
int BS(int l,int r,LL k)
{
	while(l+1<r)
	{
		int mid=(l+r)>>1;
		if(a[mid]<=k) l=mid;
		else r=mid;
	}
	return r;
}
int main()
{
	scanf("%d%d",&n,&r);
	a[q=1]=n;
	for(int i=1;i<=r;i++)
	{
		LL x;
		scanf("%lld",&x);
		while(q&&a[q]>=x) q--;
		a[++q]=x;
	}
	app[q]=1;
	for(int i=q;i;i--)
	{
		LL l=a[i];
		int p=BS(1,i-1,l);
		while(p)
		{
			app[p]+=l/a[p]*app[i];
			l%=a[p];
			p=BS(1,p-1,l);
		}
		ans[l]+=app[i];
	}
	for(int i=n;i;i--) ans[i]+=ans[i+1];
	for(int i=1;i<=n;i++) printf("%lld\n",ans[i]);
}

Measured memory_bytes: 3968