akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;  
#define ordered_set tree<ll, null_type , less<ll> , rb_tree_tag , tree_order_statistics_Node_update> 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
#define setbits __builtin_popcount
#define endl '\n'
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main()
{
    fastIO;
    ll k;
    cin>>k;
    string str="ACL",ans;
    for(int i=0;i<k;i++)
    {
        ans+=str;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3572
s = input().split()
list = []
list.append(int(s[0]))
list.append(int(s[1]))
list.append(int(s[2]))

#print(list)

for i in range(2):
    for j in range(2):
        if list[j]>list[j+1]:
            swap = list[j]
            list[j] = list[j+1]
            list[j+1] = swap

print(list[0],list[1],list[2])



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  vector<int> a(5);
  rep(i,5) cin>>a[i];
  int ans =0;
  int buf = 10;
  for(t:a){
    if (t%10 > 0) buf = min(buf,t%10);
    ans += t + (10 - t%10)%10;
  }
  if (buf<10) ans -= (10 - buf);
  cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define pb push_back
#define mpr make_pair
#define Senky_Bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{   
    Senky_Bansal
    IIIT_ALLAHABAD
    string s,p;
    cin>>s;
    p=s;
    ll ans1=0,ans2=0;
    for(int i=1;i<s.size();i++)
    {
        if(s[i]==s[i-1])
        {
            if(s[i]=='0')
            s[i]='1';
            else
            s[i]='0';
            ans1++;
        }
    }
    s=p;
    for(int i=s.size()-2;i>=0;i--)
    {
        if(s[i]==s[i+1])
        {
            if(s[i]=='0')
            s[i]='1';
            else
            s[i]='0';
            ans2++;
        }
    }
    cout<<min(ans1,ans2)<<endl;
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String[]args)throws IOException {
		Scanner S = new Scanner(System.in);
		int n = S.nextInt();
		HashMap <Integer, Integer> h = new HashMap<Integer, Integer>();
		int res[] = new int[n];
		for(int i = 1; i <= n; i++)
		{
			h.put(i, S.nextInt());
		}
		for(int i = 1; i <= n; i++)
		{
			res[h.get(i) - 1] = i;
		}
		for(int i = 0; i < n; i++)
		{
			System.out.print(res[i] + " ");
		}
	}
}

Measured memory_bytes: 70380
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define ALL(x) (x).begin(),(x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main() {
	IOS;
	const int INF = 114514;
	vector<bool> a(INF, true);
	vector<ll> s(INF, 0);
	a[0] = a[1] = false;
	a[2] = true;
	FOR(i, 2, INF) {
		if (a[i]) {
			for (ll j = i + i; j < INF; j += i)a[j] = false;
		}
		if (i > 2 && a[i] && a[(i + 1) / 2]) {
			s[i] = s[i - 1] + 1;
		}
		else {
			s[i] = s[i - 1];
		}
	}
	ll q; cin >> q;
	REP(i, q) {
		ll l, r;
		cin >> l >> r;
		dump(s[r] - s[l - 1]);
	}
	return 0;
}

Measured memory_bytes: 1536
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    String[] line = br.readLine().split(" ");
	    int n = Integer.parseInt(line[0]);
	    int m = Integer.parseInt(line[1]);

	    // parse A
	    int[][] a = new int[n][m];
	    for (int i = 0; i < n; i++) {
	    	line = br.readLine().split(" ");
	    	for (int j = 0; j < m; j++) {
		    	a[i][j] = Integer.parseInt(line[j]);
	    	}
	    }

	    // parse B
	    int[][] b = new int[m][1];
	    for (int i = 0; i < m; i++) {
	    	b[i][0] = Integer.parseInt(br.readLine());
	    }

	    // Calculation
	    int[][] ans = new int[n][1];
	    for (int i = 0; i < n; i++) {
	    	for (int j = 0; j < m; j++) {
	    		ans[i][0] += (a[i][j] * b[j][0]);
	    	}
	    }

	    // Display Answer
	    for (int i = 0; i < ans.length; i++) {
	    	System.out.println(ans[i][0]);
	    }
	}
}

Measured memory_bytes: 27608
import java.util.*;
import java.util.stream.Collectors;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
      
        String s = sc.next();
        List<String> words = Arrays.asList("dream", "erase", "dreamer", "eraser");

        int tmpIndex = s.length();
        while (true) {
            int tmpIndex2  = tmpIndex;
            for (String word : words) {
                if(s.startsWith(word, tmpIndex - word.length())) {
                    tmpIndex = s.indexOf(word, tmpIndex - word.length());
                    break;

                }
            }

            if (tmpIndex == 0 || tmpIndex == tmpIndex2) {
                break;
            }
        }
        String result = "NO";
        if (tmpIndex == 0) {
            result = "YES";
        }


        System.out.println(result);
    }
}

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


