akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<vector<int>> D(N, vector<int>(2));
    for (int i=0;i < N; i++) {
        for (int j = 0;j <2; j++) {
            cin >> D.at(i).at(j);

        }
    }
    int cnt =0;
    for (int i=0;i < N; i++) {
        if (D.at(i).at(0) == D.at(i).at(1)) {
            cnt++;
        }
        else {
            cnt = 0;
        }

        if (cnt==3) {
            cout << "Yes" << endl;
            return 0;
        }

    } 
    cout << "No" << endl;
    return 0;

}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;



ll n,k,h,ran[101010],tmp[101010],sa[101010];

bool compare_sa(int i,int j){
    if(ran[i]!=ran[j])return ran[i]<ran[j];
    int ri = (i+k<=n?ran[i+k] : -1);
    int rj = (j+k<=n?ran[j+k] : -1);
    return ri<rj;
}

void constract_sa(string&s){
    rep(i,n+1){
        sa[i]=i;
        ran[i]=(i<n?s[i] : -1);
    }
    for(k=1 ; k<=n ;k*=2 ){
        sort(sa,sa+n+1,compare_sa);
        tmp[sa[0]]=0;
        rep(i,n){
            tmp[sa[i+1]]=tmp[sa[i]]+compare_sa(sa[i],sa[i+1]);
        }
        rep(i,n+1)ran[i]=tmp[i];
    }
}
int main(){
    cin>>n>>h;
    string s;
    cin>>s;
    bool all_zero=true;
    rep(i,n)if(s[i]!='0')all_zero=false;
    if(all_zero){
        cout<<0<<endl;
        return 0;
    }
    vector<int> nonzero(n,-1);
    nonzero[0]=-1;
    reverse(s.begin(),s.end());
    rep(i,n){
        if(s[i]!='0')nonzero[i]=i;
        else if(i!=0) nonzero[i]=nonzero[i-1];
    }
    reverse(s.begin(),s.end());
    vector<ll> cnt(n+1);
    rep(i,n){
        cnt[nonzero[i]+1]++;
    }
    rep(i,n-1)cnt[n-i-1]+=cnt[n-i];
    rep(i,n)if(nonzero[i]!=-1)cnt[0]+=i-nonzero[i];
    int keta=0;
    while(h-cnt[keta]>0){
        h-=cnt[keta];
        ++keta;
    }
    if(!keta){
        cout<<0<<endl;
        return 0;
    }
    constract_sa(s);
    rep(i,n+1)sa[ran[i]]=i;
    vector<int> cnt2(n+1);
    rep(i,n)cnt2[n-nonzero[i]-1]++;
    int ans=-1;
    rep(i,n+1){
        if(n-sa[i]<keta)continue;
        if(h<=cnt2[sa[i]]){
            ans=sa[i];
            break;
        }
        h-=cnt2[sa[i]];
    }
    cout<<s.substr(ans,keta)<<endl;
    return 0;
}


Measured memory_bytes: 6776
#include <bits/stdc++.h>
#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 INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  int n;
  cin >> n;
  vector<int> a;
  for(int i = 1; i <= n; i++) {
    if(i % 3 == 0 || i % 5 == 0)
      a.push_back(0);
    else
      a.push_back(i);
  }
  ll ans = 0;
  for(auto v : a) ans += v;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7392
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

signed main() {
    SS(string,s)
    YES(regex_match(s,regex(".*keyence|k.*eyence|ke.*yence|key.*ence|keye.*nce|keyen.*ce|keyenc.*e|keyence.*")));
}

Measured memory_bytes: 384
def twoDimArraywithwall(row,column,n,wallchar): return [[n if j!=0 and j!=(column+1) else wallchar for j in range(column+2)] if i!=0 and i!=(row+1) else [wallchar]*(column+2) for i in range(row+2)]
def maketwodimarraywithwall(matrix,wallchar):
    rownum=len(matrix)
    colnum=len(matrix[0])
    ret=twoDimArraywithwall(rownum,colnum,None,wallchar)
    for i in range(rownum):
        for j in range(colnum):
            ret[i+1][j+1]=matrix[i][j]
    return ret


H, W = map(int, input().split())
table = []
for h in range(H):
    table.append(list(input())) 
table=maketwodimarraywithwall(table,"#")
for i in table:
    print("".join(i))

Measured memory_bytes: 3188
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

def main():
    h,w = i_map()
    c = [i_list() for i in range(10)]

    for k in range(10):
        for i in range(10):
            for j in range(10):
                c[i][j] = min(c[i][j], c[i][k] + c[k][j])

    ans = 0
    for h in range(h):
        a = i_list()
        for b in a:
            if b>=0:
                ans += c[b][1]
    print(ans)



if __name__=="__main__":
    main()


Measured memory_bytes: 9516
n,k,*a=map(int,open(0).read().split())
v=[-1]*n
t=c=0
while v[t]<0:
  v[t]=c
  c+=1
  t=a[t]-1
l=v[t]
c-=l
print(v.index(min(k,l+(k-l)%c))+1)

Measured memory_bytes: 31816
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e6 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	LL n, m;
	cin >> n >> m;
	if (n > m) swap(n, m);
	if (n == 1)
	{
		if (m == 1) cout << 1 << endl;
		else cout << max(0LL, m - 2) << endl;
	}
	else cout << (n - 2) * (m - 2) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()

