akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int               long long
#define endl              '\n'
#define ff                first
#define ss                second
#define mp                make_pair
#define pb                push_back
#define vii               vector<int> 
#define pii               pair<int,int>
#define vpii              vector< pii >
#define all(v)            v.begin(),v.end()
#define loop(i,s,e)       for(int i=s;i<e;i++)
#define eloop(i,s,e)       for(int i=s;i<=e;i++)
#define rloop(i,e,s)      for(int i=e;i>=s;i--)
#define mset(a,f)              memset(a,f,sizeof(a))
#define M                 1000000007
#define fastio            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define prvec(v)          loop(i_u_j,0,v.size())cout << v[i_u_j] <<" "; cout << endl;
#define prarr(arr,n)      loop(i_u_j,0,n)cout << arr[i_u_j] << " "; cout << endl;
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)


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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //
const int N = 3e5 + 7;
int n, m;
int arr[N], dp[N];
vector <vii > adj;

bool vis[N];

int get( int s ) 
{
      if(dp[s] != -1 ) return dp[s];
      vis[s] = 1;
      int ans = 0;
      for( auto i : adj[s] )
      {
            ans = max(ans, 1 + get( i ) );
      }
      return dp[s] = ans;
}

void solve()
{
      cin >> n >> m;
      adj.resize(n+1);
      loop(i,0,m)
      {
            int u, v;
            cin >> u >> v;
            adj[u].pb(v);
      }
      mset(dp,-1);
      int ans = 0;
      eloop(i,1,n)
      {
            if(!vis[i])
            {
                  ans = max(ans, get(i));
            }
      }
      cout << ans;
}

int32_t main() {
    fastio;

  
  int t = 1; 
  //cin>>t;
  
  while(t--) solve();
  
  


}


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //















Measured memory_bytes: 11648
#include <algorithm>
#include <cstdio>
using namespace std;
const int N=200005;
int l[N][20],r[N][20],dpl[1<<18],dpr[1<<18],f[N],x[N],a[N];
int main(){
	int n,v,m=0;
	scanf("%d%d",&n,&v);
	for (;1<<m<=v;m++);
	for (int i=m;i;i--,v>>=1) a[i]=v;
	for (int i=1;i<=n;i++) scanf("%d",&x[i]);
	for (int i=0;i<=m;i++) l[0][i]=0,r[n+1][i]=n+1;
	for (int i=1;i<=n;i++)
		for (int j=0;j<=m;j++)
		if (x[i]-x[i-1]<=a[j]) l[i][j]=l[i-1][j];
			else l[i][j]=i-1;
	for (int i=n;i;i--)
		for (int j=0;j<=m;j++)
		if (x[i+1]-x[i]<=a[j]) r[i][j]=r[i+1][j];
			else r[i][j]=i+1;
	int L=1<<m;
	for (int i=0;i<L;i++){
		dpl[i]=1;dpr[i]=n;
		for (int j=0;j<m;j++)
		if ((i>>j)&1){
			dpl[i]=max(dpl[i],r[dpl[i^1<<j]][j]);
			dpr[i]=min(dpr[i],l[dpr[i^1<<j]][j]);
		}
	}
	for (int i=0;i<L;i++)
		f[dpr[i]]=max(f[dpr[i]],dpl[(L-1)^i]);
	for (int i=1;i<=n;i++) f[i]=max(f[i],f[i-1]);
	for (int i=1;i<=n;i++)
		if (f[r[i][m]-1]>l[i][m]) printf("Possible\n");
			else printf("Impossible\n");
}

Measured memory_bytes: 37120
require 'pp'
H, W = gets.split.map &:to_i
s = []
H.times do
    s << gets.chomp.chars.map{|char| char == ?. ? true : false}
end

dp = Array.new(H+1) { Array.new(W+1, 100000) }
for i in 0..H-1
    for j in 0..W-1
        if [i, j] == [0, 0]
            dp[i][j] = s[0][0] ? 0 : 1
        else
            prevs = [[dp[i-1][j], [i-1, j]], [dp[i][j-1], [i, j-1]]]
            dp[i][j] = prevs.min[0]
            if !s[i][j] && !prevs.select{|prev| prev[0] == dp[i][j]}.inject(false){|res, prev| res || (s[i][j] == s[prev[1][0]][prev[1][1]])}
                dp[i][j] += 1
            end
        end
    end
end
p dp[H-1][W-1]

Measured memory_bytes: 2556
class Dictionary
  DNA = [''] + %w(A C G T)

  def initialize n
    @size = 100000
    @container = Array.new(@size)
    @ret = []
  end
  attr_accessor :ret

  def exec command, str = ''
    case command
    when 'insert' then insert str
    when 'find'   then @ret << (find?(str) ? 'yes' : 'no')
    else raise '??????'
    end
  end

  #private

  def insert str
    #puts "#{str} : #{hash(str)}"
    if @container[hash(str)].nil?
      @container[hash(str)] = LinkList.new str
    else
      group = @container[hash(str)]
      found = group.has? str
      group.insert(str) unless found
    end
  end

  def find? str
    linked_list = @container[hash(str)]
    return false if linked_list.nil?

    linked_list.has?(str)
  end

  def hash str

    return str.hash % @size
    # ?¶??´???´???????£? (????????????)
    # AAA ??? TTT -> 4?????° -> 10?????°???????????????
    #base = DNA.size
    #size = str.size
    #sum = 0
    #str.chars.each.with_index {|c, index|
    #  # ????????????4?????°??§??¨?????????
    #  n = get_dna_index c
    #  # ?????????????????????10?????°?????????
    #  # (??? ** ??????????????????) * ???
    #  # ?????????????????????10?????°???????????¨????¶????
    #  sum += (base ** (size - index)) * n
    #}

    #sum % @size
  end

  def get_dna_index char
    DNA.index char
  end

  class LinkList

    def initialize first_value
      @first = Node.new first_value, nil
    end

    def insert key
      new_node = Node.new key, @first
      @first = new_node
    end

    def has? key
      current = @first
      until current.nil?
        if current.key == key
          return true
        else
          current = current.next
        end
      end
      false
    end

    # ????????????????????¨?????¢?????????
    class Node
      def initialize key, next_node
        @key = key
        @next = next_node
      end
      attr_accessor :key, :next
    end
  end
