akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
int n,k;
long long ans;
int main(){
	scanf("%d%d",&n,&k);
	if (k==0){
		printf("%lld\n",1ll*n*n);
		return 0;
	}
	for (int i=k;i<=n;i++){
		ans+=n-i;
		int t=n/i;
		ans+=(t-1)*(i-k);
		if (n%i>=k) ans+=n%i-k+1;
	}
	printf("%lld\n",ans);
} 

Measured memory_bytes: 3744
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
 
using namespace std;
using std::cout;
using ll =long long;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int ab(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  string s;
  cin>>s;
  bool odd = true;
  bool even =true;
  for(int i=0;i<s.size();i++){
    if(i%2==0 ){
      if(s[i]=='L'){
        even =false;
        break;
      }
    }
    else{
      if(s[i]=='R'){
        odd =false;
        break;
      }
    }
  }
  if(odd && even){
    cout <<"Yes"<<endl;
  }
  else{
    cout <<"No"<<endl;
  }

}

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

int main() {
    ll N; cin >> N;
    vector<ll> H(30);
    for(int i = 0; i < N; i++) cin >> H[i];

    ll num = 1;
    for(int i = 1; i < N; i++){
        bool flag = true;
        for(int j = 0; j < i; j++){
            if(H[j] > H[i]) flag = false;
        }
        if(flag) num++;
    }
    cout << num << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
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;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    string s; cin >> s;
    int n=s.size();
    if(s[0]==s[n-1]){
        if(n%2==1) cout << "Second" << endl;
        else cout << "First" << endl;
    }else{
        if(n%2==1) cout << "First" << endl;
        else cout << "Second" << endl;
    }
}


Measured memory_bytes: 512
from functools import reduce
from operator import and_
from collections import Counter
n = int(input())
S = [input() for _ in range(n)]
C = [Counter(s) for s in S]
s = sorted(reduce(and_, map(set, S), set(S[0])))
ans = "".join(si * min(c[si] for c in C) for si in s)
print(ans)


Measured memory_bytes: 3684
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

n,m = readInts()
x = readInts()
x.sort()

if m==1:
  print(0)
  exit()

intval = []
for i in range(len(x)-1):
  intval.append(x[i+1]-x[i])
intval.sort(reverse=True)

ans = x[-1]-x[0]
for i in range(min(n-1,len(intval))):
  ans-=intval[i]

print(ans)

Measured memory_bytes: 20468
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <list>
#include <set>
using namespace  std;

constexpr int INF = std::numeric_limits<int>::max();

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    map<char, char> table;
    table['A'] = 'T';
    table['T'] = 'A';
    table['G'] = 'C';
    table['C'] = 'G';

    char c;
    cin >> c;
    cout << table[c] << endl;
}

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

bool dp[MAX];

bool playgame(int currentplayer,int n,int k,int steps[])
{
   
   for(int i=steps[0];i<=k;i++)
    
    {
        for(int j=0;j<n;j++)
        {
            if(i-steps[j]<0)
            {
                break;
            }
            
            if( dp[i-steps[j]]==false)
            {
                dp[i]=true;
                break;
            }
        }
    
    }
   

  
   return dp[k]; 
}


void findit(int n,int k,int steps[])
{
    //1 denotes Taro
    //2 denotes Jiro
    
    //map<pair<int,int>,int> v;
    
    for(int i=0;i<=MAX;i++)
    {
        
         dp[i]=false;   
        
    }
    
    int answer=playgame(0,n,k,steps);
    
    if(answer)
    {
        cout<<"First";
    }
    
    else cout<<"Second";
    
  
}


int main()
{

    int n;
    cin>>n;
    
    int k;
    cin>>k;
    
    int steps[n];
    
    for(int i=0;i<n;i++)
    {
        cin>>steps[i];
    }
    
    findit(n,k,steps);

	return 0;
}


Measured memory_bytes: 384
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
  //　入力
  // s
  // q
  // query=(1, 2) if query == 2 top_or_bottom str

  std::string first;
  ll q;
  int query, top_or_bottom;
  std::string s, ans, temp;
  bool is_reverse = false;
  std::vector<std::string> top, bottom;

  std::cin >> first;
  std::cin >> q;

  REP(i,q) {
    std::cin >> query;
    if (query == 1) is_reverse = (is_reverse)?false:true;
    else {
      std::cin >> top_or_bottom >> s;
      if (top_or_bottom == 1) {
        if (!is_reverse) top.PB(s);
        else bottom.PB(s);
      } else {
        if (!is_reverse) bottom.PB(s);
        else top.PB(s);
      }
    }
  }
  REPD(i,top.size()) temp += top[i];
  temp += first;
  REP(i,bottom.size()) temp += bottom[i];

  if (is_reverse) REPD(i, (int)(temp.length())) ans += temp[i];
  else REP(i,(int)(temp.length())) ans += temp[i];
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 12784
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

const int C = 1010;
const int N = 1001;
const int UFSIZE = C;
int P[UFSIZE]; // 親

