akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z;
    string s;
    cin>>s;
    n = s.size();
    for(int i=0;i<n;i++){
        if(s[i]=='?')s[i]='D';
    }
    cout<<s;
    
    

    return 0;
}

Measured memory_bytes: 3752
#include <iostream>
#include <math.h>
using namespace std;

int main() {

  double x[1001], y[1001];
  x[0] = 1.00;
  y[0] = 0.00;

  for ( long long int i = 0; i < 1000; i++ ) {

    double ang = atan2( y[i], x[i] ) + M_PI / 2;

    x[i+1] = x[i] + cos( ang );
    y[i+1] = y[i] + sin( ang );

  }

  long long int n;

  while( true ) {

    cin >> n;
    if ( n == -1 ) break;

    n--;
    cout << x[n] << endl << y[n] << endl;

  }

  return 0;

}

Measured memory_bytes: 1332
n=int(input())
l=[]
for i in range(n-1):
    l.append([int(i) for i in input().split()])
ans=[]
i=0 
while i<n-1:
    time=l[i][1]
    cost=0 
    j=i 
    while j<n-1: 
        karma=((max(time,l[j][1]))-(l[j][1]))%l[j][2]
        if karma:
            karma=l[j][2]-karma 
        start=max(time,l[j][1])+karma 
        time=start+l[j][0]
        j+=1 
    i+=1 
    print(time)
print(0)

Measured memory_bytes: 3188
using namespace std;

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <numeric>
typedef long long ll;
typedef pair<int,int> p;

