akhauriyash/Code-Regression huggingface dataset:
/*
 * FileName:     tree_walk
 * CreatedDate:  2020-04-22 16:25:54 +0900
 * LastModified: 2020-04-22 20:57:06 +0900
 */

#include <stdio.h>
#include <stdlib.h>
typedef struct _node{
    int number;
    struct _node *pare;
    struct _node *left;
    struct _node *right;
}node_str;
node_str *big_pare(node_str *node){
    while(node->pare!=NULL){
        node=node->pare;
    }
    return node;
}
void print_node(node_str *parent,int order,int *list,int *i){
    if(parent==NULL){
        return;
    }
    if(order==0){
        list[*i]=parent->number;
        *i=*i+1;
        print_node(parent->left,order,list,i);
        print_node(parent->right,order,list,i);
    }
    else if(order==1){
        print_node(parent->left,order,list,i);
        list[*i]=parent->number;
        *i=*i+1;
        print_node(parent->right,order,list,i);
    }
    else{
        print_node(parent->left,order,list,i);
        print_node(parent->right,order,list,i);
        list[*i]=parent->number;
        *i=*i+1;
    }
}
int main(void){
    int n;
    scanf("%d",&n);
    node_str *node = (node_str*) malloc(n*sizeof(node_str));
    for(int i=0;i<n;i++){
        node[i].number = i;
    }
    for(int i=0;i<n;i++){
        int id,left,right;
        scanf("%d %d %d",&id,&left,&right);
        if(left!=-1){
            node[id].left = node+left;
            node[left].pare = node+id;
        }
        if(right!=-1){
            node[id].right = node+right;
            node[right].pare = node+id;
        }
    }
    int node_list[3][n],i=0;
    int *a=&i;
    printf("Preorder\n");
    print_node(big_pare(node),0,node_list[0],a);
    printf(" %d",node_list[0][0]);
    for(int j=1;j<n;j++){
        printf(" %d",node_list[0][j]);
    }
    printf("\n");
    printf("Inorder\n");
    *a=0;
    print_node(big_pare(node),1,node_list[1],a);
    printf(" %d",node_list[1][0]);
    for(int j=1;j<n;j++){
        printf(" %d",node_list[1][j]);
    }
    printf("\n");
    printf("Postorder\n");
    *a=0;
    print_node(big_pare(node),2,node_list[2],a);
    printf(" %d",node_list[2][0]);
    for(int j=1;j<n;j++){
        printf(" %d",node_list[2][j]);
    }
    printf("\n");
    free(node);
    return 0;
}



Measured memory_bytes: 2044
import math
n = int(input())
a = list(map(int, input().split()))
l = []
ans = int(math.sqrt(max(a)))
for i in a:
    if i%2!=0:
        ans = 0
    else:
        cnt = 0
        while i%2==0:
            i//=2
            cnt+=1
        ans = min(ans, cnt)
print(ans)

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


#define INF 1000000000000


