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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

ll n, k, a[200000];
ll m, t[800000];

void init() {
	REP(i, 2*m-1) t[i] = 0;
}

void add(ll i, ll l, ll r, ll v, ll l1, ll r1) {
	if (r1 <= l || l1 >= r) return;
	if (l1 >= l && r1 <= r) {
		t[i] += v;
		return;
	}
	add(i*2+1, l, r, v, l1, (l1+r1) / 2);
	add(i*2+2, l, r, v, (l1+r1) / 2, r1);
}

ll get(ll i) {
	ll res = 0;
	i += m-1;
	while (i > 0) {
		res += t[i];
		i = (i-1) / 2;
	}
	return res + t[0];
}

int main(int argc, char **argv) {
	CLEAR(t);
	cin >> n >> k;
	REP(i, n) cin >> a[i];
	m = 1;
	while (m < n) m *= 2;
	REP(i, k) {
		init();
		REP(j, n) add(0, max((ll)0, j-a[j]), min(n, j+a[j]+1), 1, 0, m);
		REP(j, n) a[j] = get(j);
		bool f = true;
		REP(j, n) f &= (a[j] == n);
		if (f) break;
	}
	REP(i, n) {
		if (i != 0) cout << " ";
		cout << a[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 11424
using System;

namespace AtCoder.ABC100
{
    class a
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Trim();
            var spl = line.Split(' ');
            var A = int.Parse(spl[0]);
            var B = int.Parse(spl[1]);
            Console.WriteLine(A <= 8 && B <= 8 ? "Yay!" : ":(");
        }
    }
}


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

template<typename T, typename U> bool chmin(T &a, const U &b) {
	return (a > b ? a = b, true : false);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
	return (a < b ? a = b, true : false);
}

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;

int d[4];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n,m;
	cin>>n>>m;

	d[1] =d[2] =d[3] =11;

	for(int i=0; i<m; i++){
		int s,c;
		cin>>s>>c;

		if(d[s] ==11){
			d[s] =c;
		}else {
			if(d[s] !=c){
				writeln("-1");
				return 0;
			}
		}
	}
	if(n>1 && d[1] ==0){
		writeln(-1);
		return 0;
	}
	if(n==1 && d[1] ==11){
		writeln(0);
		return 0;
	}

	for(int i=1; i<=n; i++){
		if(d[i] !=11){
			cout<<d[i];
		}else {
			if(i==1){
				cout<<1;
			}else{
			cout<<0;
			}

		}

	}
	cout<<endl;



}


Measured memory_bytes: 256
n = int(input())
arr = list(map(int, input().split()))
q = int(input())
questions = list(map(int, input().split()))

answers = set()
for i in range(1, 2 ** n):
    bin_i = "{:020b}".format(i)[::-1]

    answer = sum(arr[x] for x in range(n) if bin_i[x] == "1")
    answers.add(answer)

for question in questions:
    print("yes" if question in answers else "no")
    


Measured memory_bytes: 5668
N = int(input())
S = [int(input()) for _ in range(N)]
table = [False] * (200 * 200 + 1)
table[0] = True
ma = 0
for s in S:
    ma += s
    for i in range(ma, -1, -1):
        table[i+s] |= table[i]
for i in range(ma, -1, -1):
    if i % 10 != 0 and table[i]:
        print(i)
        break
else:
    print(0)



Measured memory_bytes: 39792
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int MAX = 510000;
const int MOD = 1000000007;

