akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#define REP(i,a,b) for(register int i=(a); i<(b); i++)
#define REPE(i,a,b) for(register int i=(a); i<=(b); i++)
#define PERE(i,a,b) for(register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
char s[17];
int main() {
	scanf("%s", s);
	int l=strlen(s);
	if(l&1) {puts("No"); return 0;}
	for(int i=0; i<l; i+=2) {
		if(s[i]!='h' || s[i|1]!='i') {puts("No"); return 0;}
	}
	puts("Yes");
}


Measured memory_bytes: 128
n = int(input())
x = [int(i) for i in input().split()]
ave = sum(x) // n
ans1 = 0
ans2 = 0
for i in range(n):
    ans1 += (x[i] - ave) ** 2
    ans2 += (x[i] - (ave + 1)) ** 2
print(min(ans1, ans2))

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

using namespace std;

using ll = long long;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int keta = -1;
	for (int i = 1, x = 10; i < 10; i++) {
		cout << "? " << x << endl;
		char ans;
		cin >> ans;
		if (ans == 'N') {
			keta = i;
			break;
		}
		x *= 10;
	}
	if (keta == -1) {
		ll x = 9;
		for (int i = 1; i <= 10; i++) {
			cout << "? " << x << endl;
			char ans;
			cin >> ans;
			if (ans == 'Y') {
				keta = i;
				break;
			}
			x = x * 10 + 9;
		}
	}

	ll n = 0;
	for (int i = 0; i + 1 < keta; i++) {
		int ok = (i == 0), ng = 10;
		while (ng - ok > 1) {
			int mid = (ok + ng) / 2;
			cout << "? " << n * 10 + mid << endl;
			char ans;
			cin >> ans;
			if (ans == 'Y') ok = mid;
			else ng = mid;
		}
		n = n * 10 + ok;
	}
	n *= 10;
	int ng = -(keta != 1), ok = 9;
	while (ok - ng > 1) {
		int mid = (ok + ng) / 2;
		cout << "? " << (n + mid) * 10 << endl;
		char ans;
		cin >> ans;
		if (ans == 'Y') ok = mid;
		else ng = mid;
	}
	n += ok;
	cout << "! " << n << endl;
	return 0;
}

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

int main(){
    int n; cin >> n;
    vector<ll> a(n); rep(i,n) cin >> a[i];
    int minuscnt = 0; //負の数の個数を記録
    ll plusmin = 1e10; //非負整数の最小値を記録
    int plusid; //plusminに対応する要素のindexを記録
    ll minusmax = -1e10; //負の数の最大値を記録
    int minusid; //minusidに対応する要素のindexを記録
    ll ans = 0;
    rep(i,n){
        if(a[i] < 0){
            if(a[i] > minusmax) minusmax = a[i];
            minuscnt++;
        }else{
            if(a[i] < plusmin) plusmin = a[i];
        }
    }
    rep(i,n) ans += abs(a[i]);
    if(minuscnt % 2 != 0){
        ans -= 2*min(abs(minusmax),abs(plusmin));
    }
    cout << ans << endl;
}

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

typedef long double ld;
typedef long long ll;

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

void solve(ll N)
{
  ll ans = 0LL;
  N /= 2;
  while (N >= 5) {
    ans += N / 5;
    N /= 5;
  }

  print(ans);
  return;
}

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

  if (N % 2 != 0) {
    print(0);
    return 0;
  }

  solve(N);
  return 0;
}



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

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  string s, t;
  read(s, t);
  if (sz(t) > sz(s))
    die("UNRESTORABLE");

  set<string> strings;
  rep(i, 0, sz(s) - sz(t) + 1) {
    string res = s;
    for (int j = i, k = 0; k < sz(t); j++, k++)
      if (res[j] == t[k] || res[j] == '?')
        res[j] = t[k];
      else
        goto bad;
    for (char &c : res) if (c == '?') c = 'a';
    strings.insert(res);    
bad: void(0);
  }

  if (strings.size())
    die(*strings.begin());
  else
    die("UNRESTORABLE");
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
    if(x>y){
        for(int i=0;i<x;i++)
            cout<<y;
    }
    else{
        for(int i=0;i<y;i++)
            cout<<x;
    }
}


Measured memory_bytes: 3620
// ITP_1_9_C
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
    std::string to_string(char val) {
        return std::string(1, val);
        // return std::string{val};
        // you::to_string(char)
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int taro=0,hanako=0,num;
    cin>>num;
    string a,b;
    for(int i=0;i<num;i++){
        cin>>a>>b;
        if(a<b) hanako+=3;
        else if(a==b){
            taro+=1;
            hanako+=1;
        }else taro+=3;
    }
    cout<<taro<<" "<<hanako<<endl;
    return 0;
}


