akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
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; }
//#define int long long


vector<bool> seen, finished;

int pos = -1;
stack<int> hist; //訪問履歴

void dfs(const vector<vector<int>> &G, int v, int p) {
    seen[v] = true;
    hist.push(v);
    for(auto nv: G[v]) {
        if(nv == p) continue;

        if(finished[nv]) continue; //nvを通る閉路がないことはわかってる→nvを通るものをもう一度探す必要はない

        if(seen[nv] && !finished[nv]) {
            pos = nv;
            return;
        }

        dfs(G, nv, v);

        if(pos != -1) return; //サイクルを検出したなばまっすぐ抜けていく
    }
    hist.pop();
    finished[v] = true; //vから行ける頂点全ての探索が終わった
}

void solve() {
	int n; cin >> n;

    vector<vector<int>> G(n);

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

    seen.assign(n, false);
    finished.assign(n, false);
    dfs(G, 0, -1);

    set<int> cycle;
    while(!hist.empty()) {
        int t = hist.top();
        cycle.insert(t);
        hist.pop();
        if(t == pos) break;
    }

    int q; cin >> q;
    rep(i, q) {
        int a, b; cin >> a >> b; --a; --b;
        if(cycle.count(a) && cycle.count(b)) {
            cout << 2 << endl;
        } else {
            cout << 1 << endl;
        }
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}


Measured memory_bytes: 19160
#include "bits/stdc++.h"
using namespace std;
constexpr int MOD = 1e9 + 7;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int& i : A) {
    cin >> i;
  }

  vector<int> dp1(K + 1), dp2(K + 1);
  dp1[0] = 1;

  for (int i : A) {
    for (int j = 0; j <= K; j++) {
      dp2[j] = dp1[j];
      if (j > i) {
        dp2[j] -= dp1[j - i - 1];
        dp2[j] += MOD;
        dp2[j] %= MOD;
      }
      if (j > 0) {
        dp2[j] += dp2[j - 1];
        dp2[j] %= MOD;
      }
    }
    swap(dp1, dp2);
  }

  cout << dp1[K] << endl;

  return 0;
}


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

using namespace std;

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

    int n;
    cin >> n;

    vector<pair<int , int> > v(n);
    for (int i = 0 ;i < n ;i++)
        cin >> v[i].first >> v[i].second;


    sort(v.begin() , v.end() , [&](auto &a , auto &b) {
       return a.second < b.second;
    });

    int cur = 0;
    for (int i = 0 ;i < n ;i++) {
        if (cur + v[i].first > v[i].second) {
            cout << "No";
            return 0;
        }
        cur += v[i].first;
    }

    cout << "Yes";
}


Measured memory_bytes: 4732
n,m = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
i = 1
ar = []
br = []
ans = []
for i in 1..m
    a,b = gets.split.map(&:to_i)
    if h[a-1] == h[b-1]
        ans.push(a,b)
    elsif h[a-1] > h[b-1]
        ans.push(b)
    else 
        ans.push(a)
    end
end
puts n - ans.uniq.size

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

signed main() {
  int N, K;
  cin >> N >> K;

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

  static int dp[101010];
  for (int i = 0; i < 101010; i++) {
    dp[i] = 1e18; // INF
  }

  dp[0] = 0; //初期化
  for (int i = 0; i < N; i++) {
    for (int j = 1; j <= K; j++) {
      if (i + j < N) {
        dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
      }
    }
  }

  cout << dp[N - 1] << endl;
  return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}


ll powmod(ll a, ll p){
  ll ans = 1;
  ll mul = a;
  for(; p > 0; p >>= 1, mul = (mul*mul) % mod){ //初期条件なし、pを2で割り続け、mulの値を更新
    if((p & 1) == 1) ans = ( ans * mul) % mod;//pが1なら ansの値を更新
  }
  return ans;
}

const int MAX_N = 2000001;

ll fact[MAX_N];
ll revfact[MAX_N];

void setFact(int N){
  fact[0] = 1;
  for(int i = 1; i < N; ++i){
    fact[i] = fact[i-1]*i;
    fact[i] %= mod;
  }
  revfact[N-1] = powmod(fact[N-1],mod-2);//逆元を求める
  for(int i = N-2;i >= 0;--i){
    revfact[i] = revfact[i+1] * (i+1);
    revfact[i] %= mod;//互いに素
  }
}

