akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>
#include <atcoder/all>
 
using namespace std;
using namespace atcoder;
 
/* template */
 
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
 
#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};
 
struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};
 
using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

template <class T>
inline bool chmin(T &a, T b){
    if (a > b){
        a = b;
        return true;
    }
    return false;
}
 
template <class T>
inline bool chmax(T &a, T b){
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
 
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
 
constexpr ll LNF = 1LL<<50;
 
constexpr int INF = 1e9+7;
 
const long double PI=acos(-1);

vector<int> dx = {1,0,-1,0};
vector<int> dy = {0,1,0,-1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k; cin >> k;
    string a = "ACL";
    string ans = "";
    rep(i,0,k){
        ans += a;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define fir first
#define sec second
#define mod 998244353
#define ll long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
inline int min(int x,int y,int z){return min(x,min(y,z));}
inline int max(int x,int y,int z){return max(x,max(y,z));}
inline int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
inline int add(int x,int y,int z){return add(add(x,y),z);}
inline int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
inline int mul(int x,int y){return 1LL*x*y%mod;}
inline int mul(int x,int y,int z){return mul(mul(x,y),z);}
#define N 505
int a[N][N],b[N][N],n;
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
void dfs(int x,int y)
{
	for(int i=0;i<4;i++)
	{
		int tx=x+dx[i],ty=y+dy[i];
		if(tx<1||tx>n||ty<1||ty>n) continue;
		if(a[x][y]+b[x][y]<a[tx][ty])
		{
			a[tx][ty]=a[x][y]+b[x][y];
			dfs(tx,ty);
		}
	}
}
signed main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			a[i][j]=min(i-1,j-1,min(n-i,n-j));
			b[i][j]=1;
		}
	}
	int ans=0;
	for(int i=1;i<=n*n;i++)
	{
		int u=read();
		int x=(u+n-1)/n,y=(u-1)%n+1;
		ans+=a[x][y]; b[x][y]=0;
		dfs(x,y);
	}
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 24344
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
	public static void main (String[] args) {
		//code
		Scanner in=new Scanner(System.in);
		int n,x,t;
      	n=in.nextInt();
      	x=in.nextInt();
      	t=in.nextInt();
      	int ans=(int)Math.ceil((double)n/x)*t;
      	System.out.println(ans);
	}
}


Measured memory_bytes: 35588
# -*- coding: utf-8 -*-

primes = [2]
i = 3
count = 1
while count < 10000:
    flag = True
    for p in primes:
        if i % p == 0:
            flag = False
            break
    if flag:
        primes.append(i)
        count += 1
    i += 1

while True:
    n = int(raw_input())
    if n == 0:
        break
    sum = 0
    for i in range(n):
        sum += primes[i]
    print sum

Measured memory_bytes: 6852
import java.util.Scanner;

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

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int S = scanner.nextInt();
        int W = scanner.nextInt();
        if(S <= W) {
            System.out.println("unsafe");
        }else{
            System.out.println("safe");
        }

    }
}


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

int main()
{
  int con1, con2, award;
  award = 0;

  cin >> con1 >> con2;

  if(con1 == 3)
  {
    award += 100000;
  }

  else if(con1 == 2)
  {
    award += 200000;
  }

  else if(con1 == 1)
  {
    award += 300000;
  }

  if(con2 == 3)
  {
    award += 100000;
  }
  else if(con2 == 2)
  {
    award += 200000;
  }
  else if(con2 == 1)
  {
    award += 300000;
  }

  if(con1 == 1 && con2 == 1)
  {
    award += 400000;
  }

  cout << award << endl;
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	is >> p.first >> p.second;
	return (is);
}

int main() {
	ll X, Y, Z, N;
	cin >> X >> Y >> Z; N = X + Y + Z;
	vector<pair<ll, tuple<ll, ll, ll>>> data(N);

	for (int i = 0; i < N; i++) {
		ll A, B, C;
		cin >> A >> B >> C;
		data[i] = make_pair(B - A, tie(A, B, C));
	}
	sort(begin(data), end(data));

	vll sumg(N, 0), sums(N, 0);
	priority_queue<ll> que;
	for (int i = 0; i < X; i++) {
		ll A = get<0>(data[i].second);
		ll C = get<2>(data[i].second);
		sumg[X-1] += A;
		que.push(C-A);
	}

	for (int i = X; i < X+Z; i++) {
		ll value = que.top();
		ll A = get<0>(data[i].second);
		ll C = get<2>(data[i].second);
		sumg[i] += sumg[i-1];

		if (C-A < value) {
			que.pop();
			sumg[i] += value;
			sumg[i] += A;
			que.push(C-A);
		} else {
			sumg[i] += C;
		}
	}
	while (!que.empty()) que.pop();	

	for (int i = N-1; i >= N-Y; i--) {
		ll B = get<1>(data[i].second);
		ll C = get<2>(data[i].second);
		sums[N-Y] += B;
		que.push(C-B);
	}

	for (int i = N-Y-1; i >= N-Y-Z; i--) {
		ll value = que.top();
		ll B = get<1>(data[i].second);
		ll C = get<2>(data[i].second);
		sums[i] += sums[i+1];

		if (C-B < value) {
			que.pop();
			sums[i] += value;
			sums[i] += B;
			que.push(C-B);
		} else {
			sums[i] += C;
		}
	}
	ll maxv = -LLINF;
	for (int i = X; i <= X+Z; i++) {
		chmax(maxv, sumg[i-1] + sums[i]);
	}
	cout << maxv << endl;
	return (0);
}


