akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

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

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



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

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int main(){
	int s, w;
	cin >> s >> w;
	if(s <= w)
		cout << "unsafe" << endl;
	else
		cout << "safe" << endl;
	return 0;
}

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

ll a[100005], b[100005], c[100005], n;
ll dp[100005][4];

ll solve(ll day, ll activity){
	if(day == n+1){
		return 0;
	}
	if(dp[day][activity] != -1){
		return dp[day][activity];
	}
	if(activity == 1){
		return dp[day][activity] = a[day] + max(solve(day+1, 2), solve(day+1, 3));
	}
	else if(activity == 2){
		return dp[day][activity] = b[day] + max(solve(day+1, 1), solve(day+1, 3));
	}
	else if(activity == 3){
		return dp[day][activity] = c[day] + max(solve(day+1, 1), solve(day+1, 2));
	}
}

int main(){
	
	cin>>n;

	for(ll i=1;i<=n;i++){
		cin>>a[i]>>b[i]>>c[i];
	}
	memset(dp, -1, sizeof(dp));
	cout<<max(max(solve(1, 1), solve(1, 2)), solve(1, 3));

	return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

const int N = 200100;
const int M = 998244353;
// long long?

ll fat[N],inv[N];
ll C(int n,int k){
  if(k>n)return 0;
  return mod(fat[n]*mod(inv[k]*inv[n-k],M),M);
}

void init(){
  fat[0] = inv[0] = 1;
  for(int i=1;i<N;i++){
    fat[i] = (1LL*fat[i-1]*i)%M;
  }
  inv[N-1] = exp(fat[N-1],M-2,M);
  for(int i=N-2;i>=0;i--){
    inv[i] = (inv[i+1]*(i+1))%M;
  }
}

int32_t main(){
  fastio;
  int n,m,k;
  cin>>n>>m>>k;
  init();
  int res=0;
  for(int i=0;i<=k;i++){
    // usa exatamente i
    int ways1 = exp(m,1,M);
    int ways2 = exp(m-1,n-1-i,M);
    int ways3 = C(n-1,i);
    res = mod(res + mod(ways1*mod(ways2*ways3,M),M),M);
  }
  cout << res << endl;
  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

Measured memory_bytes: 6788
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            :oyhhhhhhyo:    
#define next         .sdNNNmNNNNNNNmds. 
#define y0          -hNNNNy`yNNNNNN`/Nh-
#define y1          mNNNNNd+dNNNNNN+sNNm
#define yn          mNNNNNNNNy--:smNNNms
#define tm          .+oooooosyysooooo+- 
#define read               :yhy/        
#define rank              :mNmo         
#define index              ... 
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
#define int long long
typedef long long ll;
using namespace std;

const int N = 111111;
int d[N], m[N];
int n;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    rep(i, 1, n) {
        cin >> d[i];
    }
    rep(i, 1, n) {
        m[1] += (i % 2 * 2 - 1) * d[i];
    }
    rep(i, 2, n) {
        m[i] = 2 * d[i - 1] - m[i - 1];
    }
    rep(i, 1, n) {
        cout << m[i] << " ";
    }
    return 0;
}


Measured memory_bytes: 2944
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int N, M, Q;

struct query {
	int T;
	int make;//0:ques 1:make
	int A, B;
	int id;
};

vector<int>par;
int getPar(int x) {
	if (x == par[x])return x;
	return par[x] = getPar(par[x]);
}
void unite(int a, int b) {
	a = getPar(a);
	b = getPar(b);
	if (a == b) {
		return;
	}
	if (a > b) {
		par[b] = a;
	}
	else {
		par[a] = b;
	}
}

int main(void)
{
	cin >> N >> M >> Q;
	vector<query>que;
	for (int i = 0; i < N; ++i) {
		par.push_back(i);
	}
	for (int i = 0; i < M; ++i) {
		int d, a, b;
		cin >> d >> a >> b;
		--a; --b;
		que.push_back({ d,1,a,b });
	}
	set<int>suk;
	for (int i = 0; i < N - 1; ++i) {
		suk.insert(i);
	}
	for (int i = 0; i < Q; ++i) {
		int e, s, t;
		cin >> e >> s >> t;
		--s; --t;
		que.push_back({ e,0,s,t,i });
	}
	sort(que.begin(), que.end(), [](const query&q1, const query&q2) {
		return make_pair(q1.T, q1.make) < make_pair(q2.T, q2.make);
	});
	vector<pair<int, bool>>ans;
	for (auto&q : que) {
		int T = q.T;
		int make = q.make;
		if (make == 1) {
			int A = q.A;
			int B = q.B;
			auto itr = suk.lower_bound(A);
			auto ptr = suk.lower_bound(B);
			while (itr != ptr) {
				int x = *itr;
				unite(x, x + 1);
				//++itr;
				itr = suk.erase(itr);
			}
		}
		else {
			int S = q.A;
			int T = q.B;
			int id = q.id;
			if (S >= T) {
				//cout << "Yes" << endl;
				ans.push_back({ id,true });
			}
			else {
				int SS = getPar(S);
				if (SS >= T) {
					//cout << "Yes" << endl;
					ans.push_back({ id,true });
				}
				else {
					//cout << "No" << endl;
					ans.push_back({ id,false });
				}
			}
		}
	}
	sort(ans.begin(), ans.end());
	for (auto x : ans) {
		cout << (x.second ? "Yes" : "No") << endl;
	}
	return 0;
}



Measured memory_bytes: 13120
import itertools
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = [str(i) for i in range(10) if i not in a]
anslist = b + list(itertools.product(b,b))
anslist += list(itertools.product(b,b,b))
anslist += list(itertools.product(b,b,b,b))
anslist += list(itertools.product(b,b,b,b,b))
anslist += list(itertools.product(b,b,b,b,b,b))
anslist = [int("".join(i)) for i in anslist ]
#print(anslist)
#print(b)
anslist.sort()
for i in anslist:
    if i >= n:
        print(i)
        exit()

Measured memory_bytes: 123552
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

struct _tuple{
    int first, second, third;
    _tuple(int _first=0, int _second=0, int _third=0){
        first=_first;
        second=_second;
        third=_third;
    }
};

typedef _tuple tiii;

void solve(){
    int n;
    cin>>n;
    vector<tiii> a(n);
    vector<tiii> dp(n,_tuple(0,0,0));
    for(int i=0;i<n;i++){
        cin>>a[i].first>>a[i].second>>a[i].third;
    }
    for(int i=0;i<n;i++){
        if(i>0){
            dp[i].first=max(dp[i-1].second+a[i].first,dp[i-1].third+a[i].first);
            dp[i].second=max(dp[i-1].first+a[i].second,dp[i-1].third+a[i].second);
            dp[i].third=max(dp[i-1].first+a[i].third,dp[i-1].second+a[i].third);
        }
        else{
            dp[i]=a[i];
        }
    }
    cout<<max(dp[n-1].first,max(dp[n-1].second,dp[n-1].third))<<endl;
}

int main()
{
    //freopen("IN.txt","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 5560
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (double i = (a); i < (b); i++)
typedef long long ll;

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


Measured memory_bytes: 3280
l=[int(i) for i in input().split()]
ans=max(l)**3
for i in range(3):
    t=l[(0+i)%3]*l[(1+i)%3]
    ans=min(ans,t*((l[(2+i)%3]+1)//2)-t*(l[(2+i)%3]//2))
print(ans)

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

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

    int n, k;
    cin >> n >> k;

    if(k == 10){
        string s = to_string(n);
        cout << (int)s.size() << endl;
        return 0;
    }

    if(n == 1){
        cout << 1 << endl;
        return 0;
    }

    int cnt = 0;
    while(true){
        n /= k;
        cnt++;
        if(n < k) break;
    }

    cout << cnt + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<bitset>
#include<cstdio>
#define Re register
#define maxn 500005
std::bitset<maxn> f;
int p[maxn];
int l,r,ans;
int num[1000005],re[1000005];
int main()
{
	scanf("%d%d",&l,&r);
	f[0]=1;
	f[1]=1;
	for(Re int i=2;i<=35000;i++)
	{
		if(!f[i]) p[++p[0]]=i;
		for(Re int j=1;j<=p[0]&&p[j]*i<=35000;j++)
		{
			f[p[j]*i]=1;
			if(i%p[j]==0) break;
		}
	}
	for(Re int i=l;i<=r;i++) re[i-l]=i;
	for(Re int i=1;i<=p[0];i++)
	{
		for(Re int j=2;j*p[i]<=r;j++)
		if(p[i]*j>=l)
		{
			while(re[j*p[i]-l]!=1&&re[j*p[i]-l]%p[i]==0) re[j*p[i]-l]/=p[i],num[j*p[i]-l]++;
		}
	}
	for(Re int i=l;i<=r;i++)
	{
		if(re[i-l]!=1) num[i-l]++;
		if(!f[num[i-l]]) ans++;
	}
	std::cout<<ans;
	putchar(10);
	return 0;
}


Measured memory_bytes: 11072
import java.util.*;

public class Main {
	public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        int a, b,c,d;
        a = sc.nextInt(); // 高橋体力
        b = sc.nextInt(); // 高橋攻撃
        c = sc.nextInt(); // 青木体力
        d = sc.nextInt(); // 青木攻撃
        for(int i=0;;i++){
            if(i%2==0){
                //高橋が青木攻撃
                c=c-b;
                if(c<=0){
                    System.out.println("Yes");
                    break;
                }
            }else{
                //青木が高橋攻撃
                a=a-d;
                if(a<=0){
                    System.out.println("No");
                    break;
                }

            }
        }

    }
}

Measured memory_bytes: 27072
/********************************************//**
 ****** Author: Shivam Kejriwal *****************
 ****** Handle: techno_phyle    *****************
 ***********************************************/

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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long ll;

#define mod 1000000007
#define N 100010
#define M 100010
#define db(a) cout << a << endl
#define db2(a,b) cout << a << " " << b << endl
#define dbp(a) cout << a.first << " " << a.second << endl
#define adb(a) for(auto it:a) cout << it << " "; cout << endl
#define adbp(a) for(auto it:a) cout << it.first << " " << it.second << endl
#define pb push_back
//greater<pair<int,int> , greater<int>>
const ll INF = 1e18L + 5;
//int dp[N][3];
int main(){
	fastIO;
    //#ifndef ONLINE_JUDGE
    //    freopen("../input.txt", "r", stdin);
     //   freopen("../output.txt","w",stdout);
    //#endif	
    string s1,s2;
    cin >> s1 >> s2;
    int n = s1.length();
    int m = s2.length();
    int dp[n+1][m+1] , path[n+1][m+1];
    memset(dp,0,sizeof(dp));
    memset(path, 0 ,sizeof(path));
    for(int i=n-1;i>=0;i--){
        for(int j=m-1;j>=0;j--){
            if(s1[i]==s2[j]){
                dp[i][j] = 1 + dp[i+1][j+1];
                path[i][j] = 0;
            }
            else{
                if(dp[i+1][j]>=dp[i][j+1]){
                    path[i][j] = 1;
                    dp[i][j] = dp[i+1][j];
                }
                else{
                    path[i][j] = 2;
                    dp[i][j] = dp[i][j+1];
                }
            }
        }
    }
    // for(int i=0;i<=n;i++){
    //     for(int j=0;j<=m;j++){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    // cout << endl;
    // for(int i=0;i<=n;i++){
    //     for(int j=0;j<=m;j++){
    //         cout << path[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    for(int i=0,j=0;i<n&&j<m;){
            if(s1[i]==s2[j]){
                cout << s1[i];
                i++;
                j++;
            }
            else{
                if(dp[i+1][j]>=dp[i][j+1]){
                    i++;
                }
                else{
                    j++;
                }
            }
    }
    cout << endl;
	return 0;

}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
const int maxn = 25;
char s[maxn][maxn];
bool vis[maxn][maxn];
int n , m;
const int px[4] = {0,1,0,-1};
const int py[4] = {1,0,-1,0};
struct node {
	int x , y;
};
int f[405][405];
queue <node> q;
int main() {
	cin >> n >> m;
	for(register int i = 1; i <= n; ++i)
		scanf("%s" , s[i] + 1);
	for(register int i = 1; i <= n; ++i)
		for(register int j = 1; j <= m; ++j)
			if(s[i][j] == '.') {
				q.push({i,j});
				vis[i][j] = 1;
				break;
			}
	memset(f , 0x3f3f3f3f , sizeof(f));
	while(!q.empty()) {
		node cur = q.front();
		q.pop();
		int x = cur.x , y = cur.y;
		for(register int i = 0; i < 4; ++i) {
			int xx = x + px[i] , yy = y + py[i];
			int p1 = (x-1)*m + y , p2 = (xx-1)*m + yy;
			if(s[xx][yy] == '.') {
				f[p1][p2] = f[p2][p1] = 1;
				if(!vis[xx][yy])
					q.push({xx , yy}) , vis[xx][yy] = 1;
			}
		}
	}
	for(register int i = 1; i <= n * m; ++i) f[i][i] = 0;
	for(register int k = 1; k <= n * m; ++k)
		for(register int i = 1; i <= n * m; ++i)
			for(register int j = 1; j <= n * m; ++j)
				f[i][j] = min(f[i][k] + f[k][j] , f[i][j]);
	int ans = 0;
	for(register int i = 1; i <= n * m; ++i)
		for(register int j = i; j <= n * m; ++j)
			if(f[i][j] != 0x3f3f3f3f)
				ans = max(ans , f[i][j]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 896
$N=<>;
for$i(1..$N){${-$_}+=grep$i%$'**$_<1,//..6for grep{(1x$_)!~/^(11+)\1+$/}2..$N}
for$a(-$N..0){
	for$b(-$N..0){
		$z+=$a-$b&&($$a>3&&$$b>13)+($$a>1&&$$b>23)+grep$a-$_&&$$a>1&&$$b>3&&$$_>3,$b+1..0
	}
}
print$z+($N>77)


Measured memory_bytes: 512
#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++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n;
    cin >> n;
    vector<int> a('z'-'a'+20,0);
    vector<vector<int>> v(n+10,vector<int>('z'-'a'+20,0));
    rep(i,n){
        string s;
        cin >> s;
        set<char> sc;
        rep(j,s.size()){
            sc.insert(s[j]);
            v[i][s[j]-'a']++;
        }
        for(auto u : sc){
            a[u-'a']++;
        }
    }
    string s = "";
    rep(i,a.size()){
        if(a[i]==n){
            int min1 = inf;
            rep(j,n){
                min1 = min(min1,v[j][i]);
            }
            rep(k,min1){
                s.push_back(i+'a');
            }
        }
    }
    sort(s.begin(),s.end());
    cout << s << endl;
    return 0;
}

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

const int N = 1e3 + 7;
int h, w, ch, cw, dh, dw;
char grid[N][N];
int visited[N][N];

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

    cin >> h >> w >> ch >> cw >> dh >> dw;
    for (int i = 1; i <= h; i++)
        for (int j = 1; j <= w; j++)
            cin >> grid[i][j];

    queue<tuple<int, int, int>> bfs_curr;
    queue<tuple<int, int, int>> bfs_next;

    bfs_curr.push({ch, cw, 0});
    visited[ch][cw] = 1;

    while (!bfs_curr.empty())
    {
        int x, y, dist;
        tie(x, y, dist) = bfs_curr.front();
        if (x == dh && y == dw)
            return cout << dist << "\n", 0;
        bfs_curr.pop();
        if (x > 1 && grid[x-1][y] == '.' && !visited[x-1][y])
            bfs_curr.push({x-1, y, dist}), visited[x-1][y] = 1;
        if (x < h && grid[x+1][y] == '.' && !visited[x+1][y])
            bfs_curr.push({x+1, y, dist}), visited[x+1][y] = 1;
        if (y > 1 && grid[x][y-1] == '.' && !visited[x][y-1])
            bfs_curr.push({x, y-1, dist}), visited[x][y-1] = 1;
        if (y < w && grid[x][y+1] == '.' && !visited[x][y+1])
            bfs_curr.push({x, y+1, dist}), visited[x][y+1] = 1;
        
        for (int i = x - 2; i <= x + 2; i++)
            for (int j = y - 2; j <= y + 2; j++)
                if (i >= 1 && i <= h && j >= 1 && j <= w && !visited[i][j] && grid[i][j] == '.')
                    bfs_next.push({i, j, dist+1});

        if (bfs_curr.empty())
        {
            while (!bfs_next.empty())
            {
                tie(x, y, dist) = bfs_next.front();
                visited[x][y] = 1;
                bfs_curr.push({x, y, dist});
                bfs_next.pop();
            }
        }
    }

    cout << -1;

    return 0;
}

Measured memory_bytes: 13692
#include<stdio.h>
int main(){
	char a[1205];
	scanf("%[^\n]",a);
	int p=0;
	while(a[p]!='\0'){
		p++;
	}
	for(int i=0;i<p;i++){
		if(a[i]>='a'&&a[i]<='z'){
			a[i]=a[i]-32;
		}
		else if(a[i]>='A'&& a[i]<='Z'){
			a[i]=a[i]+32;
		}
	}
	printf("%s",a);
	printf("\n");

return 0;
}


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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll big = 1e9;

  ll N, M, R; cin >> N >> M >> R;
  vector<ll> towns(R);
  for (ll r = 0; r < R; r++) {
    ll x; cin >> x; x--;
    towns.at(r) = x;
  }

  vector dist(N, vector(N, big));
  for (ll i = 0; i < N; i++) dist.at(i).at(i) = 0;
  
  for (ll i = 0; i < M; i++) {
    ll a, b, c; cin >> a >> b >> c; a--; b--;
    dist.at(a).at(b) = dist.at(b).at(a) = c;
  }
  for (ll i = 0; i < N; i++) {
    for (ll j = 0; j < N; j++) {
      for (ll k = 0; k < N; k++) {
	ll d = dist.at(j).at(i) + dist.at(i).at(k);
	if (dist.at(j).at(k) > d) {
	  dist.at(j).at(k) = d;
	}
      }
    }
  }
  ll ans = big;
  sort(towns.begin(), towns.end());
  do {
    ll rt = 0;
    for (ll i = 1; i < R; i++) rt += dist.at(towns.at(i-1)).at(towns.at(i));
    ans = min(ans, rt);
  }while (next_permutation(towns.begin(), towns.end()));
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3736
while True:
 a,op,b = input().split()
 a,b = map(int,[a,b])
 if op == '+':
  print(a+b)
 elif op == '-':
  print(a-b)
 elif op == '*':
  print(a*b)
 elif op == '/':
  print(a//b)
 elif op == '?':
  break

Measured memory_bytes: 7624
import sys

number, index = map(int, input().split())

xMin = index - number + 1
if xMin < -1000000:
  xMin = -1000000

xMax = index + number
if xMax > 1000000:
  xMax = 1000000

list = []

for i in range(xMin, xMax):
  list.append(str(i))

print(" ".join(list))

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<long long> cs(n), sum(n), ms(n);
  for (int i = 0; i < n; i++) {
    if (s[i] == 'M') ms[i]++;
    if (s[i] == 'C') cs[i]++;
  }
  for (int i = 1; i < n; i++) {
    ms[i] += ms[i - 1];
    cs[i] += cs[i - 1];
  }
  for (int i = 0; i < n; i++) {
    if (s[i] == 'C') sum[i] += ms[i];
  }
  for (int i = 1; i < n; i++) {
    sum[i] += sum[i - 1];
  }
  int q;
  cin >> q;
  for (int u = 0; u < q; u++) {
    int k;
    cin >> k;
    long long ans = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] == 'D') {
        int r = min(n - 1, i + k - 1);
        ans += sum[r] - sum[i] - ms[i] * (cs[r] - cs[i]);
      }
    }
    cout << ans << '\n';
  }
  return 0;
}