template<class T> using V = vector<T>;
template<class T> using V2 = V<V<T>>;
using P = pair<ll,ll>;


void solve(){
  int n, m; scanf("%d %d",&n,&m);//cin >> n >> m;
  V<P> v;
  FOR(i,0,n){
    int a, b; scanf("%d %d",&a,&b);//cin >> a >> b;
    if(a>m) continue;
    v.emplace_back(a,b);
  }
  sort(ALL(v));
  reverse(ALL(v));
  ll ans = 0;
  priority_queue<P> que;
  IFOR(d,0,m){
    while(!v.empty()){
      auto p = v[v.size()-1];
      if(p.first+d>m) break;
      que.push(P(p.second, p.first));
      v.pop_back();
    }
    if(!que.empty()){
      auto p = que.top();
      que.pop();
      ans += p.first;
    }
  }
  printf("%d",ans);
}

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

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

int main(){
  int n;

  cin >> n;


  vector<int> tmp;

  int tmp2 = 0;

  int i = 1;
  while(tmp2 <= 10000000){
    tmp2 += i;
    tmp.push_back(tmp2);
    i++;
  }

  while(n > 0){
    i = lower_bound(tmp.begin(),tmp.end(),n) - tmp.begin();
    i++;
    n -= i;
    cout << i << endl;
  }

  return 0;


}





Measured memory_bytes: 384
#include<stdio.h>

int main()
{
    int A, B;
    double x, y;
    scanf("%d %d", &A, &B);
    y = ((double)A+(double)B)/2;
    x = y - (int)y;

    if(x == 0)printf("%d", (int)y);
    else printf("IMPOSSIBLE");

}

Measured memory_bytes: 1692
#include<stdio.h>
#define MAX 300000

int T[MAX+1], L[MAX+1];

int main(){
  int N, Q, q, x, i, m, maxv, cur, p;

  scanf("%d %d", &N, &Q);

  for ( i = 0; i < N; i++ ) {
    scanf("%d", &x);
    T[x] = 1;
  }

  m = 0;
  for ( i = 1; i <= MAX; i++ ){
    L[i] = m;
    if ( T[i] ) m = i;
  }

  for ( i = 0; i < Q; i++ ){
    scanf("%d", &q);
    maxv = 0;
    cur = m;
    while(cur){
      p = cur%q;
      maxv = (maxv > p ? maxv : p);
      if ( cur - p < 0 ) break;
      cur = L[cur - p];
    }
    printf("%d\n", maxv);
  }

  return 0;
}



Measured memory_bytes: 4120
import sys
input = sys.stdin.readline
n,m = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
a.sort()
bc=[None]*m
for i in range(m):
    bc[i] = list(map(int, input().split(" ")))
bc.sort(reverse=True, key=lambda x:x[1])
l=[]
for [b,c] in bc:
    l.extend([c]*b)
    if n < len(l):
        break
for i in range(n):
    if len(l) <= i or l[i] <= a[i]:
        break
    a[i] = l[i]
print(sum(a))


Measured memory_bytes: 75048
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,num=2,v,now,size;
  cin >> n;
  if(n==1){
    cout <<"Yes\n";
    cout <<"2\n";
    cout << "1 1\n";
    cout << "1 1\n";
    return 0;
  }else if(n==2){
    cout <<"No\n";
    return 0;
  }
  v=-1;
  while(v<n){
    v=(num*(num+1))/2;
    num++;
  }
  if(v!=n){
    cout <<"No\n";
    return 0;
  }
  cout <<"Yes\n";
  cout << num<<endl;
  vector<ll> ans[num];
  ans[0].push_back(1);
  ans[0].push_back(2);
  ans[1].push_back(1);
  ans[1].push_back(3);
  ans[2].push_back(2);
  ans[2].push_back(3);
  now = 2;
  size = 2;
  for(int i=3;i<num;i++){
    now = now+size;
    size++;
    for(int j=0;j<size;j++){
      ans[j].push_back(now+j);
    }
    for(int j=0;j<size;j++){
      ans[size].push_back(now+j);
    }
  }
  for(int i=0;i<num;i++){
    cout << ans[i].size()<<" ";
    for(auto j:ans[i]){
      cout << j<<" ";
    }
    cout << endl;
  }
}


Measured memory_bytes: 3200
#include <iostream>
#include <queue>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;

int main(void){
    ull mod = 1000000007;
    
    uint N, M;
    cin >> N >> M;
    
    queue<uint> aq;
    for(uint i=0; i<M; i++) {
        uint a;
        cin >> a;
        if(!aq.empty() && (a - 1) == aq.back()) {
            cout << 0;
            return 0;
        } else {
            aq.push(a);
        }
    }
    
    ull dp_2 = 0;
    ull dp_1 = 1;
    ull dp = 1;
    
    for(uint i=1; i<=N; i++) {
        if(!aq.empty() && aq.front() == i) {
            dp = 0;
            aq.pop();
        } else {
            dp = (dp_1 + dp_2) % mod;
        }
        
        dp_2 = dp_1;
        dp_1 = dp;
    }
    
    cout << dp;
    return 0;
    
}


Measured memory_bytes: 432
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;

#define MOD 1000000007


int main(){

  ll a,b,c;
  cin >> a >> b;
  c=6-a-b;

  cout << c << endl ;


  }


Measured memory_bytes: 3552
h,w = map(int,input().split())
board = [input() for _ in range(h)]

