akhauriyash/Code-Regression huggingface dataset:
/**
*    author:  yuya1234
*    created: 17.07.2020 15:08:11
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
long double eps = 1.0E-14;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T>T lcm(T a,T b){return gcd(a,b)*(a/gcd(a,b))*(b/gcd(a,b));}

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

  double a,b,x;
  cin>>a>>b>>x;

  double PI=acos(-1);
  x/=a;
  double ans;

  if(a*b/2>=x)
  {
    ans=atan((b*b)/(2*x));
  }
  else
  {
    ans=atan((2*(a*b-x))/(a*a));
  }
  
  cout << ::fixed << ::setprecision(10)<<ans*180/PI<<endl;

  return 0;
}

Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define forn for(int i=1;i<n;i++)
#define form for(int j=0;j<m;j++)
#define pb push_back
#define mp make_pair
#define sc second
#define f first
#define kek cout<<"\n"
#define all(v)        ((v).begin()), ((v).end())
#define pob pop_back()
const ll MOD=1e9+7;
const int INF=1e8;
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
 int n;
 cin>>n;
 int a;
 int ans=1;
 int mx=INF;
 cin>>a;
 mx=min(mx,a);
 
 forn
 {
           cin>>a;
           if(a<=mx) ans++;
            mx=min(mx,a);
           
 }
 cout<<ans;
 return 0;
}

Measured memory_bytes: 256
n = int(input())
arr = list(map(int, input().split()))
q = int(input())
questions = list(map(int, input().split()))

answers = set()
for i in range(1, 2 ** n):
    bin_i = "{:020b}".format(i)[::-1]

    answer = sum(arr[x] for x in range(n) if bin_i[x] == "1")
    answers.add(answer)

for question in questions:
    print("yes" if question in answers else "no")
    


Measured memory_bytes: 5664
import numpy as P
M=10**9+7
m=lambda:map(int,input().split())
n,k=m()
a=P.matrix([list(m())for _ in[0]*n],dtype='O')
b=P.eye(n,n,0,'O')
while k:b=[b,b*a%M][k&1];a=a*a%M;k>>=1
print(b.sum()%M)

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

using namespace std;

typedef long long ll;
const ll MAX = 1ll << 62;

int main(){
  int N, K;
  cin >> N >> K;
  
  vector<ll> x(N);
  vector<ll> y(N);
  for(int i = 0; i < N; i++){
    cin >> x[i] >> y[i];
  }
  
  ll x1, x2, y1, y2;
  ll s = MAX;
  for(int i = 0; i < N - 1; i++){
    x1 = x[i];
    for(int j = i + 1; j < N; j++){
      x2 = x[j];
      for(int k = 0; k < N - 1; k++){
        y1 = y[k];
        for(int m = k + 1; m < N; m++){
          y2 = y[m];
          
          ll l, r, d, u;
          l = min(x1, x2);
          r = max(x1, x2);
          d = min(y1, y2);
          u = max(y1, y2);
          
          int cnt = 0;
          for(int i = 0; i < N; i++){
            if(min(l, r) <= x[i] && x[i] <= r && d <= y[i] && y[i] <= u){
              cnt++;
            }
          }
          
          if(cnt >= K && (r - l) * (u - d) <= s){
            s = (r - l)*(u - d);
          }
        }
      }
    }
  }
  
  cout << s << endl;
}

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

int prime(int a){
  if(a==1)return 0;
  else if(a==2)return 1;
  else if(a%2==0)return 0;
  for(int i=3;i*i<=a;i+=2){
    if(a%i==0)return 0;
  }
  return 1;
}

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




Measured memory_bytes: 3084
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	int W, H, N; cin >> W >> H >> N;
	int x, y;
	x = y = 0;

	REP(i,N){
		int xi, yi, ai; cin >> xi >> yi >> ai;
		switch(ai){
			case 1:
				x = max(x, xi);
				break;
			case 2:
				W = min(W, xi);
				break;
			case 3:
				y = max(y, yi);
				break;
			case 4:
				H = min(H, yi);
				break;
		}

	}

	int dx = max(0, W-x);
	int dy = max(0, H-y);

	cout << dx*dy << endl;


	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <tuple>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
const int INF = 1 << 30;

int main() {
  int N, ma, mb;
  cin >> N >> ma >> mb;
  int mincost = INF, xmax = 0;
  vector<tuple<int, int>> x_minus, x_plus;
  REP(i, N) {
    int a, b, c;
    cin >> a >> b >> c;
    int x = a * mb - ma * b;
    if (x == 0) {
      mincost = min(mincost, c);
    } else if (x < 0) {
      x_minus.emplace_back(c, -x);
    } else {
      x_plus.emplace_back(c, x);
    }
    xmax = max(xmax, abs(x));
  }
  vector<int> dp_plus(xmax + 1, INF), dp_minus(xmax + 1, INF);
  dp_plus[0] = dp_minus[0] = 0;
  for (auto& cx : x_plus) {
    int ci = get<0>(cx), xi = get<1>(cx);
    for (int w = xmax - xi; w >= 0; --w) {
      dp_plus[w + xi] = min(dp_plus[w + xi], dp_plus[w] + ci);
    }
  }
  for (auto& cx : x_minus) {
    int ci = get<0>(cx), xi = get<1>(cx);
    for (int w = xmax - xi; w >= 0; --w) {
      dp_minus[w + xi] = min(dp_minus[w + xi], dp_minus[w] + ci);
    }
  }
  for (int w = 1; w <= xmax; ++w) {
    int wp = dp_plus[w], wm = dp_minus[w];
    if (wp != INF && wm != INF && mincost > wp + wm) {
      mincost = wp + wm;
    }
  }
  cout << (mincost == INF ? -1 : mincost) << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 1000000007
  #define N 10005
  #define INF 10000000000000
  #define eps 1e-6

  int dp[N];
  int32_t main()
  {         

    IOS

    int h,n;
    cin >> h >> n;

    int a[n+1],b[n+1];

    for(int i = 1; i <= n; i++)
    {
      cin >> a[i] >> b[i];
    }
    
    //dp[n] denotes the minimum cost to win over health H

    dp[0] = 0;

    for(int i = 1; i <= h; i++)
    {
      dp[i] = INF;
    }

    for(int i = 1; i <= h; i++)
    {
      for(int j = 1; j <= n; j++)
      {     //if(i - a[j] <0) continue;
            if(i - a[j] < 0) dp[i] = min(dp[i],b[j]);
            else dp[i] = min(dp[i],dp[i-a[j]] + b[j]);
      }
    } 

    cout << dp[h];

    // for(int i = 0 ; i <= h; i++)
    // {
    //   trace2(i,dp[i]);
    // }

    return 0;   
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
int main()
{
int k;ull sum=0;
  cin>>k;
  for(int i=1;i<=k;i++)
  {
  for(int j=1;j<=k;j++)
  {
  for(int l=1;l<=k;l++)
  {
  int ans1=__gcd(i,j);
    ans1=__gcd(ans1,l);
    sum+=ans1;
  }
  }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int dp[100000+5];
int A[100+5];

int main(int argc, char const *argv[])
{
	int N, K;
	while(cin >> N >> K) {
		memset(dp, 0, sizeof(dp));
		for(int i=0; i<N; i++) {
			cin >> A[i];
		}
		for(int i=A[0]; i<=K; i++) {
			for(int j=0; j<N; j++) {
				if(i >= A[j] && dp[i - A[j]] == 0){
					dp[i] = 1;
					break;
				}
				else {
					dp[i] = 0;
				}
			}
		}
		if(dp[K]) {
			cout << "First" << endl;
		} else {
			cout << "Second" << endl;
		}
	}
	return 0;
}

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

signed main() {
  int N, Y;
  cin >> N >> Y;
  
  int ansman = -1;
  int ansgos = -1;
  int anssen = -1;
  for( int i = 0; i <= N; i++ ){ //10000円札
    for( int j = 0; i + j <= N; j++ ){//5000円札
      int sen = N - i - j;
      if( i*10000 + 5000*j + sen*1000 == Y ){
      ansman = i;
      ansgos = j;
      anssen = sen;
      }
    }
  }
  cout << ansman << " " << ansgos << " " << anssen << endl;

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

#define INF 1000000000

typedef long double Real;
#define EPS 1e-13
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

ll a[101][101];
ll sm[101][101];

inline ll getsm(int t,int b,int l,int r){
  return sm[b][r]-(t>0?sm[t-1][r]:0)-(l>0?sm[b][l-1]:0)+(t>0&&l>0?sm[t-1][l-1]:0);
}

int main(){
  int n;
  cin>>n;
  REP(i,n)REP(j,n)cin>>a[i][j];
  REP(i,n)REP(j,n)sm[i][j]=a[i][j];
  REPR(i,n)REP(j,n)sm[i][j]+=sm[i-1][j];
  REP(i,n)REPR(j,n)sm[i][j]+=sm[i][j-1];
  ll mx = -1145141919;
  REP(top,n)FOR(bot,top,n){
    int left = 0, right = 0;
    while(left<n && right<n){
      ll t = getsm(top,bot,left,right);
      mx = max(mx,t);
      if(t>0){
        ++right;
      }else{
        right = left = right+1;
      }
    }
  }
  cout<<mx<<endl;
  return 0;
}

Measured memory_bytes: 1320
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;

int main()
{
    ll A,B,C,X,Y;
    while(cin>>A>>B>>C>>X>>Y)
    {
      ll ans=0;
      if(C*2<A+B)
      {
        ll t1;
        if(X>Y){
            ans+=C*2*Y;
            int t=min(A,C*2);
            ans+=t*(X-Y);
        }else{
            ans+=C*2*X;
            int t=min(B,C*2);
            ans+=t*(Y-X);
        }
      }else{
        if(X>Y){
            ans+=(A+B)*Y;
            ans+=A*(X-Y);
        }else{
            ans+=(A+B)*X;
            ans+=B*(Y-X);
        }
      }
      cout<<ans<<endl;
    }
    return 0;
}


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

int main(){
	int n;
	cin >> n;
	map<int, int> m;
	while(n--){
		int a;
		cin >> a;
		m[a]++;
	}
	cout << m.size() - !(m.size() & 1) << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
 
int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  vector<vector<int>> cnt(h, vector<int>(w));
  rep(i,h) {
    vector<int> done(w);
    rep(j,w) {
      if (s[i][j] == '#') continue;
      if (done[j]) continue;
      int l = 0;
      while (j+l < w) {
        if (s[i][j+l] == '#') break;
        ++l;
      }
      rep(k,l) {
        cnt[i][j+k] += l;
        done[j+k] = 1;
      }
    }
  }
  rep(j,w) {
    vector<int> done(h);
    rep(i,h) {
      if (s[i][j] == '#') continue;
      if (done[i]) continue;
      int l = 0;
      while (i+l < h) {
        if (s[i+l][j] == '#') break;
        ++l;
      }
      rep(k,l) {
        cnt[i+k][j] += l;
        done[i+k] = 1;
      }
    }
  }
  int ans = 0;
  rep(i,h)rep(j,w) ans = max(ans, cnt[i][j]-1);
  cout << ans << endl;
  return 0;
}  

Measured memory_bytes: 20096
/*
 * @Author: Luisvacson
 * @LastEditors: Luisvacson
 * @Descriptions: None
 * @Date: 2020-06-13 20:02:26
 * @LastEditTime: 2020-06-13 20:03:04
 * @FilePath: \VSC\C++\Public\tokiomarine2020 A.cpp
 */ 
