akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

vector<vector<int> > d;
vector<int> g0(31,0),g1(31,0),g2(31,0);

int solver(int a,int b,int c,int C){
    int tmp=0;
    for(int i=1;i<C+1;i++) tmp+=d[i-1][a-1]*g0[i];
    for(int i=1;i<C+1;i++) tmp+=d[i-1][b-1]*g1[i];
    for(int i=1;i<C+1;i++) tmp+=d[i-1][c-1]*g2[i];
    return tmp;
}

int main(){
    int N,C,in,ans;
    cin >> N >> C;
    for(int i=0;i<C;i++){
        vector<int> tmp;
        for(int j=0;j<C;j++) cin >> in,tmp.push_back(in);
        d.push_back(tmp);
    }
    for(int i=1;i<N+1;i++){
        for(int j=1;j<N+1;j++){
            cin >> in;
            if((i+j)%3==0) g0[in]++;
            if((i+j)%3==1) g1[in]++;
            if((i+j)%3==2) g2[in]++;
        }
    }
    ans=numeric_limits<int>::max();
    for(int i=1;i<C+1;i++){
        for(int j=1;j<C+1;j++){
            for(int k=1;k<C+1;k++){
                if(i!=j&&j!=k&&k!=i){
                    int tmp=solver(i,j,k,C);
                    if(ans>tmp) ans=tmp;
                }
            }
        }
    }
    cout << ans << endl;
    
    return 0;
}


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

# シミュレーションで解く場合：
# 電源タップの個数をa, 差込口の個数をnumとおく 
a = 0
num = 1
while num < B:
  num -= 1
  num += A
  a += 1

print(a)

Measured memory_bytes: 9080
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		String A[] = new String[N];
		String B[] = new String[M];

		for (int i = 0; i < N; i++) {
				A[i]= sc.next();
			}
		for (int i = 0; i < M; i++) {
				B[i]= sc.next();
		}

		int temp = 0;
		for (int i = 0; i < A.length - B.length; i++) {
			String a = A[i];
			String b = B[i];
			int point = a.indexOf(b);
			if(point == -1){
				temp = point;
				break;
			}else if(i == 0){
				temp = point;
			}else{
				if(temp == point){
					continue;
				}else{
					break;
				}
			}
		}
		if(temp == -1){
			System.out.println("No");
		}else{
			System.out.println("Yes");
		}
		sc.close();
	}
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
ll mod=1e9+7;
ll fac(ll n){
	ll i=1;
	ll ans=1;
	while(i <= n){
		ans*=i;
		ans%=mod;
		i++;
	}
	return ans;
}


int main(){
	ll d,m;
	cin >> d >> m;
	//cout << fac(100000)<<"\n";
	if(m==d+1) cout << ((fac(m))*(fac(d)))%mod;
	else if(d==m+1) cout << ((fac(m))*(fac(d)))%mod;
	else if (d==m) cout << (2*((fac(m))*(fac(d))%mod))%mod;
	else cout << 0;
	return 0;
}

Measured memory_bytes: 256
def test_case():
    a, b = map(int, input().split())
    d = int(a / b)
    r = int(a % b)
    f = float(a) / float(b)
    print("{0} {1} {2:.8f}".format(d, r, f))


if __name__ == "__main__":
    test_case()



Measured memory_bytes: 5620
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;


int main(){
  int k, x;
  cin >> k >> x;
  for(int i = max(-1000000, x - k + 1); i <= min(1000000, x + k - 1); ++i){
    cout << i << " ";
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repi(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)
#define rep(i, n) repi(i, 0, n)
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
// using P = pair<int, int>;
struct Vec{
    double x, y;
};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
     return false;
}
using namespace std;
int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    string S;
    int cnt = 0, temp = 0;
    cin >> S;
    rep(i, 3){
        if (S[i] == 'R') cnt ++;
    }
    if (cnt != 2) cout << cnt << endl;
    else{
        if (S[0] == S[2]) cout << 1 << endl;
        else cout << cnt << endl;
    }
}

Measured memory_bytes: 3632
#include <stdio.h>

typedef struct List {
	struct List *next;
	int v;
} list;