Measured memory_bytes: 3204
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
constexpr int MOD = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}

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

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

    int n;
    cin >> n;

    vector<int> p(n);
    vector<string> s(n);
    vector<pii> res;

    rep(i,n){
        cin >> s[i] >> p[i];
    }

    rep(i,n){
        int rank = 1;
        rep(j,n){
            if(s[i] > s[j]) ++rank;
            else if(s[i] == s[j]){
                if(p[i] < p[j]) ++rank;
            }
        }
        res.emplace_back(rank,i+1);
    }

    sort(all(res),less<pii>());

    rep(i,n){
        cout << res[i].second << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define NUM 2147483647

enum TREE{
	A,
	B,
};

struct Info{
	Info(int arg_loc,TREE arg_tree){
		loc = arg_loc;
		tree = arg_tree;
	}
	int loc;
	TREE tree;
};

int N;
int table[2][526000];

void init(int first_N){
	while(N < first_N)N *= 2;
}

void update(TREE tree,int loc,int value){
	loc += N-1;

	table[tree][loc] = value;

	if(N == 1)return;

	int parent = (loc-1)/2;

	while(true){
		table[tree][parent] = min(table[tree][2*parent+1],table[tree][2*parent+2]);

		if(parent == 0)break;
		else{
			parent = (parent-1)/2;
		}
	}
}


int query(TREE tree,int search_left,int search_right,int node_id,int node_left,int node_right){

	if(search_right < node_left || search_left > node_right)return NUM;

	if(search_left <= node_left && search_right >= node_right){
		return table[tree][node_id];
	}

	int left_min = query(tree,search_left,search_right,2*node_id+1,node_left,(node_left+node_right)/2);
	int right_min = query(tree,search_left,search_right,2*node_id+2,(node_left+node_right)/2+1,node_right);

	return min(left_min,right_min);
}


int main(){

	int first_N;
	N = 1;

	scanf("%d",&first_N);

	init(first_N);

	for(int i = 0; i <= 2*N-2; i++){
		table[A][i] = NUM;
		table[B][i] = NUM;
	}

	int tmp;
	for(int i = 0; i < first_N; i++){
		scanf("%d",&tmp);
		update(A,i,tmp);
	}

	for(int i = 0; i < first_N; i++){
		scanf("%d",&tmp);
		update(B,i,tmp);
	}

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

	int x,y,z;

	bool is_First = true;
	queue<Info> update_LOG;

	for(int loop = 0; loop < Q; loop++){
		scanf("%d %d %d",&x,&y,&z);

		switch(x){
		case 1:
			update(A,y-1,z);
			update_LOG.push(Info(y-1,A));
			break;
		case 2:
			update(B,y-1,z);
			update_LOG.push(Info(y-1,B));
			break;
		case 3:
			printf("%d\n",query(A,y-1,z-1,0,0,N-1));
			break;
		case 4:
			printf("%d\n",query(B,y-1,z-1,0,0,N-1));
			break;
		case 5:
			if(is_First){
				while(!update_LOG.empty())update_LOG.pop();

				for(int i = 0; i < N; i++){
					update(A,i,table[B][N-1+i]);
				}
				is_First = false;
			}else{
				while(!update_LOG.empty()){
					update(A,update_LOG.front().loc,table[B][N-1+update_LOG.front().loc]);
					update_LOG.pop();
				}
			}
			break;
		case 6:
			if(is_First){
				while(!update_LOG.empty())update_LOG.pop();

				for(int i = 0; i < N; i++){
					update(B,i,table[A][N-1+i]);
				}
				is_First = false;

			}else{
				while(!update_LOG.empty()){
					update(B,update_LOG.front().loc,table[A][N-1+update_LOG.front().loc]);
					update_LOG.pop();
				}
			}
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 7360
import sys
for a in sys.stdin:
    if a == "\n":
        break
    s = [0 for i in range(10)]
    s[0] = float(a)
    for i in range(1, 10):
        if i % 2:
            s[i] = s[i-1] * 2
        else:
            s[i] = s[i-1] / 3
    print(sum(s))

Measured memory_bytes: 7364
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,z;
    char ca,cb,cc;
    cin>>a;
    if(a==5||a==3||a==7) YES;
    else NO;

    

    return 0;
}


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


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

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  string s; cin >> s;
  ll ans = 0;
  ll f9 = -1;
  for(int i = 1; i < s.size(); i++) {
    if(s[i] != '9') {
      f9 = i;
      break;
    }
  }
  if(f9 > 0) {
    s[f9 - 1] --;
    for(int i = f9; i < s.size(); i++) {
      s[i] = '9';
    }
  }
  rep(i, s.size()) ans += s[i]-'0';

  cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3724
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int a,b;
  cin>>a>>b;
  int ans=0;
  int now=1;
  while(now<b){
    ans++;
    now+=a-1;
  }
  cout<<ans<<endl;
}

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

ans = 0

for i in range(a,b+1):
	#print(i)
	
	s = str(i)
	k = len(s)
	s1 = s[:k//2]
	s2 = s[k//2+1:]
	s3 = s2[::-1]
	#print(s1)
	#print(s2)
	#print(s3)
	if s1==s3:
		ans = ans + 1

print(ans)


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

int main(){
  int n,s;
  string moji;
  cin >> n >> s;
  for(int i; i < n; i++){
    cin >> moji[i];
  }
  if(moji[s-1] == 'A')
    moji[s-1] = 'a';
  else if(moji[s-1] == 'B')
    moji[s-1] = 'b';
  else
    moji[s-1] = 'c';
  for(int i; i < n; i++){
  cout << moji[i];
  }

  }
             
            
          
      
    


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        a: usize, b: usize, c: usize, x: usize, y: usize,
    }
    
    if a + b < 2 * c {
        println!("{}", x * a + y * b)
    } else {
        let mut a_or_b_ans = 0;
        let min = std::cmp::min(x, y);
        for _ in 0..min {
            a_or_b_ans += c * 2;
        }

        a_or_b_ans += (x-min) * a + (y-min) * b;

        let mut c_ans = 0;
        for _ in 0..std::cmp::max(x, y) {
            c_ans += c * 2;
        }

        println!("{}", std::cmp::min(a_or_b_ans, c_ans))
    }
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


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

#define BR "\n"
#define SP " "

int main() {

  while(1) {
    ll H, W;
    cin >> H >> W;

    if (H + W == 0) break;

    string s0 = "", s1 = "";
    for (int i = 0; i < W; i++) {
      if (i % 2 == 0) {
        s0 += "#";
        s1 += ".";
      } else {
        s0 += ".";
        s1 += "#";
      }
    }

    for (int i = 0; i < H; i++) {
      if (i % 2 == 0) {
        cout << s0 << BR;
      } else {
        cout << s1 << BR;
      }
    }
    cout << BR;
  }

  return 0;
}


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

#define ll long long

int cnt(char *a,char *b)
{
    int i,j,c=0;
    for(i=0,j=0;a[i]!='\0';i++){
        if(a[i]==b[j]){
            j++;
        }
        else if(a[i]==b[0]){
            j=1;
        }else{
          j=0;
        }
        if(b[j]=='\0'){
            c++;
            j=0;
        }

    }

    return c;

}


int main()
{
    int n;
    char a[100];

    scanf("%d",&n);
    scanf("%s",a);


    cout<<cnt(a,"ABC")<<endl;


    return 0;
}


Measured memory_bytes: 256
def D_RestoringRoadNetwork(N, A):
    dist = [x[:] for x in A] # 全ての町同士の距離
    dist2 = [x[:] for x in A] # 不要な経路を削ぎ落とした町同士の距離
    isMinDist = True  # 与えられた行列が真に最短距離を表しているか

    # ワーシャルフロイド法
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if A[i][j] > dist[i][k] + dist[k][j]:
                    # 迂回路の方が短いとなれば元の行列は最短距離を表していない
                    isMinDist = False
                elif A[i][j] == dist[i][k] + dist[k][j] and dist[i][k] > 0 and dist[k][j] > 0:
                    # 最短経路でも迂回路でも同じ距離ならば、表にあった最短距離の経路は不要
                    dist2[i][j] = 0
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
    if isMinDist:
        ans = 0
        for i in range(N):
            for j in range(i, N):
                # 行列の上三角しか見ないのは、対称行列(ij成分=ji成分)になるから
                ans += dist2[i][j]
        return ans
    else:
        return -1

N=int(input())
A=[[int(i) for i in input().split()] for j in range(N)]
print(D_RestoringRoadNetwork(N, A))

Measured memory_bytes: 45148
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll , ll > pll;
typedef vector < ll > vi;
#define INF (2e18)
#define eps (1e-6)
#define pb push_back
#define mp make_pair
#define modulo1e9 ((ll)1e9 + 7)

ll mn(ll a , ll b) {if (a < b) return a; return b;}
ll mx(ll a , ll b) {if (a > b) return a; return b;}

ll n;
vi a;

int main(){
	
	cin >> n;
	ll sum = 0;
	for (ll i = 0 ; i < n ; i ++ ) {
		ll x; cin >> x;
		a.pb(x);
		sum += x;
		
	}
	sort(a.begin(), a.end());
	
	ll max = a[n-1];
	
	if (sum - max > max) cout << "Yes";
	else cout << "No";
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Long x = sc.nextLong();
        Long y = sc.nextLong();
        sc.close();

        if(Math.abs(x-y) <= 1){
            System.out.println("Brown");
        }else{
            System.out.println("Alice");
        }
    }
}

Measured memory_bytes: 22228
#include <iostream>

int main() {

	int n = 10, i = 0, j = 0, v = 0, count = 0;
	int a[10];

	for (i = 0; i < n; i++) {
		std::cin >> a[i];
	}

	for (i = 1; i < n; i++) {
		v = a[i];
		j = i - 1;

		while ((j >= 0) && (a[j] > v)) {
			a[j + 1] = a[j];
			j--;
		}

		a[j + 1] = v;
	}

	std::cout << a[9] << std::endl;
	std::cout << a[8] << std::endl;
	std::cout << a[7] << std::endl;

	return 0;


}


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

//#define int long long
#define reps(i,s,n) for(ll (i)=(s);(i)<(ll)(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) reps(i,0,n+1)
#define repst(i,s,n) reps(i,s,n+1)
#define reprt(i,n,t) for(ll (i)=(n);(i)>=t;--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<n;++i){cout<<x[i]<<(i==n-1?'\n':' ');}}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = 998244353ll;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

// n-|S|というのは "Sの凸包に含まれる点からS自体を除いた集合Ts" の要素数に等しい
// つまり "2^(n-|S|)の総和" は "Tsの部分集合の個数の総和" に等しい
// 凸包の内部(境界を含まない)の点は選んでも選ばなくても凸包の形状は変わらないが、その凸包を生成する選び方の組み合わせを倍にすることができる
// このことから求めるものは "凸包の面積が正の部分集合の個数" と等しい(というかスコアがこれに対応してる)ことがわかる
// 全部分集合2^n個から面積が0の集合の個数を引けばいい

int n, x[200], y[200], f[234], r;
bool us[200][200];

// (3点の面積)*2
int area(int i, int j, int k) {
	return (x[i]-x[k])*(y[j]-y[k]) - (y[i]-y[k])*(x[j]-x[k]);
}

signed main() {
	cin >> n;
	rep(i,n) cin >> x[i] >> y[i];
	
	f[0] = 1;
	repst(i,1,n) f[i] = f[i-1]*2 %mod;
	// 頂点数0or1or2の集合はとりあえず除く
	r = (f[n] + mod - (1 + n + n*(n-1)/2))%mod;
	// 同一直線状の点を3個以上選んでできる部分集合も除く必要がある
	rep(i,n) reps(j,i+1,n) if (!us[i][j]) {
		vi v;
		v.pb(i), v.pb(j);
		rep(k,n) if (i!=k && j!=k && area(i,j,k)==0) v.pb(k);
		each(k,v) each(l,v) us[k][l] = true;
		int t = v.size();
		if (t>=3) r = (r + mod - f[t] + 1 + t + t*(t-1)/2) %mod;
	}
	cout << r << ln;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

int main() {
    while (true) {
        int s;
        cin >> s;
        if (s == 0) break;

        int a[9];
        REP(i, 9) cin >> a[i];

        int ans = s;
        REP(i, 9) ans -= a[i];
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

int main(){
    int n, d, x, y;
    cin >> n >> d >> x;
    for (int i = 0; i < n; ++i) {
        cin >> y;
        for (int j = 1; j <= d; j += y) {
            x++;
        }
    }
    cout << x << endl;
    return 0;
}

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

using namespace std;
typedef long long LL;
int main()
{
   LL A,B,V,W,T;
   cin>>A>>V;
   cin>>B>>W;
   cin>>T;
   //if(A>B) {printf("YES\n"); return 0;}
   LL d = (V-W)*T;
   if(d>=abs(B-A)) printf("YES\n");
   else printf("NO\n");
    return 0;
}


Measured memory_bytes: 3636
N = int(input())


fbsum = 0
for i in range(1, N+1):
    if i % 3 == 0 and i % 5 == 0:
        continue
    elif i % 3 == 0:
        continue
    elif i % 5 == 0:
        continue
    else:
        fbsum += i

print(fbsum)


Measured memory_bytes: 9164
N,X = map(int,input().split())
L = list(map(int,input().split()))

M = [abs(i - X) for i in L]

def gcd(a,b):
    if b==0: 
        return a 
    return gcd(b,a%b)
    
D = 0 
for i in range(0,len(M)): 
    D = gcd(D,M[i])

print(D)


Measured memory_bytes: 14252
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void) {
  string S, T;
  int count = 0;

  cin >> S >> T;
  for (int i = 0; i < (int)S.size(); i++) {
    if (S[i] != T[i]) {
      count++;
    }
  }
  cout << count;
  return 0;
}

Measured memory_bytes: 3900
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<ll> s;
  rep(i, n) {
    ll sum = 0;
    for (int j = i ; j >= 0; j--) {
      sum += a[j];
      s.push_back(sum);
    }
  }
  for (int i = 62; i >= 0; i--) {
    vector<ll> ok;
    rep(j, s.size()) {
      if (s[j] & 1LL<<i)
        ok.push_back(s[j]);
    }
    if (ok.size() >= k)
      s = ok;
  }
  ll ans = s[0];
  for (int i = 1; i < s.size(); i++)
    ans &= s[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6512
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define per(i,n) for (int i=n-1; i>=0; --i)
#define all(a) a.begin(), a.end()
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using vi = vector<int>;
using vv = vector<vi>;
const int mod = 1000000007;
//const int mod = 998244353;

struct mint{
    ll x;
    mint(ll x=0):x(x%mod){}
    
    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 { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if(t&1) a *= *this;
        return a;
    }
    
    //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;
    mint sum = 0, sum2 = 0;
    rep(i,n){
        ll a;
        cin >> a;
        sum  += a;
        sum2 += mint(a)*a;
    }
    mint ans = ( sum*sum - sum2 ) / 2;
    
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    int total = 0;
    
    if(x == 3){
      total += 100000;
    }else if(x == 2){
      total += 200000;
    }else if(x == 1){
      total += 300000;
    }else{
    }
    
    if(y == 3){
      total += 100000;
    }else if(y == 2){
      total += 200000;
    }else if(y == 1){
      total += 300000;
    }else{
    }
    
    if(x == 1 && y == 1){
      total += 400000;
    }
    
    System.out.println(total);
  }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
int main(){
  string ans = "Yes";
  int N;
  cin>>N;
  vector <int> t(N+1);
  vector <int> x(N+1);
  vector <int> y(N+1);
  t.at(0) = 0;
  x.at(0) = 0;
  y.at(0) = 0;
  for(int i = 1;i<=N;i++){
    cin >> t.at(i) >> x.at(i) >> y.at(i);
  }
  for(int i = 1;i<=N;i++){
    if(abs(x.at(i)-x.at(i-1))+abs(y.at(i)-y.at(i-1)) > t.at(i) - t.at(i-1) || (t.at(i) - t.at(i-1) - abs(x.at(i)-x.at(i-1))+abs(y.at(i)-y.at(i-1)))%2 == 1){
      ans = "No";
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    int n; cin >> n;
    vector<int> d(n);
    rep(i, n) {
        int t; cin>>t;
        d[i]=t;
    }
    sort(d.begin(), d.end());
    n /= 2;
    cout << d[n]-d[n-1] <<endl;
}

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



int main(){
    int n;
    cin >> n;
    int m=0;
    int c=0;

    int a[n+5];

    rep(i,n){
        cin >> a[i];
    }

    rep(i,n-1){
        if(a[i+1]<=a[i]){
            c++;
        }

        else{
            m=max(m,c);
            c=0;
        }

    }
        m=max(m,c);

    cout << m << endl;
    return 0;
}

Measured memory_bytes: 640
import sys


class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n

    def _root(self, x):
        stack = []
        tbl = self.table
        while tbl[x] >= 0:
            stack.append(x)
            x = tbl[x]
        for y in stack:
            tbl[y] = x
        return x

    def find(self, x, y):
        return self._root(x) == self._root(y)

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1


def main():
    n, m, k = map(int, sys.stdin.buffer.readline().split())
    uf = UnionFind(n)
    fb = [0]*n
    i = 0
    for x in sys.stdin.buffer.readlines():
        if i < m:
            a, b = map(int, x.split())
            fb[a-1] += 1
            fb[b-1] += 1
            uf.union(a-1, b-1)
        else:
            c, d = map(int, x.split())
            if uf._root(c-1) == uf._root(d-1):
                fb[c-1] += 1
                fb[d-1] += 1
        i += 1

    ans = [-uf.table[uf._root(i)]-1-fb[i] for i in range(n)]
    print(*ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 24508
//package bag;

import java.io.*;
import java.lang.reflect.Array;
import java.text.MessageFormat;
import java.util.*;

/**
 * Created by Enzo Cotter on 2019/4/30.
 */
public class Main {
    public static void main(String []args){
        Scanner input =new Scanner(System.in);
        int x;
        int []cot1=new int[1000005];
        int []cot2=new int[1000005];
        int n,a=0,b=0;
        n=input.nextInt();
        int reso1=0;
        int rese1=0;
        int reso2=0;
        int rese2=0;
        for(int i=1;i<=n;i++){
            x=input.nextInt();
            if(i==1)a=x;
            else if(i==2)b=x;
            if(i%2==1){
                cot1[x]++;
                if(reso1<cot1[x]) {
                    reso1 = cot1[x];
                    a = x;
                }
                if(a!=x) {
                    reso2 = Math.max(reso2, cot1[x]);
                }
            } else if(i%2==0){
                cot2[x]++;
                if(rese1<cot2[x]) {
                    rese1 = cot2[x];
                    b = x;
                }
                if(b!=x) {
                    rese2 = Math.max(rese2, cot2[x]);
                }
            }
        }
        //System.out.println(reso1+" "+reso2+" "+rese1+" "+rese2);
        if(a==b){
            System.out.println(Math.min(n-reso1-rese2,n-rese1-reso2));
        }else
            System.out.println(n-reso1-rese1);
    }
}


Measured memory_bytes: 68720
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node {int p, l, r;};

Node T[MAX];
int n, D[MAX];

void print(int u){
    int i, c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";

    if (T[u].p == NIL) cout << "root, ";
    else if (T[u].l == NIL) cout << "leaf, ";
    else cout << "internal node, ";

    cout << "[";

    for (i=0, c=T[u].l; c!=NIL; i++, c=T[c].r){
        if (i) cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

//calculate depth recursively
int rec(int u, int p){
    D[u] = p;
    if (T[u].r != NIL) rec(T[u].r, p);
    if (T[u].l != NIL) rec(T[u].l, p+1);
    return 0;
}

int main(){
    int i, j, d, v, c, l, r;
    cin >> n;
    for (i=0; i<n; i++){
        T[i].p = T[i].l = T[i].r = NIL;
    }
    
    for (i=0; i<n; i++){
        cin >> v >> d;
        for (j=0; j<d; j++){
            cin >> c;
            if (j==0) T[v].l = c;
            else T[l].r = c;
            l = c;
            T[c].p = v;
        }
    }
    for (i=0; i<n; i++){
        if (T[i].p == NIL) r = i;
    }

    rec(r, 0);

    for (i=0; i<n; i++) print(i);

    return 0;


}

Measured memory_bytes: 5840
// Problem : A - ABC Swap
// Contest : AtCoder Beginner Contest 161
// URL : https://atcoder.jp/contests/abc161/tasks/abc161_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define cerr if(1)cerr
#define size(x) (int)x.size()

const int N = 1e6 + 1;

int a, b, c;

void solve() {
	cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);
	cout << a << ' ' << b << ' ' << c;
}

int main() { cin.tie(0)->sync_with_stdio(0);
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define popb(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  string s;
  cin>>s;
  rep(i,0,s.size()){
      if(s[i]==',') s[i]=' ';
  }
  cout<<s<<endl;
}


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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

void dfs(vector <int> adj[],vector <bool> &vis,int i,int &c)
{
    vis[i]=true;
    c++;
    for(int j=0;j<(int)(adj[i].size());j++)
    {
        if(!vis[adj[i][j]])
            dfs(adj,vis,adj[i][j],c);
    }
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    int n;
    cin>>n;

    if(n%2)
    {
        cout<< "0";
        return 0;
    }

    int c=0;
    for(int i=10;i<=n;i*=5)
    {
        c+=(n/i);
    }

    cout<<c;



    return 0;
}


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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
const int mod=1e9+7;
int main(){
    int n;
    cin>>n;
    vector<LL> f(n+1,0);
    vector<LL> S(n+2,0);
    if(n==1){
        cout<<1<<endl;return 0;        
    }
    if(n==2){
        cout<<4<<endl;return 0;
    }
    f[0]=1;
    f[1]=1;
    f[2]=1;
    S[0]=0;
    S[1]=1;
    S[2]=2;
    S[3]=3;
    FOR(i,2,n){
        f[i+1]=(f[i]+S[i-1])%mod;
        S[i+2]=(S[i+1]+f[i+1])%mod;
    }
    LL res=f[n-1]*n%mod;
    LL latte=(LL)n*(n-1)%mod;
    //cout<<res<<endl;
    res=(res+f[n-2]*latte%mod)%mod;
    //cout<<res<<endl;
    const LL M=1ll*(n-1)*(n-1)%mod;
    REP(i,n-2){
        res=(res+f[i]*M%mod)%mod;
        //cout<<M<<endl;
    }
    REP(i,n-2){
       LL K=i+2;
       res=(res+f[i]*K%mod)%mod;
       //cout<<K<<endl;        
    }
    cout<<res<<endl;
    
    
    return 0;
}


Measured memory_bytes: 15872
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: usize, a: [usize; n], b: [usize; n]);

    if let Some(ans) = solve(n, &a, &b) {
        println!("Yes");
        for a in ans {
            print!("{} ", a)
        }
    } else {
        println!("No")
    }
}

fn solve(n: usize, a: &[usize], b: &[usize]) -> Option<Vec<usize>> {
    let mut d = 0;
    let b = [b; 2].concat();
    for i in 0..n {
        while i + d < n && a[i] >= b[i + d] {
            d += 1;
        }
        if a[i] == b[i + d] {
            return None;
        }
    }
    Some((&b[d..d + n]).into())
}


Measured memory_bytes: 12520
#include<bits/stdc++.h>
using namespace std;
int R,C,dp[1001][1001];
char arr[1001][1001];
int main()
{
	cin>>R>>C;
	for(int x=0;x<=R;x++)
	{
		dp[x][0]=0;
	}
	for(int x=0;x<=C;x++)
	{
		dp[0][x]=0;
	}
	for(int j=1;j<=R;j++)
	{
		for(int i=1;i<=C;i++)
		{
			cin>>arr[j][i];
			dp[j][i]=0;
		}
	}
	dp[1][1]=1;
	for(int j=1;j<=R;j++)
	{
		for(int i=1;i<=C;i++)
		{
			if(arr[j][i]=='.')
			dp[j][i]+=dp[j-1][i]+dp[j][i-1];
			dp[j][i]%=1000000007;
		}
	}
	cout<<dp[R][C]<<endl;
}

Measured memory_bytes: 5120
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

class UnionFind {
private:
	unsigned size_; 
	std::vector<unsigned> par, rank;
public:
	UnionFind() : size_(0), par(std::vector<unsigned>()), rank(std::vector<unsigned>()) {};
	UnionFind(unsigned size__) : size_(size__) {
		par.resize(size_); rank.resize(size_);
		for (unsigned i = 0; i < size_; i++) par[i] = i, rank[i] = 0;
	}
	unsigned size() { return size_; }
	//unsigned root(unsigned x) { return par[x] == x ? x : par[x] = root(par[x]); }
	unsigned root(unsigned x)
	{
		while(par[x] != x)
		{
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	bool same(unsigned x, unsigned y) { return root(x) == root(y); }
	void unite(unsigned x, unsigned y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++;
		else par[y] = x;
	}
	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/
bool is_prime(ll n)
{
	for (ll i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			return false;
		}
	}
	return true;
}

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

	ll x;
	
	cin >> x;

	ll ret = x;
	while(!is_prime(ret))
	{
		ret++;
	}

	cout << ret << endl;
	return 0;
	
	return 0;
}


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	vector<string> arr = {"Sunny", "Cloudy", "Rainy"};
	string s;
	cin >> s;
	int i = find(arr.begin(), arr.end(), s) - arr.begin();
	i++, i %= 3;
	cout << arr[i] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR0(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(ll i=l;i<n;i++)
using namespace std;
#define pi pair<ll,ll>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e14
ll power(ll num,ll g,ll mod){
  if(g==0)return 1;
  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;
  return power((num*num)%mod,g/2,mod);
}

int main(){
	ll n;
	cin >> n;
	int ans = 0;
	ans += (n/500)*1000;
	n%=500;
	ans += (n/5)*5;
	cout << ans;
}

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

struct Card {
	char suit, value;
};
void bubble(struct Card A[], int N) {
	for (int i = 0; i < N; i++) {
		for (int j = N - 1; j >= i; j--) {
			if (A[j].value < A[j - 1].value) {
				Card t = A[j];
				A[j] = A[j - 1];
				A[j - 1] = t;
			}
		}
	}
}
void selection(struct Card A[], int N) {
	for (int i = 0; i < N; i++) {
		int minj = i;
		for (int j = i; j < N; j++) {
			if (A[j].value < A[minj].value) {
				minj = j;
			}
		}
		Card t = A[i];
		A[i] = A[minj];
		A[minj] = t;
	}
}
void print(struct Card A[], int N) {
	for (int i = 0; i < N; i++) {
		if (i > 0)cout << " ";
		cout << A[i].suit << A[i].value;
	}
	cout << endl;
}
bool isStable(struct Card C1[], struct Card C2[], int N) {
	for (int i = 0; i < N; i++) {
		if (C1[i].suit != C2[i].suit)return false;
	}
	return true;
}
int main() {
	Card C1[100], C2[100];
	int N;
	char ch;

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> C1[i].suit >> C1[i].value;
	}
	for (int i = 0; i < N; i++) {
		C2[i] = C1[i];
	}

	bubble(C1, N);
	selection(C2, N);
	print(C1, N);
	cout << "Stable" << endl;
	print(C2, N);
	if (isStable(C1, C2, N)) {
		cout << "Stable" << endl;
	}
	else {
		cout << "Not stable" << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
 
#define sz(x) int(x.size())
#define pii pair<int, int>
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define Debug(X) cout << #X << " = " << X << '\n'
#define All(x) (x).begin(), (x).end()
#define mp make_pair
 
typedef unsigned long long ull;
typedef long long ll;
 
const int maxn = 2e6 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;
 
ll gt[maxn], igt[maxn];
 
ll Pow(ll a, ll b){
  if (b == 0) return 1;
  ll tmp = Pow(a, b / 2);
  tmp = (tmp * tmp) % mod;
  if (b % 2) return (tmp * a) % mod;
  return tmp;
}
 
void init(){
  const int mx = 2e6 + 1;
  gt[0] = 1;
  for (int i = 1; i <= mx; ++i) gt[i] = (gt[i-1] * i) % mod;
  igt[mx] = Pow(gt[mx], mod - 2);
  for (int i = mx - 1; i >= 0; --i) igt[i] = (igt[i+1] * (i+1)) % mod;
}
 
ll C(int k, int n){
  return (((gt[n] * igt[k]) % mod) * igt[n-k]) % mod;
}
 
ll calc(int i, int j){
  return C(i+1, i+j+1);
}
 
int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);  freopen(Task".out", "w", stdout);
  int r1, r2, c1, c2; cin >> r1 >> c1 >> r2 >> c2;
  ll ans = 0;
  init();
  for (int i = r1; i <= r2; ++i){
    ans = ans + calc(i, c2) - calc(i, c1 - 1);
    ans = ans + mod;
    ans = ans % mod;
  }
  cout << ans;
}

Measured memory_bytes: 31488
#include <iostream>
using namespace std;
void uruu(int, bool&);

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

	while (true) {
		
		bool write = false;

		for (int i = a;i <= b;i++) {
			uruu(i, write);
		}
		if (!write)cout << "NA" << endl;
		
		cin >> a >> b;
		if (a == 0 && b == 0) break;
		cout << endl;
	}

	return 0;
}

void uruu(int year, bool& write) {
	if (year % 400 == 0) {
		cout << year << endl;
		write = true;
		return;
	}
	else if (year % 100 == 0) {
		return;
	}
	else if (year % 4 == 0) {
		cout << year << endl;
		write = true;
		return;
	}
	else {
		return;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> vpi;
int main(){
  int arr[3][3];
  int x;
  bool found[3][3];
  for(int i = 0; i < 3; ++i){
    for(int j = 0; j < 3; ++j){
      cin>>arr[i][j];
      found[i][j] = false;
    }
  }
  int n = 0;
  cin>>n;
  bool ok = true;
  for(int i = 0; i < n; ++i){
    cin>>x;
    for(int j = 0; j < 3; ++j){
      for(int k = 0; k < 3; ++k){
	if(arr[j][k]==x)found[j][k]=true;
      }
    }
  }
  for(int i = 0; i < 3; ++i){
    bool ok = true;
    for(int j = 0; j < 3; ++j){
      if(!found[i][j])ok=false;
    }
    if(ok){cout<<"Yes"<<endl;return 0;}
  }
  for(int i = 0; i < 3; ++i){
    bool ok = true;
    for(int j = 0; j < 3; ++j){
      if(!found[j][i])ok=false;
    }
    if(ok){cout<<"Yes"<<endl;return 0;}
  }
  ok = true;
  for(int i = 0; i < 3; ++i){
    if(!found[i][i])ok=false;
  }
  if(ok){cout<<"Yes"<<endl;return 0;}
  ok = true;
  
  if(!found[2][0])ok=false;
  if(!found[1][1])ok=false;
  if(!found[0][2])ok=false;
  
  if(ok){cout<<"Yes"<<endl;return 0;}
  cout<<"No"<<endl;
  return 0;
}


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

int main() {
  int h, n; cin >> h >> n;
  vector<int> a(n);
  for (int i=0; i<n; i++) cin >> a[i];
  int total = 0;
  for (int i=0; i<n; i++) total += a[i];
  cout << (h > total ? "No" : "Yes") << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h> 
#define int long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define mc map<char, int>
#define ms map<string, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
//#define mod 1000000007LL
#define mod 998244353 
using namespace std;
int power(int x, int y) ;
int gcd(int a, int b) ;
#define pi 3.141592653589


signed main() {
    quickie
    int n, k ;
    cin >> n >> k ;
    string s ;
    cin >> s ;
    rep(i,0,SZ(s)) {
        if(i == k-1) cout << (char)((int)(s[i])+32) ;
        else cout << s[i] ;
    }
    cout << "\n" ;
}

int power(int x, int y) {
    int res = 1; x %= mod;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
 
int gcd(int a,int b){
    if(a==0) return b;
    return gcd(b%a,a);
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define print(obj) cout << obj << endl
#define scan(obj) cin >> obj

typedef long long ll;

using namespace std;

int main(void){
    int n, a, b, ans1 = 0, ans2 = 0, ans3 = 0, ans = 0;
    cin >> n;
    cin >> a >> b;
    int p[n];
    rep(i, n){
        cin >> p[i];
    }
    rep(i, n){
        if(p[i] <= a){
            ans1++;
        }
    }
    rep(i, n){
        if(a + 1 <= p[i] && p[i] <= b){
            ans2++;
        }
    }
    rep(i, n){
        if(p[i] >= b + 1){
            ans3++;
        }
    }
    ans = min(ans1, ans2);
    ans = min(ans, ans3);
    print(ans);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long LL;

const int maxn=1000+10;
vector<int> p;

long long bfs(int n){
    priority_queue<long long,vector<long long>,greater<long long> > que;
    for(long long i=1;i<=9;i++)
        que.push(i);
    int cnt=0;
    long long u;
    while(!que.empty()){
        u=que.top();que.pop();
        if(++cnt==n)
            return u;
        int v=u%10;
        if(que.size()>n)
            continue;
        if(v<9)
            que.push(u*10+(v+1));
        if(v>0)
            que.push(u*10+(v-1));
        que.push(u*10+v);
    }
}

int main()
{
    int i,j,n;
    scanf("%d",&n);
    printf("%lld\n",bfs(n));
    return 0;
}



Measured memory_bytes: 1400