akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static long Mod = (long)1e9 + 7;
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }
        static void Solve()
        {
            var x = Sarray()[0];
            if (x < 1200)
                WriteLine("ABC");
            else
                WriteLine("ARC");
        }
    }
}

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

int main(){
  int arr[5];
  int sum=0;
  for(int i=0; i<5; i++){
  cin>>arr[i];
  }
  
  int reqSum= 15;
  
  for(int i=0; i<5; i++){
   sum+=arr[i];
  }
 cout<<reqSum-sum<<endl;
return 0;
}

Measured memory_bytes: 3588
import sys
import math
n = int(input())
#a, b, c = map(int, input().split())
#s = input()
a = list(map(int, input().split()))


for i in range(n):
  if a[i] % 2 == 0:
    if a[i] % 3 == 0:
      continue
    if a[i] % 5 == 0:
      continue
    print("DENIED")
    sys.exit()

print("APPROVED")


Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
namespace io
{
#define SIZ (1 << 21 | 1)
#define gc() (io::iS == io::iT ? (io::iT= (io::iS= io::ibuff) + fread(io::ibuff, 1, SIZ, stdin), (io::iS == io::iT ? EOF : *io::iS++)) : *io::iS++)
#define putc(x) (io::oS == io::oT ? (fwrite(io::obuff, 1, io::oS - io::obuff, stdout), io::oS= io::obuff, (*io::oS++= x)) : *io::oS++= x)
#define exit                                          \
	fwrite(io::obuff, 1, io::oS - io::obuff, stdout); \
	return 0;
	char *iS, *iT, ibuff[SIZ], obuff[SIZ], *oS= obuff, *oT= oS + SIZ - 1, fu[110], c;
	int fr;
	template <class Type>
	inline void read(Type &x)
	{
		x= 0;
		Type y= 1;
		for(c= gc(); (c > '9' || c < '0') && c != '-'; c= gc())
			;
		c == '-' ? y= -1 : x= (c & 15);
		for(c= gc(); c >= '0' && c <= '9'; c= gc()) x= x * 10 + (c & 15);
		x*= y;
	}
	inline void reads(char *x)
	{
		for(c= gc(); c == ' ' || c == '\n'; c= gc())
			;
		for(; c != ' ' && c != '\n' && c != EOF; *x= c, c= gc(), ++x)
			;
	}
	template <class Type>
	inline void print(Type x, char text= '\n')
	{
		if(x < 0) putc('-'), x*= -1;
		if(x == 0) putc('0');
		while(x) fu[++fr]= x % 10 + '0', x/= 10;
		while(fr) putc(fu[fr--]);
		putc(text);
	}
	inline void prints(char *x, char *y= NULL, char text= '\n')
	{
		for(; *x && x != y; ++x) putc(*x);
		putc(text);
	}
}  // namespace io
using io::print;
using io::prints;
using io::read;
using io::reads;
#define N 101
#define int long long
int n, m, a[N], cnt, b[N], tot, s;
signed main()
{
	read(n), read(m);
	for(int i= 1; i <= m; i++)
	{
		read(a[i]);
		if(a[i] & 1) ++cnt;
		if(cnt > 2)
		{
			printf("Impossible\n");
			return 0;
		}
	}
	if(m == 1)
	{
		print(a[1]);
		b[++tot]= a[1] - 1;
		b[++tot]= 1;
	}
	else
	{
		if(cnt == 0)
		{
			for(int i= 1; i <= m; i++) print(a[i], ' ');
			putc('\n');
			b[++tot]= a[1] + 1;
			for(int i= 2; i < m; i++) b[++tot]= a[i];
			b[++tot]= a[m] - 1;
		}
		else if(cnt == 1)
		{
			for(int i= 1; i <= m; i++)
				if(a[i] & 1)
				{
					swap(a[i], a[1]);
					break;
				}
			for(int i= 1; i <= m; i++) print(a[i], ' ');
			putc('\n');
			b[++tot]= a[1] + 1;
			for(int i= 2; i < m; i++) b[++tot]= a[i];
			b[++tot]= a[m] - 1;
		}
		else
		{
			if(m == 2)
			{
				print(a[1], ' '), print(a[2]);
				b[++tot]= a[1] + a[2];
			}
			else
			{
				bool bb= 0;
				for(int i= 1; i <= m; i++)
					if(a[i] & 1)
					{
						if(!bb)
						{
							swap(a[i], a[1]);
							bb= 1;
						}
						else
						{
							swap(a[i], a[m]);
							break;
						}
					}
				for(int i= 1; i <= m; i++) print(a[i], ' ');
				putc('\n');
				b[++tot]= a[1] + 1;
				for(int i= 2; i < m; i++) b[++tot]= a[i];
				b[++tot]= a[m] - 1;
			}
		}
	}
	for(int i= 1; i <= tot; i++)
		if(b[i] == 0) ++s;
	print(tot - s);
	for(int i= 1; i <= tot; i++)
		if(b[i]) print(b[i], ' ');
	putc('\n');
	exit;
}

