akhauriyash/Code-Regression huggingface dataset:
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

#pragma gcc target ("avx2")
#pragma gcc optimization ("o3")
#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2.0) //等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}
#define nopf(T) [](T a){return a;}
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	long double a, b, c;
	scanf("%Lf%Lf%Lf", &a, &b, &c);
	printyn(sqrtl(a) + sqrtl(b) + 1e-14 < sqrtl(c));

	Please AC;
}


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

class Rolling_Hash{
private:
  ll n;
  static constexpr ll base1=1007,base2=2009;
  static constexpr ll mod1=(1e9+7),mod2=(1e9+9);
  vector<ll> hash1,hash2,mpow1,mpow2;
public:
  Rolling_Hash(const string& s){
    n=s.size();
    hash1.resize(n+1,0);
    hash2.resize(n+1,0);
    mpow1.resize(n+1,1);
    mpow2.resize(n+1,1);
    for(ll i=0;i<n;++i){
      hash1[i+1] = (hash1[i]*base1+s[i])%mod1;
      hash2[i+1] = (hash2[i]*base2+s[i])%mod2;
      mpow1[i+1] = (mpow1[i]*base1)%mod1;
      mpow2[i+1] = (mpow2[i]*base2)%mod2;
    }
  }
  auto get(ll l,ll r){
    ll lefval = hash1[r]-hash1[l]*mpow1[r-l]%mod1;
    ll rigval = hash2[r]-hash2[l]*mpow2[r-l]%mod2;
    if(lefval<0)lefval+=mod1;
    if(rigval<0)rigval+=mod2;
    return make_pair(lefval,rigval);
  }
  auto get_LCP(ll a,ll b){
    ll len = min( n-a+1,n-b+1 );
    ll low=0,high=len;
    while( high-low>1 ){
      ll mid=(high+low)>>1;
      if(get(a,a+mid)!=get(b,b+mid))high=mid;
      else low=mid;
    }
    return low;
  }
};

main(){

  ll n;
  string s;
  cin>>n>>s;

  Rolling_Hash rh(s);
  auto judge = [&](ll len)->bool{
    using pll=pair<ll,ll>;
    map<pll,ll> mp;
    for(ll i=0;i+len<=n;++i){
      auto hash_v=rh.get(i,i+len);
      if( mp.count(hash_v) ){
        if( mp[hash_v]+len <= i )return true;
      }
      else mp[hash_v]=i;
    }
    return false;
  };
  ll low=0,high=n/2+1;
  while(high-low>1){
    ll mid=(low+high)>>1;
    if( judge(mid) )low=mid;
    else high=mid;
  }
  cout<<(low)<<endl;

}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
signed main(){
    int a,b; cin>>a>>b;
    if(b%a==0) cout<<a+b<<endl;
    else cout<<b-a<<endl;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  	long long a,b,k;
  	cin>>a>>b>>k;
  
  if(k>=a+b){
  a=b=0;
  }
  else {
  	a-=k;
  if(a<0){
    b+=a;
    a=0;
  }
  }
  
  cout<<a<<" "<<b;

  	
    return 0;
}

Measured memory_bytes: 256
A,B,K = map(int,input().split())
d=[]
if(A>B):
    M=A
    m=B
else:
    M=B
    m=A

for x in range(m,0,-1):
    if(m%x ==0 and M%x ==0):
       d.append(x) 

print(d[K-1])

Measured memory_bytes: 3060
#include<stdio.h>