void init() {
  for (auto i=0; i<UFSIZE; i++) {
    P[i] = i;
  }
}

int root(int a) {
  if (a == P[a]) return a;
  return (P[a] = root(P[a]));
}

bool issame(int a, int b) {
  return root(a) == root(b);
}

void unite(int a, int b) {
  P[root(a)] = root(b);
}

bool isroot(int a) {
  return root(a) == a;
}

int main() {
  int V, d;
  int Fib[C];
  Fib[0] = 1;
  Fib[1] = 2;
  for (auto i=2; i<C; i++) {
    Fib[i] = (Fib[i-1] + Fib[i-2])%N;
  }
  while (cin >> V >> d) {
    init();
    for (auto i=1; i<=V; i++) {
      for (auto j=i+1; j<=V; j++) {
	if (abs(Fib[i]-Fib[j]) < d) {
	  unite(i, j);
	}
      }
    }
    int ans = 0;
    for (auto i=1; i<=V; i++) {
      if (isroot(i)) ans++;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
 
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555;
const double PI = acos(-1.0);

void solve()
{
	int a;
	cin >> a;
	cout << 3 * a * a;
}	
int main()
{
	Red;
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int queue[1000020][3];
char instr[1000][1001];
int checked[1000][1000];
int st = 0;
int en = 0;
int df[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

void append(int i, int j, int k) {
	queue[en][0] = i;
	queue[en][1] = j;
	queue[en][2] = k;
	checked[i][j] = 1;
	en++;
	return;
}

int main() {
	int H,W,res = 0;
	scanf("%d %d\n",&H,&W);
	for (int i=0;i<H;i++) gets(instr[i]);
	for (int i=0;i<H;i++) for (int j=0;j < W;j++) checked[i][j]=0;
	for (int i=0;i<H;i++) for (int j=0;j < W;j++) {
		if (instr[i][j] == '#') {
			checked[i][j]=1;
			queue[en][0]=i;
			queue[en][1]=j;
			queue[en][2]=0;
			en++;
		}
	}

	while (st < en) {
		int i = queue[st][0];
		int j = queue[st][1];
		int k = queue[st][2];
		st++;
		for (int l = 0; l < 4; l++) {
			if (i+df[l][0]<H && i+df[l][0]>=0 && j+df[l][1]<W && j+df[l][1] >= 0 && !checked[i+df[l][0]][j+df[l][1]]) {
				append(i+df[l][0], j+df[l][1], k+1);
				res = k+1;
			}
		}
	}
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 16768
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<algorithm>

#define INT unsigned long long int
#define FOR1(n) for(int i=0;i<n;i++)
#define FOR2(j, n) for(int j=0;j<n;j++)
#define FOR3(i, m, n) for(int i=m;i<=n;i++)
#define PINT(d) printf("%d\n", d);
#define PDOUBLE(lf) printf("%lf\n", lf);
#define PSTR(s) printf("%s\n", s);
#define ALL(c) c.begin(), c.end()
#define MOD 1000000007
#define MAX_N 100000

using namespace std;

main(){
	int n;
	scanf("%d", &n);
	int a[n+1];
	FOR1(n){
		scanf("%d", &a[i+1]);
	}
	int ans = 0;
	FOR1(n){
		int tmp = a[i+1];
		if(a[tmp] == i+1){
			ans++;
		}
	}
	printf("%d\n", ans/2);
}

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

using namespace std;

int main() {
	while (1) {
		string card;
		int h[100] = { 0 };
		int m;
		
		cin >> card;

		if (card == "-")
			break;

		cin >> m;

		for (int i = 0; i < m; i++)
		{
			cin >> h[i];
			string word(card, 0, h[i]);
			card += word;
			card.erase(0, h[i]);
		}

		cout << card << endl;
	}
}

Measured memory_bytes: 3184
import java.io.IOException;
import java.util.NoSuchElementException;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

import java.util.Arrays;
import java.util.Comparator;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            FastScanner fs = new FastScanner();

            final int N = fs.nextInt();

            Integer[] a = new Integer[N];

            for (int i = 0; i < N; i++) a[i] = fs.nextInt();

            Arrays.sort(a, Comparator.reverseOrder());

            int al = 0;
            int bb = 0;
            for (int i = 0; i < N; i++) {
                if (i % 2 == 0) al += a[i];
                else bb += a[i];
            }

            System.out.println(al - bb);
        }
    }
}

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: 21332
unittest
{
	assert( [ "11" ].parse.expand.solve == 9 );
	assert( [ "136" ].parse.expand.solve == 46 );
	assert( [ "100000" ].parse.expand.solve == 90909 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	return tuple( n );
}

auto solve( long n )
{
	auto ans = 0L;
	foreach( i; 1L .. n + 1 )
	{
		ans += ( i.to!string.length % 2 );
	}
	return ans;
}


Measured memory_bytes: 1276
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String S = in.next();

            //S の先頭の文字は大文字の A である。
            if (S.charAt(0) != 'A') {
                out.println("WA");
                return;
            }

            //S の先頭から3文字目と末尾から2文字目の間（両端含む）に大文字の C がちょうど1個含まれる。
            int cnt = 0;
            for (int i = 2; i < S.length() - 1; i++) {
                if (S.charAt(i) == 'C') cnt++;
            }
            if (cnt == 0 || cnt > 1) {
                out.println("WA");
                return;
            }

            //以上の A, C を除くSのすべての文字は小文字である。
            for (int i = 0; i < S.length(); i++) {
                if (('A' <= S.charAt(i) && S.charAt(i) <= 'Z') && (S.charAt(i) != 'A' && S.charAt(i) != 'C')) {
                    out.println("WA");
                    return;
                }
            }


            out.println("AC");

        }

    }
}



Measured memory_bytes: 21844
/* ex4_1
   takafumi_ueki */
#include <stdio.h>
#include <math.h>
int main(void){
    double tree_num,watch_num,tree_range;
    int count;
    //tree_num(木の本数)とwatch_num(監視員の数)を受け取る
    scanf("%lf %lf",&tree_num,&watch_num);
    //監視員が見れる木の本数を定義する
    tree_range = 2*watch_num + 1;
    //「全ての木の本数」を「監視員が見れる木の本数」で割り、割り切れない場合は一人追加する
    count = ceil(tree_num/tree_range);
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 128
N = int(input())
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))
C_list = list(map(int, input().split()))

