akhauriyash/Code-Regression huggingface dataset:
/*
Author :: Shahadat Hossain Nirob
............SUST_MATH14..........
*/
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <set>
#include <string>
#include <vector>

#define Long long long
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define II() ( { int a ; read(a) ; a; } )
#define LL() ( { Long a ; read(a) ; a; } )
#define DD() ({double a; scanf("%lf", &a); a;})
#define DB if(0) 
#define D(x) cout << #x " is " << x << endl
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;
typedef vector<PII> VII;
typedef vector<string> VS;

const int INF = 2000000009;
const int MX = 200005;
const double EPS = 1e-9;
const int MOD = 1000000007;

template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }

template<class T>inline bool read(T &x){
    int c=getchar();int sgn=1;
    while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}
    for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; 
    x*=sgn; return ~c;
}

#define nl puts ("")
#define sp printf ( " " )
#define phl printf ( "hello\n" )
#define ff first
#define ss second
#define POPCOUNT __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
#define MP make_pair
#define FOR(i,x,y) for(vlong i = (x) ; i <= (y) ; ++i)
#define ROF(i,x,y) for(vlong i = (y) ; i >= (x) ; --i)
#define CLR(x,y) memset(x,y,sizeof(x))
#define UNIQUE(V) (V).erase(unique((V).begin(),(V).end()),(V).end())
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1)
#define SQ(x) ((x)*(x))
#define ABS(x) ((x)<0?-(x):(x))
#define FABS(x) ((x)+eps<0?-(x):(x))
#define ALL(x) (x).begin(),(x).end()
#define LCM(x,y) (((x)/gcd((x),(y)))*(y))
#define SZ(x) ((vlong)(x).size())
#define NORM(x) if(x>=mod)x-=mod;
#define MOD(x,y) (((x)*(y))%mod)
#define ODD(x) (((x)&1)==0?(0):(1))

typedef string st;
typedef vector<st> vs;
#define rep(i, n) for(int i = 0; i < n; i++)
#define fogg(i,a,b) for(int i = (a); i <= (b); i++)
#define ford(i,a,b) for(int i = (a); i >= (b); i--)
#define test int t; cin >> t; while(t--)
#define endl '\n'
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main()
{
	/*
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    */
    
    int l=II(),pos=II();
    string s;
    cin >> s;
    s[pos-1]=s[pos-1]+32;
    cout << s << endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,Y;
  cin >> N >> Y;
  int res10000 = -1, res5000 = -1, res1000 = -1;
  for (int a = 0; a <= N; a++) {
    for (int b = 0; a + b <= N; b++) {
      int c = N - a - b;
      int total = 10000 * a + 5000 * b + 1000 * c;
      if (total == Y) {
        res10000 = a;
        res5000 = b;
        res1000 = c;
      }
    }
  }
  cout << res10000 << " " << res5000 << " " << res1000 << endl;
}

Measured memory_bytes: 256
N = int(input())
d = dict()

for i in range(0, N):
    si = input()
    si_sorted = "".join(sorted(list(si)))
    if si_sorted in d:
        d[si_sorted] = d[si_sorted] + 1
    else:
        d[si_sorted] = 1

res = 0
for v in d.values():
    res = res + v * (v - 1) // 2

print(res)


