akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=998244353;
const int M=1e9+7;
#define inf 0x3f3f3f3f
//std::ios::sync_with_stdio(0);
int main()
{
    std::ios::sync_with_stdio(0);
    ll x,k,d;
    cin>>x>>k>>d;
    if(x>=0)
    {
        if(x/d>=k)
        {
            x=x-k*d;
            k=0;
        }
        else
        {
            k-=x/d;
            x=x-(x/d)*d;

        }
        if(k>0)
        {
            if(k&1)
               x-=d;
        }


    }
    else
    {
        if(abs(x)/d>=k)
        {
            x=x+k*d;
            k=0;
        }
        else
        {
            k-=abs(x)/d;
            x=x+abs(x/d)*d;

        }
        if(k>0)
        {

            if(k&1)
              x+=d;

        }

    }
    cout<<abs(x)<<endl;

}


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

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

  int ans = 0;
  
  ans += (X / 500) * 1000;
  X = X % 500;

  ans += (X / 5) * 5;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>

using namespace std;

int main(void) {
  int n, q, command, t, x;
  cin >> n >> q;

  priority_queue<int> que[n];

  for(int i = 0; i < q; i++) {
    cin >> command >> t;
    switch(command) {
      case 0:
        cin >> x;
        que[t].push(x);
        break;
      case 1:
        if(!que[t].empty())
          cout << que[t].top() << endl;
        break;
      case 2:
        if(!que[t].empty())
          que[t].pop();
        break;
    }
  }
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
	int n;
	cin >> n;
	vi a(n);
	rep(i,n) cin >> a[i];
	sort(all(a));
	int N = a[n-1],R,mi = INF;
	for(int i = 0; i < n; i++){
		if(N-2*min(a[i],N-a[i]) < mi){
			mi = N-2*min(a[i],N-a[i]);
			R = a[i];
		}
	}
	cout << N << ' ' << R << endl;
	return 0;
}

Measured memory_bytes: 640
n,k = map(int, input().split())
s = [ input() for i in range(k*2) ]
nl = [i for i in range(1,n+1)]
t = []
for i in range(1,k*2,2):
    l = []
    l = s[i].split()
    for j in range(len(l)):
        t.append(int(l[j]))
l = list(set(t))
for i in range(len(l)):
    nl.remove(l[i])
print(len(nl))

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