int main(){
  int n,k,i;
  cin >> n >> k;
  vector<long long> x(n);
  for(i=0;i<n;++i){
    cin >> x[i];
  }
  long long l,r;
  long long ans=1000000000;
  for(i=0;i<n-k+1;++i){
    l=x[i];
    r=x[i+k-1];
    ans=min(ans,abs(l)+abs(r-l));
    ans=min(ans,abs(r)+abs(r-l));
  }
  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main() {
  int N;
  string S;
  cin >> N >> S;
  for (char &c : S) {
    c = (c - 'A' + N) % 26 + 'A';
  }
  cout << S << endl; 
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int answer = 0;
		int max = 0;
		
		for (int i = N; i > 0; i-- ){
			
			int H = scanner.nextInt();
			if (H >= max) {
				max = H;
				answer = answer + 1;
			}
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 23124
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>

#define rep(i,a,n) for(int (i) = (a);(i) < (n);(i)++)
#define MOD 1000000007
#define ll long long

using namespace::std;
int main(){

  int N;
  int M;
  cin>>N;
  int *T = new int[N];
  int sum=0;
  rep(i,0,N){
    cin>>T[i];
    sum=sum+T[i];
  }
  cin>>M;
  int *P = new int[M];
  int *X = new int[M];
  rep(i,0,M) cin>>P[i]>>X[i];
  
  rep(i,0,M){
 //   cout<<P[i]<<" "<<T[P[i]-1]<<" "<<X[i]<<" ";
    cout<<sum-T[P[i]-1]+X[i]<<endl;
  }
    
}
// int *p = new int[N];

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <cfenv>
#include <cmath>

using namespace std;

int main(){
  double n;
  cin >> n;
  vector<int> x(n);
  for(int i=0; i<n; i++){
    cin >> x.at(i) ;
  }
  double sum =0;
  for(int i=0;i<n;i++){
    sum += x.at(i);
  }
  double hoge = sum /n;
  double ave = round(hoge);
  for(int i=0; i<n;i++){
    x.at(i) = abs(ave-x.at(i));
  }
  int health = 0;
  for(int i=0;i<n;i++){
    health += (x.at(i)*x.at(i));
  }
  
  cout << health << endl;
  
}

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repd(i, n) for (ll i = 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 FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
bool check = 0;
string s, t;
int N = 3;
vector<int> v(N);
int a, b;
int x, y;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  cin >> a >> b;
  pr(a * (a - 1) / 2 + b * (b - 1) / 2);
}

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

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long
#define ld long double

#define mod 1000000007
#define EULER 2.7182818284
#define INF 1000000000

#define pb push_back
#define ins insert
#define IT iterator
#define PQ priority_queue
#define    nl           "\n"
#define fi first
#define se second
#define maxe max_element
#define mine min_element
#define er erase
#define lb lower_bound
#define ub upper_bound

#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define mpi map<int,int>
#define mpl map<ll,ll>
#define umpi unordered_map<int,int>
#define umpl unordered_map<ll,ll>
#define si set<int>
#define sl set<ll>
#define msi multi_set<int>
#define msl multi_set<ll>

#define mem(v,i) memset(v,i,sizeof(v)) 


#define repab(i,a,b) for(int i=(a);i<=(b);i++)
#define reprab(i,a,b) for(int i=(a);i>=(b);i--)
#define repll(i,a,b) for(ll i=(a);i<=(b);i++)
#define rep(i,n) for(int i=(0);i<(n);i++)
#define repr(i,n) for(int i=(n);i>=0;i--)
#define bs bitset
#define bpc(a) __builtin_popcount(a)
#define tc int t;cin>>t;while(t--)


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

ll max(ll a,ll b)
{
    if(a>b)return a;return b;
}
ll min(ll a,ll b)
{
    if(a<b)return a;return b;
}

ll mypow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}


int main()
{   
    
    fast
    int t;
    cin>>t;
    if(t>=30)
    cout<<"Yes\n";
    else
    cout<<"No\n";
    
    return 0;
}

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

using namespace std;

// "dream", "dreamer", "erase", "eraser" → "maerd" "remaerd" "esare" "resare"
int main(){
    string S;
    cin >> S;
    
    int now = S.length() - 1;
    
    while(now > 0){
        if(S[now] == 'm'){
            if(now < 4 || S.compare(now - 4 , 5, "dream") != 0){
                cout << "NO\n";
                return 0;
            }
            
            now -= 5;
        }
        else if(S[now] == 'e'){
            if(now < 4 || S.compare(now - 4, 5, "erase") != 0){
                cout << "NO\n";
                return 0;
            }
            
            now -= 5;
        }
        else if(S[now] == 'r'){
            if(now < 5){
                cout << "NO\n";
                return 0;
            }
            if(!(now == 5) && S.compare(now - 6, 7, "dreamer") == 0){
                now -= 7;
            }
            else if(S.compare(now - 5, 6, "eraser") == 0){
                now -= 6;
            }
            else{
                cout << "NO\n";
                return 0;
            }
        }
        else{
            cout << "NO\n";
            return 0;
        }
    }
    
    // now == -1
    if(now < 0){
        cout << "YES\n";
    }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define N 100000
using namespace std;
struct line {
    int A, B, C, n;
    double p;
} L[N];
int t[N], n;
 
bool cmpX(line a, line b) {
    double Ka = -1.0 * a.A / a.B;
    double Kb = -1.0 * b.A / b.B;
    return Ka < Kb;
}
bool cmp(line a, line b) {
    return a.p < b.p;
}
int lb(int x) {
    return x & (-x);
}
double calc(double x, int i) {
    return ((double)L[i].C - (double)L[i].A * x) / L[i].B;
}
void add(int x) {
    for(; x <= n; x += lb(x)) t[x]++;
}
int ask(int x) {
    int ret = 0;
    for(; x > 0; x -= lb(x)) ret += t[x];
    return ret;
}
 
int ch(double mid) {
    for(int i = 1; i <= n; i++) L[i].p = calc(mid, i);
    sort(L + 1, L + n + 1, cmp);
    for(int i = 1; i <= n; i++) t[i] = 0;
    int ret = 0;
    for(int i = 1; i <= n; i++) {
        ret += ask(L[i].n);
        add(L[i].n);
    }
    return ret;
}
 
double sol() {
    double l = -1e9, r = 1e9;
    for(int i = 1; i <= 80; i++) {
        double mid = (l + r) / 2;
        int tmp = ch(mid);
        if (tmp + tmp < n * (n - 1) / 2) l = mid;
        else r = mid;
    }
    return l;
}
 
int main() {
    cin >> n;
    for(int i = 1; i <= n; i++) scanf("%d%d%d", &L[i].A, &L[i].B, &L[i].C);
    sort(L + 1, L + n + 1, cmpX);
    for(int i = 1; i <= n; i++) L[i].n = i;
    double X = sol();
    for(int i = 1; i <= n; i++) swap(L[i].A, L[i].B);
    sort(L + 1, L + n + 1, cmpX);
    for(int i = 1; i <= n; i++) L[i].n = i;
    double Y = sol();
    printf("%.20f %.20f\n", X, Y);
}


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

using namespace std;
 
int main()
{
    int n, num, h, w;
     
    while (1) {
        double best = 22, tmp;
        int bn;
         
        cin >> n;
        if(!n) break;
         
        for (int i = 0; i < n; i++) {
            cin >> num >> h >> w;
             
            double nh = (double)h / 100;
            double BMI = (double)w / (nh*nh);
            if (!i) {
                tmp = fabs(BMI-best);
                bn = num;
                continue;
            }
            if (tmp > fabs(BMI-best)) {
                tmp = fabs(BMI-best);
                bn = num;
            }
        }
        cout << bn << endl;
    }
    return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;




int main() {
    li a, b;
    cin >> b >> a;
    cout << (a == 100 ? 101 : a);
    rep(i, b)cout << "00";
    cout << endl;
    return 0;
}

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

int main()
{
  int n;
  float x[2], y[2], a[2];

  scanf("%d", &n);
  for (int i = 0; i < n; i++){
    for (int j = 0; j < 2; j++){
      for (int k = 0; k < 2; k++){
        scanf("%f%f", &x[k], &y[k]);
      }
      a[j] = (y[1] - y[0]) / (x[1] - x[0]);
    }
    if (a[0] == a[1]){
      puts("YES");
    }
    else {
      puts("NO");
    }
  }

  return (0);
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,n,m) for(int i=n;i<int(m);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
 
int vx[]={0,0,-1,1};
int vy[]={1,-1,0,0};
int dx[]={1,0,-1,1,-1,1,0,-1};
int dy[]={1,1,1,0,0,-1,-1,-1};
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	
 
const ll mod=1e9+7;
const int INF=INT_MAX/2;

int main(){
	int x;
	cin>>x;
	cout<<1000*(x/500)+5*((x%500)/5)<<endl;
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int x,y;
	cin >> x>> y;
      cout << x*x-y << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>

using namespace std;
typedef long long ll;

int main()
{
 	ios_base::sync_with_stdio(0);
 	ll luc[87];
 	luc[0] = 2;
 	luc[1] = 1;
 	for(int i=2; i<87; i++) {
 		luc[i] = luc[i-1] + luc[i-2];
 	}
 	int n;
 	cin >> n;
 	cout << luc[n];
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

class Mod{
    static final long MOD = 1000_000_007;
    static final long[] fact = makeFactorialArray(1000000);
    static final long[] factInv = makeInversedArray(fact);

    public static long add(long a, long b){
        long tmp = (a+b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long adds(long... ar){
        long ans=0;
        for(long x:ar) ans = Mod.add(ans, x);
        return ans;
    }
    public static long sub(long a, long b){
        return add(a,-b);
    }
    public static long mult(long a, long b){
        long tmp = (a*b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long mults(long... ar){
        long ans=1;
        for(long x:ar) ans = Mod.mult(ans, x);
        return ans;
    }
    public static long power(long a, long x){ //calculate a^x
        if(x<0)return 0;
        if(x==0)return 1;
        if(x%2==0) {
            long half = power(a,x/2);
            return mult(half,half);
        }
        return (a*power(a,x-1)) % MOD;
    }
    public static long inverse(long a){
        return power(a,MOD-2);
    }
    public static long div(long a, long b){
        return mult(a, inverse(b));
    }
    public static long[] makeFactorialArray(int size){
        long[] array = new long[size];
        array[0]=1;
        for(int i=1;i<size;i++){
            array[i]=mult(array[i-1],i);
        }
        return array;
    }
    public static long[] makeInversedArray(long[] original){
        long[] array = new long[original.length];
        for(int i=0;i<original.length;i++){
            array[i] = inverse(original[i]);
        }
        return array;
    }
    public static long combination(long n, long r){
        int N = (int)n,  R = (int)r;
        if(n<0 || r<0 || n<r) return 0;
        return mult(fact[N], mult(factInv[R],factInv[N-R]));
    }
}
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] C = new long[N];
        for(int n=0; n<N; n++) C[n]=sc.nextLong();
        Arrays.sort(C);

        long ans = 0;
        for(int n=0; n<N; n++){
            ans = Mod.add(ans,
                          Mod.mults(N-1-n==0 ? 1L : (Mod.mults(Mod.power(2,N-2-n), N+1-n)),
                                    Mod.power(2,n),
                                    C[n]));
        }
        System.out.println(Mod.mult(ans, Mod.power(2, N)));
    }

}


Measured memory_bytes: 89404
function combine(p, q)
    lsum = length(p) + length(q) - 1
    p = fft(vcat(p, fill(0., lsum - length(p))))
    q = fft(vcat(q, fill(0., lsum - length(q))))
    real(ifft(p .* q))
end

function divandconquer(arr)
    len = length(arr)
    if len == 1
        arr[1]
    else
        combine(divandconquer(arr[1:div(len, 2)]), divandconquer(arr[div(len, 2)+1:end]))
    end
end

import Base.readline
function readline(T)::Vector{T}
    map(x->parse(T, x), split(readline()))
end

N = readline(Int)[1]

println(sum(divandconquer(map(x->[x, 1. - x], readline(Float64)))[1 : div(N, 2) + 1]))

Measured memory_bytes: 208724
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll m1=0,m2=0,y1=1,y2=1;

    if((s[0] == '0' && (s[1] != '0')))m1=1;
    if((s[0] == '1' && (s[1] == '0' ||s[1] == '1' ||s[1] == '2')))m1=1;

    if((s[2] == '0' && (s[3] != '0')))m2=1;
    if((s[2] == '1' && (s[3] == '0' ||s[3] == '1' ||s[3] == '2')))m2=1;

    if(y1*y2*m1*m2 == 1) cout<<"AMBIGUOUS"<<endl;
    else if(y1 * m2 == 1) cout<<"YYMM"<<endl;
    else if(y2 * m1 == 1)cout<<"MMYY"<<endl;
    else cout<<"NA"<<endl;




}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first 
#define S second 
#define endl "\n"
#define Endl "\n"
#define emdl "\n"
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
// bool sortBy(const pair<int,pair<int,int>> &a,const pair<int,pair<int,int>> &b){
// 	if(a.S.F==b.S.F)
// 		return a.F<b.F;
// 	return a.S.F<b.S.F;
// }

// #define MAXN 1001
// int pf[MAXN]; 
// void sieve(){
// 	long long int i,j; 
//     pf[1] = 1; 
//     for (i=2; i<MAXN; i++) 
//     pf[i] = i;   
//     for (i=2; i*i<MAXN; i++){ 
//         if (pf[i] == i){
//             for (j=i*i; j<MAXN; j+=i) 
//                 if (pf[j]==j) 
//                     pf[j] = i; 
//         } 
//     } 
// }
// vector<int> factors(int x){ 
//     vector<int> ret; 
//     while (x != 1){ 
// 		int fact=pf[x];
//         ret.push_back(pf[x]); 
// 		while(fac!=1&&x%fact==0)
//         x/=fact; 
//     } 
//     return ret; 
// } 
// set<long long int>poww;
// void init(){
// 	long long int temp=1;
// 	for(int i=1;i<43;i++){
// 		poww.insert(temp);
// 		temp*=2;
// 	}
// }  

int main() {		
	ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
	int qwe=1;
	//cin>>qwe;
	//init();
	// sieve();
	while(qwe--){
        string s;
        cin>>s;
        int ans=0;
        for(int i=0;i<s.size();i++){
            ans+=s[i]-'0';
        }
        if(ans%9==0){
            cout<<"Yes";
        }else{
            cout<<"No";
        }
		

	}

	return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N, H, W;
  cin >> N >> H >> W;
  H = max(0, N - H + 1);
  W = max(0, N - W + 1);
  int ans = H * W;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import numpy as np

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

ary = np.array([i for i in range(n+1)])

def lr(l,r): # 等差数列の'l'から'r'の和_mean*number
    return (l+r)*(r-l+1)//2

ans = 0
for j in range(k,n+2):
    l = lr(0, j-1)
    r = lr(n+1-j, n)
    ans += r-l+1
    ans %= 10**9+7
    
print(ans)


Measured memory_bytes: 36392
#include <stdio.h>

int gcd(int p, int q)
{
  if(p % q == 0)
    return q;
  return gcd(q, p % q);
}

int main(void)
{
  int K, i, j, k, ans = 0;
  scanf("%d", &K);
  
  for(i=1; i<=K; i++)
    for(j=1; j<=K; j++)
      for(k=1; k<=K; k++)
        ans += gcd(gcd(i, j), k);
  
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 1700
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main() {
    int r,c,x;
    cin>>r>>c;
    int a[r][c];
    for (int i = 0; i < r; ++i) {
        for (int j = 0; j < c; ++j) {
            cin>>x;
            a[i][j]=x;
        }
    }
    int max=0;
    for (int i = 0; i < r; ++i) {
        for (int j = 0; j < c; ++j) {
            cout<<a[i][j]<<' ';
        }
        int sum=0;
        for (int j = 0; j < c; ++j) {
            sum+=a[i][j];
        }
        cout<<sum<<endl;
        max+=sum;
    }
   int c_sum=0;
    for (int i = 0; i < c; ++i) {
        int r_sum=0;
        for (int j = 0; j < r; ++j) {
            r_sum+=a[j][i];
        }
        cout<<r_sum<<' ';
        c_sum+=r_sum;
    }
    cout<<c_sum<<endl;


    return 0;
}


Measured memory_bytes: 3124
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
ans = 0
for i in range(N):
  A = list(map(int,input().split()))
  temp = C
  for j in range(M):
    temp += A[j]*B[j]
  if temp > 0:
    ans += 1
print(ans)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n;
  cin >> n;
  int a[n];
  rep(i, n) cin >> a[i];
  int count = 0;
  rep(i, n) {
    if (a[i] == i + 1) {
      int tmp = a[i];
      a[i] = a[i + 1];
      a[i + 1] = tmp;
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 4000
#include <cstdio>
#include <algorithm>
using namespace std;
struct node {
    int s;
    int f;
} a[110000];
int cmp(const node& x, const node& y) { return x.f < y.f; }
int n;
int main() {
    scanf("%d", &n);
    int x, y;
    for (int i = 1; i <= n; i++) {
        scanf("%d%d", &x, &y);
        int t = x, tt = y;
        x = t - tt; y = t + tt; 
        a[i].s = x;
        a[i].f = y;
    }
    sort(a + 1, a + n + 1, cmp);
    int tot = 1;
    int now = a[1].f;
    for (int i = 2; i <= n; i++) {
        if (a[i].s >= now) {
            tot++;
            now = a[i].f;
        }
    }
    printf("%d", tot);
    return 0;
}


Measured memory_bytes: 896
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7; //924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans,dp[201000],a[220000], b[220000];
string str, ss;
bool f[220000];
char c[4000][4000];
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>vec,rvec;
vector<edge>ed;
vector<LL>v;
map<string, LL>ma;
set<LL>st;

void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
vector<LL> tsort(vector<vector<Edge>> vec) {
	enum { YET, VISITED, DONE };
	vector<LL> res, flg(n, YET);
	static const function<bool(int)> dfs = [&](int v) {
		flg[v] = VISITED;
		for (auto &e : vec[v]) {
			int w = e.to;
			if (flg[w] != DONE && (flg[w] == VISITED || !dfs(w))) return false;
		}
		flg[v] = DONE;
		res.push_back(v);
		return true;
	};
	for (int i = 0; i < n; ++i)
		if (flg[i] == YET && !dfs(i)) return{};
	reverse(res.begin(), res.end());
	return res;
}
int main() {
	cin >> n >> m;
	vec.resize(n);
	rep(i, m) {
		LL x, y;
		cin >> x >> y;
		x--, y--;
		vec[x].push_back(Edge{ y,1 });
	}
	vector<LL>x = tsort(vec);
	rep(i, n) {
		ans = max(ans,dp[x[i]]);
		rep(j, vec[x[i]].size()) {
			LL v = vec[x[i]][j].to;
			dp[v] = max(dp[x[i]]+1, dp[v]);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 17916
import Data.List

ans :: String -> Int
ans x =
  let max = read $ reverse $ sort x :: Int
      min = read $ sort x :: Int
  in
    max - min

main = do
  n' <- getLine
  let n = read n' :: Int
  c  <- getContents
  let i = take n $ lines c
      o = map ans i
  mapM_ print o
  

Measured memory_bytes: 3636
n= int(input())
a=int(input())

import math
if n==1:
	print(a)
	exit()

b=int(input())
c=(a*b)//math.gcd(a,b)
for i in range(n-2):
	b=int(input())
	c=(c*b)//math.gcd(c,b)

print(c)

Measured memory_bytes: 9180
#include<cstdio>
#include<vector>
#include<cstdlib>

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi>  vvi;

const int INF=(1<<31)-1;

template<class T> struct Interval{
	T a,b;
	Interval(T A,T B):a(A),b(B){}
};

template<class T>
class RMQ{
	int n;
	T *a;

	T query(const Interval<int> &I,const Interval<int> &J,int u){
		if(J.b<=I.a || I.b<=J.a) return INF;
		if(I.a<=J.a && J.b<=I.b) return a[u];

		int m=(J.a+J.b)/2;
		T tl=query(I,Interval<int>(J.a,m),2*u+1);
		T tr=query(I,Interval<int>(m,J.b),2*u+2);
		return tl<tr?tl:tr;
	}

public:
	RMQ(){}

	RMQ(const vector< vector<T> > &v,int k,int b):n(1){
		int N;
		if(!b) N=v[0].size();
		else   N=v.size();

		while(n<N) n<<=1;
		a=(T *)malloc((2*n-1)*sizeof(T));
		rep(i,2*n-1) a[i]=0;

		if(!b) rep(i,N) a[n+i-1]=v[k][i];
		else   rep(i,N) a[n+i-1]=v[i][k];

		for(int i=n-2;i>=0;i--) a[i]=min(a[2*i+1],a[2*i+2]);
	}

	T query(int a,int b){
		return query(Interval<int>(a,b),Interval<int>(0,n),0);
	}
};

int main(){
	for(int h,w,q;scanf("%d%d%d",&h,&w,&q),h||w||q;){
		vvi a(h,vi(w));
		rep(i,h) rep(j,w) scanf("%d",&a[i][j]);

		RMQ<int> *rmq1=(RMQ<int> *)malloc(h*sizeof(RMQ<int>));
		RMQ<int> *rmq2=(RMQ<int> *)malloc(w*sizeof(RMQ<int>));
		rep(i,h) rmq1[i]=RMQ<int>(a,i,0);
		rep(j,w) rmq2[j]=RMQ<int>(a,j,1);

		rep(_,q){
			int t,l,b,r; scanf("%d%d%d%d",&t,&l,&b,&r); b++; r++;

			int ans=INF;
			if(b-t<r-l) for(int i=t;i<b;i++) ans=min(ans,rmq1[i].query(l,r));
			else        for(int j=l;j<r;j++) ans=min(ans,rmq2[j].query(t,b));
			printf("%d\n",ans);
		}
	}

	return 0;
}

Measured memory_bytes: 58000
#include<iostream>

using namespace std;

int main(void)
{
	int a[10000];
	
	int i = 0;
	for( ;  i < 10000 ; i++)
	{
		cin >> a[i];
		if( a[i] == 0 ) break;
	}
	
	for(int j = 1 ; j <= i ; j++)
	{
		cout << "Case " << j << ": " << a[j-1] << endl;
	}
	
	
	return 0;
} 



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

signed main(void){
    int N,x;
    cin>>N>>x;
    vector<int> a(N);
    int sum=0;
    for (int i = 0; i < N; ++i) {
        cin>>a[i];
        sum+=a[i];
    }
    sort(a.begin(),a.end());
    int ans=0;
    if(x>sum)--ans;
    for (auto i:a){
        if(x>=i){x-=i;++ans;}
        else break;
    }

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

Measured memory_bytes: 256
use std::io;

fn main() {
    let mut buffer = String::new();
    io::stdin().read_line(&mut buffer).unwrap();

    let mut buffer = String::new();
    io::stdin().read_line(&mut buffer).unwrap();
    let ns = buffer.trim().split(' ').collect::<Vec<&str>>();
    let xs = ns.into_iter().map(|n| {
        let mut counter = 0;
        let mut x = n.parse::<u32>().unwrap();
        while x % 2 == 0 {
            x = x / 2;
            counter += 1;
        }
        counter
    });
    println!("{}", xs.min().unwrap());
}

Measured memory_bytes: 4352
#include <iostream>
#include <cstring>
#include <cstdlib>
using namespace std;

void judge(int *array, int num) {
    int i;
    for (i=0; i<num-1; i++) {
        if (array[i] > array[i+1]) {
            break;
        }
    }
    if (i == num-1) {
        cout << "YES" << endl;
        exit(0);
    }
}

int main() {
    int N;

    cin >> N;
    int num_seq[N];

    for (int i=0; i<N; i++) {
        cin >> num_seq[i];
    }

    int tmp_seq[N];
    int tmp;

    judge(num_seq, N);

    for (int i=0; i<N; i++) {
        for (int j=i+1; j<N; j++) {
            memcpy(tmp_seq, num_seq, sizeof(num_seq));
            tmp = tmp_seq[i];
            tmp_seq[i] = tmp_seq[j];
            tmp_seq[j] = tmp;

            judge(tmp_seq, N);
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

    int n = s.length();

    if (s.substr(0, (n-1)/2) == s.substr((n+3)/2-1, n-1)) puts("Yes");
    else puts("No");
    return 0;
}

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

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n, vector<int>(m));
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      cin >> a.at(i).at(j);
    }
  }
  vector<int> b(m);
  for(int i = 0; i < m; i++){
    cin >> b.at(i);
  }
  vector<vector<int>> result(n, vector<int>(m));
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      result.at(i).at(j) = a.at(i).at(j) * b.at(j);
    }
  }
  vector<int> answer(n);
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      answer.at(i) += result.at(i).at(j); 
    }
  }
  for(auto x : answer){
    cout << x << endl;
  }
}



Measured memory_bytes: 3232
n,m=gets.split.map(&:to_i)
a=Array.new(m,0)
b=Array.new(m,0)
m.times do |i|
  a[i],b[i]=gets.split.map(&:to_i)
end

ok=true
ans=0
[*1..n].permutation.each do |perm|
  ok=false
  if perm[0]==1
    1.upto(n-1) do |i|
      ok=false
      m.times do |j|
        if (a[j]==perm[i-1] && b[j]==perm[i]) || (b[j]==perm[i-1] && a[j]==perm[i])
          ok=true
          break
        end
      end
      unless ok
        break
      end
    end
  end
  if ok
    ans+=1
  end
end
puts ans


Measured memory_bytes: 14528
#include <stdio.h>
#include <string.h>

int main()
{
    char a[102], b[102], tmp[102];
    int la, lb, i;
    scanf("%s%s", a, b);
    la = strlen(a);
    lb = strlen(b);
    if (la > lb) {
        strcpy(tmp, b);
        for (i=0; i<la-lb; i++)
        {
            b[i] = '0';
        }
        for (i=la-lb; i<la; i++)
        {
            b[i] = tmp[i-(la-lb)];
        }
        b[la] = '\0';
    } else if (la < lb) {
        strcpy(tmp, a);
        for (i=0; i<lb-la; i++)
        {
            a[i] = '0';
        }
        for (i=lb-la; i<lb; i++)
        {
            a[i] = tmp[i-(lb-la)];
        }
        a[lb] = '\0';
    }
    if (strcmp(a, b) > 0) {
        printf("GREATER\n");
    } else if (strcmp(a, b) < 0) {
        printf("LESS\n");
    } else {
        printf("EQUAL\n");
    }
    return 0;
}


Measured memory_bytes: 128
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

int main() {
    ll N;
    cin >> N;
    V<ll> A(N);
    for(ll &e : A) cin >> e;
    ll cur = 0;
    ll ans = 0;
    for(ll i = 0; i < N; i++) {
        if(A[i] == cur + 1) cur++;
        else ans++;
    }

    cout << (ans == N ? -1 : ans) << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


bool is_overflow(ll a, ll b)
{
	if ((a * b) / b != a)
	{
		return true;
	}
	else
	{
		return false;
	}
}

ll dp[200009][5][5];


int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================


	ll N;
	cin >> N;
	vll A(N);
	for (ll i = 0; i < N; i++)
	{
		cin >> A[i];
	}

	for (ll i = 0; i <= N; i++)
	{
		for (ll j = 0; j < 3; j++)
		{
			for (ll k = 0; k < 2; k++)
			{
				dp[i][j][k] = -LLINF;
			}
		}
	}

	A.emplace_back(0);
	A.emplace_back(0);
	A.emplace_back(0);
	A.emplace_back(0);
	A.emplace_back(0);
	A.emplace_back(0);

	/*
	配るDP！
	dp[i番目までの数字][これ以前にp回パスした][u＝１ならその数字を使う];
	*/

	dp[0][0][1] = A[0];
	dp[0][1][0] = 0;

	for (ll i = 0; i < N; i++)
	{
		for (ll p = 0; p <= 2; p++)
		{
			// ひとつ次(pass無し)
			if (dp[i][p][0] != -LLINF)
			{
				dp[i + 1][p][1] = max(dp[i][p][0] + A[i + 1], dp[i + 1][p][1]);
			}
			if (dp[i][p][1] != -LLINF)
			{
				dp[i + 1][p][0] = max(dp[i][p][1], dp[i + 1][p][0]);
			}

			// 二つ先(pass*1)
			if (p <= 1)
			{
				if (dp[i][p][0] != -LLINF)
				{
					dp[i + 2][p + 1][1] = max(dp[i][p][0] + A[i + 2], dp[i + 2][p + 1][1]);
				}
			}
		}


	}


	ll ans = -LLINF;

	if (N % 2 == 0)
	{
		ans = max(ans, dp[N - 1][0][0]);
		ans = max(ans, dp[N - 1][1][1]);
		ans = max(ans, dp[N - 1][0][1]);
		ans = max(ans, dp[N - 1][1][0]);
	}
	else
	{
		//ans = max(ans, dp[N - 1][0][0]);
		ans = max(ans, dp[N - 1][1][1]);
		ans = max(ans, dp[N - 1][2][0]);
		ans = max(ans, dp[N][2][0]);
		//ans = max(ans, dp[N - 1][0][1]);
		ans = max(ans, dp[N - 1][1][0]);
		ans = max(ans, dp[N - 1][2][1]);
		ans = max(ans, dp[N][2][1]);
	}
	cout << ans;

}





Measured memory_bytes: 45432
#include<bits/stdc++.h>
using namespace std;
using lint = long int;

int N;
string X;


/*2進数表記を10進数表記に直しmで割った際の剰余*/
lint convert_stoi_mod(string& S, int n, int m){
    if(m == 0) return 0;  //法が0⇒1のbitは存在しない
    lint res = 0, p = 1;
    for(int i = n; i > 0; i--){
        if(S[i-1] == '1'){ res += p; res %= m; }
        p *= 2; p %= m;
    }
    
    return res;
}



/*2分累乗法：剰余計算*/
lint binary_pow(lint a, lint n, lint m){
    if(m == 0) return 0;  //法が0⇒1のbitが存在しない
    
    lint res = 1;
    while(n > 0){
        if(n & 1) res = (res * a) % m;
        a = (a * a) % m;
        n >>= 1;
    }

    return res;
}



/*2進数表記の文字列についての1のビット数*/
lint pop_count_str(string& S, lint n){
    lint cn = 0;
    for(int i = 0; i < n; i++){ if(S[i] == '1') ++cn; }
    return cn;
}



/*long int型整数の2進数表記における1のビット数*/
lint pop_count_int(lint X){
    lint cn = 0;
    while(X > 0){
        if(X & 1) ++cn;
        X /= 2;
    }
    return cn;
}


/*modを法として,valを合同な最小の非負正数に修正*/
void equiv(lint& val, lint mod){
    if(mod == 0) return;  //法が0⇒1のbitなし⇒valは0⇒変更なし
    
    if(val < 0) val += mod;
    else if(val >= mod) val %= mod;
}



/*当該問題の関数*/
lint f(lint X){
    if(X == 0) return 1;

    lint cn = pop_count_int(X);
    lint X_next = X % cn;
    return 1+f(X_next);
}



/*Xに対応する整数値のみ莫大な値となるので別途計算することを念頭に...*/
int main(){
    cin >> N >> X;

    lint bit_count = pop_count_str(X, N);  //Xの2進表記における1のビット数

    /*ビットは1増えるか減るか...従って対応する法計算結果を先に取得*/
    lint dNp1 = convert_stoi_mod(X, N, bit_count+1);
    lint dNm1 = convert_stoi_mod(X, N, bit_count-1);


    lint X_tmp = 0;
    bool no_existence_1bit = false;
    for(int i = 0; i < N; i++){
        if(X[i] == '1'){
            /*同じ法で変更ビットに相当する値の修正...1 to 0*/
            if(bit_count == 1) no_existence_1bit = true;
            X_tmp = dNm1 - binary_pow(2, N-1-i, bit_count-1);
            equiv(X_tmp, bit_count-1);
        }else if(X[i] == '0'){
            /*同様...ただし法は異なる...0 to 1*/
            X_tmp = dNp1 + binary_pow(2, N-1-i, bit_count+1);
            equiv(X_tmp, bit_count+1);
        }

        if(no_existence_1bit){ cout << 0 << endl; no_existence_1bit = false; }
        else cout << f(X_tmp) << endl;
    }

    return 0;
}

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

int main()
{
	int N;
	scanf("%d", &N);
	std::vector<int64_t> A(N);
	for (auto& e: A) scanf("%lld", &e);
	A.erase(std::unique(A.begin(), A.end()), A.end());
	if (A.size() == 1)
	{
		puts("1");
		return 0;
	}
	
	int count{1}, sign{1};
	if (A[1] - A[0] < 0) sign = -1;
	for (int i{2}; i < (int)A.size(); i++)
		if ((A[i] - A[i - 1]) * sign < 0)
		{
			count++;
			if (i != (int)A.size() - 1 && (A[i + 1] - A[i]) * sign < 0)
				sign *= -1;
		}
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 1024