end

def main size, commands
  dic = Dictionary.new size.to_i
  commands.each{|raw_command|
    command, str = raw_command.split ' '
    dic.exec(command, str)
  }
  puts dic.ret.join "\n"
  #dic.container.each {|pii| p pii}
end

array = STDIN.read.split(/\n/)
size = array.shift

main(size, array)

Measured memory_bytes: 175892
//AcFreak

#include<bits/stdc++.h>
#define lint long long int 
#define mp make_pair
#define pb push_back
#define f first
#define INF (lint )(1e9)
#define __ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define s second
#define endl '\n'
#define pii pair<int,int >
using namespace std;


int main()
{__
      
     string name;
     cin>>name;
     int i;
     int n=name.length();
     int flg=0;
     
     if(name[0]!='A')
     flg=1;
     int cc=0;
     int index;
     for(int i=2;i<n-1;i++)
     {
           if(name[i]=='C'){
               cc++;
               index=i;
           }
     }
     if(cc != 1)
     flg=1;
     
     /*for(i=0;i<n;i++)
     if(name[i]=='a' || name[i]=='c')
     flg=1;*/
     
     for(i=1;i<n;i++)
     {
           if(i !=index && name[i]<97 )
           {
                flg=1;
           }
         //  flg=1;
     }
     if(flg==1)
     cout<<"WA"<<endl;
     else
     cout<<"AC"<<endl;
}

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

int main()
{
  long long n,k;
  cin >>n>>k;
  vector<long long>a(n);
  for(long long i=0;i<n;i++){
    cin>>a[i];
  }
  map<long long,long long>mp;
  for(long long x:a){
    if(mp.count(x)){
      mp.at(x)++;
    }else{
      mp[x]=1;
    }
  }
  long long kazu=mp.size();
  if(kazu<k){
    cout<<0<<endl;;
    return 0;
  }
  long long cnt=0;
  vector<long long>b(kazu);
  auto begin=mp.begin(),end=mp.end();
  for(auto iter=begin; iter!=end;iter++){
    b[cnt]=iter->second;
    cnt++;
  }
  sort(b.rbegin(),b.rend());
  long long kotae=0;
  for(long long i=0;i<k;i++){
    kotae+=b[i];
  }
  cout<<n-kotae<<endl;
  return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll n,t,a,b,i,j,k;
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5]){
        cout<<"Yes";
    }
    else cout<<"No";
}


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

using namespace std;
#define LL long long
const int qq = 5005;
LL num[qq];
LL dp[qq];
int n;
LL k;

int main(){
	scanf("%d%lld", &n, &k);
	LL sum = 0;
	for(int i = 0; i < n; ++i)
		scanf("%lld", num + i), sum += num[i];
	if(sum < k){
		printf("%d\n", n);
		return 0;
	}
	sort(num, num + n, greater<int>());
	int res = 0;
	for(int i = 0; i < n; ++i){
		if(num[i] >= k){
			res++;
			continue;
		}
		int c = 0;
		for(int j = 0; j < n; ++j)
			if(j != i)	dp[c++] = num[j];
		bool flag = true;
		LL x = 0;
		LL p = k - num[i];
		for(int j = 0; j < c; ++j){
			x += dp[j];
			if(x >= p){
				if(x >= p && x < k)	flag = false;
				x -= dp[j];
			}
		}
		if(!flag)	res++;
	}
	printf("%d\n", n - res);
	return 0;
}


Measured memory_bytes: 384
N, M, K = [int(x) for x in input().split(" ")]

A = [int(x) for x in input().split(" ")]
B = [int(x) for x in input().split(" ")]
amax = 0
bmax = 0
total_max = 0
current_max = 0
current_weight = 0
for i in range(len(A)):
  if current_weight + A[i] <= K:
    current_weight += A[i]
    amax += 1
  else:
    break

for i in range(len(B)):
  if current_weight + B[i] <= K:
    current_weight += B[i]
    bmax += 1
  else:
    break

total_max = amax + bmax
current = total_max
for i in range(amax-1, -1, -1):
  current_weight -= A[i]
  amax -= 1
  for j in range(bmax, len(B)):
    if current_weight + B[j] <= K:
      current_weight += B[j]
      current += 1
      bmax += 1
    else:
      break
  if amax + bmax > total_max:
    total_max = amax + bmax

print(total_max)

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