int main()
{
    string S;
    long K;
    cin >> S;
    cin >> K;

    long ans = 0;

    char c = S.at(0);
    long cnt = 1;
    for (long unsigned int i = 1; i < S.size(); i++)
    {
        if (c == S.at(i))
        {
            cnt++;
        }
        else
        {
            c = S.at(i);
            if (cnt > 1)
            {
                ans += cnt / 2;
                cnt = 1;
            }
        }
    }

    if (cnt == S.size())
    {
        cout << (K * cnt) / 2 << endl;
        return 0;
    }

    ans += cnt / 2;
    ans *= K;

    long tmp = cnt;
    for (long unsigned int i = 0; i < S.size(); i++)
    {
        if (c == S.at(i))
        {
            cnt++;
        }
        else
        {
            break;
        }
    }

    ans += ((cnt / 2) - (tmp / 2 + (cnt - tmp) / 2)) * (K - 1);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
using namespace std;
double a, b;
double c[7] = { 35.5,37.5,40.0,43.0,50.0,55.0,70.0 };
double d[7] = { 71.0,77.0,83.0,89.0,105.0,116.0,148.0 };
string s[7] = { "AAA","AA","A","B","C","D","E" };
int main() {
	while (cin >> a >> b) {
		for (int i = 0; i < 7; i++) {
			if (a < c[i] && b < d[i]) {
				cout << s[i] << endl; goto E;
			}
		}
		cout << "NA" << endl;
	E:;
	}
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
int main (){
    char A,B,C,D;
    cin >> A >> B >> C >> D;
    int a,b,c,d;
    a = A-'0';
    b = B-'0';
    c = C-'0';
    d = D-'0';

    if(a+b+c+d  == 7){
        cout <<a<<'+'<<b<<'+'<<c<<'+'<<d<<'='<<7<<endl;

    }
    else if(a+b+c-d  == 7){
        cout <<a<<'+'<<b<<'+'<<c<<'-'<<d<<'='<<7<<endl;
        
    }
    else if(a+b-c+d  == 7){
        cout <<a<<'+'<<b<<'-'<<c<<'+'<<d<<'='<<7<<endl;
        
    }
    else if(a+b-c-d  == 7){
        cout <<a<<'+'<<b<<'-'<<c<<'-'<<d<<'='<<7<<endl;
        
    }
    else if(a-b+c+d  == 7){
        cout <<a<<'-'<<b<<'+'<<c<<'+'<<d<<'='<<7<<endl;
        
    }
    else if(a-b+c-d  == 7){
        cout <<a<<'-'<<b<<'+'<<c<<'-'<<d<<'='<<7<<endl;
        
    }
    else if(a-b-c+d  == 7){
        cout <<a<<'-'<<b<<'-'<<c<<'+'<<d<<'='<<7<<endl;
        
    }
    else if(a-b-c-d  == 7){
        cout <<a<<'-'<<b<<'-'<<c<<'-'<<d<<'='<<7<<endl;
        
    }

}


Measured memory_bytes: 256
using System;
using System.Linq;

class B
{
	static void Main()
	{
		var s = Console.ReadLine();
		Console.WriteLine(IsPalindrome(s) && IsPalindrome(s.Remove(s.Length / 2)) && IsPalindrome(s.Substring((s.Length + 1) / 2)) ? "Yes" : "No");
	}

	static bool IsPalindrome(string s) => Enumerable.Range(0, s.Length / 2).All(i => s[i] == s[s.Length - 1 - i]);
}


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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> m(N);
  
  int s = 0;
  for (int i = 0; i < N; i++) {
    cin >> m.at(i);
    s += m.at(i);
  }
  
  sort(m.begin(), m.end());
  cout << (X - s) / m.at(0) + N << endl;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

struct Edge{
  int to;
  long long cost;
};

struct NODE{
  int pos;
  long long cost;
};
bool operator < (const NODE &a,const NODE &b){
  return a.cost > b.cost;
}
vector<Edge> g[100000],rg[100000];

int N;
const ll INF = 1e15;
vector<ll> dijkstra(vector<Edge> g[100000],int start){
  priority_queue<NODE> Q;
  Q.push({start,0});
  vector<ll> res(N+1,INF);
  while(Q.size()){
    NODE q= Q.top();Q.pop();
    if(res[q.pos] == INF){
      res[q.pos] = q.cost;
    }
    else{
      continue;
    }
    for(auto n : g[q.pos]){
      Q.push({n.to,q.cost+n.cost});
    }
  }
  return res;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int m,a,b,d,e,x,x2,y,y2;
  char c;
  cin >>N>>m;
  rep(i,m){
    cin >> a>>c>>b>>c>>d>>c>>e;
    g[a].push_back(Edge{b,d});
    g[b].push_back(Edge{a,e});
  }
  cin >> x >>c>> x2>>c >> y>>c >> y2;
  auto res = dijkstra(g,x);
  auto res2 = dijkstra(g,x2);
  cout << y - res[x2]-res2[x] -y2 << endl;
  return 0;
}

Measured memory_bytes: 7776
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 1000000;
const ll INF = (1LL << 31) - 1;
const double pi=acos(-1);

int main(){
  int n;
  cin >> n;
  vector<int>vec(n);
  int even[100010]={};
  int odd[100010]={};
  rep(i,n){
    cin >> vec[i];
    if(i%2==0)even[vec[i]-1]++;
    else odd[vec[i]-1]++;
  }
  vector<pair<int,int>>ev;
  vector<pair<int,int>>od;
  rep(i,100010){
    if(even[i])ev.push_back(make_pair(even[i],i+1));
    if(odd[i])od.push_back(make_pair(odd[i],i+1));
  }
  
  sort(ev.begin(),ev.end(),greater<pair<int,int>>());
  sort(od.begin(),od.end(),greater<pair<int,int>>());
  if(ev[0].second==od[0].second){
    cout << min(n-od[0].first-ev[1].first,n-od[1].first-ev[0].first) << endl;
  }
  else{
    cout << n-od[0].first-ev[0].first << endl;
  }
  return 0;
  
    
}


Measured memory_bytes: 2428
# -*- coding: utf-8 -*-
#D - Static Sushi 
import sys 
from math import sqrt
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())

M = 55555
p = [1]*(M+1)
p[0] = p[1] = 0
### エラストネスのふるい
for x in range(2, int(sqrt(M))+1):
    if p[x]:
        for y in range(x*x, M+1, x):
            p[y] = 0

## Mまでの5a+1を満たす素数の集合P
P = []
cnt = 0
for i in range(1,M+1):
    if p[i] and (i-1) % 5 == 0:
        P.append(i)

print(*P[:N])

Measured memory_bytes: 9320
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		sc.close();

		int n9 = n / 100000000;
		int n8 = n / 10000000;
		int n7 = n % 10000000 / 1000000;
		int n6 = n % 1000000 / 100000;
		int n5 = n % 100000 / 10000;
		int n4 = n % 10000 / 1000;
		int n3 = n % 1000 / 100;
		int n2 = n % 100 / 10;
		int n1 = n % 10;
		int f = n9 + n8 + n7 + n6 + n5 + n4 + n3 + n2 + n1;

		System.out.println(n % f == 0 ? "Yes" : "No");
	}
}

Measured memory_bytes: 23124
#include<stdio.h>

int main( void ) 
{
	char s[101],p[101];
	int i,j,k,end;
		
	scanf( "%s", s );
	scanf( "%s", p );
	

	i=end=0;
	while( 1 ) {
		if( p[0] == s[i] ) {
			j=0;
			k=i;	
			while( p[j] == s[k] ) {
				j++;
				k++;
			 	if( '\0' == s[k] ) {
					k=0;
				}				
			 }
		 	if( '\0' == p[j] ) {
				printf( "Yes\n" );
				break;
			}			 
		} else {
			if( end ) { 
				printf( "No\n" );	
				break;
			}

			if( '\0' == s[i] ) {
				i=0;	
				end=1;
			} else {		
				j=0;
			}
		}
		i++;
	}

	return 0;
}

Measured memory_bytes: 524
main = do
  s <- getContents
  let v = map (map read . words) . lines $ s
  let w = map solve v
  let x = map (\x-> if x then "YES" else "NO") $ w
  mapM_ putStrLn x

solve::[Double] -> Bool
solve [xa,ya,xb,yb,xc,yc,xd,yd] =
  abs(dot u v) < eps
  where u = (xb-xa, yb-ya)
        v = (xd-xc, yd-yc)
        dot (a,b) (c,d) = a*c + b*d
        eps = 1e-10

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

