akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const int INF = INT_MAX / 2;

int main()
{
    for(;;){
        int n, start, goal, m;
        cin >> n >> start >> goal >> m;
        if(n == 0)
            return 0;

        vector<vector<pair<int, int> > > edges(n+1);
        for(int i=0; i<m; ++i){
            int a, b;
            cin >> a >> b;
            edges[a].push_back(make_pair(b, 0));
            edges[b].push_back(make_pair(a, i+1));
        }

        multimap<pair<int, int>, int> mm;
        vector<vector<pair<int, int> > > check(n+1, vector<pair<int, int> >(2, make_pair(INF, INF)));
        mm.insert(make_pair(make_pair(0, 0), start));
        check[start][0] = make_pair(0, 0);

        for(;;){
            int t = mm.begin()->first.first;
            int rev = mm.begin()->first.second;
            int curr = mm.begin()->second;
            mm.erase(mm.begin());
            if(check[curr][rev?1:0] != make_pair(t, rev))
                continue;
            if(curr == goal){
                cout << t << ' ' << rev << endl;
                break;
            }
            
            for(unsigned i=0; i<edges[curr].size(); ++i){
                if(rev != 0 && edges[curr][i].second != 0)
                    continue;

                int t2 = t + 1;
                int rev2 = rev + edges[curr][i].second;
                int next = edges[curr][i].first;

                if(make_pair(t2, rev2) < check[next][rev2?1:0]){
                    mm.insert(make_pair(make_pair(t2, rev2), next));
                    check[next][rev2?1:0] = make_pair(t2, rev2);
                }
            }
        }
    }
}

Measured memory_bytes: 1580
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug(Head head,Tail... tail){
    cerr<<" "<<to_string(head);
    debug(tail...);
}

int main(){
    int N;
    cin>>N;
    vector<int> a(N);
    int count_2=0,count_4=0;
    FOR(i,N){
        cin>>a[i];
        if(a[i]%4==0){
            ++count_4;
        }else if(a[i]%2==0){
            ++count_2;
        }
    }
    N-=count_4*2+1;
    if(N>0){
        N-=count_2-1;
    }
    cout<<(N<=0 ? "Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){return (int)s.size();}
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    string s; cin >> s;
    int si = SIZE(s);
    s = s.substr(0,si-1);
    si--;
    if(si % 2 == 1){
        s = s.substr(0,si-1);
        si--;
    }
    for(int i = si; i > 0; i -= 2){
        if(s.substr(0,i/2) == s.substr(i/2)){
            cout << i << endl;
            return 0;
        }
        s = s.substr(0,i-2);
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int N = stdIn.nextInt();
        int X = stdIn.nextInt();

        int min = 100001;
        
        for(int i = 0; i < N; i++){
            int m = stdIn.nextInt();
            X -= m;
            if(min > m)
                min = m;

        }

        int cnt = N;

        X -= min;
        while(X > -1){
            cnt++;
            X -= min;
        }
        System.out.println(cnt);
        
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int main(){
  char c;
  cin >> c;
  c++;
  cout << c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=3005,INF=1<<29;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N,M,K;cin>>N>>M>>K;
        if(N+M+K==0) break;
        
        vector<vector<double>> dp(N+1,vector<double>(N*M+1));
        
        dp[0][0]=1.0;
        
        for(int i=0;i<N;i++){
            for(int j=0;j<=i*M;j++){
                for(int k=1;k<=M;k++){
                    dp[i+1][j+k]+=dp[i][j]/M;
                }
            }
        }
        
        double ans=0.0;
        
        for(int j=0;j<=N*M;j++){
            if(j<=K) ans+=dp[N][j];
            else ans+=dp[N][j]*(j-K);
        }
        
        cout<<setprecision(25)<<ans<<endl;
    }
}



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

int main(){
  string S;
  cin>>S;
  
  int answer =700;
  for(int i=0;i<3;i++){
    if(S.at(i)=='o'){
      answer+=100;
    }
  }
  cout<<answer<<endl;
}

   
  
 


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
  int i;
  int n;
  int a[100010], b[100010], c[100010];
  long long sum[100010];
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    b[i] = a[i];
    c[i] = a[i];
  }
  long long ans_1 = 0;
  if (b[0] >= 0) {
    long long diff = a[0]+1;
    b[0] = -1;
    ans_1 += diff;
  } 
  sum[0] = b[0];
  for (i = 1; i < n; i++) {
    sum[i] = sum[i-1] + b[i];
    if (sum[i]*sum[i-1] >= 0) {
      if (sum[i-1] < 0) {
	long long diff = 1 - sum[i];
	ans_1 += diff;
	b[i] += diff;
	sum[i] = 1;
      } else {
	long long diff = sum[i] + 1;
	ans_1 += diff;
	b[i] -= diff;
	sum[i] = -1;
      }
    }	
  }
  long long ans_2 = 0;
  for (i = 0; i < n; i++) {
    sum[i] = 0;
  }
  if (c[0] <= 0) {
    long long diff = 1-c[0];
    c[0] = 1;
    ans_2 += diff;
  } 
  sum[0] = c[0];
  for (i = 1; i < n; i++) {
    sum[i] = sum[i-1] + c[i];
    if (sum[i]*sum[i-1] >= 0) {
      if (sum[i-1] < 0) {
	long long diff = 1 - sum[i];
	ans_2 += diff;
	c[i] += diff;
	sum[i] = 1;
      } else {
	long long diff = sum[i] + 1;
	ans_2 += diff;
	c[i] -= diff;
	sum[i] = -1;
      }
    }	
  }
  /*for (i = 0; i < n; i++) {
    printf("%d ", b[i]);
  }
  printf("\n");
  for (i = 0; i < n; i++) {
    printf("%d ", c[i]);
  }
  printf("\n");
  for (i = 0; i < n; i++) {
    printf("%lld ", sum[i]);
  }
  printf("\n");*/
  printf("%lld", min(ans_1, ans_2));
  return 0;
}