for i in range(h):
    for j in range(w):
        if board[i][j] == '.': continue
        ok = False
        for k in (-1, 0, 1):
            for l in (-1, 0, 1):
                if k == 0 and l == 0:
                    continue
                if k != 0 and l != 0:
                    continue
                # print(k, l)
                ni = i + k
                nj = j + l
                if ni < 0 or ni >= h or nj < 0 or nj >= w: continue
                # if i == 1 and j == 1:
                if board[ni][nj] == '#':
                    ok |= True
        if not ok:
            print('No')
            exit(0)

print('Yes')

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

int main() {

    int N,Q;
    cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
    }
    cin>>Q;
    int cnt=0;
    for(int i=0;i<Q;i++){
        int k;
        cin>>k;
        for(int j=0;j<N;j++){
            if(A.at(j)==k){
                cnt++;
                break;
            }
        }
    }
    cout<<cnt<<endl;
}
   



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

using namespace std;

int main()
{
    int n ;
    cin >> n;
    int arr[n];
    map<int,int>mp;
    for(int i = 0 ; i < n ; i++)
    {
        cin >> arr[i];
        mp[arr[i]]++;
    }
    int ans=0;
    bool flag;
    for(int i = 0 ; i < n ; i++)
    {
        flag=true;
        /*if(arr[i]==1)
        {
            ans++;
            continue;
        }
        */
        for(int j = 1 ; j*j<=arr[i]; j++)
        {
            if(arr[i]%j==0)
            {
                if(j==arr[i])
                {
                    if(mp[j]>1)
                    {
                        flag=false;
                    }
                }
                if(j!=arr[i])
                {
                    if(mp[j]>0)
                    {
                        flag=false;
                    }
                }
                if(arr[i]/j==arr[i])
                {
                    if(mp[(arr[i]/j)]>1)
                    {
                        flag=false;
                    }
                }
                if(arr[i]/j !=arr[i])
                {
                    if(mp[(arr[i]/j)]>0)
                    {
                        flag=false;
                    }
                }
            }
        }
        if(flag)
        {
            ans++;
        }
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 33252
#include "bits/stdc++.h"
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const long long mod = 1e9 + 7;

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;
}

ll powMod(ll n, ll k, ll m) {
	if (k == 0) {
		return 1;
	} else if (k % 2 == 1) {
		return powMod(n, k - 1, m) * n % m;
	} else {
		ll t = powMod(n, k / 2, m);
		return t * t % m;
	}
}

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

	ll ans= a + pow(a, 2) + pow(a, 3);

	cout << ans << endl;
}


Measured memory_bytes: 4008
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int N = 200003;

int n, m;
int a[N], b[N];
char s[N];

int gcd(int a, int b)
{
    if (!b) return a;
    return gcd(b, a % b);
}

int main()
{
    n = gi();
    LL ans = 0;
    for (int i = 1; i <= n; i+=1)
        for (int j = 1; j <= n; j+=1)
            for (int k = 1; k <= n; k+=1)
                ans += gcd(i, gcd(j, k));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC114_C
{
    class Program
    {
        static int Add3(int[] numbers753, ref int index, int digits, int number, int count3, int count5, int count7)
        {
            ++digits;
            if (digits >= 9)
            {
                return number;
            }

            number += (int)Math.Pow(10, digits) * 3;

            ++count3;

            if (count3 >= 1 && count5 >= 1 && count7 >= 1)
            {
                numbers753[index] = number;

                ++index;
            }

            return Add753(numbers753, ref index, digits, number, count3, count5, count7);
        }
        static int Add5(int[] numbers753, ref int index, int digits, int number, int count3, int count5, int count7)
        {
            ++digits;
            if (digits >= 9)
            {
                return number;
            }

            number += (int)Math.Pow(10, digits) * 5;

            ++count5;

            if (count3 >= 1 && count5 >= 1 && count7 >= 1)
            {
                numbers753[index] = number;

                ++index;
            }

            return Add753(numbers753, ref index, digits, number, count3, count5, count7);
        }
        static int Add7(int[] numbers753, ref int index, int digits, int number, int count3, int count5, int count7)
        {
            ++digits;
            if (digits >= 9)
            {
                return number;
            }

            number += (int)Math.Pow(10, digits) * 7;

            ++count7;

            if (count3 >= 1 && count5 >= 1 && count7 >= 1)
            {

                numbers753[index] = number;

                ++index;
            }

            return Add753(numbers753, ref index, digits, number, count3, count5, count7);
        }


        static int Add753(int[] numbers753, ref int index, int digits, int number, int count3, int count5, int count7)
        {
            int number3 = number;
            int number5 = number;
            int number7 = number;

            number3 = Add3(numbers753, ref index, digits, number, count3, count5, count7);
            number5 = Add5(numbers753, ref index, digits, number, count3, count5, count7);
            number7 = Add7(numbers753, ref index, digits, number, count3, count5, count7);

            return number;
        }

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            int[] numbers753 = new int[49152];

            int index = 0;
            int digits = -1;

            Add753(numbers753, ref index, digits, 0, 0, 0, 0);

            int i = 0;
            int number = 0;
            int count = 0;
            while((number = numbers753[i]) != 0)
            {
                if (n >= number)
                {
                    ++count;
                }

                ++i;
            }

            Console.WriteLine("{0}", count);
        }
    }
}