using namespace std;
using namespace __gnu_pbds;

#define ll          long long
#define fio         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define vi          vector<ll>
#define pp          push_pop
#define pll         pair<ll,ll>
#define in          insert
#define ini(a,n)    memset(a,n,sizeof(a))
#define ff          first
#define ss          second
#define inf         10000000000000000
#define all(p)      p.begin(), p.end()
#define que_max     priority_queue <int>
#define que_min     priority_queue <int, vi, greater<int>>
#define print(a)    for(auto i:a){cout<<i<<" ";}
#define print1(a)   for(auto i:a){cout<<i.ff<<" "<<i.ss<<endl;}

typedef tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update> Set;
unordered_map<ll,vi> g;
unordered_map<ll,ll> vis;

const ll mod = 1e9+7;

ll power(ll x,ll y,ll p){ll r=1;x=x%p;while(y>0){if(y&1)r=(r*x)%p;y=y>>1;x=(x*x)%p;}return r;}
const ll N = 2e5+10;
ll dx[4]={-1, +1, 0, 0};
ll dy[4]={0, 0, +1, -1};
bool imp = false;
bool isPowerOfTwo (ll x)
{
    return x && (!(x&(x-1)));
}


void solve() {

    ll n;cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
        cin>>a[i];

    ll b[3];
    ini(b,0);
    ll ans = 1;
    for(ll i=0;i<n;i++){
        ll c=0;
        for(ll j=0;j<3;j++){
            if(a[i]==b[j]){
                if(c==0)
                    b[j] += 1;
                c += 1;
            }
        }
        ans = (ans * c)% mod;
    }
    cout<<ans<<endl;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif

    fio
    int t=1;
    if(imp) cin>>t;

    while(t--)
    {
        // cout<<"Case #"<<tc<<": ";
        g.clear();
        vis.clear();
        solve();
        // tc++;
    }

}


Measured memory_bytes: 4428
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int a,b,c,d; cin>>a>>b>>c>>d;
  int taka = c/b;
  int aoki = a/d;
  if (c%b==0) taka--;
  if (a%d==0) aoki--;
  bool ok = taka<=aoki;
  ok();
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define dmax(x, y) x = max(x, y);
#define N 110
#define M 10000001
int n, m, addx, addy, ans;
int a[N][N], b[N][N], f[M];
char c[N];
inline int pos(int i, int j, int k, int l) {
    return ((i * (n - addx + 1) + j) * addy + k) * (m - addy + 1) + l + 1;
}
int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) {
        scanf("%s", c + 1);
        for (int j = 1; j <= m; j++) {
            a[i][j] = a[i][j - 1] + (c[j] == 'o');
            b[i][j] = b[i - 1][j] + (c[j] == 'o');
            if (c[j] == 'E') addx = i, addy = j;
        }
    }
    for (int i = 0; i < addx; i++)
        for (int j = 0; j <= n - addx; j++)
            for (int k = 0; k < addy; k++)
                for (int l = 0; l <= m - addy; l++) {
                    int s = f[pos(i, j, k, l)];
                    ans = max(ans, s);
                    if (addx - i - 1 > j)
                        dmax(f[pos(i + 1, j, k, l)],
                             s + a[addx - i - 1][min(addy + l, m - k)] -
                                 a[addx - i - 1][max(addy - k, l + 1) - 1]);
                    if (addx + j + 1 <= n - i)
                        dmax(f[pos(i, j + 1, k, l)],
                             s + a[addx + j + 1][min(addy + l, m - k)] -
                                 a[addx + j + 1][max(addy - k, l + 1) - 1]);
                    if (addy - k - 1 > l)
                        dmax(f[pos(i, j, k + 1, l)],
                             s + b[min(addx + j, n - i)][addy - k - 1] -
                                 b[max(addx - i - 1, j)][addy - k - 1]);
                    if (addy + l + 1 <= m - k)
                        dmax(f[pos(i, j, k, l + 1)],
                             s + b[min(addx + j, n - i)][addy + l + 1] -
                                 b[max(addx - i - 1, j)][addy + l + 1]);
                }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 27008
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C){
  ll ans = 0;
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());
  for(ll i=0; i<N; i++) {
    ans += (lower_bound(A.begin(), A.end(), B[i])-A.begin()) *
      (C.end()-upper_bound(C.begin(), C.end(), B[i]));
  }
  std::cout << ans << std::endl;
}

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]);
  }
  std::vector<long long> B(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&B[i]);
  }
  std::vector<long long> C(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&C[i]);
  }
  solve(N, std::move(A), std::move(B), std::move(C));
  return 0;
}



Measured memory_bytes: 2560
import numpy as np

N = int(input())
V = input().split()
V = np.array(V).astype(int)
V = np.sort(V)

U = np.array([])

for _ in range(2):
    U = np.append(U, 0.5**(N-1))
    
for i in range(2, N):
    U = np.append(U, 0.5**(N-i))

print(np.dot(U, V))

Measured memory_bytes: 14312
#include <bits/stdc++.h>
#define pb push_back
#define pi pair<int, int>
#define l first
#define r second
#define all(x) x.begin(), x.end()
#define fori(a, b, step) for (int i = a; i < b; i += step)
#define forj(a, b, step) for (int j = a; j < b; j += step)

const int maxn = 5e5 + 1, mod = 1e9 + 7;

using namespace std;