signed main()
 {
   int n;
   cin>>n;
   if(n%2){
     cout<<(double)(n+1)/2/n;
   }
   else cout<<(double)1/2;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示

void solve(long long N, long long D, std::vector<std::vector<long long>> X){
  int ans=0;
  for (int i = 0; i < N-1; i++) {
    for (int l = i+1; l < N; l++) {
      double x=0;
      for (int a = 0; a < D; a++) {
        x += pow(abs(X[i][a] - X[l][a]),2);
      }
      x = sqrt(x);
      if(x == (int)x){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    std::vector<std::vector<long long>> X(N, std::vector<long long>(D));
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < D ; j++){
            scanf("%lld",&X[i][j]);
        }
    }
    solve(N, D, std::move(X));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
 int c;
 c=0;
 string s;
 cin >> s;
 for(auto p:s)
 c+=p-'0';
 cout << (c%9==0 ? "Yes" : "No");
 return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
#define arep(i, x, n) for (int i = int(x); i < (int)(n); i++)
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9 + 7

int x;
int y;

int main() {
    cin >> x >> y;
    int low = 2 * x;
    int high = 4 * x;
    
    if (y >= low && y <= high && y % 2 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>
using namespace std;
int n, x, t1,t2; 
int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%d", &x);
		int tmp = 0;
		while(x % 2 == 0) {
			x /= 2;
			tmp++;
		}
		if(tmp == 1) t1++;
		else if(tmp > 1) t2++;
	}
	if((!t2 && t1 == n) || ((n - t1 - 1) / 2 <= (t2 - 1) && t1) || (n / 2 <= t2)) printf("Yes"); else printf("No");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define B break
#define R return
#define pb push_back
#define C continue
#define F first
#define S second
using namespace std;
ll mod=1e9+7;
ll poww(ll x,ll y)
{
    if (y==0) R 1;
    if (x==1) R 1;
    if (x==0) R 0;
    if (y==1) R x;
    ll d=poww(x,y/2);
    d%=mod;
    if (y%2) R (((d*d)%mod)*x)%mod;
    R (d*d)%mod;
}
int main()
{
  ll a,b;
  cin>>a>>b;
  if(a>=b*2)
  {
      cout<<a-b*2<<endl;
  }
  else cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] A = new int[N];
        for(int i = 0; i < N; i++) {
            A[scanner.nextInt() - 1] = i;
        }
        for(int i = 0; i < N; i++) {
            System.out.print(A[i] + 1);
            System.out.print(" ");
        }
    }
}


Measured memory_bytes: 64632
#include "bits/stdc++.h"
using namespace std; typedef long long int lint; typedef pair<lint, lint> plint; typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define endk '\n'
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const lint mod = 1e9 + 7, INF = 1e18;
lint dx[8] = { 0, -1, 1, 0, 1, -1, 1, -1 }, dy[8] = { 1, 0, 0, -1, -1, -1, 1, 1 };

template< class T >
struct CumulativeSum2D {
	vector< vector< int > > data;

	CumulativeSum2D(int W, int H) {
		data.assign(W + 1, vector< int >(H + 1, 0));
	};

	void add(int x, int y, T z) {
		++x, ++y;
		if (x >= data.size() || y >= data[0].size()) return;
		data[x][y] += z;
	}

	void build() {
		for (int i = 1; i < data.size(); i++) {
			for (int j = 1; j < data[i].size(); j++) {
				data[i][j] += data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1];
			}
		}
	}

	T query(int sx, int sy, int gx, int gy) {
		return (data[gx][gy] - data[sx][gy] - data[gx][sy] + data[sx][sy]);
	}
};


lint N;
string s;
plint cnt[200000];
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N;
	CumulativeSum2D<lint> mp(500, 500);
	REP(i, N) {
		cin >> s;
		lint num = 0, idx = 0;
		while (idx < s.size() && s[idx] != '.') {
			num *= 10;
			num += (s[idx] - '0');
			idx++;
		}
		idx++;
		while (idx < s.size()) {
			num *= 10;
			num += (s[idx] - '0');
			idx++;
			cnt[i].first--;
			cnt[i].second--;
		}
		lint tmp = num;
		while (tmp % 2 == 0) {
			tmp /= 2;
			cnt[i].first++;
		}
		tmp = num;
		while (tmp % 5 == 0) {
			tmp /= 5;
			cnt[i].second++;
		}
		mp.add(cnt[i].second + 200, cnt[i].first + 200, 1);
	}	
	mp.build();
	lint ans = 0;
	REP(i, N) {
		ans += mp.query(-cnt[i].second + 200, -cnt[i].first + 200, 500, 500);
		if (-cnt[i].second <= cnt[i].second && -cnt[i].first <= cnt[i].first) ans--;
	}
	cout << ans / 2 << endl;
}

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

#define int long long
typedef pair<int, int> P;

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

/*
#define cin ifs
#define cout ofs
ifstream ifs("in.txt");
ofstream ofs("out.txt");
//*/

int N, M, X;
int cost[10000];