int main(void) {
    int N;cin>>N;
    int A[2][N];
    for (int i = 0; i < N; i++) {
        cin>>A[0][i];
    }
    for (int i = 0; i < N; i++) {
        cin>>A[1][i];
    }
    // アメの最大値
    int ma = 0;

    for (int i = 0; i < N; i++) {
        // 回収できるアメの個数
        int cur = 0;
        for (int j = 0; j <= i; j++) {
            cur += A[0][j];
        }
        for (int k = i; k < N; k++) {
            cur += A[1][k];
        }
        if (ma < cur) ma = cur;
    }
    cout << ma << endl;
    return 0;
}

Measured memory_bytes: 888
def main():
    N = int(input())
    S = input()

    ans = S.count('R') * S.count('G') * S.count('B')

    for i in range(N):
        for j in range(i+1, N):
            k = j + j - i
            if k < N:
                if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
                    ans-=1
    print(ans)
main()

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


signed main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b && b != c) {
    cout << "Yes" << endl;
  }
  else if(a == c && b != c) {
    cout << "Yes" << endl;
  }
  else if(a != b && b == c) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import sys

s = input()

def check(str):
    l = 0
    r = len(str) - 1
    while l < r :
        if str[l] != str[r]:
            return False
        l += 1
        r -= 1
    return True

if check(s):
    l = 0
    r = (len(s) - 1) // 2
    if check(s[l:r]):
        l = (len(s) + 3) // 2 - 1
        if check(s[l:len(s)]):
            print("Yes")
            sys.exit()
print("No")


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

using namespace std;

int main()
{
  int n, k;
  cin >> n >> k;
  
  string s[n];
  for (int i = 0; i < n; ++i)
    cin >> s[i];
  
  sort(s, s + n);
  for (int i = 0; i < n; ++i)
    cout << s[i];
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
	int a;
	cin >> a;
	return a;
}

void inputArray(int *p,int a){
	rep(i,a){
		cin >> p[i];
	}
}

void inputVector(vector<int> *p,int a){
	rep(i,1){
		int input;
		cin >> input;
		p -> push_back(input);
	}
}

template <typename T>
void output(T a,int precision){
	if(precision > 0){
		cout << setprecision(precision) << a << "\n";
	}else{
		cout << a << "\n";
	}
}

int main(){
	//source
	int N=inputValue();
	string S;
	cin >> S;
	ll list[26]={};
	rep(i,N){
		list[(int)S[i]-(int)'a']++;
	}
	ll num=pow(10,9)+7;
	ll ans=1;
	rep(i,26){
		ans=ans*(list[i]+1)%num;
	}
	output(ans-1,0);
	return 0;
}


Measured memory_bytes: 512
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	int n = Integer.parseInt(kbd.nextLine());
	while(n>0){
	    solve();
	    n--;
	}
    }

    static void solve(){
	String s = kbd.nextLine();
	String ans = s.replaceAll("Hoshino", "Hoshina");
	System.out.println(ans);
    }
}

Measured memory_bytes: 17256
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


struct UF {
    int n, num;
    vector<int> r, p, s;
    UF(){}
    UF(int sz) : n(sz), num(sz), r(sz, 1), p(sz, 0), s(sz, 1){ iota(begin(p), end(p), 0LL); }
    int find(int x){
        return (x == p[x] ? x : p[x] = find(p[x]));
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
    void unite(int x, int y){
        x = find(x), y = find(y);
        if(x == y) return;
        if(r[x] < r[y]) swap(x, y);
        r[x] += r[y];
        p[y] = x;
        s[x] += s[y];
        num--;
    }
    int rank(int x){
        return r[find(x)];
    }
    int count() const{
        return num;
    }
    int size(int x){
        return s[find(x)];
    }
};


int N, M, K;
VI g[100010];
UF uf;
bool u[100010];
int ans[100010];


void dfs(int v, int p){
    u[v] = true;
    uf.unite(v, p);
    rep(i, 0, SZ(g[v])) if(!u[g[v][i]]) dfs(g[v][i], p);
}


signed main(){
    cin >> N >> M >> K;
    rep(i, 0, M){
        int A, B;
        cin >> A >> B;
        A--;
        B--;
        g[A].pb(B);
        g[B].pb(A);
    }

    uf = UF(N);
    rep(i, 0, N) if(!u[i]) dfs(i, i);

    rep(i, 0, N) ans[i] = uf.size(i)-1-SZ(g[i]);

    rep(i, 0, K){
        int C, D;
        cin >> C >> D;
        C--;
        D--;
        if(uf.same(C, D)) ans[C]--, ans[D]--;
    }

    rep(i, 0, N) cout << ans[i] << ' ';
    cout << endl;

    return 0;
}

Measured memory_bytes: 13184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9+7;
#define rep(i,n) for(int i = 0;i<n;i++)

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


	if(b-a >= (k-a%k)  || a%k == 0){
		cout << "OK\n";
	}else cout << "NG\n";


	return 0;
}

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

using namespace std;

int main()
{
    int n,k,x;
    cin>>n>>k;
    vector<int> h;
    for(int i=0;i<n;i++){
        cin>>x;
        h.push_back(x);
    }
    sort(h.begin(),h.end());
    reverse(h.begin(),h.end());
    if(n<=k)cout<<0;
    else{
        long long res=0;
        for(int i=k;i<n;i++){
            res+=h[i];
        }
        cout<<res;
    }
}


Measured memory_bytes: 1400
k=int(input())