bool v[1000][1000];
int d[1000][1000];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, m; cin >> n >> m;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            char ch; cin >> ch;
            v[i][j] = (ch == '#');
        }
    }
    queue<pi> q;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) {
            d[i][j] = v[i][j];
            if (d[i][j]) q.push({i, j});
        }
    int ans = 0;
    while (!q.empty()) {
        int x = q.front().l;
        int y = q.front().r;
        q.pop();
        if (x && !d[x - 1][y]) {
            d[x - 1][y] = d[x][y] + 1;
            q.push({x - 1, y});
        }
        if (x < n - 1 && !d[x + 1][y]) {
            d[x + 1][y] = d[x][y] + 1;
            q.push({x + 1, y});
        }
        if (y && !d[x][y - 1]) {
            d[x][y - 1] = d[x][y] + 1;
            q.push({x, y - 1});
        }
        if (y < m - 1 && !d[x][y + 1]) {
            d[x][y + 1] = d[x][y] + 1;
            q.push({x, y + 1});
        }
        ans = max(ans, d[x][y]);
    }
    cout << ans - 1;
    return 0;
}


Measured memory_bytes: 16104
w,h,n = map(int, raw_input().split())
mat = [[False for _ in range(w)] for _ in range(h)]
for _ in range(n):
    x,y,a = map(int, raw_input().split())
    if a == 1:
        for i in range(h):
            for j in range(x):
                mat[i][j] = True
    elif a == 2:
        for i in range(h):
            for j in range(x,w):
                mat[i][j] = True
    elif a == 3:
        for i in range(y):
            for j in range(w):
                mat[i][j] = True
    elif a == 4:
        for i in range(y,h):
            for j in range(w):
                mat[i][j] = True
print sum([i.count(False) for i in mat])


Measured memory_bytes: 2692
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner s=new Scanner(System.in);
        int n=s.nextInt();
        int q=s.nextInt();
        String name[]=new String[n+1];
        int time[]=new int[n+1];
        for(int i=0;i<n;i++){
            name[i]=s.next();
            time[i]=s.nextInt();
        }
        int total=0,cnt=n,now=0,next=0;
        while(cnt!=0){
            if(time[now]>0){
                time[now]-=q;
                if(time[now]<=0){
                    cnt--;
                    total+=time[now]+q;
                    System.out.println(name[now]+" "+total);
                }else{
                    total+=q;
                    next=now+cnt;
                    if(next>n) next-=(n+1);
                    name[next]=name[now];
                    time[next]=time[now];
                }
                time[now]=0;
            }
            now++;
            if(now>n) now-=(n+1);
        }
    }
}


Measured memory_bytes: 74032
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k, c;
  cin >> n >> k >> c;
  string s; cin >> s;
  vector<int> vl(n), vr(n);
  {
    int i = 0;
    int cnt = 1;
    while(i < n && cnt <= k) {
      if(s[i] == 'o') {
        vl[i] = cnt;
        cnt++;
        i += c+1;
      } else {
        i++;
      }
    }
  }
  {
    int i = n-1;
    int cnt = k;
    while(i >= 0 && cnt > 0) {
      if(s[i] == 'o') {
        vr[i] = cnt;
        cnt--;
        i -= c+1;
      } else {
        i--;
      }
    }
  }
  rep(i, n) {
    if(s[i] == 'o' && vl[i] != 0 && vr[i] != 0 && vl[i] == vr[i]) cout << i+1 << endk;
  }
  return 0;
}


Measured memory_bytes: 5192
dx,dy,x,y = gets.split.map(&:to_i)
nx = gets.split.map(&:to_i).push(x).sort!
ny = gets.split.map(&:to_i).push(y).sort!
if ny[0] > nx[nx.length-1]
      puts "No War"
 else
      puts "War"
end

Measured memory_bytes: 1788
n,k=map(int,input().split())
s=input()
count=0

for i in range(n-1):
  if s[i]!=s[i+1]:
    count+=1
    
ans=n-count-1

for i in range(k):
  if ans<n-2:
    ans+=2
  elif ans==n-2:
    ans+=1
  

print(ans)
    

Measured memory_bytes: 39536
n = int(input())
a = list(map(int, input().split()))
 
r_even = 0  # 偶数桁を＋にする場合の値
a_even = a[:]
sum_even = 0
for i in range(len(a)):
    sum_even += a_even[i]
    if i % 2 == 0:
        if sum_even <= 0:
            r_even += 1 - sum_even
            a_even[i] += 1 - sum_even
            sum_even += 1 - sum_even
    else:
        if sum_even >= 0:
            r_even += sum_even + 1
            a_even[i] -= sum_even + 1
            sum_even -= sum_even + 1

r_odd = 0   #奇数桁を＋にする場合の値
a_odd = a[:]
sum_odd = 0
for i in range(len(a)):
    sum_odd += a_odd[i]
    if i % 2 != 0:
        if sum_odd <= 0:
            r_odd += 1 - sum_odd
            a_odd[i] += 1 - sum_odd
            sum_odd += 1 - sum_odd
    else:
         if sum_odd >= 0:
            r_odd += sum_odd + 1
            a_odd[i] -= sum_odd + 1
            sum_odd -= sum_odd + 1

print(min(r_odd, r_even))


Measured memory_bytes: 14464
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

R, G, B, N = s_inpl()

ans = 0

for r in range(N+1):
    for g in range(N+1-R*r):
        b = (N - r*R - g*G)//B
        if N == r*R + g*G + b*B and r>=0 and g>=0 and b >= 0:
            ans += 1

