akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 998244353
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define loop(n) for(int i=0; i<n; i++)
void solve()
{
	//int n;
	//cin>>n;
	int s,w;
	cin>>s>>w;
	if(w>=s)cout<<"unsafe\n";
	else cout<<"safe\n";
	return;
}




int32_t main() 
{ 
	fast;
	int t=1;//cin>>t;
	while(t--){solve();}
	return 0; 
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    vector<int> v(5);
    REP(i,5) cin >> v[i];
    REP(i,5) if(v[i] == 0) {
        OUT(i+1)
    }

    return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <string.h>
#include <ctype.h>
 
int main(void){
 
  char w[10];
  char t[1000];
  char e[] = {"END_OF_TEXT"};
  int i, ii, iii;
  int c = 0;
 
  scanf("%s", w);
  ii = strlen(w);
  for(i = 0; i > -1; i++){
    for(i = 0; i < ii; i++){
      w[i] = tolower(w[i]);
    }
    scanf("%s", t);
    if(strcmp(e, t) == 0) break;
    iii = strlen(t);
    for(i = 0; i < iii; i++){
      t[i] = tolower(t[i]);
    }
    if(strcmp(w, t) == 0) c++;
  }
  printf("%d\n",c);
  return 0;
}
 

Measured memory_bytes: 552
from math import gcd, sqrt
from functools import reduce

n, *A = map(int, open(0).read().split())
def f(A):
    sup = max(A)+1
    table = [i for i in range(sup)]
    for i in range(2, int(sqrt(sup))+1):
        if table[i] == i:
            for j in range(i**2, sup, i):
                table[j] = i

    D = set()
    for a in A:
        while a != 1:
            if a not in D:
                D.add(a)
                a //= table[a]
            else:
                return False
    return True

if reduce(gcd, A) == 1:
    if f(A):
        print('pairwise coprime')
    else:
        print('setwise coprime')
else:
    print('not coprime')

Measured memory_bytes: 121912
using System;
using System.Globalization;
using System.IO;
using System.Text;
using static Scanner;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Solve();
        Console.Out.Flush();
    }
    static void Solve() {
        int A = ScanInt(), B = ScanInt();
        var answer = 0;
        for (var soc = 1; soc < B; soc += A - 1) answer++;
        Console.WriteLine(answer);
    }
}

public static class Scanner
{
    static readonly Stream stream = Console.OpenStandardInput();
    static readonly byte[] buffer = new byte[1024];
    static int length, p;
    static bool isEof;
    private static byte ConsoleIn() {
        if (isEof) return 0;
        if (p < length) return buffer[p++];
        p = 0;
        if ((length = stream.Read(buffer, 0, 1024)) > 0) return buffer[p++];
        isEof = true;
        return 0;
    }
    public static char GetChar() {
        var by = ConsoleIn();
        while ((by < '!' || '~' < by) && !isEof) by = ConsoleIn();
        return (char) by;
    }
    public static int ScanInt() {
        var temp = 0;
        for (var ch = GetChar(); '0' <= ch && ch <= '9'; ch = (char) ConsoleIn()) {
            temp = temp * 10 + ch - '0';
        }
        return temp;
    }
}

Measured memory_bytes: 23776
#include<stdio.h>
int main()
{
    int n1,n2,n3;
    scanf("%d%d%d",&n1,&n2,&n3);
    if(n1!=n2 && n1!=n3 &&n2!=n3){
        printf("3\n");
    }
    else if(n1==n2&&n1==n3){
        printf("1\n");
    }
    else{
        printf("2\n");
    }


    return 0;
}


Measured memory_bytes: 128
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

ll f(ll n, ll x)
{
  return n / x + 1;
}