out = 0
out += sum(B_list)
a_prev = 0

for index, a in enumerate(A_list):
    if a_prev == 0:
        a_prev = 0
    elif a - a_prev == 1:
        out += C_list[a-2]
    a_prev = a
    
print(out)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
const long long MOD = 1e9 + 7, INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}



signed main(){
	int N;
	cin>>N;
	int ans[505][505];
	REP(i,N){
		REP(j,N){
			REP(k,15){
				if((i&1<<k)^(j&1<<k)){
					ans[i][j]=ans[j][i]=k+1;
					break;
				}
			}
		}
	}
	REP(i,N-1){
		FOR(j,i+1,N){
			if(j!=i+1)cout<<" ";
			cout<<ans[i][j];
		}
		cout<<endl;
	}
}


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

int main() {
  int N, L; cin >> N >> L;
  vector<string> S(N);
  rep(i,N) cin >> S[i];
  sort(S.begin(), S.end());
  rep(i,N) cout << S[i];
  cout << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void LCS(char *x, char *y){
	int m = strlen(x+1);
	int n = strlen(y+1);
	int i, j, **c;
	
	c = malloc(sizeof(int)*(2000));
	for (i = 0; i <= m; i++)
		c[i] = malloc(sizeof(int)*(2000));
	
	for (i = 0; i <= m; i++){
		for (j = 0; j <= n; j++){
			c[i][j] = 0;
		}
	}
	
	for (i = 1; i <= m; i++){
		for (j = 1; j <= n; j++){
			if (x[i] == y[j])
				c[i][j] = c[i - 1][j - 1] + 1;
			else if (c[i - 1][j] >= c[i][j - 1])
				c[i][j] = c[i - 1][j];
			else
				c[i][j] = c[i][j - 1];
		}
	}
	
	printf("%d\n", c[i-1][j-1]);
	for (i = 0; i < m; i++)free(c[i]);
	free(c);
	
}

int main(){
	int i, n;
	char x[1001], y[1001];

	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%s%s", x + 1, y + 1);
		LCS(x, y);
	}
	return 0;
}

Measured memory_bytes: 8600
N, M = [int(nm) for nm in input().split()]
PY = []
for m in range(M):
  PY.append([int(py) for py in input().split()] + [m])

PY.sort(key=lambda x: (x[0], x[1]))
p_ID = PY[0][0]
y_ID = 0
ID = []
for m in range(M):
  p, y, i = PY[m]
  if p == p_ID:
    y_ID += 1
  else: #p != p_ID:
    p_ID = p
    y_ID = 1
  iidd = "0"*(6-len(str(p_ID))) + str(p_ID) + "0"*(6-len(str(y_ID))) + str(y_ID)
  ID.append([iidd, i])

ID.sort(key=lambda x: x[1])
for m in range(M):
  print(ID[m][0])

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

const int Nmax=200010;

