akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int n,tmp,ans=10000 ;

int main(void){
    
    int i;
    int j;
    scanf("%d",&n);
    for(i=0;i<=n;i++){
        int sum=0;
        j=n-i;
         tmp=i;
        while(tmp){
            sum+=tmp%6;
            tmp/=6;
        }
        tmp=j;
        while(tmp){
            sum+=tmp%9;
            tmp/=9;
        }
        if(ans>sum)
            ans=sum;
            
    }
    printf("%d",ans);
}


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

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

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

#define INF 1001001001

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

    int n, m;
    cin>>n>>m;
    int s = pow(2, n);
    vector<vector<ll>> dp(m + 1, vector<ll>(s, INF));
    dp[0][0] = 0;
    rep(i, m) {
        ll a, b;
        cin>>a>>b;
        int c = 0;
        rep(j, b) {
            int d;
            cin>>d; d--;
            d = 1<<d;
            c |= d;
        }
        rep(j, s) {
            chmin(dp[i + 1][j], dp[i][j]);
            chmin(dp[i + 1][j | c], dp[i][j] + a);
        }
    }
    if (dp[m][s - 1] == INF) cout<<-1<<endl;
    else cout<<dp[m][s - 1]<<endl;
}

Measured memory_bytes: 32384
#include <iostream>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  if (c >= a && c <= b)
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include<iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
using namespace std;
 
int main(){    
  string S;
  char s,s0;
  cin >> S;
  int N = S.length(); 
  int A[N+1];
  int i = 0,count = 0;
  vector<int> vec;
  vector<int> vec2;

  s0 = S[0];
  s = S[0];
  for(int i=0;i<N;i++){
    if(s == S[i]){     
      count++;
      if(i==N-1){
	vec.push_back(count);
      }
    }
    else{
      s = S[i];
       vec.push_back(count);
       count = 1;
       if(i==N-1){
	 vec.push_back(count);
       }
     }
  }

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

  if(s0 == '>' && S.length() == 1){
    cout << 1 << endl;
    return 0;
  }

  if(s0 == '<'){
    for(int i=0;i<vec.size()/2;i++){
      if(vec[2*i] < vec[2*i+1]){
	vec2.push_back(vec[2*i]-1);
	vec2.push_back(vec[2*i+1]);
      }
      else{
	vec2.push_back(vec[2*i]);
	vec2.push_back(vec[2*i+1]-1);
      }
    }
    if(vec.size()%2 == 1){
      vec2.push_back(vec[vec.size()-1]);
    }
  }
  else{
    if(vec.size()%2 == 1){
       vec2.push_back(vec[0]);
      for(int i=0;i<vec.size()/2;i++){
	if(vec[2*i+1] < vec[2*i+2]){
	vec2.push_back(vec[2*i+1]-1);
	vec2.push_back(vec[2*i+2]);
	}
	else{
	  vec2.push_back(vec[2*i+1]);
	  vec2.push_back(vec[2*i+2]-1);
	}
      }
    }
    else{
      vec2.push_back(vec[0]);
      for(int i=0;i<vec.size()/2 - 1;i++){
	if(vec[2*i+1] < vec[2*i+2]){
	  vec2.push_back(vec[2*i+1]-1);
	  vec2.push_back(vec[2*i+2]);
	}
	else{
	  vec2.push_back(vec[2*i+1]);
	  vec2.push_back(vec[2*i+2]-1);
	}
      }
      vec2.push_back(vec[vec.size()-1]);
    }
  }


  long long k;
  long long sum=0;
  for(int i=0;i<vec2.size();i++){
    k = vec2[i];
    sum += (long long)(k*(k+1))/2;
  }

  cout << sum << endl;
  
}