Measured memory_bytes: 24860
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
if a<=40:
    a=40
if b<=40:
    b=40
if c<=40:
    c=40
if d<=40:
    d=40
if e<=40:
    e=40
print((a+b+c+d+e)//5)


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    vector<int>v;
    v.push_back(a);
    v.push_back(b);
    v.push_back(c);
    sort(v.begin(),v.end());
    string x = to_string(v[2])+to_string(v[1]);
    int m = stoi(x);
    cout<<m+v[0]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>

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

using namespace std;

char trump,led;

int f(int rank,char suit){
	if(suit==trump) return 100*rank;
	if(suit==led)   return rank;
	return 0;
}

int main(){
	int RANK[128];
	RANK['2']=2;
	RANK['3']=3;
	RANK['4']=4;
	RANK['5']=5;
	RANK['6']=6;
	RANK['7']=7;
	RANK['8']=8;
	RANK['9']=9;
	RANK['T']=10;
	RANK['J']=11;
	RANK['Q']=12;
	RANK['K']=13;
	RANK['A']=77;

	for(;scanf("%c ",&trump),trump!='#';){
		int rank[4][13];
		char suit[4][13];
		rep(i,4) rep(j,13) {
			char c; scanf("%c%c ",&c,suit[i]+j);
			rank[i][j]=RANK[c];
		}

		int ans[2]={},dealer=0;
		rep(j,13){
			int i=dealer,i_opt=0;
			led=suit[dealer][j];
			rep(t,4){
				if(f(rank[i][j],suit[i][j])>f(rank[i_opt][j],suit[i_opt][j])) i_opt=i;
				i=(i+1)%4;
			}

			ans[i_opt%2]++;
			dealer=i_opt;
		}

		if(ans[0]>ans[1]) printf("NS %d\n",ans[0]-6);
		else              printf("EW %d\n",ans[1]-6);
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
using ll = int64_t;
template<typename T>
using vec = vector<T>;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[5001][5002];


signed main(){
	IOS;
	string s;
	cin >> s;
	ll cnt = 0;
	ll ans = 0;
	REP(i,s.size()){
		if(s[i] == 'W'){
			ans += i - cnt;
			cnt++;
		}
	}
	dump(ans);
}

Measured memory_bytes: 720
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a={ 'SUN':7,'MON':6,'TUE':5,'WED':4,'THU':3,'FRI':2,'SAT':1}
    s=STR()
    print(a[s])
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define MAX 1000000007
vector<int> H;
vector<int> dp;

int N, h;

int main(){
  cin >> N;
  dp.resize(N+1, MAX);
  H.resize(N+1, 0);

  for(int i = 1; i <= N; i++){ cin >> h; H[i] = h; }
  dp[1] = 0; dp[2] = abs(H[2]-H[1]);

  for(int i = 2; i <= N; i++){
    dp[i] = min(dp[i], min(dp[i-1]+abs(H[i]-H[i-1]),
                                                     dp[i-2]+abs(H[i]-H[i-2])));
  }

  cout << dp[N] << endl;
  return 0;
}

    

Measured memory_bytes: 1024
#include <set>
#include <map>
#include <math.h>
#include <vector>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
const double eps = 1e-8;
using namespace std;

set<int> x;
set<int> y;
set<int>::iterator it;

void doit(int a,int now)
{
	if(now==0) return;
	if(a==1){
		set<int> y_;
		y_.clear();
		for(it = y.begin();it!=y.end();it++){
			y_.insert(*it-now);
			y_.insert(*it+now);
		}
		y.clear();
		for(it = y_.begin();it!=y_.end();it++){
			y.insert(*it);
			y.insert(*it);
		}
	}else{
		set<int> x_;
		x_.clear();
		for(it = x.begin();it!=x.end();it++){
			x_.insert(*it-now);
			x_.insert(*it+now);
		}
		x.clear();
		for(it = x_.begin();it!=x_.end();it++){
			x.insert(*it);
			x.insert(*it);
		}
	}
}

int main()
{
	string s;
	cin>>s;
	int xx,yy;
	scanf("%d%d",&xx,&yy);
	int now=0;
	int i;
	for(i=0;i<s.length();i++){
		if(s[i]=='F'){
			now++;
		}else{
			break;
		}
	}
	x.insert(now+10000);
	y.insert(10000);
	int a=1;
	now=0;
	for(i++;i<s.length();i++){
		if(s[i]=='F'){
			now++;
		}else{
			doit(a,now);
			a^=1;
			now=0;
		}
	}
	doit(a,now);
	if(x.find(xx+10000)!=x.end()&&y.find(yy+10000)!=y.end()){
		printf("Yes\n");
	}else
		printf("No\n");


}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);std::cout<<std::fixed<<std::setprecision(10);
    long A,B;
    cin >> A >> B;
    long maxare;
    maxare = __gcd(A,B);
    long count = 1;
    long a = 1;
    // vector<bool> IsPrime;
    // if(maxare+1 > IsPrime.size()){     // resizeで要素数が減らないように
    //     IsPrime.resize(maxare+1,true); // IsPrimeに必要な要素数を確保
    // }
    // IsPrime[0] = false; // 0は素数ではない
    // IsPrime[1] = false; // 1は素数ではない

    // // for(long i=2; i*i<=maxare; ++i) // 0からsqrt(max)まで調べる
    // //     if(IsPrime[i]) // iが素数ならば
    // //         for(long j=2; i*j<=maxare; ++j) // (max以下の)iの倍数は
    // //             IsPrime[i*j] = false;      // 素数ではない
    long maxi = maxare;
    while(maxare != 1){
        a++;
        /*if(IsPrime[a])*/if(maxare % a == 0){
            count++;
            for(;;){
                if(maxare%a == 0){
                    maxare /= a;
                }else{
                    break;
                }
            }
        }
        if(a >= sqrt(maxi)+2){
            count++;
            break;
        }
    }
    cout <<count<< "\n";
}

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

int main() {
  string S;
  int N, Q, ans = 0;
  cin >> N >> Q >> S;
  vector<vector<int>> lr(Q, vector<int>(2));
  vector<int> T(1,0);
  for (int i = 0; i < Q; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> lr.at(i).at(j);
    }
  }
  for (int i = 0; i < N - 1; i++) {
    if (S.at(i) == 'A') {
      if (S.at(i + 1) == 'C') {
        ans += 1;
      }
    }
    T.push_back(ans);
  }
  for (int i = 0; i < Q; i++) {
    cout << T.at(lr.at(i).at(1) - 1) - T.at(lr.at(i).at(0) - 1) << endl;
  }
}

