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

using namespace std;

typedef long long ll;
typedef long double ld;

#define ff 					first
#define ss 					second
#define sz(x) 				(int)(x).size()
#define all(x) 				begin(x), end(x)
#define rall(x) 			(x).rbegin(), (x).rend() 
#define rsz 				resize
#define ins 				insert 
#define ft 					front() 
#define bk 					back()
#define pf 					push_front 
#define pb 					push_back
#define eb 					emplace_back 
#define lb 					lower_bound 
#define ub 					upper_bound 
#define pqmax				priority_queue<int>
#define pqmin				priority_queue<int,vector<int>,greater<int>>
#define transup(x)			transform(x.begin(),x.end(),x.begin(),::toupper)
#define translow(x)			transform(x.begin(),x.end(),x.begin(),::tolower)
#define rep(i,a,b) 			for (int i = (a); i < (b); ++i)
#define per(i,a,b) 			for (int i = (b)-1; i >= (a); --i)
#define trav(a,x) 			for (auto a: x)

#define setbits(x)  		__builtin_popcountll(x)
#define zerobits(x)			__builtin_ctzll(x)

const ll mod = 1e9+7; // 998244353;
const ll inf = 1e18; 
const ld pie = acos((ld)-1);

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

template<typename T>
int dig(T x){

	int cnt=0;
	while(x>0){
		T r=x%10;
		cnt++;x/=10;

	}
	return cnt;
}

int main(){

	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
    auto start = std::chrono::high_resolution_clock::now();
    /*start from here*/
    
    unsigned long long k;
    cin>>k;
    if(k%2==0 || k%5==0){
    	cout<<-1<<'\n';
    }else{

    	int cur=7%k;
    	int ans=1;
    	while(cur!=0){

    		cur=10*cur + 7;
    		cur=cur%k;
    		ans++;
    	}

    	cout<<ans<<'\n';
    }

	auto stop = std::chrono::high_resolution_clock::now(); 
    auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start); 
    
    // cerr << "Time taken : " << ((long double)duration.count())/((long double) 1e9) <<"s "<< endl;     

    return 0;

    /*STUFF TO LOOK:	
	1. Special cases/corner cases(n==0||n==1)
	2. Variables in loops
	3. Input ranges
	*/
}


Measured memory_bytes: 3588
import random

def is_prime(n):
    if n == 2: return True
    if n == 1 or n & 1 == 0: return False

    d = (n - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    for k in range(100):
        a = random.randint(1, n - 1)
        t = d
        y = pow(a, t, n)

        while t != n - 1 and y != 1 and y != n - 1:
            y = (y * y) % n
            t <<= 1

        if y != n - 1 and t & 1 == 0:
            return False

    return True

x=int(input())
for i in range(x,1000000):
    if is_prime(i):
        print(i)
        break



Measured memory_bytes: 3316
#include <stdio.h>
 
main(void)
{
int H, W,i, j;

while (1) {
	scanf("%d %d", &H, &W);
	if (H == 0 && W == 0)
	break;

	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			if (i % 2 == 0) {
				if (j % 2 == 0) printf("#");
			else printf(".");
			}
		else {
			if (j % 2 == 0) printf(".");
			else
			printf("#");
			}
		}
		printf("\n");
		}
	printf("\n");
	}
	return 0;
}

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

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
} initializer;

long long n, a, b, c;
vector<string> s;

void rec(int idx, vector<string> &v, long long a, long long b, long long c) {
  if (idx == n) {
    if (a >= 0 and b >= 0 and c >= 0) {
      cout << "Yes" << endl;
      for (auto x: v) cout << x << endl;
      exit(0);
    } else {
      return;
    }
  }
  if (a < 0 or b < 0 or c < 0) return;

  if (s[idx] == "AB") {
    v.emplace_back("A");
    rec(idx+1, v, a+1, b-1, c);
    v.pop_back();
    v.emplace_back("B");
    rec(idx+1, v, a-1, b+1, c);
    v.pop_back();
  } else if (s[idx] == "AC") {
    v.emplace_back("A");
    rec(idx+1, v, a+1, b, c-1);
    v.pop_back();
    v.emplace_back("C");
    rec(idx+1, v, a-1, b, c+1);
    v.pop_back();
  } else {
    v.emplace_back("B");
    rec(idx+1, v, a, b+1, c-1);
    v.pop_back();
    v.emplace_back("C");
    rec(idx+1, v, a, b-1, c+1);
    v.pop_back();
  }
}

int main() {
  cin>>n>>a>>b>>c;
  for (int i = 0; i < n; i++) {
    string st; cin>>st;
    s.emplace_back(st);
  }

  vector<string> v;
  rec(0, v, a, b, c);
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 20572
#include <iostream>
#include <vector>
#include <iomanip>
#include <cstring>
#include <string.h>
#include <iterator>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <limits.h>
#include <string>
#include <bitset>
#include <map>
#include <numeric>
#include<unordered_map>


#define endl cout<<"\n"
#define lli long long int
#define ld long double
#define M_PI (3.14159265358979323846264338327950288)
#define MOD (10e9 + 7)

using namespace std;

//fast-exponentiation-lli
unsigned lli expo_fast(lli a, lli b) {
	a = a;
	lli result = 1;
	while (b) {
		//multiplyint(tos(result), a);
		if (b & 1)result = (result * a);
		b >>= 1;
		a = (a*a);
	}
	return (result);
}


void take_in(vector<lli> *arr) {
	for (int i = 0; i < arr->size(); i++)cin >> (*(arr))[i];
}


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

}