Measured memory_bytes: 3196
package main

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

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	t := sc.Text()
	return strconv.Atoi(t)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	x, _ := nextInt(sc)

	if x == 0 {
		fmt.Println("1")
	} else if x == 1 {
		fmt.Println("0")
	}
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
int x[4];
int main(){
    cin>>x[0]>>x[1]>>x[2]>>x[3];
    sort(x, x+4);
    if(x[0] == 1 && x[1] == 4 && x[2] == 7 && x[3] == 9)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


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

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> s(H);
  rep(i,H) cin >> s[i];
  int ans = 0;
  rep(is,1<<H)rep(js,1<<W){
   int cnt = 0;
    rep(i,H)rep(j,W) {
     if(is>>i&1) continue;
     if(js>>j&1) continue;
     if(s[i][j] == '#') cnt++;
    }
    if(cnt == K) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i,a,b) for(int(i)=(a);(i)<(b);++(i))
#define RREP(i,a,b) for(int(i)=(a)-1;(i)>=(b);--(i))
#define ALL(x) (x).begin(),(x).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
using namespace std;
typedef long long ll;

int main()
{
  int N,X;
  cin >> N >> X;
  vector<int> L(N);
  REP(i,0,N) cin >> L[i];

  ll D = 0;
  ll ans = 1;  // X 以下の領域でボールが跳ねる回数
  REP(i,0,N) {
    D += L[i];
    if (D <= X) ++ans;
    else break;
  }
  cout << ans << endl;

  return 0;
}


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

int main(){
  int n;
  cin>>n;
  
  bool hantei = false;
  
  int r;
  
  for(int i = 0; i < 3; i++){
    r = n % 10;
    if(r == 7) hantei = true;
    n /= 10;
  }
  
  if(hantei){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}
    

Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cstring>
#include <stdio.h>
#include <cstdlib>
#include <numeric>
#include <iomanip>
using namespace std;

int main(){
    int frag=0;
    string s;
    cin >> s;
    if(s[0]!='A'){
        cout << "WA";
        return 0;
    }
    for(int i=2;i<s.length()-1;i++){
        if(s[i]=='C'){
            frag++;
        }
    }
    if(frag!=1){
        cout << "WA";
        return 0;
    }
    for(int i=0;i<s.length();i++){
        if(isupper(s[i])!=0){
            frag++;
        }
    }
    if(frag!=3){
        cout << "WA";
        return 0;
    }
    cout << "AC";
}

Measured memory_bytes: 256
<?php
$b=trim(fgets(STDIN));
$a=explode(' ',trim(fgets(STDIN)));
for($i=1;$i<$b;$i++)$a[$i]+=$a[$i-1];
$c=1<<31;
for($i=0;$i<$b-1;$i++)$c=min($c,abs($a[$b-1]-2*$a[$i]));
echo $c.PHP_EOL;

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

int main() {
int N;
cin >> N;
int num = 0;
for(int i = 1; i <= N; i+=2){
int count = 0;
 for(int j = 1; j <= i; j++){
 if(i%j == 0){
 count++;}}
if(count == 8){
num++;}}
cout << num << endl;}


Measured memory_bytes: 256
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N = I()
A = LI()

X = []
Y = 1000

for i in range(N):
    for x in X:
        if Y < x[0]*A[i]+x[1]:
            Y = x[0]*A[i]+x[1]
    X.append((Y//A[i],Y%A[i]))

print(Y)

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

constexpr int M = 1012345;
constexpr int64_t mod = 998'244'353;
int64_t ten[M];
int64_t s[M][10], flag[M], a[M];

void build(int o, int l, int r) {
  if (l == r) {
    for (int i = 0; i < 10; ++i) {
        s[o][i] = 1LL * i * ten[l] % mod;
    }
  } else {
    const int m = (l + r) >> 1;
    build(o+o, l, m);
    build(o+o+1, m+1, r);
    for (int i = 0; i < 10; ++i) {
      s[o][i] = (s[o+o][i] + s[o+o+1][i]) % mod;
    }
  }
  flag[o] = 1;
  a[o] = s[o][1];
}

void update(int o, int l, int r, int ql, int qr, int qv) {
  if (l > qr || r < ql) return;
  if (ql <= l && r <= qr) {
    flag[o] = qv;
    a[o] = s[o][flag[o]];
  } else {
    if (flag[o] >= 0) {
      flag[o+o] = flag[o];
      flag[o+o+1] = flag[o];
      a[o+o] = s[o+o][flag[o]];
      a[o+o+1] = s[o+o+1][flag[o]];
      flag[o] = -1;
    }
    const int m = (l + r) >> 1;
    update(o+o, l, m, ql, qr, qv);
    update(o+o+1, m+1, r, ql, qr, qv);
    a[o] = (a[o+o]+a[o+o+1]) % mod;
  }
}

int main() {
  ios::sync_with_stdio(false);
  ten[0] = 1;
  for (int i = 1; i < M; ++i) {
    ten[i] = ten[i - 1] * 10LL % mod;
  }
  int n, q;
  cin >> n >> q;
  build(1, 0, n - 1);
  for (int i = 0; i < q; ++i) {
    int l, r, v;
    cin >> l >> r >> v;
    int ql = n - r;
    int qr = n - l;
    update(1, 0, n - 1, ql, qr, v);
    cout << a[1] << endl;
  }
  return 0;
}



Measured memory_bytes: 60732
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int sum=0;
  for(int i=0;i<m;i++){
    int d;
    cin>>d;
    sum+=d;
  }
  if(sum>n){
    cout<<-1<<endl;
  }else{
    cout<<n-sum<<endl;
   }
}


Measured memory_bytes: 3632
program test03
 implicit none
 integer N, M
 integer i
 integer,allocatable :: AC(:)
 integer,allocatable :: WA(:)
 integer Nnum
 character Nkek*2
 integer :: allAC=0, allWA=0


 read *, N, M
 allocate(AC(N))
 allocate(WA(N))
 AC=0; WA=0

 do i=1,M
  read *, Nnum, Nkek
  if ( Nkek == 'AC' ) then
   AC(Nnum)=1
  else
   if ( AC(Nnum) == 0 ) then
   WA(Nnum)=WA(Nnum)+1
   end if
  end if
 end do

 do i=1,N
  allAC=allAC+AC(i)
  if ( AC(i) == 1 ) then
   allWA=allWA+WA(i)
  end if
 end do

 print '(i0,A,i0)', allAC, ' ',allWA

endprogram test03


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


int main() {
	long K;
	string s;
	cin >> s;
	cin >> K;
	for(int i=0;i<s.size();i++) {
		if(s[i]=='a') {
			continue;
		}
		if(K>=(27-long(s[i]-'a'+1))) {
			K-=(27-long(s[i]-'a'+1));
			s[i]='a';
			continue;
		}
		//else
		//continue;
	}
	K=K%26;
	if(K>0) {
		s[s.size()-1] = (long(s[s.size()-1] - 'a')+K) + 'a';
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    double p=0;
    for(int i=1; i<=a; i++)
    {
        double t=1.0/a;
        int n=i;
        while(n<b)
        {
            n*=2;
            t/=2;
        }
        p+=t;
    }
    printf("%.12f\n",p);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    string s, t;
    cin>>s>>t;
    int n = s.size(), m = t.size();
    vector<vector<pair<int, pair<int, int>>>> dp(n+1, vector<pair<int, pair<int, int>>> (m+1, {0, {0, 0}}));
    string ans = "";
    for(int i = 1;i<=n;i++)
    {
        for(int j = 1;j<=m;j++)
        {
            if(s[i-1] == t[j-1])
            {
                dp[i][j].first = dp[i-1][j-1].first + 1;
                dp[i][j].second = {i-1, j-1};
            }
            else
            {
                if(dp[i-1][j].first > dp[i][j-1].first)
                {
                    dp[i][j].first = dp[i-1][j].first;
                    dp[i][j].second = {i-1, j};
                }
                else
                {
                    dp[i][j].first = dp[i][j-1].first;
                    dp[i][j].second = {i, j-1};
                }
            }
        }
    }
    int i = n, j = m;
    while(true)
    {
        if(i == 0 and j == 0)
        {
            break;
        }
        if(s[i-1] == t[j-1])
        {
            ans.push_back(s[i-1]);
        }
        int x = i, y = j;
        
        i = dp[x][y].second.first;
        j = dp[x][y].second.second;
    }
    reverse(ans.begin(), ans.end());
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 108988
#include <iostream>

using namespace std;

int f(int d) { return d * d; }

int main() {
	int n, sum;
	while (cin >> n) {
		sum = 0;
		for (int i = 1; i * n < 600; i++) {
			sum += f(i * n) * n;
		}
		cout << sum << endl;
	}
	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n;
	cin >> n;
	priority_queue<double, vector<double>, greater<double> > pq;
	rep (i, n) {
	  double a;
	  cin >> a;
	  pq.push(a);
	}
	while (pq.size() > 1) {
	  double x, y;
	  x = pq.top();
	  pq.pop();
	  y = pq.top();
	  pq.pop();
	  pq.push((x + y) / 2);
	}
	cout << pq.top() << endl;
	
    return 0;
}



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

int main() {
  vector<int> matrix(2);
  for (int i = 0; i < 2; i++)
  {
    cin >> matrix.at(i);
  }
  
  string data[matrix.at(0)];
  for (int i = 0; i < matrix.at(0); i++)
  {
    cin >> data[i];
  }

  for(int row = 0; row < matrix.at(0); row++)
  {
    for(int col = 0; col < matrix.at(1); col++)
    {
      if(data[row].at(col) == '#')
        continue;
      
      int countOfBomb = 0;
      for(int i = -1; i <= 1; i++)
      {
        if(row == 0 && i == -1)
          continue;
        if(row == matrix.at(0) - 1 && i == 1)
          break;
        
        for(int j = -1; j <= 1; j++)
        {
          if(i == 0 && j == 0)
            continue;
          if(col == 0 && j == -1)
            continue;
          if(col == matrix.at(1) - 1 && j == 1)
            break;
          
          if(data[row + i].at(col + j) == '#')
            countOfBomb++;
        }
      }
      data[row].at(col) = '0' + countOfBomb;
    }
    cout << data[row] << endl;
  }
  return 0;
}

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

int main(){
  int a,b;
  char op;
  while(1){
    cin >> a >> op >> b;
    if(op == '?')break;
    switch(op){
      case '+':
      cout << a + b;
      break;

      case '-':
      cout << a - b;
      break;

      case '*':
      cout << a * b;
      break;

      case '/':
      cout << a / b;
      break;

      default:
      break;
    }
    cout << '\n';
  }
  return 0;
}


Measured memory_bytes: 3124
N,K = map(int,input().split())
a = list(map(int,input().split()))

dp = [False]*(K+1)
for i in range(1,K+1):
    for step in a:
        if i - step >= 0:
            dp[i] |= not dp[i-step]
if dp[K]:
    print('First')
else:
    print('Second')

Measured memory_bytes: 41836
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {
  
  ll a, b;
  cin >> a >> b;
  int k;
  cin >> k;

  for(int i = a; i <= b; i++) {
    if(i < a+k || i > b-k) {
      cout << i << endl;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y;
  cin>>x;
  vector<int> z(x);
  for(y=0;y<x;y++) cin>>z.at(y);
  sort(z.begin(),z.end());
  cout<<z.at(x-1)-z.at(0)<<endl;
}

Measured memory_bytes: 3584
#include<iostream>
using namespace std;
int N;
long D[10][10];
main()
{
	cin>>N;
	for(int i=1;i<=N;i++)
	{
		int x=i;
		while(x>=10)x/=10;
		D[x][i%10]++;
	}
	long ans=0;
	for(int i=0;i<10;i++)for(int j=0;j<10;j++)ans+=D[i][j]*D[j][i];
	cout<<ans<<endl;
}


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

   int main() {
   string W,T;
   cin>>W;
   for(int i=0;i<W.size();i++){
     W.at(i)=(char)tolower(W.at(i));}
   int count=0;
   while(cin>>T){
    if(T=="END_OF_TEXT"){break;}
    for(int i=0;i<T.size();i++){
     T.at(i)=(char)tolower(T.at(i));}
    if(T==W){count++;}
   }
     cout<<count<<endl;
   return 0;
    }


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

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++)
    cin >> a[i];
  
  long long ans=(a[0]>0 ? 0:1-a[0]);
  long long now=(a[0]>0 ? a[0]:1);
  for(int i=1;i<n;i++)
  {
    if(now<0 and now+a[i]<=0)
    {
      ans+=(1-(now+a[i]));
      now=1;
    }
    else if(now>0 and now+a[i]>0)
    {
      ans+=(now+a[i]-(-1));
      now=-1;
    }
    else now=now+a[i];
//    cout << i << " " << ans << " " << now << endl;
  }
  long long ans2=(a[0]<0 ? 0:a[0]-(-1));
  now=(a[0]<0 ? a[0]:-1);
  for(int i=1;i<n;i++)
  {
    if(now<0 and now+a[i]<=0)
    {
      ans2+=(1-(now+a[i]));
      now=1;
    }
    else if(now>0 and now+a[i]>0)
    {
      ans2+=(now+a[i]-(-1));
      now=-1;
    }
    else now=now+a[i];
//    cout << i << " " << ans2 << " " << now << endl;
  }
  
  cout << (ans<ans2 ? ans:ans2) << endl;
}

Measured memory_bytes: 640
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

LL n, k;
LL a[101010];
LL num[101];
LL dp[101][2];

int main(){
    cin >> n >> k;
    REP(i, n)cin >> a[i];
    REP(i, 45){
        REP(j, n){
            if((a[j] >> 1) & 1)num[i]++;
        }
    }
    LL x = 0;
    for(LL m = 45;m >= 0;m--){
        if(x + (1LL << m) > k)continue;
        int cnt = 0;
        REP(i, n){
            cnt += (a[i] >> m) & 1;
        }
        if(cnt < n - cnt)x += (1LL << m);
    }
    LL ans = 0;
    REP(i, n)ans += (a[i] ^ x);
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	int n;
	cin >> n;
	vector<string> s(n);
	REP(i, n) { cin >> s[i]; }
	unordered_map<string, int> result;
	REP(i, n) { result[s[i]]++; }
	cout << "AC x " << result[string("AC")] << endl;
	cout << "WA x " << result[string("WA")] << endl;
	cout << "TLE x " << result[string("TLE")] << endl;
	cout << "RE x " << result[string("RE")] << endl;
	return 0;
}


Measured memory_bytes: 6432
#include <iostream>
typedef long long ll;
bool isPrime(ll a);

int main()
{
	using namespace std;
	ll A[10001];
	int n, prime = 0;
	cin >> n;
	for (int i = 0;i < n;i++)
	{
		cin >> A[i];
		if (isPrime(A[i]))
		{
			prime++;
		}
	}
	cout << prime << endl;
	return 0;
}

bool isPrime(ll a)
{
	for (ll i = 2;i*i <= a;i++)
	{
		if (a%i == 0)
		{
			return false;
		}
	}
	return true;
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int dx = b - d;
	int dy = c - a;
	c += dx;
	d += dy;
	printf("%d %d ", c, d);
	dx ^= dy ^= dx ^= dy;
	dx = -dx;
	printf("%d %d\n", c + dx, d + dy);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int M = 1000000007;
using P = pair<int, int>;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<P> p(n);
    vector<int> idx(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i].first >> p[i].second;
        idx[i] = i;
    }
    int c = 0;
    double sum = 0;
    do
    {
        ++c;
        for (int i = 1; i < n; ++i) {
            sum += sqrt((p[idx[i]].first - p[idx[i - 1]].first) * (p[idx[i]].first - p[idx[i - 1]].first) + (p[idx[i]].second - p[idx[i - 1]].second) * (p[idx[i]].second - p[idx[i - 1]].second));
        }
    } while (next_permutation(idx.begin(), idx.end()));
    cout << setprecision(14) << sum / c << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

string solve(char op, string t1, string t2) {
	string ret = "";
	unsigned int i = 0, j = 0;
	while (i < t1.size() && j < t2.size()) {
		if (t1[i] == t2[j]) {
			ret += t1[i];
			i ++;
			j ++;
		} else {
			bool comma = (t1[i] == ',' || t2[i] == ',');
			if ((comma && t1[i] == ',') || (!comma && t1[i] == ')')) {
				swap(i, j);
				swap(t1, t2);
			}
			int c = 0;
			unsigned int k = i;
			for ( ; k<t1.size(); ++k) {
				if (t1[k] == '(') c ++;
				else if (t1[k] == ')') c --;
				if (c <= 0) {
					break;
				} else if (op == 'u') { // for union
					ret += t1[k];
				}
			}
			if (op == 'u') ret += t1[k]; // for union
			i = k + 1;
		}
	}
	return ret;
}

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

	char op;
	string t1, t2;
	while (cin >> op) {
		cin >> t1 >> t2;
		cout << solve(op, t1, t2) << endl;
	}

	return 0;
}

Measured memory_bytes: 1196
#include "bits/stdc++.h"
using namespace std;

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

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

    int n;
    cin >> n;

    vector<LD> p(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
    }

    vector<vector<LD>> dp(n + 1, vector<LD>(n + 1));
    dp[0][0] = 1.0;
    for (int i = 1; i <= n; i++) {
        dp[0][i] = dp[0][i - 1] * (1.0 - p[i]);
    }

    for (int i = 1; i <= n; i++) {
        for (int j = i; j <= n; j++) {
            dp[i][j] += dp[i - 1][j - 1] * p[j];
            dp[i][j] += dp[i][j - 1] * (1.0 - p[j]);
        }
    }

    LD ans = 0;
    for (int i = (n + 1)/2; i <= n; i++) {
        ans += dp[i][n];
    }

    cout << fixed << setprecision(15) << ans << "\n";
    return 0;
}


Measured memory_bytes: 141056
n,k=map(int,input().split())
p=list(map(int,input().split()))
max_p=max(p)
e=[-1 for _ in range(max_p+1)]


def calc_e(i):
    if(e[i]==-1):
        ei=(i+1)/2
        e[i]=ei
        return ei
    else:
        return e[i]

ans=0
for i in range(k):
    ans+=calc_e(p[i])

now_e=ans
for i in range(1,n-k+1):
    now_e-=calc_e(p[i-1])
    now_e+=calc_e(p[i+k-1])
    if(ans<now_e):
        ans=now_e
print(ans)


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

int main() {
  int N;
  cin >> N;
  int sum = 1;
  
  vector<string> vec(N);
  
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  
  for(int i = 0; i + 1 < N; i++) {
    if(vec.at(i) != vec.at(i + 1)) {
      sum += 1;
    }
  }
  cout << sum << endl;
}
      

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define lep(j,n) for(int j=0; j<(n); j++)
#define reps(i,n) for(int i=1; i<(n); i++)
#define leps(j,n) for(int j=1; j<(n); j++)
#define pii pair<int,int>
#define gsort(x,n) sort((x),(x)+(n),greater<int>())
#define all(x) (x).begin(), (x).end()
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const long long mod = 1000000007;
using namespace std;

#define return(Z) re:(Z)

long long h[10000010],x[10000010],z[10000010];

signed main(){

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

    int a,b,c,cnt=0,ans=0;
    string s,w;
    bool p,q;

    cin>>s;
    for(int i=0; i<4; i++){
        if(s[i]=='+') cnt++;
        else cnt--;
    }
    cout<<cnt<<'\n';
    re:(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <iomanip>

const double INF = 1 << 30;

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

    std::vector<double> x_max = {-INF, -INF, -INF, -INF},
                        x_min = {INF, INF, INF, INF},
                        y_max = {-INF, -INF, -INF, -INF},
                        y_min = {INF, INF, INF, INF};

    for (int i = 0; i < N; i++) {
        double x, y;
        char d;
        std::cin >> x >> y >> d;

        int k = d == 'R' ? 0 : d == 'L' ? 1 : d == 'U' ? 2 : 3;
        x_max[k] = std::max(x_max[k], x);
        x_min[k] = std::min(x_min[k], x);
        y_max[k] = std::max(y_max[k], y);
        y_min[k] = std::min(y_min[k], y);
    }

    std::set<double> s;
    s.insert(0.0);

    auto f = [&s](double a, double b, double c) {
        if (std::abs(a) < INF && std::abs(b) < INF)
            s.insert(std::max(0.0, b - a));
        if (std::abs(b) < INF && std::abs(c) < INF)
            s.insert(std::max(0.0, c - b));
        if (std::abs(c) < INF && std::abs(a) < INF)
            s.insert(std::max(0.0, (c - a) / 2));
    };

    f(x_max[0], std::max(x_max[2], x_max[3]), x_max[1]);
    f(x_min[0], std::min(x_min[2], x_min[3]), x_min[1]);
    f(y_max[2], std::max(y_max[0], y_max[1]), y_max[3]);
    f(y_min[2], std::min(y_min[0], y_min[1]), y_min[3]);

    double ans = std::numeric_limits<double>::max();
    for (double t : s) {
        ans = std::min(ans,
                       (std::max({x_max[0] + t,
                                  x_max[1] - t,
                                  x_max[2],
                                  x_max[3]})
                      - std::min({x_min[0] + t,
                                  x_min[1] - t,
                                  x_min[2],
                                  x_min[3]}))
                     * (std::max({y_max[0],
                                  y_max[1],
                                  y_max[2] + t,
                                  y_max[3] - t})
                      - std::min({y_min[0],
                                  y_min[1],
                                  y_min[2] + t,
                                  y_min[3] - t})));
    }

    std::cout << std::fixed << std::setprecision(10) << ans << "\n";
}

Measured memory_bytes: 256
#include<cstdio>
#define mod 998244353
using namespace std;
inline void swap(int &a,int &b)
{register int t=a;a=b;b=t;}
int pow(int base,int exp)
{
	int ans=1;
	for(;exp;exp>>=1,base=1ll*base*base%mod)
		if(exp&1)
			ans=1ll*ans*base%mod;
	return ans;
}
int inv_fac[1110000],fac[1110000];
int n,m;
void init()
{
	fac[0]=1;
	for(int i=1;i<=n+m;i++)
		fac[i]=1ll*fac[i-1]*i%mod;
	inv_fac[n+m]=pow(fac[n+m],mod-2);
	for(int i=n+m-1;~i;i--)
		inv_fac[i]=1ll*inv_fac[i+1]*(i+1)%mod;
}
int C(int m,int n)
{
	return 1ll*fac[n]*inv_fac[m]%mod*inv_fac[n-m]%mod;
}
int main()
{
	scanf("%d%d",&n,&m);
	if(n<m)swap(n,m);
	init();
	int ans=0;
	for(int i=1;i<=m;i++)
		ans=(ans+1ll*C(m-i,n+m-2*i)*C(i,2*i)%mod)%mod;
	ans=1ll*ans*pow(2*C(n,n+m),mod-2)%mod;
	printf("%d",(n+ans)%mod);
	return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int x = n/2;
    int ans = a[x] - a[x-1];
    cout << ans << endl;
	return 0;
}

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

int main(void){
    int n;
    while(cin>>n){
        long long a=0,k[2001]={0};
        for(int i=0;i<1001;i++){
            for(int j=0;j<1001;j++){
                k[i+j]++;
            }
        }
        for(int i=0;i<2001;i++){
            for(int j=0;j<2001;j++){
                if(i+j==n){
                    a+=k[i]*k[j];
                }
            }
        }
        cout<<a<<endl;
    }
    return 0;
}

Measured memory_bytes: 1180
#include <iostream>
#define rep(i, n) for(int i=0; i<n; i++)
#define MAX 1000000000

using namespace std;

int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i, n)
    cin >> a[i];
  //入力終了

  //最大値の探索
  int ans1 = 0;
  rep(i, n)
    if(ans1 < a[i])
      ans1 = a[i];
  
  // combinationの性質を利用
  // r=n/2でnCrは最大をとる
  // ans1の1/2からの距離の最小値を探索
  double distance_min = MAX;
  int ans2;
  
  rep(i, n){
    // 題意より同じ値は飛ばす
    if(a[i] == ans1)
      continue;

    // ans1の1/2からの距離
    double dis = abs( (double)ans1/2 - a[i]);
    
    //最小値の更新
    if(dis < distance_min){
      distance_min = dis;
      ans2 = a[i];
    }
  } // i roop

  // 解答
  cout << ans1 << " " << ans2 << endl;
  
  return 0;
}


Measured memory_bytes: 3964
#include<iostream>
using namespace std;
int main()
{
  	int a,b,c;
  cin>>a>>b>>c;
  if (a==b&&a<c)
    cout<<"Yes";
  else if(a==b&&a>c)
    cout<<"Yes";
  else if(a==c&&a<b)
    cout<<"Yes";
  else if(a==c&&a>b)
    cout<<"Yes";
  else if(b==c&&b<a)
    cout<<"Yes";
  else if(b==c&&b>a)
    cout<<"Yes";
  else if(a=b=c)
    cout<<"No";
  else
    cout<<"No";
}

Measured memory_bytes: 3568
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

bool solve(int m, int k, vector<int>& v)
{
    if(m == 1){
        if(k == 0){
            v = vector<int>{0, 0, 1, 1};
            return true;
        }
        else{
            return false;
        }
    }

    int n = 1 << m;
    if(n <= k)
        return false;

    v.assign(2*n, 0);
    for(int i=0; i<n; ++i)
        v[n-1-i] = v[n-1+i] = i;

    replace(v.begin(), v.end(), 0, -1);
    replace(v.begin(), v.end(), k, 0);
    replace(v.begin(), v.end(), -1, k);

    return true;
}

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

    vector<int> v;
    if(solve(m, k, v)){
        int n = v.size();
        for(int i=0; i<n; ++i)
            cout << v[i] << endl;
    }
    else{
        cout << -1 << endl;
    }

    return 0;
}


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

def fib(n):
    Fib = [1,1]
    if n == 0 or n == 1:
        return Fib[n]
    for i in range(2,n+1):
        Fib.append(Fib[i-1] + Fib[i-2])
    return Fib[n]

print(fib(n))



Measured memory_bytes: 5600
#!/usr/bin/env python3
import sys
from itertools import accumulate
INF = float("inf")


def solve(N: int, M: int, V: int, P: int, A: "List[int]"):

    ans = 0

    # 降順
    A.sort(reverse=True)

    acc = [0]+list(accumulate(A))

    for i in range(N):
        # ソート後の冒頭P問は大きいので可
        if i < P:
            ans += 1
            continue
        # M人が投票してもP番目のスコアに届かないなら無駄。
        if A[i]+M < A[P-1]:
            continue

        # 対象iがP問目として選ばれるために
        # 許容可能な投票数と、実際の投票数を比較する。
        cap = 0
        # 始めのP-1問にはM人が投票してよい
        cap += M*(P-1)
        # 後ろのN-i問(i, i+1, ..., N-1)にはM人が投票して良い
        cap += M*(N-i)
        # P問目からi-1問目までは、A[i]+Mを超えない範囲で投票して良い
        # \sum_{j = P-1}^{i-1} A[i]+M-A[j]
        # = (i-P+1)*(A[i]+M) - \sum_{j=P-1}^{i-1}A[j]
        cap += (i-P+1)*(A[i]+M)
        # accは始めに0を加えているので、インデックスが異なるので注意
        # 数列(0-index)のi-1番目までの和はacc[i](0-index)
        cap -= acc[i] - acc[P-1]
        if cap >= M*V:
            ans += 1
    print(ans)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    V = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, V, P, A)


