akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
int main() {
    ll h, w;
    cin >> h >> w;
    
    vector<string> board(h);
    rep(i, h) {
        cin >> board[i];
    }

    rep(x, h) {
        rep(y, w) {
            if(board[x][y] == '#') {
                continue;
            }
            ll cnt = 0;
            rep(dir, 8) {
                ll nx = x + dx[dir];
                ll ny = y + dy[dir];
                if(nx < 0 || h <= nx || ny < 0 || w <= ny) {
                    continue;
                }
                if(board[nx][ny] == '#') {
                    cnt++;
                }
            }
            board[x][y] = cnt + '0';
        }
    }

    rep(i, h) {
        rep(j, w) {
            cout << board[i][j];
        }
        cout << "\n";
    }
    
    re0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int main() {
  int N,K,R,S,P;
  string t;
  cin >> N >> K >> R >> S >> P;
  cin >> t;
  
  map<char, int> mp;
  
  mp['r'] = count(t.cbegin(), t.cend(), 'r'); // P
  mp['s'] = count(t.cbegin(), t.cend(), 's'); // R
  mp['p'] = count(t.cbegin(), t.cend(), 'p'); // S
  for (int i = 0; i < K; ++i) {
    for (int j = 1; i+j*K < N; ++j) {
      if(t[i+(j-1)*K] == t[i+j*K]) {
        --mp[t[i+j*K]];
        ++j;
      }
    }
  }
  
  long point = mp['r'] * P + mp['s'] * R + mp['p'] * S;
  
  cout << point << endl;
  return 0;
}

Measured memory_bytes: 512
/*
[abc166] D - I hate Factorization
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const ll INF = 1e9;

int X;

void solve() {
    for (ll a = -120; a <= 120; a++) {
        for (ll b = -120; b <= 120; b++) {
            if (a * a * a * a * a - b * b * b * b * b == X) {
                cout << a << " " << b << endl;
                return;
            }
        }
    }
}

int main() {
    cin >> X;

    solve();

    return 0;
}


Measured memory_bytes: 3616
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int r = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '1') {
                r++;
            }
        }
      	System.out.println(r);
		// System.out.println(Arrays.stream(s).filter("1"::equals).count());
	}
}

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

int main()
{
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int AtoB, AB, ZAB;
	AtoB = a * x + b * y;
	AB = 2 * min(x, y) * c + (x >= y?a*(x-y):b*(y-x));
	ZAB = 2 * max(x, y) * c;
	cout << min(AtoB, min(AB, ZAB)) << endl;
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
constexpr ll MOD = 1000000007;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
void yes(bool f){cout<<(f?"yes":"no")<<endl;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

#define ANS(a) cout<<a<<endl

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    ll N, ans = 1;
    cin >>N;
    for (ll i = 1; i <= N; i++)
        ans = (ans * i) % MOD;
    cout << ans << endl;
}


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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int x[8];
int y[8];

double dist(int i, int j)
{
	return sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n;cin >> n;
	FOR(i, 0, n) cin >> x[i] >> y[i];
	
	double ans = 0;
	int cnt = 0;
	VI a(n);
	iota(ALL(a), 0);
	do
	{
		cnt++;
		FOR(i, 0, n - 1) ans += dist(a[i], a[i + 1]);
	}while(next_permutation(ALL(a)));
	
	cout << fixed << setprecision(10) << ans / cnt;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 256
S = input()
T = input()

ds = dict()
dt = dict()
for i in range(len(S)):
    s, t = S[i], T[i]
    if s in ds:
        if ds[s] != t:
            print('No')
            exit()
    else:
        ds[s] = t

    if t in dt:
        if dt[t] != s:
            print('No')
            exit()
    else:
        dt[t] = s

print('Yes')

Measured memory_bytes: 3632
N, M = map(int, input().split())
a = []
b = []
for i in range(M):
    a1 , b1 = [int(i) for i in input().split()]
    a.append(a1)
    b.append(b1)

nm = a+b

ans = [0 for i in range(N)]
for j in range(0,(len(nm))):
    i = nm[j]
    ans[i-1] += 1

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


Measured memory_bytes: 3064
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string s, t;
	int sSize, tSize, flg = 0, matchingNum = -1;
	cin >> s >> t;
	sSize = s.size();
	tSize = t.size();

	for (int i = 0; i <= (sSize - tSize); i++)
	{
		for (int j = 0; j < tSize; j++)
		{
			if (s[i + j] != t[j] && s[i + j] != '?')
			{
				flg = 1;
				break;
			}
		}
		if (flg == 0)
		{
			matchingNum = i;
		}
		else
		{
			flg = 0;
		}
	}
	if (matchingNum == -1)
	{
		cout << "UNRESTORABLE" << endl;
	}
	else
	{
		for (int i = 0; i < tSize; i++)
		{
			s[matchingNum + i] = t[i];
		}
		for (int j = 0; j < sSize; j++)
		{
			if (s[j] == '?')
			{
				s[j] = 'a';
			}
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	string S;
	cin >> S;
	N = S.size();
	if (N == 2) {
		if (S[0] == S[1])
			cout << "1 2" << endl;
		else
			cout << "-1 -1" << endl;
		return 0;
	}
	rep(i, N - 2) {
		if (S[i] == S[i + 1] || S[i + 1] == S[i + 2] || S[i + 2] == S[i]) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}
	cout << "-1 -1" << endl;
	return 0;
}

Measured memory_bytes: 512
N, A, B, C, D = [int(i) for i in input().split()]
S = input()

def solve():
    ac = S[A - 1:C]
    if A < B < D < C:
        bd = S[B - 2:D + 1]
        return ("##" not in ac and "..." in bd)
    else:
        bd = S[B - 1:D]
        return ("##" not in ac and "##" not in bd)

if solve():
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3700
import numpy as np
n = int(input())
h = np.array([-1] + [int(x) for x in input().split()] + [1e9])

flag = True
for i in range(1, n+1):
    prev = h[i-1]
    now = h[i]
    next = h[i+1]
    if prev < now:
        h[i] -= 1
    elif prev == now:
        pass
    else:
        flag = False
        break

if flag:
    print('Yes')
else:
    print('No')

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

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b,c;
    cin>>a>>b>>c;
    int temp=a;
    a=b;
    b=temp;
    int temp1=a;
    a=c;
    c=temp1;
    cout<<a<<" "<<b<<" "<<c;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
int main(){
    long long x,y;
    while(cin>>x>>y){
        int i=0;
        if(x==0&&y==0) break;
        if(x<y) swap(x,y);
        while(1){
            x=x%y;
            swap(x,y);
            i++;
            if(y==0){
                cout<<x<<" "<<i<<endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3088
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<stack>
using namespace std;
char a[3][3];
int main()
{
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 3; j++)
			cin >> a[i][j];
	for (int i = 0; i < 3; i++)
		cout << a[i][i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 384
#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 floop(i,a,n) for (int i=a;i<n;i++)
#define rfloop(i,a,n) for (int i=n-1;i>=a;i--)
#define mloop(it,x) for(it=x.begin();it!=x.end();it++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((ll)(x).size())
#define cases ll t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef unsigned long long int ull;
typedef vector<ll> vec;
typedef pair<ll,ll> pll;
typedef double db;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const ll mod=1000000007;
ll pm(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=((result%mod)*(x%mod))%mod; x=((x%mod)*(x%mod))%mod; n/=2;} return result;}
ll p(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=result*x; x=x*x; n/=2;} return result;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ncr(ll n,ll r) { ll p=1,k=1; if(n-r<r) r=n-r; if(r!=0) {while(r!=0) {p*=n; k*=r; ll temp=gcd(p,k); p/=temp; k/=temp; n--; r--;} } else p=1; return p;}
ll factorial[200000+1];
void fact(ll n) { factorial[0]=1; factorial[1]=1; floop(i,2,n+1) factorial[i] = (i * factorial[i-1]%mod) % mod; }
ll d,coeff1,coeff2; 
void euclid(ll a, ll b) { if(b==0) { d=a; coeff1=1; coeff2=0; } else { euclid(b,a%b); ll temp=coeff1; coeff1=coeff2; coeff2=temp-(a/b)*(coeff2); } }
ll modinv(ll a) { euclid(a,mod); return (coeff1%mod+mod)%mod; }
int prime[1000001]={};
int spf[1000001]={};
void sieve(ll n)
{
	prime[0]=1;
	prime[1]=1;
	for(ll i=2;i*i<=n;i++)
	{
		if(prime[i]==0)
		{
			for(ll j=i*i;j<=n;j+=i)
			{
				prime[j]=1;	
				if(spf[j]==j)
				spf[j]=i;	
			}		
		}
	}
}
/*
vec s(300000,0);
vec si(300000,1);
ll root(ll a)
{
	while(s[a]!=a)
	a=s[a];
	return a;
}
void uni(ll a,ll b)
{
	ll r1=root(a);
	ll r2=root(b);
	if(si[r1]<si[r2])
	{
		s[r1]=s[r2];
		si[r2]+=si[r1];
	}
	else
	{
		s[r2]=s[r1];
		si[r1]+=si[r2];
	}
}*/
vector<vec > adj(300000);
vec vis(300000,0);
//vec par(300000,0);
vec ans;
//set<ll> sab;
void dfs(ll t,ll n)
{
	vis[t]=1;
	ans.pb(t);
	//sab.insert(t);
	floop(i,0,sz(adj[t]))
	{
		if(vis[adj[t][i]]==0)
		{
			//ans.pb(adj[t][i]);
		//	par[adj[t][i]]=t;
			vis[adj[t][i]]=1;
		//	sum[adj[t][i]]=sum[t]+c[t][adj[t][i]];
			dfs(adj[t][i],n);
		}
	}
	//if(sz(sab)==n-1)
//	ans.pb(t);
}
int main()
{
	ll n,k;
	cin>>n>>k;
	vec a(n+1);
	floop(i,1,n+1)
	cin>>a[i];
	adj.resize(n+1);
	vis.resize(n+1);
//	par.resize(n+1);
	floop(i,1,n+1)
	{
		adj[i].pb(a[i]);
		//adj[a[i]].pb(i);
	}
	//par[1]=-1;
	dfs(1,n);
	ll pos=-1;
	//floop(i,0,sz(ans))
	//cout<<ans[i]<<" ";
	floop(i,0,sz(ans))
	{
		if(a[ans[sz(ans)-1]]==ans[i])
		{
			pos=i;
			break;
		}
	}
	//if(k<pos)
	//final=ans[k]
	ll final=0;
	if(k<pos)
	final=ans[k];
	else
	final=ans[(((k-pos)%(sz(ans)-pos))+pos)%(sz(ans))];
	cout<<final<<"\n";
	return 0;
}

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

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

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

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

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

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

    ll a, b; cin>>a>>b;
    // f(a, b) = f(a - 1, 0) ^ f(b, 0) = num1 ^ num2

    a--;
    ll arem = (a + 1) % 4;
    ll num1 = 0;
    for(int i=0; i<arem; i++) num1 ^= (a - i);

    ll brem = (b + 1) % 4;
    ll num2 = 0;
    for(int i=0; i<brem; i++) num2 ^= (b - i);

    ll ans = num1 ^ num2;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

var n int
var xs, ys []int
var went []bool
var total float64
var count int

func main() {
	fmt.Scan(&n)
	xs = make([]int, n)
	ys = make([]int, n)
	went = make([]bool, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&xs[i], &ys[i])
	}
	for i := 0; i < n; i++ {
		went[i] = true
		dfs([]int{i})
		went[i] = false
	}
	fmt.Println(total / float64(count))
}

