akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <utility> //pairを使う
using namespace std;

typedef unsigned long long ll;

const ll inf = 1000000000000;
const ll mod = 100000;

int main(){
	string s;
	int a, b, c, d, t;
	cin >> s;
	a = stoi(s.substr(0, 1));
	b = stoi(s.substr(1, 1));
	c = stoi(s.substr(2, 1));
	d = stoi(s.substr(3, 1));
	t = a + b + c + d;
	if(t == 7){
		s.insert(1, "+");
		s.insert(3, "+");
		s.insert(5, "+");
		s += "=7";
		cout << s << endl;
	}else{
		if(t - b * 2 == 7){
			s.insert(1, "-");
			s.insert(3, "+");
			s.insert(5, "+");
			s += "=7";
			cout << s << endl;
		}else if(t - c * 2 == 7){
			s.insert(1, "+");
			s.insert(3, "-");
			s.insert(5, "+");
			s += "=7";
			cout << s << endl;
		}else if(t - d * 2 == 7){
			s.insert(1, "+");
			s.insert(3, "+");
			s.insert(5, "-");
			s += "=7";
			cout << s << endl;
		}else if(t - b * 2 - c * 2 == 7){
			s.insert(1, "-");
			s.insert(3, "-");
			s.insert(5, "+");
			s += "=7";
			cout << s << endl;
		}else if(t - b * 2 - d * 2 == 7){
			s.insert(1, "-");
			s.insert(3, "+");
			s.insert(5, "-");
			s += "=7";
			cout << s << endl;
		}else if(t - c * 2 - d * 2 == 7){
			s.insert(1, "+");
			s.insert(3, "-");
			s.insert(5, "-");
			s += "=7";
			cout << s << endl;
		}else if(t - b * 2 - c * 2 - d * 2 == 7){
			s.insert(1, "-");
			s.insert(3, "-");
			s.insert(5, "-");
			s += "=7";
			cout << s << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        double[] x = new double[n];
        String[] u = new String[n];
        for(int i=0;i<n;i++){
            x[i] = Double.parseDouble(sc.next());
            u[i] = sc.next();
        }
        double bit = 380000.0;
        double sum = 0;
        for(int i=0;i<n;i++){
            if(u[i].equals("BTC")){
                sum+=x[i]*bit;
            }else{
                sum+=x[i];
            }
        }

        System.out.println(sum);
        sc.close();

    }
    
}

Measured memory_bytes: 23632
x, n = map(int, input().split())
p = list(map(int, input().split()))
a = 0
b = 0
j = 0
while True:
    a = 0
    b = 0
    for i in range(n):
        if x-j == p[i]:
            a = 1
        if x+j == p[i]:
            b = 1
    if a == 0 and b == 0:
        print (x-j)
        break
    elif a == 0 and b == 1:
        print (x-j)
        break
    elif a == 1 and b == 0:
        print (x+j)
        break
    else:
        j = j+1
        continue

Measured memory_bytes: 9148
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vii;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

// ────────────────────────────────────────────────────

ll dp[100100];
ll sm[26];

int main() {
	ll n;
	string s, t;

	cin >> n >> s >> t;

	dp[0] = 1;
	sm[s[0] - 'a'] = 1;

	Rep(i, n) {
		dp[i] = sm[t[i] - 'a'];
		sm[s[i] - 'a'] = (sm[s[i] - 'a'] + dp[i]) % mod;
	}

	cout << dp[n - 1] << endl;
}



Measured memory_bytes: 3980
from collections import Counter
n =int(input())
a = [input() for i in range(n)]
m =int(input())
b = [input() for i in range(m)]
c = Counter(a)
d = Counter(b)
e = -100000
for i,j in c.most_common():
    e = max(j-d[i],e)
print(max(e,0))

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

int main(){
  int A,B;
  cin>>A>>B;
  if(A==1||B==1){
    if(A!=1){
      cout<<"Bob"<<endl;
    }
    else if(B!=1){
      cout<<"Alice"<<endl;
    }
    else{
      cout<<"Draw"<<endl;
    }
  }
  else if(A==B){
    cout<<"Draw"<<endl;
  }
  else if(A>B){
    cout<<"Alice"<<endl;
  }
  else{
    cout<<"Bob"<<endl;
  }
}
    

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int n;
  scanf("%d", &n);
  int d[n];
  for(int i = 0; i < n; i++) {
    scanf("%d", &d[i]);
  }
  long long int sum = 0LL;
  for(int i = 0; i < n; i++) {
    for(int j = i + 1; j < n; j++) {
      sum += (long long int)(d[i] * d[j]);
    }
  }
  printf("%lld\n", sum);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INF = 1<<29;
const int MOD = 1000000007;
 
void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

ll dp[100100];

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll N;
    cin >> N;
    vector<ll> h(N);
    rep(i,N) cin >> h[i];
    REP(i,1,100100) dp[i] = LLINF;
    dp[0] = 0;
    rep(i,N){
      chmin(dp[i+1], dp[i] + abs(h[i+1] - h[i]));
      chmin(dp[i+2], dp[i] + abs(h[i+2] - h[i]));
    }
    print(dp[N-1]);
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
using namespace std;

int n,m,ans;

signed main(){
    cin>>n>>m;
    if(n%m==0)cout<<n/m<<endl;
    else cout<<n/m+1<<endl;
}


Measured memory_bytes: 256
def sim(n):
    if n == -1:
        return -1
    if n == N:
        return 1
    for t,d in TD:
        if t == s[n]:
            if d == 'L':
                n -= 1
            else:
                n += 1
        if n == -1:
            return -1
        if n == N:
            return 1
    return 0

N,Q = map(int,input().split())
s = input()
TD = [input().split() for _ in range(Q)]

l,r = -1,N
while l+1 < r:
    n = (l+r)//2
    if sim(n) == -1:
        l = n
    else:
        r = n
L = l

l,r = -1,N
while l+1 < r:
    n = (l+r)//2
    if sim(n) == 1:
        r = n
    else:
        l = n
R = r

print(R-L-1)

Measured memory_bytes: 39348
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
    const N = lines[0];
    const list = lines[1].split(" ").map(v=>v-0);
    const cnt = list.filter(v=>v%2==0).length;
    console.log(Math.pow(3,N)-Math.pow(2,cnt));
});