Measured memory_bytes: 13192
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
V = lr()
scores = set()
limit = min(N, K)
for i in range(limit+1): # iは左から取り出す個数
    for j in range(limit-i+1): # jは右から取り出す個数
        stone = V[:i] + V[N-j:]
        stone.sort()
        result = sum(stone)
        scores.add(result)
        for k in range(min(len(stone), K-(i+j))): # kは戻す個数
            if stone[k] >= 0:
                break
            result -= stone[k]
            scores.add(result)

answer = max(scores)
print(answer)
#

Measured memory_bytes: 3952
#include <iostream>
#include <cassert>
#include <string>
#include <cctype>
using namespace std;
 
string S;
size_t cur = 0;
char readchar();
char peek();
int digit();
int number();
int term();
int expression();
int factor();
 
int main() {
    int N;
    cin >> N;
    for(int i = 0; i < N; ++i){
        cur = 0;
        cin >> S;
        S.resize(S.size()-1);
        cout << expression() << endl;
    }
    return 0;
}
 
char readchar(){
    assert(cur < S.size());
    char ret = S[cur];
    cur += 1;
    return ret;
}
 
char peek(){
    assert(cur < S.size());
    return S[cur];
}
 
int digit(){
    assert(isdigit(peek()));
    int n = readchar() - '0';
    return n;
}
 
int number(){
    int n = digit();
    while(cur < S.size() && isdigit(peek()))
        n = n*10 +digit();
    return n;
}
 
int term()
{
    int a = factor();
    while(cur < S.size() && (peek() == '*' || peek() == '/')){
        char op = readchar();
        int b = factor();
        if (op == '*') a *= b; else a /= b;
    }
    return a;
}
 
int expression(){
    int a = term();
    while(cur < S.size() && (peek() == '+' || peek() =='-'))
    {
        char op =readchar();
        int b = term();
        if(op == '+')
        {
            a += b;
        }
        else a -= b;
    }
    return a;
}
int factor() {
    if (peek() != '(') return number();
    cur += 1;
    int n = expression();
    assert(peek() == ')');
    cur += 1;
    return n;
}
int parse() {return expression();}


Measured memory_bytes: 3168
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int x = scanner.nextInt();
		int t = scanner.nextInt();
		
		int total = 0;
		int rem = n;
		while(rem > 0){
			total += t;
			rem -= x;
		}
		
		System.out.println(total);
	}
}

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

int main() {
    int N, M;  cin >> N >> M;
    vector<int> A(M);
    int sum = 0;
    for (int i = 0; i < M; ++i) {
        cin >> A[i];
        sum += A[i];
    }
    if (sum <= N) cout << (N - sum) << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 3632
n, k = map(int, input().split())
x = list(map(int, input().split()))
minus = []
minus.append(0)
plus = []
plus.append(0)

for n in x:
    if n < 0:
        minus.append(n)
    else:
        plus.append(n)
minus.sort(reverse=True)
totals = []

for i in range(len(minus)):
    if (k-i < len(plus)) and (k-i >= 0):
        if i == 0:
            totals.append(plus[k-i])
        else:
            totals.append(2 * abs(minus[i]) + plus[k-i])
            # print(i)
            # print(abs(minus[i]))
            # print(plus[k-i])
for i in range(len(plus)):
    if (k-i < len(minus)) and (k-i >= 0):
        if i == 0:
            totals.append(abs(minus[k-i]))
        else:
            totals.append(2 * plus[i] + abs(minus[k-i]))
# print(totals)
print(min(totals))


Measured memory_bytes: 14484
#include <bits/stdc++.h>
using namespace std;
struct conv { 
	int l, r, x, pa;
       	bool can_merge(conv oth){
		if(r + 1 == oth.l){
			if(pa != oth.pa) return false;
			if(pa){
				if(x + r + 1 == oth.x + l) return true;
			} else {
				if(x == oth.x) return true;
			}
		}
		return false;
	}	
	conv operator + (conv oth){
		assert(can_merge(oth));
		return {l, oth.r, x, pa};
	}
};
struct node {
	vector<conv> convs;
	int get_id(int x){
		int id = 0;
		for(conv c : convs){
			if(c.l <= x && x <= c.r) return id;
			id++;
		}
		return id;
	}
	int get_val(int x){
		for(conv c : convs) if(c.l <= x && x <= c.r){
			if(c.pa) return c.x + x;
			else return c.x;
		}
		return -1;
	}
	conv get_conv(int l, int r, int x, int y){
		int cl = get_val(x);
		int cr = get_val(y);
		if(cl == cr) return { l, r, cl, 0 };
		return { l, r, cl - l, 1 };
	}
	void simplify(){
		sort(convs.begin(), convs.end(), [](conv a, conv b){
			return a.l < b.l;
		});
		vector<conv> rconvs;
		for(conv c : convs){
			if(rconvs.empty() || !rconvs.back().can_merge(c)) rconvs.push_back(c);
			else rconvs.back() = rconvs.back() + c;
		}
	}
	node operator + (node oth){
		node ans;
		for(conv c : convs){
			if(c.pa){
				int l = c.l, r = c.r;
				while(l <= r){
					int desired = oth.get_id(c.x + l);
					int lo = l + 1, hi = r, best = l;
					while(lo <= hi){
						int mid = (lo + hi)>>1;
						if(oth.get_id(c.x + mid) == desired){
							best = mid;
							lo = mid + 1;
						} else {
							hi = mid - 1;
						}
					}
					ans.convs.push_back(oth.get_conv(l, best, c.x + l, c.x + best));
					l = best + 1;
				}	
			} else {
				ans.convs.push_back({c.l, c.r, oth.get_val(c.x), 0});
			}
		}
		ans.simplify();
		return ans;
	}
};
int main(){
	int X; scanf("%d", &X);
	int k; scanf("%d", &k);
	vector<int> pts(k + 2); for(int i = 0; i < k; i++) scanf("%d", &pts[i + 1]);
       	pts.back() = 1'000'000'001;
	int q; scanf("%d", &q);
	int pt = 0;
	node cur;
	cur.convs.push_back({0, X, 0, 1});
	for(int i = 0; i < q; i++){
		int t, a; scanf("%d %d", &t, &a);
		while(pts[pt + 1] <= t){
			int sz = pts[pt + 1] - pts[pt];
			node now;
			if(pt&1){
				if(sz <= X)
					now.convs.push_back({0, X - sz, sz, 1});
				now.convs.push_back({max(0, X - sz + 1), X, X, 0});
			} else {
				now.convs.push_back({0, min(sz, X), 0, 0});
				if(sz < X)
			       		now.convs.push_back({sz + 1, X, -sz, 1});
			}
			cur = cur + now;	
			pt++;
		}
		int now = cur.get_val(a);
		if(pt&1){
			now += t - pts[pt];
			now = min(now, X);
		} else {
			now -= t - pts[pt];
			now = max(now, 0);
		}
		printf("%d\n", now);
	}	
	return 0;
}


Measured memory_bytes: 1664
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
for i in range(1,n+1):
  if i%5!=0 and i %3 != 0:
    ans +=i
print(ans)

Measured memory_bytes: 67984
#include <iostream>
#include <string>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
	string s;
	cin >> s;
	if (s == "AAA") {
		cout << "No";
	}
	else if (s == "BBB") {
		cout << "No";
	}
	else {
		cout << "Yes";
	}

}