func dfs(vs []int) {
	if len(vs) == n {
		calc(vs)
		return
	}
	for i := 0; i < n; i++ {
		if went[i] {
			continue
		}
		went[i] = true
		dfs(append(vs, i))
		went[i] = false
	}
}

func calc(vs []int) {
	sum := 0.0
	for i := 0; i < n-1; i++ {
		src, target := vs[i], vs[i+1]
		dx := xs[target] - xs[src]
		dy := ys[target] - ys[src]
		sum += math.Sqrt(float64(dx*dx + dy*dy))
	}
	count++
	total += sum
}


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

int main() {
  char c;
  cin >> c;
   
  if( c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' ){
     cout << "vowel" << endl;
  }
  
  else{
    cout << "consonant" << endl;
  }
  
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		String [] str1=new String[n];
		String [] str2=new String[n];
		int tarou=0;
		int hanako=0;
		for(int i=0;i<n;i++) {
			str1[i]=sc.next();
			str2[i]=sc.next();
		}
		for(int j=0;j<n;j++) {
			char [] ch1=str1[j].toCharArray();
			char [] ch2=str2[j].toCharArray();
			if(str1[j].length()<=str2[j].length()) {
				char [] ch3=new char[str2[j].length()];
				ch3=str1[j].toCharArray();
				for(int k=0;k<str1[j].length();k++) {
					if(str1[j].length()==str2[j].length()) {
						if(k+1==str1[j].length()&&ch3[k]==ch2[k]) {
							tarou+=1;
							hanako+=1;
						}
						else if(ch3[k]==ch2[k]) {
							continue;
						}
						else if(ch3[k]>ch2[k]) {
							tarou+=3;
							break;
						}
						else if(ch3[k]<ch2[k]) {
							hanako+=3;
							break;
						}
					}
					else {
						if(k+1==str1[j].length()&&ch3[k]==ch2[k]) {
							hanako+=3;
						}
						else if(ch3[k]==ch2[k]) {
							continue;
						}
						else if(ch3[k]>ch2[k]) {
							tarou+=3;
							break;
						}
						else if(ch3[k]<ch2[k]) {
							hanako+=3;
							break;
						}
					}
				}
			}
			else if(str1[j].length()>str2[j].length()) {
				char [] ch3=new char [str1[j].length()];
				ch3=str2[j].toCharArray();
				for(int k=0;k<str2[j].length();k++) {
						if(k+1==str2[j].length()&&ch3[k]==ch1[k]) {
							tarou+=3;
						}
						else if(ch3[k]==ch1[k]) {
							continue;
						}
						else if(ch3[k]>ch1[k]) {
							hanako+=3;
							break;
						}
						else if(ch3[k]<ch1[k]) {
							tarou+=3;
							break;
						}
				}
			}
		}
			System.out.println(tarou+" "+hanako);
		sc.close();
		}

	}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N; cin >> N;
  int result = (N+1)/2;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