LL N,M,S;
string s;
int main(){
    cin>>s;
    int ans=s.length();
    
    for(char i='a';i<='z';i++){
        int tmp=0;
        int cnt=0;
        queue<P> q;
        bool f[101]={};
        for(int j=0;j<s.length();j++){
            if(s[j]==i){
               cnt=max(cnt,tmp);
               tmp=0;
            }else{
                tmp++;
            }
        }
        cnt=max(cnt,tmp);
        ans=min(ans,cnt);
    }
    cout<<ans;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string.h>
using namespace std;

int main()
{
    char in[3];
    for(int i = 0;i < 3;i++){
        cin >> in[i];
    }
    
    int cost = 700;
    for(int i = 0;i < 3;i++){
        if(in[i] == 'o')cost += 100;
    }
    cout << cost;
    return 0;
}

Measured memory_bytes: 256
fn main() {
    let nkq = read_vec::<usize>();
    let n = nkq[0];
    let k = nkq[1];
    let q = nkq[2];

    let mut v: Vec<usize> = vec![0; n];
    for _ in 0..q {
        let a = read::<usize>();
        v[a-1] += 1;
    }

    for num in v.iter() {
        if k + *num <= q {
            println!("No");
        } else {
            println!("Yes");
        }
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 4732
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ld a, b, h;std::cin >> a >> b >> h;
  std::cout << ((a+b)/2)*h << '\n';
}


Measured memory_bytes: 256
const main = (lines: string) => {
  const data = lines.split("\n");
  const sequence = data[1].split(" ").map(str => parseInt(str, 10));
  const order = getOrder(sequence);
  let correctSize: boolean[] = [];
  let result = "NO";

  sequence.forEach((number, i) => {
    if (number !== order[i]) {
      correctSize.push(true);
    }
  });

  if (correctSize.length <= 2) {
    result = "YES";
  }

  console.log(result);
};

const getOrder = (sequence: number[]) => {
  const temp = sequence.slice();
  return temp.sort((a, b) => (a < b ? -1 : 1));
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
A, B, C, X, Y = map(int, input().split())

money = [A*X+B*Y, 2*C*max(X,Y)]
n = min(X, Y)
x, y = X - n, Y - n
money.append(A*x+B*y+2*C*n)
money.append(A*n+B*n+2*C*(max(X,Y)-n))
print(min(money))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define sz(s) (int)s.size()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

ll power(ll x,ll y){
	ll t=1;
	while(y>0){
		if(y%2) y-=1,t=t*x%mod;
		else y/=2,x=x*x%mod;
	}
return t;
}

ll ans[N],a[N],lazy[N];
vector <pll> v;

int main(){
	ll n,x;
	scanf("%lld",&n);
	REP(i,n){
		scanf("%lld",&a[i]);
		if (!i){
			v.pb(mp(a[i],i));
			ans[i]+=a[i];
		}
		else{
			if (a[i]>v.back().X){
				v.pb(mp(a[i],i));
				lazy[sz(v)-1]+=1;
			}
			else{
				if (a[i]<=a[0]){
					ans[0]+=a[i];
					continue;
				}
				x=lower_bound(all(v),mp(a[i],-1ll))-v.begin();				
				if (a[i]<v[x].X){
					ans[v[x].Y]+=a[i]-v[x-1].X;
					x--;
				}
				lazy[x]+=1;
			}
		}
	}
	for(int i=sz(v)-1;i>=0;i--){
		ans[v[i].Y]+=lazy[i]*(v[i].X);
		if (i){
			ans[v[i].Y]-=lazy[i]*v[i-1].X;
			lazy[i-1]+=lazy[i];
		}
	}
	REP(i,n) printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 11760
#include <stdio.h>
#include <algorithm>
int main(void){
    int n,m;
    scanf("%d%d",&n,&m);
    unsigned long long p[m],y[m];
    unsigned long long x[m];
    for(int i=0;i<m;i++){
        scanf("%lu%lu",&p[i],&y[i]);
        x[i]=(p[i]<<47)+(y[i]<<17)+i;
    }
    std::sort(x,x+m);
    for(int i=0;i<m;i++){
        x[i]=(p[i]<<47)+(y[i]<<17)+i;
    }
    std::sort(x,x+m);
    int c=1;
    y[(x[0]<<47)>>47]=c;
    for(int i=1;i<m;i++){
        if(x[i]>>47==x[i-1]>>47)c++;
        else c=1;
        y[(x[i]<<47)>>47]=c;
    }
    for(int i=0;i<m;i++){
        printf("%06lu%06lu\n",p[i],y[i]);
    }
}

Measured memory_bytes: 3712
#include<stdio.h>
int main()
{
    int x,y,z;
    scanf("%d %d %d",&x,&y,&z);
    
    if(x+y+z >= 22){
        
        printf("bust\n");
        
    }
    else {
        printf("win\n");
    }
    return 0;
    
    
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <queue>
#include <vector>
#define ll long long
using namespace std;
const int N=1e6+10;
int n;

int main(){
cin>>n;
cout<<n*n<<endl;

return 0;
}


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

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

int main() {
    int N,M;
    cin >> N >> M;
    int Ai;
    priority_queue<P> p;
    for (int i=0;i<N;i++) {
        cin >> Ai;
        p.push(make_pair(Ai,1));
    }
    for (int i=0;i<M;i++) {
        int b, c;
        cin >> b >> c;
        p.push(make_pair(c, b));
    }
    
    ll ans = 0;
    for (int i=0;i<N;i++){
        auto a = p.top();
        p.pop();
        ans += (ll)a.first;
        a.second--;
        if (a.second > 0){
            p.push(a);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, w, k, cnt, ans = 0;
  cin >> h >> w >> k;
  vector<string> s(h);
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }

  for (int gyou = 0; gyou < (1 << h); gyou++) {
    for (int retsu = 0; retsu < (1 << w); retsu++) {
      bitset<64> yoko(gyou);
      bitset<64> tate(retsu);
      cnt = 0;
      for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
          if (tate[j] || yoko[i]) {
            continue;
          }
          if (s[i][j] == '#') {
            cnt++;
          }
        }
      }
      if (cnt == k) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
import sys
from math import ceil
n = int(input())
p_ls = [int(i) for i in sys.stdin.readline().split()] + [-1]
cur = 0
ans = 0
for i, p in enumerate(p_ls, 1):
    if i == p:
        cur += 1
    else:
        ans += ceil(cur / 2)
        cur = 0
print(ans)

Measured memory_bytes: 13876
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

ll f(ll x){
	vector<ll> a(x+1, 1);
	ll sum=0;
	loop(i, 2, x+1){
		for(ll k=i; k<=x; k+=i){
			a[k]++;
		}
	}
	loop(i, 1, x+1){
		sum+=(i*a[i]);
		//cout << a[i] << endl;
	}
	return sum;
}

int main() {
	ll n, ans;
	cin >> n;
	cout << f(n) << endl;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;
const long double PI = 3.141592653589793;
int main() {
  ll n;

  cin >> n;

  long double ans = 2 * n * PI;
  cout << setprecision(10)<<ans << endl;
  return 0;
}


Measured memory_bytes: 3788
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cstring>
#include <cmath>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using ll = long long;

// xor segment tree
template <typename T>
class SegmentTree {
private:
  int n;
  T _init;
  std::vector<T> seg;
 
  int size (int N) {
    int ret;
    for (ret = 1; ret < N; ret <<= 1);
    return ret;
  }
 
  T query(int a, int b, int k, int l, int r) {
    if (r <= a or b <= l) return _init;
    if (a <= l and r <= b) return seg[k];
 
    T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return (vl ^ vr);
  }
 
public:
  SegmentTree (int N, T i = 0) : n(size(N)), seg(size(N) * 2, i), _init(i) {}
  SegmentTree () {}
 
  void Init(int N, int i = 0) {
      n = size(N);
      seg.resize(size(N) * 2 - 1, i);
      _init = i;
  }
 
  void Update (int k, T val) {
    k += n - 1;
    seg[k] = val;
    while (k > 0) {
      k = (k - 1) / 2;
      // 適宜変更
      seg[k] = (seg[k * 2 + 1] ^ seg[k * 2 + 2]);
    }
  }
 
  // [l, r) 半開区間であることに注意!!! ... [l, r]ならfind(l, r + 1)
  T Find(int l, int r) {
    return query(l, r, 0, 0, n);
  }
};

int main() {
  int N;
  std::vector<int> a;
  SegmentTree<int> xor_;

  cin >> N;
  a.resize(N);
  xor_.Init(N);
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
    xor_.Update(i, a[i]);
  }

  int a_sum[200001] = {0};

  for (int i = 0; i < N; ++i) {
    if (i == 0) {
      a_sum[i] = a[i];
    }
    else {
      a_sum[i] = a_sum[i - 1] + a[i];
    }
  }

  ll ans = 0;

  // (l, r]
  // しゃくとりっぽい
  // 二分探索しないと TLE
  for (int r = 0; r < N; ++r) {
    int ng = -1, ok = r, m;

    while (ok - ng > 1) {
      m = (ok + ng) / 2;

      int tmp_xor = xor_.Find(m, r + 1);
      int sum_ = a_sum[r] - (m == 0 ? 0 : a_sum[m - 1]);

      if (tmp_xor == sum_) {
        ok = m;
      }
      else {
        ng = m;
      }
    }

    ans += (r - ok + 1);
  }

  cout << ans << endl;

  return 0;
}


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

#define N_MAX 100

int main() {
    long dd;
    cin >> dd;

    cout << "Christmas";
    for (long i = 0; i < 25 - dd; i++) {
        cout << " Eve";
    }
    cout << endl;

    return 0;
}


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

int main()
{
    int x1,x2,y1,y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int vecx = x2 - x1,vecy = y2 - y1;

    cout << x2 - vecy <<  " ";
    cout << y2 + vecx <<  " ";
    cout << x1 - vecy <<  " ";
    cout << y1 + vecx << endl;
}

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

#define INF (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define N 100005
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795



ll binPowM(ll a,ll b, ll m)
{ 
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
return ans%m;
}
ll f(ll x,ll y,ll a)
{
  return (a&x)*(a&y);
}

int main()
{
ll n,k;
cin>>n>>k;
ll d;
set<ll>s;
for(int i=1;i<=k;i++)
{
    cin>>d;
    ll temp;
    for(int i=1;i<=d;i++)
    {
        cin>>temp;
        s.insert(temp);
    }
}
cout<<n-s.size()<<"\n";

  return 0;
}





Measured memory_bytes: 3636
#include<stdio.h>
void handan(int a,int b,int c);
int main(void){
	int n;
	scanf("%d",&n);
	int a,b,c;
	for(;n>0;n--){
		scanf("%d %d %d",&a,&b,&c);
		handan(a,b,c);
	}
}

void handan(int a,int b,int c){
	if(a*a==b*b+c*c||b*b==a*a+c*c||c*c==a*a+b*b)printf("YES\n");
	else printf("NO\n");
}

Measured memory_bytes: 580
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int> P;
const long long inf = 1e17;
const int mod = 1000000007;

signed main() {
	string s; cin >> s;
	cout << s[0] << s[1] << s[2] << endl;
}

Measured memory_bytes: 3624
from collections import Counter
n = int(input())
ns = list(map(int, input().split()))
xma = [x - a for x, a in enumerate(ns)]
xpa = [x + a for x, a in enumerate(ns)]
m = Counter(xma)
p = Counter(xpa)
cnt = 0
for key, value in m.items():
    if key in p:
        cnt += value * p[key]
print(cnt)


Measured memory_bytes: 166796
def solve(n,a):
    for i in range(n-1,0,-1):
        if a[i]>a[i+1]:
            a[i]-=1
    for i in range(2,n+1):
        if a[i]<a[i-1]:
            return 'No'
    return 'Yes'

n = int(input())
arr = list(map(int,input().split()))
arr.insert(0,0)
print (solve(n,arr))

Measured memory_bytes: 14396
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define push push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
int main(){
    int k,n;
    ll ans=0;
    cin >>k>>n;
    int d=0;
    int bef;
    V a(n+1);
    V s(n + 1);
    rep(i,n){
        cin>>a[i];
    }
   rep(i,n){
       if(i==0){
           s[i]=a[i]+k-a[n-1];
       }else
       s[i]=a[i]-a[i-1];
   }
   //s[n]=k-a[n-1];
    rep(i,n+1){
        clog<<s[i]<<" ";
    }
    clog<<endl;
    sort(all(s),greater<ll>());
    cout<<k-s[0]<<endl;
}

Measured memory_bytes: 3328
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
#include <omp.h>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}


long long gcd(long long a,long long b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
void solve(long long N, std::vector<long long> A){
    long long tmp = 100;
    vector<long long> inp;
    for(int i = 0;i < (N+tmp-1) / tmp;++i){
        long long geko = A[i*tmp];
        for(int q = i*tmp+1;q < N&&q < (i+1)*(tmp);++q){
            geko = gcd(geko,A[q]);
        }
        inp.push_back(geko);
    }
    long long ans = 0;
    for(int i = 0;i < inp.size();++i){
        long long geko = -1;
        for(int q = 0;q < inp.size();++q){
            if(i != q){
                if(geko == -1){
                    geko = inp[q];
                }else{
                    geko = gcd(geko,inp[q]);
                }
            }
        }
        for(int t = i*tmp;t < N&&t < (i+1)*(tmp);++t){
            long long nya = -1;
            for(int j = i*tmp;j < N&&j < (i+1)*tmp;++j){
                if(t != j){
                    if(nya == -1){
                        nya = A[j];
                    }else{
                        nya = gcd(nya,A[j]);
                    }
                }
            }
            if(nya == -1){
                ans = max(ans,geko);
            }else{
                if(geko == -1){
                    ans = max(ans,nya);
                }else{
                    ans = max(ans,gcd(geko,nya));
                }
            }
        }
    }
    cout << ans << endl;
    return;
}
// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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


int main(){
  int n,m=0;cin>>n;
  vector<int>v(n);
  vector<int>ans(n,0);
  rep(i,n){
    cin>>v[i];
  }
  for(int i=n-1;i>=0;i--){
    int a=n/(i+1),sum=0;
    for(int j=2;j<=a;j++){
      sum+=ans[(i+1)*j-1];
      sum%=2;
    }
    if((sum+v[i])%2==0)ans[i]=0;
    else ans[i]=1;
  }
  rep(i,n){
    if(ans[i])m++;
  }
  cout<<m<<endl;
  rep(i,n){
    if(i)cout<<endl;
    if(ans[i])cout<<i+1;
  }
  cout<<endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<28;
const double PI = acos(-1);
const double EPS = 1e-8;

struct P {
  int dst, time, cost;
};
int cost1[2][601][100];
int cost2[2][601][100];
vector<P> g[601][100];
vector<P> h[601][100];
int main() {
  int n, m;
  while(cin>>m, m) {
    REP(i, 601) REP(j, 100) {
      g[i][j].clear();
      h[i][j].clear();
    }
    map<string, int> mp;
    mp["Tokyo"] = 0;
    mp["Hakodate"] = 1;
    n = 2;
    REP(i, m) {
      char s[20], t[20];
      int sh,sm,th,tm, cost;
      scanf("%s %d:%d %s %d:%d %d", s,&sh,&sm,t,&th,&tm,&cost);
      int t1 = sh*60+sm - 480, t2 = th*60+tm - 480;
      if (t1<0 || t1>600 || t2<0 || t2>600) continue;
      string u(s), v(t);
      if (!mp.count(u)) mp[u] = n++;
      if (!mp.count(v)) mp[v] = n++;
      int a = mp[u], b = mp[v];
      g[t1][a].push_back((P){b, t2, cost});
      h[t2][b].push_back((P){a, t1, cost});
    }
    REP(k, 2) REP(i, 601) REP(j, 100) cost1[k][i][j] = cost2[k][i][j] = INF;
    cost1[0][0][0] = cost1[1][0][1] = 0;
    REP(k, 2) {
      REP(i, 600) {
        REP(j, n) {
          cost1[k][i+1][j] = min(cost1[k][i+1][j], cost1[k][i][j]);
          FOR(it, g[i][j]) {
            cost1[k][it->time][it->dst] = min(cost1[k][it->time][it->dst], cost1[k][i][j]+it->cost);
          }
        }
      }
    }
    cost2[0][600][0] = cost2[1][600][1] = 0;
    REP(k, 2) {
      for (int i=600; i>0; --i) {
        REP(j, n) {
          cost2[k][i-1][j] = min(cost2[k][i-1][j], cost2[k][i][j]);
          FOR(it, h[i][j]) {
            cost2[k][it->time][it->dst] = min(cost2[k][it->time][it->dst], cost2[k][i][j]+it->cost);
          }
        }
      }
    }
    int ans = INF;
    REP(i, 601-30) {
      REP(j, n) {
        ans = min(ans, cost1[0][i][j] + cost1[1][i][j] + cost2[0][i+30][j] + cost2[1][i+30][j]);
      }
    }
    cout << (ans==INF?0:ans) << endl;
  }
}

Measured memory_bytes: 0
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	r1 := scanInt()
	c1 := scanInt()
	r2 := scanInt()
	c2 := scanInt()

	facInit(r2+c2+2)

	g := 0
	for i := 0; i < r2+1; i++ {
		g = (g+comb(c2+i+1, c2))%mod
	}
	for i := 0; i < r2+1; i++ {
		g = (g-comb(c1-1+i+1, c1-1))%mod
	}
	for i := 0; i < c2+1; i++ {
		g = (g-comb(r1-1+i+1, r1-1))%mod
	}
	for i := 0; i < r1; i++ {
		g = (g+comb(c1-1+i+1, c1-1))%mod
	}

	fmt.Println(g)

}

const mod = 1000000007

var fac, ifac []int

func facInit(n int) {
	fac = make([]int,n+1)
	ifac = make([]int,n+1)

	mpow := func (x,n int) int {
		res := 1
		for n!=0 {
			if n&1 == 1 { res = res*x%mod }
			x = x*x%mod; n >>= 1
		}
		return res
	}

	fac[0] = 1; ifac[0] = 1

	for i := 0; i < n; i++ {
		fac[i+1] = fac[i]*(i+1)%mod
		ifac[i+1] = ifac[i]*mpow(i+1,mod-2)%mod
	}
}

func comb(a,b int) int { return (fac[a]*ifac[b]%mod)*ifac[a-b]%mod }
func perm(a,b int) int { return fac[a]*ifac[a-b]%mod }

Measured memory_bytes: 32896
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int Q = sc.nextInt();
        int[][] cnt = new int[N+1][N+1];
        for (int i = 0; i < M; i++) {
            int L = sc.nextInt();
            int R = sc.nextInt();
            cnt[L][R]++;
        }

        int[][] prefSum = new int[N+1][N+1];
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                prefSum[i][j] = prefSum[i][j-1]+cnt[i][j];
            }
        }

        StringBuilder ans = new StringBuilder();
        for (int i = 0; i < Q; i++) {
            int p = sc.nextInt();
            int q = sc.nextInt();
            int tmp = 0;
            for (int l = p; l <= q; l++) {
                tmp += prefSum[l][q]-prefSum[l][p-1];
            }
            ans.append(tmp).append('\n');
        }

        System.out.print(ans);
    }
}


Measured memory_bytes: 154044
import math
a = list(map(int,input().split()))
xy = [map(int, input().split()) for _ in range(a[0])]
x, y = [list(i) for i in zip(*xy)]
c = 0

for i in range(a[0]):
  d = math.sqrt((x[i-1]**2)+(y[i-1]**2))
  if a[1] >= d:
    c += 1
print(c)

Measured memory_bytes: 116608
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int a; cin >> a;
    cout << "ABC" << a << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,ma=-1000000001,c=0,d=0;
vector<vector<int>> f,p;
vector<int> jon(10);
void plan(){
  if(c!=10){
    for(int i=0;i<2;i++){
      jon[c]=i;
      c++;
      plan();
    }
  }else if(d==0){
    d++;
  }else{
    int total=0;
    for(int i=0;i<n;i++){
      int cnt=0;
      for(int j=0;j<10;j++){
        if(jon[j]==1&&f[i][j]==1){
          cnt++;
        }
      }
      total+=p[i][cnt];
    }
    ma=max(ma,total);
  }
  c--;
}
int main(){
  cin>>n;
  f.resize(n);
  p.resize(n);
  for(int i=0;i<n;i++){
    f[i].resize(10);
    for(int j=0;j<10;j++){
      cin>>f[i][j];
    }
  }
  for(int i=0;i<n;i++){
    p[i].resize(11);
    for(int j=0;j<11;j++){
      cin>>p[i][j];
    }
  }
  plan();
  cout<<ma;
}
  

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static int lcm (int a, int b) {return a*b/gcd(a,b);}

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		for(int i=0;i<=a;i++) {
			for(int j=0;j<=a;j++) {
				if(a-i-j<0) {
					break;
				}
				int _10000=10000*i;
				int _5000=5000*j;
				int _1000=1000*(a-i-j);
				if(_10000+_5000+_1000==b) {
					System.out.println(i+" "+j+" "+(a-i-j));
					return;
				}
			}
		}
		System.out.println(-1+" "+-1+" "+-1);
	}

}


Measured memory_bytes: 23636
import math
def isprime(x):
    if x==2:
        return 1
    elif x<2 or x%2==0:
        return 0
    else :
        i=3
        while i<=math.sqrt(x):
            if x%i==0:
                return 0
            i=i+2
        return 1

while True:
    n=int(input())
    if n==0:
        break
    ans=0
    for i in range(n+1,2*n+1):
        if isprime(i)==1:
            ans+=1
    print(ans)


Measured memory_bytes: 5664
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int long long i=0;i<n;i++)
typedef int long long ll;
using namespace std;
const static int N=1000;
ll f[N][10];
ll p[N][11];
int n;



int main(){
    cin>>n;
    rep(i,n){
        rep(j,10){
            cin>>f[i][j];
        }
    }
    rep(i,n){
        rep(j,11){
            cin>>p[i][j];
        }
    }
    
    int mi=-(1e+9);
    for(int b=1;b<(1<<10);b++){
        
        int cc=0;
        for(int i=0;i<n;i++){
            ll a=0;
            for(int j=0;j<10;j++){
                if ((b>>j&1)) {
                    if(f[i][j]){a++;}
                }
            }
            cc+=p[i][a];
        }
        mi=max(mi,cc);
    }
    cout<<mi<<endl;
  
    
    return 0;
}


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

const long long MOD = 1000000007;

void solve(long long N) {
  map<int, int> m;
  for (int i = 1; i < N + 1; i++) {
    int curr = i;
    for (int j = 2; j * j <= curr; j++) {
      while (curr % j == 0) {
        m[j]++;
        curr /= j;
      }
    }
    if (curr > 1) m[curr]++;
  }
  long long res = 1;
  for (auto e : m) {
    res = (res*(e.second+1)) % MOD;
  }
  cout << res << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


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

using namespace std;
int n;

void pre(){
     n %= 10;

  if (n == 3) {
   
    cout << "bon" << '\n';
  } 
  else if (n == 0 || n == 1 || n == 6 || n == 8) {
   
    cout << "pon" << '\n';
  } 
  else 
  {
    
    cout << "hon" << '\n';
  }
    
}

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

  cin >> n;
  pre();
 

  return 0;
}

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

void read_Tarou_Hanako(int *Tarou,int *Hanako,int n,int m);
int sum_Tarou_cards(int *Tarou,int n);
int sum_Hanako_cards(int *Hanako,int m);
int  find_cardset_exchanged(int *Tarou,int *Hanako,int n,int m,int difference,int *cards_exchanged,int bigger);

int main(void) {
	while(1){
		int n,m;
		scanf("%d %d",&n,&m);
		if(n==0 && m==0){return 0;}

		int Tarou[n];
		int Hanako[m];
		read_Tarou_Hanako(Tarou,Hanako,n,m);

		int sum_Tarou,sum_Hanako;
		sum_Tarou = sum_Tarou_cards(Tarou,n);
		sum_Hanako = sum_Hanako_cards(Hanako,m);
		int bigger;		// 1 Tarou > Hanako  2 Tarou < Hanako
		if(sum_Tarou>sum_Hanako){bigger = 1;}
		else{bigger = 0;}
		int sum;
		sum = sum_Tarou + sum_Hanako;
		if((sum % 2) != 0){printf("%d\n",-1);continue;}
		int middle;
		middle = sum / 2;
		int difference;
		difference = middle - sum_Tarou;
		if(difference<0){difference = difference * (-1);}

		int cards_exchanged[2];
		int found_or_not;
		found_or_not = find_cardset_exchanged(Tarou,Hanako,n,m,difference,cards_exchanged,bigger);
		if(found_or_not == 0){printf("%d\n",-1);continue;}

		printf("%d %d\n",cards_exchanged[0],cards_exchanged[1]);
	}

}

void read_Tarou_Hanako(int *Tarou,int *Hanako,int n,int m){
	int i;
	for(i=0;i<n;i++){
		scanf("%d",&Tarou[i]);
	}
	for(i=0;i<m;i++){
		scanf("%d",&Hanako[i]);
	}
}

int sum_Tarou_cards(int *Tarou,int n){
	int sum = 0;
	int i;
	for(i=0;i<n;i++){
		sum += Tarou[i];
	}
	return sum;
}

int sum_Hanako_cards(int *Hanako,int m){
	int sum = 0;
	int i;
	for(i=0;i<m;i++){
		sum += Hanako[i];
	}
	return sum;
}

int find_cardset_exchanged(int *Tarou,int *Hanako,int n,int m,int difference,int *cards_exchanged,int bigger){
	int i,j;
	int cardnumber_difference;
	int sum_cards_exchanged = 999;
	int tmp_sum_cards_exchanged;
	int flag = 0;

	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			if(bigger==1 && Tarou[i]<Hanako[j]){continue;}
			if(bigger==0 && Tarou[i]>Hanako[j]){continue;}
			cardnumber_difference = Tarou[i] - Hanako[j];
			tmp_sum_cards_exchanged = Tarou[i] + Hanako[j];
			if(cardnumber_difference<0){cardnumber_difference *= (-1);}
			if(cardnumber_difference == difference && tmp_sum_cards_exchanged<sum_cards_exchanged){
				flag = 1;
				sum_cards_exchanged = tmp_sum_cards_exchanged;
				cards_exchanged[0] = Tarou[i];
				cards_exchanged[1] = Hanako[j];
			}
		}
	}
	if(flag == 1){return 1;}
	else{return 0;}
}