Measured memory_bytes: 6904
#include <bits/stdc++.h>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INF=INT_MAX;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))


vector<vector<double> >dp;
vector<int>board;


int main(){
	int N,T,L,B;
	while(cin>>N>>T>>L>>B){
		if(N==0&&T==0&&L==0&&B==0)return 0;
		board.assign(N+1,0);
		dp.assign(T+3,vector<double>(N+1,0.0));

		REP(i,L){
			int lose;
			cin>>lose;
			board[lose]=-1;
		}
		REP(i,B){
			int b;
			cin>>b;
			board[b]++;
		}
		dp[0][0]=1.0;//dp[i][j]:=i?????????????????????j??????????¢????
		REP(turn,T){
			REP(pos,N){
				for(int dice=1;dice<=6;dice++){
					int npos=pos+dice;
					if(npos>N)npos=2*N-npos;
					int nturn=turn+1;
					if(board[npos]==1)npos=0;
					if(board[npos]==-1)nturn+=1;
					dp[nturn][npos]+=dp[turn][pos]*(1.0/6.0);
				}
			}
		}
		double res=0.0;
		REP(i,T+1)res+=dp[i][N];
		cout<<fixed<<setprecision(10)<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 1376
def print_list(a):
    out = ''
    for ai in a:
        out += str(ai) + ' '
    else:
        out = out[:-1]
    print(out)

def bubble_sort(a, n):
    flag = True
    cnt = 0
    while flag:
        flag = False
        for j in range(n - 1, 0, -1):
            if a[j] < a[j - 1]:
                tmp = a[j]
                a[j] = a[j - 1]
                a[j - 1] = tmp
                cnt += 1
                flag = True
    
    print_list(a)
    print(str(cnt))
    return a



n = int(input())
a = list(map(int, input().split(' ')))

a = bubble_sort(a, n)



Measured memory_bytes: 5600
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        string s = Console.ReadLine();
        int ans1 = 0;
        int ans2 = 0;
        for (int i = 0; i < s.Length; i++)
        {
            if (i % 2 == 1)
            {
                if (s[i] == '0') ans1++;
                else ans2++;
            }
            else
            {
                if (s[i] == '1') ans1++;
                else ans2++;
            }
        }

        Console.WriteLine(Math.Min(ans1, ans2));
    }
}

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