Measured memory_bytes: 2304
#include <iostream>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
 
using namespace std;

string s, q1, q3;
 
int main() {
  fast_io;

  cin >> s;

  q1 =  s.substr( 0, (s.size() - 1)/2 );
	q3 =  s.substr((s.size() + 2 )/2 );
  
	if (q1 == q3)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
 
  return 0;
}

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

int N, M;
vector<pair<int, int>> v;
vector<int> nodeGroup(51, -1);

bool decideGroup(int start, int k, vector<bool> check, unordered_set<int>& s,
                 vector<unordered_set<int>> vg) {
  for (auto x : vg[k]) {
    vg[x].erase(k);
    if (start == x) {
      // cout << start << " " << k <<endl;
      return true;
    }
    if (!check[x]) {
      check[x] = true;
      if (decideGroup(start, x, check, s, vg)) {
        s.insert(x);
        return true;
      }
    }
  }

  return false;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  cin >> N >> M;
  vector<unordered_set<int>> vg(51);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    v.emplace_back(a, b);
    vg[a].insert(b);
    vg[b].insert(a);
  }
  unordered_set<int> s;
  int nodeNum = 0;
  for (int i = 0; i < N; i++) {
    if (nodeGroup[i] == -1) {
      s.clear();
      s.insert(i);
      vector<bool> check(51, false);
      check[i] = true;
      decideGroup(i, i, check, s, vg);
      int newNodeNum = nodeNum;
      for (auto x : s) {
        if (nodeGroup[x] != -1) {
          newNodeNum = nodeGroup[x];
        }
      }
      for (auto x : s) {
        nodeGroup[x] = newNodeNum;
      }
      nodeNum++;
    }
  }
  for (int i = 0; i < N; i++) {
    // cout << nodeGroup[i] <<endl;
  }

  int ans = 0;
  for (int i = 0; i < M; i++) {
    if (nodeGroup[v[i].first] != nodeGroup[v[i].second]) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3920
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    string s;
    cin >> s;
    int ans = 0;
    char c = s[0];
    rep(i, s.size()) {
        if(s[i] != c){
            c = s[i];
            ans++;
        }
    }
    cout << ans << endl;
}

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

#define ANS  //for answer
#define CMP  //for compe

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define nv(x) #x,(x)
#define ncv(x) #x,":",(x)
#define ncvc(x) #x,":",(x),","
using ll = long long;
void pPRINT(std::ostream& ost) {}
template <class T, class... U>void pPRINT(std::ostream& ost,const T t,const U... u) {ost<<t<<" ";pPRINT(ost, u...);}
template <class... T>void PRINT(const T... t) {pPRINT(std::cout, t...);}
template <class... T>void PRINTl(const T... t){pPRINT(std::cout,t...);std::cout<<"\n";}
template <class T>void PRINTa(const T* const t,const ll size){REP(i,size)PRINT(t[i]);PRINTl();}
template <class T>void PRINTal(const T* const t,const ll size){REP(i,size)PRINTl(i,":",t[i]);}
#ifdef CMP
using namespace std;
#else
#endif
#ifdef ANS
#define DEBUG(...)
void init(){}
#else
#define DEBUG(...) PRINT("##DEBUG##","file :",__FILE__,", line :",__LINE__,"[");PRINT(__VA_ARGS__);PRINTl("]");
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}
#endif

void solve();

int main(int argc, char *argv[]) {

  init();
  DEBUG();
  solve();

  return 0;
}

void solve(){

  DEBUG("SOLVE START");
  ll n;cin>>n;
  ll h[n];REP(i,n)cin>>h[i];

  ll gf=0;
  ll li=-1;
  FOR(i,1,n){
    if(h[i]>h[i-1])gf=i;
    else if(h[i]==-1+h[i-1]){
      if(gf>li){
        li=gf;
      }
      else{PRINT("No");return;}
    }
    else if(h[i]<h[i-1]-1) {PRINT("No");return;}
  }
  PRINT("Yes");
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(String... args) {
    Scanner input = new Scanner(System.in);
    
    int n = input.nextInt();
    int m = input.nextInt();
    
    Map<Integer, Set<Integer>> g = new HashMap<>();
    for (int i = 0; i < m; i++) {
      int a = input.nextInt() - 1;
      int b = input.nextInt() - 1;
      
      g.computeIfAbsent(a, k -> new HashSet<>()).add(b);
      g.computeIfAbsent(b, k -> new HashSet<>()).add(a);
    }
    
    int ans = 0;
    boolean[] v = new boolean[n];
	for (int i = 0; i < n; i++) {
      if (!v[i]) {
        ans = Math.max(ans, dfs(i, v, g));
      }
    }
    
    System.out.println(ans);
  }
  
  private static int dfs(int root, boolean[] v, Map<Integer, Set<Integer>> g) {
    v[root] = true;
    
    int cnt = 1;
    for (int n : g.getOrDefault(root, new HashSet<>())) {
      if (!v[n]) {
        cnt += dfs(n, v, g);
      }
    }
    
    return cnt;
  }
}