/* Iterative Function to calculate (x^y)%p in O(log y) */
unsigned lli power(lli x, unsigned lli y, lli p)
{
	lli res = 1;      // Initialize result 
	x = x % p;  // Update x if it is more than or equal to p 
	while (y > 0) {
		// If y is odd, multiply x with result 
		if (y & 1)res = (res*x) % p;
		// y must be even now 
		y = y >> 1;
		x = (x*x) % p;
	}
	return res;
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n,w; cin >> n>>w;
	vector<lli>weight(n + 1), val(n + 1);
	for (int i = 1; i <= n; i++)cin >> weight[i] >> val[i];
	vector<vector<lli>> dp(n + 1, vector<lli>(100000 + 1,1e15));
	dp[0][0] = 0;
	vector<vector<lli>> dp2(n + 1, vector<lli>(100000 + 1,0));
	for (int i = 1; i <= n; i++) {
		dp[i][0]=0;
		for (int v = 1; v <= 100000; v++) {
			if (val[i] > v) {
				dp[i][v] = dp[i - 1][v];
				dp2[i][v] = dp2[i - 1][v];
			}
			else {
				if (weight[i] + dp[i - 1][v - val[i]] > dp[i-1][v]  ) {
					//work needed
					//if(dp[i][v] <=)
					dp[i][v] = dp[i - 1][v];
					dp2[i][v] = dp2[i - 1][v];

				}
				else {
					dp[i][v] = weight[i] + dp[i - 1][v - val[i]];
					dp2[i][v] = val[i] + dp2[i - 1][v - val[i]];
				}
			}
		}
	}
	//cout << "SHUDKKC";
	for (int i = 100000; i >= 00000; i--) {
		if (dp[n][i] <= w) {
			cout << i << " "; break;
		}
	}
	//system("PAUSE");
}


Measured memory_bytes: 159088
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


#define N 1024

int main()
{
	char buff[N];
	
	while (NULL != fgets(buff, N, stdin))
	{
		int a, b;
		sscanf(buff, "%ld %ld", &a, &b);
		
		int  m, n, k;
		m = a;
		n = b;
		do
		{
			k = m % n;
			m = n;
			n = k;
		} while (0 != k);
		
		printf("%d %d\n", m, a * (b / m));
	}
	return 0;
}

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

int main(){
    priority_queue<int> PQ;
    while (1) {
        string command;
        cin >> command;
        if (command == "end") {
            return 0;
        }
        if (command == "insert") {
            int k;
            cin >> k;
            PQ.push(k);
            continue;
        }
        if (command == "extract") {
            cout << PQ.top() << endl;
            PQ.pop();
        }
    }
    return 0;
}

Measured memory_bytes: 6960
a = input()

a = a.split(" ")
for i in range(3):
    a[i] = int(a[i])

if a[0] != a[1] and a[1] != a[2] and a[0] != a[2]:
    print("No")
elif a[0] == a[1]:
    if a[0] == a[2]:
        print("No")
    elif a[0] != a[2]:
        print("Yes")
elif a[0] == a[2]:
    if a[0] == a[1]:
        print("No")
    elif a[0] != a[1]:
        print("Yes")
elif a[1] == a[2]:
    print("Yes")

Measured memory_bytes: 3064
wlist = []
w = input()
for letter in w:
    wlist.append(letter)
a = []
b = []
i = 0
for letter in sorted(wlist):
    if i%2==1:
        a.append(letter)
    else:
        b.append(letter)
    i += 1
if sorted(a) == sorted(b):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#define N 101
int main(){

    int n,i;
    double a[N],sum=0,tmp=0;

    scanf("%d",&n);

    for(i = 1 ; i <= n ; i++){
        scanf("%lf",&a[i]);
        tmp += 1 / a[i];
    }

    sum = 1 / tmp;

    printf("%f",sum);
    
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static readonly int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			int n = int.Parse(Console.ReadLine());
			//string s = Console.ReadLine();
			//long x = long.Parse(Console.ReadLine());
			int[] p = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int[] q = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			int st = 0, en = 0;
			for (int i = 1, j = 1; i <= n; i++, j *= 10) {
				st = st * 10 + i;
				en = en + i * j;
				px = px * 10 + p[i - 1];
				qx = qx * 10 + q[i - 1];
			}
			saiki(n, 0, 0, new bool[n]);
			Console.WriteLine(Math.Abs(a - b));


			Console.Out.Flush();
		}

		static int px = 0;
		static int qx = 0;
		static int a = 0;
		static int b = 0;

		static int saiki(int n, int m, int c, bool[] f)
		{
			if (n == 0) {
				c++;
				if (px == m) { a = c; }
				if (qx == m) { b = c; }
				//System.Diagnostics.Debug.WriteLine($"{c} {m}");
				return c;
			}
			for (int i = 1; i <= f.Length; i++) {
				if (!f[i - 1]) {
					f[i - 1] = true;
					c = saiki(n - 1, m * 10 + i, c, f);
					f[i - 1] = false;
				}
			}
			return c;
		}

	}
}


Measured memory_bytes: 13396
#include <iostream>
using namespace std;
int main(void){
  int a,b,c;
  cin >> a;
  cin >> b;
  cin >> c;

  if(a <= b && b <= c){
      cout << a<< " "  << b<< " "  << c;
  }
  else if(a <= c && c <= b){
      cout << a << " " << c<< " "  << b;
  }
  else if(b < a && a < c){
      cout << b << " " << a << " " << c;
  }
  else if(b <= c && c <= a){
      cout << b << " " << c << " " << a;
  }
  else if(c <= a && a<= b){
      cout << c << " " << a << " " << b;
  }
  else{
      cout << c<< " "  << b<< " "  << a;
  }

  cout << endl;
}


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

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

