akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pii pair<int, int>

#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
char dir[] = {'R', 'L', 'D', 'U'};
const int MOD = 1e9 + 7;

void solve()
{
    string s; cin >> s;
    for(int i = 0; i < s.length(); i++)
    {
        cout << s[i];
    }
    if(s[s.length() - 1] == 's') cout << "es";
    else cout << 's';
}

int main()
{
    fastio

    //ifstream fin(".in");
    //ofstream fout(".out");


    int t = 1;
    //cin >> t;

    while(t-- > 0) solve();
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define repr(i, a, n) for (ll i = n - 1; (ll)a <= i; i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 + 99);
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
template <typename T, typename U>
void chmin(T &t, const U &u)
{
    if (t > u)
        t = u;
}
template <typename T, typename U>
void chmax(T &t, const U &u)
{
    if (t < u)
        t = u;
}
template <typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T>
T mpow(T a, T n)
{
    T res = 1;
    for (; n; n >>= 1)
    {
        if (n & 1)
            res = res * a;
        a = a * a;
    }
    return res;
}

//cin.tie(0);ios::sync_with_stdio(false);

signed main()
{
    cout<< fixed<<setprecision(20);
    ll n, m;
    cin >> n >> m;
    double ans = INF;
    vector<double> ex(n, 0);
    vector<vector<int>> e(n, vector<int>(0));
    rep(i, 0, m)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        e[a].pb(b);
    }

    rep(k, 0, n-1)
    {
        ex.assign(n,0);
        repr(i, 0, n - 1)
        {
            double mx = 0;

            rep(j, 0, siz(e[i]))
            {
                ex[i] += ex[e[i][j]] + 1;
                mx = max(mx, ex[e[i][j]] + 1);
            }

            if(k==i && siz(e[i])>1){   
                ex[i]-=mx;
                ex[i]/=siz(e[i])-1;
            }else{
                ex[i]/=siz(e[i]);
            }
            
        }
        ans = min(ans, ex[0]);
    }

    cout <<ans << endl;
}

Measured memory_bytes: 1408
# ABC141 C - Attack Survival

N, K, Q = map(int, input().split())

P = []

for i in range(N):
    P.append(K - Q)

for i in range(Q):
    P[int(input()) - 1] += 1

for i in range(len(P)):
    if P[i] <= 0:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 7860
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int n=s.length();
    if(n==6)
    {
        for(int i=2; i<n; i++)
        {
            if((s[i]==s[i+1])&&(s[i+2]==s[i+3]))
               {
                   cout<<"Yes"<<endl;return 0;
               }
               else cout<<"No"<<endl;return 0;
        }
    }
}


Measured memory_bytes: 256
// Created by ...Lusifer
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void solveTest(){
	/*int n;
	cin>>n;*/
	string s;
	cin>>s;
	set<char>st;
	for(int i=0;i<s.size();i++){
		st.insert(s[i]);
	}
	if(s.size()==st.size()){
		cout<<"yes"<<endl;
	}
	else {
		cout<<"no"<<endl;
	}
	return ;
}
 
int main(){
	fastio();

	int t=1;
	//cin>>t;
	while(t--){
		solveTest();
 
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);


      String a1 = sc.next();
      String b1 = sc.next();

      char a =a1.charAt(0);
      char b =b1.charAt(0);

      if((int)a<(int)b){
        System.out.println("<");
      }
      if((int)a>(int)b){
        System.out.println(">");
      }
      if((int)a==(int)b){
        System.out.println("=");
      }

  }
}


Measured memory_bytes: 21844
N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7


# 最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


# 最小公倍数
def lcm(a, b):
    return a * b // gcd(a, b)


LCM = A[0]
for a in A:
    LCM = lcm(LCM, a)
LCM %= MOD

ans = 0
for a in A:
    ans += LCM * pow(a, MOD - 2, MOD)
    ans %= MOD

print(ans % MOD)

Measured memory_bytes: 41820
#include <iostream>
#include <cmath>
#include <vector>
#include <map>

