akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
string S;
int A[MAX_N];

pi ans[MAX_N];

void solve() {
	cin >> S;
	N = sz(S);
	rep(i, 0, N) { 
		A[i + 1] = (S[i] == '1');
	}
	if(A[1] != 1) {
		cout << -1 << "\n"; return;
	}
	rep(i, 0, N + 1) {
		if(A[i] != A[N - i]) {
			cout << -1 << "\n"; return;
		}
	}
	ans[0] = pi(0, 1);
	int cur = 1;
	for(int i = 2; i < N; i++) {
		ans[i - 1] = pi(cur, i);
		if(i <= N / 2 && A[i] == 1) cur = i;
	}
	rep(i, 0, N - 1) {
		cout << ans[i].fst + 1 << " " << ans[i].sec + 1 << "\n";
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 2768
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
const int N = 1e5;  // limit for array size
ll n;  // array size

int main(){
    int n,k,a1,d;cin>>n>>k;
    int a[n+1]={};
    
    for(int i=1;i<=k;i++){
    	cin>>d;
    	for(int i=0;i<d;i++){
    		cin>>a1;
    		a[a1]++;
		}
	}
	
	int ans=0;
	for(int i=1;i<=n;i++){
		if(a[i]==0){
			ans++;
		}
	}
	
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3592
/*
ID: wangjun30
TASK:
LANG: C++
*/
#include<iostream>
using namespace std;
int b[20];
int rl[20][20];
int k[20];
int p[20];
int main(){
	int n,m,ans=0;
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>k[i];
		for(int j=1;j<=k[i];j++)
			cin>>rl[i][j];
	}
	for(int i=1;i<=m;i++)
		cin>>p[i];
	while(b[0]==0){
		int j=n;
		for(int i=1;i<=m;i++){
			int sum=0;
			for(int j=1;j<=k[i];j++)
				sum+=b[rl[i][j]];
			if(sum%2!=p[i])
				goto End;
		}
		ans++;
		End:;
		while(b[j]==1)
			b[j]=0,j--;
		b[j]=1;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

#[fastout]
fn main() {
   input! {
      n: usize,
      m: usize,
      lrd: [(Usize1, Usize1, i64); m]
   }

   let mut to = vec![vec![]; n];
   for &(l, r, d) in lrd.iter() {
      to[l].push((r, d));
      to[r].push((l, -d));
   }

   let mut d = BTreeMap::<usize, i64>::new();
   for i in 0..n {
      if d.contains_key(&i) {
         continue;
      }
      d.insert(i, 0i64);
      if !dfs(i, &mut d, &to) {
         println!("No");
         return;
      }
   }
   println!("Yes");
}

fn dfs(v: usize, d: &mut BTreeMap<usize, i64>, to: &Vec<Vec<(usize, i64)>>) -> bool {
   let &now = d.get(&v).unwrap();
   let mut b = true;
   for &(u, x) in to[v].iter() {
      if let Some(&v) = d.get(&u) {
         if v != now + x {
            b = false;
            break;
         }
      } else {
         d.insert(u, now + x);
         if !dfs(u, d, to) {
            b = false
         }
      }
   }
   b
}


Measured memory_bytes: 33504
#include <bits/stdc++.h>
 
using namespace std;
 
#define nl  "\n"
typedef long long ll;
 
int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 

vector<ll> mnp(1e5+1 ,1e15 ) ;
map< pair<int ,int>, int > mp ; 

void dfs( int u  , int p, vector< vector<int> > &df,vector<int > vis, ll cost  ){
       // cout<<u<<endl;
        vis[u] = 1 ;
        mnp[u] = min( mnp[u], cost )     ;
        for( auto i  : df[u] ){
                if( vis[i] == 0  ) dfs( i, u , df, vis, cost+ mp[ {u, i} ]   );
            }
    }   
 

 int  main(){
            int n  ; cin>> n ; 
            int df[n ] ;
            int sh = 0 ; 
            ll ans= 0 ; 
            for( int i = 0 ; i<n ;++i ){
                    int a ;  cin>>a ;
                    if( a<sh ) ans+= (sh -a ) ;
                    sh = max(sh,a) ;
                }
                cout<<ans ; 
        }

Measured memory_bytes: 3856
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <unordered_set>

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define vii vector<int>
#define vip vector<pair<int,int> >
#define pb push_back
int bingo[3][3]={};

bool ck_rows()
{
    bool f=0;
    if(bingo[0][0]==1&&bingo[0][1]==1&&bingo[0][2]==1)
    f=1;
    else if(bingo[1][0]==1&&bingo[1][1]==1&&bingo[1][2]==1)
    f=1;
    else if(bingo[2][0]==1&&bingo[2][1]==1&&bingo[2][2]==1)
    f=1;
    return f;
}
bool ck_columns()
{
    bool f=0;
    if(bingo[0][0]==1&&bingo[1][0]==1&&bingo[2][0]==1)
    f=1;
    else if(bingo[0][1]==1&&bingo[1][1]==1&&bingo[2][1]==1)
    f=1;
    else if(bingo[0][2]==1&&bingo[1][2]==1&&bingo[2][2]==1)
    f=1;
    return f;
}
bool ck_diagonals()
{
    bool f=0;
    if(bingo[0][0]==1&&bingo[1][1]==1&&bingo[2][2]==1)
        f=1;
    else if(bingo[0][2]==1&&bingo[1][1]==1&&bingo[2][0]==1)
        f=1;
    return f;
}
int main(int argc,char* argv[])
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //#ifndef ONLINE_JUDGE
    //   freopen("out.txt", "r", stdin);
    //   freopen("output.txt", "w",stdout);
    //#endif

    //int tc;
    //cin>>tc;
    //while(tc--)
    //{

        map<int,pair<int,int>> m;
        int x;
        bool f=0;

        for(int i=0;i<3;++i)
        for(int j=0;j<3;++j)
        {cin>>x;
        m[x]={i,j};}
        int n;
        cin>>n;
        vii v(n);
        for(int i=0;i<n;++i){
            cin>>v[i];
            if(!f){
            if(m.find(v[i])!=m.end())
            {
                auto it=m.find(v[i]);
                bingo[it->second.first][it->second.second]=1;
                if(ck_rows()) f=1;
                else if(ck_columns()) f=1;
                else if(ck_diagonals()) f=1;
            }
            }
        }
        cout<<(f?"Yes":"No");






    //}


    return 0;
}


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

using namespace std;

typedef long long int ll;

int main()
{
  	ll n,a,b;
  	cin >> n >> a >> b;
  	ll ans = a*(n/(a+b));
  	ll rem = n%(a+b);
  	
  	ans += min(rem , a);
  	cout << ans << endl;
  
  	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using LL = long long;
const LL MOD = 1e9+9;
using namespace std;



int main(){
    LL N;cin >> N;
    double ans = 0;
    for(int a = 0;a < N;a++){
        double s;cin >> s;string w;cin >> w;
        if(w == "BTC"){
            ans += s * 380000;
        }else{
            ans += s;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

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

    const ll nmax = 100001;
    vector<bool> prime(nmax, true);
    prime[0] = prime[1] = false;
    for(ll x = 2; x*x < nmax; x++){
        if(prime[x]) for(ll y = x*x; y < nmax; y += x) prime[y] = false;
    }
    
    vector<ll> like(nmax, 0);
    for(ll x = 3; x < nmax; x+=2){
        if(prime[x] && prime[(x+1)/2]) like[x] = like[x-2]+1;
        else like[x] = like[x-2];
    }

    rep(i, n){
        ll l, r; cin >> l >> r;
        ll cnt = 0;
        bool lp = prime[l] && prime[(l+1)/2], rp = prime[r] && prime[(r+1)/2];
        if(lp && rp) cnt = like[r] - like[l] + 1;
        else if(!lp && rp) cnt = like[r] - like[l];
        else if(lp && !rp) cnt = like[r] - like[l] + 1;
        else cnt = like[r] - like[l];
        
        cout << cnt << endl;
    }
    return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<double> a(n);
    double sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    sort(a.rbegin(), a.rend());
    double x = a[m - 1];
    if (x < sum / 4 / m) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(){
    cout << "Yes" << endl;
}

void no (){
    cout << "No" << endl;
}

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

ll gcds(ll a, ll b){
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

int N;vector<int>node(1048576,0);
void init(int N_){
    while(N<N_)N*=2;
}
void update(int a,int x){
    a+=N/2-1;
    node[a]=max(node[a],x);
    while(a>0){
        a=(a-1)/2;
        node[a]=max(node[2*a+1],node[2*a+2]);
    }
}
int query(int a,int b,int k=0,int l=0,int r=N){
    if(b<=l||r<=a)return 0;
    if(a<=l&&r<=b)return node[k];
    int vl=query(a,b,2*k+1,l,(l+r)/2);
    int vr=query(a,b,2*k+2,(l+r)/2,r);
    return max(vl,vr);
}

int main() {
    N = 1048576;
    int n; cin >> n;int k; cin >> k;
    vector<int> dp(n,0);
    rep(i,n){
        int a; cin >> a;
        int ans = query(max(0,a-k),min(300009,a+k+1),0,0,N/2);//cout << "!" << endl;
        dp[i] = 1 + ans;
        //rep(j,2*k+1) cout << node[a-k+j+N/2-1] << " ";cout << endl;
        update(a,dp[i]); //cout << ans << endl;
        //rep(j,10) cout << node[j+N/2-1] << " ";
        //cout << endl;
    }
    int ma = 0;
    rep(i,n) ma = max(ma,dp[i]);
    cout << ma << endl;
    //printvec(dp);
}

Measured memory_bytes: 8516
pos = list(map(int, input().split()))
sx = pos[0]
sy = pos[1]
tx = pos[2]
ty = pos[3]

dx = tx - sx
dy = ty - sy

ans = ''
for i in range(dy):
    ans += 'U'
for i in range(dx):
    ans += 'R'
for i in range(dy):
    ans += 'D'
for i in range(dx+1):
    ans += 'L'
for i in range(dy+1):
    ans += 'U'
for i in range(dx+1):
    ans += 'R'
ans += 'DR'
for i in range(dy+1):
    ans += 'D'
for i in range(dx+1):
    ans += 'L'
ans += 'U'

print(ans)

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

const ll MAX_N = 3010;
string s,t;

ll dp[MAX_N][MAX_N];

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

    cin >> s >> t;
    
    int n = (int)s.size();
    int m = (int)t.size();
    
    
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= m; j++){
            if(s[i] == t[j]) {
                dp[i+1][j+1] = dp[i][j] + 1;
            } else {
                dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
            }
        }
    }
    
    int i = n;
    int j = m;
    
    string ans;
    
    while(i != 0 and j != 0){
        if(dp[i][j] == dp[i-1][j]) i--;
        else if(dp[i][j] == dp[i][j-1]) j--;
        else {
            i--;
            j--;
            ans.push_back(s[i]);
        }
    }
    
    reverse(ans.begin(), ans.end());
    
    cout << ans << endl;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

int main(){
  ll i, j;
  string s;
  cin >> s;
  bool judge = true;
  ll c = 0;
  for(i = 0; i < s.size() && judge; i++){
    if(i == 0 && s[i] != 'A')
      judge = false;
    
    else if(i == 0);
    else if(i >= 2 && i <= s.size() - 2 && s[i] == 'C'){
      if(c == 0)
        c++;
      else
        judge = false;
      
    }
    else if(s[i] < 'a' || s[i] > 'z')
      judge = false;
    
    /*if(!judge)
      cout << s[i] spa i << endl;*/
  }
  
  if(judge && c == 1)
    cout << "AC" << endl;
  else
    cout << "WA" << endl;
    
        
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;
    public static final int inf = Integer.MAX_VALUE/10;

    public static boolean[][] use1, use2;
    public static long[][] dp1, dp2;
    public static int[] a;
    static void solve(InputReader in, PrintWriter out){
        int n = in.ni();
        a = in.ni(n);
        dp1 = new long[n][n];
        dp2 = new long[n][n];
        use1 = new boolean[n][n];
        use2 = new boolean[n][n];
        for (int i = 0; i < n; i++) {
            dp1[i][i] = a[i];
            dp2[i][i] = -a[i];
            use1[i][i] = true;
            use2[i][i] = true;
        }
        out.println(dfs(0, n-1, true));
    }
    public static long dfs(int i, int j, boolean first){
        if(first){
            if(!use1[i][j]){
                long val1 = a[i]+dfs(i+1,j, false);
                long val2 = a[j]+dfs(i,j-1, false);
                dp1[i][j] = Math.max(val1, val2);
                use1[i][j] = true;
            }
            return dp1[i][j];
        }else{
            if(!use2[i][j]){
                long val1 = dfs(i+1,j, true)-a[i];
                long val2 = dfs(i,j-1, true)-a[j];
                dp2[i][j] = Math.min(val1, val2);
                use2[i][j] = true;
            }
            return dp2[i][j];
        }
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 246568
#include<bits/stdc++.h>
#define mm(a,b) memset(a,b,sizeof(a))
#define ACCELERATE (ios::sync_with_stdio(false),cin.tie(0))
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<long long,long long>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define pf(x) printf("%d\n",x)
#define pf2(x,y) printf("%d %d\n",x,y)
#define pf3(x,y,z) printf("%d %d %d\n",x,y,z)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
#define E exp(1.0)
#define db double
#define ll long long
#define ld long double
#define ull unsigned long long
//#define io
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
//#define gc getchar
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
//inline int read()
//{
//    int ret=0,f=0;char c=gc();
//    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
//    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
//    if(f)return -ret;return ret;
//}
int n;
int main()
{
    #ifdef io
    freopen("in.txt","r",stdin);
    #endif
    cin>>n;
    cout<<3*n*n<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
def t(A,p,r):
 x=A[r][1];i=p-1
 for j in range(p,r):
  if A[j][1]<=x:i+=1;A[i],A[j]=A[j],A[i]
 A[i+1],A[r]=A[r],A[i+1]
 return i+1
def k(A,p,r):
 if p<r:q=t(A,p,r);k(A,p,q-1);k(A,q+1,r)
def s(A):
 for i in range(n-1):
  if A[i][1]==A[i+1][1]:
   if A[i][2]>A[i+1][2]:return'Not s'
 return'S'
n=int(input())
f=lambda x:(x[0],int(x[1]),x[2])
A=[(*e.split(),i)for i,e in enumerate(sys.stdin)]
A=list(map(f,A))
k(A,0,n-1)
for e in[[s(A)+'table']]+A:print(*e[:2])


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

signed main() {
  int A, B, T, ans;
  cin >> A >> B >> T;
  ans = (T + 0.5) / A;
  ans *= B;
  print(ans);
}


Measured memory_bytes: 256
#!/usr/bin/perl
use POSIX qw(floor);

my ($x) = map { $_ - 0 } split(/\s+/,<STDIN>);

my @p5 = ();

$#p5 = 1500;

for(my $i=0;$i<1500;$i++){
  my $v = $i ** 5;
  $p5[$i] = $v;
}

for(my $i=0;$i<1500;$i++){
  for(my $j=0;$j<1500;$j++){
    if( $p5[$j] - $p5[$i] == $x ){
      print "$j $i\n";
      exit(0);
    } elsif( $p5[$j] + $p5[$i] == $x ){
      print "$j -$i\n";
      exit(0);
    }
  }
}

print "1\n";

exit(0);

sub pf {
  my $n = shift;
  my %ret = ();
  
  for(my $i=1;$i*$i<=$n;$i+=2){
    my $ii = $i;
    $ii = 2 if $i == 1;
    while($n % $ii == 0) {
      $ret{$ii} ++;
      $n /= $ii;
    }
  }
  if( $n != 1 ){ $ret{$n} = 1; }
  return \%ret;
}

sub f4 {
  #my $
}





Measured memory_bytes: 6644
#include <stdio.h>

#define MOD 1000000007

int main(void) {
	int n, m;
	scanf("%d%d", &n, &m);

	int last[3] = {1, 0, 0};
	int bad = 0;
	for (int i = 1; i <= n; i++) {
		last[2] = last[1];
		last[1] = last[0];

		if (i > bad && m) {
			m--;
			scanf("%d", &bad);
		}
		if (i == bad) last[0] = 0;
		else last[0] = (last[1]+last[2]) % MOD;
	}

	printf("%d\n", last[0]);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

void _main() {
  string S;
  cin >> S;
  vector<int> zero_one(2, 0);
  fore(i, S) {
    ++zero_one[i-'0'];
  }

  int ans = min(zero_one[0], zero_one[1]) * 2;
  cout << ans << "\n";
}

Measured memory_bytes: 512
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program
{
    internal static void Main(string[] args) {
        var N = int.Parse(ReadLine());
        var d = new List<int>();
        for (int i = 0; i < N;i++) {
            d.Add(int.Parse(ReadLine()));
        }
        d = d.Distinct().ToList();
        var ans = 0;
        for (int i = 0; i < N;i++) {
            if (d.Count == 0) { break; }
            ans++;
            d.Remove(d.Max());
        }
        WriteLine(ans);
    }
}


Measured memory_bytes: 13276
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    def factorization(n):
        if n==1:
            return []
        arr = []
        temp = n
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp%i==0:
                cnt=0
                while temp%i==0:
                    cnt+=1
                    temp //= i
                arr.append([i, cnt])

        if temp!=1:
            arr.append([temp, 1])

        if arr==[]:
            arr.append([n, 1])

        return arr
    
    mod=10**9+7
    a,b=MI()
    from math import gcd
    g=gcd(a,b)
    arr=factorization(g)
    
    ans=len(arr)+1
    
    print(ans)
    
    
    

main()


Measured memory_bytes: 63688
#include <iostream>
using namespace std;
int main(void){
    int a,b,x;
    cin>>x>>a>>b;
    if(a-b>=0)cout<<"delicious"<<endl;
    if(a-b<0 && a+x-b>=0)cout<<"safe"<<endl;
    if(a-b<0 && a+x-b<0)cout<<"dangerous"<<endl;
    return 0;
    
}

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

ll A,B;
map<ll,int> cost,visited;
int n;

ll p[10];
int calc(ll x,int j){
  return x/p[j]%10;
}

int main(){
  p[0]=1;
  for(int i=1;i<10;i++)
    p[i]=p[i-1]*10LL;
  
  while(1){
    cin>>n;
    if(n==0)break;
    cost.clear();
    visited.clear();
    cin>>A>>B;    
    queue<ll> Q;
    visited[A]=1;
    cost[A]=0;
    Q.push(A);
    
    while(!Q.empty()){
      ll s=Q.front();Q.pop();
      
      int k;
      for(k=0;k<n;k++)
        if(calc(s,k)!=calc(B,k))break;
      if(k==n)break;
      ll next=s;
      int dist=(calc(B,k)-calc(s,k)+10)%10;
 
      for(int j=k;j<n;j++){
        int X=calc(next,j);
        next-=X*p[j];
        X=(X+dist)%10;
        next+=X*p[j];
        if(visited[next])continue;
        visited[next]=1;
        cost[next]=cost[s]+1;
        Q.push(next);
      }
    }
    cout<<cost[B]<<endl;
  }
  return 0;
}

Measured memory_bytes: 2540
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const long double PI = (acos(-1));
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)
int main(){
    int ans = 0;
    ll n, t; scll(n), scll(t);
    vector<ll> a(n);
    vector<ll> b;
    rep(i, 0, n) scll(a[i]);
    ll left = a[0], right = a[0];
    rep(i, 1, n){
        left = min(a[i], left);
        b.push_back(a[i]-left);
    }
    sort(b.rbegin(), b.rend());
    while (b[ans]==b[0]) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2168
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<stack>
#include<set>
#include<cstdlib>
#include<deque>
#include<queue>
#include<bitset>
#include<functional>
#include<utility>
#include<list>
#include<iomanip>
#include<ctime>
#include<cassert>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
const long long INF=1e15+9;
int a[200005];
long long qzh[200005],tot,ans;
long long abs(long long x,long long y)
{
	return x-y>0?x-y:y-x;
}
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(i==0) qzh[i]=a[i];
		else qzh[i]=qzh[i-1]+a[i];
		tot+=a[i];
	}
	//cout<<INF;
	ans=INF;
	for(int i=0;i<n-1;i++)
	{
		ans=min(ans,abs(qzh[i],tot-qzh[i]));
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2560
A, B, K = map(int, input().split())

ans_A = A
ans_B = B
if A > K:
    ans_A -= K
else:
    ans_A = 0
    if B >= K-A:
        ans_B -= K-A
    else:
        ans_B = 0

print(ans_A, ans_B)

Measured memory_bytes: 2940
//In the name of God
//SMani24
#include<bits/stdc++.h>
using namespace std;

long long n;
long long po = 10;

int main() {
	cin >> n;
	if (n & 1) {
		cout << 0 << endl;
		return 0;
	}
	long long ans = 0;
	while (po <= n) {
		ans += n / po;
		po *= 5;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define UNIQUE(c) sort(ALL(c)), c.erase(unique(ALL(c)), c.end())

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N, M; cin >> N >> M;
  vector<vector<int>> start_pos(N), end_pos(N);
  vector<ll> costs(M);
  REP(i, M) {
    int l, r; ll c; cin >> l >> r >> c; l--, r--;
    start_pos[l].emplace_back(i);
    end_pos[r].emplace_back(i);
    costs[i] = c;
  }

  vector<ll> dist(N);
  dist[0] = 0;
  set<pair<ll, int>> intervals;

  vector<pair<ll, int>> memo(M);
  for (int idx : start_pos[0]) {
    intervals.emplace(costs[idx], idx);
    memo[idx] = make_pair(costs[idx], idx);
  }

  FOR(i, 1, N) {
    if (intervals.empty()) {
      cout << -1 << endl;
      return 0;
    }

    dist[i] = intervals.begin()->first;
    for (int idx : end_pos[i]) {
      intervals.erase(memo[idx]);
    }
    for (int idx : start_pos[i]) {
      intervals.emplace(dist[i] + costs[idx], idx);
      memo[idx] = make_pair(dist[i] + costs[idx], idx);
    }
  }

  cout << dist[N-1] << endl;

  return 0;
}


Measured memory_bytes: 14208
import heapq
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for y in a:
  b.append(y*(-1))

heapq.heapify(b)
for x in range(m):
  c=heapq.heappop(b)*(-1)
  d=(c//2)*(-1)
  heapq.heappush(b,d)
  
sum1=sum(b)*(-1)
print(sum1)



Measured memory_bytes: 20360
// In the name of God

#include <bits/stdc++.h>

using namespace std;

const int N = 200005;

long long d[N], c[N];
pair<int,int> co[10];

void Push(stack<int>&st, int now) {
	st.push(now % 10);
	if(now >= 10) st.push(now / 10);
}


pair<int,int> calculate(int num) {
	int ops = 0, used = 0;
	ops++;
	used++;
	stack<int> st;
	Push(st, num + num);
	while(!(st.size() == 1 && st.top() == num)) {
		ops++;
		if(st.size() == 2) {
			int take1 = st.top();
			st.pop();
			int take2 = st.top();
			st.pop();
			Push(st, take1 + take2);
		}
		else {
			used++;
			int now = st.top();
			st.pop();
			Push(st, now + num);
		}
	}
	return make_pair(ops, used);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	for(int i=0;i<10;i++) co[i]=calculate(i);
	long long answer = 0;
	for(int i=0;i<n;i++) {
		cin >> d[i] >> c[i];
		if(c[i] >= 20){
			long long step = co[d[i]].second;
			long long ret = co[d[i]].first;
			answer += ((c[i]-20)/step)*ret;
			c[i] -= ((c[i]-20)/step)*step;
		}
	}
	vector<int> v;
	for(int i=0;i<n;i++) {
		for(int j=0;j<c[i];j++)v.push_back(d[i]);
	}
	int ind = 1;
	stack<int> st;
	Push(st, v[0]);
	while(st.size()>=2 || ind < v.size()) {
		if(st.size() >= 2) {
			answer++;
			int take1 = st.top();
			st.pop();
			int take2 = st.top();
			st.pop();
			Push(st, take1 + take2);
		}
		else if(st.size() == 1) {
			answer++;
			int take1 = st.top();
			st.pop();
			Push(st, take1 + v[ind++]);
		}
	}
	cout << answer;
	return 0;
}


Measured memory_bytes: 38244
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
    public static void main(String[] args) {
        FastScanner fsc = new FastScanner();
        long a = fsc.nextLong();
        long b = fsc.nextLong();
        long c = fsc.nextLong();
        System.out.println(c - a - b >= 0 && a * b * 4 < (c - a - b) * (c - a - b) ? "Yes" : "No");
    }
}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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

int debug =0;

int main()
{
    int a,b,c,d;
    cin >> a>> b>> c>> d;

    double ha, hb;
    ha = a;
    hb = c;
    
    int num1, num2;
    num1 = ceil(hb/b);
    num2 = ceil(ha/d);

    if(debug){
        cout << "num1,num2=" << num1 << "," << num2 << endl;
    }

    if(num1 <= num2)
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3568
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int btn[100001] = {};
int main(int argc , char **argv)
{
	(void)argc;
	(void)argv;

	int N;
	cin >> N;
	vector<int> btn(N);

	for(int i=1; i<=N; i++){
		cin >> btn[i];
	}

	int cnt = 0;
	int b = 1;

	while(1) {
		cnt++;
		if (btn[b]==2){
			printf("%d\n",cnt);
			break;
		}
		if (N < cnt){
			printf("-1\n");
			break;
		}
		b=btn[b];
	}

	return 0;
}


Measured memory_bytes: 640
n=int(input())
b=list(map(int,input().split()))

for i in range(n):
    if i+1<b[i]:
        print(-1)
        exit(0)


from collections import deque

d=deque([])

while len(d)<n:
    tmp=b
    for j in range(len(tmp)-1,-1,-1):
        if j+1==tmp[j]:
            d.append(tmp[j])
            break

    b.pop(j)


for _ in range(n):
    v=d.pop()
    print(v)


Measured memory_bytes: 9376
import sys
import copy
import  math
import bisect
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

li = sorted(na())
print(li[0] + li[1])


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

using namespace std;
const int INF = 1 << 30;

struct Dinic
{


  struct edge
  {
    int to, cap, rev;
  };

  vector< vector< edge > > graph;
  vector< int > min_cost, iter;

  Dinic(int n)
  {
    graph.resize(n);
  }

  void add_edge(int from, int to, int cap)
  {
    graph[from].push_back((edge) {to, cap, (int) graph[to].size()});
    graph[to].push_back((edge) {from, 0, (int) graph[from].size() - 1});
  }

  bool bfs(int s, int t)
  {
    min_cost.assign(graph.size(), -1);
    queue< int > que;
    min_cost[s] = 0;
    que.push(s);
    while(!que.empty()) {
      int p = que.front();
      que.pop();
      for(int i = 0; i < graph[p].size(); i++) {
        const edge &e = graph[p][i];
        if(e.cap > 0 && min_cost[e.to] == -1) {
          min_cost[e.to] = min_cost[p] + 1;
          que.push(e.to);
        }
      }
    }
    return (min_cost[t] != -1);
  }

  int dfs(int idx, const int t, int flow)
  {
    if(idx == t) return (flow);
    for(int &i = iter[idx]; i < graph[idx].size(); i++) {
      edge &e = graph[idx][i];
      if(e.cap > 0 && min_cost[idx] < min_cost[e.to]) {
        int d = dfs(e.to, t, min(flow, e.cap));
        if(d > 0) {
          e.cap -= d;
          graph[e.to][e.rev].cap += d;
          return (d);
        }
      }
    }
    return (0);
  }

  int max_flow(int s, int t)
  {
    int flow = 0;
    while(bfs(s, t)) {
      iter.assign(graph.size(), 0);
      int f = 0;
      while((f = dfs(s, t, INF)) > 0) {
        flow += f;
      }
    }
    return (flow);
  }
};

int main()
{
  int H, W;
  string S[100];

  cin >> H >> W;
  for(int i = 0; i < H; i++) {
    cin >> S[i];
  }
  Dinic flow(H * W * 2);
  int add = H * W;
  auto to = [&](int y, int x, bool in)
  {
    if(in) return (y * W + x + add);
    return (y * W + x);
  };

  int s, t;

  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if(S[i][j] == 'S') s = to(i, j, false);
      if(S[i][j] == 'T') t = to(i, j, true);

      if(S[i][j] != '.') {
        flow.add_edge(to(i, j, true), to(i, j, false), 1);
        for(int k = 0; k < H; k++) {
          if(i == k) continue;
          if(S[k][j] != '.') {
            flow.add_edge(to(i, j, false), to(k, j, true), INF);
          }
        }
      }
      if(S[i][j] != '.') {
        for(int k = 0; k < W; k++) {
          if(j == k) continue;
          if(S[i][k] != '.') {
            flow.add_edge(to(i, j, false), to(i, k, true), INF);
          }
        }
      }
    }
  }
  auto get = flow.max_flow(s, t);
  if(get >= INF) {
    cout << -1 << endl;
  } else {
    cout << get << endl;
  }
}

Measured memory_bytes: 62464
import java.io.*;
import java.util.*;
import java.lang.*;

public class Main
{
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt() % 10;
        if (n == 3) {
            System.out.println("bon");
        }
        else if (n == 0 || n == 1 || n == 6 || n == 8) {
            System.out.println("pon");
        }
        else {
            System.out.println("hon");
        }
    }
}


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

int main() {
  string str;
  cin >> str;
  int str_leng = str.size();
  //str.replace(2, 1, "G");
  //cout << str << endl;
  for(int i = 0; i < str_leng; i++){
    if (str[i] == '?'){
      str.replace(i, 1, "D");
    }
  }
  cout << str << endl;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;

// Define
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using int128 = __int128;
using cint = cpp_int;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ull MAX = ULONG_MAX;
#define endl '\n'
#define space ' '
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)

// Debug
#define debug(...)                                                             \
    {                                                                          \
        cerr << __LINE__ << ": " << #__VA_ARGS__ << " = ";                     \
        for (auto &&X : {__VA_ARGS__}) cerr << "[" << X << "] ";               \
        cerr << endl;                                                          \
    }

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define each(i, a) for (auto &&i : a)
#define rep(i, n) inc(i, 0, n - 1)

// Stream
#define input(a) scanf("%lld", &(a))
#define output(a) printf("%lld\n", (a))
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

// Math
func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
func lcm(ll a, ll b) { return a * b / gcd(a, b); }

class WarshallFloyd {
private:
    const int n;
    vector<vector<int>> d;
public:
    WarshallFloyd(int _n) : n(_n), d(_n, vector<int>(_n)) {
        rep(i, n) rep(j, n) {
            d[i][j] = (i == j ? 0 : INF);
        }
    }
    // directed
    void setDist(int i, int j, int c) {
        d[i][j] = c;
    }
    int getDist(int i, int j) {
        return d[i][j];
    }
    void calc() {
        rep(k, n) rep(i, n) rep(j, n) {
            d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
    }
};

ll N, C, X, S, M = INF, W[50][50], A[50][3], D[50][3];
signed main() {
    cin >> N >> C;
    rep(i, C) rep(j, C) {
        cin >> W[i][j];
    }
    rep(i, N) rep(j, N) {
        cin >> X;
        A[X - 1][(i + j) % 3]++;
    }
    rep(i, C) rep(j, C) rep(k, 3) {
        D[j][k] += A[i][k] * W[i][j];
    }
    rep(i, C) rep(j, C) rep(k, C) {
        S = 0;
        if((i - j) * (j - k) * (k - i)) {
            S += D[i][0];
            S += D[j][1];
            S += D[k][2];
            if(S < M) M = S;
        }
    }
    cout << M << endl;
}

// for compilation: g++ -O3 -o _ _.cpp -std=c++17

Measured memory_bytes: 256
import sys
n=int(input())
w=[]
for i in range(n):
    w.append(input())
    
if len(set(w)) < n:
    print("No")
    sys.exit(0)
else:
    for j in range(n-1):
        if w[j][-1:] != w[j+1][:1]:
            print("No")
            sys.exit(0)
print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }

struct UnionFind {
    UnionFind() {}
    UnionFind(int n) {
        par.resize(n, -1);
    }
    
    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    
    bool merge(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return false;
        if (par[rx] > par[ry]) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
        return true;
    }
    
    bool is_same(int x, int y) {
        return (root(x) == root(y));
    }
    
    int size(int x) {
        return -par[root(x)];
    }
    
private:
    vector<int> par;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        uf.merge(a, b);
    }
    set<ll> s;
    rep(i, n) s.insert(uf.root(i));
    cout << (sz(s) - 1) << endl;
    return 0;
}


Measured memory_bytes: 7632
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int mod = 1000000007;

int main(){
    int k;
    cin >> k;
    queue<ll> q;
    int count = 0;
    rrep(i, 9) q.push(i);

    ll x;

    while(count!=k){
        x = q.front();
        q.pop();
        count++;
        int tmp = (x % 10);
        if(tmp!=0) q.push(10*x + tmp - 1);
        q.push(10*x + tmp);
        if(tmp!=9) q.push(10*x + tmp + 1);
    }

    cout << x << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main()
{
	int S, h, m, s;
	scanf("%d", &S);
	h = S / 3600;
	m = S % 3600 / 60;
	s = S % 3600 % 60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

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

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >
#define smaller_queue_p  priority_queue <pll, vector<pll>, greater<pll> >
//------------------------------------------------------

struct pos {
    ll x, y;
};

bool comp_x(pos& p1, pos& p2) {
    return p1.x < p2.x;
}

bool comp_y(pos& p1, pos& p2) {
    return p1.y < p2.y;
}

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

    ll n, k;
    cin >> n >> k;
    pos p[n];
    rep(i, n) cin >> p[i].x >> p[i].y;

    ll Min = LINF;

    rep(i1, n) REP(i2, i1, n) REP(i3, i2, n) REP(i4, i3, n) {
        vector<pos> v = {p[i1], p[i2], p[i3], p[i4]};
        sort(v.begin(), v.end(), comp_x);
        ll left = v[0].x;
        ll right = v[3].x;
        sort(v.begin(), v.end(), comp_y);
        ll down = v[0].y;
        ll up = v[3].y;

        int cnt = 0;

        rep(i, n) {
            if (p[i].x >= left && p[i].x <= right
                    && p[i].y <= up && p[i].y >= down) cnt++;
        }

        if (cnt >= k) {
            Min = min(Min, (right - left) * (up - down));
        }
    }

    cout << Min << endl;
    return 0;
}


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


int main(){
    int s, w;
    cin >> s >> w;
    if (w >= s) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}

Measured memory_bytes: 3636