Measured memory_bytes: 17892
#include <bits/stdc++.h>
using namespace std;
#define REP(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define dup(x, y) (((x) + (y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template <class T> inline void chmax(T &a, T b) {
    if(a < b) {
        a = b;
    }
}
template <class T> inline void chmin(T &a, T b) {
    if(a > b) {
        a = b;
    }
}
template <class T> inline T gcd(T x, T y) {
    if(y == 0) {
        return x;
    } else if(x == 0) {
        return y;
    }
    return gcd(y, x % y);
}
template <class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template <class T> inline void print_vector(vector<T> vec) {
    for(int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    cout << endl;
}
const LL MOD = 1e9 + 7;
const LL LLINF = 1LL << 60;
const int INF = 1 << 30;

int main(void) {
    vector<int> ABC(3);
    rep(i,3) cin >> ABC[i];

    int ans = 0;
    sort(RALL(ABC));
    while(ABC[0] != ABC[1]){
        ABC[1]++;
        ABC[2]++;
        ans++;
    }

    if((ABC[1] - ABC[2])%2 == 0){
        ans += (ABC[1] - ABC[2])/2;
    }else{
        ans += (ABC[1] - ABC[2])/2 + 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	var i int
	if sc.Scan() {
		if num, err := strconv.Atoi(sc.Text()); err == nil {
			i = num
		}
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	var employees = nextInt()
	var subordinateNum = map[int]int{}
	for empNum := 1; empNum <= employees; empNum++ {
		subordinateNum[empNum] = 0
	}
	for empNum := 2; empNum <= employees; empNum++ {
		managerNo := nextInt()
		subordinateNum[managerNo]++
	}
	for empNum := 1; empNum <= employees; empNum++ {
		fmt.Println(subordinateNum[empNum])
	}
}


Measured memory_bytes: 13636
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d,e,sum;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;
	cin >> e;
	if(a<0){
		sum=-a*c+d+b*e;
	}
	if(a==0){
		sum=d+b*e;
	}
	if(a>0){
		sum=(b-a)*e;
	}
	cout << sum << endl;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

ll N, M;
vvll g(110000);

ll dp1[110000], dp2[110000], ans[110000];

void dfs1(ll x, ll p = -1) {
    ll prod = 1;
    for(auto to : g[x]) {
        if(to == p) continue;
        dfs1(to, x);
        prod *= dp1[to];
        prod %= M;
    }
    dp1[x] = (prod + 1) % M;
}

void dfs2(ll x, ll p = -1) {
    if(p == -1) dp2[x] = 1;

    vll lprod(g[x].size(), 1);
    vll rprod(g[x].size(), 1);
    rep(i, g[x].size()) {
        auto to = g[x][i];
        if(i-1 >= 0) lprod[i] = lprod[i-1];
        if(to == p) continue;
        (lprod[i] *= dp1[to]) %= M;
    }
    for(ll i = (ll)g[x].size() - 1; i >= 0; i--) {
        auto to = g[x][i];
        if(i+1 < rprod.size()) rprod[i] = rprod[i+1];
        if(to == p) continue;
        (rprod[i] *= dp1[to]) %= M;
    }

    rep(i, g[x].size()) {
        auto to = g[x][i];
        if(to == p) continue;
        ll rest_prod = 1;
        if(i-1 >= 0) (rest_prod *= lprod[i-1]) %= M;
        if(i+1 < rprod.size()) (rest_prod *= rprod[i+1]) %= M;
        dp2[to] = (dp2[x] * rest_prod + 1) % M;
        dfs2(to, x);
    }
}

void dfs3(ll x, ll p = -1) {
    ans[x] = dp2[x];
    for(auto to : g[x]) {
        if(to == p) continue;
        ans[x] *= dp1[to];
        ans[x] %= M;
        dfs3(to, x);
    }
}

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

    cin >> N >> M;
    rep(i,N-1) {
        ll x, y;
        cin >> x >> y;
        x--, y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    dfs1(0);
    dfs2(0);
    dfs3(0);
    rep(i,N) cout << ans[i] << endl;
}


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

using namespace std;

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

		string A = "";
		string B = "";

		for (int i = 0; i < b; i++) {
				A += to_string(a); 
		}
		for (int i = 0; i < a; i++) {
				B += to_string(b); 
		}

		if (A < B) {
				cout << A << endl;
		} else {
				cout << B << endl;
		}
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s1 = sc.next();
		for(int i = 0;i < s1.length();i++) {
			if(i == 0 || i % 2 == 0) {
			System.out.print(s1.charAt(i));
			}else {
				System.out.print("");
			}
		}
	}
}



Measured memory_bytes: 30676
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
typedef pair<int, int> P;
typedef pair<pair<int, int>, int> PP;
const ll INFL = 1LL << 60;
const ll MOD = 1000000007;
const int INF = 1000000005;
const int MAX = 300000;
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
//------------------------------------------------------------------------------------------------------------------------------

int main(void) {
    // code here
    int X;
    ll ans = 0;
    cin >> X;
    ans += 1000 * (X / 500);
    X -= 500 * (X / 500);
    ans += 5 * (X / 5);
    cout << ans << endl;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if (a == b) cout << "Draw" << endl;
  else if (a == 1) cout << "Alice" << endl;
  else if (b == 1) cout << "Bob" << endl;
  else if (a < b) cout << "Bob" << endl;
  else cout << "Alice" << endl;
}


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

int main()
{
    int n,r;
    cin>>n>>r;
    if(n>=10)cout<<r<<endl;
    else{
        cout<<r+(100*(10-n))<<endl;
    }

    return 0 ;
}



Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main implements Runnable {
    public static void main(String[] args) {
        new Thread(null,new Main(), "" ,Runtime.getRuntime().maxMemory()).start();
    }

    public void run() {
        FastScanner sc = new FastScanner();
        int k = sc.nextInt();
        String s = sc.next();

        String ans = "";
        if(s.length() <= k) {
            ans = s;
        }
        else {
            ans = s.substring(0, k) + "...";
        }
        
        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 36492
import java.util.Scanner;

class Main {
    static void containCheck(int[][] a, int b, boolean[][] c) {
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (a[i][j] == b) {
                    c[i][j] = true;
                    return;
                }
            }
        }
    }

    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int[][] a = new int[3][3];
        boolean[][] check = new boolean[3][3];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                a[i][j] = Integer.parseInt(stdIn.next());
            }
        }
        int n = Integer.parseInt(stdIn.next());
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            b[i] = Integer.parseInt(stdIn.next());
            containCheck(a, b[i], check);
        }

        boolean bingo = false;
        for (int i = 0; i < 3; i++) {
            int j;
            for (j = 0; j < 3; j++) {
                if (!check[i][j]) {
                    break;
                }
            }
            if (j == 3) {
                bingo = true;
            }
        }

        if (!bingo) {
            for (int i = 0; i < 3; i++) {
                int j;
                for (j = 0; j < 3; j++) {
                    if (!check[j][i]) {
                        break;
                    }
                }
                if (j == 3) {
                    bingo = true;
                }
            }
        }

        if (!bingo) {
            int i;
            for (i = 0; i < 3; i++) {
                if (!check[i][i]) {
                    break;
                }
            }
            if (i == 3) {
                bingo = true;
            }
        }

        if (!bingo) {
            int i;
            for (i = 0; i < 3; i++) {
                if (!check[i][2 - i]) {
                    break;
                }
            }
            if (i == 3) {
                bingo = true;
            }
        }

        if (bingo) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