int main()
{
  ll a, b, x;
  scanf("%lld%lld%lld", &a, &b, &x);
  printf("%lld\n", a == 0 ? f(b, x) : f(b, x) - f(a - 1, x));
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cctype>
#include <cfloat>
#include <vector>
using namespace std;

#define si static inline
#define gcu getchar_unlocked
si int in() {
	int c, n = 0;
	bool minus = false;
	if ((c = gcu()) == '-') minus = true; else ungetc(c, stdin);
	while ((c = gcu()) >= '0' && c <= '9') n = 10 * n + (c - '0');
	//return n; }
	return minus ? -n : n; }
si void scan(char *s) {while (!isspace(*s++ = gcu()));}
#define pcu putchar_unlocked
#define svo si void out
template <typename T>
svo(T n) {
	static char buf[20];
	char *p = buf;
	//if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
svo(const char *s){while(*s)pcu(*s++);}
svo(char *s){while(*s)pcu(*s++);}
svo(char c){pcu(c);}
template <typename T>
//svo(vector<T> &v){for(T &x:v)out(' '),out(x);out('\n');}
svo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
template <typename head, typename... tail>
svo(head&& h, tail&&... t){out(h);out(move(t)...);}
#undef svo
#undef si

#define v vector

struct OBST {
	typedef vector<double> vd;
	vd p, q;
	v<vd> e, w;

	void read(int n) {
		p.resize(n + 1);
		q.resize(n + 1);
		for (int i = 1; i <= n; i++)
			scanf("%lf", &p[i]);
		for (int i = 0; i <= n; i++)
			scanf("%lf", &q[i]);
	}

	double cost(int n) {
		e = v<vd>(n + 2, vd(n + 1));
		w = v<vd>(n + 2, vd(n + 1));
		for (int i = 0; i <= n; i++) {
			e[i + 1][i] = q[i];
			w[i + 1][i] = q[i];
		}
		for (int l = 1; l <= n; l++)
			for (int i = 1; i <= n - l + 1; i++) {
				int j = i + l - 1;
				e[i][j] = DBL_MAX;
				w[i][j] = w[i][j - 1] + p[j] + q[j];
				for (int r = i; r <= j; r++)
					e[i][j] = min(e[i][j], e[i][r - 1] + e[r + 1][j] + w[i][j]);
			}
		return e[1][n];
	}
};

int main() {
	int n = in();
	OBST obst;
	obst.read(n);
	printf("%.8lf\n", obst.cost(n));
}



Measured memory_bytes: 6412
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define iter(it,c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end();++it)
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
const int INF = ~(1<<31);
const double pi = acos(-1);

int main() {
	cin.sync_with_stdio(false);
	int a,b;
	cin >> a >> b;
	if(a % 3 == 0 || b % 3 == 0 || (a+b) %3 == 0) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;

int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	int i,j,n;
	string s;
//	char c;
	
//	int a,b,c;
//	cin>>a>>b>>c;
//	if(a+b<c||a+c<b||b+c<a)cout<<"Yes"<<endl;
//	else cout<<"No"<<endl;
	
	int r=0,b=0;
	cin>>n>>s;
	for(i=0;i<s.length();i++){
		if(s[i]=='R')r++;
		else b++;
	}
	if(r>b)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
//////////////////////////////////////////////////////
	return 0;
}


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

int main(){
    long long L, R;
    cin >> L >> R;
    if(R-L >= 2018){
        cout << 0 << endl;
    }

    else if(L % 2019 > R % 2019){
        cout << 0 << endl;
    }

    else{
        int l = L % 2019;
        int r = R % 2019;
        int s = 2018;
        for(int i = l; i < r; i++){
            for (int k = l+1; k <= r; k++){
                int t = (i*k) % 2019;
                if(t < s){
                    s = t;
                }
            }
        }
        cout << s << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int a, b; cin >> a >> b; --a;--b;
    cout << a * b << endl;
}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

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

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

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

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int sum = A+B;
        if(sum%2==0) System.out.println(sum/2);
        else System.out.println("IMPOSSIBLE");
    }
}


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

int main(){
  int N; cin >> N;
  int c = 0;
  int t = N;
  while(t > 0){
    c += t % 10;
    t = t / 10;
  }
  if(N % c == 0){
    cout << "Yes";
  }else{
    cout << "No";
  }
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << -1; return;}
#define yes {cout << "Yes"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

const int INF = 1e12 + 7;

void solve() {
    int n, k;
    cin >> n >> k;
    vector <int> a(n), b(n);
    loop(i, n)
        cin >> a[i];
    loop(i, n)
        cin >> b[i];
    sort(all(a), greater<int>());
    sort(all(b));
    int l = -1, r = INF;
    while (r - l > 1) {
        int m = l + r >> 1;
        int d = 0;
        loop(i, n)
            d += max(0ll, a[i] - m / b[i]);
        if (d > k)
            l = m;
        else
            r = m;
    }
    cout << r;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 6364
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
//#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const long long linf = 4523372036854775807;
const int inf = 1500000000;
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	int from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	int x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
int ari(int a, int b, int c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
int fact(int i) {
	ll sum = 1;
	for (int j = 2; j <= i; j++)
		sum = (sum* j) % Mod;
	return sum;
}//階乗(正）
 //---------------------------------------------------
 //+++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	string s;
	cin >> s;
	string h = "";
	for (int i = 0; i < 12; i++) {
		h += s[i];
		if (i == 3)
			h += " ";
	}
	cout << h << endl;
	getchar(); getchar();
}

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

int main(){
  int a = 0;
  int n = 0;
  
  cin >> n >> a;
  
  if(n % 500 > a){
    cout << "No" << endl;
  }
  else
  {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  cin >> s;
  char c[3] = {'C','F','0'};
  int index = 0;
  for(int i=0;i<s.size();i++){
    if(s[i]==c[index]) index++;
  }
  if(index>=2) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int n,x;
	vector<int> a;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x;
		a.push_back(x);
	}

	ll ans = 0,ans1=0;
	sort(a.begin(), a.end());
	if (n%2 == 0) { 
		for (int i = 0; i < n / 2; i++) { 
			if (i==(n/2)-1) { ans -= a[i]; }
			else { ans -= (a[i] * 2); }
		}
		for (int i = (n / 2) ; i < n; i++) { 
			if (i == (n / 2) ) { ans += a[i]; }
			else { ans += (a[i] * 2); }
		}
	}
	else {
		for (int i = 0; i < (n / 2) + 1; i++) {
			if (i >=(n/2)-1) { ans -= a[i]; }
			else { ans -= (a[i] * 2); }
		}
		for (int i = (n / 2)+1; i < n; i++) {
			  ans += (a[i] * 2); 
		}
	}

	sort(a.begin(),a.end(),greater<int>());
	int cnt = 0;
	if (n % 2 == 0) {
		
	}
	else {
		for (int i = 0; i < (n / 2) + 1; i++) {
			if (i>=(n/2)-1) { ans1 += a[i];}
			else { ans1 += (a[i] * 2); }
		}
		for (int i = (n / 2) + 1; i < n; i++) {
			ans1 -= (a[i] * 2);
		}
	}
	ans = max(ans, ans1);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1020
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
#include<cstring>
#define MAX_N 10000
using namespace std;
typedef pair<int, int> P;
const int INF = 1 << 30;
int dp[2][MAX_N / 2 + 1][2];
int main() {
	int n, ans = INF, t[MAX_N + 1] = {};
	scanf("%d", &n);
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < n / 2 + 1; j++) {
			fill(dp[i][j], dp[i][j] + 2, INF);
		}
	}
	for (int i = 0; i < n - 1; i++) {
		scanf("%d", &t[i]);
	}
	dp[1][1][1] = t[0];
	for (int i = 1; i < n ; i++) {
		for (int j = 0; j < n / 2 + 1; j++) {
			for (int k = 0; k < 2; k++) {
				dp[0][j][k] = dp[1][j][k]; 
				dp[1][j][k] = INF;
			}
		}
		for (int j = 0; j < n / 2; j++) {
			if (j > i) break;
			dp[1][j + 1][0] = min(dp[0][j + 1][1], dp[0][j + 1][0]);
			
			dp[1][j + 1][1] = min(dp[1][j + 1][1], dp[0][j][1] + t[i] - t[i - 1]);
			dp[1][j + 1][1] = min(dp[1][j + 1][1], dp[0][j][0] + t[i] + t[i - 1]);
		}
		ans = min(ans, min(dp[1][n / 2][0], dp[1][n/2][1]));
	}
	printf("%d\n", ans);
}

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

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
	if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
	if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define INF 1000000007
#define LLINF 2696969696969696969ll
#define MAXN 113

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

string s;
ll D;
ll dp[2][2][MAXN];
ll ans;

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> s >> D;
	dp[1][1][0] = 1;
	FOR(i, 0, SZ(s))
	{
		ll x = s[i] - '0';
		FOR(j, 0, D)
		{
			dp[i & 1][0][j] = 0;
			dp[i & 1][1][j] = 0;
		}
		FOR(j, 0, D)
		{
			FOR(k, 0, 10)
			{
				dp[i & 1][0][(j + k) % D] += dp[i & 1 ^ 1][0][j]; dp[i & 1][0][(j + k) % D] %= INF;
			}
			FOR(k, 0, x + 1)
			{
				dp[i & 1][(k == x)][(j + k) % D] += dp[i & 1 ^ 1][1][j]; dp[i & 1][(k == x)][(j + k) % D] %= INF;
			}
		}
	}
	ans = INF - 1;
	FOR(j, 0, 2)
	{
		ans += dp[SZ(s) & 1 ^ 1][j][0];
		ans %= INF;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
from collections import Counter as cnt
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
S = sum(A)
D = cnt(A)

for i in range(Q):
    B, C = map(int, input().split())
    S = S+(C-B)*D[B]
    print(S)
    D[C] += D[B]
    D[B] = 0

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i) continue;
    ret.push_back(i);
    if (i * i != n) ret.push_back(n / i);
  }

  sort(begin(ret), end(ret));
  return ret;
}