int main() {
	int N;
	cin >> N;
	int a=10;
	if(N >= 2 && N<= 9) {cout << N << endl;return 0;}
	while(N/a != 0){
		a*=10;
	}
	a/=100;
	int b=N%a;
if(b == 0) b=a;
	int c=N-b;
	int sum=0,dig=0;
	while(b){
		dig=b%10;
		sum = sum+dig;
		b/=10;
	}
	while(c){
		dig=(c)%10;
		sum += dig;
		c/=10;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
s=input()

slist=list(s)
i=0
l=0

for sin in slist:
    if i%2==0:
        if sin=='L':
            print('No')
            l=1
            break
    else:
        if sin=='R':
            print('No')
            l=1
            break
    i+=1    

if l==0:
    print('Yes')

Measured memory_bytes: 3060
cache = {}
M = 10**9+7
def f(i):
    if i == 0: return 0
    if i == 1: return 1
    if i in cache: return cache[i]
    k = i//2
    if i % 2 == 0: cache[i] = 2*f(k)%M + f(k-1)%M
    else: cache[i] = 2*f(k)%M + f(k+1)%M
    cache[i] %= M
    return cache[i]
print(f(int(input())+1))


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> even(100001, 0), odd(100001, 0);
    for (int i = 1; i <= n; i++)
    {
        int v;
        cin >> v;
        if (i % 2 == 1)
        {
            odd[v]++;
        }
        else
        {
            even[v]++;
        }
    }
    vector<pair<int, int>> es, os;
    for (int i = 0; i <= 100000; i++)
    {
        es.emplace_back(even[i], i);
        os.emplace_back(odd[i], i);
    }
    sort(es.begin(), es.end(), greater<pair<int, int>>());
    sort(os.begin(), os.end(), greater<pair<int, int>>());

    if (es[0].second != os[0].second)
    {
        cout << (n - es[0].first - os[0].first) << endl;
    }
    else
    {
        int cand1 = (n - es[0].first - os[1].first);
        int cand2 = (n - es[1].first - os[0].first);
        cout << min(cand1, cand2) << endl;
    }
}

Measured memory_bytes: 2804
#include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    using namespace std;
    char a[110];
    bool num[27];bool now[27];
    int n;int ans;int qwq;
    int main()
    {
    	scanf("%d",&n);
    	for(int i=0;i<=n;i++) scanf("%c",&a[i]);
    	for(int i=1;i<=n;i++)
    	{
    		for(int j=1;j<=i;j++)
    		  num[a[j]-'a']=true;
    		for(int j=i+1;j<=n;j++)
    		  if(num[a[j]-'a']==true&&!now[a[j]-'a']) qwq++,now[a[j]-'a']=true;
    		ans=max(ans,qwq);
    		qwq=0;
    		memset(num,0,sizeof(num));
    		memset(now,0,sizeof(now));
    	}
    	printf("%d",ans);
    	return 0;
    }

Measured memory_bytes: 256
L, R = map(int, input().split())
m = 2020
import sys
for i in range(L, R+1):
    for j in range(i+1, R+1):
        if m > (i * j) % 2019:
            m = (i * j) % 2019
        if m == 0:
            print(0)
            sys.exit()
print(m)

Measured memory_bytes: 2940
#include <iostream>

int main()
{
    int a, b, mul;
    scanf("%d %d", &a, &b);
    mul = a * b;
    if (mul % 2 == 0) {
        std::cout<<"Even"<<std::endl;
    } else {
        std::cout<<"Odd"<<std::endl;
    }
}



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

/*
H * W <= 1e6なのでbfsすれば良い？
Kが10^6なので分岐が多すぎる
O(4 * 1e6)
*/

int	main(void)
{
	int h, w, k;
	cin >> h >> w >> k;
	int from_x, from_y, to_x, to_y;
	cin >> from_x >> from_y >> to_x >> to_y;
	from_x--; from_y--; to_x--; to_y--;
	vector<vector<bool>> grid(h, vector<bool>(w));
	vector<vector<int>> dfs(h, vector<int>(w, 1e9));
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			char c;
			cin >> c;
			grid[i][j] = (c == '.');
		}
	}
	queue<pair<int, int>> q;
	vector<vector<bool>> visited(h, vector<bool>(w, false));
	q.push({from_x, from_y});
	dfs[from_x][from_y] = 0;
	visited[from_x][from_y] = true;
	int depth = 0;
	int x, y;
	vector<int> dx = {1, -1, 0, 0};
	vector<int> dy = {0, 0, 1, -1};
	while (q.size())
	{
		depth++;
		int size = q.size();
		for (int i = 0; i < size; i++)
		{
			x = q.front().first;
			y = q.front().second;
			q.pop();
			if (x == to_x && y == to_y)
			{
				cout << depth - 1 << endl;
				return (0);
			}
			for (int j = 0; j < 4; j++)
			{
				for (int z = 1; z <= k; z++)
				{
					if (x + dx[j] * z < 0 || x + dx[j] * z >= h) break ;
					if (y + dy[j] * z < 0 || y + dy[j] * z >= w) break ;
					if (!grid[x + dx[j] * z][y + dy[j] * z]) break ;
					if (dfs[x + dx[j] * z][y + dy[j] * z] < depth) break ;
					if (visited[x + dx[j] * z][y + dy[j] * z]) continue ;
					if (dfs[x + dx[j] * z][y + dy[j] * z] == depth) continue ;
					dfs[x + dx[j] * z][y + dy[j] * z] = depth;
					visited[x + dx[j] * z][y + dy[j] * z] = true;
					q.push({x + dx[j] * z, y + dy[j] * z});
				}
			}
		}
	}
	cout << -1 << endl;
	return (0);
}