Measured memory_bytes: 29908
fun main(args: Array<String>) {
    val n=readLine()!!.toInt()
    val s=readLine()!!
    val w = s.count { it=='.' }
    val b = s.count { it=='#' }
    val arr = IntArray(n+1){0}
    var wc =w
    var bc=0
    arr[0]=w
    if(w==n)arr[0]=0
    for(i in 0 until n){
        if(s[i]=='.')wc-=1
        else bc+=1
        arr[i+1]=wc+bc
    }
    print(arr.min())
}

Measured memory_bytes: 42040
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pl= pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main(){
    ll n,k;cin >>n>>k;
    V a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    map<ll,int>memo;
    ll x=1;
    for (ll i = 0; i <k; ++i) {
        if(memo[x]){
            auto t=i-memo[x],c=(k-1-i)/t;
            i+=c*t;
        }
        else {
            memo[x]=i;
        }
        x=a[x-1];
    }
    cout <<x<<endl;
}

Measured memory_bytes: 14020
import sys


if __name__ == "__main__":
    N = int(input())

    rates = map(int, raw_input().split())
    # rates = [map(int, raw_input().split()) for i in range(N)]

    # tasks = np.array(tasks)
    normal_colors = int(3200/400)
    colors = [0] * normal_colors
    aaa = 0
    for rate in rates:
        if rate >= 3200:
            aaa +=1
        else:
            colors[rate/400] = 1

    print max(sum(colors),1), sum(colors)+aaa

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

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; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using pint = pair<int, int>; 
using pll  = pair<ll, ll>;
using vint = vector<int>; 
using vll  = vector<ll>;
using vstr = vector<string>;

//　定数, 変数 *********************************************
const ll MOD=1e9+7;
const ll INF=1ll<<60;

int X, Y;

// *********************************************************
int main(){

    cin >> X >> Y;

    int turu, kame;

    if(Y%2 ==0){
        if(X*4 >= Y){
            if((X*4-Y)/2 > X){
                cout <<"No";
            }else{
                cout <<"Yes";
            }        
        }else{
            cout << "No";
        }

    }else{
        cout <<"No";
    }
    

    return 0;
}

Measured memory_bytes: 3672
// AOJ Volume 0 Problem 0016

#include <stdio.h>
#include <math.h>

#define PI	(3.14159265)

int main(void)
{
	int m, r;
	int r_old;
	double x, y;
	
	x = y = 0.0;
	r_old = 90;

	while (1){
		scanf("%d,%d", &m, &r);
		if (m == 0 && r == 0){
			break;
		}

		r *= -1;

		y = y + m * sin(r_old * PI / 180.0);
		x = x + m * cos(r_old * PI / 180.0);
		
		r_old = (r_old + r) % 360;
	}
	printf("%d\n%d\n", (int)x, (int)y);
	
	return (0);
}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  int A[N];
  map<int,int> m[N];
  REP(i,N){
    cin>>A[i];
    REP(j,A[i]){
      int x,y;
      cin>>x>>y;
      x--;
      m[i][x]=y;
    }
  }
  int ans=0;
  REP(i,1<<N){
    int C[N];
    REP(j,N)C[j]=(i>>j)%2;
    // REP(j,N)cerr<<C[j];
    bool f=true;
    REP(j,N)if(C[j]==1){
      for(auto e:m[j]){
        if(C[e.first]!=e.second){
          f=false;
        }
      }
    }
    if(f){
      int temp=0;
      REP(j,N)temp+=C[j];
      ans=max(ans,temp);
      // cerr<<"OK";
    }
    // cerr<<endl;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int min(int a,int b){
    return a > b ? b : a;
} 

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

    int ans = 0;

    ans = (m + n) * (m + n - 1) / 2;
    ans -= n * m;

    printf("%d",ans);
}