typedef long long ll;
using namespace std;

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 int dy[] = { 0, 0, 1, -1 };
//const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);

vector<ll> a, b;

int main()
{
	ll a,b,c;
	ll tmp;
	ll x,y,z = 0;
	cin >> x >> y >> z;
	a = x;
	b = y;
	c = z;
	swap(a,b);
	swap(a, c);
	cout << a << " "<< b << " " << c << endl;

	return 0;
}


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

int main() {
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    scanf("%d", &k);
    printf("%d\n", a[k - 1]);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 3030, mo =1e9+7;
int n,m,f[N][N][2],g[N][N][2];
void add(int &x, int y){x=x+y<mo?x+y:x+y-mo;}
int main() {
	read(n);read(m);rep(i,0,n)f[0][i][i==0]=1;
	rep(i,0,m-1){
		rep(j,0,n)rep(k,0,1)if(f[i][j][k]){
			if(j-1>=0)add(g[i][j-1][k|(j-1==0)],f[i][j][k]);
			if(j+1<=n)add(g[i][j][k],f[i][j][k]);
		}
		rep(j,0,n)rep(k,0,1)if(g[i][j][k]){
			if(j>=0)add(f[i+1][j][k|(j==0)],g[i][j][k]);
			if(j+1<=n)add(f[i+1][j+1][k],g[i][j][k]);
		}
	}
	int res=0;rep(i,0,n)add(res,f[m][i][1]);cout<<res;
	return 0;
}


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

#define int long long

int n,a,b,v[51];

int C[51][51];
void comb_table(int N){
  for(int i=0;i<=n;i++){
    for(int j=0;j<=i;j++){
      if(j==0 || j==i){
        C[i][j]=1LL;
      }else{
        C[i][j]=(C[i-1][j-1]+C[i-1][j]);
      }
    }
  }
}
signed main(){
  cin>>n>>a>>b;
  for(int i=0;i<n;i++){
    cin>>v[i];
  }

  sort(v,v+n);
  reverse(v,v+n);
  comb_table(n);

  double temp=0;
  for(int i=0;i<a;i++){
    temp+=v[i];
  }
  cout<<fixed<<setprecision(10)<<temp/a<<endl;

  int ans=0;
  int x=0;
  if(v[a-1]==v[0]){
    for(int i=0;i<n;i++){
      if(v[i]==v[0])
      x++;
    }
    for(int i=a;i<=b;i++){
      ans+=C[x][i];
    }
    cout<<ans<<endl;
    return 0;
  }

  int a_num=0;
  for(int i=0;i<n;i++){
    if(v[a-1]==v[i])a_num++;
  }
  int a_num2=0;
  for(int i=0;i<a;i++){
    if(v[a-1]==v[i])a_num2++;
  }

  ans=C[a_num][a_num2];
  cout<<ans<<endl;


}


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

typedef long long int LLI;

int N;
LLI ans;
LLI A, B;
LLI X[114514];

int main() {
  scanf("%d", &N);
  scanf("%lld%lld", &A, &B);
  scanf("%lld", &X[0]);
  for (int i=1; i<N; i++) {
    scanf("%lld", &X[i]);
    LLI ac = (X[i]-X[i-1])*A;
    ans += min(ac, B);
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

const int V = 100000;
vector<vector<int>> G(2*V);
vector<ll> cnt(2);
vector<bool> visited(2*V);

void dfs(int cv){
    visited[cv] = true;
    cnt[cv/V]++;
    
    for(auto nv : G[cv]){
        if(visited[nv]) continue;
        dfs(nv);
    }

    return ;
}

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

    int n; cin>>n;
    for(int i=0; i<n; i++){
        int x, y; cin>>x>>y;
        x--, y--;
        y += V;
        G[x].emplace_back(y);
        G[y].emplace_back(x);
    }

    ll ans = 0;
    for(int i=0; i<V*2; i++){
        if(visited[i]) continue;
        cnt[0] = cnt[1] = 0LL;
        dfs(i);
        ans += cnt[0] * cnt[1];
    }

    ans -= n;
    cout << ans << endl;
}

Measured memory_bytes: 9344
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define int ll
#define endl "\n"
#define all( x ) x.begin(), x.end()
#define fast ios::sync_with_stdio(0);cin.tie(0);

typedef unsigned long long ull;

const int inf = 1e9 + 5;
const long double PI = 3.141592653589793;

void solve(){
  int n;
  cin >> n;
  vector<int> dp(n+1, 0);
  for(int i = 1; i < n+1; i++){
    for(int j = i; j<n+1; j+=i){
      dp[j]++;
    }
  }
  int ans = 0;
  for(int i = 1; i<n+1;i++){
    ans += i * dp[i];
  }
  cout << ans << endl;
  return;
}  
signed main(){
  fast;
  int t;
  t = 1;
  //cin>>t;
  while(t--){
    solve();
  }
}

Measured memory_bytes: 81340
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
using namespace std;

int main(){
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;
    if (a>=c+e && b>=d+e && c-e>=0 && d+e>=0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define put(x) cout<<#x<<" = "<<x<<endl;
#define X first
#define Y second
#define pb push_back
using namespace std;
typedef long long num;
typedef pair<int,int> point;
const int maxn=1e5+10,inf=1e9+10;

int n;
string s;

int32_t main(){
	cin>>s;
	n=s.size();
	num cnt=0,sum=0;
	rep(i,0,n){
		if(s[i]=='B'){
			cnt++;
		}else{
			sum+=cnt;
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
#include<cstring>
#include<vector>
#include<stack>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<functional>
#define io ios::sync_with_stdio(false)
#define inf 0x3f3f3f3f
#define ll long long
#define P pair<int,int>
#define lc rt*2
#define rc rt*2+1
const int maxn = 2e5 + 10;
const int mod = 1e9 + 7;

using namespace std;

int a[maxn];

int main()
{
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	ll sum = 0;
	int pos = 0;
	for (int i = 0; i < k; i++)
		sum += a[i];
	ll m = sum;
	for (int i = k; i < n; i++)
	{
		sum = sum - a[i - k] + a[i];
		if (sum > m)
		{
			m = sum;
			pos = i - k + 1;
		}
	}
	double ans = 0;
	for (int j = 0; j < k; j++)
		ans += (a[pos + j] + 1) / 2.0;
	cout << fixed << setprecision(12) << ans;
	return 0;
 }

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
  long N, C;

  std::cin >> N;
  std::cin >> C;

  std::vector<long> X(N);
  std::vector<long> V(N);

  std::vector<long> sum_cw(N);
  std::vector<long> max_hist_cw(N);
  long max_cw=0;
  {
    long sum = 0;

    for (long i=0; i<N; i++) {
      std::cin >> X[i];
      std::cin >> V[i];

      if (i==0) max_hist_cw[0] = 0;

      sum += V[i];
      sum_cw[i] = sum - X[i];

      if (sum - X[i] > max_cw) max_cw = sum - X[i];
      if (i+1 < N) max_hist_cw[i+1] = max_cw;
    }
  }

  std::vector<long> max_hist_ccw(N);
  long max_ccw=0;
  long max_ccw_cw=0;
  {
    long sum = 0;

    for (long i=0; i<N; i++) {
      long x = C - X[N-1-i];
      long v = V[N-1-i];

      if (i==0) max_hist_ccw[0] = 0;

      sum += v;

      if (sum - x > max_ccw) max_ccw = sum - x;
      if (i+1 < N) max_hist_ccw[i+1] = max_ccw;

      if (max_ccw - x + max_hist_cw[N-1-i] > max_ccw_cw)
        max_ccw_cw = max_ccw - x + max_hist_cw[N-1-i];
    }
  }

  long max_cw_ccw=0;
  for (long i=0; i<N; i++) {
    if (sum_cw[i] - X[i] + max_hist_ccw[N-1-i] > max_cw_ccw)
      max_cw_ccw = sum_cw[i] - X[i] + max_hist_ccw[N-1-i];
  }

  std::cout << std::max({max_cw, max_ccw, max_cw_ccw, max_ccw_cw})
            << std::endl;

  return 0;
}


Measured memory_bytes: 4224
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

i=int(input())

print(a[i-1])


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

vector<long double>X; int H, W, N; long double x[209], y[209];

long double solve() {
	X.clear();
	x[N + 0] = W; y[N + 0] = 0; x[N + 1] = W; y[N + 1] = H;
	x[N + 2] = 0; y[N + 2] = 0; x[N + 3] = 0; y[N + 3] = H;
	for (int i = 0; i < N + 4; i++) {
		for (int j = 0; j < N + 4; j++) {
			if (x[i] - x[j] < 1e-2) continue;
			long double A = (y[i] - y[j]) / (x[i] - x[j]);
			long double B = y[i] - A*x[i];
			if (B < 0 || B > 1.0L*H) continue;
			X.push_back(B);
		}
	}
	for (int i = 0; i < N; i++) {
		if (x[i] < 1e-2) X.push_back(y[i]);
		if (x[i] > W - 1e-2) X.push_back(y[i]);
	}
	X.push_back(0);
	X.push_back(1.0L*H);
	sort(X.begin(), X.end()); X.erase(unique(X.begin(), X.end()), X.end());
	long double sum = 0;
	for (int i = 0; i < X.size() - 1; i++) {
		vector<long double>G1, G2;
		for (int j = 0; j < N; j++) {
			if (x[j] < 1e-2) {
				if (X[i] - y[j] >= -1e-9) G1.push_back(0);
				else G1.push_back(H);
			}
			else {
				long double P = (y[j] - X[i]); P *= (1.0L*W / x[j]); P += X[i];
				P = max(0.0L, min(1.0L*H, P));
				G1.push_back(P);
			}
		}
		for (int j = 0; j < N; j++) {
			if (x[j] < 1e-2) {
				if (X[i] - y[j] >= -1e-9) G2.push_back(0);
				else G2.push_back(H);
			}
			else {
				long double P = (y[j] - X[i + 1]); P *= (1.0L*W / x[j]); P += X[i + 1];
				P = max(0.0L, min(1.0L*H, P));
				G2.push_back(P);
			}
		}
		sort(G1.begin(), G1.end());
		sort(G2.begin(), G2.end());
		long double SA1 = G1[N / 2] - G1[N / 2 - 1];
		long double SA2 = G2[N / 2] - G2[N / 2 - 1];
		sum += 0.5L*(SA1 + SA2)*(X[i + 1] - X[i]);
	}
	return sum / (1.0L*H*H);
}

int main() {
	while (true) {
		cin >> W >> H >> N; N *= 2; if (H == 0) break;
		for (int i = 0; i < N; i++) cin >> x[i] >> y[i];
		printf("%.12Lf\n", solve());
	}
	return 0;
}


Measured memory_bytes: 3420
from math import log10, floor
import bisect


N = int(input())

M = []


def rec(s):
    for x in "357":
        xx = s + x
        if int(xx) >= 2e9:
            break
        if "3" in xx and "5" in xx and "7" in xx:
            M.append(int(xx))
        rec(xx)


rec("")
M.sort()
ans = bisect.bisect_right(M, N)
print(ans)


Measured memory_bytes: 4108
#include <stdio.h>

int main(void) {
    int n,m,xpos,ypos;
    scanf("%d %d %d %d",&n,&m,&xpos,&ypos);
    int x[n];
    int y[n];
    int xmax = xpos;
    int ymin = ypos;
    for (int i=0;i<n;i++) {
        scanf("%d",&x[i]);
        xmax = (xmax>x[i])?xmax:x[i];
    }
    for (int i=0;i<m;i++) {
        scanf("%d",&y[i]);
        ymin = (ymin<y[i])?ymin:y[i];
    }
    if (xmax<ymin) printf("No War\n");
    else printf("War\n");

    return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
ans = 1
i = 0
flg = 3
while i < n - 1:
    if (flg >> 1) & 1 and a[i] > a[i + 1]:
        flg -= 2
    if flg & 1 and a[i] < a[i + 1]:
        flg -= 1
    if flg == 0:
        ans += 1
        flg = 3
    i += 1
print(ans)

Measured memory_bytes: 14224
fn main() {
  fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
  }
  fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
  }
  let ABC = read_vec::<i32>();
  println!("{}", ABC[0] * ABC[1] / 2);
}



Measured memory_bytes: 4352
import sys
input = sys.stdin.readline

H,W=map(int,input().split())

A=[list(map(int,input().split())) for i in range(H)]
B=[list(map(int,input().split())) for i in range(H)]

SA=[[0]*W for i in range(H)]

for i in range(H):
    for j in range(W):
        SA[i][j]=abs(A[i][j]-B[i][j])

DP=[[[0]*6400 for i in range(W)] for j in range(H)]

DP[0][0][SA[0][0]]=1

for i in range(H):
    for j in range(W):
        for k in [l for l in range(6400) if DP[i][j][l]==1]:
            if i+1<H:
                if k+SA[i+1][j]<6400:    
                    DP[i+1][j][k+SA[i+1][j]]=1
                if abs(k-SA[i+1][j])<6400:
                    DP[i+1][j][abs(k-SA[i+1][j])]=1

            if j+1<W:
                if k+SA[i][j+1]<6400:    
                    DP[i][j+1][k+SA[i][j+1]]=1
                if abs(k-SA[i][j+1])<6400:
                    DP[i][j+1][abs(k-SA[i][j+1])]=1

for i in range(6400):
    if DP[-1][-1][i]==1:
        ANS=i
        break

print(ANS)


Measured memory_bytes: 362760
#include <cstdio>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;

int n,s[105],ans=0x3f3f3f3f;
int a[105];

int main(void){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]),
	s[i]=s[i-1]+a[i];
	for(int i=1;i<n;i++){
		ans=min(ans,abs(s[i]-s[n]+s[i]));
	}
	printf("%d",ans);
}


Measured memory_bytes: 128
s = int(input())
l = [s]
m = 1
a = s
while True:
    if a % 2 == 0:
        a = int(a/2)
    else:
        a = 3 * a + 1
    l.append(a)
    m += 1
    if a in l[:m-1]:
        break
print(m)

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner scanner =new Scanner(System.in);
        int N=scanner.nextInt();
        int[] ints=new int[N];
        for(int i=0;i<N;i++){
            ints[i]=scanner.nextInt();
        }
        for(int i=1;i<N;i++){
            for(int j=0;j<ints.length;j++){
                System.out.print(ints[j]);
                if(j!=ints.length-1){
                    System.out.print(" ");
                }
            }
            System.out.println("");
            int v=ints[i];
            int j=i-1;
            while(j>=0&&ints[j]>v){
                ints[j+1]=ints[j];
                j--;
            }
            ints[j+1]=v;
        }
        for(int j=0;j<ints.length;j++){
            System.out.print(ints[j]);
            if(j!=ints.length-1){
                System.out.print(" ");
            }
        }
        System.out.println("");
    }
}



Measured memory_bytes: 34092
#include <iostream>

using namespace std;

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

    int a;
    for (int i = 0; i < n; ++i)
    {
        cin >> a;

        if (a % 2 == 0)
        {
            if (a % 3 && a % 5)
            {
                cout << "DENIED\n";
                return 0;
            }
        }
    }

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


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.sort()
dp = [True] * (A[-1]+1)

for i,num in enumerate(A):
    if i < N-1 and A[i+1] == num:
        dp[num] = False
    for j in range(2*num, A[-1]+1, num):
        dp[j] = False

print(len([i for i in A if dp[i]]))

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

int main()
{
	int r, c, A[100][100], R[100], C[100], sum = 0;

	cin >> r >> c;

	for (int i = 0; i < r; i++){
		for (int j = 0; j < c; j++){
			A[i][j] = 0;
			R[i] = 0;
			C[j] = 0;
		}
	}

	for (int i = 0; i < r; i++){
		for (int j = 0; j < c; j++){
			cin >> A[i][j];
			R[i] += A[i][j];
			C[j] += A[i][j];
			sum += A[i][j];
		}
	}

	for (int i = 0; i < r; i++){
		for (int j = 0; j < c; j++){
			cout << A[i][j] << " ";
		}
		cout << R[i] << endl;
	}
	for (int j = 0; j < c; j++){
		cout << C[j] << " ";
	}
	cout << sum << endl;

	return 0;
}

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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int a, b, c, t;
	cin >> a >> b >> c;
	t = a;
	a = b;
	b = t;
	t = a;
	a = c;
	c = t;
	cout << a << ' ' << b << ' ' << c << '\n';

	return 0;
}

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

