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

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b,c,d; cin>>a>>b>>c>>d;
	if (a*b<c*d) cout<<(c*d)<<endl;
	else if (a*b>c*d) cout<<(a*b)<<endl;
	else if (a*b==c*d) cout<<a*b<<endl;
	else cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <queue>
#include <vector>
#include <map>
#include <set>
using namespace std;

bool prim[1000000];

int main()
{
    int x;scanf("%d",&x);
    for (int i=1;i<1e5+5;i+=2) prim[i]=1;
    prim[2]=1;
    for (int i=2;i<1e6;++i){
        if (!prim[i]) continue;
        if (i>=x){
            printf("%d",i);return 0;
        }
        for (int j=2*i;j<1e5+5;j+=i)
            prim[j]=0;
    }
}





Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	LL X,Y;
	cin>> X>>Y;
	int ans = 0;
	while(true){
		if( X >= 0 && X <= Y ){
			++ans;
			X <<= 1;
		}else{
			break;
		}
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

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

int main() {
    int N,M;cin >> N >> M;
    priority_queue<ll> que;
    for (int i = 0;i < N;i++) {
        ll A;cin >> A;que.push(A);
    }
    for (int i = 0;i < M;i++){
        ll t = que.top();que.pop();
        que.push(t/2);
    }
    ll res = 0;
    while(que.size()) {
        res+= que.top();
        que.pop();
    }
    cout << res << endl;
}

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

void show(int n,int a[])
{
    for(int i=0;i<n;i++)
    {
        if(i>0)cout<<" "<<a[i];
        else cout<<a[i];
    }
    cout<<endl;
}

void insertion(int n,int a[])
{
    int i,j,v;
    for(int i=1;i<n;i++)
    {
        j=i-1;
        v=a[i];
        while(j>=0&&v<a[j])
        {
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=v;
        show(n,a);
    }
     
}

int main()
{
    int n;
    cin>>n;
    int a[n];

    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    show(n,a);
    insertion(n,a);
    return 0;
}


Measured memory_bytes: 3120
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
//#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.12f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
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;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll value[3005][3005];
ll dp[3005][3005][4];

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll R,C,K; cin >> R >>C  >>K;
    rep(i,0,K){
        ll r,c,v; cin >> r >> c >>v;
        value[r][c] = v;
    }
    dp[1][1][1] = value[1][1];
    reps(i,1,R){
        reps(j,1,C){
            reps(k,0,3){
                chmax(dp[i][j+1][k], dp[i][j][k]);
                if(k < 3) chmax(dp[i][j+1][k+1], dp[i][j][k] + value[i][j+1]);
            }
            reps(k,0,3){
                chmax(dp[i+1][j][0], dp[i][j][k]);
                chmax(dp[i+1][j][1], dp[i][j][k] + value[i+1][j]);
            }
        }
    }
    
    ll ans = dp[R][C][0];
    chmax(ans, dp[R][C][1]);
    chmax(ans, dp[R][C][2]);
    chmax(ans, dp[R][C][3]);

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 355824
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[100005]={0};
ll n;
int main(){
    cin>>n;
    ll cost[n];
    for(ll i=0;i<n;i++){
        cin>>cost[i];
    }
     
    
    for(ll i=0;i<n;i++){
        if(i==0){
            dp[i]=0;
        }
        else if(i==1){
            dp[i]=abs(cost[i]-cost[i-1])+dp[i-1];
        }
       
        else{
            dp[i]=min(dp[i-1]+abs(cost[i]-cost[i-1]),dp[i-2]+abs(cost[i]-cost[i-2]));
        }

    }
  if(n==0){
    cout<<dp[0]<<endl;
  }
  else{
    cout<<dp[n-1]<<endl;
  }
    
    return 0;
}

Measured memory_bytes: 1792
N, M = map(int, input().split(' '))
l = [0]*(N-1)
for i in range(M):
    a, b = map(int, input().split(' '))
    if 1 in [a, b]:
        a, b = sorted([a, b])
        l[b-2] += 1
    else:
        l[a - 2] += 1
        l[b - 2] += 1
for i in l:
    if i % 2 != 0:
        print('NO')
        exit()
print('YES')

Measured memory_bytes: 3828
N,K = map(int, input().split())
h = list(map(int, input().split()))

INF = float('inf')
dp = [INF] * (N)
dp[0] = 0

for i in range(1,N):
    cost = INF
    for j in range(max(0,i-K),i):
        # print(h[j],':',h[i])
        dp[i] = min(dp[i], dp[j]+abs(h[j]-h[i]))
    # print(dp)
print(dp[-1])


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

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

  if(n>=10){
    cout << r << endl;
  }
  else{
    cout << r+100*(10-n) << endl;
  }

  return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t

int n;
string s;

void Try(int a,int b){
	vector<int> color(n);
	color[0]=a;
	color[1]=b;
	for(int i=2;i<n;++i){
		 if(color[i-1]) color[i]=color[i-2]^(s[i-1]=='x');
		 else color[i]=color[i-2]^(s[i-1]!='x');
	}
	if(color[n-1]&&((s[n-1]=='x')^(color[n-2]!=color[0]))) return;
	if(color[0]&&((s[0]=='x')^(color[n-1]!=color[1]))) return;
	if(!color[n-1]&&((s[n-1]=='x')^(color[n-2]==color[0]))) return;
	if(!color[0]&&((s[0]=='x')^(color[n-1]==color[1]))) return;
	for(int i=0;i<n;++i)
		cout<<(color[i]?'S':'W');
	cout<<'\n';
	exit(0);
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n>>s;
	for(int i=0;i<2;++i)
		for(int j=0;j<2;++j)
			Try(i,j);
	cout<<-1<<'\n';
}



Measured memory_bytes: 4236
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main(void)
{
  int a, b;
  cin >> a >> b;
  if(a == 1 && b == 1){
    cout << "Draw" << endl;
  }
  else if(a == 1){
    cout << "Alice" << endl;
  }
  else if(b == 1){
    cout << "Bob" << endl;
  }
  else{
    if(a > b){
      cout << "Alice" << endl;
    }
    else if(b > a){
      cout << "Bob" << endl;
    }
    else {
      cout << "Draw" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp85
{
    class Program
    {
        static void Main(string[] args)
        {
            int X = int.Parse(Console.ReadLine());
            int A = int.Parse(Console.ReadLine());
            int B = int.Parse(Console.ReadLine());

            int first;
            first = X - A;
            int answer;
            answer = first % B;

            Console.WriteLine(answer);

        }
    }
}


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

int main(){
  int N; cin >> N;
  vector<int> MY(2*N);
  for(int i=0;i<2*N;i++){
    cin >> MY.at(i);
  }
  sort(MY.begin(), MY.end());
  int count=0;
  for(int i=0;i<2*N-1;i+=2){
    count+=MY.at(i);
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long hoge = 1000000007;

int main(){
  int n, m, head = 0;
  // 標準入力
  cin >> n >> m;

  int a[m+1];
  long long s[n+1];
  for ( int i = 0; i < m; i++){ cin >> a[i];}
  a[m] = -1;
  a[m+1] = -1;

  // init
  for ( int i = 0; i <= n; i++){ s[i] = 0;}

  // 1段目
  s[0] = 1;
  s[1] = 1;
  // 2段目から始める
  for ( int i = 2; i <= n; i++){
    if (i == a[head] || i == a[head+1]) {
    s[i] = 0;
    }
    
    if (i-2 == a[head] && i-1 == a[head+1]){
      s[i] = 0;
      break;
    } else if (i-2 == a[head] && i-1 != a[head+1]){
      s[i] = s[i-1];
      head++;
    } else if (i-2 != a[head] && i-1 == a[head]){
      s[i] = s[i-2];
    } else {
      s[i] = s[i-2] + s[i-1];
    }

   s[i] = s[i]%hoge;
  }

  cout << s[n]%hoge << endl;

  return 0;
}


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

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long LL;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

void print(int* A, int n) {
    REP(i, n) {
        if (i > 0) cout << " ";

        cout << A[i];
    }
    cout << endl;
}

void coutingSort(int* A, int* B, int n, int k=10000) {
    int C[k];
    REP(i, k) C[i] = 0;

    REP(i, n) {
        ++C[A[i]];
    }

    FOR(i, 1, k) {
        C[i] += C[i - 1];
    }

    REP(i, n) {
        B[--C[A[i]]] = A[i];
    }
}

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

    int n; cin >> n;

    int A[n];
    REP(i, n) cin >> A[i];

    int B[n];

    coutingSort(A, B, n);

    print(B, n);
}



Measured memory_bytes: 18792
import math
a, b, C = map(float, input().split())
θ=math.radians(C)
h=b*math.sin(θ)
S=(a*h)/2
c=math.sqrt(a**2+b**2-2*a*b*math.cos(θ))
L=a+b+c
print(S, L, h, sep="\n")


Measured memory_bytes: 5756
#include <stdio.h>
#include <string.h>

int main()
{
	char name[51][101];
	//memset(name, '\0', (sizeof name));
	char slpname[100];
	int time[51];
	memset(time, 0, (sizeof time));
	int N;
	scanf("%d",&N);
	for (int x = 0; x < N; x++) {
		scanf("%s %d", name[x],&time[x]);
	}
	scanf("%s", slpname);
	int num = 0;
	for (int p = num; p < N; p++) {
		if (strcmp(name[p],slpname)==0) {
			num = p;
			break;
		}
	}
	int ans = 0;
	ans =(-1)*time[num];
	for (num; num < N; num++) {
		ans += time[num];
	}
	printf("%d", ans);
	return 0;
}


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

using namespace std;

#ifdef WIN32
	#define I64 "%I64d"
#else
	#define I64 "%lld"
#endif

typedef long long ll;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(s) s.begin(), s.end()
#define sz(s) (int(s.size()))
#define fname "a"
#define MAXN 101
#define MOD 1000000007

inline int add(int a, int b) {
	a += b;
	if (a >= MOD) a -= MOD;
	return a;
}

inline int sub(int a, int b) {
	a -= b;
	if (a < 0) a += MOD;
	return a;
}

inline int mult(int a, int b) {
	return (1LL * a * b) % MOD;
}

inline int power(int a, int b) {
	int r = 1;
	while(b) {
		if (b & 1) r = mult(r, a);
		a = mult(a, a);
		b >>= 1;
	}
	return r;
}

int n;
char s1[MAXN];
char s2[MAXN];
int d[MAXN][11];

int main()
{
	#ifdef LOCAL
	freopen(fname".in", "r", stdin);
	freopen(fname".out", "w", stdout);
	#endif

	scanf("%d", &n);
	scanf("%s", s1);
	scanf("%s", s2);
	vector <int> a;
	for (int i = 0; i < n; ++i) {
		if (s1[i] == s2[i]) {
			a.pb(1);
		} else {
			a.pb(2);
			++i;
		}
	}

	n = sz(a);
	if (a[0] == 1) {
		d[0][0] = d[0][1] = d[0][2] = 1;
	} else {
		for (int j = 0; j < 6; ++j)
			d[0][j] = 1;
	}
	for (int i = 1; i < n; ++i) {
		if (a[i] == 1) {
			if (a[i - 1] == 1) {
				for (int j = 0; j < 3; ++j)
					for (int k = 0; k < 3; ++k)
						if (j != k)
							d[i][j] = add(d[i][j], d[i - 1][k]);
			} else {
				for (int j = 0; j < 3; ++j) {
					int k = 0;
					for (int k1 = 0; k1 < 3; ++k1)
						for (int k2 = 0; k2 < 3; ++k2) {
						   if (k1 == k2) continue;
						   if (j != k1 && j != k2)
								d[i][j] = add(d[i][j], d[i - 1][k]);
							++k;
						}
				}
			}
		} else {
			if (a[i - 1] == 1) {
				int k = 0;
				for (int k1 = 0; k1 < 3; ++k1)
					for (int k2 = 0; k2 < 3; ++k2) {
					   if (k1 == k2) continue;
					   for (int j = 0; j < 3; ++j)
					   	if (j != k1 && j != k2)
								d[i][k] = add(d[i][k], d[i - 1][j]);
						++k;
					}
			} else {
				int k = 0;
				for (int k1 = 0; k1 < 3; ++k1)
					for (int k2 = 0; k2 < 3; ++k2) {
					   if (k1 == k2) continue;
					   int l = 0;
						for (int l1 = 0; l1 < 3; ++l1)
							for (int l2 = 0; l2 < 3; ++l2) {
								if (l1 == l2) continue;
								if (k1 != l1 && k2 != l2)
									d[i][k] = add(d[i][k], d[i - 1][l]);
								++l;
							}
						++k;
					}
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < 6; ++i)
		ans = add(ans, d[n - 1][i]);
	printf("%d\n", ans);
	
	return 0;        
}


Measured memory_bytes: 256
N, K = map(int, input().split())
x = list(map(int, input().split()))
ans = 3*10**8

for i in range(N-K+1):
    ans1 = abs(x[i])+abs(x[i]-x[i+K-1])
    ans2 = abs(x[i+K-1])+abs(x[i]-x[i+K-1])
    ans = min(ans, ans1, ans2)
print(ans)

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

int main() {
  int n, k;
  cin >> n;
  cin >> k;
  int d = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x <= k / 2) {
      d += 2 * x;
    } else {
      d += 2 * (k - x);
    }
  }
  cout << d << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int min(int a, int b){
  return a<b?a:b;
}
int main(){
  int n,K;
  cin >> n;
  cin >> K;
  int dp[n],val[n];
  for(int i=0;i<n;i++){
  	cin >> val[i];
  }
  for (int i = 0; i < n; ++i)
  {
  	if(i == 0){
  		dp[0] = 0;
  		//printf("%d ",dp[i] );
  	}
  	else if(i == 1){
  		dp[1] = abs(val[1] - val[0]);
  		//printf("%d ",dp[i] );
  	}
  	else{
      int cur_min = INT_MAX;
      for(int j=1; j<=K && i-j >= 0 ; j++)
        if(cur_min > dp[i-j]+abs(val[i]-val[i-j])) cur_min = dp[i-j]+abs(val[i]-val[i-j]);

	  	dp[i] = cur_min;
	  	//printf("%d ",dp[i] );
  	}
  }
  printf("%d\n",dp[n-1] );
  return 0;
}

Measured memory_bytes: 1024
S=input()
q=int(input())
rev=False
pre=''

for i in range(q):
    inp=input()
    if inp[0]=="1":
        rev=not rev
    else:
        t,f,c=inp.split()
        if (f=='1' and rev) or (f=='2' and not rev):
            S+=c
        else:
            pre+=c
if not rev:
    print(''.join(list(reversed(pre)))+S)
else:
    print(''.join(list(reversed(S)))+pre)

Measured memory_bytes: 5188
#pragma region macro
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

namespace std {
template <typename A, typename B>
string to_string(pair<A, B> 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) + ")";
}
};  // namespace std
#pragma endregion

void solve() {
    std::vector<int> a(5);
    rep(i, 5) std::cin >> a[i];
    int tmp = 0;
    rep(i, 5) tmp += (a[i] + 10 - 1) / 10 * 10;
    int ans = 1e9;
    rep(i, 5) {
        ans = std::min(ans, tmp - (a[i] + 10 - 1) / 10 * 10 + a[i]);
    }
    std::cout << ans << std::endl;
}

int main() {
    // std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}


Measured memory_bytes: 256
// Problem B

#include <stdio.h>
#include <iostream>
#include <vector>
#include <string.h>
#include <cassert>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <queue>
#include <stack>

#define MAXN 1000
#define pb push_back
#define mp make_pair

using namespace std;

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

int n;
ll a;
ll res;

int main() {
  cin >> n;
  res = (ll)1;
  bool ok = true;
  bool zero = false;
  for (int i=0; i<n; i++) {
    cin >> a;
    
    if (a == 0) {
      zero = true;
      continue;
    }
    if (zero) continue;
    if (!ok) continue;
    
    if (double(a)*double(res) > (double)2000000000000000000) ok = false;
    else if (res*a > 1000000000000000000) ok = false;
    else res = res * a;
  }
  
  if (zero) cout << "0\n";
  else if (!ok) cout << "-1\n";
  else cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 1e5+123;
int a[maxn];
int ans = 0;
int cnt[maxn];
bool was[maxn];
int main()
{
	ll n;
	cin >> n;
	if(n % 2 == 0)
	{
		cout << n;
	}else cout << n * 2;
	return 0;
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  bool can = false;
  for (int i = 1; i <= B; i++) {
    if (A*i % B == C) {
      can = true;
      break;
    }
  }
  if (can) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <stack>
#include <limits>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <numeric>
//#include <tuple>

constexpr long long mod = static_cast<long long>(1e9 + 7);

int main() {
    int V, E;
    std::cin >> V >> E;

    std::vector<std::vector<int>> edges(V, std::vector<int>());
    std::vector<int> ins(V, 0);
    std::vector<bool> memo(V, false);

    while(E--){
        int s, t;
        std::cin >> s >> t;
        edges[s].push_back(t);
        ++ins[t];
    }

    std::vector<int> ans;
    ans.reserve(V);

    for(int i = 0; i < V; ++i) {
        if(!memo[i] && ins[i] == 0) {

            std::queue<int> que;
            que.push(i);
            while(!que.empty()) {
                int v = que.front();
                que.pop();
                ans.push_back(v);
                memo[v] = true;

                for(auto val: edges[v]) {
                    --ins[val];
                    if(!memo[val] && ins[val] == 0) {
                        que.push(val);
                    }
                }

            }

        }
    }

    for(int i = 0; i < ans.size(); ++i) {
        std::cout << ans[i];
        if(i < ans.size() - 1) std::cout << " ";
    }

    std::cout << std::flush;

    return 0;
}



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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    
    if (a < b) swap(a, b);
    if (a < c) swap(a, c);
    if (b < c) swap(b, c);
    
    cout << (a == b + c ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vec<vec<int>> adj(N, vec<int>());
    range(i, 0, M) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        adj.at(u).emplace_back(v);
    }
    int S, T;
    cin >> S >> T;
    S--; T--;
    vec<vec<int>> min_steps(N, vec<int>(3, INT_MAX));
    min_steps.at(S).at(0) = 0;
    deque<pint> que;
    que.emplace_back(S, 0);
    while (!que.empty()) {
        int node = que.front().first;
        int step = que.front().second;
        que.pop_front();
        int offset = (step + 1) % 3;
        for (const int neighbor : adj.at(node)) {
            if (min_steps.at(neighbor).at(offset) == INT_MAX) {
                que.emplace_back(neighbor, step + 1);
            }
            min_steps.at(neighbor).at(offset) = min(min_steps.at(neighbor).at(offset), step + 1);
        }
    }
    int result = min_steps.at(T).at(0);
    cout << (result == INT_MAX ? -1 : result / 3) << "\n";
}


Measured memory_bytes: 11264
#!/usr/bin/env python3
import sys


def solve(N: int):
    n = 0
    for c in range(1, N):
        if N % c == 0:
            n += N // c - 1
        else:
            n += N // c
    print(n)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b) {
    while (b) {
        a%=b;
        swap(a,b);
    }
    return a;
}
int main ()
{
    int a,b,c;
    cin>>a>>b>>c;
    if (c% gcd(a,b)==0){
        cout<<"YES"<<endl;
    }
    else {
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 256
using System;

class RingosFavoriteNumbers{
    static void Main(string[] args){
        var dn = Console.ReadLine().Split(' ');
        var d = int.Parse(dn[0]);
        var n = int.Parse(dn[1]);

        if(n == 100){
            n = 101;
        }

        var result = n * (int)Math.Pow(100, d);
        Console.WriteLine(result);
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define MAX_V 200
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POSSIBLE(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Possible(i) cout<<(i?"Possible":"Impossible")<<endl
#define Yay(i) cout<<(i?"Yay!":":(")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=998244353;
//
struct poi{
	int X;int Y;int Z;
	bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
//
ll GCD(ll A,ll B){
  return (B==0)?(A):(GCD(B,A%B));
}
ll LCM(ll A,ll B){
  return A/GCD(A,B)*B;
}
//
//2部マッチング
int V;//頂点数
VE G[MAX_V];//グラフ隣接リスト表現
int match[MAX_V];//マッチングのペア
bool used[MAX_V];//フラグ
//
void add_edge(int from,int to){
  G[from].PB(to);
  G[to].PB(from);
}
//増加パスを探す
bool DFS(int v){
  used[v]=true;
  FOR(i,0,(int)G[v].size()){
    int u=G[v][i],w=match[u];
    if(w<0||!used[w]&&DFS(w)){
      match[v]=u;
      match[u]=v;
      return true;
    }
  }
  return false;
}
//最大マッチング
int bipartite_matching(){
  int res=0;
  fill(match,match+MAX_V,-1);
  FOR(v,0,V){
    if(match[v]<0){
    	fill(used,used+MAX_V,0);
      if(DFS(v)){
        res++;
      }
    }
  }
  return res;
}

int main(){
	int N;
	cin>>N;
	V=N*2;
	int X[200],Y[200];
	FOR(i,0,N*2){
		cin>>X[i]>>Y[i];
	}
	FOR(i,0,N){
		FOR(j,N,2*N){
			if(X[i]<X[j]&&Y[i]<Y[j]){
				add_edge(i,j);
			}
		}
	}
	cout<<bipartite_matching()<<endl;
	return 0;
}

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

using namespace std;

const auto MOD = (long long) 1e9 + 7;

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

    long long ans = 1;
    for (int i = 1; i <= n; ++i) {
        ans *= i;
        ans %= MOD;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np

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

w = [ 0 ] * n
v = [ 0 ] * n
for i in range( n ):
    w[ i ], v[ i ] = map( int, input().split() )

dp = np.zeros( ww+1 )
dp = dp.astype( "int64" )
for ni in range( n ):
    dp[ w[ ni ]: ] = np.maximum( dp[ w[ ni ]: ], dp[ :-w[ ni ] ]+v[ ni ] )
#    print( dp )

print( dp[ -1 ] )



Measured memory_bytes: 14792
n = int(input())
H = list(map(int, input().split()))

dp = [0]*n
dp[1] = abs(H[1] - H[0])

for i in range(2,n):
    dp[i] = min(dp[i-1] + abs(H[i] - H[i-1]), dp[i-2] + abs(H[i] - H[i-2]))

print(dp[-1])


Measured memory_bytes: 84968
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

int N, M, z, x, y;
int Rank[100001];
int parent[100001];

int find(int x);
bool isSame(int x, int y);
void unite(int x, int y);


int main() {
    cin >> N >> M;
    
    for (int i = 1; i <= N; i++ ) {
        Rank[i] = 0;
        parent[i] = i;
    }

    for (int i = 0; i < M; i++) {
        cin >> x >> y >> z;
        
        if (isSame(x, y)) continue;

        unite(x, y);
    }
    
    int ans = 0;
    for (int i = 1 ;  i <= N; i++) {
        if (parent[i] == i)
            ans++;
        //cout << parent[i] << '\n';
        
    }
    cout << ans << '\n';
}


int find(int x) {
    if (x == parent[x]) return x;
    else {
        return parent[x] = find(parent[x]);
    }
}

bool isSame(int x, int y) {
    return find(x) == find(y);
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);

    if (x == y) return;

    if (Rank[x] < Rank[y]) {
        parent[x] = y;
    } 
    else {
        parent[y] = x;
        if (Rank[x] == Rank[y]) 
            Rank[x]++;
    }
}



Measured memory_bytes: 1024
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

def bin_search(target, numbers):
    first = 0
    last = len(numbers)
    while first < last:
        mid = (first + last) // 2
        if target < numbers[mid]: last = mid
        elif target > numbers[mid]: first = mid + 1
        else: return mid
    return False

result = 0
for t in T:
    if bin_search(t, S):
        result += 1
        continue
print(result)


Measured memory_bytes: 16716
3.times do
n=gets.split.map(&:to_i)

intime=n[0]*3600+n[1]*60+n[2]
outtime=n[3]*3600+n[4]*60+n[5]
res=outtime-intime
h=res/3600
m=res%3600/60
s=res%60

printf "%d %d %d\n",h,m,s

end

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;

template<class T> void gc(T &x)
{
    char c;
    int s = 0;
    x = 0;

    c = getchar_unlocked();

    if (c == '-') s = 1;
    else if ('0' <= c && c <= '9')  x = c - '0';

    while (true)
    {
        c = getchar_unlocked();

        if (c < '0' || '9' < c) break;
        x = x * 10 + (c - '0');
    }

    if (s) x = -x;
}

int main()
{
    const int HW_MAX = 300 * 300;
    int H, W, D;

    gc(H);
    gc(W);
    gc(D);

    int x[HW_MAX];
    int y[HW_MAX];

    int A;
    REP (i, H)
    {
        REP (j, W)
        {
            gc(A);

            // 0-indexed
            A--;

            y[A] = i;
            x[A] = j;
        }
    }

    int d[HW_MAX];
    FOR (i, D, HW_MAX)
    {
        d[i] = d[i - D] + abs(x[i] - x[i - D]) + abs(y[i] - y[i - D]);
    }

    int Q;
    gc(Q);

    int L, R;
    int ans;
    while (Q--)
    {
        gc(L);
        gc(R);

        // 0-indexed
        L--;
        R--;

        ans = d[R] - d[L];
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main() {
    
    int N, M, Q;
    cin >> N >> M >> Q;
    
    vector<vector<int>> B(N + 1, vector<int>(N + 1, 0));
    for (int i = 0; i < M; i++) {
        int L, R;
        cin >> L >> R;
        B[L][R]++;
    }
    
    for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) B[i + 1][j + 1] += B[i][j + 1] + B[i + 1][j] - B[i][j];
    
    for (int i = 0; i < Q; i++) {
        int p, q;
        cin >> p >> q;
        int ans = B[q][q] - B[p - 1][q] - B[q][p - 1] + B[p - 1][p - 1];
        cout << ans << endl;
    }
    
    return 0;
}



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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;
typedef unsigned long long ULL;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

LL cities[7];

void solve()
{
  LL N; cin >> N;
  LL bottleneck = LLINF;
  RREP1(dist, 5)
  {
      LL cap; cin >> cap;
      if (cap < bottleneck)
      {
        bottleneck = cap;
      }
  }
  LL cost = N / bottleneck + (N%bottleneck!=0);
  cout << cost + 4 << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 1000000
#define Q 50000
int n,S[N],T[Q];

int binarySearch(int key)
{
  int left = 0,right = n,mid;
  while(left < right){
    mid = (left+right)/2;
    if(S[mid] == key) return 1;
    else if(key < S[mid]) right = mid;
    else left = mid+1;
  }
  return 0;
}

int main()
{
  
  int i,j,q,c=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
    if(binarySearch(T[i])==1) c++;
  }
   
  printf("%d\n",c);
  
  return 0;
}

Measured memory_bytes: 1184
from bisect import bisect_left as bl,bisect_right as br
n,a,b=map(int,input().split())
l=[]
a=a-b
for _ in range(n):
    l.append(int(input()))
l.sort()
def enough(t):
    global l,a,b,n
    ans=0
    for i in range(br(l,b*t),n):
        ans-=(-l[i]+b*t)//a
    return ans<=t
ub,lb=-(-l[-1]//b),-1
while ub-lb>1:
    if enough((ub+lb)//2):ub=(ub+lb)//2
    else:lb=(ub+lb)//2
print(ub)

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

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    for (int i=0; i<N; i++) cin >> d[i];
    ll ans = 0;
    for (int i=0; i<N-1; i++) {
        for (int j=i+1; j<N; j++) {
            ans += d[i]*d[j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
#include<algorithm>

using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    REP(i, n) cin >> l[i];
    sort(l.begin(), l.end(), greater<int>());
    int ans = 0;
    REP(i, k) ans += l[i];
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

int main() {
	int n, m;
	std::cin >> n >> m;

	std::vector<int> d(n);
	for (int i = 0; i < m; i++) {
		int u, v;
		std::cin >> u >> v;
		d[u - 1]++;
		d[v - 1]++;
	}
	for (int i = 0; i < n; i++) {
		std::cout << d[i] << std::endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n;
    scanf("%d",&n);
    int flag=0;
    for(int i=0;i<=n/4;i++){
        for(int j=0;j<=n/7;j++){
            if(4*i+7*j==n){
                flag = 1;
                break;
            }
        }
        if(flag==1) break;
    }
    if(flag==0) printf("No\n");
    if(flag==1) printf("Yes\n");
    return 0;
}

Measured memory_bytes: 128
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

int main(int argc, char* argv[]) {
	cout.precision(20);
#ifdef _MSC_VER
	while (true)
#endif
	{
		int x = -1;
		cin >> x;
		if (x <= 0) return 0;
		vector<int> dp(100001);
		dp[0] = 1;
		for (int i = 100; i <= 105; ++i) {
			for (int j = i; j <= x; ++j) {
				if (dp[j - i]) {
					dp[j] = 1;
				}
			}
		}
		cout << dp[x] << endl;
	}
	return 0;
}


Measured memory_bytes: 640
n,m=list(map(int,input().split(" ")))
 
arr=list(map(int,input().split(" ")))

def bfs(start,n,visited,m):
	
	moves=[]
	moves.append(start)
	visited[start]=1
	br=-1
	# fl=0
	while(True):

		j=arr[start]-1
		
		if(visited[j]==0):
			moves.append(j)
			visited[j]=1
		
		else:
			br=j
			# fl=1
			break
		start=j


	# print(moves,left)
		# q.popleft()
	# print(left,moves)
	if(br!=-1):
		pre=[]
		post=[]
		for i in range(len(moves)):
			if(moves[i]==br):
				pre=moves[:i]
				post=moves[i:]
				break
		if(m<=len(pre)-1):
			print(pre[m]+1)
		else:
			m-=len(pre)
			# print

			print(post[m%len(post)]+1)


	else:
		# curr=0
		# print("hdks")
		print(moves[m%len(moves)]+1)
visited=[0]*n
bfs(0,n,visited,m)

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

using namespace std;

int main() {
    string S;
    int cnt = 1;
    cin >> S;
    for (int i=0; i < S.size(); ++i) {
        if (cnt%2 == 1 && S.substr(i, 1) == "L") {
            cout << "No";
            return 0;
        }
        else if (cnt%2 == 0 && S.substr(i, 1) == "R") {
            cout << "No";
            return 0;
        }
        ++cnt;
    }
    cout << "Yes";
}


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

int main(int argc , char **argv)
{
	(void)argc;
	(void)argv;

	char s[100001] = {};
	cin >> s;
	size_t lng = strlen(s);
	for(unsigned int i=0;i<lng;i++){
		if (i%2==0){
			cout << s[i];
		}
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 384
#!/usr/bin/env python3
import sys
INF = 1<<32

def solve(N: int, W: int, w: "List[int]", v: "List[int]"):
    dp = [[INF] * (max(v)*N+1) for i in range(N+1)]
    dp[0][0] = 0

    for i in range(N):
        for sumv in range(max(v)*N+1):
            if(sumv - v[i-1] >= 0):
                dp[i+1][sumv] = min(dp[i][sumv], dp[i][sumv-v[i-1]] + w[i-1])
            else:
                dp[i+1][sumv] = dp[i][sumv]

    ans = 0
    for i in range(max(v)*N+1):
        if(dp[N][i] <= W): ans = i

    # for i in dp:
    #     print(i)

    print(ans)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    w = [int()] * (N)  # type: "List[int]" 
    v = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        w[i] = int(next(tokens))
        v[i] = int(next(tokens))
    solve(N, W, w, v)

if __name__ == '__main__':
    main()


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


int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0;i < n ;i ++){
        cin >> h.at(i);
    }

    int ans = h.at(0);
    for(int i = 1;i < n ; i ++){
        if(h.at(i) > h.at(i-1)){
            ans += h.at(i)-h.at(i-1);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (4) << f << endl; Prints x.xxxx

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

ll inv[100003],mult[100003],invmult[100003],a[100003],coun[100003];
ll gcd(ll a,ll b){
	while(b!=0){
		
		a=a%b;
		swap(a,b);
	}
	return a;
}

ll extend_gcd(ll a,ll b,ll &x,ll &y){
	if(b==0){
		x=1;
		y=0;
		return a;
	}
	ll x1,y1;
	ll ans =extend_gcd(b,a%b,x1,y1);
	x=y1;
	y=x1-(a/b)*y1;

	return ans;
}
ll combination(ll n,ll r){
	if(r==0)
		return 1;
	if(n<r)
		return 0;
	ll ans=1;
	ans*=mult[n];
	ans%=mod;
	ans*=invmult[r];
	ans%=mod;
	ans*=invmult[n-r];
	ans%=mod;
	return ans;
}

ll initcombi(){
	int i;
	f(i,1,100002){
		ll x,y;
		ll val=extend_gcd(mod,i,x,y);
		if(y>0)
			inv[i]=y%mod;
		else{
				inv[i]=(y+mod)%mod;
		}
	}
	mult[0]=1;
	f(i,1,100002){
		mult[i]=mult[i-1]*i;
		mult[i]%=mod;
	}
	invmult[0]=1;
	f(i,1,100002){
		invmult[i]=invmult[i-1]*inv[i];
		invmult[i]%=mod;
	}
	return 0;
}


// do initcombi();
int main()
{
	ll n,i,ans=0,val,val1;
	cin>>n;
	initcombi();
	f(i,1,n+2)
	{
		cin>>a[i];
		coun[a[i]]++;
		if(coun[a[i]]==2)
			val=i;
	}
	f(i,1,n+2)
	{
		if(a[i]==a[val])
		{
			val1=i;
			break;
		}
	}
	//cout<<val<<endl;
	//cout<<combination(n+1,2)<<endl;
	//return 0;
	//cout<<ans<<" ";
	for(i=1;i<=n+1;i++)
	{
		//cout<<
		ans=combination(n+1,i);
		//cout<<ans<<" ";
		ans-=combination(n+1-val+val1-1,i-1);
		//ans+=combination(n+1-val,i-1);
		ans%=mod;
		ans+=mod;
		ans%=mod;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 5120
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        StringBuilder s1 = new StringBuilder(s.substring(0,s.length()/2));
        s1.reverse();
        StringBuilder s2;
        if (s.length()%2==0)s2=new StringBuilder(s.substring(s.length()/2));
        else s2 = new StringBuilder(s.substring(s.length()/2+1));
        int ans = 0;
        for (int i=0;i<s1.length();i++)if (s1.charAt(i)!=s2.charAt(i))ans++;
        System.out.println(ans);
    }

}


Measured memory_bytes: 35628
import collections
n = int(input())
list_in = list(map(int, input().split()))
q = int(input())

counter = collections.Counter(list_in)
sum = sum(list_in)

for i in range(q):
    bc = list(map(int, input().split()))
#    list_in = [bc[1] if list_in[l] == bc[0] else list_in[l] for l in range(n)]
    sum_diff = (bc[1] - bc[0]) * counter[bc[0]]
    counter[bc[1]] = counter[bc[1]] + counter[bc[0]]
    counter[bc[0]] = 0
    print(sum+sum_diff)
    sum = sum + sum_diff

Measured memory_bytes: 24112
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int main(){
  int n = getInt();
  int l = getInt();

  vector<int> a(n);

  REP(i,n) a[i] = getInt();

  typedef pair<int,int> task;
  priority_queue<task,vector<task>,greater<task> > pq;

  REP(i,n){
    if(i == 0){ if(a[0] > a[1]) pq.push(mp(l - a[i], i)); }
    else if(i == n - 1){ if(a[n-1] > a[n-2]) pq.push(mp(l - a[i], i)); }
    else if(a[i-1] < a[i] && a[i+1] < a[i]) pq.push(mp(l - a[i], i));
  }

  int ans = 0;
  while(pq.size()){
    task t = pq.top(); pq.pop();
    int tm = t.f; ans = tm;
    int nn = t.s;

    a[nn] = 0;

    if(nn != 0){
      int i = nn - 1;
      if(a[i] > 0){
        if(i == 0){ if(a[0] > a[1]) pq.push(mp(tm + l - a[i], i)); }
        else if(i == n - 1){ if(a[n-1] > a[n-2]) pq.push(mp(tm + l - a[i], i)); }
        else if(a[i-1] < a[i] && a[i+1] < a[i]) pq.push(mp(tm + l - a[i], i));
      }
    }

    if(nn != n - 1){
      int i = nn + 1;
      if(a[i] > 0){
        if(i == 0){ if(a[0] > a[1]) pq.push(mp(tm + l - a[i], i)); }
        else if(i == n - 1){ if(a[n-1] > a[n-2]) pq.push(mp(tm + l - a[i], i)); }
        else if(a[i-1] < a[i] && a[i+1] < a[i]) pq.push(mp(tm + l - a[i], i));
      }
    }
  }

  print(ans);

  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int T = sc.nextInt();
    int A = sc.nextInt();
    int cnt = 0;
    double min = Double.MAX_VALUE;
    for (int i = 0; i < N; i++) {
      double B = Math.abs(A - (T - sc.nextInt() * 0.006));
      if (B < min) {
        min = B;
        cnt = i + 1;
      }
    }
    System.out.println(cnt);
  }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
long long int INF = 1e+10;
int Nv = 1e+5;

int main()
{
  int N, W;
  cin >> N >> W;
  int w[N + 1], v[N + 1];
  for (int i = 1; i <= N; i++)
  {
    cin >> w[i] >> v[i];
  }

  long long int dp[N + 1][int(1e+5) + 1];
  for (int i = 0; i < N + 1; i++)
  {
    for (int j = 0; j < Nv + 1; j++)
    {
      dp[i][j] = INF;
    }
  }
  dp[1][0] = 0;
  dp[1][v[1]] = w[1];

  for (int i = 1; i <= N - 1; i++)
  {
    for (int j = 0; j <= Nv; j++)
    {
      if (dp[i][j] != INF)
      {
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
        if (dp[i][j] + w[i + 1] <= W)
        {
          dp[i + 1][j + v[i + 1]] =
              min(dp[i + 1][j + v[i + 1]],
                  dp[i][j] + w[i + 1]);
        }
      }
    }
  }
  int max_v;
  for (int j = 0; j <= Nv; j++)
  {
    if (dp[N][j] != INF)
      max_v = j;
  }

  cout << max_v << endl;
}

Measured memory_bytes: 79104