Measured memory_bytes: 600
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;
	vector<ll> a(n);
	REP(i,n) cin>>a[i];
	vector<ll> nice(n);
	vector<ll> black(n);
	REP(i,n) {
		nice[i]=max(0ll,a[i]);
		black[i]=a[i];
	}
	FOR(i,1,n) {
		nice[i]=nice[i-1]+nice[i];
		black[i]=black[i-1]+black[i];
	}
	ll ret=0;
	ret=max(ret,black[n-1]);
	REP(i,n-k+1) {
		if(i==0) ret=max(ret,nice[n-1]-nice[i+k-1]+max(0ll,black[i+k-1]));
		else if(i==n-k+1) ret=max(ret,nice[i-1]+max(0ll,black[n-1]-black[i-1]));
		else ret=max(ret,nice[i-1]+(nice[n-1]-nice[i+k-1])+max(0ll,black[i+k-1]-black[i-1]));
	}
	cout<<ret<<endl;
}


Measured memory_bytes: 2560
#n,k=gets.split(' ').map(&:to_i)
#h=gets.split(' ').map(&:to_i)
#tajigen = Array.new(4) { Array.new(2,0) }
n=gets.to_i
a=gets.split(' ').map(&:to_i)
q=gets.to_i
#Array.new=n_hairetu[n+1]
n_hairetu=Array.new(10**6,0)
a.each do |i|
  n_hairetu[i]+=1