Measured memory_bytes: 2176
#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<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
  Edge(int src, int dst) : src(src), dst(dst) {}
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

bool augment(const Graph& g, int u,
    vector<int>& matchTo, vector<bool>& visited) {
  if (u < 0) return true;
  FOR(e, g[u]) if (!visited[e->dst]) {
    visited[e->dst] = true;
    if (augment(g, matchTo[e->dst], matchTo, visited)) {
      matchTo[e->src] = e->dst;
      matchTo[e->dst] = e->src;
      return true;
    }
  }
  return false;
}

int bipartiteMatching(const Graph& g, int L, Edges& matching) {
  const int n = g.size();
  vector<int> matchTo(n, -1);
  int match = 0;
  REP(u, L) {
    vector<bool> visited(n);
    if (augment(g, u, matchTo, visited)) ++match;
  }
  REP(u, L) if (matchTo[u] >= 0) // make explicit matching
    matching.push_back( Edge(u, matchTo[u]) );
  return match;
}

int h[1000][1000];
int t[1000][1000];
int H, W;

bitset<1000> ok[1000];
pii v[1000];

bool check() {
  REP(i,W) ok[i].set();
  REP(y,H) {
    REP(x,W) v[x] = pii(h[y][x],x);
    sort(v,v+W,greater<pii>());
    int id = 0;
    bitset<1000> bits;
    bits.set();
    REP(x,W) {
      while(id<W&&v[id].first>=v[x].first) bits[v[id++].second] = 0;
      ok[v[x].second] &= bits;
    }
  }
  // REP(i, W) {
  //   REP(j,W) cout << ok[i][j];
  //   cout << endl;
  // }

  Graph g(2*W);
  bool f = 0;
  REP(i,W) {
    // g[i].push_back(Edge(i,W+i));
    // g[W+i].push_back(Edge(W+i,i));
    int c = 0;
    REP(j,W) {
      if(ok[i][j]) {
        ++c;
        g[i].push_back(Edge(i,W+j));
        g[W+j].push_back(Edge(W+j,i));
      }
    }
    f |= (c == W-1) ;
  }
  if (!f) return 0;
  
  Edges gomi;
  int r = W-bipartiteMatching(g,W,gomi);
  
  return r <= 2;
}

int main() {
  cin >> H >> W;
  REP(i,H)REP(j,W)cin>>h[i][j];
  if (!check()) goto no;
  REP(i,H)REP(j,W)t[i][j]=h[i][j];
  REP(i,H)REP(j,W)h[j][i]=t[i][j];
  swap(H,W);
  if (!check()) goto no;
  cout << "YES" << endl;
  return 0;
no:
  cout << "NO" << endl;
}

Measured memory_bytes: 25032
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n,k;
    cin >> n >> k;
    int t = (n-1)*(n-2)/2;
    if(k > t){
        cout << -1 << endl;
    }else{
        cout << n-1 + t-k << endl;
        loop(i,2,n+1)cout << "1 " << i << endl;
        if(t-k == 0)return 0;
        int cnt = 0;
        loop(i,2,n+1)loop(j,2,i){
            cout << i << " " << j << endl;
            cnt++;
            if(cnt == t-k)return 0;
        }
    }
}


Measured memory_bytes: 256
N = int(input())
s = [int(input()) for _ in range(N)]
ans = sum(s)
if ans % 10:
    print(ans)
else:
    l = [n if n % 10 else 99999999 for n in s]
    l.sort()
    if l[0] == 99999999:
        print(0)
    else:
        print(ans - l[0])

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

#define ll long long int
#define llu unsigned long long int
#define f(n) for(ll i=0;i<n;i++)
#define fr(n) for(ll i=n-1;i>=0;i--)
#define endl "\n"
#define mod 1000000007

using namespace std;

int main()
{
	//#ifdef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif
	std::ios_base::sync_with_stdio(false);

	ll n;
	cin>>n;
	//ll a[n+1];
	set<ll> s;
	f(n)
	{
		ll x;
		cin>>x;
		s.insert(x);
	}
	if(s.size()==n)
	{
		cout<<"YES";
	}
	else
	{
		cout<<"NO";
	}
	
	return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,m;
    cin>>n>>m;

    long long int arr[n];

    priority_queue<long long int>s;

    for(int i=0;i<n;i++)
     {
      cin>>arr[i];
       s.push(arr[i]);
     }

       while(m > 0)
       {
          long long int x=s.top();
           s.pop();
            x=x/2;
            s.push(x);
            m--;
       }
       long long int sum=0;
       for(int i=0;i<n;i++)
       {
          sum+=s.top();
           s.pop();
       }
      cout<<sum;
}


Measured memory_bytes: 1912
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
static const int MAX = 3000;
static const int INF = 1<<29;

class E{
public:
  int t, c;
  E(){}
  E(int t, int c):t(t), c(c){}
};

int N, K;
vector<E> G[MAX];