fib=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(fib[k-1])

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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n, four = 0, two = 0, one = 0;
  cin >> n;
  ll w[n];
  rep(i, n) {
    cin >> w[i];
    if (w[i] % 4 == 0) four++;
    else if (w[i] % 2 == 0) two++;
    else one++;
  }
  if (two) {
    if (one <= four) cout << "Yes" << endl;
    else cout << "No" << endl;
  } else {
    if (one <= four + 1) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 1024
/* ITP1_8_D */
import java.io.*;

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

      String s = br.readLine();
      String p = br.readLine();
      if(s.length() < p.length()) return;
      boolean judge = false;

      char[] s_char = s.toCharArray();

      for(int i = 0; i < s.length(); i++){
        if(s_char[i] == p.charAt(0)){
          if( ((i + 1) + p.length()) > s.length() ){
            sb.append(s.substring(i, s.length()));
            sb.append(s.substring(0, (p.length() - (s.length() - i))));
          }else {
            sb.append(s.substring(i, i + p.length()));
          }
          if(p.equals(sb.toString())) judge = true;
          //System.out.println("i:" + i + " p:" + p + " sb:" + sb + " judge:" + judge);
          sb.delete(0, sb.length());
        }
      }

      if(judge)
        System.out.println("Yes");
      else
        System.out.println("No");

    }catch(Exception e){
      System.out.println(e);
    }
  }
}

Measured memory_bytes: 24376
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
#define MPlus(x,y) {x=(x+y)%M;}
#define MSub(x,y) {x=(x-y+M)%M;}
#define MMul(x,y) {x=(x*y)%M;}


bool ans=false;
int h,w;
char a[10][10];

void f(int x,int y,bool b[10][10]){

  if(x==w-1&&y==h-1){
    bool flag=true;
    rep(i,h){
      rep(j,w){
        if(a[i][j]=='#'&&!b[i][j])flag=false;
      }
    }
    ans|=flag;
    return;
  }

  if(x+1<w&&a[y][x+1]=='#'){
    b[y][x+1]=true;
    f(x+1,y,b);
    b[y][x+1]=false;
  }
  if(y+1<h&&a[y+1][x]=='#'){
    b[y+1][x]=true;
    f(x,y+1,b);
    b[y+1][x]=false;
  }
  
}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  
  cin>>h>>w;
  rep(i,h){
    cin>>a[i];
  }

  bool b[10][10]={};
  b[0][0]=true;
  f(0,0,b);


  if(ans){
    cout<<"Possible"<<endl;
  }else{
    cout<<"Impossible"<<endl;
  }



}

Measured memory_bytes: 256
<?php
$a=explode(' ',trim(fgets(STDIN)));
for($i=0;$i<2;$i++){
	for($j=$i+1;$j<3;$j++){
		if($a[$j]<$a[$i]){
			$t=$a[$i];
			$a[$i]=$a[$j];
			$a[$j]=$t;
		}
	}
}
print "$a[0] $a[1] $a[2]\n";

Measured memory_bytes: 15388
from collections import deque
N=int(input())
G=[[] for _ in range(N)]
for i in range(N-1):
	u, v, w = map(int, input().split())
	u,v=u-1,v-1
	G[u].append([v,w])
	G[v].append([u,w])
#print(G) #[[[1, 2]], [[0, 2], [2, 1]], [[1, 1]]]
color=[-1]*N
que=deque([0])
color[0]=0

while que:#dfs
	p=que.popleft()#直近で追加したグラフの頂点を取得
	for q, W in G[p]:#結合しているグラフの頂点を参照
		if color[q]==-1:#塗られていないなら
			color[q]=(color[p]+W)%2
			que.append(q)
print(*color, sep="\n")

Measured memory_bytes: 108936
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
#define reps(i, S, E) for (ll i = (S); i <= (E); i++)
#define rep(i, N) reps(i, 0, N-1)
#define deps(i, E, S) for (ll i = (E); i >= (S); i--)
#define dep(i, N) deps(i, N-1, 0)
const ll MOD = 1000000007;
const ll INF = 1LL << 60;


//AtCoder Beginner Contest 134 - A B
int main() {
	ll r;
	scanf("%lld", &r);

	ll result = 3 * r * r;

	printf("%lld\n", result);
}


//AtCoder Beginner Contest 135 - B
/*
int main() {
	ll N;
	scanf("%lld", &N);
	vector<ll> p(N);
	for (ll i = 0; i < N; i++) {
		scanf("%lld", &p[i]);
	}

	ll err = 0;
	rep(i, N) {
		if (p[i] != i + 1) {
			err++;
		}
	}

	if (err <= 2) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
}
*/

//AtCoder Beginner Contest 135 - A
/*
int main() {
	ll A;
	scanf("%lld", &A);
	ll B;
	scanf("%lld", &B);

	if (abs(A - B) % 2 == 1) {
		printf("IMPOSSIBLE\n");
		return 0;
	}

	ll ans = abs(A - B) / 2;
	ll result = min(A, B) + ans;

	printf("%lld\n", result);
}
*/

//AtCoder Beginner Contest 126 - B
/*
int main() {
	char s[101010];
	scanf("%s", s);
	ll len = strlen(s);

	ll front = (s[0] - '0') * 10 + (s[1] - '0');
	ll back = (s[2] - '0') * 10 + (s[3] - '0');

	if ((front > 12 && back > 12) || (front > 12 && back == 0) || (back > 12 && front == 0) || (back == 0 && front == 0)) {
		printf("NA\n");
	}
	else if (front > 12 || front == 0) {
		printf("YYMM\n");
	}
	else if (back > 12 || back == 0) {
		printf("MMYY\n");
	}
	else {
		printf("AMBIGUOUS\n");
	}
}
*/

