akhauriyash/Code-Regression huggingface dataset:
N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))

is_visited = [-1] * (N + 1)  # 未訪の時 -1, 既訪のとき何番目に訪れたか
p = 1
L = 0  # 周期
T = []

while is_visited[p] == -1:
    is_visited[p] = len(T)
    T.append(p)
    p = A[p]
L = len(T) - is_visited[p]
start_loop = is_visited[p]
# print(T, is_visited, p)

if K < start_loop:
    print(T[K])
else:
    K -= start_loop
    K %= L
    print(T[K + start_loop])


Measured memory_bytes: 32368
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int m = scan.nextInt();
    int [] a = new int[n];
    boolean [] b = new boolean[n];
    for (int i=0;i<n;i++){
      a[i] = scan.nextInt();
    }

    for (int j=0;j<m;j++){
      int c = scan.nextInt();
      int d = scan.nextInt();
      int e = a[c-1];
      int f = a[d-1];
      if (e>f){
        b[d-1] = true;
      }
      else if(e<f){
        b[c-1] = true;
      }
      else{
        b[d-1] = true;
        b[c-1] = true;
      }
    }

    int sum=0;
    for (int k=0;k<n;k++){
      if (b[k] == false){
        sum += 1;
      }
    }

    System.out.println(sum);

  }
}


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

