akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

int main()
{
    double x[20],y[20];
    int n=0;
    char t;
    while(cin>>x[n]>>t>>y[n])
    {
        n++;
    }
    double s=0;
    double a,b,c,z;
    for(int i=1;i<n-1;i++)
    {
        a = sqrt((x[0]-x[i])*(x[0]-x[i])+(y[0]-y[i])*(y[0]-y[i]));
        b = sqrt((x[0]-x[i+1])*(x[0]-x[i+1])+(y[0]-y[i+1])*(y[0]-y[i+1]));
        c = sqrt((x[i]-x[i+1])*(x[i]-x[i+1])+(y[i]-y[i+1])*(y[i]-y[i+1]));
        z = (a+b+c)/2;
        s+= sqrt(z*(z-a)*(z-b)*(z-c));
    }
    printf("%.6f\n",s);
    return 0;
}

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

// 型名の省略
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> P;
typedef pair<lint, lint> Plint;
 
const int MOD = 1e9+7;
const int INF = 1<<18;
const lint INFLINT = 1LL<<60;
const double PI=acos(-1.0);
 
// cinとcoutの高速化
#define endl "\n"
struct cinacc{cinacc(){cin.tie(0);ios::sync_with_stdio(false);}}cinaccc;
struct coutacc{coutacc(){cout.setf(ios::fixed);cout.precision(12);}}coutaccc;
 
// 繰り返し
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define reps(i,n) for(lint i=0;i<=(lint)(n);i++)
#define rrep(i,n) for(lint i=(lint)(n)-1;i>0;i--)
#define rreps(i,n) for(lint i=(lint)(n)-1;i>=0;i--)

#define pb push_back

#define ALL(s) (s.begin(), s.end())
#define SZ(s) (s.size())

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

// Union-Find-Tree
class UnionFind {
	vector<int> par;
	UnionFind(int n):par(n){rep(i,n)par[i]=i;}
	int root(int x){if(par[x]==x)return x;return par[x]=root(par[x]);}
	void unite(int x,int y){int rx=root(x);int ry=root(y);if(rx==ry)return;par[rx]=ry;}
	bool same(int x,int y){return root(x)==root(y);}
};

// Final Weapon!
// #define int lint

int main() {
    int a, b, x, y, n, m;
    string s;
    
    cin >> n;
    switch(n%10) {
        case 2: case 4: case 5: case 7: case 9:
        cout << "hon"; break;
        case 0: case 1: case 6: case 8:
        cout << "pon"; break;
        case 3:
        cout << "bon"; break;
    }
    
    return 0;
}


Measured memory_bytes: 3648
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
  ll n,k;
  cin>>n>>k;
  ll r=n%k;
 ll ans=min(r,k-r);
  cout<<ans<<endl;
}


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

int solve(){
	
}


int main(){

	ll i,j,k,l,n,m,t,a,b,c;

	string s;
	cin>>s;
	cin>>k;
	ll ans=0;
	if(s[0]!=s[s.size()-1]){

		for(i=0;i<(ll)s.size();++i){
			l=1;
			while(i+1<(ll)s.size()&&s[i]==s[i+1]){
				i++;
				l++;
			}
			ans+=l/2;
		}
		cout<<k*ans;
	}else{

		if(k==1){
		for(i=0;i<(ll)s.size();++i){
			l=1;
			while(i+1<(ll)s.size()&&s[i]==s[i+1]){
				i++;
				l++;
			}
			ans+=l/2;
		}
		cout<<k*ans;

		}else{
			vector<ll> V;
			for(i=0;i<(ll)s.size();++i){
				l=1;
				while(i+1<(ll)s.size()&&s[i]==s[i+1]){
					i++;
					l++;
				}
				V.push_back(l);
			}
			if(V.size()==1){
				cout<<(V[0]*k)/2;
				return 0;
			}
			for(i=0;i<(ll)V.size()-1;++i)ans+=V[i]/2;
			ans+=V[V.size()-1]/2;
			V[0]+=V[V.size()-1];
			ll sum=0;
			for(i=0;i<(ll)V.size()-1;++i)sum+=V[i]/2;
			cout<<ans+(k-1)*sum;

		}


	}


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,ans;
  char op;
  while(1){
    scanf("%d %c %d",&a,&op,&b);
    if(op=='?')break;
    if(op=='+')ans=a+b;
    if(op=='-')ans=a-b;
    if(op=='*')ans=a*b;
    if(op=='/')ans=a/b;
    printf("%d\n",ans);
  }
  return(0);
}

Measured memory_bytes: 600
#include <iostream>
#include <cmath>