end
#puts n_hairetu
sum=a.sum
#puts sum
tajigen = Array.new(q) { Array.new(2,0) }
for i in 0..q-1
  b,c=gets.split(' ').map(&:to_i)
  tajigen[i][0]= b
  tajigen[i][1]= c
end
#puts tajigen
#puts sum
for i in 0..q-1
  #b,c=gets.split(' ').map(&:to_i)
  b=tajigen[i][0]
  c=tajigen[i][1]
  #puts b
  #puts c
  b_count=n_hairetu[b]
  c_count=n_hairetu[c]
  sum=sum-b*b_count+c*(b_count)
  n_hairetu[b]=0
  n_hairetu[c]+=b_count
  puts sum
end


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

int main() {
    string s;
    cin >> s;
    int K;
    cin >> K;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'a') continue;
        int x = 26 - (s[i] - 'a');
        if (x > K) continue;
        K -= x;
        s[i] = 'a';
    }
    if (K != 0) s.back() = s.back() + K % 26;
    cout << s << endl;
}

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

int main(){
    int N, len;
    int ans=0;
    vector<int> kusi;
    cin >> N;
    for(int i=0;i<2*N;i++){
        cin >> len;
        kusi.push_back(len);
    }
    sort(kusi.begin(),kusi.end());
    for(int i=0;i<2*N;i=i+2){
        ans+=kusi[i];
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int A,B;
    cin>>A>>B;
    if(A<=5){cout<<0<<endl;return 0;}
    if(A>=6 && A<=12){B/=2;}
    cout<<B<<endl;
}

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

typedef long long ll;
typedef vector<int> vi;

int N; string S; vi l,r;
void input()
{
    cin>>N>>S;
}

void solve()
{
    int count=0;
    for(int i=0;i<N;++i) {
        if(S[i]=='W') ++count;
        l.emplace_back(count);
    }
    count=0;
    for(int i=0;i<N;++i) {
        if(S[N-1-i]=='E') ++count;
        r.emplace_back(count);
    }
    int MIN=100000000;
    for(int i=0;i<N;++i) {
        int tmp=0;
        if(i>0) tmp+=l[i-1];
        if(i<N-1) tmp+=r[N-2-i];
        MIN=min(MIN,tmp);
    }
    cout<<MIN<<endl;
}

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

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

#define vint vector<int>
#define vvint vector<vint>
#define sint stack<int>
#define qint queue<int>
#define rep(i, n) for(int i=0;i<(int)(n);i++) // 繰り返し処理
#define all(x) (x).begin(),(x).end() // 全体 こんな感じで使う→sort(all(a));
#define ct(a) cout << a << endl
#define iceil(a,b) (a+(b-1))/b //int ceil : 繰り上げの割り算 通常のceilではceil((7.0/2.0))のようにしなければならなかった。
#define ul unsigned long
vint CinLine(int N){vint v(N);for(int i=0;i<N;i++){cin >> v.at(i);}return v;}//cin line 連続でvectorに格納
void CoutLine(vint v){for(int i=0;i<v.size()-1;i++){cout<<v.at(i)<<" ";}cout << v.at(v.size()-1)<<endl;}
// str.substr(開始位置, 取り出す長さ);


void Main(){
    ul n;
    cin >> n;
    string sna = "";

    int base  = 26;
    do {
        char c;
            n -= 1;
            c = n % base;
            n /= base;
            char c2 = (c + 0x61);
            sna += c2;


    }while(n != 0);

    reverse(all(sna));
    ct(sna);
}

int main() {
    Main();
}


Measured memory_bytes: 3640
A,B,H,M=map(int,input().split())

import math  #三角関数・円周率

M_length = B  #分針長さ
H_length = A  #時針長さ

nowhour = H+M/60
nowminute=M

H_A = nowhour / 12 * 360 * math.pi /180  #針の角度
M_A = nowminute / 60 * 360 * math.pi / 180

H_x = math.cos(H_A) * H_length  #針の先端の座標計算（中心基準）
H_y = math.sin(H_A) * H_length
M_x = math.cos(M_A) * M_length
M_y = math.sin(M_A) * M_length
ans1=(H_x-M_x)**2+(H_y-M_y)**2
ans2=ans1**(0.5)
print(ans2)

Measured memory_bytes: 9528
M, K = map(int, input().split())
if K > 2 ** M - 1:
  print(-1)
elif M == 1 and K == 0:
  print('0 0 1 1')
elif M == 1 and K == 1:
  print(-1)
else:
  ans = [i for i in range(2 ** M) if i != K] + [K] + [i for i in range(2 ** M - 1, -1, -1) if i != K] + [K]
  print(' '.join(map(str, ans)))

Measured memory_bytes: 31500
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
INF = 1000000000000

n = I()

result = 1000 - (n%1000)
if(result == 1000):
    result = 0
print(result)

Measured memory_bytes: 61820
from sys import stdin


def main() -> None:
    s = next_str()

    if len(s) == 2:
        print(s)
    else:
        print("".join(reversed(s)))


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define lc 2 * v
#define rc 2 * v + 1
#define mid (s + e) / 2
#define ll long long
#define int long long
#define ld long double
#define pii pair <int , int>
#define pll pair <long long , long long>
#define FAST ios::sync_with_stdio(false);cin.tie(0);
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

const int maxn = 3e5 , N = 1e5 + 5 , SQ = 600 , base = 1999 , mod = 1e9 + 7 , INF = 1e18 , lg = 17;

int n , a[maxn][3] , dp[maxn][3];

int32_t main() {
    FAST
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }

    for( int i = 1; i <= n; ++i) {
        for (int j = 0; j < 3; ++j) {
            dp[i][j] = -INF;
        }
    }

    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int t = 0; t < 3; ++t) {
                if(t != j) {
                    dp[i][j] = max(dp[i][j] , dp[i - 1][t] + a[i - 1][j]);
                }
            }
        }
    }

    cout << max(dp[n][0] , max(dp[n][1] , dp[n][2])) << '\n';
}


