akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

bool is_prime(int n){
	for(int i = 2; i * i <= n; ++i){
		if(n % i == 0)return false;
	}
	return true;
}

int main(){
  int x;
  cin >> x;
  while(true){
  	if(is_prime(x)){
  		cout << x << endl;
  		return 0;
  	}
  	++x;
  }
  return 0;
}


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

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

    string last = "";
    string slast = "";
    ll count = 0;
    ll idx = 0;
    while(idx<s.size()){
        if(s.substr(idx, 1)!=last){
            if(idx+2==s.size() && s[idx]==s[idx+1]){
                if(slast!=last+s.substr(idx, 1)){
                    ++count;
                }
                break;
            }
            else{
                slast = last;
                last = s.substr(idx, 1);
                ++count;
                ++idx;
            }
        }
        else{
            slast = last;
            last = s.substr(idx, 2);
            ++count;
            idx += 2;
        }
    }
    cout << count << endl;
}


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

bool is_prime(int n)
{
    if (n == 0 || n == 1)
        return (false);
    if (n % 2 == 0 && n != 2)
        return (false);
    for (int i = 3; i * i < n + 1; i += 2)
    {
        if (n % i == 0)
        {
            return (false);
        }
    }
    return (true);
}

int main()
{
    int q;
    cin >> q;
    vector<int> cum(1e5 + 1, 0);
    for (int i = 0; i < 1e5 + 1; i++)
    {
        if (is_prime(i) && is_prime((i + 1) / 2) && i % 2 == 1)
        {
            cum[i + 1] = cum[i] + 1;
        }
        else
        {
            cum[i + 1] = cum[i];
        }
    }

    for (int i = 0; i < q; i++)
    {
        int l, r;
        cin >> l >> r;
        cout << cum[r + 1] - cum[l] << '\n';
    }
}


Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=200005 ;
int main()
{
   fast ;
   ll tests=1 ;
   ///cin>>tests ;
   for(ll testcase=1;testcase<=tests;testcase++)
   {
      ///cout<<"Case #"<<testcase<<": " ;
      ///Read,Think ans Test Properly,then code
      ///Try to avoid using print statements debug on your own
      ll x ;
      cin>>x ;
      ll ans=0 ;
      ans+=(x/500)*1000+((x%500)/5)*5 ;

      cout<<ans ;

   }
}
/// ans ->for answer
/// cur ->for local answer
/// level ->for depth in tree
/// v -> adjacency matrix
/// r -> array
/// s ->string



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

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b + c || b == a + c || c == a + b)
		cout << "Yes" << endl;
	else
	{
		cout << "No" << endl;
	}

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

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

int main(){
  int n;
  string s;
  cin >> n >> s;
  s += " ";

  string ans = "Yes";

  rep(i, (n+1)/2){
    if(s.at(i) != s.at(i+(n+1)/2)) ans = "No";
  }

  cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;
//階乗できるよ
ll kaizyo(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    sum = sum % ATCODER_AMARI;
  }
  return sum;
}

int main() {
  ll n; cin >> n;
  vector<ll> h(n);
  rep(i,n) cin >> h.at(i);
  ll max_h = 0;
  

  rep(i,n) {
    
    if(h.at(i) - max_h < 0) {
      cout << "No" << endl;
      return 0;
    }
    
    h.at(i)--;
    max_h = max(max_h,h.at(i));
    
  }

  cout << "Yes" << endl;
}



Measured memory_bytes: 1024
def solve(string):
    n, *s = string.split()
    num = [len([True for _s in s if _s[0] == _i]) for _i in "M A R C H".split()]
    ans = 0
    for i in range(5):
        for j in range(i + 1, 5):
            for k in range(j + 1, 5):
                ans += num[i] * num[j] * num[k]
    return str(ans)


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n)+'\n'.join([input() for _ in range(n)])))


Measured memory_bytes: 11948
// 154 B

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <iomanip>
#include <climits>
#include <string>

using namespace std;