int main()
{
	int i, u, w, N;
	scanf("%d", &N);
	list *adj[101], d[200];
	for (i = 1; i <= N; i++) adj[i] = NULL;
	for (i = 0; i < N; i++) {
		scanf("%d %d", &u, &w);
		d[i*2].v = w;
		d[i*2+1].v = u;
		d[i*2].next = adj[u];
		d[i*2+1].next = adj[w];
		adj[u] = &(d[i*2]);
		adj[w] = &(d[i*2+1]);
	}
	
	list *p;
	int dist[101] = {0, -1}, par[101] = {}, q[101] = {1}, head, tail;
	for (head = 0, tail = 1; head < tail; head++) {
		for (p = adj[q[head]]; p != NULL; p = p->next) {
			if (dist[p->v] == 0) {
				dist[p->v] = -1;
				q[tail++] = p->v;
			}
		}
	}
	q[0] = q[tail-1];
	dist[q[tail-1]] = 0;
	par[q[tail-1]] = q[tail-1];
	for (head = 0, tail = 1; head < tail; head++) {
		for (p = adj[q[head]]; p != NULL; p = p->next) {
			if (dist[p->v] == -1) {
				dist[p->v] = dist[q[head]] + 1;
				par[p->v] = q[head];
				q[tail++] = p->v;
			}
		}
	}
	
	int j, k, r, s, t, diam = dist[q[tail-1]], h[101];
	long long ans, tmp, deg[101] = {};
	if (diam % 2 == 0) {
		for (r = q[tail-1]; dist[r] > diam / 2; r = par[r]);
		for (i = 1; i <= N; i++) dist[i] = -1;
		q[0] = r;
		dist[r] = 0;
		for (head = 0, tail = 1; head < tail; head++) {
			for (p = adj[q[head]], tmp = 0; p != NULL; p = p->next) {
				if (dist[p->v] == -1) {
					dist[p->v] = dist[q[head]] + 1;
					q[tail++] = p->v;
					tmp++;
				}
			}
			if (tmp > deg[dist[q[head]]]) deg[dist[q[head]]] = tmp;
		}
		for (i = 0, ans = 1; i < diam / 2; i++) ans *= deg[i];
		
		for (k = 1; dist[q[k]] == 1; k++) h[k] = q[k];
		for (j = 1; j < k; j++) {
			for (i = 1; i <= N; i++) dist[i] = -1;
			for (i = 0; i <= diam / 2; i++) deg[i] = 0;
			q[0] = r;
			q[1] = h[j];
			dist[r] = 0;
			dist[h[j]] = 0;
			for (head = 0, tail = 2; head < tail; head++) {
				for (p = adj[q[head]], tmp = 0; p != NULL; p = p->next) {
					if (dist[p->v] == -1) {
						dist[p->v] = dist[q[head]] + 1;
						q[tail++] = p->v;
						tmp++;
					}
				}
				if (tmp > deg[dist[q[head]]]) deg[dist[q[head]]] = tmp;
			}
			for (i = 0, tmp = 2; i < diam / 2; i++) tmp *= deg[i];
			if (tmp < ans) ans = tmp;
		}
	} else {
		for (s = q[tail-1]; dist[s] > (diam + 1) / 2; s = par[s]);
		t = par[s];
		for (i = 1; i <= N; i++) dist[i] = -1;
		q[0] = s;
		q[1] = t;
		dist[s] = 0;
		dist[t] = 0;
		for (head = 0, tail = 2; head < tail; head++) {
			for (p = adj[q[head]], tmp = 0; p != NULL; p = p->next) {
				if (dist[p->v] == -1) {
					dist[p->v] = dist[q[head]] + 1;
					q[tail++] = p->v;
					tmp++;
				}
			}
			if (tmp > deg[dist[q[head]]]) deg[dist[q[head]]] = tmp;
		}
		for (i = 0, ans = 2; i < diam / 2; i++) ans *= deg[i];
	}
	
	printf("%d %lld\n", diam / 2 + 1, ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1712
N = int(input())
P = list(map(int, input().split()))
sP = sorted(P)
for i in range(N):
    for j in range(N):
        P[i], P[j] = P[j], P[i]
        if P==sP:
            print("YES")
            exit()
        P[i], P[j] = P[j], P[i]
print("NO")


Measured memory_bytes: 3060
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    Author: z0marlin
    Title: C.cpp
    Time: 16-08-2019T22:28:29+0530 
    I suck at CP T_T
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
    #include <bits/stdc++.h>
    #if DEBUG
    #define dprintf(...) printf(__VA_ARGS__)
    #else
    #define dprintf(...)
    #endif
    #define FOR(i, a, n) for(int i = a; i < n; ++i)
    #define FORE(a, v) for(auto a:v)
    #define MAX(a, b) ((a>b)?a:b)
    #define MIN(a, b) ((a<b)?a:b)
    #define MP(i, j) make_pair(i, j)
    #define PB(a) push_back(a)
    #define PPB(a) pop_back(a)
    #define all(a) a.begin(), a.end()

    using namespace std;
    typedef long long int ll;
    typedef unsigned long long int ull;
    typedef pair<int,int> pii_t;
    typedef pair<ll,ll> pll_t;
    typedef vector<int> vi_t;
    typedef vector<ll> vll_t;

    const int MAX_SZ=1e6+2;
    const int MOD=1e9+7;
    int t = 1, n, m, q, ql, qr;
    char ch;
    vi_t inp, ps, pos;

    int solve(){
        ps.resize(n);
        pos.resize(n);
        ps[0]=inp[0];
        pos[n-1]=inp[n-1];
        FOR(i,1,n){
            ps[i]=max(inp[i],ps[i-1]);
            pos[n-i-1] = max(pos[n-i], inp[n-i-1]);
        }
        printf("%d\n", pos[1]);
        FOR(i, 1, n-1){
            printf("%d\n", max(ps[i-1], pos[i+1]));
        }
        printf("%d\n", ps[n-2]);
        return 0;
    }

    int main(){
        // scanf("%d", &t);
        while(t--){
            scanf("%d", &n);
            inp.resize(n);
            FOR(i,0,n){
                scanf("%d", &inp[i]);
            }
            solve();
        }
    }

Measured memory_bytes: 3968
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{   
    int n;
    cin >> n;
    int m = int(sqrt(double(n)));
    cout << m*m << endl;
    return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        s: String,
    }

    let c: Vec<_> = s.chars().collect();

    if c.get(2) == c.get(3) && c.get(4) == c.get(5) {
        println!("Yes");
    } else {
        println!("No");
    }

}


Measured memory_bytes: 2136
using System;
using System.Collections.Generic;
					
public class Program
{
	static int time = 0;
	
	public static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		
		int[,] G = new int[n,n];
		
		for(int i = 0; i < n; i++) {
			int[] u = Array.ConvertAll(Console.ReadLine().Split(" ".ToCharArray()), int.Parse);
			
			for(int j = 0; j < u[1];  j++) {
				G[u[0]-1, u[j+2]-1] = 1;
			}
		}
		
		Node[] nodes = new Node[n];
		for(int i = 1; i <= n; i++) {
			nodes[i - 1] = new Node(i);
		}
		
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				if(G[i,j] != 0) { 
					nodes[i].Children.Add(nodes[j]);
				}
			}
		}
		
		for(int i = 0; i < n; i++) {
			if(nodes[i].StartTime == 0) DFS(nodes, nodes[i]);
		}
		
		for(int i = 0; i < n; i++) {
			Console.WriteLine(nodes[i]);
		}
	}
	
	static void DFS(Node[] nodes, Node node)
	{
		node.StartTime = ++time;
		
		for(int i = 0; i < node.Children.Count; i++) {
			if(nodes[node.Children[i].Id -1].StartTime == 0) DFS(nodes, nodes[node.Children[i].Id -1]);
		}
		
		node.EndTime = ++time;
	}
	
}