if __name__ == '__main__':
    main()


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

int main() {
    //ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int SX = sx;
    int SY = sy;
    while(sy < ty)
        cout << "U", sy++;
    while(sx < tx)
        cout << "R", sx++;
    while(sy > SY)
        cout << "D", sy--;
    while(sx > SX)
        cout << "L", sx--;
    cout << "L", sx--;
    while(sy < ty + 1)
        cout << "U", sy++;
    while(sx < tx)
        cout << "R", sx++;
    cout << "D", sy--;
    cout << "R", sx++;
    while(sy > SY - 1)
        cout << "D", sy--;
    while(sx > SX)
        cout << "L", sx--;
    cout << "U", sy++;
    assert(sx == SX && sy == SY);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<ctime>
#define rep(i,n) for (int i=0;i<n;i++)
//#include <bits/stdc++.h>
using namespace std;

int main(){
    int N;
    cin>>N;
    int a=N%1000;
    if (a==0) cout<<0<<endl;
    else  cout<<1000-a<<endl;
    return 0;
}

Measured memory_bytes: 3608
N=input()

E=[ [ "" for j in range(N+1) ] for i in range(N+1) ]

for K in range(10):
	if N<=2**K:
		break

for i in range(1,N+1):
	for j in range(i+1,N+1):
			for k in range(K):
				if (i>>k)&1!=(j>>k)&1:
						E[i][j]=k+1
						break
	
for i in range(1,N):
	s=""
	for j in range(i+1,N+1):
		s+=str(E[i][j])+" "
	print s

Measured memory_bytes: 41372
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007
#define V 300

int main() {
  ll n, M, r;
  cin >> n >> M >> r;
  vector<ll> v;
  rep(i, 0, r) {
    ll a;
    cin >> a;
    a--;
    v.pb(a);
  }
  ll m[V][V];
  for (ll i = 0; i < V; i++) {
    for (ll r = 0; r < V; r++) {
      if (i == r) {
        m[i][i] = 0;
      }
      else {
        m[i][r] = 1000000000000000000LL;
      }
    }
  }
  rep(i, 0, M) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    m[a][b] = min(m[a][b], c);
    m[b][a] = min(m[b][a], c);
  }
  for (ll k = 0; k < V; k++) {
    for (ll i = 0; i < V; i++) {
      for (ll j = 0; j < V; j++) {
        if (m[i][j] > m[i][k] + m[k][j]) {
          m[i][j] = m[i][k] + m[k][j];
        }
      }
    }
  }
  sort(all(v));
  ll ans = 1000000000000000000LL;
  do {
    ll ans1 = 0;
    rep(i, 0, v.sz - 1) {
      ans1 += m[v[i]][v[i + 1]];
    }
    ans = min(ans, ans1);
  } while (next_permutation(all(v)));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
mt19937 rng(time(NULL));

const int D = 365, N = 26;
int d;
ll c[N+1];
ll s[D+1][N+1];
ll last[N];
int contest[D];

ll calc(int idx, int x) {
	ll ans = 0;
	ll l = idx-1, r = idx+1;
	ll len, len2;
	while(l > 0 && contest[l] != contest[idx]) l--;
	len = idx - l;
	while(r <= d && contest[r] != contest[idx]) r++;
	len2 = r - idx;
	ans -= s[idx][contest[idx]];
	ans -= c[contest[idx]] * len * len2;
	ll tmp = contest[idx];
	contest[idx] = x;

	l = idx-1, r = idx+1;
	while(l > 0 && contest[l] != contest[idx]) l--;
	len = idx - l;
	while(r <= d && contest[r] != contest[idx]) r++;
	len2 = r - idx;
	ans += s[idx][x];
	ans += c[x] * len * len2;
	contest[idx] = tmp;
	return ans;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> d;
	for(int i = 1; i <= N; i++)
		cin >> c[i];
	for(int i = 1; i <= d; i++) {
		for(int j = 1; j <= N; j++)
			cin >> s[i][j];
	}
	memset(last, 0, sizeof last);
	ll ans = 0;
	for(int i = 1; i <= d; i++) {
		ll penalty = 0;
		for(int j = 1; j <= 26; j++)
			penalty += c[j] * (last[j] - i);
		ll best = -1, idx = -1;
		for(int j = 1; j <= 26; j++) {
			ll cur = s[i][j] - penalty + c[j] * (i - last[j]);
			if(best < cur)
				best = cur, idx = j;
		}
		last[idx] = i;
		ans += best;
		contest[i] = idx;
	}

	for(int i = 0; i < 400000; i++) {
		int idx = rng() % d + 1;
		for(int to = 1; to <= 26; to++) if(to != contest[idx]) {
			ll change = calc(idx, to);
			if(change > 0) {
				contest[idx] = to;
				ans += change;
			}
		}
	}

	for(int i = 1; i <= d; i++)
		cout << contest[i] << '\n';

	return 0;
}

Measured memory_bytes: 3748
#include <iostream>
#include <string>

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

using namespace std;

int main(){
	string s; cin>>s;

	if     (s=="Sunny")  cout<<"Cloudy"<<endl;
	else if(s=="Cloudy") cout<<"Rainy"<<endl;
	else                 cout<<"Sunny"<<endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if(a < b){
			System.out.println("a < b");
		}else if(a > b){
			System.out.println("a > b");
		}else{
			System.out.println("a == b");
		}
	}
}