int main(){
    int a, b, k;
    cin >> k;
    cin >> a >> b;
    for(int i=a; i<=b; i++){
        if(i%k == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
int n,m,sum;
int a[100005],b[100005];

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+m+1);
    for(int i=1;i<m;i++)
        b[i]=a[i+1]-a[i];
    sort(b+1,b+m);
    if(m<=n)
        cout<<0;
    else
    {
        int i=1;
        while(m!=n)
        {
            sum+=b[i];
            m--;
            i++;
        }
        cout<<sum;
    }
    return 0;
}


Measured memory_bytes: 1024
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
ans=0
for i in range(60):
  x=1<<i
  z=o=0
  for j in range(n):
    if a[j]&x:o+=1
    else:z+=1
  ans=(ans+((x%mod)*o*z)%mod)%mod
print(ans)

Measured memory_bytes: 122936
#!/usr/bin/env python3
sx, sy, tx, ty = map(int, input().split())
x = tx - sx
y = ty - sy
h = abs(sx - tx)
v = abs(sy - ty)
ans = [[1, 0]] * h + [[0, 1]] * v + [[-1, 0]] * h + [[0, -1]] * v
ans += [[0, -1]] + [[1, 0]] * -~h + [[0, 1]] * -~v + [[-1, 0]]
ans += [[0, 1]] + [[-1, 0]] * -~h + [[0, -1]] * -~v + [[1, 0]]
for i in ans:
    if i == [1, 0]:
        print("R", end="")
    elif i == [-1, 0]:
        print("L", end="")
    elif i == [0, 1]:
        print("U", end="")
    else:
        print("D", end="")
print("")


Measured memory_bytes: 9332
#include <iostream>
using namespace std;
int main() {
    int num, num1, numb2, list1;
    cin >> num;
    bool matrix[num][num] = {};
    for(int i = 0; i < num; i++) {
        cin >> num1 >> numb2;
        for(int i = 0 ; i < numb2; i++) {
            cin >> list1;
            matrix[num1 - 1][list1 - 1] = 1;
        }
    }
    for(int i = 0 ; i < num; i++) {
        for (int p = 0; p < num; p++) {
            if (p != num -1) {
                cout << matrix[i][p] << " ";
            } else cout<<matrix[i][p] << endl;
        }
    }
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

const ll INF = 1e15;
int N, W;
int v[111], w[111];
ll dp[111][111111];

void print() {
   for (int i = 0; i <= N; i++) { // i個選ぶ
      for (int j = 0; j <= W; j++) { // 重さjまで
         printf(" %3lld", dp[i][j]);
      }
      puts("");
   }
}

int main() {
   // fill(dp[0], dp[111], -1);
   cin >> N >> W;
   rep (i, N) {
      cin >> v[i] >> w[i];
   }

   for (int j = 0; j <= W; j++) {
      dp[0][0] = 0;
   }
   for (int i = 0; i < N; i++) { // i個選ぶ
      for (int j = 0; j <= W; j++) { // 重さjの時
         // if (j >= w[i]) { // 重さjで荷物iが置ける???
         //    dp[i+1][j] = max(dp[i][j-w[i]] + v[i], dp[i][j]);
         // } else {
         //    dp[i+1][j] = dp[i][j];
         // }

         // 選ぶ
         dp[i+1][j+w[i]] = max(dp[i][j+w[i]], dp[i][j] + v[i]);
         // 選ばない
         dp[i+1][j] = max(dp[i][j], dp[i+1][j]);

         // dp[i+1][j+w[i]] = max(dp[i][j+w[i]], dp[i+1][j+w[i]]);
      }
   }

   cout << dp[N][W] << endl;

   // print();

   return 0;
}


Measured memory_bytes: 12040
#include<iostream>
#define ll long long
using namespace std;
ll a,b,c,d;
int main(){
    cin>>a>>b>>c>>d;
    ll t1=a*c,t2=a*d,t3=b*c,t4=b*d;
    cout<<max(max(t1,t2),max(t3,t4))<<endl;
    return 0;
}


Measured memory_bytes: 3596
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    // 10:33-
    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            String s = sc.next();
            int[][] dp = new int[2][s.length()];
            char c = s.charAt(0);
            dp[0][0] = (c == '1' ? 1 : 0);
            dp[1][0] = (c == '0' ? 1 : 0);

            for (int i = 1; i < s.length(); i++) {
                char x = s.charAt(i);
                dp[0][i] = (x == '1' ? 1 : 0) + dp[1][i - 1];
                dp[1][i] = (x == '0' ? 1 : 0) + dp[0][i - 1];
            }

            out.println(Math.min(dp[0][s.length() - 1], dp[1][s.length() - 1]));
        }
    }
}


Measured memory_bytes: 26756
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


a, b, m = map(int, input().split())
aa = readints()
bb = readints()
#print(a, b, m)
# print(aa)
# print(bb)
ans = min(aa)+min(bb)
for i in range(m):
    x, y, c = map(int, input().split())
    #print(x, y, c)
    ans = min(ans, aa[x-1]+bb[y-1]-c)
print(ans)


Measured memory_bytes: 19360
#include<cstdio>
#include<map>
#include<cstring>
#define mp make_pair
#define Maxn 200010
using namespace std;
typedef pair<int,int> pii;
int N,K,L;
map<pii,int> sz;
int par[Maxn*2];//rank[Maxn*2];
int num[Maxn];
void init(int n)
{
	for(int i=1;i<=2*n;i++)
	{
		par[i] = i;
	//	rank[i] = 0;
	}
	memset(num,0,sizeof num);
}

int find(int x)
{
	if(par[x] == x)
	return x;
	return par[x] = find(par[x]);
}

void unite(int x,int y)
{
	x = find(x);
	y = find(y);
	if(x == y)
	return ;
//	if(rank[x] < rank[y])
	par[x] = y;
/*	else 
	{
		par[y] = x;
		if(rank[x] == rank[y])
		rank[x]++;
	}*/
}

bool same(int x,int y)
{
	return find(x) == find(y);
}