class Node
{
	public int StartTime,EndTime;
	public int Id { get; private set; }
	public List<Node> Children = new List<Node>();
	
	public Node (int id)
	{
		this.Id = id;
	}
	
	public override string ToString()
	{
		return Id + " " + StartTime + " " + EndTime;
	}
}

Measured memory_bytes: 9260
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int a, b;
  while (cin >> a >> b, a || b) {
    int change = b - a;
    int p      = change / 1000;
    change %= 1000;
    int q = change / 500;
    change %= 500;
    int r = change / 100;
    cout << r << ' ' << q << ' ' << p << endl;
  }
}

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<ctime>
#include<vector>
#include<queue>
#include<map>
#include<deque>
#include<stack>
#include<algorithm>
#define N
using namespace std;
const int INF=0x7fffffff;
const double Pi=acos(-1);
int main()
{
	int i,n;
	scanf("%d",&n);
	int Num=n/100;
	int Temp=Num*111;
	if(n<=Temp)printf("%d\n",Temp);
	else printf("%d\n",(Num+1)*111);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int N;
  string t;
  cin>>N>>t;
  for (int i(1);i<=2;i++){
    for (int j(1);j<=2;j++){
      int ans[100000] = {0};
      string s = t;
      ans[0] = i;
      ans[1] = j;
      if (i == 2) s[0] = (s[0] == 'o'? 'x' : 'o');
      if (j == 2) s[1] = (s[1] == 'o'? 'x' : 'o');
      for (int k(2);k<N;k++){
        if (s[k-1] == 'o'){
          ans[k] = ans[k-2];
        }else{
          ans[k] = (ans[k-2] == 1? 2:1);
        }
        if (ans[k] == 2){
          s[k] = (s[k] == 'o'? 'x' : 'o');
        }
      }
      //for (int i(0);i<N;i++) cout << ans[i] << " ";
      if ((s[N-1] == 'o' && ans[N-2] == ans[0]) || (s[N-1] == 'x' && ans[N-2] * ans[0] == 2)){
        if ((s[0] == 'o' && ans[N-1] == ans[1]) || (s[0] == 'x' && ans[N-1] * ans[1] == 2)){
          for (int k(0);k<N;k++){
            if (ans[k] == 1){
              cout << 'S';
            }else{
              cout << 'W';
            }
          }
          cout << endl;
          return 0;
        }
      }
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 896
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define repc(i, s, t) for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(ios_base::fixed);
    cout.precision(12);

    var(i64, X, A);
    print((X % 500 <= A) ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))

A.insert(0,0)

start = 1
next_ = A[1]

visited = [0] * (N+1)
visited[start] = 1

route = [1]
cnt = 0
while True:
    if visited[next_] == 1:
        break
    visited[next_] = 1
    route.append(next_)
    cnt += 1
    if cnt >= K:
        print(next_)
        exit()
    next_ = A[next_]

roop_s = route.index(next_)
roop = route[roop_s:]

stop = (K - roop_s) % len(roop) + 1
ans = roop[stop-1]

print(ans)


Measured memory_bytes: 32412
#import sys
#input = sys.stdin.readline
Q = 10**9+7
# def getInv(N):#Qはmod
#     inv = [0] * (N + 1)
#     inv[0] = 1
#     inv[1] = 1
#     for i in range(2, N + 1):
#         inv[i] = (-(Q // i) * inv[Q%i]) % Q
#     return inv

def main():

    N, K = map( int, input().split())
    if K == 1:
        print(0)
        return
    A = list( map( int, input().split()))
    A.sort()
    ans = 0

    cnt = 1
    for i in range(K-1,N):
        if i >= K:
            cnt *= i*pow(i-(K-1), Q-2, Q)%Q
            cnt %= Q
        ans += cnt*A[i]

        ans -= cnt*A[N-1-i]
        ans %= Q
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 63472
a, b = gets.split.map(&:to_i)
ary = []
a.times do
  like = gets.split.map(&:to_i)
  like.shift
  ary << like
end

likes = {}
likes.default = 0
ary.each do |like|
  like.each do |elem|
    likes[elem] += 1
  end
end

puts likes.count{|key, val| val == a}


Measured memory_bytes: 3836
import math

n, m = map(int, input().split())

def calculation(number):
    factorial = math.factorial(number)
    combination = factorial/math.factorial(number-2)
    result = math.floor(combination/2)
    return result

if m == 1 or m == 0:
    if n == 1 or n == 0:
        print("0")
    else:
        print("{}".format(calculation(n)))
else:
    if n == 1 or n == 0:
        print("{}".format(calculation(m)))
    else:
        print("{}".format(calculation(n)+calculation(m)))


Measured memory_bytes: 3060
St = input()

Se = set(St)

answer = 0

if len(Se) == 2 and St.count(St[0]) == 2 and  St.count(St[1]) == 2 and St.count(St[2]) == 2 and St.count(St[3]) == 2:
	print("Yes")
else:
	print("No")

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

int main() {
  
  int64_t N, X, M;
  cin >> N >> X >> M;
  
  vector<int64_t> Xlist(200001,0);
  Xlist.at(0) = X;
  
  bool lcheck = false;
  int d = 0;
  int64_t m = 0;
  int i2 = 0;
  
  for (int i = 1; i < N; i++) {
    X = X*X%M;
    Xlist.at(i) = X;
    if (lcheck) {
      if ((N-i-1)%d == 0) {
        m = (N-i-1)/d;
        i2 = i;
        goto end;
      }
    }
    else {
      for (int j = 0; j < i; j++) {
        if (Xlist.at(i) == Xlist.at(j)) {
          d = i-j;
          lcheck = true;
          break;
        }
      }
    }
  }
  
  end:
  
  int64_t S = 0;
  int64_t S2 = 0;
  
  if (m == 0) {
    for (int i = 0; i < N; i++) {
      S = S+Xlist.at(i);
    }
  }
  else {
    for (int i = 0; i < i2+1-d; i++) {
      S = S+Xlist.at(i);
    }
    for (int i = i2+1-d; i < i2+1; i++) {
      S2 = S2+Xlist.at(i);
    }
    S2 *= m+1;
    S += S2;
  }
  
  
  cout << S << endl;

return 0;
}

Measured memory_bytes: 4844
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

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

vector<double> p(1000);
void init(){
  rep(i, 1000){
    p[i] = ((i+1)+1)/2.0;
  }
}

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> d(N);
  rep(i, N) {
    cin >> d[i];
  }
  init();

  // 期待値を調べる
  double e = 0.0;
  double tmp = 0.0;
  rep(i, K) {
      tmp += p[d[i]-1];
  }
  e = max(e, tmp);
  // cout << "debug:" << tmp << endl;
  int cnt = 0;
  for(int i = K; i < N;i++){
    // cout << e << endl;
    tmp += p[d[i]-1];
    tmp -= p[d[cnt] - 1];
    cnt++;
    e = max(e, tmp);
  }

  cout << setprecision(7) << e << endl;

}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;


const long long MOD = 1000000007;

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

	ll n;
	int k;
	cin >> n >> k;

	ll p = k;
	int ans = 1;
	while (true) {
		if (p > n) break;
		++ans;
		p *= k;
	}

	cout << ans << "\n";

	return 0;
}
 

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,a,b;
	cin>>n>>a>>b;
	cout<<min(n*a,b)<<endl;
}


Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;
using System.IO;
using System.Collections.Generic;
namespace I_am_the_green_coder{
    class Inonoa{
        static void Main(){
            long[] ab = ILongs();
            if(Math.Abs((ab[0]-ab[1]))%2==1){
                Console.WriteLine("IMPOSSIBLE");
            }else{
                Console.WriteLine((ab[0]+ab[1])/2);
            }
        }

