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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
	for (auto i : a) cerr << i << ' ';\
	cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int> odd, even;
	forn(i, 0, m) {
		int t;
		cin >> t;
		if (t % 2) odd.eb(t);
		else even.eb(t);
	}
	if (odd.size() >= 3) {
		cout << "Impossible\n";
		return 0;
	}
	if (odd.size() == 2) {
		cout << odd[0] << ' ';
		forn(i, 0, m - 2) cout << even[i] << ' ';
		cout << odd[1] << " \n" << m - (odd[1] == 1) << '\n' << odd[0] + 1 << ' ';
		forn(i, 0, m - 2) cout << even[i] << ' ';
		if (odd[1] != 1) cout << odd[1] - 1 << '\n';
	}
	if (odd.size() == 1) {
		if (even.size() == 0) {
			int x = odd[0];
			if (x == 1) {
				cout << "1\n1\n1\n";
			} else {
				cout << x << "\n2\n" << x - 1 << " 1 \n";
			}
		} else {
			forn(i, 0, m - 1) cout << even[i] << ' ';
			cout << odd[0] << "\n";
			cout << m << '\n' << even[0] - 1 << ' ';
			forn(i, 1, m - 1) cout << even[i] << ' ';
			cout << odd[0] + 1 << '\n';
		}
	}
	if (odd.size() == 0) {
		forn(i, 0, m) cout << even[i] << ' ';
		cout << '\n' << m + 1 << '\n' << even[0] - 1 << ' ';
		forn(i, 1, m) cout << even[i] << ' ';
		cout << "1 \n";
	}
	return 0;
}


Measured memory_bytes: 256
def loadIcicle():
	icicles = []
	line = input().strip().split(" ")
	N, L = int(line[0]), int(line[1])
	while True:
		icicles.append(int(input().strip()))
		if len(icicles) == N: break
	return icicles, N, L

def calcDiff(icicles, N):
	diff_2times = [0]*N

	for idx in range(N):
		dif_right = icicles[idx+1] - icicles[idx] if idx != N-1 else -icicles[idx]
		dif_left = icicles[idx] - icicles[idx-1] if idx != 0 else icicles[idx]

		dif_right = 1 if dif_right > 0 else -1
		dif_left = 1 if dif_left > 0 else -1

		if dif_right - dif_left < 0: diff_2times[idx] = -1
		elif dif_right - dif_left > 0: diff_2times[idx] = 1
		else: diff_2times[idx] = 0

	return diff_2times

icicles, N, L = loadIcicle()
diff_2times = calcDiff(icicles, N)

time = [-1]*N
peakX = [i for i in range(N) if diff_2times[i]==-1]
for i in peakX:
	time[i] = L - icicles[i]

	isLocalMinL, isLocalMinR = False, False
	posL, posR = i, i
	while not (isLocalMinL and isLocalMinR):
		posL -= 1
		if posL < 0:
			isLocalMinL = True
		if not isLocalMinL:
			if time[posL] == -1:
				time[posL] = (L-icicles[posL]) + time[posL+1]
			else:
				time[posL] = (L-icicles[posL]) + max(time[posL-1], time[posL+1])

			if diff_2times[posL] == 1:
				isLocalMinL = True

		posR += 1
		if posR >= N:
			isLocalMinR = True
		if not isLocalMinR:
			if time[posR] == -1:
				time[posR] = (L-icicles[posR]) + time[posR-1]
			else:
				time[posR] = (L-icicles[posR]) + max(time[posR-1], time[posR+1])

			if diff_2times[posR] == 1:
				isLocalMinR = True

print(max(time))

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

struct P {
  int x;
  int area;
};
vector<P> st;

int main() {
  char c;
  vector<int> l;
  int x = 0;
  int ans = 0;
  while (cin >> c) {
    if (c == '\\') {
      l.push_back(x);
    } else if (c == '/') {
      if (l.size() > 0) {
        int left = l.at(l.size()-1);
        int sum = (x-left+1)-1;
        ans += sum;
        while(st.size() > 0 && st.at(st.size()-1).x > left) {
          P tmp = st.at(st.size()-1);
          sum += tmp.area;
          st.pop_back();
        }
        P a= {x, sum};
        st.push_back(a);
        l.pop_back();
      }
    }
    x++;
  }
  cout << ans << endl;

  if (st.size() > 0) {
    cout << st.size() << " ";
    for(int i=0; i<st.size()-1; i++) {
      cout << st.at(i).area << " ";
    }
    cout << st.at(st.size()-1).area << endl;
  } else {
    cout << st.size() << endl;
  }
}



Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = 0;
        
        for(int i=a;i<=b;i++){
            if(c%i==0){
                d++;
            }
        }
        System.out.println(d);
        sc.close();
    }
}


Measured memory_bytes: 26388
import java.util.*;

public class Main {
    public static void main(String[] args){

	Scanner sc = new Scanner(System.in);
	// 整数の入力
	int n = sc.nextInt();

	int[] h = new int[n];
	for(int i = 0; i < n; i++){
	    h[i] = sc.nextInt();
	}

	int ans = 0;
	boolean lastWatered;
	for(int level = 100; level > 0; level--){
	    lastWatered = false;
	    for(int i = 0; i < n; i++){
		if(h[i] == level){
		    h[i]--;
		    if(lastWatered){
			// do nothing
		    }else{
			ans++;
			lastWatered = true;
		    }
		}else{
		    lastWatered = false;
		}
	    }
	}

	System.out.println(ans);
    }

}




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