Measured memory_bytes: 8276
import java.util.*;

public class  Main{
	public static void main(String args[]){
	    Scanner sc = new Scanner(System.in);
	    int x = sc.nextInt();
      	int y = x/500;
        int z = (x-500*y)/5;
      	int ans = y*1000+z*5;	
      
      	System.out.println(ans);
      	
	}
}

Measured memory_bytes: 23764
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;
typedef long long int ll;
typedef std::pair<int, int> PA;
#define rep(i,n) for(int i=0;i<(int)n;i++)

bool my_compare(pair<pair<string, int>,int> a, pair<pair<string, int>,int> b) {
	//first優先比較
	if (a.first.first != b.first.first) {
		return a.first.first < b.first.first; // 昇順
		//return a.first.first > b.first,first; // 降順
	}

	// それ以外はsecondで比較
	if (a.first.second != b.first.second) {
		//return a.first.second < b.first.second;//昇順
		return a.first.second > b.first.second;//降順
	}
	else {
		// どちらも同じ
		return true;
	}
}
int main(void){
	int n; cin >> n;
	vector<std::pair<std::pair<string,int>,int>> v(n);
	string str;
	int x;
	rep(i, n) {
		v[i].second = i+1;
		cin >> str >> x;
		v[i].first = make_pair(str, x);
	}
	sort(v.begin(), v.end(),my_compare);
	rep(i, n) {
		//cout << v[i].first.first << " " << v[i].first.second << " ";
		cout << v[i].second << endl;
	}
	return 0;
}

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n, a[100001];
  ll one = 0, two = 0, four = 0;
  string result;
  cin >> n;
  rep(i, n) {
    cin >> a[i];
    if(a[i] % 4 == 0) four++;
    else if(a[i] % 2 == 0) two++;
    else one++;
  }
  if(two) {
    if(one <= four) result = "Yes";
    else result = "No";
  } else {
    if(one <= four + 1) result = "Yes";
    else result = "No";
  }
  cout << result << endl;
	return 0;
}