        static readonly long MOD = 1000000007;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        ///<summary>n行の文字列を取ったり</summary>
        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = ReadLine().ToCharArray();
            }
            return re;
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a, ll b)
{
    if(b == 0) return a;
    return gcd(b, a%b);
}
int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        ll s = a - b;
        if(s < 0 || b > d)
        {
            cout << "No" << endl;
            continue;
        }
        if(c+1 >= b)
        {
            cout << "Yes" << endl;
            continue;
        }
        ll x = gcd(b, d);
        ll out = b - x + s%x;
        if(out > c) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
    #include <climits>
    #include <set>
    #include <string>
    #include <algorithm>
    #include <vector>
    #define MAX 1000000007
    
    
    using namespace std;
    #define ll long long
    #define dbg if(0)
    #define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))
    
    
    
    int main(){
        ll ans,n,a,b;
        cin>>n>>a>>b;

        ans=(n/(a+b))*a+min(a,n%(a+b));
    
        cout <<ans<<endl;
    
        return 0;
    
    }

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

int main(){
  	string s;
  	cin >> s;
  
  	cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
  	return 0;
}

Measured memory_bytes: 256
MOD = 10**9+7
n = int(input())
m = n - 1
x = list(map(int, input().split()))
d = [x[i+1] - x[i] for i in range(m)]