Measured memory_bytes: 26196
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

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

	vector<pair<int, int>> ans;
	if (N % 2) {
		for (int i = 1; i <= N / 2; ++i) {
			ans.emplace_back(i, N - i);
		}
	} else {
		int n = N / 2 - 1;
		for (int i = 1; i <= n; ++i) {
			if (i <= (n + 1) / 2) {
				ans.emplace_back(i, N - i + 1);
			} else {
				ans.emplace_back(i, N - i);
			}
		}
	}

	for (int i = 0; i < min(M, (int)ans.size()); ++i) {
		cout << ans[i].first << " " << ans[i].second << endl;
	}

	return 0;
}


Measured memory_bytes: 4280
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {

    int a, b, x;
    cin >> a >> b >> x;

    if (a <= x && x <= a + b) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

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

        List<string> cityList = new List<string>();
        List<Restaurant> restaurantList = new List<Restaurant>();

        for (int i = 0; i < N; i++)
        {
            string[] input = Console.ReadLine().Split(' ');
            string s = input[0];
            if(!cityList.Contains(s)) cityList.Add(s);

            Restaurant r = new Restaurant();
            restaurantList.Add(r);
            r.city = s;
            r.score = int.Parse(input[1]);
            r.index = i+1;
        }

        cityList.Sort();

        for (int i = 0; i < cityList.Count; i++)
        {
            string city = cityList[i];

            List<Restaurant> newRestaurantList = new List<Restaurant>();
            for (int j = 0; j < restaurantList.Count; j++)
            {
                if(restaurantList[j].city == city)
                {
                    newRestaurantList.Add(restaurantList[j]);
                }
            }

            newRestaurantList.Sort((a, b) => b.score - a.score);

            for (int j = 0; j < newRestaurantList.Count; j++)
            {
                Console.WriteLine(newRestaurantList[j].index);
            }
        }
    }

    class Restaurant
    {
        public string city;
        public int score;
        public int index;
    }
}