print(ans)

Measured memory_bytes: 41196
from sys import stdin
import math
import itertools


def makeIntMatrix(lines):
    intMatrix = []
    for a in makeStringMatrix(lines):
        intMatrix.append([int(b) for b in a])
    return intMatrix
 
 
def makeStringMatrix(lines):
    stringMatrix = [line.split() for line in lines]
    return stringMatrix
 
 
def makeInt(line):
    return int(line.rstrip())
 
 
def makeMultiInteger(line):
    return [int(x) for x in line.rstrip().split()]


def solve(input_string):
    r, d, x = makeMultiInteger(input_string[0])
    x1 = x
    for _ in range(10):
        x1 = r*x1 - d
        print(x1)
    return 


def main():
    input_lines = stdin.readlines()
    answer = solve(input_lines)
    #print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  int N, T; std::cin >> N >> T;
  std::vector<std::pair<int,int>> ab;
  std::vector<int> zb;
  for(int i = 0; i < N; ++i) {
    int a, b; std::cin >> a >> b;
    if(a == 0) zb.push_back(b); else ab.emplace_back(a, b);
  }
  std::sort(ab.begin(), ab.end(),
    [](auto const&l, auto const& r) {
      return (int64_t)l.first*(r.second+1) > (int64_t)r.first*(l.second+1); });
  std::sort(zb.begin(), zb.end());
  int maxP = 0;
  while(maxP < N && (1<<maxP) < T) ++maxP;
  std::vector<int> dp(maxP+1, T+100);
  dp[0] = 0;
  for(auto const& p: ab) {
    for(int i = maxP-1; i >= 0; --i) if(dp[i]<T) {
      int64_t t = (int64_t)(p.first+1)*(dp[i]+1) + p.second;
      if(t < dp[i+1]) dp[i+1] = t;
    }
  }
  int ans = 0;
  for(int i = 0; i <= maxP; ++i) {
    int t = dp[i];
    if(t > T) continue;
    int cur = i;
    for(int b: zb) {
      if(t + b+1 > T) break;
      t += b+1; ++cur;
    }
    ans = std::max(ans, cur);
  }
  fin(ans);
  return 0;
}


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_bacm
#define mp mame_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << ' ' << x << ' ' << y << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
vector<int> e[maxn];
int f[maxn];
int solve(int x){
  if(f[x] != -1) return f[x];
  int ans = 0;
  for(int v : e[x]) ans = max(ans, 1 + solve(v));
  return f[x] = ans;
}
int main(){
  int n, m; cin >> n >> m;
  for(int i = 0; i < m; i++) {
    int x, y; cin >> x >> y;
    e[x].push_back(y);
  }
  int ans = 0;
  memset(f, -1, sizeof(f));
  for(int i = 1; i <= n; i++) ans = max(ans, solve(i));
  cout << ans << endl;
  return 0;
}


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

int N;
vector<long> A, B;
int main() {
  cin >> N;
  A = vector<long>(N);
  B = vector<long>(N);
  long ret = 0;
  for(int i = 0; i < N; i++) cin >> A[i] >> B[i];
  for(int i = N - 1; i >= 0; i--) {
    long tmp = (B[i] - (A[i] + ret)) % B[i];
    if(tmp < 0) tmp += B[i];
    ret += tmp;
  }
  cout << ret << endl;
}

Measured memory_bytes: 1792
N, M, Q = map(int, input().split())
student = []
for i in range(N) :
    student.append(i)
x = 0
a = list(map(int, input().split()))
q = list(map(int, input().split()))

for i in range(M) :
    if a[i] % 2 == 0 : ## 偶数
        x = (x + a[i]) % len(student)
    else : ## 奇数
        x = x - a[i]
        if x < 0 :
            while x < 0 :
                x += len(student)
    del student[x]
    if x == len(student) :
        x = 0
for i in range(Q) :
    if q[i] in student :
        print(1)
    else :
        print(0)
        


Measured memory_bytes: 28988
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  string op;
  int ans=0;
  cin >> N >> op >> M;
  if (op=="+"){
    ans = N+M;
  }else{
    ans = N-M;
  }
  
  cout << ans << endl;
  return 0;
}

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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

//昇順
int asc(const void* a, const void* b){
    return *(int*)a-*(int*)b;
}

//降順
int desc(const void* a, const void* b){
    return *(int*)b-*(int*)a;
}

