akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi = 3.141592654;
int main()
{
    //  #ifndef oj
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w",stdout);
    //#endif
    // system("cls");
    //getchar();
    int n1,n2,n3;
    cin>>n1>>n2>>n3;
    if(n1+n2+n3>=22)
        cout<<"bust"<<endl;
    else
        cout<<"win"<<endl;

}



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

int main()
{
    int m,n;
    cin>>m>>n;
    cout<<m*(m-1)/2+n*(n-1)/2;
    return 0;
}


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

int main() {
  int N, A, B;
  cin >> N >> A >> B;

  if( (N * A) < B )                      // プラン1の方が安い
    cout << N * A << endl;
  else                                           //両プランの金額が等しい又はプラン2の方が安い
    cout << B << endl;
}


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


#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int bpm(int x, int y) {
  if (x == 0)
    return 0;
  else if (y == 0) {
    return 1;
  }
  int ans = 1;
  x %= MOD;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) {
      ans *= x;
      ans %= MOD;
    }
    x = x * x;
    x %= MOD;
  }
  return ans;
}

class CTakahashisInformation {
public:
  int solve(std::istream &cin, std::ostream &cout) {
    vector<vector<int>> c(3, vector<int>(3));
    rep(i, 3) {
      rep(j, 3) {
        cin >> c[i][j];
      }
    }
    rep(a1, 101) {
      rep(a2, 101) {
        rep(a3, 101) {
          int b1, b2, b3;
          b1 = c[0][0] - a1;
          b2 = c[0][1] - a1;
          b3 = c[0][2] - a1;
          if (c[1][0] == a2 + b1 && c[1][1] == a2 + b2 && c[1][2] == a2 + b3 && c[2][0] == a3 + b1 && c[2][1] == a3 + b2 && c[2][2] == a3 + b3) {
            cout << "Yes" << endl;
            return 0;
          }
        }
      }
    }
    cout << "No" << endl;
  }
};


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n)cin >> a[i];
	map<int,int> cnt;
	rep(i,n)cnt[a[i]]++;
	int ret = 0,two = 0;
	for(auto p:cnt){
		
		int num = p.second;
		num %= 2;
		if(num == 1){
			ret++;
		}
		else if(num == 0){
			two++;
		}
		
	}
	ret += two/2*2;
	//trace(two);
	//trace(cnt);
	cout << ret << endl;

	

	return 0;
}

Measured memory_bytes: 10312
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

vvi dp((1<<11)+1, vi(100010));

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vi V(N+1), W(N+1);
  for(int i = 1; i <= N; i++){
    cin >> V[i] >> W[i];
  }

  
  for(int i = 0; i < 100010; i++){
    if(i < W[1]) dp[1][i] = 0;
    else dp[1][i] = V[1];
  }
  int NN = min((1<<11), N);
  for(int i = 2; i <= NN; i++){
    for(int j = 0; j < 100010; j++){
      dp[i][j] = dp[i/2][j];
      if(j-W[i] >= 0) chmax(dp[i][j], dp[i/2][j-W[i]] + V[i]);
    }
  }

  int Q;
  cin >> Q;
  while(Q--){
    int v, L;
    cin >> v >> L;
    if(v <= NN){
      cout << dp[v][L]<< endl;
      continue;
    }

    int tmp = v / (1 << 11);
    int counter = 0;
    while(tmp > 0){
      counter++;
      tmp /= 2;
    }
    int ans = 0;
    int par = v/(1<<counter);
    for(int bit = 0; bit < (1<<counter); bit++){
      int wsum = 0, vsum = 0;
      for(int i = 0; i < counter; i++){
        int j = v/(1<<i);
        if((bit>>i) & 1){
          wsum += W[j];
          vsum += V[j];
          if(wsum > L) break;
        }
      }
      if(wsum > L) continue;
      chmax(ans, vsum + dp[par][L-wsum]);
    }
    cout << ans << endl;
  }
}


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