Measured memory_bytes: 164488
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

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

	int a, b; cin >> a >> b;
	if (a > b) swap(a, b);
	for (int i = 0; i < b; i++) cout << a;
	cout << endl;

	return 0;
}

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int> > V1(n, vector<int>(m));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> V1.at(i).at(j);
		}
	}

	vector<int> V2(m);
	for (int i = 0; i < m; i++) {
		cin >> V2.at(i);
	}

	for (int i = 0; i < n; i++) {
		int sum = 0;
		for (int j = 0; j < m; j++) {	
			sum += V1[i][j] * V2[j];
		}
		cout << sum << endl;
	}
}



Measured memory_bytes: 3208
import sys

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

for i in range(m//10000+1):
    for j in range((m-10000*i)//5000+1):
        if i % 1 == 0 and j % 1 == 0:
            if n-(i+j) >= 0 and i*10000 + j* 5000 + (n-(i+j))*1000 == m:
                print(i, j, n-(i+j))
                sys.exit()
print(-1, -1, -1)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
bool pal(string s) {
	string temp = s;
	reverse(temp.begin(), temp.end());
	return s == temp;
}
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	string s;
	cin >> s;
	int n = s.length();
	if(pal(s) && pal(s.substr(0, (n - 1) / 2)) && pal(s.substr(n / 2 + 1))) cout << "Yes";
	else cout << "No";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int t[3];
    int m = 0 , mn = 0 ;
    for (int i = 0; i < 3; i++) {
        cin >> t[i];
        if (t[i] > m){
        m = t[i];
        mn = i;
        }
    }
    swap(t[0], t[mn]);
    
    if (t[2] > t[1]) {
        swap(t[2], t[1]);
    }
    cout << (t[0] - t[1] )+ (t[1] - t[2] );
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

using namespace std;

vector <int> r, p;

int get(int v) {
	return (p[v] == v ? v : p[v] = get(p[v]));
}

ll n, m, q;
int cnt;

void uni(int v, int u) {
	v = get(v);
	u = get(u);
	if (v == u) return;
	if (r[v] == r[u]) r[u]++;
	if (r[v] > r[u]) swap(v, u);
	p[v] = u;
	cnt--;
}

int main(){
#ifdef LOCAL
	freopen("D_input.txt", "r", stdin);
	//freopen("D_output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	cin >> n >> m >> q;

	cnt = n;

	r.resize(n, 0), p.resize(n);
	iota(p.begin(), p.end(), 0);

	vector <pair <int, int> > bad;
	for (int i = 0; i < q; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		if (!c) {
			uni(a, b);
		} else {
			bad.push_back({a, b});
		}
	}

	vector <bool> used(n, false);

	ll mink = 0;

	for (auto t : bad) {
		int v = t.first, u = t.second;
		if (!used[get(v)]) {
			used[get(v)] = true;
			mink++;
		}
		if (!used[get(u)]) {
			used[get(u)] = true;
			mink++;
		}
		if (get(v) == get(u)) {
			cout << "No\n";
			return 0;
		}
	}

	ll maxk = cnt;

	if (mink < 3 && bad.size()) {
		mink = 3;
	}

	if (mink > maxk) {
		cout << "No\n";
		return 0;
	}

	ll add = n - cnt;

	//cout << add << "\n";

	ll emin = mink;
	ll emax = maxk * (maxk - 1) / 2;
	if (add + emin > m || add + emax < m) {
		cout << "No\n";
		return 0;
	}

	cout << "Yes\n";
	return 0;

}


Measured memory_bytes: 2168
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S[] = sc.next().split("");
    String T[] = sc.next().split("");
    
    Arrays.sort(S);
    Arrays.sort(T, Collections.reverseOrder());
    
    String newS = String.join("", S);//文字列の連結
    String newT = String.join("", T);//文字列の連結
    
    //System.out.println(newS);
    //System.out.println(newT);
    
    if(newS.equals(newT)){
      System.out.println("No");
      return;
    }
    
    String s[] = {newS, newT};
    Arrays.sort(s);
    
    if(s[0]==newS){
      System.out.println("Yes");      
    }else{
      System.out.println("No");      
    }
  }
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define forn(i,n) for(int i=0;i<int(n);++i)
#define vet(a) for(auto&i:a)cout<<i<<" "
#define out(a) cout<<a<<endl

typedef long long int ll;

int32_t main()
{
	IOS;
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif

	char a;
	cin>>a;
	if(a>=65&&a<=90){
		cout<<"A";
	}else{
		cout<<"a";
	}

	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init));

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