long long layer_num[51], patty_num[51];

long long getPatty(long long level, long long x) {
	if (level == 0 && x == 1) {
		return 1;
	}
	else if (level == 0 && x != 1) {
		return 0;
	}
	else {
		if (x < layer_num[level - 1] + 1) {
			return getPatty(level - 1, x - 1);
		}
		else if (x == layer_num[level - 1] + 1) {
			return patty_num[level - 1];
		}
		else if(x == layer_num[level - 1] + 2) {
			return patty_num[level - 1] + 1;
		}
		else if (x == 2 * layer_num[level - 1] + 2 || x == 2 * layer_num[level - 1] + 3) {
			return 2 * patty_num[level - 1] + 1;
		}
		else {
			return patty_num[level - 1] + 1 + getPatty(level - 1, x - (layer_num[level - 1] + 2));
		}
	}
}

int main() {
	long long N, X;
	cin >> N >> X;

	layer_num[0] = 1;
	patty_num[0] = 1;
	for (int i = 1; i <= 50; i++) {
		layer_num[i] = 2 * layer_num[i - 1] + 3;
		patty_num[i] = 2 * patty_num[i - 1] + 1;
	}

	long long ans = getPatty(N, X);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

const int mod = 1e9 + 7;
const int inf = 1e9;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;

struct edge {ll from,to,cost;};

int main()
{
    int n;
    cin >> n;
    map<string,ll> m;
    ll ans = 0;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        
        map <string,ll>::iterator it = m.find(s);
        if(it == m.end()){
            m[s] = 1;
        }else{
            ans += m[s];
            m[s]++;
        }
    }
    cout << ans;
}

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