//AtCoder Beginner Contest 126 - A
/*
int main() {
	ll N;
	scanf("%lld", &N);
	ll K;
	scanf("%lld", &K);
	char s[101010];
	scanf("%s", s);
	ll len = strlen(s);

	s[K - 1] = s[K - 1] - 'A' + 'a';

	printf("%s\n", s);
}
*/

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define SZ(X) ((int64_t)((X).size()))
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
#define doublemax (std::numeric_limits<double>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);



vector<int> construct(int N) {
	int n;
	vector<int> p;
	for (n = 40; n>0; n--) {
		if (N >= (1LL << n) - 1)break;
	}
	for (int i = 1; i <= n; i++)
		p.push_back(i);
	N -= (1LL << n) - 1;
	for (int i = n - 1; i >= 0; i--) {
		if (N<1LL << i)continue;
		n++;
		p.insert(p.begin() + i, n);
		N -= 1LL << i;
	}
	return p;
}


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	auto p = construct(N);
	int S = p.size();
	rep(i, S)p.push_back(i + 1);

	cout << p.size() << endl;
	rep(i, p.size()) {
		if (i)cout << " ";
		cout << p[i];
	}

	return 0;
}

Measured memory_bytes: 256
s=input()
t=input()
set_s = {x for x in s}
set_t = {x for x in t}
if len(set_t-set_s)>0:
    print(-1)
else:
    n=len(s)
    letters='abcdefghijklmnopqrstuvwxyz'
    l=[[-1 for i in range(n)] for j in range(26)]
    for i in range(26):
        letter = letters[i]
        if s[-1]==letter:
            l[i][-1]=n-1
        for j in range(1,n):
            idx=n-1-j
            if s[idx]==letter:
                l[i][idx]=idx
            else:
                l[i][idx]=l[i][idx+1]
    cnt=1
    a=0
    for x in t:
        id = ord(x)-97
        if a>=n or l[id][a]==-1:
            cnt+=1
            a=0
            a=l[id][a]+1
        else:
            a=l[id][a]+1
    print((cnt-1)*n+a)

Measured memory_bytes: 119496
_, K = map(int, input().split())
S = input() + '2'

current_length = 1
sections = []  # (start_i, end_i)
current_section = (S[0], 1)

max_length = 0

k = 0


# def display_section(sections, current_section):
#     a = sections[:]
#     b = current_section[:]
#     a += b
#     s = ''
#     for section in a:
#         s += section[0] * section[1]
#     return s


for i in range(1, len(S)):
    # t = display_section(sections, [current_section, (S[i], 1)])
    # print(t)
    if S[i - 1] == S[i]:
        current_section = (S[i], current_section[1] + 1)
        current_length += 1
    else:
        if current_section[0] == '0':
            if len(sections) > 0 and sections[-1][0] == '1':
                pop = sections.pop(-1)
                sections.append((0, pop[1] + current_section[1]))
            else:
                sections.append(current_section)
            k += 1
            if k > K:
                current_length -= sections[0][1]
                sections.pop(0)
        else:
            sections.append(current_section)

        if current_length > max_length:
            max_length = current_length

        current_section = (S[i], 1)
        current_length += 1

print(max_length)


Measured memory_bytes: 5108
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <map>
#include <queue>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll mod = 1e9 + 7;

int main()
{
	ll n, a, b;
	cin >> n >> a >> b;
	vector<ll> x(n);
	rep(i, n)cin >> x[i];
	ll ans = 0;
	rep(i, n-1)
	{
		if ((x[i+1]-x[i])*a>b)
		{
			ans += b;
		}
		else
		{
			ans += (x[i + 1] - x[i])* a;
		}
	}
	co(ans);
	return 0;
}

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

typedef long long ll;
const ll MOD = 1e9+7;