const string code[9] = {".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  ll n;
  cin >> n;
  rep(i,n){
    cin >> s;
    ll cnt = 0,num = 0;
    bool f = false;
    string ans = "";
    rep(j,s.size()){
      if(!f && s[j] != '0'){
        num = s[j] - '0' - 1;
        cnt = 0;
        f = true;
      }
      else{
        if(s[j] == '0'){
          if(f)
            ans += code[num][cnt];
          f = false;
        }
        else{
          ++cnt;
          cnt %= code[num].size();
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int h, w, k;
  cin>>h>>w>>k;
  char arr[h][w];
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      cin>>arr[i][j];
    }
  }
  int kval=0;
  for (int i=0; i<(1<<h); i++) {
    for (int j=0; j<(1<<w); j++) {
      int val=0;
      for (int k=0; k<h; k++) {
        if ((i & (1<<k))) {
          for (int m=0; m<w; m++) {
            if ((j & (1<<m)) and arr[k][m]=='#') val++;
          }
        }
      }
      if (val == k) kval++;
    }
  }
  cout<<kval<<'\n';
}

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

int main(int argc, char const *argv[])
{
   int k, x;
   cin >> k >> x;
   int l = max(-1000000, x-k+1);
   int r = min(1000000, x+k-1);
   for(int i = l; i <= r; i++)
   {
      cout << i  <<  (i == r ? "" : " ") ;
   }
   cout << endl;
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
#define MAX 1000001
  bool num[MAX]={1,1,0};
  for(int i=3;i<MAX;i+=2){
    if(num[i])continue;
    for(int j=i*3;j<MAX;j+=i*2){
      num[j]=1;
    }
  }
  int n;
  while(cin>>n,n){
    int co=0;
    for(int i=3;i<=n/2;i+=2){
      if(!num[i]&&!num[n-i])co++;
    }
    cout<<co<<endl;
  }


}

Measured memory_bytes: 2144
fn find_close(g: &Vec<Vec<usize>>, cur: usize, mut back: &mut Vec<usize>, mut visited: &mut Vec<bool>) -> Option<Vec<usize>> {
    visited[cur] = true;
    for &next in &g[cur] {
        if visited[next] {
            // FOUND
            back[next] = cur;
            let mut pos = next;
            let mut ret = vec![0usize; 0];
            loop {
                pos = back[pos];
                ret.push(pos);
                if pos == next {
                    break
                }
            }
            ret.reverse();
            return Some(ret);
        } else if back[next] == std::usize::MAX {
            back[next] = cur;
            let ret = find_close(g, next, &mut back, &mut visited);
            if ret.is_some() {
                return ret
            }
        }
    }
    visited[cur] = false;
    return None
}

fn find_close_all(g: &Vec<Vec<usize>>) -> Option<Vec<usize>> {
    let mut back = vec![std::usize::MAX; g.len()];
    let mut visited = vec![false; g.len()];

    for i in 0..g.len() {
        if back[i] != std::usize::MAX {
            continue
        }
        let ret = find_close(g, i, &mut back, &mut visited);
        if ret.is_some() {
            return ret
        }
    }
    return None
}

fn check(g: &Vec<Vec<usize>>, loops: &Vec<usize>) -> Vec<usize> {
    let mut in_loop = vec![false; g.len()];
    let mut index = vec![0usize; g.len()];
    for (i, &v) in loops.iter().enumerate() {
        in_loop[v] = true;
        index[v] = i;
    }
    for &v in loops {
        for &u in &g[v] {
            if in_loop[u] {
                if (index[v] + 1) % loops.len() != index[u] {
                    let mut next_loop = vec![0usize; 0];
                    let mut cur = index[u];
                    while cur != index[v] {
                        next_loop.push(loops[cur]);
                        cur = (cur + 1) % loops.len();
                    }
                    next_loop.push(loops[cur]);
                    assert!(next_loop.len() < loops.len());
                    return check(g, &next_loop);
                }
            }
        }
    }
    return loops.clone()
}

fn main() {
    let (n, m) = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let v: Vec<usize> = line.split_whitespace().map(|a| a.parse().unwrap()).collect();
        (v[0], v[1])
    };
    let mut g = vec![vec![0usize; 0]; n];
    for _ in 0..m {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let v: Vec<usize> = line.split_whitespace().map(|a| a.parse().unwrap()).collect();
        g[v[0] - 1].push(v[1] - 1);
    }
    let loopc = find_close_all(&g);
    if loopc.is_none() {
        println!("-1");
        return;
    } else {
        let ret = check(&g, &loopc.unwrap());
        println!("{}", ret.len());
        for v in ret {
            println!("{}", v + 1);
        }
    }
}


Measured memory_bytes: 4476
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  int n,k; cin >>n>>k;
  vector<ll> vec(n);
  rep(i,n) cin >>vec[i];
  sort(all(vec));
  ll ans =0;
  rep(i,vec.size()-k) ans+=vec[i];
  cout <<ans<<endl;
}