Measured memory_bytes: 13408
/* ABC144-B
   Takatan */

#include<stdio.h>
int main(void){
    int number, i;

    scanf( "%d" , &number);
    for(i=1; i <= 9; i++){
        if(number%i==0 && number/i>=1 && number/i<=9){
            printf( "Yes\n" ); /* 九九の範囲にあったとき */
            return 0;
        }
    }
    printf( "No\n" );
    return 0;
}

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

int main(){

    int m,n;
    cin >> n >> m;
    int p;
    string s;
    int i;
    int tr[n+1], fl[n+1];
    bool flag[n+1];

    int ans,ans2;
    ans = 0;
    ans2 = 0;
    

    for(i = 0; i < n+1; i++){
        tr[i] = 0;
        fl[i] = 0;
        flag[i] = false;
    }

    for (i = 0; i < m; i++){
        cin >> p >> s;
        if(flag[p]) continue;

        if(s == "AC"){
            ans++;
            flag[p] = true;
            ans2 += fl[p];
        }
        else if(s == "WA") fl[p]++;
    }

       cout << ans << " " << ans2 << endl;
}

Measured memory_bytes: 1152
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
#from fractions import gcd
from math import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)
inf = float("inf")

def input():
    return sys.stdin.readline()[:-1]

def main():
    x = int(input())
    for a in range(1000):
        for b in range(1000):
            if a**5 - b**5 == x:
                print(a, b)
                exit()
            elif a**5 + b**5 == x:
                print(a, -b)
                exit()
            else:
                continue