int main()
{
  ll n;
  cin >> n;
  vector<string> name;
  vector<ll> count(5,0);
  for (ll i = 0; i < n; i++)
  {
    string tmp;
    cin >> tmp;
    // name.push_back(tmp);
    if (tmp[0] == 'M')
    {
      count[0]++;
    }else if (tmp[0] == 'A')
    {
      count[1]++;
    }else if (tmp[0] == 'R')
    {
      count[2]++;
    }else if (tmp[0] == 'C')
    {
      count[3]++;
    }else if (tmp[0] == 'H')
    {
      count[4]++;
    }

  }
  // for (ll i = 0; i < 5; i++)
  // {
  //   cout << count[i] << endl;
  // }

  ll res = 0;
  for (ll i = 0; i < 5; i++)
  {
    for (ll j = i+1; j < 5; j++)
    {
      for (ll k = j+1; k < 5; k++)
      {
        // if (i != j && i != k && j != k)
        // {
          // cout << cnt << endl;
          // cnt++;
          res += (count[i] * count[j] * count[k]);
        // }
      }
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main(){
	int n;
	string s;
	cin>>n>>s;
	if(n%2!=0){
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=0;i<n/2;i++){
		if(s[i]!=s[i+n/2]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>

using namespace std;

int main() {
    stack<int> s;
    while(1) {
        string target;
        cin >> target;
        if (cin.eof()) break;
        if (target == "+") {
            int b = s.top();
            s.pop();
            int a = s.top();
            s.pop();
            s.push(a + b);
        } else if (target == "-") {
            int b = s.top();
            s.pop();
            int a = s.top();
            s.pop();
            s.push(a - b);
        } else if (target == "*") {
            int b = s.top();
            s.pop();
            int a = s.top();
            s.pop();
            s.push(a * b);
        } else {
            s.push(stoi(target));
        }
    }
    cout << s.top() << endl;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, A[1005][1005];
vector <int> Graph[int(1e6+5)];
int num[int(1e6+5)], day[int(1e6+5)];
bool visited[int(1e6+5)];

int Make(int i, int j){
  if (i < j) return N * i + j;
  else return N * j + i;
}

int main(){
  cin >> N;
  for (int i = 1; i <= N; i++){
    for (int j = 0; j < N - 1; j++){
      cin >> A[i][j];
    }
    for (int j = 1; j < N - 1; j++){
      int before = Make(i, A[i][j-1]);
      int next = Make(i, A[i][j]);
      Graph[before].push_back(next);
      num[next]++;
    }
  }

  queue <int> que;
  for (int i = 1; i <= N; i++){
    for (int j = i + 1; j <= N; j++){
      int now = Make(i, j);
      if (num[now] == 0){
        que.push(now);
        visited[now] = true;
        day[now] = 1;
      }
    }
  }

  while (!que.empty()){
    int Q = que.front(); que.pop();
    for (int next:Graph[Q]){
      num[next]--;
      if (num[next] == 0){
        que.push(next);
        visited[next] = true;
        day[next] = day[Q] + 1;
      }
    }
  }

  int ans = 0;
  for (int i = 1; i <= N; i++){
    for (int j = i + 1; j <= N; j++){
      int now = Make(i, j);
      if (!visited[now]){
        cout << -1 << endl;
        return 0;
      }
      ans = max(ans, day[now]);
    }
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 55312
#include <bits/stdc++.h>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef int64_t Int;
const double pi = M_PI;

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

    int a[n];
    for (Int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (Int i = n - 1; i != 0; i--)
    {
        cout << a[i] << ' ';
    }
    cout << a[0] << endl;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
 
/*** Template Begins ***/
 
typedef long long   ll;
typedef pair<ll,ll> pll;
typedef long double ld; 
#define rep(i,a,b) for(i=a;i<b;i++)
#define pb           push_back
#define F            first
#define S            second
#define ios          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define hell   1000000007LL
#define all(a)       (a).begin(),(a).end()
ll power(ll x, ll y, ll p){ ll res = 1;x = x % p;while (y > 0) {if (y & 1) res = (res*x) % p;y = y>>1;
  x = (x*x) % p;} return res;} 

const long double PI = acos(-1);
// Debug //
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
ll euclid(ll x,ll y,ll a,ll b){
  return (a-x)*(a-x)+(b-y)*(b-y);
}
void solve()
{
  ll n;
  string str;
  cin>>n;
  while (n > 0) { 
    ll rem = n % 26; 
    if (rem == 0) { 
        str.pb('z'); 
        n = (n / 26) - 1; 
    } 
    else
    { 
        str.pb((rem - 1) + 'a'); 
        n = n / 26; 
    }  
  }
  reverse(all(str));
  cout<<str;
}
int main()
{ 
  ios; 
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  ll t=1,i=1;
  // sieve();
  // cin>>t;
  while(i<=t)
  {
    solve();
    i++;
  }
  return 0;
}


Measured memory_bytes: 3652
N = int(input())
A = (tuple(map(int, input().split())), tuple(map(int, input().split())))

if 1 == N:
	print(sum(A[0] + A[1]))
	exit()

asum = 0
for i in range(N + 1):
	asum = max(asum, sum(A[0][:i] + A[1][i - 1:]))
print(asum)


Measured memory_bytes: 3060
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

N = INT()
vcnt = 0
for i in range(1, N+1):
    vcnt += i * (N+1-i)
ecnt = 0
for i in range(N-1):
    a, b = MAP()
    if a > b:
        a, b = b, a
    ecnt += a * (N+1-b)
ans = vcnt - ecnt
print(ans)


Measured memory_bytes: 9376
import java.awt.Point;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
 
public class Main {
	static char[][] c;
	static int H, W;
	static List<Point> p;
	static long ans = 0;
	static boolean[][] m;
	static int[][] g;
	static long cnt1 = 0;
	static long cnt2 = 0;
	static int[][] h;
	static Set<Integer> set1;
	static Set<Integer> set2;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		H = sc.nextInt();
		W = sc.nextInt();
		String[] S = new String[H];
		for(int i = 0; i < H; i++) {
			S[i] = sc.next();
		}
		sc.close();
		c = new char[H][W];
		m = new boolean[H][W];
		g = new int[H][W];
		h = new int[H][W];
		set1 = new HashSet<Integer>();
		set2 = new HashSet<Integer>();
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				m[i][j] = true;
			}
		}
		p = new ArrayList<Point>();
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				c[i][j] = S[i].charAt(j);
				if(c[i][j] == '#') {
					p.add(new Point(j, i));
				}
			}
		}
		for(int i = 0; i < p.size(); i++) {
			int x = p.get(i).x;
			int y = p.get(i).y;
			//System.out.println(y + " " + x);
			if(g[y][x] == 1) {
				continue;
			}
			g[y][x] = 1;
			h[y][x] = 1;
			m[y][x] = false;
			rec('#', x, y);
 
			int k = y * W + x;
			set2.add(k);
			cnt1 = set1.size();
			cnt2 = set2.size();
 
			//System.out.println(cnt1 +" " + cnt2);
			ans += cnt1 * cnt2;
			set1.clear();
			set2.clear();
		}
		System.out.println(ans);
	}
	static void init() {
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				h[i][j] = 0;
			}
		}
	}
	static void rec(char color, int x, int y) {
		int[] dx = {1, -1, 0, 0};
		int[] dy = {0, 0, 1, -1};
		for(int i = 0; i < 4; i++) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if(nx >= 0 && nx < W && ny >= 0 && ny < H) {
				if(color == '#' && m[ny][nx] && c[ny][nx] == '.') {
					int k = ny * W + nx;
					m[ny][nx] = false;
					set1.add(k);
					rec('.', nx, ny);
				}else if(color == '.' && m[ny][nx] && c[ny][nx] == '#') {
					g[ny][nx] = 1;
					m[ny][nx] = false;
					int k = ny * W + nx;
					set2.add(k);
					rec('#', nx, ny);
				}
			}
		}
	}
}

Measured memory_bytes: 83552
n = int(input())
l = []
ans = 'Yes'
ps = 'a'
for i in range(n):
  s = input()
  if s in l:
    ans = 'No'
  l.append(s)
  if i != 0 and ps[-1] != s[0]:
    ans = 'No'
  ps = s

print(ans)


Measured memory_bytes: 3060
data  = [int(_) for _ in input().split()]
enemy = [int(_) for _ in input().split()]

if len(enemy) < data[1]:
    print(0)
    exit()
elif data[1] == 0:
    print(sum(enemy))
else:
    enemy.sort()
    
    print(sum(enemy[:-data[1]]))


Measured memory_bytes: 87372
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;
const int ny[4] = {-1,1,0,0}, nx[4] = {0,0,-1,1};
int sy,sx,gy,gx;

int main(){
  int n,m; cin >> n >> m;
  vector<int> ans(m);
  rep(i,n){
    int k; cin >> k;
    rep(j,k){
      int a; cin >> a;
      a--;
      ans[a]++;
    }
  }
  int cnt = 0;
  rep(i,m){
    if(ans[i] == n) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define lc 2 * v
#define rc 2 * v + 1
#define mid (s + e) / 2
#define ll long long
#define int long long
#define ld long double
#define pii pair <int , int>
#define pll pair <long long , long long>
#define FAST ios::sync_with_stdio(false);cin.tie(0);
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

const int maxn = 2e5 + 10 , N = 2e6 + 10 , SQ = 320 , base = 1999 , mod = 1e9 + 7 , INF = 1e18 , lg = 33;

int x[maxn] , y[maxn];
vector <pii> vec;

bool cmp(pii a , pii b) {
    if(a.F != b.F) {
        return a.F < b.F;
    }
    return a.S < b.S;
}

int32_t main() {
    FAST
    int n; cin >> n;
    int mini = INF , maxi = -INF , mx = -INF , mn = INF;
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
        vec.PB({x[i] , y[i]});
        maxi = max(maxi , x[i] + y[i]);
        mini = min(mini , x[i] + y[i]);
        mx = max(mx , x[i] - y[i]);
        mn = min(mn , x[i] - y[i]);
    }
    cout << max(maxi - mini , mx - mn) << endl;
}


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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 20;


void solve() {
	int n, t;
	cin >> n >> t;
	vector<pair<int, int>> a(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> a[i].first >> a[i].second;
	}
	sort(all(a));

	vector<int> suf(n + 1);
	for (int i = n; i >= 1; i--) {
		suf[i] = max(i == n ? 0 : suf[i + 1], a[i].second);
	}

	vector<vector<int>> dp(n + 1, vector<int>(t));
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int mx = 0;
		for (int j = 1; j < t; j++) {
			if (j - a[i].first >= 0) dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - a[i].first] + a[i].second);
			mx = max(mx, dp[i][j]);
		}
		ans = max(ans, mx + (i == n ? 0 : suf[i + 1]));
	}

	cout << ans;
}
	

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