using namespace std;
int main (){
    int n;
    cin >> n;
    int sum=n;
    int l[n],r[n];
    for (int i = 0; i < n; i++)
    {
        cin >> l[i] >> r[i];
    }
    for (int i = 0; i < n; i++)
    {
        sum+=r[i]-l[i];
    }
    cout << sum << "\n";
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 
	
void solve(){
   int a; char b;
   string input;
   map<string, int> m;
   while(cin >> a >> b >> input){
	    m[input]++;  
	 }
   cout << m["A"] << endl;
   cout << m["B"] << endl;
   cout << m["AB"] << endl;
   cout << m["O"] << endl;  
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



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

int main() {
  int n;
  cin >> n;
  vector<ll> ans(n + 1, 0);
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        ll sum = i * i + j * j + k * k + i * j + j * k + k * i;
        if (n >= sum) ans[sum]++;
      }
    }
  }

  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3548
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	ll n, k;
	cin >> n >> k;

	vector<ll> a(n);
	for (ll i = 0; i < k; i++)
	{
		ll d;
		cin >> d;
		for (ll j = 0; j < d; j++)
		{
			ll x;
			cin >> x;

			a[x - 1]++;
		}
	}

	ll cnt = 0;
	for (ll i : a)
	{
		if (i == 0)
		{
			cnt++;
		}
	}

	println(cnt);
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
  int n;
  cin >> n;
  string s[n];
  for (int i=0;i<n;i++) cin >> s[i];
  ll tot=0;
  int enda=0,firb=0,bothn=0;
  
  for (int i =0;i<n;i++){
    int len=s[i].length();
    if (s[i][0] == 'B'){
      firb += 1;
    }
    if (s[i][len-1] == 'A'){
      enda += 1;
    }
    if (s[i][0] == 'B' && s[i][len-1] == 'A') bothn += 1;
    for (int j =0;j<len-1;j++){
      if (s[i][j] == 'A' && s[i][j+1] == 'B'){
	tot += 1;
      }
    }
  }
  if (bothn == enda && bothn == firb && bothn > 0){
    tot += bothn - 1;
  }else{
    tot += min(firb,enda);
  }
  cout << tot;
}

Measured memory_bytes: 896
#include <stdio.h>
#include <cctype>

int main(void){

	char str[1201];
	int i=0;
	int n=0;
	
	while(1){
		scanf("%c",&str[i]);
		n++;
		if(str[i]=='\n'){
			break;
		}
		if(islower(str[i])){
			str[i]=toupper(str[i]);
		}else if(isupper(str[i])){
			str[i]=tolower(str[i]);
		}
		i++;
	}
	
	for(i=0;i<n;i++){
		printf("%c",str[i]);
	}	
	
	return 0;
}

Measured memory_bytes: 2616
#include <stdio.h>
int main(void)
{
	int n, jap, eng, mat, i,all,all2;
	while (1)
	{
		scanf("%d", &n);
		if (n == 0)
			break;
		for (i = 0; i < n; i++)
		{
			scanf("%d %d %d", &mat, &eng, &jap);
			all = (mat + eng + jap) / 3;
			all2 = (mat + eng) / 2;
			if (mat == 100 || eng == 100 || jap == 100)
				{
				printf("A\n");
				}
			else if (all2 >= 90)
			{
				printf("A\n");
			}
			else if (all >= 80)
			{
				printf("A\n");
			}
				else if (all >= 70)
				{
					printf("B\n");
				}
				else if (all >= 50)
				{
					if (mat >= 80 || eng >= 80)
						printf("B\n");
					else
					{
						printf("C\n");
					}
				}
				else
				{
					printf("C\n");
				}
		}

	}
	return 0;
}

Measured memory_bytes: 584
n = int(input())
p_taro = 0
p_hanako = 0
for i in range(n):
	taro, hanako = map(str, input().split())
	cards = tuple(sorted((taro, hanako)))
	#print(cards)

	if taro == hanako:
		p_taro += 1
		p_hanako += 1
	else:
		if cards == (taro, hanako):
			p_hanako += 3
			#print("hanako win")
		else:
			p_taro += 3
			#print("taro win")

print(p_taro, p_hanako)

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

ll get_ans(ll a, ll b)
{
    ll res = a - 1;
    b -= a - 1;
    a = 1;
    res++;
    b--;
    return res + (b - 1) / 2;
}

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    if (a % 2 == b % 2)
    {
        cout << (b - a) / 2 << '\n';
    }
    else
    {
        cout << min(get_ans(a, b), get_ans(n - b + 1, n - a + 1)) << '\n'; 
    }

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#define llint long long
#define inf 1e18

using namespace std;

llint n;
llint a, b, c, d;

int main(void)
{
	bool flag = true;
	while(1){
		cin >> n;
		if(n == 0) break;
		cin >> a >> b >> c >> d;
		
		llint ans = inf, aa, bb, cc, dd;
		for(int i = 0; i <= a; i++){
			for(int j = 0; j <= b; j++){
				for(int k = 0; k <= c; k++){
					for(int l = 0; l <= d; l++){
						llint x = l*500+k*100+j*50+i*10;
						if(x < n) continue;
						llint ex = x - n;
						llint A = ex / 500; ex %= 500;
						llint B = ex / 100; ex %= 100;
						llint C = ex / 50; ex %= 50;
						llint D = ex / 10;
						if(l*A || k*B || j*C || i*D) continue;
						
						llint tmp = (a-i)+(b-j)+(c-k)+(d-l)+A+B+C+D;
						if(ans > tmp){
							ans = tmp;
							aa = i, bb = j, cc = k, dd = l;
						}
					}
				}
			}
		}
		if(!flag) cout << endl;
		flag = false;
		if(aa > 0) cout << 10 << " " << aa << endl;
		if(bb > 0) cout << 50 << " " << bb << endl;
		if(cc > 0) cout << 100 << " " << cc << endl;
		if(dd > 0) cout << 500 << " " << dd << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3076
//おまじない
//#include <bits/stdc++.h>
#include <iostream>
#include<iomanip>
#include <map>
#include <set>
#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 all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
#define pll pair<ll,ll>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

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

const int maxn = 10000;

int main(){
    
    int N;
    ll sum_1=0,sum_2=0;
    ll a[maxn],b[maxn];
    
    cin >> N;
    rep(i,N)cin >> a[i];
    rep(i,N)cin >> b[i];
    
    rep(i,N){
        if(a[i]>b[i])sum_1+=a[i]-b[i];
        else if(a[i]<b[i])sum_2+=(b[i]-a[i])/2;
    }
    
    if(sum_1<=sum_2)cout << "Yes"<<endl;
    else cout << "No"<<endl;
    
    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

bool sign(int num) {
	if (num >= 0) return true;
	return false;
}

int main() {
	int x, y;
	cin >> x >> y;

	long int ans;

	if (sign(x)) {
		if (sign(y) && y != 0 ) {
			if (x <= y) {
				ans = y - x;
			}
			else {
				ans = x - y + 2;
			}
		}
		else {
			ans = abs(x - abs(y)) + 1;
		}
	}
	else {
		if (sign(y) && y != 0 ) {
			ans = abs(abs(x) - y) + 1;
		}
		else {
			if (x <= y) {
				ans = abs(x) - abs(y);
			}
			else {
				ans = abs(y) - abs(x) + 2;
			}
		}
	}
	cout << ans << endl;
}


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

const int INF = 1000000000;

int main() {
	int h, n; cin >> h >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i) >> b.at(i);
	}
	vector<vector<int>> dp(n + 1, vector<int>(h + 1));
	dp.at(0).at(0) = 0;
	for (int j = 1; j <= h; j++) {
		dp.at(0).at(j) = INF;
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= h; j++) {
			dp.at(i).at(j) = min( dp.at(i - 1).at(j), dp.at(i).at( max(j - a.at(i - 1), 0 ) )+ b.at(i - 1) );
		}
	}
	cout << dp.at(n).at(h) << endl;
}

