akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;

int GCD(int a, int b) {
	int A = 0, B = 0;
	if (a == max(a, b)) {
		A = a;
		B = b;
	}
	else {
		A = b;
		B = a;
	}
	if (A == B) return A;
	else return GCD(B, A - B);
	return -1;
}

int main()
{
	int a, b;
	while (cin >> a >> b ) {
		int gcd = GCD(a, b);
		int lcm = a / gcd*b;
		cout << gcd << " " << lcm << endl;
	}
    return 0;
}

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

int main() {
  ostringstream oss;
  int n, m, flag=0, sum=0;
  cin >> n >> m;
  vector<int> vec(n); //-1で初期化
  for (int i = 0; i < n; i++) {vec.at(i) = -1;}
  
  for (int i = 0; i < m; i++) {
    int s,c;
    cin >> s >> c;
    if (vec.at(s-1) == -1 || vec.at(s-1) == c) {
      vec.at(s-1) = c;
    }else{
      flag = -1;
      cout << -1;
      break;
    }
  }
  if (n > 1 && vec.at(0) == -1) {
    vec.at(0) = 1;
  }
  for (int i = 0; i < n; i++){
    if (vec.at(i) > 0){
      sum += vec.at(i) * pow(10 , n-i-1);
    }
  }
  if (n > 1 && vec.at(0) == 0){
    flag = -1;
    cout << -1;
  }else if (flag == 0){
    cout << sum;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <ios>     // std::left, std::right
#include <iomanip> 
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;

int main(){
    int N;cin>>N;
    vector<string>W(N);
    map<string, int>count;
    REP(i,N) cin>>W[i];
    int start = 1;
    char last;
    REP(i,N){
        if(count[W[i]]>=1){
            cout<<"No";
            return 0;
        }
        count[W[i]]++;
        if(start == 1){
            start = 0;
            last = W[i][W[i].size()-1];
            continue;
        }
        if(last == W[i][0]){
            last =  W[i][W[i].size()-1];
        }else{
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
bool cmp(int i,int j)
{
return i>j;}
int main(){
int a[2],maxx,k=0;
for (int i=0;i<3;i++)
cin>>a[i];
cin>>k;
sort(a,a+3,cmp);
maxx=a[0];
if (k==1)
cout<<a[1]+a[2]+maxx*2<<endl;
if (k==2)
cout<<a[1]+a[2]+maxx*4<<endl;
if (k==3)
cout<<a[1]+a[2]+maxx*8<<endl;
if (k==4)
cout<<a[1]+a[2]+maxx*16<<endl;
if (k==5)
cout<<a[1]+a[2]+maxx*32<<endl;
if (k==6)
cout<<a[1]+a[2]+maxx*64<<endl;
if (k==7)
cout<<a[1]+a[2]+maxx*128<<endl;
if (k==8)
cout<<a[1]+a[2]+maxx*256<<endl;
if (k==9)
cout<<a[1]+a[2]+maxx*512<<endl;
if (k==10)
cout<<a[1]+a[2]+maxx*1024<<endl;
system("pause");
return 0;
}

Measured memory_bytes: 504
def main():
    n = int(input())
    a = list(map(int, input().split()))
    print(resolve(a))

def resolve(a):
    cnt = 0
    base = 0
    skip = 0

    for i in range(len(a)):
        c, base = resolve_1(a, i, skip, base)

        skip = c - 1
        base = base ^ a[i]
        cnt += c

    
    return cnt

def resolve_1(a, i, skip, base):
    cnt = skip

    for j in range(i + skip, len(a)):
        if a[j] & base != 0:
            break
        
        cnt += 1
        base |= a[j]

    return (cnt, base)

main()

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(num) scanf("%d",&num)
#define sff(num1,num2) scanf("%d %d",&num1,&num2)
#define sfff(num1,num2,num3) scanf("%d %d %d",&num1,&num2,&num3)
#define sl(num) scanf("%lld",&num)
#define sll(num1,num2) scanf("%lld %lld",&num1,&num2)
#define slll(num1,num2,num3) scanf("%lld %lld %lld",&num1,&num2,&num3)
#define rep(i,n) for(i=1;i<=n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define pb push_back
#define mpp make_pair
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
#define TIME cerr<<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<"s\n";
typedef long long int ll;
using namespace std;
int main()
{
    FAST;
    int i,n;
    cin>>n;
    string a;
    vector<string>vec;
    rep0(i,n)
    {
        cin>>a;
        sort(all(a));
        vec.pb(a);
    }
    sort(all(vec));
    ll sum=0,cnt=0;
    rep(i,vec.size()-1)
    {
        //dbb(vec[i],vec[i-1]);
        if(vec[i]==vec[i-1])
        {
            cnt++;
            sum+=cnt;
            //db(cnt);
        }
        else
            cnt=0;
    }
    cout<<sum;
}


Measured memory_bytes: 5748
#![allow(dead_code)]

use std::io;
fn main() {
    solve_b();
}

fn solve_b() {
    loop {
        let mut line = String::new();
        io::stdin().read_line(&mut line).unwrap();
        if line.trim() == "0" {
            break;
        }
        let mut count = 0;
        for c in line.trim().chars() {
            count += c.to_digit(10).unwrap();
        }
        println!("{}", count);
    }
}



Measured memory_bytes: 5036
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std ;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define rep(i,a,b) for(int i=a; i<=b; i++)
#define per(i,b,a) for(int i=b; i>=a; i--)
#define sz(v) (int)v.size()
#define len(s) (int)s.length()
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
typedef pair<int, int> pi ;
typedef vector<pair<int,int> > vpi ;
typedef vector<int> vi ;
typedef long long ll ;
typedef double db ;
typedef long double ldb ;
const int mod = 1e9 + 7;
const int cmod = 998244853 ;
const ll inf = 1e18 + 5;
const db cpi = 3.14159265358 ;
ll powmod(ll a, ll b) { ll ret = 1 ; while(b) { if(b&1) ret = (ret*a)%mod ;  a = (a*a)%mod ; b >>= 1 ; }  return ret ; }
const int maxn = 1e6 + 5;
string s ;
int cnt[30] ;
int main()
{
    ios::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    cin >> s ;
    ll res = 1 ;
    int n = len(s) ;
    rep(i,0,n-1)
    {
        int x = int(s[i] - 'a') ;
        cnt[x]++ ;
    }
    rep(i,0,n-1)
    {
        int x = int(s[i] - 'a') ;
        rep(j,0,25)
        {
            if(j == x) continue ;
            res += cnt[j] ;
        }
        cnt[x]-- ;
    }
    cout << res << "\n" ;
    return 0 ;
}


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



int main(){
    int N;

    cin >> N;
    std::vector<int> seq(N);
    for(int i=0; i < N; i++){
        cin >> seq.at(i);
    }
    std::vector<int> copy;
    copy = seq;
    sort(copy.begin(), copy.end(),std::greater<int>() );
    int f, s;
    f = copy.at(0);
    s = copy.at(1);
    for(int i=0; i < N; i++){
        if(seq.at(i)==f){
            cout << s << endl;
        }else{
            cout << f << endl;
        }
    }
    return 0;


}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
typedef long long ll;

ll gcd(ll x, ll y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a;
    rep(i, n){ int tmp; cin >> tmp; a.push_back(tmp);}

    int lcm_sum = a[0]/2;
    rep(i, n-1){
        lcm_sum = lcm(lcm_sum, a[i+1]/2);
    }
    int flag = 0;
    rep(i, n){
        if ((lcm_sum / (a[i]/2)) % 2 == 0) flag = 1;
    }
    if (flag){
        cout << "0" << endl;
    } else {
        int ans = 0;
        if (m >= lcm_sum){
            ans = 1 + (m - lcm_sum)/(lcm_sum*2);
        }
        cout << ans << endl;
    }
}


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

typedef long long int ll;

int main()
{
	ll n,k;
	scanf("%lld %lld",&n,&k);
	ll sum=n%k;
	ll count=k-sum;
	if(sum>count)
		printf("%lld\n",count);
	else
		printf("%lld\n",sum);
}


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

int dp[10009][1009], n, h, b[1009], a[1009], MAX;
bool solved[10009][1009];

int f(int32_t h, int32_t i) {
    if(h <= 0)
        return 0;
    if(i == n + 1)
        return MAX;
    if(solved[h][i])
        return dp[h][i];
    solved[h][i] = 1;
    return dp[h][i] = min(f(h - a[i], i) + b[i], f(h, i + 1));
}

int32_t main() {
    cin >> h >> n;
    MAX = ((int64_t(1) << 63) - 1ll);
    for(int i = 1; i <= n; i++)
        cin >> a[i] >> b[i];
    cout << f(h, 1) << '\n';
}


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

int main() {
  int s1s2s3;
  cin >> s1s2s3;
  cout << s1s2s3 / 100 + s1s2s3 % 100 / 10 + s1s2s3 % 100 % 10 / 1 << endl;
}


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

double T, X;

int main(){
  cin >> T >> X;
  cout << fixed << setprecision(10);
  cout << T / X << endl;
}


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

int main()
{
    int N, K;
    cin >> N >> K;
    int h[N];
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
    }

    sort(h, h + N);

    int ans = 999999999;
    for (int i = 0; i < N - K + 1; i++)
    {
        ans = min(h[i + K - 1] - h[i], ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdio.h>
using namespace std;

int main(){
    int n;
    cin>>n;
    char c[n];
    int i, j;
    int ans = 0;
    for(i=0; i<n; i++){
        cin>>c[i];
        if(c[i]=='Y'){
            ans++;
        }
    }
    if(ans>0){
        cout<<"Four"<<endl;
    }
    else{
        cout<<"Three"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp fixed << setprecision
#define pb(x) push_back(x)
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

//aとbの最大公約数
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}

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

//ax+by=cの整数解(x,y)のうちの一つ
pll extgcd(ll a, ll b, ll c){
    if(b == 0){
        return pll(c/a, 0);
    }
    else{
        pll p = extgcd(b, a%b, c);
        ll x = p.second, y = p.first;
        return pll(x, y-(a/b)*x);
    }
}

int N;

//judge(v):=配列の状態がvであるときに手番で勝てるなら1,負けるなら0
int judge(vector<int> v){
    int g = v[0];
    for(auto &e: v) g = gcd(g, e);
    for(auto &e: v) e /= g;
    int cnt = 0, sum = 0;
    for(auto &e: v) sum += e, cnt += e&1;
    if(sum%2 == 0){
        if(N%2 == 0) return 0;
        else return 1;
    }
    else{
        if(N%2 == 0) return 1;
        elif(cnt > 1) return 0;
        else{
            for(auto &e: v){
                if(e == 1) return 0;
                if(e&1) e--;
            }
            return judge(v)^1;
        }
    }
}

int main(){
    cin >> N;
    vector<int> v(N);
    rep(i, N) cin >> v[i];
    if(judge(v)) cout << "First" << endl;
    else cout << "Second" << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<ll>asum(n);
  rep(i,n){
    int a;
    cin >> a;
    if(i != 0) asum[i] = asum[i-1];
    asum[i] += a;
  }
  ll m = 1e18;
  for(int i = 0;i <= n;i++){
    m = min(m,abs(asum[n-1]-2*asum[i]));
  }
  cout << m << endl;
}

Measured memory_bytes: 1920
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"
 
#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
typedef long long ll;
using namespace std;
int n,mem,cnt;
ll ans;
bool b;
map<int,bool>mp;
int main(){
	cin>>n;
	lp(n){
		cin>>mem;
		mp[mem]=true;
	}
	lp(n){
		cin>>mem;
		mp[mem]=false;
	}
	ans=1;
	cnt=0;
	for(auto it=mp.begin();it!=mp.end();it++){
		if(cnt==0)b=it->second;
		if(b==it->second)cnt++;
		else {
			ans*=cnt;
			cnt--;
		}
		ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v){
    is >> e;
  }
  return is;
}

int main(){
  int n; cin >> n;
  int sum = 0;
  int x=0;
  for(int i = 1; i <= n; ++i){
    sum += i;
    if(sum >= n){
      x = i; 
      break;
    }
  }
  for(int i = 1; i <= x; ++i){
    if(i != sum - n)cout << i << endl;
  }
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  for (int i = K; i < N; i++) {
    if (A[i - K] < A[i]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 4852
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<58;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

string s;

int main(){
	cin>>s;
	cout<<s.substr(0,s.size()-8)<<endl;
}

Measured memory_bytes: 764
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main(){

  ll r, D, x;
  cin >> r >> D >> x;

  for(int i=0;i<10;i++){
    x = r*x - D;
    cout << x <<endl;
  }

  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
int main()
{
    int A,B,C,D;

    
    scanf("%d %d %d %d", &A,&B,&C,&D);
    
    if (A*B > C*D)
    
    {
        printf ("%d",A*B);
    }
    
    else if (A*B < C*D)
    
    {
        printf ("%d",C*D);
    }
    
    else
    {
        printf ("%d",A*B);
    }
    
    
 
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int n;
    cin >> n;
    vector<int> a(n+2);
    //aの[0]と[n+1]は0のままで1〜nまでに代入する
    for(int i=1; i<=n; i++){
        cin >> a[i];
    }

    //sumは全てを回ったときの料金
    int sum=0;

    //0から始まって0に戻るのでループを0からn+1にしている
    for(int i=0; i<=n+1; i++){
        cin >> a[i];
        sum += abs(a[i]-a[i+1]);
    }

    for(int i=1; i<=n; i++){
        int dif = abs(a[i]-a[i-1]) + abs(a[i+1]-a[i]) - abs(a[i+1]-a[i-1]);
        int ans = sum - dif;
        cout << ans << endl;
    }
    return 0;



}

Measured memory_bytes: 3784
// AOJ 1021
#include<iostream>
#include<vector>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

const int LMAX = 1000;

vector<string> lines;
int h, w;
string buffer;

bool on_tail() { return w == lines[h].size(); }
void goto_tail() { w = lines[h].size(); }
bool on_eof() { return h >= lines.size() - 1; }
void remove_line(int n) { lines.erase(lines.begin() + n); }
void remove_char(int h, int w) {
  lines[h].erase(lines[h].begin() + w);
}

void a() { w = 0; }
void e() { goto_tail(); }
void p() { h = max(h - 1, 0); w = 0; }
void n() { h = min(h + 1, (int)lines.size() - 1); w = 0; }
void f() {
  if (not on_tail()) { w++; }
  else if (not on_eof()) {
    h++; w = 0;
  }
}
void b() {
  if (w > 0) { w--; }
  else if (h > 0) { h--; goto_tail(); }
}
void d() {
  if (on_tail() and !on_eof()) {
    lines[h] += lines[h + 1];
    remove_line(h + 1);
  } else if (not on_tail()) {
    remove_char(h, w);
  }
}
void k() {
  if (on_tail() and !on_eof()) {
    d();
    buffer = "\n";
  } else if (not on_tail()) {
    buffer = lines[h].substr(w);
    lines[h] = lines[h].substr(0, w);
  }
}
void y() {
  if (buffer == "\n") {
    string temp = lines[h].substr(w);
    lines[h] = lines[h].substr(0, w);
    lines.insert(lines.begin() + h + 1, temp);
    h++; w = 0;
  } else if (not buffer.empty()) {
    lines[h].insert(lines[h].begin()+w, buffer.begin(), buffer.end());
    w += buffer.size();
  }
}

int main() {
  string l;
  buffer = "";
  while (getline(cin, l) and l != "END_OF_TEXT") {
    lines.push_back(l);
  }

  char com;
  while (cin >> com and com != '-') {
    switch (com) {
    case 'a':
      a(); break;
    case 'e':
      e(); break;
    case 'p':
      p(); break;
    case 'n':
      n(); break;
    case 'f':
      f(); break;
    case 'b':
      b(); break;
    case 'd':
      d(); break;
    case 'k':
      k(); break;
    case 'y':
      y(); break;
    default:
      break;
    }
/*    REP(i, lines.size()) {
      cout << ">" << lines[i] << endl;
    }
    cout << "(" << h << "," << w << ")" << endl;
*/  }

  for (int i = 0; i < lines.size(); i++) {
    cout << lines[i] << endl;
  }
}

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

int main(){
  int n, tE=0, tW=0, ret=1000000;
  string str;
  cin >> n >> str;
  for(int i=1; i<n; i++){
    if(str[i]=='E')tW++;
  }
  ret = min(ret, tW+tE);
  for(int i=1; i<n; i++){
    if(str[i]=='E')tW--;
    if(str[i-1]=='W')tE++;
    ret = min(ret, tW+tE);
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 900
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim_right().parse().ok().unwrap()
}
fn main() {
    let A: u32 = read();
    let B: u32 = read();
    println!("{}", 6 - A - B);
}


Measured memory_bytes: 4352
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X, N;
    cin >> X >> N;
    ll A[N];
    REP(i, 0, N) {
        cin >> A[i];
    }
    bool end = false;
    REP(i, 0, N + 1) {
        REP(j, 0, 2) {
            ll y = -1;
            if (j == 1) {
                y = 1;
            }
            ll z = X + y * i;
            bool ok = false;
            REP(i, 0, N) {
                if (A[i] == z) {
                    ok = true;
                    break;
                }
            }
            if (!ok) {
                cout << z << endl;
                end = true;
                break;
            }
        }
        if (end) {
            break;
        }
    }
}


Measured memory_bytes: 3652
#pragma GCC optimize ("-O3")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ");
//#define double long double

template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int MAX = 200060;
const double pi = acos(-1);
const ll INF = 1e16;


void solve() {
	int N; cin >> N;
	vector<int>A(N);
	REP(i, N)cin >> A[i];
	sort(all(A));
	ll ans = 0;
	REP(i, N - 2) {
		FOR(j, i + 1, N - 1) {
			FOR(k, j + 1, N) {
				if (A[i] + A[j] <= A[k])break;
				if (A[i] < A[j] + A[k] && A[j] < A[i] + A[k] && A[k] < A[i] + A[j])ans++;
			}
		}
	}
	print(ans);
}


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

	solve();
}


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


int main(){
    long long n,k;
    cin >> n >> k;
    long long a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
        a[i]--;
    }
    vector<int> num;
    set<int> S;
    num.push_back(0);
    S.insert(0);
    int front = a[0];
    while(1){
        num.push_back(front);
        S.insert(front);
        if(S.size()!=num.size()){
            break;
        }
        front = a[front];
    }
    if(k<=S.size()){
        cout << num[k]+1 << endl;
    }else{
        int i=0;
        while(1){
            if(num[i]==front) break;
            i++;
        }
        
        int loop = num.size()-i-1;
        k -= i;
        k%=loop;
        cout << num[i+k]+1 << endl;
    }
}

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

typedef long long ll;
typedef long double ld;

ll a[200007];
int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int n;
	scanf("%d", &n);
	ll s = 0;
	for (int i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
		s += a[i];
	}
	ll res = abs(a[0] - (s - a[0]));
	ll ss = 0;
	for (int i = 0; i < n - 1; i++) {
		ss += a[i];
		res = min(res, abs(ss - (s - ss)));
	}
	cout << res << endl;
}



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

int main(void){
    int n,m;  
    cin >> n >> m;

    if(n == 1 && m == 1 ){
        cout << 0 << endl;
    }else if(n == 0){
        cout << m * (m - 1) / 2 << endl;
    }else if(m == 0){
        cout << n * (n - 1) / 2 << endl;
    }else{
        cout << m * (m - 1) / 2 + n * (n - 1) / 2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////



int main(){
    ll h,n;
    cin >> h >> n;
    ll c = 0;
    rep(i,0,n){
	ll a;
	cin >> a;
	c += a;
    }
    
    if(h <= c)Yes;
    else No;
		  
    return  0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long double PI=3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
inline long long read() {
	long long x=0,f=0;char ch=getchar();
	while(!isdigit(ch))f|=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
	return f?-x:x;
}
int main(){
    long long n=read(),a=read(),b=read();
    if(n<=a){cout<<"1\n";return 0;}
    if(b>=a){cout<<"-1\n";return 0;}
	cout<<(long long)ceil((long double)(n-a)/(a-b))*2+1<<"\n";
    return 0;
}

Measured memory_bytes: 256
//Date : 01 - 07 - 18  //Author:Rishabh Paul

#include<bits/stdc++.h>
using namespace std;

// int main() {
// 	int n;
// 	cin >> n;
// 	if(n % 2 == 0)	printf("%d" ,n);
// 	else printf("%d" ,n*2);
// 	return 0;
// }

int main() {
	int n;
	cin >> n;
	std::vector<int> a(n);
	for(int i = 0 ; i < n ; i++)	cin >> a[i];
	sort(a.begin() ,a.end());
	cout << a[n - 1] - a[0] << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
int n;
string s;
bool ok=true;
int main(void){
	cin>>n;
	if(n%2!=0)ok=false;
	cin>>s;
	for(int i=0;i<n/2;i++){
		if(s[i]!=s[n/2+i])ok=false;
	}
	if(ok)cout<<"Yes\n";
	else cout<<"No\n";
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
	int n,k;
	scanf("%d%d",&n,&k);
	long long ans=k;
	for(int i=1;i<n;i++)ans *= (k-1);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#define INF 1<<29
#define LL long long
#define ek()(putchar('\n'))
#define sk()(putchar(' '))
#define WY()(putchar('Y'),putchar('e'),putchar('s'),ek())
#define WN()(putchar('N'),putchar('o'),ek())
#define MAXN 15
#define MAXSTATE 1<<15 
using namespace std;
inline int Read(){
	int X=0,flag=1;char ch=0;
	while (ch<'0'||ch>'9'){
		if (ch=='-') flag=-1;
		ch=getchar();
	}
	while (ch>='0'&&ch<='9')
	  X=(X<<3)+(X<<1)+ch-48,ch=getchar();
	return X*flag;
}
inline void Write(int x){
	if (x<0) x=-x,putchar('-');
	if (x>9) Write(x/10);
	putchar(x%10+48);
}
int n,m;
int dis[MAXN+1][MAXN+1];
int exc[MAXSTATE+5];
int p[MAXSTATE+5];
int DP[MAXSTATE+5][MAXN+1];
int lowbit(int x){
	return x&(-x);
}
int main(){
	n=Read(),m=Read();
	for (int i=0;i<n;i++)
	  exc[1<<i]=i;
	int sum=0;
	for (int i=1;i<=m;i++){
		int x=Read()-1,y=Read()-1;
		sum+=dis[x][y]=dis[y][x]=Read();
	} 
	for (int s=0;s<(1<<n);s++){
		int x=s;
		int tmp=lowbit(x);
		int now=exc[tmp];
		x-=tmp;
		p[s]=p[x];
		for (;x;x-=lowbit(x)){
			int y=exc[lowbit(x)];
			p[s]+=dis[now][y];
		}
	}
	for (int i=0;i<(1<<n);i++)
	  for (int j=0;j<n;j++)
	    DP[i][j]=-INF;
	DP[1][0]=0;
	int ans=0;
	for (int s=0;s<(1<<n);s++){
		for (int x=s;x;x-=lowbit(x)){
			int tmp=lowbit(x);
			for (int st=s;st;st=(st-1)&s)
			  if ((st&tmp)&&DP[(s-st)|tmp][exc[tmp]]!=-INF)
			  	DP[s][exc[tmp]]=max(DP[s][exc[tmp]],DP[(s-st)|tmp][exc[tmp]]+p[st]);   
			for (int j=1;j<=n;j++)
			  if (!(s&(1<<j))&&dis[exc[tmp]][j]&&DP[s][exc[tmp]]!=-INF)
			    DP[s|(1<<j)][j]=max(DP[s|(1<<j)][j],DP[s][exc[tmp]]+dis[exc[tmp]][j]);
		}
		if ((s&(1<<n-1))&&DP[s][n-1]!=-INF) ans=max(ans,DP[s][n-1]); 
	}  
	
	Write(sum-ans);ek();
	return 0;
}

Measured memory_bytes: 8448
#include <stdio.h>

#define abs(a) ((a)>0 ? (a) : -(a) )

int main(){
    int K, N, i;
    scanf("%d%d", &K, &N);
    int A[N+1];
    for(i=0; i<N; i++){
        scanf("%d", A+i);
    }
    A[N] = K + A[0];
    int max = 0, buf;
    for(i=0; i<N; i++){
        buf = abs(A[i]-A[i+1]);
        max = max<buf ? buf : max ;
    }
    printf("%d\n", K-max);
    return 0;
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

inline bool isAlpha(char c){ return 'A' <= c && c <= 'Z'; }

string parse(string & str, int & pos){
    string ret;

    while(pos < str.size() && str.at(pos) != ']'){
        if(str.at(pos) == '['){
            pos++;

            string diff = parse(str, pos);
            reverse(all(diff));
            ret += diff;

            pos++;
        }
        else {
            ret.pb(str.at(pos));
            pos++;
        }
    }

    return ret;
}

vs strs;

void dfs(string str){
    bool ok = true;

    for(char & c : str){
        if(c != '?') continue;

        ok = false;
        rep(i, 26){
            c = 'A' + i;

            dfs(str);
        }
    }

    if(!ok) return;

    string s;
    int delta = 0;
    for(char c : str){
        if(c == '+') delta++;
        else if(c == '-') delta--;
        else {
            if(isAlpha(c)) s.pb((c - 'A' + delta + 26 * 10) % 26 + 'A');
            else s.pb(c);

            delta = 0;
        }
    }

    strs.pb(s);
}

int main(void){
    for(string str; cin >> str, str != ".";){
        
        //アルファベットを埋めて禅探索
        strs = vs();
        dfs(str);

        string res;
        rep(i, 1000) res.pb('Z');
        
        for(auto cur : strs){
            int pos = 0;
            res = min(res, parse(cur, pos));
        }

        cout << res << endl;
    }

	return 0;
}

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

using namespace std;


int main(){
  int A, B;
  cin >> A >> B;
  
  if(A==1){
    if(B==2) cout << 3 << endl;
    else if(B==3) cout << 2 << endl;
  }else if(A==2){
    if(B==1) cout << 3 << endl;
    else if(B==3) cout << 1 << endl;
  }else if(A==3){
    if(B==1) cout << 2 << endl;
    else if(B==2) cout << 1 << endl;
  }
  

  return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <iomanip>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  ll i = 0;
  for (auto x : v) {os << " [" << i++ << "]" << x; if (i % 10 == 0) os << std::endl;}
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp) {os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }



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

  ll X, Y;
  std::cin >> X >> Y;

  if (X % Y == 0) {
    print(-1);
    return 0;
  }

  print(X);
  return 0;
}


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

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    for (auto i = 0; i <= n; i++) {
        for (auto j = 0; j <= m; j++) {
            if ((m - j) * i + (n - i) * j == k) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <map>           // sorted map so O(logn)
#include <unordered_map> // O(1)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
using namespace std;

int main()
{
    int x;
    cin >> x;
    int s = 0;
    if (x >= 500)
    {
        s += (x / 500) * 1000;
        x %= 500;
    }
    if (x >= 5)
    {
        s += (x / 5) * 5;
        x %= 5;
    }
    cout << s << endl;
}

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

struct Graph{
	vector<vector<int>> fld;
	
	Graph(int h,int w) : fld( h,vector<int>(w) ){}
	
	void dfs(int x, int y){
		
		fld.at(x).at(y) = 2;
		for(int i=-1; i<=1; i++){
			for(int j=-1; j<=1; j++){
				int h = fld.size();
				int w = fld.at(0).size();
				if(x+i<0||h-1<x+i||y+j<0||w-1<y+j) continue;
				if(fld.at(x+i).at(y+j)!=1) continue;
				dfs(x+i,y+j);
			}
		}
		return;
	}
	
};

int main() {
	while(1){
		int w,h;
		cin >> w >> h;
		if(w==0&&h==0) break;
		
		Graph graph(h,w);
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				int s;
				cin >> s;
				graph.fld.at(i).at(j) =  s;
			}
		}
		
		int cnt{};
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				if(graph.fld.at(i).at(j)==1) {
					graph.dfs(i,j);
					cnt++;
				}
				
			}
			
		}
		cout << cnt << endl;
	}
	
}


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

int main()
{
    int x;
    cin >> x;
    if (x == 2)
    {
        cout << "2\n";
        return 0;
    }
    if (!(x & 1))
        x++;
    bool is_prime = true;
    while (x < 1e8)
    {
        for (int i = 3; i * i <= x; i += 2)
        {
            if (x % i == 0)
            {
                is_prime = false;
                break;
            }
        }
        if (is_prime)
            break;

        is_prime = true;
        x += 2;
    }
    cout << x << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (typeof((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(typeof(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}

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

bool isexist[30][30];
bool seen[30][30];
int N, M;

int main() {
    //freopen( "/Users/macuser/Documents/Programming/Contest/input.in", "r", stdin );
    
    while (cin >> N) {
        if (N == 0) break;
        
        memset(isexist, 0, sizeof(isexist));
        memset(seen, 0, sizeof(seen));
        
        for (int i = 0; i < N; ++i) {
            int x,y;
            cin >> x >> y;
            isexist[x][y] = true;
        }
        cin >> M;
        
        int x = 10, y = 10;
        seen[x][y] = true;
        for (int i = 0; i < M; ++i) {
            char c; int dis, dir;
            cin >> c >> dis;
            if (c == 'N') dir = 1;
            if (c == 'E') dir = 0;
            if (c == 'W') dir = 2;
            if (c == 'S') dir = 3;
            for (int j = 0; j < dis; ++j) {
                x += dx[dir];
                y += dy[dir];
                seen[x][y] = true;
            }
        }
        bool iscomp = true;
        for (int i = 0; i <= 20; ++i) {
            for (int j = 0; j <= 20; ++j) {
                if (isexist[i][j] && !seen[i][j]) {
                    iscomp = false;
                }
            }
        }
         
        if (iscomp) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1152
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int N;
std::string S[112345], T;
int l, r;

int main()
{
	in >> N;
	rep(i, N) { in >> S[i]; }
	in >> T;

	rep(i, N)
	{
		std::string a, z;
		a = z = S[i];
		rep(j, S[i].length())
		{
			if (S[i][j] == '?')
			{
				a[j] = 'a';
				z[j] = 'z';
			}
		}
		if (T < a) { ++r; }
		else if (z < T) { ++l; }
	}

	for (int i = l + 1; i <= N - r; ++i) { out << i << " "; }
	out << N - r + 1 << std::endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int rating = sc.nextInt();
        if (rating < 1200)
            System.out.println("ABC");
        else if (rating >= 1200 && rating < 2800)
            System.out.println("ARC");
        else
            System.out.println("AGC");
    }
}


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

int main(){

  string s;
  cin>>s;
  
  if(s[2]==s[3] && s[4]==s[5])cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

}

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

string reverse(string s);

int main(){
    string str;

    cin >> str;

    cout << reverse(str) << endl;

    return 0;
}

string reverse(string s){
    if(s.length() == 0){
        return "";
    }
    string sub = s.substr(1);

    return reverse(sub) + s.substr(0,1);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


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

int n;
cin >> n;
vl a(n),b(n);
rep(i,n) cin >> a[i] >> b[i];

sort(all(a));
sort(all(b));

if(n % 2 == 1) {
    cout << b[n/2] - a[n/2] + 1 << endl;
}
else {
    rep(i,n) {
        a[i] *= 2;
        b[i] *= 2;
    }
        cout << (b[n/2] + b[n/2-1])/2 - (a[n/2] + a[n/2-1])/2 + 1 << endl;
}

return 0;
}

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

int main() {
	
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	
	vector<int> v(n);
	for(int i=0; i<n; ++i)
	cin >> v[i];
	
	if(n==2) 
	cout << abs(v[0]-v[1]) << endl;
	
	else {
		
		vector<int> cost(n);
		cost[0] = 0;
		cost[1] = abs(v[0]-v[1]);
		
		for(int i=2; i<n; ++i) 
		cost[i] = min(cost[i-1]+abs(v[i]-v[i-1]), cost[i-2]+abs(v[i-2]-v[i]));
		
		cout << cost[n-1] << endl;
		
	}
	
	return 0;
	
}

Measured memory_bytes: 4044
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define AB_BHI_NI_DEGI                \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
int mod = 1e9 + 7;
//int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double

#define ordered_set tree<P, null_type, less<P>, rb_tree_tag, tree_order_statistics_node_update>

int n;
int a[210];
string s;

int32_t main()
{
	AB_BHI_NI_DEGI
	int T;
	cin >> T;
	while (T--)
	{
		cin >> n;
		for (int i = 0; i < n; i++)
			cin >> a[i];
		cin >> s;
		vi v;
		int x = 0, y = 0;
		for (int i = n - 1; ~i; i--)
		{
			for (auto p : v)
				a[i] = min(a[i], a[i] ^ p);
			v.pb(a[i]);
			x |= s[i] == '1' && a[i];
		}
		cout << x << "\n";
	}

	return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
  int n,k;cin >> n >> k;
  ll r,s,p;cin >> r >> s >> p;
  map<char, ll> mp;
  mp['s']=r;
  mp['p']=s;
  mp['r']=p;
  string t;cin >> t;
  //int m = n / k;
  ll ans = 0;
  for(int i = 0; i < k; ++i){
    char now = 'a';
    for(int j = i; j < n; j+=k){
      if(t[j]!=now){
        now=t[j];
        ans += mp[now];
      }
      else{
        now='a';
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
template<typename T> void show(T e){ cout << e << endl; }
template<typename T> void show(const vector<T>& v){ for(const auto& e : v){ cout << e << " "; } cout << endl; }
template<typename T> void show(const vector<vector<T>>& vv){ for(const auto& v : vv){ show(v); } }
template<class Iter> void show(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
const ll DVSR = 10e9+7;


int main(int argc, char const *argv[])
{
  ll x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2;
  cout << (x2 - (y2 - y1)) << " " << (y2 + (x2 - x1)) << " "
    << (x1 - (y2 - y1)) << " " << (y1 + (x2 - x1)) << endl;
  return 0;
}


Measured memory_bytes: 256