signed main() {
    cin >> N >> M >> X;
    for (int i = 0; i < M; i++) {
        int A;
        cin >> A;
        cost[A] = 1;
    }
    int ans1 = 0;
    for (int i = 1; i < X; i++) {
        ans1 += cost[i];
    }
    int ans2 = 0;
    for (int i = X + 1; i < N; i++) {
        ans2 += cost[i];
    }
    cout << min(ans1, ans2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>














ll n,t,t2,b,e,res;



void solve()
{
	cin>>n>>t>>b;
	e=b+t;
	res=0;
	for(int i=2;i<=n;i++)
	{
		cin>>t2;
		if(e<t2)
		{
			res+=e-b;
			b=t2;
		}
		e=t2+t;
	}
	res+=e-b;
	cout<<res<<"\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 256
import math

n = int(input())
xs = []
ys = []
for i in range(n):
    x, y = map(int, input().split())
    xs.append(x)
    ys.append(y)

sum_dist = 0
for i in range(n-1):
    for j in range(i+1, n):
        sum_dist += math.sqrt((xs[i]-xs[j]) ** 2 + (ys[i]-ys[j]) ** 2)

print(sum_dist * 2 / n)

Measured memory_bytes: 3188
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(c>a && c<b)
    {
        printf("Yes\n");
    }
    else if(c==a && c==b)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }





    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int M=2200;
vector<int> e[M];
int dis[M][M],ans[M];
void bfs(int st){
	queue<int> q;
	dis[st][st]=1;
	q.push(st);
	while(!q.empty()){
		int u=q.front();
		q.pop();
		for(int v:e[u])
			if(dis[v][st]==0){
				dis[v][st]=dis[u][st]+1;
				q.push(v);
			}
	}
}
int main(){
	int n,x,y;cin>>n>>x>>y;
	for(int i=0;i<n-1;i++){
		e[i].push_back(i+1);
		e[i+1].push_back(i);
	}
	--x,--y;
	e[x].push_back(y);
	e[y].push_back(x);
	for(int i=0;i<n;i++)
		bfs(i);
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			++ans[dis[i][j]-1];
	for(int i=1;i<n;i++)
		cout<<ans[i]<<"\n";
	return 0;
}

Measured memory_bytes: 18816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int max_keta;
int k;

void dfs( int digit, int keta, ll val ){
	if ( k < 0 )
		return;
	val = val * 10 + digit;
	
	keta++;
	if ( keta == max_keta ){
		if ( --k == 0 ){
			cout << val << endl;
		}
		return;
	}
	else {
		if ( digit != 0 ){
			dfs(digit-1, keta, val);
		}
		dfs(digit, keta, val);
		if ( digit != 9 ){
			dfs(digit+1, keta, val);
		}
	}
}

int main(){
	cin >> k;
	for ( max_keta = 1; ; max_keta++ ){
		for ( int i = 1; i <= 9; i++ ){
			dfs(i, 0, 0);
			if ( k < 0 )
				return 0;
		}
	}
}




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

using namespace std;

int main(){

  int a, b, c;
  int x, y, z;
  cin >> a >> b >> c;
  cin.ignore();
  x = c;
  y = a;
  z = b;
  cout << x << " " << y << " " << z << endl;
  return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=(ll)1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    string s;
    cin >> s;
    string t;
    cin >> t;
    ll A;
    cin >> A;
    ll B;
    cin >> B;
    string u;
    cin >> u;
    if(s==u)cout<<A-1<<" "<<B<<endl;
    else cout<<A<<" "<<B-1<<endl;

    return 0;
}



Measured memory_bytes: 3612
///Coder ---->>>> Kael (Joan Marcos Rivera)
///Team ACM : CyberSpace ____ IPVCE FEDERICO ENGELS
///KingOfString
///Copyright

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;

typedef long long ll;
typedef pair < string , int > par;

#define pb push_back
#define s second
#define mp make_pair
#define f first
#define maxn 100010
#define eps 1e-9
#define mod 50010
#define less(n) order_of_key(n)
#define en_pos(n) find_by_order(n) /// --- >> iterador --- >> empieza en 0

const int oo=1e9+10;

int h[maxn],dp[maxn];
int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n,k;

    cin >> n >> k;

    for(int i=1;i<=n;i++){
        cin >> h[i];
        dp[i]=oo;
    }

    dp[1]=0;
    for(int i=2;i<=n;i++){
        for(int j=max(1,i-k);j<i;j++){
            dp[i]=min(dp[i],dp[j]+(abs(h[i]-h[j])));
        }
    }

    cout << dp[n];
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n,c;
  scanf("%d%d",&n,&c);
  const int m=100000;
  int *ss=(int *)calloc(c*(m+1),sizeof(int));
  int i;
  for(i=0;i<n;i++){
    int s,t,cc;
    scanf("%d%d%d",&s,&t,&cc);
    ss[(cc-1)*(m+1)+s]++;
    ss[(cc-1)*(m+1)+t]--;
  }
  int *cnt=(int *)calloc(2*m+1,sizeof(int));
  for(i=0;i<c;i++){
    int j;
    for(j=0;j<=m;j++){
      if(ss[i*(m+1)+j]==1){
	cnt[2*j-1]++;
      } else if(ss[i*(m+1)+j]==-1){
	cnt[2*j]--;
      }
    }
  }
  int cc=0;
  int max=0;
  for(i=0;i<=2*100000;i++){
    cc+=cnt[i];
    max=MAX(max,cc);
  }
  printf("%d\n",max);
}

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


Measured memory_bytes: 12672
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def MI() : return map(int, input().split())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

N = I()
XY = []

for i in range(N):
    alen = I()
    tmp = [-1] * N

    for j in range(alen):
        x, y = LI()
        tmp[x - 1] = y

    XY.append(tmp)

ret = 0
for i in range(2 ** N):
    if i == 0:
        continue

    ans = [(i >> j) & 1 for j in range(N)]
    
    flag = True
    for e, a in enumerate(ans):
        if a != 1:
            continue

        for b, c in zip(XY[e], ans):
            if b == -1:
                continue
            if b!= c:
                flag = False
        
    if flag:
        ttt = 0
        for d in ans:
            if d == 1:
                ttt += 1
        ret = max(ret, ttt)

print(ret)



Measured memory_bytes: 49884
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////


///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	int n;
	cin >> n;
	
	vector<int> tab;
	for(int i = 0; i < n;i++){
		int x;
		cin >> x;
		tab.pb(x);
	}
	
	sort(tab.begin(), tab.end());
	int suma = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < i; j++){
			int ab = tab[i] + tab[j];
			int r = lower_bound(tab.begin(), tab.end(), ab) - tab.begin();
			//cout << "current r: " << endl;
			suma += r - i - 1; 
		}
	}
	
	cout << suma << endl;






	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(K: int, A: int, B: int):
    if B - A <= 2 or K <= A:
        print(K + 1)
        return
    K -= A - 1
    ret = A + (K // 2) * (B - A) + K % 2
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(K, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0)
#define F first
#define S second 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> tpi;
typedef pair<pii,pii> qpi;
const int INF = 2e9;
const int MAX = 1e5;
const int MV = 1e5;
int MA = -INF , MI = INF;

int n , m;
vector<int> ans , adj[MAX+10];
int in[MAX+10];
bool vis[MAX+10];
queue<int> qu;

int32_t main()
{
	IO;
	cin >> n >> m;

	while(m--)
	{
		int u , v;
		cin >> u >> v;
		in[v]++;
		adj[u].push_back(v);
	}

	for(int i=0 ; i<n ; i++)
	{
		if( in[i] == 0 )
			qu.push(i) , vis[i] = 1;
	}

	while( ans.size() < n )
	{
		int v = qu.front();
		qu.pop();
		ans.push_back(v);
		
		for(int u : adj[v])
		{
			if( !vis[u] )
			{
				in[u]--;
				if( in[u] == 0 )
					qu.push(u) , vis[u] = 1;
			}
		}
	}
		
	for(int u : ans)
		cout << u << "\n";
	cout << "\n";
	return 0;
}

Measured memory_bytes: 5732
/*
        Author: Prokash
                CSE48, JU

*/

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

typedef long long ll;
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main()
{
    FAST;
    ll x,y;
    cin>>x>>y;
    if(x==1&&y==1)
    {
        cout<<1<<endl;
    }
    else if(x==1)
    {
        cout<<y-2<<endl;
    }
    else if(y==1)
    {
        cout<<x-2<<endl;
    }
    else
    {
        cout<<(x-2)*(y-2)<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

def calc_sum(a, flag):
    ret = 0
    sum = 0
    for i in range(n):
        if (flag == 1 and sum + a[i] >= 0) or (flag == -1 and sum + a[i] <= 0):
            ret += abs(sum) + a[i] * flag + 1
            sum = -flag
        else:
            sum += a[i]
        flag = -flag
    return ret

print(min(calc_sum(a, 1), calc_sum(a, -1)))

Measured memory_bytes: 14332
from math import sqrt
n = int(input())
s = int(input())

if n < s:
  print(-1)
  import sys
  sys.exit()
if n == s:
  print(n+1)
  import sys
  sys.exit()

def f(b, n):
  if n < b:
    return n
  return f(b, n//b) + (n % b)

res = -1

for p in range(int(sqrt(n)), 0, -1):
  b = (n-s)//p + 1
  if b == 1:
    continue
  if f(b, n) == s:
    res = b
    break

for b in range(2, int(sqrt(n))+2):
  if f(b, n) == s:
    res = b
    break

print(res)

Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
  int a,b,c;
  int e = 0;
  bool d = false;
  e += scanf("%d %d",&b,&c);
  if (e != 2){
    return -1;
  }
  a = b;
  do {
    d = a == c;
    a += b;
  } while (a <= 20 && !d);
  if (d){
    e = printf("%d",b+c);
  }
  else {
    e = printf("%d",c-b);
  }
  
  if (e <= 0){
    return -2;
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>

using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    cout << a/b << " " << a%b << " ";
    double c,d;
    c = a;
    d = b;
printf("%.8lf", c/d);
    cout << endl;
   
  
}  




Measured memory_bytes: 3248
/*---> 20 April 2020 <--- > 08:26:50 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=1e5+5;
int n,k,tot;
void add(int &a,int b){
	a+=b;
	if(a>=mod)
		a-=mod;
}
int Find(int x){
	int left=n-x;
	int mn=((x-1)*x)/2,rem=(left*(left+1))/2;
	int mx=tot-rem;
	return (mx-mn+1)%mod;
}
int32_t main(){__
	// int n,k;
	cin>>n>>k;
	tot=(n*(n+1))/2;
	int ans=0;
	for(int i=k;i<=n+1;i++){
		add(ans,Find(i));
	}
	cout<<ans<<"\n";
return 0;
}

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

#define N 100
#define M 10000
#define PCHK(X) \
  ( ( ( ( p >> 4 ) & 3 ) == ( ( p >> 2 ) & 3 ) \
   && ( ( p >> 2 ) & 3 ) == ( p & 3 ) ) )

static int d[ N ] = { 0 };
static int n;

static int k_operafan[ N ][ 64 ];

int
dpFSA (
  int s,
  int p
  )
{
  int i;

  if ( s >= n ) return !( PCHK( p ) );
  else if ( s >= 3 && PCHK( p ) )  return ( 0 );
  else if ( ~k_operafan[ s ][ p ] ) ;
  else if ( d[ s ] != 0 )
  {
    k_operafan[ s ][ p ]
      = dpFSA ( s + 1, ( ( p << 2 ) | d[ s ] ) & 63 );
  }
  else
  {
    k_operafan[ s ][ p ] = 0;
    for ( i = 1; i <= 3; ++i )
    {
      k_operafan[ s ][ p ] += dpFSA ( s + 1, ( ( p << 2 ) | i ) & 63 );
      k_operafan[ s ][ p ] %= M;
    }
  }

  return ( k_operafan[ s ][ p ] );
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int k;

  scanf ( "%d%d", &n, &k );
  while ( k-- )
  {
    int a, b;

    scanf ( "%d%d", &a, &b );
    d[ a - 1 ] = b;
  }

  memset ( k_operafan, -1, sizeof ( k_operafan ) );
  printf ( "%d\n", dpFSA ( 0, 0 ) );

  return ( 0 );
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace テスト
{
    class Program
    {
        static void Main(string[] args)
        {
            int  A, B ;
            var word = Console.ReadLine().Split(' ');
            A = int.Parse(word[0]);
            B = int.Parse(word[1]);
            if(A<=8&&B<=8)
                Console.WriteLine("Yay!");
            else
                Console.WriteLine(":(");
            Console.ReadLine();

        }
    }
}


Measured memory_bytes: 13140
s=input();s_list=list(s)
a=int(0);z=int(0)
for i in range(0,len(s_list)):
    if(s_list[i]=='A'):
        a=i
        break
for i in range(0,len(s_list)):
    if(s_list[i]=='Z'):
        z=i
print(z-a+1)


Measured memory_bytes: 4840
n,m = map(int,input().split())
k = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))

c = 0
q = 0
for i in range(2**n):
    t = format(i,"010b")
    s = t[10-n:]
    r = 0
    for j in range(m):
        for u in range(k[j][0]):
            q += int(s[k[j][u+1]-1])
        if q % 2 == p[j]:
            q = 0
            continue
        else:
            q = 0
            r = 1
            break
    if r == 0:
        c += 1

print(c)

Measured memory_bytes: 3064
// https://github.com/PabloMessina/Competitive-Programming-Material/blob/master/Codejam_template.cpp
#pragma GCC optimize("Ofast") // OPTIONAL: for faster execution
#include <bits/stdc++.h>      // import everything in one shot
using namespace std;
// defines
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define invrep(i, a, b) for (int i = b - 1; i >= a; --i)
#define umap unordered_map
#define uset unordered_set
// typedefs
typedef unsigned int uint;
typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
// -------------------------------

int main()
{
    // OPTIONAL: for faster input/output (only if using cin/cout)
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll N,tmp;
    cin >> N;
    ll m = -1;
    cin >> tmp;
    m = max(m, tmp);
    ll ans = 0;
    rep(i, 0, N - 1)
    {
        cin >> tmp;
        if(tmp < m)
            ans += m - tmp;
        m = max(m, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  cout << A[N-1] - A[0] << endl;
}


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

int main() {
  int value[10] = {};
  int A, B;
  cin >> A >> B;

  int ans = 0;

  for (int i = A; i <= B; i++) {
    int x = i;
    for (int i = 0; i < 5; i++) {
      value[4 - i] = x % 10;
      x /= 10;
    }
    if (value[0] == value[4] && value[1] == value[3]) {
      ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var h, w int
	fmt.Scan(&h, &w)

	lines := make([]string, h)

	for i := 0; i < h; i++ {
		fmt.Scan(&lines[i])
	}

	fmt.Println(strings.Repeat("#", w+2))

	for _, l := range lines {
		fmt.Print("#")
		fmt.Print(l)
		fmt.Println("#")
	}

	fmt.Println(strings.Repeat("#", w+2))
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int  main()
{
int n,k,i,j,cnt=0,z,d;
cin>>n>>k;
vector<int> a(n+1,0);
for(i=0;i<k;i++)
{
cin>>d;
for(j=0;j<d;j++)
{
cin>>z;
a[z]++;
}
}
for(i=1;i<=n;i++)
{
if(a[i]==0)
cnt++;
}
cout<<cnt;
return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef double db;
const int MOD = 1e9 + 7;
int mul(int a, int b) { return 1ll * a * b % MOD; }
int add(int a, int b) { return (ll(a) + b + MOD) % MOD; }
int pow_bin(int a, int b)
{
	int t = 1;
	while (b > 0)
	{
		if (b & 1) t = mul(t, a);
		a = mul(a, a);
		b >>= 1;
	}
	return t;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, k;
	cin >> n >> k;
	vector<int> nums(k + 1, 1);
	vector<vector<int>> primes(k + 1);
	for (int i = 2; i <= k; ++i)
	{
		if (nums[i])
		{
			for (ll j = 1ll * i * i; j <= k; j += i)
			{
				nums[j] = 0;
			}
		}
	}
	for (int i = 2; i <= k; ++i)
	{
		if (nums[i])
			for (int j = i; j <= k; j += i)
				primes[j].push_back(i);
	}
	int ans = 0;
	for (int i = 1; i <= k; ++i)
	{
		int cnt = pow_bin(k / i, n);
		ans = add(ans, mul(i, cnt));
		int m = primes[i].size();
		for (int v = 1; v < (1 << m); ++v)
		{
			int ct = 0, tmp = i;
			for (int j = 0; j < m; ++j)
				if (v & (1 << j))
				{
					++ct;
					tmp /= primes[i][j];
				}
			if (ct & 1)
				ans = add(ans, -mul(tmp, cnt));
			else
				ans = add(ans, mul(tmp, cnt));
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 8996
using System;

namespace AtCorder1
{
    class AtCorder160C
    {
        static void Main(string[] args)
        {

            string[] line = System.Console.ReadLine().Trim().Split(' ');

            var lakePerim = int.Parse(line[0]);
            var houseNum = int.Parse(line[1]);


            string[] meterFrmLake = System.Console.ReadLine().Trim().Split(' ');


            int meterMax = 0;

            //二軒の家の間の距離が最も遠いものを求める（そこから反対周りに回ればよい）
            for (int i = 0; i < houseNum - 1; i++)
            {
                int meterBtwHouse = int.Parse(meterFrmLake[i + 1]) - int.Parse(meterFrmLake[i]);
                if (meterBtwHouse > meterMax)
                {
                    meterMax = meterBtwHouse;
                }

            }

            //配列の最後と最初の家の距離を求める
            int lastToFirst = lakePerim - int.Parse(meterFrmLake[houseNum - 1]) + int.Parse(meterFrmLake[0]);

            if (lastToFirst > meterMax)
            {
                meterMax = lastToFirst;
            }

            Console.WriteLine(lakePerim - meterMax);
        }
    }
}





Measured memory_bytes: 30940
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int N,M;
vector<int>G[1<<17];
int ans[1<<17];
main()
{
	cin>>N>>M;
	for(int i=1;i<=N;i++)ans[i]=-1;
	ans[1]=0;
	for(int i=0;i<M;i++)
	{
		int a,b;cin>>a>>b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	queue<int>P;
	P.push(1);
	while(!P.empty())
	{
		int u=P.front();P.pop();
		for(int v:G[u])
		{
			if(ans[v]==-1)
			{
				ans[v]=u;
				P.push(v);
			}
		}
	}
	cout<<"Yes"<<endl;
	for(int i=2;i<=N;i++)cout<<ans[i]<<endl;
}


Measured memory_bytes: 11140
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll>a(n);
    REP(i,n)cin >> a[i];

    const int MAX_DIGIT = 50;
    ll dp[MAX_DIGIT+1][2];
    memset(dp,-1,sizeof(dp));
    dp[0][0]=0;

    REP(i,MAX_DIGIT){
        ll mask = (ll)1 << (MAX_DIGIT-1-i);
        ll num = 0;
        REP(j,n)if(a[j]&mask)num++;
        ll cost0 = num*mask;
        ll cost1 = (n-num)*mask;

        if(dp[i][1]!=-1){
            chmax(dp[i+1][1],dp[i][1]+max(cost0,cost1));
        }
        if(dp[i][0]!=-1){
            if(mask&k)chmax(dp[i+1][1],dp[i][0]+cost0);
        }
        if(dp[i][0]!=-1){
            if(mask&k)chmax(dp[i+1][0],dp[i][0]+cost1);
            else chmax(dp[i+1][0],dp[i][0]+cost0);
        }
    }
    cout << max(dp[MAX_DIGIT][0],dp[MAX_DIGIT][1]) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std ;
int main()
{
    int a,b,k;
    vector<int>v;
    cin>>a>>b>>k;
    int m = min(a,b);
    for(int i=1;i<=m;i++)
    {
        if(a%i==0 && b%i==0)
        {
            v.push_back(i);
        }
    }
   sort(v.begin(),v.end());
   reverse(v.begin(),v.end());
   cout<<v[k-1]<<endl;
  // cout<<v[k-2]<<endl;
    return 0 ;
}


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

int main(){
  string s;
  cin >> s;
  
  string ans = "No";
  
  for(int i = 0; i < s.size()-1; i++) {
    if(s.at(i) == 'A' && s.at(i+1) == 'C') ans = "Yes";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import math
n,d=map(int,input().split())

x=[[] for _ in range(n)]

for j in range(n):
    x[j] = input().split()
cnt=0
for i in range(n):
    for k in range(i+1,n):
        wa=0
        for j in range(d):
            wa +=(int(x[k][j])-int(x[i][j]))**2
        a=math.sqrt(wa)
        if a.is_integer()==True:
            cnt+=1
print(cnt)           



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i,h) cin >> s[i];

    vector<P> c;
    vector<int> no(h);
    rep(i, h){
        int num = 0;
        rep(j, w){
            if (s[i][j] == '#'){
                c.push_back(make_pair(i,j));
                num++;
            } 
        }
        if (num == 0) no[i] = 1;
    }

    vector<vector<int>> ans(h, vector<int>(w));
    int num = 1;
    rep(i,k){
        int stR, stC, enR, enC;
        if (i == 0){
            stR = 0; stC = 0;
        }else{
            if (c[i].first == c[i-1].first){
                stR = c[i].first;
                stC = c[i].second;
            } 
            else {
                stR = c[i-1].first+1;
                stC = 0;
            }
        }

        if (i == k-1){
            enR = h-1;
            enC = w-1;
        }else{
            if (c[i].first == c[i+1].first){
                enR = c[i].first;
                enC = c[i+1].second-1;
            }else{
                enR = c[i+1].first-1;
                enC = w-1;
            }
        }

        while(stR){
            if (no[stR-1] == 1) stR--;
            else break;
        }
        while(enR != h-1){
            if (no[enR+1] == 1) enR++;
            else break;
        }

        for(int row = stR; row <= enR; row++){
            for(int col = stC; col <= enC; col++){
                ans[row][col] = num;
            }
        }
        num++;
    }

    rep(i,h) rep(j,w){
        printf("%d%c", ans[i][j], j == w-1 ? '\n': ' ');
    }
    return 0; 
}

Measured memory_bytes: 4332
io = STDIN
n,k=io.gets.split.map(&:to_i)
s=io.gets.chomp
if k==1
  puts "#{s[0].downcase}#{s[1..-1]}"
else
  puts "#{s[0..k-2]}#{s[k-1].downcase}#{s[k..-1]}"
end


Measured memory_bytes: 1788
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Arrays;
import java.util.Objects;

public class Main{
    public static void main(String[] args){
        FastScanner sc = new FastScanner();

        while(true){
            int ans = 0;
            int n = sc.nextInt();
            int x = sc.nextInt();

            if(n==0 && x==0)break;
            for(int i=1;i<=n;i++){
                for(int j=1;j<n;j++){
                    for(int k=1;k<n;k++){
                        if(i+j+k==x && i>j && j>k)ans++;
                    }
                }
            }
            System.out.println(ans);
        }


    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}



Measured memory_bytes: 24504
import copy
n = int(input())
a = list(map(int,input().split()))
dp = [[0,0,0] for _ in range(n+1)]
mod = 10**9+7
ans = 1
for i in range(1,n+1):
  dp[i] = copy.copy(dp[i-1])
  for j in range(3):
    if dp[i-1][j] == a[i-1]:
      dp[i][j] += 1
      break
  dp[i].sort(reverse=True)
for i in range(n):
  ans = ans*dp[i].count(a[i])%mod
print(ans)

Measured memory_bytes: 23984
MAXN = 300010
sieve = [1]* MAXN
primes = []
for n in range(7,MAXN,7):
    for m in [n-1,n+1]:
        if sieve[m] == 0: continue
        primes.append(m)
        for l in range(2*m,MAXN,m):
            sieve[l] = 0

def solve(n):
    ret = []
    for p in primes:
        if p > n: break
        if n%p == 0:
            ret.append(p)
    return ret

while True:
    N = int(input())
    if N == 1: break
    ans = ' '.join(list(map(str,solve(N))))
    print('{0}: {1}'.format(N,ans))

Measured memory_bytes: 9252
#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define INF 0x7fffffff
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
typedef tree<int,null_type,std::less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
using namespace std;
/*
ordered_set X;
X.insert(1);
cout<<*X.find_by_order(1)<<endl; Kth largest element
cout<<X.order_of_key(-5)<<endl;  number of elemets less than K
*/
vector<ll>vv[100003];
ll dp[100003];
bool visited[100003];
ll  dfs(int u){
    visited[u] = true;
    ll z = 0;
    for(auto v : vv[u]){
        if(!visited[v])
            z = max(dfs(v),z);
        else
            z = max(z,dp[v]);
    }
    return dp[u] = z+1;
}
int main(){
    //freopen(".txt", "w", stdout
    //IO;

    ll n,m;
    cin>>n>>m;
    for(int i = 0; i < m; i++){
        ll a,b;
        cin>>a>>b;
        vv[a] .push_back(b);
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        if(!visited[i])
            ans = max(dfs(i),ans);
    }
    cout<<ans-1;
    return 0;
}


Measured memory_bytes: 8576
x, y = list(map(int, input().split()))
ans = []
if y - x >= 0:
    ans.append(y - x)
if y + x >= 0:
    ans.append(y + x + 1)
if -1 * y - x >= 0:
    ans.append(-1 * y - x + 1)
if -1 * y + x >= 0:
    ans.append(-1 * y + x + 2)
print(min(ans))


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

#define FOR(i, a, b) for (int i = a; i < (int) b; i++)
#define F0R(i, a) FOR (i, 0, a)
#define ROF(i, a, b) for (int i = a; i >= b; i--)
#define R0F(i, a) for (int i = a; i >= 0; i--)
#define GO(i, a) for (auto i : a)

#define f first
#define s second
#define eb emplace_back
#define pb push_back
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;
typedef vector<vi64> vvi64;
typedef vector<vpi64> vvpi64;

const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int ms[] = {+31, +29, +31, +30, +31, +30, +31, +31, +30, +31, +30, +31};
const int rm[] = {+1, +4, +5, +9, +10, +40, +50, +90, +100, +400, +500, +900, +1000};

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  string A = string ( a, char ('0' + b) );
  string B = string ( b, char ('0' + a) );
  cout << min (A, B) << '\n';
  return 0;
}



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

N = int(input())

W = list(map(int, input().split()))


ans = 10**(200)
ans_num = 0
for i in range(N-1):
    k = sum(W[:i+1]) - sum(W[i+1:])
    if k**2 < ans:
        ans = k**2
        ans_num = i


print(int(ans**(1/2)))

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

int main()
{
    int n,x = 0,ans = 0;
    string s;
    cin >> n >> s;
    
    for(int i = 0; i < n; i++){
        (s[i] == 'I') ? x++ : x--;
        if(x > ans) ans = x;
    }

    cout << ans << endl;
    
    return 0;
}

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

long long N, M;
long long d[200][200];
vector<pair<pair<long long, long long> , long long> >vec;

bool used(long long idx){
	long long from = vec[idx].first.first;
	long long to = vec[idx].first.second;
	long long cost = vec[idx].second;
	return (d[from][to] == cost);
}

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

	for(long long i = 0; i < 200; i++){
		for(long long j = 0; j < 200; j++){
			d[i][j] = INT_MAX;
		}
	}

	for(long long i = 0; i < M; i++){
		long long a,b,c;
		cin >> a >> b >> c;
		a--;b--;
		d[a][b] = c;
		d[b][a] = c;
		vec.push_back(make_pair(make_pair(a, b), c));
	}

	for(int k = 0; k < N; ++k){
		for(int i = 0; i < N; ++i){
			for(int j = 0; j < N; ++j){
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}


	long long ans = M;
	for(long long i = 0; i < vec.size(); i++){
		if(used(i))
			ans--;
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long

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

string input;
vector<char> odds = {'R', 'U', 'D'};
vector<char> evens = {'L', 'U', 'D'};

int main () {
  cin >> input;

  bool ans = true;

  rep(i, input.size()) {
    char curr = input[i-1];

    if (i % 2 == 0) {
      if (find(evens.begin(), evens.end(), curr) == evens.end()) {
        ans = false;
      }
    } else {
      if (find(odds.begin(), odds.end(), curr) == odds.end()) {
        ans = false;
      }
    }
  }

  cout << (ans ? "Yes" : "No") << "\n";
}

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

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


Measured memory_bytes: 79904
#include "bits/stdc++.h"
using namespace std;
#define shandom_ruffle random_shuffle
#define pb push_back
#define nl puts("")
using ll = long long;
using pii = pair<ll,ll>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;
using vlll = vector<vll>;
using mpll = map<ll,ll>;
using stch = stack<char>;
using stvll = stack<vll>;
const ll nax = 1000*1007;
const ll mno = 1007;
const ll mod = 1e9 + 7;
const ll mxN = 1e5;
const ll rc = 64;
const ll MOD = 998244353; 
int main() {
  int n;
  cin >> n;
  ll sum = 0;
  for(int i = 1; i <= n; ++i) {
     if(i % 3 != 0 && i % 5 != 0) sum += i;
  }
  cout << sum;
  return 0;
}


Measured memory_bytes: 3636