akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i <= (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

int main()
{
	const int MOD = 1000000007;
	int N;
	cin >> N;
	int A[N];
	REP(i,N) cin >> A[i];
	int arr[N];
	REP(i,N) arr[i]=0;//ここで初期化しないといけない。
	bool error = false;
	REP(i,N){
		if(N%2 == A[i]%2){
			error = true;
			break;
		}else{
			arr[A[i]]++;
		}
	}
	long long sum = 1;
	REP(i,N){
		if(arr[0] > 1){
			error = true;
			break;
		}else if(arr[i] > 2){
			error = true;
			break;
		}else if(arr[i]!=0 && i!=0){
			sum = sum * 2 % MOD;
		}
	}
	if(error){
		cout << 0 << endl;
	}else{
		cout << sum << endl;
	}    
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,y,m,d;
  int ans;
  int Y[1000];
  cin>>n;
  for(int i=0;i<n;i++){
    ans=0;
    for(int j=0;j<1000;j++){
      if(j%3==2)Y[j]=200;
      else Y[j]=195;
    }
    cin>>y>>m>>d;
    for(int j=y-1;j<1000;j++){
      ans+=Y[j];
    }
    for(int j=1;j<m;j++){
      if(y%3==0) ans-=20;
      else if(j%2==0) ans-=19;
      else if(j%2==1) ans-=20;
    }
    for(int j=0;j<d;j++){
      ans--;
    }
    cout<<ans-194<<endl;
  }
  return 0;
}



Measured memory_bytes: 3008
S=input()
N=len(S)
M=int( (N-1)/2 )
flag=True
for i in range( M ):
  if S[i]!=S[-(i+1)]:
    flag=False
    break
  if S[i]!=S[int( (N-1)/2 ) -1 -i]:
    flag=False
    break
print("Yes") if flag else print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
const double PI = acos(-1);
using namespace std;
int main() {
    int a, b;
    string op;
    while (true)
    {
        cin >> a >> op >> b;
        if(op == "?"){
            break;
        }
        if(op == "+"){
            cout << a + b << endl;
        }
        else if( op == "-"){
            cout << a - b << endl;
        }
        else if ( op == "/"){
            cout << a / b << endl;
        }
        else{
            cout << a * b << endl;
        }
        /* code */
    }
    
}


Measured memory_bytes: 3112
# D - Brick Break
N = int(input())
A = list(map(int, input().split()))
DP = []
tmp = 0

for i in range(N):
    if A[i] == tmp +1:
        DP.append(A[i])
        tmp += 1
    else:
        pass

if len(DP) >= 1:
    print(N-len(DP))
else:
    print(-1)

Measured memory_bytes: 85748
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
//typedef __int128_t lll;
using namespace std;

bool check(string s){
  bool ret = true;
  for(int i=0;i<s.size()/2;i++) if(s[i]!=s[s.size()-1-i]) ret = false;
  return ret;
}

int main(int argc, char const *argv[]) {
  string s;std::cin >> s;
  bool f = true;
  if(!check(s)) f = false;
  string t = "", k = "";

  re(i, s.size()/2) t+=s[i];
  for(int i=(s.size()/2 + 1);i<s.size();i++) k += s[i];

  //std::cout << t << " " << k << '\n';
  if(!check(t)) f = false;
  if(!check(k)) f = false;
  std::cout << (f?"Yes":"No") << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,i,max=-100000000,min=1000001;
  long long int sum=0;
  scanf("%d",&n);
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(max<a[i]){
      max=a[i];
    }
    if(min>a[i]){
      min=a[i];
    }
    sum+=a[i];
  }
  printf("%d %d %lld\n",min,max,sum);
  return(0);
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n,m,a,b,c,d,e;
	long double z,w;
	string str;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a;
	cout<<"Christmas";
	if(a<25){cout<<" Eve";}
	if(a<24){cout<<" Eve";}
	if(a<23){cout<<" Eve";}



	cout<<endl;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ri register
#define int long long
using namespace std;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int n,m,k,p,q;
signed main()
{
    n=read(), m=read(), k=read();
    for(ri int i=1;i<=m;i++)
    {
        int x=read();
        if(x<k) p++;
        if(x>k) q++;
    }
    printf("%lld\n",min(p,q));
    return 0;
}

Measured memory_bytes: 3700
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

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

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  int N;
  std::cin >> N;
  std::vector<int> a(N);
  for (int i = 0; i < N; ++i)
    std::cin >> a[i];

  std::vector<int> res(N, 0);
  for (int i = N - 1; i >= 0; --i) {
    int k = i + 1;
    int which = 0;
    while (k <= N) {
      which += res[k - 1];
      which %= 2;
      k += (i + 1);
    }
    // std::cout << "which = " << which << std::endl;
    if (a[i] == which)
      res[i] = 0;
    else
      res[i] = 1;
  }

  int M = 0;
  for (int i = 0; i < N; ++i)
    if (res[i] == 1)
      M += 1;

  std::cout << M << std::endl;
  for (int i = 0; i < N; ++i)
    if (res[i] == 1)
      std::cout << i + 1 << std::endl;

  return 0;
}