void dijkstra(){
  int d[MAX];
  priority_queue<pair<int, int> > PQ;
  for ( int i = 0; i < N; i++ ) d[i] = INF;
  for ( int i = 0; i < K; i++ ){
    int k; cin >> k; k--;
    PQ.push(make_pair(0, k));
    d[k] = 0;
  }
  int u, v, c;
  pair<int, int> s;
  while(!PQ.empty() ){
    s = PQ.top(); PQ.pop();
    u = s.second;
    for ( int i = 0; i < G[u].size(); i++ ){
      v = G[u][i].t;
      c = G[u][i].c;
      if ( d[v] > d[u] + c ){
	d[v] = d[u] + c;
	PQ.push(make_pair(-1*d[v], v));
      }
    }
  }

  double maxv = 0;
  for ( u = 0; u < N; u++ ){
    maxv = max(maxv, 1.0*d[u]);
    for ( int j = 0; j < G[u].size(); j++ ){
      v = G[u][j].t;
      c = G[u][j].c;
      maxv = max(maxv, (d[u] + d[v] + c)/2.0);
    }
  }
  cout << (int)(maxv+0.5) << endl;
  
}


main(){
  int M,  s, t, c;
  cin >> N >> M >> K;
  for ( int i = 0; i < M; i++ ){
    cin >> s >> t >> c; s--; t--;
    G[s].push_back(E(t, c));
    G[t].push_back(E(s, c));
  }
  dijkstra();
}

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

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

	for (int i = 0; i < N; i++) {
		ll h;
		cin >> h;
		H.push_back(h);
	}

	sort(H.begin(), H.end());

	ll ans = 0;
	for (int i = 0; i < N - K; i++) {
		ans += H[i];
	}

	cout << ans << endl;

}

Measured memory_bytes: 2420
#include <stdio.h>
using namespace std;