using namespace std;

void Main() {
    int A, B, K;
    cin >> A >> B >> K;

    int N = min(A, B);
    vector<int> div;
    for (int i = 1; i <= N; ++i) {
        if (A % i == 0 && B % i == 0) {
            div.push_back(i);
        }
    }
    reverse(div.begin(), div.end());
    cout << div[K - 1] << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3636
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n, m = sc.nextInt
    val stairs = Array.fill[Boolean](n + 1)(true)
    for (i <- 0 until m) {
      val a = sc.nextInt
      stairs(a) = false
    }

    val mod = 1000000007
    val dp = Array.fill[Int](n + 1)(0)
    dp(0) = 1
    for (i <- 0 to n) {
      for (j <- 1 to 2) {
        val next = i + j
        if (next <= n && stairs(next) == true) {
          dp(next) += dp(i)
          dp(next) = dp(next) % mod
        }
      }

    }
    println(dp(n))
  }
}


Measured memory_bytes: 51848
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;

int color[N] ;
vector<pair<int ,int > > v[N];


void dfs(int i , int col , int par = -1) {
	
	for(auto j : v[i]) {
		int node = j.first , c = j.second;
		if(node == par) continue;
		if(c % 2 == 0) color[node] = col;
		else color[node] = col^1;
		dfs(node ,color[node] , i);
	}
	
}
		


