akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include<cmath>
#include <queue>
#include <numeric>

using lli = long long int;
int inf = 1000000007;
using namespace std;
#define sort(X) sort(X.begin(),X.end())

int N, M;

int main()
{
	cin >> N >> M;
	int wf[100][100];
	for (int i = 0; i < 100; i++)
		for (int j = 0; j < 100; j++)wf[i][j] = (i == j ? 0 : inf);
	vector<int> A;
	vector<int> B;
	vector<int> C;
	for (int i = 0; i < M; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		A.push_back(a-1),B.push_back(b-1),C.push_back(c);
		wf[a - 1][b - 1] = wf[b - 1][a - 1] = c;
	}
	//wf
	for (int t = 0; t < N; t++)
		for (int s = 0; s < N; s++)
			for (int g = 0; g < N; g++)
				wf[s][g] = min(wf[s][g], wf[s][t] + wf[t][g]);
	//最短経路ではない辺を探す
	int ans = 0;
	for (int i = 0; i < M; i++) {
		if (wf[A[i]][B[i]] < C[i])ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int i;
    
    //input
    int n;
    scanf("%d", &n);
    
    int R[n];
    for( i = 0; i < n; i++)
        scanf("%d", &R[i]);
    
    int max = R[1] - R[0];
    int min = R[0];
    
    for ( i = 1; i < n; i++){
        max = max < R[i] - min ? R[i] -min : max;
        min = min > R[i] ? R[i] : min;
    }
    printf("%d\n", max);
    
    return 0;
}


Measured memory_bytes: 2616
#include <iostream>

using namespace std;

long long gcd(long long a, long long b) {
	if(a < b) gcd(b, a);
	if(b == 0) return a;
	long long r = a % b;
	return gcd(b, r);
}

int main() {
	long long A, B, C, D;
	cin >> A >> B >> C >> D;
	A--;
	long long ca, cb, da, db, cda, cdb;
	ca = A / C, cb = B / C, da = A / D, db = B / D;
	long long CD = C * D / gcd(C, D);
	cda = A / CD, cdb = B / CD;
//	cout << ca << " " << cb << " " << da << " " << db << " " << cda << " " << cdb << endl;
	cout << B - A - (cb - ca) - (db - da) + (cdb - cda) << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define RREP(i,n) for(long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define llINF (long long) 9223372036854775807
#define loINF (long) 2147483647
#define shINF (short) 32767
#define SORT(c) sort((c).begin(),(c).end())
#define DEBUG

using namespace std;
typedef vector<long> VI;
typedef vector<VI> VVI;
typedef pair<long,long> pr;
typedef map<double,pr> mp;

short N;
char t;

int main(void){
    cin >> N;
    REP(i,N){
        cin >> t;
        if (t == 'Y'){
            cout << "Four";
            return 0;
        }
    }
    cout << "Three";
    return 0;
}

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

bool is_uruu(int y){
    if(y % 4 == 0){
        if(y % 100 == 0){
            if(y % 400 == 0) return true;
            else return false;
        }else return true;
    }else return false;
}
 
int main(){
    int month[] = {31,28,31,30,31,30,31,31,30,31,30,31};
    int a,b,c,d,e,f;
    while(cin >> a >> b >> c >> d >> e >> f,a >= 0){
        int x = c,y = f;
        for(int i = 0;i < a;i++){
            if(is_uruu(i)) x += 366;
            else x += 365;
        }
        for(int i = 0;i < d;i++){
            if(is_uruu(i)) y += 366;
            else y += 365;
        }
        for(int i = 0;i < b - 1;i++){
            if(i == 1 && is_uruu(a)) x += 29;
            else x += month[i];
        }
        for(int i = 0;i < e - 1;i++){
            if(i == 1 && is_uruu(d)) y += 29;
            else y += month[i];
        }
        cout << y - x << endl;
    }
    return 0;
}


Measured memory_bytes: 3080
import math
n, k = map(int,input().split())
a = list(map(int, input().split()))

asum = sum(a)
gcdmax = int(math.sqrt(asum))
li = []
for i in range(2,gcdmax+1):
    if asum%i==0:
        li.append(i)
for i in range(gcdmax,0,-1):
    if asum%i==0:
        li.append(asum//i)


ans = 1
# print(li)

for i in li:
    b = [a[ii] % i for ii in range(n)]
    b.sort()
#     print(i,b)
    l = 0
    r = 0
    x = 0
    y = n-1
    while x<=y:
        if r>=l:
            l += b[x]
            x += 1
        else:
            r += i - b[y]
            y -= 1
#         print(l,r)
    if max(l,r) <= k and (l-r)%i==0 :
        ans = i

print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class T> using treap = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
    {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
    {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
    {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
template <class T, class S> ostream& operator<<(ostream& s, unordered_map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
    #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
    #define dump(...)
    #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(nullptr); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
    int n; cin >> n;
    cout << n * n * n << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int a[100],n,b,sum=0,c,dem=1;
    cin>>n>>b>>c;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]==0) continue;
        if(a[i]>=1) sum++;
        for(;dem*a[i]+1<=b;){
            sum++;
            dem++;
        }
        dem=1;
    }
    // }
    // for(int i=0;i<n;i++){
    //     sum=a[n-i-1]-a[n-i-2];
    //   // cout<<sum<<endl;
    // }
    cout<<sum+c;
    return 0;
}

Measured memory_bytes: 256
#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 main() {
  int K;
  cin >> K;

  ll x = 7;
  for (int i = 1; i <= K; i++) {
    if (x % K == 0) {
      cout << i << endl;
      return 0;
    }
    x = (x * 10 + 7) % K;
  }

  cout << "-1" << endl;
  return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define int long long 
using namespace std;


int32_t main(){
	
	int n,h;
	cin>>h>>n;
	
	int dp[n+1][h+1];
	for (int i=0;i<=h;i++)
		dp[0][i] = INT_MAX;
	
	for (int i=0;i<=n;i++)
		dp[i][0] = 0;
	
	
	for (int i=1;i<=n;i++){
		int a,b;
		cin>>a>>b;
		
		for (int j=1;j<=h;j++){
			
			int diff = j-a;
			if (diff<=0)
				dp[i][j] = min(b,dp[i-1][j]);
			else
				dp[i][j] = min(dp[i-1][j],b+dp[i][j-a]);
		}	
	}
	
	cout<<dp[n][h];


}

Measured memory_bytes: 78464
from collections import Counter

N=int(input())
A=input()
B=input()
C=input()

D=[]
for i in range(N):
  mc = Counter([A[i],B[i],C[i]]).most_common()[0][0]
  D.append(mc)
D=''.join(D)
  
def diff(s1,s2):
  out=0
  for i in range(len(s1)):
    if s1[i] != s2[i]:
      out += 1
  return out

ans=0
ans+=diff(D,A)
ans+=diff(D,B)
ans+=diff(D,C)

print(ans)

Measured memory_bytes: 9476
a=input()
b=input()
c=input()

x=a[0]
a=a[1:]
while True:
  if x=="a":
    if a=="":
      print("A")
      break
    else:
      x=a[0]
      a=a[1:]
  elif x=="b":
    if b=="":
      print("B")
      break
    else:
      x=b[0]
      b=b[1:]
  elif x=="c":
    if c=="":
      print("C")
      break
    else:
      x=c[0]
      c=c[1:]

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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int a[5];
  int c[5];
  int sum=0;
  for(int i=0;i<5;i++){
    cin>>a[i];
    if(a[i]%10==0){
      c[i]=a[i]/10;

    }else{
      c[i]=a[i]/10+1;
    }
    sum+=c[i];
  }
  int d[5];
  for(int i=0;i<5;i++){
    d[i]=(sum-c[i])*10+a[i];

  }
  sort(d,d+5);
  cout<<d[0];
  




}



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

int main() {
  int n;
  cin >> n;
  map<string, int> m;
  int c = 0;
  while (n--) {
    string e;
    cin >> e;
    m[e]++;
    c = max(c, m[e]);
  }
  set<string> s;
  for (const auto& e : m) {
    if (e.second == c) s.insert(e.first);
  }
  for (const auto& e : s) cout << e << endl;
}


Measured memory_bytes: 34560
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    int l=sc.nextInt();
    int sum=0;
    if(aji(l,1)*aji(l,n)>0){
        sum -= aji(l,1)>0 ? aji(l,1) : aji(l,n) ;
    }
    for(int i=1;i<=n;i++){
        sum+=aji(l,i);
    }
    System.out.println(sum);
  }
  static int aji(int l,int i){
      return l+i-1;
  }
}


Measured memory_bytes: 21844
/* -> Written by <-
   -----------
  |K_A_Z_A_M_A|
  |___________|
  |    ___    |
  |   (^_^)   |
  |  /( | )\  |
  |____|_|____|
    H O A N G
*/

// i hope i get better

// Task name:
#define Task ""
using namespace std;

// Include
#include <bits/stdc++.h>

// Define
#define reset(x, value) memset((x), (value) ,sizeof((x)))
#define fr(i,a,b) for(int i = (a); i <= (b); i++)
#define FR(i,a,b) for(int i = (a); i < (b); i++)
#define frr(i,a,b) for(int i = (a); i >= (b); i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define nl "\n"
#define bit(x,i) (x >> i) & 1
#define all(x) (x).begin(), (x).end()
#define optimize(x) (x).resize(unique(all(x)) - (x).begin())
#define Inpf freopen(Task".inp","r",stdin)
#define Outf freopen(Task".out","w",stdout)
#define fasterIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

// typedef
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vii;
typedef vector<ll> vll;

const int base = 131;
const int MOD = 1e9 + 7;
const ll MM = 1ll * MOD * MOD;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

template <class T> inline void Gmax(T &x,T y)
{
    x = max((x), (y));
}
template <class T> inline void Gmin(T &x,T y)
{
    x = min((x), (y));
}

// --------------------------------------------------------------------
const int maxn = 1e5 + 5;
// --------------------------------------------------------------------

void Solve()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int x = min(a, k);
    k -= x;
    int cost = x;
    if (k)
    {
        int y = min(k, b);
        k -= y;
        if (k)
        {
            int z = min(k, c);
            cost -= z;
        }
    }
    cout << cost;
}