Measured memory_bytes: 128
a, b, k = map(int, input().split())

def ooo(x):
    lix =[]
    for i in range(1, x+1):
        if x % i == 0:
            lix.append(i)
    return lix

lia = ooo(a)
lib = ooo(b)
li = lia + lib

li2 =[]
for n in range(len(li)):
    if not li[n] in li2: 
        if li.count(li[n]) == 2:
            li2.append(li[n])

li2.sort(reverse=True)
print(li2[k-1])

Measured memory_bytes: 3064
/*https://bom.to/nxtvde2k1m4l*/
#include<bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cout << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}

#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define task "NAME"
typedef pair<int,int> ii;
typedef long long ll;
void init()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    freopen(task".inp","r",stdin);
    freopen(task".out","w",stdout);
}
int main()
{
    string s,t;
    cin >> s >> t;
    int n,m;
    cin >> n >> m;
    string k; cin >> k;
    if (k == s) n --;
    if (k == t) m -- ;
    cout << n << ' ' << m;
}







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

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

ll prime_fac_num(ll n){
  ll s = floor(sqrt(n));
  ll ans = 0;
  for(ll i=2; i<=s; i++){
    if(n%i==0){
      do{
        n /= i;
      }while(n%i==0);
      ans++;
    }
  }

  if(n>s){
    ans++;
  }

  return ans;
}

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

  ll g = gcd(a, b);

  ll ans = 1 + prime_fac_num(g);

  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
