akhauriyash/Code-Regression huggingface dataset:
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false ll_MAX ll_MIN insert erase clear pop push compare ll64_MAX ll64_MIN  reverse replace stringstream string::npos length substr front priority_queue

#ifndef ONLINE_JUDGE
#include "debug.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define debug(...) 42
#endif

#define endl '\n'
#define ll long long
#define rint register int
#define minpq priority_queue <int, vector<int>, greater<int> >
#define maxpq  priority_queue <int>

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX

#define conutBits(n)	__builtin_popcount(n)
#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

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

	ll t, i, x, j, y, 	z = 0, k, n;
	string s;
	cin >> n;

	ll a[n];
	rep(i, 0, n, 1) {
		cin >> a[i];
		if (i) {
			x = a[i - 1];
			if (x > a[i]) {
				t = x - a[i];
				z += t;
				a[i] += t;
			}
		}
	}

	// if (z % 9 == 0)	puts("Yes");
	// else puts("No");

	ce(z);

}



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

int main()
{
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int upp = 2*max(x, y);
  ll ans = 1000000000;
  int i=0;
  while(i <= upp)
  {
    ll price = max(x-i/2, 0)*a + max(y-i/2, 0)*b + c*i;
    ans = min(ans, price);
    i+=2;
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    while(cin>>n>>m, n){
        vector<vector<pll>> edge(n);
        ll minc=LINF, v=0;
        rep(i,m){
            ll s,t,c;
            cin>>s>>t>>c;
            s--;t--;
            edge[s].emplace_back(t,c);
            edge[t].emplace_back(s,c);
            if(minc>c){minc=c; v=s;}
        }
        priority_queue<tlll,vector<tlll>, greater<tlll>> q;
        vl cost(n,LINF);
        cost[v]=0;
        for(auto&e:edge[v]){
            q.emplace(e.sc, v, e.fs);
        }
        vl ans;
        while(!q.empty()){
            ll c,s,t;
            tie(c,s,t) = q.top();
            q.pop();
            if(cost[t]!=LINF)continue;
            ans.push_back(c);
            cost[t]=0;
            for(auto&e:edge[t]){
                if(cost[e.fs]==LINF)q.emplace(e.sc, t, e.fs);
            }
        }
        sort(all(ans));
        cout<<ans[n/2-1]<<endl;
    }
    return 0;
}


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

using namespace std;

const int maxn = 12;

int n, d, x[maxn][maxn];

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> d;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < d; ++j)
			cin >> x[i][j];

	int ans = 0;
	for (int i = 0; i < n; ++i)
		for (int j = i+1; j < n; ++j) {
			int sum = 0;
			for (int k = 0; k < d; ++k)
				sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);

			int tmp = floor(sqrt(sum));
			if (tmp * tmp == sum)
				++ans;
		}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
// È¥°É£¡Æ¤¿¨Çð! °ÑAC´ø»ØÀ´£¡
//      ¤Ø¡¡¡¡¡¡¡¡¡¡£¯|
// ¡¡¡¡/£Ü7¡¡¡¡¡¡ ¡Ï£ß/
// ¡¡ /¡¡©¦¡¡¡¡ £¯¡¡£¯								AC		AC		AC		AC
//    ©¦¡¡Z £ß,£¼¡¡£¯¡¡¡¡ /`©c						AC		AC		AC		AC
//    ©¦¡¡¡¡¡¡¡¡¡¡©c¡¡¡¡ /¡¡¡¡¡µ					AC		AC		AC		AC
// ¡¡Y¡¡¡¡¡¡¡¡¡¡`¡¡ /¡¡¡¡/  /						AC		AC		AC		AC
// ¡¡Øé¡ñ¡¡.¡¡¡ñ¡¡¡¡¡´¡¡/¡¡/						AC		AC		AC		AC
// ¡¡()¡¡ ¤Ø¡¡¡¡¡¡¡¡|¡¡£Ü¡´							AC		AC		AC		AC
// ¡¡¡¡>- ._¡¡ ¥£¡¡ ©¦ £¯£¯							AC		AC		AC		AC
// ¡¡ / ¤Ø¡¡¡¡ /¡¡/£¼| £Ü£Ü							AC		AC		AC		AC
// ¡¡ ©c_/¡¡¡¡(_£¯¡¡ ©¦£¯£¯							AC		AC		AC		AC
// ¡¡¡¡ 7¡¡¡¡¡¡¡¡¡¡¡¡¡¡|£¯							AC		AC		AC		AC
// ¡¡¡¡ £¾¨Dr£þ£þ`-¨D£ß/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end());

using namespace std;

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

const int Days[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};

inline int read()
{
	#define gc getchar
	int ans=0;
	bool f=1;
	char ch=gc();
	
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	
	return f?ans:-ans;
	
	#undef gc
}

typedef long long ll;

vector<int> par;

int FindRoot(int x){return(par[x]<0 ? x : par[x]=FindRoot(par[x]));}

