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

const int dx[] = { 0,1 };
const int dy[] = { 1,0 };
char mp[10][10];
bool used[10][10];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, w;
	cin >> h >> w;
	rep(i, h)rep(j, w) cin >> mp[i][j];
	queue<P> que;
	que.emplace(0, 0);
	memset(used, 0, sizeof(used));
	while (que.size()) {
		P p = que.front(); que.pop();
		used[p.first][p.second] = true;
		rep(i, 2) {
			int a = p.first + dx[i], b = p.second + dy[i];
			if (a < 0 || b < 0 || a >= h || b >= w) continue;
			if (mp[a][b] == '.') continue;
			que.emplace(a, b);
			break;
		}
	}
	bool ok = true;
	rep(i, h)rep(j, w) if (mp[i][j] == '#' && !used[i][j]) ok = false;
	if (ok) printf("%s\n", "Possible");
	else printf("%s\n", "Impossible");
	return 0;
}


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

int main() {
  int n, k, ans=0;
  cin >> n >> k;

  int x[n];
  rep(i, n)
  {
    cin >> x[i];
  }

  rep(i, n)
  {
    ans += min(x[i]*2, abs(k-x[i])*2);
  }

  cout << ans << endl;

}


Measured memory_bytes: 3488
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

bool cmp(pii& lhs, pii& rhs) {
  if (lhs.first < rhs.first)
    return true;
  else if (lhs.first == rhs.first)
    return (lhs.second > rhs.second);
  return false;
}