#define pi acos(-1)
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int MAXN = 1e5 + 10;
const int MAXM = 2e6 + 10;
const ll mod = 1e9 + 7;

map<int,int>mp;
int a[MAXN];

int main() {
#ifdef local
    freopen("data.txt","r",stdin);
#endif
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++) {
        scanf("%d",&a[i]);
        mp[a[i]]++;
    }
    int ans=0;
    for(int i=0; i<n; i++) {
        if(mp[a[i]]==a[i]) continue;
        else if(mp[a[i]]>a[i]) {
            ans+=mp[a[i]]-a[i];
            mp[a[i]]=a[i];
        }
        else {
            ans+=mp[a[i]];
            mp[a[i]]=a[i];
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class I,class V=typename I::value_type>V sum_up(const I&l,const I&r){V v;for(I i=l;i!=r;i++)v=i==l?*i:v+*i;return v;}
template<class I,class T=iterator_traits<I>>I operator+(I it,int n){for(int i=0;i<n;i++)it++;return it;}
template<class I,class T=iterator_traits<I>>I operator-(I it,int n){for(int i=0;i<n;i++)it--;return it;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }

/*!* [modint] *!*/
/*+* 剰余環整数と剰余階乗 *+*/
struct int_m;
int_m invmod(int_m);
int_m powmod(int_m, i64);
struct int_m {
    static i64 m;
    i64 v;
    int_m() {}
    int_m(i64 x) : v(x) {}
    int_m operator+(const int_m &y) const { return (v + y.v) % m; }
    int_m operator-(const int_m &y) const { return (v - y.v + m) % m; }
    int_m operator*(const int_m &y) const { return (v * y.v) % m; }
    int_m operator/(const int_m &y) const { return *this * invmod(y); }
    int_m operator^(const i64   &y) const { return powmod(*this, y); }
    void operator+=(const int_m &y) { *this = *this + y; }
    void operator-=(const int_m &y) { *this = *this - y; }
    void operator*=(const int_m &y) { *this = *this * y; }
    void operator/=(const int_m &y) { *this = *this / y; }
    void operator^=(const i64   &y) { *this = *this ^ y; }
    bool operator==(const int_m &y) const { return v == y.v; }
    bool operator!=(const int_m &y) const { return v != y.v; }
    friend istream &operator>>(istream &ist, int_m &m) { ist >> m.v; return ist; }
    friend ostream &operator<<(ostream &ost, int_m m) { ost << m.v; return ost; }
};
i64 int_m::m;

// O(log a)
int_m powmod(int_m a, i64 p) {
    int_m v = 1;
    for(int_m b = a; p > 0; p >>= 1, b *= b ) if(p & 1) v *= b;
    return v;
}
int_m invmod(int_m x) {
    return powmod(x, x.m - 2);
}

int main() {
    int_m::m = 1e9 + 7;
    i64 N;
    cin >> N;
    int_m p4 = int_m(4) ^ (N - 1);
    vector<i64> C(N);
    for(i64 &c : C) cin >> c;
    sort(REV_WHOLE(C));
    int_m ans = 0;
    for(int k = 0; k < N; k++) {
        ans += int_m(C[k]) * int_m(k + 2);
    }
    ans *= p4;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ldb long double
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define xh1(a,b) for(int i=a;i<b;i++)
#define xh2(a,b) for(int j=a;j<b;j++)
#define stlbl(a) for(it=a.begin();it!=a.end();it++)
#define dzkt int T;cin>>T;while(T--)
#define mst(a,i) memset(a,i,sizeof(a))
#define iosks std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int N=2005,inf=1e9+10,mod=1e9+7;
ll pow2(ll a,ll b) {ll s=1; while(b) {if(b&1) s=(s*a); a=(a*a); b/=2; } return s;}
int gcd(int a,int b) {return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) {return a/gcd(a,b)*b; }
ll prime(ll x) {for(ll i=2;i<=sqrt(x+0.5);i++) if(x%i==0) return 0; return 1; }

char ch[N];
vector<ll> vec;

ll n,k=1,t=26;

void slove(ll nn,ll kk)
{
    if(kk==k) return;
    slove(nn/26,kk+1);
    printf("%c",(nn%26)+'a');
}
int main()
{
    //iosks;
    cin>>n;
    while(n>t) n-=t,k++,t*=26;
    n--;
    slove(n,0);
    cout<<endl;
    return 0;
}


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

int main(){
    int h, w, i, j, k, s = 0;
    int c[10][10];
    cin >> h >> w;
    for(i=0; i<10; i++){
        for(j=0; j<10; j++){
            cin >> c[i][j];
        }
    }
    for(k=0; k<10; k++){
        for(i=0; i<10; i++){
            for(j=0; j<10; j++){
                if(c[i][j] > c[i][k] + c[k][j]){
                    c[i][j] = c[i][k] + c[k][j];
                }
            }
        }
    }
    for(i=0; i<h*w; i++){
        cin >> k;
        if(k != -1){
            s += c[k][1];
        }
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,A,B;
  cin >> N >> A >> B;
  if(abs(A-B) % 2 == 1) cout << "Borys" << endl;
  else cout << "Alice" << endl;
  return 0;
}


Measured memory_bytes: 892
#include<iostream>
#include<vector>
#include<cstring>

using namespace std;

const int MAX = 301;
const int MAX_E = 10001;
const int INF = (1<<25);
struct edge{int to,cap,rev,num;bool isrev;};
vector<edge> V[MAX];
bool used[MAX];
bool R[MAX_E];
int N,M;
int s,g;

void input(){
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    int a,b;
    cin >> a >> b;
    V[a].push_back((edge){b,1,V[b].size(),i,false});
    V[b].push_back((edge){a,1,V[a].size()-1,i,true});
  }
  cin >> s >> g;
}

int dfs(int v, int t, int f){
  if(v == t) return f;
  used[v] = true;
  
  for(int i = 0; i < (int)V[v].size(); i++){
    edge& e = V[v][i];
    if(!used[e.to] && e.cap > 0){
      int d = dfs(e.to,t,min(f,e.cap));
      if(d > 0){
	e.cap -= d;
	V[e.to][e.rev].cap += d;
	R[e.num] = e.isrev;
	return d;
      }
    }
  }
  return 0;
}

int max_flow(int s, int t){
  int flow = 0;
  while(1){
    memset(used,false,sizeof(used));
    int f = dfs(s,t,INF);
    if(f == 0) return flow;
    flow += f;
  }
}


void solve(){

  cout << max_flow(s,g) << endl;

  vector<int> req;
  for(int i = 0; i < M; i++)
    if(R[i]) req.push_back(i+1);

  cout << req.size() << endl;
  for(int i = 0; i < (int)req.size(); i++)
    cout << req[i] << endl;
  
}

int main(){
  input();
  solve();
  return 0;
}

Measured memory_bytes: 1320
/*
	Powered by C++11.
	Author : Alex_Wei.
*/

#include <bits/stdc++.h>
using namespace std;

//#pragma GCC optimize(3)
//#define int long long

#define ll long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb emplace_back
#define all(x) x.begin(),x.end()
#define sor(x) sort(all(x))
#define rev(x) reverse(all(x))
#define mem(x,v) memset(x,v,sizeof(x))

// Templates start.

namespace IO{
	char buf[1<<21],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
	#ifdef __WIN32
		#define gc getchar()
	#else
		#define gc (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
	#endif
	#define pc(x) (*O++=x)
	#define flush() fwrite(obuf,O-obuf,1,stdout)

	inline int read(){
		int x=0,sign=0; char s=gc;
		while(!isdigit(s))sign|=s=='-',s=gc;
		while(isdigit(s))x=(x<<1)+(x<<3)+(s-'0'),s=gc;
		return sign?-x:x;
	}
	void print(int x) {if(x>9)print(x/10); pc(x%10+'0');}
}

namespace math{
	const int mod=998244353;
	const int maxn=1e6+5;

	ll ksm(ll a,ll b){ll s=1,m=a; while(b){if(b&1)s=s*m%mod; m=m*m%mod,b>>=1;} return s;}
	ll inv(ll x){return ksm(x,mod-2);}

	ll fc[maxn],ifc[maxn];
	void init_m(int n){
		fc[0]=1; for(int i=1;i<=n;i++)fc[i]=fc[i-1]*i%mod;
		ifc[n]=inv(fc[n]); for(int i=n-1;i>=0;i--)ifc[i]=ifc[i+1]*(i+1)%mod;
	}
	ll C(ll n,ll m){return fc[n]*ifc[m]%mod*ifc[n-m]%mod;}
}

// Templates end. Please give me more points.

using namespace IO;
//using namespace math;

ll n,i,bs;
string s;

int main(){
	cin>>n;
	for(i=0,bs=1;;i++,bs*=26)if(n>=bs)n-=bs; else break;
	while(i)s+=(char)(n%26+'a'),n/=26,i--;
	reverse(s.begin(),s.end());
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<cfloat>
using namespace std;
int mod = 1e9+7;
long long int inf = 1e18;

int main() {
  int n, k;
  cin >> n >> k;
  int x;
  int sum = 0;
  for(int i=0; i<n; i++){
    cin >> x;
    sum += min(abs(0-x), abs(k-x));
  }
  cout << sum * 2 << endl;

  return 0;
}

//


Measured memory_bytes: 256
def main(n):
    f = [list(map(int, input().split())) for i in range(n)]
    d = True
    ans = 0
    while d:
        d = False
        for i in range(n):
            l = []
            for k in range(3):
                if f[i][k] == 0:
                    continue
                if f[i][k] == f[i][k + 1] == f[i][k + 2]:
                    l.append(k)
                    l.append(k + 1)
                    l.append(k + 2)
            if l == []:
                continue
            l = list(set(l))
            b = f[i][l[0]]
            d = True
            for k in l:
                ans += b
                f[i][k] = 0
        if d:
            for i in range(n-1,-1,-1):
                for k in range(5):
                    x = i
                    while f[x][k]:
                        if x < n - 1:
                            if f[x + 1][k] == 0:
                                f[x+1][k] = f[x][k]
                                f[x][k] = 0
                                x += 1
                                continue
                        break
    print(ans)

while 1:
    n = int(input())
    if n == 0:
        break
    main(n)


Measured memory_bytes: 5624
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main()
{
    long long int m,n,i,s,t;
    scanf("%lld%lld",&m,&n);
    if(n>=2*m)
    {
        t=(n-m*2)/4;
        s=m+t;
    }
    else
        s=n/2;
    printf("%lld",s);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll MOD = 1e9 + 7;

ll fastPow(ll x, ll n)
{
    if (n == 0)
        return 1;
    if (n % 2 == 0)
        return fastPow(x * x % MOD, n / 2);
    else
        return x * fastPow(x, n - 1) % MOD;
}

ll fac[112345];
void combInit(int mx)
{
    fac[0] = 0;
    fac[1] = 1;
    for (int i = 2; i <= mx; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
    }
}

ll modDiv(ll a, ll b)
{
    return a * fastPow(b, MOD - 2) % MOD;
}

ll comb(ll a, ll b)
{
    if (a < b)
        return 0;
    if (a <= 0 || b < 0)
        return 0;
    if (a == b)
        return 1;

    ll p, c;

    c = modDiv(fac[a], fac[a - b]);
    p = fac[b];

    ll res = modDiv(c, p);

    return res;
}

int main()
{

    combInit(110000);

    int n, a[112345], d, l, r;
    bool used[112345] = {false};

    cin >> n;
    REP(i, n + 1)
    {
        cin >> a[i];

        if (used[a[i]])
            d = a[i];

        used[a[i]] = true;
    }

    l = -1;
    REP(i, n + 1)
    {
        if (d == a[i])
        {
            if (l == -1)
                l = i;
            else
                r = i;
        }
    }

    for (int i = 1; i <= n + 1; i++)
    {
        ll res = comb(n + 1, i);

        res -= comb(l + (n - r), i - 1);

        if (i == 1)
            res--;

        res = (res + MOD) % MOD;

        cout << res << endl;
    }

    return 0;
}

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

int main(){
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  
  map<int,int> L,R;
  int count=0;
  vector<int> ans;
  
  for(int i=0;i<N;i++){
    int lnum=a[i];
    int rnum=a[N-1-i];
    
    if( L[ lnum ] == R[ lnum ] ){
      count++;
    }
    L[ lnum ]++;
    if( L[ lnum ] == R[ lnum ] ){
      count--;
    }
    
    if( L[ rnum ] == R[ rnum ] ){
      count++;
    }
    R[ rnum ]++;
    if( L[ rnum ] == R[ rnum ] ){
      count--;
    }
    
    if( count == 0 ){
      ans.push_back(i+1);
    }
  }
  for(int i=0;i<(int)ans.size();i++){
    if(i)cout<<' ';
    cout<<ans[i];
  }
  cout<<endl;
  return 0;
}



Measured memory_bytes: 7896
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    

S=input()
ans=0
cnt=0

for i in range(len(S)):
	if S[i]=="A" or S[i]=="T" or S[i]=="C" or S[i]=="G":
		cnt+=1
		for j in range(1,len(S)-i):
			if S[i+j]=="A" or S[i+j]=="T" or S[i+j]=="C" or S[i+j]=="G":
				cnt+=1
			else:
				ans=max(cnt,ans)
				cnt=0
				break
			
	else:
		continue		
							
	ans=max(ans,cnt)
	cnt=0
			
ans=max(ans,cnt)

print(ans)

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

double gcd(double a, double b)
{
	return b ? gcd(b, fmod(a, b)) : a;
}

int main()
{
	double a, b;
	cin >> a >> b;
	cout << fixed << setprecision(0) << gcd(b, a) << endl;
	return 0;
}

Measured memory_bytes: 1280
import java.util.*; 
import java.math.BigDecimal;
import java.math.MathContext;

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        BigDecimal a= sqrt(new BigDecimal(sc.nextDouble()),50);
    BigDecimal b= sqrt(new BigDecimal(sc.nextDouble()),50);
    BigDecimal c= sqrt(new BigDecimal(sc.nextDouble()),50);
    
  		BigDecimal d=a.add(b);
  		
  		int f=d.compareTo(c);
    
 	if(f==-1){
    		System.out.println("Yes");
    	}else{
     		System.out.println("No");
   	 }

    	
    }
   public static BigDecimal sqrt(BigDecimal a, int scale){
        //とりあえずdoubleのsqrtを求める
        BigDecimal x = new BigDecimal(
                Math.sqrt(a.doubleValue()), MathContext.DECIMAL64);
        if(scale < 17) return x;

        BigDecimal b2 = new BigDecimal(2);
        for(int tempScale = 16; tempScale < scale; tempScale *= 2){
            //x = x - (x * x - a) / (2 * x);
            x = x.subtract(
                    x.multiply(x).subtract(a).divide(
                    x.multiply(b2), scale, BigDecimal.ROUND_HALF_EVEN));
        }
        return x;
    }


}

Measured memory_bytes: 24788
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll int64_t
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    map<string,int> mp;
    REP(i,n){
        string s, c;
        cin>>s;cin>>c;
        if(s=="insert") mp[c]++;
        else{
            if(mp[c]) cout<<"yes"<<endl;
            else cout<<"no"<<endl;
        }
    }
}


Measured memory_bytes: 47476
#include <bits/stdc++.h>
using namespace std;
int n,a[10004],b[10004];
int main(){
	scanf("%d",&n);
	for (int i = 1; i <= n; i++)
		scanf("%d",&a[i]);
	for (int i = 1; i <= n; i++)
		scanf("%d",&b[i]);
	long long s = 0;
	long long ss = 0;
	for (int i = 1; i <= n; i++)
		s += b[i] - a[i];
	for (int i = 1; i <= n; i++)
		ss += max(a[i] - b[i], 0);
	for (int i = 1; i <= n; i++)
		ss += (a[i] % 2 != b[i] % 2) * (a[i] - b[i] < 0);
	if (s >= ss) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 384
let [A, B, C]= require('fs').readFileSync('/dev/stdin', 'utf8').split(' ').map(Number);
 let coin = 0;
 let i = 1;
 if (A >= C) {
     console.log(1);
 } else {
 while (coin <= C) {
  coin += A;
  if (i % 7 === 0)
     coin += B;
  if (C === coin || C < coin) {
      console.log(i);
      break;
  } else if (C - coin < A) {
      console.log(i + 1);
      break;
  }
  i++;
 }
}


Measured memory_bytes: 15408
N=int(input())
goal=[]
step=[]
i=1
while i*i<=N:
     if N%i==0:
          j=N/i
          goal.append([i,j])
     i+=1
n=len(goal)
for i in range(n):
     step.append(goal[i][0]-1+goal[i][1]-1)
print(int(min((step))))


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using P = pair<ll,ll>;
int INF = 1e9+7;
int A[100000+5];

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

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N-1; i++) {
        A[i+1] = gcd(A[i],A[i+1]);
    }

    cout << A[N-1] << endl;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<climits>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reg(i,a,b) for(int i=(a);i<=(b);i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=(b);i>=(a);i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX

int n,nq;
int dat[300005]={};



int main(void){
	scanf("%d%d",&n,&nq);
	rep(i,n){
		int a;
		scanf("%d",&a);
		dat[a]=a;
	}
	rep(i,300004){
		dat[i+1] = max(dat[i],dat[i+1]);
	}
	
	rep(i,nq){
		int q;
		scanf("%d",&q);
		int no = q-1;
		int ans=0;
		while(no<300005){
			ans = max(ans,dat[no]%q);
			no+=q;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 2196
#include<bits/stdc++.h>
using namespace std;
vector<int> adj[200005];
bool visited[200005];
int main() 
{	
    int n, m, a, b; 
    cin >> n >> m; 
    int ans = 0; 

    for(int i = 1; i <= m; i++) {
      cin >> a >> b; 
      adj[a].push_back(b);
      adj[b].push_back(a);
    }
	
    memset(visited, false, sizeof(visited));

    for(int i = 1; i <= n; i++) {
      if(visited[i]) {
        continue;
      }
      int temp = 0; 

      queue<int> q; 
      q.push(i);
      visited[i] = true;
      
      while(!q.empty()) {
        int start = q.front(); 
        q.pop();
        temp++;
        for(auto it = adj[start].begin(); it != adj[start].end(); it++) {
          if(!visited[*it]) {
            q.push(*it);
            visited[*it] = true;
          }
        }
      }
      ans = max(temp, ans);
    }

    cout << ans;

	return 0;
}


Measured memory_bytes: 15240
// Copyright 2020 yaito3014
#include <bits/stdc++.h>
using namespace std;

int main(){
	string N;
	int K;
	cin >> N >> K;
	int len = N.length();
	// dp[i][j][smaller]
	vector<vector<array<int,2>>> dp(len+1,vector<array<int,2>>(K+1));
	for(auto&v:dp)for(auto&w:v)w.fill(0);
	dp[0][0][0] = 1;
	for(int i = 0; i < len; ++i){
		for(int j = 0; j <= K; ++j){
			for(auto smaller : { true, false }){
				int k_n = smaller?9:N[i]-'0';
				for(int k = 0; k <= k_n; ++k){
					if(k!=0&&j==K)continue;
					dp[i+1][j+(k==0?0:1)][smaller||k<N[i]-'0']
						+= dp[i][j][smaller];
				}
			}
		}
	}
	cout << dp[len][K][0] + dp[len][K][1] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;

	int t;
	if(y<x) {
		t=y;y=x;x=t;
		t=b;b=a;a=t;
	}

	int r;
	r=min({2*y*c, 2*x*c+(y-x)*b, a*x+b*y});

	cout << r << endl;

	return 0;

}




Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>	
#include <stdio.h>    
 
using namespace std;
     
#define F first
#define S second
#define lb lower_bound          	
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcount                                                                                        
#define sqr(x) ((x) * (x))
#define al 0x3F3F3F3F
#define sz(x) x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;                                  
const int N = (int)2e5 + 123;
const ll inf = (ll)3e18 + 1;
                                       
const double pi = acos(-1.0);
const double eps = 1e-7;
const int dx[] = {0, 0, 1, 0, -1};   																																					
const int dy[] = {0, 1, 0, -1, 0};  

int n, j, a[N], ans;

inline void boost () {
	ios_base :: sync_with_stdio (NULL);
	cin.tie (NULL), cout.tie (NULL);
}

inline void Solve () {  
	boost (); 
	cin >> n;
	for (int i = 1; i <= n; i ++) cin >> a[i];
	for (int i = 1; i <= n; i = j) {
		j = i;
		while (j <= n && a[i] == a[j]) j ++;
		ans += (j - i) / 2;
	}
	cout << ans;
}                                          
                  
main () {                                       
//	freopen ("ormax.in", "r", stdin);    
//	freopen ("ormax.out", "w", stdout); 	          
	int tt = 1;
//	cin >> tt;   
	while (tt --) {
		Solve ();
	}        
	return 0;      
}                                                  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef map<int,int> mii;
#define pb push_back


int main()
{
    int tst=1;
    /*scanf("%d",&tst);*/
    while(tst--) 
	{
		ll a,b,c,k;
		cin >> a >> b >> c >> k;
		ll mx=0;
		mx+=min(a,k);
		k-=min(a,k);
		k-=min(b,k);
		mx-=min(c,k);
		cout << mx << endl;
    }
    return 0;
}


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

bool integer(float k)
{
    return k == (float)(int)k;
}

int main()
{
    int a[11][11];
    int n, d, dem = 0;
    cin >> n >> d;
    
    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j < d; ++j)
        {
            cin >> a[i][j];
        }
    }
    
    for(int i = 0; i < n - 1; ++i)
    {
        for(int j = i + 1; j < n; ++j)
        {
            float s = 0;
            for(int k = 0; k < d; ++k)
            {
                s += pow((a[i][k] - a[j][k]), 2);
            }
            if(integer(sqrt(s))) ++dem;
        }
    }
    
    cout << dem;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
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; }
const ll INF = 1e10;
const ll MOD = 1000000007;
int main() {
    int n,m,c;
    int b[21];
    int a[21][21];
    cin >> n >> m >> c;
    rep(i,m) cin >> b[i];
    rep(i,n) rep(j,m) cin >> a[i][j];
    int cnt = 0,ans = 0;
    rep(i,n){
        cnt = 0;
        rep(j,m){
            cnt += a[i][j]*b[j];
        }
        if (cnt+c > 0) ans++;
    }
    PRINT(ans);
}

Measured memory_bytes: 256
a,b,c,d = map(int,input().split())


 
while a>0 or c>0:
    c = c - b
    
    if c<1:
        
        break
    
    a = a - d
    
    if a < 1:

        break
    
   

  


if a<0 or a==0:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 9108
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

L,R,d = LI()

print(R//d-(L-1)//d)


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

def main():
    w, h, N = map(int, input().split())
    xya = [list(map(int, input().split())) for i in range(N)]


    top = h
    bottom = 0
    left = 0
    right = w
    for i in range(N):
        x, y, a = xya[i]
        if a == 1:
            left = max(left, x)
        elif a == 2:
            right = min(right, x)
        elif a == 3:
            bottom = max(bottom, y)
        else:
            top = min(top, y)
    # print("top:{} bottom:{} left:{} right:{}".format(top, bottom, left, right))
    if bottom >= top or left >= right:
        print(0)
    else:
        print((top-bottom)*(right-left))




if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>
#include <functional>

using namespace std;
using ll = long long;
using ld = double;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll, ll>;
const ll INF = 1e17;
const ld eps = 1e-10;
const ll MOD = 1e9 + 7;

const double pi = acos(-1.0);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	s = "CCC" + s;
	ll now = 3;
	ll ans = 0;
	ll anum = 0;
	while (now < (ll)s.size() - 2) {
		if (s[now] == 'A' && s[now + 1] == 'B' && s[now + 2] == 'C') {
			s[now] = 'B';
			s[now+1] = 'C';
			s[now+2] = 'A';
			now += 2;
			ans += anum + 1;
		}
		else {
			if (s[now] == 'A')
				anum++;
			else
				anum = 0;
			now++;
		}
	}

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






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

int bubbleSort(int A[], int N){
  int sw=0, tmp;
  bool flag = 1;

  for (int i=0; flag; i++){
    flag = 0;
    for (int j=N-1; j>=i+1; j--){
      if (A[j] < A[j-1]){
        tmp = A[j];
        A[j] = A[j-1];
        A[j-1] = tmp;
        flag = 1;
        sw++;
      }
    }
  }
  return sw;
}

int main(){
  int sw, N;
  int A[100];

  cin >> N;
  for (int i=0; i<N; i++){
    cin >> A[i];
  }

  sw = bubbleSort(A, N);

  for (int i=0; i<N; i++){
    if(i){
      cout << " ";
    }
    cout << A[i];
  }
  cout << endl;
  cout << sw << endl;

  return 0;
}



Measured memory_bytes: 3080
#include <iostream>

int main()
{
    long n;
    scanf("%ld", &n);

    long sum = 0;
    for (long i = 1; i <= n; i++)
    {
        if (i % 3 == 0 || i % 5 == 0)
        {
            continue;
        }

        sum += i;
    }

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


Measured memory_bytes: 3828