int main(int argc, char* argv[]) {
  ll n, m;
  cin >> n >> m;

  auto v = divisor(m);

  rrep(i, sz(v), 0) {
    if (v[i] <= (m / n)) {
      put(v[i]);
      return 0;
    }
  }
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n;
	cin >> n;
	vector<int> a(n + 1, INF);
	FOR(i, 0, n) cin >> a[i];
	int ans = 0;
	int x = 0;
	while(x < n)
	{
		int curr = 0;
		while (x < n && a[x] >= a[x + 1]) x++, curr++;		
		x++;
		setmax(ans, curr);
	}
	
	cout << ans << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
int d;
int dd[50];
int fib(int a){
	if(a==0||a==1)return dd[a]=1;
	if(dd[a])return dd[a];
	return dd[a]=fib(a-1)+fib(a-2);
}

int main() {
int c;
cin>>c;
/*for (int i = 0; i < 50; ++i) {
	dd[i]=-1;
}*/

cout<<fib(c)<<endl;
	return 0;
}

Measured memory_bytes: 3100
class Dice
    @faces = nil

    def initialize arr
        @faces = arr
    end

    def top
        @faces[0]
    end

    def rotate news
        f = @faces.dup
        case news
        when "N"
            @faces = [f[1], f[5], f[2], f[3], f[0], f[4]]
        when "E"
            @faces = [f[3], f[1], f[0], f[5], f[4], f[2]]
        when "W"
            @faces = [f[2], f[1], f[5], f[0], f[4], f[3]]
        when "S"
            @faces = [f[4], f[0], f[2], f[3], f[5], f[1]]
        end
    end

    def right top, front
        "SWSWS".each_char{|c|
            break if @faces[0] == front
            rotate c
        }
        rotate "S"
        "WWW".each_char{|c|
            break if @faces[0] == top
            rotate c
        }
        @faces[2]
    end
end

numbers = gets.chomp.split
dice = Dice.new numbers

n = gets.to_i
n.times{
    top, front = gets.chomp.split
    puts dice.right top, front
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int d;
	cin >> d;
	cout << "Christmas";
	rep(i,25-d) cout << " Eve";
	cout << endl;
	return 0;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int main(){
    int n; cin >> n;
    vector<lint> t(n), a(n);
    vector<lint> l(n), u(n);
    rep(i, n){
        l[i] = 1; u[i] = 1e9;
    }

    rep(i, n){
        cin >> t[i];
        if(i != 0 && t[i-1] == t[i]) u[i] = t[i];
        else{
            l[i] = t[i]; u[i] = t[i];
        }
    }

    rep(i, n) cin >> a[i];
    repr(i, n){
        if(i != n-1 && a[i] == a[i+1]) u[i] = min(u[i], a[i]);
        else{
            l[i] = max(l[i], a[i]);
            u[i] = min(u[i], a[i]);
        }
        if(l[i] > u[i]){
            out(0); return 0;
        }
    }

    lint ans = 1;
    rep(i, n){
        ans *= u[i] - l[i] + 1;
        ans %= MOD;
    }
    out(ans);
}


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

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

    int sum = 0, maxLen = 0;
    rep (i, n)
    {
        int l;
        cin >> l;
        sum += l;
        maxLen = max(l, maxLen);
    }

    cout << (maxLen < sum - maxLen ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

/* add vars here */

int n;

/* add your algorithm here */

int main() {
  cin >> n;

  int m = 0;
  for (int i = 0; i <= 25; ++i) {
    for (int j = 0; j <= 20; ++j) {
      m = 4 * i + 7 * j;
      if (m == n) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  h,w=LI()
  a=[]
  for _ in range(h):
    a.append(S())

  row=[False]*h
  col=[False]*w

  for i in range(h):
    for j in range(w):
      if a[i][j]=='#':
        row[i]=True
        col[j]=True

  for i in range(h):
    if row[i]:
      for j in range(w):
        if col[j]:
          print(a[i][j], end='')
      print()

main()


Measured memory_bytes: 6820
Module _20190421

    Sub Main()

        Dim sRead As String = Console.ReadLine()

        Dim iOnceMoney As Integer = sRead.Split(" ")(0)
        Dim iHaveMoney As Integer = sRead.Split(" ")(1)
        Dim iMaxCount As Integer = sRead.Split(" ")(2)

        If iOnceMoney * iMaxCount > iHaveMoney Then

            Console.WriteLine(iHaveMoney \ iOnceMoney)

        Else

            Console.WriteLine(iMaxCount)

        End If

    End Sub

End Module

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define int long long
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second
#define NIL -1
using ll = long long;
const ll MOD = 1000000007;
#define REP(i,n) for (ll i=0; i < (n); ++i)
#define FOR(i,a,b) for (ll i=(a); i < (b); ++i)
using namespace std;

int get_gcd(int a, int b){while(1){if (a < b) swap(a, b); if (b == 0) return a; a %= b;}}
int get_lcm(int a, int b){return a * b / get_gcd(a, b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

  int a,b,q;
  cin >> a >> b >> q;

  vector<int> s(a);
  vector<int> t(b);
  REP(i,a) cin >> s[i];
  REP(i,b) cin >> t[i];

  //sとtは入力時点でソート済
  //各xに対して、近いsとtの要素を二部探索で見つけて処理する。
  //計算量はO(Q*(log(A)+log(B))なので間に合う。
  REP(i,q) {
    int x;
    cin >> x;
    auto s_itr = lower_bound(ALL(s), x);
    auto t_itr = lower_bound(ALL(t), x);

    vector<int> sc, tc;
    if (s_itr == s.begin()) {
      sc.push_back(*s_itr);
    }
    else if (s_itr == s.end()) {
      sc.push_back(*(s_itr-1));
    }
    else {
      sc.push_back(*s_itr);
      sc.push_back(*(s_itr-1));
    }
    if (t_itr == t.begin()) {
      tc.push_back(*t_itr);
    }
    else if (t_itr == t.end()) {
      tc.push_back(*(t_itr-1));
    }
    else {
      tc.push_back(*t_itr);
      tc.push_back(*(t_itr-1));
    }

    int ans = MAX;
    REP(i,sc.size()) {
      REP(j,tc.size()) {
        const int& ss = sc[i];
        const int& tt = tc[j];
        int k;
        if (ss<=x && x<=tt) {
          k = tt - ss + min(tt-x, x-ss);
        }
        else if (tt<=x && x<=ss) {
          k = ss - tt + min(ss-x, x-tt);
        }
        else if (ss>=x) {
          k = max(ss, tt) - x;
        }
        else {
          k = x - min(ss, tt);
        }
        if (k < ans) ans = k;
      }
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;
#define N 100009
#define LL long long
#define INF 0x3f3f3f3f
#define mymin(x,y) (x>=y?y:x)
#define mymax(x,y) (x>=y?x:y)
const int K = 1e9 + 7;
LL ans = 1;
int k, mark[N], head[N], tot = 0, ding[N], lian[N], dist[N];
struct link{
	int to, nxt;
}l[N * 2];
void add1(int a, int b){
	l[++tot].to = b;
	l[tot].nxt = head[a];
	head[a] = tot;
}
void add(int a, int b){
	add1(a, b), add1(b, a);
}
void dfs(int x, int f){
	ans = 1ll * ans * (k - ding[f]) % K;
	for(int i = head[x]; i; i = l[i].nxt)
		ding[l[i].to]++;
	ding[x]++;
	for(int i = head[x]; i; i = l[i].nxt)
		if(l[i].to != f) dfs(l[i].to, x);	
}
int main() {
	std::ios::sync_with_stdio(0); std::cin.tie(0);
	int n, a, b;
	cin >> n >> k;
	for(int i = 1; i < n; i++){
		cin >> a >> b;
		add(a, b);
		lian[a]++, lian[b]++;
	}
	for(int i = 1; i <= n; i++){
		if(lian[i] + 1 > k){
			cout << 0 << endl;
			return 0;
		}
	}
	ding[0] = 0;
	dfs(1, 0);
	cout << ans;
	return 0;
}


Measured memory_bytes: 9852
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
using namespace std;

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

    for(int i = 0;i < 3;i++){
        if(s[i] == s[i + 1]){
            cout << "Bad";

            return 0;
        }
    }

    cout << "Good";
    
    return 0;
}

Measured memory_bytes: 256
input_lines = input().split()
num_lines = []
a = int(input_lines[0])
b = int(input_lines[1])
c = int(input_lines[2])
d = int(input_lines[3])

num_lines.append(a*c)
num_lines.append(a*d)
num_lines.append(b*c)
num_lines.append(b*d)

print(max(num_lines))

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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,x; cin>>n;
	map<ll,ll> ct;
	ll pre=0;
	for (int i=0; i<n; i++) {
		ct[pre]++;
		cin>>x;
		pre+=x;
	}
	ct[pre]++;

	ll ret=0;
	for (auto it : ct)
		ret+=it.second*(it.second-1)/2;
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 12800
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
using namespace std;
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<pin,int>
#define V vector
#define Endl endl
#define veb vector<bool>
#define sq(a) (a)*(a)
#define rev(s) reverse(s.begin(),s.end())
#define end_pr(s) cout << s <<endl;return 0
#define itn int
#define bs bitset<5001>
#define mk_re(a) if(a){RE();}
int kai_size = 1000001;
vel kai(kai_size, 1);
vel ink(kai_size, 1);
vel dist;
int sz(pin x) { return x.first*x.second; }
signed main() {
	while (true) {
		int n, w, d; cin >> n >> w >> d;
		if (n == 0 and w == 0 and d == 0) { break; }
		V<pin> ans(1, mkp(w, d));
		rep(i, n) {
			int num; cin >> num;
			num--;
			pin wd = ans[num];
			V<pin> nans(0);
			rep(j, i+1) {
				if (num != j) { nans.push_back(ans[j]); }
			}
			int s; cin >> s;
			int w1 = wd.first;
			int d1 = wd.second;
			s %= (w1 + d1);
			if (s < w1) {  nans.push_back(mkp(s,d1)); nans.push_back(mkp(w1 - s,d1));}
			else { s -= w1; nans.push_back(mkp(w1,s)); nans.push_back(mkp(w1,d1 - s));}
			ans = nans;
			if (sz(ans[i + 1]) < sz(ans[i])) { swap(ans[i + 1], ans[i]); }
		}
		vel ret(n+1);
		rep(i, n+1) { ret[i] = ans[i].first*ans[i].second; }
		sor(ret);
		rep(i,n) { cout << ret[i] << " "; }
		cout << ret[n] << endl;
	}
	return 0;
}
/*
13:40~

*/


Measured memory_bytes: 18200
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        if(N % 2 == 0){
            System.out.println(0.5);
        }else{
            System.out.println((double) (N + 1) / 2 / N);
        }

    }
}


Measured memory_bytes: 35876
// g++ -std=c++14

/*

Today might be the chance to grasp the chance to let your talent bloom.
May be tomorrow, the day after, or next year...
May be even when you are 30. I'm not sure if physique has anything to do with it
but if you think that it will never come, it probably never will.

- Tooru Oikawa.

*/


#include<bits/stdc++.h>

typedef long long ll;
typedef long double lld;
using namespace std;

#define endl "\n"
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define all(c) c.begin(),c.end()
#define inf 1000000000000000001
#define pii pair<int, int>
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}

template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
ll l=v.size();for(ll i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}

template <typename T>
ostream &operator<<(ostream &out, set<T> const &v) {
    for (auto i = v.begin(); i != v.end(); i++)
        out << (*i) << ' ';
    return out;
}
template <typename T, typename V>
ostream &operator<<(ostream &out, map<T, V> const &v) {
    for (auto i = v.begin(); i != v.end(); i++)
        out << "\n" << (i->first) <<  ":"  << (i->second);
    return out;
}

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

#define int ll

const int N = 1e5 + 199;

int arr[N], n, m;
int pen[N];
int32_t main(){ _
    cin >> n >> m;
    int p = 0, a = 0;
    for (int i = 1; i <= m; i++) {
        int x;
        string s;
        cin >> x >> s;
        if (s[0] == 'W') {
            if (arr[x] == 0) {
                pen[x]++;
            }
        } else {
            if (arr[x] == 0) {
                arr[x] = 1;
                a++;
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        if (arr[i] == 1) {
            p += pen[i];
        }
    }
    cout << a << " " << p << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdlib>
#include<stack>
using namespace std;

int main()
{
  stack<int> S;
  int a,b;
  string s;
  while(cin>>s){
    if(s[0]=='+'){
      a=S.top();S.pop();
      b=S.top();S.pop();
      S.push(a+b);
    }else if(s[0]=='-'){
      a=S.top();S.pop();
      b=S.top();S.pop();
      S.push(b-a);
    }else if(s[0]=='*'){
      a=S.top();S.pop();
      b=S.top();S.pop();
      S.push(a*b);
    }else{
      S.push(atoi(s.c_str()));
    }
  }
  cout<<S.top()<<endl;

  return 0;
}


Measured memory_bytes: 3204
#include <cstdio>
#define MAXN 100100
int solve(int* a, int n) {
	int ans = 1;
	int go = 0;
	for(int i = 1; i < n; i++) {
		if(go == 0 && a[i - 1] < a[i]) go = 1;
		else if(go == 0 && a[i - 1] > a[i]) go = -1;
		else if(go == -1 && a[i - 1] < a[i]) ans++, go = 0;
		else if(go == 1 && a[i - 1] > a[i]) ans++, go = 0;
	}
	return ans;
}
int main(void) {
	int n;
	static int a[MAXN];
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	printf("%d\n", solve(a, n));
	return 0;
}

Measured memory_bytes: 512
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: usize,
        a: [i32; n],
    }
    let mut cnt = 1;
    for i in a {
        if i == cnt {
            cnt += 1;
        }
    }
    println!("{}", if cnt == 1 {-1} else {n as i32 - cnt + 1});
}


Measured memory_bytes: 6396
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as MP
import qualified Data.Set as ST
import qualified Data.Sequence as SQ
import Data.Array
import Data.Array.ST
import Data.Array.IO
import Data.Maybe
import Data.Ratio
import Data.Char
import Data.Bits
import Data.List
import Data.Tuple
import Data.Functor
import Data.IORef
import Data.STRef
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Debug.Trace

dfs :: Int -> Int -> Int
dfs n acc
  | n < acc = 0
  | cond = 1 + dfs'
  | otherwise = dfs'
  where
    xs = show acc
    cond = (elem '7' xs) && (elem '5' xs) && (elem '3' xs) 
    dfs' = dfs n (acc*10+7) + dfs n (acc*10+5) + dfs n (acc*10+3)

main = do
  n <- readLn :: IO Int
  let res = dfs n 0
  print res

Measured memory_bytes: 892
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  long a, b, c, d;
  readf("%s %s %s %s\n", &a, &b, &c, &d);
  int i;
  while (a > 0 && c > 0) {
    if (i % 2) {
      a -= d;
    } else {
      c -= b;
    }
    i++;
  }
  if (a <= 0) {
    writeln("No");
  } else {
    writeln("Yes");
  }
}


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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  string S,T; cin >> S; cin >> T;

  int min_val = T.size();
  for(int i = 0; i < S.size(); i++){
    int tmp = 0;
    bool flg = false;
    for(int j = 0; j < T.size(); j++){
      if(i+j >= S.size()){
        flg = true;
        break;
      }
      if(S[i+j] != T[j]) tmp++;
    }
    if(flg) break;
    min_val = min(min_val, tmp);
  }
  cout << min_val << endl;

}


Measured memory_bytes: 3600
import math
import sys

n = int(sys.stdin.readline().rstrip())
s = sys.stdin.readline().rstrip()
v = sys.stdin.readline().rstrip()

# s = s[:3]
# v = v[-3:]
ans = 0

for i in range(min(len(s), len(v))):
    if s[-i - 1:] == v[:i + 1]:
        ans = i + 1

print(n * 2 - ans)

Measured memory_bytes: 3060
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)

int main() {
	int a, b;
	cin >> a >> b;
	if (a >= 1) cout << "Positive" << endl;
	else if (a <= 0 && 0 <= b) cout << "Zero" << endl;
	else {
		int dif = b - a + 1;
		if (dif % 2 == 1) cout << "Negative" << endl;
		else cout << "Positive" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    int s = N;
    int sum = 0;
    while(N) {
        int dig = N % 10;
        sum += dig;
        N /= 10;
    }
    // cout << sum << endl;
    if(s % sum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
  string s;
  cin>>s;
  int l=s.length(),f=0,r=0;
  do{
    for(int i=l-1;i>0;--i){
      f=0;
      if(s[i]=='9')continue;
      if(s[i-1]=='0'){
        int j=i-1;
        while(j>=0){
          if(s[j]!='0')break;
          --j;
        }
        if(j<0)break;
        for(int k=j+1;k<=i;k++)s[k]='9';
        s[j]--; f++;
      }
      else {s[i-1]--;s[i]='9';f++;}
    }
  }while(f);
  for(int i=0;i<l;i++)r+=s[i]-'0';
  cout<<r;
}

Measured memory_bytes: 256
#include <stdio.h>
  
int main() {
    int sep, n, i, j, count;
      
    while(1) {
        scanf("%d", &n);
        if(n == 0) {
            break;
        }
          
        count = 0;
        for(i = 2;; i ++) {
            sep = n/i;
            if(i%2 == 0 && sep - (i/2 - 1) <= 0 || i%2 != 0 && sep - i/2 <= 0) { break; }
              
            if(i%2 == 0) {
                if((sep + (sep + 1))*(i/2) == n) {
                    count ++;
                }
            }
            else {
                if(sep + sep*2*(i/2) == n) {
                    count ++;
                }
            }
        }
          
        printf("%d\n", count);
    }
      
    return 0;
}

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

#define int long long

vector<int> getPrimes(int n) {
    vector<int> res;
    for(int i = 1; i*i <= n; ++i) {
        if(n % i != 0) continue;
        res.push_back(i);
        if(n/i == i) continue; // 上の行で追加済み。
        res.push_back(n/i);
    }
    return res;
}

signed main(){

    int n, p; cin >> n >> p;
    
    vector<int> result = getPrimes(p);
    /*for(int i = 0; i < result.size(); i++){
        cout << result[i] << endl;
    }
    cout << endl;
    */
    int ans = 1;

    for(auto mul : result){
        if(mul == 1) continue;
        //cout << mul << endl;    
        int cnt = 0;
        int tmp = p;
        while(1){
            if(tmp % mul == 0){
                //cout << tmp << " " << mul << " " << tmp % mul << endl;
                cnt++;
                tmp /= mul;
                
            }else{
                break;
            }
        }

        if(cnt >= n) ans = max(ans, mul);
        
    }

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

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

#define N 5010
#define H 123
#define INF 0x7f7f7f7f
#define LL long long

LL len,k,cnt,nk=0,mark,a[N<<5],ans[6],kmax[6]={0};
char s[5010];

void print(LL x){
	if (x==0) return ;
	if (x<H) printf("%c",x);
	else {
		print((x-(x%H))/H);
		if (x%H) printf("c",x%H);
	}
}
int main()
{
	scanf("%s",s);
	scanf("%d",&k);
	LL mmax = 1;
	for (LL i=1;i<=5;i++) mmax*=H; 
	len = strlen(s);
	memset(a,0x7f7f7f7f,sizeof(a));
	for (int i=0;i<len;i++){
		a[++cnt] = (int)(s[i]);
		for (int j=1;i+j<len && j<=4;j++)
			a[++cnt] = a[cnt-1] *H + (int)(s[i+j]);
	}
	for (int i=1;i<=cnt;i++)
		while (a[i]<mmax) a[i]*=H;
	sort(a+1,a+cnt+1);
	for (int i=1;i<=cnt;i++){
		mark = 1;
		for (int j=1;j<=5;j++) 
			if (a[i]==kmax[j]) mark = 0;
		if (mark) kmax[++nk] = a[i];
		if (nk==k) break;
	}
	int x = 0;
	while (kmax[k]>0){
		ans[++x] = kmax[k]%H;
		kmax[k] = (kmax[k]-ans[x])/H;
	}
	for (int i=6;i>0;i--){
		if (ans[i]==0) break;
		printf("%c",ans[i]);
	}
	return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>a(n+1); for(int i=1;i<=n;++i)cin>>a.at(i);
	vector<int>v(n+1,0);
	vector<int>ans;
	for(int i=n;i>=1;--i){
		int cnt=0;
		for(int j=i+i;j<=n;j+=i){
			cnt+=v.at(j);
		}
		if(cnt%2!=a.at(i)){
			v.at(i)=1;
			ans.emplace_back(i);
		}
	}
	cout<<ans.size()<<"\n"s;
	if(ans.size()){
		cout<<ans.front();
		for(auto i=ans.begin()+1;i!=ans.end();++i){
			cout<<" "s<<*i;
		}
		cout<<"\n"s;
	}
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
inline int sum_di(int x)
{
	int res=0;
	while(x)
	{
		res+=x%10;
		x/=10;
	}
	return res;
}
int main()
{
	int n, res=999999999;
	cin>>n;
	if(n%10==0)
	{
		cout<<"10";
		return 0;
	}
	cout<<sum_di(n);
	return 0;
}


Measured memory_bytes: 256