int main(){
	int sum=0;
	int num=0;
	int now=0;
	
	int a,b;
	while(~scanf("%d,%d",&a,&b)){
		sum+=a*b;
		now++;
		num+=b;
	}
	printf("%d\n%d\n",sum,(int)((double)num/(double)now+0.5));
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	int ans = 0;
	for( int i = 0; i <= a; ++i ){
		for( int j = 0; j <= b; ++j ){
			for( int k = 0; k <= c; ++k ){
				if( x == i*500 + j*100 + k*50 ){
					++ans;
				} 
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int hen[2];
	int tai;
	int c_chou = 0;
	int c_hishi = 0;
	
	while (scanf("%d,%d,%d", &hen[0], &hen[1], &tai) != EOF){
		if (hen[0] *  hen[0] + hen[1] * hen[1] == tai * tai){
			c_chou += 1;
		}
		else if (hen[0] == hen[1]){
			c_hishi += 1;
		}
		hen[0] = 0;
		hen[1] = 0;
		tai = 0;
	}
	
	printf("%d\n%d\n", c_chou, c_hishi);
	
	return (0);
}

Measured memory_bytes: 596
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);

    int n=sc.nextInt();
    int a[]=new int[n];

    for (int i=0;i<n;i++) {
      a[i]=sc.nextInt();
    }

    int count1=0;
    int count2=0;
    for (int i=0;i<n;i++) {
      if (a[i]%2==0) {
        count1++;
        if (a[i]%3==0||a[i]%5==0) {
          count2++;
        }
      }
    }

    if(count1==0||count1==count2){
      System.out.println("APPROVED");
    }else{
      System.out.println("DENIED");
    }
  }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N, K;
  cin >> N >> K;
  
  int a[N];
  for(int i=0; i<N; i++) cin >> a[i];
  
  bool dp[K+1];
  // 0:後攻が勝ち, 1:先行が勝ち
  for(int i=0; i<K+1; i++) dp[i] = false;
  
  for(int i=0; i<K+1; i++) {
    for(int j=0; j<N; j++){
      if(i + a[j] <= K){
        dp[i+a[j]] = dp[i+a[j]] || (dp[i] ? false : true);
      }else break; 
    }
  }
//  for(int i=0; i<K+1; i++) cout << dp[i] << " ";
  string ans = dp[K] ? "First" : "Second"; 
  cout << ans << endl;
  return 0;
}

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

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

    int m, n;
    cin >> m >> n;

    queue<pair<int, int>> q;
    vector<vector<int>> dp(m + 2, vector<int>(n + 2));
    vector<vector<char>> mat(m + 2, vector<char>(n + 2));
    for (int i = 1; i <= m; i++)
        for (int j = 1; j <= n; j++) {
            cin >> mat[i][j];
            if (mat[i][j] == '#') {
                q.emplace(i, j);
                dp[i][j] = 1;
            }
        }

    int addLin[] = {-1, 0, 1, 0};
    int addCol[] = {0, 1, 0, -1};

    while (!q.empty()) {
        auto top = q.front(); q.pop();
        for (int i = 0; i < 4; i++) {
            int x = top.first + addLin[i];
            int y = top.second + addCol[i];
            if (mat[x][y] == '.' && !dp[x][y]) {
                dp[x][y] = dp[top.first][top.second] + 1;
                q.emplace(x, y);
            }
        }
    }

    int mx = 0;
    for (int i = 1; i <= m; i++)
        for (int j = 1; j <= n; j++)
            mx = max(mx, dp[i][j]);

    cout << mx - 1 << '\n';
    return 0;
}


Measured memory_bytes: 13456
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	string s, t;
	cin >> s >> t;
	
	int ans = 0;
	for(int i = 0; i < s.size(); ++i) {
		if( s[i] == t[i] ) ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)
p = list(s[2:(n-1)])
if s[0] == "A":
    flag = 1
else:
    print("WA")
    quit()
cnt = 0
for i in range(2,n-1):
    if s[i] == "C":
        cnt += 1
    elif s[i].isupper():
        flag = 0
if flag and s[1].islower() and s[n-1].islower() and cnt==1:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3064
#include<stdio.h>

#include <stdlib.h>
int main(){
  int i,n,a[2000000],b[2000000],c[10000],count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    c[i]=0;
  }
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    c[a[i]]++;
  }
  for(i=0;i<10000;i++){
    count +=c[i];
    c[i]=count;
  }
  
  
  for(i=n-1;i>=0;i--){
    b[c[a[i]]-1]=a[i];
    c[a[i]]--;
  }
  for(i=0;i<n;i++){
    printf("%d",b[i]);
    if(i!=n-1) printf(" ");
    else printf("\n");
  }
  return 0;
}



Measured memory_bytes: 17392
#include<bits/stdc++.h>
using namespace std;
int dp1[100005][105],dp2[100005][105];
string k;
int d;
int main() {
	cin >> k;
	cin >> d;
	dp1[0][0] = 1;
	k = " " + k;
	for(int i=1; i<k.length(); i++) {
		for(int j=0; j<d; j++) {
			for(int l=0; l<k[i]-'0'; l++) {
				dp2[i][(l+j)%d] += dp1[i-1][j];
				dp2[i][(l+j)%d] %= 1000000007;
			}
			for(int l=0; l<10; l++) {
				dp2[i][(l+j)%d] += dp2[i-1][j];
				dp2[i][(l+j)%d] %= 1000000007;
			}
			dp1[i][(k[i]-'0'+j)%d] += dp1[i-1][j];
			dp1[i][(k[i]-'0'+j)%d] %= 1000000007;
		}
	}
	cout << (dp1[k.length()-1][0] + dp2[k.length()-1][0]-1+1000000007)%1000000007 << endl;
}