inv = [0, 1]
for i in range(2, n):
  inv += [inv[MOD % i] * (MOD - int(MOD / i)) % MOD]

s = 1
for i in range(2, n):
    s *= i
    s %= MOD

ans = s * sum(d) % MOD

p = 0
for i in range(1, m):
    p += inv[i+1]
    p %= MOD
    ans += s * d[i] * p
    ans %= MOD

print(ans)


Measured memory_bytes: 65304
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>
#include <vector>
#include <array>

using std::cout;
using std::cin;
using std::string;


int main()
{
  int n;
  std::vector<int> v;
  std::vector<int> c;
  std::vector<int> diff;
  cin >> n;
  diff.resize(n);
  v.resize(n);
  c.resize(n);

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

  for(size_t i = 0; i < n; ++i)
  {
    cin >> c[i];
  }

  
  for(size_t i = 0; i < n; ++i)
  {
    diff[i] = v[i] - c[i];
  }

  int sum = 0;
  for(size_t i = 0;i < n; ++i)
  {
    if(diff[i] > 0)
    {
      sum += diff[i];
    }
  }
  cout << sum << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <cstring>
#include <cstdlib>

using namespace std;

int ans = 0;
int n;

void check753 (long x, bool x3, bool x5, bool x7){
    if (x > n) return;  //値がNを超えていないか
    if (x3 && x5 && x7) ans++;  //3,5,7がすべて現れれば+1

    x *= 10;
    check753(x + 3, true, x5, x7);  //先頭が3のとき
    check753(x + 5, x3, true, x7);  //先頭が5のとき
    check753(x + 7, x3, x5, true);  //先頭が7のとき
}

int main()
{
    cin >> n;
    check753(0, false, false, false);
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 29, 2019
 * 
 */

#include <bits/stdc++.h>

//#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 


    int n;

    cin>>n;

    vi dp(3 , 0);

    rep(n){
        vi new_dp(3, 0);
        vi c(3);

        iv(c);

        for(int j=0; j<3; ++j){

            for(int k=0; k<3; ++k){
                
                if(j!=k)
                    new_dp[k] = max(new_dp[k] , dp[j] + c[k]);
            }

        }
        dp = new_dp;
    }

    cout<<max({dp[0] , dp[1] , dp[2]})<<endl;


    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("cin","r",stdin);
    freopen("cout","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}


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

using namespace std;

typedef long long ll;
int main()
{
	ll n,W; cin >> n >> W;
	vector<ll> s(n+1), v(n+1);
	for(int i = 1; i < n+1; i++) cin >> s[i] >> v[i];
	
	const ll mx = (ll)1e5+1;
	ll ans = 0;
	vector<vector<ll>> dp(mx, vector<ll>(n+1));
	for(int i = 0; i < mx; i++){
		for(int j = 0; j <= n; j++) dp[i][j] = INT_MAX;
	}
	dp[0][0] = 0;
	for(ll i = 0; i < mx; i++){
		for(int j = 1; j <= n; j++){
			ll x = INT_MAX;
			if(i >= v[j]) x = dp[i-v[j]][j-1]+s[j];
			dp[i][j] = min(x, dp[i][j-1]);
			
			if(dp[i][j] <= W) ans = i;
		}
	}
	cout << ans;
}


Measured memory_bytes: 85368
import math 
a, b, x = map(int, input().split())
s = x / a
flg = 0
if s == a * b / 2:
    print(45.0)
    exit()
elif s > a * b / 2:
    flg = 1
else:
    flg = -1
if flg == -1:
    print(math.atan(b ** 2 /(2 * s)) / (2 * math.pi) * 360)
else:
    print(math.atan(2 / a ** 2 * (a * b - s)) / (2 * math.pi) * 360)

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

using namespace std;

long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a;}

long long lcm(long long a, long long b) { return a / gcd(a,b) * b;}

int number_of_division2(int n){
    if(n % 2 == 1) return 0;
    
    int count = 0;
    
    while(n % 2 == 0){
        count++;
        n /= 2;
    }
    
    return count;
}

int main(){
    int n, m;
    cin >> n >> m;
    
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
        a[i] /= 2;
    }
    
    //aたちが２で割れる回数がすべて同じであるか否かをチェックする/
    //２で割れる回数が同じでなければ, 答えは０と決まる
    int count_of_division = number_of_division2(a[0]);
    
    rep(i, n){
        int temp = number_of_division2(a[i]);
        
        if(count_of_division != temp){
            cout << 0 << endl;
            return 0;
        }
        
        a[i] /= pow(2, count_of_division);
    }
    
    m /= pow(2, count_of_division);
    
    //最小公倍数を求める
    long long L;
    if(n == 1) L = a[0];
    else{
         L = lcm(a[0], a[1]);
         
         rep(i, n){
             L = lcm(L, a[i]);
             
         }
    }
   
    
    if(L > m){
        cout << 0 << endl;
        return 0;
    }
    
    int temp_ans = m / L;
    int ans;
    
    if(temp_ans % 2 == 0) ans = temp_ans / 2;
    else ans = 1 +  temp_ans / 2;
    
    cout << ans << endl;
    
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>



int main() {
    double a,b,x;
    cin >> a >> b >> x;
    if(2 * x < a*a*b){
        double tan = 2 * x / (a*b*b);
        double ans =  90 - atan(tan) /3.1415926535 * 180 ;
        printf("%.10f\n",ans);
    }
    else{
        double tan = a*a*a/(2*(a*a*b - x));
        double ans = 90 - atan(tan) /3.1415926535 * 180;
        printf("%.10f\n",ans);
    }
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int a[200004];
long long ans=0;
int main(){
	cin>>n;
	int b=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]>=b)b=a[i];
		else ans+=b-a[i];
	}
	cout<<ans;
}