Measured memory_bytes: 70784
A=[1,3,5,7,8,10,12]
B=[4,6,9,11]
x,y=map(int,input().split())

if x in A and y in A:
    print('Yes')
elif x in B and y in B:
    print('Yes')
elif x==y==2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
import math
n, h = map(int,input().split())
a=[]
b=[]

for i in range(n):
    ta, tb = map(int,input().split())
    a.append(ta)
    b.append(tb)

maxa=max(a)
b.append(maxa)
b.sort()
b.reverse()

damage=0
cnt=0
while(h>damage):
    
    if b[0]>maxa:
        damage+=b[0]
        del b[0]
        cnt+=1
    else:
        cnt=cnt+int((h-damage)/b[0])
        #print(cnt,damage)
        damage+=b[0]*int((h-damage)/b[0])
        if h>damage:
            cnt+=1
            damage+=b[0]

print(cnt)


Measured memory_bytes: 11264
#include<cstdio>
#include<algorithm>
#include<cmath>
inline int read() {
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*f; 
}
int ans,a[4];
int main() {
	for(register int i=1;i<=3;i++) a[i]=read();
	std::sort(a+1,a+4);
	for(register int i=2;i<=3;i++)
		ans+=a[i]-a[i-1];
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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; }


const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<long long> H){
	bool can = true;
	REPR(i, N-1) {
		ll n = H[i] - H[i+1];
		if (n > 0) H[i]--;
		n = H[i] - H[i+1];
		if (n > 0) can = false;
	}
	if (can) cout << YES << "\n";
	else cout << NO << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    solve(N, std::move(H));
    return 0;
}


