akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
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;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
const ll mod=1e9+7ll;
ll a[100]={1, 2, 4, 5, 8, 10, 13, 14, 18, 21, 26, 28, 33, 36, 40, 41, 46, 50, 57, 60, 68, 73, 80, 82, 89, 94, 102, 105, 112, 116, 121, 122, 128, 133, 142, 146, 157, 164, 174, 177, 188, 196, 209, 214, 226, 233, 242, 244, 253, 260, 272, 277, 290, 298, 309, 312, 322, 329, 340};
map<ll,ll> m;
ll f(ll k)
{
//    cout<<k<<endl;
    if(k<=50)
    {
        return a[k];
    }
    if(m[k])
    {
        return m[k];
    }
    if(k&1)
    {
        return m[k]=(2ll*f(k/2ll)%mod+f(k/2ll-1ll)%mod)%mod;
    }else
    {
        return m[k]=(2ll*f(k/2ll-1ll)%mod+f(k/2ll)%mod)%mod;
    }
}
int main()
{
    //freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
	//freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);
	ll n;
	cin>>n;
	cout<<f(n)<<endl;

    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



Measured memory_bytes: 888
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int qty = sc.nextInt();
		int lighted = sc.nextInt();

		int height[] = new int[qty];
		for(int i = 0; i < qty; i ++) {
			height[i] = sc.nextInt();
		}
		Arrays.sort(height);

		int differ[] = new int [qty - lighted + 1];
		int min = height[lighted - 1] - height[0];
		int minIndex = 0;
		for(int i = 0; i < qty - lighted + 1; i ++) {
			differ[i] = height[i + lighted - 1] - height[i];
			if(differ[i] < min) {
				min = differ[i];
				minIndex = i;
			}
		}

		System.out.println(differ[minIndex]);
	}
}

Measured memory_bytes: 49928
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		TreeSet<Integer> set = new TreeSet<Integer>();
		int a = sc.nextInt();
		set.add(a);
		for (int i = 1; i < n; i++) {
			int ai = sc.nextInt();
			set.add(ai % a);
		}
		sc.close();

		while (set.size() > 1) {
			TreeSet<Integer> tempSet = set;
			set = new TreeSet<Integer>();
			tempSet.remove(0);
			Integer[] array = tempSet.toArray(new Integer[0]);
			a = array[0];
			set.add(a);
			for (int i = 1; i < array.length; i++) {
				set.add(array[i] % a);
			}
		}
		System.out.println(set.first());
	}
}


Measured memory_bytes: 61184
#include<cstdio>
#define M 200001
#define N 100001
int a[N],b[M],c[M],e[N],m,n,s,t;bool d[N];
bool dfs(int u,bool w)
{
	if(e[u]==4&&u!=s)w=true;
	if(u==s&&!w)return true;
	if(u==s&&w)w=false;
	for(int v;a[u];)
	if(!d[a[u]>>1])
	{
		d[a[u]>>1]=true,v=c[a[u]],a[u]=b[a[u]];
		if(dfs(v,w))return true;
	}
	else a[u]=b[a[u]];
	return false;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=t=1,u,v;i<=m;i++)scanf("%d%d",&u,&v),b[++t]=a[u],e[c[a[u]=t]=v]++,b[++t]=a[v],e[c[a[v]=t]=u]++;
	for(int i=1;i<=n;i++)if(e[i]&1)return 0*puts("No");
	for(int i=1;i<=n;i++)if(e[i]>=6)return 0*puts("Yes");
	for(int i=t=0;++i<=n;)if(e[i]==4)s=i,t++;
	if(t==2)puts(dfs(s,true)?"Yes":"No");
	else puts(t<2?"No":"Yes");
	return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>

int main() {
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  for (auto& a : A) {
    std::cin >> a;
    a--;
  }
  std::vector<int> B(N);
  for (auto& b : B) std::cin >> b;
  std::vector<int> C(N - 1);
  for (auto& c : C) std::cin >> c;

  int s = 0;
  for (int i = 0; i < N; i++) {
    s += B[A[i]];
    if (i > 0 && A[i - 1] + 1 == A[i]) {
      s += C[A[i - 1]];
    }
  }
  std::cout << s << std::endl;
  return 0;
}


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