void trace(int A[], int N) {
  int i ;
  for (i = 0; i < N; i++) {
    if (i > 0) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

void insertionSort(int A[], int N){
  int j, i, v;
  for (i = 1; i < N; i++) {
	v = A[i];
    j = i - 1;
    while (j >= 0 && A[j] > v) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;
    trace(A, N);
  }
}
  
  
int main() {
    int N, i, j;
    int A[100];
    
    scanf("%d", &N);
    for (i = 0; i < N; i++) scanf("%d", &A[i]);
    
    trace(A, N);
    insertionSort(A, N);
}


Measured memory_bytes: 2752
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,ans=0;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    partial_sort(a,a+k,a+n,greater<int>());
    for(int i=0;i<k;i++)
        ans+=a[i];
    cout<<ans;
} 

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int X[3];

int main(){

  scanf("%d %d %d", X, X+1, X+2);
  sort(X, X+3);
  
  int res = 0;
  res += (X[2] - X[0])/2;
  res += (X[2] - X[1])/2;
  X[0] += (X[2] - X[0])/2*2;
  X[1] += (X[2] - X[1])/2*2;
  sort(X, X+3);
  switch((X[2]-X[0]) + (X[1]-X[0])){
    case 0:
      break;
    case 1:
      res += 1;
      break;
    case 2:
      res += 2;
      break;
  }

  printf("%d\n", res);
    
  return 0;
}


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

cnt = 0
m,d = map(int, input().split())
for i in range(1, m+1):
        for j in range(11, d+1):
                d1 = j//10
                d2 = j%10
                if d1 * d2 == i and d1>1 and d2 > 1:
                        cnt += 1
print(cnt)


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  while(cin>>N,N){
	VS vs(N);
	REP(i,N){
	  string s; cin >> s;
	  string t = string(1, s[0]);
	  for(int i=1;i<SZ(s);++i){
		if(string("aiueo").find(s[i-1]) != string::npos){
		  t += s[i];
		}
	  }
	  vs[i] = t;
	}
	
	int k;
	for(k=1;k<=50;++k){
	  set<string> s;
	  for(int i=0;i<N;++i)
		s.insert(vs[i].substr(0,k));
	  if(SZ(s) == N){
		break;
	  }
	}
	cout << (k>50?-1:k) << endl;
  }

  return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M=52;
ll a[M],ct[M];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	ll ans=0;
	while(1)
	{
		ll res = 0;
		for(int i=1;i<=n;i++)
		{
			ct[i]=(a[i])/n;
			a[i]%=n;
			res = res + ct[i];
		} 
		if(res==0)
			break;
		for(int i=1;i<=n;i++)
			a[i]=a[i]+res-ct[i];
		ans+=res;
	}
	multiset<ll> mlt;
	for(int i=1;i<=n;i++)
		mlt.insert(a[i]);
	while(sz(mlt))
	{
		auto it=mlt.begin();
		ll z=*it;
		mlt.erase(it);
		if(z<n)
			break;
		z=z-n;
		mlt.insert(z);
		ans++;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
ll b1[1 << 18], b2[1 << 18]; int n,m;
void add(int a, int b, ll w) {
	for (int i = a; i < m+1; i |= i + 1)b1[i] += -a * w;
	for (int i = b; i < m+1; i |= i + 1)b1[i] += b * w;
	for (int i = a; i < m+1; i |= i + 1)b2[i] += w;
	for (int i = b; i < m+1; i |= i + 1)b2[i] += -w;
}
ll sum0(int a) {
	ll ret = 0;
	for (int i = a - 1; i >= 0; i = (i &(i + 1)) - 1)ret += b1[i];
	for (int i = a - 1; i >= 0; i = (i &(i + 1)) - 1)ret += a*b2[i];
	return ret;
}
ll sum(int a, int b) {
	return sum0(b) - sum0(a);
}
struct miyage { int from, to; };
bool comp(miyage a, miyage b) {
	if (a.to - a.from < b.to - b.from)return true;
	else return false;
}
miyage x[300000];
int main() {
	cin >> n >> m;
	rep(i, n) {
		int l, r; cin >> l >> r;
		x[i] = { l,r };
	}
	sort(x, x + n, comp);
	int now = 0;
	int cnt = n;
	rep1(i, m) {
		int out = cnt;
		for (int j = 0; j <= m; j+=i) {
			out += sum(j,j+1);
		}
		cout << out << endl;
		while (now < n&&x[now].to - x[now].from + 1 <= i) {
			add(x[now].from, x[now].to+1, 1);
			now++; cnt--;
		}
	}
	return 0;
}

Measured memory_bytes: 7040
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> vi;

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

int n,q;
cin >> n >> q;
string s;
cin >> s;
int l,r;
int i;
vi ans(n,0);
ans[0] = 0;
for(i=0;i<n-1;++i){
    if(i!=0) ans[i]=ans[i-1];
    if(s[i]=='A' && s[i+1]=='C') ans[i]++;
}
ans[i+1] = ans[i];
for(i=0;i<q;++i){
    cin >> l >> r;
    cout << ans[r-2]-ans[l-2] << endl;
}

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 1488
class RollingHash:

    PS1 = 1009
    PS2 = 1007
    PL1 = 100000007
    PL2 = 100000009

    def __init__(self, s: str):
        self._n = len(s) + 1
        self._pow1, self._pow2, self._hash1, self._hash2 = self._initialize(s, self._n)

    def _initialize(self, s: str, n: int):
        pow1 = [1 for _ in range(n)]
        pow2 = [1 for _ in range(n)]
        hash1 = [0 for _ in range(n)]
        hash2 = [0 for _ in range(n)]

        idx = 1
        for c in s:
            pow1[idx] = pow1[idx - 1] * self.PS1 % self.PL1
            pow2[idx] = pow2[idx - 1] * self.PS2 % self.PL2
            hash1[idx] = (hash1[idx - 1] * self.PS1 + ord(c) - ord('a') + 1) % self.PL1
            hash2[idx] = (hash2[idx - 1] * self.PS2 + ord(c) - ord('a') + 1) % self.PL2
            idx += 1

        return pow1, pow2, hash1, hash2

    def get(self, l: int, r: int):
        p1 = ((self._hash1[r] - self._hash1[l] * self._pow1[r - l]) % self.PL1 + self.PL1) % self.PL1
        p2 = ((self._hash2[r] - self._hash2[l] * self._pow2[r - l]) % self.PL2 + self.PL2) % self.PL2
        return p1, p2


N = int(input())
S = input()

rh = RollingHash(S)

MAGIC_NUMBER = 261

ans = 0
end = False
for l in range((N + 1) // 2, 1, -1):
    d = {}
    for idx in range(N - l + 1):
        p1, p2 = rh.get(idx, idx + l)
        lv, rv = d.get((p1, p2), (N, 0))
        lv = min(lv, idx)
        rv = max(rv, idx)
        d[(p1, p2)] = (lv, rv)

    for _, (lv, rv) in d.items():
        if rv - lv >= l:
            print(l)
            end = True
            break

    if end:
        break

if not end:
    print(0)


Measured memory_bytes: 114904
import math
n=int(input())
arr=list(map(int,input().split()))
ans=True

if n%2!=0:
    if arr.count(0)!=1:
    	ans=False
    elif len(set(arr))!=int(n/2)+1:
        ans=False
else:
    if 0 in arr:
        ans=False
    elif len(set(arr))!=int(n/2):
        ans=False

if ans:
    print(2**math.floor(n/2)%((10**9)+7))
else:
    print(0)

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

#define int long long

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int P[n], Q[n];
	for (int i = 0; i < n; i++){
		cin >> P[i];
		P[i] --;
		Q[P[i]] = i;
	}
	set <int> ST;
	ST.insert(Q[n - 1]);
	long long ans = 0;
	for (int i = n - 2; i >= 0; i--){
		auto x = ST.lower_bound(Q[i]);
		int X;
		if (x != ST.begin()){
			x --;
			X = *x;
		}
		else
			X = -1;
		auto y = ST.upper_bound(Q[i]);
		int Y;
		if (y == ST.end()){
			Y = n;
		}
		else{
			Y = *y;
		}
		int A, B;
		if (x != ST.begin()){
			x --;
			A = *x;
		}
		else
			A = -1;
		if (y != ST.end()){
			y ++;
			if (y == ST.end())
				B = n;
			else
				B = *y;
		}
		else
			B = n;
		if (X != -1){
			ans += (i + 1) * (X - A) * (Y - Q[i]);
		}
		if (Y != n){
			ans += (i + 1) * (B - Y) * (Q[i] - X);
		}
		ST.insert(Q[i]);
	}
	cout << ans;
}


Measured memory_bytes: 6528
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <list>
using namespace std;
 
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<int, ll> i_ll;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
#define rep(i, N) for (int i = 0; i < (int)(N); i++)
#define pb push_back
 
int INF = INT_MAX / 10;
ll MOD = 924844033;
ll _MOD = 1000000009;
double EPS = 1e-10;

struct union_find {
	vector<int> v;
	union_find(int n) : v(n, -1) {}
	int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		if (-v[x] < -v[y]) swap(x, y);
		v[x] += v[y]; v[y] = x;
	}
	bool root(int x) { return v[x] < 0; }
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -v[find(x)]; }
};