Measured memory_bytes: 1792
from functools import reduce

def gcd(m, n):
    if m < n:
        return gcd(n, m)
    if n == 0:
        return m
    return gcd(n, m % n)

def lcm(m, n):
    return m * n // gcd(m, n)

n = int(input())
l = [int(arg) for arg in input().split()]
print(reduce(lcm, l, l[0]))



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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

template <typename T>
T mod_expt(T a, std::int64_t n, T mod){
    T power {1};
    while(n > 0){
        if(n & 1){power = power * a % mod;}
        a = a * a % mod;
        n >>= 1;
    }
    return power;
}

template <typename T>
std::tuple<T, T, T> extgcd(T a, T b){
    T s1 = 1, t1 = 0, s2 = 0, t2 = 1;
    while(b != 0){
        std::tie(s1, t1, s2, t2) = std::make_tuple(s2, t2, s1 - (a / b) * s2, t1 - (a / b) * t2);
        std::tie(a, b) = std::make_tuple(b, a % b);
    }
    return std::make_tuple(s1, t1, a);
}

// 注意: a と mod が互いに素である必要がある
template <typename T>
T mod_inverse(T a, T mod){
    T b;
    std::tie(b, std::ignore, std::ignore) = extgcd(a, mod);
    if(b < 0){b += mod;}
    return b;
}

template <typename T>
struct Combinatorics{
    T modulo;
    std::vector<T> fact, inv_fact;

    Combinatorics() = default;

    Combinatorics(T max, T modulo) : modulo(modulo), fact(max + 1), inv_fact(max + 1) {
        fact[0] = 1;
        for(T i=1;i<=max;++i){
            fact[i] = i * fact[i - 1] % modulo;
        }

        inv_fact[max] = mod_inverse(fact[max], modulo);
        for(T i=max;i>0;--i){
            inv_fact[i - 1] = i * inv_fact[i] % modulo;
        }
    }

    T nPk(T n, T k){
        if(n < k){return 0;}
        return fact[n] * inv_fact[n - k] % modulo;
    }

    T nCk(T n, T k){
        if(n < k){return 0;}
        return fact[n] * inv_fact[k] % modulo * inv_fact[n - k] % modulo;
    }

    T nHk(T n, T k){
        if(n == 0 && k == 0){return 1;}
        return nCk(n + k - 1, k);
    }
};

Combinatorics<ll> comb;
int N, M;
ll dp[3100][3100];

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

    std::cin >> N >> M;

    dp[0][0] = 1;

    for(int i=0;i<N;++i){
        for(int j=0;j<=N;++j){
            dp[i+1][j] = (dp[i+1][j] + dp[i][j] * (j + 1)) % M;
            dp[i+1][j+1] = (dp[i+1][j+1] + dp[i][j]) % M;
        }
    }
    
    comb = Combinatorics<ll>(3100, M);

    ll res = 0;

    for(int i=1;i<=N;++i){
        int s = i % 2 == 1 ? +1 : M - 1;
        ll x = 0;

        for(int j=0;j<=i;++j){
            x = (x + dp[i][j] * mod_expt<ll>(2ll, (N - i) * j, M)) % M;
        }

        x = x * mod_expt<ll>(2ll, mod_expt<ll>(2ll, N - i, M - 1), M) % M * s % M * comb.nCk(N, i);
        
        res = (res + x) % M;
    }
    
    res = (mod_expt<ll>(2ll, mod_expt<ll>(2ll, N, M - 1), M) + M - res) % M;
    std::cout << res << std::endl;
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> s, t;
  rep(i,n) {
    cin >> a[i];
    if (a[i] < 0) t.push_back(a[i]);
    else s.push_back(a[i]);
  }

  int S = s.size();
  int T = t.size();
  bool ok = false;
  if (S > 0) {
    if (n == k) ok = (T%2==0);
    else ok = true;
  } else {
    ok = (k%2==0);
  }

  mint ans = 1;
  if (!ok) {
    sort(a.begin(), a.end(), [](int x, int y) {
      return abs(x) < abs(y);
    });
    rep(i,k) ans *= a[i];
  } else {
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    if (k%2 == 1) {
      ans *= s.back();
      s.pop_back();
    }
    vector<ll> p;
    while (s.size() >= 2) {
      ll x = s.back(); s.pop_back();
      x *= s.back(); s.pop_back();
      p.push_back(x);
    }
    while (t.size() >= 2) {
      ll x = t.back(); t.pop_back();
      x *= t.back(); t.pop_back();
      p.push_back(x);
    }
    sort(p.rbegin(), p.rend());
    rep(i,k/2) ans *= p[i];
  }

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