int main() {
  int n;
  cin >> n;
  vector<pii> d;
  rep(t, 3) {
    rep(i, n) {
      int x;
      cin >> x;
      d.emplace_back(make_pair(x, t));
    }
  }
  sort(ALL(d), cmp);
  ll a = 0, b = 0;
  ll ans = 0;
  for (const auto& x : d) {
    // cout << x.first << "," << x.second << endl;
    if (x.second == 0)
      a++;
    else if (x.second == 1)
      b += a;
    else
      ans += b;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6384
from sys import exit, stdin
N, P = [int(_) for _ in stdin.readline().rstrip().split()]
A = [int(_) for _ in stdin.readline().rstrip().split()]

for a in A:
    if a % 2 == 1:
        print(2**(N-1))
        exit()
if P == 1:
    print(0)
else:
    print(2**N)


Measured memory_bytes: 38256
init = input()
num = int(input())

_strings = [''] * (num * 2 + len(init))

fi = num - 1
li = num
for c in list(init):
    _strings[li] = c
    li += 1

isReverse = False

i = 0
while i < num:
    query = input().split()
    type = int(query[0])

    if type == 1:
        # _strings.reverse()
        isReverse = not isReverse
    else:
        mode = int(query[1])

        if (mode == 1 and not isReverse) or (mode == 2 and isReverse):
            _strings[fi] = str(query[2])
            fi -= 1
            # _strings.insert(0, str(query[2]))
        else:
            _strings[li] = str(query[2])
            li += 1
            # _strings.append(str(query[2]))
    i += 1

if isReverse:
    _strings.reverse()

print(''.join(_strings))

Measured memory_bytes: 65912
#include <iostream>
using namespace std;
int main(void){
    int N, number = 0, sum = 0;
    cin >> N;
    number = N;
    if (N < 10){
        cout << "Yes";
    }else{
    for(; number > 0;){
        sum = sum + number % 10;
        number = number / 10;
    }
    if(N % sum == 0){
        cout << "Yes";
    }else{
        cout << "No";
    }
    }
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

//75 = 1*75,3*25,5*15,3*5*5

int cnt[110];
int calc(int num)
{
    int ret=0;
    for(int i = 0; i < 100; i++)
    {
        if(cnt[i]+1>=num) ret++;
    }
    return ret;
}

int main(){
    int n;
    cin>>n;
    for(int i = 0; i < 110; i++)
    {
        cnt[i]=0;
    }
    
    for(int now = 2; now <= n; now++)
    {
        int tmp=now;
        for(int div = 2; div <= n; div++)
        {
            while(tmp%div==0){
                cnt[div]++;
                tmp/=div;
            }
        }
    }
    int ans = calc(75) +
        (calc(3)-1)*calc(25) + calc(15)*(calc(5)-1) +
        calc(5)*(calc(5)-1)*(calc(3)-2)/2;
    cout<<ans<<endl;

    return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key) return u;
  if(k < u->key) return treeSearch(u->left, k);
  else return treeSearch(u->right, k);
}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(Node u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
 
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20492
#include<stdio.h>
int main(void){
int n,i=0;
int a[99];
scanf("%d",&n);

while(scanf("%d",&a[i])==1){
    if(i==n-1) break;
    i++;
}

for(i=n-1;i>=0;i--){
    printf("%d",a[i]);
    if(i!=0)
    printf(" ");
}

printf("\n");
return 0;
}


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

// using namespace std;

// const int T = 100;

// int main() {
// 	int n, m;
// 	cin >> n >> m;
	
// 	int sum = 0;
// 	vector<int> t(n), count(T + 1, 0);
// 	for (int i = 0; i < n; i++) {
// 		cin >> t[i];
// 	}
	
// 	for (int i = 0; i < n; i++) {
// 		int d = sum + t[i] - m, k = 0;
//         cout<<d<<" "<<sum<<"    ";
// 		if (d > 0) {
// 		    for (int j = T; j > 0; j--) {
// 				int x = j * count[j];
// 				if (d <= x) {
// 					k += (d + j - 1) / j;
// 					break;
// 				}
// 				k += count[j];
// 				d -= x;
// 			}
// 		}
// 		sum += t[i];
// 		count[t[i]]++;
// 		cout << k << " "<<endl;
// 	}
// }
#include<bits/stdc++.h>

// @author : sam000013

#define int long long
#define PI 3.14159265
#define fi(i,start,end) for(int i=0; i<n; i++)
#define pb(x) push_back(x)
#define int long long
#define PI 3.14159265
#define all(v) v.begin(), v.end()
#define endl cout<<"\n" 
#define ll long long
#define dbg(x) cout<<#x<<" "<<x;endl;
#define bye endl;return
using namespace std;
int mod = 1000000009;
template<typename T>

void debug(vector<T> x){
    for(auto e:x){
        cout<<e<<" ";
    }
    cout<<"\n";
}
/*
1
8 6
1 2 4 1 2 4 1 2

*/

void solve(int r){
    string s,t;
    cin>>s>>t;
    int n = s.size(), m = t.size();
    int ans = 1e5;
    for(int i=0; i<=n-m; i++){
        int cur = 0;
        for(int j =0; j<m; j++){
            if(s[i+j] != t[j]){
                cur++;
            }
        }
        ans = min(ans, cur);
    }
    cout<<ans;bye;
}

signed main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    // int t = 1;
    //cin>>t;
    for(int i=1; i<=1; i++){
        solve(i);
    }
    return 0;
}

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

string solve() {
    ll N;
    cin >> N;
    vector<vector<int>> G(N);
    ll a, b;
    for ( int i = 0; i < N-1; i++ ) {
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int l = -1, dm = -1;
    vector<int> d(N,-1);
    queue<int> q;
    q.push(0);
    d[0] = 0;
    while ( !q.empty() ) {
        int v = q.front();
        q.pop();
        for ( int u : G[v] ) {
            if ( d[u] >= 0 ) continue;
            d[u] = d[v] + 1;
            q.push(u);
            if ( dm < d[u] )  {
                dm = d[u];
                l = u;
            }
        }
    }
    
    int st = l;
    l = -1, dm = -1;
    d.assign(N, -1);
    q.push(st);
    d[st] = 0;
    while ( !q.empty() ) {
        int v = q.front();
        q.pop();
        for ( int u : G[v] ) {
            if ( d[u] >= 0 ) continue;
            d[u] = d[v] + 1;
            q.push(u);
            if ( dm < d[u] )  {
                dm = d[u];
                l = u;
            }
        }
    }
    int di = dm + 1;
    string ans = di % 3 == 2 ? "Second" : "First";
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 13556
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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

long long n;

long long  cnt(long long  pw) {
	long long  k = n / pw;
	if (n % 2 == 1) {
		if (k % 2 == 1) return (k - 1) / 2 + 1;
		else return k / 2;
	}
	else {
		if (k % 2 == 1) return (k - 1) / 2;
		else return k / 2;
	}
}

int main() {

	cin >> n;
	if (n % 2 == 1) {
		cout << 0;
		return 0;
	}
	long long  pw = 5, q5 = 0;
	while (n >= pw) {
		q5 += cnt(pw);
		pw *= 5;
	}

	pw = 2;
	long long q2 = 0;
	while (n >= pw) {
		q2 += cnt(pw);
		pw *= 2;
	}

	cout << min(q2, q5);

	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

struct Edge
{
    int from, to, cost;
    Edge(int from, int to, int cost) : from(from), to(to), cost(cost) {}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

bool operator<(const Edge &e, const Edge &f)
{
    return e.cost > f.cost;
}

vector<int> dijkstra(const Graph &g, int s)
{
    vector<int> d(g.size(), INF);
    d[s] = 0;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, s)); // P(dis, pos)
    while (!que.empty())
    {
        int dist = que.top().first;
        int v = que.top().second;
        que.pop();
        if (d[v] < dist)
            continue;
        for (const auto &e : g[v])
        {
            if (d[e.to] <= d[v] + e.cost)
                continue;
            d[e.to] = d[v] + e.cost;
            que.push(P(d[e.to], e.to));
        }
    }
    return d;
}

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

    int V, E, r;
    cin >> V >> E >> r;
    Graph g(V);
    for (int i = 0; i < E; i++)
    {
        int s, t, d;
        cin >> s >> t >> d;
        g[s].push_back(Edge{s, t, d});
    }
    vector<int> ret = dijkstra(g, r);
    for (int i = 0; i < V; i++)
    {
        cout << (ret[i] == INF ? "INF" : to_string(ret[i])) << endl;
    }
}



Measured memory_bytes: 15388
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    int L[N];
    for(int i = 0; i < N; i++) {
        cin >> L[i];
    }

    sort(L, L+N);

    int x = 0;
    int flag = 0;

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

    if(L[N-1] < x) {
        flag = 1;
    }

    if(flag == 1) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                           \
    (upper_bound((V).begin(), (V).end(), X) - \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                             \
    {                                        \
        cerr << #v << ':';                   \
        for (auto xv : v) cerr << xv << ' '; \
        cerr << endl;                        \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* library */

/* main */

ll N;

vl H;

bool memo[330][330];
ll memo_value[330][330];

ll dfs(int index, int k) {
    if (index >= N) {
        return 0;
    }
    if (memo[index][k]) {
        return memo_value[index][k];
    }
    ll res = max(0, H[index + 1] - H[index]) + dfs(index + 1, k);
    for (size_t i = 0; i <= k; i++) {
        ll tmp = 0;
        if (index + i + 1 <= N) {
            tmp = max(0, H[index + i + 1] - H[index]) + dfs(index + i + 1, k - i);
        }
        res = min(res, tmp);
    }
    memo[index][k] = true;
    return memo_value[index][k] = res;
}

signed main() {
    ll K;
    cin >> N >> K;
    H.resize(N + 1);
    H[0] = 0;
    for (size_t i = 0; i < N; i++) {
        cin >> H[i + 1];
    }
    cout << dfs(0, K) << endl;
}

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

#define rep(i,a,b)                for(ll i=a;i<b;i++)
#define repr(i,n)                for(ll i=n-1;i>=0;i--)
#define ll long long int
#define ld long double
#define llu long long unsigned
#define vll std::vector<ll>
#define mll std::map<ll, ll>
#define sll std::set<ll>
#define msll std::multiset<ll>
#define all(c) c.begin(), c.end()
#define allr(c) c.rbegin(), c.rend()
#define srt(x) sort(all(x))
#define rsrt(x) sort(allr(x))
#define mp make_pair
#define pb push_back
#define mod 1000000007

/*
                    ** author **
                ** Parth Lathiya **
    ** https://www.cse.iitb.ac.in/~parthiitb/ **
*/

int main()
{

ios::sync_with_stdio(false);


//  --------------------------------------------------------------------------------------

int a[7]={1, 3, 5, 7, 8, 10, 12};
int b[4]={4, 6, 9, 11};
int c[1]={2};

//  --------------------------------------------------------------------------------------

int x,y;
cin>>x>>y;

if(x==2 || y==2)
	cout<<"No";

else
{
	int f1=0,f2=0;
	rep(i,0,4)
	{
	if(b[i]==x)f1=1;
	if(b[i]==y)f2=1;

	}
	if((f1 && !f2)  || (!f1 && f2)) 
		cout<<"No";
		else
		{cout<<"Yes";}
}
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	int n;
	cin >> n;
	int x=0,y=0;
	for(int i = 0;i<n;i++)
	{
		int t,X,Y;
		cin >> t >> X >> Y;
		if(abs(x-X)+abs(y-Y)<=t&&abs((abs(x-X)+abs(y-Y))-t)%2==0)
		{

		}
		else
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

signed main(void)
{
	int n, d;
	int i = 1;
	cin >> n >> d;

	while(n > (d * 2 + 1) * i)
		i++;
	cout << i << endl;
	return 0;
}


Measured memory_bytes: 764
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        a, b = map(int, input().split())

        if b < 0:
            if (b - a) % 2 == 0:
                print('Negative')
            else:
                print('Positive')
        elif a <= 0:
            print('Zero')
        else:
            print('Positive')
        
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()


Measured memory_bytes: 3568
from itertools import accumulate, islice

h, w, d = map(int, input().split())
xys = [[int(x) for x in input().split()] for _ in range(h)]
q = int(input())
lrs = [tuple(map(int, input().split())) for _ in range(q)]

dict_ = {v:(x, y) for y, row in enumerate(xys) for x, v in enumerate(row)}
def jump_cost(xy1, xy2):
    x1, y1 = dict_[xy1]
    x2, y2 = dict_[xy2]
    return abs(x1-x2) + abs(y1-y2)

d_ = {}
for i in range(d):
    values = range(i+1, h*w+1, d)
    startend = zip(values, islice(values, 1, None))
    costs = (jump_cost(xy1, xy2) for xy1, xy2 in startend)
    running_totals = [0] + list(accumulate(costs))
    d_.update(dict(zip(values, running_totals)))

for l, r in lrs:
    print(d_[r] - d_[l])

Measured memory_bytes: 54732
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#include<map>
#include <limits>
# include <iomanip>
#include <queue>
#define INF 1000000000000000009;
#define WARU 1000000007;

using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}

int main() {
	int sx = 0, sy = 0, tx = 0, ty = 0;
	//int a[100];
	cin >> sx >> sy >> tx >> ty;
	for (int i = 0; i < tx-sx; i++) {
		cout << "R";
	}
	for (int i = 0; i < ty - sy; i++) {
		cout << "U";
	}
	for (int i = 0; i < tx - sx; i++) {
		cout << "L";
	}
	for (int i = 0; i < ty - sy+1; i++) {//+1は二回目で外周に移動するため
		cout << "D";
	}
	for (int i = 0; i < tx - sx+1; i++) {
		cout << "R";
	}
	for (int i = 0; i < ty - sy+1; i++) {
		cout << "U";
	}
	cout << "LU";
	for (int i = 0; i < tx - sx+1; i++) {
		cout << "L";
	}
	for (int i = 0; i < ty - sy+1; i++) {
		cout << "D";
	}
	cout << 'R' << endl;
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define qwq(x) cout<<"# "<<#x<<" = "<<x<<endl;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=1000005,mod=998244353;
int fac[N],rev[N],n,K,ans;

int power(int x,int p){
	int res=1;
	for(;p;p>>=1,x=(ll)x*x%mod)
		if(p&1)res=(ll)res*x%mod;
	return res;
}

int C(int n,int m){
	return m<0||m>n?0:(ll)fac[n]*rev[m]%mod*rev[n-m]%mod;
}

int fix(int x){
	return x>=mod?x-mod:x;
}

void init(int lim){
	fac[0]=1;
	rep(i,1,lim)fac[i]=(ll)fac[i-1]*i%mod;
	rev[lim]=power(fac[lim],mod-2);
	per(i,lim,1)rev[i-1]=(ll)rev[i]*i%mod;
}

int main(){
	read(n),read(K);
	init(1000000);
	for(int red=max(n,(K+1)/2);red<=K;red++){
		int blue=K-red,f=blue==red;
		ans=fix(ans+fix(C(K-f,red)+mod-C(K-f,red*2-(n-1))));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8064
#import numpy as np
import math
#from fractions import gcd

def check_Q(current_list,Qset):

    sum_d = 0
    for i in range(len(Qset)):
        current_Qset = Qset[i]
        #print(current_Qset)
        #print(current_list)
        #print(sum_d)
        if (current_list[current_Qset[1]-1]-current_list[current_Qset[0]-1])==current_Qset[2]:
            sum_d = sum_d+current_Qset[3]

    return sum_d

def check_N(preget_list,zan_pre,M,nokori_N,Qset):

    if nokori_N==1:
        sum_list = []
        for i in range(zan_pre,M+1):
            current_list = preget_list+[i]
            sum_list.append(check_Q(current_list,Qset))

        return sum_list
    else:
        sum_list = []
        for i in range(zan_pre,M+1):
            current_list = preget_list+[i]
            sum_list = sum_list + check_N(current_list,i,M,nokori_N-1,Qset)

        return sum_list

def main():

    ##get int
    first_input = list(map(lambda x:int(x), input().split(" ")))
    #second_input = list(map(lambda x:int(x), input().split(" ")))

    ##get float
    #first_input = list(map(lambda x:float(x), input().split(" ")))
    #second_input = list(map(lambda x:float(x), input().split(" ")))

    ##get string
    #first_input = input().split(" ")

    N = first_input[0]
    M = first_input[1]
    Q = first_input[2]

    Qset = []
    for i in range(Q):
        secondkara_input = list(map(lambda x:int(x), input().split(" ")))
        Qset.append(secondkara_input)

    #print(check_N([],1,M,N,Qset))
    print(max(check_N([],1,M,N,Qset)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 90564
function Main (input) {
  let N = Number(input);
  let sum = 0;
  for(let i = 1; i < (N + 1); i++){
      if((i % 3 !== 0) && (i % 5 !== 0)) {
        sum += i;
      }
  }
  console.log(sum);
}
  
  
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 35076
open System
let R T = stdin.ReadLine()|> T
let RS T = stdin.ReadLine().Split()|>Array.map T
let Mod = (1e9|>int64)+7L
[<EntryPoint>]
let main argv =
    let N,K = RS int|>fun c -> c.[0],c.[1]
    RS int64
    |>Array.sort
    |>fun c -> c.[0..N-K-1]
    |>Array.sum
    |>stdout.WriteLine
    0

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

#include <iostream>
using namespace std;

int n, a[2000001];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;
    
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);

    for (int i = 0; i < n - 1; i++) {
        if (a[i] == a[i + 1]) {
            cout << "NO";
            return 0;
        }
    }

    cout << "YES";
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#define FOR(i, a, b)  for(int i=a;i<=b;++i)
#define rep(i, n) for(int i=0;i<n;++i)
using namespace std;

int main(){
  int a, b, c;  cin >> a >> b >>c;
  cout << ((a+b) >= c ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(i=0; i<n; i++)
int sum=0;
int main(){
  int N,K,X,Y;
  cin>>N>>K>>X>>Y;
  if(N>=K){
    sum=X*K+(N-K)*Y;
    cout<<sum;
  }
  else{
    sum=X*N;
    cout<<sum;
  }
}

Measured memory_bytes: 764
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:1024000000")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;




int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	int n;
	ll d, a;
	cin >> n >> d >> a;
	vector<pair<ll, ll>> ar(n);
	for (int i = 0; i < n; i++)
	{
		cin >> ar[i].first >> ar[i].second;
		ar[i].second = (ar[i].second + a - 1) / a;
	}
	sort(all(ar));
	queue<pair<ll, ll>> q;
	ll res = 0;
	ll cur = 0;
	for (int i = 0; i < n; i++)
	{
		while (!q.empty() && q.front().first < ar[i].first)
		{
			cur -= q.front().second;
			q.pop();
		}
		if (cur >= ar[i].second)
			continue;
		ll dif = ar[i].second - cur;
		res += dif;
		cur += dif;
		q.emplace(ar[i].first + d * 2, dif);
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 4992
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def base_10_to_n(X, n):
    ans = []

    while X > 0:
        X -= 1
        ans.insert(0, X % n)
        X //= n

    return ans


def main():
    N = int(input())
    n26 = base_10_to_n(N, 26)

    ans = []

    for n in n26:
        ans.append(chr(97 + int(n)))
    
    print("".join(ans))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9184
#include<bits/stdc++.h>
#define ll 				long long
#define ld 				long double
#define fastio 			ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(x) 		cerr<<#x<<" "<<x<<endl
#define cina(a,n) 		for(ll i = 0;i<n;i++)	cin>>a[i];
#define couta(a,n) 		for(ll i = 0;i<n;i++) cout<<a[i]<<" ";
#define fauto(ar)		for(auto x : ar)	cout<<x<<" ";
#define mod 			1000000007
#define inf				10010010010010010
#define siz 			3005
#define f 				first
#define s 				second
#define pb 				push_back
#define endl 			"\n"
#define ci 				cin.ignore()
using namespace std;
ll dp[siz][siz];
ll getans(ll *a,ll n,ll s,ll e)
{
	if(s > e)	return 0;
	if(s == e)	return a[s];
	if(dp[s][e] != -inf)	return dp[s][e];
	return dp[s][e] = max(a[s] + min(getans(a,n,s+1,e-1),getans(a,n,s+2,e)),a[e] + min(getans(a,n,s+1,e-1),getans(a,n,s,e-2)));
}
int main()
{
	ll n,i,j = 0;
	cin>>n;
	ll a[n];
	cina(a,n);
	for(i = 0;i<n+1;i++)	for(j = 0;j<n+1;j++)	dp[i][j] = -inf;
	j = 0;
	for(ll x : a)
	j += x;
//	debug(getans(a,n,0,n-1));
	cout<<2*getans(a,n,0,n-1)-j;
}

Measured memory_bytes: 74120
#ifdef __GNUC__
#pragma GCC target("avx2")
#pragma GCC optimize ("O30")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC optimize("unroll-loops")
#define iss std::cin
#endif
#include "bits/stdc++.h"
#define rep(i, times) for(ll i = 0; i < (times); ++i)
#define p(x) (cout << (x) << "\n")
using ll = long long; using ld = long double; using namespace std;

class Festival
{
	ll N{0};
	vector<vector<ll>> A;
	void inp( ) {
		iss >> N; A.resize(3, vector<ll>(N));
		for (auto &abc : A) {
			for (auto &a : abc)  iss >> a;
		}		
		sort(begin(A[0]), end(A[0]));
		sort(begin(A[2]), end(A[2]));
	}
	void biSearch( ) {
		ll cnt{0};
		for (auto &b : A[1]) {
			cnt += (end(A[2]) - upper_bound(begin(A[2]), end(A[2]), b))
				* (lower_bound(begin(A[0]), end(A[0]), b) - begin(A[0]));
		}
		p(cnt);
	}
public:
	void procedures( ) {
		inp( );	biSearch( );
	}
};
int main( ) {
	cin.tie(0);	ios::sync_with_stdio(0);
	class Festival a; a.procedures( );
}

Measured memory_bytes: 6360
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let a: u32 = sc.read();
    let b: u32 = sc.read();
    println!("{} {}", a*b, a*2 + b*2);
}

use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
 
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


Measured memory_bytes: 5024
N = int(input())

A = []
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))

if N > 1:
    up = A[0][1]
    down = A[1][0]

    for i in range(1, N-1):
        up_ = up + A[1][i]
        down += A[1][i]
        up += A[0][i+1]

        down = max(down, up_)

    print(max(up, down)+A[0][0]+A[1][N-1])
else:
    print(A[0][0]+A[1][0])


Measured memory_bytes: 3064
import sys
input=sys.stdin.readline
n=int(input())
button=[False]*(n+1)
button[1]=True
a={}
for i in range(1,n+1):
    ai=int(input())
    a[i]=ai
tmp=1
pushed={}
ans=0
while not button[2]:
    button[tmp]=False
    if tmp in pushed:
        print(-1)
        exit()
    pushed[tmp]=1
    tmp=a[tmp]
    button[tmp]=True
    ans+=1
print(ans)

Measured memory_bytes: 30972
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.math.BigDecimal;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    BigDecimal a = new BigDecimal(str[0]);
    BigDecimal b = new BigDecimal(str[1]);
    System.out.println((a.multiply(b)).setScale(0,BigDecimal.ROUND_DOWN));
  }
}

Measured memory_bytes: 33160
/******************************************
* 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))
int resf(bool bits[],int n, int index, int gmaxi,vector<pair<int,bool>>v[])
{
	if(index==n+1)
		return gmaxi;
	int i,j;
	int maxi=0;
	int check[16];
	memset(check,-1,sizeof(check));
	bool yes=true;
	for(i=1;i<=n;i++)
	{
		if(bits[i])
		{
			for(int j=0;j<v[i].size();j++)
			{
				bool curr=v[i][j].S;
				int banda= v[i][j].F;
				if(check[banda]==-1)
				{
					if(bits[banda]==curr)
					{
						check[banda]=curr;
					}
					else 
					{
						yes=false;
						break;
					}
				}
				else
				{
					if(check[banda]==curr)
					{
						//ok
					}
					else
					{
						//not ok
						yes=false;
						break;
					}
				}
			}
		}
	}
	if(yes==true)
	{
		int count=0;
		for(i=1;i<=n;i++)
		{
			if(bits[i])
				count++;
		}
		gmaxi=max(count,gmaxi);
	}
	for(i=index+1;i<=n;i++)
	{
		bits[i]=1;
		gmaxi=max(gmaxi,resf(bits,n,i,gmaxi,v));
		bits[i]=0;
	}
	return gmaxi;
} 
int main() {
	fastio;
	int n,i,j;
	cin>>n;
	vector<pair<int,bool>>v[n+1];
	for(i=0;i<n;i++)
	{
		int t;
		cin>>t;
		while(t--)
		{
			int a,b;
			cin>>a>>b;
			v[i+1].pb(mp(a,b));
		}
	}
	bool bits[16]={0};
	int res= resf(bits,n,0,0,v);
	cout<<res<<endl;
	return 0;
}

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

int n, x, a, b, c;

bool ok(){
    if(c <= a){
        return 1;
    }
    if(c == a + 1){
        return b ? 0 : 1;
    }
    return 0;
}

int main(){
    while(~scanf("%d", &n)){
        a = b = c = 0;
        for(int i=0; i<n; i++){
            scanf("%d", &x);
            x %= 4;
            if(x == 0){
                a++;
            } else if(x == 2){
                b++;
            } else {
                c++;
            }
        }
        puts(ok()?"Yes":"No");
    }
    return 0;
}


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

int main() {
  string N;
  cin >> N;
  
  int p=N.size();
  int answer=0;
  
  for(int i=0;i<p-1;i++){
    if(N.at(i)!=N.at(i+1)){
      answer++;
    }
  }
  
  cout<<answer<<endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<utility>
#include<cmath>
using namespace std;
#define all(a) a.begin(),a.end()
int main()
{
	int n;
	while(cin>>n&&n)
	{
		vector<int> a;
		for(int i=0;i<n;i++)
		{
			int x;cin>>x;
			a.push_back(x);
		}
		int ans=0;
		bool ok=true;
		while(ok)
		{
			ok=false;
			for(int i=0;i<n-1;i++)
			{
				if(a[i]>a[i+1])
				{
					ans++;ok=true;
					swap(a[i],a[i+1]);
				}
			}
		}
		cout<<ans<<endl;
		
		
		
	}
	
}

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

int main() {
  int N;
  cin >>N;
  for (int i=0;i<N;i++){
    string S;
    cin >> S;
    if (S=="Y"){
      cout << "Four"  <<endl;
      break;
    }
    if (i == N-1){
      cout << "Three" <<endl;
    }
  }
}

Measured memory_bytes: 3564
function Main(input) {
    var data = input.split("\n")
    var answer = Infinity;
	for(var i=1; i<=Math.sqrt(data[0]);i++){
		if(data[0]%i===0 ){
			var m = (data[0]/i-1) + (i-1);
			if( m < answer) {
				answer = m;
			}
		}
	}
	console.log(answer)
}
 
// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

int n, t;

int solve(vector<int> &l, vector<int> &r) {
    int ans = LLONG_MAX;
    for (int i = 0; i < r.size(); i++) {
        if (i + 1 > t)continue;
        if (i + 1 == t)ans = min(ans, r[i]);
        int xtra = t - (i + 1);
        if(xtra == 0)continue;

        if (xtra <= l.size()) {
            ans = min(ans, 2 * r[i] + l[xtra - 1]);
        }
    }
    return ans;
}

void solve() {
    cin >> n >> t;

    vector<int> neg, pos;
    for (int i = 0; i < n; i++) {
        int tp;
        cin >> tp;
        if (tp < 0)neg.push_back(-tp);
        else pos.push_back(tp);
    }
    sort(neg.begin(), neg.end());
    int ans = min(solve(neg, pos), solve(pos, neg));
    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 1656
/*
我的心脏怦怦跳，监管者就在附近
name:
Algorithm:
writer:Lxs(cdx)
place:
nothing is impossible
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
int main()
{
	int a;
	cin>>a;
	cout<<a*2*3.141592653589793116<<endl;
	return 0;
}


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

int main(){
  int n,d,s;
  cin >> n;
  cin >> d;
  int x[10][10];
  for (int i=0; i<n; i++){
    for (int j=0; j<d; j++){
      cin >> x[i][j];
    }
  }
  int ans = 0;
  for (int i=0; i<n-1; i++){
    for (int k=i+1; k<n; k++){
      s = 0;
        for (int j=0; j<d; j++){
          s += pow(x[i][j] - x[k][j], 2);
        }
      int p = sqrt(s);
      if(p*p == s){
        // cout << s << endl;
        // cout << p << endl;
        ans += 1;
      }
    }
  }
  cout << ans;
  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 K = sc.nextInt();
        int S = sc.nextInt();
        int ans = 0;
        for(int X=0; X<=K; X++){
            for(int Y=0; Y<=K; Y++){
                int Z = S-X-Y;
                if(Z>=0&&Z<=K)ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 9684
n = int(input())
list_s = []
for i in range(n):
    dict_i = {}
    si = str(input())
    for j in range(len(si)):
        try:
            dict_i[si[j]] += 1
        except KeyError:
            dict_i[si[j]] = 1
    list_s.append(dict_i)

set_ans = set(list_s[0].keys())
for dic in list_s:
    set_ans = set_ans & set(dic.keys())
dic_ans = {}
for alp in set_ans:
    dic_ans[alp] = 100

for dic in list_s:
    for key, value in dic.items():
        try:
            if dic_ans[key] > value:
                dic_ans[key] = value
        except KeyError:
            pass
list_ans = []
for key, value in dic_ans.items():
    for i in range(value):
        list_ans.append(key)
list_ans.sort()
if len(list_ans) == 0:
    print("")
else:
    print("".join(list_ans))


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

int main() {
  int n = 100000;
  vector<bool> p(n + 1, true);
  for (int i = 2; i <= n; i++) {
    if (p[i]) {
      for (int j = 2 * i; j <= n; j += i) {
        p[j] = false;
      }
    }
  }
  vector<int> v;
  for (int i = 2; i <= n; i++) {
    if (p[i]) v.push_back(i);
  }

  int m, a, b;
  while (cin >> m >> a >> b, m) {
    int p = 0, q = 0;
    for (int i = 0; i < v.size(); i++) {
      for (int j = i; j < v.size() && (long long)v[i] * v[j] <= (long long)m && a * v[j] <= b * v[i]; j++) {
        if (v[i] * v[j] > v[p] * v[q]) {
          p = i;
          q = j;
        }
      }
    }
    cout << v[p] << " " << v[q] << endl;
  }
}



Measured memory_bytes: 3276
N = int(input())
if N >= 64:
  print(64)
elif N >= 32:
  print(32)
elif N >= 16:
  print(16)
elif N >= 8:
  print(8)
elif N >= 4:
  print(4)
elif N >= 2:
  print(2)
else:
  print(1)

Measured memory_bytes: 3060
from collections import deque
H,W = map(int, input().split())
A = [input() for _ in range(H)]

inf = 10**6
d = [[inf]*W for _ in range(H)]
q = deque()
for i in range(H):
    for j in range(W):
        if A[i][j] == "#":
            q.append((i, j, 0))
            d[i][j] = 0
            
while q:
    temp = q.popleft()
    x = temp[0]
    y = temp[1]
    r = temp[2]
    if x > 0 and d[x-1][y] > r+1:
        d[x-1][y] = r+1
        q.append((x-1, y, r+1))
    if y > 0 and d[x][y-1] > r+1:
        d[x][y-1] = r+1
        q.append((x, y-1, r+1))
    if x < H-1 and d[x+1][y] > r+1:
        d[x+1][y] = r+1
        q.append((x+1, y, r+1))
    if y < W-1 and d[x][y+1] > r+1:
        d[x][y+1] = r+1
        q.append((x, y+1, r+1))

ans = 0
for i in range(H):
    ans = max(ans, max(d[i]))
print(ans)

Measured memory_bytes: 163420
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  int t[n],x[n],y[n];
  REP(i,n) cin >> t[i] >> x[i] >> y[i];
  REP(i,n){
    if(abs(x[i]+y[i]) > t[i]){
      cout << "No" << endl;
      return 0;
    }
    if(t[i]%2==0 && (x[i]+y[i])%2==1){
      cout << "No" << endl;
      return 0;
    }else if(t[i]%2==1 && (x[i]+y[i])%2==0){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


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

int main(){
    ios_base::sync_with_stdio(0);
    int n,y;
    cin>>n>>y;
    int ans = 0;
    for(int i=0;i<=2000;i++){
        if(i*10000>y||i>n) break;
        for(int j=0;j<=2000;j++){
            if(i*10000+j*5000>y||i+j>n) break;
            int z = y-i*10000-j*5000;
            if(z%1000==0){
                z = z/1000;
                if(i+j+z==n){
                    cout<<i<<' '<<j<<' '<<z;
                    return 0;
                }
            }
        }
    }
    cout<<"-1 -1 -1";
    return 0;
}


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

using namespace std;

int main(){
	long long k;
	cin >> k;
	if(k%2==0 || k%5==0){
		return cout << "-1\n",0;
	}
	int cur=7%k;
	int ans=1;
	while(cur!=0){
		cur=cur*10+7;
		cur%=k;
		ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3592
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n';
#define no cout<<"No"<<'\n';
using namespace std;

int main()
{
    godspeed
    ll  t,i,x,j,k,n;
    string s;
    cin>>x>>t;
     cout<<max(0LL,x-t)<<endl;

    return 0;
}





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

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

	int n;
	cin >> n;
	vector<long long> arr(n + 1);
	arr[0] = 2;
	arr[1] = 1;
	for (int i = 1; i < n; ++i) {
		arr[i + 1] = arr[i] + arr[i -1];
	}
	
	cout << arr[n] << endl;
	return 0;
}

Measured memory_bytes: 256
// Created by Bingoo on 7/8/2020.
#include"bits/stdc++.h"
using namespace std ;
#define ll  long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

template <class ...Args>
auto &see(const Args &...args) {return ((cerr << " " << args), ...) << '\n';}
#define bug(...)  cerr << "[ "#__VA_ARGS__" ] = "; see(__VA_ARGS__) << '\n';
//C++17
template<typename... Args>
void read(Args&... args){((cin >> args), ...);}
template<typename... Args>
void write(Args... args){((cout << args << " "), ...);}

ll mod = 1e6 +3 ;
ll power(ll a, ll b)	//a is base, b is exponent
{
    if (b == 0)
        return 1;
    if (b == 1)
        return a;
    if (b % 2 == 1)
        return (power(a, b - 1) * a) % mod;
    ll q = power(a, b / 2);
    return (q * q) % mod;
}

bool comp(pair<int,int>&a ,pair<int,int>&b)
{
    return a.second > b.second ;
}



int a ,b ,n ;



int main(){
    cin >> n ;

    int v[n],c[n];

    for (int i = 0; i < n; ++i) {
        cin >> v[i] ;
    }
    for (int j = 0; j < n; ++j) {
       cin >> c[j] ; 
    }
    int X=0,Y=0, mx=0;
    for (int k = 0; k <n ; ++k) {
        if(v[k]>c[k]){
            X += v[k] ;
            Y += c[k] ;
            mx= max(mx,X-Y);
        }

    }
    cout << mx << '\n' ;


}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int a,b;cin>>a>>b;
    cout<<max(0,a-2*b)<<endl;
}


Measured memory_bytes: 256