void Unite(int x,int y)
{
	x=FindRoot(x);y=FindRoot(y);
	
	if(x==y)return;
	
	par[y]+=par[x];
	par[x]=y;
}

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	
	int n,m;cin>>n>>m;
	
	par=vector<int>(n,-1);
	
	for(int i=0;i<m;i++){int x,y;cin>>x>>y;x--,y--;Unite(x,y);}
	
	sort(all(par));
	
	cout<<-par[0];
	
	//printf("Time used = %.12f",(double)(clock())/CLOCKS_PER_SEC);
	return 0;
}

/*  GOD BLESS  */


Measured memory_bytes: 3988
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	int i, j;
	int n, k;
	vector<int>list;


	cin >> n >> k;

	rep(i, 0, n) {
		int num;
		cin >> num;
		list.push_back(num);
	}

	sort(list.begin(), list.end(), greater<int>());

	int minn = 999999999;

	for (i = 0; i < n - (k-1); i++) {
		minn = min(minn, list[i] - list[i + (k - 1)]);
	}
	cout << minn << endl;













	getchar();
	getchar();
	return 0;
}

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

int main(){
  
  int N,keep,sum = 0;
  cin >> N;
  keep = N;
  
  while(N != 0){
    sum += N % 10;
    N /= 10;
  }
  
  if(keep % sum == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
A  = [[j for j in input().split()] for i in range(3)]
N  = input()
B  = [input() for i in range(int(N))]

s1 = len(set(A[0]) - set(B))
s2 = len(set(A[1]) - set(B))
s3 = len(set(A[2]) - set(B))
s4 = len(set([A[i][0] for i in range(3)]) - set(B))
s5 = len(set([A[i][1] for i in range(3)]) - set(B))
s6 = len(set([A[i][2] for i in range(3)]) - set(B))
s7 = len(set([A[i][i] for i in range(3)]) - set(B))
s8 = len(set([A[0][2], A[1][1], A[2][0]]) - set(B))

S  = [s1, s2, s3, s4, s5, s6, s7, s8]
if 0 in S:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int r,D,x;
    cin >> r >> D >> x;
    int ans=x;
    rep(i,10){
        ans=r*ans-D;
        cout << ans << endl;
    }



}


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

int main() {
  long long a,b;
  double fa,fb;
  cin >> a >> b;
  fa = a;fb = b;
  cout << fixed;
  cout << a/b << " " << a%b << " ";
  cout << setprecision(8) << fa/fb << endl;
}



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

int main() {

 int n;
 cin >> n;
 int d;
 cin >> d;
 int x;
 cin >> x;
 
 int c=0;
 for (int i=0; i<n; i++) {
  int a;
  cin >> a;
  c+=(d-1)/a;
  }
  
  cout << c+n+x << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()
int main() {
	int n;
	cin >> n;
	vector<int> buka(n, 0);
	for (int i = 1; i < n; i++) {
		int a;
		cin >> a;
		buka[a - 1] += 1;
	}
	rep(i, n) {
		cout << buka[i] << endl;
	}
}


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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if ((b * 2 + c) % 4 == 0)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll x,k,d,c; cin>>x>>k>>d;
    if(x<0) x=-x;
    c=(x+d-1)/d;
    if(c>k){
        cout<<x-k*d<<endl;
        return 0;
    }
    k-=c-1;
    x-=(c-1)*d;
    if(k%2) cout<<-(x-d)<<endl;
    else cout<<x<<endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
const int mxn = (1e5)  + 5;
int a[mxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 0 ; i  < n ; ++i)scanf("%d",&a[i]);
    int mx = 0;
    int cnt = 1;
    for(int i = n - 2;  i >= 0 ; --i)
    {
        if(a[i] >= a[i + 1])
            cnt++;
        else
            cnt = 1;
        mx = max(mx, cnt - 1);
    }
    cout<<mx<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>

using namespace std;

typedef long long ll;

void solver_main()
{
	ll n;
	cin >> n;
	cout << (n * (n - 1)) / 2 << endl;
}

int main(void)
{
	solver_main();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define range(a,b)		substr(a,b-a+1)
#define w(x)            int x; cin>>x; while(x--)
#define trace(x) 		cerr<<#x<<": "<<x<<" "<<endl;
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
	FIO;
	int n, m, k; cin >> n >> m >> k;
	mk(arr, n, string);

	for (int i = 0; i < n; ++i)
		cin >> arr[i];

	int ans = 0;

	for (int mi = 0; mi < (1 << n); ++mi)
		for (int mj = 0; mj < (1 << m); ++mj)
		{
			int cur = 0;
			for (int i = 0; i < n; ++i)
				for (int j = 0; j < m; ++j)
					if (!((mi >> i) & 1) && !((mj >> j) & 1) && arr[i][j] == '#')
						cur++;

			if (cur == k)
				ans++;
		}

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

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

int main(){
	string s; cin>>s;
	string r="CODEFESTIVAL2016";
	int cnt=0;
	rep(i,16) if(s[i]!=r[i]) cnt++;
	cout<<cnt<<endl;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

int main(){
  ll m1,d1,m2,d2;
  cin >> m1 >> d1;
  cin >> m2 >> d2;
  bool can = false;
  if(d2 == 1){
    can = true;
  }else{
    can = false;
  }
  if(can){
    cout << "1";
  }else{
    cout << "0";
  }

}


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

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

int main(){
    int n,k,a;
    cin >> n >> k;
    int mx = 0, gc;
    for(int i=0;i<n;i++){
        cin >> a;
        mx = max(a,mx);
        if(i==0) gc = a;
        else gc = gcd(gc, a);
    }
    if(mx < k || k % gc != 0) cout << "IMPOSSIBLE" << endl;
    else cout << "POSSIBLE" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout<< "YES"<<endl;
#define No cout<< "No"<<endl;
#define Yes cout<< "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main(){
    
    double v[50];
    double ans=0;
    int n;
    cin >> n;
    rep(i,n){
        cin>>v[i];
    }
    
    sort(v,v+n);
    reverse(v,v+n);
    
    double bi = 2;
    
    for(int i=0;i<n-2;i++){
        ans+=v[i]/bi;
        bi=bi*2.0;
    }
    
    ans+=(v[n-2]+v[n-1])/bi;
    
    cout << ans<<endl;
    
    return 0;
}


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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;


// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}





int main(){
  int r,D,x;
  cin >> r >> D >> x;
  rep(i,10){
    x=r*x-D;
    cout << x << '\n';
  }

}


Measured memory_bytes: 256
'use strict';
(function(stdin) { 
  var inputs = stdin.toString();
  var params = inputs.split('\n')[0].split(' ').map(Number);
  (function(a,b) {
     console.log(a * b,(a + b) * 2)
  }(params[0],params[1])); 
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7376
#include<bits/stdc++.h>
#define cases long long test;cin>>test;while(test--)
#define f_io ios::sync_with_stdio(false); cin.tie(0)
#define foi(a,n) for(long long i=a;i<n;i++)
#define foj(a,n) for(long long j=a;j<n;j++)
#define fok(a,n) for(long long k=a;k<n;k++)
#define ll long long
#define MOD 998244353
#define INF 1000000000
using namespace std;

int main()
{
    f_io;
    ll n,k;
    cin >> n >> k;
    vector<pair<ll,ll> > arr(k);
    foi(0,k)
        cin >> arr[i].first >> arr[i].second;
    vector<ll> dp(n),pre(n+1);
    dp[0]=1;
    pre[1]=1;
    foi(1,n)
    {
        foj(0,k)
        {
            ll tmp = pre[max(i-arr[j].first+1,0LL)]-pre[max(i-arr[j].second,0LL)];
            dp[i] = (dp[i] + tmp + MOD )%MOD;
        }  
        pre[i+1]=(pre[i]+dp[i])%MOD;
    }
    cout << dp[n-1];
    return 0;
}

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

int main(){

    int n;
    cin >> n;

    vector<int> a(100001,0);

    rep(i,n){
        int t;
        cin >> t;
        a[t]++;
    }

    int te=0;

    rep(i,100001){
        if(a[i]>1){
            te+=a[i]-1;
        }
    }

    if(te%2==1){
        te++;
    }

    cout << n-te << endl;

    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll Pow_mod(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

ll Division_mod(ll n,ll m){
	return n*Pow_mod(m,mod-2)%mod;
}

int n;
string s;

int main(){
	cin>>n>>s;
	int S=s.size();
	vl dp(n+1);
	dp[0]=1;
	for(int i=0;i<n;i++){
		vl DP(n+1);
		DP[0]=dp[0];
		for(int j=0;j<=n;j++){
			if(j) (DP[j]+=2*dp[j-1])%=mod;
			if(j!=n) (DP[j]+=dp[j+1])%=mod;
		}
		dp=DP;
	}
	cout<<Division_mod(dp[S],Pow_mod(2,S))<<endl;
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(){
	while(1){
		int total = 0, cut = 0;
		cin >> total;
		if(total == 0) break;
		total = 1000 - total;
		cut += total / 500;
		total = total % 500;
		cut += total / 100;
		total = total % 100;
		cut += total / 50;
		total = total % 50;
		cut += total / 10;
		total = total % 10;
		cut += total / 5;
		total = total % 5;
		cut += total / 1;
		cout << cut << endl;
	}
	return 0;
}

Measured memory_bytes: 3044
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define what_is(x) cerr << #x << " = " << x << endl;
typedef long long ll;
ll pra[1000009];
ll prb[1000009];
int main()
{
    fastIO
    ll n,m,k;

    cin>>n>>m>>k;

    vector<ll>a(n);
    vector<ll>b(m);
    pra[0]=0;
    prb[0]=0;
    for (int i=0; i<n; ++i)
        cin>>a[i],pra[i+1]=pra[i]+a[i];
    for (int i=0; i<m; ++i)
        cin>>b[i],prb[i+1]=prb[i]+b[i];

    ll ans1=0,j=m;
    for ( int i=0; i<=n; ++i)
    {
        if (pra[i]>k)
            break;
        while(pra[i]+prb[j]>k)
            --j;

        ans1=max(ans1,j+i);
    }
    cout<<ans1;


}


Measured memory_bytes: 9520
N,K =map(int,input().split())
S = list(input())
if S[K-1]=="A":
    S[K-1] = "a"
if S[K-1]=="B":
    S[K-1] = "b"
if S[K-1]=="C":
    S[K-1] = "c"
print("".join(S))

Measured memory_bytes: 3060
program redistribution
  implicit none
  integer :: s
  integer(8) :: m(3, 3) = 0
  read(*,*) s
  if (s < 6) then
    write(*,'(i0)') s / 3
    stop
  end if
  m(1, 1) = 1
  m(2, 1) = 1
  m(3, 2) = 1
  m(1, 3) = 1
  m = modmatpow(m, s - 6)
  write(*,'(i0)') mod(m(1, 1) + m(1, 1) + m(1, 2) + m(1, 3), 1000000007_8)
contains
  function modmatmul(x, y) result(res)
    integer(8), parameter :: modu = 1000000007_8
    integer(8), intent(in) :: x(3, 3), y(3, 3)
    integer(8) :: tmp, res(3, 3)
    integer :: i, j, k
    do j = 1, 3
      do i = 1, 3
        res(i, j) = 0
      end do
      do k = 1, 3
        tmp = y(k, j)
        do i = 1, 3
          res(i, j) = mod(res(i, j) + x(i, k) * tmp, modu)
        end do
      end do
    end do
  end
  function modmatpow(x, n) result(res)
    integer(8), intent(in) :: x(3, 3)
    integer, intent(in) :: n
    integer(8) :: res(3, 3), tmp(3, 3)
    integer :: m
    res(1, 1) = 1
    res(2, 1) = 0
    res(3, 1) = 0
    res(1, 2) = 0
    res(2, 2) = 1
    res(3, 2) = 0
    res(1, 3) = 0
    res(2, 3) = 0
    res(3, 3) = 1
    tmp = x
    m = n
    do while (m > 0)
      if (btest(m, 0)) res = modmatmul(res, tmp)
      tmp = modmatmul(tmp, tmp)
      m = rshift(m, 1)
    end do
  end
end program redistribution

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

typedef long long ll;
#define REP(i, n, m) for(int i = n; i < m; i++)
#define REPR(i, n, m) for(int i = n; i >= m; i--)
#define LREP(i, n, m) for(ll i = n; i < m; i++)
#define LREPR(i, n, m) for(ll i = n; i >= m; i--)

#define P pair<ll, ll >


const ll INF = 1e9 + 1;
const int MOD = 1e9 + 7;



//---functions---//
int gcd(int a, int b){
    if(a < b) swap(a, b);
    return b?gcd(b, a%b):a;
}

int s2i(string num){stringstream ss; ss << num << flush; int n; ss >> n; return n;}
string i2s(int n){stringstream ss; ss << n << flush; return ss.str();}

bool firstCompare(const P& firstElof, const P& secondElof){
    return firstElof.first < secondElof.first;
}
bool secondCompare(const P& firstElof, const P& secondElof){
    return firstElof.second < secondElof.second;
}
//---------------//
//-----class-----//
class UnionFind{
    public:
        vector<ll> par; //parents
        vector<ll> siz; // sizes of set
        vector<ll> rank; // rank of each element 
    UnionFind(ll n): par(n), siz(n, 1LL), rank(n){
        LREP(i, 0, n) par[i] = i;
    }
    //initialization
    /*
    void init(ll n){
        par.assign(n);
        siz.assign(n, 1LL);
        rank.assign(n);
        LREP(i, 0, n) par[i] = i;
    }
    */

    // find the root of x
    ll find(ll x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    //Unite two set including x or y
    void unite(ll x, ll y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(rank[x] < rank[y]){
            par[x] = y;
            siz[y] += siz[x];
        }else{
            par[y] = x;
            siz[x] += siz[y];
            if(rank[x] == rank[y]) rank[x]++;
        }
    }

    //Do x and y belong to the same set?
    bool issame(ll x, ll y){
        return find(x) == find(y);
    }

};

struct edge{ll to, cost;};
ll V, E;
int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cin >> V >> E;
    vector<edge> G[V];
    LREP(i, 0, E){
        ll s, t, w;
        edge e;
        cin >> s >> t >> w;
        e.to = t; e.cost = w;
        G[s].push_back(e);
        e.to = s;
        G[t].push_back(e);
    }
    priority_queue<P, vector<P>, greater<P>> q;
    q.push(P(0, 0));
    ll d[V];
    LREP(i, 0, V) d[i] = INF;
    d[0] = 0;
    ll ans = 0;
    while(!q.empty()){
        ll cost = q.top().first;
        ll v = q.top().second;
        q.pop();
        if(d[v] < cost) continue;
        ans += cost;
        d[v] = -INF;
        LREP(i, 0, G[v].size()){
            if(d[G[v][i].to] > G[v][i].cost){
                d[G[v][i].to] = G[v][i].cost;
                q.push(P(d[G[v][i].to], G[v][i].to));
            }
        }
    }
    cout << ans << '\n';
}



Measured memory_bytes: 8916
#include<stdio.h>
#include <string.h>
#include <stdlib.h>

int main (){
  
 int a,b,k,i,j,count,ans;
  scanf("%d",&a);
  
  
  if(a % 2 == 0){
    printf("%d",a);
  }else{
    printf("%d",a*2);
  }
  

    
  
      return 0;
  
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int N=S.size();
  vector<char> q;
  for(int i=0;i<N;i++){
    q.push_back(S.at(i));
  }
  int ans1=0;
  int ans2=0;
  vector<char> a,b;
  for(int j=0;j<N;j++){
    if(j%2==0){
      a.push_back('1');
    }else{a.push_back('0');
    }
  }
  for(int k=0;k<N;k++){
    if(k%2==0){
      b.push_back('0');
    }else{b.push_back('1');
    }
  }
  for(int l=0;l<N;l++){
    if(q.at(l)!=a.at(l)){
      ans1++;
    }
  }
  for(int m=0;m<N;m++){
    if(q.at(m)!=b.at(m)){
      ans2++;
    }
  }
  cout << min(ans1,ans2) << endl;
}

Measured memory_bytes: 896
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	s := nextStr()

	for i := range s {

		fmt.Printf("%c", 'A'+(int(s[i])+n-'A')%('Z'-'A'+1))

	}

}

// ---- readfunc
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

int main(){
	int a,b,i = 0,c[200];
	while(cin >> a >> b){
		c[i] = a + b;
		i++;
	}
	for(int j = 0; j < i ; j++){
		int res = 0;
		while(c[j] > 0){
			res++;
			c[j] /= 10;
		}
		cout << res << endl;
	}
}


Measured memory_bytes: 3008
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a , b ;
  cin >> a>> b;
  string c = a+b;
  int n = stoi(c);
  bool ans =false;
  for(int i=1;i<n;i++){
    int nn =i*i;
    if( nn == n){
      ans =true;
    }
  }
  cout  << (ans ? "Yes":"No");
      
}

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

int main()
{
	LL n;
	string s;
	cin >> n >> s;
	LL cnt = 0;
	for (LL i = 0; i < n-2; ++i) {
		if (s.substr(i, 3) == "ABC") {
			cnt++;
		}
	}

	cout << cnt << endl;



}

Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  n = input[0].split(" ").map(Number);
  a = input[1].split(" ").map(Number);
  var odd = true;
  var ans = 0;
  while(odd){
    for(var i=0;i<n[0];i++){
      if(a[i]%2!=0){
        odd = false;
      }
      a[i] = a[i]/2;
    }
    if(odd){
      ans++;
    }
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n;
    cin >> n;
    vector<int> a(n + 1), b(n + 1, 0), c;
    rep(i, 1, n + 1) cin >> a[i];
    int k = 2, cnt = 0, ans = 0;
    for (int i = n; i >= 1; --i) {
        k = 2;
        cnt = 0;
        while(i * k <= n){
            if(b[i * k] == 1){
                cnt++;
            }
            k++;
        }
        if(cnt % 2 == 0){
            if(a[i] == 1){
                b[i] = 1;
                c.push_back(i);
                ans++;
            }
        }else{
            if(a[i] == 0){
                b[i] = 1;
                c.push_back(i);
                ans++;
            }
        }
    }
    cout << ans << endl;
    if(c.size() == 0){
        return 0;
    }
    rep(i, 0, c.size() - 1){
        cout << c[i] << " ";
    }
    cout << c[c.size() - 1] << endl;
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<string.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int x[100001],y[100001];
int t[100001]={};
int main() {

	int n;
	int x2=0,y2=0,t2=0;

	cin>>n;
	rep(i,n){
		cin>>t[i+1]>>x[i+1]>>y[i+1];
		t2=t[i+1];
		t2-=t[i];
		if((t2-(abs(x[i+1]-x2)+(y[i+1]-y2)))%2==0&&t2>=(abs(x[i+1]-x2)+(y[i+1]-y2))){
			x2=x[i+1];
			y2=y[i+1];
		}else{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ordered_set tree<ll int, null_type,less<ll int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005
ll dp[3003][3003];
vi v(3003);
void solve(ll i,ll j)
{
    if(dp[i][j]!=-peak)
        return;
    if(i==j)
    {
        dp[i][i]=v[i];
        return;
    }
    ll x1,x2;
    solve(i+1,j);
    solve(i,j-1);
    x1=v[i]-dp[i+1][j];
    x2=v[j]-dp[i][j-1];
    dp[i][j]=max(x1,x2);
    return;
}
int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
        ll i,j,k,l,m,n;
        cin>>n;
        for(i=0;i<n;i++)
            cin>>v[i];
        for(i=0;i<n;i++)
        {
            for(j=0;j<n;j++)
            {
                dp[i][j]=-peak;
            }
        }
        solve(0,n-1);
        cout<<dp[0][n-1];
    }
    return 0;
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 4611686018427387903;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

const int w=8;
const int k=430;
const int n=26;
int d;

VI c(n);
VVI s(365,VI(n));

struct st{
	VI a;
	ll score;
	bool operator<(const st &another) const {return score < another.score;};
};

vector<st> f(st p){
	VI a=p.a; ll score=p.score;
	int now=a.size()+1;
	VI last(n,0);
	REP(i,a.size())
		last[a[i]]=i+1;
	VI down(n); ll downsum=0;
	REP(i,n){
		down[i]=c[i]*(now-last[i]);
		downsum+=down[i];
	}
	a.push_back(-1);
	vector<st> tmp;
	REP(i,n){
		a[now-1]=i;
		tmp.push_back({a,score-downsum+down[i]+s[now-1][i]});
	}
	sort(ALL(tmp));
	vector<st> ret;
	REP(i,w)
		ret.push_back(tmp[n-1-i]);
	return ret;
}


int main(){
	cin >> d;
	REP(i,n) cin >> c[i];
	REP(i,d)REP(j,n) cin >> s[i][j];
	priority_queue<st> q;
	VI a(0);
	q.push({a,0});
	REP(i,d){
		priority_queue<st> next;
		REP(j,k){
			if(q.empty())
				break;
			for(auto nx:f(q.top()))
				next.push(nx);
			q.pop();
		}
		q=next;
	}
	REP(i,d)
		cout << q.top().a[i]+1 << endl;
	return 0;
}

Measured memory_bytes: 27592
#include<iostream>
#define ll long long
#define pb push_back
#define mp make_pair

int main(){
std::string s,t;
std::cin >> s;
std::cin >> t;
int count=0;
for(int i=0;i<(int)s.size();i++){
    if(s[i]!=t[i])
         count++;
}
std::cout << count;
return 0;
}


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

int main(){
  ll n;
  cin >> n;
  ll ans = 1e14;
  for(ll i = 1;i <= 1e6;i++){
    if (n % i != 0)continue;
    ll temp = i + n/i - 2;
    ans = min(ans,temp);
  }
  cout << ans << endl;
}

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

using namespace std;

int ok;

int main()
{
    int n;
    char c;
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        cin>>c;
        if (c=='Y')
            ok=1;
    }
    if (ok==1)
        cout<<"Four";
    else cout<<"Three";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=b;
    ll lcm=c/__gcd(c,d)*d;
    ans-=b/c+b/d-b/lcm;
    ans-=a-1;
    ans+=(a-1)/c+(a-1)/d-(a-1)/lcm;
    cout<<ans<<endl;
}


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

const int inf = 1e9;
const ll linf = 1e18;

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

    ll h; cin >> h;
    cout << (1LL << __lg(h << 1)) - 1 << endl;
    return 0;
}

Measured memory_bytes: 256
/***

   Author : Md. Jashim Uddin
   From   : RMSTU

 ***/
#include<bits/stdc++.h>
using namespace std;
#define     sf(a)           scanf("%d",&a)
#define     sff(a,b)        scanf("%d %d",&a,&b)
#define     sfff(a,b,c)     scanf("%d %d %d",&a,&b, &c)
#define     pb              push_back
#define     pob             pop_back()
#define     ll              long  long int
#define     fast            ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define     pi              2*acos(0)
#define     sp              fixed<<setprecision
#define     lcm(a,b)        (a*b)/gcd(a,b)
#define     gcd(a,b)        _gcd(a,b)
#define     forn(i,n)       for(int i=1;i<=n;i++)
#define     mx  800005

int main()
{
    string s,ss; cin>>s;
    cin>>ss;
    ll c=0;
    for(int i=0;i<s.size();++i)
    {
        if(s[i]!=ss[i]) c++;
    }
    cout<<c<<'\n';

    return 0;
}


Measured memory_bytes: 3916
console.log((args=>{
  const S = args.trim();
  const L = S.length;
  const T = Array(L+1).fill(0);
  for ( let i = 0; i < L; i++ ) {
    if ( S[i] === '<' ) {
      T[i+1] = Math.max( T[i+1], T[i] + 1 );
    }
    if ( S[L-i-1] === '>' ) {
      T[L-i-1] = Math.max( T[L-i-1], T[L-i] + 1 );
    }
  }
  return `${T.reduce((a,b)=>a+b)}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 42548
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

class Point
{
public:
	double x, y;
};

class Circle
{
public:
	double x, y, r;
};

bool isInCircle(Point p, Circle c)
{
	double a = pow(p.x - c.x, 2.0) + pow(p.y - c.y, 2.0);
	if(a < c.r * c.r)
	{
		return(true);
	}
	else
	{
		return(false);
	}
}

bool isIntersectCircleAndLine(Point p1, Point p2, Circle c)
{
	if(isInCircle(p1, c) && isInCircle(p2, c)) 
	{
		return(false);
	}

	double vx1 = (c.x - p1.x);
	double vy1 = (c.y - p1.y);
	double vx2 = (p2.x - p1.x);
	double vy2 = (p2.y - p1.y);

	double n1 = vx1 * vx2 + vy1 * vy2;
	double n2 = vx2 * vx2 + vy2 * vy2;
	double n3 = vx1 * vx1 + vy1 * vy1;
	
	if(n1 < 0)
	{
		if(pow(p1.x - c.x, 2.0) + pow(p1.y - c.y, 2.0) <= c.r * c.r)
		{
			return(true);
		}
		else
		{
			return(false);
		}
	}
	else if(n1 > n2)
	{
		if(pow(p2.x - c.x, 2.0) + pow(p2.y - c.y, 2.0) <= c.r * c.r)
		{
			return(true);
		}
		else
		{
			return(false);
		}
	}
	else
	{
		if(n2 <= 0) 
		{
			if(n3 * n2 - n1 * n1 >= c.r * c.r * n2)
			{
				return(true);
			}
			else
			{
				return(false);
			}
		}
		else
		{
			if(n3 * n2 - n1 * n1 <= c.r * c.r * n2)
			{
				return(true);
			}
			else
			{
				return(false);
			}
		} 
	}
}

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<Circle> circle(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> circle[i].x >> circle[i].y >> circle[i].r;
		}
		int m;
		cin >> m;
		for(int i = 0; i < m; ++i)
		{
			Point taro, oni;
			cin >> taro.x >> taro.y >> oni.x >> oni.y;
			bool isSafe = false;
			for(int j = 0; j < circle.size(); ++j)
			{
				if(isIntersectCircleAndLine(taro, oni, circle[j]))
				{
					isSafe = true;
				}
			}
			if(isSafe)
			{
				cout << "Safe" << endl;
			}
			else
			{
				cout << "Danger" << endl;
			}
		}
	}
}

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

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

int main() {
    int n, k;
    string s;
    cin >> n >> k >> s;
    s[k-1] = s[k-1] + 0x20;
    cout << s << endl;
}

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

using pii = pair<int, int>;

int main() {
    int N;
    while(cin >> N, N) {
        vector<pii> v(N);
        int sum = 0;
        int kansou_sum = 0;
        for(int i=0; i<N; ++i) {
            cin >> v[i].first >> v[i].second;
            sum += v[i].first;
            kansou_sum += v[i].second;
        }
        sort(v.begin(), v.end());
        sum -= v.back().first;
        if(v.back().first > sum) {
            int t = 2 * v.back().first;
            vector<int> dp(v.back().first - sum + 1);
            dp[0] = 1;
            for(int i=0; i<N-1; ++i) {
                for(int j=dp.size()-1-v[i].second; j>=0; --j) {
                    dp[j+v[i].second] |= dp[j];
                }
            }
            int ma = 0;
            for(int j=dp.size()-1; j>=0; --j) {
                if(dp[j]) {
                    ma = j;
                    break;
                }
            }
            t += kansou_sum - ma;
            cout << t << endl;
        } else {
            int t = sum + v.back().first + kansou_sum;
            cout << t << endl;
        }
    }
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

void solve(){
    ll n;
    cin >> n;
    ll a[n+10];
    rep(i,n){
        cin >> a[i];
        a[i] = a[i] - i - 1;
    }
    /*
    long double avg;
    long double sum=0;
    rep(i,n){
        sum+=(long double)a[i];
    }
    avg = sum/n;
    ll t = ceil(avg);
    */
    //最初は平均値でやっていたが、どうやら平均値でなく中央値でやるのが最適らしい
    /*
    1 1 1 97
    avg=25 24*3+72=144
    med=1 96

    0 -1 -2 -3 -3 -3 -3
    */

    sort(a,a+n);
    int med;
    if(n%2==0){
        med = (a[n/2-1]+a[n/2])/2;
    }
    else{
        med = a[n/2];
    }

    ll s1,s2;
    s1=0;
    s2=0;
    rep(i,n){
        s1 += abs(a[i]-med);
    }
    rep(i,n){
        s2 += abs(a[i]-med+1);
    }

    cout << min(s1,s2) << endl;

}

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



Measured memory_bytes: 1792
import sys

lucas_nums = [None] * 101
lucas_nums[0] = 2
lucas_nums[1] = 1
for i in range(2, 101):
    lucas_nums[i] = lucas_nums[i-2] + lucas_nums[i-1]

n = int(sys.stdin.readline().rstrip())

def main():
    return lucas_nums[n]

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = 1001002003004005006ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, m;
	cin >> n >> m;
	ll res = min(n, m / 2);
	if (n >= m / 2) {
		cout << res << endl;
	}
	else {
		m -= 2 * n;
		res += m / 4;
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 3556
###abc157
###<a>ac
##n=int(input())
##print(n//2+n%2)

#<b> wa
import numpy as np
s=np.array([list(map(int,input().split())) for i in range(3)])
n=int(input())
for j in range(n):
    s=np.where(s==int(input()),0,s)
bingo1=min(np.sum(s,axis=0))==0
bingo2=min(np.sum(s,axis=1))==0
bingo3=s[2][0]==0 and s[1][1]==0 and s[0][2]==0
bingo4=s[0][0]==0 and s[1][1]==0 and s[2][2]==0
if bingo1 or bingo2 or bingo3 or bingo4:
    print("Yes")
    exit()
print("No")


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

using namespace std;

typedef long long ll;
#define em emplace_back

bool ok(ll x, ll y, ll z) {
	return ((x*x)+(y*y))<=(z*z);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n, d;
	cin >> n >> d;
	ll ans = 0;
	for (ll i=0, x, y; i<n; i++){ 
		cin >> x >> y;
		ans += ok(abs(x), abs(y), d);
	}
	cout << ans << '\n';
	return 0;
}


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

using namespace std;

string s;

bool parseCat(int &p)
{
  if(s[p] != 'm') return false;
  p++;
  if(s[p] == 'w') return false;
  if(s[p] != 'e'){
    if(!parseCat(p)) return false;
  }
  if(s[p] != 'e') return false;
  p++;
  if(s[p] == 'w'){ p++; return true;}
  if(s[p] == 'e') return false;
  if(!parseCat(p)) return false;
  if(s[p] == 'w'){ p++; return true;}
  return false;
}

int main(){
  cin >> s;
  int p = 0;
  if(parseCat(p) && p == s.size()) cout << "Cat" << endl;
  else cout << "Rabbit" << endl;
  return 0;
}



Measured memory_bytes: 3224
import math
firstInp = input()
num = int(firstInp.split()[0])
distance = int(firstInp.split()[1])

answer = 0
for i in range(num):
    inp = input()
    x = int(inp.split()[0])
    y = int(inp.split()[1])
    kyori = math.sqrt(x ** 2 + y ** 2)
    if kyori <= distance:
        answer += 1
print(answer)

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

using namespace std;

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

	sort(a, a + N);

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

	cout << output << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
typedef pair<double,double> Pd;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,(n))
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) rrepi(i,(n),0)
#define rrepi(i,a,b) for(ll i=(a);i>=(b);i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const double Pi = acos(-1);
const ll INF=1e18;
const int iINF = 1e9;

int main(){
  double a,b,x;
  cin>>a>>b>>x;
  double vol = a * a * b, tmp = (vol - x)/(a*a) * 2;
  double ans = 90 - (atan2(a,tmp) * 180.0 / Pi);

  if(vol >= x*2){
    tmp = x/(a*b) * 2;
    ans = (atan2(b,tmp) * 180.0 / Pi);
  }


  printf("%.10f\n",ans); 
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<int,int>
const int M=100010;
const int MOD=1000000007;
const long long INF=1000000007;
using ll=long long;

int main() {
	int W,H,ans=0;
	char s[55][55];
	cin>>H>>W;
	rep(j,1,H+1)rep(i,1,W+1){
		cin>>s[i][j];
		if(s[i][j]=='.')ans++;
	}
	//BFS;
	int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
	queue<P> que;
	int dist[55][55];
	rep(j,1,H+1)rep(i,1,W+1)dist[i][j]=INF;
	dist[1][1]=1;
	que.push(P(1,1));
	while(que.size()){
		P p=que.front();
		que.pop();
		rep(i,0,4){
			int next_x=p.first+dx[i];
			int next_y=p.second+dy[i];
			if(s[next_x][next_y]=='.'&&
				next_x>0&&next_x<=W&&
				next_y>0&&next_y<=H&&
				dist[next_x][next_y]==INF){
				que.push(P(next_x,next_y));
				dist[next_x][next_y]=dist[p.first][p.second]+1;
			}
		}
	}
	if(dist[W][H]==INF)cout<<"-1"<<endl;
	else cout<<ans-dist[W][H]<<endl;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;

    Main() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int D = sc.nextInt();
        int X = sc.nextInt();
        int ans = 0;
        for (int i = 0; i < N; i++) {
            int num = sc.nextInt();
            for (int k = 0; k < 100; k++)
                if (k * num + 1 <= D)
                    ans++;
                else
                    break;
        }
        System.out.println(ans+X);
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 22996