Measured memory_bytes: 11328
#include <bits/stdc++.h>
using namespace std;
int main(void){
    vector <int> a(3);
    for(int i = 0; i < 3; i++)
        cin >> a.at(i);
    sort(a.begin(), a.end());
    for(int i = 0; i < 3; i++){
        cout << a.at(i);
        if (i == 2){
            cout << endl;
            break;
        }
        cout << " ";
    }
}



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

int main()
{

	int n;
	cin>>n;
	vector<int> inp;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		inp.push_back(x);
	}
	sort(inp.begin(),inp.end(),greater<int>());
	inp[0]/=2;
	long long int ans=0;
	for(int i=0;i<n;i++)
	{
		ans+=inp[i];
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


int main(int argc, char* argv[])
{
    int n,K;
    scanf("%d%d", &n, &K);

    ll ans=0;
    int b;
    for(b=K+1; b<=n; b++) {
        ll ans0=0;
        int p=n/b;
        int q=n%b;
        if(K<=q) {
            ans0=(ll)p*(b-q-1)+(ll)(p+1)*(q-K+1);
            if(K==0) ans0--;
        }
        else {
            ans0=(ll)p*(b-K);
        }
        ans+=ans0;
    }
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

namespace
{
void OutputRow(int Length, std::vector<int>::const_iterator Begin, std::vector<int>::const_iterator End)
{
	std::vector<int>::const_iterator It = Begin;
	for(int i = 1; i < Length; ++i){
		if(It == End || i < *It){
			std::cout << 0;
		}else{
			std::cout << 1;
			++It;
		}
		
		if(i < Length - 1){
			std::cout << " ";
		}else{
			std::cout << std::endl;
		}
	}
}
}//unnamed namespace
//================================================================

class TGraph
{
	std::vector<std::vector<int> > FNodes;
public:
	TGraph(int Count);
	
	void InputNodes(int Index, int BranchCount);
	void OutputAdjacencyMatrix()const;
};

TGraph::TGraph(int Count)
:FNodes(Count + 1)
{
}

void TGraph::InputNodes(int Index, int BranchCount)
{
	for(int i = 0; i < BranchCount; ++i){
		int Target;
		std::cin >> Target;
		FNodes[Index].push_back(Target);
	}
}

void TGraph::OutputAdjacencyMatrix()const
{
	for(unsigned int i = 1; i < FNodes.size(); ++i){
		OutputRow(FNodes.size(), FNodes[i].begin(), FNodes[i].end());
	}
}
//================================================================

int main()
{
	int Count;
	std::cin >> Count;
	TGraph Graph(Count);
	for(int i = 0; i < Count; ++i){
		int Index;
		std::cin >> Index;
		int BranchCount;
		std::cin >> BranchCount;
		Graph.InputNodes(Index, BranchCount);
	}
	Graph.OutputAdjacencyMatrix();
	return 0;
}

Measured memory_bytes: 3160
import sys
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
n, = [int(num) for num in lines.pop(0).split(" ")]
t, a = [int(num) for num in lines.pop(0).split(" ")]
h_list = [int(num) for num in lines.pop(0).split(" ")]
ans = 1
prev_dif = sys.maxsize
for index, h in enumerate(h_list, 1):
    dif = abs((t - h * 0.006) - a)
    if dif < prev_dif:
        prev_dif = dif
        ans = index
print(ans)


Measured memory_bytes: 9180
fun main(args: Array<String>) {
    abc063c()
}

fun abc063c() {
    val n = readLine()!!.toInt()
    val scores = (1..n).map { readLine()!!.toInt() }

    val sum = scores.sum()

    // 総計が10の倍数の場合、10の倍数でないもののうち一番小さいものを除く（全部10の倍数の場合は答えは0）
    val answer = if (sum % 10 != 0) {
        sum
    } else {
        val min = scores.filter { it % 10 != 0 }.min()
        if (min == null) {
            0
        } else {
            sum - min
        }
    }

    println(answer)
}


Measured memory_bytes: 31872
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int num = sc.nextInt();
			int[] takoyaki = new int[num];
			long aji = 0;
			for (int i = 0; i < num; i++) {
				int temp = sc.nextInt();
				takoyaki[i] = temp;
				aji += temp;
			}
			long sum = 0;
			for (int i = 0; i < num; i++) {
				long other = aji - takoyaki[i];
				sum += other * takoyaki[i];
				aji -= takoyaki[i];
			}
			System.out.print(sum);
		}
	}
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <math.h>

int isprime(int);

main(){

  int n,res=0;
  int i;
  int A[10000];
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<n;i++){
    if(isprime(A[i])==0) res++;
  }


  printf("%d\n",res);

  return 0;
}