int main()
{

    fasterIO;
    int test = 1;
//    cin >> test;
    while (test --)
        Solve();

    // Did you check with the special test case n = 0, n = 1??
}

// Goodbye, see u again


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

int T[3] = {1, 5, 10};
int M[3] = {0, 0, 0};

int fresh() {
    return T[0]*M[0] + T[1]*M[1] + T[2]*M[2];
}

int main()
{
    int N, Y;
    cin >> N >> Y;
    Y /= 1000;
    M[0] = N;
    int sub = Y - fresh();
    // 4*i + 9*j == sub (i + j <= N) となるi, jを求める。
    for(int i = 0; i <= N; ++i) {
        int tmp = sub - 4*i;
        if( tmp >= 0 && tmp%9 == 0 && (i + tmp/9) <= N) {
            M[0] -= i + tmp/9;
            M[1] = i;
            M[2] = tmp/9;
            break;
        }
    }
    if(fresh() != Y) cout << "-1 -1 -1" << endl;
    else cout << M[2] << " " << M[1] << " " << M[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main(){
  ll n,m;
  cin>>n>>m;
  vector<ll> v;
  ll sum = 0;
  rep(i,0,n){
    ll a;
    cin>>a;
    v.pb(a);
    sum+=a;
  }
  ll c = 0;
  rep(i,0,v.sz){
    if(v[i]*4*m>=sum)c++;
  }
  if(c>=m){
      cout << "Yes" << endl;
  }
  else{
      cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args)  {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        String []a = new String [H];
        
        for(int i=0; i<H; i++){
            a[i] = sc.next();
        }
        
        boolean [] judge1 = new boolean [H];
        boolean [] judge2 = new boolean [W];
        
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                if(a[i].charAt(j) == '#'){
                    judge1[i] = true;
                    judge2[j] = true;
                }
            }
        }
        
        for(int i=0; i<H; i++){
            if(judge1[i] == false){
                continue;
            }
            for(int j=0; j<W; j++){
                if(judge2[j] == false){
                    continue;
                }
                System.out.print(a[i].charAt(j));
            }
            System.out.println("");
        }

    }
}