int main() {
	int n ; cin >> n;
	for(int i = 0 ;i < n - 1; i ++) {
		int x , y, w ; cin >> x >> y >> w;
		v[x].push_back({y , w});
		v[y].push_back({x , w});
	}
	
	dfs(1 , 0);
	for(int i = 1; i <= n ; i ++) cout << color[i] << endl;
}
	


Measured memory_bytes: 11520
#include<stdio.h>
#include<stdlib.h>

int main(void){
	int n,total,i;
	int d[3];
	int *a;

	scanf("%d",&n);
	a=(int *)malloc(sizeof(int)*n);
	d[0]=0;
	scanf("%d",&d[1]);
	a[0]=abs(d[1]);
	total=a[0];
	for(i=0;i<n-1;i++){
		scanf("%d",&d[2]);
		a[i+1]=abs(d[1]-d[2]);
		total+=a[i+1];
		a[i]+=a[i+1]-abs(d[0]-d[2]);
		d[0]=d[1];
		d[1]=d[2];
	}
	a[n-1]+=abs(d[1])-abs(d[0]);
	total+=abs(d[1]);
	for(i=0;i<n;i++){
		printf("%d\n",total-a[i]);
	}

	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) max_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)

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

    ll L,R; cin >> L >> R;
    if(R - L >= 2018){
        cout << 0 << endl;
        return 0;
    }
    ll ans = INF;
    ll temp1,temp2;
    for(int i = L; i <= R;i++){
        temp1 = i % 2019;
        for(int j = i + 1;j <= R;j++){
            temp2 = j % 2019;
            ll timesmod = temp1 * temp2 % 2019;
            ans = min(ans, timesmod);
        }
    }
    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 dump(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

ll powmod(ll a, ll b, ll p) {
  if(b == 0) return 1;
  if(b % 2 == 0) {
    ll d = powmod(a, b / 2, p);
    return ((d % p) * (d % p)) % p;
  }
  return ((a % p) * (powmod(a, b - 1, p) % p)) % p;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll MOD = 1e9 + 7;
  ll m, n;
  cin >> m >> n;
  cout << powmod(m, n, MOD) << endl;

  return 0;
}


Measured memory_bytes: 3224
n, q = list(map(int, input().split()))
s = input()

cnt = [0 for i in range(n)]
ac = 0
for i in range(1, n):
    if s[i-1:i+1] == "AC":
        ac += 1

    cnt[i] = ac

for i in range(q):
    l, r = list(map(int, input().split()))

    print(cnt[r-1]-cnt[l-1])

Measured memory_bytes: 11560
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <climits>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <bitset>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;

#define ten(n) ((int)1e##n)
#define COUT cout <<
#define SPACE_COUT << " "  <<
#define COMMA_COUT << ", " <<
#define ENDL << endl;

#define MAX_N 200000

class UnionFind
{
public:
    std::vector<long> _parent;
    std::vector<long> _rank;
    UnionFind(long n)
    {
        for(long i = 0; i < n; i++) {
            _parent.push_back(i);
            _rank.push_back(0);
        }
    }
    
    long root(long i)
    {
        return (_parent[i] == i) ? i: 
                _parent[i] = root(_parent[i]);
    }
    
    bool same(long i, long j)
    {
        return root(i) == root(j);
    }
    
    void unite(long i, long j)
    {
        i = root(i);
        j = root(j);
        if (i == j) return;

        if(_rank[i] < _rank[j])
            _parent[i] = j;
        else {
            _parent[j] = i;
            if (_rank[i] == _rank[j])
                _rank[i]++;
        }
    }
};

int
main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K, L;
    cin >> N >> K >> L;

    UnionFind car(N);
    vector<pair<int, int> > v(K);
    for (int i = 0; i < K; ++i) {
        int p, q;
        cin >> p >> q; p--; q--;
        if (p > q) v[i] = make_pair(q, p);            
        else v[i] = make_pair(p, q);
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < K; ++i) {
        pair<int, int> pq = v[i];
        car.unite(pq.first, pq.second);
    }

    UnionFind train(N);
    vector<pair<int, int> > vv(L);
    for (int i = 0; i < L; ++i) {
        int p, q; 
        cin >> p >> q; p--; q--;
        if (p > q) vv[i] = make_pair(q, p);            
        else vv[i] = make_pair(p, q);
    }
    sort(vv.begin(), vv.end());
    for (int i = 0; i < L; ++i) {
        pair<int, int> pq = vv[i];
        train.unite(pq.first, pq.second);
    }

    map<pair<int, int>, int> counts;
    for (int i = 0; i < N; ++i) {
        int cp = car.root(i);
        int tp = train.root(i);
        pair<int, int> p = make_pair(cp, tp);
        if (counts.find(p) == counts.end()) {
            counts.insert(make_pair(p, 0));
        }
        counts[p]++;
    }

    for (int i = 0; i < N; ++i) {
        int cp = car.root(i);
        int tp = train.root(i);
        pair<int, int> p = make_pair(cp, tp);
        if (i != 0) cout << " ";
        cout << counts[p];
    }
    cout << endl;
    return 0;
}