int main(){
  int a,b,k;
  cin >>a >>b >>k;
  for(int i = a; i<=b ;i++){
    if(i<a+k || i>b-k) {
      cout << i << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
#define mod 1000000007
#define ps(x,noOfDecimal) fixed<<setprecision(noOfDecimal)<<x
  
using namespace std;

 
long long bpm(long long a, long long b, long long m)
{
   a %= m;
   long long res = 1;
   while (b > 0)
   {
      if (b & 1)
         res = (res * a) % m;
      a = (a * a) % m;
      b >>= 1;
   }
   return res % m;
}

signed main()
{

  std::ios::sync_with_stdio(false);
  cin.tie(); cout.tie();
   int n;
   cin >> n;
   int p10 = bpm(10,n,mod);
   int p9 = bpm(9,n,mod);
   int p8 = bpm(8,n,mod);

   int ans = (p10%mod - p9%mod - p9%mod + p8%mod)%mod;

   if(ans < 0 ) ans = (ans + mod)%mod;

   cout<<ans;

  return 0;
}

Measured memory_bytes: 3596
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	if len(s) == 2 {
		fmt.Println(s)
		return
	}
  r := []rune(s)
  r[0], r[2] = r[2], r[0]
	fmt.Println(string(r))
}


Measured memory_bytes: 512
function main(input) {
  var args = input.split('\n');
  var k = args[0].split(' ')[1];
  var s = args[1].split('');
  
  s[k - 1] = s[k - 1].toLowerCase();
  s = s.join('');
  console.log(s);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int a, b; cin >> a >> b;
	for(int i = 1; i < 100010; ++i) {
		if(i * 8 / 100 == a) {
			if(i * 10 / 100 == b) {
				cout << i << '\n';
				return 0;
			}
		} 
	}
	cout << -1 << '\n';
	return 0;
}

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

a, b = [0], [0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])

ans, j = 0, M
for i in range(N+1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i+j)

print(ans)

Measured memory_bytes: 47308
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
// #include <boost/multiprecision/cpp_int.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>

using namespace std;
// using namespace boost::multiprecision;

typedef long long ll;
typedef long double ld;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mis map<int,string>
#define msi map<string,int>
#define mll map<ll,ll>
#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 all(c) c.begin(),c.end()
#define srta(a) sort(all(a))
#define srtd(a) sort(all(a),greater<型>())
#define rvs(s) reverse(all(s))
#define psb push_back
#define ppb pop_back
#define ers erase
#define isu isupper
#define isl islower
#define lb(a,k) lower_bound(all(a),k)
#define ub(a,k) upper_bound(all(a),k)
#define bs(a,k) binary_search(all(a),k)
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

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; }

const int I_INF = 1001001001;
const ll LL_INF = 1001001001001001001;
const ld EPS = 0.001;

void Main() {
    ll X, K, D;
    cin >> X >> K >> D;

    X = abs(X);
    ll a = 0;
    ll d = abs(X/D);
    if (d > K) {
        a = X - K*D;
    } else {
        ll r = X%D;
        K -= d;
        if (K%2 == 0) {
            a = r;
        } else {
            a = min(abs(r-D), abs(r+D));
        }
    }

    cout << a << endl;
}

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


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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll d, t, s;
  cin >> d >> t >> s;

  if ((d + s - 1) / s <= t) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	lint p1,p2,p3;
	p1=a*x+b*y+c*0;
	p2=2*x*c+max(y-x,0)*b;
	p3=max(x-y,0)*a+2*y*c;
	cout<<min({p1,p2,p3})<<endl;
}

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

using namespace std;

int main() {

	string a;
	int k;
	int counter = 0;


	while (cin >> a) {
		k = a.size();
		counter++;
		while ((double)k >= ((double)a.size() / 2.0)) {
			if (a[a.size()-k] != a[k-1]) {
				counter--;
				break;
			}
			k--;
		}
	}

	cout << counter << endl;

	return 0;
}

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

const int INF = 0x3f3f3f3f;
const int MAXN = 3123;

int n;
double p[MAXN];
bool stat[MAXN][MAXN];
double pd[MAXN][MAXN];

double rec(int cur, int n_head)
{
	if(cur>=n)
	{
		if(n_head > (n/2))
			return 1.00;
		else
			return 0.00;
	}

	if(stat[cur][n_head])
		return pd[cur][n_head];

	stat[cur][n_head] = true;
	return pd[cur][n_head] = p[cur]*rec(cur+1,n_head+1) + (1-p[cur])*rec(cur+1,n_head);
}

int main(){

	cin >> n;
	for(int i=0; i<n; i++){
		char in[8];
		scanf("%s", in);
		p[i] = stod(in);
		// cout << p[i] << endl;
	}

	printf("%.9lf\n", rec(0, 0));

	return 0;
}

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

typedef pair<int, int> P;

struct WUF {
	int par[100000];
	int w[100000];
	//int rank[100000];
	
	WUF() {
		for (int i = 0; i < 100000; i++) {
			par[i] = i;
			w[i] = 0;
			//rank[i] = 0;
		}
	}
	
	P root(int x) {	//(root, rootまでの距離)
		if (par[x] == x) {
			return P(x, 0);
		}
		P res = root(par[x]);
		par[x] = res.first;
		w[x] += res.second;
		return P(par[x], w[x]);
	}
	
