akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define pll pair<ll,ll>
#define pii pair<int,int>
#define F first
#define S second
const int maxn = 2e5 + 5;
const double eps = 1e-14;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long double a, b, c;
    while(cin >> a >> b >> c) {
    if (sqrt(a) + sqrt(b) + eps < sqrt(c)) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
}
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N, M;
	string S;
	bool flag = true;
	vector<int> ans, res;
	
	cin>>N>>M;
	
	cin>>S;
	
	// reverse(S.begin(), S.end());
	
	ans.push_back(N);
	
	for(int i = N-1, j = 0; i >= 0; i--){
		
		// cout<<S[i]<<" i = "<<i<<" ans j = "<<ans[j]<<" - "<<i<<endl;
		if(S[i] == '1') continue;
		if(ans[j] - i <= M) {
			if(ans.size() >= j + 1 + 1) ans.back() = i;
			else ans.push_back(i);
		} else {
			j++;
			ans.push_back(i);
		}
	}
	
	// for(int i = ans.size()-1; i >= 1; i--){
	for(int i = 1; i < ans.size(); i++){ //cout<<ans[i]<<endl;
		res.push_back(ans[i-1] - ans[i]);
		if(res.back() > M) flag = false;
	}
	
	if(flag == false){
		cout<<-1<<endl;
		return 0;
	}
	
	// for(int i = 0; i < res.size(); i++){
	for(int i = 0; i < res.size(); i++){
		if(i) cout<<" ";
		cout<<res[res.size() - i-1];
	}
	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 2628
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#define FOR(i, a, b)  for(int i=a; i<b; ++i)
#define rFOR(i, a, b) for(int i=a-1; i>=b; --i)
#define REP(i, n) for(int i=0; i<n; ++i)
#define rREP(i, n) for(int i=n-1; i>=0; --i)
#define all(a)  a.begin(), a.end()
#define MAXNUM 1024
using namespace std;
typedef long long ll;

int main(){
  int n; cin >> n;
  string dict[10] = {
    {""},
    {".,!? "},
    {"abc"},
    {"def"},
    {"ghi"},
    {"jkl"},
    {"mno"},
    {"pqrs"},
    {"tuv"},
    {"wxyz"},
  };

  REP(i, n){
    string input;  cin >> input;
    int num = 0, cnt=-1;
    REP(j, input.length()){
      if(input[j] != '0'){
        if(num==0)  num = input[j] - '0';
        cnt++;
        continue;
      }else{
        if(num!=0){
          cnt %= dict[num].length();
          cout << dict[num][cnt];
          cnt = -1;
          num = 0;
        }
      }
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3024
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N, D, X;
  cin >> N >> D >> X;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    sum += 1 + (D - 1) / a;
  }
  cout << X + sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <functional>
#include <set>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
	ll k, N;
	string s;

	cin >> k >> s;

	N = (ll)(s.length());

	if (k >= N){
		cout << s << endl;
	}
	else{
		cout << s.erase(k) << "..." << endl;
	}

	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

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

    int d = 1000000, sum = 0, c = -1;
    REP(i, n) sum += (l + i);

    REP(i, n){
        int s = 0;
        REP(j, n) {
            if(i == j) continue;
            s += l + j;
        }

        if(d > abs(sum - s)) {
            d = abs(sum - s);
            c = s;
        }
    }

    cout << c << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define hell                         1000000007
#define hell2                        998244353
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define all(v)                       v.begin(),v.end()
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(ll i=a;i<b;i++)
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'
 
const ll MAX=1000005;
const ll SQN=330;
const ll LG=22;
const double PI=atan(1)*4;
using namespace std;

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

    ll n,m,x;
    cin >> n >> m >> x;
    ll c[n];
    ll a[n][m];
    rep(i,0,n) {
    	cin >> c[i];
    	rep(j,0,m) cin >> a[i][j];
    }

    ll ans=hell;

    rep(i,0,(1<<n)) {
    	ll sm[m]={0};
    	ll cost=0;
    	for(ll j=0;j<n;j++) {
    		if((i>>j)&1) {
    			cost+=c[j];
    			for(ll k=0;k<m;k++) {
    				sm[k]+=a[j][k];
    			}
    		}
    	}
    	ll flag=0;
    	rep(k,0,m) {
    		if(sm[k]<x) {
    			flag=1;
    			break;
    		}
    	} 
    	if(!flag) ans=min(ans,cost);
    }
    if(ans==hell) ret(-1);
    ret(ans);
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int a = sc.nextInt();
			int b = sc.nextInt();

			int ans = 0;
			for (int i = 1; i <= n; i++) {
				int checkNum = (i / 10000) +
						((i % 10000) / 1000) +
						((i % 1000) / 100) +
						((i % 100) / 10) +
						(i % 10);
				if (checkNum >= a && checkNum <= b) {
					ans += i;
				}
			}

			System.out.println(ans);

			sc.close();
		}
}