Measured memory_bytes: 2432
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int k=sc.nextInt();
		int x=sc.nextInt();
		k *= 500;
		if(k>=x) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();
	}
}


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

#define MAXN 1000010
#define endl '\n'


using namespace std;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    int matrix[n][m];
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> matrix[i][j];
        }
    }
    int M = m;
    int b[m];
    while (M--) cin >> b[m - M - 1];
    int sum[n];
    for (int l = 0; l < n; ++l) {
        sum[l] = 0;
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            sum[i] += matrix[i][j] * b[j];
        }
    }
    for (int k = 0; k < n; ++k) {
        cout << sum[k] << endl;
    }
    return 0;
}


Measured memory_bytes: 3200
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    public static void Main()
    {
        string S = NextString();
        string _S = new string(S.Reverse().ToArray());
        int ans = 0;
        string box = "";
        char[] cs = { 'A', 'T', 'C', 'G' };
        for (int i = 0; i < S.Length; i++)
        {
            for (int j = 0; j <= S.Length - i; j++)
            {
                string a = S.Substring(i, j);
                string b = _S.Substring(i, j);
                int ac = 0;
                int bc = 0;
                cs.ToList().ForEach(c => ac += a.Count(v => v == c));
                cs.ToList().ForEach(c => bc += b.Count(v => v == c));
                if (ac == a.Length) ans = Math.Max(ans, ac);
                else if (bc == b.Length) ans = Math.Max(ans, bc);
            }
        }
        Console.WriteLine(ans);
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long H, W;
  cin >> H >> W;
  
  if (H == 1 || W == 1) {
    cout << 1 << endl;
  } else {
    cout << (H*W+1)/2 << endl;
  }    
}

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

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