Measured memory_bytes: 12544
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9+5;
const ll INF=1e18+5;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll x;
  cin >> x;
  for(ll i=-500; i<=500; i++) {
    for(ll j=-500; j<=500; j++) {
      if(i*i*i*i*i-j*j*j*j*j==x) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3640
S = input()
quantity = int(input())
L = [input().split() for i in range(quantity)]
hanten = -1
atama = ""
shiri = ""
for row in range(quantity):
    each = L[row]
    if each[0] == "1":
        hanten = hanten * -1
    else:
        if each[1] == "1":
            if hanten == -1:
                atama = atama + each[2]
            else:
                shiri = shiri + each[2]
        else:
            if hanten == -1:
                shiri = shiri + each[2]
            else:
                atama = atama + each[2]

atama = atama[::-1]
ans = atama + S + shiri
if hanten == 1:
    ans = ans[::-1]

print(ans)

Measured memory_bytes: 40432
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cctype>
#include <cstdio>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define REVE(x) reverse(x.begin(),x.end())
#define all(x) (x).begin(),(x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(),x.end(),x.begin() ,::toupper);
#define down(x) transform(x.begin(),x.end(),x.begin() ,::tolower);
using LL = long long;
using ULL = unsigned long long;
#define FOR(i, m, n) for(int i = m;i < n;i++)
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
int main(){
    int n,a,b,c;
    cin >> a >> b >> c;
   if(a<=c&&b>=c){
       cout << "Yes";
   }else{
       cout <<"No";
   }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

ll INF = numeric_limits<int>::max();

const int MAX_V = 210;
vector<vector<ll>> d(MAX_V,vector<ll>(MAX_V,INF));
//d[[i][j]:i,j間の最短経路
int E,V; //辺の数，頂点数
void wf(){
	rep(k,0,V)
		rep(i,0,V)
			rep(j,0,V)
				d[i][j] = min(d[i][j] , d[i][k] + d[k][j] );
}

//入力
void make(){
	rep(i,0,E){
		int u,v,c;
		cin>>u>>v>>c;
		u--; v--;
		d[u][v] = c;
		d[v][u] = c;
	}
}

//初期化
void init(){
	rep(i,0,V){
		rep(j,0,V){
			if( i == j ) d[i][j] = 0;
			else d[i][j] = INF;
		}
	}
}

int main(){
	int r;
	cin >> V >> E >> r;
	
	vector<int> v(r);
	rep(i,0,r){	
		cin >> v[i];
		v[i]--;
	}
	init();
	make();
	wf();
	vsort(v);
	/*
	rep(i,0,V){
		rep(j,0,V){
			cout << d[i][j] <<" ";
		}
		cout << endl;
	}
	*/	
	ll ans = numeric_limits<ll>::max();

	do{
		ll sum = 0;
		int bef = v[0];
		rep(i,1,r){
			//cout << v[i] << " " << bef << " " << d[v[i]][bef] << endl;
			sum += d[v[i]][bef];
			bef = v[i];
		}
		ans = min(ans,sum);
	}while(next_permutation(v.begin(),v.end()));
	
	cout << ans << endl;
	ret 0;
}

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

int ans;
string q = "a";

int main() {
    for (; q!="0";) {
        cin >> q;
        if (q=="0") return 0;
        for (int i=0; i<q.length(); i++) ans+=(q[i]-48);
        cout << ans << endl;
        ans = 0;
    }
}


Measured memory_bytes: 3144
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, [ $t:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
  }
  let mut count = vec![vec![0i64; 10]; 10];
  for i in 1 .. n + 1 {
    let tail = i % 10;
    let mut head = i;
    while head >= 10 {
      head /= 10;
    }
    count[head][tail] += 1;
  }
  let mut ans = 0;
  for a in 0 .. 10 {
    for b in 0 .. 10 {
      ans += count[a][b] * count[b][a];
    }
  }

  puts!("{}\n", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int d[1000];

void dfs(int v, int p, int dep, const vvi& g) {
  d[v] = dep;
  assert(v < g.size());
  for (int nv : g[v]) {
    if (nv == p) continue;
    dfs(nv, v, dep + 1, g);
  }
}

ll solve(const vvi & g, int root) {
  dfs(root, -1, 0, g);
  vl sz(g.size());
  for (int t = g.size() - 1; t >= 0; --t) {
    int maxdeg = -1;
    for (int i = 0; i < (int)g.size(); ++i) if (d[i] == t) {
      maxdeg = max(maxdeg, (int)g[i].size());
    }
    if (t) --maxdeg;
    if (maxdeg < 0) continue;
    sz[t] = sz[t + 1] * maxdeg;
    if (maxdeg == 0) {
      sz[t]++;
    }
  }
  return sz[0];
}

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  vvi g;
  int n;
  cin >> n;
  g.resize(n);
  for (int i = 0; i < n-1; ++i) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vi mad(n);
  int mi = n;
  for (int i = 0; i < n; ++i) {
    dfs(i, -1, 0, g);
    for (int j = 0; j < n; ++j) mad[i] = max(mad[i], d[j]);
    mi = min(mi, mad[i]);
  }
  vi roots;
  for (int i = 0; i < n; ++i) if (mad[i] == mi) roots.push_back(i);
  assert(roots.size() && roots.size() < 3);
  if (roots.size() == 1) cout << mi + 1 << ' ';
  else cout << mi << ' ';
  if (roots.size() == 2) {
    g.resize(n + 1);
    for (int t = 0; t < 2; ++t) {
      g[roots[t]].erase(find(g[roots[t]].begin(), g[roots[t]].end(), roots[1-t]));
      g[n].push_back(roots[t]);
      g[roots[t]].push_back(n);
    }
    cout << solve(g, n) << endl;
  } else {
    ll res = solve(g, roots[0]);
    vi cands = g[roots[0]];
    g.resize(n + 1);
    g[n].push_back(roots[0]);
    g[roots[0]].push_back(n);
    for (int v : cands) {
      g[roots[0]].erase(find(g[roots[0]].begin(), g[roots[0]].end(), v));
      g[v].erase(find(g[v].begin(), g[v].end(), roots[0]));
      g[n].push_back(v);
      g[v].push_back(n);
      res = min(res, solve(g, n));
      g[n].pop_back();
      g[v].pop_back();
      g[roots[0]].push_back(v);
      g[v].push_back(roots[0]);
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


class Main{
    public static void main(String[] args){
        InputStreamReader inputStreamReader = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(inputStreamReader);
        boolean firstTime = true;

        String str;
        int[] num;
        try {
            while(reader.ready()){
                str = reader.readLine();
                if (firstTime) {
                    firstTime = false;
                }
                else{
                    num = getNum(str);
                    if (gudgeRightTriangle(num))
                        System.out.println("YES");
                    else
                        System.out.println("NO");
                }
            }   
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static int[] getNum(String str){
        String[] data = str.split(" "); 
        int[] num = new int[data.length];

        for (int i = 0; i < data.length; i++){
            num[i] = Integer.parseInt(data[i]);
        }
        return num;
    }

    private static long cntDigit(int num) {
        int n = 1;
        while(num >= 10) {
            n++;
            num /= 10;
        }
        return n;
    }

    private static boolean gudgeRightTriangle(int[] num) {
        Arrays.sort(num);
        
        if ((num[2] * num[2]) == (num[0] * num[0]) + (num[1] * num[1]))
            return true;
        else 
            return false;
    }
}


Measured memory_bytes: 26188
b = [0 for i in range(28)]
d = {
    "a":1,
    "b":2,
    "c":3,
    "d":4,
    "e":5,
    "f":6,
    "g":7,
    "h":8,
    "i":9,
    "j":10,
    "k":11,
    "l":12,
    "m":13,
    "n":14,
    "o":15,
    "p":16,
    "q":17,
    "r":18,
    "s":19,
    "t":20,
    "u":21,
    "v":22,
    "w":23,
    "x":24,
    "y":25,
    "z":26
}
while(True):
  try:
    a = input()
  except:
    break
  if a == "":
    break
  a = str.lower(a)
  a = list(a)

  for i in a:
    if i in d:
      b[d[i]-1] = b[d[i]-1] + 1

for key in d:
  print(key, b[d[key]-1],sep=" : ")



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

int main(){
    int n;
    cin >> n;
    vector<int> a(1<<n);
    for(int i=0;i<(1<<n);i++){
        cin >> a[i];
    }
    bool ok = true;
    if(a[0]==1) ok=false;
    if(a[(1<<n)-1]==0) ok=false;
    int ans = 0;
    for(int S=1;S<(1<<n);S++){
        bool f = true;
        for(int i=0;i<n;i++){
            if((S>>i)&1){
                int T = S^(1<<i);
                if(a[S]==0 && a[T]==1) ok = false;
                f &= a[T] == 0;
            }
        }
        if(f && a[S]==1) ans++;
    }
    cout << (ok ? ans : -1) << endl;
    return 0;
}


Measured memory_bytes: 7064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

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

int h,w,cnt;

void dfs(vc<vc<char>> &C,int hh,int ww){
    rep(k,8){
        int a=hh+dx[k],b=ww+dy[k];
        if(a<h && a>=0 && b<w && b>=0){
            if(C[a][b]=='1'){
                C[a][b]='0';
                dfs(C,a,b);
            }
        }
    }
}

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

    while(true){
        cin >> w >> h;
        cnt=0;
        if(h==0 && w==0) break;
        vc<vc<char>> c(h,vc<char>(w));
        rep(i,h) rep(j,w) cin >> c[i][j];
        rep(i,h){
            rep(j,w){
                if(c[i][j]=='1'){
                    cnt++;
                    c[i][j]='0';
                    dfs(c,i,j);
                }
            }
        }
        cout << cnt << "\n";
    }
}


Measured memory_bytes: 3260
'''
ABC050 A - Addition and Subtraction Easy
https://atcoder.jp/contests/abc050/tasks/abc050_a
'''
def main():
    a, op, b = input().split()
    a, b = int(a), int(b)

    if op == '+':
        ans = a+b
    elif op == '-':
        ans = a-b
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9016
b = int(input())
a = input()
mc = 0
for i in range(1, len(a)):
    b = a[:i]
    c = a[i:]
    d = {}
    e = []
    cnt = 0
    for j in range(len(b)):
        d[b[j]] = 1
    for j in range(len(c)):
        if c[j] in d and c[j] not in e:
            cnt += 1
            e.append(c[j])
    mc = max(mc, cnt)
print(mc)


Measured memory_bytes: 3188
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
	auto data = readln.split;
	auto N = data[0].to!int, M = data[1].to!int;
	auto D = M / N;
	if (D == 1) { writeln(1); return; }
	foreach_reverse (i; 1 .. D+1) {
		if (M%i == 0) { writeln(i); return; }
	}
}

Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

N = NI()

d = [1 for _ in range(100)]

for i in range(1,N+1):
    j = 2
    while i > 1:
        if i % j == 0:
            d[j] += 1
            i //= j
        else:
            j += 1
n3 = 0
n5 = 0
n15 = 0
n25 = 0
n75 = 0
for x in d:
    if x >= 3: n3 += 1
    if x >= 5: n5 += 1
    if x >=15: n15 +=1
    if x >=25: n25 +=1
    if x >=75: n75 +=1
ans = (n3-n5) * ((n5) * (n5-1) // 2) + (n5) * (n5-1) * (n5-2) // 2
ans += (n5 - n15) * n15 + (n15) * (n15-1)
ans += (n3 - n25) * n25 + (n25) * (n25-1)
ans += n75
print (ans)



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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int res = 0;
  for (int a = 0; a <= A; ++a) {
    for (int b = 0; b <= B; ++b) {
      for (int c = 0; c <= C; ++c) {
        int total = 500*a + 100*b + 50*c; // 合計金額
        if (total == X) ++res; // 合計金額が X に一致したら答えをインクリメント
      }
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    cin>>a>>b;
    c=a*b;
    if(c%2!=0){
        cout<<"Odd";
    }else{
        cout<<"Even";
    }
    cin>>a>>b;
    return 0;
}


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

#define ll long long
#define ld long double
#define ii pair<int ,int >
#define S second
#define F first
#define PI 3.1415926535897932384626
#define SPEED std::ios_base::sync_with_stdio(false);

ll n,A,a[55],mem[55][55][2550];

ll dp(int i,int j,int sum){
    if(i==n){
        if(j>0 && sum%j==0 && sum==j*A) return 1LL;
        return 0LL;
    }
    ll &ret = mem[i][j][sum];
    if(ret!=-1)return ret;

    ll p1,p2;
    p1 = dp(i+1,j+1,sum+a[i]);
    p2 = dp(i+1,j,sum);

    return ret = p1+p2;
}

int main(){
    SPEED
    cin>>n>>A;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    memset(mem,-1,sizeof mem);
    cout<<dp(0,0,0);

}


Measured memory_bytes: 60544
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define inf 1001001001001000
#define mod 1000000007
#define pi 3.1415926535
using namespace std;
ll dp[101][4][2];
int main(void){
    string n;
    cin>>n;
    ll K;
    cin>>K;
    dp[0][0][1] = 1;
    rep(i,n.size()) rep(j,K+1) rep(k,2){
        rep(l,10){
            ll ni=i+1,nj=j,nk=k;
            if(l != 0) nj++;
            if(nj > K) continue;
            if(k == 1){
                if(l<n[i]-'0') nk = 0;
                if(l>n[i]-'0') continue;
            }
            dp[ni][nj][nk] += dp[i][j][k];
        }
    }
    ll ans = dp[n.size()][K][0]+dp[n.size()][K][1];
    cout<<ans<<endl;
}


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

int main()
{   
    string S;
    cin >> S;
    int max=0;
    int temp=0;
    for(int i=0;i<S.length();i++){
        if(S[i]=='A' || S[i]=='C' || S[i]=='G' || S[i]=='T'){
            temp++;
            if(temp>max){
                max=temp;
            }
        }else{
            temp=0;
        }
    }
    cout<<max<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
    int a[100005];
    int n;
    cin>>n;
    int i;
    for(i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
 
    long long j=0,r=0,t=0;
    for(i=n; i>0; i--)
    {
        if(a[i]!=t)
        {
            t=a[i];
        }
        else
        {
            break;
        }
    }
 
    for(j=i-1; j>0; j--)
    {
        if(a[j]!=r)
        {
            r=a[j];
        }
        else
        {
            break;
        }
    }
 
    if(i==0||j==0)
    {
        cout<<"0"<<endl;
    }
    else
    {
        printf("%lld",t*r);
    }
 
    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
	#include<algorithm>
	using namespace std;
	int main()
	{
		int n;
		long long a[100005];
		int i;
		scanf("%d",&n);
		for(i=0;i<n;i++)
		{
			scanf("%lld",&a[i]);
		}
		
		sort(a,a+i);
		int t=0,z=0;
		long long w=0;
		long long q[2]={0,0};
		for(int j=n-1;j>=0;j--)
		{
	
			if(a[j]==w)
			{
				t++;
				if(t==2)
				{
					q[z++]=w;
					t=0;
				}
				if(z==2)
					break;	
			}
			else
			{
				w=a[j];
				t=1;
			}
				
		}
		
		printf("%lld",q[0]*q[1]);
		
	
		return 0;
	}

Measured memory_bytes: 896
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>

typedef long long ll;

using namespace std;

int main(){

    int n,a,b;
    cin>>n>>a>>b;

    if(a*n>b){
        cout<<b<<endl;
    }
    else{
        cout<<a*n<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define ll long long
    #define int long long
    #define pb push_back
    #define For(i,n) for(ll  i=0;i<n;i++)
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;clock_t clk = clock();
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define ld long double
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define fi first
    #define se second
    #define pii pair<ll,ll>
    #define endl "\n"
    #define sz(x) (int)(x).size()
    #define what_is(x) cerr << #x << " is " << x << endl;
    #define time cerr << "Time (in ms): " << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';
    const double pi=3.14159265358979323846264;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
/*.....................................................................................................................*/

    ll mod =(ll)1e9+7;
    ll add(ll x,ll y) {return (x+y)%mod;}
    ll mult(ll x, ll y){return ((x%mod )* (y%mod)) % mod;}
    long long binpow(long long x, long long p) 
    {
        if (p == 0) return 1;
    	if (p == 2 || (p & 1)) return mult(x, binpow(x, p - 1));
    	return binpow(binpow(x, p / 2), 2);
    }
    ll modinv(ll a) {return binpow(a,mod-2);}

    // bool check(ll y){}
    ll binsearch(ll l,ll r)
    {
        // while(r-l>1)
        // {
        //     ll mid=(l+r)/2;
        //     if(check(mid))l=mid;
        //     else r=mid;
        // }
        return l;
    }
    const ll man=(ll)1e3+5;
    vector<ll>adj[man];
    bool vis[man][man];
    ll d[man],depth[man],par[man];
    void addedge(ll u,ll v){adj[u].pb(v);adj[v].pb(u);}
    ll dx[4]={1,-1,0,0};ll dy[4]={0,0,1,-1};
/*........................................................................................................................*/

signed main()/*Check flow...question galat mat padhna */
{
    fast;
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<min(b/a,c)<<endl;
}


Measured memory_bytes: 3684
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
//----------------------------------------------------------------

int MOD = 998244353;
// int MOD = 1000000007;
ll bitpow(ll x,ll n){
    ll ans = 1;
    while(n > 0){
        if(n%2 == 1) ans = ans * x % MOD;
        x = x * x %MOD;
        n = n >> 1;
    }
    return ans;
}
ll d[100010] = {0};
//----------------------------------------------------------------
signed main(){
   
    int n;
	cin >> n;
	ll mx = -1;
	
	rep(i,n){
		ll v;
		cin >> v;
		if(i == 0 && v != 0){
			cout << 0 << endl;
			return 0;
		}

		d[v]++;
		mx = max(mx,v);
	}

	if(d[0] != 1){
		cout << 0 << endl;
		return 0;
	}

	ll ans = 1;
	for(int i = 0;i<mx;i++){
		if(d[i] == 0){
			cout << 0 << endl;
			return 0;
		}
		ans *= bitpow(d[i],d[i+1]);
		ans %= MOD;
	}

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

//----------------------------------------------------------------

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://nikkei2019-2-qual.contest.atcoder.jp/tasks/nikkei2019_2_qual_b
// rm -r -f test;oj dl https://abc144.contest.atcoder.jp/tasks/abc144_b


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

int main(){
  int N;
  int a;
  int count=0;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>a;
    if(a%4==0)count+=2;
    else if(a%2==0)count++;
  }
  if(N%2==0){
    if(N-count<=0)cout<<"Yes";
    else cout<<"No";
  }else{
    if(N-count<=1)cout<<"Yes";
    else cout<<"No";
  }
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

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

using namespace std;
typedef long long ll;

int main()
{
    // Input
    ll d, t, s;
    cin >> d >> t >> s;

    if (d <= t * s) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}


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

int main(){
    int x1,x2,x3,x4,x5;
    cin >> x1 >> x2 >> x3 >> x4 >> x5;
    int ans = 0;
    if(x1 == 0){ans = 1;}
    if(x2 == 0){ans = 2;}
    if(x3 == 0){ans = 3;}
    if(x4 == 0){ans = 4;}
    if(x5 == 0){ans = 5;}
    cout << ans << endl;
    return 0;
}


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

#define rep(i, N) for(int i = 0; i < (int)N; i++)
#define ll long long
const ll INF = 2LL<<60;
const int mod = 1000000007;

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

    vector<int> a(M, 0);
    rep(i,M) cin >> a[i];
    
    int dp[100002] = {0};

    rep(i,M)
    {
        int pos = a[i];

        //床が破損している
        dp[pos] = -1;
    }

    dp[0] = 1;

    rep(i, N)
    {  
        if(dp[i] == -1)   continue;

        if(dp[i + 1] != -1)
        {
            dp[i + 1] += dp[i];
            dp[i + 1] %= mod;
        }

        if(dp[i + 2] != -1)
        {
            dp[i + 2] += dp[i];
            dp[i + 2] %= mod;
        }
    }
    
    cout << dp[N] << endl;
    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef pair<int,double> pib;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define IO(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout);
const int INF = 0x3f3f3f3f;
int main()
{

   int A,B,C,D,E,F;
   scanf("%d%d%d%d%d%d",&A,&B,&C,&D,&E,&F);
   double du=0;
   int all=0,su=0;
   for(int i=0;i<=40;i++)
   {
      for(int j=0;j<=40;j++)
      {
         for(int k=0;k<=40;k++)
         {
            for(int q=0;q<=40;q++)
            {
               int sum=100*A*i+100*B*j+k*C+q*D;
               if(sum<=F&&k*C+q*D<=i*A*E+j*B*E)
               {
                  double t=(double)(k*C+q*D)/(sum);
                  if(t>=du)
                  {
                  du=t;
                  all=sum;
                  su=k*C+q*D;
                  }
               }

            }
         }
      }
   }
   printf("%d %d",all,su);
 return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
  int A1, A2, A3;
  std::cin >> A1 >> A2 >> A3;

  if (A1 + A2 + A3 >= 22) {
    std::cout << "bust";
  } else {
    std::cout << "win";
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define MOD           1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define endl "\n"
#define PI 3.14159265358979323846264338327950L
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int fc[100001], in[100001];
/*int pwmd(int a, int n)
{
	if (!n)
		return 1;
	int pt = pwmd(a, n / 2);
	pt *= pt, pt %= mod;
	if (n & 1)
		pt *= a, pt %= mod;
	return pt;
}*/

/*void dfs(int i,int par)
{
	for(int x:adj[i])
	{
		if(x!=par)
		{
			dfs(x,i);
		    sub[i]+=sub[x];
		}
	}
}*/
int pow(int a, int b, int m)
{
	int ans = 1;
	while (b > 0)
	{
		if (b % 2 == 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans % m;
}
/*vector<int> sq(5002);
void pre()
{
	for (int i = 0; i <= 5000; ++i)
		sq.pb(i * i);
}*/

bool compare(pair<int, pair<int, int>> a, pair<int, pair<int, int>> b)
{
	if (a.ss.ff != b.ss.ff)
		return (a.ss.ff > b.ss.ff);
	else
		return (a.ff < b.ff);
}
bool comp(string a, string b)
{
	if (a.size() == b.size())
		return a < b;
	return a.size() < b.size();
}
int32_t main()
{
	FIO;
	int n, k;
	cin >> n >> k;

	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];

	sort(a.begin(), a.end());
	int sum = 0;
	for (int i = 0; i < min(k, n); i++)
		sum += a[i];

	cout << sum << endl;

}


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

#define ll long long;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int N;
  cin >> N;
  map<string, int> m;
  for (int i = 0; i < N; ++i) {
    string s;
    cin >> s;
    m[s] += 1;
  }
  for (string s : {"AC", "WA", "TLE", "RE"})
    cout << s << " x " << m[s] << "\n";
}



Measured memory_bytes: 3652
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    // 数値の配列を作る
    const numList0 = input[0].split(' ').map(x => parseInt(x, 10));
    const N = numList0[0];
    const aList = input[1].split(' ').map(x => parseInt(x, 10));

    var sum = 0;
    for (var i = 0; i < N; i++) {
        var a = aList[i];
        sum += 1 / a;
    }

    console.log(1 / sum);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
alphabet="abcdefghijklmnopqrstuvwxyz"

N=int(input())

left = N-1

ans = ""
while True:
    idx = left % 26
    left = left // 26 -1 
    ans = alphabet[idx] + ans
    # print(left,idx,ans)

    if left == -1:
        break

print(ans)

Measured memory_bytes: 9164
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        arc076_a solver = new arc076_a();
        solver.solve(1, in, out);
        out.close();
    }

    static class arc076_a {
        static long MOD = (long) (1e9 + 7);

        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.Int();
            int M = in.Int();
            if (Math.abs(N - M) > 1) {
                out.println(0);
                return;
            }

            long n = 1;
            for (int i = 2; i <= N; i++) {
                n *= i;
                n %= MOD;
            }
            long m = 1;
            for (int i = 2; i <= M; i++) {
                m *= i;
                m %= MOD;
            }
            long ans = n * m % MOD;
            if (N == M) ans *= 2;
            ans %= MOD;
            out.println(ans);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23508
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int x, n;
	cin >> x >> n;
	if (n == 0) {
		cout << x;
		return 0;
	}
	vector<int>  p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	int c=0;
	bool f1 = 0, f2 = 0;
	while (1) {
		for (int i = 0; i < n; i++) {
			if (x - c == p[i])
				f1 = 1;
			if (x + c == p[i])
				f2 = 1;
		}
		if (!f1) {
			cout << x - c;
			return 0;
		}
		if (!f2) {
			cout << x + c;
			return 0;
		}
		c++;
		f1 = 0; f2 = 0;
	}
}

Measured memory_bytes: 3636
#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 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> ;

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};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  map<int,int> m;
  int n;
  cin >> n;
  rep(i,n){
    m[i+1] = 0;
  }
  int a,v;
  rep(i,n){
    cin >> a >> v;
    m[a] = v;
  }
  int ma = -1;
  REP(i,1,n+1){
    if(ma < m[i]){
      a = i;
      ma = m[i];
    }
//     cout << i << " " << m[i]<<endl;
  }
  cout << a << " " << ma << endl;
  return 0;
}

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

using namespace std;
int main()
{
  int arr[3];
  int cost=0;
  for(int i = 0 ; i < 3;i++)
  cin>>arr[i];
  sort(arr,arr+3);
  for(int i =0 ; i < 2; i++)
  {
  cost+=abs(arr[i+1]-arr[i]);
  }
  cout<<cost;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);

static const int INF = (1<<21);
static const int N = 2010;
vector <int> ans(N);
int n, x, y;

void bfs(int s){
  //cout << "start BFS" << s << endl;
  vector<int> d(n);
  REP(i,n) d[i] = INF;

  queue<int> q;
  q.push(s);
  int now;
  now = s;
  d[now] = 0;
  while( !q.empty()){
    now = q.front(); q.pop();
    //if(d[now] != INF) continue; //既に訪れていたら飛ばす
    if(now == x) {
      //cout << "1" << endl;
      if(d[y] == INF){
        d[y] = d[now] + 1;
        q.push(y);
      }
    }

    if(now == y){
      //cout << "2" << endl;
      if(d[x] == INF){
        d[x] = d[now] + 1;
        q.push(x);
      }
    }
    if(now - 1 >= 0){
      //cout << "3" << endl;
      if(d[now-1] == INF){
        d[now - 1] = d[now] + 1;
        q.push(now-1);
      }
    }
    if(now + 1 < n){
      //cout << "4" << endl;
     if (d[now+1] == INF){
       d[now + 1] = d[now] + 1;
       q.push(now+1);
     }
    }
  }
  REP(i,n) ans[d[i]]++; //始点からの距離ごとに集計
}

int main(){
  cin >> n >> x >> y;
  --x; --y;

  REP(i,n) ans[i] = 0;

  REP(i,n){
    bfs(i);
  }
//各頂点ごとに双方向から調べているため，半分に．
  REP(i,n) ans[i] /= 2;

//OUTPUT
//cout << " ans " << endl;
  REP2(i,1,n){
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 3592