typedef pair<int,int> P;
struct edge{int to, id;};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    ll a[n+1];
    ll b[m+1];
    ll suma[n+1];
    ll sumb[m+1];
    rep(i,n+1){
        a[i] = 0;
        suma[i] = 0;
    }
    rep(i,m+1){
        b[i] = 0;
        sumb[i] = 0;
    }
    for(int i = 1; i <= n; i++){
        ll temp;
        cin >> temp;
        a[i] = temp;
        suma[i] = suma[i-1]+temp;
    }
    for(int i = 1; i <= m; i++){
        ll temp;
        cin >> temp;
        b[i] = temp;
        sumb[i] = sumb[i-1]+temp;
    }
    int upper = m;
    int ans = -1;
    for(int i = 0; i <= n && suma[i] <= k;i++){
        while(sumb[upper] + suma[i]> k && upper > 0){
            upper--;
        }
        //ans = max(ans,upper+i+2);
        int temp = upper+i;
        if(ans < upper+i){
            ans = temp;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9864
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created: 日  9/23 21:17:33 2018

# Usage
#
"""
def get_input():
    first = [int(i) for i in input().split(" ")]
    second = list(sorted([int(i) for i in input().split(" ")]))
    third = list(sorted([int(i) for i in input().split(" ")]))

    return first[2], first[3], second, third

def judge(x, y, x_list, y_list):
    """
    >>> judge(10,20,[8,15], [16,22])
    >>> judge(-48, -1, [-20,-35,-91,-23], [-22, 66])
    >>> judge(6,8, [-10,3,1,5,-100], [100,6,14])
    """
    x_max = max(x_list)
    y_min = min(y_list)

    if x_max >= y_min:
        return False
    if y <= x_max:
        return False
    if y_min <= x:
        return False
    return True

if __name__ == '__main__':
    # import doctest
    # doctest.testmod()
    res = judge(*get_input())
    if res:
        print("No War")
    else:
        print("War")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100005
#define PAIR pair<ll,ll>

ll dp[1000002][2][2];

ll F(ll i,ll c1,ll c2)
{
    if(i<=0){
        if(c1&&c2) return 1;
        else return 0;
    }

    if(dp[i][c1][c2]!=-1) return dp[i][c1][c2];

    ll ret = 0;

    for(ll j = 0;j<=9;j++)
    {
        ret = ret + F(i-1,c1 | (j==0),c2 | (j==9))%mod;
        ret%=mod;
    }

    return dp[i][c1][c2] = ret;
}

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

    ll n;
    cin>>n;

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

    memset(dp, -1, sizeof dp);
    ll ans = F(n,0,0);

    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 112908
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int n,m;
char a[100+50];
string st;
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
    	for(int j=1;j<=m;j++)
    		cin>>a[j];
    	for(int k=1;k<=m;k++)
    		cout<<a[k];
    	cout<<"\n";
    	for(int k=1;k<=m;k++)
    		cout<<a[k];
    	cout<<"\n";
    }
	return 0;
}

Measured memory_bytes: 256
/*
    Author: isaf27 (Ivan Safonov)
*/

#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

//defines
typedef long long ll;
typedef long double ld;
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define what_is(x) cerr << #x << " is " << x << endl
#define solve_system int number; cin >> number; for (int i = 0; i < number; i++) solve()
#define solve_system_scanf int number; scanf("%d", &number); for (int i = 0; i < number; i++) solve()

//permanent constants
const ld pi = acos(-1.0);
const ld log23 = 1.58496250072115618145373894394781;
const ld eps = 1e-8;
const ll INF = 1e18 + 239;
const ll prost = 239;
const int two = 2;
const int th = 3;
const ll MOD = 1e9 + 7; //998244353;
const ll MOD2 = MOD * MOD;
const int BIG = 1e9 + 239;
const int alf = 26;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dxb[4] = {-1, 1, 1, -1};
const int dyb[4] = {-1, 1, -1, 1};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int dig = 10;
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int digarr[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const ll bt = 30;

//easy functions
template< typename T >
inline T gcd(T a, T b)
{
    while (a)
    {
        b %= a;
        swap(a, b);
    }
    return b;
}
template< typename T >
inline T lcm(T a, T b) { return (a / gcd(a, b)) * b; }
inline bool is_down(char x) { return ('a' <= x && x <= 'z'); }
inline bool is_upper(char x) { return ('A' <= x && x <= 'Z'); }
inline bool is_digit(char x) { return ('0' <= x && x <= '9'); }

//random
//mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rnd(239);

//constants
const int M = 2e5 + 239;
const int N = (2 * M);
const int L = 20;
const int T = (1 << 20);
const int B = trunc(sqrt(M)) + 1;
const int X = 1e4 + 239;

ll ln, a[M], pref[M];
int n;

ll gett(int l, int r)
{
    if (l > r) return 0;
    //if (l < 0) cerr << "BAD!!\n";
    return (pref[r + 1] - pref[l]);
}

ll solve()
{
    //for (int i = 0; i < n; i++)
    //    cerr << a[i] << " ";
    //cerr << "\n";
    pref[0] = 0;
    for (int i = 0; i < n; i++)
        pref[i + 1] = pref[i] + a[i];
    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        ll f = 0;
        int l = i + 1;
        int r = n - l;
        r = min(r, l);
        l = min(l, r);
        //cerr << l << " " << r << "\n";
        f += 2LL * gett(i - l, i);
        f += 2LL * (ln * (ll)r - gett(i + 1, i + r));
        f -= a[i];
        //cerr << gett(i + 1, i + r) << "f\n";
        //cerr << f << "\n";
        ans = max(ans, f);
    }
    return ans;
}

int main()
{
    #ifdef ONPC
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> ln >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    ll ans = solve();
    reverse(a, a + n);
    for (int i = 0; i < n; i++)
        a[i] = ln - a[i];
    ans = max(ans, solve());
    cout << ans;
    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define FASTIO() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N = 200005, M = 1000000007, BIG = 0x3f3f3f3f;

int n;
int m;

bool Read() {
  cin >> n;
  if (cin.eof())
    return 0;
  cin >> m;

  return 1;
}

void Process() {
  int sum = n + m;
  int c = sum * (sum - 1) / 2;
  cout << c - n * m << "\n";
}

int main() {
  FASTIO();

  while (Read())
    Process();

  return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class B105 {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n;
	    in >> n;
	    int res = 0;
	    for(int i=1; i<=n; i++){
	        if(i%2 == 0) continue;
	        int cnt = 0;
	        for(int j=1; j<=i; j++){
	            if(i%j == 0) cnt++;
	        }
	        if(cnt == 8) res++;
	    }

	    out << res << endl;
	}
};


int main() {
	B105 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main() {
  string S;
    cin >> S;
  
  int N;
  N=S.size()-1;

  int kai=0;

 for(int i=0; i<N; i++){
    if(S.at(i)!=S.at(N-i)){
      kai++;
      }
    }


  for(int j=0; j<(N-1)/2; j++){
    if(S.at(j)!=S.at(((N-1)/2)-j)){
      kai++;
      }
  }

  for(int k=0; k<(N-(N+3)/2); k++){
    if(S.at(((N+3)/2)+k)!=S.at(N-k)){
      kai++;
    }
  }

  if(kai==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
  
   int main(void){
  
       int S,s,m,h;
       scanf("%d",&S);
       if(S>=0 && S<=86400){
  
           h=S/(60*60);
          m=(S%(60*60))/60;
          s=S%60;
          printf("%d:%d:%d\n",h,m,s);
 
      }
      return 0;
  }

Measured memory_bytes: 1020
/*
ID:dyx_6661
TASK:
LANG:
*/
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<algorithm>
#include<deque>
#include<set>
#include<map>
#include<vector>
#include<iostream>
using namespace std;
typedef long long int ll;
typedef double db;
typedef string str;
typedef pair<int,int> pa;
typedef vector<int> vec;

int A,B; 

int main(){
//  freopen(".in","r",stdin);
//  freopen(".out","w",stdout);
    scanf("%d%d",&A,&B);
    printf("%d",max(A-B,max(A+B,A*B)));
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  char S[110], T[110];
  cin >> S >> T;
  for (int i = 0; i < N; i++) {
    cout << S[i] << T[i];
  }
  cout << '\n';
}


Measured memory_bytes: 256
/*#include <iostream>
using namespace std;
const int N = 100010;
int n, length;
int step;
int a[N], vis[N];
int p;
long long k;
int dfs(int x) {
	if (vis[x]) return x;
	step++;
	vis[x] = 1;
	dfs(a[x]);
}

void dfs1(int x) {
	if (length && x == p) return;
	length++;
	dfs1(a[x]);
}

int main() {
	ios::sync_with_stdio(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++) cin >> a[i];

	p = dfs(1);
	if (k <= step) {
		int now = 1;
		for (int i = 1; i <= k; i++) {
			now = a[now];
		}
		cout << now << endl;
	}
	else {
		dfs1(p);
		int sstep = (k - step) % length;
		int now = p;
		for (int i = 1; i <= sstep; i++) {
			now = a[now];
		}
		cout << now << endl;
	}

}


*/
/*
#include <bits/stdc++.h>
using namespace std;
const int N = 1000 + 10;
int T, p1, p2, x, y;
char mp[N][N];
int f;
int ans;
void dfs(int mx, int my) {
	if (my == y + 1) dfs(mx + 1, 1);
	if (mx == x + 1) return;
	if (mp[mx][my] == '*') dfs(mx, my + 1);
	if (mp[mx][my] == '.' && mp[mx][my + 1] == '.') {
		ans += p2;
		dfs(mx, my + 2);
	}
	else if (mp[mx][my] == '.' && mp[mx][my + 1] != '.') {
		ans += p1;
		dfs(mx, my + 1);
	}
}

int main() {
	cin >> T;
	while (T--) {
		ans = 0;
		int sum = 0;
		getchar();
		cin >> x >> y >> p1 >> p2;
		for (int i = 1; i <= x; i++) {
			for (int j = 1; j <= y; j++) {
				cin >> mp[i][j];
				if (mp[i][j] == '.') sum++;
			}
		}
		if (p1 * 2 < p2) {
			cout << p1 * sum << endl;
			continue;
		}
		dfs(1, 1);
		cout << ans << endl;
		memset(mp, 0, sizeof mp);
	}
}
*/
#include <iostream>
using namespace std;
typedef long long ll;
ll a, b;
ll solve(ll n) {
	ll t = n & 3;
	if (t & 1) return t / 2 ^ 1;
	return t / 2 ^ n;
}

int main() {
	cin >> a >> b;
	ll x = solve(a - 1), y = solve(b);
	ll ans = y ^ x;
	cout << ans << endl;
}

Measured memory_bytes: 3640
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    Set<Integer> alreadyNums;
    public int getFirstOccurrence(int k) {
        if (k % 2 == 0) return -1;
        alreadyNums = new HashSet<>();

        int count = 1;
        int dividend = 7;
        while (true) {
            if (dividend % k == 0) return count;
            if (alreadyNums.contains(dividend % k)) return -1;
            alreadyNums.add(dividend % k);
            dividend = (dividend % k) * 10 + 7;
            count++;
        }
    }

    public static void main(String[] args) throws Exception {
        Main solution = new Main();

        Scanner scanner = new Scanner(System.in);
        int k = scanner.nextInt();

        int answer = solution.getFirstOccurrence(k);
        System.out.println(answer);
    }
}

Measured memory_bytes: 102908
def f_contrast():
    from collections import Counter
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [int(i) for i in input().split()]

    c = [0] * (N + 1)
    d = [0] * (N + 1)

    for a, b in zip(A, B):
        c[a] += 1
        d[b] += 1

    for s, t in zip(c, d):
        if s + t > N:
            return 'No'

    for i in range(1, N + 1):
        c[i] += c[i - 1]
        d[i] += d[i - 1]

    shift = max(c[i] - d[i - 1] for i in range(1, N + 1))
    ans = [B[(i + N - shift) % N] for i in range(N)]
    ret = ' '.join(map(str, ans))
    return f'Yes\n{ret}'

print(f_contrast())

Measured memory_bytes: 59188
#include<iostream>
using namespace std;
int main(void)
{
	int a,b,c;
	cin >> a >> b >> c;
	for(int i=1;i<=b;i++)
	{
		if(i*a%b==c)
		{
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
mod=10**9+7

a=[]
for i in range(M):
    a.append(int(input()))
a.sort(reverse=True)

DP=[1]*(N+1)

if len(a)>0 and 1==a[-1]:
    DP[1]=0
    a.pop()


for i in range(2,N+1):
    if len(a)>0 and i==a[-1]:
        DP[i]=0
        a.pop()
        if DP[i-1]==0:
            print(0)
            exit()
    else:
        DP[i]=DP[i-1]+DP[i-2]
        DP[i]=DP[i]%mod

print(DP[N])


Measured memory_bytes: 7848
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <limits>
#include <algorithm>
#include <queue>
#include <set>
#include <unordered_map>
#include <numeric>
using namespace std;

int main() {
	int N;
	cin >> N;
	int sum = 0,Lma = 0;
	for (int i = 0; i < N; i++) {
		int L;
		cin >> L;
		sum += L;
		Lma = max(Lma, L);
	}
	if (Lma < sum - Lma) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>

using namespace std;

const int maxn = 10000 + 10;

int main()
{
    int n;
    while(scanf("%d",&n)!= EOF){
        int cot = 0;
        for (int i = 1 ; i <= n ; i ++){
            int A;
            int flag = 1;
            scanf("%d",&A);
            for (int i = 2 ; i <= (int)sqrt(A) ; i ++){
                if (A % i == 0){
                    flag = 0;
                    break;
                }
            }
            if (flag){
                cot ++;
            }
        }
    cout << cot << endl;
    }
    return 0;
}



Measured memory_bytes: 3236
// Problem : B - Go to Jail
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// Macros

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int, int>
#define mii map<pii, int>
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(x) (int) x.size()
#define mod 1000000007
#define EPS 1e-9
#define inf 1e10
#define PI acos(-1.0)
#define int long long
#define N 100005

// Solution

void solve() {
  int n;
  cin >> n;
  vii p(n);
  for (auto & [ a, b ] : p) cin >> a >> b;
  int cnt = 0;
  for (auto[a, b] : p) {
    if (a == b)
      cnt++;
    else
      cnt = 0;
    if (cnt >= 3) {
      cout << "Yes\n";
      return;
    }
  }
  cout << "No\n";
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

  int tests;
  tests = 1;
  // cin>>tests;

  for (int test = 1; test <= tests; test++) {
    // cout<<"Case #"<<test<<": ";
    solve();
  }

  return 0;
}

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

/*
Knapsack 1では
dp[i][sum_w] := i-1 番目までの品物から重さが sum_w を超えないように選んだときの、価値の総和の最大値
としたが, 今回はWの制約が大きいので, 添字を変えて
dp[i][sum_v] := i-1 番目までの品物から価値が sum_v 以上を達成するように選んだときの、重さの総和の最小値
とする.
*/

int main() {
  int N;
  ll W;
  cin >> N >> W;
  vector<ll> weights(N), values(N);
  for (int i = 0; i < N; i++) cin >> weights[i] >> values[i];
  
  const ll INF = 1LL << 60;
  const int MAX_V = 100010;
  vector<vector<ll>> dp(N+1, vector<ll>(MAX_V, INF));
  dp[0][0] = 0;
  for (int i = 0; i < N; i++) {
    for (ll j = 0; j < MAX_V; j++) {
      if (j - values[i] >= 0) dp[i+1][j] = min(dp[i+1][j], dp[i][j-values[i]] + weights[i]);
      dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
    }
  }
  
  // 重さW以内の, 価値の最大の総和
  ll res = 0;
  for (ll i = 0; i < MAX_V; i++) if (dp[N][i] <= W) res = i;
  cout << res << endl;
}

Measured memory_bytes: 83148
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<list>
using namespace std;
constexpr auto MOD = 1000000007;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VLL;



int main() {
   int n, k;
   int a;
   cin >> n >> k;
   int cnt = 0;
   for (int i = 0; i < n; i++)
   {
	  cin >> a;
	  if (a >= k)cnt++;
   }
   cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int n;
double a[300],a1,a2;
int h,t;
double ans,temp;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	h=1,t=n;
	while(1)
	{
		sort(a+h,a+t+1);
		temp=(double)(a[h]+a[h+1])/2;
		h+=2;
		a[++t]=temp;
		if(h>=t) break;
	}
	printf("%.6lf",temp);
	return 0;
}

Measured memory_bytes: 256
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

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

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    a,b = map(int,input().split())
    if a%2!=0 and b%2!=0:
        print('Odd')
    else:
        print('Even')
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38892
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>

using namespace std;
typedef long long ll;


int main()
{
	int n, k = 0;
	cin >> n;
	while (n) {
		if (n == 1)break;
		k++;
		
		n = (n >> 1);
	}
	int ans= 1;
	while (k--) {
		ans = ans << 1;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include<unordered_map>
using namespace std;
const long long int mod1=1000000007;
const long long int mod2 = -1;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back                                       
#define ff first
#define ss second
#define ll long long int
#define ull unsigned long long int
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define ordered1 tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define inf mod1
#define all(x) x.begin(),x.end()
ll gcd(ll a, ll b){
    ll c;
     while(b){
        c = b;
        b = a % b;
        a = c;
     }
     return a;
}
ll power1(ll a, ll b){
     if(b == 0) return 1;
     else if(b % 2) return a * power1(a, b - 1);
     else {
        ll temp = power1(a, b / 2);
        return temp * temp;
     }
}
ll power2(ll a, ll b, ll m){
     a %= m;
     if(b == 0) return 1;
     else if(b % 2) return (a * power2(a, b - 1, m)) % m;
     else{
        ll temp = power2(a, b / 2, m);
        return (temp * temp) % m;
     }
}
ll mod(ll x, ll p){
return (x % p + p) % p;
}
ll lcm(ll x, ll y){
return (x * y)/gcd(x, y);
}
int main(){
    fast;
    ll tt = 1;
    //cin >> tt;
    while(tt--){
        ll n, m;
        cin >> n >> m;
        ll o = 0;
        for(int i = 0; i < m; i++){
            ll x;
            cin >> x;
            o += x;
        }
        if(o > n){
            cout << -1 << endl;
        }
        else{
            cout << n - o << endl;
        }
    }
}

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

#define int int_fast64_t

signed main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);

  int n; cin >> n;
  vector<pair<int, int> > v(n);
  for (auto& x : v)
    cin >> x.first >> x.second;
  vector<int> l(n), r(n);
  iota(l.begin(), l.end(), int(0));
  iota(r.begin(), r.end(), int(0));
  sort(l.begin(), l.end(), [&](int i, int j) { return v[i].second < v[j].second; });
  sort(r.begin(), r.end(), [&](int i, int j) { return v[i].first  > v[j].first ; });

  struct state { int ans, pos; vector<bool> used; } lfirst={0,0,vector<bool>(n)}, rfirst={0,0,vector<bool>(n)};
  auto walk = [&](int i, state& s) {
    if (s.used[i])
      return;
    int l=v[i].first, r=v[i].second;
    if (l <= s.pos && s.pos <= r)
      return;
    s.used[i] = true;
    int to = r < s.pos ? r : l;
    s.ans += abs(to - s.pos);
    s.pos = to;
  };
  auto finish = [](state& s) {
    s.ans += abs(s.pos);
    s.pos = 0;
  };
  for (int i=0; i<n; ++i) {
    walk(r[i], rfirst);
    walk(l[i], rfirst);

    walk(l[i], lfirst);
    walk(r[i], lfirst);
  }
  finish(lfirst);
  finish(rfirst);
  cout << max(lfirst.ans, rfirst.ans) << '\n';
}

/*
 * Local variables:
 * compile-command:"g++ -D_GLIBCXX_DEBUG -g3 -ggdb3 -O0 -Wall -Wextra -std=c++14 c.cc -o c && for f in *.in; do echo \"--- $f -------------\"; ./c <$f; done"
 * end:
 */



Measured memory_bytes: 3456
#include<iostream>
using namespace std;
int main(){
    while(1){
        int stone[50]={},p,n,flag,winer=-1;
        cin >> n >> p;
        if(n==0&&p==0)  break;
        while(winer<0){
            for(int i=0;i<n;i++){
                flag = 0;
                for(int j=0;j<n;j++){
                    if(stone[j]!=0&&j!=i){
                        flag=1;
                        break;
                    }
                }
                
                if(p==1&&flag==0){
                    winer = i;
                    break;
                }
                else if(p==0) {
                    p+=stone[i];
                    stone[i]=0;
                }
                else{
                    p--;
                    stone[i]++;
                }
            }
        }
        cout << winer << "\n";
    }
}

Measured memory_bytes: 3068
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApp14
{
    class Program
    {
        static void Main(string[] args)
        {
            var solver = new Solver();
            solver.Calc();
        }
    }

    public class Solver
    {


        public void Calc()
        {
            var N = int.Parse(Console.ReadLine());


            var dic = new Dictionary<char, Dictionary<char, int>>();

            for (var a = 1; a <= 9; a++)
            {

                var chi = new Dictionary<char, int>();
                dic.Add(a.ToString()[0], chi);
                for (var b = 1; b <= 9; b++)
                {
                    chi.Add(b.ToString()[b.ToString().Length - 1], 0);
                }
            }
            for (var a = 1; a <= N; a++)
            {
                if (a.ToString()[a.ToString().Length - 1] != '0')
                {
                    dic[a.ToString()[0]][a.ToString()[a.ToString().Length - 1]]++;
                }
            }

            var count = 0;
            for (var a = 1; a <= N; a++)
            {
                if (a.ToString()[a.ToString().Length - 1] != '0')
                {
                    count += dic[a.ToString()[a.ToString().Length - 1]][a.ToString()[0]];
                }
            }


            Console.WriteLine(count);

        }
    }
}

Measured memory_bytes: 17352
#include<bits/stdc++.h>
#include<cctype>
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 rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;

int main(){
  vector<ll> dp(40,1);
  for (int i=1;i<=30;i++){
    dp[i] = dp[i-1];
    if (i>1) dp[i] += dp[i-2];
    if (i>2) dp[i] += dp[i-3];
  }
  rep(i,30){
    int n; cin >> n;
    if (n==0) return 0;
    ll day = (dp[n]+9)/10;
    ll year = (day+364)/365;
    cout << year << endl;
  }
 

  // cout << fixed << setprecision(10);
  
  return 0;
}



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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n; cin >> n;
  double t,a; cin >> t >> a;
  vector<double> h(n); rep(i,n) cin >> h[i];

  double temp = INF;
  int ans;
  rep(i,n){
    double tmp = t-h[i]*0.006;
    double test = abs(a-tmp);
    if(temp>=test){
      temp = test;
      ans = i+1;
    }
  }

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


Measured memory_bytes: 3728
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, m;

int main(){
	cin >> n >> m;
	if(n > m){cout << 2*n-1 << endl;}
	if(m > n){cout << 2*m-1 << endl;}
	if(m == n){cout << 2*n << endl;}
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  string s;
  cin >> s;
  char a = s[0];
  int ans = 0;
  rep(i, 1, s.length()) {
    if(a != s[i]) {
      a = s[i];
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
/*
[abc129] F - Takahashi's Basics in Education and Learning
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

ll L, A, B;
int MOD;

class gf {
public:
    int n;
    gf() : n(0) {}
    gf(int n) : n(n % MOD) {}
    gf operator+(const gf x) const { return gf((n + x.n) % MOD); }
    gf operator*(const gf x) const { return gf((1LL * n * x.n) % MOD); }
    gf &operator+=(const gf x) { return *this = (*this + x); }
    gf &operator*=(const gf x) { return *this = (*this * x); }
};

typedef gf Number;
typedef vector<Number> Array;
typedef vector<Array> Matrix;

Matrix identity(int n) {
    Matrix A(n, Array(n));
    for (int i = 0; i < n; i++) {
        A[i][i] = 1;
    }
    return A;
}

Array mul(const Matrix &A, const Array &x) {
    Array y(A.size());
    for (int i = 0; i < (int)A.size(); i++) {
        for (int j = 0; j < (int)x.size(); j++) {
            y[i] += A[i][j] * x[j];
        }
    }
    return y;
}

Matrix mul(const Matrix &A, const Matrix &B) {
    Matrix C(A.size(), Array(B[0].size()));
    for (int i = 0; i < (int)C.size(); i++) {
        for (int j = 0; j < (int)C[i].size(); j++) {
            for (int k = 0; k < (int)A[i].size(); k++) {
                C[i][j] += A[i][k] * B[k][j];
            }
        }
    }
    return C;
}

Matrix pow(const Matrix &A, ll e) {
    Matrix AA = A;
    Matrix ans = identity(A.size());
    for (; e > 0; e >>= 1) {
        if (e & 1) {
            ans = mul(ans, AA);
        }
        AA = mul(AA, AA);
    }
    return ans;
}

const Number eps = 1e-8;
const int D = 18;
ll c[D + 1];

ll solve() {
    for (ll d = 1, dec = 10; d <= D; d++, dec *= 10) {
        c[d] = min(L, max(dec - A + B - 1, 0LL) / B);
    }

    Array v = {0, (int)(A % (ll)MOD), 1};
    gf dec = 10;
    for (int d = 1; d <= D; d++) {
        Matrix A = {{dec, 1, 0}, {0, 1, (int)(B % (ll)MOD)}, {0, 0, 1}};
        v = mul(pow(A, c[d] - c[d - 1]), v);
        dec *= 10;
    }
    gf ans = v[0];

    return ans.n;
}

int main() {
    cin >> L >> A >> B >> MOD;

    cout << solve() << endl;

    return 0;
}


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

#define gap " "
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ok cout<<"ok"<<endl
#define dbg(x) cout<<(#x)<<" is "<<x<<endl
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}

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

const int N=100009;

int main()
{
  //fastio; 
  int n,i,cnt=0,r;
  cin>>n;
  for(i=1; i<=n; i++)
  {
  	 cin>>r;
  	 if(i%2==1 && r%2==1) cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<int,int> P;

int main(){
    int i,j;
    int h,w,n;
    cin>>h>>w>>n;
    vector<P> v;

    for(i=0;i<n;i++) {
        int x,y;
        cin>>x>>y;
        v.pb(P(x,y));
    }
    sort(v.begin(),v.end());

    int temp=0;
    for(i=0;i<v.size();i++){
        if(v[i].fi>=v[i].se+temp) {
            if(v[i].fi>=v[i].se+temp+1) {
                cout<<v[i].fi-1<<endl;
                return 0;
            }
            else temp++;
        }
    }
    cout<<h<<endl;
    return 0;
}

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

int main()
{
  int m, f, r, sum;
  for (int i = 0; i < 100; i++) {
    cin >> m >> f >> r;
    if (m == -1 && f == -1 && r == -1) break;
    
    if (m == -1 || f == -1) cout << "F" << endl;
    else {
      sum = m + f;
      if (sum >= 80) cout << "A" << endl;
      else if (sum >= 65) cout << "B" << endl;
      else if (sum >= 50) cout << "C" << endl;
      else if (sum >= 30)
        if (r >= 50) cout << "C" << endl;
        else cout << "D" << endl;
      else cout << "F" << endl;
    }
  }
  return 0;
}


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

using ll = long long;
using pii = pair<int, int>; using pll = pair<ll, ll>;

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

template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ s >> p.first >> p.second; return s;}

int main()
{
    char c; cin >> c;
    char ans;
    if ('a' <= c && c <= 'z') {
        ans = 'a';
    } else {
        ans = 'A';
    }
    cout << ans << endl;
}


Measured memory_bytes: 3556