using namespace std;
int n, c, k;
int t[108000];

int main(){
  cin >> n >> c >> k;
  for(int i = 0;i < n;i++)cin >> t[i];
  sort(t, t + n);
  int l = 0;
  int waiting = 0;
  int res = 0;
  for(int i = 0;i < n;i++){
    if(waiting == 0 || t[l] + k >= t[i]){
      waiting++;
    }
    else{
      res++;
      l = i;
      waiting = 1;
    }
    if(waiting == c){
      waiting = 0;
      res++;
      l = i+1;
    }
  }
  if(waiting)res++;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <math.h>
using namespace std;

int main(int argc, const char * argv[]) {
    double xp1, yp1, xp2, yp2;
    int q;
    double xp, yp;
    
    cin >> xp1 >> yp1 >> xp2 >> yp2;
    cin >> q;
    
    double dist = sqrt((xp1 - xp2) * (xp1 - xp2) + (yp1 - yp2) * (yp1 -yp2));
    double nx, ny; //unit vector along the line
    nx = (xp2 - xp1) / dist;
    ny = (yp2 - yp1) / dist;
    
    for (int i = 0; i < q; ++i) {
        cin >> xp >> yp;
        cout.precision(15);
        double t = nx * (xp - xp1) + ny * (yp - yp1);
        cout << xp1 + nx * t << ' ' << yp1 + ny * t << endl;
    }
    
    return 0;
}



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

int main(){
  int N;
  cin >> N;
  
  vector<int> t(N);
  vector<int> x(N);
  vector<int> y(N);
  
  for(int i=0; i<N; i++){
    cin >> t.at(i) >> x.at(i) >> y.at(i);
  }
  
  for(int i=0; i<N; i++){
    if(t.at(i) < abs(x.at(i)) + abs(y.at(i))){
      cout << "No" << endl;
      return 0;
    }
    
    if(t.at(i)%2 != (x.at(i) + y.at(i))%2){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 1408
a,b,c,d=map(int,input().split())
cnt_t=0
cnt_a=0

while  c>0:
  c=c-b
  cnt_t+=1
while a>0:
  a=a-d
  cnt_a+=1

if cnt_t<=cnt_a:
  print('Yes')
else:
  print('No')
  

Measured memory_bytes: 9172
n=int(input())
t_sum=1
a_sum=1
for i in range(n):
    T,A=map(int,input().split())
    t_sum = max(-(-t_sum//T),-(-a_sum//A))*T
    a_sum = max(-(-t_sum//T),-(-a_sum//A))*A
print(t_sum+a_sum)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVVld = vector<VVld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


using Graph = vector<vector<int>>;
Graph G;

Pll dfs(int u, int p=-1) {
  ll bl = 1;
  ll wh = 1;
  for (auto v : G[u]) {
    if (v == p) continue;
    ll b, w;
    tie(b, w) = dfs(v, u);
    (bl *= w) %= MOD;
    (wh *= b + w) %= MOD;
  }
  return Pll(bl, wh);
}

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

  G = Graph(N);
  for (int i = 0; i < N-1; ++i) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  ll b, w;
  tie(b, w) = dfs(0);
  int ans = (b + w) % MOD;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12672
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){
  string S;
  cin>>S;
  int ans=7;
  rep(i,3){
    ans+= S[i]=='o';
  }
  cout<< ans*100<<"\n";
}

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


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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = (a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (a); i <= (long long)(n); i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std;

int main(void)
{
    int a,b,c;
    cin >> a >> b >> c;

    swap(a,b);
    swap(a,c);

    cout << a << " " << b << " " << c << endl;
    return 0;
}
/** atcoder **/


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  char s[5];
  int a=0,b=0,c=0,i;
  scanf("%s", s);
  for(i=0;i<3;i++){
    switch(s[i]){
    case 'a': a=1;break;
    case 'b': b=1;break;
    case 'c': c=1;break;
    }
  }
  if(a==1 && b==1 && c==1)puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define AB_BHI_NI_DEGI                \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
int mod = 1e9 + 7;
//int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double

#define ordered_set tree<P, null_type, less<P>, rb_tree_tag, tree_order_statistics_node_update>

ll power(ll a, ll n)
{
	ll ans = 1;
	while (n > 0)
	{
		if (n % 2)
			ans = (ans * a) % mod;
		n = n >> 1;
		a = (a * a) % mod;
	}
	return ans;
}
ll inv(ll n)
{
	return power(n, mod - 2);
}
int fact[5 * N];
void init()
{
	fact[0] = 1;
	for (int i = 1; i < 5 * N; i++)
	{
		fact[i] = (fact[i - 1] * i) % mod;
		fact[i] %= mod;
	}
}
int ncr(int n, int r)
{
	if (r > n)
		return 0;
	int x = fact[n] % mod;
	int y = fact[n - r] % mod;
	int z = fact[r] % mod;
	int ans = inv(y * z) % mod;
	ans = (ans * x) % mod;
	return ans % mod;
}
int32_t main()
{
	AB_BHI_NI_DEGI
	int n, m, k;
	cin >> n >> m >> k;
	int a[n + 1], b[m + 1];
	int pre_a[n + 1] = {0};
	int pre_b[m + 1] = {0};
	for (int i = 0; i < n; i++)
		cin >> a[i], pre_a[i + 1] = pre_a[i] + a[i];
	for (int i = 0; i < m; i++)
		cin >> b[i], pre_b[i + 1] = pre_b[i] + b[i];
	int l = 0, r = m, ans = 0;
	for (int l = 0; l <= n; l++)
	{
		if (pre_a[l] > k)
			break;
		while (k - pre_a[l] < pre_b[r])
			r--;
		ans = max(ans, l + r);
	}
	cout << ans << "\n";

	return 0;
}

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

long aps(long a, long d, long n) {
  return n * (2 * a + (n - 1) * d) / 2;
}

int main() {
  int N;
  cin >> N;
  long ans = 0;
  for (int i = 1; i <= N; i++) {
    ans += aps(i, i, N / i);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3604
local n = io.read("*n")
local cur = io.read("*n")
local ren = 1
local ret = 0
for i = 2, n do
  local a = io.read("*n")
  if(a == cur) then
    ren = ren + 1
  else
    ret = ret + ren // 2
    ren = 1
    cur = a
  end
end
ret = ret + ren // 2
print(ret)


Measured memory_bytes: 1016
#include <bits/stdc++.h>
using namespace std;
#define int long long int 
#define f(i,n) for(int i=0;i<(n);i++)
#define rep(i,a,n) for(int i=(a);i<=(n);i++)
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define all(a) a.begin(), a.end()
#define F first
#define S second
#define inf LONG_MAX
#define ninf LONG_MIN
#define pi  3.14159265358979
const int mod = 1e9+7;

int32_t main() {
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  
  int a,b,h,m;
  cin>>a>>b>>h>>m;
  
  double ans;
  ans = sqrt(pow((a*cos( pi*h/6.0 + pi*m/(6*60.0) ) - b*cos((pi*m)/30.0)),2) + pow(( a*sin(pi*h/6.0 + pi*m/(6*60.0) ) - b*sin((pi*m)/30.0) ),2));
  printf("%0.10lf\n",ans);

  
  
  return 0;
}


Measured memory_bytes: 4232
#include<bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int mod=10e8+7,maximum=-1;;

 long long int getmax(long long int n,long long int weight,long long int wt[],long long int values[])
{
  
    long long int i,j;
    long long int dp[n+1][weight+1];
   
    for(i=0;i<n+1;i++)
    dp[i][0]=0;
    for(j=0;j<weight+1;j++)
    dp[0][j]=0;
    
     for(i=1;i<n+1;i++)
     {
         for(j=1;j<weight+1;j++)
         {
             if(j>=wt[i-1])
             dp[i][j]=max(values[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
             else
             {
                 dp[i][j]=dp[i-1][j];
             }
             
         }}
     
         
   
 
  
    return dp[n][weight];

    

}
int main()
{
     long long int n,weight;
    
    
   
        cin>>n>>weight;
         long long int wt[n],values[n],i;
        for(  i=0;i<n;i++)
   
        cin>>wt[i]>>values[i];
        cout<<getmax(n,weight,wt,values)<<"\n";
    
}

Measured memory_bytes: 82412
#include <stdio.h>

int main(void) {
	int N, c = 0;
	unsigned long long a, ans = 1;

	scanf("%d", &N);

	for (int i = 0; i < N; i++) {
		scanf("%llu", &a);

		if (a == 0) {
			printf("0");
			return 0;
		}

		if ((1000000000000000000ULL / ans) < a) {
			c = 1;
		}
		else if (ans > 1000000000000000000ULL) {
			c = 1;
		}
		else {
			ans = ans * a;
		}
	}

	if ((ans > 1000000000000000000ULL) || (c > 0)) {
		printf("-1");
		return 0;
	}
	else {
		printf("%llu", ans);
		return 0;
	}
}


Measured memory_bytes: 2152
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>

using namespace std;
#define int long  long int
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int a;
	cin >> a;
	cout << 3 * a * a;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

const ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
int main() {
	int h, w, i, j;
	char a[111][111], ans[111][111];
	cin >> h >> w;
	for (i = 0; i < h; i++)
		cin >> a[i];
	for (i = 0; i < h + 2; i++){
		for (j = 0; j < w + 2; j++)
			ans[i][j] = '#';
      ans[i][w+2]='\0';
    }
	for (i = 0; i < h; i++)
		for (j = 0; j < w; j++)
			ans[i + 1][j + 1] = a[i][j];
	for (i = 0; i < h+2; i++)
		cout << ans[i] << endl;
}

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


def base10to(n, b):
    if n // b:
        return base10to(n // b - 1, b) + ',' + str(n % b)
    return str(n % b)

res_26 = base10to(N - 1, 26)

res = []
for s in res_26.split(','):
    res.append(chr(97 + int(s)))

print(''.join(res))

Measured memory_bytes: 9184
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

ll n;
ll cycle(ll x){
  return x%n;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    string s,t;
    cin >> s;
    cin >> t;
    n = s.length();
    F0R(i,s.length()){
      bool same = true;
      F0R(j,t.length()){
        if(s[cycle(i+j)] != t[j] ){
          same = false;
          break;
        }
      }
      if(same)
      {
        cout << "Yes"<<endl;
        return 0;
      }
    }

    cout << "No" << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
n,m=map(int,input().split())
data=[]
for i in range(m):
    s,t=map(int,input().split())
    data.append((s,t))
ans=-1
for i in range(1000):
    a=str(i)
    flag=True
    for j in range(m):
        s,t=data[j][0],data[j][1]
        if  s<=len(a) and a[s-1]!=str(t):
            flag=False
            break
        if s>len(a):
            flag=False
            break
    if flag and len(str(i))==n:
        ans=i
        break
print(ans)

Measured memory_bytes: 3064
def comb(n,k,p):
  """power_funcを用いて(nCk) mod p を求める"""
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a = 1
  b = 1
  c = 1
  for i in range(1,n+1):
    a = (a*i)%p
  for i in range(1,k+1):
    b = (b*i)%p
  for i in range(1,n-k+1):
    c = (c*i)%p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p
mod = 10**9+7
N,K = map(int,input().split())
red = N-K
blue = K
for i in range(1,K+1):
    if i > N-K+1:
        print(0)
        continue
    if i == 1:
        print(red+1)
        continue
    count = comb(red+1,i,mod)
    count *= comb(blue-1,i-1,mod)
    print(count%mod)
    
    
    

Measured memory_bytes: 3444
#include <iostream>
#include <math.h>

using namespace std;

int main(){
    int n;
    cin >> n;
    int bi,bp;
    bp = 0;
    int ans = 0;
    for(int i=0; i<n-1; i++){
        cin >> bi;
        if(i==0){
            ans += bi;
        }else{
            ans += min(bi, bp);
        }
        bp = bi;
        if(i==n-2){
            ans += bi;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
while 1:
    n = int(input())
    if n == 0:
        break
    m = 1000 - n
    count = m // 500
    m %= 500
    count += m // 100
    m %= 100
    count += m // 50
    m %= 50
    count += m // 10
    m %= 10
    count += m // 5
    m %= 5
    count += m
    print(count)
    



Measured memory_bytes: 5584
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n;
    cin >> n;
    vi a(n), b(n);
    rep(i,n) cin >> a.at(i) >> b.at(i);
    vector<P> vp(n);
    rep(i,n) vp.at(i) = make_pair(a.at(i), b.at(i));
    sort(vp.begin(), vp.end(), greater<>());
    ll res = vp.at(0).first + vp.at(0).second;
    cout << res << endl;
}

Measured memory_bytes: 6316
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	int N;
	int c = 0;
	cin >> N;
	rep(i,N) {
		int a;
		cin >> a;
		c += a % 2;
	}
	if(c % 2)
		cout << "NO" << endl;
	else
		cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll dp[(int)1e5+10][13]={};
int main()
{
  string s;
  cin>>s;
  if(s[0]=='?'){
    for(int i=0;i<10;i++){
      dp[0][i]=1;
    }
  }
  else{
    dp[0][s[0]-'0']=1;
  }
  
  
  for(int i=1;i<s.size();i++){
    if(s[i]!='?'){
      for(int j=0;j<13;j++){
        dp[i][(j*10+(s[i]-'0'))%13]+=dp[i-1][j];
      }
      for(int j=0;j<13;j++){
        dp[i][j]%=mod;
      }
    }
    else{
      for(int k=0;k<10;k++){
        for(int j=0;j<13;j++){
          dp[i][(j*10+(k))%13]+=dp[i-1][j];
        }
        for(int j=0;j<13;j++){
          dp[i][j]%=mod;
        }
      }
    }
  }
  cout<<dp[s.size()-1][5];
}

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 1000010
const int MOD = 1000000007;

int fact[maxn];

int pw(int a, int b,int m = MOD) {
    if (b == 0)
        return 1;
    if (b & 1)return a * pw(a, b - 1) % m;
    return pw(a * a % m, b / 2);
}

int inverse(int a) {
    return pw(a, MOD - 2);
}

void solve() {
    fact[0] = 1;
    for (int i = 1; i < maxn; i++)
        fact[i] = i * fact[i - 1] % MOD;
    int x, y;
    cin >> x >> y;

    int a = (2 * y - x) / 3;
    int b = (x - a) / 2;
    if (a < 0 or b < 0 or (x + y) % 3) {
        cout << 0;
        return;
    }
    int ans = fact[a + b] * (inverse(fact[a] * fact[b] % MOD)) % MOD;
    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 8064
ok = true
gets.to_i.times.map{|i|
    gets.split.map(&:to_i)
}.sort_by{|it| it[1]}.inject(0){|acc_time, task|
    ok = ok && acc_time + task[0] <= task[1]
    acc_time + task[0]
}

puts(ok ? 'Yes' : 'No')


Measured memory_bytes: 22544
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <array>
#include <cmath>
#include <queue>
#include <stack>
#include <numeric>

using namespace std;


int main() {
	string s;
	cin >> s;
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'o') {
			cnt++;
		}
	}cout << 700 + 100 * cnt;

}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n,m; cin >> n >> m;
    vector<pair<ll,ll> > p;
    rep(i,n){
        int a; cin >> a;
        p.push_back(make_pair(a,1));
    }
    rep(i,m){
        int b,c; cin >> b >> c;
        p.push_back(make_pair(c,b));
    }
    sort(all(p),greater<pair<ll,ll> >());

    ll res = 0;
    ll cnt = 0;
        for(auto a:p){
            rep(i,a.second){
                res+=a.first;
                cnt++;
                if(cnt==n){
                    cout << res << endl;
                    return 0;
                }
            }
        }
}


Measured memory_bytes: 6512
import sys
from itertools import count, accumulate
from operator import mul
from functools import reduce
lines = sys.stdin.readlines()

positions = [int(i) for i in lines[1].split(' ')]

distances = [ j - i for i, j in zip(positions, positions[1:])]

n = len(distances)
p = pow(10,9) + 7

factorials = [1] + list(accumulate(range(1,n + 1), lambda x, y: (x * y) % p))

combinations = dict()
def combination(i, j):
    j = min(j, i - j)
    if (i, j) in combinations:
        return combinations((i, j))
    else:
        return factorials[i] // (factorials [j] * factorials[i - j])

permutations = dict()
def permutation(i, j):
    if (i, j) in permutations:
        return permutations((i, j))
    else:
        return reduce(mul, range(j, i+1))

def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n = n >> 1
    return res

s = 0
result = 0
for d, i in zip(distances, count(1)):
    lt = i - 1
    gt = n - i
    i_inv = modpow(i, p-2, p)
    t = factorials[n] * i_inv
    s += t
    result += d * s

print(int(result % (pow(10,9) + 7)))

Measured memory_bytes: 17924
#include <iostream>
#include <vector>
#include <stdio.h>
#include <string>

#define rep(i,n) for(int i = 0; i < n; i++)

typedef long long ll;

using namespace std;

const int INF = 1e9;
const double PI=3.14159265358979323846;

int main(){
  int n,m,l;
  cin >> n >> m >> l;

  ll a[110][110] = {{}};
  ll b[110][110] = {{}};
  ll ans[110][110] = {{}};

  rep(i,n)rep(j,m) cin >> a[i][j];
  rep(i,m)rep(j,l) cin >> b[i][j];

  rep(i,n)rep(j,l){
    rep(k,m) ans[i][j] += a[i][k] * b[k][j];
  }

  rep(i,n){
    rep(j,l){
      if(j==l-1){
	cout << ans[i][j];
	continue;
      }
      cout << ans[i][j] << " ";
      }
    cout << endl;
  }
}



Measured memory_bytes: 3372
import java.util.Scanner;
import java.util.stream.Stream;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.nextLine());
		int[] v_list = Stream.of(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		int[] c_list = Stream.of(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		int[] x_y_data = new int[N];
		int result=0;
		
		for(int i=0;i<N;i++) {
			if(v_list[i]-c_list[i]>0) {
				result += v_list[i]-c_list[i];
			}
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 28116
var mod = 1e9+7;
function Main(s) {
  var n = parseInt(s[0]);
  var sl = s[1].length;
  var a = Array(2).fill(0).map(a => Array(n+2).fill(0));
  a[0][0] = 1;
  for(var i = 1; i <= n; i++){
    a[i&1][0] = a[(i+1)&1][0] + a[(i+1)&1][1];
    a[i&1][0] %= mod;
    for(var j = 1; j <= i; j++){
      a[i&1][j] = a[(i+1)&1][j-1] * 2 + a[(i+1)&1][j+1];
      a[i&1][j] %= mod;
    }
  }
  console.log(permod(a[n&1][sl], powmod(2, sl)));
}
function abmod(){
	var rt = arguments[0];
	for(var i = 1; i < arguments.length; i++){
		rt = (rt >>> 16) * arguments[i] % mod * 0x10000 + (rt & 0xFFFF) * arguments[i];
		rt %= mod;
	}
	return rt;
}
function powmod(a,n){//a^n%mod
	var rt = 1;
	while(n){
		if(n & 1) rt = abmod(a, rt);
		a = abmod(a, a);
		n >>>= 1;
	}
	return rt;
}
function permod(a,n){
	var rt = powmod(n, mod-2);
	rt = abmod(rt, a);
	return rt;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"));

Measured memory_bytes: 7500
#include <stdio.h>

int main()
{
	char str[1200];
	int i;
	
	scanf("%[^\n]", str);
	
	i = 0;
	while (str[i] != '\0'){
		if (str[i] >= 'A' && str[i] <= 'Z'){
			printf("%c", str[i] + ('a' - 'A'));
		}
		else if (str[i] >= 'a' && str[i] <= 'z'){
			printf("%c", str[i] - ('a' - 'A'));
		}
		else {
			printf("%c", str[i]);
		}
		i++;
	}
	printf("\n");
	
	return 0;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N; cin >> N;
    vector<vector<int>> dist(N, vector<int>(N));
    for (int i=0;i<N;i++) for (int j=0;j<N;j++) dist[i][j] = abs(i-j);
    int l,r; cin >> l >> r; --l; --r;
    for (int i=0;i<N;i++) for (int j=0;j<N;j++){
        dist[i][j] = min({dist[i][j], dist[i][l]+1+dist[r][j], dist[i][r]+1+dist[l][j]});
    }
    vector<int> cnt(N);
    for (int i=0;i<N;i++) for (int j=0;j<N;j++) cnt[dist[i][j]]++;
    for (int k=1;k<=N-1;k++) cout << cnt[k] / 2<< endl;
    return 0;
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  lint s = 0, x, y, a, b, c, k = 0;
  cin >> x >> y >> a >> b >> c;
  v1i t(a), u(b), v(c);
  rep(i, a) cin >> t[i];
  rep(i, b) cin >> u[i];
  rep(i, c) cin >> v[i];
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  sort(u.begin(), u.end());
  reverse(u.begin(), u.end());
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  while(x > 0 || y > 0){
    if((v[k] - t[x-1] > v[k] - u[y-1] && x > 0) || y == 0){
      if(v[k] > t[x-1] && k < c){
        s += v[k];
        ++k;
      }
      else s += t[x-1];
      --x;
    }
    else{
      if(v[k] > u[y-1] && k < c){
        s += v[k];
        ++k;
      }
      else s += u[y-1];
      --y;
    }
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 1408
import sys
S = input()
if len(S)==7:
    if S == 'keyence':
        print('YES')
        sys.exit()


    else:
        print('NO')
        sys.exit()

red = len(S)-7
for i in range(0,len(S)-red+1):
    new = list(S)
    del new[i:i+red]
    news = ''

    for j in new:
        news += j


    if news == 'keyence':
        print('YES')
        sys.exit()

print('NO')


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <utility>
#include <queue>

using namespace std;

typedef pair<int, int> pii;
typedef priority_queue<int> pqi;

int main() {
    int n, m;
    cin >> n >> m;
    pii ab[n];
    for (int i = 0; i < n; i++) {
        cin >> ab[i].first >> ab[i].second;
    }
    sort(ab, ab+n);

    pqi q;
    int ans = 0;

    int j = 0;
    for (int i = 1; i <= m; i++) {
        while (j < n && ab[j].first <= i) {
            q.push(ab[j++].second);
        }
        if (!q.empty()) {
            ans += q.top();
            q.pop();
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N;
ll parent[100050];
ll SIZE[100050];
vector<l_l> children[100050];
vector<l_l> pathes[1000050];
ll SIZE2[100050];
ll dist[100050];
ll parent2[100050];
ll ans = 0;
int kernel;
void search(int from) {
    SIZE[from] = 1;
    for(int i = 0; i < pathes[from].size(); i++) {
        int to = pathes[from][i].first;
        ll cost = pathes[from][i].second;
        if(to == parent[from]) continue;
        parent[to] = from;
        children[from].push_back({to, cost});
        search(to);
        SIZE[from] += SIZE[to];
    }
    return;
}

void search2(int from, ll cost) {
    SIZE2[from] = 1;
    dist[from] = cost;
    for(int i = 0; i < pathes[from].size(); i++) {
        int to = pathes[from][i].first;
        ll path_cost = pathes[from][i].second;
        if(to == parent2[from]) continue;
        parent2[to] = from;
        search2(to, cost + path_cost);
        SIZE2[from] += SIZE2[to];
    }
    ans += 2 * dist[from];
    return;
}

int main() {
    //cout.precision(10);
    cin >> N;
    for(int i = 1; i < N; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        pathes[a].push_back({b, c});
        pathes[b].push_back({a, c});
    }
    search(1);
    kernel = -1;
    for(int i = 1; i <= N; i++) {
        //cout << i << " " << SIZE[i] << endl;
    }
    for(int i = 1; i <= N; i++) {
        if(kernel != -1) continue;
        int boundary = N / 2;
        if(N - SIZE[i] > boundary) continue;
        bool checker = true;
        for(int j = 0; j < children[i].size(); j++){
            int to = children[i][j].first;
            if(SIZE[to] > boundary) checker = false;
        }
        if(checker) kernel = i;
    }
    //cout << kernel << endl;

    search2(kernel, 0);
    for(int i = 1; i <= N; i++) {
        //cout << i << " " << SIZE2[i] << " " << dist[i] << endl;
    }
    for(int i = 0; i < pathes[kernel].size(); i++) {
        int now = pathes[kernel][i].first;
        if(SIZE2[now] * 2 == N) {
            ans -= dist[now];
            cout << ans << endl;
            return 0;
        }
    }
    ll minimum = 1e9;
    for(int i = 1; i <= N; i++) {
        if(i == kernel) continue;
        minimum = min(minimum, dist[i]);
    }
    cout << ans - minimum << endl;
    return 0;
}


Measured memory_bytes: 45952
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

using Field = vector<string>;
const int INF = 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
void solve(int h,int w){
    Field f(h);
    for(int i=0;i<h;i++) cin>>f[i];

    auto isRange=[&](int i,int j){
        return 0<=i && i<h && 0<=j && j<w;
    };
    auto isMovable=[&](int i,int j){
        return isRange(i,j) && f[i][j]!='x';
    };
    int si=-1,sj=-1;
    int ndirt = 0;
    vector<vector<int>> dirt(h,vector<int>(w,-1));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(f[i][j]=='o') si=i,sj=j;
            else if(f[i][j]=='*') dirt[i][j] = ndirt++;
        }
    }
    assert(si!=-1 && sj!=-1);
    vector<vector<vector<int>>> dp(1<<ndirt,vector<vector<int>>(h,vector<int>(w,INF)));
    struct X{
        int mask;
        int i,j;
    };
    queue<X> que;
    auto push=[&](int mask,int i,int j,int score){
        dp[mask][i][j]=score;
        que.push({mask,i,j});
    };
    push(0,si,sj,0);

    while(!que.empty()){
        auto tmp = que.front(); que.pop();
        int i=tmp.i,j = tmp.j,mask = tmp.mask;
        if(mask==(1<<ndirt)-1){
            cout<<dp[mask][i][j]<<endl;
            return;
        }
        for(int k=0;k<4;k++){
            int toi = i+dx[k],toj=j+dy[k];
            if(isMovable(toi,toj)){
                int tomask = mask;
                if(dirt[toi][toj]!=-1){
                    tomask |= (1<<dirt[toi][toj]);
                }
                if(dp[mask][i][j]+1<dp[tomask][toi][toj]){
                    push(tomask,toi,toj,dp[mask][i][j]+1);
                }
            }
        }
    }
    
    cout<<-1<<endl;
    return;
}
int main(){
    int w,h;
    while(cin>>w>>h,!(w==0 && h==0)){
        solve(h,w);
    }
    
    return 0;
}



Measured memory_bytes: 4268
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char c = s.charAt(0);
        if(Character.isUpperCase(c)) {
            System.out.println("A");
        } else {
            System.out.println("a");
        }
    }
}


Measured memory_bytes: 35720
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let k: i64 = iterator.next().unwrap().parse().unwrap();
    let s: i64 = iterator.next().unwrap().parse().unwrap();

    let mut count: u64 = 0;
    for x in 0..(k + 1) {
        for y in 0..(k + 1) {
            let z = s - x - y;
            if z >= 0 && z <= k {
                count += 1;
            }
        }
    }
    return format!("{}", count);
}


Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define F first
#define S second


typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n, m;
	cin >> n;
	VI a(n); rep(i, n)cin >> a[i];
	cin >> m;
	VI b(m); rep(i, m)cin >> b[i];

	VI re;
	set_difference(all(a), all(b), inserter(re, end(re)));
	for (auto x : re)cout << x << endl;
}


Measured memory_bytes: 5500
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int A, B, C; cin >> A >> B >> C;
	cout << (max({A, B, C}) == min({A, B, C})?"1":(max({A, B, C})!=A+B+C-max({A, B, C})-min({A, B, C}) &&  min({A, B, C})!=A+B+C-max({A, B, C})-min({A, B, C})?"3":"2")) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define qmax(x,y) (x=max(x,y))
#define qmin(x,y) (x=min(x,y))
#define mp(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline int read(){
	int ans=0,fh=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') fh=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
		ans=ans*10+ch-'0',ch=getchar();
	return ans*fh;
}
const int maxn=2e5+100,inf=1e9;
struct node{
	int x,y;
}a[maxn];
#define lc (o<<1)
#define rc (o<<1|1)
int n,lx,ln,rx,rn=inf,px[maxn<<2],pn[maxn<<2];
ll Ans=1e18;
bool cmp(node x,node y){return x.x==y.x?x.y>y.y:x.x>y.x;}
void build(int o,int l,int r){
	if(l==r){px[o]=pn[o]=a[l].y;return;}
	int mid=l+r>>1;
	build(lc,l,mid),build(rc,mid+1,r);
	px[o]=max(px[lc],px[rc]);
	pn[o]=min(pn[lc],pn[rc]);
}
int qmx(int o,int l,int r,int ql,int qr){
	if(ql==l&&qr==r){return px[o];}
	int mid=l+r>>1,ans=0;
	if(ql<=mid) ans=qmx(lc,l,mid,ql,min(qr,mid));
	if(qr>mid) qmax(ans,qmx(rc,mid+1,r,max(ql,mid+1),qr));
	return ans;
}
int qmn(int o,int l,int r,int ql,int qr){
	if(ql==l&&qr==r){return pn[o];}
	int mid=l+r>>1,ans=0x7fffffff;
	if(ql<=mid) ans=qmn(lc,l,mid,ql,min(qr,mid));
	if(qr>mid) qmin(ans,qmn(rc,mid+1,r,max(ql,mid+1),qr));
	return ans;
}
int main(){
//	freopen("nh.in","r",stdin);
//	freopen("zhy.out","w",stdout);
	n=read();
	for(int i=1;i<=n;i++){
		a[i].x=read(),a[i].y=read();
		if(a[i].x<a[i].y) swap(a[i].x,a[i].y);
		rn=min(rn,a[i].y);
	}
	for(int i=1;i<=n;i++)
		if(a[i].y==rn) swap(a[i],a[n]);
	sort(a+1,a+n,cmp),build(1,1,n);
	for(int i=1;i<n;i++){
		rx=a[1].x;
		lx=max(a[n].x,max(qmx(1,1,n,1,i),a[i+1].x));
		ln=min(a[n].x,min(qmn(1,1,n,1,i),i==n-1?inf:a[n-1].x));
		qmin(Ans,1ll*(rx-rn)*(lx-ln));
	}
	for(int i=1;i<n;i++){
		lx=max(a[n].x,a[1].x);
		rx=max(qmx(1,1,n,1,i),i==n-1?0:a[i+1].x);
		ln=min(a[n].x,min(i==n-1?inf:a[i+1].y,i==n-2?inf:a[n-1].x));
		qmin(Ans,1ll*(rx-rn)*(lx-ln));
	}
	printf("%lld\n",Ans);
	return 0;
}












Measured memory_bytes: 7808
import sys

n=int(input())
li=[int(x) for x in input().split()]

h=0
k=0

for i in range(n):
  if h<=li[i]:
    h=max(h,li[i])
  else:
    k=k+(h-li[i])
    h=max(h,li[i])
    
print(k)

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

using namespace std;

int main(void){
    int N,M,X,Y;
    cin>>N>>M>>X>>Y;
    vector<int> x(N),y(M);
    for(int i=0;i<N;i++){
        cin>>x[i];
    }
    for(int i=0;i<M;i++){
        cin>>y[i];
    }
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    if(x[N-1]>=X&&y[0]<=Y&&x[N-1]<y[0]){
        cout<<"No War"<<endl;
    }else{
        cout<<"War"<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
const ll MAX_N=1e5;
ll N,M,par[MAX_N],outdeg[MAX_N];
vector<ll> G[MAX_N];
void init(ll n){
	REP(i,n)par[i]=i;
}
ll fndpar(ll v){
	if(par[v]==v)return v;
	return par[v]=fndpar(par[v]);
}
void unite(ll a,ll b){
	a=fndpar(a);
	b=fndpar(b);
	par[a]=b;
}
bool same(ll a,ll b){
	a=fndpar(a);
	b=fndpar(b);
	return a==b;
}
void prtedge(ll v,ll u){
	cout<<v+1<<' '<<u+1<<endl;
}
void dfs(ll v,ll p){
	for(auto e:G[v]){
		if(e!=p)dfs(e,v);
	}
	if(p!=-1){
		if(outdeg[v]%2==0){
			prtedge(p,v);
			outdeg[p]++;
		}else{
			prtedge(v,p);
			outdeg[v]++;
		}
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>M;
	if(M%2==0){
		init(N);
		REP(i,M){
			ll a,b;
			cin>>a>>b;
			a--;
			b--;
			if(same(a,b)){
				prtedge(a,b);
				outdeg[a]++;
			}else{
				unite(a,b);
				G[a].push_back(b);
				G[b].push_back(a);
			}
		}
		dfs(0,-1);
	}else{
		cout<<-1<<endl;
	}
}

Measured memory_bytes: 12416
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>

using std::vector;
using std::map;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::min;
using std::max;

// @author: pashka

int nl, nr;
vector<vector<bool>> a;
vector<bool> z;
vector<int> p;

bool prime(int x) {
    if (x == 1) return false;
    for (int i = 2; i * i <= x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}

bool dfs(int x) {
    if (z[x]) return false;
    z[x] = true;
    for (int y = 0; y < nr; y++) {
        if (a[x][y]) {
            if (p[y] == -1 || dfs(p[y])) {
                p[y] = x;
                return true;
            }
        }
    }
    return false;
}

int main() {
    std::ios::sync_with_stdio(false);

    int n;
    cin >> n;

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

    vector<int> l;
    vector<int> r;

    for (int i = 0; i < n; i++) {
        if (i == 0 || x[i - 1] != x[i] - 1) {
            (x[i] % 2 == 0 ? l : r).push_back(x[i]);
        }
        if (i == n - 1 || x[i + 1] != x[i] + 1) {
            ((x[i] + 1) % 2 == 0 ? l : r).push_back(x[i] + 1);
        }
    }

    nl = l.size();
    nr = r.size();
    a.resize(nl);
    for (int i = 0; i < nl; i++) {
        a[i].resize(nr);
        for (int j = 0; j < nr; j++) {
            int d = abs(l[i] - r[j]);
            a[i][j] = prime(d);
        }
    }

    p.resize(nr);
    fill(p.begin(), p.end(), -1);
    z.resize(nl);
    int res = 0;
    for (int i = 0; i < nl; i++) {
        fill(z.begin(), z.end(), false);
        if (dfs(i)) {
            res++;
        }
    }

    nr -= res;
    nl -= res;

    int ans = nr + nl + res;
    if (nr % 2 == 1) {
        ans++;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
/*
*author : alfarelzaki
*created : 27.04.2019
*/
#include <bits/stdc++.h>
using namespace std;

int main (){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	cout << c/a*b << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;
 
typedef pair <int, int> pii;
const int N = 3e3 + 5;
const long long INF = 1e18;
const int mod = 1e9 + 123;//786433;//998244353;
const double Pi = acos(-1);
const int p = 510200;
 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

long long a, b, v, w;
long long t;

signed main()
{
	Fastio();
	cin >> a >> v >> b >> w >> t;
	if((t * (v - w)) >= abs(a - b))
	{
		cout << "YES";
	}
	else
	{
		cout << "NO";
	}
}

Measured memory_bytes: 3648