Measured memory_bytes: 1024
# ABC140E
class SegTree:
    def __init__(self, init_val, n, ide_ele, seg_func):
        self.segfunc = seg_func
        self.num = 2**(n-1).bit_length()
        self.ide_ele = ide_ele
        self.seg=[self.ide_ele]*2*self.num
        for i in range(n):
            self.seg[i+self.num-1]=init_val[i]    
        for i in range(self.num-2,-1,-1) :
            self.seg[i]=self.segfunc(self.seg[2*i+1],self.seg[2*i+2]) 
    def update(self, k, x):
        k += self.num-1
        self.seg[k] = x
        while k+1:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1],self.seg[k*2+2])
        
    def query(self, p, q):
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res=self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res,self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res,self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res,self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res,self.seg[p]),self.seg[q])
        return res

n,m=map(int, input().split())
xs = []
for _ in range(m):
    L, R, C = map(int, input().split())
    xs.append((L-1, R-1, C))
xs.sort()

mx = 10**15
ss = SegTree([0] + [mx] * n, n+1, mx, min)
for l, r, c in xs:
    mm = ss.query(l, n+1)
    nx = min(mm + c, ss.query(r, r+1))
    ss.update(r, nx)
r = ss.query(n-1,n)
print(r if r != mx else -1)


