akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    string S,T;
    cin>>S;
    cin>>T;

    int k=S.size();

    string P,Q;
    
    for(int i=0;i<=k-1;++i){
      P=S.substr(i,k-i);
      Q=S.substr(0,i);
      if(T==P+Q){
        cout<<"Yes"<<endl;
        goto xyz;
      }
    }

  cout<<"No"<<endl;

xyz:;
}

Measured memory_bytes: 256
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int n,d;
  cin >> n >> d;
  d=d*2+1;
  if(n%d==0){
    cout << n/d << endl;
  }
  else{
    cout << n/d+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3620
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n; cin>>n;
    vector<int> a(n,0),b(n,0),c(n-1,0);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    rep(i,n-1) cin>>c[i];
    int ans=0;
    rep(i,n) ans+=b[i];
    rep(i,n-1){
        if(a[i+1]==a[i]+1) ans+=c[a[i]-1];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<climits>
using namespace std;
const int N=1e5+3;
int n;
int a[N],d[N];
int maxx,mid,now=INT_MAX,ans,fail;
int main(){
	scanf("%d",&n);
	for(int i = 1;i<=n;i++){
		scanf("%lld",&a[i]);
		if(maxx<a[i]) maxx=a[i],fail=i;
	}
	a[fail]=0;
	mid = maxx/2;
	for(int i = 1;i<=n;i++){
		int k = abs(a[i]-mid);
		if(k<now) now=k,ans=a[i];
	}
	printf("%d %d",maxx,ans);
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin>>n;
  vector<char> str;
  while(n)
  {
      long long p = n%26;
      if(p==0){
      str.push_back('z');
      n = (n / 26) - 1;} 
      else{
      n = n/26;
     str.push_back('a'+p-1);}
  }
for(long long i=str.size()-1;i>=0;i--)
printf("%c",str[i]);
}


Measured memory_bytes: 3608
//トポソの唯一性
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
using namespace std;

int main(){

    int n, m; cin >> n >> m;
    vector<vector<int> > adj(n);
    vector<int> d(n, 0);                           //入次数
    for(int i = 0; i < m; i++){
        int a, b; cin >> a >> b; a--; b--;          //aがbにかつ
        d[b]++;
        adj[a].push_back(b);
    }

    queue<int> q;

    //入次数が0の頂点queueに入れる
    for(int i = 0; i < n; i++){
        if(d[i] == 0) q.push(i);                    
    }

    bool flag = false;                              //トポソのいちいせい
    vector<int> ans;

    while(!q.empty()){

        flag |= (q.size() > 1);
        int v = q.front();
        q.pop();
        ans.push_back(v);

        //vから伸びている有向辺をなめる
        for(int i = 0; i < (int)adj[v].size(); i++){
            d[adj[v][i]]--;
            //辺を取り除いた後に入次数が0になったら
            if(d[adj[v][i]] == 0) q.push(adj[v][i]);
        }

    }

    for(int i = 0; i < (int)ans.size(); i++) cout << ans[i] + 1 << endl;
    cout << flag << endl;
    return 0;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define ref(i,n) for(long long i=0;i<n;i++)


using namespace std;

int a[2000002],t[2000002];

long long k,n;



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

    ref(i,n) cin>>a[i+1];
    int b=1;

    ref(i,60){
        if(k&1) b=a[b];
        k=k>>1;

        ref(j,n){
            t[j+1]=a[a[j+1]];
        }

        ref(j,n) a[j+1]=t[j+1];
   }

    cout<<b;

    return 0;
}


Measured memory_bytes: 5208
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {

	long long L,R,mod=2018;

	cin >> L;
	cin >> R;

	for (long long i = L; i < R; i++) {
		for (long long j = i+1; j <= R; j++) {
			if (j % 2019 == 0) {
				cout << "0";
				return 0;
			}
			if (i%j == 0)break;

			mod = min((i*j) % 2019, mod);

		}
	}
	cout << mod;
}

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

int main()
{
    int N;
    cin >> N;
    rep(i, N + 100)
    {
        if (i * 108 / 100 == N)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

int n;
int res = 100000;

int main()
{
  cin >> n;

  while(n--){
    res *= 1.05;
    if(res % 1000){
      res += 1000;
      res -= res % 1000;
    }
  }

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main(){
  int X;
  cin >> X;
  if(X < 600){
    cout << 8 << endl;
  }
  else if(X < 800){
    cout << 7 << endl;
  }
  else if(X < 1000){
    cout << 6 << endl;
  }
  else if(X < 1200){
    cout << 5 << endl;
  }
  else if(X < 1400){
    cout << 4 << endl;
  }
  else if(X < 1600){
    cout << 3 << endl;
  }
  else if(X < 1800){
    cout << 2 << endl;
  }
  else{
    cout << 1 << endl;
  }
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <functional>

using namespace std;

int main()
{
	int N;

	cin >> N;

	vector<long long> a(3 * N);
	for(int i = 0 ; i < 3 * N ; ++i)
		cin >> a[i];

	vector<long long> af(3 * N, -((long long)1) << 60);
	vector<long long> ab(3 * N, ((long long)1) << 60);

	long long ca;
	vector<long long> ha(N);
	for(int i = 0 ; i < N ; ++i)
		ha[i] = a[i];
	ca = accumulate(ha.begin(), ha.end(), (long long)0);
	make_heap(ha.begin(), ha.end(), greater<long long>());

	for(int i = N ; i < 3 * N ; ++i) {
		af[i] = ca;
		if(ha.front() < a[i]) {
			pop_heap(ha.begin(), ha.end(), greater<long long>());
			ca = ca - ha.back() + a[i];
			ha.back() = a[i];
			push_heap(ha.begin(), ha.end(), greater<long long>());
		}
	}

	for(int i = 0 ; i < N ; ++i)
		ha[i] = a[3*N-i-1];
	ca = accumulate(ha.begin(), ha.end(), (long long)0);
	make_heap(ha.begin(), ha.end());

	for(int i = N ; i < 3 * N ; ++i) {
		ab[3*N-i] = ca;
		if(ha.front() > a[3*N-i-1]) {
			pop_heap(ha.begin(), ha.end());
			ca = ca - ha.back() + a[3*N-i-1];
			ha.back() = a[3*N-i-1];
			push_heap(ha.begin(), ha.end());
		}
	}

	long long result = -(((long long)1) << 60);
	for(int i = 0 ; i < 3 * N ; ++i) {
		cerr << i << ": " << af[i] << " - " << ab[i] << " = " << (af[i] - ab[i]) << endl;
		result = max(result, af[i] - ab[i]);
	}

	cout << result << endl;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define tll tuple<ll, ll, ll>
#define all(c) c.begin(),c.end()

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
 
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;

char albt[26] = {'a','b','c','d','e','f','g','h','i','j','k','l',
                 'm','n','o','p','q','r','s','t','u','v','w','x',
                 'y','z'};

//vector<ll> g[202020];
//fill(score, score+202020, 0);
//vector<ll> v;

int main(){
  ll n;
  cin >> n;
  
  //ll sum1 = 0;
  //ll sum2 = 0;
  ll A[n];
  for (int i=0;i<n;i++){
    cin >> A[i];
    //sum1 += tmp;
    //sum2 += tmp*tmp;
  }
  
  ll ans = 0;
  for (int i=0;i<n;i++){
    for (int j=i+1;j<n;j++){
      ans += A[i]*A[j];
    }
  }
  
      
  //cout << (sum1*sum1)/2 - sum2 << endl;
  
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N2 = sc.nextInt() * 2;
		int[] L = new int[N2];
		for (int i = 0; i < N2; i++) {
			L[i] = sc.nextInt();
		}
		Arrays.sort(L);
		int ans = 0;
		for (int i = 0; i < N2; i+=2) {
			ans += L[i];
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21076
#include<stdio.h>
#define reg register
#define ri reg int
#define rep(i, x, y) for(ri i = x; i <= y; ++i)
#define nrep(i, x, y) for(ri i = x; i >= y; --i)
#define DEBUG 1
#define ll long long
#define max(i, j) (i) > (j) ? (i) : (j)
#define min(i, j) (i) < (j) ? (i) : (j)
struct IO {
	#define MAXSIZE (1 << 20)
	#define isdigit(x) (x >= '0' && x <= '9')
	char buf[MAXSIZE], *p1, *p2;
	char pbuf[MAXSIZE], *pp;
	#if DEBUG
	#else
		IO() : p1(buf), p2(buf), pp(pbuf) {}
		~IO() {
			fwrite(pbuf, 1, pp - pbuf, stdout);
		}
	#endif
	inline char gc() {
		#if DEBUG
    		return getchar();
		#endif
    	if(p1 == p2)
			p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin);
    	return p1 == p2 ? ' ' : *p1++;
	}
	inline bool blank(char ch) {
    	return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
	}
	template <class T>
	inline void read(T &x) {
    	register double tmp = 1;
    	register bool sign = 0;
    	x = 0;
    	register char ch = gc();
    	for(; !isdigit(ch); ch = gc())
    		if(ch == '-') sign = 1;
    	for(; isdigit(ch); ch = gc())
			x = x * 10 + (ch - '0');
    	if(ch == '.')
			for(ch = gc(); isdigit(ch); ch = gc())
        		tmp /= 10.0, x += tmp * (ch - '0');
    	if(sign) x = -x;
	}
	inline void read(char *s) {
		register char ch = gc();
		for(; blank(ch); ch = gc());
		for(; !blank(ch); ch = gc())
			*s++ = ch;
    	*s = 0;
	}
	inline void read(char &c) {
    	for(c = gc(); blank(c); c = gc());
	}
	inline void push(const char &c) {
		#if DEBUG
    		putchar(c);
		#else
    		if(pp - pbuf == MAXSIZE) {
				fwrite(pbuf, 1, MAXSIZE, stdout);
				pp = pbuf;
			}
    		*pp++ = c;
		#endif
	}
	template <class T>
	inline void write(T x) {
    	if(x < 0) {
			x = -x;
			push('-');
		}
    	static T sta[35];
    	T top = 0;
    	do {
			sta[top++] = x % 10;
			x /= 10;
    	}while(x);
    	while(top)
			push(sta[--top] + '0');
	}
	template <class T>
	inline void write(T x, char lastChar) {
    	write(x);
		push(lastChar);
	}
} io;
ll n, k, d;
int main() {
	io.read(n), io.read(k), io.read(d);
	n = max(n, -n);
	if(n / d > k) io.write(n - d * k);
	else {
		k -= n / d, n -= n / d * d;
		if(k % 2) io.write(min(n + d, - n + d));
		else io.write(n);
	}
}

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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    int N; // 行
    int M; // 列
    int K; // 黒の個数
    cin >> N >> M >> K;

    // 選択する行は0～N行なので、0オリジンで(i<=N)終端でなければならない。(i<N)ではだめ
    // 列についても上記と同じ事が言える。
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= M; j++) {
            int ans = (M * i) + (N * j) - 2 * (i * j);
            if ( ans == K ) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

int main(){
  string a, b, ab;
  istringstream ss;
  int a_b;
  bool flag = false;

  cin >> a >> b;

  ab = a + b;

  ss = istringstream(ab);
  ss >> a_b;

  for(int i = 1; i < a_b; i++){
    if(a_b == i*i){
      flag = true;
      break;
    }
    if(a_b < i*i) break;
  }

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

	return 0;
}


Measured memory_bytes: 256
a , b , c = map(int, input().split())
count = 0
if a == 1 and b == 1 and c == 1:
  pass
elif a == b and a == c:
  count = -1
else:
  while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
    a_copy = a
    b_copy = b
    c_copy = c
    a = int(b_copy / 2 + c_copy / 2)
    b = int(a_copy / 2 + c_copy / 2)
    c = int(b_copy / 2 + a_copy / 2)
    count += 1
  
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<string>
typedef long long ll;
const int mod = 1e9 + 7;
using namespace std;

void solve() {
	int n,k, sum = 0; 
	cin >> n >> k;
	int arr[n];
	for(int i = 0; i < n; ++i) cin >> arr[i];
	sort(arr, arr + n);
	for(int i = 0; i < k; ++i) sum += arr[i];
	cout << sum << endl;
}

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.precision(20);
	int t;
		solve();
	return 0;
}
 















Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;

int main() {
  ll N, a[100010] = {0}, ans = 0;
  cin >> N;

  ll tmp;
  for(ll i = 0; i < N; i++) {
    cin >> tmp;
    a[tmp]++;
  }
  for(ll i = 1; i < 100001; i++) {
    ans = max(ans, a[i-1] + a[i] + a[i+1]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
// 5/2 リアルタイム参加

#include <iostream>
#include <vector>
#include <math.h>
using namespace std;



int main() {
    long long A, B, N;
    cin >> A >> B >> N;

    int ans = 0;

    // 最大値を取りうるのは、
    // x = Nの時、または、
    // x + 1 % B == 0を満たす最大のxの時。
    // 後者は（N / B） * B - 1で求める。

    // while (true) {
    //     ans = max(ans, )

    // }

    int ans1 = floor(A * N / B) - A * floor(N / B);

    N = (N / B) * B - 1;
    int ans2 = floor(A * N / B) - A * floor(N / B);

    ans = max(ans1, ans2);

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


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int m,d;
int ans;
int main(){
    cin>>m>>d;
    if(m<4){cout<<0;return 0;}
	for(int i=1;i<=m;i++)	
	for(int j=22;j<=d;j++)
	{
	    int a=j/10,b=j%10;
		if(a>=2&&b>=2&&a*b==i)ans++; 
	}
	cout<<ans;
}

Measured memory_bytes: 256
#ifdef LOCAL
#include "libs/debug/print_list.hpp"
#define debug(x) (cout << # x ": " << x << endl)
#define dev(v, m, n) for(int i=0;i<n;++i){for(int j=0;j<m;++j){cout<<"|"<<v[j][i];}cout<<"|"<<endl;}
#else
#define debug(x) ;
#define dev(v, m, n) ;
#endif

// :----------------------------------------

#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;
using pi = pair<int, int>;
using vp = vector<pi>;
using Graph = vector<vector<int>>;

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

#define P (1'000'000'007)

signed main() {
    int m, k;
    cin >> m >> k;

    if (m == 1) {
        if (k == 0) {
            cout << "0 0 1 1";
        } else {
            cout << -1;
        }
    } else if (k < (1 << m)) {
        list<int> li;
        li.push_back(k);
        rep (i, 1 << m) {
            if (i == k) continue;
            li.push_back(i);
            li.push_front(i);
        }
        li.push_back(k);

        bool is_initial = true;
        for (auto x: li) {
            if (!is_initial) {
                cout << " ";
            } else {
                is_initial = false;
            }
            cout << x;
        }
    } else {
        cout << -1;
    }

    return 0;
}


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

int dicebottom(int top) {
  return 7 - top;
}

int dicedown(int up) {
  return 7 - up;
}

int diceright(int left) {
  return 7 - left;
}


int main() {
  int top, up, left, bottom, down, right;
  int n,sum,hold;
  string order;
  while(cin >> n) {
    if(n == 0) break;
    top = 1;
    up = 5;
    left = 4;
    bottom = 6;
    down = 2;
    right = 3;
    //dice(top,up,left,bottom,down,right);
    sum = 1;

    for(int i=0;i<n;i++) {
      cin >> order;
      if(order == "North") {
	hold = top;
	top = down;
	up = hold;
      }
      else if(order == "East") {
	top = left;
	left = bottom;
      }
      else if(order == "West") {
	hold = top;
	top = right;
	left = hold;
      }
      else if(order == "South") {
	top = up;
	up = bottom;
      }
      else if(order == "Right") {
	up = left;
	left = down;
      }
      else if(order == "Left") {
	hold = up;
	up = right;
	left = hold;
      }
      bottom = dicebottom(top);
      down = dicedown(up);
      right = diceright(left);
      //cout << top << " " << up << " " << left << " " << bottom << " " << down << " " << right << endl;
      sum += top;
    }
    cout << sum << endl;
  }
}

Measured memory_bytes: 0
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,k = map(int, input().split())
p = list(map(int, input().split()))

s = sum(p[:k])
best = (s, 0)
for i in range(1,n-k+1):
    s = s - p[i-1] + p[i+k-1]
    if s>best[0]:
        best = (s, i)
        
ans = sum((p[i]+1)/2 for i in range(best[1], best[1]+k))
print(ans)

Measured memory_bytes: 98816
x,n = map(int,input().split())
p = list(map(int,input().split()))

p1 = [abs(i-x) for i in p]

p = set(p)
p1.sort()
if len(p1) ==0:
    print(x)
else:
    if p1[0] != 0:
        print(x)
    else:
        cnt = 1
        while(cnt < len(p1)):
            #print("------")
            #print(cnt)
            #print(p1[cnt])
            if p1[cnt] != int((cnt+1)/2):
                break
            else:
                cnt +=1
        #import pdb;pdb.set_trace()
        if x-int((cnt+1)/2) in p:
            print(x+int((cnt+1)/2))
        else:
            print(x-int((cnt+1)/2))

Measured memory_bytes: 9220
# 2020/04/24
# AtCoder Grand Contest 003 - A

# Input
s = input()
d = dict()

d['N'] = 0
d['W'] = 0
d['S'] = 0
d['E'] = 0

for i in range(len(s)):
    d[s[i]] = d[s[i]] + 1

nsflg = False
if (d['N'] == 0 and d['S'] == 0) or (d['N'] > 0 and d['S'] > 0):
    nsflg = True

weflg = False
if (d['W'] == 0 and d['E'] == 0) or (d['W'] > 0 and d['E'] > 0):
    weflg = True

if nsflg and weflg:
    ans = 'Yes'
else:
    ans = 'No'

# Output
print(ans)


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

template<typename M>
struct segment_tree{
	typedef function<M(M, M)> F;
	int size;//2冪
	vector<M> val;//1-indexed
	F f;//結合関数
	M e;//単位元

	segment_tree(int N, vector<M> &data, F f, M e) : f(f), e(e){
		size = 1;
		while(size < N) size *= 2;
		val.assign(2 * size, e);
		for(int i = 0; i < N; i++) val[size + i] = data[i];
		for(int i = N; i < size; i++) val[size + i] = e;
		for(int i = size - 1; i > 0; i--) val[i] = f(val[2 * i], val[2 * i + 1]);
	}

	//k番目の要素をxに変更する
	void update(int k, M x){
		k += size;
		val[k] = x;
		while(k /= 2) val[k] = f(val[2 * k], val[2 * k + 1]);
	}

	//[l, r)の演算の結果を返す
	M query(int l, int r){
		M L = e, R = e;
		for(l += size, r += size; l < r; l /= 2, r /= 2){
			if(l & 1) L = f(L, val[l++]);
			if(r & 1) R = f(val[--r], R);
		}
		return f(L, R);
	}
};


//(int, my_max, -inf)
#define inf (int)(1e9)

int my_max(int x, int y){
	return max(x, y);
}

int MOD(int a){
	return (a %= p) >= 0 ? a : a + p;
}

int solve(int N, vector<int> &rs, int &k){
//	printf("solve(%lld)\n", k);
	int ans = 1;
	int r = rs[k];
	k++;
	while(k < r){
//		printf("(r, k) = (%lld, %lld)\n", r, k);
		ans = MOD(ans * solve(N, rs, k));
	}
//	printf("(ans + 1, k) = (%lld, %lld)\n", ans + 1, k);
	return MOD(ans + 1);
}

signed main(){
	int N, i;
	scanf("%lld", &N);
	vector<pair<int, int>> XD(N);
	for(i = 0; i < N; i++){
		scanf("%lld%lld", &XD[i].first, &XD[i].second);
	}
	sort(XD.begin(), XD.end());
	vector<int> X(N), D(N);
	for(i = 0; i < N; i++){
		X[i] = XD[i].first;
		D[i] = XD[i].second;
	}
	vector<int> data(N + 1, -1);
	segment_tree<int> t(N + 1, data, my_max, -inf);
	for(i = N - 1; i >= 0; i--){
//		printf("i = %lld\n", i);
//		printf("(X, D) = (%lld, %lld)\n", X[i], D[i]);
		int r = lower_bound(X.begin(), X.end(), X[i] + D[i]) - X.begin();
//		printf("r = %lld\n", r);
		if(r == i + 1){
			t.update(i, r);
		}
		else{
			t.update(i, max(r, t.query(i + 1, r)));
		}
	}
	vector<int> rs(N);
	for(i = 0; i < N; i++){
		rs[i] = t.query(i, i + 1);
	}
/*	printf("rs:");
	for(i = 0; i < N; i++){
		printf("%lld ", rs[i]);
	}
	printf("\n");
*/	int k = 0, ans = 1;
	while(k < N){
		ans = MOD(ans * solve(N, rs, k));
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 26240
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
long i,n,a[100005],f[100005];
int main() {
    cin >> n ;
    for (long i =1; i<=n; i++) cin >> a[i];
    f[1] = 0;
    f[2] = abs(a[2] - a[1]);
    for (long i=3; i <=n; i++) {
        f[i] = min(f[i-1] + abs(a[i] - a[i-1]),f[i-2] + abs(a[i] - a[i-2]));
    }
    cout << f[n];
    return 0;
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]) throws Exception{
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(stdR.readLine());
        int[] A = new int[N + 1];
        int[] B = new int[N];
        String[] stra = stdR.readLine().split(" ");
        String[] strb = stdR.readLine().split(" ");
        for(int i = 0 ; i <= N ; i++) {
            A[i] = Integer.parseInt(stra[i]);
            if(i != N)B[i] = Integer.parseInt(strb[i]);
        }
        long counter = 0;
        for(int i = 0 ; i < N ; i++) {
            int stnum = Math.min(A[i], B[i]);
            A[i] -= stnum;
            B[i] -= stnum;
            counter += stnum;
            stnum = Math.min(A[i + 1], B[i]);
            A[i + 1] -= stnum;
            B[i] -= stnum;
            counter += stnum;
        }
        System.out.println(counter);
    }
}


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

pub 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")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::{max, min};

fn main() {
    let n: usize= read();
    let a: Vec<i64> = read_n(n);
    let mut ans = "APPROVED".to_string();

    for i in 0..a.len() {
        let ai = a[i];
        if ai % 2 == 0 {
            if ai % 3 != 0 && ai % 5 != 0 {
                ans = "DENIED".to_string();
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
fn run() {
    proconio::input! {
        n: u64,
    }
    let mut ans = 0;
    let mut i = 1;
    while i * i <= n {
        let p = n / i;
        ans += i * p * (p + 1) * 2;
        i += 1;
    }
    i = n / i;
    let mut prev = n / (i + 1);
    while i > 0 {
        let x = n / i;
        let y = prev;
        prev = x;
        ans += i * (i + 1) * (x * (x + 1) - y * (y + 1));
        i -= 1;
    }
    ans >>= 2;
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 2148
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] x = new int[n];
    int[] a = new int[n];
    int[] k = new int[n + 1];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
      k[a[i]]++;
      if(a[i] >= k[a[i]]) x[a[i] - k[a[i]]]++;
    }
    int ans = 0;
    for(int i = 0; i < n; i++) {
      if(x[i] == 0) ans++;
    }
    for(int i = 0; i < m; i++) {
      int X = sc.nextInt() - 1;
      int Y = sc.nextInt();
      int t = a[X];
      a[X] = Y;
      if(t >= k[t]) {
        x[t - k[t]]--;
        if(x[t - k[t]] == 0) ans++;
      }
      k[t]--;
      if((Y - k[Y]) >= 1) {
        x[Y - k[Y] - 1]++;
        if(x[Y - k[Y] - 1] == 1) ans--;
      }
      k[Y]++;
      System.out.println(ans);
    }
  }
}

Measured memory_bytes: 168808
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W; cin >> H >> W;
  for(int i=0; i<W+2; i++){
   cout <<"#";
  }
  cout << endl;
 for(int i=0; i<H; i++){
   string name;
   cin >> name;
   cout <<"#"<< name <<"#" <<endl;
 }
   for(int i=0; i<W+2; i++){
   cout <<"#";
  }
 cout<< endl;
} 

Measured memory_bytes: 3608
void main()
{
    long n, m;
    rdVals(n, m);
    Edge[] edge = m.rdCol!Edge;
    foreach (ref e; edge) --e.from, --e.to;

    long[] dist = new long[n];
    foreach (i; 1 .. n) dist[i] = -inf;

    void Bellman_Ford()
    {
        foreach (i; 0 .. n)
        {
            foreach (e; edge)
            {
                if (dist[e.from] == -inf) continue;
                dist[e.to] = max(dist[e.to], dist[e.from]+e.cost);
            }
        }
    }

    Bellman_Ford();
    long result = dist[$-1];
    Bellman_Ford();

    if (result == dist[$-1]) result.writeln;
    else "inf".writeln;
}

struct Edge
{
    long from, to, cost;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

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

using namespace std;

int main(void){
  int n;
  cin >> n;
  
  vector<long long> a = vector<long long>(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }

  long long temp[n];
  for(int i=0; i<n; i++){
    a[i] = a[i] - i - 1;
  }
  sort(a.begin(), a.end());

  long long median1, median2;
  if(n%2 == 0){
    median1 = a[n/2-1];    
    median2 = a[n/2];
    //cout << n/2-1 << " " << n/2 << endl;
    median1 = min(median1, median2);
  }
  else{
    median1 = a[n/2];
    //cout << n/2 << endl;    
  }
  long long sum = 0LL;
  for(int i=0; i<n; i++){
    sum = sum + abs(a[i] - median1);
  }
  cout << sum << endl;
  
  return 0;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

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

    int ans = 1e9+7;
    for(int i = 0; i < N; i++){
        int tmp = 0;
        int tmp_val = A[i];
        while((tmp_val % 2 )==0){
            tmp++;
            tmp_val = tmp_val/2;
        }
        chmin(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
from fractions import gcd
from functools import reduce
def gcds(*numbers):
    return reduce(gcd, numbers)

def resolve():
    (N, X) = list(map(int, input().split(" ")))
    Xs = list(map(int, input().split(" ")))
    Xs.append(X)
    Xs.sort()
    diffs = [Xs[i+1]-Xs[i] for i in range(len(Xs)-1)]
    print(gcds(*diffs))


if '__main__' == __name__:
    resolve()

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

int main()
{
    double a;
    double b;
    int c;
    
    cin >> a;
    
    c = (int)(a/3600);
    cout << c << ":";
    b = ( (a/3600) - c ) * 3600;
    cout << (int)(b/60) << ":";
    cout << ((b/60) - (int)(b/60) ) *60 << endl;
}



Measured memory_bytes: 3288
<?php

 $n = trim(fgets(STDIN));
 
 $cnt = [];
 
 for($i=1;$i<=$n;$i++){
   if($i%10==0){
     continue;
   }
   $s = substr($i, 0, 1);
   $e = substr($i, -1);
   if(!isset($cnt[$s.$e])){
      $cnt[$s.$e]=0;
   }
   $cnt[$s.$e]++;
 }
 
 $ans=0;
 foreach($cnt as $key => $val){
//   echo $key." ".$val.PHP_EOL;
   if(isset($cnt[strrev($key)])){
     $ans+=$val*$cnt[strrev($key)];
   }
 }
 
 echo $ans;
 
 

Measured memory_bytes: 4604
#include <stdio.h>

int main(void)
{
    int X = 0;
    int Y = 0;
    int i = 0;
    int j = 0;

    scanf("%d %d", &X, &Y);

    for (i = 0; i <= X; i++)
    {
        if ((i * 2) + ((X - i) * 4) == Y)
        {
            printf("Yes");
            return 0;
        }
    }
    printf("No");
    return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define BITSEARCH(i,n) for(int i=0;i<(1<<(n));++i)
#define BITCHK(i,j) (i) & (1<<(j))

/* BITSEARCH 使い方
 
BITSEARCH(i,n){
  vector<int> h;
  REP(j,n){
    if (BITCHK(i,j)){
      h.push_back(j+1);
    }
  }
}

*/

using namespace std;

// 最大公約数
int64_t gcd(int64_t a, int64_t b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
int64_t lcm(int64_t a, int64_t b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

typedef pair<int,int> P;
int main(){
  int64_t h,w;
  cin >> h >> w;
  vector<string> vec(h);
  REP(i,h){
    cin >> vec.at(i);
  }
  queue<P> q;
  int reached[100][100];
  REP(i,100){
    REP(j,100){
      reached[i][j] = INT_MAX;
    }
  }
  q.push(P(0,0));
  reached[0][0] = 1;
  int t=0;
  while (q.size()){
    int x,y;
    P p = q.front();q.pop();
    y = p.first;
    x = p.second;
    if (y < 0 || y >= h || x < 0 || x >= w || vec.at(y).at(x) == '#'){
      continue;
    }
    if (y == h-1 && x == w-1){
      t = reached[y][x];
      break;
    }
    if (reached[y+1][x] == INT_MAX){
      reached[y+1][x] = reached[y][x] + 1;
      q.push(P(y+1,x));
    }
    if (reached[y-1][x] == INT_MAX){
      reached[y-1][x] = reached[y][x] + 1;
      q.push(P(y-1,x));
    }
    if (reached[y][x+1] == INT_MAX){
      reached[y][x+1] = reached[y][x] + 1;
      q.push(P(y,x+1));
    }
    if (reached[y][x-1] == INT_MAX){
      reached[y][x-1] = reached[y][x] + 1;
      q.push(P(y,x-1));
    }
  }
  int wall = 0;
  REP(i,h){
    REP(j,w){
      if (vec.at(i).at(j) ==  '#'){
        wall++;
      }
    }
  }
  if (reached[h-1][w-1] != INT_MAX){
    int ans =  h * w - t - wall;
    cout << ans << endl;
  }else{
    cout << -1 << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    int n,t;cin>>n>>t;
    vector<int>a(n);
    vector<int>p(n);
    rep(i,n)cin>>a[i];
    int mi=a[0],ma1=0;
    REP(i,1,n){
        mi=min(mi,a[i]);
        p[i]=a[i]-mi;
        ma1=max(ma1,p[i]);
    }
    ll cnt=0;
    rep(i,n)if(p[i]==ma1)cnt++;
    cout<<cnt<<endl;
}

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


int main() {
	string S;
	int w;
	cin >> S >> w;
	
	for (int s = 0; s < S.size(); s+= w) {
   cout << S[s];
 }
	cout << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
long n,i,a,b,c,d;
string s;
int main()
{
	cin >> n;
  	for ( i = 0 ; i < n ; i++ ) 
    {
      	cin >> s;
      	if ( s == "AC" ) a++;
      	else if ( s == "WA" ) b++;
      	else if ( s == "TLE" ) c++;
      	else d++;
    }
  	cout << "AC x " << a << endl << "WA x " << b << endl << "TLE x " << c << endl << "RE x " << d;
}

Measured memory_bytes: 3140
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int m = sc.nextInt();
            int k = sc.nextInt(); 
            int r = sc.nextInt(); 
            if(m==-1 && k==-1 && r==-1) break;
             if(m==-1||k==-1){
                System.out.println("F");
             }else if(m+k>79){
                System.out.println("A");
             }else if(m+k>64){
                 System.out.println("B");
             }else if(m+k>49){
                 System.out.println("C");
             }else if(m+k>29){
                 if(r>49){System.out.println("C");}
                 else{System.out.println("D");}
             }else{
                 System.out.println("F");
             }
    
        }
    }
}


Measured memory_bytes: 26348
def f(A,M):
    N=len(A)
    c=0
    for i in range(N):
        if A[i]>=1/(4*M)*(sum(A)):
            c+=1
    if c>=M:
        return "Yes"
    else:
        return "No"
N,M=map(int,input().split())
A=list(map(int,input().split()))
print(f(A,M))
            

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#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, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    cin >> n;
    vector<ll> v(n);
    for(auto& i : v) cin >> i;

    v.push_back(-1e13);
    if(n%2 == 0) v.push_back(-1e13);
    int m = v.size();
    vector<vector<vector<ll>>> dp(m, vector<vector<ll>>(2, vector<ll>(3, -1e13)));

    REP(i, m){
        if(i == 0){
            dp[0][0][0] = 0;
            dp[0][1][0] = v[0];
            continue;
        }

        dp[i][0][0] = dp[i-1][1][0];
        dp[i][1][0] = dp[i-1][0][0] + v[i];

        dp[i][0][1] = max(dp[i-1][0][0], dp[i-1][1][1]);
        dp[i][1][1] = dp[i-1][0][1] + v[i];

        dp[i][0][2] = max(dp[i-1][0][1], dp[i-1][1][2]);
        dp[i][1][2] = dp[i-1][0][2] + v[i];
    }

    ll ans = -INF;
    chmax(ans, dp[m-1][0][1]);
    chmax(ans, dp[m-1][1][1]);
    chmax(ans, dp[m-1][0][2]);
    chmax(ans, dp[m-1][1][2]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 34536
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

ll S;

int main() {
	cin >> S;
	cout << 0 << sp << 0 << sp << 1000000000 << sp << ((S - 1) / 1000000000 + 1) * 1000000000 - S << sp << 1 << sp << (S - 1) / 1000000000 + 1 << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(n):
    ans += b[a[i] - 1]
    if i > 0 and a[i-1] + 1 == a[i]:
        ans += c[a[i-1] - 1]
print(ans)

Measured memory_bytes: 3064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Echizen
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int arr[] = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
                sum += arr[i];
            }
            // sort the arrays;
            Arrays.sort(arr);
            if (sum % 10 != 0) {
                out.println(sum);
            } else {
                for (int i = 0; i < arr.length; i++) {
//                sum = sum - arr[i];
                    if (arr[i] % 10 != 0) {
                        sum -= arr[i];
                        out.println(sum);
                        break;
                    }
                }
            }
            if (sum % 10 == 0) {
                out.println(0);
            }
        }

    }
}



Measured memory_bytes: 22740
#include<iostream>
#include<cmath>
#include<vector>
#include<queue>
#include<algorithm>
#include <stack>
#include<set>
#include<cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdio>
#include <string.h>
#include<iterator>
#include <map>
using namespace std;
//bool cmp(long long a, long long b){
//    return a > b;
//}
//int gcd(int a, int b) {
//    int t;
//    while (b != 0) {
//        t = b;
//        b = a % b;
//        a = t;
//    }
//    return a;
//}
//long long levels[100500];
//void dfs(long long current, long long prev, set<long long>* sets){
//    for (auto it:sets[current]){
//        if (prev != it){
//            levels[it] = levels[current] + 1;
//            dfs(it, current, sets);
//        }
//    }
//}
//long long st[10], fin[10];
//int matr[25][25], saved_matr[5][5], ish_matr[5][5];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    long long t, ch, i, curr, p = 1, x, y, weight, j, k = 0, n, m = 1, ch1, ans = 0;
    long long a, b;
    int fl, fl1, fl2, fl3;
    string s;
//    cin >> t;
    long long f, size_f, size_s, weight1, weight2;
    long long sum, k_min, k_max, s1;
    long long da, db;
//    for (auto test_case = 0; test_case < t; test_case++) {
//    }
    cin >> n;
    ans = 0;
    k = 0;
    for (i = 0; i < n; i++){
    	cin >> ch >> ch1;
    	if (ch == ch1)
    		ans++;
    	else
    		ans = 0;
    	k = max(k, ans);
	}
	if (k >= 3)
		cout << "Yes";
	else
		cout << "No";
    return 0;
}

Measured memory_bytes: 3608
n = int(input())

h = list(map(int, input().split()))

h[0] -= 1

if max(h) - min(h) == 1:
    print('Yes')
    exit()

for i in range(1, len(h)):
    if h[i - 1] - h[i] > 1:
        print('No')
        exit()
    if h[i - 1] < h[i]:
        h[i] -= 1

for i in range(1, len(h)):
    if h[i] < h[i - 1]:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 14396
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i+100*j+50*k==x:
        ans += 1
print(ans)

Measured memory_bytes: 42132
#include<iostream>

using namespace std;

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

	if (r < 1200) {
		cout << "ABC" << endl;
	}
	else if (r < 2800) {
		cout << "ARC" << endl;
	}
	else {
		cout << "AGC" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Text;


namespace AtCoderDotNetCore
{
	class Program
	{
		static void Main(string[] args)
		{
			Question.Exec();
		}
	}

	public static class Question
	{
		public static void Exec()
		{
			int n = int.Parse(Console.ReadLine());
			var d = new List<int>();
			for (int i = 0; i < n; ++i) {
				int dd = int.Parse(Console.ReadLine());
				if (d.Contains(dd) == false){
					d.Add(dd);
				}
			}

			Console.WriteLine($"{d.Count()}");
		}
	}
}

Measured memory_bytes: 28088
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
#define sys system("PAUSE")
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int cnt=1;
	if (x == 0)return 1;
	cnt = kai(x - 1);
	return x * cnt;
}
int prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
void prime_factor(int n){
	int cnt = 1;
	map<int, int>res;
	int m = n;
	for (int i = 2; i<= n; i++) {
		if(prime(i)){
			while (m%i == 0) {
				++res[i];
				m /= i;
			}
		}
	}
	cout << n <<":"<< endl;
	for (int i = 2; i<= n; i++) {
		if (res[i]) {
			cout << i << " " << res[i] << endl;
		}
	}
	cout << endl;
}
/*Library End!*/
int n, x[200005], y[200005], ave;
vector<int>v;
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		y[i] = x[i];
	}
	sort(x, x + n);
	for (int i = 0; i < n; i++) {
		if (x[n / 2 - 1] >= y[i])cout << x[n / 2] << endl;
		else cout << x[n / 2 - 1] << endl;
	}
	sys;
	return 0;
}



Measured memory_bytes: 5504
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using ll = long long;
using namespace std;

int main() {
	int H, W, h, w;
	cin >> H >> W;
	cin >> h >> w;
	cout << H * W - h * W - w * H + h * w << endl;
}


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

using namespace std;
typedef pair<int, int> P;
// input


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
    int N;
    cin >> N;
    string judge = "";
    vector<string> judges = {"AC", "WA", "TLE", "RE"};
    vector<int> result = {0, 0, 0, 0};
    rep(i,N) {
        cin >> judge;
        rep(j,4) {
            if(judge == judges.at(j))result.at(j)++;
        }

    }
    rep(i,4) {
            cout << judges.at(i) + " x " + to_string(result.at(i)) << endl;
        }
}

Measured memory_bytes: 3724
N = int(input())
a = list(map(int,input().split()))
ans = [None] * (N-1)
ans[0] = sum(a[1:]) - a[0]
mina = abs(ans[0])

for i in range(1,N-1):
  ans[i] = ans[i-1] - 2*a[i]
  mina = min(mina, abs(ans[i]))
print(mina)

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

void trace(int A[], int N){
  for(int i = 0; i<N; i++){
    if(i>0) cout << " ";
    cout << A[i];
  }
  cout << endl;
}

void insertionSort(int A[], int N){
  int j, v;
  for(int i = 1; i<N; i++){
    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v){
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;
    trace(A , N);
  }
}

int main(){
  int N, i, j;
  int A[100];
  cin >> N;
  for(i = 0; i<N; i++) cin >> A[i];
  
  trace(A, N);
  insertionSort(A, N);
}


Measured memory_bytes: 3076