int main(){
	int k;
	cin>>k;
	
	string s;
	cin>>s;
	
	if((s.length())>k){
		for(int i=0;i<k;i++){
			cout<<s[i];
		}
		cout<<"..."<<endl;
	}
	else
	cout<<s<<endl;
	
	

	return 0;
}

Measured memory_bytes: 3620
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
i,j,k=0,0,0
m1=[]
while k<n and i<n:
  if b[i]>a[k]:
    j+=1
    k+=1
  else:
    m1.append(j)
    i+=1
for t in range(len(m1),len(b)):
  m1.append(j)
i,j,k=0,0,0
m2=[]
while k<n and i<n:
  if c[i]>b[k]:
    j+=m1[k]
    k+=1
  else:
    m2.append(j)
    i+=1
for t in range(len(m2),len(c)):
  m2.append(j)
print(sum(m2))

Measured memory_bytes: 23476
// https://atcoder.jp/contests/abc158/tasks/abc158_c
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>

using namespace std;
#define lli long long int
#define numberofdigits(x) floor(log10(x)) + 1

int main()
{
    lli a,b,x,y,z,Z,flag=0;
    cin>>a>>b;
    x = (a*100)/8;
    y = b*10;
    lli a0 = min(x,y);
    lli b0 = max(x,y);
    for(lli i=1;i<=1000;i++)
    {
        z = (i*0.08);
        Z = (i*0.10);
        if(z==a && Z==b)
        {
            flag=1;
            cout<<i<<"\n";
            break;
        }
    }
    if(!flag)   cout<<"-1\n";
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include <random>
#define ll long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,a[100010];
    cin>>n;
    rep(i,n){
        cin>>a[i];
    }
    ll cnt1=0,cnt2=0;
    ll c=1,sum=0;
    rep(i,n){
        sum+=a[i];
        if(sum*c<=0){
            cnt1+=abs(sum)+1;
            sum=c;
        }
        c*=(-1);
    }
    c=-1;sum=0;
    rep(i,n){
        sum+=a[i];
        if(sum*c<=0){
            cnt2+=abs(sum)+1;
            sum=c;
        }
        c*=(-1);
    }
    cout<<min(cnt1,cnt2)<<endl;
    return 0;
}