Measured memory_bytes: 4400
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<utility>
using namespace std;

const int maxn = 10000+5;
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define pb push_back
#define mp make_pair 
struct P
{
	int first;   //現在地
	int second;  //C値
};
queue<P> que;
vector<int> memp [maxn];
vector<int> memc;
int ans[maxn];
int n;
int check[maxn];

int solve()
{
	sort(memc.begin(), memc.end(), greater<int>());
	memset(check, 0, sizeof(check));

	int s = 0;
	repn(i, n)
	{
		if(memp[i].size() == 1) 
		{
			s = i; 
			break;
		}
	}

	P ns; ns.first = s; ns.second = 0; 
	que.push(ns);

	int total = 0;
	int k = 0;

	while(!que.empty())
	{
		P nns = que.front();
		que.pop();

		check[nns.first] = 1; //行った所に記しをつける

		int target = nns.second;
		int length = memp[nns.first].size();

		int cmpv = memc[k++]; //今指しているnodeにC値を与える
		total += min(cmpv, target);
		ans[nns.first] = cmpv;

		rep(j, length)
		{ 	
			if(check[memp[nns.first][j]]) continue; //行ったことがあるかを確かめる
			
			//printf("ans[%d] = %d\n", nns.first, cmpv);

			P nnns;
			nnns.first = memp[nns.first][j]; nnns.second = cmpv; 
			que.push(nnns);

			//printf("nnns.first = %d\n", nnns.first);
		}
	}
	return total;
}