// x^n % MOD
ll pow_MOD(ll x, ll n) {
    if (n == 0) return 1;
    if (n == 1) return x;

    ll ret = pow_MOD(x, n/2);
    if (n%2 == 0) {
        return (ret*ret) % MOD;
    } else {
        return (x * ((ret*ret)%MOD)) % MOD;
    }
}

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

    int H, W, A, B; cin >> H >> W >> A >> B;
    vector<ll> fact(H+W), inv_fact(H+W);
    fact[0] = fact[1] = 1;
    for (ll i = 2; i < H+W; i++) {
        fact[i] = (fact[i-1]*i) % MOD;
    }
    for (ll i = 0; i < H+W; i++) {
        inv_fact[i] = pow_MOD(fact[i], MOD-2);
    }

    ll ans = 0;
    for (int i = B; i < W; i++) {
        ll tmp = (((fact[i+H-A-1]*inv_fact[i])%MOD) * inv_fact[H-A-1])%MOD;
        tmp = (tmp * ((((fact[A+W-i-2]*inv_fact[A-1])%MOD) * inv_fact[W-i-1])%MOD))%MOD;
        ans = (ans + tmp) % MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <cmath>

#define mst(a,b)memset(a, b, sizeof(a))
#define repi(a,b)for(ll i = a; i < b; i++)
#define repj(a,b)for(ll j = a; j < b; j++)
#define pii pair<int,int>

#ifdef LOCAL
#define fre()freopen("in.txt","r",stdin)
#endif
#ifndef LOCAL
#define fre()
#endif

//static int x = []() {
//	std::ios::sync_with_stdio(false);
//	std::cin.tie(NULL);
//	return 0;
//}();

#define FASTIO
#ifdef FASTIO
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
//#define scanf abcabc
//#define printf abcabc
#endif
//#ifndef FASTIO
//#define cin abcabc
//#define cout abcabc
//#endif

typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;

using namespace std;


struct aa {
	string s;
	int sc, ind;
	bool operator<(const aa& rhs)const {
		if (s == rhs.s)return sc > rhs.sc;
		return s < rhs.s;
	}
}rifa[110];
int main() {
	int n; cin >> n;
	repi(0, n) {
		cin >> rifa[i].s >> rifa[i].sc;
		rifa[i].ind = i + 1;
	}
	sort(rifa, rifa + n);
	repi(0, n)cout << rifa[i].ind << endl;
	return 0;
}

Measured memory_bytes: 256
program atcoder
    implicit none
    integer :: i,n,ans
    integer,allocatable,dimension(:) :: a
    read*,n
    allocate(a(n))
    ans = 0
    read(*,*)(a(i),i=1,n)
    do i=1,n
        if(a(a(i))==i)then
            ans = ans + 1
        endif
    enddo
    write(*,'(I0)')ans/2
    stop 
contains
end program atcoder

Measured memory_bytes: 1152
gets
d = [gets, gets].map{|v| v.split(" ").map(&:to_f)}.transpose.map{|c| c.inject(:-).abs}
(1..4).each do |i|
  puts ((i == 4) ? d.max : d.map{|c| c**(i)}.inject(:+)**(1.0/i))
end

Measured memory_bytes: 8752
//edpc_b.cpp
//Sat Jan 12 15:12:27 2019

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

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

	int dp[n+1];
	dp[0] = 0;
	dp[1] = 0;
	for (int i=2;i<=n;i++){
		int temp = INTINF;
		for (int j=1;j<=min(k,i-1);j++){
			if (temp>dp[i-j]+abs(h[i]-h[i-j])){
				temp = dp[i-j]+abs(h[i]-h[i-j]);
			}
		}
		dp[i] = temp;
	}

	cout << dp[n] << endl;

//	for (int i=1;i<=n;i++){
//		cout << dp[i] << " ";
//	}
//	printf("\n");

}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
char c;
int main()
{ cin>>c;
  if(c=='1')
     cout<<'9';
  else if(c=='9')
     cout<<'1';
  else cout<<c;
  cin>>c;
  if(c=='1')
     cout<<'9';
  else if(c=='9')
     cout<<'1';
  else cout<<c;
  cin>>c;
  if(c=='1')
     cout<<'9';
  else if(c=='9')
     cout<<'1';
  else cout<<c;
  return 0;
}

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

bool right();

int main()
{
    if (right()) printf("Yes\n");
    else printf("No\n");

    return 0;
}

bool right()
{
    char s[16];
    int a, b;
    scanf("%d%d%s", &a, &b, s);
    if (s[a] != '-') return false;
    for (int i = 0; i < a + b + 1; i++)
        if ((s[i] < '0' || s[i] > '9') && i != a) return false;
    
    return true;
}

Measured memory_bytes: 256
while True:
    m, f, r = map(int, input().split())
    
    if m==-1 and f==-1 and r==-1 :
        break
    
    if m==-1 or f==-1:
        print('F')
        continue
    
    if 80<=m+f:
        print('A')
        continue
    
    if 65<=m+f<80:
        print('B')
        continue
    
    if 50<=m+f<65:
        print('C')
        continue
    
    if 30<=m+f<50:
        if 50<=r:
            print('C')
        else:
            print('D')
        continue
    
    if m+f<30:
        print('F')
        continue


Measured memory_bytes: 5596
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;
int main(void)
{
  int n;
  string s;
  cin>>s;
  n=s.size();
  if(s[n-1]=='s'){
    cout<<s<<"es";
  }
  else{
    cout<<s<<'s';
  }
  return 0;
}
  

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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
const double PI = acos(-1.0);

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

bool check(ll n, ll x) {
    if (x == 1) return false;
    while (n % x == 0) n /= x;
    if (n % x == 1) return true;
    return false;
}

void solve() {
    ll n;
    cin >> n;
    ll t = n - 1;
    set<ll> s;
    for (ll i = 1; i <= t / i; i++) {
        if (t % i == 0) {
            if (i != 1) s.insert(i);
            if (t / i != 1) s.insert(t / i);
        }
    }

    for (ll i = 1; i <= n / i; i++) {
        if (n % i == 0) {
            if (check(n, i)) s.insert(i);
            if (check(n, n / i)) s.insert(n / i);
        }
    }

    cout << s.size() << endl;
}

int main() {
	header();
	solve();
	return 0;
}


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

#ifdef BTK
#include<dvector.h>
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define DEBUG if(0)
#endif

#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

const string ok="Yes";
const string ng="No";

typedef vector<int> V;
typedef vector<V> VV;