int isprime(int x)
{
  int i;

  if(x==2) return 0;

  if(x<2 || x%2==0) return 1;


  i=3;
  while(i<=sqrt(x)){
    if(x%i==0) return 1;
    i+=2;
  }
  return 0;
 }

Measured memory_bytes: 628
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
#include<tuple>
using namespace std;
#define INF 11000000000
#define MAX 5100
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
const double PI = acos(-1);

int main(){
    int N;
    cin>>N;
    string ans;
    vector<int> A;
    if(N==3) ans="2 5 63";
    else if(N==4) ans="2 5 20 63";
    else if(N==5) ans="2 5 20 30 63";
    if(N<=5){
        cout<<ans<<endl;
        return 0;
    }
    ll sum=0;
    for(int i=0;i<N;i++){
        int x;
        if(i%4==0) x=i/4*6+2;
        else if(i%4==1) x=i/4*6+3;
        else if(i%4==2) x=i/4*6+4;
        else if(i%4==3) x=i/4*6+6;
        A.push_back(x);
        sum+=x;
    }
    int x;
    if(sum%6==2){
        x=8; A.push_back(30000);
    }else if(sum%6==3){
        x=9; A.push_back(30000);
    }else if(sum%6==5){
        x=9; A.push_back(29998);
    }else{
        x=-1;
    }
    for(int i=0;i<(int)A.size();i++){
        int temp=A[i];
        if(temp==x) continue;

        cout<<temp<<endl;;
    }

}



Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cmath>
#include <set>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cstring>

using namespace std;

constexpr long long mod = 1000000007;
constexpr double eps = 0.0000000001;

typedef long long ll;
typedef long long unsigned ull;

int main() {
    int n,a;
    cin >> n;
    bool f = true;
    for(int i = 0;i<n;i++) {
        cin >> a;
        if(a%2)continue;
        if(!(a%3) || !(a%5)) continue;
        f = false;
    }
    cout << (f ? "APPROVED" : "DENIED") << endl;
}

Measured memory_bytes: 256
package main
 
import (
	"fmt"
)
 
func main() {
	var x, y, z int
	fmt.Scanf("%d %d %d", &x, &y, &z)

 	if x*y*z == 5*7*5 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

Measured memory_bytes: 512
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

char L[55][55];
int d[55][55];
int H,W;
bool inside(int i,int j){
	return (1<=i && i<=H && 1<=j && j<=W);
}

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

int main(){
	  int i,j;

	  cin >> H >> W;
	  int B=0;
	  for(i=1;i<=H;i++){
		  for(j=1;j<=W;j++){
			  cin >> L[i][j];
			  if(L[i][j]=='#') B++;
			  d[i][j]=1e9;
		  }
	  }

	  queue<P> q;
	  q.push(P(1,1));
	  d[1][1]=0;

	  while(!q.empty()){
		  P p=q.front();
		  q.pop();
		  int a=p.first,b=p.second;
		  REP(i,4){
			  int x=a+dx[i],y=b+dy[i];
			  if(inside(x,y) && L[x][y]=='.'){
				  if(d[a][b]+1<d[x][y]){
					  d[x][y]=d[a][b]+1;
					  q.push(P(x,y));
				  }
			  }
		  }

	  }

	  if(d[H][W]==1e9) cout << -1 << endl;
	  else cout << H*W-1-B-d[H][W] << endl;

	  return 0;
}


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

char s[1000005];
int dp[1000005][2];

int main(){
    int n;
    scanf("%s",s+1);
    n=strlen(s+1);
    dp[n][0]=s[n]-'0';
    dp[n][1]=10-(s[n]-'0');

    for(int i=n-1;i>=1;i--){
        dp[i][0]=min(dp[i+1][0],dp[i+1][1]+1)+s[i]-'0';
        dp[i][1]=min(dp[i+1][0],dp[i+1][1]-1)+10-(s[i]-'0');
        //cout<<dp[i][0]<<" "<<dp[i][1]<<endl;
    }
    printf("%d\n",min(dp[1][0],dp[1][1]+1));
}


Measured memory_bytes: 9088
import numpy as np

a, b, c  = input().split()
a = int(a)
b = int(b)
c = int(c)

left = 4 * a * b
right = (c - (a + b)) ** 2

judge = c - (a + b)

if(judge < 0):
  print("No")
else:
  if(left < right):
  	print("Yes")
  else:
  	print("No")

Measured memory_bytes: 12508
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fori(i,a,b) for(int i=a;i<=b;i++)

unordered_map<ll,ll> mp;

int main()
{
    string s,t;
    cin>>s>>t;
    int cnt=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]==t[i])
        {
            cnt++;
        }
    }
    cout<<cnt; 
    return 0;
}

Measured memory_bytes: 256
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func main() {
	io := NewIo()
	defer io.Flush()
	a := io.NextInt()
	b := io.NextInt()
	c := io.NextInt()
	max := b/a
	if max < c {
		io.PrintLn(max)
	} else {
		io.PrintLn(c)
	}
}

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

XYs = []