int main()
{
	scanf("%d", &n);
	rep(i, n-1)
	{
		int a, b;
		scanf("%d %d", &a, &b);
		memp[a].pb(b);
		memp[b].pb(a);
	}
	rep(i, n)
	{
		int c;
		scanf("%d", &c);
		memc.pb(c);
	}

	printf("%d\n", solve());
	for(int i = 1; i <= n; i++) 
	{
		if(i != n) printf("%d ", ans[i]);
		else printf("%d\n", ans[i]);
	}
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
typedef long long ll;

const int N=2000005,P=1000000007;
int a,b,c,d,Fac[N],Inv[N];

ll Pow(ll a,int b,ll s=1){for(;b;b>>=1,a=a*a%P)if(b&1)s=s*a%P;return s;}
inline ll Calc(int x,int y){return (ll)Fac[x+y]*Inv[x]%P*Inv[y]%P;}

int main()
{
    scanf("%d%d%d%d",&a,&b,&c,&d);
    int l=c+d+1;
    for(int i=Fac[0]=1;i<=l;++i)Fac[i]=(ll)Fac[i-1]*i%P;
    Inv[l]=Pow(Fac[l],P-2);
    for(int i=l;i>=1;--i)Inv[i-1]=(ll)Inv[i]*i%P;
    ll Ans=0;
    for(int i=a;i<=c;++i)Ans+=Calc(i+1,d)-Calc(i+1,b-1);
    return printf("%lld\n",(Ans%P+P)%P),0;
}

Measured memory_bytes: 15872
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")

#include <bits/stdc++.h>
#define  f               first
#define  s               second
#define  sym(s)          s = "#" + s + "#";
#define  all(x)          (x).begin(), (x).end()
#define  alll(x,n)       x+1, x+n+1
#define  newl            cout<<"\n";
#define  foo(i,a,n)      for(ll i = (a); i <= n; i++)
#define  deb1(a)         cout<<a<<"\n";
#define  deb2(a,b)       cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)     cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)   cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  debp(a)         cout<<a.f<<" "<<a.s<<"\n";
#define  debv(a)         for(auto it: a)cout<<it<<" ";newl;
#define  debm(a)         for(auto it: a)cout<<"{"<<it.f<<","<<it.s<<"}, ";newl;
#define  deb1d(a,n)      foo(i,1,n)cout<<a[i]<<" ";newl;
#define  deb2d(a,n,m)    foo(i,1,n){foo(j,1,m){cout<<a[i][j]<<" ";}newl;}

using namespace std;
using ll              =  long long;
using ld              =  long double;
const ll   MOD        =  1e+9 + 7;
const ll   INF        =  LLONG_MAX;
const int  N          =  (int)1e+6 + 8;

ll n;
ll dp[N][2][2];

ll fast_pow(ll x, ll y, ll MOD=MOD){
    ll res=1;
    while(y){
        if(y&1)res=(res*x)%MOD;
        y>>=1;x=(x*x)%MOD;
    }
    return res;
}

void MAIN(int tc){
    cin >> n;
    ll r1 = 2 * fast_pow(9, n) % MOD;
    r1 = (r1 - fast_pow(8, n) + MOD) % MOD;
    ll res = (fast_pow(10,n) - r1 + MOD) % MOD;
    deb1(res);
}

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

    int test_cases = 1;
    //cin>>test_cases;
    for(int i = 1; i <= test_cases; i++){
        MAIN(i);
    }
}