Measured memory_bytes: 39180
// /Code by : Harry_Singh/
#include<bits/stdc++.h>
#define int long long 
#define io ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define ipair pair<int,int>
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fo(i,n) for(int i=n;i>=0;i--)
#define F(i,n) for(int i=1;i<=n;i++)
#define FO(i,n) for(int i=n;i>=1;i--)
#define mod 1000000007
using namespace std;
#define inf 100000000000000009
#define tr cout<<"\n" 
#define br break
#define N 100005
// directions
vector<int> G[N];

void we_have_choices()
{


string s;
cin>>s;
int sum=0;
for(int i=0;i<s.length();i++)
	sum+=(s[i]-'0');

if(sum%9==0)cout<<"Yes";
else cout<<"No";
tr;
}


int32_t main()
{
#ifndef ONLINE_JUDGE
 freopen("input.txt","r",stdin);
 freopen("output.txt","w",stdout);
#endif
    io;
    int t=1;
    while (t--)we_have_choices();
    return 0;
}

Measured memory_bytes: 6128
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main() {
  int a,b;
  cin >> a >> b;
  string x = to_string(a);
  string y = to_string(b);
  string z = x+y;
  int c = stoi(z);

  for (int i = 0; i < 1000; i++) {
    if (i*i == c) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int N, M, Q; cin >> N >> M >> Q;
  vector<vector<int>> F(N+2, vector<int>(N+2, 0));
  for (int _ = 0; _ < M; ++_) {
    int l, r; cin >> l >> r;
    ++F[l][r];
  }
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) {
      F[i+1][j] += F[i][j];
      F[i][j+1] += F[i][j];
      F[i+1][j+1] -= F[i][j];
    }
  }
  for (int _ = 0; _ < Q; ++_) {
    int p, q; cin >> p >> q;
    auto res = F[q][q] - (F[p-1][q] + F[q][p-1]) + F[p-1][p-1];
    cout << res << CRLF;
  }
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


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

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

    queue<string> q;
    q.push("");
    int ans=0;
    while(q.size()){
        string tmp=q.front();q.pop();
        int a,b,c;a=b=c=0;
        for(int i=0;i<tmp.size();i++){
            if(tmp[i]=='3') a++;
            if(tmp[i]=='5') b++;
            if(tmp[i]=='7') c++;
        }
        if(a>0&&b>0&&c>0&&stoll(tmp)<=n){
            ans++;
        }
        if(tmp.size()>9){
            continue;
        }
        tmp+='3';
        q.push(tmp);
        tmp.pop_back();
        tmp+='5';
        q.push(tmp);
        tmp.pop_back();
        tmp+='7';
        q.push(tmp);
        tmp.pop_back();
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 5092
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

//string HOGE(".!\"#&%&'()*+,-/:;<=>?@[\\]^_`{|}~"); // ok
//string HOGE(".!\"#&%&'()*+,-/:"); // bad
//string HOGE(";<=>?@[\\]^_`{|}~"); // bad

//string HOGE(".!\"#&%&'"); // bad
//string HOGE("()*+,-/:;<=>?@[\\"); // bad
//string HOGE("]^_`{|}~"); // bad

//string HOGE(".!\"#&%&'()*+,-/:;<=>?@[\\"); // bad
//string HOGE("()*+,-/:;<=>?@[\\]^_`{|}~"); // bad

//string HOGE(".!\"#&%&'()*,-/:;<=>?@[\\]^_`{|}~"); // ok (no +)

//string HOGE(".!\"#&%&'()*+,-/:;<=>?@[\\]^_"); // ok -5


// included '_'

//string HOGE("_.!\"#&%&'()*+,-/:;<=>?"); // ok more -5
//string HOGE("_.!\"#&%&'()*+,-/:"); // ok more -5 

string HOGE("_.!\"#&%&'()*"); // ? more -5 

int main(void) {
	string s;

	int total = 0;

	while (cin >> s) {
		replace_if(s.begin(), s.end(), [](char c){ return isalpha(c) || c == '.' || HOGE.find(c) != string::npos; }, ' ');
		
		istringstream iss(s);
		int num;
		while (iss >> num) {
			total += num;
		}
	}

	cout << total << endl;

	return 0;}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m=0,l=0,sum=0;

        cin>>n;
        while(l<n){
            l++;
            if(l%3!=0&&l%5!=0){
                m+=l;}


        }sum=sum+m;
       cout << sum<<endl;



}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  
  vector<int> d(N);
  for(int i=0;i<N;i++){
    cin >> d.at(i);
  }
  
  sort(d.begin(),d.end());
  int h=d.size()/2;
  
  if(d.at(h)>d.at(h-1)){
    cout << d.at(h)-d.at(h-1) << endl;
  }else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 640
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
 
