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

long long findAns(long long n, long long a, long long b){
    if(a - 1 < n - b) return a + (b - a - 1)/2;
    else return n - b + 1 + (b - a - 1)/2;
}

int main(){
    long long A, B, N;
    cin >> N >> A >> B;

    if(N == 2){
        cout << 1 << endl;
    } else if((B - A) % 2 == 0){
        cout << (B - A) / 2 << endl;
    } else{
        cout << findAns(N, A, B) << endl;
    }
}


Measured memory_bytes: 3612
#include<stdio.h>

int main(){
    int i;
    long long int sum = 0;
    scanf("%d", &i);
    for(int j = 1; j <= i; j++){
        if((j % 3 != 0) && (j % 5 != 0)){
            sum = sum + j;
        }
    }
    printf("%lld", sum);
    return 0;
}


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

int H, W;
char S[100][100];
bool visited[100][100];
queue<tuple<int, int, int> > que;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

/*
void bfs(int x, int y, int cnt) {
    visited[x][y] = true;
    if (x == H-1 && y == W-1) {
        ans = cnt;
        return;
    }
    else {
        for (int i = 0; i < 4; i++) {
            if (0 <= x+dx[i] && x+dx[i] < H && 
                0 <= y+dy[i] && y+dy[i] < W) {
                if (!visited[x+dx[i]][y+dy[i]]) {
                    if (S[x+dx[i]][y+dy[i]] == '.') {
                        que.push(make_tuple(x+dx[i], y+dy[i], cnt+1));
                    } 
                }
            }
        }
        if (!que.empty()) {
            int next_x = get<0>(que.front());
            int next_y = get<1>(que.front());
            int next_cnt = get<2>(que.front());
            que.pop();
            bfs(next_x, next_y, next_cnt);
        }
        return;
    }
}*/

int main() {
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> S[i][j];
        }
    }

    memset(visited, false, sizeof(visited));

    int white = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S[i][j] == '.') white++;
        }
    }

    int ans = -1;
    int x = 0;
    int y = 0;
    int cnt = 0;
    while (true) {
        if (x == H-1 && y == W-1) {
            ans = cnt;
            break;
        }
        else {
            for (int i = 0; i < 4; i++) {
                if (0 <= x+dx[i] && x+dx[i] < H && 
                    0 <= y+dy[i] && y+dy[i] < W) {
                    if (!visited[x+dx[i]][y+dy[i]]) {
                        if (S[x+dx[i]][y+dy[i]] == '.') {
                            visited[x+dx[i]][y+dy[i]] = true;
                            que.push(make_tuple(x+dx[i], y+dy[i], cnt+1));
                        } 
                    }
                }
            }
            if (!que.empty()) {
                x = get<0>(que.front());
                y = get<1>(que.front());
                cnt = get<2>(que.front());
                que.pop();
            }
            else {
                break;
            }
        }
    }

    // bfs(0, 0, 0);

    if (ans == -1) {
        cout << -1 << endl;
    }
    else {
        cout << white - ans - 1 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
var
 a:array[0..101,0..101] of char;
 i,j,k,n,m:longint;
 s,t:string;
begin
 readln(n,m);
 for i:=1 to n do 
  begin
   readln(s);
   for j:=1 to m do a[i,j]:=s[j];
  end;
  for i:=0 to n+1 do 
   begin
    a[i,0]:=' ';
    a[i,m+1]:=' ';
   end;
  for i:=1 to n do 
   for j:=1 to m do 
    begin
     k:=0;t:='';
     if a[i-1,j]='#' then inc(k);
     if a[i+1,j]='#' then inc(k);
     if a[i,j-1]='#' then inc(k);
     if a[i,j+1]='#' then inc(k);
     if a[i-1,j-1]='#' then inc(k);
     if a[i-1,j+1]='#' then inc(k);
     if a[i+1,j-1]='#' then inc(k);
     if a[i+1,j+1]='#' then inc(k);
     str(k,t);
     if a[i,j]<>'#' then a[i,j]:=t[1];
    end;
   for i:=1 to n do 
    begin
     for j:=1 to m do 
     write(a[i,j]);
     writeln;
    end;
end.

Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<algorithm>
#include <unordered_map> 
#include<utility>
#include<list>
#include<vector>
using namespace std;
int main() {
	int n, b, f, r, v, house[10][12] = { 0 }, cnt = 0;;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> b >> f >> r >> v;
		house[r - 1][f + (b - 1) * 3 - 1] += v;
	}
	for (int i = 0; i < 15; ++i) {
		if ((i + 1) % 4 == 0) {
			cout << "####################" << endl;
			cnt++;
		}
		else {
			for (int j = 0; j < 10; ++j) {
				cout << " " << house[j][i-cnt];
			}cout << endl;
		}
	}
	return 0;
}




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

using namespace std;