for i in range(N):
    x,y = map(int,input().split())
    tmp = (x,y)
    XYs.append(tmp)


if N == 1:
    print(1)
    exit()

distances = {}

for index_fr in range(N):
    for index_to in range(N):
        if index_fr == index_to:
            continue
        fr = XYs[index_fr]
        to = XYs[index_to]
        key = str(fr[0] - to[0]) + str(fr[1] - to[1])
        if key in distances.keys():
            distances[key] += 1
        else:
            distances[key] = 1


print(N - max(distances.values()))


Measured memory_bytes: 3316
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

VL prime;
void generate_prime(ll max_p) {
    prime.push_back(2); 
    for(ll i = 3; i <= (ll)1e6; i++) {
        for(auto p : prime) {
            if(i % p == 0) break;
            if(p > sqrt(i)) {
                prime.push_back(i);
                break;
            }
        }
    }

    for(auto p : prime) {
        if(max_p % p == 0) break;
        if(p == prime.back()) prime.push_back(max_p);
    }
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, p;
    cin >> n >> p;
    if(n == 1) {
        cout << p << endl;
        return 0;
    }
    generate_prime(p);
    VL prime_cnt(prime.size(), 0);
    int p_index = 0;
    while(p > 1) {
        if(p_index >= prime.size()) break;
        if(p % prime[p_index] == 0) {
            prime_cnt[p_index]++;
            p /= prime[p_index];
        } else {
            p_index++;
        }
    }
    
    ll ans = 1;
    REP(p_index, prime_cnt.size()) {
        REP(i, prime_cnt[p_index] / n) ans *= prime[p_index];
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int Q = 998244353;
const int N = 209;
ll x[N], y[N], p[N], f[N], size[N];
inline int read() {
    int s = 1, a = 0; char ch = getchar();
    while (ch < '0' || ch > '9') {if (ch == '-') s = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9') {a = a * 10 + ch - '0'; ch = getchar();}
    return s * a;
}
inline int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}
inline int findSet(int x) {
    return f[x] == x ? x : f[x] = findSet(f[x]);
}
inline void unionSet(int x, int y) {
    int fx = findSet(x), fy = findSet(y);
    if (fx != fy) {
        f[fy] = fx;
        size[fx] += size[fy];
    }
}
struct Seg {
    int p, q; ll hash;
    bool operator < (const Seg &rhs) const {
        return hash < rhs.hash;
    }
};
vector<Seg> seg;
int main() {
    p[0] = 1;
    for (int i = 1; i < N; i++) {
        p[i] = p[i - 1] << 1, p[i] %= Q;
    }
    int n = read();
    for (int i = 1; i <= n; i++) {
        x[i] = read(), y[i] = read();
    }
    ll res = (p[n] - n - 1) % Q;
    for (int i = 1; i < n; i++) {
        for (int j = i + 1; j <= n; j++) {
            int dx = x[i] - x[j], dy = y[i] - y[j], g = gcd(dx, dy);
            dx /= g, dy /= g;
            if (dx == 0) dy = 1;
            if (dy == 0) dx = 1;
            if (dx < 0) dx *= -1, dy *= -1;
            Seg s; s.p = i, s.q = j, s.hash = dx * 50000 + dy;
            seg.push_back(s);
        }
    }
    sort(seg.begin(), seg.end());
    for (int i = 0, j = 0; i < seg.size(); i = j) {
        for (int k = 1; k <= n; k++) {
            f[k] = k, size[k] = 1;
        }
        for (; j < seg.size() && seg[i].hash == seg[j].hash; j++) {
            unionSet(seg[j].p, seg[j].q);
        }
        for (int k = 1; k <= n; k++) {
            if (f[k] == k && size[k] >= 2) {
                res -= (p[ size[k] ] - size[k] - 1), res += Q, res %= Q;
            }
        }
    }
    res += Q, res %= Q;
    printf("%lld\n", res);
    return 0;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    if(b-a==c-b) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


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

typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    int i;
    for(i = 0;i <n ;++i){
        cin >> p.at(i);
    }
    int min_n = p.at(0);
    int ans = 1;
    for(i = 1;i < n;++i){
        if(p.at(i) <= min_n){
            ++ans;
            min_n = p.at(i);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
S = input()
if (1 <= int(S[0:2]) <= 12):
  f = "M"
else:
  f = "Y"
if (1 <= int(S[2:4]) <= 12):
  b = "M"
else:
  b = "Y"
if(f=="Y")and(b=="M"):
  print("YYMM")
elif(f=="M")and(b=="Y"):
  print("MMYY")
elif(f=="M")and(b=="M"):
  print("AMBIGUOUS")
else:
  print("NA")

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <set>
#include <algorithm>
#include<cmath>

#define rep(i, a, b) for (int i=a; i <b; i++)
#define F first
#define S second

using namespace std;

typedef long long ll;
typedef vector< int > vi;


int main() {
    ll n, k;
    cin >> n >> k;
    ll b = n/k;
    ll ans1 = b * b * b;
    ll ans2 = 0;


    if ( k % 2 == 0 && n >= k/2) {
        ll c = (n - k/2) / k;
        c++;
        ans2 = c * c*c;
    }


    cout << ans1 + ans2 << endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	var c int
	if n < 10 {
		c = n
	} else if n < 100 {
		c = 9
	} else if n < 1000 {
		c = 9 + n - 99
	} else if n < 10000 {
		c = 909
	} else if n < 100000 {
		c = 909 + n - 9999
	} else {
		c = 90909
	}
	fmt.Println(c)
}


Measured memory_bytes: 640
program main
  implicit none

  integer :: n, i, j, s
  integer, allocatable :: a(:), b(:)

  read *, n
  allocate(a(2:n), b(n))
  read *, a
  b = 0

  do i = 2, n
     b(a(i)) = b(a(i)) + 1
  end do

  do i = 1, n
     print *, b(i)
  end do
  
  stop
end program main


Measured memory_bytes: 5084
#include <stdio.h>

int main()
{
  int x, y, temp;

  while (1) {
    scanf("%d", &x);
    scanf("%d", &y);
    if (x == 0 && y == 0) {
      break;
    }
    if (x > y) {
      temp = x;
      x = y;
      y = temp;
    }
    printf("%d %d\n", x, y); 
  }

  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  int pasta = min(a, b);
  pasta = min(pasta, c);
  int drink = min(d, e);
  cout << pasta + drink - 50 << endl;
  return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
    
    int N, R;
    cin >> N >> R;

    int ans;
    if (10 <= N) {
        ans = R;
    } else {
        ans = R + 100 * (10 - N);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import deque

S = list(input())
Q = int(input())
s = deque(S)
h = 1


for i in range(Q):
    q = list(map(str, input().split()))
    if q[0] == "1":
        h *= -1
        continue
    if q[1] == "1":
        if h == 1:
            s.appendleft(q[2])
        else:
            s.append(q[2])
    else:
        if h == 1:
            s.append(q[2])
        else:
            s.appendleft(q[2])

print("".join(map(str,list(s)[::h])))

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

//?????¶?????????????????????????????????????????????????????????????????§?????????
//????????¨??¨????????????????????¶?????????????????????????????°??????
//?¨??????????????????§???????????§??????
int count(int n, int x){
  int cnt = 0;
  for(int i = 1; i <= n-2; i++){
    for(int j = i+1; j <= n-1; j++ ){
      for(int k = j+1; k <= n; k++){
	if( i+j+k == x ) cnt++;
      }
    }
  }

  return cnt;
}


int main(){
  int n, x;

  while(1){
    cin >> n >> x;
    if(n == 0 && x == 0) break;
    cout << count(n, x) << endl;
  }
  
  return 0;
}

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


vector<pair<long long,long long> > vec;


ll solve(ll x){
	ll dig = x%4;
	if(dig==0ll) return x;
	if(dig==1ll) return 1ll;
	if(dig==2ll) return x+1;
	if(dig==3ll) return 0ll; 
}

int main (){	
	ll l,r;cin>>l>>r;
	l--;
	ll c = solve(r),cc = solve(l);
	cout<<(c^cc)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  //
  string s;
  cin >> s;
  int n = s.size();
  ll cnt = 0;
  rep(i, n / 2) {
    if (s[i] == s[n - 1 - i]) continue;
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ff first
#define ss second
#define eps 1e-9

using namespace std;


int main()
{

    ll t,n,m,f,l,r,q,k,x,y,z,ans,mn,mx,sum=0;

    cin>>n;

    vector< ll > a(n+1),b(n+1),c(n);

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

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

    for(int i=1; i<n; i++)
    {
        cin>>c[i];
    }
    l = -10;
    ans=0;
    for(int i=1;i<=n;i++)
    {
        mn = a[i];

        if(mn-1 == l)
        {
            ans+= b[mn] + c[mn-1];
        }
        else
        {
            ans+= b[mn];
        }

        l = a[i];
    }

    cout<<ans<<endl;


}


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

using namespace std;

int main()
{
	long long n;
	cin>>n;
	long long arr[n];
	vector< pair<long long,long long> >v;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		v.push_back(make_pair(arr[i],i+1));
	}
	 sort(v.begin(),v.end());
	 for(int i=0;i<n;i++)
		cout<<v[i].second<<" ";
}


Measured memory_bytes: 3312
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  if(S == "Sunny") cout << "Cloudy" << endl;
   if(S == "Cloudy") cout << "Rainy" << endl; 
    if(S == "Rainy") cout << "Sunny" << endl;
  
}

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

int main(){
  int N;
  cin >> N;
  int A[N], B[N];
  for(int i = 0; i < N; i++)
    cin >> A[i];
  for(int i = 0; i < N; i++)
    B[A[i] - 1] = i + 1;
  for(int i = 0; i < N; i++)
    cout << B[i] << '\n';
}

Measured memory_bytes: 1536