int main()
{
    string s,t;
    cin>>s>>t;
    vector<vector<int>>dp(s.size()+1,vector<int>(t.size()+1,0));
    for(int i=1;i<=s.size();i++)
    {
        for(int j=1;j<=t.size();j++)
        {
            if(s[i-1]==t[j-1])
            {
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    string ans="";
    int i,j;
    i=s.size();
    j=t.size();
    // cout<<dp[i][j]<<"\n";
    // for(int i=1;i<=s.size();i++)
    // {
    //     for(int j=1;j<=t.size();j++)
    //     {
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    while(i>0&&j>0)
    { 
        if(s[i-1]==t[j-1])
        {
            ans+=s[i-1];
            i--;
            j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
        {
            i--;
        }
        else
        {
            j--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
    
}

Measured memory_bytes: 35584
/*	MASTER HAS FAILED MORE TIMES
	THAN BEGINNER HAS EVER TRIED
*/

#include <bits/stdc++.h>

using namespace std;

#define endl             '\n'
#define all(a)           a.begin(), a.end()
#define mem(a, n)        memset(a, n, sizeof(a))
#define Unique(n)        (n).erase(unique(all(n)), (n).end())
#define NumofDigits(n)   ((long long)log10(n)+1)
#define repeat(i, a, n)  for(int i=a; i<n; i++)
#define isPowerOfTwo(n)  (n && !(n & (n - 1)))

typedef long long ll;
typedef long double ld;

int sieve(int n);
unsigned long long pow(long long base, long long power);
long long gcd(long long a, long long b)
{
    return a%b ? gcd(b, a%b) : b;
}
long long lcm(long long a, long long b)
{
    return a*b/gcd(a, b);
}

void quicken()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
void file()
{
#ifdef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif /*ONLINE_JUDGE*/
}

int main()
{
    quicken();

    ll n, a, b, ans; cin >> n >> a >> b;
    if(a+b==0) return cout << 0, 0;

    ans = n/(a+b) * a;
    n %= (a+b);

    if(n>=a) cout << ans + a;
    else cout << ans + n;

    return 0;
}

unsigned long long pow(long long base, long long power)  /// mod?
{
    if(power==0)
        return 1;
    if(power==1)
        return base;

    unsigned long long ans = pow(base, power/2); /// mod?
    ans *= ans; /// ((ans%mod)*(ans%mod))%mod;

    if(power&1)
        return ans*base; /// ((ans%mod)*(base%mod))%mod;
    return ans;
}

int sieve(int n)
{
    int c = 0;
    vector<bool> isPrime(n+1, true);
    isPrime[0] = isPrime[1] = 0;

    for(long long i=2; i*i<=n; i++)
        if(isPrime[i])
            for(long long j=i*2; j<=n; j+=i)
                isPrime[j] = 0;
    repeat(i, 0, n+1)
    if(isPrime[i])
        c++;
    return c; /// primeCount [1:n]
}


Measured memory_bytes: 256
N, M, C = map(int, input().split())
*L, = map(int, input().split())
BALL = [list(map(int, input().split())) for i in range(N)]
BALL.sort(key=(lambda x: x[1]), reverse=1)
ans = 0
for c, w in BALL:
    if L[c-1]:
        ans += w
        L[c-1] -= 1
        M -= 1
        if M == 0:
            break
print(ans)


Measured memory_bytes: 26756
n, x = gets.split.map(&:to_i)
ls = gets.split.map(&:to_i)
ret = 0

ls.each_with_index.inject(0) do |sum, (l, i)|
	(ret = i + 1) && break if sum + l > x
	ret = i + 2 if i == ls.size - 1
	sum + l
end

p ret

Measured memory_bytes: 1916
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	int P,Q, R;
	String line;
	int pos;
	void run() {
		for(;;) {
			line = sc.nextLine();
			if( line.equals(".") ) break;
			int cnt = 0;
			for(P=0;P<3;P++) for(Q=0;Q<3;Q++) for(R=0;R<3;R++) {
				pos = 0;
				if(formula() == 2) cnt++;
			}
			System.out.println(cnt);
		}
		
	}
	
	int formula() {
		char c = line.charAt(pos);
		int value = val( c );
		if( value >= 0 ) { pos++; return value; }
		
		if( c == '-' ){
			pos++;
			return not(formula());
		}
		pos++;
		int a = formula();
		char cc = line.charAt(pos++);
		int b = formula();
		pos++;
		
		if( cc == '*' ) {
			return and(a, b);
		}
		
		return or(a, b);
	}
	
	int val(char c) {
		switch (c) {
		case ('0'): return 0;
		case ('1'): return 1;
		case ('2'): return 2;
		case ('P'): return P;
		case ('Q'): return Q;
		case ('R'): return R;
		default:    return -1;
		}
	}
		
	
	int not( int x ) {
		return 2-x;
	}
	
	int and (int x, int y) {
		return Math.min(x, y);
	}
	
	int or ( int x, int y ) {
		return Math.max(x, y);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
	
}

Measured memory_bytes: 12000
n,C=gets.split.map &:to_i
table=$<.map{|l|l.split.map(&:to_i)}
d=C.times.map {[0]*(2*10**5+2)}
table.each{|s,t,c|
for k in (2*s-1)..(2*t)
  d[c-1][k]=1
end
}
d=d.transpose
m=0
d.each{|e|m=[e.inject(:+),m].max}
p m

Measured memory_bytes: 124436
#include <cstdio>
#include <algorithm>
#define mp(x,y) make_pair(x,y)
#define ft first
#define sd second
#define rep(i,l,r) for (int i=l;i<=r;++i)
#define P pair<int ,int >
using namespace std;
const int N =2e5+10;
void read(int &x)
{
	x=0;
	char ch=getchar();int f=1;
	while (ch<'0'||ch>'9') ch=='-'?f=-1:0,ch=getchar();
	while ('0'<=ch&&ch<='9') x=x*10+ch-'0',ch=getchar();
	x*=f;
}
int n,bo[N],tot,m,a[N],top,v[233],l[N][20],r[N][20],f[1<<20],g[1<<20],cnt,tmp;
P b[N<<1];
void _mx(int &x,int y)
{
	x=max(x,y);
}

void _mn(int &x,int y)
{
	x=min(x,y);
}

int main()
{
	read(n);read(m);
	rep(i,1,n) read(a[i]);
	for (;v[top++]=m;m>>=1);
	rep(i,0,top) 
	{
		int lst=1;
		rep(j,2,n) if (a[j]-a[j-1]>v[i]) 
		{
			rep(k,lst,j-1) l[k][i]=lst,r[k][i]=j-1;
			lst=j;
		}
		rep(k,lst,n) l[k][i]=lst,r[k][i]=n;
	}
	tot=1<<top;--tot;rep(i,0,tot) g[i]=n+1;
	rep(i,0,tot) rep(j,0,top) 
	if (!(i&1<<j)) _mx(f[i|1<<j] ,r[f[i]+1][j]),_mn(g[i|1<<j] ,l[g[i]-1][j]);
	rep(i,0,tot) if (!(i&1)) b[++cnt]=mp(g[i],i);
	rep(i,1,n) b[++cnt]=mp(r[i][0]+1,(1<<top)+i);
	sort(b+1,b+1+cnt);tmp=-1;
	rep(i,1,cnt) if (b[i].sd>(1<<top))
	{
		b[i].sd-=(1<<top);
		if (tmp>=l[b[i].sd][0]-1) bo[b[i].sd]=1;
	}else _mx(tmp,f[((1<<top)-2)^b[i].sd]);
	rep(i,1,n) printf("%s\n",bo[i]?"Possible":"Impossible");
	return 0;
}

Measured memory_bytes: 45696
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <math.h>
#include <cstdlib>
#include <cctype>
#include <random>

using namespace std;

int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  int max_a = -1;

  for (int i=0; i<3; i++) {
    max_a = max(max_a, a[i]);
  }

  cout << a[0]+a[1]+a[2]-max_a << endl;




  return 0;
}


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

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// Type / Class / Struct Definitions:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;

// Global Variables:

// Prototype Declarations:
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;

    long double ans;
    // ans = sqrt(a * a + b * b - 2.0 * a * b * (long double)cos(((h * 60.0 - m * 11.0) * M_PI / 720.0 * 180.0)));
    ans = sqrt(a * a + b * b - 2.0 * a * b * cos(((h * 60 + m) * 0.5 - m * 6.0) * M_PI / 180.0));
    setpre(20);
    cout << ans << endl;
    return 0;
}
// ===========================================

// Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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;
}


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

int main() {
  int x, y;
  while (cin >> x >> y, x | y) {
    if (x < y) {
      cout << x << " " << y << endl;
    } else {
      cout << y << " " << x << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

struct Data{
    int a, b, c, d;
};
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	int cnt = 0;
	while (cin >> n) {
		if (n == 0) break;
		if (cnt) cout << endl;
		int c[4];
		cin >> c[0] >> c[1] >> c[2] >> c[3];
        
        int min_mai=1e9;
        Data ans;
        int t = c[0]+c[1]+c[2]+c[3];
		bool judge = false;
		for (int i = 0; i <= c[0]; ++i) {
			for (int j = 0; j <= c[1]; ++j) {
				for (int k = 0; k <= c[2]; ++k) {
					for (int l = 0; l <= c[3]; ++l) {
						int sum = 10 * i + 50 * j + 100 * k + 500 * l;
						if (sum < n) continue;
                        
                        int cnt=t-(i+j+k+l);
						sum = sum - n;

						if (l == 0) {
                            cnt += sum/500;
							sum %= 500;
                            
						}

						if (k == 0 ) {
                            cnt += sum/100;
							sum %= 100;
						}

						if (j == 0 ) {
                            cnt += sum/50;
							sum %= 50;
						}
						if (i == 0 ) {
                            cnt += sum/10;
							sum %= 10;
						}
                        
                        if(sum == 0 &&min_mai>cnt){
                            min_mai = cnt;
                            ans = {i, j, k, l};
                        }
                    }
				}
				
			}
		}
        
        if(ans.a!=0){
            cout << 10 << " " << ans.a << endl;
        }
        if(ans.b!=0){
            cout << 50 << " " << ans.b << endl; 
        }
        if(ans.c!=0){
            cout << 100 << " " << ans.c << endl;
        }
        if(ans.d!=0){
            cout << 500 << " " << ans.d << endl;
        }
        
		cnt++;
	}
	return 0;

}


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

def prime_factor(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table

res = prime_factor(N)

result = 10 ** 10
for i in range(1, N+1):
    if N%i == 0:
        result = min(result, max(len(str(i)), len(str(N//i))))
    if i*i > N:
        break


print(result)

Measured memory_bytes: 39408
#include<stdio.h>
#include<stdlib.h>
int main(void){
  int n,m,i,p=0;
  int a[10000];
  scanf("%d%d", &n, &m);
  for(i=0;i<m;i++){
    scanf("%d", &a[i]);
    p+=a[i];
  }
  if(p>n){
    printf("-1");
  }
  else{
    printf("%d", n-p);
  }
  return 0;
}
    
  


Measured memory_bytes: 1764
#include <bits/stdc++.h>
const int N = 100050;
#define ll long long
using namespace std;
int gi(){
  char ch=getchar(); int x=0,q=0;
  while(ch<'0' || ch>'9') (ch=='-'?q=1:0),ch=getchar();
  while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
  return q?(-x):x;
}
int a[N],n;
ll s[N],ans=1e18,w;
inline void work(){
  w=0;
  for (int i=1; i<=n; ++i){
    s[i]=s[i-1]+a[i];
    if (s[i-1]<0){
      if (s[i]<=0)
	w+=1-s[i],s[i]=1;
    }
    else{
      if (s[i]>=0)
	w+=s[i]+1,s[i]=-1;
    }
  }
  ans=min(ans,w);
  return;
}
int main(){
  cin>>n;
  for (int i=1; i<=n; ++i)
    a[i]=gi();
  s[0]=1,--a[1],work(),++a[1];
  s[0]=-1,++a[1],work();
  cout<<ans;
  return 0;
}


Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static int N;
    static long[] Al, Bl;

    static long Dfs(int i, long sum)
    {
        if (i == N) return sum;

        var p1 = (Al[i] > Bl[i]) ? Bl[i] : Al[i];
        sum += p1;
        Bl[i] -= p1;
        var p2 = (Al[i + 1] > Bl[i]) ? Bl[i] : Al[i + 1];
        sum += p2;
        Al[i + 1] -= p2;
        sum = Dfs(i + 1, sum);
        return sum;
    }

    static void Main(string[] args)
    {
        N = int.Parse(Console.ReadLine());
        Al = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        Bl = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        Console.WriteLine(Dfs(0, 0));
    }
}


Measured memory_bytes: 40372
#include <bits/stdc++.h>
    using namespace std;
    #define rep(i,n) for( int i = 0 ; i < n ; i++ )
    typedef long long ll ;
    int main() {
      int A[33] ;
      A[1] = 1 ;
      A[2] = 1 ;
      A[3] = 1 ;
      A[4] = 2 ;
      A[5] = 1 ;
      A[6] = 2 ;
      A[7] = 1 ;
      A[8] = 5 ;
      A[9] = 2 ;
      A[10] = 2 ;
      A[11] = 1 ;
      A[12] = 5 ;
      A[13] = 1 ;
      A[14] = 2 ;
      A[15] = 1 ;
      A[16] = 14 ;
      A[17] = 1 ;
      A[18] = 5 ;
      A[19] = 1 ;
      A[20] = 5 ;
      A[21] = 2 ;
      A[22] = 2 ;
      A[23] = 1 ;
      A[24] = 15 ;
      A[25] = 2;
      A[26] = 2 ;
      A[27] = 5 ;
      A[28] = 4 ;
      A[29] = 1 ;
      A[30] = 4 ;
      A[31] = 1 ;
      A[32] = 51 ;
      int B ;
      cin >> B ;
      cout << A[B] << endl;
    }

Measured memory_bytes: 256
//om nama sivaya
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define pb push_back
using namespace std;
void solve(){
   int n;
   cin>>n;
   ll a[n],co=0;
   for(int i=0;i<n;i++)cin>>a[i];
   sort(a,a+n);
   for(int i=0;i<n;i++){
       for(int j=i+1;j<n;j++){
           for(int k=j+1;k<n;k++){
               if(a[i]+a[j]>a[k] && a[i]!=a[j] && a[j]!=a[k] && a[k]!=a[i])co++;
           }
       }
   }
   cout<<co<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tt=1;
    //cin>>tt;
    while(tt--){
        solve();
    }
}


Measured memory_bytes: 3644
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

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<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> ds(N);
  int sum = 0;
  F0R(i, N) {
    cin >> ds[i];
    sum += ds[i];
  }
  int result = 0;
  F0R(i, N) {
    result += ds[i] * (sum - ds[i]);
  }
  cout << (result / 2);
}
#endif


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		String[] Slist = S.split("");
		String[] Tlist = T.split("");
		int countNum = 0;

		for(int i = 0; i <= 2 ; i++) {
			if(Slist[i].equals(Tlist[i])) {
				countNum++;
			}
		}

		System.out.println(countNum);
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll a[100009],b,c,d,n,mn=1e10,k,dp[100009];
int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    dp[0]=0;
    for(int i=1;i<n;i++)
    {
        dp[i] = 1e18;
        for(int j=i-1;j>=max(0ll,i-k);j--)
        {
            dp[i] = min(dp[i],abs(a[i]-a[j])+dp[j]);
        }
    }
    cout<<dp[n-1]<<endl;
}


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

int n;
std::vector<int> A;

bool constructible(int, int);

int main()
{
	scanf("%d", &n);
	A.resize(n);
	for (auto& e: A) scanf("%d", &e);
	int q;
	scanf("%d", &q);
	for (int i{}; i < q; i++)
	{
		int m;
		scanf("%d", &m);
		if (constructible(0, m)) puts("yes");
		else puts("no");
	}

	return 0;
}

bool constructible(int index, int rest)
{
	if (rest == 0) return true;
	if (index == n) return false;
	return constructible(index + 1, rest - A[index]) || constructible(index + 1, rest);
}


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

vector<int> f, uf;

int find(int x) { return uf[x] < 0 ? x : uf[x] = find(uf[x]); }
void merge(int x, int y) {
  int xr = find(x), yr = find(y);
  if (xr == yr) return;
  uf[yr] += uf[xr];
  uf[xr] = yr;
}
int value(int x) { return uf[x] < 0 ? -uf[x] : value(uf[x]); }

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  f.resize(n + 1, 0);
  uf.resize(n + 1, -1);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    f[a]++;
    f[b]++;
    merge(a, b);
  }
  for (int i = 0; i < k; i++) {
    int a, b;
    cin >> a >> b;
    if (find(a) == find(b)) {
      f[a]++;
      f[b]++;
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << value(i) - f[i] - 1 << " ";
  }
  cout << endl;
  return 0;
}


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

int main() {
 int n;
 cin >> n;
 set<int> s;
 rep(i,n) {
     int d;
     cin >> d;
     s.insert(d);
 }

 int ans=0;
 for(auto x:s){
     ans++;
 }
 cout << ans << endl;
}

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

const int NMAX = 50;
char A[NMAX][NMAX];
char B[NMAX][NMAX];

int main() {
  int N, M;
  scanf("%d%d", &N, &M);

  for (int y = 0; y < N; y++) {
    for (int x = 0; x < N; x++) {
      cin >> A[y][x];
    }
  }
  for (int y = 0; y < M; y++) {
    for (int x = 0; x < M; x++) {
      cin >> B[y][x];
    }
  }

  bool exist = false;
  for (int dy = 0; dy < N; dy++) {
    for (int dx = 0; dx < N; dx++) {
      // テンプレート画像が収まらない場合、判定を行わない
      if (dy + M - 1 >= N || dx + M - 1 >= N) continue;

      bool match = true;
      for (int y = 0; y < M; y++) {
        for (int x = 0; x < M; x++) {
          if (A[dy + y][dx + x] != B[y][x]) match = false;
        }
      }
      if (match) exist = true;
    }
  }

  if (exist) {
    printf("Yes");
  } else {
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int D; cin >> D; 
	int C[30] = {}; 
	for(int i = 1; i <= 26; i++) cin >> C[i]; 
	int S[370][30] = {}; 
	for(int i = 1; i <= D; i++){
		for(int j = 1; j <= 26; j++){
			cin >> S[i][j]; 
		}
	}
	int ans[370] = {}; 
	int L[30] = {}; 
	for(int i = 1; i < D; i+= 2){
		int E[700] = {}; 
		for(int j = 1; j <= 676; j++){
			int p = (j - 1) % 26 + 1; // i日目
			int q = (j - 1) / 26 + 1; // i+1日目
			int M[30] = {}; 
			for(int k = 1; k <= 26; k++){
				M[k] = L[k]; 
			}
			E[j] += S[i][p] + C[p] * (i - M[p]) * min(365-i, 10); 
			M[p] = i; 
			E[j] += S[i+1][q] + C[q] * (i + 1 - M[q]) * min(365-i, 10);
		}
		int a = 0; int mx = -1145141919; 
		for(int j = 1; j <= 676; j++){
			if(E[j] > mx){
				a = j; mx = E[j]; 
			}
		}
		ans[i] = (a-1) % 26 + 1; ans[i+1] = (a-1) / 26 + 1; 
		L[(a-1) % 26 + 1] = i; L[(a-1) / 26 + 1] = i + 1; 
	}
	for(int i = D; i <= D; i++){
		int E[30] = {}; 
		for(int j = 1; j <= 26; j++){
			E[j] = S[i][j] + C[j] * (i - L[j]); 
		}
		int a = 0; int mx = -1145141919; 
		for(int j = 1; j <= 26; j++){
			if(E[j] > mx){
				a = j; mx = E[j]; 
			}
		}
		ans[i] = a; L[a] = i; 
	}
	for(int i = 1; i <= D; i++) cout << ans[i] << endl; 
}

Measured memory_bytes: 3692
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn criterion(k: usize, i: usize, a: &Vec<usize>) -> bool {
    if i == 0 {
        return true;
    }
    if i == a.len() + 1 {
        return false;
    }
    let mut dp = vec![false; k];
    dp[0] = true;
    for j in 0..a.len() {
        if i - 1 == j {
            continue;
        }
        for ki in (0..k).rev() {
            if ki >= a[j] && dp[ki - a[j]] {
                dp[ki] = true;
            }
            if dp[ki] && ki >= k - a[i - 1] {
                return false;
            }
        }
    }
    // println!("{:?}", (i, dp));
    true
}

fn main() {
    let v: Vec<usize> = read_vec();
    let (n, k) = (v[0], v[1]);
    let mut a = read_vec::<usize>();
    a.sort();
    let a = a.into_iter().take_while(|&num| num < k).collect::<Vec<_>>();
    // println!("{:?}", &a);

    let mut lb = 0;
    let mut ub = a.len() + 1;
    while ub - lb > 1 {
        let mid = (ub + lb) / 2;
        if criterion(k, mid, &a) {
            lb = mid;
        } else {
            ub = mid;
        }
    }
    println!("{}", lb);
}


Measured memory_bytes: 4352
#include<stdio.h>

int main(){
  int A, B, C, K;
  scanf("%d %d %d", &A, &B, &C);
  scanf("%d", &K);
  
  for (int i = 0; i < K; i++){
    if(A >= B && A >= C){
      A *= 2;
    } else if(B >= A && B >= C){
      B *= 2;
    } else {
      C *= 2;
    }
  }
  
  printf("%d\n", A + B + C);
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n)for(ll i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll>P;

ll X[40], Y[40];
ll len[2];
P h[2][15000000];
void dfs(ll idx, ll s, ll g, ll x, ll y) {
	if (s == g) {
		h[idx][len[idx]++] = P(x, y);
		return;
	}
	dfs(idx, s + 1, g, x + X[s], y + Y[s]);
	dfs(idx, s + 1, g, x - X[s], y - Y[s]);
	dfs(idx, s + 1, g, x, y);
}
int main() {
	ll n, d; scanf("%lld%lld", &n, &d);
	rep(i, n)scanf("%lld%lld", &X[i], &Y[i]);
	dfs(0, 0, n / 2, 0, 0);
	dfs(1, n / 2, n, 0, 0);
	sort(h[0], h[0] + len[0], greater<>());
	sort(h[1], h[1] + len[1]);
	ll s = 0, t = 0;
	deque<P>que;
	ll Max = LLONG_MIN;
	rep(i, len[0]) {
		for (; t < len[1] && h[1][t].first <= d - h[0][i].first; t++) {
			while (!que.empty() && que.back().second < h[1][t].second)
				que.pop_back();
			que.push_back(h[1][t]);
		}
		for (; s < len[1] && h[1][s].first < -d - h[0][i].first; s++) {
			if (!que.empty() && que.front() == h[1][s])que.pop_front();
		}
		if (!que.empty())
			Max = max(Max, h[0][i].second + que.front().second);
	}
	printf("%lld\n", Max);
}

Measured memory_bytes: 451628
#include<stdio.h>
int main(){
  int i,n,max=0,sum=0;
  scanf("%d",&n);
  int p[n+1];
  for(i=0;i<n;i++){
    scanf("%d",&p[i]);
    if(max<p[i]){
      sum+=max;
      max=p[i];
    }
    else
      sum+=p[i];
  }
  sum+=max/2;
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES

#include<iostream>
#include<math.h>
#include <iomanip>

using namespace std;



int main() {
	double a,b,h,m;
	
	cin >> a >> b >> h >> m;

	double hthieta, mthieta, l;

	mthieta = M_PI * m / 30.0;
	hthieta = M_PI * h / 6.0 + mthieta / 12.0;

	l = sqrt(a * a + b * b - 2 * a * b * cos(mthieta - hthieta));

	cout << fixed << setprecision(20) << l << endl;
	


	return 0;
}


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

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi std::vector<int>
#define vvi std::vector<std::vector<int> >
#define vpi std::vector<pi >
#define pi std::pair<int,int>
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (int var = (from); var <= ((int)(to)); var++)
#define DOWNTO(var, from, to) for (int var = (from); var >= ((int)(to)); var--)
#define FOR(var, to)		  UPTO(var, 0, (to)-1)
#define DOWN(var, from)	   DOWNTO(var, (from)-1, 0)

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

static const int MOD = 1000000007;
static const int INF = ((1<<30)-1);
static const s64 LINF = ((1LL << 62)-1);

struct Comb {
	std::vector<std::vector<s64> > a;
	Comb(int n) { // O(n^2)
		a.resize(n+1);
		FOR(i,n+1) {
			a[i].resize(i+1, 1);
			UPTO(j,1,i-1) a[i][j] = a[i-1][j] + a[i-1][j];
		}
	}
	s64 ncr(int n, int r) {
		assert(n >= 0);
		assert(n <= (int)a.size());
		assert(r >= 0);
		assert(r <= n);
		return a[n][r];
	}
};

#define gc(c) (c)=getchar()
int ri() {
	int c,s=0,r=0;
	for(;;){gc(c);if(c=='-'){s=1;break;}if(c>='0'&&c<='9'){r=c-'0';break;}}
	for(;;){gc(c);if(c<'0'||c>'9')break;r*=10;r+=c-'0';}
	if(s)r=-r;
	return r;
}
s64 rs64() {
	s64 r;
	int c,s;
	for(;;){gc(c);if(c=='-'){s=1;break;}if(c>='0'&&c<='9'){r=c-'0';break;}}
	for(;;){gc(c);if(c<'0'||c>'9')break;r*=10;r+=c-'0';}
	if(s)r=-r;
	return r;
}

int int_less(const void *a, const void *b) {
	return (*(const int*)a - *(const int*)b);
}
int int_greater(const void *a, const void *b) {
	return (*(const int*)b - *(const int*)a);
}
std::string operator*(const std::string &s, int n){ std::string res; FOR(i,n) res += s; return res; }

template<class T> std::ostream& operator<<(std::ostream& os, std::vector<T> a) { for (auto i : a) os << i << " "; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, std::set<T> a) { for (auto i : a) os << i << " "; return os; }
template<class A, class B> std::ostream& operator<<(std::ostream&os, std::pair<A,B> a) { os << a.fi << "," << a.se; return os; }


int main() {
	int a[5];
	FOR(i,5) a[i] = ri();
	int min = INF;
	FOR(i,5) {
		if (a[i] % 10 && min > a[i] % 10) min = a[i] % 10;
		if (a[i]%10) a[i] -= a[i] % 10 - 10;
	}
	if (min == INF) min = 10;
	std::cout << a[0] + a[1] + a[2] + a[3] + a[4]  - (10 - min) << std::endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char a , b;
int n, countor = 0;
int main(){
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> b;
        if(b!=a){
            countor++;
            a = b;
        }
    }
    cout << countor;
    return 0;
}

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

int main()
{
  long long n;
  scanf("%lld", &n);
  long long od = 1;
  for (long long i = 0; i < n; ++i)
  {
    long long a;
    scanf("%lld", &a);
    od *= 2 - (a & 1);
  }
  printf("%lld\n", (long long)std::pow(3, n) - od);
  return 0;
}

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

int main() {
    int n;cin >>n;
    vector <int> num(n);
    for (int i=0;i<n;++i) cin >> num[i];
    int ans=0;
    int j=0;
    while(true){
        if (num[j]%2 == 1) break;
        else num[j] /= 2;
        ++j;
        if (j==n-1){
            j=0;
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e16;
#define int long long

const int MAX_N = 1010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, x; cin >> n >> x;
	VE t(n); rep(i, n)cin >> t[i];
	int ans = x;
	rep(i, n - 1) {
		ans += min(x, t[i + 1] - t[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << " " << y << " " << z << " " << endl;
    return 0;
}

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


Measured memory_bytes: 2100
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

int n,ans[N];
signed main(){
    FastIO;
    cin>>n;
    rep(x,1,100) rep(y,1,100) rep(z,1,100){
        ll sum=x*x+y*y+z*z+x*y+x*z+y*z;
        if(sum<=n) ans[sum]++;
    }
    rep(i,1,n){
        cout<<ans[i]<<'\n';
    }
    return 0;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define int int long long
#define MdataX 200005
#define FdataST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define MOD 1000000007
int n;
int handle(int x)
{
    return (x%MOD + MOD)%MOD;
}
int myCustPower(int a,int y)
{
    int pw = 1;
    while(y > 0)
    {
        if(y%2)
        {
            pw = handle(pw*a);
        }
        a = handle(a*a);
        y/=2;
    }
    return pw;
}
int MODInverse(int a, int m) 
{ 
    int m0 = m; 
    int y = 0, x = 1; 
  
    if (m == 1) 
      return 0; 
  
    while (a > 1) 
    { 
        // q is quotient 
        int q = a / m; 
        int t = m; 
  
        // m is remainder now, process same as 
        // Euclid's algo 
        m = a % m, a = t; 
        t = y; 
  
        // Update y and x 
        y = x - q * y; 
        x = t; 
    } 
  
    // Make x positive 
    if (x < 0) 
       x += m0; 
  
    return x; 
} 
void GO()
{
    cin>>n;
    if(n==1)
    {
        cout<<0<<endl;
        return;
    }
    if(n==2)
    {
        cout<<2<<endl;
        return;
    }

    int viv = myCustPower(10 , n );
    int t1 = myCustPower(9 , n );
    t1 = t1*2;
    t1 %= MOD;
    int t2 = myCustPower(8 , n );
    
    t1 = (-t1+t2 + MOD) % MOD;
    
    cout << (viv + t1 + MOD) % MOD;
}

int32_t main()
{
    FdataST
    #ifndef ONLINE_JUDGE
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
    #endif
    int testCase;
    // cin>>testCase;
    testCase=1;
    std::vector<int> tc;
    for (int i = 0; i < testCase; ++i)
    {
        tc.push_back(i);
    }
    for(auto test : tc)
    {
        GO(); // let's solve this case :)
    }
    
    return 0;
}

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

using namespace std;

int v[100007];
int main() {
int n; cin >> n;
vector<int> dp(n+1);
for(int i=1; i <= n; ++i) cin >> v[i];
dp[n] = 0;
dp[n-1] = abs(v[n] - v[n-1]);
for(int i = n-2; i >= 1; --i) {
dp[i] = min(dp[i+1] + abs(v[i+1] - v[i]), dp[i + 2] + abs(v[i+2] - v[i]));
}

cout << dp[1] << endl;
}

Measured memory_bytes: 1024
from math import floor,ceil,sqrt
import fractions
import collections
import itertools
from collections import deque
X=int(input())
"""
l=[]
for i in range(1,ceil(sqrt(X))+1):
    if X%i==0:
        l.append(i)
        l.append(X//i)
l=list(set(l))
l2=l
for i in range(len(l)):
    l2.append(-l[i])
#print(l2)
l2.sort()
if len(l)!=0:
    for i in l2:
        x=X//i
        #print(i,x)
        n=(x-pow(i,4))/(pow(i,2)+1)
        #print(n)
        if (5*pow(i,4)+20*x)>=0:
            if sqrt((5*pow(i,4)+20*x)).is_integer()==True:
                #print(x,i)
                m=int(sqrt((5*pow(i,4)+20*x)))
                if (-5*i*i+m)%10==0:
                    y=(-5*i*i+m)//10
                    #print(i,y)
                    if pow(i,2)+4*y>=0:
                        if sqrt(pow(i,2)+4*y).is_integer()==True:
                            z=int(sqrt(pow(i,2)+4*y))
                            if (-i+z)%2==0:
                                b=(-i+z)//2
                                a=i+b
                                print(a,b)
                                break
                            elif (-i - z) % 2 == 0:
                                b = (-i - z) // 2
                                a = i + b
                                print(a, b)
                                break
                elif (-5*i*i-m)%10==0:
                    y=(-5*i*i+m)//10
                    #print(i,y)
                    if pow(i,2)+4*y>=0:
                        if sqrt(pow(i,2)+4*y).is_integer()==True:
                            z=int(sqrt(pow(i,2)+4*y))
                            if (-i+z)%2==0:
                                b=(-i+z)//2
                                a=i+b
                                print(a,b)
                                break
                            elif (-i - z) % 2 == 0:
                                b = (-i - z) // 2
                                a = i + b
                                print(a, b)
                                break
"""
flag=0
#こんなことしなくても全探査で通る!
for i in range(-1000,1000):
    for j in range(-1000,1000):
        if pow(i,5)-pow(j,5)==X:
            print(i,j)
            flag=1
            break
    if flag==1:
        break










Measured memory_bytes: 73104
{-# OPTIONS_GHC -Wall -Werror #-}

import System.IO

solve :: Int -> Int -> Int -> Int
solve _ 0 s = s
solve d n s = solve d next (s + ds)
  where next = n - d
        ds = d * next * next

main :: IO ()
main = do
  end <- isEOF
  if end
     then return ()
     else do
       d <- (readLn :: IO Int)
       print $ solve d 600 0
       main

Measured memory_bytes: 4120
#!/usr/bin/env python3
import sys

def solve(N: int, S: str):

    a = ""
    ans = 0
    for i in range(N):
        a += S[i]
        while(len(a) > 0):
            if a in S[i+1:]:    
                ans = max(ans,len(a))
                break
            else:               
                a = a[1:]
    print(ans)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
# K,X = list(map(int, input().split()))

N = int(input())

alphabet = "abcdefghijklmnopqrstuvwxyz"

ans_dic = {}

for i in range(N):
    word = input()
    tmp = 0
    for s in word:
        tmp += 10**alphabet.index(s)

    if tmp in ans_dic:
        ans_dic[tmp] += 1
    else:
        ans_dic[tmp] = 1
ans = 0
for k, v in ans_dic.items():
    ans += v * (v-1) // 2
print(ans)


Measured memory_bytes: 15808
#include <bits/stdc++.h>
using namespace std;
int a[100009],n,m,win;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) if(a[i]%2==1) win=1;
	if(win==1) cout<<"first";
	else cout<<"second";
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class AAtCoderCrackers {
public:
	void solve(istream& in, ostream& out) {
	    int a, b;
	    in >> a >> b;
	    if(a % b == 0) out << 0 << endl;
	    else out << 1 << endl;
	}
};

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

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

int main() {
  string S;
  cin >> S;
  
  bitset<26> b;
  for (char c: S) b.set(c - 'a');

  for (int i = 0; i < 26; i++) {
    if (!b.test(i)) {
      cout << (char)('a' + i) << endl;
      return 0;
    }
  }
  
  cout << "None" << endl;
}


Measured memory_bytes: 3696
#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 srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) 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(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#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;


vll prime(ll n) {
    vll ans;
    vbool ls(n, true);
    ls[0] = false;
    ls[1] = false;
    srep(i, n+1, 2) {
        if (ls[i]) {
            ans.push_back(i);
            ll j = i*2;
            while (j <= n) {
                ls[j] = false;
                j += i;
            }
        }
    }
    return ans;
}

int main() {
    int n;
    cin >> n;
    vll p = prime(55555);
    vint ans;
    for (auto pi : p) {
        if (pi%5==1) {
            ans.push_back(pi);
            if (ans.size() >= n) break;
        }
    }
    
    rep(i, n) printf("%d%s", ans[i], i != n-1 ? " " : "\n");
    return 0;
}

Measured memory_bytes: 384