Measured memory_bytes: 3600
var main = function main(input) {
  var count = 0
  for (var i = 0; i < input.length; i++) {
      if (input[i] === 'o') count++ 
  }
  console.log(700 + count*100)
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf-8'))


Measured memory_bytes: 7372
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
//#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int bm = 200001;
ll BIT[bm];
void add(int A, ll B) {
	while (A <= bm) {
		BIT[A] = max(BIT[A], B);
		A += A & -A;
	}
}
ll query(int A) {
	ll kotae = 0;
	while (A > 0) {
		kotae = max(BIT[A], kotae);
		A -= A & -A;
	}
	return kotae;
}

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

char cn2[1300000], * ci2 = cn2;
inline int getint2() {
	int A = 0;
	while ((ct = *ci2++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = 0;
	while ((ct = getchar_unlocked()) >= '0') N = N * 10 + ct - '0';
	int k = 0;
	if (N < 10) k = 2 * N;
	else if (N < 100) k = 18 + (N - 9) * 3;
	else if (N < 1000) k = 288 + (N - 99) * 4;
	else if (N < 10000) k = 3888 + (N - 999) * 5;
	else if (N < 100000) k = 48888 + (N - 9999) * 6;
	else k = 588888 + (N - 99999) * 7;
	fread(cn2, 1, k, stdin);
	rep(i, N) {
		int h = getint2();
		add(h, query(h) + getint());
	}

	printf("%lld", query(N));

	Would you please return 0;
}

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

void call(int n) {
    for(int i=1;i<n+1;i++)
    {
        if( i%3==0 )
        {
            cout << " " << i;
        }
        else
        {
            int x = i;
            while(x>0)
            {
                if( x%10==3 )
                {
                    cout << " " << i;
                    break;
                }
                x = x/10;
            }
        }
    }
    cout << endl;
}

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

Measured memory_bytes: 3024
class MASS
  def initialize(h, w)
    @h = h
    @w = w
    @m = Array.new(@h){Array.new(@w, 0)}
    @x = 0
    @y = 0
  end
  def draw(v, n)
    n.times do |i|
      @m[@y][@x] = v
      @y, @x = if (@y == 0 || @m[@y - 1][@x] > 0) \
                && @x + 1 < @w && @m[@y][@x + 1] == 0
              [@y, @x + 1]
            elsif (@x == @w - 1 || @m[@y][@x + 1] > 0) \
                && @y + 1 < @h && @m[@y + 1][@x] == 0
              [@y + 1, @x]
            elsif (@y == @h - 1 || @m[@y + 1][@x] > 0) \
                && @x - 1 >=0 && @m[@y][@x - 1] == 0
              [@y, @x - 1]
            elsif (@x == 0 || @m[@y][@x - 1] > 0) \
                && @y - 1 >= 0 && @m[@y - 1][@x] == 0
              [@y - 1, @x]
            end
    end
  end
  def out
    @h.times do |i|
      puts @m[i] * ' '
    end
  end
end

h, w = gets.split.map(&:to_i)
n = gets.to_i
a = gets.split.map(&:to_i)
m = MASS.new(h, w)
n.times do |i|
  m.draw(i + 1, a[i])
end
m.out

Measured memory_bytes: 2428
#include <bits/stdc++.h>
#define PI 3.14159265358979323846264338327
#define NUM 1000000007
#define ss second
#define ff first
using namespace std;
int main(){
	ios::sync_with_stdio(0);	
	int n, m;
	int l, r, cnt[100010] = {0};
	cin >> n >> m;
	for (int i = 0; i < m ;i++){
		cin >> l >> r;
		cnt[l]++;
		cnt[r + 1]--;
	}
	cnt[0] = 0;
	int ans = 0;
	for (int i = 1; i <= n; i++){
		cnt[i] += cnt[i - 1];
		if (cnt[i] == m)
			ans++;
	}
	cout << ans <<"\n";
	
	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Mll = M<ll, ll>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin(),ie=(c).rend();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, k;

int main() {
    cin >> k >> n;
    Vi a(n*2);
    REP(i, n) {
        cin >> a[i];
        a[i+n] = a[i] + k;
    }

    int mini = 1e9;
    REP(i, n) {
        mini = min(mini, a[i+n-1] - a[i]);
    }
    cout << mini << '\n';

    return 0;
}


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

using namespace std;

int main() {

	long n;

	cin >> n;

	vector<long> h(n + 1);

	for (long i = 1; i <= n; i++) {
		cin >> h[i];
	}
	h[0] = h[1];

	vector<long> dp(n+2);
	dp[1] = 0;
	dp[0] = 0;

	for (long i = 2; i <= n; i++) {
		dp[i] = min(dp[i - 1]+abs(h[i]-h[i-1]), dp[i - 2]+ abs(h[i] - h[i - 2]));
	}

	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 1792
N = int(raw_input())
A = map(int, raw_input().split())
for i in range(0, N):
	A[i] -= i+1
A.sort()
m = 0
if N % 2 == 0:
	m = (A[N/2-1]+A[N/2])/2
else:
	m = A[N/2]
sum = 0
for i in range(0, N):
	sum += abs(A[i]-m)
print sum

Measured memory_bytes: 56004
use std::cmp::min;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn gcd(a: i32, b: i32) -> i32 {
    fn gcd1(m: i32, n: i32) -> i32 {
        if n == 0 {
            m
        } else {
            gcd1(n, m % n)
        }
    }
    if a > b {
        gcd1(a, b)
    } else {
        gcd1(b, a)
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b' ');
    let x: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    let mut xv = vec![0i32; n];
    for i in 0..n - 1 {
        xv[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    xv[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    let mut ans = (x - xv[0]).abs();
    for i in 1..n {
        ans = gcd(ans, (x - xv[i]).abs());
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
function Main(input){
	input = input.split("\n")
	var n = input[0];
	var arr = input[1].split(" ").map(Number);
	var max = 0;
	var sum = 0;
	for(var i=0;i<n;i++){
		if(max<=arr[i]){
			max = arr[i];
			sum++;
		}
	}
	console.log(sum);
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
int main() {

  int a,b,c,d;
  cin >> a >> b >> c >> d;
  string res = "No";

  if(abs(a - c) <= d) res = "Yes";
  else if((abs(a - b) <= d) && (abs(b - c) <= d)) res = "Yes";

  cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 100005
#define MOD 1000000007
using namespace std;
int n,k,a[105],dp[105][M];
int pre[M];
int mod(int x) { x %= MOD; if (x<0) x += MOD; return x; }

int main()
{
    scanf("%d %d", &n, &k);
    REP(i,1,n) scanf("%d", &a[i]);

    REP(i,0,a[1]) dp[1][i] = 1;
    REP(i,2,n) {
        pre[0] = dp[i-1][0];
        REP(j,1,k) pre[j] = mod(pre[j-1] + dp[i-1][j]);
        
        REP(j,0,k) {
            int r = j;
            int l = max(0, j-a[i]);
            int sum = pre[r];
            if (l>0) sum = mod(sum - pre[l-1]);
            dp[i][j] = sum;
        }
    }
    
    printf("%d\n", dp[n][k]);
    return 0;
}


Measured memory_bytes: 43136
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll ceil(ll a, ll b) {  // a÷b以上の最小の整数
    if(b == 0) {
        return 0;
    }
    return (a+b-1)/b;
}
 
int main() {
    ll S;
    cin >> S;

    ll x1 = 0, y1 = 0;

    const ll m = 1e9;

    if(S <= m) {
        cout << x1 << " " << y1 << " " << 1 << " " << 0 << " " << 0 << " " << S << endl;
        re0;
    }

    ll x2 = m, y2 = 1;

    if(S == 1e18) {
        ll x3 = 0, y3 = m;
        cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
        re0;
    }
    
    ll y3 = S/m + 1;
    ll z = S%m;
    ll x3 = m - z;
    
    cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
    re0;
}

Measured memory_bytes: 256