int main(){
    LL N,M;
    cin>>N>>M;
    VV g(N);
    int f=1;
    V c(N,-1);
    REP(i,M){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    queue<int> que;
    que.push(0);
    c[0]=0;
    while(que.size()){
        int v=que.front();que.pop();
        //cout<<v<<endl;
        for(auto &u:g[v]){
            if(c[u]==c[v]){
                f=0;
                DEBUG cout<<v<<u<<" "<<c[v]<<c[u]<<endl;
                break;
            }
            else if(c[u]==-1){
                c[u]=1-c[v];
                DEBUG cout<<v<<u<<" "<<c[v]<<c[u]<<endl;
                
                que.push(u);
            }
        }
    }
    LL E=N*(N-1)/2;
    if(f){
        E=0;
        REP(i,N)E+=c[i];
        E=E*(N-E);
    }
    cout<<E-M<<endl;
    return 0;
}


Measured memory_bytes: 6272
N,M = map(int,input().split())

def solve(n,m):
  if n == 1 and m == 1:
    return 1
  elif n == 1:
    return m - 2
  elif m == 1:
    return n - 2
  else:
    return (n-2)*(m-2)
  
print(solve(N,M))
 

Measured memory_bytes: 9112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll d, n;
    cin >> d >> n;

    if(n == 100){
        n++;
    }
    printf("%lld\n", (ll)pow(100, d) * n);
    return 0;
}


Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include<bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(a, c) for (int(a) = 0; (a) < (c); (a)++) 
#define ll long long
#define vi vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int> 
#define pb push_back
#define str string
#define mod 998244353
#define pi 3.14159265
using namespace std;
int main()
{
    char c;
    cin >> c;
    ll l=int(c);
    if(l>=65 && l<=90)
    {
        cout << 'A' << endl;
    }
    else
    {
        cout << 'a' << endl;
    }
}

Measured memory_bytes: 3600
main = do
    [n,u] <- map read . words <$> getLine :: IO [Int]
    putStrLn . unwords . map show . head $
        [ [x, y, z] |
          x <- [0..n],
          y <- [0..n-x],
          let z = n-x-y,
          10000 * x + 5000 * y + 1000 * z == u
        ] ++ [replicate 3 (-1)]

Measured memory_bytes: 508
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

typedef string::const_iterator State;


string getop(State &begin){
	if(*begin=='*'){
		begin++;
		return "*";
	}
	else if(*begin=='+'){
		begin++;
		return "+";
	}else{
		begin++;
		begin++;
		return "->";
	}
}


bool mul(bool a,bool b){
	if(a&&b)return true;
	else return false;
}


bool add(bool a,bool b){
	if(!a&&!b)return false;
	else return true;
}


bool imp(bool a,bool b){
	if(a&&!b)return false;
	else return true;
}


bool exp(State &begin){
	if(isdigit(*begin)){
		bool num = *begin-'0';
		begin++;
		return num;
	}
	else if(*begin=='-'){
		begin++;
		return !exp(begin);
	}else if(*begin=='('){
		begin++;
		bool ll = exp(begin);
		string op = getop(begin);
		bool rr = exp(begin);
		begin++;
		
		if(op=="*")return mul(ll,rr);
		else if(op=="+")return add(ll,rr);
		else return imp(ll,rr);
	}
	
	assert(1);
	return 0;
}


bool check(string s){
	string left="",right="";
	bool f=false;
	rep(i,s.size()){
		if(s[i]=='=')f=true;
		else if(f)right+=s[i];
		else left+=s[i];
	}
	
	State bl = left.begin(),br = right.begin();
	bool l = exp(bl);
	bool r = exp(br);
	
	if(l==r)return true;
	else return false;
}


int main(){
	string s;
	while(cin>>s&&s!="#"){
		set<char> var;
		rep(i,s.size()){
			if(s[i]=='T')s[i]='1';
			if(s[i]=='F')s[i]='0';
		}
		rep(i,s.size()){
			if(isalpha(s[i])){
				var.insert(s[i]);
			}
		}
		
		
		bool f = false;
		int en = 1<<var.size();
		rep(i,en){
			map<char,int> mp;
			int num = i;
			for(auto &e:var){
				mp[e] = num%2;
				num/=2;
			}
			string t = s;
			rep(j,t.size()){
				if( isalpha(t[j]) ){
					t[j] = '0'+mp[t[j]];
				}
			}
			if(check(t)==false)f=true;
		}
		if(f)cout<<"NO"<<endl;
		else cout<<"YES"<<endl;
	}
}

Measured memory_bytes: 3320
n = int(input())
ans = n
for i in range(n+1):
  cc=0
  t=i
  while t>0:
    cc=cc+t%6
    t=t//6
  t=n-i
  while t>0:
    cc=cc+t%9
    t=t//9
  ans=min(ans, cc)
print(ans)

Measured memory_bytes: 3060
using System;

namespace debug
{
    class Program
    {
        static void Main(string[] args)
        {
            ProgramE a = new ProgramE();
            a.main();

        }
    }

    //
    class ProgramE
    {
        public void main()
        {
            string[] s = Console.ReadLine().Split(' ');
            long n = long.Parse(s[0]);
            long k = long.Parse(s[1]);
            long MOD = 1000000000 + 7;
            long[] ans = new long[k];
            //最大公約数が大きいほうから数えていく
            for(long i = k;i > 0;i--)
            {
                //答えを格納
                ans[i - 1] = modpow(k / i, n, MOD);

                long x = 2 * i;
                //これより大きい公約数をもつ場合は除く
                while(x <= k)
                {
                    ans[i - 1] = (ans[i - 1] - ans[x - 1]) % MOD;
                    x += i;
                }
            }

            long count = 0;
            for(int i = 0;i < k;i++)
            {
                count += ans[i] *(i + 1) % MOD;
                count %= MOD;
            }

            Console.WriteLine(count);
        }