if __name__ == '__main__':
    main()

Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int n=0,sum=s.size();
  for(int i=1;i<sum;i++){
    if(s[i]!=s[i-1]) n++;
  }
  cout<<n<<'\n';
  return 0;
}


Measured memory_bytes: 512
use std::cmp;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let h: usize = sc.read();
    let w: usize = sc.read();
    let n: usize = sc.read();
    let r: usize = sc.read();
    let c: usize = sc.read();
    let s: Vec<char> = sc.chars();
    let t: Vec<char> = sc.chars();

    let check = |left: char, right: char, w: usize, cur: usize| -> bool {
        let mut right_win = w + 1;
        let mut left_win = 0;
        let mut segments = vec![(0, 0); n];
        for i in (0..n).rev() {
            if t[i] == left && right_win < w + 1 {
                right_win += 1;
            }
            if t[i] == right && left_win > 0 {
                left_win -= 1;
            }

            if s[i] == left {
                left_win += 1;
            }
            if s[i] == right && right_win > 0 {
                right_win -= 1;
            }
            segments[i] = (left_win, right_win);
        }
        segments.push((0, w + 1));

        let mut left_cur = cur;
        let mut right_cur = cur;

        for i in 0..n {
            let (left_win, right_win) = segments[i];
            if left_cur <= left_win || right_win <= right_cur {
                return true;
            }
            if s[i] == left {
                left_cur -= 1;
            }
            if s[i] == right {
                right_cur += 1;
            }

            let (left_win, right_win) = segments[i + 1];
            if t[i] == left && right_cur - 1 > left_win {
                right_cur -= 1;
            }
            if t[i] == right && left_cur + 1 < right_win {
                left_cur += 1;
            }
        }

        if left_cur <= 0 || w + 1 <= right_cur {
            true
        } else {
            false
        }
    };

    if check('L', 'R', w, c) || check('U', 'D', h, r) {
        println!("NO");
    } else {
        println!("YES");
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

int main(){
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int ma = 60*h1 + m1;
  int mb = 60*h2 + m2;
  int zikan = mb - ma;
  cout << zikan - k << endl;
}


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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define llong long long
const llong mod=1e9+7;
int n,m;
int nu[2020];
llong getsum(int a1,int d)
{ return 1ll*a1*m%mod+1ll*m*(m-1)/2%mod*d%mod; }
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)scanf("%d",&nu[i]);
	int a1,d;
	llong ans=0;
	for(int i=1;i<=n;++i)
	{
		a1=0;d=0;
		for(int j=1;j<=n;++j)
			if(nu[j]>nu[i])
			{
				d++;
				if(j<i)a1++;
			}
		(ans+=getsum(a1,d))%=mod;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256