	void unit(int x, int y, int c) {
		P res1 = root(x);
		P res2 = root(y);
		int rt1 = res1.first;
		int rt2 = res2.first;
		
		if (rt1 == rt2) return;
		//if (rank[rt1] < rank[rt2]) {
			par[rt1] = rt2;
			w[rt1] = c + res2.second - res1.second;
		//}
		/*else {
			if (rank[rt1] == rank[rt2]) { rank[rt1]++; }
			par[rt2] = rt1;
			w[rt2] = -c + res1.second - res2.second;
		}*/
	}
	
	bool same(int x, int y) {
		return root(x).first == root(y).first;
	}
};

WUF wuf;

int main() {
	int n, q;
	cin >> n >> q;
	
	for (int i = 0; i < q; i++) {
		int type;
		cin >> type;
		
		if (type == 0) {
			int x, y, c;
			cin >> x >> y >> c;
			wuf.unit(x, y, c);
		}
		else {
			int x, y;
			cin >> x >> y;
			if (wuf.same(x, y) == false) {
				cout << "?" << endl;
			}
			else {
				int cx = wuf.root(x).second;
				int cy = wuf.root(y).second;
				cout << cx - cy << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 4192
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int a,b;
    while( cin>>a>>b,(a+b))cout <<min(a,b) <<" " << max(a,b) << endl;
}




Measured memory_bytes: 3016
import numpy as np

N = int(input())

x_min = [np.inf] * 4
x_max = [-np.inf] * 4
y_min = [np.inf] * 4
y_max = [-np.inf] * 4
for _ in range(N):
    x, y, d = input().split()
    x = int(x)
    y = int(y)
    i = {'R': 0, 'L': 1, 'U': 2, 'D': 3}[d]
    x_min[i] = min(x_min[i], x)
    x_max[i] = max(x_max[i], x)
    y_min[i] = min(y_min[i], y)
    y_max[i] = max(y_max[i], y)

x_max_ = max(x_max[2], x_max[3])
x_min_ = min(x_min[2], x_min[3])
y_max_ = max(y_max[0], y_max[1])
y_min_ = min(y_min[0], y_min[1])

def W(t):
    R = max(x_max[0] + t, x_max[1] - t, x_max_)
    L = min(x_min[0] + t, x_min[1] - t, x_min_)
    return R - L

def H(t):
    U = max(y_max[2] + t, y_max[3] - t, y_max_)
    D = min(y_min[2] + t, y_min[3] - t, y_min_)
    return U - D

def WH(t):
    return W(t) * H(t)

ts = [
    0,
    (x_max[1] - x_max[0]) / 2,
    (x_min[1] - x_min[0]) / 2,
    (y_max[3] - y_max[2]) / 2,
    (y_min[3] - y_min[2]) / 2,
    x_max_ - x_max[0],
    -(x_max_ - x_max[1]),
    x_min_ - x_min[0],
    -(x_min_ - x_min[1]),
    y_max_ - y_max[2],
    -(y_max_ - y_max[3]),
    y_min_ - y_min[2],
    -(y_min_ - y_min[3]),
]

result = np.inf;
for t in ts:
    if t >= 0:
        result = min(result, WH(t))

print(result)


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

using namespace std;

void pung() {
    puts("Impossible");
    exit(0);
}

int n, m;
int arr[110];

int main() {
    int i;

    scanf("%d%d",&n,&m);
    for (i=0;i<m;i++) scanf("%d",&arr[i]);
    int c = 0;
    for (i=0;i<m;i++) c += arr[i]%2;
    if (c>2) pung();
    int f = 0;
    for (i=0;i<m;i++) {
        if (arr[i]%2) {
            swap(arr[i],arr[f?m-1:0]);
            f++;
        }
    }
    for (i=0;i<m;i++) printf("%d ",arr[i]);
    printf("\n");
    printf("%d\n",(m==1?2:m)+(arr[0]==1?-1:0));
    if (m==1) {
        if (arr[0]==1) printf("1\n");
        else printf("%d %d\n",arr[0]-1,1);
        return 0;
    }
    for (i=0;i<m;i++) {
        int v = arr[i]-(i==0)+(i==m-1);
        if (v) printf("%d ",v);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define MAX 100005
#define MOD 1000000007
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define mt make_tuple
#define eb emplace_back
#define INF 1e9
#define PI 3.141592653589793238
#define EPS 1e-9
ll modexp(ll a, ll b)
{
	ll res = 1;
	while(b)
	{
		if(b&1) res = (res*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return res;
}
int main()
{
	ll a,b,n;
	cin>>n>>a>>b;
	ll s,l,c;
	s = a+b+a*(n-2);
	l = a+b+b*(n-2);
	cout<<max(0ll,l-s+1)<<endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

n = int(input())
strings = []
for i in range(n):
    s = sorted(input().strip())
    s = ''.join(s)
    strings.append(s)

counts = defaultdict(int)

for s in strings:
    counts[s] += 1

comb = 0
for v in counts.values():
    comb += v * (v - 1) // 2

print(comb)

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

int main(){
    int n, a;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a;
        if(a % 2) continue;
        if((a % 3) && (a % 5)){
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

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

int main(){
    ll h,w; cin >> h >> w;
    ll ans = INF;
    rep(i,h-1){
        ll a = (i+1) * w;
        ll b, c;
        b = ((h - (i+1))/2) * w;
        c = h*w - (a+b);
        chmin(ans, max({a,b,c}) - min({a,b,c}));
        b = (w/2) * (h - (i+1));
        c = h*w - (a+b);
        chmin(ans, max({a,b,c}) - min({a,b,c}));
    }
    rep(i,w-1){
        ll a = (i+1) * h;
        ll b, c;
        b = h * ((w - (i+1))/2);
        c = h*w - (a+b);
        chmin(ans, max({a,b,c}) - min({a,b,c}));
        b = (h/2) * (w - (i+1));
        c = h*w - (a+b);
        chmin(ans, max({a,b,c}) - min({a,b,c}));
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

int main()
{
  int x,y;
  int r;

  std::cin>>x>>y;

  r=x%y;

  while(r>0){
    x=y;
    y=r;
    r=x%y;
  }

  std::cout<<y<<'\n';

  return 0;
}



Measured memory_bytes: 3088
n, k = map(int, input().split())
s = input()
memo = []
c = 0
ps = ''
lens = len(s) - 1
b = 0
if s[0] == '1':
    b = 1

for i in range(lens + 1):
    if s[i] != ps:
        memo.append(c)
        c = 1
        ps = s[i]
        if i == lens:
            memo.append(1)
        continue
    if i == lens:
        memo.append(c+1)
    c += 1
    ps = s[i]

if  len(memo) < k * 2 + b + 1:
    print(sum(memo))
else:
    sumi = 0
    sumi = sum(memo[: k * 2 + b + 1])
    temp = [sumi]
    memo.append(0)
    # print(memo)
    # print(len(memo))
    for i in range(b, len(memo) - 2 * k  - 1, 2):
        last = 0
        if i + 2 * k + 2 <= len(memo) - 1:
            last = memo[i + 2 * k + 2]
        sumi = sumi - memo[i] - memo[i + 1] + memo[i + 2 * k  + 1] +last
        temp.append(sumi)
    # print(temp)
    print(max(temp))


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

int main()
{
    ll l, r, ans = 2018 * 2018;
    cin >> l >> r;
    if (r - l >= 2019)
        ans = 0;
    l %= 2019;
    r %= 2019;
    if (l > r)
    {
        ll tmp = l;
        l = r;
        r = tmp;
    }
    for (ll i = l; i <= r - 1; i++)
    {
        for (ll j = i + 1; j <= r; j++)
        {
            ans = min(ans, (i * j) % 2019);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		double min=Double.MAX_VALUE;
		double max=Double.MIN_VALUE;
		while(sc.hasNext()){
			double m=sc.nextDouble();
			if(min>m){
				min=m;
			}
			if(max<m){
				max=m;
			}
		}
		System.out.println(max-min);
	}
}

Measured memory_bytes: 18608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[105][105];
ll f(string x, string y, ll a, ll e, ll s, ll r) {
    //cerr << x << " " << y << endl;
    int n = x.size();
    int m = y.size();
    x = "#" + x;
    y = "#" + y;
    dp[0][0] = 0;
    for(int i = 1; i <= n; i++) dp[i][0] = i * a;
    for(int i = 1; i <= m; i++) dp[0][i] = i * e;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            dp[i][j] = min(dp[i][j-1] + e, min(dp[i-1][j-1] + s + r, dp[i-1][j] + a));
            if(x[i] == y[j]) dp[i][j] = min(dp[i][j], dp[i-1][j-1] + r);
        }
    }
    //cerr << x << " " << y << " " << dp[n][m] << endl;
    return dp[n][m];
}


int main() {
    while(true) {
        string X, Y;
        cin >> X;
        if(X == "#") break;
        cin >> Y;
        swap(X, Y);
        ll A, E, S, R;
        cin >> A >> E >> S >> R;
        ll ans = 1e18;
        for(int i = 0; i <= X.size(); i++) {
            for(int j = 0; j <= Y.size(); j++) {
                string x1 = X.substr(0, i);
                string x2 = X.substr(i, X.size() - i);
                string y1 = Y.substr(0, j);
                string y2 = Y.substr(j, Y.size() - j);
                //f(x1, y2, A, E, S, R);
                ans = min(ans, f(x1, y2, A, E, S, 0) + f(x2, y1, A, E, S, R));
            }
        }
        cout << ans << endl;
    }
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  while(1){
    int n,m,a;
    cin >> n >> m >> a;
    if(n==0) return 0;
    vector<pair<int,pair<int,int>>> p(m);
    for(int i=0;i<m;i++){
      cin >> p[i].first >> p[i].second.first >> p[i].second.second;
    }
    sort(all(p));
    vector<int> aa(n);
    for(int i=0;i<n;i++) aa[i]=i;
    int tmp;
    for(int i=0;i<m;i++){
      tmp=aa[p[i].second.first-1];
      aa[p[i].second.first-1]=aa[p[i].second.second-1];
      aa[p[i].second.second-1]=tmp;
    }
    cout << aa[a-1]+1 << endl;
  }
  return 0;
}



Measured memory_bytes: 3084
n,m=map(int,input().split())
a=[tuple(map(int,input().split()))for i in range(n)]
b=[tuple(map(int,input().split()))for j in range(m)]
total=10**17
num=0
ans=[]
for i in range(n):
    for j in range(m):
        dis=abs(a[i][0]-b[j][0])+abs(a[i][1]-b[j][1])
        if dis<total:
            total=dis
            num=j+1
    ans.append(num)
    total=10**17
for i in ans:
    print(i)


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

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    for (size_t i = 1; i <= n; i++)
    {
        int sum = i % 10 + (i / 10) % 10 + (i / 100) % 10 + (i / 1000) % 10 + (i / 10000) % 10;
        if (a <= sum && sum <= b)
        {
            ans += i;
        }
        /* code */
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

s64 gcd(s64 x, s64 y)
{
    if (x < y) swap(x, y);
    if (y == 0) return x;
    return gcd(y, x % y);
}

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

    s64 n, m;
    string s, t;
    cin >> n >> m;
    cin >> s >> t;

    s64 g = gcd(n, m);
    bool flag = true;
    s64 N = n / g;
    s64 M = m / g;
    for (int i = 0; i < g && flag; ++i)
    {
        if (s[i * N] != t[i * M])
        {
            flag = false;
        }
    }

    cout << (flag ? N * M * g : -1) << "\n";
    return 0;
}



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

int main(){
  int d;
  cin >> d;
  vector<int> c(26);
  vector<vector<int>> s(d,vector<int>(26));
  int i,j;
  for(i=0;i<26;i++){
    cin >> c.at(i);
  }
  
  for(j=0;j<d;j++){
    for(i=0;i<26;i++){
      cin >> s.at(j).at(i);
    }
  }
  
  
  vector<int> last(26,-1),last1(26,-1);
  int k,l;
  for(j=0;j<d/2;j++){
    vector<int> v1(26);
    for(i=0;i<26;i++){
      v1.at(i)=s.at(j*2).at(i);
      for(k=0;k<26;k++){
        if(k!=i){
          v1.at(i) -= c.at(k)*(j*2-last.at(i));
        }
      }
    }
    vector<vector<int>> v2(26,vector<int>(26));
    for(i=0;i<26;i++){
      for(k=0;k<26;k++){
        last1.at(k)=last.at(k);
      }
      last1.at(i)=j*2;
      for(k=0;k<26;k++){
        v2.at(i).at(k)=v1.at(i)+s.at(j*2+1).at(k);
        for(l=0;l<26;l++){
          if(l!=k){
            v2.at(i).at(k) -= c.at(l)*(j*2+1-last1.at(l));
          }
        }
      }
    }
    int max=v2.at(0).at(0),type1=0,type2=0;
    for(i=0;i<26;i++){
      for(k=0;k<26;k++){
        if(max<=v2.at(i).at(k)){
          max=v2.at(i).at(k);
          type1=i;
          type2=k;
        }
      }
    }
    cout << type1+1 << endl;
    cout << type2+1 << endl;
    last.at(type1)=j*2;
    last.at(type2)=j*2+1;
  }
  
  vector<int> v(26);
  int maxv,type;
  for(i=0;i<26;i++){
    v.at(i)=s.at(d-1).at(i);
    for(k=0;k<26;k++){
      if(k!=i){
        v.at(i) -= c.at(k)*(d-1-last.at(k));
      }
    }
  }
  maxv=v.at(0);
  type=0;
  for(i=0;i<26;i++){
    if(maxv<=v.at(i)){
      maxv=v.at(i);
      type=i;
    }
  }
  cout << type+1 << endl;
}

Measured memory_bytes: 3688
#include <stdio.h>
#include <math.h>

int main()
{
  int i,n,j;

  int flag=1 , cnt=0;

  int temp;

  int minj;

  scanf("%d",&n);

  int a[n];
  
  for(i=0;i<n;i++){

    scanf("%d",&a[i]);
    
  }

  for(i=0;i<n-1;i++){

    minj=i;

    for(j=i;j<n;j++){
      
      if(a[j]<a[minj]){
	minj=j;
      }

    }

    temp=a[i];
    a[i]=a[minj];
    a[minj]=temp;

    if(i!=minj){
    cnt++;
    }

  }


  for(i=0;i<n;i++){

    if(i>0){
      printf(" ");
    }
    printf("%d",a[i]);

  }
  
  printf("\n%d\n",cnt);

  return 0;
}



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

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

#define lli long long
#define sz(A) (int)A.size()
#define lsz(A) (long long)A.size()
#define INT_INF (int)(1e9 + 7)


// Compiling command
// g++ -02 -Wall <question_name>.cpp -o <question_name>

int main(int argc, char const *argv[]){

    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int x;
    cin >> x;
    cout << !x << endl;

    
    
    return 0;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
  ll a,v,b,w,t;
  cin >> a >> v >> b >> w >> t;
  if(a<b){
    if(a+v*t < b+w*t){
      cout << "NO" << endl;
    }
    else cout << "YES" << endl;
  }
  else {
    if(a-v*t > b-w*t) cout << "NO" << endl;
    else cout << "YES" << endl;
  }
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <list>
#include <cstring>
#include <algorithm>
#include <string>
using namespace std;
int main(){ 
    char tab[] ={"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
    int check = 0;
    string hoge;
    cin >> hoge;
    for(int i=0;i<26;i++){
        if(count(hoge.cbegin(), hoge.cend(), tab[i]) == 2){
            check++;
            if(check == 2){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int a , b;
string s;

int main()
{
    _FastIO;
    cin >> s;
    cout << "2018";
    for(int i = 4; i < s.size(); i++){
        cout << s[i];
    }
    cout << endl;
    return 0;
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

vector<vector<int>> vi;
int N;
int main()
{
    scanf("%d",&N);
    vi.resize((N+1)/2);
    int st = 1;
    int ed = N%2?N-1:N;
    int cnt = 0;
    vector<pair<int,int>> ans;
    while(st < ed){
        vi[cnt].push_back(st);
        vi[cnt].PB(ed);

        st++;ed--;
        cnt++;
    }

    if(N%2){
        vi[cnt++].PB(N);
    }

    _for(i,0,cnt-1){
        int a = vi[i][0];
        int b = vi[i][1];
        _for(j,i+1,cnt){
            _for(k,0,vi[j].size()){
                ans.PB(make_pair(a,vi[j][k]));
                ans.PB(make_pair(b,vi[j][k]));
            }
        }
    }

    printf("%d\n",(int)ans.size());
    _for(i,0,ans.size()){
        printf("%d %d\n",ans[i].first,ans[i].second);
    }

    return 0;
}


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

using namespace std;

typedef long long ll;

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

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



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

  ll N;
  cin >> N;
  vector<ll> P(N);
  REP(i,N){ cin >> P[i];}

  ll mi = INF;
  ll ans = 0;
  REP(i,N){
    if (P[i]<=mi){
      ans++;
    }
    mi = min(mi, P[i]);
  }

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


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

int main() {
  ll a,b,c; cin >> a >> b >> c;
  if (c-a-b > 0 && (c-a-b)*(c-a-b) > 4*a*b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int main(){
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		int a,b;
		cin>>a>>b;
		int p=0;
		int sol=0;
		while(p<b-1){
			sol++;
			p+=a-1;
		}
		cout<<sol;
		return 0;
}


Measured memory_bytes: 256
import Control.Monad

solver::Int -> Int -> Int -> [Int]
solver a b k = if ((b-a)+1) <= (2*k) then [a..b] else [a..(a+(k-1))]++[((b-k)+1)..b]

ls_print::(Show a )=>[a]->IO ()
ls_print ls = forM_ ls (\x -> print x)

main::IO()
main=do
  abkc<-getLine
  let a:b:k:[]= map read (words abkc)
  ls_print (solver a b k)


Measured memory_bytes: 764
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[])
{
    int n; cin >> n;
    vector<int> v(n,0);
    int c;
    for(int i=0;i<n;++i) {
        cin >> v[i];
    }
    int z=0;
    for(int i=0;i<n;++i) {
        cin >> c;
        v[i] -= c;
        if (v[i]>0) z+=v[i];
    }
    cout << z << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}cout<<endl;}

int main() {
    ll h,w,n;

    cin>>n;
    unordered_map<ll,unordered_set<ll>> m;
    vector<ll> v(n+1, 0),kv(n+1, 0);
    rep(i, n-1){
        ll a,b;
        cin>>a>>b;
        m[a].insert(b);
        m[b].insert(a);
    }
    stack<ll> s,z;
    s.push(1);
    v[1] = 1;
    ll yy = 0;
    ll indx = 0;
    while(s.size() > 0) {
        auto y = s.top();
        s.pop();
        auto tmp = v[y];
        for(auto it:m[y]) if(v[it]==0) {
            v[it] = tmp+1;
            s.push(it);
            if(v[it] > yy) yy = v[it], indx = it;
        }
        // pr(s.size());
    }
    z.push(indx);
    v = kv;
    s = z;
    v[indx] = 1;
    yy = 0;
    indx = 0;
    while(s.size() > 0) {
        auto y = s.top();
        s.pop();
        auto tmp = v[y];
        for(auto it:m[y]) if(v[it]==0) {
            v[it] = tmp+1;
            s.push(it);
            if(v[it] > yy) yy = v[it], indx = it;
        }
    }
    auto length = yy;
    // pr(length);
    if(length % 3 == 2) pr("Second");
    else pr("First");
    
    return 0;
}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(a, b);
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

Measured memory_bytes: 42616
#include<bits/stdc++.h>
#define MAX 100
#define inf 1<<29
#define linf (1e16)
#define eps (1e-8)
#define Eps (1e-12)
#define mod 1000000007
#define pi acos(-1.0)
#define phi (1.0+sqrt(5.0))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define pld(a) printf("%.10Lf\n",(ld)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define Unique(v) v.erase(unique(all(v)),v.end())
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<pii> vpi;

int main()
{
  int n,l,r,A[MAX];
  while(cin>>n && n){
    cin>>l>>r;
    int ans = 0;
    FOR(i,1,n+1)cin>>A[i];
    FOR(x,l,r+1){
      FOR(i,1,n+1){
        if(x%A[i]==0){
          if(i%2==1)ans++;
          break;
        }
        if(i==n && n%2==0)ans++;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}


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

using LL = long long;

constexpr int MOD = 1'000'000'007;

int powmod (int a, int b, int MOD) {
	int ans = 1;
	while (b) {
		if (b & 1) ans = 1LL * ans * a % MOD;
		b >>= 1;
		a = 1LL * a * a % MOD;
	}
	return ans;
}


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

	int n; std::cin >> n;
	std::string s; std::cin >> s;

	std::vector <std::vector<LL>> dp;
	dp.assign (n+1, std::vector<LL> (n+1, 0));
	dp[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= i; ++j) {
			if (j > 0) dp[i][j] += 2 * dp[i-1][j-1];
			else dp[i][j] += dp[i-1][j];
			if (j < n) dp[i][j] += dp[i-1][j+1];
			dp[i][j] %= MOD;
		}
	}


	std::cerr << dp[n][(int)(s.length())] << "\n";

	std::cout << dp[n][(int)(s.length())] * powmod (powmod (2, MOD-2, MOD), (int)(s.length()), MOD) % MOD << "\n";

	return 0;
}

Measured memory_bytes: 195840
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt

getInt = readInt <$> BS.getLine

main = do
  x <- getInt
  let d = x `div` 100
  let m = x `mod` 100
  if m <= 5 * d
    then print 1
    else print 0


Measured memory_bytes: 380
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;
int main()
{
  ll n, r;
  cin >> n >> r;
  int res = 1;
  ll tmp = r;
  while(tmp <= n) {
    res++;
    tmp = tmp*r;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

type UnionFind struct {
	par []int
}

func newUnionFind(N int) *UnionFind {
	u := new(UnionFind)
	u.par = make([]int, N)
	for i := range u.par {
		u.par[i] = -1
	}
	return u
}

func root(u *UnionFind, x int) int {
	if u.par[x] < 0 {
		return x
	}
	u.par[x] = root(u, u.par[x])
	return u.par[x]
}

func unite(u *UnionFind, x, y int) {
	xr := root(u, x)
	yr := root(u, y)
	if xr == yr {
		return
	}
	u.par[yr] += u.par[xr]
	u.par[xr] = yr
}

func same(u *UnionFind, x, y int) bool {
	if root(u, x) == root(u, y) {
		return true
	}
	return false
}

func size(u *UnionFind, x int) int {
	return -u.par[root(u, x)]
}

func perm(n int, k int) int {
	v := 1
	if 0 < k && k <= n {
		for i := 0; i < k; i++ {
			v *= (n - i)
		}
	} else if k > n {
		v = 0
	}
	return v
}

func fact(n int) int {
	return perm(n, n-1)
}

func comb(n int, k int) int {
	return perm(n, k) / fact(k)
}

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	result := make([]int, M)
	bList := make([][]int, M)
	for i := 0; i < M; i++ {
		var A, B int
		fmt.Scan(&A, &B)
		bList[i] = []int{A - 1, B - 1}
		result[i] = 0
	}

	u := newUnionFind(N)
	incon := comb(N, 2)

	for i := range bList {
		result[M-1-i] = incon
		a := bList[M-1-i][0]
		b := bList[M-1-i][1]
		if !same(u, a, b) {
			incon -= size(u, a) * size(u, b)
			unite(u, a, b)
		}
	}

	for i := range result {
		fmt.Println(result[i])
	}
}

Measured memory_bytes: 12032
#include<iostream>
using namespace std;
#define ll long long
const int mod=1e9+7;
const int MAX=10000;

ll fac[MAX],inv[MAX],finv[MAX];
void COMinit(){
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i % mod;
        inv[i]=mod-inv[mod%i]*(mod/i) % mod;
        finv[i]=finv[i-1]*inv[i] % mod;
    }
}

ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

int main(){
    COMinit();
    ll n,k;cin>>n>>k;
    for(int i=1;i<=k;i++){
        ll ans=COM(n-k+1,i)*COM(k-1,i-1)%mod;
        cout<<ans<<endl;
    }
    return 0;
}

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

#define ll long long

using namespace std;

bool vis[2][3005][3005];
ll ara[3005],dp[2][3005][3005];

ll FuN(ll player,ll pos1,ll pos2)
{
    if(pos1 > pos2)
        return 0;
    if(vis[player][pos1][pos2])
        return dp[player][pos1][pos2];
    ll ret1=0,ret2=0;
    if(player){
        ret1 = ara[pos1] + FuN(player^1 , pos1+1 , pos2);
        ret2 = ara[pos2] + FuN(player^1 , pos1 , pos2-1);
        vis[player][pos1][pos2] = 1;
        return dp[player][pos1][pos2] = max(ret1 , ret2);
    }
    else{
        ret1 = -ara[pos1] + FuN(player^1 , pos1+1 , pos2);
        ret2 = -ara[pos2] + FuN(player^1 , pos1 , pos2-1);
        vis[player][pos1][pos2] = 1;
        return dp[player][pos1][pos2] = min(ret1 , ret2);
    }
}

int main()
{
    ll i,j,k,n,ans;
    cin>>n;
    for(i=1 ; i<=n ; i++)   cin>>ara[i];

    ans = FuN(1 , 1 , n);
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 113756
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    string s;
    cin >> s;

    int cnta = 0, cntb = 0, cntc = 0;
    rep(i, s.size()) {
        if(s[i] == 'a') {
            cnta++;
        }
        else if(s[i] == 'b') {
            cntb++;
        }
        else {
            cntc++;
        }
    }

    int x[3] = {cnta, cntb, cntc};
    sort(x, x+3);

    int t = x[2] - x[0];
    if(t <= 1) {
        cout << "YES";
    }
    else {
        cout << "NO";
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}





int main(){
  ll N;
  cin >> N;
  char a[28];
  string s = "";
  for(char i='a'; i<='z';i++){
	a[int(i) - int('a')] = i;
  }
  while(N){
	N--;
	s += a[N%26];
	N /= 26;
  }
  reverse(s.begin(), s.end());
  cout << s << endl;
  return 0;
}




Measured memory_bytes: 3092
/*     ####   ####  #               ####  #        ##   #    # #    # ###### #####
      #      #    # #              #      #       #  #  ##  ## ##  ## #      #    #
       ####  #    # #               ####  #      #    # # ## # # ## # #####  #    #
           # #  # # #                   # #      ###### #    # #    # #      #####
      #    # #   #  #              #    # #      #    # #    # #    # #      #   #
       ####   ### # ###### #######  ####  ###### #    # #    # #    # ###### #    #
*/
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef vector<long long> VLL;
typedef vector<string> VS;
typedef vector<pair<LL, LL> > VP;
 
 
#define For(in) for (LLi i = 0; i < (n); i++)
#define FOR(in) for(LLi i=1; i <= (n); i++)
#define pb push_back
#define sr(v) sort(v.begin(), v.end())
#define rev(v) reverse(v.begin(), v.end())
#define uniq(v) v.erase(unique(v.begin(), v.end()), v.end());
#define exit(); return 0;
#define no "NO"
#define yes "YES"
#define con continue;
 

 
 
int main()
{
	
	LL n;
	cin>>n;
	cout<<n*(n+1)/2<<endl;

	2
			
    exit()
 
 
}


Measured memory_bytes: 3620
#include <stdio.h>

int main(int argc, char const *argv[])
{
    int testcase_total = 0;
    int testcase_right = 0;

    scanf("%d %d", &testcase_total, &testcase_right);

    if (testcase_total == testcase_right)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 128
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

s=SI()
if s[0]!="<":
    s="<"+s
if s[-1]!=">":
    s=s+">"
#print(s)
state="<"
strs=[]
count=0
for i in range(len(s)):
    if state=="<":
        if s[i]=="<":
            count+=1
        else:
            strs.append(count)
            count=1
            state=">"
    else:
        if s[i]==">":
            count+=1
        else:
            strs.append(count)
            count=1
            state="<"
strs.append(count)
#print(strs)
ans=0
for i in range(len(strs)//2):
    u=min(strs[2*i],strs[2*i+1])
    v=max(strs[2*i],strs[2*i+1])
    ans+=(u-1)*u//2+v*(v+1)//2
print(ans)

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

int main() {
	int n; cin >> n;
	string s; cin >> s;
	vector<int>W(n + 1, 0), E(n + 1, 0);
	for (int i = 0; i < s.size(); i++) {
		W[i + 1] = W[i] + (s[i] == 'W');
		E[i + 1] = E[i] + (s[i] == 'E');
	}
	int ans = 1e9;
	for (int i = 0; i < n; i++) {
		ans = min(ans, W[i] + E[n] - E[i + 1]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3076