using ll = long long;

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::cout.tie(nullptr);
  std::ios::sync_with_stdio(false);

  ll A, B;
  std::cin >> A >> B;

  std::map<ll, bool> is_correct;
  for (ll i = 1; i <= 3; i++) is_correct[i] = true;

  is_correct[A] = false;
  is_correct[B] = false;

  for (ll i = 1; i <= 3; i++) {
    if (is_correct[i]) {
      print(i);
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T,class U> void outs(T a,U b){if((ll)(a)>=inf-100||(ll)(a)<=-inf+100)out(b);else out(a);}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
vi dijkstra(int from,vvp g){
    vi dis(g.size(),inf);
    dis[from]=0;
    SPQ(P) pq;
    pq.push(P(0,from));
    while(!pq.empty()){
        auto t=pq.top();pq.pop();
        if(t.fi!=dis[t.se])continue;
        for(auto x:g[t.se]){
            if(chmin(dis[x.fi],t.fi+x.se))pq.push(P(dis[x.fi],x.fi));
        }
    }
    return dis;
}
int main(){
    ll n,m,s,t;cin>>n>>m>>s>>t;
    s--;t--;
    vvp g(n),f(n);
    rep(i,m){
        ll u,v,a,b;cin>>u>>v>>a>>b;u--;v--;
        g[u].eb(v,a);
        g[v].eb(u,a);
        f[u].eb(v,b);
        f[v].eb(u,b);
    }
    vi dis=dijkstra(s,g),dis2=dijkstra(t,f);
    vp v(n);
    rep(i,n)v[i]=P(dis[i]+dis2[i],i);
    sort(all(v));
    int w=0;
    rep(i,n){
        while(w<n){
            if(v[w].se<i)w++;
            else break;
        }
        out(1000000000000000-v[w].fi);
    }
}

Measured memory_bytes: 26684
#include <iostream>
#include <array>
#include <algorithm>

int main ()
{
  const int max_N = 100'000;
  struct Robot {
    int left;
    int right;
  };

  int N;
  std::cin >> N;

  std::array<Robot, max_N> robots;

  // Read input
  int X, L;
  for (int i=0; i<N; i++)
    {
      std::cin >> X >> L;
      robots.at(i).left = X-L;
      robots.at(i).right = X+L;
    }

  // Sort by ascending order w.r.t right arm
  std::sort(robots.begin(), robots.begin()+N, [&](auto r1, auto r2){return r1.right < r2.right;});

  // greedy method
  int cur_right = -1'000'000'000; //first right arm position
  int ans = 0; // store the number of robots left

  for (int i=0; i<N; i++)
    {
      // Do not remove robot[i] if its left arm is right to the current right arm position.
      if (robots.at(i).left >= cur_right)
        {
          ans++;
          // move the current rightest arm to robots[i].
          cur_right = robots.at(i).right;
        }
    }

  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using namespace std;



int main() {
    string s, t;
    cin >> s >> t;
    long slen = s.size();
    long next[slen+1][26],
         buf[26];
    fill(buf, buf+26, -1);
    fill(next[slen], next[slen+1], -1);
    for (long i=slen-1; i>=0; i--) {
        buf[s[i]-'a'] = i+1;
        for (long j=0; j<26; j++) next[i][j] = buf[j];
    }
    long cnt=0, id=0;
    for (auto c:t) {
        if (next[0][c-'a'] < 0) {
            cout << "-1\n";
            return 0;
        }
        if (next[id][c-'a'] < 0) {
            cnt += slen;
            id = next[0][c-'a'];
        }
        else id = next[id][c-'a'];
    }
    cout << cnt + id << endl;
}

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

int x, y;
int main() {
	cin >> x >> y;
	for(int i=0; i<=x; i++) {
		if(i*2 + (x-i)*4 == y) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <iterator>
#include <sstream>
#include <bits/stdc++.h>

using ll = long long;
using namespace std;
#define modmod 1000000007

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

int main(){
    int N;
    ll C,K;
    cin >> N >> C >> K;
    ll T[N];
    rep(i,N) cin >> T[i];

    sort(T,T+N);

    ll result = 1;
    ll now = T[0];
    ll count = 1;
    for(int i = 1; i < N; i++){
        //printf("count : %lld, now : %lld, result : %lld\n", count, now, result);
        if(T[i]-now <= K){
            count++;
            if(count>C){
                result++;
                count = 1;
                now = T[i];
            }
        }else{
            result++;
            now = T[i];
            count = 1;
        }
    }

    cout << result << endl;
    return 0;

}


Measured memory_bytes: 1024
N = int(input())
S = [input() for _ in [0]*N]

ans = 0
BA = 0
BX = 0
XA = 0
for s in S:
    ans += s.count("AB")
    if s[0]=="B" and s[-1]=="A":BA+=1
    elif s[0]=="B":BX+=1
    elif s[-1]=="A":XA+=1
ans += min(BX,XA) + max(0,BA - (BX==XA==0))
print(ans)

Measured memory_bytes: 3700
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;

int main(){
  int R;
  cin >> R;
  if(R < 1200) printf("ABC\n");
  else if(R < 2800) printf("ARC\n");
  else printf("AGC\n");
  return 0;
}


Measured memory_bytes: 256
l,r=map(int,input().split())
a=l%2019
b=r%2019
ans=2018
if l+2019<=r:
  ans=0
elif a<b:
  for i in range(a,b):
    for j in range(i+1,b+1):
      tmp=(i*j)%2019
      if tmp<ans:
        ans=tmp
else:
  ans=0
print(ans)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;
int main()
{
	int N;
	cin >> N;
	int A[200];
	bool check = true;
	int count = 0;

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

	while (check!=false) {
		for (int i = 0; i < N; i++)
		{
			if (A[i] % 2 == 1)
			{
				check = false;
			}
			else
			{
				A[i] = A[i] / 2;
			}
		}
		if (check==true)
		{
		count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


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

    int a[20000]={},b[20000]={};
    rep(i,n){
        cin>>a[i]>>b[i];
    }
    int maxi=-1;
    int now=m;
    bool flag=false;
    
    rep(i,n){
        maxi=max(maxi,now);
        now=now+a[i]-b[i];
        if(now<0)flag=true;
    }
    maxi=max(maxi,now);

    
    
    if(flag)cout<<"0"<<endl;
    else cout<<maxi<<endl;
    
    return 0;
}

Measured memory_bytes: 1324
from heapq import heappop, heappush
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
X = sorted([list(map(int, input().split())) for _ in range(N)], key = lambda x: x[0])

hq = []
ans, j = 0, 0

for i in range(1, M + 1):  # M - i 日後にするバイトを考える
    while (j < N) and (X[j][0] <= i):
        heappush(hq, -X[j][1])  # 候補の追加
        j += 1
    if len(hq):
        ans += -heappop(hq)  # 候補があるとき、候補から最大値を取り出す

print(ans)

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

int main()
{
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> l(101);
    // rep(i, 101) l[i] = 10000000;
    rep(i, n) cin >> x[i];
    sort(x.begin(), x.end());
    for (int i = 0; i <= 100; i++)
    {
        rep(j, n)
        {
            l[i] += (i - x[j]) * (i - x[j]);
        }
    }

    sort(l.begin(), l.end());
    cout << l[0] << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
ans = 0

if N < 10:
  ans = N
elif N < 100:
  ans = 9
elif N < 1000:
  ans = 9 + N - 99
elif N < 10000:
  ans = 9 + 900
elif N < 100000:
  ans = 9 + 900 + N - 9999 #1-9, 100-999, 10000-99999
else:
  ans = 9 + 900 + 90000
print(ans)
  


Measured memory_bytes: 2940
N, M = map(int, input().split())

A = []
for _ in range(N):
    A.append(list(map(int, input().split())))

A.sort(key=lambda x: x[0])
ans = 0
num = 0
i = 0
while True:
    if M - num <= A[i][1]:
        ans += A[i][0] * (M-num)
        num = M
    else:
        ans += A[i][0] * A[i][1]
        num += A[i][1]
        i += 1
    if num == M:
        print(ans)
        break


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

int main() {
	// your code goes here
	long n,k;
	cin>>n>>k;
	long a=(n-1)/(k-1);
	if((n-1)%(k-1)==0)
	cout<<a;
	else
	cout<<a+1;
	return 0;
}


Measured memory_bytes: 256
from collections import Counter
s = input()
c = Counter(s)
ans = float("inf")
for i in c.keys():
    s2 = list(s)
    cnt = 0
    while s2:
        if len(set(s2)) == 1:
            break
        for j in range(len(s2) - 1):
            if s2[j] == i or s2[j + 1] == i:
                s2[j] = i
            else:
                continue
        s2 = s2[:-1]
        cnt += 1
    ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 3316
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
# 得票数*4M<総評数であるような商品は選べません
s = sum(A)
ok = not True in [a * 4 * M < s for a in A[::-1][:M]]

if ok:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
int main(){
  cin>>s;
  n=s.size();
  for(int i=1;i<=(n-1)/2;i++)
{
	if(s[i-1]!=s[(n+1)/2-1-i]||s[i-1]!=s[(n+1)/2-1+i]||s[i-1]!=s[n-i])
	 {cout<<"No";return 0;
	  } 
}
cout<<"Yes";
return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll X, Y;
  cin >> X >> Y;
  cout << X + Y / 2 << endl;
  return 0;
}

Measured memory_bytes: 3584
x,y=map(int, input().split())
a=0
b=0
A=(1,3,5,7,8,10,12)
B=(4,6,9,11)
C=(2)
if x in A:
  a=1
elif x in B:
  a=2
else:
  a=3
if y in A:
  b=1
elif y in B:
  b=2
else:
  b=3
if a==b:
  print('Yes')
else:
  print('No')

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

using namespace std;
const long long MOD = 1e9 + 7;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M);
  bool is_valid = true;
  for (int i = 0; i < M; ++i) {
    cin >> a[i];
    if (i > 0 && a[i] - a[i - 1] == 1) {
      is_valid = false;
    }
  }

  if (!is_valid) {
    cout << 0 << endl;
    return 0;
  }

  a.push_back(N + 1);
  int start = 0;
  long long ans = 1;
  for (int i = 0; i <= M; ++i) {
    int range = a[i] - start;
    if (range > 2) {
      vector<long long> befores(2);
      befores[0] = 1;
      befores[1] = 1;
      for (int j = 3; j <= range; ++j) {
	long long n = (befores[0] +  befores[1]) % MOD;
	befores[0] = befores[1];
	befores[1] = n;
      }
      ans = ans * befores[1] % MOD;
    }
    start = a[i] + 1;
  }

  
  // if (a[M - 1] < N) {
  //   int range = N - a[M - 1];
  //   if (range > 2) {
  //     vector<long long> befores(2);
  //     befores[0] = 1;
  //     befores[1] = 1;
  //     for (int j = 3; j <= range; ++j) {
  // 	long long n = (befores[0] + befores[1]) % MOD;
  // 	befores[0] = befores[1];
  // 	befores[1] = n;
  //     }
  //     ans = ans * befores[1] % MOD;
  //   }    
  // }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    int sl=s.length();
    int tl=t.length();
    int tc=0;
    int sc=0;
    for(int i=0;i<tl*2;i++){
        if(i%2){
            cout<<t[tc];
            tc++;
        }else{
            cout<<s[sc];
            sc++;
        }
    }
    if(sl>tl){
        cout<<s[sc];
     }
     cout<<endl;
}
       

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll a[100009];
int main()
{
    ll i,j,n,t,m,cnt=1;
    cin>>n;
     string x;
     cin>>x;
     for(i=0;i<x.length()-1;i++)
     {
        if(x[i]!=x[i+1]) cnt++;
     }
     cout<<cnt<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N;
    cin >> N;
    set<ll> ans;
    for (ll i = 1; i*i <= N-1; i++) {
        if ((N-1) % i == 0) {
            ans.insert((N-1)/i);
            ans.insert(i);
        }
    }

    for (ll i = 1; i*i <= N; i++) {
        if (N % i == 0) {
            ll n = N;
            ll a = i, b = n / i;
            while (n % a == 0 && a > 1 && n >= a) n /= a;
            if (n % a == 1) ans.insert(a);
            n = N;
            while (n % b == 0 && n >= b) n /= b;
            if (n % b == 1) ans.insert(b);
        }
    }

    // for (ll e : ans) {
    //     cout << e << " ";
    // }
    // cout << endl;

    ans.erase(1);

    cout << ans.size() << endl;
}


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

int main(){
    int height, width;
    
    while(1){
        cin >> height >> width;
        if(height == 0 && width == 0) break;
        for(int i = 0; i < height; i++){
            for(int j = 0; j <width; j++){
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
import java.util.*;

public class Main{
    int INF = Integer.MAX_VALUE;
    
    public static void main(String[] args){
        new Main().solve();
    }
    void solve(){
        Scanner sc = new Scanner(System.in);
        
        while(true){
            int m = sc.nextInt();
            int n = sc.nextInt();
            if(m==0 && n==0) break;
 
            int[] b = new int[m];
            int[] r = new int[n];
            for(int i=0; i<m; i++) b[i] = sc.nextInt();
            for(int i=0; i<n; i++) r[i] = sc.nextInt();
 
            V[] graph = new V[n+m+2];
            for(int i=0; i<n+m+2; i++) graph[i] = new V();
 
            for(int i=0; i<m; i++){
                for(int j=0; j<n; j++){
                    int n1 = Math.max(b[i], r[j]);
                    int n2 = Math.min(b[i], r[j]);
                    int gcd = gcd(n2, n1);
                    if(gcd!=1) graph[i].add(graph[j+m], 1);
                }
            }
 
            int s = n+m;
            int t = n+m+1;
            for(int i=0; i<m; i++) graph[s].add(graph[i], 1);
            for(int i=0; i<n; i++) graph[m+i].add(graph[t], 1);
            int ans = dinic(graph[s], graph[t]);
            System.out.println(ans);
        }
    }
 
    int gcd(int x, int y){
        if(x==0) return y;
        return gcd(y%x, x);
    }
 
    int dinic(V s, V t){
        int flow = 0;
        for(int p=1;  ; p++){
            Queue<V> que = new LinkedList<V>();
            s.level = 0;
            s.p = p;
            que.offer(s);
            while(!que.isEmpty()){
                V v = que.poll();
                v.iter = v.es.size() - 1;
                for(E e : v.es) if(e.to.p < p && e.cap > 0){
                        e.to.level = v.level + 1;
                        e.to.p = p;
                        que.offer(e.to);
                    }
            }
            if(t.p < p) return flow;
            for(int f; (f=dfs(s, t, INF)) > 0; ) flow += f;
        }
    }
 
    int dfs(V v, V t, int f){
        if(v==t) return f;
        for(; v.iter >= 0; v.iter--){
            E e = v.es.get(v.iter);
            if(v.level < e.to.level && e.cap > 0){
                int d = dfs(e.to, t, Math.min(f, e.cap));
                if(d > 0){
                    e.cap -= d;
                    e.rev.cap += d;
                    return d;
                }
            }
        }
        return 0;
    }
     
    class V{
        ArrayList<E> es = new ArrayList<E>();
        int level, p, iter;
        void add(V to, int cap){
            E e = new E(to, cap), rev = new E(this, 0);
            e.rev = rev; rev.rev = e;
            es.add(e); to.es.add(rev);
        }
    }
 
    class E{
        V to;
        E rev;
        int cap;
        E(V to, int cap) {
            this.to = to;
            this.cap = cap;
        }
    }
}

Measured memory_bytes: 120628
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define rep1(i,n) for(int i=1; i<(int)n; i++)
#define repa(i,a,n) for(int i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
#define COUT(x) cout<<(x)<<endl
#define YES(x) cout<<(x?"YES":"NO")<<endl
#define Yes(x) cout<<(x?"Yes":"No")<<endl
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a / gcd(a, b)*b;}

int N, M, K, H, W, L, R, X;
string S, T;

signed main(){
  cin >> N >> L;
  int tgr = N*(N+1)/2 + N *(L-1);
  int dif = 1e9;
  int dp;
  int ans;
  rep1(i,N+1){
     if(dif> abs(i+L-1)){
       dif = abs(i+L-1);
       dp = i;
     }
  }
  ans = tgr - (L+dp-1);
  COUT(ans);
  return 0;
}


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


int main(){
    int l,i(0),N,M,all;
    cin >> N >> M;
    int* num = new int[M];
    all=0;
    while (cin >> l){
        num[i] = l;
        i++;
        if(i==M) break;
    }
    for(int i=0;i<M;i++){
        all+=num[i];
    }
    if (all > N)
    {
        cout << -1;
    }
    else
    {
        cout << N - all;
    }
}

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

int main() {
    int K, T;
    cin >> K >> T;
    vector<int> nums(T);
    int sum = 0;
    int maxVal = 1;
    for (int i=0; i<T; ++i) {
        cin >> nums[i];
        sum += nums[i];
        maxVal = max(maxVal, nums[i]);
    }
    sum -= maxVal;
    if (sum >= maxVal-1) {
        cout << 0 << endl;
    } else {
        cout << maxVal-1 - sum << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define p_b push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
using namespace std;

int main()
{
    ll k,n;
    cin >> k >> n;
    vector < ll > v;
    for( int i = 0 ; i < n; i++)
    {
        ll b;
        cin >> b;
        v.push_back(b);
    }
    sort(all(v));
    ll mx = k-v[n-1]+v[0];
    for( int i = 0; i < n-1; i++)
    {
        mx = max(mx,abs(v[i]-v[i+1]));
    }
    cout << k - mx;
}


Measured memory_bytes: 2420
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		String[] s = S.split("");
		String[] t = T.split("");
		int count = 0;
		for(int i=0;i<s.length;i++) {
			if(s[i].equals(t[i])) {
				count++;
			}
		}
		System.out.println(count);
	}
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    int N,K; cin >> N >> K;
    string S; cin >> S;

    vector<P> lis;
    int cnt1 = 0;
    int cnt0 = 0;
    for (int i = 0;i < S.size();i++){
        if(S[i] == '1'){
            if(cnt0 > 0) lis.push_back(P(1,cnt0));
            cnt0 = 0;
            cnt1++;
        }else{
            if(cnt1 > 0) lis.push_back(P(0,cnt1));
            cnt1 = 0;
            cnt0++;
        }
    }

    if(cnt1 > 0) lis.push_back(P(0,cnt1));
    if(cnt0 > 0) lis.push_back(P(1,cnt0));    

    int ans = 0;
    int sum = 0;
    int cnt = 0;
    int l = 0;
    int r = 0;
    while(true){
        while(cnt <= K && l < lis.size()){
            cnt += lis[l].first;
            sum += lis[l].second;
            if(cnt <= K)ans = max(ans,sum);
            l++;
        }
        while(cnt > K){
            cnt -= lis[r].first;
            sum -= lis[r].second;
            if(cnt <= K) ans = max(ans,sum);
            r++;
        }
        if(l >= lis.size()) break;

    }
    
    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 1528
#include<stdio.h>
#define N 100

int n, G[N][N], c[N], d[N], f[N], t;

void dfs_v(int u){
  int v;
  c[u] = 1;
  d[u] = ++t;
  for( v = 0 ; v < n ; v++ ){
    if( G[u][v] == 0 ) continue;
    if( c[v] == 0 ) dfs_v(v);
  }
  c[u] = 2;
  f[u] = ++t;
}

void dfs(){
  int u;
  for( u = 0 ; u < n ; u++ ) c[u] = 0;
  t = 0;

  for( u = 0 ; u < n ; u++ ){
    if( c[u] == 0 ) dfs_v(u);
  }

  for( u = 0 ; u < n ; u++ ) printf("%d %d %d\n", u+1,d[u],f[u]);
}

int main(){
int u, v, k, i, j;

scanf("%d", &n);
for( i = 0 ; i < n ; i++ ){
for( j = 0 ; j < n ; j++ ){
G[i][j] = 0;
}
}

for( i = 0 ; i < n ; i++ ){
scanf("%d%d",&u,&k);
u--;
for( j = 0 ; j < k ; j++ ){
scanf("%d",&v);
v--;
G[u][v] = 1;
}
}
dfs();
return 0;
}



Measured memory_bytes: 2084
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int a[maxn],n,q,to[maxn<<1],bg[maxn],nt[maxn<<1],e,f[maxn];
inline void add(int x,int y)
{
	to[++e]=y;
	nt[e]=bg[x];
	bg[x]=e;
}
void dfs(int x)
{
	for(register int i=bg[x];i;i=nt[i])
	{
		int u=to[i];
		if(u!=f[x])
		{
			f[u]=x;
			a[u]+=a[x];
			dfs(u);
		}
	}
}
int main()
{
	scanf("%d%d",&n,&q);
	for(register int i=1,x,y;i<n;i++)
	{
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
	}
	for(register int i=1,x,y;i<=q;i++)
	{
		scanf("%d%d",&x,&y);
		a[x]+=y;
	}
	dfs(1);
	for(register int i=1;i<=n;i++)
		printf("%d ",a[i]);
	return 0;
}

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

using namespace std;

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

	string name;
	std::vector<string> names;
	for(int i = 0; i < n; i++){
		cin >> name;
		names.push_back(name);
	}
	std::sort(names.begin(), names.end());
	names.erase( unique(names.begin(), names.end()), names.end() );


	int* a_ = new int[26];
	for(int i = 0; i < 26; i++){
		a_[i] = 0;
	}
	for(string name : names){
		++a_[name[0] - 'A'];
	}

	int a[5] = {
			a_['M'-'A'],
			a_['A'-'A'],
			a_['R'-'A'],
			a_['C'-'A'],
			a_['H'-'A']
	};

	int num = 0;
	for(int i = 0; i < 5; i++){
		if(a[i] != 0){
			++num;
		}
	}

	if(num < 3){
		cout << "0" << endl;

	}else{
		int64_t comb = 0;

		for(int i = 0; i < 3; i++){
			if(a[i] == 0) continue;

			int64_t i_inner = 0;
			for(int j = i+1; j < 4; j++){
				if(a[j] == 0) continue;
				int64_t j_inner = 0;

				for(int k = j+1; k < 5; k++){
					j_inner += a[k];
				}
				i_inner += a[j] * j_inner;
			}
			comb += a[i] * i_inner;
		}
		cout << comb << endl;
	}

	return 0;
}

Measured memory_bytes: 6132
#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;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
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)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int N;
int a[210000];

int main()
{
  while (cin >> N) {
	for (int i = 0; i < N; ++i) cin >> a[i];
	int zero = 0, one = 0, two = 0;
	for (int i = 0; i < N; ++i) {
	  if (a[i] % 2 != 0) ++zero;
	  else if (a[i] % 4 != 0) ++one;
	  else ++two;
	}
	if (one == 0) {
	  if (two < zero - 1) puts("No");
	  else puts("Yes");
	}
	else {
	  if (two < zero) puts("No");
	  else puts("Yes");
	}
  }
}
















Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
ll dp[100005],p[100005],hell=pow(10,9)+7;
ll exp(ll x,ll y){
	ll res=1;
	x%=hell;
	while(y>0){
		if(y&1)
		res=(res*x)%hell;
		y>>=1;
		x=(x*x)%hell;
	}
	return res;
}
void solve(){
	ll n,k,res=0;
	cin>>n>>k;
	for(ll i=0;i<=k;i++)
	p[i]=exp(i,n);
	for(ll i=k;i>=1;i--){
		ll sum=0;
		for(ll j=i;j<=k;j+=i){
			dp[i]-=dp[j];
			dp[i]%=hell;
			sum++;
		}
		dp[i]+=p[sum];
		dp[i]%=hell;
		if(dp[i]<0)
		dp[i]+=hell;
	}
	for(ll i=1;i<=k;i++){
		res+=(i*dp[i])%hell;
		res%=hell;
	}
	cout<<res;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll qc=1;
	for(ll i=1;i<=qc;i++)
	solve();
}


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

typedef long long ll;

main()
{
    int n, T, a, b;
    cin >> n >> T;
    vector<pair<int, int>> p;
    for(int i = 0; i < n; i++){
        cin >> a >> b;
        p.push_back(make_pair(a, b));
    }
    sort(p.begin(), p.end());
    for(int i = 0; i < n; i++){
        if(p[i].second <= T){
            cout << p[i].first;
            break;
        }
        else if(i == n-1){
            cout << "TLE";
        }
    }


}





///promy_pompom
//hello world


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

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve(){
    llint x;
    cin >> x;
    for(int a=0;a<=200;a++){
        for(int b=-200;b<=200;b++){
            if(a*a*a*a*a-b*b*b*b*b==x){
                printf("%d %d\n",a,b);
                return;
            }
        }
    }
}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define cases long long test;cin>>test;while(test--)
#define f_io ios::sync_with_stdio(false); cin.tie(0)
#define foi(a,n) for(long long i=a;i<n;i++)
#define foj(a,n) for(long long j=a;j<n;j++)
#define fok(a,n) for(long long k=a;k<n;k++)
#define ll long long
#define MOD 1000000007
#define INF 1000000000
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

void dfs(vector< vector<ll> > &adj,vector<bool> &visited,vector<ll> &order,vector<ll> &arr,ll src)
{
    visited[src] = 1;
    foi(0,adj[src].size())
    {
        if (!visited[adj[src][i]])
            dfs(adj,visited,order,arr,adj[src][i]);
    }
    order.push_back(arr[src]);
}

int main()
{
    f_io;
    ll n,k;
    cin >> n >> k;
    vector<ll> per(n),arr(n);
    foi(0,n)
        cin >> per[i];
    foi(0,n)
        cin >> arr[i];
    vector<vector<ll> > adj(n);
    foi(0,n)
        adj[i].push_back(per[i]-1);
    ll ans = LLONG_MIN;
    foi(0,n)
    {
        vector<bool> visited(n);
        vector<ll> order;
        dfs(adj,visited,order,arr,i);
        ll l = (ll)order.size();
        ll maxi = order[l-1];
        ll sum = maxi,num=k-1,p=2;
        vector<ll> pre(l+1);
        pre[1]=sum;
        for(ll j=l-2;j>=0;j--)
        {
            sum+=order[j];
            if(num>0)
                maxi = max(maxi,sum);
            num--;
            pre[p]=sum;
            p++;
        }
        if(sum>0)
        {
            if((k/l)>1)
            {
                ll tmp2 = sum*(k/l - 1);
                ll some2 = 0;
                foj(0,l)
                    some2 = max(some2,pre[j]);
                tmp2+=some2;
                maxi = max(maxi,tmp2);
            }
            ll tmp = sum*(k/l);
            ll some = 0;
            foj(0,(k%l)+1)
                some = max(some,pre[j]);
            tmp+=some;
            maxi = max(maxi,tmp);
        }
        ans = max(ans,maxi);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 4484
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        private static CompareInfo ci = new System.Globalization.CultureInfo("ja-JP").CompareInfo;
        private static int Compare(string a, string b) { return ci.Compare(a, b, System.Globalization.CompareOptions.Ordinal); }

        static int Gcd(int a, int b)
        {
            var v = new[] { a, b };
            while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
            return v[0];
        }

        static int Gcd(IEnumerable<int> values)
        {
            return values.Aggregate(Gcd);
        }

        static void Main(string[] args)
        {
            int K = ReadInt();
            int sum = 0;
            for (int i = 1; i <= K; ++i)
            {
                for (int j = 1; j <= K; ++j)
                {
                    for (int k = 1; k <= K; ++k)
                    {
                        sum += Gcd(new[] { i, j, k });
                    }
                }
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 40840
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    string s;
    cin>>s;
    int c;
    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<2;k++){
                c=(int)(s[0]-48);
                if(i==0)c+=(int)(s[1]-48);
                if(i==1)c-=(int)(s[1]-48);
                if(j==0)c+=(int)(s[2]-48);
                if(j==1)c-=(int)(s[2]-48);
                if(k==0)c+=(int)(s[3]-48);
                if(k==1)c-=(int)(s[3]-48);
                if(c==7){
                    cout<<s[0]<<(char)(43+(i*2))<<s[1]<<(char)(43+(j*2))<<s[2]<<(char)(43+(k*2))<<s[3]<<"=7"<<endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}


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

template<class T, class U> T lexical_cast(const U &from) {
    stringstream ss;
    ss << from;
    T to;
    ss >> to;
    return to;
}

int main() {
    int Q; cin >> Q;
    while(Q--) {
        int N; cin >> N;
        int ans = 0;
        set<int> histo;
        while(N >= 10) {
            histo.insert(N);
            string s = lexical_cast<string>(N);
            vector<int> list;
            for(int i = 1; i < (int)s.length(); i++) {
                int left = lexical_cast<int>(s.substr(0, i));
                int right = lexical_cast<int>(s.substr(i));
                list.push_back(left * right);
            }
            N = *max_element(list.begin(), list.end());
            if(histo.count(N)) {
                ans = -1;
                break;
            }
            ans++;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1252
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
#define FORi(N) for(ll i = 0; i < N; ++i)
#define FORj(N) for(ll j = 0; j < N; ++j)
#define FORk(N) for(ll k = 0; k < N; ++k)
//using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1 ,rr =1;
    for(ll i=0;i<k;++i) {
      r*=(n-i);
      rr*=(i+1);
      //r %= 1000000007;
      //rr %= 1000000007;
    }
    r/=rr;
    //r %= 1000000007;
    return r;
}
 
int main() {
  ll H,W;
  cin>>H>>W;
  vector<string> S(H);
  FORi(H){
    cin>>S[i];
  }
  ll n=0;//白の数
  FORi(H){
    FORj(W){
      if(S[i][j]=='.'){
        n++;
      }
    }
  }
  list<vector<ll>> l;
  l.push_back(vector<ll>{0,0,1});
  ll route = -1;
  while(l.size()>0){
    vector<ll> tmp = l.front();
    l.pop_front();
    if(S[tmp[0]][tmp[1]]!='.')continue;
    if(tmp[0]==H-1&&tmp[1]==W-1){
      route=tmp[2];
      break;
    }
    S[tmp[0]][tmp[1]]='#';
    if(tmp[0]!=0&&S[tmp[0]-1][tmp[1]]=='.'){
      l.push_back(vector<ll>{tmp[0]-1,tmp[1],tmp[2]+1});
    }
    if(tmp[0]!=H-1&&S[tmp[0]+1][tmp[1]]=='.'){
      l.push_back(vector<ll>{tmp[0]+1,tmp[1],tmp[2]+1});
    }
    if(tmp[1]!=0&&S[tmp[0]][tmp[1]-1]=='.'){
      l.push_back(vector<ll>{tmp[0],tmp[1]-1,tmp[2]+1});
    }
    if(tmp[1]!=W-1&&S[tmp[0]][tmp[1]+1]=='.'){
      l.push_back(vector<ll>{tmp[0],tmp[1]+1,tmp[2]+1});
    }
  }
  if(route==-1){
    cout<<-1<<endl;
  }else{
    cout<<n-route<<endl;
  }
  return 0;
}

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

int main(){
  string s;
  int k;
  cin >> s >> k;
  set<string> st;
  int n = s.size();
  for(int i=0; i<n; ++i) for(int j=1; i+j<=n; ++j){
    string ns = s.substr(i,j);
    if(st.size() >5){
      if(*st.rbegin() > ns){
        st.insert(ns);
        st.erase(*st.rbegin());
      }
    }
    else st.insert(ns);
  }
  auto it = st.begin();
  for(int i=1; i<k; ++i) ++it;
  cout << *it << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
string s;
cin >>s;
if(s[0]=='a'||s[0]=='i'||s[0]=='u'||s[0]=='e'||s[0]=='o')
cout<<"vowel";
else
cout<<"consonant";
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define se second
#define fi first
#define mp make_pair
#define pb push_back
#define ll long long
const int MAXN = (int)1e7 + 1000;
const int N = 105;
const int mod = (int)1e9 + 7;
const int INF = (int)1e9;
int d[N][N];
struct edge{
    int u,v,c;
};
edge e[N * N];
bool ok(int number, int v1,int v2){
    return (d[v1][e[number].u] + d[e[number].v][v2] + e[number].c == d[v1][v2]);
}
int main(){
    // ifstream cin("input.txt");
    // ofstream cout("output.txt");
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin >> n >> m;
    for(int i = 0;i <= 101;i++){
        for(int j = 0;j <= 101;j++){
            d[i][j] = INF;
        }
    }
    int ans = 0;
    for(int i = 1;i <= m;i++){
        cin >> e[i].u >> e[i].v >> e[i].c;
        d[e[i].u][e[i].v] = e[i].c;
        d[e[i].v][e[i].u] = e[i].c;
    }
    for(int k = 1;k <= n;k++){
        for(int i = 1;i <= n;i++){
            for(int j = 1;j <= n;j++){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    for(int i = 1;i <= m;i++){
        if(d[e[i].v][e[i].u] != e[i].c){
            ans++;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int a, b, x, A, Z;
    double ans;
    cin >> a >> b >> x;

    A = pow(a, 2.0);

    Z = A * b - x;

    double c, cosk;
    if(x * 2 >= A * b){
        c = (double)Z * 2 / A;
        cosk = a / sqrt(pow(a, 2.0) + pow(c, 2.0));
    } else {
        c = (double)x * 2 / b / a;
        cosk = c / sqrt(pow(b, 2.0) + pow(c, 2.0)); 
    }
    cout << fixed << setprecision(10) << acos(cosk) * 180 / PI << endl;
    
    return 0;
}


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

int main()
{
	int R, G;

	cin >> R >> G;

	cout << 2 * G - R << endl;

	return 0;
}
	











//  (R+ans)/2 == G
// R/2 + ans/2 == G
// ans/2 == G - R/2
// ans == 2G - R

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
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(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

LL gcd(LL a, LL b) {
	return b != 0 ? gcd(b, a % b) : a;
}

LL lcm(LL a, LL b) {
	return a * b / gcd(a, b);
}



int main() {

	LL a, b;
	while (cin >> a) {
		cin >> b;

		cout << gcd(a, b) << " " << lcm(a, b) << endl;
	}
	
	return 0;

}


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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

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

int main() {
    lli a;
    cin1(a);
    string s;
    cin1(s);
    if (a >= 3200)
        cout << s << endl;
    else
        cout << "red" << endl;
}


Measured memory_bytes: 256