Measured memory_bytes: 1024
import itertools
import copy

class Dice:
    def __init__(self,d1,d2,d3,d4,d5,d6):
        self.dice = [d1,d2,d3,d4,d5,d6]
    def turn(self,dir):
        if dir == 'S':
            self.dice = [self.dice[4],self.dice[0],self.dice[2],self.dice[3],self.dice[5],self.dice[1]]
        if dir == 'N':
            self.dice = [self.dice[1],self.dice[5],self.dice[2],self.dice[3],self.dice[0],self.dice[4]]
        if dir == 'W':
            self.dice = [self.dice[2],self.dice[1],self.dice[5],self.dice[0],self.dice[4],self.dice[3]]
        if dir == 'E':
            self.dice = [self.dice[3],self.dice[1],self.dice[0],self.dice[5],self.dice[4],self.dice[2]]


def check_1_column(dice1,dice2):
    '''
    input:Diceクラスを2つ読み込む
    output:Dice1を4回縦回転して、Dice2と一致するようであれば1を返す。一致しなければ、0を返す。
    '''
    for b in range(4):
        if dice1.dice[0] == dice2.dice[0] and dice1.dice[1] == dice2.dice[1] and dice1.dice[2] == dice2.dice[2] and dice1.dice[3] == dice2.dice[3] and dice1.dice[4] == dice2.dice[4] and dice1.dice[5] == dice2.dice[5]:
            return 1
        dice1.turn('N')
    return 0