ll getC(int a, int b){
  return (fact[a] * revfact[b] % mod) * revfact[a-b] % mod;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll h,w,a,b;
  cin >> h >> w >> a >> b;
  setFact(MAX_N);
  vector<ll> q(w-b);
  ll k = w-b;
  rep(i,k){
    q[i] = getC(b+h-a+i-1,b+i);
  }
  ll ans = 0;
  rep(i,k){
    ans += (q[i] % mod * (getC(k+a-2-i,k-1-i) % mod))% mod;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 32256
n,k = map(int,input().split())
ans = 0

sum_min = 0
sum_max = 0

for i in range(1,k):
    if i != 0:   
        sum_min += i-1
    sum_max += n -i + 1
  #  print(i,sum_max - sum_min + 1,sum_min,sum_max)
for i in range(k,n+2):
    if i != 0:   
        sum_min += i-1
    sum_max += n -i+1
    ans += sum_max - sum_min + 1
 #   print(i,sum_max - sum_min + 1,sum_min,sum_max)
print(ans%(10**9+7))

Measured memory_bytes: 9200
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#include<tuple>
#include<stdio.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	double n, k;
	cin>>n>>k;
	vector<double> v;
//	priority_queue<double> q;
	double a, b=0.0, c=0.0;
	rep(i, n){
		cin>>a;
		a=(a+1)/2;
		v.push_back(a);
		b+=a;
		if(k<=i){
			b-=v[i-k];
		}
		if(c<b){
			c=b;
		}
	}
	printf("%f\n", c);
	return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
ll S[10005][5005];
int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	int p[n], c[n];
	rep(i, n) {
		scanf("%d", p + i);
		p[i]--;
	}
	rep(i, n) scanf("%d", c + i);
	rep(i, 10003) rep(j, n) S[i + 1][p[j]] = S[i][j] + c[p[j]];
	ll ans = -INF;
	rep(i, n) ans = max(ans, S[1][i]);
	vector<bool> seen(n, 0);
	rep(i, n) {
		if (seen[i])
			continue;
		else {
			seen[i] = 1;
			set<int> s;
			s.insert(i);
			int x = i;
			while (true) {
				x = p[x];
				seen[x] = 1;
				s.insert(x);
				if (x == i) break;
			}
			if (k <= s.size()) {
				repl(j, 1, k + 1) for (auto t : s) ans = max(ans, S[j][t]);
			} else if (S[s.size()][i] > 0) {
				ll c = (k / s.size() - 1) * S[s.size()][i];
				rep(j, k % s.size() + s.size() + 1) for (auto t : s) ans = max(ans, c + S[j][t]);
			} else {
				repl(j, 1, s.size() + 1) for (auto t : s) ans = max(ans, S[j][t]);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 395064
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);
constexpr ll INF = 1LL << 60;

int main(void) {
	int n, w;
	cin >> n >> w;
	
	vector<int> dw(n), v(n);
	for(int i = 0; i < n; ++i) {
		cin >> dw[i] >> v[i];
	}
	
	vector< vector<ll> > dp(n + 10, vector<ll>(100001, INF));
	dp[0][0] = 0;
	
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j <= 100000; ++j) {
			if( j >= v[i] ) {
				dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + dw[i]);
			} else {
				dp[i + 1][j] = dp[i][j];
			}
		}
	}
	
	int ans = 0;
	for(int i = 100000; i >= 0; i--) {
		if( dp[n][i] <= w ) {
			ans = i;
			break;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 90308
#include<bits/stdc++.h>
using namespace std;
bool isprime(int a)
{
    for(int i=2;i<=sqrt(a);i++)
    {
        if(a%i==0)
            return false;
    }
    return true;
}
bool comp(int a,int b)
{
    return a>b;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;long long int k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int ans=0,ind=0;
    bool vis[n];
    for(int i=0;i<n;i++)
        vis[i]=false;
    while(k--)
    {
       // cout<<ind;
        ind=arr[ind]-1;
        if(vis[ind])
            break;
        vis[ind]=true;
    }
    int count=0;
    if(k<=0)
        cout<<ind+1;
    else
    {
        ans=arr[ind]-1;
            count++;
        while(ind!=ans)
        {
            ans=arr[ans]-1;
            count++;
        }

        k%=count;
        while(k--)
        {
       // cout<<ind;
        ind=arr[ind]-1;

        }
        cout<<ind+1;
    }
    //cout<<ind+1;
    return 0;
}


Measured memory_bytes: 4648
S = list(input())

def check(x):
    #print(S[len(S)-x:x])
    for y in S[len(S)-x:x]:
        if y != S[len(S)-x]: break
    else:
        return True
    return False

def bisect(l,r):
    if r - l == 1: return l
    mid = (l+r) // 2
    if check(mid) == False:
        return bisect(l,mid)
    else:
        return bisect(mid,r)
print(bisect(0,len(S)+1))



Measured memory_bytes: 4692
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	long long r,d,x;
	cin>>r>>d>>x;
	for(int i = 0; i < 10;i++){
		x = r*x-d;
		cout<<x<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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

int main(){
	int N;
	cin >> N;
	
	double ans = 0.0;
	for(int i=0;i<N;i++){
		double x;
		string s;
		cin >> x >> s;
		if(s[0]=='J'){
			ans += x;
		}else{
			ans += 380000.0 * x;
		}
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;

const int N = 1e6 + 6;

char s[N];

int main() {
  scanf("%s", s);
  int n = strlen(s);
  int ans = 0;
  int mid = n / 2;
  ans = mid;
  while (ans < n) {
    if (s[ans] != s[n-1-ans] || s[ans] != s[mid]) break;
    ans++;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(int i=(s);i<(t);++i)
#define per(i,s,t) for(int i=((t)-1);i>=s;--i)
#define repb(i,s,t) for(int i=(s);i<=(t);++i)
#define lepb(i,s,t) for(int i=(s);i>=(t);--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
#define mst(a,b) memset(a,b,sizeof(a))
#define dd(x) cout<<#x<<'='<<x<<' '
#define de(x) cout<<#x<<'='<<x<<'\n'
#define fi first
#define se second
#define sq(x) ((x)*(x))
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;

const int inf = 0x3f3f3f3f;
const ll inff = 4557430888798830399ll;
const db eps = 1e-10;
const db pi = acos(-1.0);
const ll mod = 1e9+7;

#define maxn 1003
int a[maxn];
ll p[2][maxn*maxn];

int main()
{
//	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,k,c,cnt,dnt;ll z,t,s;
	scanf("%d%d",&n,&k);
	repb(i,1,n)scanf("%d",a+i);
	cnt=0;repb(i,1,n){t=0;repb(j,i,n)p[0][cnt++]=(t+=a[j]);}
	for(z=1,s=0;(z<<1)<=p[0][n-1];z<<=1);
	for(int o=0;z;z>>=1,o^=1,cnt=dnt)
	{
		dnt=0;c=0;
		rep(i,0,cnt)if(p[o][i]&z)p[o^1][dnt++]=p[o][i],c+=1;
		if(c<k)
			{rep(i,0,cnt)if(!(p[o][i]&z))p[o^1][dnt++]=p[o][i];}
		else s|=z;
	}
	printf("%lld\n",s);
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#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 mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

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

int main() {
    constexpr ll N_MAX = 300;
    constexpr ll H_MAX = 1000000000;
    constexpr ll INF = N_MAX * H_MAX;

    ll N, K;
    cin >> N >> K;
    vector<ll> H(N + 1, 0);
    FOR(i, 1, N + 1) cin >> H[i];

    vector<vector<vector<ll>>> dp(N + 1, vector<vector<ll>>(N + 1, vector<ll>(K + 1, INF)));
    REP(j, N + 1) {
        REP(k, K + 1) {
            dp[N][j][k] = 0;
        }
    }
    RFOR(i, 0, N) {
        REP(j, i + 1) {
            FOR(k, 0, K + 1) {
                dp[i][j][k] = dp[i + 1][i + 1][k] + max(H[i + 1] - H[j], 0ll);
                if (k > 0) {
                    amin(dp[i][j][k], dp[i + 1][j][k - 1]);
                }
            }
        }
    }
    cout << dp[0][0][K] << endl;

    return 0;
}

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

#define what_is(x)    cerr<<#x<<" is "<<x<<"\n";
#define rep(i,n)      for(int i=0; i < (n); ++i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define sz(x)         (x).size()
#define M             1e9+7;
#define MM            998244353
#define PI            3.14159265358979

typedef long double ld;
typedef pair <int,int> pii;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,ans; string str;

int solve(){
    int k,q; cin>>n>>k>>q;
    int a[n+1];
    rep(i,n+1) a[i]=0;
    rep(i,q){
        int t; cin>>t;
        a[t]++;
    }
    for (int i = 1; i <= n; ++i)
    {
        int t=k-(q-a[i]);
        if(t>0) cout<<"Yes\n";
        else cout<<"No\n";
    }
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>
#include <bitset>
using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n,m,x;
  cin>>n>>m>>x;
  vector2d<int> a(n,vector<int>(m,0));
  vector<int> c(n);
  for(int i=0;i<n;i++){
    cin>>c[i];
    for(int j=0;j<m;j++){
      cin>>a[i][j];
    }
  }
  int result=INT32_MAX;

  for(int i=0;i<(1<<n);i++){
    bitset<12> bs(i);
    vector<int> point(m,0);
    int sum=0;
    for(int j=0;j<n;j++){
      if(bs[j]){
        sum+=c[j];
        for(int k=0;k<m;k++){
          point[k]+=a[j][k];
        }
      }
    }

    bool isOK=true;
    for(auto p:point){
      if(p<x){
        isOK=false;
      }
    }
    if(isOK){
      UpdateMin(result,sum);
    }
  }
  cout<<(result==INT32_MAX?-1:result)<<endl;

  return 0;
}




Measured memory_bytes: 3664
#include<bits/stdc++.h>
#define int long long
using namespace std;
int mod  = 1e9+7;
int32_t  main(){
     int n;
     cin>>n;
     int a[n];
     int k[n+1]= {0};
     for(int i=0;i<n;++i){
         cin>>a[i];
     }
     int sum = a[n-1]% mod ;
     for(int i=n-1;i>=0;--i){
            k[i] =(  (a[i] % mod) +(k[i+1]% mod ) ) % mod ;
     }
    //  for(int i=0;i<n;++i){
    //      cout<<a[i]<<" ";
    //  }
     int ans= 0 ;
     for(int i=0;i<n-1;++i){
         ans=    (ans+ ( a[i]* k[i+1])% mod )  %mod;
         ans %= mod;
     }
     cout<<ans % mod;;
    
}

Measured memory_bytes: 6760
N, K = gets.split.map &:to_i
S = gets.chomp.chars.map &:to_i
ans = k = l = r = 0
until l == N
  until r == N || k == K
    if S[r].zero?
      k += 1
      r += 1 while r < N && S[r].zero?
    end
    r += 1 while r < N && S[r].odd?
  end
  ans = [ans, r - l].max
  s = S[l]
  k -= 1 if s.zero?
  l += 1 while l < N && S[l] == s
end
p ans


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

using namespace std;
using LL = long long;

const int MOD = 1e9+7;

class Edge{
public:
    LL from,to, value;
    Edge(int f,int t, int c){
        from = f;
        to = t;
        value = c;
    }
};

int main(){
    int A,B;cin >> A >> B;
    if(A <= 9 && B <= 9){
        cout<<A*B<<endl;
    }else{
        cout<<-1<<endl;
    }
}


Measured memory_bytes: 256
n = gets.to_i
s = gets.chop
all = s.count('R') * s.count('G') * s.count('B')
n.times do |i|
  ml = [i, n-1-i].min
  (1..ml).each do |j|
    all -= 1 if s[i-j] != s[i+j] && s[i] != s[i+j] && s[i-j] != s[i]
  end
end
puts all

Measured memory_bytes: 14372
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <climits>
#include <iomanip>

using namespace std;

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

#define INF 1000000000
#define mod 1000000007
#define MAX5 100001

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

// cout << setfill('0') << setw(5) << number < endl;
// while(getline(cin, s)) { .. } | `s` is a string

int gcd(int a, int b){
	int old_a, old_b;
	while(a % b != 0){
		old_a = a;
		old_b = b;

		a = old_b;
		b = old_a % old_b;
	}

	return b;
}
#define MAX 1000000000
vector<long long> h;
void precompute() {
	h.push_back(2);
	int i = 2;
	while(h.back() < MAX) {
		h.push_back(h.back() + (i - 1) + i * 2);
		++i;
	}
}

int main(){
	IOS;
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif
	
	long long int a, b, c, k;

	cin >> a >> b >> c >> k;

	if( k <= a + b) {
		cout << ((k > a) ? a : k);
	} else {
		cout << a  - (k - (a + b)) << endl;
	}
	
}

/*
11 
4 4 
-2 -2 
-3 -4 
-1 3 
2 3 
-4 0 
1 1 
-1 -1 
3 -1 
-4 2 
-2 4
*/

















Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;

int main(){
  int N,L;
  cin >> N >> L;
  vector<int> ai;
  int a0=0;
  int memo=0;
  bool pof=false;
  for(int i=0;i<N;i++){
    int a1;
    cin >> a1;
    if(a0+a1>=L){
      pof=true;
      memo=i;
    }
    a0=a1;
    ai.push_back(a1);
  }
  if((!pof)){
    cout <<"Impossible"<<endl;
    return 0;
  }
  cout <<"Possible"<<endl;
  int cnt0=1,cnt1=N-1;
  while(cnt0 < memo)
    cout << cnt0++<<endl;
  while(cnt1 > memo)
    cout << cnt1-- <<endl;
  cout << memo;
  return 0;
}


Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=9;i++){
		if(n%i!=0)
			continue;
		int j=n/i;
		if(j>=1&&j<=9)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }





void solve() {
    /*
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    */
    
    ll a, b, k;
    cin >> a >> b >> k;
    
    ll tmp = min(a, k);
    a -= tmp;
    k -= tmp;
    
    b -= min(b, k);
    cout << a << " " << b << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T;
    // cin >> T;
    T = 1;
    while (T--) {
        solve();
        // cout << (solve() ? "YES" : "NO") << endl;
    }
}


Measured memory_bytes: 256
import collections

N=int(input())
S=[input() for _ in range(N)]
M=int(input())
T=[input() for _ in range(M)]

set_S=set(S)
dict_S=collections.Counter(S)
set_T=set(T)
dict_T=collections.Counter(T)

for i in set_S:
    if i in set_T:
        dict_S[i]-=dict_T[i]
print(max(max(dict_S.values()),0))

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long X){
    ll K = 360;
    while (K % X != 0) K += 360;
    K /= X;
    cout << K << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


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

int main(){
    int n,x,y;
    cin>>n;
    x=n/10;
    y=n%10;
    if(x==9 || y==9){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(void) {
	int n, sum = 0,min=10000,s=0;
	int a[110];
	cin>>n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	for (int i = 0; i < n; i++) {
		s += a[i];
		if (abs(sum-(s*2)) < min)min = abs(sum-(s*2));
	}
	cout << min << endl;
	return 0;
}

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

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	A.erase(unique(A.begin(), A.end()), A.end());
	int n = A.size();
	cout << (n & 1 ? n : n - 1) << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int arr[101];
int main() {
	int n;
	cin>>n;
	
	for(int i=0; i<n; i++) cin>>arr[i];
	
	int ans=10000000;
	for(int x=-200; x<200; x++){
		int t=0;
		for(int i=0; i<n; i++){
			
			t += (x-arr[i])*(x-arr[i]);
		
		}
		
		ans= min(ans, t); 
	}
	
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3644
import java.io.*;
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;

public class Main{

    public static void main(String[] args){
        //START

        Scanner sc=new Scanner(System.in);
        int A=sc.nextInt();
        int B=sc.nextInt();
        int H=sc.nextInt();
        int M=sc.nextInt();

        double longW=((H%12)*30)+(M*0.5); //長針のデフォルトからの角度
        double shortW=M*6; //短針のデフォルトからの角度

        //System.out.print(longW);
        //System.out.print(" ");
        //System.out.println(shortW);

        double W=longW-shortW;

        if(W<0){
            W=Math.abs(longW-shortW);
        }else if(W>180){
            W=360-W;
        }

        //System.out.println(W);

        double cosW=0;

        if(W==90){
            cosW=0;
        }else{
            cosW=Math.cos(Math.toRadians(W));
        }

        //System.out.println(cosW);

        double JIJOU=A*A+B*B-2*A*B*cosW;

        //System.out.println(A*A+"と"+B*B+"と"+2*A*B*cosW);
        //System.out.println(JIJOU);

        double ans=Math.sqrt(JIJOU);

        System.out.println(String.format("%.15f", ans));
        //END

    }
}



Measured memory_bytes: 35920
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6;
const LL mod = 1000000007ll;
 
string S;
 
string ans = "No";
 
void solve(){
	if(S[0]!=S[1] || S[1]!=S[2]){
		ans = "Yes";
	}
}
 
int main(){
	cin >> S;
 
	solve();
 
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int a,b,c;
	string s="error";
	cin >> a; cin >> b; //cin >> c;
	//a[0]==a[2]?cout << "Yes"<< endl: cout << "No" << endl;
	if (a+b<10)cout << a+b << endl;
	else cout << s << endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N, K; cin >> N >> K;
  vector<int> hs(N); for (auto &h : hs) cin >> h;
  vector<long long> dp(N, 1LL << 40); dp[0] = 0;
  for (int i = 0; i < N; ++i)
    {for (int j = 1; j <= K; ++j) dp[i] = min(dp[i], i - j < 0 ? 1LL << 40 : dp[i - j] + abs(hs[i - j] - hs[i]));}
  cout << dp[N - 1] << endl;}

Measured memory_bytes: 1408
H,W,K=map(int,input().split())
C=[input() for i in range(H)]
count=0
for i in range(2**(H+W)):
    tate=[]
    yoko=[]
    for j in range(W):
        if ((i >> j)&1)==True:
            for k in range(H):
                tate.append((k,j))
    for j in range(W,H+W):
        if ((i >> j)&1)==True:
            for k in range(W):
                yoko.append((j-W,k))
    kyo=set(tate) & set(yoko)
    itti=0
    if len(kyo)!=0:
        for items in kyo:
            if C[items[0]][items[1]]=="#":
                itti+=1
        if itti==K:
            count+=1
print(count)

Measured memory_bytes: 69272
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <random>
#include <bitset>
#include <time.h>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
//#define endl '\n'
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define sp system("pause")
#define queuel queue<long long>
#define all(x) (x).begin(),(x).end()
#define matrix vector<vector<ll>>
#define pin(p) cin >> p.first >> p.second;
#define rev(v) reverse(v.begin(),v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end());
#define sout(s, c) for(auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for(ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for(int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for(int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define sin(s, n) for(int i = 0; i < n; ++i){int a; cin >> a; s.insert(a);}
#define fastio() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const ll INF = 1000LL * 1000 * 1000 * 1000 * 1000 * 1000;
const int inf = 1000 * 1000 * 1000;
const ld PI = acos(-1.0);
const ll mod1 = inf + 7;
const ll mod2 = inf + 9;
const int MAXN = 500001;
const ld EPS = 1e-9;
int hp = 179;

signed main()
{
	fastio();
	string s;
	cin >> s;
	ll k;
	cin >> k;
	for (int i = 0; i < min((ll)s.size(), k); ++i)
	{
		if (s[i] != '1' )
		{
			cout << s[i];
			return 0;
		}
	}
	cout << 1;
	system("pause");
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll dp[1005][1005] = {};

const ll N_MAX = 100005;

ll inv[N_MAX],fac[N_MAX],finv[N_MAX];
void make(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<N_MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll)i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}

ll Combination(ll C, ll D){
    if(C<D||C<1) return 0;
    return fac[C]*(finv[D]*finv[C-D]%mod)%mod;
}

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

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll f(ll G, ll k){
	ll bunshi = fac[G*k]%mod;
	ll bunbo = fac[k]%mod;
	bunbo *= powLL(fac[G], k);
	bunbo %= mod;
	return (bunshi * modinv(bunbo, mod)) % mod;
}

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

    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;

    dp[0][0] = 1;
    REP(i, B-A+1){
    	ll G = A+i;
    	REP(j, N+1){
    		dp[i+1][j] += dp[i][j];
    		dp[i+1][j] %= mod;
    		for(int k=C;k<=D;k++){
    			if(j+G*k>N) break;
    			dp[i+1][j+G*k] += (Combination(N-j, G*k)*(dp[i][j] * f(G, k)%mod))%mod;
    			//dp[i+1][j+G*k] += (Combination(N-j, G*k)*dp[i][j])%mod * f(G, k) %mod;
    			dp[i+1][j*G*k] %= mod;
    		}
    	}
    }
    cout << dp[B-A+1][N] << endl;

    /*
    REP(i,B-A+2){
    	REP(j, 10){
    		cout << dp[i][j] << " ";
    	}
    	cout << endl;
    }
    */
    return 0;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
int main(){
    string a,b;
    int n;
    cin >> n;
    int pointa,pointb = 0;
    for(int i = 0; i < n; i++) {
        cin >> a >> b;
        if(a > b) {
            pointa += 3;
        }
        else if(a < b) {
            pointb += 3;
        }
        else if(a == b) {
            pointa++;
            pointb++;
        }
    }
    cout << pointa << " " << pointb << endl;
}


Measured memory_bytes: 3156
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<functional>
#include<queue>

using namespace std;
const int MX=2011;
int n,a[MX];
struct Edge{int t,nxt;Edge(int _t=0,int _nxt=0):t(_t),nxt(_nxt){}}e[MX*MX];
int hed[MX],ec;
inline void ade(int f,int t){e[++ec]=Edge(t,hed[f]);hed[f]=ec;}
#define FE(k,i) for(int (i)=hed[k];(i);(i)=e[i].nxt)if(!vis[e[i].t])
inline int gcd(int x,int y){if(x<y)swap(x,y);while(y)x%=y,swap(x,y);return x;}

int vis[MX],stk[MX],nxt[MX],stc;

vector<int> operator+(vector<int> x,vector<int> y){
	vector<int> res;res.clear();
	vector<int>::iterator i=x.begin(),j=y.begin();
	while(i!=x.end()||j!=y.end()){
		if(i!=x.end()&&(j==y.end()||*i>*j))res.push_back(*(i++));
		else res.push_back(*(j++));
	}
	return res;
}
vector<int> dfs(int k){
	vis[k]=1;
	vector<int>res;res.clear();
	res.push_back(0x7fffffff);
	FE(k,i)res=res+dfs(e[i].t);
	res[0]=k;
	return res;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=n;i>=1;i--)
		for(int j=n;j>i;j--)
			if(gcd(a[i],a[j])>1)ade(i,j),ade(j,i);
	vector<int>S;S.clear();
	for(int i=1;i<=n;i++)if(!vis[i])S=S+dfs(i);
	for(vector<int>::iterator it=S.begin();it!=S.end();it++)printf("%d ",a[*it]);
	puts("");
	return 0;
}


Measured memory_bytes: 32256
G1 = [1, 3, 5, 7, 8, 10, 12]
G2 = [4, 6, 9, 11]
 
x, y = map(int, input().strip().split(' '))
 
if x in G1 and y in G1 or x in G2 and y in G2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<iostream>
#include<string>

using namespace std;
class dice {
public:
	int dat[6];

	int get() {
		return dat[0];
	};

	void east() {
		int tmp = dat[0];
		dat[0] = dat[3];
		dat[3] = dat[5];
		dat[5] = dat[2];
		dat[2] = tmp;
	};
	void west() {
		int tmp = dat[0];
		dat[0] = dat[2];
		dat[2] = dat[5];
		dat[5] = dat[3];
		dat[3] = tmp;
	};
	void north() {
		int tmp = dat[0];
		dat[0] = dat[1];
		dat[1] = dat[5];
		dat[5] = dat[4];
		dat[4] = tmp;
	};
	void south() {
		int tmp = dat[0];
		dat[0] = dat[4];
		dat[4] = dat[5];
		dat[5] = dat[1];
		dat[1] = tmp;
	};

};


int main() {
	dice d;
	string ins;
	for (int i = 0; i < 6;i++) cin >> d.dat[i];
	cin >> ins;
	for (int i = 0;i < ins.size();i++) {
		switch (ins[i]) {
		case 'E':
			d.east();
			break;
		case 'W':
			d.west();
			break;
		case 'N':
			d.north();
			break;
		case 'S':
			d.south();
			break;
		}
	}
	cout << d.get() << endl;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,T;
    cin >> N >> T;
    vector<vector<int>> backhome(N,vector<int>(2));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 2; j++){
            cin >> backhome[i][j];
        }
    }
    int k;
    bool ans = false;
    for(int i = 0; i < N; i++){
if(backhome[i][0] < k && backhome[i][1] <= T)
     {k = backhome[i][0];
     ans = true;}
    }
    if(ans)
    cout << k << endl;
    if(ans == false)
    cout << "TLE" << endl;
}

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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  if ((r*100 + g*10 + b)%4==0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

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

int main() {
    int n, a, ans; ans = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        for (;a % 2 != 1; a /= 2) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

public static void main(String[] args){


Scanner sc = new Scanner(System.in);
  while(true){
   int n = sc.nextInt();
   if(n == 0){ break; }
    int[]scores = new int[n];
     for(int i = 0;i < scores.length;i++){
     scores[i] = sc.nextInt();
     }
     int Max = 0, Min = 1000, average = 0, S = 0;

     for(int i = 0; i < scores.length; i++){
	 if(scores[i]>Max){
             Max = scores[i];
         }
         if(scores[i]<Min){
             Min = scores[i];
	 }
     }
     for(int i = 0; i < scores.length; i++){
       S = S + scores[i];
     }
     S = S - Max - Min;
     average = S / (n-2);
 
     System.out.println(average);
  }
}
}

Measured memory_bytes: 29132
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("2");
            //1 2 2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("3485");
            //872 1012974 1539173474040
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("4664");
            //3498 3498 3498
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        checked {
            List<string> InputList = GetInputList();
            long N = long.Parse(InputList[0]);

            for (long B = 1; B <= 3500; B++) {
                for (long C = 1; C <= 3500; C++) {
                    long wkBunsi = N * B * C;
                    long wkBunbo = 4 * B * C - N * C - N * B;

                    if (wkBunbo == 0) continue;
                    if (wkBunsi % wkBunbo > 0) continue;
                    long wkA = wkBunsi / wkBunbo;
                    if (wkA <= 0) continue;

                    Console.WriteLine("{0} {1} {2}", wkA, B, C);
                    return;
                }
            }
        }
    }
}


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

bool isprime[131072];

int main() {
  for(int i = 0; i < 131072; ++i) {
    isprime[i] = true;
  }
  isprime[0] = isprime[1] = false;
  for(int i = 2; i < 1024; ++i) {
    if( isprime[i] ) {
      for(int j = i + i; j < 131072; j+=i) {
        isprime[j] = false;
      }
    }
  }
  std::vector<int> primes;
  for(int i = 0; i < 131072; ++i) {
    if( not isprime[i] ) continue;
    primes.push_back(i);
  }  
  
  int m, a, b;
  for(;;) {
    int max = 0;
    int resp, resq;
    std::cin >> m >> a >> b;
    if( m == 0 and a == 0 and b == 0 ) break;

    for(int p : primes) {
      for(int q : primes) {
        if( p * q > m ) break;
        if( q < p ) continue;
        if( not ( a * q <= b * p ) ) continue;
        if( max < p * q ) {
          max = p * q;
          resp = p;
          resq = q;
        }
      }
    }
    assert( max != 0 );
    std::cout << resp << ' ' << resq << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 3280
#include <iostream>
#include <cassert>
#include <string>
//#define NDEBUG

int tmp    = 0;
int top    = 0;
int south  = 0;
int east   = 0;
int west   = 0;
int north  = 0;
int bottom = 0;

void GoSouth(){
    tmp = top;
	top = north;
	north  = bottom;
	bottom = south;
	south  = tmp;
}
void GoEast(){
    tmp = top;
	top = west;
	west   = bottom;
	bottom = east;
	east   = tmp;
}
void GoWest(){
    tmp = top;
	top = east;
	east   = bottom;
	bottom = west;
	west   = tmp;
}
void GoNorth(){
    tmp = top;
	top = south;
	south  = bottom;
	bottom = north;
	north  = tmp;
}
int main(void){
	using namespace std;

	static const int INPUT_DICE_MIN = 0;
	static const int INPUT_DICE_MAX = 100;
	static const int INPUT_LENG_MIN = 0;
	static const int INPUT_LENG_MAX = 100;
	
	int input_top;
	int input_south;
	int input_east;
	int input_west;
	int input_north;
	int input_bottom;
	string input_word;

	cin >> input_top >> input_south >> input_east >> input_west >> input_north >> input_bottom >> input_word;
     
	assert(INPUT_DICE_MIN <= input_top    && input_top <= INPUT_DICE_MAX);		/* Precondition */
	assert(INPUT_DICE_MIN <= input_south  && input_south <= INPUT_DICE_MAX);	/* Precondition */
	assert(INPUT_DICE_MIN <= input_east   && input_east <= INPUT_DICE_MAX);		/* Precondition */
	assert(INPUT_DICE_MIN <= input_west   && input_west <= INPUT_DICE_MAX);		/* Precondition */
	assert(INPUT_DICE_MIN <= input_north  && input_north <= INPUT_DICE_MAX);	/* Precondition */
	assert(INPUT_DICE_MIN <= input_bottom && input_bottom <= INPUT_DICE_MAX);	/* Precondition */
	assert(INPUT_LENG_MIN <= input_word.length() && input_word.length() <= INPUT_LENG_MAX);  /* Precondition */ 

	/* init */
	top    = input_top;
	south  = input_south;
	east   = input_east;
	west   = input_west;
	north  = input_north;
	bottom = input_bottom;
	
	/* Direction Command */	
	for(int i=0; i<input_word.length(); i++){
		char direction = input_word[i];
		switch(direction){
			case 'S':	/* To South */
				GoSouth();
				break;
			case 'E':	/* To East  */
				GoEast();
				break;
			case 'W':	/* To West  */
				GoWest();
				break;
			case 'N':	/* To North */
				GoNorth();
				break;
			default:	/* Other */
				break;
		}
	}

	cout << top << endl;

	return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int card[100005];
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,M;
	cin >> N >> M;
	vector<vector<int>> to(N);
	for(int i=0;i<M;i++){
		int x,y,z;
		cin >> x >> y >> z;
		x--,y--;
		to[x].push_back(y);
		to[y].push_back(x);
	}
	int ans = 0;
	vector<bool> visited(N);
	for(int i=0;i<N;i++){
		if(visited[i])continue;
		ans++;
		queue<int> q;
		q.push(i);
		while(!q.empty()){
			int now = q.front();
			q.pop();
			for(int j=0;j<to[now].size();j++){
				int next = to[now][j];
				if(!visited[next]){
					q.push(next);
					visited[next] = true;
				}
			}
		}
	}
	cout << ans << endl;
}

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

using namespace std;

#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef long long ll;
typedef pair<int, int> pii;

const int INF = 1e9;
const int N = 1e5 + 5;
const int K = 105;
int arr[N];
int dp[N][K];
int n , k;

int solve(int idx , int i){
    if(idx + i > n || i > k)return INF;
    if(idx == n-1)return 0;
    int &ret = dp[idx][i];
    if(~ret)return ret;
    ret = solve(idx , i + 1);
    ret = min(ret , solve(idx + i , 1) + abs(arr[idx + i] - arr[idx]));
    return ret;
}

int main() {

#ifndef ONLINE_JUDGE
    //freopen("in.in", "r", stdin);
    //freopen("out.in", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> k;
    loop(i,n)cin >> arr[i];
    memset(dp,-1,sizeof dp);
    cout << solve(0,1) << endl;

    return 0;
}


Measured memory_bytes: 44800
n = int(input())
a = list(map(int,input().split()))

from collections import Counter

z = Counter(a)

i,j,temp = (0,0,0)
for tu in z.items():
    i,j = tu
    if i>j:
        temp+=j
    elif i<j:
        temp+=j-i
    else:
        continue

print(temp)

Measured memory_bytes: 68136
N, K = map(int, input().split())

ok = [True]*10

d = [int(s) for s in input().split()]

for i in d:
    ok[i] = False

ans = 0
for i in range(N, 10*N+1):
    j = i
    while j > 0 and ok[j%10]:
        j //= 10
    if j == 0:
        ans = i
        break

print(ans)


Measured memory_bytes: 3060