Measured memory_bytes: 3612
"""
Writer: SPD_9X2
https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_d

startとGoalを決めると、その間は奇数回、それ以外は偶数回通ることとなる
また、始点と終点は交換可能なので、始点が左にある方としてよい

始点・終点間は最小１で、好きな位置を2ずつ増やすことが可能
始点から左、終点より右は0があればそれ以降先は全て0にせざるを得ない
それ以外は2,4,6…と2ずつ好きに増やすことが可能

→大体情報が出そろってきた

もし終点と始点が全探索可能だとしたら？
始点より左の最適化 = 終点より右はどうするんだ？
→切れ目を全探索すれば行ける　始点・終点間は自明

高速化→dpだろうなぁ
フェーズごとに分ける

左のずっと0フェーズ→偶数フェーズ→(始点)→奇数フェーズ→(終点)→偶数フェーズ→0フェーズ
の5段階ごとに最小値を持っておいてあげればよい
あとは適当にdp(フェーズは戻っちゃだめだけど飛ばしても良いことに注意)
→解けた！！！
"""

dp = [0] * 5

L = int(input())

for i in range(L):

    ndp = [float("inf")] * 5

    A = int(input())

    ndp[0] = dp[0] + A

    if A == 0:
        D = 2
    else:
        D = A % 2
    ndp[1] = min(dp[0],dp[1]) + D
    ndp[2] = min(dp[0],dp[1],dp[2]) + (A+1)%2
    ndp[3] = min(dp[0],dp[1],dp[2],dp[3]) + D
    ndp[4] = min(dp) + A

    dp = ndp

print (min(dp))

Measured memory_bytes: 55256
#include "iostream"
#include "vector"
#define ll long long int
using namespace std;
int main() {
    ll a,b,k;
    cin>>a>>b>>k;
    
    if(k<=a)
    {
        cout<<a-k<<" "<<b<<endl;
        exit(0);
    }
else if(k<= a+b)
{
    cout<<"0"<<" "<<b-(k-a)<<endl;
}
    
    else
        cout<<"0"<<" "<<"0"<<endl;
    
}


Measured memory_bytes: 256
#include <memory.h>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <cctype>
#include <cstring>
#include <climits>
#include <cmath>
#include <vector>
#include <string>
#include <memory>
#include <numeric>
#include <limits>
#include <functional>
#include <tuple>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <iostream>

#ifndef __GNUC__
#include <intrin.h>
#endif
#include <immintrin.h>

using namespace std;

#define PROFILE_START(i)    clock_t start##i = clock()
#define PROFILE_STOP(i)     fprintf(stderr, "elapsed time (" #i ") = %f\n", double(clock() - start##i) / CLOCKS_PER_SEC)

// https://atcoder.jp/contests/abc149/tasks/abc149_e?fbclid=IwAR0nHOgZ-UygqFHB08BPLs_o3_6r5K2TB_Rd0fV3Ijhcru1aSaIaRQQjo4Y
// E - Handshake

typedef long long           ll;
typedef unsigned long long  ull;

