akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

class seg_node {
public:
	using T1 = int;
	using T2 = int;

	static const T1 id = INT_MAX;
	static T1 op(const T1& l, const T1& r) { return min(l, r); }

	T1 get() const {
		if (!flag) return val;
		return lazy;
	}
	bool is_updated() const {
		return flag;
	}
	void update(T2 v) {
		if (!flag) {
			lazy = v;
			flag = true;
			return;
		}
		lazy = v;
	}
	void update_up(const seg_node& l, const seg_node& r) {
		val = op(l.get(), r.get());
	}
	void push(seg_node& l, seg_node& r) {
		if (!flag) return;
		l.update(lazy);
		r.update(lazy);
		val = get();
		flag = false;
	}
	void init(const seg_node& l, const seg_node& r) {
		val = op(l.val, r.val);
	}
	void init(const T1& v) {
		val = v;
	}
	seg_node() : val(id), flag(false) {}

private:
	T1 val;
	T2 lazy;
	bool flag;

};

template <typename M>
class segment_tree {
	using T1 = typename M::T1;
	using T2 = typename M::T2;
	const int h, n;
	vector<M> data;
	void push(int node) {
		data[node].push(data[node << 1], data[(node << 1) | 1]);
	}
	void update(int node) {
		data[node].update_up(data[node << 1], data[(node << 1) | 1]);
	}
public:
	segment_tree(int n_)
		: h(ceil(log2(n_))), n(1 << h), data(n * 2) {
		init();
	}
	segment_tree(int n_, T1 v1)
		: h(ceil(log2(n_))), n(1 << h), data(n * 2) {
		init();
	}
	segment_tree(const vector<T1>& data_)
		: h(ceil(log2(data_.size()))), n(1 << h), data(n * 2) {
		for (int i = 0; i < (int)data_.size(); i++) {
			data[i + n].init(data_[i]);
		}
		init();
	}
	void init() {
		for (int i = n - 1; i >= 1; i--) {
			data[i].init(data[i << 1], data[(i << 1) | 1]);
		}
	}
	void update(int l, int r, T2 val) {
		l += n, r += n;
		for (int i = h; i > 0; i--) push(l >> i), push(r >> i);
		int tl = l, tr = r;
		r++;
		while (l < r) {
			if (l & 1) data[l++].update(val);
			if (r & 1) data[--r].update(val);
			l >>= 1; r >>= 1;
		}
		while (tl >>= 1, tr >>= 1, tl) {
			if (!data[tl].is_updated()) update(tl);
			if (!data[tr].is_updated()) update(tr);
		}
	}
	T1 find(int l, int r) {
		l += n, r += n;
		for (int i = h; i > 0; i--) push(l >> i), push(r >> i);
		r++;
		T1 res1 = M::id, res2 = M::id;
		while (l < r) {
			if (l & 1) res1 = M::op(res1, data[l++].get());
			if (r & 1) res2 = M::op(data[--r].get(), res2);
			l >>= 1; r >>= 1;
		}
		return M::op(res1, res2);
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q, com, x, y, val;
	cin >> n >> q;
	segment_tree<seg_node> st(n);
	while (q--) {
		cin >> com >> x >> y;
		if (com) {
			printf("%d\n", st.find(x, y));
		}
		else {
			cin >> val;
			st.update(x, y, val);
		}
	}
	return 0;
}



Measured memory_bytes: 6212
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<map>

using namespace std;

#define rep(i,N) for(int i=0;i<N;i++) //0から


typedef long long ll;




ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

vector<ll> prime;
void Prime(ll n){ //線形篩,素数列挙
    vector<ll> p(n,0);
    p[0]=1;
    p[1]=1;
    for(ll i=2;i<n;i++){
        if(p[i]==0){
            prime.push_back(i);
            p[i]=i;
        }
        ll k=prime.size();
        for(ll j=0;j<k && i*prime[j]<n && prime[j]<=p[i];j++){
            p[i*prime[j]]=prime[j];
        }
    }
}

ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    //a>=b
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

#define MOD ((ll)1e+9 + 7)



//cout<<fixed<<setprecision(10);
int main(){
    ll l,r;
    cin>>l>>r;
    ll ans=2019;
    for(ll i=l;i<=min(l+2019,r);i++){
        for(ll j=i+1;j<=min(l+2019,r);j++){
            ans=min(ans,(i*j)%2019);
        }
    }
    cout<<ans<<endl;

    return 0;
}



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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
int n;
vector<int> to[200005]; // 隣接リスト
 
mint ans;
// 戻り値は頂点v以下の部分きのサイズ（頂点数）
int dfs (int v, int p = -1) {
  int res = 1;
  vector<int> ts;
  for (int u : to[v]) {
    if (u == p) continue;  // 隣接相手が親ならスルー
    int t = dfs(u, v);
    res += t;
    ts.push_back(t);
  }

  if (p != -1) {
    ts.push_back(n - res);  // 部分木じゃない、親方向の木のサイズ
  }

  // 頂点vが白の時、vを内部に含むような部分きの数をnowとする
  mint now = mint(2).pow(n - 1) - 1;
  for (int t : ts) {
    now -= mint(2).pow(t) - 1;
  }
  ans += now;
  return res;
}

// 解説の解法2に相当
int main() {

  cin >> n;
  rep (i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  dfs(0);
  ans /= mint(2).pow(n);
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 29184
#include<iostream>
using namespace std;
int main(){
  int h,n;
  cin>>h>>n;
  int a;
  int ans=0;
  for(int i;i<n;i++){
    cin>>a;
    ans+=a;
  }
  if(ans>=h)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
txy = [[0,0,0]]
for i in range(N):
    txy.append([int(x) for x in input().split()])
flg = 0

for j in range(1, N + 1):
    dt = txy[j][0] - txy[j - 1][0]
    dx = txy[j][1] - txy[j - 1][1]
    dy = txy[j][2] - txy[j - 1][2]
    d = dt - abs(dx) - abs(dy)

    if d < 0 or d % 2 != 0:
        print("No")
        flg = 1
        break

if flg == 0:
    print("Yes")

Measured memory_bytes: 21108
#include <bits/stdc++.h>
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
int main()
{
  string s;
  cin >> s;

  bool sp = true;
  re(i, s.size()/2) {
    if (s[i] != s[s.size()-1-i]) {
      sp = false;
      break;
    }
  }

  re(i, s.size()/4) {
    if (s[i] != s[s.size()/2-1-i]) {
      sp = false;
      break;
    }
  }

  if(sp) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.append(X)
y.append(Y)
x.sort()
y.sort()
if x[-1] < y[0]:
    print('No War')
else:
    print('War')

Measured memory_bytes: 3064
#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;

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

  unordered_map<ll,ll> cnts;
  rep(i,n) {
    ++cnts[a[i]];
  }

  auto check = [&](ll v) {
    if (cnts.find(v) != cnts.end() && cnts[v] != 0) { // found
      return true;
    }
    return false;
  };

  ll ans = 0;
  rep(i,n) {
    --cnts[a[i]];

    bool found = false;
    for (ll j = 1; j*j <= a[i]; ++j) {
      if (a[i]%j == 0) {
        if (check(j)) {
          found = true;
          break;
        }
        if (check(a[i]/j)) {
          found = true;
          break;
        }
      }
    }

    if (!found) {
      ++ans;
    }

    ++cnts[a[i]];
  }
  cout << ans << endl;
}


Measured memory_bytes: 12928
n = int(input())
a = list(map(int,input().split()))
so_list = [0 for i in range(10**6)]
mod = 10**9+7

def fac(n):
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            if so_list[i]<cnt:
              so_list[i]= cnt
    if temp!=1:
    #  print(temp)
      if so_list[temp]==0:
        so_list[temp]=1
for i in range(n):
  a1 = a[i]
  fac(a1)
l = 1
for i in range(len(so_list)):
  if so_list[i]!=0:
    l *= pow(i,so_list[i],mod)
    l %= mod
ans = 0
#print(l)
for i in a:
  t = pow(i,mod-2,mod)
  ans += (l*t)%mod
print(ans%mod)
  

Measured memory_bytes: 17812
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

int R, G, B, N, ans = 0;

int main(){
	getint(R), getint(G), getint(B), getint(N);
	for(register int r = 0, maxr = N / R; r <= maxr; r++)
		for(register int g = 0, maxg = (N - r * R) / G; g <= maxg; g++)
			if((N - r * R - g * G) % B == 0) ans++;
	return printf("%d\n", ans), 0;
}


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

using namespace std ;
typedef long long ll;
typedef string str;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<double> vdou ;
typedef vector<ll> vll;
typedef vector<vint> vvint;
typedef vector<str> vstr;
typedef pair<ll,ll> pll ;
typedef vector<pii> vpii ;
typedef vector<pll> vpll ;

#define REP(i, n) for (ll (i) = 0; (i) < (ll)(n); i++) 
#define FOR(i, a, b) for(ll (i) = a; (i) < (ll)b; i++)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define CHI 1000000000000000003
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define NP next_permutation
#define SZ(x)  (ll)x.size()
#define SP(x)  setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}
//-----------------------------------------

struct warshall_floyd {
  vvint d ;
  
  void make(int n){
    REP(i,n){
      d.PB(vint());
    }
    REP(i,n){
      REP(j,n){
        if(i==j){
          d[i].PB(0);
        }
        else{
          d[i].PB(INF) ;
        }
      }
    }
  }
  
  void inin(int a,int b,int c){
    d[a][b] = c ;
  }
  
  void work(){
    int n = SZ(d[0]) ;
    REP(k,n){
      REP(i,n){
        REP(j,n){
          d[i][j] = min(d[i][j],d[i][k]+d[k][j]) ;
        }
      }
    }
  }
  
  int dis(int i,int j){
    return d[i][j] ;
  }
  
  bool negative(){
    int n = SZ(d[0]) ;
    REP(i,n){
      REP(j,n){
        if(d[i][j]<0){
          return true ;
        }
      }
    }
    return false ;
  }
      
  
};


















//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w ;
  cin >> h >> w ;
  warshall_floyd hoge ;
  hoge.make(10) ;
  REP(i,10){
    REP(j,10){
      int a ; 
      cin >> a ;
      hoge.inin(i,j,a) ;
    }
  }
  hoge.work() ;
  ll ans = 0 ;
  
  REP(i,h){
    REP(j,w){
      int b ;
      cin >> b ;
      if(b!=-1){
        ans += hoge.dis(b,1) ;
      }
    }
  }
  
  cout << ans <<endl ;
  
  
  
  
  return 0 ;
}

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

ll Ten(int x){
ll ret=1;
while( x-- )ret*=10ll;
return ret;
}

int ask(ll n){
cout<<"? "<<n<<endl;
cout.flush();
char c;
cin>>c;
return c=='Y';
}

int main(){

if( ask( Ten(9) ) ){

for(int i=0;i<=10;i++){
    if( ask( 2ll*Ten(i) ) ){
        cout<<"! "<<Ten(i)<<endl;
        return 0;
    }
}

}else{


for(int i=0;i<=15;i++)
if( !ask( Ten(i) ) ){

    ll low = Ten(i-1) , high=Ten(i)-1;
    while( low < high ){
        ll mid = low+high>>1;
        if( ask(10ll*mid) )high=mid;
        else low=mid+1;
    }

    cout<<"! "<<high<<endl;
    return 0;
}

}


return 0;
}


Measured memory_bytes: 596
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(void){
  int n,k;
  scanf("%d%d",&k,&n);
  int a[n],sum1=0,max=0,sum,i,sum2;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=1;i<n;i++){
    sum1+=(a[i]-a[i-1]);
  }
  sum2=sum1;
  for(i=1;i<n;i++){
    if(max<a[i]-a[i-1]) max=a[i]-a[i-1];
  }
  sum=sum1-max+(k-a[n-1]+a[0]);
  printf("%d",sum2<sum?sum2:sum);
    return 0;
}

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

using namespace std;

int main()
{
    int n,d,c=0;
    cin>>n>>d;
    for(int i=0; i<n; i++){
        long long a,b;
        cin>>a>>b;
        if(sqrt(a*a+b*b)<=d){
            c++;
        }
    }
    cout<<c;
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <iomanip>
using std::cin;
using std::cout;
using std::endl;

const int MAX_N = 100000;

struct War
{
    int west, east;
    bool operator>(const War &another) const
    {
        return east > another.east;
    };
    bool operator<(const War &another) const
    {
        return east < another.east;
    };
};

bool comp(War a, War b)
{
    return a.east < b.east;
}

int main(void)
{
    cout << std::fixed << std::setprecision(10);
    int n, m;
    cin >> n >> m;
    std::vector<War> war;

    int m1, m2;
    War pushed_war;
    for (int i = 0; i < m; i++)
    {
        scanf("%d %d", &m1, &m2);
        pushed_war.west = m1;
        pushed_war.east = m2;
        war.push_back(pushed_war);
    };

    std::sort(war.begin(), war.end());

    int answer = 0;
    int break_bridge = 0;
    for (int i = 0; i < m; i++)
    {
        War query = war[i];
        if (query.west >= break_bridge)
        {
            break_bridge = query.east;
            answer++;
        }
    }

    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 1400
#include <stdio.h>

#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define STR(i,str) for(int i=0;(str)[i];i++)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX3(a,b,c) ((a)>(b)?(a)>(c)?(a):(c):(b)>(c)?(b):(c))
#define MIN3(a,b,c) ((a)<(b)?(a)<(c)?(a):(c):(b)<(c)?(b):(c))
#define RNG(a,b) ((a)>(b)?(a)-(b):(b)-(a))
#define RNG3(a,b,c) ((a)>(b)?(b)>(c)?(a)-(c):(c)>(a)?(c)-(b):(a)-(b):(b)>(c)?(c)>(a)?(b)-(a):(b)-(c):(c)-(a))
#define MAXS(a,b) {if((a)<(b))(a)=(b);}
#define MINS(a,b) {if((a)>(b))(a)=(b);}

int main(){
	int a, b, c, d, e, f;
	int ans1, ans2;
	bool flag = 1;
	scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f);
	a *= 100;
	b *= 100;
	for(int i = 0;; i++){
		if(a*i > f) break;
		else for(int j = 0;; j++){
			if(!i && !j) continue;
			else if(a*i + b*j > f) break;
			else{
				//printf("i:%d, j:%d\n", i, j);
				int max = 0;
				for(int k = 0;; k++){
					if(c*k > (a*i + b*j)*e / 100) break;
					else for(int l = 0;; l++){
						if(c*k + d*l > (a*i + b*j)*e / 100 || a*i + b*j + c*k + d*l > f) break;
						//printf(" k:%d, l:%d, ai+bj:%d, ck+dl:%d\n", k, l, a*i + b*j, c*k + d*l);
						if(c*k + d*l <= (a*i + b*j)*e / 100){
							MAXS(max, c*k + d*l);
						}
					}
				}
				if(flag){
					ans1 = a*i + b*j + max;
					ans2 = max;
					flag = 0;
				}else if(ans1*max > ans2*(a*i + b*j + max)){
					ans1 = a*i + b*j + max;
					ans2 = max;
				}
			}
		}
	}
	printf("%d %d\n", ans1, ans2);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
#include <set>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int N;
const int MAX_N = 200000;
ll A[MAX_N];


int main(){
  cin >> N;
  REP(i, N) cin >> A[i];

  if(A[0] != 0) {
    cout << -1 << endl;
    return 0;
  }

  ll ans = 0;
  REP(i, N - 1) {
    if(A[i + 1] > A[i] + 1) {
      cout << -1 << endl;
      return 0;
    } else if(A[i + 1] == A[i] + 1) {
      ans++;
    } else {
      ans += A[i + 1];
    }
  }

  cout << ans << endl;

  return 0;

}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
#define lcm(x, y) ((x) * (y) / __gcd((x), (y)))
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define debug(x) cout << #x << " : " << x << endl
#define part cout << "----------------------------------\n";
#include <iostream>

#define fastinput                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

int main()
{
    fastinput;
    LL n, i, j, k, t, temp, M;
    cin >> n >> M;
   // vector<LL> v(M), pairs(M);
    map<LL, LL> freq, freqmod;
    LL cnt = 0;
    for (i = 0; i < n; i++)
    {
        cin >> j;
        freq[j]++;
    }

    for (auto x : freq)
    {
        LL num = x.first;
        LL f = x.second;
        if (f & 1)
        {
          //  cout<<"increasing due to "<<num<<endl;
            freqmod[num % M]++;
            freq[num]--;
        }
    }

    for (auto &x : freqmod)
    {
        LL num = x.first;
        LL f = freqmod[num];
        if (f == 0)
        {
            continue;
        }
        else
        {

            LL complement = (M - num)%M;
            LL a = min(f, freqmod[complement]);
            cnt += a;
           // cout << "num is " << num << endl;
           // debug(a);
            freqmod[num] -= a;
            freqmod[complement] -= a;
        }
    }

    for (auto x : freqmod)
    {
        LL num = x.first;
        LL f = x.second;
        if (f == 0)
        {
            freqmod.erase(num);
        }
    }
   // debug(cnt);
   // cout<<"invetifate\n";
    for (auto x : freq)
    {
        LL num = x.first;
        LL f = x.second;
       // debug(num);
        //debug(f);
       // part;
        LL reqd = freqmod[(M-num % M)%M];
        LL add = min(reqd, f);
        cnt += add;
        freq[num] -= add;
        freqmod[(M-num % M)%M] -= add;
        cnt += (freq[num] / 2);
    }
    //debug(cnt);
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector<int> h(n+1);
  
  for (int i = 1; i < n+1; i++) cin >> h[i];
  h[0] = 0;
  int ans = 0;
  
  for (int i = 1; i < n+1; i++){
    if(h[i] > h[i-1]) ans += h[i] - h[i-1];
  }
  
  cout << ans;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main (void)
{
 int A;

 scanf("%d",&A);
 int B = 0;
 if(A%2 ==0){
 for(int i = 1;i < A/2;++i)
 {
     B = B + 1;
 }
 }
 else{
     for(int i = 1;i <= A/2;++i)
 {
     B = B + 1;
 }
 }
 printf("%d",B);
 return 0;
}

Measured memory_bytes: 128
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    a,b,c,d = readInts()
    while True:
        c -= b
        #print(a)
        if c <= 0:
            print('Yes')
            exit()
        a -= d
        #print(b)
        if a <= 0:
            print('No')
            exit()
if __name__ == '__main__':
  main()


Measured memory_bytes: 10860
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MAX = 1000;
const int INF = 1e9;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L
//setprecision(15)


int main() {
	int N; cin >> N;
	vector<int> A(N); rep(i, N) cin >> A[i];
	rep(i, N) {
		if (A[i] % 2 == 1) continue;
		if (A[i] % 3 != 0 && A[i] % 5 != 0) {
			cout << "DENIED" << endl;
			return 0;
		}
	}
	cout << "APPROVED" << endl;
}

Measured memory_bytes: 3632
import Control.Monad

main :: IO ()
main = do
  n <- readLn
  if n == 0
    then return ()
    else do
      ls <- replicateM n getLine
      pqrc <- getLine
      let ls' = map (map read . words) ls
          pqrc' = map read .  words $ pqrc
      mapM_ putStrLn $ solve ls' pqrc'
      main
      
solve :: [[Int]] -> [Int] -> [String]
solve ls pqrc
  | checkedL == [] = ["NA"]
  | otherwise = reverse checkedL
  where
    checkedL = foldl check [] ls
    check :: [String] -> [Int] -> [String]
    check acc item = check' acc item pqrc
      where
        check' :: [String] -> [Int] -> [Int] -> [String]
        check' acc [i,pi,qi,ri] [p,q,r,c]
          | pi <= p && qi <= q && ri <= r && (pi * 4 + qi * 9 + ri * 4) <= c = (show i):acc
          | otherwise = acc

Measured memory_bytes: 5704
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint MOD = 1e9+7;
lint dp[110][110][2];

signed main(){
	string s; cin >> s;
	lint K; cin >> K;
	lint N = s.size();
	dp[0][0][0] = 1;
	for(lint i = 0; i < N; i++){
		for(lint j = 0; j < 100; j++){
			for(lint k = 0; k < 2; k++){
				if(k == 1){
					for(lint l = 0; l < 10; l++){
						dp[i + 1][j + (l != 0)][1] += dp[i][j][1];
					}
				}
				if(k == 0){
					lint lim = s[i] - '0';
					for(lint l = 0; l <= lim; l++){
						dp[i + 1][j + (l != 0)][l != lim] += dp[i][j][0];
					}
				}
			}
		}
	}
	cout << dp[N][K][0] + dp[N][K][1] << endl;
}

Measured memory_bytes: 384
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var ABCD string
	fmt.Scan(&ABCD)

	var nums [4]int
	for i := 0; i < len(nums); i++ {
		val, _ := strconv.Atoi(string(ABCD[i]))
		nums[i] = val
	}

	var ans int
	var bits int

	for bits = 0; bits < (1 << uint(3)); bits++ {
		ans = nums[0]
		for i := 0; i < 3; i++ {
			if ((bits >> uint(i)) & 1) == 1 {
				ans -= nums[i+1]
				continue
			}
			ans += nums[i+1]
		}
		if ans == 7 {
			break
		}
	}
	ops := ""
	for i := 0; i < 3; i++ {
		if ((bits >> uint(i)) & 1) == 1 {
			ops = ops + "-"
			continue
		}
		ops = ops + "+"
	}

	fmt.Printf("%d%s%d%s%d%s%d=7\n", nums[0], string(ops[0]), nums[1], string(ops[1]), nums[2], string(ops[2]), nums[3])
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
int d[256];
int main( void )
{
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  for( int i=0; i<S.size(); i++ ){
    d[S[i]]++;
  }
  if( ( d['N']  > 0 && d['S'] == 0 ) ||
      ( d['N'] == 0 && d['S'] >  0 ) ||
      ( d['W']  > 0 && d['E'] == 0 ) ||
      ( d['W'] == 0 && d['E'] >  0 ) ) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int x;
  cin >> x;
  if (x <= 599) {
    cout << 8 << endl;
  } else if (x <= 799) {
    cout << 7 << endl;
  } else if (x <= 999) {
    cout << 6 << endl;
  } else if (x <= 1199) {
    cout << 5 << endl;
  } else if (x <= 1399) {
    cout << 4 << endl;
  } else if (x <= 1599) {
    cout << 3 << endl;
  } else if (x <= 1799) {
    cout << 2 << endl;
  } else {
    cout << 1 << endl;
  }
  return 0;
}

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

double dist(double x1, double y1, double x2, double y2)
{
	//return (pow(x1 - x2, 2) + pow(y1 - y2, 2));
	return (hypot(x1 - x2, y1 - y2));
} 

int main(void)
{
	double ax, ay;
	double bx, by;
	double ar, br;
	double abdist;
	int n, i;

	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%lf %lf %lf %lf %lf %lf", &ax, &ay, &ar, &bx, &by, &br);

		abdist = dist(ax, ay, bx, by);
		if (abdist <= ar + br){
			if (ar > br + abdist){
				puts("2");
			}
			else if (br > ar + abdist){
				puts("-2");
			}
			else {
				puts("1");
			}
		}
		else {
			puts("0");
		}
	}

	return (0);
}

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

using ll = long long;

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

int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<int>> field(h + 2, vector<int>(w + 2, 0));
    REP(y, h){
        string s;
        cin >> s;
        REP(x, w){
            if(s[x] == '#') field[y + 1][x + 1] = 1;
        }
    }
    REP(y, h){
        REP(x, w){
                int cx = x + 1;
                int cy = y + 1;
                if(field[cy][cx]){
                bool is_able = false;
                if(field[cy][cx - 1]) is_able = true;
                if(field[cy][cx + 1]) is_able = true;
                if(field[cy - 1][cx]) is_able = true;
                if(field[cy + 1][cx]) is_able = true;
                if(!is_able){
                    cout << "No";
                    return 0;
                }
            }
        }
    }
    cout << "Yes";
    return 0;
}

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

int main() {
  long double a;
  long double b;

  cin >> a >> b;

  long double ans = a * b;
  ans = floor(ans);
  
  ANS((ll)ans);
  return 0;
}


Measured memory_bytes: 3728
#include <iostream>
#include <map>

using namespace std;

int main()
{
	int N, a;
	int ans = 0;
	map<int, int> table;

	cin >> N;

	for (int i = 0; i < N; i++)
	{
		cin >> a;

		if (table.find(a) != table.end())
			table[a]++;
		else
			table[a] = 1;
	}

	for (auto v : table)
	{
		if (v.second % 2 != 0)
			ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  ll r, D, x;
  cin >> r >> D >> x;

  rep(i,10){
    x = r*x-D;
    cout << x << endl;
  }
  
  return 0;
}



Measured memory_bytes: 256
/**
 *      ABC 97 C
 *      author  : kyomukyomupurin
 *      created : 2018-10-05 12:54:41
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s; cin >> s;
    int_fast16_t K; cin >> K;

    vector<string> sub;

    for (auto i = 1; i <= min(K, (int_fast32_t) s.size()); ++i) {
        for (auto j = 0; j < (int_fast32_t) s.size() - i + 1; ++j) {
            sub.push_back(s.substr(j, i));
        }
    }

    sort(sub.begin(), sub.end());
    auto result = unique(sub.begin(), sub.end());
    sub.erase(result, sub.end());

    cout << sub[K - 1] << '\n';
    return 0;
}

Measured memory_bytes: 1660
using System;

namespace abc147_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string kai = Console.ReadLine();
            int hug = 0;
            for(int i = 0; i < kai.Length / 2; i++)
            {
                if(kai[i]!=kai[kai.Length -1 -i])
                {   
                    hug++;
                }
            }
            Console.WriteLine(hug);
            Console.ReadLine();
        }
    }
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,a,b;cin >> n >> a >> b;
	int ans=0;
	for(int i=1;i<=n;++i){
		int sum=0,k=i;
		while(k>0){
			sum+=k%10;
			k/=10;
		}
		if(sum>=a && sum<=b) ans+=i;
	}
	cout << ans << endl;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
const int INF = 1 << 27;
const ll LLINF = (ll)1 << 60;
const ll MOD = 1e9+7;

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

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }

  vector<ll> sum(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    sum[i] = sum[i-1] + a[i-1];
  }

  vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, 0));
  for (int len = 1; len <= n; len++) {
    for (int i = 0; ; i++) {
      int j = i + len;
      if (j > n) break;
      dp[i][len] = max(
        a[i] + sum[j] - sum[i+1] - dp[i+1][len-1],
        a[j - 1] + sum[j-1] - sum[i] - dp[i][len-1]);
    }
  }

  printf("%lld\n", 2 * dp[0][n] - sum[n]);
}


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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int ans[5 * mx2], c[5 * mx2], s[5 * mx2], f[5 * mx2];

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

    for(int i = 1; i < n; i++)
        cin >> c[i] >> s[i] >> f[i];

    for(int i = 1; i < n; i++){

        int pre = 0;
        for(int j = i; j < n; j++){
            pre = max(s[j], ((pre + f[j] - 1) / f[j]) * f[j]);
            pre += c[j];
        }

        ans[i] = pre;
    }

    for(int i = 1; i <= n; i++)
        cout << ans[i] << '\n';

    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <fstream>
#include <cmath>

using namespace std;
ifstream in("sortaret.in");
ofstream out("sortaret.out");

const int NMax = 5e4 + 5;
typedef long long ll;
const int inf = 1e9;

int N,M;
struct elem {
    int x,y;
}v1[55],v2[55];

int d(elem,elem);

int main()
{
    cin>>N>>M;
    for (int i=1;i<=N;++i) {
        cin>>v1[i].x>>v1[i].y;
    }
    for (int i=1;i<=M;++i) {
        cin>>v2[i].x>>v2[i].y;
    }

    for (int i=1;i<=N;++i) {
        int mn = inf,poz;
        for (int j=1;j<=M;++j) {
            if (mn > d(v1[i],v2[j])) {
                mn = d(v1[i],v2[j]);
                poz = j;
            }
        }

        cout<<poz<<'\n';
    }
    in.close();out.close();
    return 0;
}

int d(elem a,elem b) {
    return abs(a.x - b.x) + abs(a.y - b.y);
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Unit[] arr = new Unit[n];
		for (int i = 0; i < n; i++) {
		    arr[i] = new Unit(i, sc.nextInt());
		}
		Arrays.sort(arr);
		int count = 0;
		for (int i = 0; i < n; i++) {
		    if (i % 2 != arr[i].idx % 2) {
		        count++;
		    }
		}
		System.out.println(count / 2);
	}
	
	static class Unit implements Comparable<Unit> {
	    int idx;
	    int value;
	    
	    public Unit (int idx, int value) {
	        this.idx = idx;
	        this.value = value;
	    }
	    
	    public int compareTo(Unit another) {
	        return value - another.value;
	    }
	}
}


Measured memory_bytes: 64388
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
	int n;
	char str[1024];

	scanf("%d ", &n);

	for (int i = 0; i < n; i++){
		fgets(str, sizeof(str), stdin);

		int len = strlen(str);
		for (int j = 0; j < len - 6; j++){
			if (strncmp(&str[j], "Hoshino", 7) == 0){
				str[j + 6] = 'a';
			}
		}

		cout << str;
	}

	return (0);
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=100000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<int,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
ll mypow(ll x,int m){
	if(m==0)return 1;
	if(m%2==0){
		int x2=mypow(x,m/2);
		return x2*x2;
	}else{
		int x2=mypow(x,m/2);
		return x2*x2*x;
	}
}
int n;
string s;
double x[10],y[10];
int main() {
	cin>>n;
	rep(i,0,n){
		cin>>x[i]>>y[i];
	}
	double count=0;
	for(int i=0;i<n;++i){
		for(int j=i+1;j<n;++j){
			count+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
		}
	}
	printf ("%.10f\n",count*2/n);
	//cout<<count*2/n<<endl;
	return 0;
}


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

int main(void)
{
	int num,n,max,min,sum,ave,i;
	
	while(cin >> num){
		if(num == 0){
			break;
		}

		sum = 0;
		ave = 0;
		for(i = 0; i < num; i++){
			cin >> n;
			if(i == 0){
				max = n;
				min = n;
			}else{
				if(max < n){
					max = n;
				}
				if(min > n){
					min = n;
				}
			}
			sum += n;
		}
		sum = sum - max - min;
		ave = sum / (num - 2);
		cout << ave<< endl;
	}

	return 0;
}

Measured memory_bytes: 3028
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	cout << n*(n-1)/2 << endl;
	
	return 0;
}

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

int n,k,ans,b;
int d[101],a[101];

int main(){
	cin >> n >> k;
  
  	for (int i=1; i<=k; i++){
    	cin >> d[i];
      	
      	for (int j=1; j<=d[i]; j++){
      		cin >> b;
      		
      		a[b]=1;
		}
    }
    
    for (int i=1; i<=n; i++)
    	if (a[i]==0)
    		ans++;
	
	cout << ans << endl;
}

Measured memory_bytes: 3624
import fractions
A, B, C, D = (int(x) for x in input().split())
l = C*D//fractions.gcd(C,D)
comp = (B//C - (A-1)//C) + (B//D - (A-1)//D) - (B//l - (A-1)//l)
print(B-A+1-comp)


Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

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

int main() {
  ll n;
  cin >> n;
  vector<ll> x(n), y(n);
  REP(i, n) { cin >> x[i] >> y[i]; }

  ll ans = 0;
  {
    ll maxi = -1e18, mini = 1e18;
    REP(i, n) {
      chmax(maxi, x[i] + y[i]);
      chmin(mini, x[i] + y[i]);
    }
    chmax(ans, maxi - mini);
  }
  {
    ll maxi = -1e18, mini = 1e18;
    REP(i, n) {
      chmax(maxi, x[i] - y[i]);
      chmin(mini, x[i] - y[i]);
    }
    chmax(ans, maxi - mini);
  }
  cout << ans << endl;
}

Measured memory_bytes: 6392
class Dice:
    def __init__(self, top, south, east, west, north, bottom):
        self.eyes = [top, south, east, west, north, bottom]


def roll_to_S(dice):
    eyes = dice.eyes

    return Dice(eyes[4], eyes[0], eyes[2], eyes[3], eyes[5], eyes[1])


def roll_to_N(dice):
    eyes = dice.eyes

    return Dice(eyes[1], eyes[5], eyes[2], eyes[3], eyes[0], eyes[4])


def roll_to_W(dice):
    eyes = dice.eyes

    return Dice(eyes[2], eyes[1], eyes[5], eyes[0], eyes[4], eyes[3])


def roll_to_E(dice):
    eyes = dice.eyes

    return Dice(eyes[3], eyes[1], eyes[0], eyes[5], eyes[4], eyes[2])


if __name__ == "__main__":
    eyes = list(map(int, input().split()))

    roll_directions = input()

    dice = Dice(*eyes)

    roll_function_table = {
        "S": roll_to_S,
        "N": roll_to_N,
        "W": roll_to_W,
        "E": roll_to_E
    }

    for roll_direction in roll_directions:
        dice = roll_function_table[roll_direction](dice)

    print(dice.eyes[0])




Measured memory_bytes: 5608
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		int N = sc.nextInt();
		int[] score = new int[N];
		int sum = 0;
		for (int i = 0; i < N; i++) {
			score[i] = sc.nextInt();
			sum += score[i];
		}
		if (sum % 10 != 0) {
			System.out.println(sum);
			return;
		}
		Arrays.sort(score);
		for (int i = 0; i < N; i++) {
			if (score[i] % 10 != 0) {
				sum -= score[i];
				System.out.println(sum);
				return;
			}
		}
		System.out.println(0);
	}

}

class FScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

template <class T> void readPoint(vector< vector<T> >& aVec, int nIdx) {
    T x, y;
    vector<T> aPoint(2);
    std::cin >> x >> y;
    aPoint[0] = x;
    aPoint[1] = y;
    aVec[nIdx] = aPoint;
}
int main()
{
    int nSize;
    cin >> nSize;
    vector< vector<int> > aPoints(nSize);
    for (int i = 0; i < nSize; i++) {
        readPoint(aPoints, i);
    }
    int nAns(1), nDir(0), nVecx(0), nVecy(0), nNew_vecx(0), nNew_vecy(0);
    for (int i = 0; i <= nSize; i++) {
        nNew_vecx = aPoints[(i + 1) % nSize][0] - aPoints[i % nSize][0];
        nNew_vecy = aPoints[(i + 1) % nSize][1] - aPoints[i % nSize][1];
        int nCross_prod = (nVecx * nNew_vecy - nVecy * nNew_vecx);
        if (nCross_prod != 0) {
            if (nCross_prod * nDir >= 0) {
                nDir = nCross_prod > 0 ? 1 : -1;
            }
            else {
                nAns = 0;
                break;
            }
        }
        nVecx = nNew_vecx;
        nVecy = nNew_vecy;
    }
    cout << nAns << "\n";
    return 0;
}


Measured memory_bytes: 3156
# D - String Equivalence
from string import ascii_lowercase


def dfs(n: int) -> list:
    if n == 1:
        return ["a"]
    cur = dfs(n - 1)
    result = []
    for s in cur:
        for c in ascii_lowercase[: len(set(s)) + 1]:
            result.append(s + c)
    return result


def main():
    N = int(input())
    result = dfs(N)
    result.sort()
    print("\n".join(result))


if __name__ == "__main__":
    main()


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


int64_t MOD;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

vector<int64_t> fact, seq_inv, fact_inv;

void create_fact_mod(int num){
    fact[0] = fact[1] = 1;
    for(int i=2; i<=num; i++) fact[i] = fact[i-1] * i % MOD;
}

void create_seq_inv_mod(int num){
    seq_inv[0] = seq_inv[1] = 1;
    for(int i=2; i<=num; i++) seq_inv[i] = (MOD - MOD/i) * seq_inv[MOD%i] % MOD;
}

void create_fact_inv_mod(int num){
    fact_inv[0] = fact_inv[1] = 1;
    for(int i=2; i<=num; i++) fact_inv[i] = fact_inv[i-1] * seq_inv[i] % MOD;
}

void create_mod_tables(int num){
    fact.resize(num+1);
    seq_inv.resize(num+1);
    fact_inv.resize(num+1);
    create_fact_mod(num);
    create_seq_inv_mod(num);
    create_fact_inv_mod(num);
}

int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

int main(){
    cin >> MOD;
    create_mod_tables(MOD-1);
    vector<int64_t> ans(MOD);
    for(int i=0; i<MOD; i++){
        int p;
        cin >> p;
        if(p){
            add(ans[0], 1);
            int64_t pw = 1;
            for(int j=MOD-1; j>=0; j--){
                int64_t res = pw * comb_mod(MOD-1, j) % MOD;
                if(j%2 == 0) res = MOD-res;
                add(ans[j], res);
                mul(pw, i);
            }
        }
    }
    for(int i=0; i<MOD; i++) cout << ans[i] << " \n"[i==MOD-1];
}


Measured memory_bytes: 384
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())
 
P = (A1 - B1) * T1
Q = (A2 - B2) * T2
if P > 0:
	P *= -1
	Q *= -1
 
if P + Q < 0:
	print(0)
elif P + Q == 0:
	print("infinity")
else:
	S = (-P) // (P + Q)
	T = (-P) % (P + Q)
	if T != 0:
		print(S * 2 + 1)
	else:
		print(S * 2)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
 
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;
 
void print(vector<vector<int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}
 
void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}
 
void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}
 
 
 
int main(){
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> choco(h);
	rep(i,h){
		string s;
		cin >> s;
		choco[i] = s;
	}
	int ans = inf;
	rep(i, (1 << (h-1)))
	{
		int g = 0;
		vector<int> id(h, 0);
		rep(j,h){
			id[j] = g;
			if (i>>j&1){
				g++;
			}
		}
		g++;
		vector<vector<int>> c(g, vector<int>(w, 0));
		rep(n, h) rep(m, w) c[id[n]][m] += (choco[n][m] - '0');
		int div = g - 1;
		vector<int> now(g, 0);
		rep(n, w)
		{
			rep(m, g)
			{
				now[m] += c[m][n];
			}
			rep(m, g)
			{
				if (now[m] > k){
					div++;
					now = vector<int>(g, 0);
					rep(l,g){
						now[l] += c[l][n];
					}
					if (now[m] > k){
						div = inf;
					}
				}
			}
			if (div == inf)
			{
				break;
			}
		}
		ans = min(ans, div);
	}
	cout << ans << endl;
 
	return 0;
}

Measured memory_bytes: 256
# # # coding=utf-8
# # # Author: lee215

get = lambda: int(raw_input().strip())
getl = lambda: raw_input().strip()
gets = lambda: map(int, raw_input().strip().split())
getss = lambda n: [gets() for _ in xrange(n)]

# 2019-03-30 20:14

A, B, C = gets()


# def solve(A, B, C):
#     if len(set([A, B, C])) < 3:
#         print 'Yes'
#     else:
#         print 'No'



def solve(A, B, C):
    if len(set([A, B, C])) == 1:
        print 'Yes'
    else:
        print 'No'

solve(A, B, C)


Measured memory_bytes: 2568