int main() {
  int R; cin >> R;
  if (R < 1200) {
    cout << "ABC" << endl;
  } else if (R < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
X, Y = map(int, input().split())
import math
mod = pow(10,9) + 7
a = 2*Y -X
b = 2*X -Y
if a % 3 == 0 and b % 3 == 0 and a >= 0 and b >= 0:
  k = a // 3
  l = b // 3
  c = max(k, l)
  d = min(k, l)
  bunshi = 1
  bunbo = 1
  for i in range(c+1,c+d+1):
    bunshi = bunshi * i % mod
  for i in range(1,d+1):
    bunbo = bunbo * i % mod
  ans = bunshi * pow(bunbo, mod-2, mod) % mod
  print(ans)
else:
  print(0)


Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(void){
    char s[11];
    int a[11],i,min=1000,num;
    scanf("%s",s);
    int len = strlen(s);
    //printf("%d",len);
    for(i=0;i<len;i++){
        a[i]=s[i]-'0';
    }
    for(i=0;i<len-2;i++){
        num=a[i]*100+a[i+1]*10+a[i+2]-753;
        num = abs(num);
        if(min>num){
            min = num;
        }
    }
    printf("%d",min);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n,k;
int main(){
	cin>>n>>k;
	cout<<n-k+1<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import defaultdict
d = defaultdict(lambda: 0)

N = int(input())
for i in range(N):
    s = list(input())
    s.sort()
    s = "".join(s)
    d[s] += 1

print(max(sum([i * (i - 1) // 2 for i in d.values()]), 0))


Measured memory_bytes: 18192
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

struct M{int e,a;};

int main(void){
	
	int x,y,z;
	double dp[51][5001];
	map<int,M>m;
	
	while(cin >> x >> y >> z,x|y|z){
		vector<int>v(x);
		m.clear();
		
		for(int i=0;i<x;i++)cin >> v[i];
		for(int i=0;i<z;i++){
			int n,e,a;
			M in;
			cin >> n >> in.e >> in.a;
			m[n]=in;
		}
		
		fill(dp[0],dp[51],0);
		dp[0][0]=1;
		
		for(int i=0;i<y;i++){
			for(int j=0;j<5001;j++){
				for(int k=0;k<x;k++){
					int nx=i+v[k];
					if(nx>=y)dp[y][j]+=dp[i][j]/x;
					else if(m.count(nx)){
						if(m[nx].e==1)dp[min(y,nx+m[nx].a)][j]+=dp[i][j]/x;
						else if(m[nx].e==2)dp[nx][j+m[nx].a]+=dp[i][j]/x;
						else if(m[nx].e==3)dp[nx][max(0,j-m[nx].a)]+=dp[i][j]/x;
					}
					else dp[nx][j]+=dp[i][j]/x;
				}
			}
		}
		double ans=0;
		for(int j=0;j<5001;j++)ans+=dp[y][j]*j;
		
		cout << (int)ans << endl;
	}
	
return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n, m; cin>>n>>m;
    vector<ll> x(n), y(n), z(n);
    for(int i=0; i<n; i++){
        cin>>x[i]>>y[i]>>z[i];
    }

    ll ans=0;
    for(int bit=0; bit<(1<<3); bit++){
        int a=-1, b=-1, c=-1;
        if(bit & (1<<0)) c=1;
        if(bit & (1<<1)) b=1;
        if(bit & (1<<2)) a=1;

        vector<ll> sum(n);
        for(int i=0; i<n; i++){
            sum[i]=a*x[i]+b*y[i]+c*z[i];
        }

        sort(sum.begin(), sum.end(), greater<ll>());

        ll msum=0;
        for(int i=0; i<m; i++) msum+=sum[i];
        
        ans=max(ans, msum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
    int a,b,c,d,e,f,g;
    while(scanf("%d %d %d %d",&a,&b,&c,&d)==4)
    {
        e = a-c;
        f = b-d;
        g = (e*f);
        cout<<g<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> a(N); rep(i, 0, N) {
		cin >> a[i];
	}
	vector<int> s = a;
	int ans1 = 0, ans2 = 0;
	rep(i, 0, N) {
		dump(s);
		if (i & 1) {
			if (s[i] <= 0) {
				int c = abs(s[i]) + 1;
				ans1 += c;
				s[i] += c;
			}
		}
		else {
			if (s[i] >= 0) {
				int c = abs(s[i]) + 1;
				ans1 += c;
				s[i] -= c;
			}
		}
		if (i < N - 1)s[i + 1] += s[i];
	}
	if (s.back() == 0)ans1++;
	dump(s);
	dump(ans1);
	s = a;
	rep(i, 0, N) {
		dump(s);
		if (i & 1) {
			if (s[i] >= 0) {
				int c = abs(s[i]) + 1;
				ans2 += c;
				s[i] -= c;
			}
		}
		else {
			if (s[i] <= 0) {
				int c = abs(s[i]) + 1;
				ans2 += c;
				s[i] += c;
			}
		}
		if (i < N - 1)s[i + 1] += s[i];
	}
	if (s.back() == 0)ans2++;
	dump(s);
	dump(ans2);
	cout << min(ans1, ans2) << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
main(n){
    for(;~scanf("%d",&n);){
      n=n>18?36-n:n;
      printf("%d\n",n<0?0:(n+1)*(n+2)*(n+3)/6-(n>9?(n-9)*(n-8)*(n-7)*2/3:0));
    }
}

Measured memory_bytes: 1784
#include<iostream>
using namespace std;
int main() {
    int A, B, ans;
    cin >> A >> B;
    if(A >= 13) {
        ans = B;
    } else if(6 <= A && A <= 12) {
        ans = B / 2;
    } else {
        ans = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <stdlib.h>
#include <time.h>
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define setDP(arr) memset(arr,-1,sizeof arr)
#define Clear(arr) memset(arr,0,sizeof arr)
#define oo 1000000000
#define inf 1000000000000000000
#define M 998244353
using namespace std;
typedef long long ll;
const int N = 1e6+300;
const int SQRTN = 320;
const int LOGN = 20;
const double PI = acos(-1);
const double TAU = 2*PI;

int a,b,c;

inline void solve(){
  cin >> a >> b >> c;
  int ans = 0;
  for(int i = a ; i <= b ; i++)ans+=(i%c)==0;
  cout << ans << endl;
}

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


Measured memory_bytes: 3188
#include <algorithm>
#include <iostream>
#include <iterator>
#include <sstream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[]) {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;

  bool sakadachi_start = S[0] == '1';

  vector<int> mem;
  size_t i = 0;
  while (i < N) {
    int c = 0;
    while (S[i + c] == S[i + c + 1]) {
      c++;
    }
    mem.push_back(c + 1);
    i += c + 1;
  }

  int l = mem.size();
  vector<int> ruiseki;
  int sum = 0;
  ruiseki.push_back(sum);
  for (int a : mem) {
    sum += a;
    ruiseki.push_back(sum);
  }

  // int aaa = sakadachi_start ? l / 2 : (l + 1) / 2;
  // cout << aaa << endl;
  // for (size_t i = 0; i < l; i++) {
  //   cout << mem[i] << " ";
  // }
  // cout << endl;
  // for (int a : ruiseki) {
  //   cout << a << " ";
  // }
  // cout << endl;

  if (sakadachi_start) {
    int res = 0;
    for (int i = 0; i < l + 1; i += 2) {
      res = max(res, ruiseki[min(2 * K + 1 + i, l)] - ruiseki[i]);
    }
    cout << res << endl;
  } else {
    int res = 0;
    for (int i = 0; i < l + 1; i += 2) {
      res = max(res, ruiseki[min(2 * K + i, l)] - ruiseki[max(0, i - 1)]);
    }
    cout << res << endl;
  }
}

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


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

    int n;
    cin >> n;

    vector<pair<string,int>> arr(n);

    rep(i,n) cin >> arr[i].first >> arr[i].second;

    string s;
    cin >> s;

    bool flag = false;
    int res = 0;
    for(int i = 0; i < n; i++){
        if(flag) res += arr[i].second;
        if(arr[i].first == s) flag = true;
    }
    cout << res << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <climits>
#include <functional>
#include <array>
#include <cmath>

using namespace std;

char S[11];

int main(){
	
	cin >> S;

	S[3] = '8';

	cout << S << endl;

	return 0;
}



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

using namespace std;

const int N = 2e5 + 5;
int n, dp[N];
long long ans = 0;
string s;

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

    cin >> s; n = s.size(); s = '!' + s;

    for (int i = n, lst = n + 1; i > 0; --i) {
        if (i < n && s[i] == 'B' && s[i + 1] == 'C') dp[i] = 1 + dp[lst];
        if (i < n && s[i + 1] != 'A') lst = i + 1;
    }

    for (int i = n, lst = n + 1; i > 0; --i) {
        if (s[i] == 'A') ans += dp[lst];
        else lst = i;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 1360
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
typedef	long long ll;
typedef unsigned long long ull;
#define all(v) ((v).begin()),((v).end())
#define PI(n) ((double)acos(n))
int dx8[8] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy8[8] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	// online submission
#endif
}
void fast()
{
	std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
}
int main()
{
	int a, b;
	cin >> a >> b;
	int c1, c2, c3;
	if ( a%3==0 ||b%3==0||(a + b) % 3==0){
		cout << "Possible" << endl;
	}
	else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }

ull gcd(ull x, ull y) {
  return y ? gcd(y, x % y) : x;
}

ull lcm(ull x, ull y) {
  return (x * y) / gcd(x, y);
}

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

  cout << lcm(a, b) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<ll> dqll;

#define MOD 1000000007

vector<ll> kirai(10, false);

bool judge(ll x) {
  string xstr = to_string(x);
  for (size_t i = 0; i < xstr.size(); i++) {
    if(kirai[xstr[i] - '0']){
      return false;
    }
  }

  return true;
}

int main() {
  ll N;
  ll M;
  cin >> N >> M;

  for (int i = 0; i < M; i++) {
    ll tmp;
    cin >> tmp;
    kirai[tmp] = true;
  }

  ll ans = N;
  while (true) {
    if (judge(ans))
      break;
    else
      ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int s = a.back();
	int g = s / 2;
	int t;
	int dif = 1 << 30;
	for (int i = 0; i < n - 1; i++) {
		if (abs(g - a[i]) <= dif) {
			dif = abs(g - a[i]);
			t = a[i];
		}
	}
	cout << s << " " << t << endl;
	return 0;	
}

Measured memory_bytes: 640
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = input()
V = {"s":R, "p":S, "r":P}
ans = 0
for i in range(K):
    check = T[i]
    ans += V[T[i]]
    while True:
        i += K
        if i >= N:
            break
        if check == T[i]:
            check = -1
        else:
            ans += V[T[i]]
            check = T[i]
print(ans)

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


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

  long long int ans = 0;
  for (int i = n-1; i >= 1; i--) {
    ans += i;
  }
  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;





int main(){
    ll n;
    cin>>n;
    vector<ll> A(n);
    for(auto &i:A){cin>>i;}
    vector<ll> dp(n,0);
    stack<pll> S;
    for(int i=1;i<n;i++){
        dp[i]=dp[i-1];
        ll k=A[i-1];
        while(k<A[i]){
            k*=4;
            if(S.empty()){
                dp[i]+=i*2;
            }
            else{
                pll w=S.top(); S.pop();
                dp[i]+=(i-w.F)*2;
                w.S--;
                if(w.S>0){S.push(w);}
            }
        }
        ll count=0;
        ll b=A[i];
        while(k>=b){count++; b*=4;}
        if(count>1){S.push({i,count-1});}
    }
    reverse(A.begin(),A.end());
    while(!S.empty()){S.pop();}
    vector<ll> dp2(n,0);
    for(int i=1;i<n;i++){
        dp2[i]=dp2[i-1];
        ll k=A[i-1];
        while(k<A[i]){
            k*=4;
            if(S.empty()){
                dp2[i]+=i*2;
            }
            else{
                pll w=S.top(); S.pop();
                dp2[i]+=(i-w.F)*2;
                w.S--;
                if(w.S>0){S.push(w);}
            }
        }
        ll count=0;
        ll b=A[i];
        while(k>=b){count++; b*=4;}
        if(count>1){S.push({i,count-1});}
    }
    reverse(dp2.begin(),dp2.end());
    ll ans=E;
    for(int i=0;i+1<n;i++){
        ans=min(ans,dp[i]+dp2[i+1]+i+1);
    }
    ans=min(ans,dp2[0]);
    ans=min(ans,dp[n-1]+n);
    cout<<ans<<endl;
    
    
    
    
    return 0;
}


Measured memory_bytes: 4992
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
using namespace std;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	string s;
	cin>>s;
	int len=s.length();
	len--;
	if(len%2==0){
		for(int i=len;i>0;i-=2){
			bool flag=true;
			int sol=i/2;
			for(int j=0;j<sol;j++){
				if(s[j]!=s[j+sol])
				flag=false;
			}
			if(flag==true){
				cout<<i;
				return 0;
			}
		}
	}
	else{
		for(int i=len-1;i>0;i-=2){
			bool flag=true;
			int sol=i/2;
			for(int j=0;j<sol;j++){
				if(s[j]!=s[j+sol])
				flag=false;
			}
			if(flag==true){
				cout<<i;
				return 0;
			}
		}
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;

  vector<Int> as(n),bs(n);
  for(Int i=0;i<n;i++) cin>>as[i];
  for(Int i=0;i<n;i++) cin>>bs[i];

  vector<Int> cs(as),ds(bs);
  sort(cs.begin(),cs.end());
  sort(ds.begin(),ds.end());
  for(Int i=0;i<n;i++)
    if(cs[i]>ds[i]) drop("No");

  vector<Int> xs(n),ys(n),zs(n);
  for(Int i=0;i<n;i++){
    xs[i]=cs[i]<=ds[i];
    if(i+1<n) ys[i]=cs[i]<=ds[i+1];
    if(i)     zs[i]=cs[i]<=ds[i-1];
  }

  vector<Int> sx(n+1,0),sy(n+1,0),sz(n+1,0);
  for(Int i=0;i<n;i++){
    sx[i+1]=sx[i]+xs[i];
    sy[i+1]=sy[i]+ys[i];
    sz[i+1]=sz[i]+zs[i];
  }

  for(Int i=0;i<n;i++){
    if(as[i]>bs[i]) continue;

    Int p=lower_bound(cs.begin(),cs.end(),as[i])-cs.begin();
    Int q=lower_bound(ds.begin(),ds.end(),bs[i])-ds.begin();

    if(p==q){
      Int sum=1+(sx[p]-sx[0])+(sx[n]-sx[p+1]);
      if(sum==n) drop("Yes");
    }
    if(p>q){
      Int sum=1+(sx[q]-sx[0])+(sy[p]-sy[q])+(sx[n]-sx[p+1]);
      if(sum==n) drop("Yes");
    }
    if(p<q){
      Int sum=1+(sx[p]-sx[0])+(sz[q+1]-sz[p+1])+(sx[n]-sx[q+1]);
      if(sum==n) drop("Yes");
    }
  }
  //assert(0);
  using P = pair<Int, Int>;
  vector<P> vp,vq;
  for(Int i=0;i<n;i++){
    vp.emplace_back(as[i],i);
    vq.emplace_back(bs[i],i);
  }
  sort(vp.begin(),vp.end());
  sort(vq.begin(),vq.end());
  vector<Int> pp(n),pq(n);
  for(Int i=0;i<n;i++){
    pp[vp[i].second]=i;
    pq[vq[i].second]=i;
  }

  vector<Int> pos(n);
  for(Int i=0;i<n;i++)
    pos[pp[i]]=pq[i];

  Int cur=pos[0],len=1;
  while(cur!=0){
    cur=pos[cur];
    len++;
  }
  if(len==n) drop("No");

  drop("Yes");
  return 0;
}


Measured memory_bytes: 13540
S = input()
i = 0
length = len(S)
ans = 0
flag = False
while True:
	if S[i] == S[i+1]:
		if flag == False:
			i+=2
			flag = True
		else:
			i+=1
			flag = False
	else:
		i+=1
		flag = False
	ans+=1
	if i == length - 1:
		ans += 1
		break
	if i >= length:
		break
print(ans)

Measured memory_bytes: 3500
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long a[] = new long[n+1];
        a[0] = 2;
        a[1] = 1;
        for(int i = 2; i<=n; i++){
            a[i] = a[i-1] + a[i-2];
        }
        System.out.println(a[n]);
    }
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

const int MAX = 250;
int dp1[1000006];
int dp2[1000006];
vector<int> pollock;
vector<int> pollock2;

int main() {
    rep(i,1000006) dp1[i] = dp2[i] = 10000000;
    rep(i,MAX){
        int t = i*(i+1)*(i+2)/6;
        if(t>1000006) break;
        pollock.push_back(t);
        if(t&1) pollock2.push_back(t);

    }
    rep(i,pollock.size()) {
        if(!i) continue;
        dp1[pollock[i]] = 1;
    }
    rep(i,pollock2.size()) {
        dp2[pollock2[i]] = 1;
    }
    rep(i,1000006) {
        rep(j,pollock.size()) {
            if(!j) continue;
            if(i+pollock[j]>1000006) continue;
            dp1[i+pollock[j]] = min(dp1[i+pollock[j]],dp1[i]+1);
        }
        rep(j,pollock2.size()) {
            if(i+pollock2[j]>1000006) continue;
            dp2[i+pollock2[j]] = min(dp2[i+pollock2[j]],dp2[i]+1);

        }
    }
    int n;
    while(cin>>n) {
        if(n==0) break;
        cout<<dp1[n]<<" "<<dp2[n]<<endl;

    }



    return 0;
}

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


int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); ++i)
	{
		if (s[i] == '?')
			s[i] = 'D';
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
//const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
    int a,b;
    cin>>a>>b;
    if(a<=b)cout<<"unsafe"<<"\n";
    else cout<<"safe"<<"\n";
}

Measured memory_bytes: 3640
// #pragma GCC optimize(3,"Ofast","inline")
// #pragma GCC optimize(2)
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <string>
#include <iostream>
#include <list>
#include <cstdlib>
#include <bitset>
#include <assert.h>
#include <time.h>
#include <iomanip>
// #define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
// char buf[(1 << 21) + 1], * p1 = buf, * p2 = buf;
// #define int long long
#define lowbit(x) (x & (-x))
#define lson root << 1, l, mid
#define rson root << 1 | 1, mid + 1, r
#define pb push_back
typedef unsigned long long ull;
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
#define bug puts("BUG")
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const double eps = 1e-6;
template <class T>
inline void read(T &x)
{
    int sign = 1;char c = getchar();x = 0;
    while (c > '9' || c < '0'){if (c == '-')sign = -1;c = getchar();}
    while (c >= '0' && c <= '9'){x = x * 10 + c - '0';c = getchar();}
    x *= sign;
}
#ifdef LOCAL
    // FILE* _INPUT=freopen("input.txt", "r", stdin);
    // FILE* _OUTPUT=freopen("output.txt", "w", stdout);
#endif
using namespace std;
int main()
{
    string s;
    cin >> s;
    puts(s == "ABC" ? "ARC" : "ABC");
}

Measured memory_bytes: 3592
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// INPUT
		int n = sc.nextInt(); // トッピングの種類
		if(n < 0 || n > 1000) System.exit(-1);
		int a = sc.nextInt(); // 生地の値段
		if(a < 0 || a > 1000) System.exit(-1);
		int b = sc.nextInt(); // トッピングの単価
		if(b < 0 || b > 1000) System.exit(-1);
		int c = sc.nextInt(); // 生地のカロリー
		if(c < 0 || c > 10000) System.exit(-1);
		int[] t_cal = new int[n]; // n種類のトッピングの各カロリー
		for(int i=0; i<n ; i++) {
			t_cal[i] = sc.nextInt();
			if(t_cal[i] < 0 || t_cal[i] > 10000) System.exit(-1);
		}
		int price = a; // 総額
		int sum_cal = c; // 総カロリー
		int best = c / a; // best pizza
		Arrays.sort(t_cal);
		for(int i=n-1; i>=0 ;i--) {
			sum_cal += t_cal[i];
			price += b;
			int tmp = sum_cal / price;
			if(tmp > best) best = tmp;
		}
		System.out.println(best);
	}
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }

    int ans = 0, cnt = 0;

    for(int i = n - 2; i >= 0; i--){
        if(h[i] >= h[i+1]) cnt++;
        else cnt = 0;
        ans = max(ans, cnt);
    }

    cout << ans << endl;

}

Measured memory_bytes: 640
N = int(input())
A = list(map(int,input().split()))
finish = 0
result = 1

if 0 in A:
    print(0)
    finish = 1
else:
    for n in range(N):
        result = result*A[n]
        if result > 10**18:
            print(-1)
            finish = 1
            break

    if finish == 0:
        print(result)

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

int calculate_gcd(int a, int b){
    if(a<b){swap(a,b);}
    if(b<1){return 0;}
    int r;
    while((r = a%b) != 0){
        a = b;
        b = r;
    }
    return b;
}

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++){cin >> a[i];}
    int gcd = a[0];
    for(int i = 1; i < n; i++){
        gcd = calculate_gcd(gcd,a[i]);
    }
    int max_num = *max_element(a.begin(), a.end());
    if(k%gcd == 0 && k <= max_num){cout << "POSSIBLE" <<"\n";}
    else{cout << "IMPOSSIBLE" <<"\n";}


    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
 
int main() {
  string l = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  int N;
  cin >> N;
  
  string S;
  cin >> S;
  int size;
  size = S.size();
  
  char r;
  int let_n;
  rep(i, size){
    r = S.at(i);
    rep(j, 26){
      if(r == l.at(j)) let_n = j;
    }
    //cout << let_n;
    //for Z
    if((let_n+N) > 25){
      cout << l.at(let_n+N - 26);
    } else {
      cout << l.at(let_n+N);
    }
  }
  
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn.readLine
/**
  * AOJ
  */

object Main {

  def main(args: Array[String]): Unit = {
    println(if(find(read,read)){"Yes"}else{"No"})
  }

  def find(dice1:Array[Int],dice2:Array[Int]) : Boolean = {
    for(i <- createDiceArray(dice1,"WNNNW"); j <- createDiceArray(i,"HHH")){
      if(diceMatch(j,dice2)){return true}
    }
    return false
  }

  def createDiceArray(dice:Array[Int],commands:String) : List[Array[Int]] = {
    var dices = List(dice)
    for(cmd <- commands.toCharArray){
      dices :+= getNextStatus(cmd,dices.last)
    }
    dices
  }

  def read() : Array[Int] = {readLine().split(" ").map(_.toInt)}

  def diceMatch(dice1:Array[Int],dice2:Array[Int]):Boolean = (dice1 zip dice2).forall(x => x._1 == x._2)

  def getNextStatus(cmd:Char,dice:Array[Int]): Array[Int] = cmd match {
    case 'N' => Array(dice(1), dice(5), dice(2), dice(3), dice(0), dice(4))
    case 'H' => Array(dice(0), dice(2), dice(4), dice(1), dice(3), dice(5))
    case 'W' => Array(dice(2), dice(1), dice(5), dice(0), dice(4), dice(3))
  }
}

Measured memory_bytes: 44268
n = int(input())
l = list(map(int,input().split()))

l.sort()
ans = "Yes"
count = 1
if l[0] == l[-1]:
  if ((n // 2) < l[0]) and (l[0] != 1) and (l[0] != n - 1):
    ans = "No"
elif l[-1] - l[0] >= 2:
    ans = "No"
else:
  for i in range(n-1):
    if l[i+1] - l[i] == 0:
      count += 1
    elif l[i+1] - l[i] == 1:
      break
  umax = count + (n - count) // 2
  if (l[-1] > umax) or (l[-1] <= count):
    ans = "No"

print(ans)

Measured memory_bytes: 14008
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define All(obj) (obj).begin(),(obj).end()

using namespace std;


int main() {
	speed;
	int n, m;
	cin >> n >> m;
	vector<int>count(m, 0);
	rep(i, n) {
		int k;
		cin >> k;
		rep(j, k) {
			int a;
			cin >> a;
			++count[--a];
		}
	}
	int ans = 0;
	rep(i, m) {
		if (count[i] == n)ans++;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#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 INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

ll gcd(ll a, ll b){
    if(a % b == 0){
        return(b);
    }
    else{
        return(gcd(b, a % b));
    }
}

//scanf("%lld", &);
//cin >> ;
//cout << ans << endl;

ll N, M, K, i, j, k, l, ans, cnt = 0;


int main(){
    ll data, prod = 1;
    vector<ll> A;
    cin >> N;

    REP(i, N){
        scanf("%lld", &data);
        if(data == 0){
            cout << 0 << endl;
            return 0;
        }
        A.push_back(data);
    }

    REP(i, N){
        if(A[i] <= 1000000000000000000 / prod){
            prod *= A[i];
        }
        else{
            cout << -1 << endl;
            return 0;
        }
    }
    cout << prod << endl;

    return 0;
}

Measured memory_bytes: 4364
#include <bits/stdc++.h>
#define RANGE(i,n) for(int i=0;i<n;i++)
typedef long long ll;
struct P{
    ll var1;
    ll var2;
};
bool operator< ( const P &one, const P &two){
    return one.var1 < two.var1;
};
bool operator> ( const P &one, const P &two){
    return one.var1 > two.var1;
};

using namespace std;

signed main() {
    char x;
    cin >> x;
    set<char> capital{'A','B','C','D','E','F','G','H','I','J','K','L','M','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
    set<char> lower{'a','b','c','d','e','f','g','h','i','j','k','l','m','o','p','q','r','s','t','u','v','w','x','y','z'};
    auto is_in_c = capital.find(x);
    if (is_in_c != capital.end()) cout << "A" << endl;
    else cout << "a" << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;

int main(){
    ll S;
    cin >> S;
    ll W;
    cin >> W;
    if(W>=S)cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;

    return 0;
}


Measured memory_bytes: 3636
from collections import deque

s = list(input())
s2 = deque(list(reversed(s)))
s = deque(s)
Q = int(input())
q = []
f = []
c = []
count = 0

for _ in range(Q):
    tmp = list(map(str,input().split()))
    if len(tmp) == 1:
        count += 1
        q.append(int(tmp[0]))
        f.append(0)
        c.append('')
    else:
        q.append(int(tmp[0]))
        f.append(int(tmp[1]))
        c.append(tmp[2])


for i in range(Q):
    if q[i] == 1:
        tmp = s
        s = s2
        s2 = tmp
    else:
        if f[i] == 1:
            s.appendleft(c[i])
            s2.append(c[i])
        else:
            s.append(c[i])
            s2.appendleft(c[i])

for i in range(len(s)):
    print(s.popleft(),end="")
print("")


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

const ll mod = 1e9 + 7;

int main()
{
	int N;
	cin >> N;
	vector<int> a(N), b(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> b[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	ll res = 1, st = 0;
	for (int i = 0, j = 0; i < N || j < N; ) {
		if (i == N) {
			j++;
			if (st > 0) res = res * abs(st) % mod;
			st--;
		}
		else if (j == N) {
			i++;
			if (st < 0) res = res * abs(st) % mod;
			st++;
		}
		else if (a[i] < b[j]) {
			i++;
			if (st < 0) res = res * abs(st) % mod;
			st++;
		}
		else {
			j++;
			if (st > 0) res = res * abs(st) % mod;
			st--;
		}
	}
	cout << res << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
ll N;
ll x[100001];
ll y[100001];
unordered_map<ll,ll> ums[100001];
ll z[100001];
priority_queue<pair<ll,ll>, vector<pair<ll,ll>> ,greater<pair<ll,ll>>> pq;

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> x[i] >> y[i];
    vector<pair<ll,ll>> vx,vy;
    for(int i=0;i<N;i++){
        vx.push_back(make_pair(x[i],i));
        vy.push_back(make_pair(y[i],i));
    }
    sort(vx.begin(),vx.end());
    sort(vy.begin(),vy.end());
    for(int i=1;i<N;i++){
        ums[vx[i].second][vx[i-1].second] = ums[vx[i-1].second][vx[i].second] = min(abs(x[vx[i].second] - x[vx[i-1].second]), abs(y[vx[i].second] - y[vx[i-1].second]));
        ums[vy[i].second][vy[i-1].second] = ums[vy[i-1].second][vy[i].second] = min(abs(y[vy[i].second] - y[vy[i-1].second]), abs(x[vy[i].second] - x[vy[i-1].second]));
    }
    for(int i=0;i<N;i++) z[i] = 0;
    z[0] = 1;
    for(auto p=ums[0].begin(); p!=ums[0].end(); p++){
        pq.push(make_pair(p->second, p->first));
    }
    ll cost = 0;
    while(!pq.empty()){
        pair<ll,ll> pp = pq.top();
        pq.pop();
        if(z[pp.second] != 0) continue;
        z[pp.second] = 1;
        cost += pp.first;
        for(auto p=ums[pp.second].begin(); p!=ums[pp.second].end(); p++){
            if(z[p->first] == 0) pq.push(make_pair(p->second, p->first));
        }
    }
    cout << cost << endl;
    return 0;
}

Measured memory_bytes: 31460
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 昇順にソート済みのarrから、n以上の最小の要素を探索して返します。
# 存在しない場合は、Noneを返します。
def bin_gte(arr, n, l):
    r = len(arr) - 1
    c = (l+r)//2
    while l < r:
        c = (l+r)//2
        if arr[c] >= n:
            r = c
        else :
            l = c+1
    c = max(0, (l+r)//2)
    if arr[c] >= n:
        return (c, arr[c])
    else:
        return None

def bin_lte(arr, n, l):
    r = len(arr) - 1
    c = (l+r)//2
    while l < r:
        # c = math.ceil((l+r)/2)
        c = (l+r+1)//2
        if arr[c] <= n:
            l = c
        else :
            r = c-1
    c = max(0, (l+r)//2)
    if arr[c] <= n:
        return (c, arr[c])
    else:
        return None

n = int(input())
lll = get_nums_l()
lll.sort()

ans=0

# maxs = [None] * 2002
# mi = 0
# prev = lll[0]
# for l in lll[1:]:
#     for j in range(prev, l):
#         maxs[j] = mi
#     mi += 1
#     prev = l
# for j in range(prev, 2002):
#     maxs[j] = mi

# mins = [None] * 2002
# mi = 0
# prev = 0
# for l in lll:
#     for j in range(prev+1, l+1):
#         mins[j] = mi
#     mi += 1
#     prev = l

# print(maxs)
# print(mins)

for ai, a in enumerate(lll):
    if ai == n-2:
        break
    for bi in range(ai+1, n-1):
        b = lll[bi]

        _min = abs(a-b) + 1
        _max = a+b - 1

        # left = mins[_min]
        # right = maxs[_max]
        left = bin_gte(lll, _min, bi+1)
        right = bin_lte(lll, _max, bi+1)
        if left is None or right is None:
            continue
        
        ans += right[0]-left[0]+1
        # ans += right-left+1

print(ans)

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

using namespace std;

int N,Y;
int num[3] = {0};

bool dfs2(int x,int y,int z){
    int sum = 10000*x + 5000*y + 1000*z;
    
    if( sum == Y){
        num[0] = x;
        num[1] = y;
        num[2] = z;
        return true;
    }

    if( x == 0 && y == 0) return false;
    else if( sum < Y ) return false;

    if( y > 0){
        if(dfs2(x,y-1,z+1)) return true;
    }
    //cout << x << " " << y << " " << z << " " <<endl;
    return false;


}

bool dfs(int x,int y,int z){
    int sum = 10000*x + 5000*y + 1000*z;
    
    if( sum == Y){
        num[0] = x;
        num[1] = y;
        num[2] = z;
        return true;
    }

    if( x == 0 && y == 0) return false;
    else if( sum < Y ) return false;

    if( y > 0){
        if(dfs2(x,y-1,z+1)) return true;
    }

    if(x > 0){
        if(dfs(x-1,y+1,0)) return true;
    }
    
    

    
    //cout << x << " " << y << " " << z << " " <<endl;
    return false;
}

int main (void){
    cin >> N >> Y;
    num[0] = N;

    //どうあがいても無理
    if( N * 10000 < Y){
        cout << "-1 -1 -1" << endl;
        return 0;
    }

    //深さ優先探索
    if(dfs(num[0],num[1],num[2]) ){
        cout << num[0] << " " << num[1] << " " << num[2]<<" "<<endl;
    }
    else cout << "-1 -1 -1" << endl;

    return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int H, W;
    for(;;) {
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        for(int i = 0; i < H; i++) {
            for(int j = 0; j < W; j++) {
                if((i+j)%2 == 0) cout << "#";
                else cout << ".";
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3048
import sys
from collections import Counter

sys.setrecursionlimit(10000)
INF = float('inf')

N = int(input())
V = list(map(int, input().split()))

v1 = Counter(V[::2]).most_common(2)
v2 = Counter(V[1::2]).most_common(2)


if v1[0][0] != v2[0][0]:
    ans = N - (v1[0][1] + v2[0][1])
else:
    ans = N - v1[0][1]
    if len(v1) >= 2:
        ans = min(ans, N - (v1[1][1] + v2[0][1]))
    if len(v2) >= 2:
        ans = min(ans, N - (v1[0][1] + v2[1][1]))
print(ans)


Measured memory_bytes: 15588
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int x,y; cin>>x>>y;
    int ans = 0;
    if(x == 1)ans += 300000;
    if(x == 2)ans += 200000;
    if(x == 3)ans += 100000;
    if(y == 1)ans += 300000;
    if(y == 2)ans += 200000;
    if(y == 3)ans += 100000;

    if(ans == 600000)ans += 400000;
    cout<<ans<<endl;

}


Measured memory_bytes: 256
n,m=map(int,input().split())
A=list(map(int,input().split()))
bc = [list(map(int,input().split())) for _ in range(m)]
bc = sorted(bc,key=lambda x:-x[1])

sub = []
for i in range(m):
   sub += [bc[i][1]] * bc[i][0]
   if len(sub) > n:
       break

A += sub

print(sum(sorted(A,reverse=True)[:n]))

Measured memory_bytes: 38416
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
long long A[500];
long long tmp_A[500];

bool can_be_done(long long divisor, long long K, int N){
    for(int i = 0; i < N; i++){
        tmp_A[i] = A[i] % divisor;
    }
    sort(tmp_A, tmp_A + N);
    int left = 0;
    int right = N - 1;
    while(left < right){
        if(tmp_A[left] == 0){
            left++;
        } else if(tmp_A[right] == 0){
            right --;
        } else if(tmp_A[left] <= divisor - tmp_A[right]){
            K -= tmp_A[left];
            tmp_A[right] = (tmp_A[right] + tmp_A[left]) % divisor;
            tmp_A[left] = 0;
        } else if(tmp_A[left] > divisor - tmp_A[right]){
            K -= (divisor - tmp_A[right]);
            tmp_A[left] -= (divisor - tmp_A[right]);
            tmp_A[right] = 0;
        }

        //cout << K << endl;
        if(K < 0){
            return false;
        }
    }
    return true;
}   

int main(){
    int N;
    long long K;
    cin >> N >> K;
    long long sum_A = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        sum_A += A[i];
    }

    vector <long long> divisors;
    for(int i = 1; i < sqrt(sum_A) + 1; i++){
        if(sum_A % i == 0){
            divisors.push_back(i);
            divisors.push_back(sum_A / i);
        }
    }
    sort(divisors.begin(), divisors.end());

    for(int i = divisors.size() - 1; i >= 0; i--){
        if(can_be_done(divisors[i], K, N)){
            cout << divisors[i] << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  int a[n];
  long sum=0;
  for(int i=0;i<n;i++)
  {cin>>a[i];
   sum+=a[i];}
  sort(a,a+n);
  reverse(a,a+n);
  int ans=0;
  long r=sum/(4*m);
  if(sum % (4*m)==0)
    r=r-1;
  for(int i=0;i<n;i++)
  {
   if(a[i]>r)
     ans++;
  }
  if(ans>=m)
   cout<<"Yes";
   else
   cout<<"No";
}

Measured memory_bytes: 256
n=int(input())
n_1 = n%10
if n_1 == 2 or n_1 == 4 or n_1 == 5 or n_1 == 7 or n_1 == 7 or n_1 == 9:
	print("hon")
elif n_1 == 3:
	print("bon")
else:
	print("pon")


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

typedef long long ll;

ll mod_pow(ll x,ll n,ll mod){
  if(n==0)return 1;
  ll res=mod_pow(x*x%mod,n/2,mod);
  if(n&1)res=res*x%mod;
  return res;
}

signed main(){
  int n;
  cin>>n;
  int a[111111]={};
  int s,t;
  for(int i=1;i<=n+1;i++){
    int ai;
    cin>>ai;
    if(a[ai]){
      s=a[ai];
      t=i;
    }else a[ai]=i;
  }
  int p[111111],pp[111111],j=1;
  p[0]=pp[0]=1;
  for(int i=1;i<111111;i++){
    j*=i;
    j%=MOD;
    p[i]=j;
    pp[i]=mod_pow(p[i],MOD-2,MOD);
  }
  for(int k=1;k<=n+1;k++){
    int ans1=(((p[n+1]*pp[n+1-k])%MOD)*pp[k])%MOD;
    int am=s-1+n+1-t;
    int ans2=(((p[am]*pp[am-(k-1)])%MOD)*pp[k-1])%MOD;
    if(am<k-1)cout<<ans1<<endl;
    else cout<<(ans1+MOD-ans2)%MOD<<endl;
  }
  return 0;
}


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


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

	int starti, endi;
	for (int i = 0; i < s.size(); ++i){
		if (s.at(i) == 'A') {
			starti = i;
			break;
		}
	}
	for (int i = s.size()-1; i >= 0; --i){
		if (s.at(i) == 'Z') {
			endi = i;
			break;
		}
	}
	cout << endi - starti + 1 << endl;
}


Measured memory_bytes: 640
#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 SMAX 50

string miss_match = "UNRESTORABLE";

int main() {
  string S, T;

  cin >> S;
  cin >> T;

  if (T.size() > S.size()) {
    cout << miss_match << endl;
    return 0;
  }

  int pos = 100;

  // 高々, ( |S| - |T| + 1 ) 通り
  // 候補を全て考える. 候補が複数ある場合, できるだけ後ろのものを採用.
  REP(cand, S.size() - T.size() + 1) {
    int count = 0;
    for (int index = cand; index < cand + T.size(); index++) {

      if (S[index] != '?' && S[index] != T[count]) {
        break;
      }
      count++;
      if (count == T.size()) {
        pos = cand;
      }

    }

  }

  if (pos == 100) {
    cout << miss_match << endl;
  } else {

    int j = 0;


    // pos以降を文字列Tで埋める
    for (int i = pos; i < pos + T.size(); i++) {
      S[i] = T[j];
      ++j;
    }


    // '?'を'a'で埋める
    REP(i,S.size()) {
      if (S[i] == '?') S[i] = 'a';
    }

    cout << S << endl;
  }

  return 0;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define LLINF LLONG_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

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

ll N, M;
vector<vector<ll>> G;

ll dp[100100];
ll rec(ll v) {
    if (dp[v] != -1) {
        return dp[v];
    }

    ll res = 0;
    for (auto next : G[v]) {
        chmax(res, rec(next)+1);
    }

    return dp[v] = res;
}

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    // input values
    cin >> N >> M;
    G.assign(N, vector<ll>());

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

    // dp table
    // init dp table
    // init condition
    rep (i, N) {
        dp[i] = -1;
    }

    // loop
    ll ans = 0;
    rep (v, N) {
        chmax(ans, rec(v));
    }

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

Measured memory_bytes: 8576