tuple<ll, ll, ll> calc(const vector<int>& A, const vector<ll>& prefixSum, int x) {
    int N = int(A.size());

    ll cnt = 0;
    ll sum = 0;
    ll minX = numeric_limits<ll>::max();

    int j = N - 1;
    for (int i = 0; i < N; i++) {
        while (j >= 0 && (A[i] + A[j]) >= x)
            j--;

        if (j < N - 1) {
            minX = min(minX, 0ll + A[i] + A[j + 1]);
            sum += prefixSum[N] - prefixSum[j + 1] + 1ll * A[i] * (N - 1 - j);
            cnt += N - 1 - j;
        }
    }

    return make_tuple(cnt, sum, minX);
}

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

    int N;
    ll M;
    cin >> N >> M;

    vector<int> A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];
    sort(A.begin(), A.end());

    vector<ll> prefixSum(N + 1);
    for (int i = 0; i < N; i++)
        prefixSum[i + 1] = prefixSum[i] + A[i];

    int lo = 1, hi = A.back() * 2ll;
    while (lo <= hi) {
        int mid = lo + (hi - lo) / 2;

        auto t = calc(A, prefixSum, mid);

        if (get<0>(t) >= M)
            lo = mid + 1;
        else
            hi = mid - 1;
    }

    auto t = calc(A, prefixSum, hi);
    ll ans = get<1>(t) - get<2>(t) * (get<0>(t) - M);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1408
import math

def resolve():
    S = input()
    answer = judge_palindrome(S)
    print(answer)
    

def judge_palindrome(s):
    h = math.floor(len(s) / 2)
    not_palind_count = 0
    s_list = list(s)
    for i in range(h):
        if s_list[i] != s_list[-1*(i+1)]:
            not_palind_count += 1
    return not_palind_count

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 3060
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

#define MOD 1000000007;//1e9+7

int main() {
    string S, T;
    cin >> S >> T;
    cout << T << S << endl;
}

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