Measured memory_bytes: 6136
#include <cstdio>

int N, ans, a[105];

int first(int x) {
  while (x >= 10) x /= 10;
  return x;
}

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

  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= N; j++) {
      if (first(i) == j%10 && i%10 == first(j)) {
        a[i]++;
      }
    }
  }

  for (int i = 1; i <= N; i++) {
    int x = first(i) * 10 + i % 10;
    ans += a[x];
  }

  printf("%d", ans);
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>
#include <bitset>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;



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

  ll N;
  cin >> N;

  unordered_map<ll, vector<P>> evidence;
  REP(i,N){
    ll Ai;
    cin >> Ai;
    vector<P> e(Ai);
    REP(j, Ai){
      ll x, y;
      cin >> x >> y;
      e[j] = P(x-1,y);
    }
    evidence[i] = e;
  }


  ll ans = 0;
  REP(state,1<<N){
    ll contradict = false;
    // check
    REP(i,N){
      if ((state>>i)&1 != 0){
        for (P& p : evidence[i]){
          if ((state&(1<<p.first))>0 && p.second==0){
            contradict = true;
          }; 
          if ((state&(1<<p.first))==0 && p.second==1){
            contradict = true;
          }
         }
      }
      if (contradict) break;
    }

    if (!contradict){
       ans = max(ans, (ll)std::bitset<15>(state).count());
    }
  }

  cout << ans << "\n";
  return 0;
}


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

int N, T;
int t[200010];

int main() {
  cin >> N >> T;
  for (int i=0; i<N; i++) cin >> t[i];
  int ans = T;
  int _time = T;
  for (int i=1; i<N; i++) {
    if (t[i] + T < _time) continue;
    if (t[i] < _time) ans -= _time - t[i];
    _time = t[i] + T;
    ans += T;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
while True:
    try:
        f = float(input())
    except:
        break
    l = [0] * 11
    l[1] = f
    for i in range(2,11):
        if i % 2 == 0:
            l[i] = l[i-1] * 2
        else:
            l[i] = l[i-1] / 3

    print(sum(l))

Measured memory_bytes: 6744
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 1145141919
#define MOD 1000000007
#define ALL(a) begin((a)),end((a))
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int main()
{
	int h;
	while (cin >> h, h)
	{
		int tmp[11][6];
		REP(i, h + 1)REP(j, 6) tmp[i][j] = 0;
		REP(i, h)REP(j, 5) cin >> tmp[i][j];
		int sum = 0;
		while (1)
		{
			int res = 0;
			REP(i, h)
			{
				if (count(tmp[i],tmp[i]+5, tmp[i][2]) == 3)
				{
					if ((tmp[i][0] == tmp[i][1] && tmp[i][1] == tmp[i][2]) || (tmp[i][1] == tmp[i][2] && tmp[i][2] == tmp[i][3]) || (tmp[i][2] == tmp[i][3] && tmp[i][3] == tmp[i][4]))
					{
						int k = tmp[i][2];
						REP(j, 5)
						{
							if (tmp[i][j] == k) tmp[i][j] = 0;
						}
						res += 3 * k;
					}
				}
				else if (count(tmp[i], tmp[i] + 5, tmp[i][2]) == 4)
				{
					int k = tmp[i][2];
					if (tmp[i][1] != tmp[i][3])
					{
						if (tmp[i][1] != k) FOR(j, 2, 5) tmp[i][j] = 0;
						else REP(j, 3) tmp[i][j] = 0;
						res += k * 3;
					}
					else
					{
						REP(j, 5) if (tmp[i][j] == k) tmp[i][j] = 0;
						res += k * 4;
					}
				}
				else if (count(tmp[i], tmp[i] + 5, tmp[i][2]) == 5)
				{
					int k = tmp[i][2];
					REP(j, 5) tmp[i][j] = 0;
					res += k * 5;
				}
			}

			if (res == 0) break;
			sum += res;
			REP(s, 11)
			{
				for (int i = h - 1; i > 0; i--)REP(j, 5)
				{
					if (tmp[i][j] == 0)
					{
						tmp[i][j] = tmp[i - 1][j];
						tmp[i - 1][j] = 0;
					}
				}
			}

		}
		cout << sum << endl;

	}
	return 0;
}

Measured memory_bytes: 1160
#include <cstdio>

int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  if(a == 1) a = 14;
  if(b == 1) b = 14;
  if(a < b)
    printf("Bob\n");
  else if(a > b)
    printf("Alice\n");
  else
    printf("Draw\n");
}

Measured memory_bytes: 128
from heapq import *

N = int(input())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]