int main()
{
	while(~scanf("%d%d%d",&N,&K,&L))
	{
		init(N);
		int a,b;
		for(int i=1;i<=K;i++)
		{
			scanf("%d%d",&a,&b);
			unite(a,b);
		}
		for(int i=1;i<=L;i++)
		{
			scanf("%d%d",&a,&b);
		//	if(same(a,b))
			{
				unite(a+N,b+N);
			}
		}
		for(int i=1;i<=N;i++)
		sz[mp(find(i),find(i+N))]++;
	/*	for(int i=N+1;i<=2*N;i++)
		{
			find(i);
			num[par[i]-N]++;
		}
		for(int i=N+1;i<=2*N;i++)
		{
			if(par[i]!=i)
			num[i-N] = num[par[i]-N];
		}*/
		for(int i=1;i<=N;i++)
		{
			printf("%d",sz[mp(find(i),find(i+N))]);
			if(i!=N)
			printf(" ");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 14336
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    int[] val = new int[N];
    for(int i = 0; i < N; i++){
      val[i] = Integer.parseInt(sc.next());
    }
    Arrays.sort(val);
    System.out.println(val[N-1]-val[0]);
  }
}

Measured memory_bytes: 24148
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

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

	map<int, int> mp;
	int N, K;
	cin >> N >> K;
	REP(i, N){
		int a;
		cin >> a;
		mp[a]++;
	}
	vector<int> v;
	for(auto m : mp){
		v.push_back(m.second);
	}
	sort(all(v));
	int res = 0;
	REP(i, (int)v.size()-K){
		res += v[i];
	}
	cout << res << endl;
}


Measured memory_bytes: 10744
#include<stdio.h>
int main(void){
int a;
  scanf("%d",&a);
  int b=a%100;
  int c=a%10;
  if(a/100==7||b/10==7||c==7){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>
#include <string.h>

int detect(char x[9], int i){
    int y=0;
    if(i==strlen(x)){return y;}
    if (x[i]=='A' || x[i]=='T' || x[i]=='G' || x[i]=='C'){
        y++;
        y+=detect(x,i+1);
    }
    return y;
}

int main(){
    char S[9];
    int i, y, m = 0;
    scanf("%s",S);
    for(i=0;i<strlen(S);i++){
        y = detect(S, i);
        if(m < y){m = y;}
    }
    printf("%d\n",m);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vi v(a),w(b),z(c);
    rep(i,a)cin>>v[i];
    rep(i,b)cin>>w[i];
    rep(i,c)cin>>z[i];
    Rort(v);Rort(w);
    rep(i,x)z.pb(v[i]);
    rep(i,y)z.pb(w[i]);
    Rort(z);
    ll ans=0;
    rep(i,x+y)ans+=z[i];
    fin(ans);
}


Measured memory_bytes: 2680
from itertools import accumulate
N, M = map(int,input().split())
L = []
R = []
for i in range(M):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)

m = max(R)
imo = [0] * (m+2)
for l,r in zip(L,R):
    imo[l] += 1
    imo[r+1] -= 1
imo = list(accumulate(imo))

m = max(imo)
if m < M:
    print(0)
else:
    ans = 0
    for c in range(M,m+1):
        ans += imo.count(c)
    print(ans)

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


int main(){
    ll n ;
    cin >> n ;
    ll a = 0 , b = 0 ;
    vector<ll> a2(10000,0) , b2(10000,0) ;
    for(ll i = 0 ; a <= 1000000000000001 ; i++ ){
        if( i-1 >= 0 ) b += pow(26,i-1) ;
        a += pow(26,i) ;
        if( a > n && b <= n ){
            //cout << n - b << endl ;
          	ll m = ( n - b ) ;
            for(ll j = i ; j >= 1 ;j--){ 
              	ll l = pow(26,j-1) ;
              	//cout << m << ' ' << l << endl ;
                char c = 'a' +  m / l ;
                cout << c ; 
              	m = m % l ;
            }
            return 0 ;
        }
    }
}
    

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

int main() {

	long long A, B, C, K, sum = 0;
	cin >> A >> B >> C >> K;


	for (int i = 0; i < K; i++) {

		if (i == A) {
			for (int j = 0; j < K-i; j++) {
				if (j == B) {
					for (int k = 0; k < K-i-j; k++) {
						sum++;
						if (k == K - i - j -1 ) {
							cout << A-sum << endl;
							return 0;
							}
						}
					}
				if (j == K - i - 1) {
					cout << A << endl;
					return 0;
				}
				}
			}

	}

	cout << K << endl;


}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(string, S);
  set<char> st;
  each(x, S) {
    st.insert(x);
  }
  if (st.count('N') ^ st.count('S')) {
    print("No");
    return;
  }
  if (st.count('W') ^ st.count('E')) {
    print("No");
    return;
  }
  print("Yes");
}


Measured memory_bytes: 256
s = input()
n = len(s)
mod = 10**9 + 7
dp = [[0 for i in range(13)] for i in range(n)]
if s[n-1] == "?":
    for i in range(10):
        dp[n-1][i] = 1
else:
    dp[n-1][int(s[n-1])] = 1