int main(){
    string s, t; cin >> s >> t;
    int N = s.size();
    map<char, char> m1, m2;
    for (int i = 0; i < N; i++)
    {
        if(m1.count(s[i])==0 && m2.count(t[i])==0){
            m1[s[i]] = t[i];
            m2[t[i]] = s[i];
            continue;
        }
        if(m1.count(s[i])==0) m1[s[i]] = t[i];
        if(m2.count(t[i])==0) m2[t[i]] = s[i];
        
        if(m1[s[i]] != t[i] || m2[t[i]] != s[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 904
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
sumA = sum(A)

for i, b in enumerate(B):
    c = min(A[i], b)
    A[i] -= c
    A[i + 1] -= min(A[i + 1], b - c)

print(sumA - sum(A))

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

int main(){
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  
  if(s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3548
n=int(input())
import bisect
l=[1,6,9,36,81,216,729,1296,6561,7776,46656,59049]
def draw(x,y):
    ind=bisect.bisect_right(l,x)-1
    if ind==0:
        return y+x
    else:
        y += 1
        x1=x-l[ind]
        x2=x-l[ind-1]
        if x1==0 or x2==0:
            return y
        else:
            return(min(draw(x1,y),draw(x2,y)))
print(draw(n,0))

Measured memory_bytes: 9124
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, k, sum, diff;
		TreeSet<Integer> ts = new TreeSet<Integer>();
		TreeSet<Integer> nts = new TreeSet<Integer>();

		while (true) {
			n = sc.nextInt();
			if (n == 0) {
				break;
			}

			sum = 0;
			ts.clear();
			nts.clear();
			for (int i = 0; i < n; i++) {
				k = sc.nextInt();
				sum += k;
				nts.add(k);
				for (Integer x: ts) {
					nts.add(x + k);
				}
				for (Integer x: nts) {
					ts.add(x);
				}
			}

			diff = 0;
			while (true) {
				if (ts.contains(sum / 2 - diff)) {
					System.out.println(sum - 2 * (sum / 2 - diff));
					break;
				}
				diff++;
			}
		}
	}
}

Measured memory_bytes: 31188
#include<iostream>
using namespace std;
int p[200005];
  int s[200005];
 int find(int v)
  {
if(v==p[v])
  return v;
    return p[v]=find(p[v]);
  }
  
  void uni(int a,int b)
  {
     a=find(a);
    b=find(b);
    if(a!=b)
    {   p[b]=a;
    s[a]+=s[b];
    }
    }

int main()
{
int n,m;
  cin>>n>>m;
  
    for(int i=0;i<n+1;i++)
    { 
      p[i]=i;
      s[i]=1;
    }
    
    
  int a,b;
  while(m--)
  {
  cin>>a>>b;
    uni(a,b);
  }
  int ma=0;
  for(int i=1;i<n+1;i++)
    if(ma<s[i])
      ma=s[i];
  cout<<ma<<endl;
}

Measured memory_bytes: 5200
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
string s;
int k;

int dp[324][324][324];

int main(){
	cin >> s >> k;
	int n = s.size();
	s = "*" + s;
	for(int i = 0;i < 324;i++)
		for(int j = 0;j < 324;j++)
			for(int k = 0;k < 324;k++)
				dp[i][j][k] = -100000;
	
	dp[0][n+1][0] = 0;
	for(int i = 0;i <= n;i++){
		for(int j = n+1;j > i;j--){
			for(int k = 0;k <= n;k++){
				if(i > 0)dp[i][j][k] = max(dp[i][j][k], dp[i-1][j][k]);
				dp[i][j][k] = max(dp[i][j][k], dp[i][j+1][k]);
				dp[i][j][k] = max(dp[i][j][k], dp[i][j+1][k]);
				int cost = s[i] != s[j];
				if(k-cost >= 0 && i > 0)
					 dp[i][j][k] = max(dp[i][j][k], dp[i-1][j+1][k-cost] + 1);
			}
		}
	}
	int res = 0;
	for(int i = 1;i <= n+1;i++){
		for(int j = 0;j <= k;j++){
			res = max(res, dp[i-1][i+1][j] * 2 + 1);
			res = max(res, dp[i-1][i][j]*2);
		}
	}

	cout << res << endl;
	return 0;
}
					

Measured memory_bytes: 133752
int main(void) {
  int N;
  scanf("%d", &N);
  int n;
  if (100 <= N && N <= 999) {
    n = N % 10 % 10;
  }
  if (0 <= N && N <= 9) {
    n = N;
  }
  if (10 <= N && N <= 99) {
    n = N % 10;
  }
  switch (n) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      printf("hon\n");
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      printf("pon\n");
      break;
    case 3:
      printf("bon\n");
      break;
  }
  return 0;
}

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

int main() {

  int A1, A2, A3; cin >> A1 >> A2 >> A3;
  int M, m;
  M = max({A1, A2, A3});
  m = min({A1, A2, A3});
  cout << M - m << endl;
    
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

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

  cout << 0 << endl;
  string init; cin >> init;
  if(init == "Vacant") {
    return 0;
  }

  int l = 0, r = n;
  while(r-l > 1) {
    int mid = l+(r-l)/2;
    cout << mid << endl;
    string s; cin >> s;
    if(s == "Vacant") return 0;

    if(mid%2==0 ^ s != init ) l=mid;
    else r=mid;
  }
  cout << r << endl;
}

Measured memory_bytes: 3840
use std::io;
use std::io::prelude::*;
use std::str::FromStr;


fn calc_radius(cur: i32, prev: i32, n: usize, tos: &Vec<Vec<i32>>)
        -> (i32, i32) {
    let mut maxdep = 0;
    let mut maxpos = cur;
    let nexts = &tos[cur as usize];
    for next in nexts {
        if *next == prev {
            continue;
        }
        let (getdep, getpos) = calc_radius(*next, cur, n, tos);
        if maxdep < getdep + 1 {
           maxdep = getdep + 1;
           maxpos = getpos;
        }
    }
    return (maxdep, maxpos)    
}

fn main() {
    let stdin = io::stdin();
    let mut data = stdin.lock().lines();
    let n = {
        let line = data.next().unwrap().unwrap();
        usize::from_str(&line).unwrap()
    };
    let mut tos = Vec::new();
    for _ in 0..n {
        tos.push(Vec::new());
    }
    for _ in 0..((n - 1) as usize) {
        let (x, y) = {
            let line = data.next().unwrap().unwrap();
            let mut line_split = line.split(' ');
            (i32::from_str(line_split.next().unwrap()).unwrap(),
             i32::from_str(line_split.next().unwrap()).unwrap())
        };
        tos[(x - 1) as usize].push(y - 1);
        tos[(y - 1) as usize].push(x - 1);
    }
    let (_, a) = calc_radius(0, -1, n, &tos);
    let (radius, _) = calc_radius(a, -1, n, &tos);
    if radius % 3 == 1 {
        println!("Second");
    } else {
        println!("First");
    }
}

Measured memory_bytes: 24692
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
const int INF = 1001001001;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define re0 return 0

int npr(int n , int r){//nPr
    r = n - r;
    int sum = 1;
    int i;
    for (i=n;i>=r+1;i--)sum*=i;
    return sum;
}
int gcd(int a, int b) {//最大公約数
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {//最小公倍数
    return a * b / gcd(a, b);
}
int digsum(int n) {//桁和
    int res = 0;
    while(n > 0) {
        //res += n%10;
        //　↑をres++;にすれば桁数
         res++;
        n /= 10;
    }
    return res;
}
bool isPrime(int x){//素数判定
    if(x==1)return 0;
    if(x==2)return 1;
    if(x%2==0)return 0;
    for(int i=3;i*i<=x;i++)if(x%i==0)return 0;
    return 1;
}
/*bit全探索
for (int bit = 0; bit < (1<<N); ++bit) {
}
if (bit & (1 << i)) {
}
*/


signed main(){ 
    string s;
    cin >>s;
    if(s=="Sunny"){
        cout << "Cloudy"<<endl;
    }else if(s=="Cloudy"){
        cout << "Rainy"<<endl;
    }else if(s=="Rainy"){
        cout << "Sunny"<<endl;
    }
    return 0;
}


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

using namespace std;
using ll = long long;


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

    if(a.size() != b.size()){
        cout << (a.size() > b.size() ? "GREATER" : "LESS") << endl;
        return 0;
    }

    if(a == b){
        cout << "EQUAL" << endl;
    }else if(a > b){
        cout << "GREATER" << endl;
    }else{
        cout << "LESS" << endl;
    }

}

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


# プラススタート ------------------
ans01 = 0
temp = a[0]
if (temp > 0):
    pass
else:
    add = abs(temp) + 1
    ans01 += add
    temp = 1

for i in range(1, n):
    tar = temp + a[i]
    if (tar * temp < 0):
        temp = tar
    else:
        add = abs(tar) + 1
        ans01 += add
        if (temp > 0):
            temp = -1
        else:
            temp = 1
    #print(tar, ans)
# マイナススタート ------------------
ans02 = 0
temp = a[0]
if (temp < 0):
    pass
else:
    add = abs(temp) + 1
    ans02 += add
    temp = -1

for i in range(1, n):
    tar = temp + a[i]
    if (tar * temp < 0):
        temp = tar
    else:
        add = abs(tar) + 1
        ans02 += add
        if (temp > 0):
            temp = -1
        else:
            temp = 1
    #print(tar, ans)

ans = min(ans01, ans02)

print(ans)


Measured memory_bytes: 14504
#include <iostream>
using namespace std;
 
int cnt=0;
 
int insertionSort(int A[],int n,int g){
    for(int i=g;i<=n-1;i++){
        int v=A[i];
        int j=i-g;
        while(j>=0&&A[j]>v){
            A[j+g]=A[j];
            j=j-g;
            cnt++;
        }
        A[j+g]=v;
    }
}
 
int main(){
    int i,n;
    int m=0;
    int G[13]={1,4,13,40,121,364,1093,3280,9841,29524,88573,265720,797161};
    cin >> n;
    while(n>G[m]||(n==1&&m==0)) m++;
    int A[n];
    for(i=0;i<n;i++) cin>>A[i];
    for(i=m-1;i>=0;i--) insertionSort(A,n,G[i]);
    cout<<m<<endl;
    for(i=m-1;i>=0;i--){
        if(i!=0) cout << G[i] << " ";
        else cout << G[i] << endl;
    }
    cout<<cnt<<endl;
    for(i=0;i<n;i++) cout<<A[i]<<endl;
}

Measured memory_bytes: 7000
S = input()

tmp = 0
length = 0
ans = 100
for s in S:
    for t in S:
        if t != s:
            tmp += 1
        else:
            length = max(tmp, length)
            tmp = 0
    else:
        length = max(tmp, length)
        tmp = 0
    ans = min(ans, length)
    length = 0

print(ans)

Measured memory_bytes: 67132
#include<bits/stdc++.h>
#define fr(i,x,y) for(int i=x;i<=y;++i)
#define rf(i,x,y) for(int i=x;i>=y;--i)
#define LL long long
using namespace std;
const int N=110;
int a[N];

int main(){
	int n;scanf("%d",&n);
	fr(i,1,n) scanf("%d",&a[i]);
	int maxn=1e9;
	fr(i,-100,100){
		int pos=0;
		fr(j,1,n){
			pos+=(a[j]-i)*(a[j]-i);
		}
		maxn=min(maxn,pos);
	}
	cout<<maxn<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int N,A;
	cin>>N;
	cin>>A;
	int x=N/500*500;
	int y=N%500;

	if (y<=A){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val k = sc.nextInt()
    println(problem120b(a, b, k))
}

fun problem120b(a: Int, b: Int, k: Int): Int {
    val list = mutableListOf<Int>()
    for (i in 1..100) {
        if (a % i == 0 && b % i == 0) list.add(i)
    }
    return list.sortedDescending()[k - 1]
}

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

int main(){
	int n, i, j, k;
	cin >> n;
	int arr[1000001]={0};

	for(i=1; i<=100; i++){
		for(j=1; j<=100; j++){
			for(k=1; k<=100; k++){
				int x = i*i + j*j + k*k + i*j + j*k + k*i;
				// cout << "AA" << x << "\n";
				arr[x]++;
			}
		}
	}

	for(i=1; i<=n; i++)
		cout << arr[i] << "\n";
}

Measured memory_bytes: 7496
import collections
n = int(input())
a = input()
a = a.replace('R','1')
a = a.replace('G','2')
a = a.replace('B','3')
a = tuple(map(int,list(a)))
b = collections.Counter(a)
ans =b[3]*b[1]*b[2]
for i in range(n-2):
    for j in range(i+1,n):
        if a[i] == a[j]:
            continue
        c = j*2 -i
        if c < n:
            if a[i]+a[j]+a[c]==6:
                ans -= 1
        else:
            break
print(ans)

Measured memory_bytes: 9424
#include <bits/stdc++.h>
#include <iostream>
#include <cstdlib>
 
using namespace std;
 
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if(A < C  && C<B){
     cout << "Yes" << endl;
  }
  else if(B<C&&C<A){
     cout << "Yes" << endl;}
  else{
  cout << "No" << endl;
}
}



Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n,p[50],flag=0,ele_1=0,ele_2=0;
	scanf("%d",&n);
	int i,j;
	for(i=1;i<=n;i++){
		scanf("%d",&p[i]);
	}
	for(i=1;i<=n;i++){
		if(p[i]!=i && flag == 0){
			flag++;
			ele_1=i;
		}
		else if(p[i] != i && flag == 1){
			flag++;
			ele_2=i;
		}
		else if(p[i] != i)
			flag++;
	}
	if(flag == 2 && ele_1 == p[ele_2] && ele_2 ==p[ele_1] || flag ==0)
		puts("YES");
	else
		puts("NO");
	return 0;
}
		

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

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

int main(){
	int N;
	cin >> N;
	vector<int> d(N);
	rep(i,N) cin >> d[i];
	if(N%2) cout << 0 << endl;
	else{
		sort(d.begin(),d.end());
		cout << d[N/2]-d[N/2-1] << endl;
	}

	return 0;
}

Measured memory_bytes: 640
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
sys.setrecursionlimit(10**6)

n,k = na()
s = 'p'+ns()+'p'
a = 0

for i in range(1,n+1):
    if (s[i] == "L" and s[i-1] == "L") or (s[i] == "R" and s[i+1] == "R"):
        a+=1

print(min(a+2*k,n-1))

Measured memory_bytes: 3316