h = []
for i in range(N):
    heappush(h, -((B[i]<<18)+i))

ans = 0
while h:
    a = -heappop(h)
    b = a>>18
    i = a%(1<<18)
    if b == A[i]:
        continue
    k = - (-(B[i] - max(B[i-1], B[(i+1)%N], A[i])) // (B[i-1] + B[(i+1)%N]))
    if k <= 0:
        print("-1")
        break
    B[i] -= (B[i-1] + B[(i+1)%N]) * k
    heappush(h, -((B[i]<<18)+i))
    ans += k
else:
    print(ans)


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

int main()
{
  int A, result1000 , result100 , result10 ,result1;
  cin >>  A;
  result1000 = A/1000;
  result100 = (A-result1000*1000)/100;
  result10 = (A-result1000*1000-result100*100)/10;
  result1 = A-result1000*1000-result100*100-result10*10;
  if(((result1000 == result100) && (result100 == result10)) || ((result100 == result10) && (result10 == result1)))
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3588
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int ans = Math.min(Math.min(a+b,b+c),a+c);
        System.out.println(ans);
    }
}
 

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

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

  vector<int> arr(3);
  for (int i = 0; i < 3; ++i) cin >> arr[i];
  sort(begin(arr), end(arr));

  int k; cin >> k;
  cout << arr[0] + arr[1] + (arr[2] << k) << "\n";
}


Measured memory_bytes: 3664
H, W = STDIN.gets.split.map(&:to_i)

G = []

H.times do
  a = Array.new(W)
  line = STDIN.gets.chomp.bytes.push 35
  i, j = 0, 0
  while i <= W
    if line[i] == 35
      if j < i
        c = i - j
        k = j
        while k < i
          a[k] = c
          k += 1
        end
      end 
      i += 1
      j = i
    else
      i += 1
    end
  end
  G << a
end 
G << Array.new(W)

ans = 0
G.transpose.each do |ar|
  i, j = 0, 0
  local_max = 0
  while i <= H
    v = ar[i]
    if v.nil?
      if j < i
        local_max += (i - j)
        ans = local_max if ans < local_max
        local_max = 0
      end 
      i += 1
      j = i
    else
      local_max = v if local_max < v  
      i += 1
    end 
  end 
end
STDOUT.puts ans - 1

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(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 repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, m;
    cin >> n >> m;
    vi d(n, -1);
    rep(i, m) {
        pii c;
        cin >> c.first >> c.second;
        if (d[c.first-1] != -1) {
            if (d[c.first-1] == c.second) continue;
            else {
                cout << -1 << endl;
                return 0;
            }
        }
        if (c.second == 0 && n >= 2 && c.first == 1) {
            cout << -1 << endl;
            return 0;
        }
        else {
            d[c.first-1] = c.second;
        }
    }
    rep(i, n) {
        if (d[i] == -1) {
            if (n >= 2 && i == 0) d[i] = 1;
            else d[i] = 0;
        }
    }
    rep(i, n) {
        cout << d[i];
    }
    puts("");
    return 0;
}



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

int main(){
	int n,ans,x;
	vector<int> vec;
	while(1){
		cin >> n;
		if(n == 0)break;
		ans = 10000000;
		vec.clear();
		for(int i = 0;i < n;i++){
			cin >> x;
			vec.push_back(x);
		}
		sort(vec.begin(),vec.end());
		for(int i = 1;i < n;i++){
			ans = min(ans,vec[i] - vec[i-1]);
		}
		cout << ans <<endl;
	}
	return 0;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    ll ans = 0;
    for (ll i = 0; i < N; i++){
        for (ll j = i; j < N; j++){
            if (A[i] > A[j]){
                ans = (ans + (((K + 1) * K) / 2) % 1000000007) % 1000000007;
            }
            else if (A[i] < A[j]){
                ans = (ans + (((K - 1) * K) / 2) % 1000000007) % 1000000007;
            }
        }
    }
    cout << ans << endl;
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    int A, B;
    cin >> A >> B;

    if (A == B) {
        puts("Draw");
        return 0;
    }

    string ans = A > B ? "Alice" : "Bob";
    if (A == 1) ans = "Alice";
    if (B == 1) ans = "Bob";

    cout << ans << endl;
}

Measured memory_bytes: 3588
#include <stdio.h>
int main(void){
    // Your code here!
    int x,y,z,k;
    scanf("%d%d%d",&x,&y,&z);
    k=y;
    y=x;
    x=k;
    k=z;
    z=x;
    x=k;
    printf("%d %d %d\n",x,y,z);
    return 0;
    
}