Measured memory_bytes: 84568
from itertools import product
n, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(n)]
ans = 10**9
for v in product([0, 1, 2, 3], repeat=n):
    a, b, c = 0, 0, 0
    cost = 0
    for i in range(n):
        if v[i] == 0:
            if a > 0:
                cost += 10
            a += l[i]
        elif v[i] == 1:
            if b > 0:
                cost += 10
            b += l[i]
        elif v[i] == 2:
            if c > 0:
                cost += 10
            c += l[i]
    if min(a, b, c) > 0:
        cost += abs(a-A) + abs(b-B) + abs(c-C)
        ans = min(ans, cost)

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

// const int maxn = 
// const int mo = 1e9 + 7;

int n, m;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> m;
	int x = 1, y = n;
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		x = max(x, a);
		y = min(y, b);

		if (x > y)
			break;
	}
	
	cout << max(y-x+1, 0) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;



int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin >> n;
    string s;
    while(n != 0){
        n--;
        ll r = n%26;
        s +=(char)(97 + r);
        n /= 26;
    }
    reverse(s.begin(),s.end());
    cout << s << endl;
}


Measured memory_bytes: 3648
fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line);
    if line.as_bytes()[4] == line.as_bytes()[5] &&line.as_bytes()[2] == line.as_bytes()[3]  {
        println!("Yes")
    } else {
        println!("No")
    };
}


Measured memory_bytes: 4352