        public long modpow(long a, long n, long mod)
        {
            if (n == 0)
                return 1;

            if (n % 2 == 0)
            {
                long temp = modpow(a, n / 2, mod);
                return temp * temp % mod;
            }

            return modpow(a, n - 1, mod) * a % mod;
        }
    }
}


Measured memory_bytes: 28244
import java.util.Scanner;


public class Main 
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		
		int[] r = new int[n];
		int[] f = new int[n];
		int[] v = new int[n];
		for(int i=0; i<n; i++)
		{
			int b = scanner.nextInt();
			r[i] = scanner.nextInt();
			f[i] = scanner.nextInt();
			v[i] = scanner.nextInt();
			
			r[i] =  (4*(b-1)  + r[i] - 1);
			f[i] = f[i]*2 - 1;
		}
		
		String[][]  s = new String[15][20];
		for(int i=0; i<15; i++)
		{
			for(int j=0; j<20; j++)
			{
				if(i%4 == 3)
				{
					s[i][j] = "#";
				}
				else if(j%2 == 0)
				{
					s[i][j] = " ";
				}
				else {
					s[i][j] = "0";
				}
			}
		}
			for(int i=0; i<15; i++)
			{
				for(int j=1; j<20; j+=2)
				{
					for(int k=0; k<n; k++)
					{
						if(r[k]==i && f[k]==j)
						{
							int in = Integer.parseInt(s[i][j])+v[k];
							if(in > 9)
							{
								in = 9;
							}
							s[i][j] = in+"";
						}
					}
			}
		}
		
		
		for(int i=0; i<15; i++)
		{
			for(int j=0; j<20; j++)
			{
				System.out.print(s[i][j]);
			}
			System.out.println("");
		}
	}
}

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

using namespace std;

int main() {
	string str;
	cin >> str;
	int a = 0, b = 0;
	for (int i = 0; i < 3; i++) {
		if (str[i] == 'A') {
			a++;
		} else {
			b++;
		}
	}
	if (a >= 1 && b >= 1) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}

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

int main(){
    long int N,ans=0;
    cin >> N;
    for(int i=1;i<=N;i++){
        if((i%3!=0)&&(i%5!=0)){
            ans=ans+i;
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 3624
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        a: u64, b: u64
    }

    println!("{}", if a % 2 == 0 || b % 2 == 0 {"No"} else {"Yes"});
}

Measured memory_bytes: 4476
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(),(c).end()
const ll mod=10e9+7;
ll ABS(ll a){return max(a,-a);}


int main(void){
    ll N,D,ans=0;
    cin>>N>>D;
    vector<vector<ll>> X(N, vector<ll>(D));
    rep(i,N){
        rep(j,D) cin>>X.at(i).at(j);
    }
    rep(i,N-1){
        for(ll j=i+1;j<N;j++){
            ll total=0;
            rep(k,D) total+=(X.at(i).at(k)-X.at(j).at(k))*(X.at(i).at(k)-X.at(j).at(k));
            for(ll m=1;m*m<=total;m++){
                if(m*m==total) ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}


int main(){
	int n;
	cin>>n;
	vector<int> a(n),b(n);
	rep(i,n){
		cin>>a[i];
	}
	rep(i,n){
		cin>>b[i];
	}
	int ans=0;
	rep(i,n){
		int x=0;
		rep(j,i+1){
			x+=a[j];
		}
		FOR(j,i,n){
			x+=b[j];
		}
		ans=max(ans,x);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
n=int(input())
s=list(input())
ins=0
app=0
for i in range(n):
    if s[i]=='(':
        app += 1
    else:
        if app>0:
            app -= 1
        else:
            ins += 1
inL=['(']*ins
app=[')']*app
ans=inL+s+app
print(''.join(ans))

Measured memory_bytes: 3064
import * as fs from 'fs';
// main
function main(input: string[]) {
    // param
    let a: number = 0;
    let b: number = 0;
    let ans: number = 0;
    // init
    [a, b] = input.shift().split(" ").map(x => Number(x));
    // solve
    ans = -1;
    for (var rx = 0; rx <= 1010; rx++) {
        if (Math.floor(rx * 0.08) == a &&
            Math.floor(rx * 0.10) == b) {
            ans = rx;
            break;
        }
    }
    // answer
    console.log(ans);
}
// entrypoint
function entrypoint() {
    try {
        // linux
        let input = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        console.debug = function () { };
        main(input);
    }
    catch (ex) {
        // windows
        const lines: string[] = [];
        // @ts-ignore
        const reader = require('readline').createInterface({
            // @ts-ignore
            input: process.stdin,
            // @ts-ignore
            output: process.stdout
        });
        reader.on('line', function (line: string) {
            lines.push(line);
        });
        reader.on('close', function () {
            let input = lines;
            main(input);
        });
    }
}
entrypoint();


Measured memory_bytes: 29900
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_9_C
// Heaps - Priority Queue

#define SUBMIT

#include <iostream>
#include <queue>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

int main() {
    priority_queue<int> pq;

    int key;
    string command;
    while (true) {
        cin >> command;
        if (command == "end") break;
        else if (command == "extract") {
            cout << pq.top() << endl;
            pq.pop();
        } else { // insert
            cin >> key;
            pq.push(key);
        }
    }

    return 0;
}


Measured memory_bytes: 7004