Measured memory_bytes: 128
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define rep(i, n) for(int i=0; i<n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
typedef long long ll;

#define MAX_N 1000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

//--------------------------



int main() {

  string s;
  cin >> s;

  rep(i, s.size()) {
    if(s[i]!='U'&&s[i]!='D') {
      if((i+1)%2==0) {
        if(s[i]!='L') {
          cout << "No" << endl;
          return 0;
        }
      }else {
        if(s[i]!='R') {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }

  cout << "Yes" << endl;

  return 0;
}


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

int main(){
    for(int i=1;i<=3000;i++){
        int x,y;
        cin>>x>>y;
        if((x==0)&&(y==0))break;
        if(x>y){
            cout<<y<<" "<<x<<endl;
        }else{
            cout<<x<<" "<<y<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<cstdio>
using namespace std;
int a;
int main()
{
    cin>>a;
    if(a<2) cout<<1<<endl;
    else if(a<4)  cout<<2<<endl;
    else if(a<8)  cout<<4<<endl;
    else if(a<16) cout<<8<<endl;
    else if(a<32) cout<<16<<endl;
    else if(a<64) cout<<32<<endl;
    else          cout<<64<<endl;
    return 0;
} 

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
 
int main() {
  string S;
  cin >> S;
  vector<int> A(S.size());
  int B = S.size();
  for (int i = 0; i < B; i++) {
    A.at(i) = ctoi(S.at(i));
  }
  int memo = B - 1;
  int64_t ans = 0;
  for (int tmp = 0; tmp < (1 << memo); tmp++) {
    bitset<10> s(tmp);
    int64_t m = 0;
    m += A.at(0);
    for (int i = 0; i < memo; i++) {
      if (s.test(i)) {
        ans += m;
        m = 0;
        m += A.at(i + 1);
      }
      else {
        m = m * 10 + A.at(i + 1);       
      }
      if (i == memo - 1) {
          ans += m;
      }
      
    }
  }
  if (B == 1) {
    ans += A.at(0);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3564
from collections import defaultdict
d = defaultdict(int)
N = int(input())
A = list(map(int, input().split()))
for i, v in enumerate(A):
    d[i + 1] = v
ans = []
d_swap = {v: k for k, v in d.items()}
sd = sorted(d_swap.items())
for i, v in enumerate(sd):
    ans.append(v[1])
print(' '.join(map(str, ans)))


Measured memory_bytes: 84328
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
using ll = long long;
using namespace std;
using P = pair<int, int>;

int main(){
    string S, T;
    int count = 0;
    cin >> S >> T;
    rep(i, S.size()) if(S.at(i) != T.at(i)) count++;
    cout << count << endl;
}


Measured memory_bytes: 3920
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string str;
    cin >> str;
    bool sho = false;
    ll ue=0,sita=0;
    int cnt_ue=0,cnt_sita=0;
    bool roop = false;
    for(int i=0; i<str.size(); i++){
        if(str[i] == '.'){
            sho = true;
            continue;
        }
        if(str[i] == '(' or str[i] == ')'){
            roop = true;
            continue;
        }
        if(sho){
            if(roop){
                ue *= 10;
                ue += str[i] - '0';
                cnt_ue++;
            }else{
                ue *= 10;
                ue += str[i] - '0';
                sita *= 10;
                sita += str[i] - '0';
                cnt_ue++;
                cnt_sita++;
            }
        }else{
            ue *= 10;
            ue += str[i] - '0';
            sita *= 10;
            sita += str[i] - '0';
        }
    }
    ll bunbo,bunsi;
    if(ue == sita){
        bunbo = pow(10,cnt_ue);
        bunsi = ue;
    }else{
        bunbo = pow(10,cnt_ue) - pow(10,cnt_sita);
        bunsi = ue - sita;
    }
    ll g = gcd(bunbo,bunsi);
    bunbo /= g;
    bunsi /= g;
    cout << bunsi << "/" << bunbo << enld;
    return 0;
}


Measured memory_bytes: 3352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    string s;
    int n;
    cin >> n >> s;
    string ans = "";
    rep(i, s.length()) {
        int tmp = s[i] - 'A';
        tmp += n;
        tmp %= 26;
        char a = (char)(tmp + 'A');
        ans += a;
    }
    cout << ans << endl;
    return 0;
}


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

#define rep(i, N) for (int i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define MOD 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;

int main(){
    ll D, G; cin >> D >> G;
    vi p(D),c(D),v(D); rep(i,D) cin>>p[i]>>c[i];

    int ans = MOD;

    //R個の全探索(2^R通り)
    for (int bit = 0; bit < (1 << D); bit++) {
        ll tmpscr = 0;
        int tmpnum = 0;
        int pnum = -1;

        for (int i = 0; i < D; i++) {
            //i番目のビットが立っていた時の処理
            if (bit & (1<<i)) {
               tmpscr += 100*(D-i)*p[D-1-i]+c[D-1-i]; //完答
               tmpnum += p[D-1-i];
            } else if(pnum == -1) {
                pnum = i;//完答しないもので最大のスコアを記録
            }
        }

        if(tmpscr >= G) {
            ans = min(ans,tmpnum);
        } else {
            if(pnum != -1)
                if((G-tmpscr+100*(D-pnum)-1)/(100*(D-pnum)) < p[pnum])
                    ans = min(ans,tmpnum+(int)((G-tmpscr+100*(D-pnum)-1)/(100*(D-pnum))));
        }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}
 
int main(){
    ll n;
    cin >>n;
    vector<ll> d(n);
    
    
    for (ll i = 0; i < n; i++){
        cin >> d[i];
    }
    ll ans = 0;
    for (ll i = 0; i < n; i++){
        for (ll j = i+1; j < n; j++){
            ans += d[i]*d[j];
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(void){
    int N;
    cin >> N;
    vector<int> a(N);
    for(auto& it : a){
        cin >> it;
        it--;
    }
    vector<int> vis(N, 0);
    int ans = 0;
    int cur = 0;
    while(cur != 1){
        if(vis[cur]){
            cout << -1 << endl;
            return 0;
        }
        vis[cur] = 1;        
        cur = a[cur];
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
N=int(input())
s=[0]*N
for i in range(N):
  s[i] = int(input())
s.sort()
s_sum=sum(s)

if s_sum%10 !=0:
  ans = s_sum
else:
  for num in s:
    if (s_sum-num)%10 !=0:
      maxi_1 = s_sum-num
      #print(num,maxi_1)
      break
    else:
      maxi_1=0
  tmp=0
  for num in s:
    tmp += num
    if (s_sum-tmp)%10 !=0:
      maxi_2= s_sum-tmp
      #print(num,maxi_2)
      break
    else:
      maxi_2=0
  ans=max(maxi_1,maxi_2)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int p=1e9+7;
inline void inc(int &x,int y){x+=y;if (x>=p) x-=p;}
inline int mul(int x,int y){return (ll)x*y%p;}
int power(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=mul(x,x))
		if (y&1) ans=mul(ans,x);
	return ans;
}
int n,m,ans,go[20][20],a[16],bit[16];
int q[16][16],deg[16];
void init(ll S){for (int i=0;i<15;i++) a[i]=S&15,S>>=4;}
struct hash_table{
	typedef unsigned long long ull;
	typedef pair<ll,int> pii;
	vector<pii> a;
	void init(int size){
		a.resize(size,pii(-1,0));
	}
	int& operator [] (ll x){
		ull key=x^531515465ll;
		key^=key<<13;
		key^=key>>17;
		key^=key<<5;
		vector<pii>::iterator p=a.begin()+key%a.size();
		while (~p->first&&p->first!=x){
			++p;
			if (p==a.end()) p=a.begin();
		}
		p->first=x;
		return p->second;
	}
}M[20];
//map<ll,int> M[20];
unsigned long long add;int add_cnt=0;
inline void work2(int v){
	register char j;
	static char cnt1[16];
	memset(cnt1,0,16);
	for (j=0;j<deg[n-1];j++) cnt1[a[q[n-1][j]]]++;
	static char cnt2[16];
	memset(cnt2,0,16);
	for (j=0;j<deg[n-2];j++) cnt2[a[q[n-2][j]]]++;
	static char suf[16];
	suf[15]=0;
	for (j=14;j>=0;j--) suf[j]=suf[j+1]+cnt1[j]+cnt2[j];
	for (j=0;v;j++){
		add+=((ll)v<<suf[j+1]);
		add_cnt++;
		if (add_cnt==32) ans=(ans+add)%p,add_cnt=0,add=0;
		v=mul(v,bit[cnt1[j]]*bit[cnt2[j]]);
	}
}
void work1(int v){
	static char cnt[16],suf[16];
	static char i=n-3,j,lim=0;
	memset(cnt,0,16);
	for (j=0;j<i;j++) if (go[i][j]) cnt[a[j]]++;
	for (j=14;j>=0;j--) suf[j]=suf[j+1]+cnt[j];
	while (cnt[lim]) lim++;
	for (int j=0;j<=lim;j++){
		a[i]=j;
		work2(mul(v,1<<suf[j+1]));
		v=mul(v,bit[cnt[j]]);
	}
}
char cnt[20],suf[20];
int main()
{
	//freopen("a.txt","r",stdin);
	for (int i=0;i<16;i++) bit[i]=(1<<i)-1;
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		u=n-u;v=n-v;
		go[u][v]=1;
		if (v!=n-2) q[u][deg[u]++]=v;
	}
	for (int i=0;i<=9;i++) M[i].init(2e5);
	M[10].init(1e6);
	M[11].init(6e6);
	M[0][0]=1;
	for (int i=0;i<11;i++)
	for (auto pr:M[i].a)
	if (~pr.first){
		register int v=pr.second;
		register ll S=pr.first;
		init(S);
		register char j,lim=0;
		memset(cnt,0,12);
		for (j=0;j<=i;j++) if (go[i+1][j]) cnt[a[j]]++;
		for (j=11;j>=0;j--) suf[j]=suf[j+1]+cnt[j];
		while (cnt[lim]) lim++;
		for (char j=0,bit=(i+1)<<2;j<=lim;j++){
			inc(M[i+1][(ll)j<<bit|S],mul(v,1<<suf[j+1]));
			v=mul(v,(1<<cnt[j])-1);
		}
	}
	if (n<=12){
		for (auto pr:M[n-1].a)
		if (~pr.first){
			int v=pr.second;ll S=pr.first;
			init(S);
			if (a[n-1]!=a[n-2]) inc(ans,v);
		}
		printf("%d\n",ans);
	}
	else{
		for (auto pr:M[n-4].a)
		if (~pr.first) init(pr.first),work1(pr.second);
		ans=(ans+add)%p;
		ans=(power(2,m)+p-ans)%p;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 141056
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
//#include <unordered_map>
//#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()

//typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18; // segment tree size
const ll MOD = 998244353;
const int INF = 0x3f3f3f3f; // memset(dp, 0x3f, sizeof(dp)), 2*INF < INT_MAX
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10; // double EPS

int G1[605][605];
int G2[605][605];

int r[400050][2];
int root(int x) {
	if (x == r[x][0]) return x;

	int t = r[x][0];
	r[x][0] = root(t);
	r[x][1] ^= r[t][1];
	return r[x][0];
}
void mymerge(int x, int y) {
	int r1 = root(x), r2 = root(y);
	int t = r[x][1] ^ r[y][1] ^ 1;
	if (r1 == r2) return;
	r[r1][0] = r2, r[r1][1] = t;
}

void getgroup(int N, int D, int G[605][605]) {
	int i, j, k;
	vector <pii> Vl;

	for (i = 0; i < 4 * N*N; i++) r[i][0] = i, r[i][1] = 0;

	for (i = 0; i*i <= D; i++) {
		int x = (int)(sqrt(D - i*i) + 0.5);
		if (i*i + x*x != D) continue;

		if (i > x) break;
		Vl.emplace_back(i, x);
		if (i != x) Vl.emplace_back(x, i);
	}
	for (i = 0; i < 2 * N; i++) {
		for (j = 0; j < 2 * N; j++) {
			for (auto it : Vl) {
				int x = i + it.first, y = j + it.second;
				if (x < 2 * N && y < 2 * N && x >= 0 && y >= 0) mymerge(i * 2 * N + j, x * 2 * N + y);

				x = i + it.first, y = j - it.second;
				if (x < 2 * N && y < 2 * N && x >= 0 && y >= 0) mymerge(i * 2 * N + j, x * 2 * N + y);
			}
		}
	}
	for (i = 0; i < 2 * N; i++) {
		for (j = 0; j < 2 * N; j++) {
			int t = i * 2 * N + j;
			int ro = root(t);
			if (r[t][1] == 1) G[i][j] = -1;
			else G[i][j] = 1;
		}
	}
}

int main() {
	int N, D1, D2, i, j, k;
	scanf("%d", &N);
	scanf("%d %d", &D1, &D2);
	getgroup(N, D1, G1);
	getgroup(N, D2, G2);

	for (i = 0; i < 4; i++) {
		int t1 = (i & 1) ? 1 : -1;
		int t2 = (i & 2) ? 1 : -1;

		int c = 0;
		for (j = 0; j < 2 * N; j++) {
			for (k = 0; k < 2 * N; k++) {
				if (t1 == G1[j][k] && t2 == G2[j][k]) c++;
			}
		}
		if (c >= N*N) {
			c = N*N;
			for (j = 0; j < 2 * N; j++) {
				for (k = 0; k < 2 * N; k++) {
					if (t1 == G1[j][k] && t2 == G2[j][k]) {
						c--;
						printf("%d %d\n", j, k);
						if (c == 0) return 0;
					}
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 6912
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void Main()
{
	int N;
	std::string str;
	std::cin >> N;
	std::cin >> str;
	std::vector<int> black_count(N + 1);
	for (int i : boost::irange(0, N))
	{
		black_count[i + 1] = black_count[i] + (str[i] == '#');
	}
	auto all = black_count[N];
	int min = all;
	for (int i : boost::irange(1, N + 1))
	{
		auto left_black = black_count[i];
		auto right_white = (N - i) - (all - black_count[i - 1]);
		min = std::min(min, left_black + right_white);
	}
	std::cout << min << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 1428
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
 	ll a,b;
 	cin>>a>>b;
 	for(long long i=1;i<10000000;i++)
 	{
 		ll A = (i*8)/100;
 		ll B = (i*10)/100;
 		if(a==A && b==B)
 		{
 			cout<<(long long)i<<endl;
 			return 0;
 		}

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

Measured memory_bytes: 256
N = int(input())

#入力に対して約数の個数を返す関数
def divisors(N):
  sum = 0
  for i in range(1,int(N**0.5+1)):
    if N % i == 0:
      if i **2 == N:
        sum += 1
      else:
        sum +=2
  return sum
# 問題の条件を満たすものの個数
SUM = 0 
# 1からNまでの奇数に関して関数を実行
for x in range(1,N+1,2):
  div = divisors(x)
  if div == 8:
    SUM += 1
print(SUM)

Measured memory_bytes: 3060
//#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <string.h>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <math.h>
#include <assert.h>
#define ff first
#define ss second
#define ll long long
#define mod 998244353
using namespace std;
int h1, s1, h2, s2;
int main () {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>h1>>s1>>h2>>s2;
    int turn = 1;
    while(true) {
        if(turn == 1) {
            h2 -= s1;
            if(h2 <= 0) {
                cout<<"Yes\n";
                return 0;
            }
        }
        else {
            h1 -= s2;
            if(h1 <= 0) {
                cout<<"No\n";
                return 0;
            }
        }
        turn = 3 - turn;
    }
}
/*
 4
 -2 2 3 5
 3 10 21 5
 */


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

template<class T>
inline void read(T &x) {
    static char ch;
    static bool opt;
    while (!isdigit(ch = getchar()) && ch != '-');
    x = (opt = ch == '-') ? 0 : ch - '0';
    while (isdigit(ch = getchar()))
        x = x * 10 + ch - '0';
    if (opt)
        x = ~x + 1;
}

const int MaxN = 2e5 + 5;
const int MaxS = MaxN << 2;

const int INF = 0x3f3f3f3f;

#define lcc x << 1, l, mid
#define rcc x << 1 | 1, mid + 1, r

int n, m, cur;
int seg[MaxS], tag[MaxS];

inline void upt(int x) {
    seg[x] = std::min(seg[x << 1], seg[x << 1 | 1]);
}

inline void nodeCover(int x, int l, int r, int val) {
    seg[x] = l - val;
    tag[x] = val;
}

inline void dnt(int x, int l, int r) {
    if (tag[x]) {
        int mid = (l + r) >> 1;
        nodeCover(lcc, tag[x]);
        nodeCover(rcc, tag[x]);
        tag[x] = 0;
    }
}

inline void segCover(int u, int v, int t, int x = 1, int l = 1, int r = m) {
    if (u <= l && r <= v) {
        nodeCover(x, l, r, t);
        return;
    }
    dnt(x, l, r);
    int mid = (l + r) >> 1;
    if (u <= mid) segCover(u, v, t, lcc);
    if (v > mid) segCover(u, v, t, rcc);
    upt(x);
}

inline int segQuery(int p, int x = 1, int l = 1, int r = m) {
    if (l == r)return p - seg[x];
    dnt(x, l, r);
    int mid = (l + r) >> 1;
    return p <= mid ? segQuery(p, lcc) : segQuery(p, rcc);
}

int main() {
    read(n), read(m);
    cur = 1;
    for (int i = 1; i <= n; ++i) {
        int l, r;
        read(l), read(r);
        if (cur >= l && cur <= r) 
            segCover(cur, r, -INF),cur = r + 1;
        else if (cur < l) 
            segCover(l, r, segQuery(l - 1));
        if (cur > m) {
            for (int j = i; j <= n; ++j) {
                puts("-1");
            }
            return 0;
        }
        printf("%d\n", i + seg[1]);
    }
    return 0;
}


Measured memory_bytes: 7660
// ※※※ 解答不能 ※※※
// snuke氏.
// https://atcoder.jp/contests/abc170/submissions/14369452
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using LP = pair<LL, int>;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define a first
#define b second
const LL INF = 1010101010101010;
constexpr int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};

int main(){
    int H, W, K, x1, y1, x2, y2;
    scanf("%d %d %d %d %d %d %d", &H, &W, &K, &x1, &y1, &x2, &y2);
    x1--, y1--, x2--, y2--;
    vector<string> pond(H);
    rep(i, H){
        char c[1010101];
        scanf("%s", c);
        string s(c);
        pond[i] = s;
    }
    
    auto toId     = [&](int i, int j, int v){ return (i * W + j) * 4 + v; };
    auto modCeilK = [&](LL x){ return (x + K - 1) / K * K; };
    
    vector<LL> dist(H * W * 4, INF);
    priority_queue<LP, vector<LP>, greater<LP>> pq;
    auto push = [&](int i, int j, int v, LL x){
        int id = toId(i, j, v);
        if(dist[id] <= x) return;
        dist[id] = x;
        pq.emplace(x, id);
    };
    rep(v, 4) push(x1, y1, v, 0);
    while(!pq.empty()){
        LL d = pq.top().a;
        int id = pq.top().b;
        pq.pop();
        if(dist[id] != d) continue;
        int i = id / W / 4;
        int j = id / 4 % W;
        int v = id % 4;
        rep(nv, 4) push(i, j, nv, modCeilK(d));
        int nx = i + dx[v], ny = j + dy[v];
        if(0 <= nx && nx < H && 0 <= ny && ny < W && pond[nx][ny] == '.') push(nx, ny, v, d + 1);
    }
    
    LL ans = INF;
    rep(v, 4) ans = min(ans, dist[toId(x2, y2, v)]);
    if(ans == INF){
        puts("-1");
    }else{
        ans = modCeilK(ans) / K;
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 43712
#include <bits/stdc++.h>
#define Roc ios_base::sync_with_stdio(false), cin.tie(NULL)
#define ll long long
#define NMAX 100009
using namespace std;
int v[NMAX], pd[NMAX], n;
int main()
{
    Roc;
    cin >> n;
    for(int i = 1; i <= n; ++i)
        cin >> v[i];
    pd[1] = 0;
    pd[2] = abs(v[1] - v[2]);
    for(int i = 3; i <= n; ++i)
        pd[i] = min(pd[i - 1] +  abs(v[i - 1] - v[i]), pd[i - 2] +  abs(v[i - 2] - v[i]));
    cout << pd[n];
    return 0;
}


Measured memory_bytes: 1024
from networkx import*
N = int(input())
G = MultiDiGraph()
for i in range(N):
    x, y, c = map(int, input().split())
    G.add_node(i, demand = -c)
    G.add_weighted_edges_from([(i, -1, x + y), (i, -2, x - y), (i, -3, -x + y), (i, -4, -x - y)], capacity = c)
for i in range(N, N * 2):
    x, y, c = map(int, input().split())
    G.add_node(i, demand = c)
    G.add_weighted_edges_from([(-1, i, -x - y), (-2, i, -x + y), (-3, i, x - y), (-4, i, x + y)], capacity = c)

print(-min_cost_flow_cost(G))

Measured memory_bytes: 63916
import sys
from collections import defaultdict, deque
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    return


# B
def B():
    return


# C
def C():
    n = I()
    for i in range(int(n ** 0.5), 0, -1):
        if n % i == 0:
            print(i + n // i - 2)
            return
    return


# D
def D():
    return


# E
def E():
    return


# F
def F():
    return


# Unittest
def resolve():
    C()
    return


# Solve
if __name__ == "__main__":
    C()

Measured memory_bytes: 38512
#include <iostream>
#define fol(i,n) for(int i=0;i<n;i++)
#define db(a) cout << a<< endl;
using namespace std;

int mod(int n){
    int j=0;
    while(n%2==0) {n /=2;j++;}
    return j;
}
int main(){
    int n,cnt=0,ans=1,m=0;
    cin >>n;
    fol(i,n+1){
        cnt=0;
        if (i!=0){
            cnt = mod(i);
        }
        if (cnt>=m) {m=cnt;ans=i;}
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


llint a,b,c,d;

llint gcd(llint x,llint y){
    if(x<y)gcd(y,x);
    llint r;
    while((r=x%y)){
        x=y;
        y=r;
    }
    return y;
}

void solve(){
    cin >> a >> b >> c >> d;
    a--;
    llint cb=0,ca=0;
    llint g=gcd(c,d);
    llint l=c*d/g;
    llint tb=b/l,ta=a/l;
    cb=b-b/c-b/d+tb;
    ca=a-a/c-a/d+ta;
    cout << cb-ca << endl;
}

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


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))

count = 0
list00 = sorted(a)
for i in range(1, n):
  if list00[i-1] == list00[i]:
    count = count*0
  else:
    count = count + 1

if count == n-1:
  print('YES')
else:
  print('NO')


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

#define rep(i,n) for(long long i=0; i<n ; ++i)
#define REP(i,a,b) for(long long i=a; i<b; ++i)
#define all(v) (v).begin() , (v).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//プロトタイプ宣言
void faster(void);
template <class T>
T gcd(T , T);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);


int main(){
  faster();
  int a,b,c;
  cin >> a >> b >> c;
  if((a==b && b==c)||(a!=b && b!=c && c!=a)) cout << "No";
  else cout << "Yes";
}



























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//ユークリッドの互除法
template <class T>
T gcd(T a, T b) {
  return (b ? gcd(b, a%b) : a);
} 

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//べき乗計算
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 



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

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1001001001;

#define rep(i, n)  for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
int main() {
    int k;
    cin >> k;
    int ans = 0;
    for(int a = 1; a <= k; a++) {
        for(int b = 1; b <= k; b++) {
            for(int c = 1; c <= k; c++) {
                int ansi = gcd(a, b);
                ansi = gcd(ansi, c);
                ans += ansi;
            }
        }
    }

    cout << ans << endl;
}


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


int main(){
	int N;cin >> N;
	string S;cin >> S;
	int x = 0;
	rep(i,N){
		int tmp = 0;
		rep(j,i+1){
			if(S[j] =='I') tmp++;
			else tmp--;
		}
		x = max(x,tmp);
	}
	cout << x << endl;


}












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

int main(){
  ll a,v,b,w;cin>>a>>v>>b>>w;
  ll t;cin>>t;
  ll dist = abs(a-b);
  ll diff = v -w;
  if (dist > diff * t)
  {
    cout << "NO" << endl;
  }
  else
  {
    cout << "YES" << endl;
  }
  
}

Measured memory_bytes: 3632