Measured memory_bytes: 39424
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int k,s;cin>>k>>s;
  int res=0;
  rep(i,k+1)rep(j,k+1){
    if(s-i-j>=0&&s-i-j<=k)res++;
  }
  cout<<res<<endl;

  return 0;

}


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

t1 = [0] * N
for i in range(N):
    for j in range(i+1,N):
        if A[i] > A[j]: t1[i] += 1

t2 = [0] * N
for i in range(N):
    for j in range(N):
        if A[i] > A[j]: t2[i] += 1

ans = 0
for i in range(N):
    ans += K*t1[i] + (K*K - K + 1) // 2 * t2[i]
    ans %= (10**9+7)
print(ans)

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

using ld = long double;
ld henkaku(ld x, ld y) {
  return atan2(y, x);
}

using ll = long long;
struct Pos {
  ll x, y;
  ld p;
};

ld dist(ld x, ld y) {
  return sqrt(x*x+y*y);
};

int main() {
  int n; cin >> n;
  vector<Pos> lp;
  for (int i = 0; i < n; ++i) {
    int x, y; 
    cin >> x >> y;
    if (x == 0 && y == 0) continue;
    lp.push_back((Pos){x, y, henkaku(x,y)});
  }
  sort(lp.begin(), lp.end(), [&](auto &l, auto &r){
    return l.p < r.p;
  });
  int n2 = lp.size();
  ld ans = 0;
  for (int i = 0; i < n2; ++i) {
    ll x = 0, y = 0;
    for (int j = 0; j < n2; ++j) {
      Pos &p = lp[(i+j)%n2];
      x += p.x; y += p.y;
      ans = max(ans, dist(x,y));
    }
  }
  cout << fixed << setprecision(15) << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n, a, b, c, d; cin >> n >> a >> b >> c >> d;
  string s; cin >> s;
  for (ll i=a-1; i<max(c,d)-2; i++) if (s[i]=='#' && s[i+1]=='#') {cout << "No" << endl; return 0;}
  if (c < d) cout << "Yes" << endl;
  else {
    for (ll i=b-1; i<d; i++) if (s[i-1]=='.' && s[i]=='.' && s[i+1]=='.') {cout << "Yes" << endl; return 0;}
    cout << "No" << endl;
  }
  return 0;
}


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

int main(){
	int n,lim,*ice,buf,pg,ov,sz,h=0;
	queue<int> q;
	
	cin >> n >> lim;
	
	ice = new int[n+2];
	ice[0] = ice[n+1] = 0;
	for(int i = 1; i < n+1; i++){
		cin >> ice[i];
	}
	
	for(int i = 1; i < n+1; i++){
		if((ice[i] > ice[i-1]) && (ice[i] > ice[i+1])){
			q.push(i);
		}
	}
	
	while(1){
		buf = q.front();
		pg = (lim - ice[buf]) > 0?(lim - ice[buf]):0;
		
		sz = q.size();
		for(int i = 0; i < sz; i++){
			buf = q.front();
			q.pop();
			
			ice[buf] += pg;
			ov = (ice[buf] - lim) >= 0?(ice[buf] - lim):-1;
			
			if(ov != -1){
				ice[buf] = 0;
				
				if(ice[buf-1] > ice[buf-2]){
					ice[buf-1] += ov;
					q.push(buf-1);
				}
				if(ice[buf+1] > ice[buf+2]){
					ice[buf+1] += ov;
					q.push(buf+1);
				}
			}else{
				q.push(buf);
			}
		}
		h += pg;
		
		if(q.empty()){
			break;
		}
	}
	
	cout << h << endl;
	
	return 0;
}

Measured memory_bytes: 1416
a = input()
q = int(input())
s = [input().split() for i in range(q)]