int main() {
	int N, K; cin >> N >> K;
	vector<i_i> p;
	rep(i, N) {
		if (i - K >= 0) p.pb(i_i(i, i - K));
		if (i + K < N) p.pb(i_i(i, i + K));
	}
	int M = p.size();
	union_find uf(M);
	rep(j, M) rep(k, M)
		if (p[j].first == p[k].first || p[j].second == p[k].second)
			uf.unite(j, k);
	vector<ll> ans(M + 1);
	ans[0] = 1;
	rep(j, M) {
		if (!uf.root(j)) continue;
		int n = uf.size(j);
		vector<ll> dp0(n + 1), dp1(n + 1);
		dp0[0] = 1;
		rep(t, n) {
			vector<ll> _dp0(n + 1), _dp1(n + 1);
			rep(x, n) {
				_dp0[x] = (_dp0[x] + dp0[x] + dp1[x]) % MOD;
				_dp1[x + 1] = (_dp1[x + 1] + dp0[x]) % MOD;
			}
			dp0 = _dp0; dp1 = _dp1;
		}
		vector<ll> _ans(M + 1);
		rep(y, M + 1) {
			if (!ans[y]) continue;
			rep(x, n + 1) _ans[y + x] = (_ans[y + x] + ans[y] * (dp0[x] + dp1[x])) % MOD;
		}
		ans = _ans;
	}
	ll unko = 0;
	rep(y, N + 1) {
		if (y >= ans.size()) continue;
		ll z = ans[y];
		rep(i, N - y) z = z * (i + 1) % MOD;
		if (y % 2) z *= -1;
		unko = (unko + z) % MOD;
	}
	cout << (unko + MOD) % MOD << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  int A[2];
  cin >> A[0];
  cin >> A[1];
  cin >> A[2];
  
  sort(A,A+3);
  
  if (A[0] == 5 && A[1] == 5 && A[2] == 7){
    cout << "YES";
  }
  else{
    cout << "NO";
  }
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b-1; i >= a; i--)
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;

signed main(){
    int a, b, c, cnt = 0, ans = 0;
    string S;
    vector<int> v(10);
    cin >> a >> b;
    rep(i, 1, 4){
        if(i == a || i == b) continue;
        cout << i << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define pa pair<int,int> 
#define MP(x,y) make_pair(x,y) 
#define fi first
#define se second 
using namespace std;
const int maxn=201;
int n,m,s,t,ans;
char c[maxn];
int a[maxn][maxn],dis[maxn][maxn];
pa q[maxn*maxn*2];
int l,r;
int dx[]={1,0};
int dy[]={0,1};
void bfs() 
{
	l=maxn*maxn+1;r=l-1;
	q[++r]=MP(1,1);
	while(l<=r) {
		pa X=q[l];l++;int x=X.fi,y=X.se;
		for(int i=0;i<2;++i) {
			int tx=dx[i]+x,ty=dy[i]+y;//cout<<tx<<" "<<ty<<"\n";
			if(tx>n) continue ;if(ty>m) continue ;if(dis[tx][ty]!=-1) continue ;
			if(a[x][y]^a[tx][ty]) {
				dis[tx][ty]=dis[x][y]+1;q[++r]=MP(tx,ty);
			}else {
				dis[tx][ty]=dis[x][y];q[--l]=MP(tx,ty);
			}
		}
	}
}

int main() 
{
	memset(dis,-1,sizeof(dis));
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i) {
		scanf("%s",c+1);
		for(int j=1;j<=m;++j) {
			if(c[j]=='.') a[i][j]=1;
			else a[i][j]=0;
		}
	}
	dis[1][1]=0;
	if(a[1][1]==0) dis[1][1]++;bfs();
	if(a[n][m]==0) dis[n][m]++;
	cout<<dis[n][m]/2<<"\n";
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


signed main(){
    string s;
    cin >> s;
    int n = s.length();
    int A[3] = {};
    REP(i,n){
        A[int(s[i]) - 'a'] ++;
    }
    sort(A,A+3);
    if(A[2] - A[0] <= 1) cout << "YES" << endl;
    else cout << "NO" << endl;

}


Measured memory_bytes: 512
#include<iostream>
#include<cmath>
#include <iomanip>
using namespace std;

int main(){
    double a, b, c, area, length, height;
    double pi=3.1415926535;
    cin >> a >> b >> c;
    area=a*b*sin(c*pi/180)/2;
    length=a+b+sqrt(a*a+b*b-2*a*b*cos(c*pi/180));
    height=b*sin(c*pi/180);

    cout << fixed << setprecision(6);
    cout << area << endl;
    cout << length << endl;
    cout << height << endl;

    return 0;  
}


Measured memory_bytes: 3420
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
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; }
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

vector<long long> L(51), P(51);

ll ans = 0;

void f(ll N, ll X){
    ll l = L[N];
    if(N == 0){
        ++ans;
        return;
    }
    if(X <= 1) return;
    if(X <= 1 + L[N - 1]) f(N - 1, X - 1);
    else if(X <= 2 + L[N - 1]) ++ans, f(N - 1, X - 1);
    else if(X <= 2 + 2 * L[N - 1]) ans += 1 + P[N - 1], f(N - 1, X - 2 - L[N - 1]);
    else ans += 1 + 2 * P[N - 1];
};

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

    ll N, X;
    cin >> N >> X;

    L[0] = 1;
    P[0] = 1;
    rep1(i, 50){
        L[i] = 3 + 2 * L[i - 1];
        P[i] = 1 + 2 * P[i - 1];
    }
    f(N, X);
    print(ans);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)