now = 1
for i in reversed(range(n-1)):
    now *= 10
    now %= 13
    if s[i] == "?":
        for j in range(10):
            amari = (j * now) % 13
            for k in range(13):
                dp[i][(k+amari)%13] += dp[i+1][k]
                dp[i][(k+amari)%13] %= mod
    else:
        amari =(int(s[i]) * now) % 13
        for k in range(13):
            dp[i][(k+amari)%13] += dp[i+1][k]
            dp[i][(k+amari)%13] %= mod
print(dp[0][5])

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

#define sc1(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define pr1(a) printf("%d\n",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define loop(i,a,b) for(ll i=a;i<b;i+=1)
#define ll long long int
#define ld long double
#define lvec vector<long long int> v
#define vec vector<int> v
#define ite1 vector<int>:: iterator it1
#define ite2 vector<int>:: iterator it2
#define ite3 vector<int>:: iterator it3
#define mp make_pair
#define pb push_back
#define pf push_front
#define pff pop_front
#define pbb pop_back
#define ft first
#define sd second

int main()
{
    int t=1;

    //cin>>t;           // comment this line when number of testcases = 1

    while(t--)
    {
        int n;
        cin>>n;
        int h[n];
        loop(i,0,n){cin>>h[i];}
        int dp[n];

        dp[0]=0;
        dp[1]=abs(h[1]-h[0]);

        loop(i,2,n)
        {
            dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]) );
        }

        cout<<dp[n-1]<<endl;
    }
}


Measured memory_bytes: 1024
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
a3=list(map(int,input().split()))
n=int(input())
for i in range(n):
    b=int(input())
    for j in range(3):
        if a1[j]==b:
            a1[j]='o'
        if a2[j]==b:
            a2[j]='o'
        if a3[j]==b:
            a3[j]='o'

if a1.count('o')==3 or a2.count('o')==3 or a3.count('o')==3:
    print('Yes')
elif a1[0]==a2[0]==a3[0]=='o':
    print('Yes')
elif a1[1]==a2[1]==a3[1]=='o':
    print('Yes')
elif a1[2]==a2[2]==a3[2]=='o':
    print('Yes')
elif a1[0]==a2[1]==a3[2]=='o':
    print('Yes')
elif a1[2]==a2[1]==a3[0]=='o':
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
/*
 * ITP1_4A.c
 *
 *  Created on: 2016/05/28
 *      Author: TakaakiShogaki
 */
#include<stdio.h>

int main(){
	int a,b;
	double f;

	scanf("%d %d",&a,&b);
	f=(double)a/b;
	printf("%d %d %f\n",a/b,a%b,f);

return 0;
}

Measured memory_bytes: 632
# coding: utf-8
# AGC 013 a 
# Here your code !
n = input()
if n <= 2:
    print 1
    exit()
    
a = map(int, raw_input().split())

c = 1

status = "n"
i = 1
while i < n:
    if status == "n":
        if a[i-1] < a[i]:
            status = "i"
        elif a[i-1] > a[i]:
            status = "d"
        i += 1
        
    elif status == "i":
        if a[i-1] <= a[i]:
            i += 1
        elif a[i-1] > a[i]:
            status = "n"
            c += 1
            i += 1
        
    elif status == "d":
        if a[i-1] < a[i]:
            status = "n"
            c += 1
            i += 1
        elif a[i-1] >= a[i]:
            i += 1
print c

Measured memory_bytes: 11320
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int start;