Measured memory_bytes: 20196
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(int, n);
	IN(string, s);
	vector<int> x(n + 1), y(n + 1);
	inc(i, n) { x[i + 1] = x[i] + (s[i] == 'W'); }
	dec(i, n) { y[i] = y[i + 1] + (s[i] == 'R'); }
	int ans = n;
	incII(i, 0, n) { setmin(ans, max(x[i], y[i])); }
	OUT(ans);
}


Measured memory_bytes: 5172
n = int(input())
st = []
for i in range(n-1):
    a = list(map(int, input().split()))
    st.append(a)
ans = []

for i in range(n-1):
    if i==0:
        ans.append(st[0][0]+st[0][1])
    else:
        for j in range(len(ans)):
            if ans[j]>=st[i][1] and ans[j]%st[i][2]==0:
                ans[j] += st[i][0]
            elif ans[j]<st[i][1]:
                ans[j] = st[i][0]+st[i][1]
            else:
                a = (ans[j]-st[i][1])%st[i][2]
                a = ans[j]-a
                ans[j] = a+st[i][2]+st[i][0]
        ans.append(st[i][0]+st[i][1])

ans.append(0)
for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 41200
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <sstream>

#define DEBUG 0
#define fi first
#define se second
#define pb push_back
#define INF 1000000000
#define fore(i,a,b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i,a,b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i,a,b) for (int i = (a), _b = (b); i >= (_b); --i)

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
    if (DEBUG) {
        freopen("CP.inp", "r", stdin);
        //freopen("CP.out", "w", stdout);
    }
    ios_base::sync_with_stdio(false); cin.tie(0);
    int k, x; cin >> k >> x;
    fort(i, x - k + 1, x + k - 1) cout << i << ' ';
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int A = int.Parse(str[0]);
		int B = int.Parse(str[1]);
		int ans = B-A;
		if(B%A==0){
			ans = A+B;
		}
		Console.WriteLine(ans);
	}
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 
	long long A, B, K;
	scanf("%lld%lld%lld", &A, &B, &K);
 
	long long ans = 0;
 
	long long firstDivisble = A%K == 0 ? A : A + (K - A%K);
  long long lastDivisible = B%K == 0 ? B : B - B%K;
  ans = (lastDivisible - firstDivisble)/K + 1;
 
	printf("%lld\n", ans);
 
	return 0;
}

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

typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<=(b);i++) // no semicoron
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく

using namespace std;


int main(){
    ll K, N;
    cin >> K >> N;

    vector<int> A(N);
    vector<int> B(N);

    REP(i, N) cin >> A.at(i);

    sort(ALL(A));

    REP(i, N-1) B.at(i) = A.at(i+1) - A.at(i);
    B.at(N-1) = A.at(0) + (K - A.at(N-1));

    sort(ALL(B));

    //ll ans = A.at(N-1) - A.at(0);

    ll ans = 0;

    REP(i, N-1) ans += B.at(i);

    cout << ans << endl;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}
const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n;
  double m;
  cin >> n >> m;
  vector<double> hoge(n);
  rep_i(i, n){
    cin >> hoge[i];
  }
  double sum = accumulate(hoge.begin(), hoge.end(), double(0));
  d_sort_vi(hoge);

  rep_i(i, m){
    if(hoge[i] >= sum*(1/(4*m))){
      continue;
    }else{
      cout << "No" << endl;
      return 0;
    }
  }
  say("Yes");

}

Measured memory_bytes: 256
sub f{$M[$_]=1;$M[$_]||&f for@$_;unshift@s,$_}<>;/ /,push@{$`},$'+0for<>;map$M[$_]||f,1..1e5;map{$\+=$-=($p=$p[$_])-$\;$p[$_]+=$-=$p+1-$p[$_]for@$_}@s;print

Measured memory_bytes: 114432
N = gets.to_i
A = gets.split.map(&:to_i)

sum = A.inject(&:+)
s = 0
min = 2 * ( 10 ** 9 )

(0...N-1).each do |i|
  s += A[i]
  v = ( sum - 2 * s ).abs
  min = v if min > v
end

puts min


Measured memory_bytes: 15236
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	cout << n * n * n << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int check[30]={};
    string s,t;
    cin>>s>>t;
    bool flag=true;
    for(int i=0;i<s.size();i++){
        char si=s[i];
        char ti=t[i];
        int ai=si-'0';
        int bi=ti-'0';
        ai-=48;
        bi-=48;
        //cout<<ai<<" "<<bi<<endl;
        if(check[ai]==0){
            check[ai]=bi;
        }
        else if(check[ai]!=bi){
            flag=false;
            //cout<<"a"<<endl;
        }
    }
    for(int i=0;i<30;i++){
        for(int j=i+1;j<30;j++){
            if(check[i]==0) continue;
            else if(check[i]==check[j]){
                flag=false;
                //cout<<"b"<<endl;
                //cout<<check[i]<<" "<<check[j]<<endl;
            }
        }
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}




Measured memory_bytes: 776
s = input()
K = int(input())
 
li = sorted(list(set(s)))
result = []

def substring(l):
    result.append(l)
    if len(result) < K:
        for m in li:
            if l+m in s:
                return substring(l+m)
    else:
        pass

for l in li:
    substring(l)

print(result[K-1])

Measured memory_bytes: 3060
use std::io;
use std::io::BufRead;

fn main() {
    let mut sc = Scanner::new(std::io::stdin());
    let n: usize = sc.next().unwrap();
    let mut v: Vec<usize> = vec![];
    for i in 0..n {
        v.push(sc.next().unwrap());
    }
    println!("{}", if f(&v) { "Yes" } else { "No" });
}

fn f(v: &Vec<usize>) -> bool {
    let mn = *v.iter().min().unwrap();
    let mx = *v.iter().max().unwrap();
    if mn + 2 <= mx {
        return false;
    }
    let n = v.len();
    if mn == mx {
        return 2 * mn <= n || mn + 1 == n;
    }
    let a = v.iter().fold(0, |sum, x| if *x == mn { sum + 1 } else { sum });
    a + 1 <= mx && 2 * (mx - a) <= n - a
}

/// Scanner
///
/// # Example
/// ```
/// use contest::io::scanner;
/// let mut sc = scanner::Scanner::new("1 2 \n\n \r\t \n 3.5".as_bytes());
/// assert_eq!("1".to_string(), sc.next::<String>().unwrap());
/// assert_eq!(2, sc.next().unwrap());
/// assert_eq!(3.5, sc.next().unwrap());
/// assert_eq!(None, sc.next::<i32>());
/// ```

pub struct Scanner<R: io::Read> {
    br: io::BufReader<R>,
    // Read tokens are stored in reversed order per line.
    buf: Vec<String>,
}

impl<R: io::Read> Scanner<R> {
    pub fn new(r: R) -> Scanner<R> {
        Scanner {
            br: io::BufReader::new(r),
            buf: vec![],
        }
    }
    #[inline]
    pub fn next<T>(&mut self) -> Option<T>
        where T: std::str::FromStr,
              T::Err: std::fmt::Debug
    {
        self.next_string().map(|s| s.parse::<T>().expect("Parse failed: "))
    }
    fn next_string(&mut self) -> Option<String> {
        self.buf.pop().or_else(|| match self.update() {
            true => self.next_string(),
            false => None,
        })
    }
    #[inline]
    fn update(&mut self) -> bool {
        let mut s = String::new();
        let res = self.br.read_line(&mut s);
        match res.expect("I/O error.") {
            0 => false,
            _ => {
                self.buf = s.split_whitespace().map(|x| x.to_string()).rev().collect();
                true
            }
        }
    }
}


Measured memory_bytes: 10492