int main(void){
    int N,K;
    scanf("%d%d",&N,&K);

    //A[0]~A[N-1]に格納する
    int* x;
    NEW(x,N);
    for(int i=0;i<N;i++){
        scanf("%d",&x[i]);
    }

    int ans=MIN(abs(x[0])+abs(x[K-1]-x[0]), abs(x[K-1])+abs(x[K-1]-x[0]));
    for(int i=1;i<N+1-K;i++){
        int tmp=MIN(abs(x[i])+abs(x[K+i-1]-x[i]), abs(x[K+i-1])+abs(x[K+i-1]-x[i]));
        ans=MIN(ans,tmp);
    }
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 512
from sys import stdin
import math
input=input=stdin.readline().rstrip().split()
for i in range(len(input)):
  input[i]=int(input[i])

output=0
R=input[0]
G=input[1]
B=input[2]
N=input[3]
for r in range(math.floor(N/R)+1):
    for g in range(math.floor(N/G)+1):
        #for b in range(math.floor(N/B)+1):
        #print(r,g)
        #if r*R+g*G+b*B==N:
        b=N-(r*R+g*G)
        #b/B
        #if b>=0:
        if b<0:
            break
        if b % B == 0:
            #print(r,g)
            output+=1
print(output)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
stack<int>st;
queue<int>q;
vector<int>v,v1,v2,v3;
set<int>stt;
set<int>::iterator set_it;
map<string,int>mp;
//initialy map er all index er value zero thake;
//map er jonno this pointer(->) use korte hoy
//akta value dakhar jonno staristics pointer(*) use  korte hoy
// one more value print korar jonno this pointer(->) use korte hoy (must be)
map<string,int>::iterator map_it;
int a[20007];
int i,j,k,l,m,n,cnt=0,sum=0,mx=0,mn=0;
string s,s1,s2;
int main()
{
    cin>>s;
    int flag=0;
    for(i=0; i<s.size(); i++)
    {
        //cout<<s[i]<<endl;
        if(s[i]=='7')
        {
            cout<<"Yes"<<endl;
            return 0;

        }

    }

        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3640
import sys
n,y=map(int,input().split())
for i in range(n+1):
    for j in range(n-i+1):
        if(i*10000+j*5000+(n-i-j)*1000==y):
            print(i,j,n-i-j)
            sys.exit(0)

print("-1 -1 -1")

Measured memory_bytes: 40684
// 入力関数
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u64) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let init: Vec<u64> = read_vec();
    let n = init[0];
    let m = init[1];
    let mut price: Vec<Vec<u64>> = read_vec2(n);

    price.sort_by_key(|i| i[0]);

    let mut remain = m;
    let mut money: u64 = 0;

    for i in 0..n {
        let index = i as usize;
        if remain >= price[index][1] {
            money = money + price[index][0] * price[index][1];
            remain = remain - price[index][1];
        } else {
            money = money + price[index][0] * remain;
            break;
        }
    }

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


Measured memory_bytes: 10492
#include<bits/stdc++.h>
#define INF (1e9)
#define N 155
#define S 85
#define M 15
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> P1;
 
struct Node{
  int X,cost;
  Node(){};
  Node(int a,int c){X=a,cost=c;};
};
 
struct Edge{
  int y,x,cost,flag;
  Edge(){};
  Edge(int a,int b,int c,int d){
    y=a,x=b,cost=c,flag=d;
  };
};
 
int n,m,k,a,b;
vector<Node> node[N];
vector<Edge> e[N][M];
int d[S][N][M];

int dijkstra(int sy,int sx,int sm){
  priority_queue<P1,vector<P1>,greater<P1> > q;
  for(int i=0;i<S;i++)
    for(int j=0;j<N;j++)
      for(int l=0;l<M;l++)d[i][j][l]=INF;
  d[sm][sy][sx]=0;
  if(sm<=m)q.push(P1(P(0,sm),P(sy,sx)));
  while(!q.empty()){
    P1 t=q.top(); q.pop();
    int cost=t.first.first;
    int mcnt=t.first.second;
    int y=t.second.first;
    int x=t.second.second;
    if(d[mcnt][y][x]<cost)continue;
    if(n-1<=y||(n-2<=y&&mcnt<m))return cost;
    for(int i=0;i<e[y][x].size();i++){
      int ny=e[y][x][i].y,nx=e[y][x][i].x;
      int ncost=cost+e[y][x][i].cost,f=e[y][x][i].flag;
      if(f+mcnt>m)continue;
      if(d[f+mcnt][ny][nx]>ncost){
	d[f+mcnt][ny][nx]=ncost;
	q.push(P1(P(ncost,f+mcnt),P(ny,nx)));
      }
    }
  }
  return INF;
}

int main(){
  while(1){
    cin>>n>>m;
    if(!n&&!m)break;
    for(int i=0;i<n;i++){
      cin>>k;
      for(int j=0;j<k;j++){
	cin>>a>>b;
	node[i].push_back(Node(a,b));
      }
    }
    for(int i=0;i<n;i++)
      for(int j=i+1;j<=i+2&&j<n;j++)
	for(int l=0;l<node[i].size();l++)
	  for(int p=0;p<node[j].size();p++)
	    e[i][l].push_back(Edge(j,p,(node[i][l].cost+node[j][p].cost)*abs(node[i][l].X-node[j][p].X),j-i-1));
    int ans=INF;
    for(int i=0;i<node[0].size();i++) ans=min(ans,dijkstra(0,i,0));
    for(int i=0;i<node[1].size();i++) ans=min(ans,dijkstra(1,i,1));
    cout<<ans<<endl;
    for(int i=0;i<N;i++)node[i].clear();
    for(int i=0;i<N;i++)
      for(int j=0;j<M;j++)e[i][j].clear();
  }
  return 0;
}

Measured memory_bytes: 6116
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define INF 10000000
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
    int H,W;
    cin>>H>>W;
    int c[10][10];
    int A[H][W];
    rep(i,10) rep(j,10) cin>>c[i][j];
    rep(i,H) rep(j,W) cin>>A[i][j];
    rep(k,10){
        rep(i,10){
            rep(j,10){
                c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
            }
        }
    }
    ll ans=0;
    rep(i,H){
        rep(j,W){
            if(A[i][j]==-1) continue;
            ans+=c[A[i][j]][1];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

//int n, m;
//vector<P> vp;
//
//int main() {
//	cin >> n >> m;
//	rep(i, m) {
//
//	}
//}

int n, m;
vector<P> vp;
int sum[100100];

int main() {
	cin >> n >> m;
	vp.resize(m);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		sum[a]++;
		sum[b]--;
	}
	rep(i, n + 2)sum[i + 1] += sum[i];
	ll ans = 0;
	rep(i, n + 1) {
		if (sum[i] > 0)ans += 3;
		else ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3144
K = int(input())
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[K-1])

Measured memory_bytes: 61860
#include<bits/stdc++.h>
using namespace std;
int main(){
   int n,q,i,t,x;
   cin>>n>>q;
   queue<int>a[n];
   while(q){
   	q--;
   	cin>>i;
   	if(i==0){
   		cin>>t>>x;
   		a[t].push(x);
	   }
	if(i==1){
		cin>>t;
		 if(a[t].size()!=0)
		cout<<a[t].front()<<endl;
   }
   if(i==2){
   	cin>>t;
   	if(a[t].size()!=0)
   	a[t].pop();
   }
}
}



Measured memory_bytes: 4292
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int isPos(vector<double> A, double L, int k) {
	int n = A.size(), count = 0;
	for(int i=0;i<n;i++) {
		if(A[i]<=L) continue;
		count+=(A[i]-1)/L;
	}
	if(count<=k) return 0;
	else return 1;
}
int main() {
	int n,k;
	cin>>n>>k;
	vector<double> A(n);
	double L = 0, R = 1e9, maxi = INT_MIN;
	for(double &i:A) {
		cin>>i;
		//R = max(R,i);
		maxi = max(maxi,i);
	}
	if(k==0) {
		cout<<(int)maxi;
		return 0;
	}
	double prospect = 0;
	while(L<=R) {
		double mid = L + (R-L)/2;
		debug()<<imie(mid);
		int check = isPos(A,mid,k);
		if(check==0) {
			prospect = mid;
			R = mid-0.01;
		} else {
			L = mid+0.01;
		}
	}
	debug()<<imie(prospect);
	cout<<(int) ceil(prospect);
}



Measured memory_bytes: 6496
#include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;


int main(){
	long int n, k, i,j,c;
	double z=0;
	cin >> n >> k;
	

	for (i = 1; i <= n; i++) {
		c = 1;
		j = i;
		while (j < k) {
			j = 2*j;
			c = c * 2;
		}
		z =z+ (1 / double(n*c));
	
	}
	
	
	
	
	
	
	
	cout <<setprecision(12) << z;

	return 0;
	}



Measured memory_bytes: 256
#include "stdio.h"

int main(void){
	long long L[87];
	int N;
	int i;

	L[0] = 2;
	L[1] = 1;

	scanf("%d", &N);

	for(i=2;i<N+1;i++)
	{
		L[i] = L[i-1] + L[i-2];
	}

//	printf("%d__%d\n", L[i-1]/1000000000, L[i-1]-((L[i-1]/1000000000)*1000000000));
	if(L[i-1]/1000000000 !=0) printf("%d", L[i-1]/1000000000);
	printf("%d\n", L[i-1]-((L[i-1]/1000000000)*1000000000));
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int GCD(int a, int b)
{
    if (b == 0) return a;
    return GCD(b, a % b);
}

int main(void)
{
    int n;
    int array[3];
    int mini = 1000000000;
    int i, j;
    int gcd;
    
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%d", array + i);
        if (mini > array[i]) mini = array[i];
    }
    for (i = 1; i <= mini; i++){
        for (j = 0; j < n; j++){
            if (array[j] % i != 0) break;
        }
        if (j == n) printf("%d\n", i);
    }
    
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <limits>


using namespace std;
using ll = long long;
using ld = long double;

int main() {

    int N;
    cin >> N;
    ld result = 0;

    vector<ld> v;

    for (int i = 0; i < N; ++i) {
        string x;
        string u;

        ll xl;
        ld xd;
        cin >> x >> u;
        if(u == "JPY"){
            xl = stoi(x);
            v.push_back((ld) xl);
        }else{
            xd = stold(x);
            xd *= 380000;
            v.push_back((ld) xd);
        }

    }

    sort(v.begin(),v.end(),greater<ld>());
    for (int i = 0; i < v.size(); ++i) {
        result += v[i];
    }


    std::cout<<std::fixed<<std::setprecision(10) << result << endl;
    return 0;
}

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


int main(){
    ll n,m;cin>>n>>m;
    map<ll,ll> mp;
    rep(i,0,2*m){
        ll a;
        cin>>a;
        mp[a]++;
    }
    for(auto i:mp){
        if(i.second%2==1){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}







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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin >> N;

	int primem[110] = { 0 };

	rep(k, 0, N + 1)
	{
		int t = k;
		for (int i = 2; i <= (int)sqrt(k); i += (i == 2 ? 1 : 2))
		{
			while (t%i == 0)
			{
				primem[i]++;
				t /= i;
			}
		}
		if (t != 1)
		{
			primem[t]++;
		}
	}

	vector<pair<int,int>> fac;
	fac.push_back(mp(1, 1));
	rep(i, 2, 110)
	{
		if (primem[i] > 0)
		{
			fac.push_back(mp(i, primem[i]));
		}
	}

	int ans = 0;
	rep(i, 0, SZ(fac))rep(j, i + 1, SZ(fac))rep(k, j + 1, SZ(fac))
	{
		if (4 <= fac[i].second && 4 <= fac[j].second && 2 <= fac[k].second)
		{
			ans++;
		}
		if (2 <= fac[i].second && 4 <= fac[j].second && 4 <= fac[k].second)
		{
			ans++;
		}
		if (4 <= fac[i].second && 2 <= fac[j].second && 4 <= fac[k].second)
		{
			ans++;
		}
	}

	rep(i, 0, SZ(fac))rep(j, i + 1, SZ(fac))
	{
		if (2 <= fac[i].second && 24 <= fac[j].second)
		{
			ans++;
		}
		if (24 <= fac[i].second && 2 <= fac[j].second)
		{
			ans++;
		}
		if (14 <= fac[i].second && 4 <= fac[j].second)
		{
			ans++;
		}
		if (4 <= fac[i].second && 14 <= fac[j].second)
		{
			ans++;
		}
	}

	rep(i, 0, SZ(fac))
	{
		if (74 <= fac[i].second)
		{
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n=int(input())

s=[[] for _ in range(n)]
for i in range(n):
  a=int(input())
  for j in range(a):
    s[i].append(list(map(int,input().split())))

max_=0
one_hot=[[] for _ in range(n)]
for i in range(2**n):
  temp=i
  count=0
  for j in range(n):
    one_hot[j]=temp%2
    temp//=2
    if one_hot[j]==1:
      count+=1
  flg=True
  for j in range(n):
    for k in range(len(s[j])):
      if one_hot[j]==1:
        if one_hot[s[j][k][0]-1]!=s[j][k][1]:
          flg=False
          break
      if not flg:
        break
  if flg and max_<count:
    max_=count
  count=0
print(max_)
    

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>

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

using namespace std;
using ll = long long;
using P = pair<int,int>;

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

    if (s == "ABC")
    {
        cout << "ARC" << endl;
    } else
    {
        cout << "ABC" << endl;
    }
    
    

    return 0;
}

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


int binarySearch(int);

int n,S[100001],q,T[50001];

int main(){
  int i,j,count=0,bs;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
    if(S[i]<0 || S[i]>1000000000){
      exit(1);
    }
  }

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
    if(T[i]<0 || T[i]>1000000000){
      exit(8);
    }
  }

  for(i=0;i<q;i++){
    bs=binarySearch(i);
    if(bs==1){
      count++;
    }
  }

  printf("%d\n",count);

  return 0;
}

//Binarysearch
int binarySearch(int i){
  int left,right,mid=0;

  left=0;
  right=n;

  while(left<right){
    mid=(left+right)/2;
    if(S[mid]==T[i]){
      return 1; //Found
    }else if(T[i]<S[mid]){
      right=mid;
    }else{
      left=mid+1;
    }
  }

  return 0; //Not found
}

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

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

const ll INF = LONG_LONG_MAX / 2;

vector<vector<ll>> dp;
vector<ll> A;
vector<ll> B;

ll solve(int i, int j, const int H, const int N) {
    if (dp[i][j] >= 0) {
        return dp[i][j];
    }

    ll ans = solve(i - 1, j, H, N);
    chmin(ans, solve(i, max(0LL, j - A[i]), H, N) + B[i]);
    dp[i][j] = ans;
    return ans;
}

int main(void) {
    int H, N;
    cin >> H >> N;

    A.resize(N + 1);
    B.resize(N + 1);
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        A[i + 1] = a;
        B[i + 1] = b;
    }

    dp.resize(N + 1, vector<ll>(H + 1, -1));
    for (int i = 0; i <= H; i++) {
        dp[0][i] = INF;
    }
    for (int i = 0; i <= N; i++) {
        dp[i][0] = 0;
    }

    solve(N, H, H, N);

    cout << dp[N][H] << endl;
    
    return 0;
}


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

int main()
{
    int n;
    string s;
    cin >> n >> s;
    string t;
    for( int i = 0; i < s.size(); i++ ){
        int x = s[i]-'A';
        x = (x+n) % 26;
        t.push_back( char(x+'A') );
    }
    cout << t << endl;

    return 0;
}



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

nums = [0] * N

for i in range(K):
    d = int(input())
    As = list(map(int, input().split()))
    for a in As:
        nums[a-1] += 1

ans = 0
for num in nums:
    if num == 0:
        ans += 1
print(ans)

Measured memory_bytes: 9188
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>

using namespace std;
/*
int find(int x, vector<int> &p) {
if (p[x] == x)return x;
return p[x] = find(p[x], p);
}

void uni(int x, int y, vector<int> &p) {
x = find(x, p);
y = find(y, p);
p[x] = y;
}

int same(int x, int y, vector<int> p) {
if (find(x, p) == find(y, p))return 1;
return 0;
}
*/

int main()
{
	int D, N, ans = 0;

	cin >> D >> N;
	if (D == 0 && N == 100) {
		ans = 101;
	}
	else if (D == 0) {
		ans = N;
	}
	else if (D == 1&&N == 100) {
		ans = 10100;
	}
	else if (D == 1) {
		ans = 100 * N;
	}
	else if (D == 2 && N == 100) {
		ans = 1010000;
	}
	else {
		ans = 10000 * N;
	}

	cout << ans;

	char qq;
	cin >> qq;
	return 0;
}

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

 
int main() {
	ll n,d;
	cin>>n>>d;
	ll arr[n];
	ll ans=0;
	for(int i=0;i<n;i++)
	{
		ll x,y;
		cin>>x>>y;
		ll val=(x*x)+(y*y);
		if(sqrt(val)<=d)
		{
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3676