Measured memory_bytes: 1024
n = gets.to_i
s = gets.chomp.split(//).map &:to_i

cl = Array.new(n+1, 0)
cr = Array.new(n+1, 0)
cnt = Array.new(1000, 0)

n.times do |i|
  j = n - i
  cl[i+1] = cl[i] | 2 ** s[i]
  cr[j-1] = cr[j] | 2 ** s[j-1]
end

n.times do |i|
  l = cl[i]
  r = cr[i+1]
  m = s[i]
  10.times do |j|
    10.times do |k|
      next if l[j] == 0 || r[k] == 0
      ix = j * 100 + m * 10 + k
      cnt[ix] = 1
    end
  end
end

ans = cnt.count(1)
puts ans

Measured memory_bytes: 3836
#include<cstdio>
using namespace std;
const int N=200200;
int i,j,k,n,m;
char s[N],ans[N];
int main() {
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	j=1;
	for (i=n;i;i--) {
		if ((n-i)&1) ans[i]='B';
		else ans[i]='A';
	}
	for (i=1;i<=m;i++) {
		if (s[j]=='A') {
			s[j]='B';
			continue;
		}
		else {
			if (++j>n) break;
			if (!(j&1)) s[j]='A'+'B'-s[j];
		}
	}
	m-=i;
	for (i=j;i<=n;i++) {
		if (!(j&1) && i!=j) s[i]='A'+'B'-s[i];
		ans[i-j+1]=s[i];
	}
	if (m>0 && (m&1) && ans[1]=='A') ans[1]='B';
	printf("%s\n",ans+1);
}

Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
using namespace std;
using ll =long long;
const int mod = 1000000007;
/*
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		retrun os;
	}
};
*/
int main() {
	ll S, W;
	cin >> S >> W;
	S > W ? cout << "safe" : cout << "unsafe";
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<string.h>

int main(){
	int s;
	scanf("%d", &s);
	int nl[1000000];
	nl[0]=s;
	int i=0, same=0;
	while(i<1000000){
		if(nl[i]%2 == 0){
			nl[i+1]=nl[i]/2;
			//printf("%d:%d\n",i+1, nl[i+1]);
		}
		else{
			nl[i+1]=3*nl[i]+1;
			//printf("%d:%d\n",i+1, nl[i+1]);
		}
		for(int j=0; j<=i; j++){
			if(nl[i+1]==nl[j]){
				same=i+2;
				break;
			}
		}
		if(same != 0){
			printf("%d", same);
			break;
		}
		i++;
	}
	return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
//LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }
//max_element


//---------- 素因数分解 ----------
vector<pair<int, int>> prime_fact(ll n) //a0^b0 * a1^b1 * ...
{
	vector<pair<int, int>> list;
	ll a = n;
	for (int i = 2; i * i <= n; i++)
	{
		int cnt = 0;
		while (a % i == 0)
		{
			cnt++;
			a /= i;
		}
		if (cnt > 0)
		{
			list.push_back(make_pair(i, cnt));
		}
	}
	if (a != 1)
	{
		list.push_back(make_pair(a, 1));
	}
	return list;
}


int calc(int n)
{
	int ret = 0;
	int cnt = 1;
	while (true)
	{
		n -= cnt;
		if (n < 0)
		{
			break;
		}
		ret++;
		cnt++;
	}
	return ret;
}

signed main()
{
	int N;

	cin >> N;
	auto p = prime_fact(N);

	int ans = 0;
	for (int i = 0; i < p.size(); i++)
	{
		ans += calc(p[i].second);
	}

	cout << ans << endl;
}




Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
  
namespace ALDS1_3
{
    class Program
    {
        public struct Process
        {
            public readonly string n;
            public readonly int t;
            public Process(string n, int t)
            {
                this.n = n;
                this.t = t;
            }
        }
  
        static void Main()
        {
            var s = Console.ReadLine().Split();
            var a = int.Parse(s[1]);
            var b = new Queue<Process>();
            string w;
 
            while ((w = Console.ReadLine()) != null)
            {
                var c = w.Split();
                var d = c[0]; var e = int.Parse(c[1]);
                b.Enqueue(new Process(d, e));
            }
  
            var f = 0;
  
            while (b.Count > 0)
            {
               var g = b.Dequeue();
               var k = g.n;
               var v = g.t;
               f += v < a ? v : a;
               v -= a;
               if (v <= 0)
                   Console.WriteLine("{0} {1}", k, f);
               else
                   b.Enqueue(new Process(k, v));
            }
        }
    }
}

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

void Constraints(int a,int b,char op)
{
  if(!(0<=a&&a<=200000&&0<=b&&b<=200000&&(op=='+'||op=='-'||op=='*'||op=='/'||op=='?'))){
    printf("条件を満たす入力をしてください。\n");
    exit(0);
  }
}

int Operator(int a,int b,char op)
{
  switch(op)
  {
    case '+': return (a+b);
    break;
    case '-': return (a-b);
    break;
    case '*': return (a*b);
    break;
    case '/':
    if(b==0)
    {
      printf("0 による割り算はできません。");
      exit(0);
    }
    else{return a/b;}
    break;
    case '?': return NULL;
    break;
  }
}

int main(void)
{
  int a,b;
  char op=' ';
  while(op!='?')
  {
    scanf("%d %c %d",&a,&op,&b);
    Constraints(a,b,op);
    if(op=='?'){
      break;
    }
    printf("%d\n",Operator(a,b,op));
  }
  return 0;
}



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

int main() {
    int n, m, a, b, branch[50][50]={0};
    cin >> n >> m;
    for(int i=0; i<m; i++) {
        cin >> a >> b;
        branch[a-1][b-1]++;
        branch[b-1][a-1]++;
    }
    for(int i=0; i<n; i++) {
        int cnt=0;
        for(int j=0; j<n; j++) cnt+=branch[i][j];
        cout << cnt << endl;
    }
    return 0;
}


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

    using namespace std;

    #define pan(i,n) for(int i=0;i<n;i++)
    #define pans(i,n,a) for(int i=a;i<n;i++)
    #define ll long long int
    #define vi vector<int>
    #define vl vector<ll>
    #define pb push_back
    #define INF 1000000007
    #define PI 3.141592653
    #define inf 100007
    #define P pair<ll,ll>
    ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
    ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

    int h, w;
    int used[60][60], d[60][60];
    string o[60];
    queue<pair<int, int> > q;

    void bfs(){
        q.push({0, 0});
        used[0][0] = 10, d[0][0] = 0;
        while(!q. empty()){
            pair<int, int> k = q.front();
            int i = k.first, j = k.second;
            q.pop();
            if((i+1 >= 0 && i+1 < h && j < w && j>=0) && !used[i+1][j] && o[i+1][j] != '#'){
                q.push({i+1, j}), d[i+1][j] = d[i][j] + 1,used[i+1][j]=10;
            }
            if((i-1>= 0 && i-1 < h && j < w && j>=0) && !used[i-1][j] && o[i-1][j] != '#'){
                q.push({i-1,j}),d[i-1][j]=d[i][j]+1,used[i-1][j]=10;
            }
            if((i>= 0 && i < h && j-1 < w && j-1>=0) && !used[i][j-1] && o[i][j-1]!='#'){
                q.push({i,j-1}),d[i][j-1]=d[i][j]+1,used[i][j-1]=10;
            }
            if((i>= 0 && i < h && j+1 < w && j+1>=0) && !used[i][j+1] && o[i][j+1]!='#'){
                q.push({i,j+1}),d[i][j+1]=d[i][j]+1,used[i][j+1]=10;
            }
                
        }
    }

    int main(){
        int dc=0;
        cin>>h>>w;
        pan(i,h) {
            cin>>o[i];
            pan(j,w) if(o[i][j]=='.') dc++;
        }
        // cout<<hc<<endl;

            bfs();
            if(!d[h-1][w-1]) cout<<-1;
            else
                cout<<dc-d[h-1][w-1]-1;
        
    }

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

const int N = 200010;
const double PI = std::acos(-1);
typedef std::pair <int, int> pii;

std::vector <pii> fount;
int c[N];

bool in(int x1, int x2, int x){
	return x1 <= x && x <= x2 || x1 >= x && x >= x2;
}

const int MAX = 1 << 18;

int seg[MAX << 1];

void add(int sit, int value){
	seg[sit += MAX] = value;
	for (sit >>= 1; sit; sit >>= 1){
		seg[sit] = std::max(seg[sit << 1], seg[sit << 1 | 1]);
	}
}

int query(int l, int r){
	int ret = 0;
	for (l += MAX, r += MAX + 1; l < r; l >>= 1, r >>= 1){
		if (l & 1) ret = std::max(ret, seg[l ++]);
		if (r & 1) ret = std::max(ret, seg[-- r]);
	}
	return ret;
}

int main(){
	int x1, y1, x2, y2;
	int n;
	scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
	if (x1 > x2){
		std::swap(x1, x2);
		std::swap(y1, y2);
	}
	else if (x1 == x2 && y1 > y2){
		std::swap(y1, y2);
	}
	scanf("%d", &n);
	for (int i = 0, x, y; i < n; ++ i){
		scanf("%d%d", &x, &y);
		if (in(x1, x2, x) && in(y1, y2, y)){
			fount.push_back({x, y});
		}
	}
	std::sort(fount.begin(), fount.end());
	int cnt = 0;
	for (auto u : fount){
		c[cnt ++] = u.second;
	}
	std::sort(c, c + cnt);
	for (auto u : fount){
		int sit = std::lower_bound(c, c + cnt, u.second) - c;
		int x = y1 < y2 ? query(0, sit) : query(sit, MAX - 1);
		add(sit, x + 1);
	}
	int x = query(0, MAX - 1);
	double ans = 100ll * (std::abs(x2 - x1) + std::abs(y2 - y1));
	if (x == std::min(std::abs(x2 - x1), std::abs(y2 - y1)) + 1){
		-- x;
		ans += (PI - 2) * 10;
	}
	ans -= (2 - PI / 2) * x * 10;
	printf("%.15lf\n", ans);
	return 0;
}

Measured memory_bytes: 4336
N,M=map(int,input().split())
A=[]
for i in range(M):
    A.append(list(map(int,input().split())))
P=list(map(int,input().split()))
ans=0
for i in range(2**N,2**(N+1)):
        B=bin(i)
        count=0
        for j in range(M):
            tet=0
            for l in range(A[j][0]):
                tet+=int(B[A[j][l+1]+2])
            if tet%2==P[j]:
                  count+=1
        if count==M:
            ans+=1
print(ans)

Measured memory_bytes: 3188
from collections import Counter

def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass

n,p = map(int,input().split())

a = prime_factor(p)
a.append(1)
c = Counter(a)
d = c.most_common()

res = 1

for i in range(len(d)):
    if d[i][1] >= n:
        k = d[i][1]//n
        res = res * (d[i][0]**k)
        
        if i == len(d)-1:
            break
    else:
        break

print(res)

Measured memory_bytes: 3444
#include <iostream>
#include <vector>
 
using namespace std;
 
void solve()
{
    int n, r;
    while(cin >> n >> r, n || r)
    {
        vector<int> Vec(n);
        for(int i = 0; i < n; ++i)
        {
            Vec[i] = n - i;
        }
        while(r--)
        {
            int p, c;
            cin >> p >> c;
            vector<int> VecBuf = Vec;
            int pos = 0;
            for(int i = p - 1; i < p + c - 1; ++i)
            {
                Vec[pos] = VecBuf[i];
                ++pos;
            }
            for(int i = 0; i < p - 1; ++i)
            {
                Vec[pos] = VecBuf[i];
                ++pos;
            }
            // for(int i = p + c - 1; i < n; ++i)
            // {
            //     Vec[pos] = VecBuf[i];
            //     ++pos;
            // }
        }
        cout << Vec[0] << endl;
    }
}
 
int main()
{
    solve();
    return(0);
}

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

using namespace std;

typedef long long ll;

int main() {
  int N;
  ll D, A;
  cin >> N >> D >> A;

  vector<pair<ll, ll>> monsters(N);
  for (int i = 0; i < N; i++) {
    int X;
    ll H;
    cin >> X >> H;
    monsters[i] = make_pair(X, H);
  }

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

  vector<ll> counts;
  vector<ll> pos;

  counts.push_back(0);

  int c = 0;
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    auto it = lower_bound(pos.begin(), pos.end(), monsters[i].first);
    if (it != pos.end()) {
      int k = distance(pos.begin(), it);
      monsters[i].second -= A * (counts[c] - counts[k]);
    }
    if (monsters[i].second <= 0) continue;

    ll count = monsters[i].second / A;
    if (monsters[i].second % A > 0) count++;

    pos.push_back(monsters[i].first + 2 * D);
    counts.push_back(counts[c] + count);
    c += 1;
    ans += count;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6756
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
map<int, int> D;

void solve() {
	cin >> N;
	rep(i, 0, N) {
		int a; cin >> a; D[a]++;
	}
	vl vec;
	for(auto p: D) {
		if(p.sec >= 2) vec.pb(p.fst);
		if(p.sec >= 4) vec.pb(p.fst);
	}
	if(sz(vec) < 2) cout << 0 << "\n";
	else {
		int n = sz(vec);
		cout << vec[n - 1] * vec[n - 2] << "\n";
	}
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      
      String[] input = sc.nextLine().split(" ");
      int sum = 0;
      for(int i = 0; i < 3; i ++) {
         sum += Integer.parseInt(input[i]);
      }
      System.out.println(sum);
   }
}


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

using namespace std;
struct DSU{
    vector<int> par, size;
    int CC;
    DSU(int n){
        CC = n;
        par.resize(n+1);
        size.assign(n+1, 1);
        iota(par.begin(), par.end(), 0);
    }
    int root(int a){
        return par[a] == a ? a: par[a] = root(par[a]);
    }
    void unite(int a,int b){
        a = root(a);
        b = root(b);
        if(a == b) return;
        if(size[a] < size[b]) swap(a,b);

        par[b] = a;
        size[a] += size[b];
        --CC;
    }
    bool same(int a,int b){
        return root(a) == root(b);
    }
};
int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    DSU dsu(n);
    for(int i=0; i<m; i++){
        int x, y, z;
        scanf("%d %d %d", &x, &y, &z);
        dsu.unite(x, y);
    }
    printf("%d\n", dsu.CC);
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main()
{
   int n,k=0;
   cin>>n;
   int a[n+10];
   for ( int i=1 ; i<=n ; i++ )
    cin>>a[i];
   for ( int i=1 ; i <=n ; i++ )
    if ( a[i]%2 == 0 )
   if ( a[i]%3 != 0 && a[i]%5 != 0 ) {k=1;break;}
   if ( k==0 ) cout<<"APPROVED"<<endl;
   else if ( k==1 ) cout<<"DENIED"<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 100001


int main(){
	int a[N];
	int x[N];
	int y[N];
	f(i, N)a[i] = 0;
	int n, k;
	int z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%d", &n);
	a[0] = 0;
	x[0] = 0;
	y[0] = 0;
	for (int i = 1; i <= n; i++){
		scanf("%d %d %d", &a[i],&x[i],&y[i]);
	}
	for (int i = 0; i < n; i++){
		k = x[i + 1] - x[i];
		if (k < 0)k = -k;
		z = y[i + 1] - y[i];
		if (z < 0)z = -z;
		k += z;
		if (k > a[i + 1] - a[i]){
			v = false;
			break;
		}
		if ((a[i + 1] - a[i] - k) % 2 != 0){
			v = false;
			break;
		}
	}

	if(v)printf("Yes\n");
	else printf("No\n");


	return 0;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <cstdlib>

#include <vector>
#include <cassert>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;

struct Edge {
   int to, weight;
};

int N;
vector< vector<Edge> > adj;

VI vis;
void dfs(int u) {
   vis[u] = 1;
   for (Edge e : adj[u]) {
      int v = e.to;
      if (!vis[v]) {
         dfs(v);
      }
   }
}

int main() {
   int M;
   scanf("%d %d", &N, &M);
   adj = vector< vector<Edge> >(N);
   for (int j = 1; j <= M; ++j) {
      int u, v, w;
      scanf("%d %d %d", &u, &v, &w);
      --u, --v;
      adj[u].push_back({v, w});
      adj[v].push_back({u, w});
   }

   int res = 0;
   vis = VI(N);
   for (int u = 0; u < N; ++u) {
      if (!vis[u]) {
         dfs(u);
         ++res;
      }
   }
   printf("%d\n", res);

   return 0;
}


Measured memory_bytes: 9216
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int a, b, c; cin >> a >> b >> c;
    int ans;
    ans = b / a;
    cout << (ans < c ? ans : c) << endl;
}

Measured memory_bytes: 256
fn solve() {
    let mut n: usize = read();
    let mut base = 26;
    let mut length = 1;
    while let Some(nv) = n.checked_sub(base) {
        n = nv;
        base *= 26;
        length += 1;
    }
    // i桁の26進数を評価
    // 0にする
    base /= 26;
    // println!("{}", n);
    let mut ans = String::new();
    if n == 0 {
        while length > 1 {
            ans.push('z');
            length -= 1;
        }
    } else {
        n -= 1;
        while base > 0 {
            ans.push((b'a' + (n / base) as u8) as char);
            n %= base;
            base /= 26;
        }
    }
    println!("{}", ans);
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 2236
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int N=1010,M=1000010,P=1e9+7;
const int inf=0x3f3f3f3f;
const int INF=0xcfcfcfcf;
const db eps=1e-9,pi=asin(1)*2;
inline ll read();
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
inline int ADD(int a,int b) { return a+b>=P?a+b-P:a+b; }
inline int MINUS(int a,int b) { return a-b<0?a-b+P:a-b; }
#define plus(a,b) a=ADD(a,b)
#define minus(a,b) a=MINUS(a,b)
#define mul(a,b) a=(1ll*a*(b))%P
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define mp(x,y) make_pair(x,y)

int n,nn,d1,d2;
bool col[N][N];

inline void solve(int d)
{
	int tmp=0;
	while(d%4==0) d>>=2,tmp++;
	if(d%4==1)
	{
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				if((i>>tmp)+(j>>tmp)&1) col[i][j]=true;
	}
	else
	{
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				if((i>>tmp)&1) col[i][j]=true;
	}
}

#ifdef FILE
const int RS=1<<20;
char buf[RS],*p1=buf,*p2=buf;
#define getchar() p1==p2&&(p2=(p1=buf)+fread(buf,1,RS,stdin),p1==p2)?EOF:*p1++
#endif
inline ll read()
{
	ll s=0;
	bool flag=false;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') flag=true;
	for(;'0'<=ch&&ch<='9';ch=getchar()) s=(s<<3)+(s<<1)+(ch^'0');
	if(flag) return -s;
	return s;
}

int main()
{
#ifdef FILE
	freopen(FILE ".in","r",stdin);
	freopen(FILE ".out","w",stdout);
#endif
	n=read(),nn=n*n,d1=read(),d2=read(),n<<=1;
	solve(d1),solve(d2);
	for(int i=0,now=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(!col[i][j])
			{
				printf("%d %d\n",i,j);
				now++;
			}
			if(now==nn) break;
		}
		if(now==nn) break;
	}
	return 0;
}

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

int main(void){
    string s;
    cin >> s;
    
    int ans = 0;
    for(int i = 0; i < s.length(); i++){
        if(i % 2 == 0){
            if(s[i] == 'p'){
                ans--;
            }
        }else{
            if(s[i] == 'g'){
                ans++;
            }
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 512
N, K = map(int, input().split())
MOD = 10**9 + 7

num = []
now = N + 1
i = 1
while True:
  r = N // (i+1) + 1
  if r == now:
    break
  num.append(now - r)
  now = r
  i += 1
  
num += [1] * (N - sum(num))
n = len(num)
dp = [[0]*n for i in range(K)]
for _n in range(n):
  dp[0][_n] = num[_n]

for i in range(1, K):
  s = 0
  for _n in range(n):
    j = n - 1 - _n
    s += dp[i-1][j] % MOD
    s %= MOD
    dp[i][_n] = s * num[_n] % MOD

ans = sum(dp[-1])
print(ans % MOD)

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

typedef long long ll;

const int M = 1000005;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> cnt(M);
    for (int x : a)
    {
        if (cnt[x] != 0)
        {
            cnt[x] = 2;
            continue;
        }
        for (int i = x; i < M; i += x)
            cnt[i]++;
    }
    int ans = 0;
    for (int x : a)
    {
        if (cnt[x] == 1)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;

void print(vector<int> vec){
  for(int i=0; i<vec.size(); i++){
    if(i!=0) cout <<" ";
    cout << vec[i];
  }
  cout << endl;
}

int main() {
  int n; cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];

  int N=1;
  for(int i=1; i<=n; i++) N*=i;

  vector<int> v(n);
  iota(v.begin(),v.end(),1);
  vector<vector<int> > b(400000);
  int i=0, k=0;
  do {
    for(auto x:v){
      b[i].push_back(x);
      //cout << x <<" ";
    }
    //cout << endl;
    bool f=true;
    for(int j=0; j<n; j++){
      if(b[i][j]!=a[j]) f=false;
    }
    if(f){
      k=i;
    }
    i++;
  } while(next_permutation(v.begin(),v.end()));

  //cout << k <<" "<< N << endl;
  if(N==1) print(b[k]);
  else if(k==0){
    print(b[k]);
    print(b[k+1]);
  }
  else if(k==N-1){
    print(b[k-1]);
    print(b[k]);
  }
  else {
    print(b[k-1]);
    print(b[k]);
    print(b[k+1]);
  }

}


Measured memory_bytes: 40620
#include<iostream>
using namespace std;
int main (){
    int a=0;
    char b[3];
    for(int i=0;i<3;i++){
        cin >>b[i];
        if(b[i]=='o'){
            a++;
        }
    }
    cout <<700+100*a<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <numeric>

using namespace std;

int main(){
   int a,b;
   cin>>a>>b;
   cout<<(a+b+1)/2<<endl;
}

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

signed main() {
  int N;
  cin >> N;

  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N);


  for( int i = 0; i < N; i++ ) cin >> A.at(i);
  for( int i = 0; i < N; i++ ) cin >> B.at(i);
  for( int i = 0; i < N; i++ ) cin >> C.at(i);
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());
  
  int ue, sita;
  int ans = 0;
  for( int i = 0; i < N; i++ ){
	ue = lower_bound(A.begin(), A.end(), B.at(i)) - A.begin();
	sita = C.end() - upper_bound(C.begin(), C.end(), B.at(i));
	ans += ue*sita;
  }
  cout << ans << endl;
}



Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

int main(){
  ll i,j;
  ll n;
  cin>>n;
  ll ans=0;
  
  for(i=1;i*i<=n;i++){
      if(n%i==0) {
          ll s=i;
          ll t=n/i;
          if(s>t) swap(s,t);
          if(s>0&&s<=t-2) {
              ans+=t-1;
          }
      }
  }
  
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int i,p[3]={0};
  char s[4];
  cin >> s;
  for(i=0;i<3;i++){
    if(s[i]-'a'<3) p[s[i]-'a']=1;
  }
  if(p[0]==1&&p[1]==1&&p[2]==1) cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;
    ll N;
    cin >> N;
    vector<ll> h(N);
    rep(i, N) cin >> h[i];

    ll ans = 0;
    bool flg = true;
    while (1) {
        flg = false;
        ll l = -1, r = -1;

        rep(i, N) {
            if (h[i] > 0) {
                flg = true;
                l = i;
            }

            reps(j, i, N) {
                if (h[j] > 0) {
                    r = j;
                } else
                    break;
            }

            if (flg) break;
        }

        if (!flg) break;

        // cout << "l: " << l << ", r: " << r << endl;
        reps(i, l, r + 1) { h[i]--; }
        ans++;

        // rep(i, N) { cout << h[i] << " "; }
        // cout << endl;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3608