int main() {
  int N;
  while(cin >>N && N){
    vector<int> cnt(10, 0);
    REP(i, N){
      int n; cin >>n;
      ++cnt[n];
    }
    REP(i, 10){
      if(cnt[i] <= 0) cout <<"-" <<endl;
      else{
        REP(j, cnt[i]) cout <<"*";
        cout <<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector<int> B(N);
	for(int i = 0; i < N; i++) cin >> B[i];
	for(int i = 0; i < N; i++) if(B[i] > i+1) {
		cout << "-1\n";
		return 0;
	}
	vector<int> ans, A = B;
	for(int i = 0; i < N; i++) {
		int id = -1;
		for(int j = 0; j < N-i; j++) if(A[j] == j+1) id = j;
		if(id == -1) {
			cout << "-1\n";
			return 0;
		}
		A.erase(begin(A)+id);
		ans.push_back(id+1);
	}
	reverse(begin(ans), end(ans));
	for(int i = 0; i < N; i++) cout << ans[i] << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 256
//X軸とY軸に独立に写像、あとは累積和やるだけ。O( N+W+H )
#include<iostream>
using namespace std;

int n, W, H;
int x[100000], y[100000], w[100000];
int Fillx[100001], Filly[100001];

int main() {
	int i, j, k;
	cin >> n >> W >> H;
	for( i = 0; i < n; i++ ) 
		cin >> x[i] >> y[i] >> w[i];
	
	for( i = 0; i < n; i++ ) {
		//cout << space << endl;
		Fillx[max(0, x[i] - w[i])]++;
		Fillx[min(W, x[i] + w[i])]--;
		Filly[max(0, y[i] - w[i])]++;
		Filly[min(H, y[i] + w[i])]--;
	}
	for( i = 1; i < W; i++ ) 
		Fillx[i] += Fillx[i-1];
	for( i = 1; i < H; i++ ) 
		Filly[i] += Filly[i-1];
		
	bool ok1 = true;
	for( i = 0; i < W; i++ ) {
		if ( !Fillx[i] )
			ok1 = false;
	}
	bool ok2 = true;
	for( i = 0; i < H; i++ ) {
		if ( !Filly[i] )
			ok2 = false;
	}
	if( ok1 || ok2 )
		cout << "Yes" << endl;
	else 
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main() {
    set<char> letters;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        letters.insert(s[i]);
    }
    if (letters.size() == 2) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 3528
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll; //long longをllとして簡略

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int nxt=1,ans=0;
    rep(i,n){
        if(nxt == a[i]){
            ++nxt;
        }
        else {
            ++ans;
        }
    }
    if(ans==n)ans=-1;
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
  char x[100]={},y[100]={};
  int h=0,t=0;
  int n;
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %s",x,y);
    j = 0;
    while(j<50){
      if(x[j]<y[j]){
	h += 3;
	break;
      }
      else if(y[j]<x[j]){
	t += 3;
	break;
      }
      else if(x[j]==0&&y[j]==0){
	h++;
	t++;
	break;
      }
      else if(x[j]==0&&y[j]!=0){
	t += 3;
	break;
      }
      else if(y[j]==0&&x[j]!=0){
	h += 3;
	break;
      }
      j++;
    }
  }
  printf("%d %d\n",t,h);
  return 0;
}

Measured memory_bytes: 1808
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
using namespace std;
template<class T>inline void read(T &x) {
    x=0; int ch=getchar(),f=0;
    while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    if(f)x=-x;
}
const int inf=0x3f3f3f3f;
int n;
int main()
{
	cin>>n;
	string s;cin>>s;
	int cnt=1;
	for(int i=0;i<s.size();i++)
	{
		if(i==0) continue;
		if(s[i]==s[i-1]) continue;
		cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <math.h>
using namespace std;
typedef long long ll;

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

  vector<int> times(N);
  for (int i = 0; i < N; i++) cin >> times.at(i);

  int M;
  cin >> M;

  vector<vector<int>> drinks(M, vector<int>(2));
  for (int i = 0; i < M; i++) cin >> drinks.at(i).at(0) >> drinks.at(i).at(1);

  int sum=0;
  for (int i = 0; i < M; i++) // loop for drinks
  {
    for (int j = 0; j < N; j++) // calc time
    {
      if (drinks.at(i).at(0) == j+1) sum += drinks.at(i).at(1);
      else sum += times.at(j);
    }
    cout << sum << endl;
    sum = 0;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <vector>

int getCombo(std::vector<int> v, int n, int mod) {
    int j = 0;
    if (n % 2 == 0) {
        for (int i = 0; i < n; i++) {
            if (v[i] != 2*j + 1) return 0;
            if (i % 2 == 1) j++;
        }
    } else {
        for (int i = 0; i < n; i++) {
            if (v[i] != 2*j) return 0;
            if (i % 2 == 0) j++;
        }
    }

    int result = 1;
    for (int i = 0; i < n/2; i++) {
        result = result*2 % mod;
    }
    return result;
}

int main() {
    int n;
    std::cin >> n;
    std::vector<int> v(n);

    for (int i = 0; i < n; i++) {
        std::cin >> v[i];
    }

    std::sort(v.begin(), v.end());

    int mod = std::pow(10, 9) + 7;
    printf("%d\n", getCombo(v, n, mod));
}

Measured memory_bytes: 1024
#include"stdio.h"
#include"stdlib.h"
#define INFTY 1000000001

int C;

void marge(int *A,int left,int mid,int right)
{
  int n1=mid-left;
  int n2=right-mid;
  int *L=(int*)malloc(sizeof(int)*(n1+1));
  int *R=(int*)malloc(sizeof(int)*(n2+1));
  int i,j,k;
  for(i=0;i<n1;i++)
    {
      L[i]=A[left+i];
    }
  for(i=0;i<n2;i++)
    {
      R[i]=A[mid+i];
    }
  L[n1]=INFTY;
  R[n2]=INFTY;
  i=0;
  j=0;
  for(k=left;k<right;k++)
    {
      C++;
      if(L[i]<=R[j])
        {
          A[k]=L[i];
          i++;
        }
      else
        {
          A[k]=R[j];
          j++;
        }
    }
}
void margeSort(int *A,int left,int right)
{
  int mid;
  if(left+1<right)
    {
      mid=(left+right)/2;
      margeSort(A,left,mid);
      margeSort(A,mid,right);
      marge(A,left,mid,right);
    }
}
int main()
{
  int *S;
  int n;
  int i;
  C=0;
  scanf("%d",&n);
  S=(int*)malloc(sizeof(int)*n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&S[i]);
    }
  margeSort(S,0,n);
  printf("%d",S[0]);
  for(i=1;i<n;i++)
    {
      printf(" %d",S[i]);
    }
  printf("\n%d\n",C);
}


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

int main() {
    unsigned long N, M;
    cin >> N >> M;
    vector<vector<unsigned long>> edges(N);
    for (unsigned long i = 0, a, b; i < M; ++i) {
        cin >> a >> b;
        edges[--a].push_back(--b);
        edges[b].push_back(a);
    }

    vector<unsigned long> used(N);
    vector<unsigned long> ans({0});
    used[0] = 1;
    
    for(unsigned long beg = 0, iter = 2; iter--; beg = 0){
        while([&edges, &beg, &used, &ans]{
            for(const auto i : edges[beg])
                if(!used[i]){
                    used[beg = i] = 1;
                    ans.push_back(beg);
                    return true;
                }
            return false;
        }());
        reverse(ans.begin(), ans.end());
    }

    cout << ans.size() << endl;
    for(const auto i : ans)cout << i + 1 << " ";

    return 0;
}

Measured memory_bytes: 7924
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define inc(a) scanf("%c", &(a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
int main(void){
    ll N, l, r, ans=0;
    in(N);
    rep(_, N){
        in2(l, r);
        ans += 1 + r - l;
    }
    put(ans);
    return 0;
}


Measured memory_bytes: 128
#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 main() {
    string s;
    cin >> s;

    vector<int> N(s.size());

    for (int i = 0; i < s.size() ; ++i) {
        N.at(i) = (int)(s.at(i) - '0');
    }

    int sum = 0;
    for (int i = 0; i < N.size(); ++i) {
        sum += int(N.at(i));
    }
    if (sum % 9 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 4368
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

int main(){
  int n;
  int m;
  cin>>n>>m;
  vector<int> a(n);
  rep(i,n)
    cin>>a.at(i);
  
  int ans=0;
  int sum;
  rep(i,n)
    sum+=a.at(i);
  rep(i,n){
    if(a.at(i)*4*m>=sum)
      ans++;
  }
  if(ans>=m)
    Yes;
  else
    No;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int D, N;
int memo[256][256];
int a[256], e[256], r[256];
int func(int ex, int HP){
  if(HP <= 0){
    return 0;
  }
  if(memo[ex][HP] != -1) return memo[ex][HP];
  int res = INT_MAX/2;
  for(int i=0; i < N; i++){
    if(ex >= r[i]){
      if(a[i] == 0 && e[i] == 0) continue;
      if(a[i] == 0 && ex == 110) continue;
      res = min(res, func(min(110,ex+e[i]), HP-a[i])+1);
    }
  }
  memo[ex][HP] = res;
  return res;
}
 
int main(void){
  while(cin >> D >> N, D | N){
    for(int i=0; i < 256; i++){
      for(int j=0; j < 256; j++){
        memo[i][j] = -1;
      }
    }
    for(int i=0; i < N; i++){
      cin >> a[i] >> e[i] >> r[i];
    }
    int ans = func(0, D);
    if(ans == INT_MAX/2){
      cout << "NA" << endl;
    }else{
      cout << ans << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1440
//当其中有一个数不符，往后退，直到退到末尾，输出UNSTORABLE，若相符，将剩下问好替换为？; 
#include<bits/stdc++.h>
using namespace std;
string s,t,sss="";
int i,j,r;
int main()
{
    cin>>s>>t;
    if(s.size()<t.size()){
        cout<<"UNRESTORABLE";
        return 0;
    }
    for(i=0;i<=s.size()-t.size();i++)
	{
        int k=i;
        string ss=s;
        j=0;
        while(j<t.size())
		{
            if(ss[k]=='?')
                ss[k]=t[j];
            else if(s[k]!=t[j])
                break;
            k++;
            j++;
        }
        if(j==t.size())
		{
            for(r=0;r<ss.size();r++)
			{
                if(ss[r]=='?')
                {
            		ss[r]='a';
				}

            }
            if(sss=="")
                sss=ss;
            else sss=min(sss,ss);
        }
    }
    if(sss=="")
        cout<<"UNRESTORABLE";
    else cout<<sss;
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long long ll;

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n, 0);
    map<ll, ll> s;
    REP(i, n){
        cin >> a[i];
        s[a[i]]++;
    }
    ll remove = s.size() - k;

    vector<ll> freq;
    for (auto p : s){
        freq.push_back(p.second);
    }
    sort(ALL(freq));

    ll ct = 0;
    ll i = 0;
    
    while (remove > 0){
        ct += freq[i];
        remove--;
        i++;
        
    }
    cout << ct << endl;
}


Measured memory_bytes: 16500
def findSumOfDigits(n):
    ret = 0
    while n>0:
        ret += n % 10
        n //= 10
    return ret
 
if __name__ == '__main__':
    n, a, b = map(int, input().split())
    ttl = 0
    for i in range(1, n+1):
        sod = findSumOfDigits(i) ##各桁の和
        if (a <= sod) and (sod <= b):
            ttl += i
    print(ttl)    

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll mod=1e9+7;
#define endl '\n'
const ld PI=3.14159265358979;
#define w(x) int x;cin>>x;while(x--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vll vector<ll>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define F first
#define S second 
#define LB lower_bound
#define UB upper_bound
#define mset multiset
#define uset unordered_set
#define umap unordered_map
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll binpow(ll x, ll y, ll p){  ll res = 1;x = x % p;if (x == 0)return 0;while (y > 0)  { if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p;}return res;}  
ll gcd(ll a, ll b){ if (b == 0) return a; return gcd(b, a % b); } 
bool parity(ll x,ll y){ bool f = ((x ^ y) < 0);return !f;}

int main()
{
    IOS
    ld factor=PI/180.0;
    ld a,b,h,m;
    cin>>a>>b>>h>>m;
    h=h*5.0+((ld)m/60.0)*5.0;
    //cout<<fixed<<setprecision(12)<<h<<endl;
    ld deg=abs(h-m)*6.0;
    if(deg>180)
        deg=360.0-deg;
    //cout<<fixed<<setprecision(12)<<deg<<endl;
    
    ld ans=((a*a)+(b*b)-(2*a*b*cos(factor*deg)));
    ans=sqrt(ans);
    cout<<fixed<<setprecision(12)<<ans<<endl;

    return 0;  
}

Measured memory_bytes: 4148
using System;
using System.Linq;

class Program {
    static void Main() {
        int N = int.Parse(Console.ReadLine());
        for (int i = 0; i < N; i++) {
            int[] a = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();
            if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2]) {
                Console.WriteLine("YES");
            } else {
                Console.WriteLine("NO");
            }
        }
    }
}


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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

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

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

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

  string line;
  while(getline(cin, line), line != "") {
    string s = line, a;
    while(getline(cin, line), line != "") s += line;
    getline(cin, a);

    int n = s.size(), k = a.size();
    vint pos[55];
    rep(i, n) rep(j, k) {
      if(s[i] == a[j]) pos[j].push_back(i);
    }
    bool imp = false;
    rep(i, k) if(!pos[i].size()) imp = true;
    if(imp) {
      cout << 0 << endl << endl;
      getline(cin, line);
      continue;
    }

    int idx[55] = {};
    int ans = 0, head = 0, len = n;
    rep(i, n) {
      int tail = i;
      rep(j, k) chmax(tail, pos[j][idx[j]]);
      if(tail-i+1 < len) ans = 0, head = i, len = tail-i+1;
      if(tail-i+1 == len) ans++;
      int p = a.find(s[i]);
      if(p != -1) {
	idx[p]++;
	if(idx[p] >= pos[p].size()) break;
      }
    }

    string t = s.substr(head, len);
    cout << ans << endl;
    rep(i, t.size()) {
      if(i%72 == 0) cout << endl;
      cout << t[i];
    }
    cout << endl << endl;
    getline(cin, line);
  }

  return 0;
}

Measured memory_bytes: 3476
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n = int(input())
print(A[n-1])

Measured memory_bytes: 38256
use proconio::{input, marker::Usize1};

pub struct UnionFind {
    dim: usize,
    par: Vec<usize>,
}

impl UnionFind {
    pub fn new(d: usize) -> UnionFind {
        let mut list = vec![0; d];
        for i in 0..d {
            list[i] = i;
        }
        UnionFind { dim: d, par: list }
    }

    pub fn dim(self) -> usize {
        self.dim
    }

    pub fn union(&mut self, x: usize, y: usize) {
        let x_root = self.find(x);
        let y_root = self.find(y);
        if x_root > y_root {
            self.union(y, x);
        } else if x_root < y_root {
            self.par[y_root] = x_root;
        }
    }

    pub fn find(&mut self, x: usize) -> usize {
        if self.par[x] == x {
            return x;
        }
        self.par[x] = self.find(self.par[x]);
        self.par[x]
    }

    pub fn same(&mut self, x: usize, y: usize) -> bool {
        return self.find(x) == self.find(y);
    }
}

pub struct AdjList {
    dim: usize,
    list: Vec<Vec<usize>>,
}

impl AdjList {
    pub fn new(d: usize) -> AdjList {
        AdjList {
            dim: d,
            list: vec![vec![]],
        }
    }

    pub fn dim(&self) -> usize {
        self.dim
    }

    pub fn add_edge(&mut self, from: usize, to: usize) {
        self.list.get_mut(from).unwrap().push(to);
    }

    pub fn add_undirected_edge(&mut self, from: usize, to: usize) {
        self.list.get_mut(from).unwrap().push(to);
        self.list.get_mut(to).unwrap().push(from);
    }

    pub fn out_edges(&mut self, vertex: usize) -> Vec<usize> {
        self.list.get_mut(vertex).unwrap().to_vec()
    }

    pub fn in_edges(&mut self, v: usize) -> Vec<usize> {
        let mut res = vec![];
        for l in 0..self.dim() {
            if let Some(list) = self.list.get(l) {
                if list.contains(&v) {
                    res.push(l);
                }
            }
        }

        res
    }
}

fn main() {
    input! {
        n: usize,
        m: usize,
        edges: [(Usize1, Usize1); m]
    }

    let mut res = 0;
    for i in 0..m {
        // iは使わないもの
        let mut uf = UnionFind::new(n);
        for j in 0..m {
            if j != i {
                uf.union(edges[j].0, edges[j].1);
            }
        }

        // つなげたので連結性判定
        let mut f = true;
        for j in 0..n {
            f &= uf.find(j) == 0;
        }
        if !f {
            res += 1;
        }
    }
    println!("{}", res);
}


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

int main(int,char**) {
    ios_base::sync_with_stdio(0); cin.tie(NULL);
    int N;
    cin >> N;
    int cnt = 0;
    for (int i = 1; i <= N; ++i) {
        int x ;
        cin >> x;
        if (x != i)
            ++cnt;
    }
    
    if (cnt == 0 || cnt == 2) cout << "YES\n";
    else cout << "NO\n";
    
    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 A = sc.nextInt();
        int B = sc.nextInt();

        if (B % A == 0) {
            System.out.println(A + B);
        } else {
            System.out.println(B - A);
        }
    }
}


Measured memory_bytes: 21716
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int a;
	scanf("%d", &a);
		int b, c, d, e;
		b = a/1000;
		c = (a/100)%10;
		d = ((a/10)%100)%10;
		e = ((a%1000)%100)%10;
		while(1000 <= a <=9999){
			if(((b == c) && (c ==d)) || ((c == d) && (d == e))){
			printf("Yes\n");
	}
	else{
		printf("No\n");
		}
		break;
	}

}

Measured memory_bytes: 256
import math

N = int(input())

#f(n) を以下の 2 つの条件の両方を満たすような 3 つの整数の組 (x,y,z)の個数とします。
# 1≤x,y,z
# x**2 + y**2 + z**2 + xy + yz + zx = n

# x,y,zの最大値を考える。
# x**2 + 1**2 + 1**2 + x + 1 + x = n
# x**2 + 2x = n - 3
# x**2 + 2x -n + 3 = 0
# x = {-2 ± sqrt(2**2 - 4*1*(-n+3))}/2*1
# x = {-2 ± sqrt(4 + 4n -12)}/2
# 1 ≤ xより
# x = {-2 + sqrt(4n - 8)}/2 = {-2 + 2 * sqrt(n - 2)}/2 = -1 + sqrt(n - 2)
# ∴ 1 ≤ x ≤ math.floor(-1 + sqrt(n - 2))
# y,zも同様。
# N <= 10**4 より、x,y,xで全探索しても(10**2)**3 = 10**6 で間に合う

ans_dict = {i:set() for i in range(1,N+1)}

if N != 1:
    for i in range(1,1 + math.floor(-1 + math.sqrt(N - 2))):
        for j in range(1,1 + math.floor(-1 + math.sqrt(N - 2))):
            for k in range(1,1 + math.floor(-1 + math.sqrt(N - 2))):
                n = i**2 + j**2 + k**2 + i*j + j*k + k*i
                if 1 <= n <= N:
                    ans_dict[n].add((i,j,k))
                
    for i in range(1,N+1):
        print(len(ans_dict[i]))
else:
    print(0)

Measured memory_bytes: 43164
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

int main() {
  ll n;
  cin >> n;
  rep(i,5){
    ll N = pow(10,i*2);
    if(n==N){
      cout<<i+1<<endl;
      return 0;
    }
  }
  ll ans = 10;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ll A = i;
      ll B = n/i;
      string s = to_string(A);
      string t = to_string(B);
      ll S = s.size();
      ll T = t.size();
      ll M = max(S,T);
      ans = min(ans,M);
    }
  }
  cout << ans << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define Pr(a) (#a)<<"="<<(a)<<" "
#define pr1(a) cerr<<Pr(a)<<endl
#define pr2(a,b) cerr<<Pr(a)<<Pr(b)<<endl
#define pr3(a,b,c) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<endl
#define pr4(a,b,c,d) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<endl
#define pr5(a,b,c,d,e) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<endl
#define pr6(a,b,c,d,e,f) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<Pr(f)<<endl
#define int long long
#define double long double
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


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

  int n;
  cin>>n;
  vector<int> A(n);
  cin>>A;

  int q;
  cin>>q;
  while(q--){
    int k;
    cin>>k;
    cout<<count(A.begin(), A.end(), k)<<endl;
  }

  return 0;
}



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

int main( )
{
    char s[1005];
    int i, j, k, l = 0;
    string inp;
    cin >> inp;
    for (i = 0; i < (int) inp.size(); i++) {
        if (inp[i] == '0') {
            s[l++] = '0';
        }
        else if (inp[i] == '1') {
            s[l++] = '1';
        }
        else if (l > 0) {
            s[l--];
        }
    }
    s[l++] = '\0';
    cout << s << '\n';
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	int n;
	boolean[] color;
	int[][] map;
	int INF = 1 << 24;

	private void run() {
		Scanner scanner = new Scanner(System.in);
		n = scanner.nextInt();
		map = new int[n][n];
		for (int[] a : map)
			Arrays.fill(a, INF);
		for (int i = 0; i < n; i++) {
			int u = scanner.nextInt();
			int k = scanner.nextInt();
			for (int j = 0; j < k; j++) {
				int v = scanner.nextInt();
				int c = scanner.nextInt();
				map[u][v] = c;
			}

		}
		dijkstra();
	}

	private void dijkstra() {
		int minv;
		int[] d = new int[n];
		color = new boolean[n];
		Arrays.fill(d, INF);
		d[0] = 0;
		while (true) {
			minv = INF;
			int u = -1;
			for (int i = 0; i < n; i++) {
				if (minv > d[i] && !color[i]) {
					u = i;
					minv = d[i];
				}
			}
			if (u == -1)
				break;
			color[u] = true;
			for (int i = 0; i < n; i++) {
				if (!color[i] && d[i] > d[u] + map[u][i]) {
					d[i] = d[u] + map[u][i];
				}
			}
		}
		for (int i = 0; i < n; i++) {
			System.out.printf("%d %d\n", i, d[i] == INF ? -1 : d[i]);
		}

	}
}

Measured memory_bytes: 34724