def check_all(dice1,dice2):

    if check_1_column(dice1,dice2):
        return 1
    dice1.turn('E')
    if check_1_column(dice1,dice2):
        return 1
    dice1.turn('E')
    if check_1_column(dice1,dice2):
        return 1
    dice1.turn('E')
    if check_1_column(dice1,dice2):
        return 1
    dice1.turn('N')
    dice1.turn('E')
    if check_1_column(dice1,dice2):
        return 1
    dice1.turn('E')
    if check_1_column(dice1,dice2):
        return 1
    dice1.turn('E')
    if check_1_column(dice1,dice2):
        return 1
    dice1.turn('E')
    if check_1_column(dice1,dice2):
        return 1
    return 0

# 入力
n = int(input())
input_dice = []
for a in range(n):
    temp = list(map(int,input().split()))
    temp_class = Dice(temp[0],temp[1],temp[2],temp[3],temp[4],temp[5])
    input_dice.append(temp_class)

# Diceを2つ入力
# 一致してたら、Trueを返す。
flag = 0
for a in itertools.combinations(input_dice,2):
    temp1 = copy.copy(a[0])
    temp2 = copy.copy(a[1])
    flag += check_all(temp1,temp2)
if flag == 0:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 6344
#include <iostream>
#include <queue>

using namespace std;