Measured memory_bytes: 6412
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
inline ll bigmod(ll B,ll P){ll R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline ll ad(ll x,ll y){ll ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll sub(ll x,ll y){ll ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll gun(ll x,ll y){ll ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
const int N = 2e5 + 100;
namespace Combi {
    int fact[N], inv[N];

    int bm(int b, int p, int m) {
        if(p == 0) return 1%m;
        int t = bm(b,p/2,m);
        t = (1ll*t*t)%m;
        if(p&1) return 1ll*t*b%m;
        return t;
    }

    int C(int n, int r) {
        if(n < 0 or r < 0 or r > n) return 0;
        int ret = 1ll*fact[n]*inv[r]%mod;
        ret = 1ll*ret*inv[n-r]%mod;
        return ret;
    }
    // X1 + X2 + ... + Xvar = Sum
    int no_of_eqns(int sum, int var) {
        return C(sum+var-1,var-1); // Xi >= 0
        // return C(sum-1,var-1); // Xi > 0
    }
    void init() {
        fact[0] = 1;
        for(int i = 1; i < N; i++) {
            fact[i] = 1ll*fact[i-1]*i%mod;
        }
        inv[N-1] = bm(fact[N-1], mod-2, mod);
        for(int i = N-2; i >= 0; i--) {
            inv[i] = 1ll*inv[i+1]*(i+1)%mod;
        }
    }
}
int yo(int x,int y,int a,int b)
{
    int ret=1;
    int down=abs(a-x);
    int rgt=abs(b-y);
    int p=(down+rgt);
    ret=Combi::C(p,down);
    return ret;
}
 main()

{
    fast
    Combi::init();
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    int ses=0;
    for(int i=1;i<=h-a;i++)
    {
        int cost=yo(1,1,i,b);
        cost=gun(cost,yo(i,b+1,h,w));
        ses=ad(ses,cost);
    }
    cout<<ses<<endl;
    return 0;

}





































Measured memory_bytes: 6772
mod = 10**9+7
fact = [1 for _ in range(10000)]
inv = [1 for _ in range(10000)]
fact_inv = [1 for _ in range(10000)]

for i in range(2, 10000):
    fact[i] = (fact[i-1]*i) % mod
    inv[i] = mod - (inv[mod % i] * (mod // i)) % mod
    fact_inv[i] = (fact_inv[i-1] * inv[i]) % mod

S = int(input())
a = S//3
if a == 0:
    print(0)
    exit()
else:
    ans = 0
    for i in range(1, a+1):
        n = S-i*3
        ans += (fact[n+i-1]*fact_inv[i-1]*fact_inv[n])
        ans = ans % mod
    print(ans)

Measured memory_bytes: 9928
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second

const int inf = 0x3f3f3f3f;
const int mxn = 100000;
int n, m;
int a[mxn], b[mxn], c[mxn];
int cc[mxn], d[mxn], dd[mxn], p[mxn], vis[mxn];
vector<int> f(1, 0), g(1, 0);
ll sum, cnt, cyc;
int ret, ret2;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	
	for(int i = 0; i < m; i++){
		cin >> a[i] >> b[i] >> c[i];
		a[i]--, b[i]--;
		d[a[i]]++, dd[b[i]]++, p[b[i]] = a[i], cc[a[i]] = c[i];
		if(a[i] != b[i]) ret++, sum += c[i] - 1;
	}
	
	for(int i = 0; i < m; i++){
		if(a[i] == b[i]){
			if((d[a[i]] > 1 || dd[a[i]] > 1) && c[i] > 1){
				f.push_back(c[i] - 1);
			}else if(c[i] > 2){
				g.push_back(c[i] - 2);
			}
		}else if(!~-d[a[i]] && !~-dd[a[i]] && !vis[a[i]]){
			ll j, s;
			for(j = a[i], s = 0; !~-d[j] && !~-dd[j] && !vis[j]; j = p[j]) vis[j] = 1, s += cc[j] - 1;
			if(j == a[i]) cnt++, cyc += s;
		}
	}
	
	sort(f.begin() + 1, f.end(), greater<int>());
	sort(g.begin() + 1, g.end(), greater<int>());
	
	ret += cnt;
	ret2 = !!cnt * inf;
	for(int i = sum == cyc, j = 0; i < f.size(); i++){
		sum += f[i];
		while(j < g.size() - 1 && sum < cnt) sum += g[++j];
		while(j && sum - g[j] >= cnt) sum -= g[j--];
		if(sum >= cnt) ret2 = min(ret2, i + 2 * j);
	}
	
	cout << (ret2 == inf ? -1 : ret + ret2) << endl;

	return 0;
}

Measured memory_bytes: 6716
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
using namespace std;
#define ll long long
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int k;
	int a, b;
	cin >> k;
	cin >> a >> b;
	if (a == b && a % k == 0)
	{
		cout << "OK";
		return 0;
	}
	if (a % k == 0 || b % k == 0)
	{
		cout << "OK";
		return 0;
	}
	if ((a / k) < (b / k)) cout << "OK";
	else cout << "NG";
}

Measured memory_bytes: 3652
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = list(iss())
    ret = []
    for s in S:
        if s == "0":
            ret.append("0")
        elif s == "1":
            ret.append("1")
        elif s == "B" and len(ret) > 0:
            ret.pop()

    print("".join(ret))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#define REP(i, a, n) for(int i = a; i < n; i++)
using namespace std;


int m, n, ans;
bool mp[90][90];

bool move(int i, int j) {
  if(0 <= i && i < n && 0 <= j && j < m && mp[i][j]) {
    mp[i][j] = false;
    return true;
  }
  return false;
}

void backtrack(int i, int j) {
  mp[i][j] = true;
}

int dfs(int i, int j, int d) {
  if(move(i, j)) {
    int r = d;
    r = max(r, dfs(i + 0, j - 1, d + 1));
    r = max(r, dfs(i + 0, j + 1, d + 1));
    r = max(r, dfs(i + 1, j + 0, d + 1));
    r = max(r, dfs(i - 1, j + 0, d + 1));
    backtrack(i, j);
    return r;
  }

  return d;
}

int main(void) {
  while(cin >> m >> n, !(m == 0 && n == 0)) {
    REP(i, 0, n) {
      REP(j, 0, m) {
        cin >> mp[i][j];
      }
    }

    ans = 0;
    REP(i, 0, n) {
      REP(j, 0, m) {
        ans = max(ans, dfs(i, j, 0));
      }
    }

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

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

int main(){
    long long n, k, s;

    cin >> n >> k >> s;

    long long a[n];

    if(s == 1){
        for(long long i = 0; i < n; i++){
            if(i < k){
                a[i] = 1;
            }
            else{
                a[i] = 2;
            }
        }

        for(long long i = 0; i < n; i++){
            printf("%lld\n", a[i]);
        }

        return 0;
        
    }

    

    for(long long i = 0; i < n; i++){
        if(i < k){
            a[i] = s;
        }
        else{
            a[i] = s-1;
        }
    }

    for(long long i = 0; i < n; i++){
        printf("%lld\n", a[i]);
    }

    return 0;
}

Measured memory_bytes: 2048
n = int(input())
a = list(map(int,input().split()))

from collections import Counter
MOD = 10**9 + 7
c = Counter(a)

ans = 0

if n % 2 == 1:
    for i in range(2, n, 2):
        if c[i] != 2:
            print(0)
            exit()
    if c[0] == 1:
        ans = pow(2, n // 2, MOD)
else:
    for i in range(1, n, 2):
        if c[i] != 2:
            print(0)
            exit()
    ans = pow(2, n // 2, MOD)
print(ans)

Measured memory_bytes: 14692
#include <iostream>
using namespace std;
 
#define HOUR 3600
#define MINUT 60

int main(){
    int S, hour, minut, second;
    cin >> S;
    hour = S / HOUR;
    minut = (S % HOUR) / MINUT;
    second = (S % HOUR) % MINUT;
    cout << hour << ':' << minut << ':' << second << endl;
    return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    int ans = 0;
    if (a > b) {
      ans += a;
      a--;
    } else {
      ans += b;
      b--;
    }
    if (a > b) {
      ans += a;
      a--;
    } else {
      ans += b;
      b--;
    }
    System.out.println(ans);
  }

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  ll A, B, C, K;
  cin >> A >> B >> C >> K;

  ll ret = 0;
  ret += min(A, K);
  K -= min(A, K);
  K -= min(B, K);
  ret -= min(C, K);

  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <iomanip>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <functional>
#include <iterator>
using namespace std;

#define SIZE 101

long long int dp[SIZE][2];

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

    int targetLen, thickLen;
    while (cin >> targetLen >> thickLen)
    {
        memset(dp, 0, sizeof(dp));
        dp[1][0] = 1;
        dp[thickLen][0] = 1;
        for (int i = 2; i <= targetLen; i++)
        {
            dp[i][0] += dp[i - 1][1];
            if (i > thickLen)
                dp[i][0] += dp[i - thickLen][1];
            dp[i][1] += dp[i - 1][0];
        }

        long long int ans = 0;
        for (int i = 1; i <= targetLen; i++)
        {
            ans += dp[i][0];
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3204
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265359

using namespace std;

ll powMod(ll a, ll y)
{
    ll ans = 1;
    
    while (y > 0) 
    { 
        if (y & 1) 
            ans = (ans*a) % MOD; 
  
        y = y>>1;
        a = (a*a) % MOD; 
    } 
    return ans;
}

/*ll modInv(ll a)
{
    return powMod(a, MOD-2);	
}*/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    ll ans = 0;
    ans = (powMod(10,n) - 2*powMod(9,n) + powMod(8,n))%MOD;
    cout << (ans+MOD)%MOD << endl;
    return 0;
}




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


int main(){
    string S;
    cin>> S;
    if(S.size()%2==1){
        cout <<"No"<<endl;
        return 0;
    }
    for(long unsigned int i=0;i<S.size();i++){
        if(i%2==0&&S.at(i)=='h'){
            continue;
        }
        if(i%2==1&&S.at(i)=='i'){
            continue;
        }
        cout <<"No"<<endl;
        return 0;
    }
    cout <<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 3632
from collections import deque
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline
n = int(input())
a,b = map(int,input().split())
x = list(map(int,input().split()))
iti = 0
ni = 0
san = 0
for i in range(n):
        if x[i] <= a:
                iti += 1
        elif a+1<= x[i] and x[i] <= b:
                ni += 1
        else:
                san += 1
print(min(iti,ni,san))

Measured memory_bytes: 3316
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TOPSIC2
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();

            if (S == T.Substring(0, S.Length))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}


Measured memory_bytes: 17188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(a,j,n) for(ll i=a;i<j;i=i+n )
typedef pair<ll,ll> P;
const ll mod = 1000000007;
const ll INF = 1000000009;
ll i;
vector<string> a={"a","b","c","d","e","f","g","h","i","j","k","l"};
typedef pair<string,int> S;
int main(){
    int N;
    cin>>N;
    vector<pair<string,int>> ans;
    
    for(ll j=0;j<N;j++){
        if(j==0)ans.push_back(S("a",0));
        else{
            int size=ans.size();
            for(ll k=0;k<size;k++){
                if(ans.at(k).second+1==j){
                    for(int x=0;x<j;x++){
                        ans.push_back(S(ans.at(k).first+a.at(x),j-1));
                    }
                    ans.push_back(S(ans.at(k).first+a.at(j),j));
                }
                else{
                    for(int y=0;y<ans.at(k).second+1;y++){
                        ans.push_back(S(ans.at(k).first+a.at(y),ans.at(k).second));
                    }
                    ans.push_back(S(ans.at(k).first+a.at(ans.at(k).second+1),ans.at(k).second+1));
                }
            }
            ans.erase(ans.begin(),ans.begin()+size);
        }
    }
    vector<string> realans;
    for(int w=0;w<ans.size();w++)realans.push_back(ans.at(w).first);
    sort(realans.begin(),realans.end());
    for(string h:realans)cout<<h<<endl;
}



Measured memory_bytes: 12652
<?php
$L=trim(fgets(STDIN));

$p0=0;
$p1=0;

for($i=0;$i<$L;$i++){
  list($c0,$c1)=explode(' ',trim(fgets(STDIN)));

  if($c0<$c1){$p1+=3;continue;}
  if($c0>$c1){$p0+=3;continue;}
  ++$p0;
  ++$p1;
}

echo $p0,' ',$p1;
?>

Measured memory_bytes: 15292
# -*- coding: utf-8 -*-
#ABC140
import sys
#sys.setrecursionlimit(100000)


n=int(input())
tmp = input().split()
a = list(map(lambda a: int(a), tmp))
tmp = input().split()
b = list(map(lambda a: int(a), tmp))
tmp = input().split()
c = list(map(lambda a: int(a), tmp))


ans=0
tmp=0
for i in range(n):
	ans+=b[a[i]-1]
	if(i!=n-1):
		if(a[i]+1==a[i+1]):
			ans+=c[a[i]-1]


print(ans)




Measured memory_bytes: 3064
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e5+10,M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}

#define trace(...) cerr<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
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...);
}

int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll h;
    cin>> h;
    ll ans=0;
    int j=1;
    while(h){
        ans+=j;
        h/=2;
        j*=2;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;
string s;
double table[301][301][301];

double dp(ll n1, ll n2, ll n3) {
  // cout << n1 << " " << n2 << " " << n3 << endl;
  ll n0 = N - (n1 + n2 + n3);
  if (n1 == 0 && n2 == 0 && n3 == 0) {
    return 0.0;
  }

  if (table[n1][n2][n3] > 0.0) return table[n1][n2][n3];

  double p0 = (double)n0 / (double)N;
  double p1 = (double)n1 / (double)N;
  double p2 = (double)n2 / (double)N;
  double p3 = (double)n3 / (double)N;

  double v = 1.0;
  if (n1 > 0) v += p1 * dp(n1 - 1, n2, n3);
  if (n2 > 0) v += p2 * dp(n1 + 1, n2 - 1, n3);
  if (n3 > 0) v += p3 * dp(n1, n2 + 1, n3 - 1);
  if (n0 > 0) v /= 1.0 - p0;
  table[n1][n2][n3] = v;
  return v;
}

int main(void){
  
  IN(N);
  vl n(4, 0);
  ll a;
  REP(i, N) {
    IN(a);
    n[a]++;
  }

  REP(i, N+1) {
    REP(j, N+1) {
      REP(k, N+1) {
        table[i][j][k] = -1.0;
      }
    }
  }
  double ans = dp(n[1], n[2], n[3]);

  cout << fixed << setprecision(10) << ans << endl;

}


Measured memory_bytes: 213376