// BFSによる塗りつぶし探索
#define MAX_H (50)
#define MAX_W (50)
typedef char Graph[MAX_H][MAX_W];
Graph graph;
typedef int Dist[MAX_H][MAX_W];
Dist dist;
bool seen[MAX_H][MAX_W];
int H, W; // グラフサイズ
typedef pair<int, int> P;

// 指定されたマスが次のdfsを行う対象かどうかをチェックする関数
// 0 <= h < H, 0 <= w < W を満たすこと
// その他追加条件を満たすこと　を確認
bool willCheck(int h, int w) {

	// グラフサイズ内であることの確認
	if (h < 0) return false;
	if (w < 0) return false;
	if (H <= h) return false;
	if (W <= w) return false;

	// 既に探索済みでないことの確認
	if (seen[h][w]) return false;

	// 問題ごとの条件を満たす確認
	if (graph[h][w] == '.') return true;

	return false;
}

void bfs(int start_h, int start_w) {
	// キューを用意して、初期探索点をセット
	queue<P> que;
	que.push(P(start_h, start_w)); // 初期点の距離を0
	dist[start_h][start_w] = 0;
	seen[start_h][start_w] = true;

	while (!que.empty()) { // BFSループ
		// ★★　この中で迂闊に break しないこと

		// キューの先頭のセルを取得
		P v = que.front(); que.pop();
		int h = v.first;
		int w = v.second;

		// 取得したセルに対する処理

		// そのセルからつながるセルに処理を移行
		if (willCheck(h + 1, w)) {
			dist[h + 1][w] = dist[h][w] + 1;
			seen[h + 1][w] = true; // ここでseenをセットしないと、queに同一アイテムが入る
			que.push(P(h + 1, w));
		}
		if (willCheck(h - 1, w)) {
			dist[h - 1][w] = dist[h][w] + 1;
			seen[h - 1][w] = true;
			que.push(P(h - 1, w));
		}
		if (willCheck(h, w + 1)) {
			dist[h][w + 1] = dist[h][w] + 1;
			seen[h][w + 1] = true;
			que.push(P(h, w + 1));
		}
		if (willCheck(h, w - 1)) {
			dist[h][w - 1] = dist[h][w] + 1;
			seen[h][w - 1] = true;
			que.push(P(h, w - 1));
		}
	}

}


int main() {

	cin >> H >> W;

	int white = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			char tmp;
			cin >> tmp;
			graph[i][j] = tmp;
			dist[i][j] = -1;
			if (tmp == '.') white++;
		}
	}

	bfs(0, 0);

	if (dist[H - 1][W - 1] == -1) cout << "-1" << endl;
	else cout << white - dist[H-1][W-1] - 1 << endl;

	return 0;

}

Measured memory_bytes: 256
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc138_a.cpp
 * time   : Sat May  2 01:43:51 2020
 * quest  : A - Red or Not
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int a; string s;
  cin >> a >> s;
  cout << (a < 3200 ? "red" : s) << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 2550
#define pii pair<int, int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x < n and y >= 0 and y < n)
using namespace std;
const ll mod = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;

    vector<int> a(n), b(n-1);

    for (int& x: b) cin >> x;

    a[0] = b[0], a[n-1] = b[n-2];
    int ans = a[0] + a[n-1];

    for (int i=1; i<n-1; i++){
        a[i] = min(b[i], b[i-1]);
        ans += a[i];
    }

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

Measured memory_bytes: 256
package main

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

func main() {
	N := nextInt()
	A := nextInt()
	B := nextInt()

	if N*A < B {
		fmt.Println(N * A)
	} else {
		fmt.Println(B)
	}
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)

	return i
}


Measured memory_bytes: 640
#!/usr/bin/ruby

def solve(y, m, d)
  h = "Heisei"
  t = "TBD"
  return h if y < 2019
  return h if m <= 4
  return t
end

def each_case(sin)
  y, m, d = sin.gets.chomp.split("/").map(&:to_i)
  yield y, m, d
end

each_case(STDIN) do |y, m, d|
  puts solve(y, m, d)
end




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

typedef long long int64;
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())