Measured memory_bytes: 23252
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    L=list(map(int,input().split()))
    even=[False]*3
    ans=0
    for i in range(3):
        if L[i]%2==0:
            even[i]=True

    M=L.index(max(L))
    if even.count(even[M]) in [1,3]:
        ans+=(max(L)*3-sum(L))//2
    else:
        ans+=1
        ans+=((max(L)+1)*3-(sum(L)+2))//2


    print(ans)






resolve()

Measured memory_bytes: 38256
A,B,C,x,y = map(int,input().split())
a = 0
b = 0
c = 0
if C*2 >= A + B:
    print (A*x+B*y)
    exit(0)

if C * 2 <= A and C * 2 <= B:
    print (max(x,y) * 2 * C)
    exit(0)

if x > y:
    if A >= C * 2:
        c = x * 2
    else:
        c = y * 2
        a = (x-y)
else:
    if B >= C * 2:
        c = y * 2
    else:
        c = x * 2
        b = (y-x)
print(A*a + B*b + C*c)

Measured memory_bytes: 38512
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
 	int a, b, m, minrei = MOD, minden = MOD;
 	cin >> a >> b >> m;
 	int rei[100001];
 	int den[100001];
 	for (int i = 1; i <= a; i++){
 		cin >> rei[i];
 		minrei = min(minrei, rei[i]);
 	}
 	for (int i = 1; i <= b; i++){
 		cin >> den[i];
 		minden = min(minden, den[i]);
 	}
 	int ans = minrei + minden;
 	for (int i = 0; i < m; i++){
 		int x, y, c;
 		cin >> x >> y >> c;
 		ans = min(ans, rei[x] + den[y] - c);
 	}
 	cout << ans << endl;
	return 0;
}


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

long long int dp[100005][4];
const long long int mod=1e9+7;
int main(){
    string S;
    cin >> S;
    long long int ans=0;
    dp[0][0]=1;
    for(int i=0;i<S.length();i++){
        if(S[i]=='A'){
            for(int j=0;j<4;j++)(dp[i+1][j] += dp[i][j])%=mod;
            (dp[i+1][1] += dp[i][0])%=mod;
        }
        else if(S[i]=='B'){
            for(int j=0;j<4;j++)(dp[i+1][j] += dp[i][j])%=mod;
            (dp[i+1][2] += dp[i][1])%=mod;
        }
        else if(S[i]=='C'){
            for(int j=0;j<4;j++)(dp[i+1][j] += dp[i][j])%=mod;
            (dp[i+1][3] += dp[i][2])%=mod;
        }
        else{
            for(int j=0;j<4;j++){
                (dp[i+1][j] += 3 * dp[i][j])%=mod;
                if(j<3)(dp[i+1][j+1] += dp[i][j])%=mod;
            }
        }
    }
    cout << dp[S.length()][3] << endl;
}

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

using namespace std;

int main()
{
    int l;
    cin >> l;
    double best = 0;
    double bestI = -1;
    double bestJ = -1;
    double cur;
    for (double i = 0.0; i < l; i += 0.05)
    {
        for (double j = 0.0; j < l; j += 0.05)
        {
            cur = i * j * (l - i - j);
            if (cur > best)
            {
                best = cur;
                bestI = i;
                bestJ = j;
            }
        }
    }
    best = 0;
    for (double i = bestI - 0.1; i < bestI+0.1; i += 0.0001)
    {
        for (double j = bestI - 0.1; j < bestI+0.1; j += 0.0001)
        {
            cur = i * j * (l - i - j);
            if (cur > best)
            {
                best = cur;
            }
        }
    }
    cout.precision(12);
    cout << fixed <<  best << endl;
    return 0;
}