vector<int> xval;
vector<int> yval;
int main(){
    string s;
    cin>>s;
    int x,y;
    
    cin>>x>>y;
    int n = s.length();
    int pos = n;
    for(int i=0;i<n;i++){
        if(s[i] == 'T'){
            pos = i+1;
            break;
        }
        start++;
    }
    
    int curr = 1;
    int val = 0;
   
    for(int i=pos;i<n;i++){
        if(s[i] == 'F'){
           val++;
           if(i == n-1){
               if(curr == 1){
                    yval.push_back(val);
                    //cout<<val<<endl;
                    val = 0;
                    curr = 0;
                }else{
                    xval.push_back(val);
                    val = 0;
                    curr = 1;
                }
           }
           continue;
        }
        if(curr == 1){
            yval.push_back(val);
            //cout<<val<<endl;
            val = 0;
            curr = 0;
        }else{
            xval.push_back(val);
            val = 0;
            curr = 1;
        }
    }
   
    int distx = abs(start-x);
    int disty = abs(y);
  
    sort(yval.rbegin(),yval.rend());
    sort(xval.rbegin(),xval.rend());
    int currx = 0;
    for(int i=0;i<xval.size();i++){
       
        if(currx>distx){
            currx-=xval[i];
        }else{
            currx+=xval[i];
        }
    }
   
    int curry = 0;
    for(int i :yval){
        if(curry>disty){
            curry-=i;
        }else{
            curry+=i;
        }
    }
    if(currx == distx && curry == disty){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fore(b,c) for(int val0=b;val0<c;val0++)
#define forr(k,c,s) for(int k=c;k<s;k++)
#define pb push_back
#define mmp make_pair
using namespace __gnu_pbds;
using namespace std;
template<typename T>
using oset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int> ii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long double ld;
typedef vector<vii> al;
typedef vector<ll> vl;
const int INF = 1e9;
const ll INFL = 1LL<<61;
vl w;
int main() {
	ios::sync_with_stdio(0);cout.precision(20);cout.tie(0);cin.tie(0);
	ll n,k;
	cin >> n >> k;
	for(int i=0;i<n;i++) {
		ll t;
		cin >> t;
		w.push_back(t);
	}
	for(int it=0;it<k;it++) {
		ll lc = 0;
		vl nu(w.size(),0);
		vl ru(w.size(),0);
		vl ac(w.size(),1);
		for(int i=0;i<n;i++) {
			if(i+1 < n) {
				nu[i+1]++;
			}
			if(i+w[i]+1 < n) {
				nu[i+w[i]+1]--;
			}
			if(i-1 >= 0) {
				ru[i-1]++;
			}
			if(i-w[i]-1 >= 0) {
				ru[i-w[i]-1]--;
			}
		}
		ll rs = 0;
		for(int i=0;i<n;i++) {
			rs += nu[i];
			ac[i] += rs;
		}
		rs = 0;
		for(int i=n-1;i>=0;i--) {
			rs += ru[i];
			ac[i] += rs;
		}
		w = ac;
		bool lo = true;
		for(int i=0;i<n;i++) {
			if(ac[i] != n) {lo = false;break;}
		}
		if(lo) {break;}
	}
	for(int i=0;i<n;i++) {
		if(i > 0) {cout << " ";}
		cout << w[i];
	}
	cout << '\n';
}



Measured memory_bytes: 9512
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include<bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(a, c) for (int(a) = 0; (a) < (c); (a)++) 
#define ll long long
#define vi vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int> 
#define pb push_back
#define str string
#define mod 998244353
#define pi 3.14159265
using namespace std;
int main()
{
    str s,t;
    cin >> s;
    cin >> t;
    ll count=0;
    for(ll i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
        {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3920
using System;

namespace D
{
    class Program
    {
        static long dp1(int[] w,int[] v,int N,int Wmax)
        {
            long[,] dp = new long[110,100000 + 3];
            dp[0, 0] = 0;
            for(int i=0;i<N;i++)
            {
                for(int sum_w = 0;sum_w<100003;sum_w++)
                {
                    if (sum_w - w[i] > 0)
                    {
                        dp[i+1, sum_w] = Math.Max(dp[i + 1, sum_w], dp[i, sum_w - w[i]] + v[i]);
                    }
                    dp[i+1, sum_w] = Math.Max(dp[i + 1, sum_w], dp[i, sum_w]);

                }

            }
            return (dp[N, Wmax + 1]);
        }

        static void Main(string[] args)
        {
            string[] NW = Console.ReadLine().Split(' ');
            int N = int.Parse(NW[0]);int Wmax = int.Parse(NW[1]);
            int[] w = new int[N];
            int[] v = new int[N];
            for(int i=0;i<N;i++)
            {
                string[] WV = Console.ReadLine().Split(' ');
                w[i] = int.Parse(WV[0]);
                v[i] = int.Parse(WV[1]);
            }
            long result = dp1(w, v, N, Wmax);
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 105692
#include <stdio.h>
int main(void)
{
	int n,m,x,y,a,xmax=-100,ymin=100,i;
	scanf("%d %d %d %d", &n, &m, &x, &y);
	for(i=0; i<n; i++)
	{
		scanf("%d", &a);
		if(xmax<a)
		xmax=a;
	}
	for(i=0; i<m; i++)
	{
		scanf("%d", &a);
		if(ymin>a)
		ymin=a;
	}
	if(x<xmax)
	x=xmax;
	if(y>ymin)
	y=ymin;
	if(y>x&&abs(x-y)>0)
	printf("No ");
	printf("War\n");
	
	return 0;
}

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

int main() {
  long X;
  cin >> X;
  for (long i = -1975; i <= 1975; i++) {
    for (long j = -1975; j <= 1975; j++) {
      if (pow(i, 5) - pow(j, 5) == X) {
        return cout << i << " " << j << "\n", 0;
      }
    }
  }
}


Measured memory_bytes: 4204
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <sstream>
#include <complex>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using iii = pair<int, ii>;
using viii = vector<iii>;

using ll = long long int;
using vc = vector<char>;
using vb = vector<bool>;
using ib = pair<int, bool>;
using vib = vector<ib>;

#define MOD 1000 * 1000 * 1000 + 7
#define INF 1000 * 1000 * 1000
#define EMPTY -10
#define mp(a, b) make_pair(a,b)

int mcd(int a, int b) { //Algoritmo de Euclides 
	if (b == 0) return a;
	else return mcd(b, a % b);
}

bool resuelveCaso() {
	int n;
	cin >> n;
	if (!cin) return false;
	int x;
	cin >> x;

	vi v(n);
	for (int i = 0; i < n; ++i) {
		int aux;
		cin >> aux;
		v[i] = abs(aux - x);
	}

	int sol = v[0];
	for (int i = 1; i < n; ++i) {
		sol = mcd(sol, v[i]);
	}

	cout << sol << '\n';

	return true;
}

int main() {
	while (resuelveCaso()) {}
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int partition(int *a, int lo, int hi)
{
	int i, j, x, t;

	x = a[hi], i = lo-1;
	for (j = lo; j < hi; j++) {
		if (a[j] <= x) i++, t = a[i], a[i] = a[j], a[j] = t;
	}
	t = a[++i], a[i] = a[hi], a[hi] = t;
	return i;
}

int a[100002];

int main()
{
	int n, i, k;
	
	n = in(); for (i = 0; i < n; i++) a[i] = in();
	k = partition(a, 0, n-1);
	printf((!k? "[%d]": "%d"), a[0]);
	for (i = 1; i < n; i++) {
		putchar(' ');
		printf((k==i? "[%d]": "%d"), a[i]);
	}
	putchar('\n');
	return 0;
}


Measured memory_bytes: 2084
#pragma GCC optimize ("Ofast")
#include <cstdio>
using namespace std;

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

	int* ans = new int[n];
	for(int i=0;i<n;i++){
		ans[a[i]-1] = i+1;
	}

	for(int i =0;i<n;i++){
		printf("%d ",ans[i]);
	}
	return 0;
}

Measured memory_bytes: 1536
for i in range(20):
    n=int(input())
    if n==0:break
    
    x=[]
    for j in range(n):
        a=int(input())
        x.append(a)
        
    for k in range(10):
        y=x.count(k)
        
        if y==0:
            print('-')
        else:
            print('*'*y)


Measured memory_bytes: 5708
#include<iostream>
#include<cstdlib>
#include<utility>
#include<tuple>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
using namespace std;

int main() {

	int n;
	cin >> n;
	string s = "APPROVED";

	vector<int> a(n);
	int i;
	for (i = 0; i < n; i++) cin >> a[i];

	for(i=0;i<n;i++){
		if (a[i] % 2 == 0){
			if (a[i] % 3 != 0 && a[i] % 5 != 0) {
				s = "DENIED";
				cout << s << endl;
				return 0;
			}
		}
	}

	cout << s << endl;

	return 0;
}


Measured memory_bytes: 256
def count(strings):
    s = set()
    for c in strings:
        s.add(c)
    return s


N = int(input())
S = input()
ans = 0
for i in range(1, len(S)):
    left = count(S[:i])
    right = count(S[i:])
    ans = max(ans, len(left & right))
print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int A, B, X;
	cin >> A >> B >> X;
	if (B < X - A || A > X) cout << "NO" << endl;
	else cout << "YES" << endl;
}


Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N;
	cin >> N;
	//ll p[N];
	int cnt = 0;
	rep(i, N)
	{
		ll tmp;
		cin >> tmp;
		if (tmp!= i+1)
		{
			cnt++;
		}
	}
	if (cnt > 2)
	{
		cout << "NO" << endl;
	}
	else
	{
		cout << "YES" << endl;
	}
	

	

	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define INF 1e9+7
using namespace std;
typedef long long int ll;


int main() {

	int n;
	int a, b;
	cin >> n >> a >> b;

	if (n == 1) {
		cout << "Hello World" << endl;
	}
	else {
		cout << a + b << endl;
	}


	return 0;
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
#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 REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int main(){
    vector<bool> l(31,false);
    REP(i,28){
	int t;
	cin >> t;
	l[t] = true;
    }
    FOR(i,1,31){
	if(!l[i]) cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}

int N_MAX = 100000;
vi a(N_MAX),b(N_MAX),c(N_MAX);
vvi dp(N_MAX,vi(3,0));

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    for(int i = 0;i < N;i++) cin >> a[i] >> b[i] >> c[i];
    dp[0][0] = a[0]; dp[0][1] = b[0]; dp[0][2] = c[0];
    for(int i = 1;i < N;i++){
        dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a[i];
        dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + b[i];
        dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + c[i];
    }
    int ans = max(dp[N-1][0],max(dp[N-1][1],dp[N-1][2]));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>

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

using namespace std;

struct UnionFind{
  vector<int> par,num;

  UnionFind(int N) : par(N),num(N){
    for(int i=0;i<N;i++){
      par[i] = i;
      num[i] = 1;
    }
  }

  int root(int x){
    if(par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return;
    par[rx] = ry;
    num[ry] = num[ry]+num[rx]; 
  }

  int get_num(int x){
    int rx = root(x);
    return num[rx];
  }

  bool same(int x, int y){
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};


int main(void){
  int x,y,z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef long double ld;
struct point{
	int x; ld y;
	bool operator <(const point b)const{
		return y*b.x<b.y*x;
	}
}q[500005];
int head,tail;
int main(){
	int n,l;
	scanf("%d%d",&n,&l);
	ld allt=0;int allv=0;
	int head=0,tail=-1;
	for(int i=1;i<=n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		point v=(point){y,(ld)x*y};
		allt+=v.y; allv+=v.x;
		while(allv>l){
		//	printf("%d %.6lf\n",allv,(double)allt);
			if(allv-q[head].x>=l){
				allt-=q[head].y;
				allv-=q[head].x;
				head++;
			}else{
				ld v=q[head].y*(allv-l)/q[head].x;
				q[head].x-=allv-l;
				allv=l;
				q[head].y-=v;
				allt-=v;
			}
		}
		//printf("%d %.6lf\n",allv,(double)allt);
		printf("%.6lf\n",(double)(allt/allv));
		while(tail>=head&&v<q[tail]){
			v.y+=q[tail].y;
			v.x+=q[tail].x;
			tail--;
		}
		q[++tail]=v;
	}
	return 0;
}


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

int n;
int h[100010];
int memo[100010];

int dp(int i){
  if(i == n-1){
    return 0;
  }

  if(i == n-2){
    return abs(h[i+1] - h[i]);
  }

  if(memo[i] != -1) return memo[i];

  return memo[i] = min(dp(i+1) + abs(h[i+1]-h[i]), dp(i+2) + abs(h[i+2]-h[i]));
}

int main(){
  cin >> n;

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

  memset(memo, -1, sizeof(memo));

  cout << dp(0) << endl;

  return 0;
}


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

int main()
{
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  if(s < t) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  } 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	long long i,n,m,a[100010],x;
	cin >> n >> m;
	for(i=0;i<n;i++){
		cin >> a[i];
		a[i] = a[i]%m;
	}
	long long b[100010],ans=0,c;
	x = 0;
	for(i=0;i<n;i++){
		x += a[i];
		x= x%m;
		b[i] = x;
	}
	b[n] = 0;
	sort(b,b+n+1);
	c = 1;
	for(i=0;i<n;i++){
		if(b[i]==b[i+1]){
			c++;
		}else{
			ans += c*(c-1)/2;
			c = 1;
		}
	}
	ans += c*(c-1)/2;
	cout << ans << endl;
}

Measured memory_bytes: 1792
import java.util.*;
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int N = sc.nextInt();
		int W[]=new int[N+1];
		long sum=0;
		String ans="Yes";
		for(int i=1;i<=N;i++){
			W[i]=sc.nextInt();
		}
		for(int i=1;i<=N;i++){
			sum=sum+W[i];
		}
		if (sum<H) {
			ans="No";
		}
		System.out.println(ans);
    }
}

Measured memory_bytes: 51600
use std::io::*;
const MOD: usize = 1_000_000_007;

fn pow(mut x: usize, mut e: usize) -> usize {
    let mut res = 1;
    while e > 0 {
        if e & 1 == 1 {
            res = res * x % MOD;
        }
        x = x * x % MOD;
        e >>= 1;
    }
    res
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let k: usize = itr.next().unwrap().parse().unwrap();

    let mut phi: Vec<usize> = (0..k + 1).collect();
    for i in 2..k + 1 {
        if phi[i] == i {
            for j in 1..k / i + 1 {
                phi[i * j] = phi[i * j] / i * (i - 1);
            }
        }
    }
    let mut ans = 0;
    for i in 1..k + 1 {
        ans = (ans + phi[i] * pow(k / i, n) % MOD) % MOD;
    }

    println!("{}", ans);
}


Measured memory_bytes: 2744
import sys
h,w = map(int, sys.stdin.readline().split())
a = [[[c] for c in l.strip()] for l in sys.stdin]
from itertools import chain
a = list(chain.from_iterable(a))
a = list(chain.from_iterable(a))
import collections
c = collections.Counter(a)
counts,values = zip(*c.most_common())
if (h %2 == 0 and w %2 == 0):
    for i in values:
        if i %4 != 0:
            print("No")
            break
    else:
        print("Yes")
elif (h%2 == 1 and w %2 == 1):
    yu = (w-1 + h-1)/2
    iko = 1
    for i in values:
        if i %4 == 0:
            continue
        elif i %2 == 0:
            yu -= 1
            if yu < 0:
                print("No")
                break
        elif i %4 == 1:
            iko -= 1
            if iko < 0:
                print('No')
                break
        else:
            iko-= 1
            yu-=1
            if iko < 0:
                print('No')
                break
            if yu < 0:
                print("No")
                break
    else:
        print('Yes')
else:
    if h %2 == 0:
      yu = h/2
    else:
      yu = w/2
    for i in values:
        if i %4 == 0:
            continue
        elif i %2 == 0:
            yu -= 1
            if yu < 0:
                print("No")
                break
        else:
            print("No")
            break
    else:
        print('Yes')

Measured memory_bytes: 4212
#include<bits/stdc++.h>
using namespace std;
inline long long getnum()
{
    long long now=0;long long fh=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')fh=-1;ch=getchar();}
    while(ch>='0' && ch<='9'){now=(now<<3)+(now<<1)+ch-'0';ch=getchar();}
    return now*fh;
}
int n,m,ans;
int main()
{
  char c[4];
  c[0]=getchar();
  c[1]=getchar();
  c[2]=getchar();
  c[3]=getchar();
  if (c[0]=='Y'&&c[1]=='A'&&c[2]=='K'&&c[3]=='I') printf("Yes\n");else printf("No\n");
  return 0;
}


Measured memory_bytes: 256
# Red and Black
require 'scanf'

def get_player_pos(map)
  x = 0
  y = 0

  map.each_with_index do |row, yy|
    x = row.index('@')
    y = yy
    break if x
  end

  [x, y]
end

def walk(map, x, y)
  map[y][x] = 'x'

  walk(map, x, y + 1) if map[y + 1][x] == '.'
  walk(map, x, y - 1) if map[y - 1][x] == '.'
  walk(map, x + 1, y) if map[y][x + 1] == '.'
  walk(map, x - 1, y) if map[y][x - 1] == '.'
end

def count_walked(map)
  w = 0

  map.each do |row|
    w += row.count('x')
  end

  w
end

while true
  w, h = gets.scanf('%d %d')

  break if w == 0 && h == 0

  wall = '#' * (w + 2)
  map = [wall]

  h.times do
    map << '#' + gets.chop + '#'
  end

  map << wall

  pos = get_player_pos(map)

  walk(map, *pos)
  puts count_walked(map)
end

Measured memory_bytes: 6440
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>

using namespace std;
#define SAY_YES cout<<"YES"<<endl;
#define SAY_Yes cout<<"Yes"<<endl;
#define SAY_NO cout<<"NO"<<endl;
#define SAY_No cout<<"No"<<endl;
#define IFYES(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;} 
#define IFYes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;} 
#define IFyes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"yes"<<endl;}else{cout<<"no"<<endl;} 
#define DEBUG_OUTPUT_ARRAY(XXX,ONE) for(int i=0;i<(ONE);i++){cout<<"DEBUG: i = "<<i<<" -> "<<XXX[i]<<endl;}
#define DEBUG_OUTPUT_ARRAY2(XXX,ONE,TWO) for(int i=0;i<(ONE);i++){cout<<"<<< i = "<<i<<" >>>"<<endl;for(int j=0;j<(TWO);j++){cout<<"DEBUG: j = "<<j<<" -> "<<XXX[i][j]<<endl; } }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX,ONE,TWO) for(int i=0;i<(ONE);i++){cout<<i<<"  ";for(int j=0;j<(TWO);j++){cout<<XXX[i][j]<<" "; } cout<<endl;}

typedef pair<long long int,long long int> pll;


const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int N,K,p,q,cou=0,P[10],Q[10],normal[10]={1,2,3,4,5,6,7,8};
pair<long double,long double> xy[15];
int main() {
	cout << fixed << setprecision(18);
    cin>>N;
    long double res=0,tmp=0;
    for(int i=0;i<N;i++){
        cin>>P[i];
    }
    for(int i=0;i<N;i++){
        cin>>Q[i];
    }
    do{
        bool keyp=true,keyq=true;
        for(int i=0;i<N;i++){
            if(normal[i]!=P[i]){keyp=false;}
            if(normal[i]!=Q[i]){keyq=false;}   
        }
        if(keyp){p=cou;}
        if(keyq){q=cou;}
        cou++;
        //DEBUG_OUTPUT_ARRAY(normal,3);
        //cout<<p<<" "<<q<<endl;
    }while(next_permutation(normal,normal+N));
    cout<<abs(p-q)<<endl;

} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve() {
  ll n,p;
  cin>>n>>p;
  string s;
  cin>>s;
  if(p!=2&&p!=5){
    vvi v(p);
    vi t(n);
    ll sum=0;
    ll k=1,ans=0;
    for(ll i=n-1; i>=0; i--){
      sum+=(s[i]-'0')*k;
      k*=10;
      k%=p;
      sum%=p;
      v[sum].eb(n-1-i);
      t[n-1-i]=sum;
      if(sum==0) ans++;
    }
    rep(i,p) ans+=(v[i].size()*(v[i].size()-1))/2;
    out(ans);
  }
  else{
    ll ans=0;
    rep(i,n){
      if((s[i]-'0')%p==0) ans+=i+1;
    }
    out(ans);
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 5012
use text_io::*;
use std::process::exit;

fn main() {
    let n:usize = read!();
    let mut a:usize = 0;
    for i in 0..n {
        let mut b:usize = read!();
        if (b*(i+1))%2 == 1 {
            a += 1;
        }
    }
    println!("{}",a);
}

Measured memory_bytes: 2076
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
		try{
			Scanner sc = new Scanner(System.in);
			String input = sc.next();
			String result = "yes";
			first : for(int i = 0 ; i < input.length()-1 ; i++){
				for(int j = i+1; j < input.length(); j++){
					if(input.charAt(i) == input.charAt(j)){
						result = "no";
						break first;
					}
				}
			}
			System.out.println(result);
		}catch(Exception e){
			e.getMessage();
		}
	} 
}

Measured memory_bytes: 21972