int main(){
    int t=0,ma=0;
    rep(i,0,3){
        int x;
        cin>>x;
        t+=x;
        ma=max(ma,x);
    }
    cout<<t-ma<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

#define LLincII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define LLincID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define LLdecII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define LLdecID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define LLinc(i, n)  LLincID(i, 0, n)
#define LLinc1(i, n) LLincII(i, 1, n)
#define LLdec(i, n)  LLdecID(i, 0, n)
#define LLdec1(i, n) LLdecII(i, 1, n)

// { x in (l, r] | x mod m = a } の要素数
LL cmCI(LL l, LL r, LL m, LL a) { assert(m > 0); return max(0LL, fl(r - a, m) - fl(l - a, m)); }
LL cmCD(LL l, LL r, LL m, LL a) { return cmCI(l    , r - 1, m, a); }
LL cmII(LL l, LL r, LL m, LL a) { return cmCI(l - 1, r    , m, a); }
LL cmID(LL l, LL r, LL m, LL a) { return cmCI(l - 1, r - 1, m, a); }

LL n, ans;

int main() {
	cin >> n;
	
	LLinc1(i, n) {
		if((n - i) / i <= i) { break; }
		if((n - i) % i == 0) { ans += (n - i) / i; }
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>

const long INF = (1l << 30);
const long LINF = (1l << 60);

std::string s;
int main(){
  std::cin >> s;
  std::sort(s.begin(), s.end());
  if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2]){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
}


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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  string s;
  cin >> s;

  cout << (s == "ABC" ? "ARC" : "ABC") << "\n";
}

Measured memory_bytes: 3612
#include <iostream>
#include <stack>
#include <tuple>
using namespace std;

int main() {
	int n, balls[10]; cin >> n;
    while(n--){
        for(int i = 0; i < 10; i++){
            cin >> balls[i];
        }
        
        bool sortable = false;
        stack<tuple<int, int, int> > states;
        
        states.push(make_tuple(0,0,0));
        while(!states.empty()){
        	tuple<int, int, int> now = states.top();
        	states.pop();
        	
        	int idx = get<0>(now);
        	if(idx < 10){
        		if(get<1>(now) < balls[idx]){
        			if(idx == 9){
        				sortable = true; break;
        			}
        			states.push(make_tuple(idx+1,balls[idx],get<2>(now)));
        		}
        		if(get<2>(now) < balls[idx]){
        			if(idx == 9){
        				sortable = true; break;
        			}
        			states.push(make_tuple(idx+1,get<1>(now),balls[idx]));
        		}
        	}        	
        }
         
        if(sortable) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}

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

#define debug(x) cerr << #x << ": " << x << endl

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int h, w;
  cin >> h >> w;
  vector<vector<char>> r(h, vector<char>(w));
  vector<vector<char>> c(w, vector<char>(h));
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++) {
      cin >> r[i][j];
      c[j][i] = r[i][j];
    }
  vector<bool> row(h);
  for (int i = 0; i < h; i++)
    if (count(r[i].begin(), r[i].end(), '.') == w)
      row[i] = true;
  vector<bool> col(w);
  for (int i = 0; i < w; i++)
    if (count(c[i].begin(), c[i].end(), '.') == h)
      col[i] = true;
  for (int i = 0; i < h; i++) {
    bool has = false;
    for (int j = 0; j < w; j++) {
      if (row[i] || col[j])
        continue;
      has = true;
      cout << r[i][j];
    }
    if (has)
      cout << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <deque>
#include <numeric>
#include <map>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
 
using namespace std;
 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
int main () {
	int N, K;
    cin >> N >> K;
	ll ans = 0;
	for (int b = 1; b <= N; ++b) {
		int p = N/b;
		int r = N%b;
		ans  += max(0,b-K) * p + max(0, r - K + 1);
	}
	if (K==0) {
		ans -= N;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.TreeSet;
import java.util.stream.IntStream;

public class Main {

  static final String PAIRWISE = "pairwise coprime";
  static final String SETWISE = "setwise coprime";
  static final String NOT = "not coprime";

  public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());
    String[] data = br.readLine().split(" ");
    br.close();
    int[] a = new int[n];
    for(int i = 0; i < n; i++){
      a[i] = Integer.parseInt(data[i]);
    }
    int allGcd = a[0];
    int idx = 1;
    while(allGcd != 1 && idx < n){
      allGcd = gcd(allGcd, a[idx]);
      idx++;
    }
    if(allGcd == 1){
      int max = IntStream.of(a).max().getAsInt();
      EratosthenesSieve sieve = new EratosthenesSieve(max);
      TreeSet<Integer> set = new TreeSet<>();
      for(int i = 0; i < n; i++){
        int num = a[i];
        while(num > 1){
          int multiple = sieve.minimumMultiple(num);
          if(set.contains(multiple)){
            System.out.println(SETWISE);
            return;
          } else {
            set.add(multiple);
          }
          while(num % multiple == 0){
            num /= multiple;
          }
        }
      }
      System.out.println(PAIRWISE);
    } else {
      System.out.println(NOT);
    }
  }
  static int gcd(int a, int b){
    return b == 0 ? a : gcd(b, a % b);
  }
}
class EratosthenesSieve {
  int div[];
  EratosthenesSieve(int n){
    if (n < 2) return;
    div = new int[n + 1];
    Arrays.setAll(div, i -> i);
    int end = (int)Math.sqrt(n) + 1;
    for(int i = 2; i <= end; i++){
      int multiple = i;
      while(multiple <= n){
        div[multiple] = i;
        multiple += i;
      }
    }
  }
  boolean isPrimeNumber(int n){
    if(n <= 1) return false;
    return div[n] == n;
  }
  int minimumMultiple(int n){
    return div[n];
  }
}

Measured memory_bytes: 114960
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

class Main{
    public static void main(String[] args) throws IOException{
        final PrintWriter out = new PrintWriter(System.out);
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final int n = Integer.parseInt(br.readLine());
        final String[] in = br.readLine().split(" ");
        final int[] a = new int[n];
        for(int i = 0; i<n; i++){
            a[i] = Integer.parseInt(in[i]);
        }
        int num = 0;
        for(int i = 0; i<n; i++){
            int mini = i;
            for(int j = i+1; j<n; j++){
                if(a[j]<a[mini]) mini = j;
            }
            if(i!=mini){
                num++;
                final int t = a[i];
                a[i] = a[mini];
                a[mini] = t;
            }
        }
        out.print(a[0]);
        for(int i = 1; i<n; i++)
            out.print(" "+a[i]);
        out.println();
        out.println(num);
        out.flush();
    }
}

Measured memory_bytes: 24476
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

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

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

	int n, k;
	cin >> n >> k;
	vector<int> p(n);
	for (int& x : p) cin >> x;
	sort(p.begin(), p.end());
	int ans = 0;
	rep(i, k) ans += p[i];
	cout << ans << endl;
 	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

void solve() {
    int K;
    cin >> K;
    int A,B;
    cin >> A >> B;
    int tmp = K;
    while(K <= 1000) {
        if ( A <= K && K <= B) {
            cout << "OK" << endl;
            return;
        }
        K+=tmp;
    }
    cout << "NG "<< endl;
}

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


Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void solve() {
        Int N;
        cin >> N;
        vector<Int> A(N);
        for (int i = 0; i < N; ++i) {
            cin >> A[i];
            A[i] -= (i + 1);
        }

        vector<Int> B = A;
        sort(all(B));
        Int med = B[B.size() / 2];
        Int ans = 0;
        for (int i = 0; i < N; ++i) {
            ans += abs(med - A[i]);
        }

        cout << ans << endl;

    }

};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 3328
class in{struct myIterator{int it;const bool rev;explicit constexpr myIterator(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(myIterator& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const myIterator i,n;public:explicit constexpr in(int n):i(0),n(n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const myIterator& begin(){return i;}const myIterator& end(){return n;}};

#include <bits/stdc++.h>
using namespace std;
 
using i64 = long long;
inline i64 calc(i64 mean, const vector<i64>& vec, vector<i64>& ma) {
    i64 res = 0LL;
    for(int i : in(vec.size())) {
        i64 t = vec[i];
        i64 plus = mean > t ? mean - t : t - mean;
        ma[i] += plus;
        res += plus << 1LL;
    }
    return res;
}
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    i64 w, h, n;
    cin >> w >> h >> n;
    vector<i64> xcoord(n), ycoord(n);
    for(int i : in(n))
      cin >> xcoord[i] >> ycoord[i];
    auto sortx = xcoord, sorty = ycoord;
    sort(sortx.begin(), sortx.end());
    sort(sorty.begin(), sorty.end());
    vector<i64> midId = {n / 2};
    if(~n & 1) midId.emplace_back(n / 2 - 1);
    tuple<i64, i64, i64> ans(1e18, 0LL, 0LL);
    for(auto id1 : midId) for(auto id2 : midId) {
        i64 x = sortx[id1], y = sorty[id2];
        vector<i64> ma(n, 0LL);
        i64 sum = calc(x, xcoord, ma) + calc(y, ycoord, ma);
        sum -= *max_element(ma.begin(), ma.end());
        ans = min(ans, make_tuple(sum, x, y));
    }
    i64 sum, x, y; tie(sum, x, y) = ans;
    cout << sum << '\n' << x << ' ' << y << endl;
    return 0;
}

Measured memory_bytes: 6920
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

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


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <random>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N; cin >> N;
	int d1 = N % 10;
	if (d1 == 2 || d1 == 4 || d1 == 5 || d1 == 7 || d1 == 9) cout << "hon\n";
	else if (d1 == 0 || d1 == 1 || d1 == 6 || d1 == 8) cout << "pon\n";
	else cout << "bon\n";
	return 0;
}




Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>

typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e18;
const ll N = 3e5;
const ll bits = 20;
const ld pi = 3.14159265358979323846;
const ll mod = 1e9+7;
const ll p = 29;

int par[N],rnk[N];
void init(int n){
    
    for(int i=1;i<=n;i++){
        par[i]= i;
        rnk[i] = 0;
    }
}

int root(int x){
    if(par[x]!=x){
        par[x] = root(par[x]);
    }
    return par[x];
}

bool merge(int u,int v){
    int ru = root(u);
    int rv = root(v);

    if(ru==rv) return false;
    
    if(rnk[ru]>rnk[rv]) swap(rv,ru);

    rnk[rv]++;    
    par[ru] = rv;

    return true;
}

int main(){

    FASTIO;
    PRECISION; 

    int n,m,u,v,z;
    cin>>n>>m;
    init(n);

    for(int i=0;i<m;i++){
        cin>>u>>v>>z;
        merge(u,v);
    }

    int count = 0;

    for(int i=1;i<=n;i++){
        if(par[i]==i) count++;
    }

    cout<<count<<"\n";
    
}


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

typedef long long ll;
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define rerepi(i, a, b) for(int i = int(a)-1; i >= b; --i)
#define rerep(i, n) rerepi(i, n, 0)
#define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() );

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

const long long INF = 1LL << 60;

// ここから開始だよ！
ll H, W, shiro_count, marker[51][51], tmp;
string maps[51][51], inin;
queue<ll> Qx;
queue<ll> Qy;

int run() {
	if (Qx.empty()) {
		return 0;
	}
	ll x = Qx.front();
	ll y = Qy.front();
	Qx.pop();
	Qy.pop();
	ll base = marker[x][y];
	
	if (x+1 <= H && maps[x+1][y] != "#" && marker[x+1][y] == -1) {
		marker[x+1][y] = base + 1;
		Qx.push(x+1);
		Qy.push(y);
	}
	if (x-1 >= 1 && maps[x-1][y] != "#" && marker[x-1][y] == -1) {
		marker[x-1][y] = base + 1;
		Qx.push(x-1);
		Qy.push(y);
	}
	if (y+1 <= W && maps[x][y+1] != "#" && marker[x][y+1] == -1) {
		marker[x][y+1] = base + 1;
		Qx.push(x);
		Qy.push(y+1);
	}
	if (y-1 >= 1 && maps[x][y-1] != "#" && marker[x][y-1] == -1) {
		marker[x][y-1] = base + 1;
		Qx.push(x);
		Qy.push(y-1);
	}
	return 1;
}

int main() {
	cin >> H >> W;
	repi(i, 1, H+1) {
		cin >> inin;
		rep(j, inin.size()) {
			maps[i][j+1] = inin[j];
			if (maps[i][j+1] == ".") {
				shiro_count += 1;
			}
		}
	}
	repi(i, 1, H+1) {
		repi(j, 1, W+1) {
			marker[i][j] = -1;
		}
	}
	
	marker[1][1] = 0;
	Qx.push(1);
	Qy.push(1);
	
	while(1) {
		if (0 == run()) {
			break;
		}
	}
	
	tmp = marker[H][W];
	if (-1 == tmp) {
		cout << -1 << endl;
		return 0;
	}
	cout << shiro_count - (tmp+1) << endl;
	return 0;
}


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

int min_moves(string s)
{
    int opts=0;
    int len=s.length();
    for(int i=0;i<len/2;++i){
        if(s[i]!=s[len-i-1]) opts++;
    }
    return opts;
}

int main() {
    string s;
    cin>>s;
    cout<<min_moves(s);
    return 0;
}

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

long long int n, a, b;
long long int x[100000];
long long int d[100000];
long long int ans;

int main(){
	scanf("%lld %lld %lld", &n, &a, &b);
	for(int i=0; i<n; i++) scanf("%lld", &x[i]);

	for(int i=0; i<n-1; i++){
		d[i] = a * (x[i+1] - x[i]);
		if(d[i] < b) ans += d[i];
		else ans += b;
	}

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

Measured memory_bytes: 1664
x = int(input())
if x < 600:
    print(8)
elif x < 800:
    print(7)
elif x < 1000:
    print(6)
elif x < 1200:
    print(5)
elif x < 1400:
    print(4)
elif x < 1600:
    print(3)
elif x < 1800:
    print(2)
else:
    print(1)

Measured memory_bytes: 9176
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
 
#include <bits/stdc++.h>
 
using namespace std;
 
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  
#define pb push_back
#define in insert
#define f first
#define s second
#define ll long long
#define dd double
  
const int mod = 1e9 + 7;
const int N = 2e5 + 7;
const int inf = 2e9;
const ll INF = 1e18;

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	// freopen("*.in", "r", stdin);freopen("*.out", "w", stdout);
	int x[6];
	for (int i = 1; i <= 5;i++) {
		cin >> x[i];
	}

	for (int i= 1; i <= 5; i++) {
		if (x[i] == 0) cout << i << " ";
	}
}

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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



int main(void)
{
  ll n;
  vector<ll> a;
  cin >> n;
  REP(i, n) {
    ll a1;
    cin >> a1;
    a.push_back(a1 - 1);
  }

  ll cnt = 0;
  REP(i, n) {
    if(i == a[a[i]]) cnt ++;
  }
  cout << (cnt / 2) << endl;
    
}


Measured memory_bytes: 1400
n,k = map(int,input().split())
d = list(map(str,input().split()))
a = 0 #フラグ
for i in range(n,100000):
    for j in d:
        if j in str(i): # もしも嫌いな文字dが含まれていたらこの文字iはだめ
            a = 1 #フラグをダメにする　次の値段にアップ
            break
        elif j == d[-1]: a=0 #最後までまわった⇨全て含まれない⇨フラグ０に
    if a==0:  
        print(i)
        break

Measured memory_bytes: 3060
//ヘッダファイル
#include<stdio.h>
#include<string.h>

//マクロ定義
#define MAX 300
#define BORDER 80
#define FALSE 1
#define compile 0

//プロトタイプ宣言
void func_init(char array[]);
void func_cal(char input1[] , char input2[], char output[]);
void func_output(char array[], int n);

main()
{
	int a = 0, b = 0 , flag1 = 0, flag2 = 0;
	int n = 0, i = 0, j = 0;
	scanf("%d", &n); //データセットの個数を入力
	
	char input1[n][MAX], input2[n][MAX]; //入力用配列の宣言
	char result[n][MAX]; //結果代入用の配列
	
	for(i = 0; i < n; i++) //結果代入用の配列の初期化
	{
		func_init(result[i]);
	}
	
	for(i = 0; i < n; i++)
	{
		func_init(input1[i]); //input1を初期化
		scanf("%s", input1[i]); //整数文字列1を読み取り
		//printf("input1[%d] = %s\n", i, input1[i]);
		a = 0;
		while(input1[i][a] != 0x00) //input1の最後の要素まで要素番号iを進める
		{
			//printf("a = %d\n", a);
			if(BORDER < a) //input1におけるoverflow判定
			{
				flag1 = FALSE;
				break;
			}
			a++;
		}
		if(flag1 == FALSE)
		{
			//printf("func_output_input1\n");
			func_output(input1[i], a);
			break;
		}
		
		func_init(input2[i]); //input2を初期化
		scanf("%s", input2[i]); //整数文字列2を読み取り
		
		b = 0;
		while(input2[i][b] != 0x00) //input2の最後の要素まで要素番号jを進める
		{
			if(BORDER < b)
			{
				flag2 = FALSE;
				break;
			}
			b++;
		}
		if(flag2 == FALSE)
		{
			//printf("func_output_input2\n");
			func_output(input2[i], b);
			break;
		}
		
		func_cal(input1[i], input2[i], result[i]);
		
	}
	
	return 0;
}

void func_init(char array[])
{
	int i = 0;
	for(i = 0; i < MAX; i++)
	{
		array[i] = 0x00;
	}
}

void func_cal(char input1[] , char input2[], char result[])
{
	int i = 0, j = 0; //入力配列の要素番号
	int r = 0; //結果格納用の配列の要素番号
	int x = 0; //input1の要素を数値変換した際に代入
	int y = 0; //input2の要素を数値変換した際に代入
	int sum = 0; //x + yの結果を代入
	int up = 0; //桁の繰上げに使用
	
	while(input1[i] != 0x00) //input1の最後の要素まで要素番号iを進める
	{
		i++;
	}
	
	while(input2[j] != 0x00) //input2の最後の要素まで要素番号jを進める
	{
		j++;
	}
	i--;
	j--;
	
	while((i >= 0) || (j >= 0))
	{
		if(i >= 0)
		{
			x = input1[i] - 0x30;
			i--;
		}
		else
		{
			x = 0;
		}
		
		if(j >= 0)
		{
			y = input2[j] - 0x30;
			j--;
		}
		else
		{
			y = 0;
		}
		
		sum = x + y + up;
		
		if(10 <= sum)
		{
			sum -= 10;
			up = 1;
		}
		else
		{
			up = 0;
		}
		
		result[r] = sum;
		r++;
	}
	if(up != 0)
	{
		result[r] = up;
		r++;
	}
	//printf("func_output_result\n");
	func_output(result, r - 1);
}
void func_output(char array[], int n)
{
	int i = n;
#if compile == 1
	printf("i = %d\n", i);
#endif
	if(BORDER <= i)
	{
		printf("overflow\n");
	}
	else
	{
		while(i >= 0)
		{
			if(i == 0)
			{
				printf("%d\n", array[i]);
				i--;
			}
			else
			{
				printf("%d", array[i]);
				i--;
			}
		}
	}
}

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

int main() {
	string S,T;
    cin>>S>>T;
  	int	A =S.size();
    char f =T.at(A);
    if (S+f == T){
      cout<<"Yes"<<endl;
    }
  	else{
      cout<<"No"<<endl;
    }
    
  
}



Measured memory_bytes: 3580
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef pair < int, int > pii;

const int N = 16;
const int M = (1 << N);
const int INF = 0x3f3f3f3f;

int dp[N][M], g[N][N], n, m, rv[M];

int f(int st, int msk){
    if(st == n - 1) return 0;
    if(dp[st][msk] != -1) return dp[st][msk];
    int sol = INF;
    for(int msk1 = (msk - 1) & msk; msk1 ; msk1 = (msk1 - 1) & msk){
        int msk2 = msk ^ msk1;
        if(msk1 & (1 << (n - 1))) continue;
        if(msk2 & (1 << st)) continue;
        int sum = 0;
        for(int t1 = msk1; t1 ; t1 -= t1 & (-t1)){
            for(int t2 = msk2 ; t2 ; t2 -= t2 & (-t2)){
                sum += g[rv[t1 & (-t1)]][rv[t2 & (-t2)]];
            }
        }
        for(int t2 = msk2 ; t2 ; t2 -= t2 & (-t2)){
            if(g[st][rv[t2 & (-t2)]]){
                sol = min(sol, f(rv[t2 & (-t2)], msk2) + sum - g[st][rv[t2 & (-t2)]]);
            }
        }

    }
    return dp[st][msk] = sol;
}

int main(){
    memset(dp, -1, sizeof(dp));
    for(int i = 0;i<N;i++) rv[(1 << i)] = i;
    memset(dp, -1, sizeof(dp));
    scanf("%d%d", &n, &m);
    for(int i = 0;i<m;i++){
        int x, y;scanf("%d%d", &x, &y);x--;y--;
        scanf("%d", &g[x][y]);
        g[y][x] = g[x][y];
    }
    printf("%d\n", f(0, (1 << n) - 1));
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

int main()
{
        string s, t;
        cin >> s; cin >> t;
        if (s[0] == t[2] && s[1] == t[1] && s[2] == t[0]) {
                cout << "YES" << endl;
        }
        else {
                cout << "NO" << endl;
        }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    int cnt = 0;
    set<int> st;
    int a;
    REP(i,n){
        cin >> a;
        if(st.find(a) != st.end()){
            cnt++;
        }else{
            st.insert(a);
        }
    }
    if(cnt % 2 == 1){
        cnt++;
    }
    cout << n - cnt << endl;
}

Measured memory_bytes: 4992
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d,time;
	cin>>time;
	for(int abc=0;abc<time;abc++){
		cin>>a>>b>>c;
		if(a>b){
			d=a;
			a=b;
			b=d;
		}
			if(b>c){
			d=b;
			b=c;
			c=d;
		}
		if(a>b){
			d=a;
			a=b;
			b=d;
		}
		if(a*a+b*b==c*c){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  string S; cin >> S;
  int ans = 0;
  int ans2 = 0;
  rep(i, S.size()) {
    if (i == 0) ans += S[0] - '0' - 1;
    else ans += 9;
    ans2 += S[i] - '0';
  }
  cout << max(ans, ans2) << endl;
}


Measured memory_bytes: 256
import math
DEBUG_FREE = False
N = int(input())

tax_free_f = N/1.08
tax_free_int = math.ceil(tax_free_f)

if DEBUG_FREE:
    print("float    : %f"%tax_free_f)
    print("int      : %d"%tax_free_int)
    print("recover_f: %f"%(tax_free_int*1.08))
    print("recover_i: %d"%(int(tax_free_int * 1.08)))
    
if N == int(tax_free_int * 1.08):
    print(tax_free_int)
else:
    print(":(")

Measured memory_bytes: 3064
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict
def primefactor(n):
     ans=defaultdict(int)
     for i in range(2,int(n**0.5+1)):
         while n%i==0:
             ans[i] += 1
             n //= i
     if n>1:
         ans[n]=1
     return dict(ans)

from itertools import product
from functools import reduce

def main():
    N=int(input())
    d=primefactor(N)
    f=list(d.keys())
    v=[list(range(i+1)) for i in d.values()]
    ans = N - 1
    for i in product(*v):
        a = reduce(lambda x, y: x*y, [x**y for x, y in zip(f, i)])
        b = N // a
        ans = min(a-1 + b-1, ans)

    print(ans)

# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc144","c",main)




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

int main() {
  int a, b, cnt;
  cin >> a >> b;
  string s;
  for(int i = a; i <= b; i++){
    s = to_string(i);
    if(s.at(0) == s.at(4) && s.at(1) == s.at(3)){
      cnt++;
    }
  }
  cout << cnt << endl;
}


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

#define rep(i,n)  for(int i = 0; i < (int)(n); i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll a, b, c, d; std::cin >> a >> b >> c >> d;
  ll ans = -1e18-2;
  ans = std::max(ans, a*c);
  ans = std::max(ans, a*d);
  ans = std::max(ans, b*c);
  ans = std::max(ans, b*d);
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main(){
   int a1,a2,a3,a4,a5;
       cin>>a1>>a2>>a3>>a4>>a5;
       if(a1==0)
           cout<<"1"<<endl;
       if(a2==0)
           cout<<"2"<<endl;
       if(a3==0)
           cout<<"3"<<endl;
       if(a4==0)
           cout<<"4"<<endl;
       if(a5==0)
           cout<<"5"<<endl;
    return 0;
}

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

#define WHITE 1
#define BLACK 2

int w,h;
string s[50];
int dx[4]={0,-1,0,1};
int dy[4]={1,0,-1,0};
void rec(int x, int y, int mark)
{
  int i;
  int xx,yy;
  if(s[x][y]!='W'&&s[x][y]!='B')s[x][y]|=mark;
  for(i=0;i<4;i++){
    xx=x+dx[i];
    yy=y+dy[i];
    if((xx<0)||(h<=xx))continue;
    if((yy<0)||(w<=yy))continue;
    if(s[xx][yy]=='W'||s[xx][yy]=='B')continue;
    if((s[xx][yy]&mark)==mark)continue;
    rec(xx,yy,mark);
  }
}

int main()
{
  int i,j;
  int W,B;
  while(cin>>w>>h,w||h){
    for(i=0;i<h;i++)cin>>s[i];
    /*
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	cout<<s[i][j];
      }
      cout<<endl;
    }
    */
    for(i=0;i<h;i++)for(j=0;j<w;j++)if(s[i][j]=='.')s[i][j]=0;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(s[i][j]=='W')rec(i,j,WHITE);
	if(s[i][j]=='B')rec(i,j,BLACK);
      }
    }
    /*
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	printf("%d",s[i][j]);
      }
      cout<<endl;
    }
    */
    W=B=0;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(s[i][j]==WHITE)W++;
	if(s[i][j]==BLACK)B++;
      }
    }
    cout<<B<<" "<<W<<endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  int minv = INT_MAX;
  for (int res = 0; res < 101; res++) {
    int count = 0;
    for (int i = 0; i < n; i++) {
      count += abs(res-v[i]) * abs(res-v[i]);
    }
    minv = min(minv, count);
  }
  cout << minv << endl;

}


Measured memory_bytes: 256