/*using namespace std;
 
int main() {
	return 0;
}

using namespace std;
 
int main() {
	return 0;
}

using namespace std;
 
int main() {
	return 0;
}*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main(){
  int n,k,l;
  cin >> n >> k >> l;
  double ans=(n+k)*l/2.0;
  cout << ans <<endl;
  return 0;
}


Measured memory_bytes: 256
Scanf.scanf "%d %d" (fun n m ->
    let par = Array.init n (fun i -> i) in
    let size = Array.make n 1 in

    let rec root x =
        if par.(x) = x then x else
            let r = root par.(x) in
            let () = par.(x) <- r in
            r
    in

    let merge a b =
        if root a <> root b then (
            size.(par.(a)) <- size.(par.(a)) + size.(par.(b));
            par.(par.(b)) <- par.(a)
        )
    in
    for i = 1 to m do
        Scanf.scanf " %d %d" (fun a b -> merge (a - 1) (b - 1)
        )
    done;

    let rec loop i acc =
        if i = n then acc else loop (i + 1) (max acc size.(root i))
    in
    loop 0 0 |> Printf.printf "%d\n"
)


Measured memory_bytes: 9252
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();
		
		if(A==2||B==2){
			System.out.println("No");
		}else{
			System.out.println("Yes");
		}		
	}
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

template <class T>
void cout_vec2(const vector<vector<T>> &vec){
  rep(i,vec.size()){
    rep(j,vec[i].size()){
      cout<<vec[i][j]<<' ';
    }
    cout<<endl;
  }
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

ll n,k;
vector<ll> a(200010),f(200010);

bool solve(ll x){
  ll ret=k;
  rep(i,n){
    if(a[i]*f[i]<=x) continue;
    ll now=(a[i]*f[i]-x+f[i]-1)/f[i];
    if(now<=ret) ret-=now;
    else{
      return false;
    }
  }
  return true;
}


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>k;
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>f[i];
  sort(begin(a),begin(a)+n);
  sort(begin(f),begin(f)+n,greater<ll>());
  ll ans=0;
  ll high=1e18,low=-1,mid;
  while(high-low>1){
    mid=(high+low)/2;
    if(solve(mid)) high=mid;
    else low=mid;
  }
  cout<<high<<endl;
}

Measured memory_bytes: 3456
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: i128,
        k : i128,
        d: i128,
    }

    let n = n.abs();
    let cnt : i128 = n/d;

    if k <= cnt{
        println!("{}",n - k*d);
        return;
    }

    if k%2 == cnt%2{
        println!("{}",n - cnt*d);
    }else{
        println!("{}",(n - (cnt+1) * d).abs());
    }


}


Measured memory_bytes: 2160
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

typedef long long ll;

using namespace std;
//using namespace boost::multiprecision;


int main(){

    int n;
    string s;
    cin >> n;
    cin >> s;

    //1匹目と2匹目を決め打ちしてそのあと、3匹目以降をsに従って、
    //順に決めていったときに、n匹目の動物が矛盾しないかをみる。

    //1を羊、0を狼とする
    vector<int> animals(n);

    function<int(int, int, char)> get_animal = [=](int n0, int n1, char c1) -> int{

        if(n1){
            if(c1 == 'o'){
                return n0;
            }else{
                return 1 - n0;
            }
        }else{
            if(c1 == 'o'){
                return 1 - n0;
            }else{
                return n0;
            }
        }
    };

    bool able = false;

    rep(i,2){
        rep(j,2){
            animals[0] = i;
            animals[1] = j;
        
            for(int k = 1; k < n - 1; k++){
                animals[k + 1] = get_animal(animals[k - 1], animals[k], s[k]);
            }

            if(get_animal(animals[n - 2], animals[n - 1], s[n - 1]) == animals[0]){
                if(get_animal(animals[n - 1], animals[0], s[0]) == animals[1]){
                    able = true;
                    break;
                }
            }
        }

        if(able){
            break;
        }
    }

    if(able){
        rep(i,n){
            if(animals[i]){
                cout << "S";
            }else{
                cout << "W";
            }
        }
        cout << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //d
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int hi = a[i] + a[j];
      int x = lower_bound(a.begin(), a.end(), hi) - a.begin();
      ans += max(0, x - j - 1);
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,ans=0;
  cin>>n;
  vector<ll> v(n);
  rep(i,n) cin>>v[i];
  sort(ALL(v));
  rep(i,n-2) for(ll j=i+1;j<n-1;j++) ans+=(lower_bound(ALL(v),v[i]+v[j])-v.begin())-j-1;
  cout<<ans<<endl;
}

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

constexpr size_t MAX_H = 3001;
constexpr size_t MAX_W = 3001;

char S[MAX_H][MAX_W];
int I_count[MAX_H][MAX_W];
int O_count[MAX_H][MAX_W];
int H;
int W;

using namespace std;

int main() {
  
  cin >> H >> W;
  char s;

  for (int x=0; x<H; x++) {
    for (int y=0; y<W; y++) {
      cin >> s;
      assert(s == 'J' || s == 'O' || s == 'I');
      S[H-1-x][W-1-y] = s;
    }
  }

  for (int y=0; y<W; y++) {
    int count=0;
    for (int x=0; x<H; x++) {
      if (S[x][y] == 'I') count += 1;
      I_count[x][y] = count;
    }
  }

  for (int x=0; x<H; x++) {
    int count=0;
    for (int y=0; y<W; y++) {
      if (S[x][y] == 'O') count += 1;
      O_count[x][y] = count;
    }
  }

  // for (int x=0; x<H; x++) {
  //   for (int y=0; y<W; y++) {
  //     cout << I_count[x][y];
  //   }
  //   cout << endl;
  // }


  long long ans = 0;

  for (int x=0; x<H; x++) {
    for (int y=0; y<W; y++) {
      if (S[x][y] == 'J') {
        ans += O_count[x][y] * I_count[x][y];
      }
    }
  }

  cout << ans << endl;

  return 0;
}



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

int main() {
  int N, X=0, Y=0, cnt=1;
  cin >> N;
  vector<int> P(N), Q(N), A(N);
  rep(i, N) cin >> P.at(i);
  rep(i, N){
    cin >> Q.at(i);
    A.at(i)=i+1;
  }
  while(next_permutation(A.begin(), A.end())){
    if(A==P) X=cnt;
    if(A==Q) Y=cnt;
    cnt++;
  }
  cout << abs(Y-X) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t=1;
    //cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        ll n=s.length(),i,x=0;
        for(i=0;i<n;i++)
        {
            x=x+(s[i]-'0');
            x=x%9;
        }
        if(x==0)
            cout<<"Yes";
        else
            cout<<"No";
    }
}

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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

const int MOD = (int)1e9 + 7;

// A: 0, G: 1, C: 2, T: 3
int n;
VVI memo;
ll dfs(int i, int a0, int a1, int a2) {
    if(i == n) return 1;
    int a_state = a0 * 100 + a1 * 10 + a2;
    if(memo[i][a_state] != -1) return memo[i][a_state];
    ll sum = 0;
    REP(k, 4) {
        if(a0 == 0 and a2 == 1 and k == 2) continue;
        if(a1 == 0 and a2 == 2 and k == 1) continue;
        if(a0 == 0 and a1 == 1 and k == 2) continue;
        if(a1 == 0 and a2 == 1 and k == 2) continue;
        if(a1 == 1 and a2 == 0 and k == 2) continue;
        sum = (sum + dfs(i + 1, a1, a2, k)) % MOD;
    }
    return memo[i][a_state] = sum;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    memo = VVI(n + 1, VI(400, -1));
    cout << dfs(0, 3, 3, 3) << ln;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;

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

    ll m = 1000;
    ll s = 0;

    vi price(n);
    for(int i = 0; i < n; i++) cin >> price[i];

    for(int i = 0; i < n-1; i++) {
        if(price[i+1] > price[i]) {
            s += (m / price[i]);
            m %= price[i];
        } else if(price[i+1] < price[i]) {
            m += s*price[i];
            s = 0;
        }
    }
    m += s*price[n-1];

    cout << m;

    return 0;
}

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

class Program
{
    public static void Main()
    {
        var N = Int32.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split(' ').Select(x=>Int32.Parse(x)).ToArray();
        var lcm = A[0];
        for (int i =1;i<A.Length;++i)
        {
            var a = A[i] < lcm ? lcm : A[i];
            var b = a == lcm ? A[i]:lcm;
            
            var r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            lcm = (lcm * A[i]) / b;
        }
        decimal ans = (decimal)lcm / (decimal)(A.Select(x => lcm / x).Sum()); 
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13396
N, K = map(int, input().split())
mod = 1000000007
l = 0
r = N
ans = 0
for i in range(1, K):
    l += i
    r += N - i

for i in range(K, N+2):
    ans += r - l + 1
    ans %= mod
    r += N - i
    l += i

print(ans)


Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,i,x;
  cin>>n;

  double ans=0;
  for(i=0;i<n;i++)
  {
    cin>>x;
     ans+=(1.00/x);
  }
  ans=1.00/ans;
  cout<<setprecision(14);
  cout<<ans<<endl;

}

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

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

//UnionFind
int n = 100000;
vector<int> par(n);
vector<int> Size(n);

void init(int n){
  for(int i=0; i<n; i++){
    par.at(i) = i;
    Size.at(i) = 1;
  }
}

int root(int x){
  if(par.at(x) == x){
    return x;
  }
  else{
    return par.at(x) = root(par.at(x));
  }
}

bool same(int x, int y){
  return root(x) == root(y);
}

void unite(int x, int y){
  x = root(x);
  y = root(y);
  if(x == y){
    return;
  }
  if (Size.at(x) < Size.at(y)){
    swap(x, y);
  }
  Size.at(x) += Size.at(y);
  par.at(y) = x;
}

int Size_x(int x){
  return Size.at(root(x));
}


int main(){
  int N, M;
  cin >> N >> M;
  init(N);
  for(int i=0; i<M; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    unite(a,b);
  }
  int64_t ans = 0;
  int64_t A = Size_x(0);
  int64_t B = Size_x(1);
  if(A >= B){
    ans += (N-B)*(N-B-1)/2;
    ans += B*(B-1)/2;
    ans -= M;
  }
  else{
    ans += (N-A)*(N-A-1)/2;
    ans += A*(A-1)/2;
    ans -= M;
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 3904
#include<bits/stdc++.h>
#define ll long long
using namespace std;
signed main(){
  ll n,a[1000000],ans=0;
  ll l[1000000]={},r[1000000]={};
  cin>>n;
  for(ll i=1;i<=n;i++){
    cin>>a[i];
  }
  for(ll i=1;i<=n;i++){
    if(a[i]+1 <= n){
      l[a[i]+i]++;
    }
    if(i-a[i] >= 1){
      r[i-a[i]]++;
    }
  }
  for(ll i=1;i<=n;i++){
    ans += l[i]*r[i];
  }
  cout<<ans<<"\n";
  return 0;
}


Measured memory_bytes: 20812
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int n;
double a[50];
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=1;i<n;i++){
        a[i]=(a[i]+a[i-1])/2;
    }
    cout<<a[n-1]<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
int main(){
    int L,R;
    cin>>L>>R;
    ll x=2000000000;
    if(R-L+1>=2019){
        cout<<0<<endl;
    }
    else{
        ll w=0;
        for(ll i=L;i<R;i++){
            for(ll j=L+1;j<=R;j++){
                ll a=i%2019;
                ll b=j%2019;
                x=min(x,a*b%2019);
            }
        }
        cout<<x<<endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 924844033LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
int dy[4] = {0, 1, 0, -1};
int dx[4] = {1, 0, -1, 0};
int main() {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    if(a > b) {
        ans += 2 * a - 1;
    } else if(a < b) {
        ans += 2 * b - 1;
    } else {
        ans += a + b;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int number_n, i;
  char ch;
  scanf("%d", &number_n);
  for(i = 0; i < number_n; i++) {
    scanf("%c", &ch);
    if(ch == 'Y') break;
  }
  if(i == number_n) {
    printf("Three\n");
  } else {
    printf("Four\n");
  }
  return 0;
}


Measured memory_bytes: 128
readlines.each{|line|
  yyyy,mm,dd = line.split.map(&:to_i)
  if yyyy < 1868 || (yyyy == 1868 && (mm < 9 || (mm == 9 && dd < 8)))
    puts "pre-meiji"
  elsif yyyy < 1912 || (yyyy == 1912 && (mm < 7 || (mm == 7 && dd < 30)))
    puts "meiji #{yyyy-1867} #{mm} #{dd}"
  elsif yyyy < 1926 || (yyyy == 1926 && (mm < 12 || (mm == 12 && dd < 25)))
    puts "taisho #{yyyy-1911} #{mm} #{dd}"
  elsif yyyy < 1989 || (yyyy == 1989 && (mm < 1 || (mm == 1 && dd < 8)))
    puts "showa #{yyyy-1925} #{mm} #{dd}"
  else
    puts "heisei #{yyyy-1988} #{mm} #{dd}"
  end
}

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

double dp[3001][3001];

double solve(vector<double>& ar,int i,int x)
{
    if(x==0)  // no matter how many coins we can get 1 head
        return 1;
    if(i==0)//0 coins
        return 0;

    if(dp[i][x]>-0.9)
       return dp[i][x];

       return dp[i][x] = ar[i]*solve(ar,i-1,x-1)+ (1-ar[i])*solve(ar,i-1,x);

}
int main()
{
    int n;
    cin>>n;
    memset(dp,-1,sizeof dp);
     vector<double>ar(n+1);

     for(int i=1;i<=n;i++)
        cin>>ar[i];

       cout<<fixed<<setprecision(10)<<solve(ar,n,(n+1)/2);
        return 0;
}


Measured memory_bytes: 70784
/*
将这n个二元组看做n个向量。
移动方式遵循平行四边形定则。
所以两个向量夹角越小，相加形成的和向量模长就越大。
所以将这些向量按照极角排序。
选择的向量肯定是一个区间。
枚举左右端点，求最大值即可。
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e2+5;

struct Point{
        int x,y;
}p[MAXN];

bool cmp(Point a,Point b) {
        return atan2(a.y,a.x) < atan2(b.y, b.x);
}

int nx[MAXN];//让它循环
int main() {
        int n;
        cin>>n;
        for(int i=1;i<=n;++i)   cin>>p[i].x>>p[i].y;
        for(int i=1;i<=n;++i)    nx[i] = i+1; nx[n] = 1;
        sort(p+1,p+n+1,cmp);
        ll  ans=0;
        for(int i=1;i<=n;++i) {
                ll x = p[i].x, y = p[i].y;
                ans = max(ans, x * x + y * y);
                for(int j=nx[i];j!=i;j = nx[j]) {
                        x += p[j].x;
                        y += p[j].y;
                        ans = max(ans, x * x + y * y);
                }
        }
        printf("%.10lf\n",sqrt(ans));
        return 0;
}




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

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

  int sum = 0;
  int max_L = 0;
  for (int i = 0; i < N; i++) {
    int L = 0;
    scanf("%d", &L);
    sum += L;
    max_L = max(max_L, L);
  }

  if (max_L < sum - max_L)
    printf("Yes");
  else
    printf("No");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  
  if( c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' ){
  	cout << "vowel" << endl;
  }else{
  	cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
// きりみんちゃんの配信からきました
// 左右をとる+-1のしゃくとり、左がマイナスかつ右がプラスの場合には「左に行った後折り返す」vs「右に行ったあと折り返す」が発生する
// ゼロ含む場合マジでなんなんだよ
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	a := make([]int, n)
	includeZero := false
	zeroIdx := -1
	for i := 0; i < n; i++ {
		var j int
		fmt.Scan(&j)
		a[i] = j
		if j == 0 {
			includeZero = true
			zeroIdx = i
		}
	}
	if includeZero {
		// ゼロを含む場合、よくわかんなかったので値を更新することにした
		if zeroIdx != 0 && zeroIdx != n-1 {
			if abs(a[zeroIdx-1]) < abs(a[zeroIdx+1]) {
				a[zeroIdx] = a[zeroIdx-1]
			} else {
				a[zeroIdx] = a[zeroIdx+1]
			}
		}
	}
	ans := 10000000000000000
	r := 0
	tmp := 0
	// しゃくとりフェーズ
	for l := 0; l <= n-k; l++ {
		for r < n && r-l < k {
			r += 1
		}
		// 更新は3パターン
		if a[r-1] <= 0 {
			// 最大で0より小さい場合
			tmp = a[l] * -1
		} else if a[l] >= 0 {
			// 最小で0より大きい場合
			tmp = a[r-1]
		} else if a[l] < 0 {
			// 最小が0より小さく、最大が0より大きい場合
			// これが無限にバグった原因 0を挟んでいる状態だと右にいくか左にいくかで変わるんだよ（あたりまえ）
			tmp = min(a[l]*-2+a[r-1], a[r-1]*2+a[l]*-1)
		}
		ans = min(ans, tmp)
		tmp -= a[l]
	}
	fmt.Println(ans)
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 5504
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int main(){
  int X;
  cin >> X;
  if(X == 7){
    cout << "YES" << endl;
  }else if(X == 5){
    cout << "YES" << endl;
  }else if(X == 3){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
d=[]
a=[]
for i in range(K):
    d.append(int(input()))
    a.append(list(map(int,input().split())))
    
aa=[0]*N
counts=0

for k in a:
    for j in k:
        aa[j-1]+=1
        
for x in aa:
    if x==0:
        counts+=1

print(counts)

Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

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

    while(N > 0){
        N--;
        LL a = N % 26;
        LL b = N / 26;
        s += ('a' + a % 26);
        N = b;
    }
    rep(i,s.size()){
        cout << s[s.size()-i-1];
    }
    cout << endl;


}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
// #include "ane.cpp"

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 100005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(int)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = (_begin + _end) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


char N,M,K,A,B,C,D,E;
int dp[NMAX] = {};

string S;
vec v;

char ans = {};

void solve(){
  // main algorithm
  if(N < M) {
    ans = '<';
  }
  else if(N > M){
    ans = '>';
  }
  else {
    ans = '=';
  }
}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  cout << ans << endl;
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  cin >> N >> M;
  solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sz(s) (int)(s.size())
#define all(v) v.begin(),v.end()
#define endl "\n"
using namespace std;
ll gcd(ll x, ll y) { return (!y) ? x : gcd(y, x % y); }
void Run() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // freopen("mex.in", "r", stdin);
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin); freopen("outt.txt", "w", stdout);
#endif
}
const int N = 1e5 + 10;
int pfx[N];
int main()
{
    Run();
    string x; cin >> x;
    x == "ABC" ? cout << "ARC" : cout << "ABC";

}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001;
const int INFLL=1001001001001001001ll;
const int mod=1000000007;
inline void add(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}


struct Dinic{
    struct edge{
        int to,cap,rev,id;
        edge(int to,int cap,int rev,int id):to(to),cap(cap),rev(rev),id(id){}
    };

    const int INF=1001001001;
    vector<vector<edge>>G;
    vector<int>level,iter;
    Dinic(int v):G(v),level(v),iter(v){}

    void addEdge(int from,int to,int id){
        G[from].push_back(edge(to,1,G[to].size(),id));
        G[to].push_back(edge(from,1,G[from].size()-1,id));
    }

    void bfs(int s){
        fill(level.begin(),level.end(),-1);
        queue<int>que;
        level[s]=0;
        que.push(s);
        while(que.size()){
            int v=que.front();
            que.pop();
            for(auto &e:G[v]){
                if(e.cap&&level[e.to]==-1){
                    level[e.to]=level[v]+1;
                    que.push(e.to);
                }
            }
        }
    }

    int dfs(int v,int t,int f){
        if(v==t)return f;
        for(int &i=iter[v];i<G[v].size();i++){
            edge &e=G[v][i];
            if(e.cap>0&&level[v]<level[e.to]){
                int d=dfs(e.to,t,min(f,e.cap));
                if(d>0){
                    e.cap-=d;
                    G[e.to][e.rev].cap+=d;
                    return d;
                }
            }
        }
        return 0;
    }

    int maxFlow(int s,int t){
        int flow=0;
        while(true){
            bfs(s);
            if(level[t]<0)return flow;
            fill(iter.begin(),iter.end(),0);
            int f;
            while((f=dfs(s,t,INF))>0)flow+=f;
        }
    }
};

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

    Dinic d(N);
    vint A(M),B(M);
    rep(i,M){
        int a,b;
        cin>>a>>b;
        a--;b--;
        d.addEdge(a,b,i);
        A[i]=a;B[i]=b;
    }


    int src,snk;
    cin>>src>>snk;
    src--;snk--;

    int tmp=d.maxFlow(src,snk);
    vint lis;
    rep(i,N){
        for(auto &e:d.G[i]){
            if(e.cap==0&&A[e.id]!=i){
                lis.pb(e.id);
            }
        }
    }

    printf("%lld\n",tmp);
    printf("%lld\n",(int)lis.size());
    rep(i,lis.size())printf("%lld\n",lis[i]+1);
    return 0;
}

Measured memory_bytes: 3372
#include <cstdio>

template<int N, typename T, T M>
struct factorial_mod
{
	T mod[N + 1];
	T inv_mod[N + 1];

	constexpr factorial_mod() : mod(), inv_mod()
	{
		mod[0] = 1;
		for (int i = 0; i < N; ++i)
		{
			mod[i + 1] = (mod[i] * (i + 1)) % M;
		}
		inv_mod[N] = power(mod[N], M - 2);
		for (int i = N - 1; i >= 0; --i)
		{
			inv_mod[i] = (inv_mod[i + 1] * (i + 1)) % M;
		}
	}

	constexpr T power(T a, T b)
	{
		T r = 1;
		while (b > 0)
		{
			if ((b & 1) != 0) r = (r * a) % M;
			a = (a * a) % M;
			b >>= 1;
		}
		return r;
	}

	constexpr T comb(T n, T r)
	{
		if (r > n || n < 0) return 0;
		return (((mod[n] * inv_mod[r]) % M) * inv_mod[n - r]) % M;
	}
};

factorial_mod<5000, long long, 1000000007> fmod;

int main()
{
  long long n, k;
  scanf("%lld%lld", &n, &k);
  for (long long i = 1; i <= k; ++i)
  {
    printf("%lld\n", fmod.comb(n - k + 1, i) * fmod.comb(k - 1, k - i) % 1000000007);
  }
  return 0;
}

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


int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int i, j;
    
    
    for(j=0; j<n; j++){
        for(i = 0; i< s.size(); i++){
            if(s[i]== 'A'){
                s[i]= 'B';
            }else if(s[i]== 'B'){
                s[i]= 'C';
            }else if(s[i]== 'C'){
                s[i]= 'D';
            }else if(s[i]== 'D'){
                s[i]= 'E';
            }else if(s[i]== 'E'){
                s[i]= 'F';
            }else if(s[i]== 'F'){
                s[i]= 'G';
            }else if(s[i]== 'G'){
                s[i]= 'H';
            }else if(s[i]== 'H'){
                s[i]= 'I';
            }else if(s[i]== 'I'){
                s[i]= 'J';
            }else if(s[i]== 'J'){
                s[i]= 'K';
            }else if(s[i]== 'K'){
                s[i]= 'L';
            }else if(s[i]== 'L'){
                s[i]= 'M';
            }else if(s[i]== 'M'){
                s[i]= 'N';
            }else if(s[i]== 'N'){
                s[i]= 'O';
            }else if(s[i]== 'O'){
                s[i]= 'P';
            }else if(s[i]== 'P'){
                s[i]= 'Q';
            }else if(s[i]== 'Q'){
                s[i]= 'R';
            }else if(s[i]== 'R'){
                s[i]= 'S';
            }else if(s[i]== 'S'){
                s[i]= 'T';
            }else if(s[i]== 'T'){
                s[i]= 'U';
            }else if(s[i]== 'U'){
                s[i]= 'V';
            }else if(s[i]== 'V'){
                s[i]= 'W';
            }else if(s[i]== 'W'){
                s[i]= 'X';
            }else if(s[i]== 'X'){
                s[i]= 'Y';
            }else if(s[i]== 'Y'){
                s[i]= 'Z';
            }else if(s[i]== 'Z'){
                s[i]= 'A';
            }
        }
    }
    cout << s << endl;
    
    return 0;
}


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

typedef long long ll;

int main() {
    int N;
    while (cin >> N, N) {
        vector<ll> d(N), u(N);
        vector<bool> used(N, false);
        ll sum = 0;
        bool ans = true;
        for (int i = 0; i < N; i++) {
            cin >> d[i] >> u[i];
            sum += d[i];
        }

        while(true) {
            bool flag = false;
            for (auto i : used)
                if (!i) flag = true;

            if (!flag) break;
            else flag = false;

            ll sub = 0;
            for (int i = 0; i < N; i++) {
                if (used[i]) continue;
                if (u[i] >= sum) {
                    sub += d[i];
                    used[i] = true;
                    flag = true;
                }
            }
            if (!flag) {
                ans = false;
                break;
            }
            sum -= sub;
        }
        if (ans) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define maxn 100005
#define inf 1e18
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define fr freopen("source.txt","r",stdin),freopen("output.txt","w",stdout)
#define SET(a,b) memset(a,b,sizeof(a))
ll dp[4][maxn];
ll n,a[maxn],b[maxn],c[maxn];
ll go(ll i,ll flag){
    if(i==n) return 0;
    ll &ans=dp[flag][i];
    if(ans!=-1) return ans;
    ans=0;
    if(i==0){
        ans=max(ans,a[i]+go(i+1,1));
        ans=max(ans,b[i]+go(i+1,2));
        ans=max(ans,c[i]+go(i+1,3));
    }
    else{
        if(flag!=1) ans=max(ans,a[i]+go(i+1,1));
        if(flag!=2) ans=max(ans,b[i]+go(i+1,2));
        if(flag!=3) ans=max(ans,c[i]+go(i+1,3));
    }
    return ans;
}
int main()
{
    ll i,j,x;
    cin>>n;
    for(i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];
    SET(dp,-1);
    cout<<go(0,0);
}


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

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)

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

const ll INF = 1LL << 60;

int main(){
  int n,k; cin >> n >> k;
  if (n%k==0) std::cout << 0 << '\n';
  else std::cout << 1 << '\n';
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int K = Integer.parseInt(in.next());
		String S = in.next();

		if(S.length() <= K) {
			System.out.println(S);
		}else {
			System.out.println(S.substring(0, K) + "...");
		}
	}
}


Measured memory_bytes: 38504
#include<iostream>
#include<vector>
#include<math.h>
using namespace std;

int main(){
    int N;
    cin >> N;
    int D;
    cin >> D;

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

    int cou = 0;
    float dis = 0;

    for(int i = 1; i < N; i++){
        for(int j = 0; j < i; j++){

            dis = 0;

            for(int k = 0; k < D; k++){
                dis += abs(X[i][k] - X[j][k]) * abs(X[i][k] - X[j][k]);
            }

            dis = sqrt(dis);

            //cout << dis << endl;

            if(dis == int(dis)){
                cou++;
            }

        }
    }

    cout << cou << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  char a;
  cin>>a;
  if(a<=90) cout<<  'A'<<endl;
  else cout<< 'a' <<endl;
}

Measured memory_bytes: 3620