#include<bits/stdc++.h>
using namespace std;

string s;
signed main(){
    cin>>s;
    cout<<s[0]<<s[1]<<s[2]<<'\n';
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  map<int,int> mp;
  int N;
  cin >> N;
  int d;
  rep(i,N){
    cin >> d;
    mp[d]++;
  }
  cout << mp.size() << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int ans=0,lim,cnt=0,dp[55][300000],ct[300005],n,a[2][20],v;
const int inf=1e9;
int main()
{
	scanf("%d",&n);
	lim=(1<<n);
	for(int i=0;i<n;i++)scanf("%d",&a[0][i]);
	for(int i=0;i<n;i++)scanf("%d",&a[1][i]);
	for(int i=0;i<=50;i++)for(int j=0;j<lim;j++)dp[i][j]=inf;
	ct[0]=0;
	for(int i=1;i<lim;i++)
	{
		for(int j=0;j<n;j++)
		{
			if((1<<j)&i)
			{
				ct[i]=ct[i-(1<<j)]+1;
				break;
			}
		}
	}
	dp[0][0]=0;
	for(int i=0;i<lim;i++)
	{
		cnt=0;
		for(int j=n-1;j>=0;j--)
		{
			if(i&(1<<j))
			{
				cnt++;
				continue;
			}
			v=a[abs(j-ct[i])&1][j];
			for(int k=0;k<=v;k++)dp[v][i+(1<<j)]=min(dp[v][i+(1<<j)],dp[k][i]+cnt);
		}
	}
	ans=inf;
	for(int i=0;i<=50;i++)ans=min(ans,dp[i][lim-1]);
	if(ans>=inf)printf("-1\n");
	else printf("%d\n",ans);
	return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri(), y = ri();
	int a[n];
	int64_t min = 0;
	for (auto &i : a) i = ri(), min += i;
	min /= 5;
	min -= y;
	
	int64_t res = 0;
	for (int v = 0; v < n; v++) {
		int64_t dp[6][n + 1];
		for (int j = 0; j < 6; j++) for (int i = 0; i <= n; i++) dp[j][i] = 0;
		dp[0][0] = 1;
		for (int i = 0; i < 5; i++) {
			for (int j = 0; j <= n; j++) {
				if (dp[i][j] == 0) continue;
				int64_t sum = 0;
				for (int k = j + 1; k <= n; k++) {
					sum += a[(v + k - 1) % n];
					if (sum < min) continue;
					dp[i + 1][k] += dp[i][j];
				}
			}
		}
		res += dp[5][n];
	}
	std::cout << res / 5 << std::endl;
	return 0;
}






Measured memory_bytes: 3232
n = int(input())
e = [[] for _ in range(n)]
for _ in range(n-1):
    u,v,w = map(int, input().split())
    u -= 1
    v -= 1
    e[u].append((v,w))
    e[v].append((u,w))

res = [-1]*n
res[0] = 0
q = [0]
while len(q):
    v = q.pop()
    for u,w in e[v]:
        if res[u]>=0:
            continue
        res[u] = res[v]+w
        q.append(u)

for r in res:
    print(r%2)


Measured memory_bytes: 47332
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <set>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 10000000000
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main(void) {
    ll n, k;
    cin >> n >> k;
    ll x[100000];
    ll d;
    ll i;
    ll ans=INF, tmp;
    
    for(i=0; i<n; i++)
        cin >> x[i];
    

    
    for(i=0; i+k-1<n; i++) {
        tmp=INF;
        ll j=i+k-1;
        d=x[j]-x[i];

        
        if(x[i]<0 && x[j]>0)
            tmp=min(abs(x[i]), abs(x[j]))+d;
        else if(x[i]>=0)
            tmp=x[j];
        else if(x[j]<=0)
            tmp=abs(x[i]);
        ans=min(ans, tmp);
    }
    
    
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
#define INF 2000000000
#define REP(i,b,n) for(int i = (b); i < n; i++)
#define rREP(i,b,n) for(int i = (n-1); i >= (b); i--)
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
int gcd(int a, int b){return b ? gcd(b, a % b): a;}
void yes(){cout<<"Yes"<<endl;return;}
void no(){cout<<"No"<<endl;return;}

int main()
{
    int t[5];
    REP(i,0,5) cin >> t[i];
    int ilast;
    int mod_min = 10;
    int ans = 0;
    REP(i,0,5) {
        int mod = t[i] % 10;
        if (mod == 0) mod = 10;
        if (mod <= mod_min) {
            mod_min = mod;
            ilast = i;
        }
        ans += t[i] - mod + 10;
    }
    ans -= 10 - mod_min;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
K = int(input())
num = 1
pls = 1
coun = 0

while num <= 1000000000000000 and coun < K:
    while (num/sum(list(map(int, list(str(num)))))) <= ((num+pls)/sum(list(map(int, list(str(num+pls)))))) and coun < K:
        print(num)
        coun = coun + 1
        num = num + pls
    num = num - pls
    pls = pls * 10
    num = num + pls

Measured memory_bytes: 3188
#include <stdio.h>
int main(){
    char a[300000];
    int now=0,r=1,ans=0;
    for(int i=0;i<300000;i++)a[i]='\0';
    scanf("%s",a);
    while(a[now]!='\0')now++;
    for(int i=0;i<now-r;i++){
        if(a[i]!=a[now-r]){
            if(a[now-r]=='x'){
                r++;
                i--;
            }
            else if(a[i]!='x'){
                printf("-1\n");
                return 0;
            }
            ans++;
        }
        else r++;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 512
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // Initialize
        	var sC = cin.ReadLine;
            // Process
            // Output
        	WriteLine((char)(sC[0]+1));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 26072
#include<cstdio>
#include<cstring>
#include<string.h>
#include<algorithm>
using namespace std;
int cnt[2007];
int n,x,y;
int main(){
	scanf("%d%d%d",&n,&x,&y);
	for(int i=1;i<n;i++){
		for(int j=i+1;j<=n;j++){
			if(j>=y&&i<=x){
		//		printf("%d %d min=%d\n",i,j,min(j-i,j-y+x-i+1));
				cnt[min(j-i,j-y+x-i+1)]+=1;
			}
			else if(j<=x||i>=y){
		//		printf("%d %d min=%d\n",i,j,j-i);
				cnt[j-i]+=1;
			}
			else if(x>=i&&j>x){
		//		printf("%d %d min=%d\n",i,j,min(j-i,y-j+x-i+1));
				cnt[min(j-i,y-j+x-i+1)]+=1;
			}
			else if(j>=y&&i>x){
		//		printf("%d %d min=%d\n",i,j,min(j-i,j-y+i-x+1));
				cnt[min(j-i,j-y+i-x+1)]+=1;
			}
			else{
		//		printf("%d %d min=%d\n",i,j,min(j-i,i-x+y-j+1));
				cnt[min(j-i,i-x+y-j+1)]+=1;
			}
		}
	}
	for(int i=1;i<=n-1;i++){
		printf("%d\n",cnt[i]);
	}
	return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

func main() {
	r := bufio.NewReaderSize(os.Stdin, 100000)
	s, _, _ := r.ReadLine()

	v := s[0]
	cnt := 0
	for i := 1; i < len(s)-1; i++ {
		if v == s[i+1] {
			v = s[i+1]
			i++
		} else {
			cnt++
		}
	}

	if cnt == 0 {
		out("Second")
	} else if cnt%2 == 0 {
		out("Second")
	} else {
		out("First")
	}
}


Measured memory_bytes: 768
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int main(){
	int n;
	string s;
	cin>>n>>s;
	int mx=0;
	int x=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='I')x++;
		else x--;
		mx=max(mx,x);
	}
	cout<<mx<<endl;
	return 0;
}


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

using namespace std;

int main() {
	int A, B, M; cin >> A >> B >> M;
	vector<int> a(A), b(B);
	int ans, mina, minb;
	mina = minb = 1e9;
	for (auto& e : a) cin >> e, mina = min(mina, e);
	for (auto& e : b) cin >> e, minb = min(minb, e);
	ans = mina + minb;
	while (M--) {
		int x, y, c; cin >> x >> y >> c;
		--x, --y;
		ans = min(ans, a[x] + b[y] - c);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
def main():
    import sys
    sys.setrecursionlimit(10**7)

    N,M=list(map(int,sys.stdin.readline().split()))
    dic=[[] for _ in range(N)]
    for i in range(M):
        x,y=list(map(int,sys.stdin.readline().split()))
        dic[x-1].append(y-1)


    dp=[0]*(N)
    def dfs(frm):
        if dp[frm]:
            return dp[frm]

        mx=0
        if not dic[frm]:
            return 0

        for val in dic[frm]:
            mx=max(mx,dfs(val)+1)

        dp[frm]=mx
        return mx

    mx=0
    for key in range(N):
        mx=max(mx,dfs(key))

    return mx

print(main())


Measured memory_bytes: 139596
#include <cstdio>
#include <cmath>
#define N 100005
using namespace std;
int n, to, xo, yo, tt, xx, yy, t, d;
int main() {
	scanf("%d", &n);
	for(int i=1; i<=n; i++) {
		scanf("%d%d%d", &tt, &xx, &yy);
		t = abs(tt - to);
		d = abs(xx - xo) + abs(yy - yo);
		if(t<d || (t-d)%2) {puts("No"); return 0;}
		to=tt, xo=xx, yo=yy;
	}
	puts("Yes");
	return 0;
}

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

using namespace std;



int main()
{
    int a,b,c;
    set<int> s;
    set<int>:: iterator it;
    scanf("%d ",&a);


    for(int k=0;k<a;k++){
    scanf("%d",&b);
    if (b==0){
            scanf("%d",&c);
            s.insert(c);
            cout<<s.size()<<endl;

            }
    else if (b==1){

             scanf("%d",&c);
             it=s.find(c);
             if(it!=s.end()){

                printf("1\n");

            }
             else{
               printf("0\n");
            }

    }

     else if (b==2){

           scanf("%d",&c);
         
           s.erase(c);


    }

    }
    return 0;



}


Measured memory_bytes: 12520
#include <iostream>
#include <unordered_map>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

using namespace std;

int ans;
char S[105];
int N;
unordered_map<char, bool> om;

int main(void) {
    scanf("%d", &N);
    scanf("%s", S);
    
    REP(p, 0, N-1) {
    	int cnt = 0;
    	REP(i, 0, p+1) om[S[i]] = true;
    	
    	REP(i, p+1, N) if (om[S[i]]) {cnt++; om[S[i]] = false;};
    	ans = max(ans, cnt);
    	  
    }
    printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <string>

using namespace std;

set<int> st[26];

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    for(int i = 0; i < n; ++i){
        st[(int)(s[i] - 'a')].insert(i);
    }
    int q;
    cin >> q;
    for(int i = 0; i < q; ++i){
        int type;
        cin >> type;
        if(type == 1){
            int p;
            char c;
            cin >> p >> c;
            --p;
            if(s[p] == c) continue;
            st[(int)(s[p] - 'a')].erase(p);
            st[(int)(c - 'a')].insert(p);
            s[p] = c;
        }else if(type == 2){
            int l, r;
            cin >> l >> r;
            --l;
            int ans = 0;
            for(int i = 0; i < 26; ++i){
                auto it = st[i].lower_bound(l);
                if(it != st[i].end() && *it < r) ++ans;
            }
            cout << ans << "\n";
        }
    }
}

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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string N;
    cin>>N;
    
    char c=N[N.size()-1];
     

    if(c=='2' || c=='4' || c=='5' || c=='7' || c=='9'){
        cout<<"hon";    
    }
    else if(c=='1' || c=='6' || c=='8' || c=='0'){
        cout<<"pon";
    }
    else if(c=='3'){
        cout<<"bon";
    }
    cout<<"\n";
    
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int cnt = 0;
  int s = a[0];
  int flg = 0;
  rep(i,n) {
    cnt++;
    if (s == 2) {
      flg = 1;
      break;
    } else {
      s = a[s-1];
    }
  }
  if (flg) cout << cnt << endl;
  else cout << -1 << endl;
  return 0;
}

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

int main() {
  ll a, b, k;
  ll c = 0;
  cin >> a >> b >> k;
  if(k >= a) {
    cout << 0 << endl;
    cout << max(a-k + b, c) << endl;
  }
  else {
    cout << a-k << endl;
    cout << b << endl;
  }  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fr(i, p, n) for(int i = (int )p; i < (int )n; i++)
#define frn(i, p, n) for(int i = (int )p; i <= (int )n; i++)
#define rev(i, n, p) for(int i = (int )n; i >= (int )p; i--)

typedef long long int LL;
typedef pair< int, int> ii;
const int mod = 1e9 + 7;
const int mx = 1e6;
const int i27 = 1 << 27;

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
	int r, g, b;
	cin >> r >> g >> b;
	int a = r * 100 + g * 10 + b;
	if(a % 4) cout << "NO";
	else cout << "YES";
	return 0;
}

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

int main() {
	int x,h;
    while(1){
        cin>>x>>h;
        if(!x&&!h)break;
        double s=(double)x*sqrt((double)x*(double)x+4*(double)h*(double)h)+(double)x*(double)x;
        printf("%f\n",s);
    }
	return 0;
}

Measured memory_bytes: 1184
fun main(args: Array<String>) = ABC167C.main()

object ABC167C {
    fun log(message: Any?) {
        //println(message)// TODO: ←消す
    }

    data class Book(val c: Int, val a: List<Int>)

    fun main() {
        val (N, M, X) = readInts()
        val books = (1..N).map {
            val a = readInts()
            Book(c = a.first(), a = a.drop(1))
        }

        val choices = BitChoose<Book>().generate(books)
        val best = choices
            .filter { it.isNotEmpty() }
            .filter { it.isValid(X) }
            .map { it.cost() }.min()

        val ans = best ?: -1
        println(ans)
    }

    fun List<Book>.cost(): Int = this.map { it.c }.sum()
    fun List<Book>.isValid(X: Int): Boolean {
        var a = this.first().a
        this.drop(1).forEach { book ->
            a = a.mapIndexed { index, it -> it + book.a[index] }
        }
        return a.all { it >= X }
    }

    /*####################################################################################*/
    class BitChoose<T> {
        fun generate(items: List<T>): Sequence<List<T>> {
            when {
                items.isEmpty() -> return sequenceOf(listOf())
                else -> {
                    val first = items.last()
                    val remain = items.dropLast(1)
                    val base = generate(remain)
                    return base + base.map { it + first }
                }
            }
        }
    }

    fun readString() = readLine()!!
    fun readStrings() = readLine()!!.split(" ")
    fun readInt() = readLine()!!.toInt()
    fun readInts() = readLine()!!.split(" ").map { it.toInt() }
    fun readLong() = readLine()!!.toLong()
    fun readLongs() = readLine()!!.split(" ").map { it.toLong() }
    fun readMatrixRows(height: Int) = (1..height).map { readLine()!!.toList() }

    fun Boolean.yesOrNo() = if (this) "Yes" else "No"
    fun Double.toNaturalExpr() = println("%f".format(this))
}

Measured memory_bytes: 54648
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#define ll int64_t
#define REP(i, n) for (ll i=0; i<n; i++)
using namespace std;

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

    ll N;
    cin >> N;
    vector<ll> A(N), B(N-1);
    REP (i, N) cin >> A[i];

    REP (i, N-1) {
        B[i] = A[i+1] - A[i];
    }

    REP (i, N-1) {
        if (B[i] != 0) B[i] /= abs(B[i]);
    }


    ll now = 0;
    ll ans = 1;
    REP (i, N-1) {
        if (B[i] == 0) continue;
        else {
            now = B[i];
            break;
        }
    }

    REP (i, N-1) {
        if (B[i] == 0) continue;
        else {
            if (now == 0) {
                now = B[i];
            }
            else if (now * B[i] < 0) {
                ans++;
                now = 0;
            }
        }
    }

    cout << ans << "\n";
}

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

int main(void){
    
    int N,M,C,count=0;
    cin >> N >> M >> C;
    vector<int> B{};
    
    for(int i=0;i<M;i++){
        int b_i;
        cin >> b_i;
        B.push_back(b_i);
    }
    
    for(int i=0;i<N;i++){
        int sum = 0;
        for(int j=0;j<M;j++){
            int a_i;
            cin >> a_i;
            sum += (B.at(j)*a_i);
        }
        if(sum + C > 0) count++;
    }
    
    cout << count << endl;
    
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
    char c[3][3];
    for (int i=0; i<3; i++) {
        for (int j=0; j<3; j++){
            cin >> c[i][j];
        }
    }
        
    cout << c[0][0] << c[1][1] << c[2][2] << endl;
}


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

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

const long long INF = 1LL << 60;

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

  long long dp[110000];
  for (int i = 0; i < 110000; ++i) {
    dp[i] = INF;
  }
  
  dp[0] = 0;
  
  for (int i = 0; i < N; ++i) {
    chmin(dp[i + 1], dp[i] + 1);
    for (int pow6 = 6; i + pow6 <= N; pow6 *= 6) {
      chmin(dp[i + pow6], dp[i] + 1);
    }
    for (int pow9 = 9; i + pow9 <= N; pow9 *= 9) {
      chmin(dp[i + pow9], dp[i] + 1);
    }
  }
  cout << dp[N] << endl;
}

Measured memory_bytes: 4440
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
int main(void){
  int N;
  cin>>N;
  int l[N],r[N];
  for(int i=0;i<N;i++){
      cin>>l[i]>>r[i];
  }
  int sum=0;
  for(int i=0;i<N;i++){
    sum=sum+r[i]-l[i]+1;
  }
  cout<<sum;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void swap( int *a, int *b ){
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

int main( void ){
  int i,j;
  int N;
  int T[100];
  int M;
  int p, x;

  int sum = 0;

  scanf("%d", &N);
  for(i = 0; i < N; i++){
    scanf("%d", &T[i]);
  }
  scanf("%d", &M);
  for(i = 0; i < M; i++){
    scanf("%d %d", &p, &x);
    sum = 0;
    for(j = 0; j < N; j++ ){
      // printf( "T[%d] = %d ", j, T[j] );
      if( j != p-1 ){
        sum += T[j];
      }else{
        sum += x;
      }
    }
    printf( "%d\n", sum );
  }

  return 0;
}


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

typedef int64_t Int;
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int n;
    cin >> n;
    map<string, Int> mp;
    for (Int i = 0; i < (Int)n; i++) {
        string s;
        cin >> s;
        mp[s]++;
    }
    print(mp.size());
    return 0;
}

Measured memory_bytes: 19048
#include <iostream>
using namespace std;
 
void call(int n);
     
int main() {
  int n;
  cin >> n;
  call(n);
  return 0;
}
  
void call(int n) {
  int tmp;
  for (int i = 1; i <= n; i++) {
    tmp = i;
    if (i % 3 == 0) {
      cout << " " << i;
    } else {
      while (tmp > 0) {
        if (tmp % 10 == 3) {
          cout << " " << i;
          break;
        }
        tmp /= 10;
      }
    }
  }
  cout << endl;  
}

Measured memory_bytes: 1164
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }






        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var n = Read();
            var a = Reads();
            var count = new long[(long)Math.Pow(10,5)+1];
            for (int i = 0; i < n; i++)
            {
                count[a[i]]++;
            }
            long ans = 0;
            for (int i = 0; i <= (long)Math.Pow(10,5)-2; i++)
            {
                var tmp = count[i] + count[i + 1] + count[i + 2];
                ans = Math.Max(tmp, ans);
            }
            Console.WriteLine(ans);
         
            Console.Out.Flush();
        }
    }
}




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