bool checkPassword(char ch, char next_ch)
{
  switch (ch) {
  case ('A'):
    if (next_ch == 'B' || next_ch == 'D') return true;
    else return false;
  case ('B'):
    if (next_ch == 'A' || next_ch == 'C'
        || next_ch == 'E') return true;
    else return false;
  case ('C'):
    if (next_ch == 'B' || next_ch == 'F') return true;
    else return false;
  case ('D'):
    if (next_ch == 'A' || next_ch == 'G'
        || next_ch == 'E') return true;
    else return false;
  case ('E'):
    if (next_ch == 'B' || next_ch == 'D'
        || next_ch == 'F' || next_ch == 'H') return true;
    else return false;
  case ('F'):
    if (next_ch == 'C' || next_ch == 'I'
        || next_ch == 'E') return true;
    else return false;
  case ('G'):
    if (next_ch == 'D' || next_ch == 'H') return true;
    else return false;
  case ('H'):
    if (next_ch == 'G' || next_ch == 'I'
        || next_ch == 'E') return true;
    else return false;
  case ('I'):
    if (next_ch == 'F' || next_ch == 'H') return true;
    else return false;
  default:
    return false;
  }
}
  
int main()
{
  int n = 1000;
  while (n--) {
    string password;
    cin >> password;
    bool isPassword = true;
    for (int i = 0; i != password.size() - 1; i++) {
      if (!checkPassword(password[i], password[i + 1])) {
        isPassword = false;
        break;
      }
    }
    if (isPassword) cout << password << endl;
    cin.ignore();
  }
}



Measured memory_bytes: 3100
import collections

n,k = map(int,input().split())
a = list(map(int,input().split()))

#数える
a = collections.Counter(a)

#ソートする
a_sort = sorted(a.items(), key=lambda x:x[1])

#必要な分だけ足す
out = 0
if len(a_sort) <= k:
    print(0)
else:
    for i in range(len(a_sort)-k):
        out += a_sort[i][1]
    print(out)

Measured memory_bytes: 37780
S=list(input())
N=len(S)

ans=0
for i in range(2**(N-1)):
  l=0
  for j in range(N-1):
    if (i>>j)&1:
      ans+=int("".join(S[l:j+1]))
      l=j+1
  ans+=int("".join(S[l:]))
  
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << "\n"
using namespace std;
using ll = long long;

ll mod = 1000000007;

ll expo(ll a, ll b) {
	ll ret = 1;
	a = a % mod;
	while(b) {
		if(b & 1) ret = (ret * a) % mod;
		b /= 2;
		a = (a * a) % mod;
	}
	return ret;
}

ll fact[2000005], invfact[2000005];

ll ncr(ll n, ll r) {
	ll ret = fact[n];
	ret = (ret * invfact[r]) % mod;
	ret = (ret * invfact[n - r]) % mod;
	return ret;
}

signed main() {
    IO;
    fact[0] = 1;
    invfact[0] = expo(fact[0], mod - 2);
    for(ll i = 1; i <= 2000000; ++i) {
    	fact[i] = (fact[i - 1] * i) % mod;
    	invfact[i] = expo(fact[i], mod - 2);
    }
    ll k, sz;
    string s;
    cin >> k >> s;
    sz = s.size();
    ll pr = 0;
    for(ll i = sz; i <= sz + k; ++i) {
    	ll ans = 1;
    	ans = (ans * expo(26, sz + k - i)) % mod;
    	ans = (ans * expo(25, i - sz)) % mod;
    	ll r1 = ncr(sz - 1 + i - sz, sz - 1);
    	ans = (ans * r1) % mod;
    	pr = (pr + ans) % mod;
    }
    cout << pr;
    return 0;
}


Measured memory_bytes: 35480
// VC, WIP

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

// Utility
#define ALL(X) (X).begin(), (X).end()
#define RANGE(I, X, Y) for (int I = (X); I < (Y); I++)
using ll = int64_t;
using ull = uint64_t;
namespace std {
template<class ...Ts>        istream& operator>>(istream& i, tuple<Ts...>& x) { apply([&](auto&&... ys){ ((i >> ys), ...); }, x); return i; }
template<class T1, class T2> istream& operator>>(istream& i, pair<T1, T2>& x) { i >> x.first >> x.second; return i; }
template<class T>            istream& operator>>(istream& i, vector<T>& x)    { for (auto& y : x) { i >> y; } return i; }
}