const int N = 111;
const double pi = acos(-1.0);
vector< pair<double, int> > a;
int n, x[N], y[N];
double ans[N];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d%d", &x[i], &y[i]);
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (i == j) {
				continue;
			}
			int64 a = y[i] - y[j], b = x[j] - x[i], c = x[i] * (int64) y[j] - x[j] * (int64) y[i];
			bool ok = true;
			for (int k = 0; k < n; ++k) {
				int64 d = a * x[k] + b * y[k] + c;
				if (d < 0) {
					ok = false;
					break;
				}
				if ((d == 0) && ((x[k] - x[i]) * (int64) (x[k] - x[j]) + (y[k] - y[i]) * (int64) (y[k] - y[j]) > 0)) {
					ok = false;
					break;
				}
			}
			if (ok) {
				double alpha = atan2(a, b);
				if (alpha < 0) {
					alpha += 2 * pi;
				}
				(::a).pb(mp(alpha, j));
			}
		}
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < sz(a); ++i) {
		double delta = 0;
		delta = (i == 0) ? (a[i].fs - a[sz(a) - 1].fs + 2 * pi) : (a[i].fs - a[i - 1].fs);
		ans[a[i].sc] = delta;
	}
	for (int i = 0; i < n; ++i) {
		printf("%.10f\n", ans[i] / (2 * pi));
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //int cnt = Integer.parseInt(scan.next());
        //int total = Integer.parseInt(scan.next());

        String input = scan.next();
        if(input.contains("7")) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35760
#include <cstdio>
#include <cstring>
#include <stack>
#include <algorithm>
#define MAXN 1000010
using namespace std;

struct edge{
	int to,next;
	edge(int _to=0,int _next=0):to(_to),next(_next){}
}e[10000000];

int n,sizew,nump,numw;
int g[MAXN],nume;
pair<int,int> a[MAXN];
int dfn[MAXN],low[MAXN];
int last[MAXN];
int p[MAXN][2];
stack<int> S;
bool instack[MAXN];
int c[MAXN],numc;

void addEdge(int u,int v){
	e[nume]=edge(v,g[u]);
	g[u]=nume++;
}

void build(int x,int cl,int cr,int l,int r,int src){
	if(l<=cl && cr<=r){
		addEdge(p[sizew+src-1][1],p[x][0]);
		addEdge(p[x][1],p[sizew+src-1][0]);
		return;
	}
	int mid=(cl+cr)>>1;
	if(l<=mid) build(x<<1,cl,mid,l,r,src);
	if(r>mid) build(x<<1|1,mid+1,cr,l,r,src);
}

void tarjan(int x){
	S.push(x);
	instack[x]=1;
	dfn[x]=low[x]=++numw;
	for(int i=g[x];~i;i=e[i].next)
		if(!dfn[e[i].to]){
			tarjan(e[i].to);
			if(low[e[i].to]<low[x]) low[x]=low[e[i].to];
		}else if(instack[e[i].to]){
			if(dfn[e[i].to]<low[x]) low[x]=dfn[e[i].to];
		}
	if(dfn[x]==low[x]){
		++numc;
		while(S.top()!=x){
			instack[S.top()]=0;
			c[S.top()]=numc;
			S.pop();
		}
		instack[S.top()]=0;
		c[S.top()]=numc;
		S.pop();
	}
}

bool check(int lim){
	memset(g,-1,sizeof g);
	nump=nume=0;
	for(sizew=1;sizew<n;sizew<<=1);
	for(int i=1;i<=2*sizew-1;i++) p[i][0]=++nump;
	for(int i=1;i<=2*sizew-1;i++) p[i][1]=++nump;
	for(int i=sizew-1;i;i--){
		addEdge(p[i<<1][1],p[i][1]);
		addEdge(p[i<<1|1][1],p[i][1]);
		addEdge(p[i][0],p[i<<1][0]);
		addEdge(p[i][0],p[i<<1|1][0]);
	}
	memset(last,0,sizeof last);
	for(int i=1;i<=n;i++)
		if(last[a[i].second]){
			int j=last[a[i].second];
			addEdge(p[sizew+i-1][0],p[sizew+j-1][1]);
			addEdge(p[sizew+j-1][0],p[sizew+i-1][1]);
			addEdge(p[sizew+i-1][1],p[sizew+j-1][0]);
			addEdge(p[sizew+j-1][1],p[sizew+i-1][0]);
		}else last[a[i].second]=i;
	for(int i=n-1;i;i--)
		if(a[i+1].first-a[i].first<lim){
			int l=i+1,r=n;
			while(l<r){
				int mid=(l+r+1)>>1;
				if(a[mid].first-a[i].first<lim) l=mid;
				else r=mid-1;
			}
			build(1,1,sizew,i+1,l,i);
		}
	memset(dfn,0,sizeof dfn);
	numc=numw=0;
	for(int i=1;i<=nump;i++)
		if(!dfn[i]) tarjan(i);
	for(int i=1;i<=n;i++)
		if(c[p[sizew+i-1][0]]==c[p[sizew+i-1][1]]) return 0;
	return 1;
}

int main(){
#ifdef DEBUG
	freopen("F.in","r",stdin);
#endif
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int t1,t2;
		scanf("%d%d",&t1,&t2);
		a[i*2-1]=make_pair(t1,i);
		a[i*2]=make_pair(t2,i);
	}
	n*=2;
	sort(a+1,a+n+1);
	int l=0,r=a[n].first-a[1].first;
	while(l<r){
		int mid=(l+r+1)>>1;
		if(check(mid)) l=mid;
		else r=mid-1;
	}
	printf("%d\n",l);
	return 0;
}


Measured memory_bytes: 102912
#![allow(dead_code)]
#![allow(unused_imports)]
#![allow(unused_variables)]

use proconio::{fastout, input};
use std::cmp::{max, min};

const INF: i32 = 1001001001;
const LNF: i64 = 1001001001001001001;
const MOD: i32 = 1000000007;

fn is_prime(x: i32) -> bool {
  if x == 1 {
    return false;
  }
  let mut i = 2;
  while i * i <= x {
    if x % i == 0 {
      return false;
    }
    i += 1;
  }
  true
}

#[fastout]
fn main() {
  input! {
    q: usize,
    lines: [(usize, usize); q],
  }
  let mut v = vec![0; 100001];
  for i in (1..=100000).step_by(2) {
    if is_prime(i) && is_prime((i + 1) / 2) {
      v[i as usize] += 1;
    }
  }
  for i in 1..=100000 {
    v[i] += v[i - 1];
  }
  for (l, r) in lines {
    let ans = v[r] - v[l - 1];
    println!("{}", ans);
  }
}

struct SegmentTree<T> {
  v: Vec<T>,
  f: fn(T, T) -> T,
  e: T,
  n: usize,
}