int main() {
  string str;
  string button[10] = {" ", "',.!?", "abcABC", "defDEF", "ghiGHI", "jklJKL", "mnoMNO", "pqrsPQRS", "tuvTUV", "wxyzWXYZ"};
  while(getline(cin, str)) {
    char bfr;
    int cnt = 0;
    for(int i = 0; i < str.length(); i++) {
      int j;
      for(j = i+1; j < str.length(); j++) {
	if(str[j] != str[i]) {
	  break;
	}
      }
      int cnt = j-i;
      i = j-1;

      if(str[i] == '0') {
	cnt--;
	for(int k = 0; k < cnt; k++) {
	  cout << ' ';
	}
      } else {
	cout << button[charToInt(str[i])][cnt-1];
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 0
mod = 10**9 + 7
kaijotable = [0 for i in range(200100)]
kaijotable[0] = 1
for i in range(1, 200051):
    kaijotable[i] = (kaijotable[i - 1] * i) % mod

def doubling(x, y, mod):
    if y == 0:
        return 1
    if y == 1:
        return x
    elif y % 2 == 0:
        val = (doubling(x, y // 2, mod) ** 2) % mod
        return val
    else:
        val = (doubling(x, y // 2, mod) ** 2) * x % mod
        return val

def gyaku(x):
    gyaku = doubling(x, mod - 2, mod) % mod
    return gyaku

gyakutable = [0 for i in range(200100)]
gyakutable[200050] = gyaku(kaijotable[200050])
for i in range(200050, 0, -1):
    gyakutable[i - 1] = i * gyakutable[i] % mod

N,K=map(int,input().split())
A=sorted(list(map(int,input().split())))
value=0
mod=10**9 + 7
if K==1:
    print(0)
    exit()

z=0

for i in range(N):
    if i>=K-1:
        c=kaijotable[z+K-1] * gyakutable[K-1] * gyakutable[z+K-1-(K-1)] % mod
        value+=c*A[i]
        value-=c*A[N-1-i]

        z+=1
    value%=mod
print(value)


Measured memory_bytes: 87884
#include <stdio.h>

int main ()
{
	int H, A, X;
	
	scanf ("%d %d", &H, &A);
	if (H%A==0){
		printf("%d", H/A);
	}else if (H%A!=0){
		X = (H/A)+1;
		printf("%d", X);
	}
	
	return 0;
}

Measured memory_bytes: 1732
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		Stack<Integer> a = new Stack<Integer>();
		int L = s.nextInt();
		for(int i=1; i<=L; i++){
			int b = s.nextInt();
			if(b > 0){
				if(a.search(b) != -1){  //入れる時の条件判断
					System.out.println(i);
					break;
				}else{
					a.push(b);
				}
	/*2,if*/}else{
				if(a.empty() || -b != a.peek()){  //出す時の条件判断
					System.out.println(i);
					break;
				}else{
					a.pop();
				}
			}//2,else
			if(i == L){
				System.out.println("OK");
			}
		}//for
	}//main
}//class


Measured memory_bytes: 30128
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		LiningUp lu = new LiningUp();
		lu.run();
	}
}

class LiningUp {
	
	int N;
	int[] A;
	
	int[] nums;
	int MOD;
	
	LiningUp() {
		Scanner cin = new Scanner(System.in);
		this.N = cin.nextInt();
		this.A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = cin.nextInt();
		}
		
		this.nums = new int[N];
		this.MOD = (int) Math.pow(10, 9) + 7;
	}
	
	void run() {
		if (invalid()) {
			System.out.println(0);
			return;
		}
		
		long ans = pow(2, N / 2);
		System.out.println(ans);
	}

	long pow(long x, int n) {
		long ans = 1;
		while (n > 0) {
			if ((n & 1) == 1) {
				ans = ans * x % MOD;
			}
			x = x * x % MOD;
			n >>= 1;
		}
		return ans;
	}
	
	boolean invalid() {
		for (int num: A) {
			
			if (num >= N) 
				return true;
			
			if (N % 2 == 0 && num % 2 == 0)
				return true;
			
			if (N % 2 != 0 && num % 2 != 0)
				return true;
				
			nums[num]++;
			if (nums[num] > 2)
				return true;
			
			if (num == 0 && nums[num] == 2)
				return true;
				
		}
		return false;
	}
	
}


Measured memory_bytes: 31524
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    int A;
    cin >> A;
    if (A % 2 == 0 and (A % 3 != 0 and A % 5 != 0)) {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}


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

char a, b;

int main() {
    cin >> a >> b;

    if (a == 'H' && b == 'H' || a == 'D' && b == 'D') {
        cout << "H" << endl;
    }
    else {
        cout << "D" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
#define repd(i,x,y) for (int i=x; i>=y; --i)
using namespace std;

typedef long long LL;
int n,m,nxt[200100];
LL l,r,ans[26],sum[100][26],len[100];
char a[200100];

int calc(int m)
{
    int x=m-n%m;
    return (n+x)/m&1?x+m:x;
}

void solve(LL n,int w)
{
    repd(i,m,0)
        if (n>=len[i])
        {
            n-=len[i];
            repu(j,0,25)
                ans[j]+=w*sum[i][j];
        }
    repu(i,1,n)
        ans[a[i]-'a']+=w;
}

int main()
{
    scanf("%s%lld%lld",a+1,&l,&r),n=strlen(a+1)/2;
    for (int i=2,j=0; i<=n; ++i)
    {
        for (; j && a[i]!=a[j+1]; j=nxt[j]);
        nxt[i]=j+=a[i]==a[j+1];
    }
    len[m=1]=n,len[0]=n-nxt[n];
    repu(i,1,n)
    {
        ++sum[1][a[i]-'a'];
        sum[0][a[i]-'a']+=i<=len[0];
    }
    while (len[m]<r)
    {
        ++m,len[m]=len[m-1]+len[m-2];
        repu(i,0,25)
            sum[m][i]=sum[m-1][i]+sum[m-2][i];
    }
    solve(l-1,-1),solve(r,1);
    repu(i,0,25)
        printf("%lld ",ans[i]);
    return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--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 CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  ll q,h,s,d,n;
  cin>>q>>h>>s>>d>>n;
  CHMIN(h,2ll*q);
  CHMIN(s,2ll*h);
  CHMIN(d,2ll*s);
  ll ans = (n/2) * d + (n%2) * s;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#define LOCAL

#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>

using namespace std;

// From Errichto's Youtube stream
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////

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

    string S;

    cin >> S;

    int N = S.size();

    int64 result = 0;

    for (int msk = 0; msk < (1<<(N - 1)); msk++) {
        int64 at = S[0] - '0';

        for (int i = 0; i < N - 1; i++) {
            if (!(msk >> i & 1)) {
                at = at * 10 + S[i+1] - '0';
            } else {
                result += at;
                at = S[i+1] - '0';
            }
        }

        result += at;
    }

    cout << result << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_set>
#include <random>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()

int N, P;
string s;

ll modpow(ll a, ll b) {
	if (b == 0) return 1;
	if (b & 1) return modpow(a, b - 1) * a % P;
	ll half = modpow(a, b / 2) % P;
	return (half * half) % P;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> P >> s;

	reverse(all(s));
	if (P != 2 && P != 5) {
		ll tmp = 0;
		ll cnt[11000] = { 0 };
		for (int i = 0; i < s.size(); i++) {
			tmp += (s[i] - '0') * modpow(10, i);
			tmp %= P;
			cnt[tmp]++;		
		}

		ll ans = 0;
		cnt[0]++;
		for (int i = 0; i < P; i++) ans += cnt[i] * (cnt[i] - 1) / 2;
		cout << ans << '\n';
	}
	else {
		ll ans = 0;
		if (P == 2) {
			for (int i = 0; i < s.size(); i++) {
				if (s[i] == '2' || s[i] == '4' || s[i] == '6' || s[i] == '8' || s[i] == '0')
					ans += s.size() - i;
			}
		}
		else if (P == 5){
			for (int i = 0; i < s.size(); i++) {
				if (s[i] == '5' || s[i] == '0')
					ans += s.size() - i;
			}
		}
		cout << ans << '\n';
	}

	return 0;
}

Measured memory_bytes: 3836
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(l[k-1])

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    map<char,int> m;
    string S; cin >> S;
    rep(i,S.size()){
        m[S[i]]++;
    }
    int a=m['S'],b=m['N'],c=m['E'],d=m['W'];
    if((a==0 && b==0 || a*b>0)&&(c==0 && d==0 || c*d>0))
    cout << "Yes" << endl;
    else 
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int b[100005];
int main()
{
    int i,j,m,n,k;
    cin>>m;
    int count=0;
    for(i=1;i<=m;i++)
    {
        cin>>a[i];
        if(a[i]==i)
        {
            b[count++]=i;
        }
    }
    if(count==0){cout<<0<<endl;return 0;}
    //cout<<count<<endl;
    j=1;k=1;
    int s=0;
    for(i=0;i<count;i++)
    {
        if(b[i]+1==b[i+1])
        {//cout<<"haha"<<endl;
            k++;
            //j=k;//cout<<k<<endl;
        }
        else{
            if(k&1) s+=(k+1)/2;
            else s+=k/2;
            //cout<<s<<endl;
            k=1;
        }
    }
    cout<<s<<endl;
    return 0;
}

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

int d(int n){
    int res = 0;
    while(n > 0){
        n/=10;
        res++;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int res = 0;
    for (int i = 1; i <= n; ++i){
        if(d(i) % 2 == 1)res++;
    }
    cout << res << endl;
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    vvint c(3, vint(3));
    rep(i, 3) rep(j, 3) cin >> c[i][j];

    vint d(2);
    rep(i, 3) rep(j, 2)
    {
        if (i == 0)
        {
            d[j] = c[i][j + 1] - c[i][j];
        }
        else
        {
            if (d[j] != c[i][j + 1] - c[i][j])
            {
                No;
                return;
            }
        }
    }
    Yes;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 1000000000000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}

/*--------Library Zone!--------*/

struct edge
{
	int to, cost;
};
int n, q, k, d[100005];
vector<edge>G[100005];
void dijkstra() {
	prique(P) que;
	fill(d, d + n, inf);
	d[k] = 0;
	que.push({ 0,k });
	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (d[v] < p.first)continue;
		rep(i, G[v].size()) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push({ d[e.to],e.to });
			}
		}
	}
}
signed main() {
	cin >> n;
	rep(i, n - 1) {
		int fr, t, co;
		cin >> fr >> t >> co;
		G[fr - 1].push_back({ t - 1,co });
		G[t - 1].push_back({ fr - 1,co });
	}
	cin >> q >> k;
	k--;
	dijkstra();
	rep(i, q) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		cout << d[x] + d[y] << endl;
	}
	endre;
}


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

  if (k == 0) {
    cout << n*n << endl;
    return 0;
  }

  ll ans = 0;
  for (ll i = k+1; i <= n; ++i) {
    ll mul = i-k;
    ll sum = mul * ((n/i)+1);

    ll l = i*(n/i) + k;
    ll r = i*(n/i) + (i-1);
    if (n < l) {
      sum -= (r-l)+1;
    } else if (l <= n && n < r) {
      sum -= (r-n);
    }
    ans += sum;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3572
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        string S;
        cin >> S;

        int T = (S[5] - '0') * 1000 + (S[6] - '0') * 100 + (S[8] - '0') * 10 + (S[9] - '0');
        if (T <= 430)
        {
                cout << "Heisei" << endl;
        }
        else
        {
                cout << "TBD" << endl;
        }
        return 0;
}


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

int main(){
  int n;
  cin >> n;
  while(n >0){
    if(n % 4 == 0 || n % 7 == 0){
      cout << "Yes" << endl;
      return 0;
    }
    
    n -= 7;
  }
  cout << "No" << endl;
}

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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 101;

int n;
ll k;
char s[maxN];

ll res = 0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> (s + 1) >> k;
    n = strlen(s + 1);
    bool ext = false;
    fore(i, 2, n)
    {
        if (s[i] != s[i - 1])
        {
            ext = true;
            break;
        }
    }
    if (!ext)
    {
        cout << ((n * k) >> 1);
        return 0;
    }
    int c = 1;
    fore(i, 2, n)
    {
        if (s[i] == s[i - 1])
        {
            ++c;
        }
        else
        {
            res += c >> 1;
            c = 1;
        }
    }
    res += c >> 1;
    if (k > 1)
    {
        int r1 = 0, r2 = 0, d = 0;
        int c = 1;
        fore(i, 2, n)
        {
            if (s[i] == s[i - 1])
            {
                ++c;
            }
            else
            {
                r1 += c >> 1;
                d += c;
                c = 1;
                break;
            }
        }
        c = 1;
        for (int i = n - 1; i > 0; --i)
        {
            if (s[i] == s[i + 1])
            {
                ++c;
            }
            else
            {
                r2 += c >> 1;
                d += c;
                c = 1;
                break;
            }
        }
        if (s[1] == s[n])
        {
            res = (res - r1) + (res - r2) + (k - 2) * (res - r1 - r2) + (k - 1) * (d >> 1);
        }
        else
        {
            res *= k;
        }
    }
    cout << res;
    return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

void f(ll &a,ll x,ll g){
    ll d=g-x;
    if(d>0){
        ll cost=(d%2==1)?2:0;
        a+=d/2+cost;
    }
    else a+=-d;
}

int main(){
   ll a,b,c;cin >>a>>b>>c;
   ll ans=INF;
    for (int i = 0; i <=100; ++i) {
        ll now=0;
        f(now,a,i);
        f(now,b,i);
        f(now,c,i);
//        cout <<i <<" "<<now<<endl;
        ans=min(ans,now);
    }
    cout <<ans <<endl;
   return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
A=[[0]*w for i in range(h)]
for i in range(h):
  A[i]=list(map(int,input().split()))
B=[[0]*w for i in range(h)]
for i in range(h):
  B[i]=list(map(int,input().split()))
C=[[0]* w for i in range(h)]
for i in range(h):
  for j in range(w):
    C[i][j]=abs(A[i][j]-B[i][j])
dp=[[[0]*6401 for j in range(h+1)] for i in range(h+w+1)]
dp[0][0][C[0][0]]=1
for i in range(h+w):
  for j in range(max(0,i-w),min(i,h)+1):
    for k in range(6401):
      if dp[i][j][k]==1:
        if i-j<w-1:
          if k+C[j][i-j+1]<6400:
            dp[i+1][j][k+C[j][i-j+1]]=1
          dp[i+1][j][abs(k-C[j][i-j+1])]=1
        if j<h-1:
          if k+C[j+1][i-j]<6400:
            dp[i+1][j+1][k+C[j+1][i-j]]=1
          dp[i+1][j+1][abs(k-C[j+1][i-j])]=1
for k in range(6400):
  if dp[h+w-2][h-1][k]==1:
    print(k)
    exit()

Measured memory_bytes: 688776
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vl l(n), r(n);
    vector<pll> rl(n);
    for (int i = 0; i < n; ++i) {
        cin >> l[i] >> r[i];
        rl[i].second = l[i];
        rl[i].first  = r[i];
    }
    vl sortedl = l;
    vl sortedr = r;
    sort(sortedl.begin(), sortedl.end());
    sort(sortedr.begin(), sortedr.end());
    ll maxi = 0;
    for (int i = 0; i < n; ++i) {
        ll sec  = r[i] - l[i] + 1;
        ll minr = sortedr[0] == r[i] ? sortedr[1] : sortedr[0];
        ll maxl = sortedl[n - 1] == l[i] ? sortedl[n - 2] : sortedl[n - 1];
        chmax(maxi, sec + max(0LL, minr - maxl + 1));
    }
    sort(rl.begin(), rl.end());
    vl cummaxl(n), cummaxlrev(n);
    cummaxl[0]        = rl[0].second;
    cummaxlrev[n - 1] = rl[n - 1].second;
    for (int i = 1; i < n; ++i) {
        cummaxl[i] = max(cummaxl[i - 1], rl[i].second);
    }
    for (int i = n - 2; i >= 0; --i) {
        cummaxlrev[i] = max(rl[i].second, cummaxlrev[i + 1]);
    }
    for (int i = 0; i < n - 1; ++i) {
        ll temp1 = max(0LL, rl[0].first - cummaxl[i] + 1);
        ll temp2 = max(0LL, rl[i + 1].first - cummaxlrev[i + 1] + 1);
        chmax(maxi, temp1 + temp2);
    }
    cout << maxi << "\n";
    return 0;
}

Measured memory_bytes: 6528
N=int(input())
a,b,ba=0,0,0
ret = 0
for i in range(N):
  st = input()
  ret+=st.count('AB')
  if st[0]=='B' and st[-1]=='A':
    ba+=1
  elif st[0]=='B':
    b+=1
  elif st[-1]=='A':
    a+=1
if ba>0:
  ret+=ba-1
  if a>0 and b>0:
    ret+=2
    ret+=min(a-1,b-1)
  elif a==0 and b==0:
    ret+=0
  else:
    ret+=1
else:
  ret+=min(a,b)
print(ret)


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

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

#define rrep(i, s, n) for(int i = s; i > (s)-(n); i--)

#define pr(s) std::cout << s << std::endl

#define prb(s) std::cout << s

using namespace std;







int main() {

  cin.tie(0);

  ios::sync_with_stdio(false);





  string s;

  cin >> s;



  set<char> sset{s[0], s[1], s[2]};

  pr((sset.size() == 3 ? "Yes" : "No"));



  return 0;

}



Measured memory_bytes: 256
// AtCoder-Template.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second
#define FOR(i,N) for(auto i=0; i<N; ++i)
#define FORREV(i,N,_cnt) for(auto i=N-1,cnt=_cnt; cnt > 0; --i, --cnt)
#define ALL(x) x.begin(), x.end()

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T& a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T& a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
	ifstream ifs("in.txt");
	cin.rdbuf(ifs.rdbuf());
#endif
	ll N;
	string S;
	cin >> S;
	map<char, int> cnt;
	for (auto c : S) {
		cnt[c] += 1;
	}
	if (cnt['x'] >= 8) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}

	return 0;
}


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

using namespace std;

char str[200010];

int main() {
	cin >> str;
	int n = strlen(str);

	long long int ans=0, as=0;
	for(int i=0; i<n; i++) {
		if(str[i] == 'A') as++;
		else {
			if(i+1 < n) {
				if(str[i] == 'B' && str[i+1] == 'C') {
					ans += as;
					i++;
				}
				else as=0;
			}
			else as=0;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
// #define M_PI   3.14159265358979323846264338327950288
#define deb(x) cout << #x << " = " << x << '\n'
#define deb2(x, y) cout<<"("<< #x <<", "<< #y <<") = ("<<x << ", " << y << ")\n"
 
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
struct cmp{
  bool operator() (pair<int,int> const & lhs, pair<int,int> const & rhs) const
  {
    if(lhs.first != rhs.first)
     return lhs.first > rhs.first;
   return lhs.second < rhs.second;
  }
};
 
// int digsum(int pos,int n,int sum ){
 
//   if(pos == n){
//     return sum;
//   }
 
//   int s = 0;
//   for(int i=0;i<10;i++){
//     s += digsum(pos+1,n,sum+i);
//   }
 
//   return s;
// }

bool fx(int odd,int even,int rqdev){
  
  if(odd < 0)return false;
  
  while(even < rqdev){
  	rqdev--;
  	odd-=2;
  	if(odd < 0)return false;
  }

  return true;
}

int fx(int a,int b){
   
   int ans = 0;
   
   if(a/2 <= b){

    ans += a/2;

    b -= a/2;
    a -= 2*(a/2);

   }else if(a/2 >= b){
     
    ans += b;
    a -= 2*b;
    b -= b;
   }
   
  
   ans += min(b/2,a);

   return ans;
}


signed main() {
 
  FIO;

#ifndef ONLINE_JUDGE     
   freopen("input.txt", "r", stdin); 
   // freopen("output.txt", "w", stdout);  
#endif 

 int a,b;
 cin>>a>>b;
 cout<<a*b<<"\n";

  return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#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())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N;cin>>N;
  vector<ll> a(N);
  rep(i,N) cin>>a[i];

  set<ll> s;
  rep(i,N) s.insert(a[i]);
  cout<<s.size()<<endl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,m,res,m1,m2;
    cin>>n>>m;
    if(m&1){
       m1 =(m/2)+1;
       m2 = m-m1;
    }
    else
    {
       m1 =m/2;
       m2 =m/2;
    }
    if(n&1){
        res =(n/2)*(m1+m2);
        res +=m1;
    }
    else{
        res =(n/2)*(m1+m2);
    }
    if(n==1||m==1)
        res =1;
    cout<<res<<endl;
    return 0;
}


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

int main () {
	vector<int> a(3);
	for (int i = 0; i < 3; i++) cin >> a.at(i);
	
	sort(a.begin(), a.end());
	cout << a.at(2) - a.at(0) << endl;

	return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
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/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    string S;
    cin >> S;

    ll N = S.length();

    map<char, ll> M;
    REP(i, N){
        M[S[i]]++;
    }

    ll count = 0;
    priority_queue<ll> que;
    for(auto iter=M.begin(); iter!=M.end(); iter++){
        que.push(iter->second);
        count++;
    }
    
    // 処理を一度も実行できない場合
    if(count == 2){
        cout << "Second" << endl;
        return 0;
    }

    que.pop();
    que.pop();

    ll third = que.top();

    // 処理が1回だけできる場合
    // if((count == 3) && (third == 1)){
    //     cout << "First" << endl;
    //     return 0;
    // }

    if(S[0] == S[N-1]){
        if((N-3)%2 == 0){
            cout << "Second" << endl;
        }
        else{
            cout << "First" << endl;
        }
    }
    else{
        if((N-2)%2 == 0){
            cout << "Second" << endl;
        }
        else{
            cout << "First" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793
 

 struct Unionfind{
    vector<int> rank;
    Unionfind(int n){
       rank=vector<int>(n,-1);
    }
    int goroot(int x){
       if(rank.at(x)<0) return x;
       return rank.at(x)=goroot(rank.at(x));
    }
    bool unite(int x,int y){
       x=goroot(x);
       y=goroot(y);
       if(x==y)return false;
       if(rank[x] > rank[y]) swap(x,y);
       rank[x]+=rank[y];
       rank[y]=x;
       return true;
    }
    int size(int x){
       return -rank[goroot(x)];
    }

 };  
   int main(){
     int  n,m;
     cin >> n >> m;
     Unionfind Uf(n);
     rep(i,m){
        int a,b;
        cin >> a >>b;
        a-=1;
        b-=1;
        Uf.unite(a,b);
     }
   
     int ans=0;
     rep(i,n){
        ans=max(ans,Uf.size(i));
     }
     cout << ans << endl;
   } 

Measured memory_bytes: 3968
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
if(s=="Sunny")
cout<<"Cloudy";
else if(s=="Cloudy")
cout<<"Rainy";
else if(s=="Rainy")
cout<<"Sunny";
else
cout<<0;
return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
      	int k = scn.nextInt();
		int[] a = new int[n];
		for(int i=0; i<a.length; i++){
			a[i] = scn.nextInt();
		}
      	Arrays.sort(a);
      	int ans = 0;
      	for(int i=0; i<k; i++) ans+=a[i];
      	System.out.println(ans);
	}
}

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

coin = [500, 5, 100, 50, 10, 1]

ans = 0
for i in range(6):
    if i == 0:
        ans += (n // coin[i]) * 1000
    if i == 1:
        ans += (n // coin[i]) * 5
    n = n % coin[i]

print(ans)

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

signed main(void){
    int n,k; cin>>n>>k;
    if(k==1) {cout<<0<<endl; return 0;}
    else cout<<n-k<<endl;
}


Measured memory_bytes: 256
let () =
  let n = read_int () in
  let rec doit i m ans =
    if i >= n then ans
    else let r = read_int () in doit (i + 1) (min m r) (max ans (r - m))
  in
  Printf.printf "%d\n" (doit 1 (read_int ()) min_int)

Measured memory_bytes: 4436
#include <cstdio>
int d[1000000],c[1000000];
int main() {
	int i,j,r=0,n;
	for(i=2;i<=999999;i++) {
		if(d[i]){c[i]=r;continue;}
		c[i]=++r;
		for(j=i*2;j<=999999;j+=i)d[j]=1;
	}
	while(scanf("%d",&n)!=EOF) {
		printf("%d\n",c[n]);
	}
}

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

int main(){
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for(int i=0; i<s.size(); i++){
        if(s.at(i) == t.at(i) ) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
const int N = 205;
const int M = 1e7 + 5; 
using namespace std;

int lim = 10000001, n, path[N][N], l[N], r[N], cntl, cntr, vis[M], bl[N], prm[M], top, s[M]; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

bool dfs(int u)
{
	for(int i = 1; i <= cntr; i++)
		if(!vis[i] && path[u][i])
		{
			vis[i] = 1; 
			if(!bl[i] || dfs(bl[i]))
			{
				bl[i] = u; return 1; 
			}
		}
	return 0; 
}

int hungary()
{
	int cnt = 0;
	for(int i = 1; i <= cntl; i++)
	{
		for(int j = 1; j <= max(cntl, cntr); j++) vis[j] = 0; 
		if(dfs(i)) cnt++; 
	}
	return cnt; 
}

void Euler()
{
	vis[1] = 1; 
	for(int i = 2; i <= lim; i++)
	{
		if(!vis[i]) prm[++top] = i;
		for(int j = 1; i * prm[j] <= lim; j++)
		{
			vis[i * prm[j]] = 1; 
			if(i % prm[j] == 0) break; 
		}
	}
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin); 
#endif
	Euler();
	n = read <int> ();
	for(int x, i = 1; i <= n; i++) x = read <int> (), s[x] = 1;
	for(int i = 1; i <= lim; i++)
		if(s[i] != s[i - 1])
		{
			if(i & 1) l[++cntl] = i; 
			else r[++cntr] = i; 
		}
	for(int i = 1; i <= cntl; i++)
		for(int j = 1; j <= cntr; j++)
			if(!vis[l[i] - r[j] > 0 ? l[i] - r[j] : r[j] - l[i]])
				path[i][j] = 1; 
	int tmp = hungary(), ans = tmp;
	cntl -= tmp, cntr -= tmp, ans += cntl / 2 * 2, cntl %= 2, ans += cntr / 2 * 2, cntr %= 2;
	if(cntl && cntr) ans += 3;
	printf("%d\n", ans); 
	return 0; 
}


Measured memory_bytes: 45916
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
//以上テンプレ

int main(){
    ll N;
    cin>>N;
    vector<vl> dp(N+1,vl(3,-1*INF));
    vector<vl> a(N,vl(3));
    rep(i,N){
        rep(j,3){
            cin>>a.at(i).at(j);
        }
    }
    rep(i,3) dp.at(0).at(i)=0;
    for(ll i=1;i<N+1;i++){
        chmax(dp.at(i).at(0),dp.at(i-1).at(1)+a.at(i-1).at(0));
        chmax(dp.at(i).at(0),dp.at(i-1).at(2)+a.at(i-1).at(0));
        chmax(dp.at(i).at(1),dp.at(i-1).at(0)+a.at(i-1).at(1));
        chmax(dp.at(i).at(1),dp.at(i-1).at(2)+a.at(i-1).at(1));
        chmax(dp.at(i).at(2),dp.at(i-1).at(0)+a.at(i-1).at(2));
        chmax(dp.at(i).at(2),dp.at(i-1).at(1)+a.at(i-1).at(2));
    }
    rep(i,2){
        chmax(dp.at(N).at(2),dp.at(N).at(i));
    }
    cout<<dp.at(N).at(2)<<endl;
}


Measured memory_bytes: 11136