long long n, m, ans;
priority_queue<int> q;

int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    q.push(a);
  }
  
  while (m--) {
    q.push(q.top()/2);
    q.pop();
  }
  
  while (q.size()) {
    ans += q.top();
    q.pop();
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    string s;
    cin>>s;
    string t="CODEFESTIVAL2016";
    int ans=0;
    rep(i,0,16){
        if(s[i]!=t[i]) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;

int main(void) {
	int n;
	int count = 0;
	int point = 0;
	int a[3][101] = {};

	cin >> n;
	FOR(i, 1, 2) {
		FOR(t, 1, n) {
			cin >> a[i][t];
		}
	}
	FOR(i, 1, n) {
		count = 0;
		FOR(t, 1, n) {
			if (i > t) {
				count += a[1][t];
			}
			else if (i == t) {
				count += a[1][i];
				count += a[2][i];
			}
			else {
				count += a[2][t];
			}
		}
		if (count > point) {
			point = count;
		}
	}

	cout << point << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
template <class T>
int upb(V<T> &v, const T &x) { return upper_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    if (n == 1) {
        cout << 1 << newl;
        return 0;
    }
    ll res = INF;
    for (ll i = 1; i * i <= 2 * n; i++) {
        if ((2LL * n) % i > 0) continue;
        ll j = (2LL * n) / i;
        if (__gcd(i, j) != 1) continue;
        ll a, b;
        extGCD(i, j, a, b);
        if (a == 0 || b == 0) {
            a += j;
            b += i;
        }
        //  dump(i, j, a, b);
        chmin(res, min(abs(i * a), abs(j * b)));
    }
    cout << res << newl;
}

Measured memory_bytes: 3652
import numpy as np

n = int(input())
count = np.zeros((10, 10), dtype=np.int)
for i in range(1, n+1):
  str_i = str(i)
  head = int(str_i[0])
  tail = int(str_i[-1])
  count[head, tail] += 1
print(np.sum(count.T * count))

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

INF = 10**18

N, K = map(int, input().split())
A = [0] + list(map(int, input().split())) + [0]

dp = [[INF]*(K+1) for _ in range(N+2)]
dp[0][0] = 0
for i in range(1, N+2):
    for k in range(K+1):
        tmp = INF
        for j in range(max(0, i-k-1), i):
            tmp = min(tmp, dp[j][k-(i-j-1)] + max(0, A[i]-A[j]))
        dp[i][k] = tmp

print(min(dp[-1]))

Measured memory_bytes: 42860
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

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

string L;

Int dp[100000+10][2]; //i's digit, 0->just, 1->smaller

int main(void) {
    cin>>L;

    dp[0][0] = 1;
    for(int i = 0;i < L.size();i++) {
        //a+b == 0
        if(L[i] == '0') {
            dp[i+1][0] += dp[i][0];
            dp[i+1][1] += dp[i][1];
        } else {
            dp[i+1][1] += (dp[i][0]+dp[i][1])%MOD;
        }

        //a+b == 1
        if(L[i] == '0') {
            dp[i+1][1] += dp[i][1]*2%MOD;
        } else {
            dp[i+1][0] += dp[i][0]*2%MOD;
            dp[i+1][1] += dp[i][1]*2%MOD;
        }
    }

    cout<<(dp[L.size()][0]+dp[L.size()][1])%MOD<<endl;

    return 0;
}


Measured memory_bytes: 2048
#include<iostream>

using namespace std;

int main(){
  int n,m,a[1001];

while(1){
  cin>>n>>m;
  if(n==0&&m==0) break;
  int ans=0;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(i!=j){
      if(a[i]+a[j]<=m) ans=max(ans,a[i]+a[j]);
}
}
}
    if(ans!=0) cout<<ans<<endl;
    else cout<<"NONE"<<endl;
}
return 0;
}



Measured memory_bytes: 3064
#include <stdio.h>
int n, y, a = 1000000;
int x[100];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", x + i);
	}
	for (int i = 1; i <= 100; i++) {
		y = 0;
		for (int j = 0; j < n; j++) {
			y += (i - x[j]) * (i - x[j]);
		}
		if (y < a)a = y;
	}
	printf("%d\n", a);
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cmath>
 