for i in range(q):
    if s[i][0] == "print":
        print(a[int(s[i][1]) : int(s[i][2])+1])
    elif s[i][0] == "reverse":
        a = a[: int(s[i][1])] + a[int(s[i][1]) : int(s[i][2]) + 1][::-1] + a[int(s[i][2]) + 1 :]   
    elif s[i][0] == "replace":
        a = a[: int(s[i][1])] + s[i][3] + a[int(s[i][2])+1 :]
        


Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string S;
    cin >> S;

    int N = S.length();
    int answer = 999;

    for (int i = 0; i < N-2; i++){
        int n = stoi(S.substr(i, 3));
        answer = min(answer, abs(753-n));
    }
    cout << answer << endl;
}

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

using namespace std;

int main() {
	int N; //Number of days in vac
	int M; //Number of Assignments 
	
	cin >> N >> M;
	int a{0};
	int result{0};
	
	while(M--) {
		cin >> a;
		result += a;
	}
	
	int fin = N - result;
	
	if ( fin >= 0) {
		cout << fin << "\n";
	}
	else {
		cout << "-1" << "\n";
	}
	return 0;
	
}

Measured memory_bytes: 3616
#include<stdio.h>

int main(){
    int n,i,j,k;
    double y;

    scanf("%d %lf",&n,&y);

    for(i=0;i<=n;i++){
        for(j=0;j<=n-i;j++){
            for(k=0;k<=n-i-j;k++){
                if(10000*i+5000*j+1000*k==y && n==i+j+k){
                    printf("%d %d %d",i,j,k);
                    return 0;
                }
            }
        }
    }
    printf("-1 -1 -1");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <string>
#include <cstring>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>
#include <tuple>

using namespace std;
mt19937_64 rng(58);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int h, w;
    cin >> h >> w;
    vector<string> grid(h);
    for (int i = 0; i < h; i++) cin >> grid[i];
    vector<vector<int>> dp(h, vector<int>(w));
    dp[0][0] = grid[0][0] == '#' ? 1 : 0;
    for (int i = 1; i < w; i++) {
        dp[0][i] = dp[0][i - 1];
        if (grid[0][i] == '#' && grid[0][i-1] == '.')
            dp[0][i]++;
    }
    for (int i = 1; i < h; i++) {
        dp[i][0] = dp[i - 1][0];
        if (grid[i][0] == '#' && grid[i - 1][0] == '.')
            dp[i][0]++;
    }
    for (int i = 1; i < h; i++) {
        for (int j = 1; j < w; j++) {
            dp[i][j] = min(
                dp[i - 1][j] + ((grid[i][j] == '#' && grid[i - 1][j] == '.') ? 1 : 0),
                dp[i][j - 1] + ((grid[i][j] == '#' && grid[i][j - 1] == '.') ? 1 : 0)
            );
        }
    }
    cout << dp[h - 1][w - 1] << "\n";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  
  cin >> s;
  
  int count = 0;
  for(int i = 0; i < s.size(); i++) {
    if (s[i] == '1') count++;
  }
  
  cout << count << endl;
  
  return 0;
}

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

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
    int b = sc.nextInt();
    double c = sc.nextInt();

		if(a/c > b){
      System.out.println("No");
    }else{
      System.out.println("Yes");

    }
		
	}
}

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

using ll = long long;

set<int> solve() {
	int N; cin >> N;
	if (N == 3) return set<int>{2, 5, 63};
	if (N == 4) return set<int>{2, 5, 20, 63};
	set<int> res;
	for (int i = 1; i <= 30000; i++) {
		if (i % 6 != 1 && i % 6 != 5) res.insert(i);
	}
	vector<int> mi{6, 1, 2, 3, 4, 5};
	N = 20000 - N;
	for (int i = 1; i < N; i+=2) {
		if (i / 2 % 4 == 0) {
			res.erase(mi[0]); res.erase(mi[0]+6);
			mi[0] += 12;
		} else if (i / 2 % 4 < 3) {
			res.erase(mi[2]); res.erase(mi[4]);
			mi[2] += 6; mi[4] += 6;
		} else {
			res.erase(mi[3]); res.erase(mi[3]+6);
			mi[3] += 12;
		}
	}
	if (N & 1) res.erase(mi[0]);
	if (N == 20000 - 5) { res.insert(6); res.erase(mi[2]); res.erase(mi[4]);}
	return res;
}

int main() {
	auto res = solve();
	for (auto x : res) cout << x << endl;
}

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

#define INF 100100100
#define MOD 1000000007

using namespace std;