// Debugging
#define DD(X) std::cout << #X ": " << (X) << std::endl << std::flush
namespace std {
template<class ...Ts>        ostream& operator<<(ostream& o, const tuple<Ts...>& x) { o << "("; apply([&](auto&& y, auto&&... ys){ o << y; ((o << ", " << ys), ...); }, x); o << ")"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const pair<T1, T2>& x) { o << tie(x.first, x.second); return o; }
template<class T>            ostream& operator<<(ostream& o, const vector<T>& x)    { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const set<T1, T2>& x)  { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const map<T1, T2>& x)  { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
}

// Main
void mainCase() {
  string s1, s2;
  cin >> s1 >> s2;
  bool res = s1 == s2.substr(0, s1.size());
  cout << (res ? "Yes" : "No") << endl;
}

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


Measured memory_bytes: 3628
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

const ll mod = 1000000007;
int n;
ll a[300010];
ll ans;

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    cin >> n;
    forn(i, n) cin >> a[i];
    forn(ii, 60)
    {
        ll x = 0;
        ll y = 0;
        forn(i, n)
        {
            if(a[i]&1) x++;
            else y++;
            a[i] >>= 1;
        }
        ll add = x * y % mod * ((1LL<<ii) % mod) % mod;
        ans = (ans + add) % mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  int n;
  cin >> n;

  vector<int> a(n), b(n), c(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ll aCount = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
    ll cCount = n - (upper_bound(c.begin(), c.end(), b[i]) - c.begin());

    ans += aCount * cCount;
  }

  cout << ans << endl;

  return 0;
}


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

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

  if(R<1200){
    cout << "ABC" << endl;
  }
  else if(R<2800){
    cout << "ARC" << endl;
  }
  else{
    cout << "AGC" << endl;
  }

return 0;  
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cassert>
#include <utility>
#include <numeric>
#include <cstring>
using namespace std;
using ll = long long;

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if (B+C >= A){
        cout << B+C - A;
    }
    else cout << "0";
}

Measured memory_bytes: 256
MOD = 998244353

N = int(input())
Ss = input()

convs = {'R': 0, 'G': 1, 'B': 2}
num0 = N
num1s = [0] * 3
num2s = [0] * 3
ans = 1
for S in Ss:
    c = convs[S]
    if num2s[c]:
        ans *= num2s[c]
        num2s[c] -= 1
    else:
        for i in range(3):
            if i == c: continue
            if num1s[i]:
                ans *= num1s[i]
                num1s[i] -= 1
                num2s[3-i-c] += 1
                break
        else:
            ans *= num0
            num0 -= 1
            num1s[c] += 1
    ans %= MOD

print(ans)


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

int main() {
    int a, b, c, k, num = 0;
    cin >> a >> b >> c >> k;
    while(b <= a) {
        b *= 2;
        num++;
    }
    while(c <= b) {
        c *= 2;
        num++;
    }
    cout << ((k >= num)?"Yes":"No") << '\n';
}


Measured memory_bytes: 3648
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()
	as := scanInts(n)

	ans := 1

	hat := make([]int, 3)
	
	for i := 0; i < n; i++ {
		cnt := 0
		add := make([]int, 0)
		for j := 0; j < 3; j++ {
			if as[i] == hat[j] {
				cnt++
				add = append(add,j)
			}
		}
		if len(add) == 0 {
			fmt.Println(0)
			return
		}
		hat[add[0]]++
		ans = (ans*cnt)%mod
	}

	fmt.Println(ans)
}

const mod = 1000000007


Measured memory_bytes: 4736
#include<cstdio>
#include<iostream>
using namespace std;
int main(void){
	long long int w,h,c,i,wh,m,min;
	cin>>w>>h>>c;
	wh=w*h;
	min=9223372036854775807;
	for(i=1;i*i<=wh;i++){
		if(wh%(i*i)==0&&w%i==0&&h%i==0){
			m=(wh/(i*i))*c;
			if(min>m) min=m;
		}
	}
	cout<<min<<endl;
	return 0;
}

Measured memory_bytes: 3128
X, K, D = map(int, input().split())                
negative = False                                   
if X < 0:                                          
    X = -X                                         
    negative = True                                
cnt = X // D                                       
if cnt >= K:                                       
    print(abs(X - D * K))                          
    exit()                                         
K -= cnt                                           
X = X - D * cnt                                    
                                                   
if K % 2 == 0:                                     
    print(abs(X))                                  
else:                                              
    print(abs(X - D))                              
                                                   

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