int main()
{
    using namespace std;
    int n;
 
    cin >> n;
    for( int i=0; i<n; ++i ) {
        double x1, y1, x2, y2, x3, y3;
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
 
        double const p
            = ( ( y1 - y3 ) * ( y1 * y1 - y2 * y2 + x1 * x1 - x2 * x2 ) - ( y1 - y2 ) * ( y1 * y1 - y3 * y3 + x1 * x1 - x3 * x3 ) )
            / ( 2 * ( y1 - y3 ) * ( x1 - x2 ) - 2 * ( y1 - y2 ) * ( x1 - x3 ) );
 
        double const q
            = ( ( x1 - x3 ) * ( x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2 ) - ( x1 - x2 ) * ( x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3 ) )
            / ( 2 * ( x1 - x3 ) * ( y1 - y2 ) - 2 * ( x1 - x2 ) * ( y1 - y3 ) );
 
        double const r1 = sqrt( pow( p - x1, 2 ) + pow( q - y1, 2 ) );
        double const r2 = sqrt( pow( p - x2, 2 ) + pow( q - y2, 2 ) );
        double const r3 = sqrt( pow( p - x3, 2 ) + pow( q - y3, 2 ) );
        double const r = ( r1 + r2 + r3 ) / 3.0;
 
        cout << showpoint << fixed << setprecision( 3 );
        cout << p << " " << q << " " << r << endl;
    }
}

Measured memory_bytes: 1292
#include<iostream>   
#include<cstdio>  
#include<algorithm>
#include<stack>
using namespace std;
const int maxx = 1410;

int H, W;
int buffer[maxx][maxx];
int T[maxx][maxx];
struct Rectangle { int height; int pos; };

int getLargestRectangle(int size, int height[]) {
    stack<Rectangle> S;
    int maxv = 0;
    // 使得栈顶元素必定大于最后元素，使得前面的值被计算进来
    height[size] = 0;

    for (int i = 0; i <= size; i++) {
        Rectangle rect;
        rect.height = height[i];
        rect.pos = i;
        // 当S为空
        if (S.empty())
            S.push(rect);
        // 栈顶的高度小于当前的高度
        else if (S.top().height < rect.height)
            S.push(rect);
        // 栈顶的高度大于当前的高度
        else if (S.top().height > rect.height) {
            int target = i;
            // 栈顶的高度大于等于当前的高度
            // 出现小于栈顶高度的代表pre.pos~i之间都存在高度为pre.height的干净瓷砖
            // 此时可以计算当前的面积
            while (!S.empty() && S.top().height >= rect.height) {
                Rectangle pre = S.top(); S.pop();
                // 长 * 宽
                int area = pre.height * (i - pre.pos);
                maxv = max(maxv, area);
                target = pre.pos;
            }
            // 加上前面的宽度（下标设置为之前的），以便后面有合适的瓷砖进行计算
            rect.pos = target;
            S.push(rect);
        }
    }
    return maxv;
}

int solve() {
    // 以行为直方图,计算纵向的干净长度
    for (int j = 0; j < W; j++) {
        for (int i = 0; i < H; i++) {
            if (buffer[i][j])
                T[i][j] = 0;
            else
                T[i][j] = (i > 0) ? T[i - 1][j] + 1 : 1;
        }
    }

    // 从行计算出当前行的最大面积
    int maxv = 0;
    for (int i = 0; i < H; i++)
        maxv = max(maxv, getLargestRectangle(W, T[i]));
    return maxv;
}
int main()
{
    scanf("%d %d", &H, &W);
    for (int i = 0; i < H; i++)
        for (int j = 0; j < W; j++)
            scanf("%d", &buffer[i][j]);

    printf("%d\n", solve());
    return 0;
}


Measured memory_bytes: 18544
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return (i for i in range(n + 1) if is_prime[i])


N = int(input())
print(*tuple(x for x in primes(55555) if x % 5 == 1)[:N])


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n, m;
  cin >> n >> m;
  vector<char> ans(n, '?');
  for (ll i = 0; i < m; i++) {
    ll s;
    char c;
    cin >> s >> c;
    if (s == 1 && c == '0' && n > 1) {
      cout << -1 << endl;
      return 0;
    }
    if (ans[s - 1] == '?') ans[s - 1] = c;
    else if (ans[s - 1] != c) {
      cout << -1 << endl;
      return 0;
    }
  }
  for (ll i = 0; i < n; i++) {
    if (ans[i] == '?') {
      if (i == 0 && n > 1) cout << 1;
      else cout << 0;
    }
    else cout << ans[i];
  }
  cout << endl;
}

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

using namespace std;

int main(void) {

	int k, s, num = 0, x, y, z;

	cin >> k >> s;

	for (x = 0; x <= k; x++) {
		for (y = 0; y <= k; y++) {
			if (s - x - y >= 0 && s - x - y <= k)num++;
		}
	}

	cout << num << "\n";

	return 0;
}

Measured memory_bytes: 256