int main() {
  int A, B;
  char op;
  cin >> A;
  cin >> op;
  cin >> B;
  if (op == '+') {
    cout << A + B << endl;
  }
  else {
    cout << A - B << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		// ??????????????£??????????´?
		int num[] = { scan.nextInt(), scan.nextInt(), scan.nextInt(), scan.nextInt(), scan.nextInt(), scan.nextInt() };
		int num2[] = { scan.nextInt(), scan.nextInt(), scan.nextInt(), scan.nextInt(), scan.nextInt(), scan.nextInt() };
		int result = check(num, num2);

		if (result == 1) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	// ?????????????????????????????¢??¨?????¢?????????????????????
	private static int check(int num[], int num2[]) {
		int top = num[0];
		int front = num[1];
		int left = num[2];
		int right = num[3];
		int back = num[4];
		int bot = num[5];

		// top????????´???????????´??????false
		boolean flg = false;
		// top?????????????¨????????????????????????¨????????????????????´???????????´??????false
		boolean flg2 = false;

		for (int count2 = 0; count2 < 2; count2++) {

			// ??????????????????????????????????????????
			for (int count = 0; count < 4; count++) {

				// num2[0](top)???????????????num[]???
				if (num2[0] == num[0]) {
					if (num2[5] == num[5]) {
						flg = true;
						break;
					}
				}

				// ?????????num1??????????¶???????????????£??????????????£??\????????¨?????´??°?????????????????????????????????????????????????????£?????????
				int x1 = num[1];
				num[1] = num[0];
				num[0] = num[4];
				num[4] = num[5];
				num[5] = x1;
			}
			// ???????¨??????¢?????????
			int x2 = num[1];
			num[1] = num[3];
			num[3] = num[4];
			num[4] = num[2];
			num[2] = x2;
		}

		// ?¨???????4????????¨????????´??????????¢??????????
		for (int count3 = 0; count3 < 4; count3++) {

			if (num2[1] == num[1]) {
				if (num2[2] == num[2]) {
					if (num2[3] == num[3]) {
						if (num2[4] == num[4]) {
							flg2 = true;
							break;
						}

					}
				}

			}

			// ???????¨??????¢?????????
			int x2 = num[1];
			num[1] = num[3];
			num[3] = num[4];
			num[4] = num[2];
			num[2] = x2;

		}
		
		

		int rs = 0;

		if (flg & flg2) {
			rs = 1;
		} else {
			rs = 0;
		}

		return rs;
	}
}

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

template <typename T> inline void rd(T& x) {
	int si = 1; char c = getchar(); x = 0;
	while(!isdigit(c)) si = c == '-' ? -1 : si, c = getchar();
	while(isdigit(c)) x = x * 10 + c - 48, c = getchar();
	x *= si;
}
template <typename T, typename... Args>
inline void rd(T& x, Args&... args) { rd(x); rd(args...); }
#define fi first
#define se second
#define mkp std::make_pair
#define V std::vector
typedef long long ll;
typedef double ff;
typedef std::pair <int, int> pii;
const int kN = 4e5 + 5, kInf = 0x3f3f3f3f;
const ll kMod = 998244353, kInfLL = 0x3f3f3f3f3f3f3f3fLL;

ll QPow(ll a, ll b) {
	ll ans = 1, bas = a;
	for(; b; b >>= 1, bas = bas * bas % kMod) if(b & 1) ans = ans * bas % kMod;
	return ans;
}

int n, m, k, q, a[kN];
int main() { 
	int T = 1; //rd(T);
	while(T--) {
		rd(n); int cnt = 0, len = 0;
		for(int i = 1; i <= n; ++i) {
			rd(a[i]);
		}
		n = std::unique(a + 1, a + n + 1) - a - 1;
		for(int i = 1; i <= n; ++i, ++len) {
			if(len >= 2 && (a[i] >= a[i - 1]) != (a[i - 1] >= a[i - 2])) {
				++cnt; len = 0;
			}
		}
		printf("%d", cnt + 1);
	} return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<set>
#include<functional>
#include<cmath>

#define Vi vector<int>
#define Vs vector<string>
#define PB push_back
#define ALL(a) a.begin(),a.end()
#define FOR(i,n) for(int i=0;i<n;i++)
#define DEB cout<<"!"
using namespace std;

typedef pair<int,int> pii;
typedef pair<int,pii> piii;

int main(){
  string s;
  cin>>s;
  int flag[] = {0,0,0,0};
  for(int i=0;i<s.length();i++)
    switch(s[i]){
    case 'N':flag[0]=1;break;
    case 'S':flag[1]=1;break;
    case 'E':flag[2]=1;break;
    case 'W':flag[3]=1;break;
    };
  if((flag[0]+flag[1])%2==0&&(flag[2]+flag[3])%2==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
S = input()

ACGT = 'ACGT'

count = []
tmp_num = 0
for i in S:
    if i in ACGT:
        tmp_num += 1
    elif i not in ACGT:
        count.append(tmp_num)
        tmp_num = 0
count.append(tmp_num)

print(max(count))

Measured memory_bytes: 9100
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

//ただの辺
struct edge {
    using lint = long long int;
    int to;
    lint cost;
    //引数一つの時は距離1
    edge(int t, lint c = 1) : to(t), cost(c) {
    }
};

// Bellman-Ford
// depend:edge
vector<lint> bellman_ford(vector<vector<edge>> g, int s) {
    using lint = long long int;
    int n = g.size();
    vector<lint> res(n, LLONG_MAX);
    res[s] = 0;
    for (int i = 0; i < 2 * n; i++) {
        for (int j = 0; j < n; j++) {
            if (res[j] == LLONG_MAX) continue;
            for (int k = 0; k < (int)g[j].size(); k++) {
                int c = g[j][k].cost, dest = g[j][k].to;
                if (i < n - 1) {
                    res[dest] = min(res[dest], res[j] + c);
                } else {
                    if (res[j] == LLONG_MIN || res[dest] > res[j] + c)
                        res[dest] = LLONG_MIN;
                }
            }
        }
    }
    return res;
}

int main() {
    int n, m, p;
    cin >> n >> m >> p;
    vector<vector<edge>> g(n);
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        g[a].push_back(edge(b, p - c));
    }
    vector<lint> dist = bellman_ford(g, 0);
    if (dist[n - 1] == LLONG_MIN) {
        cout << -1 << endl;
    } else {
        cout << max(-dist[n - 1], 0LL) << endl;
    }
}

Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;

void solve()
{
	long N, K;
	cin >> N >> K;

	int m = 50;
	vector<int> cnt(m);
	vector<long> as(N);

	for (int i = 0; i < N; i++)
	{
		cin >> as[i];
		for (int b = 0; b < m; b++)
		{
			cnt[b] += as[i]>>b&1;
		}
	}

	long mask = 0;

	for (int b = m-1; b >= 0; b--)
	{
		if ((mask | 1L<<b) <= K && cnt[b]*2 <= N)
		{
			mask |= 1L<<b;
		}
	}

	long ans = 0;

	for (long a : as)
	{
		ans += a ^ mask;
	}

	cout << ans << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <deque>
#include <numeric>
#include <sstream>
#include <iomanip>
using lint = long long;

int main()
{
    lint n;
    scanf("%lld", &n);

    std::vector<lint> a(n);
    std::vector<lint> b(n);

    lint sum = 0;

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

    for (int i = 0; i < n; ++i)
    {
        sum += a[i] - (i + 1);
        b[i] = a[i] - (i + 1);
    }

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

    if (n % 2 == 1)
    {
        lint sad = 0;
        lint med = b[n / 2];

        for (int i = 0; i < n; ++i)
        {
            sad += abs(b[i] - med);
        }
        printf("%lld", sad);
    }
    else
    {
        lint sad_floor = 0;
        lint sad_ceil = 0;

        double med = (b[n / 2] + b[n / 2 - 1]) / 2;

        lint floor = std::floor(med);
        lint ceil = std::ceil(med);

        for (int i = 0; i < n; ++i)
        {
            sad_floor += abs(b[i] - floor);
            sad_ceil += abs(b[i] - ceil);
        }

        printf("%lld", std::min(sad_floor, sad_ceil));
    }

    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
typedef  long long ll;
using namespace std;
const int maxn = 3e5 + 100;
int main() {
	ios::sync_with_stdio(0);
	ll n, m,sum=0;
	cin >> n >> m;
	for (int i = 1, x; i <= m; i++)
		cin >> x, sum += x;
	if (sum >= n)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()

a = [0]
for i in range(1,N):
    if S[i - 1 :i+1] == 'AC': a.append(a[i - 1] + 1)
    else: a.append(a[i - 1])

for i in range(Q):
    l, r = map(int, input().split())
    print(a[r - 1] - a[l - 1])


Measured memory_bytes: 6156
#include<bits/stdc++.h>
using namespace std;
const int maxn = 50;
int a[maxn], b[maxn], c[maxn];
int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		scanf("%d", a + i);
	}
	for(int i = 1; i <= n; i++){
		scanf("%d", b + i);
	}
	for(int i = 1; i < n; i++){
		scanf("%d", c + i);
	}
	long long ans = 0;
	for(int i = 1; i <= n; i++){
		ans += b[a[i]];
		if(a[i - 1] + 1 == a[i]){
			ans += c[a[i] - 1];
		}
	}
	printf("%d", ans);
	return 0;
}

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

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

    int res1 = 0, res2 = 0;
    long long res;
    for (int a=1; a<=N; a++) {
        if (a % K == 0) res1++;
    }
    res = pow(res1, 3);

    if (K % 2 == 0) {
        for (int a=1; a<=N; a++) {
            if (a % K == (K/2)) res2++;
        }
        res = pow(res1, 3) + pow(res2, 3);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a) 
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a) 
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll sum(ll n) { 
	return (1 + n) * n / 2;
}
//1から整数nまでの合計
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double sqrtNum = sqrt(a);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定

// ===============================================================

int main() {
	ll n, k;
	cin >> n >> k;
	vl a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<bool> ans(n - k);
	for (int i = 0; i < n - k; i++) {
		if (a[i + k] > a[i]) {
			ans[i] = true;
		}
		else {
			ans[i] = false;
		}
	}
	for (int i = 0; i < n - k; i++) {
		if (ans[i]) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}

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

using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin>>t;
    map<string,int> mp;
    string s;
    while(t--){
          cin>>s;
         int v = mp[s];
         mp[s] = v+1;
    }
    cout<<"AC x "<<mp["AC"]<<endl ;
    cout<<"WA x "<<mp["WA"]<<endl ;
    cout<<"TLE x "<<mp["TLE"]<<endl ;
    cout<<"RE x "<<mp["RE"]<<endl ;





    return 0;
}




Measured memory_bytes: 3664