akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////

int n,m;int t[110000], c[110000], d[110000];
signed main(){
  cin>>n>>m;
  rep(i,n){
    int x;cin>>x;
    c[x%m]++;
    t[x]++;
    if(t[x]%2 == 0)d[x%m]++;//同じ数の2枚組を数える
  }
  int ans = 0;
  rep(md,m){
    if(c[md] == -1)break;
    int op = (m-md)%m;
    if(md == op){
      ans += c[md]/2;
      c[md] = -1;
    }else{
      int dc = min(c[md], c[op]);
      ans += dc;
      c[md] -= dc;
      c[op] -= dc;
      ans += max(min(d[op], c[op]/2), min(d[md], c[md]/2));
      c[md] = c[op] = -1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
#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() { cerr << endl; }

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

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


int main() {
    long long n, m; cin >> n >> m;
    long long f = min(n, m/2);
    m -= f * 2;
    cout << f + (m / 4);
}


Measured memory_bytes: 3632
import java.util.Vector;

class Main{
	public static void main(String[] av){
		Vector<StringBuffer> vec = new Vector<StringBuffer>();
		java.util.Scanner sc = new java.util.Scanner(System.in);
		while( sc.hasNext() ){
			vec.add( new StringBuffer(sc.next()) );
		}
		for ( StringBuffer str : vec ){
			System.out.println( str.reverse() );
		}
	}
}

Measured memory_bytes: 17116
#include <iostream>
    #include <vector>
    #include <algorithm>
    #include <tuple>
    using namespace std;
     
    long long N, X[1009], Y[1009], H[1009]; vector<tuple<long long, long long, long long>>vec;
     
    int main() {
    	cin >> N; tuple<long long, long long, long long>G = make_tuple(-1, -1, -1);
    	for (int i = 1; i <= N; i++) {
    		cin >> X[i] >> Y[i] >> H[i];
    		if (H[i] >= 1) G = make_tuple(X[i], Y[i], H[i]);
    	}
    	for (int i = 0; i <= 100; i++) {
    		for (int j = 0; j <= 100; j++) {
    			long long V = get<2>(G) + abs(get<0>(G) - i) + abs(get<1>(G) - j); V = max(V, 0LL); bool flag = true;
    			for (int k = 1; k <= N; k++) {
    				long long VV = V - abs(X[k] - i) - abs(Y[k] - j); VV = max(VV, 0LL);
    				if (H[k] != VV) flag = false;
    			}
    			if (flag == true) vec.push_back(make_tuple(i, j, V));
    		}
    	}
    	if (vec.size() == 1) {
    		cout << get<0>(vec[0]) << " " << get<1>(vec[0]) << " " << get<2>(vec[0]) << endl;
    	}
    	return 0;
    }

Measured memory_bytes: 3696
import itertools
import sys

INF = 10 ** 9

def input(): return sys.stdin.readline().strip()
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N, M, R = ZZ()
    r = ZZ()
    d = [[INF] * (N) for _ in range(N)]
    for i in range(N): d[i][i] = 0
    for _ in range(M):
        a, b, c = ZZ()
        a -= 1
        b -= 1
        d[a][b] = c
        d[b][a] = c
    for k in range(N):
        for i in range(N):
            for j in range(N): d[i][j] = min(d[i][j], d[i][k]+d[k][j])
    ans = INF
    for v in itertools.permutations(r, R):
        cc = 0
        for i in range(R-1): cc += d[v[i]-1][v[i+1]-1]
        ans = min(ans, cc)
    print(ans)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 42844
#include <iostream>
using namespace std;
int MCD(int a,int b, int c)
{
	int mcd=1;
	for(int i=1;i<=a;i++)
	{
		if((b%i)==0 && (a%i)==0 && (c%i)==0)
		{
			mcd=i;
		}
	}
	return mcd;
}

int main(int argc, char** argv) {
	int tot=0,K=0,x;
	cin>>K;
	for(int n=1;n<=K;n++)
	{
		for(int m=1;m<=K;m++)
		{
			for(int l=1;l<=K;l++)
			{
				x=MCD(n,m,l);
				tot= tot + x;
			}
		}
	}
	cout<<tot;
	
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int N;
  cin >> N;
  vector<vi32> a(N, vi32(N));
  cin >> a;
  vi64 dp(bit32(N), -1e18);
  int c = 0;
  function<i64(int S)> rec = [&](int S) {
    if (dp[S] != -1e18) return dp[S];
    i64 ret = 0;
    rep(i, N) rep(j, i) {
      if ((S & bit32(i)) && (S & bit32(j))) ret += a[i][j];
    }
    for (int T = 1; T < S; T++) {
      if ((~S) & T) continue;
      amax(ret, rec(T) + rec(S ^ T));
    }
    // for (int T = (S - 1) & S; T > 0; T = (T - 1) & S) {
    //   c++;
    //   amax(ret, rec(T) + rec(S ^ T));
    // }
    return dp[S] = ret;
  };
  cout << rec(bit32(N) - 1) << endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>

using namespace std;

void factorize(long N, map<long, long> *m){
    long lim = sqrt(N);
    long div = 2;
    while(N != 1 && div <= lim){
        long cnt = 0;
        while(N % div == 0){
            cnt ++;
            N /= div;
        }
        if(cnt != 0) (*m).insert({div, cnt});
        div ++;
    }
    if(N != 1) (*m).insert({N, 1});
}

int main(){

    int N;
    cin >> N;

    long cnt[N + 1]; fill(cnt, cnt + N + 1, 0);
    for(int i=1; i<=N; i++){
        map<long, long> m;
        factorize(i, &m);
        for(auto itr = m.begin(); itr != m.end(); ++itr){
            cnt[itr->first] += itr->second;
        }    
    }
    long n74, n24, n14, n4, n2; 
    n74 = n24 = n14 = n4 = n2 = 0;
    for(int i=2; i<=N; i++){
        if(cnt[i] >= 74) n74++;
        if(cnt[i] >= 24) n24++;
        if(cnt[i] >= 14) n14++;
        if(cnt[i] >= 4) n4++;
        if(cnt[i] >= 2) n2++;
    }
    cout << n74 + n24 * (n2 - 1) + n14 * (n4 - 1) + n4 * (n4-1) / 2 * (n2 - 2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const int MOD = 1e9 + 7;



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

	vector<ll> v(n);

	rep(i, 0, n) {
		ll x;
		cin >> x;
		v[i] = x - (i + 1);
	}
	sort(v.begin(), v.end());



	ll median;
	ll sum=0;
	median = v[n / 2];
	rep(i, 0, n) {
		sum += abs(v[i] - median);
	}

	cout << sum << endl;

	return 0;

}


Measured memory_bytes: 1792
import java.util.ArrayDeque;

public class Main {
	private static int h, w, n;
	private static boolean[] wall;
	private static int[] sx, sy;

	private static int[] dx = { 0, 1,  0, -1 };
	private static int[] dy = { 1, 0, -1,  0 };
	
	private static int getInt() throws Exception {
		int i = 0;
		while(true){
			int buf = System.in.read();
			if('0' > buf || buf > '9'){
				break;
			}
			i = i * 10 + buf - '0';
		}
		return i;
	}
	private static int search(int sx, int sy, int ex, int ey) {
		int sc = 0;
		boolean[] visited = new boolean[h*w];
		ArrayDeque<Integer> qx = new ArrayDeque<>();
		ArrayDeque<Integer> qy = new ArrayDeque<>();
		ArrayDeque<Integer> qc = new ArrayDeque<>();
		qx.offer(sx);
		qy.offer(sy);
		qc.offer(sc);
		while(true){
			sx = qx.pop();
			sy = qy.pop();
			sc = qc.pop() + 1;
			for(int i = 0; i < 4; i++){
				int nx = sx + dx[i];
				int ny = sy + dy[i];
				int p = nx + ny*w;
				if(0 <= nx && nx < w && 0 <= ny && ny < h && !wall[p] && !visited[p]){
					if(nx == ex && ey == ny) return sc;
					visited[p] = true;
					qx.offer(nx);
					qy.offer(ny);
					qc.offer(sc);
				}
			}
		}
		
	}
	public static void main(String[] args) throws Exception {
		h = getInt();
		w = getInt();
		n = getInt();
		wall = new boolean[h*w];
		sx = new int[10];
		sy = new int[10];
		for(int y = 0; y < h; y++){
			for(int x = 0; x < w; x++) {
				int buf = System.in.read();
				if(buf =='\n' || buf == '\r'){
					x--;
					continue;
				}
				wall[x + y*w] = buf == 'X';
				if(buf == 'S'){
					sx[0] = x;
					sy[0] = y;
				}
				if('1' <= buf && buf <= '9'){
					buf -= '0';
					sx[buf] = x;
					sy[buf] = y;
				}
			}
		}
		int a = 0;
		for(int i = 1; i <= n; i++) a += search(sx[i-1], sy[i-1], sx[i], sy[i]);
		System.out.println(a);
	}

}

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

#define ll long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ld long double

#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)
#define Fit(i,v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++i)
#define Fitd(i,v) for(__typeof((v).rbegin()) i = (v).rbegin(); i != (v).rend(); ++i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))

using namespace std;

const int nm = 200010;
const ll mod = 998244353;

int n;
string x;
int cnt[nm];
vector<int> y;

// check if we use first k characters, would we get something <= x
bool ok(int k) {
	for (int i = k; i < n; ++i) {
		int tmp = i % (2*k);
		int xi = (tmp < k ? x[tmp] - '0' : 1 - (x[tmp - k] - '0'));
		if (xi < x[i] - '0')
			return 1;
		if (xi > x[i] - '0')
			return 0;
	}
	return 1;
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    cin >> n >> x;
    int cur = 0;
    ll res = 0;
    for (int i = 1; i <= n; ++i) {
    	cur = (cur * 2 + (x[i - 1] - '0')) % mod;
    	if ((2*n) % (2*i) == 0 && n % (2*i) != 0) {
    		cnt[i] = (cur + ok(i)) % mod;
    		for (int j: y) {
    			if (i % j == 0) {
    				cnt[i] = (cnt[i] - cnt[j] + mod) % mod;
    			}
    		}
    		y.pb(i);
    		res = (res + (2ll * i) * cnt[i]) % mod;
//    		cout << i << " " << cnt[i] << "\n";
    	}
    }
    cout << res << "\n";
#ifdef LOCAL
    cout << (double) clock() / CLOCKS_PER_SEC << "\n";
#endif
}


Measured memory_bytes: 644
#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 n,a;
  cin>>n>>a;
  cout<<n*n-a<<endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
using namespace std;
////////////// Prewritten code follows. Look down for solution. ////////////////
#define x first
#define y second
#define LEN(x) ((int)(x).size())
#define ALL(x) x.begin(), x.end()
using ll = long long;
using llu = long long unsigned;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vpii = vector<pii>;

const ld EPS = 1e-9;
inline int cmp(ld x, ld y = 0, ld tol = EPS) {
	return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

const int MOD = 1;
inline int mod(ll x, int m = MOD) {
	return (int)(((x%m) + m)%m);
}

template<typename T, typename M = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, M, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

////////////////////////// Solution starts below. //////////////////////////////

const int N = 5e5 + 10;

int n, q;
map<int, int> mp;
int bit[N], c[N];

void add(int p, int v) {
	for(int i = p; i < N; i +=i&-i)
		bit[i] += v;
}

int sum(int p) {
	int ret = 0;
	for(int i = p; i; i-=i&-i)
		ret += bit[i];
	return ret;
}

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

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

	vector<pair<pii, int>> queries;
	for(int i = 1; i <= q; i++) {
		int l, r;
		cin >> l >> r;
		queries.push_back({{r, l}, i});
	}
	sort(ALL(queries));
	int lst = 1;
	mp[c[1]] = 1;
	add(1, 1);
	vector<pii> ans;
	for(auto p : queries) {
		int r = p.x.x, l = p.x.y;
		while(lst < r) {
			lst++;
			int val = c[lst];
			if(mp.count(val))
				add(mp[val], -1);
			add(lst, 1);
			mp[val] = lst;
		}
		ans.push_back({p.y, sum(r) - sum(l-1)});
	}
	sort(ALL(ans));
	for(auto p : ans)
		cout << p.y << '\n';

	return 0;
}


Measured memory_bytes: 40908
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
int main(void){

  int n;
  cin>>n;

  vector<int> w(n);
  int sum=0,sum1=0,sum2=0;
  r(i,n){cin>>w.at(i);sum+=w.at(i);}
  int dis,mini=10000000000;

  for(int i=1;i<n;i++){
    r(j,i){
      sum1+=w.at(j);
    }
    sum2=sum-sum1;
    //cout<<sum2<<" "<<sum<<endl;
    dis=abs(sum2-sum1);
    mini =min(mini,dis);
    sum2=0;sum1=0;
  }
  cout<<mini<<endl;





  return 0;
}


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

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int a, b; cin >> a >> b;
  cout << a*b << endl;

  
  return 0;
}




Measured memory_bytes: 3652
n = gets.to_i
h = gets.split.map(&:to_i)
max = 0
cnt = 0
for i in 0..(n-2)
  if h[i] >= h[i+1]
    cnt += 1
  else
    max = cnt if max < cnt
    cnt = 0
  end
end
max = cnt if max < cnt
puts max

Measured memory_bytes: 8580
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** Problem0568 : Pasta **/
int N, K;
vector<int> A;
const int MOD = 10000;
int dp[101][3][3];

int solve(int n, int old1, int old2)
{
	if (n >= N)
		return 1;
	
	if (dp[n][old1][old2]!=-1)
		return dp[n][old1][old2];
	
	int res=0;
	if  (A[n] != 0) {
		if (old1 != old2 || old2 != A[n])
			res += solve(n+1, old2, A[n]);
		res %= MOD;
	} else {
		rep(i, 3) {
			if (old1 != old2 || old2 != i+1)
				res += solve(n+1, old2, i+1);
			res %= MOD;
		}
	}
	return dp[n][old1][old2] = res;
}

int main()
{
	cin>>N>>K;
	A.resize(N);
	fill(A.begin(), A.end(), 0);
	memset(dp, -1, sizeof(dp));
	
	rep(i, K) {
		int a, b;
		cin>>a>>b;
		A[a-1] = b;
	}
	cout << solve(0, 0, 0) << endl;
}

Measured memory_bytes: 1208
#include <iostream>
#include <vector>
#include <tuple>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <functional>
#define REP(i, n) for(int i = 0; i < n; i++)
//using ll = long long;
using namespace std;
const int mod = 1000000007;

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

  int n, ans=0;
  cin >> n;
  string s[n];

  REP(i,n){
    cin >> s[i];
  }

  sort(s, s+n);

  REP(i,n-1){
    if(s[i] != s[i+1]){
      ans += 1;
    }
  }



  
 cout << ans+1 << endl;
  
  
      
}


Measured memory_bytes: 9868
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>	
#include <cmath>
#include <string>
#include<math.h>
#include<sstream>//���炵���̂Œ���
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;
int mod = 1000000007;

int main()
{
	cin >> s >> t;
	if (s == t.substr(0, sz(s)))cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>	
#define ll long long 
#define pb push_back
#define N 100005
using namespace std;

//ll A[N],ans;
ll n,k,a,b,c,d;
 
#pragma region
void ingresoInt(int A[]){
	for (int i = 0; i < n; ++i)scanf("%d",&A[i]);
}
void ingresoLL(ll A[]){
	for (int i = 0; i < n; ++i)scanf("%lld",&A[i]);
}
void mostrarInt(int A[]){
	for (int i = 0; i < n; ++i)printf("%d ",A[i]);printf("\n");
}
void mostrarLL(ll A[]){
	for (int i = 0; i < n; ++i)printf("%lld ",A[i]);printf("\n");
}
#pragma endregion




bool esIso(vector<int> a[],vector<int> b[],int u, int v){
	
	if(a[u].size()==0 && b[v].size()==0) return true;
	
	if(a[u].size() != b[v].size())return false;

	if(a[u].size()==1)
		return esIso(a,b,a[u][0],b[v][0]);

	return esIso(a,b,a[u][1],b[v][1])&&esIso(a,b,a[u][0],b[v][0]) || esIso(a,b,a[u][0],b[v][1])&&esIso(a,b,a[u][1],b[v][0]);

}


int main(){
	/*
	char P[100500];
	int j=0;
	scanf("%[^'\n']s",P);
	for (int i = 0; i < strlen(P); ++i)
	{	
		if(P[i]==' '){printf("%c.",P[j]);j=i+1;}
	}
	for (int i = j; i < strlen(P); ++i)
	{
		printf("%c",P[i]);
	}*/
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(c<=a+b) printf("Yes");
	else printf("No");
	return 0; 

}

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

int main() {
  int s;
  cin >> s;
  vector<int> a(1000010);
  a.at(0) = s;
  bool finished = false;
  for (int i=1; i<1000010; i++){
    if (a.at(i-1)%2 == 0){
      a.at(i) = a.at(i-1)/2;
    }
    else {
      a.at(i) = a.at(i-1)*3 + 1;
    }
    for (int j=0; j<i; j++){
      if(a.at(i) == a.at(j)){
        cout << i+1 << endl;
        finished = true;
        break;
      }
    }
    if(finished){
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 4096
import numpy as np

def main():
	b=input()
	result=''
	if(b=='A'):
		result='T'
	elif(b=='T'):
		result='A'
	elif(b=='G'):
		result='C'
	elif(b=='C'):
		result='G'
	
	print(result)

def inputList():
	a=list(map(int,input().split()))
	return a

def multisort(li,index):
	return sorted(li,key=lambda x: x[index])

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


Measured memory_bytes: 21892
fun main(args: Array<String>) {
  val (w, h, x, y) = listOfLong()
  println("${w*h/2.0} ${if (x * 2 == w && y * 2 == h) 1 else 0}")
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }
fun listOfLong() = listOfString().map { it.toLong() }

Measured memory_bytes: 36160
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}

int h,w,sh,sw;bool a[1100][1100];

signed main(){
cin>>h>>w;queue<pair<int,int>> q;int ans = 0, rest = 0;
rep(i,h)rep(j,w){
  char ab;cin>>ab;a[i][j] = ab == '#';
  if(a[i][j])q.push(pair<int,int>(i,j));
  else rest++;
}
while(rest){
  ans++;
  int s = q.size();
  rep(i,s){
    pair<int,int> p = q.front();q.pop();
    rep(j,4){
      int nh = p.first + fd[j].first, nw = p.second + fd[j].second;
      if(nh >= 0 && nh < h && nw >= 0 && nw < w && !a[nh][nw]){
        a[nh][nw] = true;rest--;q.push(pair<int,int>(nh, nw));
      }
    }
  }
}
cout << ans << endl;
}


Measured memory_bytes: 17716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9+7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
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; }
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,1,-1};

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

ll c[51],s[51];

ll f(ll n,ll x){
    if(n == 0)return (x <= 0? 0:1);
    else if(x <= 1 + s[n - 1])return f(n - 1,x - 1);
    else return c[n - 1] + 1 + f(n - 1,x - s[n - 1] - 2);
}

//modの値の確認をすること
int main(){
    c[0] = 1;
    s[0] = 1;
    rep1(i, 50){
        c[i] = c[i - 1] * 2 + 1;
        s[i]  = s[i - 1] * 2 + 3;
    }
    
    ll n,x;
    cin >> n >> x;
    pf(f(n,x));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);
#define ll long long int
#define pii pair <ll , ll >
#define pb push_back
ll x8[] = {1, 1, 1, 0, 0, -1, -1, -1};
ll y8[] = {1, 0, -1, 1, -1, -1, 0, -1};
ll x4[] = {1, -1, 0, 0};
ll y4[] = {0, 0, 1, -1};
ll mod = 1e9 + 7;
ll inf = 1e18;


void getac()
{
    int m;
    cin>>m;
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++){
        char p=(s[i]-'A'+m)%26+'A';
        cout<<p;
    }
}
int  main()
{
    fastio;
    ll t;


    t = 1;

    
    while(t--)
    {
        getac();
    }

    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}

Measured memory_bytes: 256
h, n = map(int, input().split())
magic = [tuple(map(int, input().split())) for _ in range(n)]

INF = 10**10
dp = [INF] * (h + 1)
dp[h] = 0
for i in reversed(range(h + 1)):
    for aj, bj in magic:
        dp[max(0, i - aj)] = min(dp[max(0, i - aj)], dp[i] + bj)

print(dp[0])


Measured memory_bytes: 41072
n=int(input())
l=list(map(int,input().split()))
ans=0
for i in range(n):
    for j in range(n):
        for k in range(n):
            if i<j and j<k:
                le=[l[i],l[j],l[k]]
                le.sort()
                if le[0]+le[1]>le[2] and le[0]!=le[1] and le[1]!=le[2] and le[2]!=le[0]:
#                    print(i+1,j+1,k+1)
                    ans+=1
print(ans)


Measured memory_bytes: 9220
def main():
    n, a, b = list(map(int, input().split()))
    X = list(map(int, input().split()))
    INF = float('inf')
    dp = [0] * n
    for i in range(1, n):
        dp[i] = dp[i - 1] + min(a * (X[i] - X[i - 1]), b)
    print(dp[n - 1])

if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
	int w, a, b;
	scanf("%d %d %d", &w, &a, &b);
	int xa1 = a;
	int xa2 = a + w;
	int xb1 = b;
	int xb2 = b + w;
	int ans = 1e9;
	if (b > a + w) {
		ans = min(ans, b - (a + w));
	}
	if (b + w < a) {
		ans = min(ans, a - (b + w));
	}
	if (a <= b && b <= a + w) {
		ans = 0;
	}
	if (a <= b + w && b + w <= a + w) {
		ans = 0;	
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
N,H=map(int,input().split())
ab=[]
a=[]
b=[]

for i in range(N):
    ab.append(list(map(int,input().split())))
    a.append(ab[i][0])
    b.append(ab[i][1])

a.sort(reverse=True)
b.sort(reverse=True)
k=0
cnt=0

while a[0]<b[k]:
    H-=b[k]
    cnt+=1
    if H<=0:
        break
    k+=1
    if k==len(b):
        break

#print(cnt,H)
H=max(H,0)

if H%a[0]==0:
    cnt+=H//a[0]
else:
    cnt+=H//a[0]+1

print(cnt)

Measured memory_bytes: 29296
#include<cstdio>
#include<cstring>

char s[111];

int main() {
	scanf("%s", s);
	int win=0;
	int len = strlen(s);
	for(int i=0;i<len;i++)
		if(s[i]=='o') win++;
	puts(win+(15-len)>=8 ? "YES" : "NO");
	
	return 0;
}

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

int p[100005];

vector<int> neighbors[100005];
bool visited[100005];
set<int> nodes;

void visit(int i) {
  if (visited[i]) return;
  visited[i] = true;
  nodes.insert(i);
  for (auto neighbor : neighbors[i]) {
    if (!visited[neighbor]) visit(neighbor);
  }
}

int main() {
  int n, m;
  cin >> n >> m;
  for (int ni = 1; ni <= n; ni++) {
    cin >> p[ni];
  }
  for (int mi = 0; mi < m; mi++) {
    int x, y;
    cin >> x >> y;
    neighbors[x].push_back(y);
    neighbors[y].push_back(x);
  }
  int answer = 0;
  for (int ni = 1; ni <= n; ni++) {
    if (!visited[ni]) {
      nodes.clear();
      visit(ni);
      for (auto node : nodes) {
        if (nodes.find(p[node]) != nodes.end()) {
          answer++;
        }
      }
    }
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 13952
from collections import deque
n=int(input())
g=[[] for i in range(n)]
for i in range(n):
    p=list(str(input()))
    for j in range(n):
        if p[j]=='1':
            g[i].append(j)
q=deque([0])
v=[-1]*n
v[0]=0
while q:
    p=q.popleft()
    for i in g[p]:
        if v[i]==-1:
            v[i]=1-v[p]
            q.append(i)
        else:
            if v[i]!=1-v[p]:
                print(-1)
                exit()
ans=0
for s in range(n):
    q=deque([s])
    v=[0]*n
    v[s]=1
    while q:
        p=q.popleft()
        for i in g[p]:
            if v[i]==0:
                v[i]=1+v[p]
                q.append(i)
    ans=max(ans,max(v))
print(ans)


Measured memory_bytes: 42220
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;
ll MOD = 1000000007;

int main()
{
    ll N, T;
    cin >> N >> T;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    ll _min = A[0];
    ll _max = 0;
    ll count = 0;
    for(ll i = 1; i < N; ++i) {
        ll B = A[i] - _min;
        if (_max < B) {
            count = 1;
            _max = B;
        } else if (_max == B){
            count++;
        }
        _min = min(A[i], _min);
    }
    cout << count << endl;
    return 0;
}


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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    string a, b, c;
    cin >> a >> b >> c;

    outYES(a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]);
}

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

bool isPrime(int x);

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

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

	int count = 0;

	for (int i = 0; i < n; i++) {
		if (isPrime(A[i]))
			count++;
	}

	cout << count << '\n';

	return 0;
}

bool isPrime(int x)
{
	if (x == 2)
		return true;

	if (x < 2 || x % 2 == 0)
		return false;

	int i = 3;

	while (i <= sqrt(x)) {
		if (x % i == 0)
			return false;
		else
			i = i+2;

	}

	return true;
}


Measured memory_bytes: 3136
#include <stdio.h>

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

  while (N) {
    if (N % 10 == 2) {
      ans++;
    }
    N /= 10;
  }

  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
	int k, t, max = 0, count = 0;
	cin >> k >> t;
	vector<int> a(t);
	for(int i = 0; i < t; i++) {
		cin >> a[i];
		count += a[i];
		if(max < a[i]) max = a[i];
	}
	count -= max;
	max -= count;
	if(2 <= max) {
		cout << max - 1 << endl;
	} else {
		cout << "0" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a[5], sum = 0, min = 10;
    for (int i = 0; i < 5; i++) {
        cin >> a[i];
        if (a[i] % 10 == 0) {
            sum += a[i];
            continue;
        } else if (a[i] % 10 < min){
            min = a[i] % 10;
        }
        sum += a[i] + 10 - (a[i] % 10);
        
    }
    cout << sum - 10 + min << endl;
}

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

const int MAX = 3e5 + 5;
int n, m, mk[MAX];
pair <int, int> a[MAX];
vector <int> ans;
vector <pair <int, int> > g[MAX];

int dfs(int u, int edge_parent = -1) {
	mk[u] = 1;

	int ret = a[u].second;

	for(auto o : g[u])
		if(!mk[o.first])
			ret ^= dfs(o.first, o.second);

	if(ret) {
		if(edge_parent == -1) {
			printf("-1\n");
			exit(0);
		}

		ans.push_back(edge_parent);
	}

	return ret;
}

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

	for(int i = 1; i <= n; i++)
		scanf("%d%d", &a[i].first, &a[i].second);

	sort(a + 1, a + n + 1);

	for(int i = n + 1; i > 0; i--)
		a[i].second ^= a[i - 1].second;

	for(int i = 1; i <= m; i++) {
		int l, r; scanf("%d%d", &l, &r);
		l = lower_bound(a + 1, a + n + 1, make_pair(l, -1)) - a;
		r = upper_bound(a + 1, a + n + 1, make_pair(r, +2)) - a;

		if(l == r)
			continue;

		g[l].push_back({r, i});
		g[r].push_back({l, i});
	}

	for(int i = 1; i <= n; i++) {
		if(!mk[i])
			dfs(i);
	}

	sort(ans.begin(), ans.end());

	printf("%d\n", (int) ans.size());

	for(int i = 0; i < (int) ans.size(); i++) {
		printf("%d", ans[i]);
		printf(i == (int) ans.size() - 1 ? "\n" : " ");
	}

	return 0;
}

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

int main() {
    string s;
    cin >> s;
    if(s == "SUN") cout << 7 << endl;
    if(s == "MON") cout << 6 << endl;
    if(s == "TUE") cout << 5 << endl;
    if(s == "WED") cout << 4 << endl;
    if(s == "THU") cout << 3 << endl;
    if(s == "FRI") cout << 2 << endl;
    if(s == "SAT") cout << 1 << endl;
}


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

public class Main {

	static Scanner scanner;

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

        int N=gi();
        int T=gi();
        
        int min=Integer.MAX_VALUE;
        for(int i=0; i<N;i++) {
        	int c=gi();
        	int t=gi();
        	if (t<=T && min>c) {
        		min = c;
        	}
        }
	    //System.out.println(min);
	    
        if (min==Integer.MAX_VALUE) {
        	System.out.println("TLE");
        }else {
        	System.out.println(min);
        }
	}


	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35676
#include <stdio.h>

int main(){
	double x1, y1, x2, y2, x3, y3, x4, y4;
	double ab, cd;
	int n, i;

	scanf("%d", &n);
	for( i=0; i<n; i++ ){
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf",
				&x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
		ab = (y2-y1)/(x2-x1);
		cd = (y4-y3)/(x4-x3);
		( ab==cd )? puts("YES"):puts("NO");
	}

	return 0;
}
	

Measured memory_bytes: 620
int main(void){
  
    long long int input;
    int cnt, name[100] = {0};
    int memo;
  
    scanf("%lld", &input);
    //memo = input;
  
    //--;
    /*for(int j = 1; j <= memo; j++){  
        input = j;
        cnt = 0;*/
        
    for(int i = 0; ; i++){
        if(input == 0){
            break;
        } else {
	        name[i] = input % 26;
	        input = input / 26;
	        //printf("%d %lld\n", name[i], input);
	        cnt++;
        }
    }
    
    for(int i = 0; i < cnt; i++){
        if(name[i] < 1){
            name[i] += 26;
            name[i + 1]--;
            if(name[cnt - 1] == 0){
                cnt--;
            }
        }
    }
    
    //name[0];
    cnt--;
    
    //printf("%d: ", j);                                 
    for(int i = 0; i <= cnt; i++){
        //printf("%lld", name[cnt - i]);
        printf("%c", name[cnt - i] + 'a' - 1);
    }
    printf("\n");
    
    //}
  
    return 0;
}

Measured memory_bytes: 1664
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(s);
  n = stoll(s);
  REP(i,s.size()){
    x += stoll(gCh(s,i));
  }
  Yes(n%x==0);
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
#define MOD_BIG2 998244353
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using std::vector;

#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

//////////////////////////////////////



//////////////////////////////////////

int main() {
    
    int N, A, B, C, D;
    string S;
    cin >> N >> A >> B >> C >> D;
    cin >> S;

    bool ans = true;
    char b = '.';
    FOR(i, B, D) {
        if (b == '#' && S[i-1] == '#') {
            ans = false;
            break;
        }
        b = S[i-1];
    }
    b = '.';
    FOR(i, A, C) {
        if (b == '#' && S[i-1] == '#') {
            ans = false;
            break;
        }
        b = S[i-1];
    }
    if (C > D && ans) {
        int cnt = 0;
        ans = false;
        if (S[B] == '.' && S[B-2] == '.') {
            ans = true;
        }
        FOR(i, B, D+3) {
            if (S[i-1] == '#') {
                if (cnt >= 3) {
                    ans = true;
                }
                cnt = 0;
            } else {
                cnt++;
            }
        }
    }
    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n; ll k; cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }

    vector<int> v;
    set<int> st;
    v.emplace_back(0);
    st.insert(0);
    int loop = 0;
    while (true) {
        int e = a[v.back()];
        if (st.count(e)) {
            loop = find(v.begin(), v.end(), e) - v.begin();
            break;
        }
        v.emplace_back(e);
        st.insert(e);
    }
    int loopend = v.size();

    if (k >= loop) {
        k = loop + (k - loop) % (loopend - loop);
    }
    cout << v[k] + 1 << endl;
    return 0;
}


Measured memory_bytes: 13980
import Control.Arrow
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = breads >>= print . solve 

solve :: [Int] -> Int
solve [n, m] = prodOnVal . map mf . group $ sort es
    where
        mf x = fact (calcH $ head x) (length x)
        prodOnVal = foldl' (\l r -> val $ l * r) 1

        calcH v = val $ x * y
            where
                x = prodOnVal [n..(n + v - 1)]
                y = prodOnVal $ map inv [2..v]

        es = dcmp m [2..hm]
        hm = truncate . sqrt $ fromIntegral m

        dcmp v (x : xs)
            | x > v && v > 1 = [1]
            | x > v = []
            | v `mod` x /= 0 = dcmp v xs
            | otherwise = c : dcmp w xs
            where
                (c, w) = count x v
        dcmp v _ 
            | v > 1 = [1]
            | otherwise = []

        
        count = loop 0
            where
                loop acc x v
                    | b == 0 = loop (acc + 1) x a
                    | otherwise = (acc, v)
                    where
                        (a, b) = v `divMod` x

inv :: Int -> Int 
inv = (`fact` m)
    where
        m = 10 ^ 9 + 5

fact :: Int -> Int -> Int
fact b e
    | e == 0 = 1
    | odd e = val $ b * fact b (e - 1)
    | otherwise = val $ v * v
    where
        v = fact b $ e `div` 2

val :: Int -> Int 
val = (`mod` m)
    where
        m = 10 ^ 9 + 7

breads :: IO [Int]
breads = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

Measured memory_bytes: 892
#include <iostream>
#include<algorithm>
#include<stack>
#include<vector>
#include<map>
#include<cmath>
#include<set>
#define N 1000000007
using namespace std;
using ll = long long;

#define FastIO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);





void solve() {
    int x;
    cin>>x;
    x = (x==1)?0:1;
    cout<<x;
}

//Driver code
int main() {
    FastIO;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //freopen("error", "w", stderr);
    // int t;
    // cin>>t;
    // while(t--) {
        solve();
    // }

}

Measured memory_bytes: 3688
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#include <sstream>
#include <iterator>
#include <sstream>
#include <iomanip>
#include <istream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

void solve(int num, int time) {
    vector<int> range;
    for(int i = 0; i < num; i++) {
        int x;
        cin >> x;
        range.push_back(x);
    }

    int ans = 0;

    for(int i = 0; i < num-1; i++) {
        if(range[i+1] - range[i] > time) ans += time;
        else    ans += range[i+1] - range[i];
    }
    //last man
    ans += time;

    cout << ans << endl;
}

int main()
{
    int n , t;
    cin >> n >> t;
    solve(n, t);
}


Measured memory_bytes: 1400
N=int(input())
a=list(map(int,input().split()))

ans=0
cnt=0
B=[0 for i in range(N)]
for x in range(10**6):
    for i in range(N):
        if a[i]>=N:
            cnt+=a[i]//N
            B[i]+=a[i]//N
            a[i]%=N
    if cnt==0:
        print(ans)
        exit()
    else:
        ans+=cnt
        for j in range(N):
            a[j]+=(cnt-B[j])
        cnt=0
        B=[0 for k in range(N)]
print(ans)
    

Measured memory_bytes: 3064
import sys
N = int(input())
A = list(map(int, input().split()))

if N == 1:
    print(1)
    sys.exit(0)
    
cnt = [0 for _ in range(10**5+1)]
for a in A:
    if a == 0:
        cnt[a] += 1
        cnt[a+1] += 1
    else:
        cnt[a-1] += 1
        cnt[a] += 1
        cnt[a+1] += 1
    
print(max(cnt))

Measured memory_bytes: 20864
#include <stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    int a[n],b[n],c[n-1];
    for(int d=0;d<n;d++){scanf("%d",&a[d]);}
    for(int e=0;e<n;e++){scanf("%d",&b[e]);}
    for(int f=0;f<n-1;f++){scanf("%d",&c[f]);}
    int ans;
    ans=0;
    for(int i=0;i<n;i++){
        ans+=b[a[i]-1];
        if(a[i]+1==a[i+1]){ans+=c[a[i]-1];}
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<iomanip>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const ll mod = 1e9+7;
const ll INF = ll(1e18)+1;
const ll MAXN = 1e6;

int main()
{
    int r,d,x;
    cin>>r>>d>>x;
    rep(i,10)
    {
        x=r*x-d;
        cout<<x<<endl;
    }
    
}

Measured memory_bytes: 256
INF = 10 ** 20
 
N = int(input())
coin_list = [1] + [6**i for i in range(1, 7)] + [9**i for i in range(1, 6)]
dp = [INF]*(N+1)
dp[0] = 0
 
for coin in coin_list:
    for i in range(coin,N+1):
        dp[i] = min(dp[i], dp[i-coin]+1)
 
print(dp[N])

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

int main(){
	int s,h,m,a;
    cin>>s;
    h=(s-s%3600)/3600;
    a=s%3600;
    m=(a-a%60)/60;
	s=a%60;
	cout<<h<<":"<<m<<":"<<s<<endl;
}


Measured memory_bytes: 3088
N = int(input())
for h in range(3501):
    for w in range(3501):
        if 4*h*w-N*h-N*w <= 0:
            continue
        n = N*h*w/(4*h*w-N*h-N*w)
        if int(n) == n:
            print(h,int(n),w)
            exit()


Measured memory_bytes: 3188