int main(int argc, char const* argv[])
{
   vector<int>n(3);
   for(int i=0;i<3;i++)cin >> n[i];
   sort(n.begin(),n.end());
   cout << n[2]*10+n[1]+n[0];
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;

#define A first
#define B second

typedef long long ll;
constexpr int MOD = 1000000007;

void solve() {
  int X;
  cin >> X;
  if(X >= 30){
    cout << "Yes";
  }
  else {
    cout << "No";
  }
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int T;
  T = 1;
  //cin >> T;
  while(T--){
    solve();
  }
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
int f[200];
char s[205];
int main() {
  scanf("%s", s);
  int n = strlen(s);
  int t = 0;
  for (int i = 0; i < n; i++) {
    t = max(t, ++f[s[i]]);
  }
  int ans = 1234;
  for (char c = 'a'; c <= 'z'; c++) {
    if (f[c] == 0) continue;
    int x = 0, y = 0, i = 0;
    while (i < n) {
      if (s[i] == c) {
        x = max(x, y);
        y = 0;
      } else {
        y++;
      }
      i++;
    }
    x = max(x, y);
    //printf("%c: %d\n", c, x);
    ans = min(ans, x);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;
const double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N;
	string s;
	cin >> s;
	vector<vector<int>>dp(N, vector<int>(N + 1));
	for (int i = 0; i < N; i++) dp[0][i] = 1;
	for (int i = 1; i < N; i++) {
		if (s[i - 1] == '<') {
			int sum = dp[i - 1][N - 1];
			for (int j = N - 2; j >= 0; j--) {
				dp[i][j] = sum;
				sum += dp[i - 1][j];
				sum %= MOD;
			}
		}
		else {
			for (int j = 0; j < N; j++) {
				dp[i][j] += dp[i - 1][j];
				dp[i][j] %= MOD;
				dp[i][N-i] += MOD - dp[i - 1][j];
				dp[i][N-i] %= MOD;
			}
			for (int j = 1; j < N; j++) {
				dp[i][j] += dp[i][j - 1];
				dp[i][j] %= MOD;
			}
		}
	}
	//for (int i = 0; i < N; i++) {
	//	for (int j = 0; j < N; j++) {
	//		cout << i << " " << j << " " << dp[i][j] << endl;
	//	}
	//}
	cout << dp.back().front() << endl;
}

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

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll powMod(ll a, ll b) {
    if (b == 0) return 1;
    else {
        if (b & 1) {
            return a * powMod(a, b - 1) % MOD;
        } else {
            ll half = powMod(a, b / 2);
            return half * half % MOD;
        }
    }
}

ll calcComb(ll n, ll k) {
    if (k > n - k) {
        return calcComb(n, n - k);
    } else {
        ll ansMul = 1;
        ll ansDiv = 1;
        for (ll i = 0; i < k; ++i) {
            ansMul *= (n - i);
            ansDiv *= (k - i);
            ansMul %= MOD;
            ansDiv %= MOD;
        }
        ll ans = ansMul * powMod(ansDiv, MOD - 2) % MOD;
        return ans;
    }
}

int main() {
    ll n, m;
    cin >> n >> m;
    ll t = m;
    ll ans = 1;
    for (ll i = 2; i * i <= t; ++i) {
        if (t % i == 0) {
            int cnt = 0;
            while (t % i == 0) {
                ++cnt;
                t /= i;
            }
            ans *= calcComb(n + cnt - 1, n - 1);
            ans %= MOD;
        }
    }
    if (t != 1) {
        ans *= calcComb(n + 1 - 1, n - 1);
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}

static int speedUp = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stdint.h>
#include<stdbool.h>
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  double x;
  if(b<10)
	  x=sqrt(a*10+b);
  else if(b<100)
	  x=sqrt(a*100+b);
  else //b=100
	  x=sqrt(a*1000+100);
  if(ceil(x) == floor (x))
	  puts("Yes");
  else
	  puts("No");
}


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

int main() {
  int k, s;
  cin >> k >> s;
  
  int count = 0;
  
  for (int i = 0; i <= k; i++) {
  	for (int j = 0; j <= k; j++) {
    	int z = s -(i + j);
      if ((z >=  0) && (z <= k)) {
        	count++;
        }
    }
  }
  
  cout << count << endl;
 
}


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


int a[200010],vis[200010],pass[200010];

int main()
{
ll h,w;
cin>>h>>w;
if(h==1||w==1){cout<<1;return 0;};
ll ans=(h*w);
if(ans%2==0)cout<<ans/2;
else cout<<ans/2+1;
return 0;
}


Measured memory_bytes: 256
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print_container(const ContainerType<ValueType, Args...> &c)
{
	cout << "{ ";
	for (const auto &v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

ll power(ll x, ll y)
{
	ll res = 1;
	while (y)
	{
		if (y & 1)
			res = mul(res, x, MOD);
		y /= 2;
		x = mul(x, x, MOD);
	}
	return res;
}

void solve()
{
	int n;
	cin >> n;
	v32 arr(n + 1, 0);
	for (int i = 1; i < n + 1; i++)
		cin >> arr[i];
	sort(arr.begin(), arr.end());
	reverse(arr.begin() + 1, arr.end());
	ll ans = 0;
	for (int i = 1; i < n + 1; i++)
	{
		ll temp = mul(i + 1, arr[i], MOD);
		ans = add(ans, temp, MOD);
	}
	ans = mul(ans, power(4, n - 1), MOD);
	cout << ans << ln;
	return;
}

int main()
{
	FASTIO;
#ifdef file_input
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	clock_t start, stop;
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
#ifdef measure_time
	start = clock();
#endif
	for (int tc = 1; tc < t + 1; tc++)
		solve();
#ifdef measure_time
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 1024
using System;

namespace ALDS1
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = 0;
            int n = getint();
            for (int i = 0; i < n; i++)
            {
                int m = 0;
                int x = getint();
                if (x == 2) count++;
                else if (x % 2 == 1)
                {
                    for (int j = 3; j < Math.Sqrt(x)+1; j += 2)
                    {
                        if (x % j == 0)
                        {
                            m = 1;
                            break;

                        }
                    }
                    if (m == 0) count++;
                }
                
            }
            Console.WriteLine(count);
           
        }
        static int getint()
        {
            int x = int.Parse(Console.ReadLine());
            return x;
        }
    }
}

Measured memory_bytes: 9016
#include <cstdio>
#include <iostream>

#define MAX_N 1000

int main() {
    int K;
    int A, B;
    int loop = 1;
    int Ks;

    scanf("%d", &K);
    //printf("K = %d\n", K);
    scanf("%d %d", &A, &B);
    //printf("A = %d, B = %d\n", A, B);

    Ks = K;

    while(Ks <= B) {
        Ks = K * loop;
        //printf("Ks = %d, loop = %d\n", Ks, loop);
        if (Ks >= A && Ks <= B) {
            printf("OK\n");
            exit(0);
        }
        loop++;
    }
    printf("NG\n");

    return 0;
}

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

using namespace std;

int n,i,j,v[100005];
vector <int> edge[100005];

void solve(int id, int p){
	for(int k = 0; k < edge[id].size(); k++){
		int to = edge[id][k];
		if(to == p) continue;
		solve(to, id);
		
		v[id] ^= (v[to] + 1);
	}
}

int main(){
	scanf("%d", &n);
	
	for(i = 0; i < n - 1; i++){
		int x,y;
		scanf("%d%d", &x, &y);
		edge[x].push_back(y);
		edge[y].push_back(x);
	}
	
	solve(1, -1);
	
	if(v[1] == 0)
	printf("Bob\n");
	else
	printf("Alice\n");
}


Measured memory_bytes: 13952
import fractions

A, B = map(int, input().split())

g = fractions.gcd(A, B)
d = []
p = []

for i in range(1,int(pow(g, 0.5))+1):
    if g % i == 0:
        d.append(i)
        if i != g//i:
           d.append(g//i)

for i in d:
    s = 0
    for j in range(1,int(pow(i, 0.5))+1):
        if i % j == 0:
            s += 1

    if s == 1:
        p.append(i)

print(len(p))


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

int main(int argc, char **argv) {
  unsigned long long A, B, C;
  cin >> A >> B >> C;
  if (A % 2 && B % 2 && C % 2) {
    if (A < B) {
      if (B < C) {
        cout << A * B;
      } else {
        cout << A * C;
      }
    } else {
      if (A < C) {
        cout << A * B;
      } else {
        cout << B * C;
      }
    }
  } else {
    cout << 0;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int h,w,i,j,y[30010],x[30010],c[30010],r,t,ny,nx,a,b,n;
  int Y[]={-1,-1,0,0,1,1};
  int X[]={-1,1,-2,2,-1,1};
  while(scanf("%d %d",&w,&h),w){
    int max=0,d[200][300]={};
    for(i=1;i<=h;i++){
      for(j=1;j<=w;j++)d[i][j*2+1-i%2]=1e9;
    }
    /*for(i=0;i<h+2;i++){
      for(j=0;j<w*2+3;j++)printf("%d ",d[i][j]);
      printf("\n");
      }//*/
    scanf("%d",&n);
    for(i=r=0;i<n;i++){
      scanf("%d %d",&a,&b);
      a=a*2+1-b%2;
      d[y[r]=b][x[r]=a]=1;
      r++;
    }
    for(t=0;r-t;t++){
      for(i=0;i<6;i++){
	ny=y[t]+Y[i];
	nx=x[t]+X[i];
	if(d[y[t]][x[t]]+1>=d[ny][nx])continue;
	d[y[r]=ny][x[r]=nx]=d[y[t]][x[t]]+1;
	r++;
      }
    }
    /*for(i=0;i<h+2;i++){
      for(j=0;j<w*2+3;j++)printf("%d ",d[i][j]);
      printf("\n");
      }//*/
    scanf("%d",&n);
    while(n--){
      int f[200][300]={};
      scanf("%d %d",&a,&b);
      f[y[0]=b][x[0]=a*2+1-b%2]=c[t=0]=1;
      if(d[y[0]][x[0]]==1)continue;
      for(r=1;r-t;t++){
	for(i=0;i<6;i++){
	  ny=y[t]+Y[i];
	  nx=x[t]+X[i];
	  if(d[ny][nx]<=c[t]+1||f[ny][nx])continue;
	  f[y[r]=ny][x[r]=nx]=1;
	  c[r++]=c[t]+1;
	}
      }
      /*for(i=0;i<h+2;i++){
	for(j=0;j<w*2+3;j++)printf("%d ",f[i][j]);
	printf("\n");
	}//*/
      if(max<r)max=r;
    }
    printf("%d\n",max);
  }
  return 0;
}
    

Measured memory_bytes: 1112
/******************************************
* AUTHOR : Lokesh goel*
* NICK : InsaneNerd *
* INSTITUTION : NIT Kurukshetra *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 1000000000
#define N 100005
#define pii pair<int,int>
#define vp vector<pair<int,int > >
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define gsz(x) ((int)(x).size())
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ms(x,v) memset(x,v,sizeof(x))
ll int power(ll int x, unsigned int y, int p) 
{ 
    long long int res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return (long long)res; 
} 
int main() {
	fastio;
	ll n,i,j,k,arr[300000];
	cin>>n;
	for(i=0;i<n;i++)
		cin>>arr[i];
	ll count0[61]={0},count1[61]={0};
	ll maxj=0;
	for(i=0;i<n;i++)
	{
		j=0;
		while(arr[i])
		{
			if(arr[i]%2)
				count1[j]++;
			
			arr[i]/=2;
			maxj=max(j,maxj);
			j++;
			

		}
	}
	ll res=0;

	for(i=0;i<=60;i++)
	{

		res=(res+((((count1[i]%mod)*((n-count1[i])%mod))%mod)*(power(2,i,mod)%mod))%mod)%mod;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstdlib>
#include <string>

using namespace std;

int main()
{
    int m, n;
    string s;
    bool flag;
    int cur;
    while(cin >> m >> n && m && n)
    {
        vector<int> p(m);
        cur=0;
        for(int i=1;i<=m;++i) p[i-1] = i;
        for(int i=1;i<=n;++i)
        {
            cin >> s;
            flag=false;
            if(i%15==0)flag = s!="FizzBuzz";
            else if(i%5==0)flag = s!="Buzz";
            else if(i%3==0)flag = s!="Fizz";
            else flag = i!=atoi(s.c_str());
            if(p.size() > 1 && flag)
            {
                p.erase(p.begin()+cur);
                cur = cur%p.size();
            }
            else cur=(cur+1)%p.size();
        }
        for(int i=0;i<p.size();++i) cout << p[i] << ((i==p.size()-1)?"\n":" ");
    }
}

Measured memory_bytes: 1248
#include<iostream>
#include<cstdio>
using namespace std;
int n;
int main()
{
	scanf("%d",&n);
	int t1=0,t2=0;
	for (int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		if (x%4==0) t1++;
		if (x%2!=0) t2++;
	}
	if (t1>=t2) { puts("Yes");return 0;}
	if (n%2==1&&t1+1==t2) { puts("Yes");return 0;}
	puts("No"); 
	return 0;
}

Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <stack>
#include <algorithm>
#define MIN(x,y) ((x)<(y)?(x) : (y))
#define MAX(x,y) ((x)>(y)?(x) : (y))
#include <stdlib.h>
#include <time.h>
#include <sstream>
#define mem(a,b) memset(a,b,sizeof(a))
#include <string>
using namespace std;
typedef long long ll;
const int maxn=1e6+5;
const ll INF=1e9;
/*坚持不懈，无懈可击*/
int num[maxn];
int main()
{
    int A,B,k;
    scanf("%d%d%d",&A,&B,&k);
    int tot=0;
    for(int i=1;i<=1000;i++)
    {
        if(A%i==0&&B%i==0&&i<=A&&i<=B)
            num[++tot]=i;
    }
    printf("%d\n",num[tot-k+1]);
    return 0;
}


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

typedef long double ld;

int a, b, x;

int main()
{
    cin >> a >> b >> x;
    ld h = ld(x) / ld(a * a);
    if (h >= b / 2.0l)
        cout << fixed << setprecision(10) << 180.0l / acos(-1.0) * atan((b - h) / (a / 2.0l)) << endl;
    else {
        ld z = 2.0l * h * a / b;
        cout << fixed << setprecision(10) << 180.0l / acos(-1.0) * atan(b / z) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long

#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); };

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

const int inf = TEN(9) + 10;
const int mod = TEN(9) + 7;

signed main()
{
	int a,b;cin>>a>>b;
	cout<<((a*b%2)?"Odd":"Even")<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100010

int A[MAX];

int Partition(int A[], int sp, int ep) {	//A[sp] ~ A[ep]
	int x = A[ep];
	int i = sp - 1;
	int buff;
	for (int j = sp; j < ep; j++) {
		if (A[j] <= x) {
			i++;
			buff = A[i];
			A[i] = A[j];
			A[j] = buff;
		}
	}
	A[ep] = A[i + 1];
	A[i + 1] = x;
	return i + 1;
}

int main() {
	int N, q;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	q = Partition(A, 0, N - 1);
	for (int i = 0; i < q; i++) {
		if (i)printf(" ");
		printf("%d", A[i]);
	}
	printf(" [%d]", A[q]);
	for (int i = q + 1; i < N; i++) {
		if (i)printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
	return 0;
}



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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

int main() {
    Int n, l, t;
    cin >> n >> l >> t;
    vector<Int> x(n), w(n);
    for (Int i = 0; i < n; i++) {
        cin >> x[i] >> w[i];
    }
    vector<Int> ox = x;
    bool check = true;
    for (Int i = 0; i < n; i++) {
        if (w[i] != w[(i + 1) % n]) check = false;
    }
    if (check) {
        Int d = t % l;
        for (Int i = 0; i < n; i++) {
            if (w[0] == 1) {
                dump((x[i] + d) % l);
            }
            else {
                dump((x[i] - d + l) % l);
            }
        }
        return 0;
    }
    Int index = -1;
    for (Int i = 0; i < n; i++) {
        if (w[i] == 1) {
            index = i;
            break;
        }
    }
    Int cnt = 0;
    for (Int i = 0; i < n; i++) {
        if (w[i] == 2) {
            cnt++;
        }
    }
    Int rnum = cnt * ((Int)2 * t / l);
    Int r = 2 * t % l;
    for (Int i = index + 1; i < n; i++) {
        if (w[i] == 2) {
            if (x[i] - x[index] < r) {
                rnum++;
            }
        }
    }
    for (Int i = 0; i < index; i++) {
        if (w[i] == 2) {
            if (x[i] + (l - x[index]) < r) {
                rnum++;
            }
        }
    }
    rnum %= n;
    Int xx = (x[index] + t) % l;
    vector<Int> res(n);
    for (Int i = 0; i < n; i++) {
        if (w[i] == 1) {
            res[i] = (x[i] + t) % l;
        }
        else {
            res[i] = (x[i] - (t % l) + l) % l;
        }
    }
    sort(all(res));
    Int new_index = -1;
    for (Int i = 0; i < n; i++) {
        if (res[i] == xx) {
            new_index = i;
            break;
        }
    }
    new_index = (new_index - rnum + n) % n;
    vector<Int> ans(n);
    for (Int i = 0; i < n; i++) {
        ans[(index + i) % n] = res[(new_index + i) % n];
    }
    for (Int i = 0; i < n; i++) {
        dump(ans[i]);
    }
    return 0;
}


Measured memory_bytes: 5120
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 998244353;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int len = (int)1e6 + 1;
	
	
	void doIt() {
		int K = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int len = K;
		while(len <= B) {
			if(A <= len) {
				System.out.println("OK");
				return;
			}
			
			len += K;
		}
		System.out.println("NG");
	}
	
	
	public static void main(String[] args) {
		new Main().doIt();
	}

}


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

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int n;
    ll sumA = 0LL, sumB = 0LL;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sumA += a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
        sumB += b[i];
    }

    ll sousa1 = 0, sousa2 = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] > b[i]) {
            sousa1 += a[i] - b[i];
        } else if (a[i] < b[i]) {
            sousa2 += (b[i] - a[i] + 1) / 2;
        }
    }

    if (sousa1 <=sumB-sumA && sousa2 <= sumB-sumA) puts("Yes");
    else puts("No");

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstring>
#include<map>
#include<vector>
#include<set>
#include<cstring>
#include<algorithm>
#include<cmath>
#define Max zhi5968
typedef long long ll;
using namespace std;
 
int main ()
{
	ll n,i,a[1000010],b[1000010],c[1000010],aa[1000010],bb[1000010];
	cin>>n;
	for(i=0;i<n;i++)
		scanf("%lld",&a[i]);
	for(i=0;i<n;i++)
		scanf("%lld",&b[i]);
	for(i=0;i<n;i++)
		scanf("%lld",&c[i]);
	ll tmp1=0,tmp2=0,tmp3=0;
	sort(a,a+n); sort(b,b+n); sort(c,c+n);
	for(i=0;i<n;i++)
	{
		while(b[i]>=c[tmp3])
		{
			if(tmp3==n)
				break;
			tmp3++;
		}
		bb[i]=n-tmp3;
	//	cout<<i<<" "<<bb[i]<<endl;
	}
	for(i=n-2;i>=0;i--)
	{
		bb[i]+=bb[i+1];
	//	cout<<"b="<<bb[i]<<endl;
	}
	ll ans=0;
	for(i=0;i<n;i++)
	{
		while(a[i]>=b[tmp2])
		{
			if(tmp2==n)
				break;
			tmp2++;
		}
	//	cout<<tmp2<<" "<<bb[tmp2]<<endl;
		ans+=bb[tmp2];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 12544
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

map<ll, ll> prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; ++i) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    Map M=prime_factor(N);
    ll ans=0;
    vector<ll> vec(50,0);
    vec[1]=1;
    for(ll i=2;i<50;++i){
        vec[i]=vec[i-1]+i;
    }
    for(auto p: M){
        ll x=p.second;
        ll count=0;
        while(vec[count+1]<=x){
            count++;
        }
        ans+=count;
    }prt(ans)

    
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <string>

int main(void)
{
	int base = 100000;
	
	int n;
	std::cin >> n;
	
	for (int i = 0; i < n; i++) {
		base = 1.05 * base;
    if (base % 1000 != 0) {
      base = (base / 1000) * 1000 + 1000;
    }
    else {
      base = (base / 1000) * 1000;
    }
	}
  
  std::cout << base << std::endl;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <functional>
#include <stdio.h>
#include <array>
#include <algorithm>
#include <string>
#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <queue>
#include<iomanip>
#include<bitset>
#include<stack>
#include<set>
#include<limits>
#include <complex>
#include<cstdlib>
using namespace std;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};
struct aUnionFind {
	vector<pair<int, long long int>> data;
	aUnionFind(int size) : data(size, make_pair(-1, 0)) { }
	bool unionSet(const int x, const int y, const long long int w) {
		const int rx(root(x).first), ry(root(y).first);
		if (rx != ry) {
			data[rx].first += data[ry].first; data[ry].first = rx;
			data[ry].second =-data[y].second + w + data[x].second;
		}
		return rx != ry;
	}
	bool findSet(const int x, const int y) {
		return root(x) == root(y);
	}
	pair<int,long long int> root(const int x) {
		if (data[x].first < 0) {
			return make_pair(x, 0);
		}
		else {
			pair<int, long long int>ndata;
			ndata.first = root(data[x].first).first;
			ndata.second =data[x].second+ root(data[x].first).second;
			return data[x]=ndata;
		}
	}
	int size(const int x) {
		return -data[root(x).first].first;
	}
};



int main() {
	while (1) {
		int N, M; cin >> N >> M;
		if (!N)break;
		vector<pair<int,int>>weis(N,make_pair(-1,-1));
		aUnionFind uf(N);
		for (int i = 0; i < M; ++i) {
			char c; cin >> c;
			if (c == '!') {
				int a, b, w; cin >> a >> b >> w;
				a--; b--;
				uf.unionSet(a, b,w);
				
				
			}
			else {
				int a, b; cin >> a >> b;
				a--; b--;
				if (uf.root(a).first == uf.root(b).first) {
					int aa=uf.root(a).second - uf.root(b).second;
					cout << -aa << endl;
				}
				else {
					cout << "UNKNOWN" << endl;
				}
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 7476
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, k;
  cin >> n >> k;
  vl a(n);
  rep(i, n) {
    cin >> a[i];
    a[i]--;
  }
  vl d(n, -1);
  ll m = 0, cnt = 0;
  while(true) {
    d[m] = cnt;
    cnt++;
    if(d[a[m]] != -1) break;
    m = a[m];
  }
  ll ans = 0;
  if(k <= d[a[m]]) {
    rep(j, n) {
      if(d[j] == k) ans = ll(j);
    }
  } else {
    ll x = d[m] - d[a[m]] + 1;
    k -= d[a[m]];
    k %= x;
    rep(j, n) {
      if(d[j] == k + d[a[m]]) ans = ll(j);
    }
  }
  cout << ans + 1 << endl;
}


Measured memory_bytes: 6428