int main(){
  int h,w;
  while (1){
    cin >> h >> w;
    if (h==0 && w==0) break;
    for (int i = 0; i < h; i++){
      for (int k = 0; k < w; k++){
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;      
  }
  return 0;
}


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

bool desc(const int a, const int b)
{
    return a > b;
}

int putere(int a, int b){
    int sol = 1;
    for(int i = 0 ; i < b ; i++){
        sol *= a;
    }
    return sol;
}

int main()
{
    int n;
    cin>>n;
    vector<int> s(putere(2, n));

    for(auto &x : s){
        cin>>x;
    }

    sort(s.begin(), s.end());

    int length = s.size();
    vector<int> resolved(length, 0);
    resolved[resolved.size() - 1] = 1;

    for(int i = 0 ; i < n ; i++){
        vector<int> parents;
        for(int k = 0 ; k < length ; k++){
            if(resolved[k])
                parents.push_back(s[k]);
        }
        for(int j = length - 1 ; j > -1 ; j--){
            if(parents[parents.size() - 1] > s[j] && resolved[j] == 0){
                resolved[j] = 1;
                parents.pop_back();
            }
            if(parents.size() == 0){
                break;
            }
        }
        if(parents.size() > 0){
            cout<<"No";
            return 0;
        }
    }

    cout<<"Yes";

    return 0;

}


Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <numeric>
#include <climits>
#define ll long long
#define INF 1000000000
using namespace std;
int main(){
    int A[3];
    cin >> A[0] >> A[1] >> A[2];
    sort(A,A+3);
    int ans = 0;
    for(int i=0;i<2;i++){
        ans += A[i];
    }
    cout << ans << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;

bool pair_comp(pair<ll, pair<string, ll>> &a, pair<ll, pair<string, ll>> &b) {
  if (a.second.first == b.second.first) {
    return a.second.second > b.second.second;
  }
  return a.second.first < b.second.first;
}

int main() {
  ll n;
  cin >> n;
  vector<pair<ll, pair<string, ll>>> sp(n);
  for (ll i = 0; i < n; ++i) {
    string s;
    ll p;
    cin >> s >> p;
    sp[i] = pair<ll, pair<string, ll>>(i+1, pair<string, ll>(s, p));
  }
  sort(sp.begin(), sp.end(), pair_comp);

  for (ll i = 0; i < sp.size(); ++i) {
    cout << sp[i].first << endl;
  }
  
  return 0;
}

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

int main() {
    ll N;
    cin>>N;
    ll a=0;
    rep(i,N){
        if((i+1)%3!=0&&(i+1)%5!=0){
            a+=(i+1);
        }
    }
    cout << a << endl;
}

Measured memory_bytes: 3592
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int m;
    int a[]=new int[n+1];

    for (int i=1;i<=n;i++) {
      m=sc.nextInt();
      a[m]=i;
    }

    for (int i=1;i<=n;i++) {
      System.out.println(a[i]);
    }


  }
}


Measured memory_bytes: 59304
N = int(input())
L=[]

for i in range(N):
  a, b = input().split()
  b = int(b)
  lis = []
  lis.append(a)
  lis.append(0-b)
  lis.append(i)
  L.append(lis)
L.sort()
for i in L:
  print(i[2]+1)

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

int main() {
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	string s;
	string t;
	cin >> s >> t;
	// cout<<s<<" "<<t<<endl;
	int n = s.size();
	int m = t.size();

	int dp[n + 1][m + 1];
	int dir[n + 1][m + 1];
	memset(dir, -1 ,sizeof dir);
	
	for(int i = 0; i <= n; ++i) {
		for(int j = 0; j <= m; ++j) {
			if(i == 0 || j == 0) dp[i][j] = 0;
			else if(s[i - 1] == t[j - 1]){
				dir[i][j] = 0;
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
			else {
				if(dp[i - 1][j] > dp[i][j - 1]) {
					dir[i][j] = 1;
					dp[i][j] = dp[i - 1][j];
				}
				else {
					dp[i][j] = dp[i][j - 1];
					dir[i][j] = 2;
				}
			}
		}
	}
	int x = n, y = m;
	string res;
	while(true) {
		if(dir[x][y] == 0) {
			// cout<<s[x-1];
			res += s[x - 1];
			--x;
			--y;
		}
		else if(dir[x][y] == 1) {
			--x;
		}
		else if(dir[x][y] == 2) {
			--y;
		}
		else break;
	}
	reverse(res.begin(), res.end());
	cout<<res;
}

Measured memory_bytes: 73892
// Don't place your source in a package
import java.util.*;
import java.lang.*;
import java.io.*;
 
// Please name your class Main
class Main {
	public static void main (String[] args) throws java.lang.Exception {
	    Scanner in = new Scanner(System.in);
		int m = in.nextInt();
		int n = in.nextInt();
		System.out.println(((n-m)*(n-m+1))/2-n);
	}
}

Measured memory_bytes: 21844
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
char memarr[96000000];
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void rd(string &x){
  char *buf = (char *)wmem;
  rd(buf);
  x = buf;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
string S;
const char *w[] = {"Sunny", "Cloudy", "Rainy"};
int main(){
  int i;
  wmem = memarr;
  rd(S);
  for(i=0;i<(3);i++){
    if(S==w[i]){
      wt_L(w[(i+1)%3]);
      wt_L('\n');
    }
  }
  return 0;
}
// cLay varsion 20190914-1

// --- original code ---
// string S;
// const char *w[] = {"Sunny", "Cloudy", "Rainy"};
// {
//   rd(S);
//   rep(i,3) if(S==w[i]) wt(w[(i+1)%3]);
// }


Measured memory_bytes: 256
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def prime_table(N):
    is_prime = np.zeros(N, np.int64)
    is_prime[2:3] = 1
    is_prime[3::2] = 1
    for p in range(3, N, 2):
        if p * p >= N:
            break
        if is_prime[p]:
            is_prime[p * p::p + p] = 0
    return is_prime, np.where(is_prime)[0]

def main(N, primes):
    div = np.ones(N + 1, dtype=np.int64)
    for p in primes:
        for i in range(N // p + 1):
            div[p * i] += div[i]
    div *= np.arange(N + 1)
    return div.sum()

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.int64
    cc = CC('my_module')

    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)

    main = cc_export(main, (i8, i8[:]))
    cc.compile()

from my_module import main

N = int(read())
is_prime, primes = prime_table(N + 1)
print(main(N, primes))

Measured memory_bytes: 266304
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    string S;
    cin >> S;
    ll p = 1000000007;
    vll mod_ten(S.size() + 1);
    ll x = 1;
    mod_ten[0] = 1;
    REP(i, 1, S.size() + 1){
        mod_ten[i] = mod_ten[i - 1] * 10;
        mod_ten[i] %= 13;
    }
    v2ll dp(S.size() + 1, vll(14, 0));
    dp[0][0] = 1;
    for (int d = S.size() - 1; d >= 0; d--) {
        int i = S.size() - d;
        REP(j, 0, 14) {
            if (S[d] == '?') {
                REP(x, 0, 10) {
                    int t = ((x % 13 * mod_ten[i - 1] % 13) % 13 + j) % 13;
                    dp[i][t] += dp[i - 1][j];
                    dp[i][t] %= p;
                }
            }
            else {
                int x = S[d] - 0x30;
                int t = ((x % 13 * mod_ten[i - 1] % 13) % 13 + j) % 13;
                dp[i][t] += dp[i - 1][j];
                dp[i][t] %= p;
            }
        }
    }
    cout << dp[S.size()][5] << endl;
    return 0;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const ll INF = numeric_limits<ll>::max();
int main()
{
    int h, w, k; cin >> h >> w >> k;
    vector<string> c(h); rep(i, h) cin >> c[i]; 
    
    int ans = 0;
    rep(bith, (1<<h)) {
        rep(bitw, (1<<w)) {
            int cnt = 0;
            rep(i, h) {
                rep(j, w) {
                    if (bith & (1<<i)) { // 列挙に i が含まれるか
                        if (bitw & (1<<j)) { // 列挙に i が含まれるか
                            if(c[i][j] == '#') ++cnt;
                        }
                    }
                    
                }
            }
            if (cnt == k) ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
S = input()

flag = True
c_count = 0
for i in range(0, len(S)):
  if i == 0:
    if S[i] != "A":
      flag = False
      break
  elif i >= 2 and i <= (len(S) - 2):
    if S[i] == "C":
      c_count += 1

  if ord("A") <= ord(S[i]) and ord(S[i]) <= ord("Z"):
    if ord("A") != ord(S[i]) and ord("C") != ord(S[i]):
      flag = False
      break

if flag and c_count == 1:
  print("AC")
else:
  print("WA")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef long double ld;

//repetition
#define REP(i,n)  for(ll i=0;i<n;i++)

unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
 
unsigned binarySearch(ll target, ll max, ll min) {
  while((max - min) > 1) {
      if((max + min)/2 > target) {
        max = (max + min)/2;
        min = min;
      } else {
        max = max;
        min = (max + min)/2;
      }
    }
}


int main() {
  string s, t;
  cin >> s >> t;
  cout << t << s;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;

int i,n,m,d[200010],t[200010],k;

int main()
{
	cin>>n;
	for (i=0;i<n;i++) cin>>d[i];
	sort(d,d+n);
	cin>>m;
	for (i=0;i<m;i++) cin>>t[i];
	sort(t,t+m);
	k=0;
	for (i=0;i<m;i++) 
	{
		while (d[k]<t[i]) k++;
		if (d[k]==t[i])k++; 
		else {cout<<"NO";return 0;}
	}
	cout<<"YES";
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    int N, K;
    cin >> N >> K;
    vector<ll> h(N);
    for(auto& x: h) cin >> x;

    vector<ll> dp(N, 1e18);
    dp[0] = 0;
    for(int i=0; i<N-1; i++){
        for(int j=1; j<=K; j++){
            if(i+j>=N) break;
            dp[i+j] = min(dp[i+j], dp[i]+abs(h[i+j]-h[i]));
        }
    }

    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    l = LMIIS()
    if sum(l) >= 22:
        print('bust')
    else:
        print('win')



if __name__ == '__main__':
    main()

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

namespace abc61
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            int C = int.Parse(str[2]);
            if (C >= A && C <= B)
            {
                Console.WriteLine("Yes");
            }else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 11092
// 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 REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    ll k;
    cin>>n>>k;
    //vector<vector<ll>> v(tate,vector<ll> (yoko));
    vector<ll> v(n);
    rep(i,n)   cin >> v[i];
    ll j;
    for(ll i=k,j=0;i<n;i++,j++){
        //cout<<v[j]<<" "<<v[i]<<endl;
        if(v[j]<v[i]) Yes;
        else No;
    }


    return 0;
}


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

const int nMatch[10] = {0,2,5,5,4,5,6,3,7,6};

string append(string s, string t){
    if(s=="") return t;

    int n = s.length();
    for(int i=0; i<n; i++){
        if(s[i] <= t[0]){
            s.insert(i,t);
            break;
        }
    }

    return s;
}

int main(){
    int N, M;
    vector<int> A;
    cin >> N >> M;
    A = vector<int>(M,0);
    for(int i=0; i<M; i++) cin >> A[i];

    vector<string> dp(N+1,"");
    for(int i=0; i<M; i++){
        int ii = nMatch[A[i]];
        if(ii > N) continue;
        if(dp[ii] == "" || dp[ii] < to_string(A[i])) 
            dp[ii] = to_string(A[i]);
    }

    for(int i=1; i<=N; i++){
        if(dp[i]=="") continue;
        for(int j=0; j<M; j++){
            int nxt = i + nMatch[A[j]];
            if(nxt > N) continue;
            if(dp[nxt].length() < dp[i].length() + 1){
                dp[nxt] = append(dp[i], to_string(A[j]));
            }else if(dp[nxt].length() == dp[i].length() + 1){
                string tmp = append(dp[i], to_string(A[j]));
                if(dp[nxt] < tmp) dp[nxt] = tmp;
            }
        }
    }
    cout << dp[N] << endl;
}


Measured memory_bytes: 53632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    vector<int> vec(5);
    for(int i=0; i<5; i++){
        cin >> vec.at(i);
    }
    int k;
    cin >>k;

    sort(vec.begin(),vec.end());

    for(int i=0; i<5; i++){
        for(int j=i+1; j<5; j++){
            if(vec.at(j)-vec.at(i) > k){
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    cout << "Yay!" << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))
mod=10**9+7

ANS=0

for keta in range(61):
    ZERO=0
    ONE=0

    for a in A:
        if a & (1<<keta)!=0:
            ONE+=1
        else:
            ZERO+=1

    ANS=(ANS+ONE*ZERO*(1<<keta))%mod

print(ANS)


Measured memory_bytes: 123132
#include <iostream>

using namespace std;

int main() {

  char map[8][8];

  char temp[8][8];


  for(int i=0;i<8;i++) {

    cin >> map[i];

  }

  //90ツ度ツ嘉アツ転
  for(int i=0;i<8;i++) for(int j=0;j<8;j++) temp[i][j]=map[7-j][i];

  cout << "90" << endl;

  for(int i=0;i<8;i++) {

    for(int j=0;j<8;j++) {

      cout << temp[i][j];

    }

    cout << endl;

  }

  //180ツ度ツ嘉アツ転
  for(int i=0;i<8;i++) for(int j=0;j<8;j++) temp[i][j]=map[7-i][7-j];

  cout << "180" << endl;

  for(int i=0;i<8;i++) {

    for(int j=0;j<8;j++) {

      cout << temp[i][j];

    }

    cout << endl;

  }

   //270ツ度ツ嘉アツ転
  for(int i=0;i<8;i++) for(int j=0;j<8;j++) temp[i][j]=map[j][7-i];

  cout << "270" << endl;

  for(int i=0;i<8;i++) {

    for(int j=0;j<8;j++) {

      cout << temp[i][j];

    }

    cout << endl;

  }
  return 0;

}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class B { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		var S = GetStrings(N);
		WriteLine("AC x " + S.Count(x => x == "AC"));
		WriteLine("WA x " + S.Count(x => x == "WA"));
		WriteLine("TLE x " + S.Count(x => x == "TLE"));
		WriteLine("RE x " + S.Count(x => x == "RE"));
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


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

using namespace std;

int main(){

    int N;
    cin >> N;

    vector<int> vec(N);
    for(int i = 0; i < N; i++){
	int d;
	cin >> d;
	vec.at(i) = d;
    }

    sort(vec.begin(), vec.end());

    int d = 0;
    int sum = 0;
    for(int i = 0; i < N; i++){
	if(d < vec.at(i)){
	    d = vec.at(i);
	    sum++;
	}
    }
    cout << sum << endl;
    
    return 0;
}


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

int main()
{
    ll x;
    cin >> x;
    int yen500 = int(x / 500);
    x = x - (yen500 * 500);
    int yen5 = int(x / 5);
    ll ans = yen500 * 1000 + yen5 * 5;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
int powing(int a, int b) {
	int ans = 1;
	while (b) {
		if (b % 2) {
			ans *= a;
			ans %= MAX_MOD;
		}
		b /= 2;
		a *= a;
		a %= MAX_MOD;
	}
	return ans;
}
int inv(int now) {
	return powing(now, MAX_MOD - 2LL);
}
void solve() {
	int k, query;
	cin >> k >> query;
	vector<int> inputs;
	REP(i, k) {
		int a;
		cin >> a;
		inputs.push_back(a);
	}
	REP(i, query) {
		int a, b, c;
		cin >> a >> b >> c;
		b %= c;
		int geko = 0;
		for (int q = 0; q < inputs.size(); ++q) {
			if (inputs[q] % c == 0) {
				geko += c;
				continue;
			}
			geko += inputs[q] % c;
		}
		a--;
		long long hoge = a / k;
		int top = b + geko * hoge;
		int ans = a;
		a %= k;
		REP(q, a) {
			if (inputs[q] % c == 0) {
				top += c;
				continue;
			}
			top += inputs[q] % c;
		}
		ans -= top / c;
		cout << ans << endl;
	}
}
#undef int
int main() {
	init();
	solve();
}

Measured memory_bytes: 384
import sys

n,hp=map(int,input().split())
swords=[]
max_a=[]
for i in range(n):
    a,b=map(int,input().split())
    swords.append(b)
    max_a.append(a)

swords.sort()
A=max(max_a)

damage=0
count=0


i=-1
while(A < swords[i]):
    count+=1
    damage+=swords[i]
    if(hp<=damage):
        print(abs(i))
        sys.exit()
        break
    i-=1
    if(i<-1*n):
            break

tmp=(hp-damage)//A
if((hp-damage)%A==0):
    pass
else:
    tmp+=1

print(count + tmp )

Measured memory_bytes: 11296
#include <bits/stdc++.h>
using namespace std;
long long n,k;
long long w[109],s[109];
long long dp[109][100009];
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>w[i]>>s[i];
	}
	dp[0][w[0]]=s[0];
	for(int i=1;i<n;i++){
		for(int j=0;j<=k;j++){
			if(j-w[i]<0){
				dp[i][j]=dp[i-1][j];
				continue;
			}
			dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+s[i]);
		}
	}
	long long mx=0;
	for(int i=0;i<=k;i++){
		mx=max(mx,dp[n-1][i]);
	}
	cout<<mx<<endl;
}


Measured memory_bytes: 79360
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect

def s():
    return input()
def n():
    return int(input())

N = n()
che = 0
name = []
name.append(s())
for i in range(1,N):
    tmp = s()
    if tmp in name or tmp[0] != name[-1][-1]:
        print('No')
        exit()
    else:
        name.append(tmp)
print('Yes')


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

#define V vector
typedef long long ll;
typedef unsigned long long ull;

typedef V<int> vi;
typedef V<ll> vll;
typedef V<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define f(i,a) for(int i = 0 ; i < a ; i++)
#define fll(i,a) for(ll i = 1 ; i <= a ;i++)
#define forab(i,a,b) for(int i = a ; i < b ; i++)
#define prec(x) cout<<fixed<<setprecision(x)
#define ff first
#define ss second
#define INF 1000000000

#define pb push_back
#define mp make_pair
#define numberofdigits(x) floor(log10(x)) + 1

long long binpow(long long a, long long b) {
	long long res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a;
		a = a * a;
		b >>= 1;
	}
	return res;
}


void solve()
{
	int fr[101] = {0};
	int x, n;
	cin >> x >> n;

	for (int i = 1 ; i <= n ; i++)
	{
		int num;
		cin >> num;

		fr[num] = 1;
	}

	int mn = INT_MAX , y = -1;

	for (int i = 0 ; i <= 101 ; i++)
	{
		if (fr[i] == 0)
		{
			if (mn > abs(x - i))
			{
				mn = abs(x - i);
				y =  i;
				//cout << mn << " ";
			} else if (mn == abs(x - i))
			{
				y = min(i, y);
			}
		}
	}

	cout << y << "\n";
}



int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);


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


	while (t--)
	{
		solve();
	}
	return 0;
}

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

using namespace std;
using ll = long long int;

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

  ll sum1 = 0;
  for (ll i = 1; i <= K; i++) {
    for (ll j = i + 1; j <= K; j++) {
      for (ll k = j + 1; k <= K; k++) {
        ll g = __gcd(i, __gcd(j, k));
        sum1 += g;
      }
    }
  }

  ll sum2 = 0;
  for (ll i = 1; i <= K; i++) {
    for (ll j = i + 1; j <= K; j++) {
      ll g = __gcd(i, j);
      sum2 += g;
    }
  }

  ll sum3 = 0;
  for (ll i = 1; i <= K; i++) {
    sum3 += i;
  }

  cout << (sum1 * 6 + sum2 * 6 + sum3) << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <chrono>
#include <math.h>
using namespace std;

using lli = long long int;
using Vint = std::vector<int>;
using Vlli = std::vector<lli>;
using Wint = std::vector<Vint>;
using Wlli = std::vector<Vlli>;
using Vbool = std::vector<bool>;
using pii = std::pair<int, int>;
using pll = std::pair<lli, lli>;

constexpr int MOD = 1e9 + 7;
constexpr int INFi = 2e9 + 1;
constexpr lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {std::make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};
constexpr char BR = '\n';

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(ele, vec) for(auto &(ele) : (vec))
#define vREPcopy(ele, vec) for(auto (ele) : (vec))
#define SORT(A) std::sort((A).begin(), (A).end())


template <class T> inline int argmin(vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}
inline int toInt(string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline int toInt(const string s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res = "";
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;}
  std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

constexpr int MAX_SIZE = 1e5 + 1;
Vint Data(MAX_SIZE, 1);
Vbool Data2(MAX_SIZE, false);

int main(void){
  Data2[0] = true;
  int n, m, x, y; cin >> n >> m;
  REP(_, m){
    cin >> x >> y;
    x--; y--;
    Data[x]--; Data[y]++;
    if(Data2[x]){
      if(Data[x] == 0) Data2[x] = false;
      Data2[y] = true;
    }
  }
  int ans = 0; REP(i, n) if(Data2[i]) ans++;
  cout << ans << BR;
  return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

int main() {
  int n;
  cin >> n;
  vi a(n);
  rep (i, n) {
    cin >> a[i];
  }
  vi ans;
  rrep1 (t, n) {
    bool flag = false;
    rrep (i, a.size()) {
      if (i + 1 == a[i] && a[i] <= t) {
        ans.push_back(a[i]);
        a.erase(a.begin() + i);
        flag = true;
        break;
      }
    }
    if (!flag) {
      cout << -1 << endl;
      return 0;
    }
  }
  rep (i, n) {
    cout << ans[n - 1 - i] << endl;
  }
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
double x,y,a,b,h,pai=3.1415926535897932384;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>x>>y>>a>>b;
	double h=abs(a*30+b*0.5-b*6);
	cout<<fixed<<setprecision(20)<<sqrt(x*x+y*y-2*x*y*cos(h*pai/180.0));
	return 0;
}


Measured memory_bytes: 4192
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
    int n; cin >> n;
    int t[n], x[n], y[n];

    bool traveling = true;

    for (int i = 0; i < n; i++) {
        cin >> t[i] >> x[i] >> y[i];
        int dt = 0, ds = 0;
        if (i == 0) {
            dt = t[i];
            ds = x[i] + y[i];
        } else {
            dt = t[i] - t[i - 1];
            ds = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
        }
        // 旅行がプラン実行が不可能な場合
        if ((dt < ds) || (ds % 2 == 0 && dt % 2 != 0) || (ds % 2 != 0 && dt % 2 == 0)) traveling = false;
    }

    if (traveling) cout << "Yes" << endl;
    else           cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main()
{
    int age, cost;
    cin >> age >> cost;

    auto res = cost;
    if (age < 6) {
        res = 0;
    } else if (age < 13) {
        res = cost / 2;
    }

    cout << res << "\n";
    return 0;
}


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

using namespace std;

typedef long long ll;

int n;
int s[105];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  int sum = 0;
  for(int i=0; i<n; i++) cin >> s[i], sum += s[i];
  if(sum % 10){
    cout << sum << endl;
    return 0;
  }
  int ans = 0;
  for(int i=0; i<n; i++){
    if((sum - s[i]) % 10) ans = max(ans, sum - s[i]);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

const int N = 1010;
int A[N];
int n, ans = 0;
int main() {
    //freopen("a.txt", "r", stdin);
    cin >> n;
    n *= 2;
    for(int i = 1; i <= n; ++i)
        cin >> A[i];
    sort(A + 1, A + n + 1);
    for(int i = 1; i < n; i += 2)
        ans += A[i];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    set<string> st;
    while(n--){
        string s;
        cin >> s;
        st.insert(s);
    }
    cout << st.size();


    return 0;
}


Measured memory_bytes: 19256
K, N = map(int, input().split())
A = list(map(int, input().split()))

dis = [(K+A[0]-A[-1])]

for i in range(len(A)):
    if i+1 == len(A):
        break
    dis.append(A[i+1] - A[i])


        
print(K - max(dis))

Measured memory_bytes: 26000