impl<T: Copy> SegmentTree<T> {
  fn new(size: usize, f: fn(T, T) -> T, e: T) -> Self {
    let mut n = 1;
    while n < size {
      n <<= 1;
    }
    let v: Vec<T> = vec![e; n * 2];
    SegmentTree { v, f, e, n }
  }
  fn set(&mut self, k: usize, x: T) {
    self.v[k + self.n] = x;
  }
  fn build(&mut self) {
    for i in (1..self.n).rev() {
      self.v[i] = (self.f)(self.v[i * 2 + 0], self.v[i * 2 + 1]);
    }
  }
  fn update(&mut self, mut k: usize, x: T) {
    self.v[k + self.n] = x;
    k += self.n;
    while (k >> 1) > 0 {
      k >>= 1;
      self.v[k] = (self.f)(self.v[k * 2 + 0], self.v[k * 2 + 1]);
    }
  }
  fn query(&self, mut a: usize, mut b: usize) -> T {
    let mut l = self.e;
    let mut r = self.e;
    a += self.n;
    b += self.n;
    while a < b {
      if a & 1 == 1 {
        l = (self.f)(l, self.v[a]);
        a += 1;
      }
      if b & 1 == 1 {
        b -= 1;
        r = (self.f)(self.v[b], r);
      }
      a >>= 1;
      b >>= 1;
    }
    (self.f)(l, r)
  }
  fn reset(&mut self, k: usize) {
    self.update(k, self.e);
  }
}


Measured memory_bytes: 5240
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x,y) x = min(x,y)
int main() {
  int N;
  cin >> N;
  string C;
  cin >> C;
  vector<int> A(N+1,0);
  rep(i,N) {
    A.at(i+1) += A.at(i);
    if (C.at(i) == 'R') {
      A.at(i+1)++;
    }
  }
  //rep(i,N+1) { cout << A[i] << endl;}
  // i番目を含まずひだりをすべてRに、→をWにする。全部Rも考慮せなあかん
  int ans = N - A.at(N); // 全部Rにするとき。
  rep(i,N) {
    int leftW = i - A.at(i);
    int rightR = A.at(N) - A.at(i);
    //cout << leftW << "," << rightR << endl;
    chmin(ans, max(leftW,rightR));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4464
var
	N,K,i,p,q,x,tmp,get:Longint;
	ans,now,make:double;
begin
	read(N,K);
	if N>=K then begin
		ans:=(N-K+1)/N;
		q:=K-1;
	end
	else q:=N;
	make:=1;
	get:=1;
	for i:=1 to 3 do begin
		if q=0 then break;
		get:=get*2;
		make:=make*0.5;
		p:=K div get;
		if p<q then begin;
			ans:=ans+(q-p)/N*make;
			q:=p;
		end;
	end;
	for i:=q downto 1 do begin
		tmp:=(K+i-1)div i;
		x:=1;
		now:=1/N;
		while tmp>x do begin
			now:=now*0.5;
			x:=x*2;
		end;
		ans:=ans+now;
	end;
	writeln(ans:0:9);
end.

Measured memory_bytes: 128
# import itertools
# import math
# import sys
# import numpy as np

K = int(input())
# S = input()
# n, *a = map(int, open(0))
# H, W, K = map(int, input().split())
# A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# S = input()

# d = sorted(d.items(), key=lambda x:x[0])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

a1 = 7
ai = 0
for i in range(K + 1):
    if i == 0:
        ai = a1 % K
    else:
        ai = (ai * 10 + 7) % K
    if ai == 0:
        break
else:
    i = -2

print(i + 1)

Measured memory_bytes: 9132
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;

struct ch {
	char num,eng;
};
void bubblesort(struct ch str[], int n);
void selectionsort(struct ch str[], int n);

int main()
{
	int n,i,j;
	ch str1[100],str2[100];
	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> str1[i].eng >> str1[i].num;
	}
	for (i = 0; i < n; i++) str2[i] = str1[i];

	bubblesort(str1,n);
	selectionsort(str2, n);

	for (i = 0; i < n; i++) {
		cout << str1[i].eng << str1[i].num;

		if (i != n - 1) {
			cout << " ";
		}
		else {
			cout << endl;
			break;
		}
	}
	cout << "Stable" << endl;
	j = 1;
	for (i = 0; i < n; i++) {
		cout << str2[i].eng << str2[i].num;
		if (j == 1 && str2[i].eng == str1[i].eng && str1[i].num==str2[i].num) {
			j = 1;
		}else {
			j = 0;
		}
		if (i != n - 1) {
			cout << " ";
		}
		else {
			cout << endl;
			break;
		}
	}
	if (j == 1) {
		cout << "Stable" << endl;
	}
	else {
		cout << "Not stable" << endl;
	}
}
void bubblesort(struct ch str[], int n) {
	int i,j,flag=1;
	struct ch temp;
	while (flag) {
		flag = 0;
		for (j = n - 1; j > 0; j--) {
			if (str[j].num < str[j - 1].num) {
				swap(str[j], str[j - 1]);
				flag = 1;
			}
		}
	}
}
void selectionsort(struct ch str[], int n) {
	struct ch temp;
	int i, j,min;
	for (i = 0; i < n; i++) {
		min = i;
		for (j = i; j < n; j++) {
			if (str[j].num < str[min].num) {
				min = j;
			}
		}
		swap(str[i], str[min]);
	}
}

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

using namespace std;

const int MAXN = 1e6 + 7;

#define int long long

const int mod = 1e9 + 7;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> cnt(60);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        for (int j = 0; j < 60; ++j)
        {
            if (a[i] & (1ll << j))
            {
                ++cnt[j];
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < 60; ++i)
    {
        int cur = cnt[i] * (n - cnt[i]);
        for (int k = 0; k < i; ++k)
        {
            cur *= 2ll;
            cur %= mod;
        }
        ans += cur;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560