akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

int n, m, a, b;
std::vector<std::vector<int>> vec;
std::vector<bool> visited;
std::vector<std::pair<int, int>> edge;
int c = 0;


int main() {
    std::cin >> n >> m;
    vec.assign(n+1, std::vector<int>(n+1, 0));
    edge.assign(m, {0, 0});
    for (int i = 0; i < m; i++) {
        std::cin >> a >> b;
        edge[i].first = a;
        edge[i].second = b;
        vec[a][b] = 1;
        vec[b][a] = 1;
    }
    for (int i = 0; i < edge.size(); i++) {
        std::vector<bool> visited(n+1, false);
        std::queue<int> q;
        int x = edge[i].first;
        int y = edge[i].second;
        vec[x][y] = 0;
        vec[y][x] = 0;
        for (int p = 0; p < edge.size(); p++) {
            if (i != p) {
                q.push(edge[p].first);
                break;
            }
        }
        while (!q.empty()) {
            int e = q.front();
            visited[e] = true;
            q.pop();
            for (int j = 1; j <= n; j++) {
                if (vec[e][j] == 1) {
                    if (!visited[j])
                        q.push(j);
                }
            }
        }
        for (int i = 1; i <= n; i++) {
            if (!visited[i]) {
                c++;
                break;
            }
        }
        vec[x][y] = 1;
        vec[y][x] = 1;
    }
    std::cout << c << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MX 1000005
#define INF 1000000005
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
 
struct UF
{
	int par[MX],rank[MX];
	
	void init(int n)
	{
		for(int i=0;i<n;i++)
		{
			par[i]=i;
			rank[i]=0;
		}
	}
	void rem(int i)
	{
		par[i]=i;
		rank[i]=0;
	}
	int find(int x)
	{
		if(x==par[x]) return x;
		return par[x]=find(par[x]);
	}
	void unite(int x,int y)
	{
		x=find(x);
		y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y])
		{
			par[x]=y;
		}
		else
		{
			par[y]=x;
			if(rank[x]==rank[y]) rank[x]++;
		}
	}
	bool same(int x,int y)
	{
		return find(x)==find(y);
	}
};
UF uf;
vector <int> vec[MX];
vector <P> query[MX];
int id[MX];
bool use[MX];
int dp[MX];
 
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++)
	{
		int p,q,c;
		scanf("%d %d %d",&p,&q,&c);p--,q--,c--;
		query[c].push_back(P(p,q));
	}
	int sz=n;
	for(int i=0;i<MX;i++)
	{
		if(query[i].empty()) continue;
		for(int j=0;j<query[i].size();j++)
		{
			P p=query[i][j];
			uf.rem(p.first);
			uf.rem(p.second);
			id[p.first]=id[p.second]=-1;
			use[p.first]=use[p.second]=false;
		}
		for(int j=0;j<query[i].size();j++)
		{
			P p=query[i][j];
			uf.unite(p.first,p.second);
		}
		for(int j=0;j<query[i].size();j++)
		{
			P p=query[i][j];
				use[p.first]=true;
				int r=uf.find(p.first);
				if(id[r]==-1) id[r]=sz++;
				//printf("%d %d: %d\n",r,id[r],p.first);
				vec[p.first].push_back(id[r]);
				vec[id[r]].push_back(p.first);
				use[p.second]=true;
				r=uf.find(p.second);
				if(id[r]==-1) id[r]=sz++;
				//printf("%d %d: %d\n",r,id[r],p.second);
				vec[p.second].push_back(id[r]);
				vec[id[r]].push_back(p.second);
		}
	}
	queue <int> que;
	que.push(0);
	memset(dp,-1,sizeof(dp));
	dp[0]=0;
	while(!que.empty())
	{
		int v=que.front();que.pop();
		for(int i=0;i<vec[v].size();i++)
		{
			int to=vec[v][i];
			if(dp[to]==-1)
			{
				dp[to]=dp[v]+1;
				que.push(to);
			}
		}
	}
	if(dp[n-1]==-1) puts("-1");
	else printf("%d\n",dp[n-1]/2);
	return 0;
}


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

int64_t crcl(int64_t H){
  if(H==1) return 1;
  else return 2*crcl(H/2)+1;
}

int main(){
  int64_t H;
  cin>>H;
  cout<<crcl(H)<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
 int A,B,C ;
 cin>>A>>B>>C ;
  if (A==B || B== A ) {
     cout<< C;
  }
  else if (C==B|| B==C ) {
    cout<<A ;
  }
  else {
    cout<<B ;
  }
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#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 all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	int n;
	cin >> n;
	vl a(n);
	ll total = 0;
	rep(i,0,n) {
		cin >> a[i];
		total += a[i];
	}
	map<ll, ll> r;
	rep(i,0,n) {
		r[a[i]]++;
	}
	rep(i,1,n) {
		a[i] = max(a[i-1],a[i]);
	}
	vl idx;
	idx.pb(0);
	rep(i,1,n) {
		if(a[i] != a[i-1]) {
			idx.pb(i);
		}
	}
	int m = idx.size();
	vl ans(n);
	ll subtotal = 0;
	per(i,1,m) {
		ll j = idx[i];
		ll x = a[j-1];
		ll y = a[j];
		auto start = r.upper_bound(x);
		auto end = r.lower_bound(y);
		ll ret = 0;
		for (auto it = start; ; ++it) {
			ll diff = (it->F) - x;
			ll cnt = (it->S);
			ret += (diff * cnt);
			r[x] += cnt;
			it->S = 0;
			if(it == end) {
				break;
			}
		}
		ans[j] = ret;
		subtotal += ret;
	}
	ans[0] = total - subtotal;
	rep(i,0,n) {
		cout << ans[i] << '\n';
	}
	return 0;
}


Measured memory_bytes: 9848
/*
お財布メタボ診断
４月に消費税が８％になってから、お財布が硬貨でパンパンになっていませんか。同じ金額を持ち歩くなら硬貨の枚数を少なくしたいですよね。硬貨の合計が１０００円以上なら、硬貨をお札に両替して、お財布のメタボ状態を解消できます。
お財布の中の硬貨の枚数が種類ごとに与えられたとき、硬貨をお札に両替できるかどうかを判定するプログラムを作成してください。
*/

macro_rules! input_vec {
    () => {
        input!()
            .split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };
    ($delimiter:expr) => {
        input!()
            .split($delimiter)
            .map(|x| x.parse().unwrap())
            .collect()
    };
}

macro_rules! input {
    () => {{
        let mut return_ = String::new();
        std::io::stdin().read_line(&mut return_).ok();
        return_.pop();
        return_
    }};
}

fn main() {
    let v: Vec<i32> = input_vec!();
    println!(
        "{}",
        if v[0] + v[1] * 5 + v[2] * 10 + v[3] * 50 + v[4] * 100 + v[5] * 500 >= 1000 {
            1
        } else {
            0
        }
    );
}



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

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

Node root;

//Node treeMinimum(Node x){


//}

//Node treeMaximum(Node x){


//}

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

  Node N = NIL;
  return N;
}

//Node treeSuccessor(Node x){


//}

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



//}

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

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

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

      z->parent = y;

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

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


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

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

      return 0;
}



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

int main() {
  const int64_t inf = 1e18;
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 0; i <= n; i++) {
    cin >> a.at(i);
  }
  vector<int64_t> vmax(n + 1), vmin(n + 1);
  vmax.at(0) = 1;
  for (int i = 0; i < n; i++) {
    vmax.at(i + 1) = min(inf, 2 * (vmax.at(i) - a.at(i)));
    if (vmax.at(i + 1) < 0) {
      cout << -1 << endl;
      return 0;
    }
  }
  if (vmax.at(n) < a.at(n)) {
    cout << -1 << endl;
    return 0;
  }
  vmin.at(n) = a.at(n);
  for (int i = n - 1; i >= 0; i--) {
    vmin.at(i) = min(vmax.at(i), vmin.at(i + 1) + a.at(i));
  }
  cout << accumulate(vmin.begin(), vmin.end(), 0ll) << endl;
}


Measured memory_bytes: 5104
sx, sy, tx, ty = map(int, input().split())
up_num = ty - sy
right_num = tx - sx

ans = ""
#first
for i in range(up_num):
    ans += "U"
for i in range(right_num):
    ans += "R"
for i in range(up_num):
    ans += "D"
for i in range(right_num):
    ans += "L"
ans += "L"
for i in range(up_num):
    ans += "U"
ans += "UR"
for i in range(right_num):
    ans += "R"
ans += "DRD"
for i in range(up_num):
    ans += "D"
for i in range(right_num):
    ans += "L"
ans += "LU"

print(ans)

Measured memory_bytes: 43356
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define F first
#define S second
#define pss pair<string,string>
#define pcc pair<char,char>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define vs vector<string>
#define vl vector<ll>
#define vs vector<string>
#define vll vector<pll>
#define vss vector<pss>
#define vcc vector<pcc>
#define MP make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
#define Very_fast std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int N = 1e5+5;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
inline ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll lowbit(ll x){return (x&-x);}
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	a-=b*c;
	if(a<=0)cout<<"Yes";else cout<<"No";
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
int M = 1e9 + 7;

int minCost(int n, vector<int> &heights, vector<int> &dp, int k)
{
    if (n <= 0)
        return 0;
    if (n == 1)
        return abs(heights[n] - heights[n - 1]);
    if (dp[n] != -1)
        return dp[n];

    int x = INT_MAX;
    for (int i = 1; i <= k && n - i >= 0; i++)
    {
        x = min(x, minCost(n - i, heights, dp, k) + abs(heights[n] - heights[n - i]));
    }
    dp[n] = x;
    return dp[n];
}

int main()
{

    //Fast IO crap
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, k;
    cin >> n >> k;
    vector<int> heights(n);
    for (int i = 0; i < n; i++)
        cin >> heights[i];

    vector<int> dp(n, -1);
    cout << minCost(n - 1, heights, dp, k);

    return 0;
}


Measured memory_bytes: 8832
#include <cstdio>
#include <vector>

using namespace std;

using i64=long long;
using Vector=vector<i64>;
using Matrix=vector<Vector>;

Matrix operator*(Matrix &a, Matrix &b) {
    Matrix c(a.size(), Vector(b[0].size()));
    for (size_t i=0; i<a.size(); ++i)
        for (size_t j=0; j<b[0].size(); ++j)
            for (size_t k=0; k<b.size(); ++k)
                c[i][j] += a[i][k] * b[k][j];

    return c;
}

int main() {
    size_t n, m, l;
    scanf("%zu %zu %zu", &n, &m, &l);

    Matrix a(n, Vector(m));
    for (size_t i=0; i<n; ++i)
        for (size_t j=0; j<m; ++j)
            scanf("%d", &a[i][j]);

    Matrix b(m, Vector(l));
    for (size_t j=0; j<m; ++j)
        for (size_t k=0; k<l; ++k)
            scanf("%d", &b[j][k]);

    Matrix c=a*b;
    for (size_t i=0; i<n; ++i)
        for (size_t k=0; k<l; ++k)
            printf("%lld%c", c[i][k], k<l-1? ' ':'\n');

    return 0;
}

Measured memory_bytes: 2800
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
int ans[520][520];
void divide(vector<int> a,int dep){
	int n = a.size();
	if(n<=1)return ;
	vector<int> x,y;
	for(int i=0;i<n;i++){
		if(i<n/2)x.pb(a[i]);
		else  y.pb(a[i]);
	}
	for(int i:x)for(int j:y)ans[i][j] = dep;
	divide(x,dep+1);
	divide(y,dep+1);
}
int main()
{
	int n;cin>>n;
	vector<int> tmp;
	for(int i=1;i<=n;i++)tmp.pb(i);
	divide(tmp,1);
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++)
			printf("%d ",ans[i][j]);
		puts("");
	}
	return 0;
}


Measured memory_bytes: 1536
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n=sc.nextLong();
		long a[]=new long[5];
		for(int i=0;i<5;i++) a[i]=sc.nextLong();
		Arrays.sort(a);
		System.out.println(n%a[0]==0?n/a[0]+4:n/a[0]+5);
	}
}



Measured memory_bytes: 23124
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <bits/stdc++.h>
#define llinf 4154118101919364364

using namespace std;
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
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;
}

bool judge(long long n,long long k){
  if(n<=0){return false;}
  Bint v=n,bk=k;
  v=(v*(v+1));v/=2;
  if(v%bk==0){return true;}
  return false;
}

int main(){
  long long n,cn;
  scanf("%lld",&n);
  if(n==1){puts("1");return 0;}
  cn=n;
  cn*=2;
  vector<long long> pf;
  for(long long i=2;i*i<=cn;i++){
    if(cn%i!=0){continue;}
    long long v=1;
    while(cn%i==0){
      v*=i;
      cn/=i;
    }
    pf.push_back(v);
  }
  if(cn!=1){
    pf.push_back(cn);
  }
  int cnt=pf.size();

  long long res=n;//res=n-1;

  for(int i=0;i<(1<<cnt);i++){
    long long jv=1;
    for(int j=0;j<cnt;j++){
      if(i&(1<<j)){jv*=pf[j];}
    }
    long long tjv=(n/jv);
    long long cx,cy;
    extGCD(jv,tjv,cx,cy);
    long long te;
    if(cx>0){te=jv*cx;}
    else{te=tjv*cy;}
    if(te%n==0){te=n;}else{te%=n;}
    for(long long j=-3;j<=3;j++){
      if(judge(te+j,n)){res=min(te+j,res);}
    }
  }
  printf("%lld\n",res);
  return 0;
}


Measured memory_bytes: 3832
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<string>
#define LL long long
#define li i<<1
#define ri i<<1|1
using namespace std;
inline LL read()
{
    char c=getchar();LL x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
char s[10];
int main()
{
	cin>>s;
	if(s[0]>='a'&&s[0]<='z')
		printf("a\n");
	else
		printf("A\n");
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repm(i,m,n) for (int i = (m); i < (n); i++)
#define rrep(i,n) for (int i = (n); i >= 0; i--)
using namespace std;
typedef long long ll;

int main() {
  int N, T, A;
  cin >> N >> T >> A;
  vector<int> H(N);
  rep(i,N) cin >> H.at(i);
  
  int ans;
  double Ti , d;
  double dmin = 1e9;
  rep(i,N) {
    Ti = T - H.at(i)*0.006;
    d = abs(Ti - A);
    if (d < dmin) {
      dmin = min(d,dmin);
      ans = i+1;
    }
  }
  
  cout << ans << endl;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> v(n + 2, 0);
    vector<int> ans(n + 2, 0);
    for (int i = 1; i <= n; i++) cin >> v[i];
    while (k--) {
        int maxOut = 0;
        for (int i = 0; i < n + 2; i++) ans[i] = 0;
        for (int i = 1; i <= n; i++) {
            int left = max(1, i - v[i]);
            int right = min(n, i + v[i]);
            ans[left] += 1;
            ans[right + 1] -= 1;
        }
        for (int i = 1; i <= n; i++) {
            ans[i] += ans[i - 1];
            v[i] = ans[i];
            maxOut += v[i] == n;
        }
        if (maxOut == n) break;
    }
    for (int i = 1; i <= n; i++) {
        cout << v[i] << " ";
    }

    return 0;
}


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

int main() {
  int n, w;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
  }

  int b0 = 0;
  for(int i = 0; i < n; i++){
    if(i%2 == 0) b0 += a.at(i);
    else b0 -= a.at(i);
  }
  b.at(0) = b0;
  cout << b.at(0);

  for(int i = 0; i < n-1; i++){
    b.at(i+1) = 2*a.at(i) - b.at(i);
    cout << " " << b.at(i+1);
  }
  cout << endl;
}


Measured memory_bytes: 2048
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	ll N, A, B;
	cin >> N >> A >> B;

	ll AB = A + B;

	ll wari = N / AB;
	ll amari = N % AB;

	co(wari * A + min(amari, A));



	Would you please return 0;
}

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

using namespace std;

int a[11], k;

int main(void) {
  for (int i = 0; i < 5; i++) {
    scanf("%d", a + i);
  }
  scanf("%d", &k);
  puts(a[4] - a[0] > k ? ":(" : "Yay!");  
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

  
public class Main {
	
	
  public static void main(String[] args) {
	  Scanner sc=new Scanner(System.in);
	  
	  
	  
		  int a=Integer.parseInt(sc.next());
		  int b=Integer.parseInt(sc.next());
		  int c=Integer.parseInt(sc.next());
		  int x,y,z;
		  
		  x=Math.max(a,b);
		  z=Math.min(a, b);
		  y=Math.max(x, c);
		  int q=Math.min(x, c);
		  int p=Math.max(z, q);
		  int r=Math.min(z, q);

		  System.out.println(r +" "+ p +" "+  y);;
		  
  }
}

Measured memory_bytes: 17292
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end

nums = gc

puts eval nums.join('+')


Measured memory_bytes: 2300
import sys

bitcnt = [0] * (1 << 10)
for i in range(1,1 << 10):
    bitcnt[i] = bitcnt[i//2] + i % 2
    bitcnt[i] %= 2

field = [[bitcnt[i & j] for j in range(1 << 10)] for i in range(1 << 10)]
    
n, m = map(int, input().split())
n = 1 << n
m = 1 << m
for i in range(1, n):
    for j in range(1, m):
        num = field[i][j] - field[i-1][j-1] - field[i-1][j] -field[i][j-1]
        sys.stdout.write(str(num%2))
    print()

Measured memory_bytes: 13808
A = ['']*3
for i in range(3):
    A[i] = list(map(int,input().split()))
N = int(input())
B = [0]*N
for i in range(N):
    B[i] = int(input())

# print(A)
# print(A[0][0])
# print(A[0].index(66))
for b in B:
    for i in range(3):
        if b in A[i]:
            # print(b)
            A[i][A[i].index(b)] = 0
        


flag = False
for i in range(3):
    if A[i][0] == A[i][1] == A[i][2] == 0:
        flag = True
    if A[0][i] == A[1][i] == A[2][i] == 0:
        flag = True
if A[0][0] == A[1][1] == A[2][2] == 0:
    flag = True
if A[0][2] == A[1][1] == A[2][0] == 0:
    flag = True
if flag:
    print('Yes')
else:
    print('No')

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

using namespace std;

//typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)

typedef pair<int, int> P;
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };

int H, W;
int sy, sx, gy, gx;
char a[402][402];
int d[402][402];

int bfs(int sy, int sx){
	queue<P> que;

	// 通ったところを記録
	vector<P> v;

	for (int h = 1; h <= H; h++)
		for (int w = 1; w <= W; w++) d[h][w] = INF;

	que.push(P(sy, sx));
	d[sy][sx] = 0;

	v.push_back(P(sy, sx));

	int black = 1, white = 0;

	while (que.size()>0){
		P p = que.front();
		que.pop();

		for (int i = 0; i < 4; i++){
			int ny = p.first + dy[i], nx = p.second + dx[i];
			// 今黒なら次が白だけqueueに
			if (a[p.first][p.second]=='#'){
				if (a[ny][nx] == '.' && d[ny][nx] == INF){
					que.push(P(ny, nx));
					d[ny][nx] = d[p.first][p.second] + 1;
					white++;
					v.push_back(P(ny, nx));
				}
			}
			// 今白なら次が黒だけqueueに
			else if (a[p.first][p.second] == '.'){
				if (a[ny][nx] == '#' && d[ny][nx] == INF){
					que.push(P(ny, nx));
					d[ny][nx] = d[p.first][p.second] + 1;
					black++;
					v.push_back(P(ny, nx));
				}
			}
		}
	}
	for (int i = 0; i < v.size(); i++)
		a[v[i].first][v[i].second] = '%';
	/*
	int black = 0, white=0;
	for (int h = 1; h <= H; h++)
		for (int w = 1; w <= W; w++){
			if (d[h][w] != INF && a[h][w] == '.'){
				white++;
				a[h][w] = '%';
			}
			if (d[h][w] != INF && a[h][w] == '#'){
				black++;
				a[h][w] = '%';
			}
		}
	*/
	return black*white;
}

signed main(){

	cin >> H >> W;

//		H = W = 400;
//		for (int h = 1; h <= H; h++)
//			for (int w = 1; w <= W; w++) a[h][w]= '.';


	int bl = 0, wh = 0;
	for (int h = 1; h <= H; h++)
		for (int w = 1; w <= W; w++){
			cin >> a[h][w];
			if (a[h][w] == '#') bl++;
			else wh++;
		}

	if (bl > wh){
		for (int h = 1; h <= H; h++)
			for (int w = 1; w <= W; w++){
				if (a[h][w] == '#') a[h][w] = '.';
				else a[h][w] = '#';
			}
	}

	int ans = 0;
	for (int h = 1; h <= H; h++)
		for (int w = 1; w <= W; w++)
			if (a[h][w] == '#'){
				ans += bfs(h, w);
			}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 7540
from math import pow,fabs

N = int(input())
X = list(map(float,input().split()))
Y = list(map(float,input().split()))

def distance(length,x,y,n):
    D = 0
    for i in range(length):
        D += fabs(x[i]-y[i]) ** n
    return pow(D,1.0/n)

def che_distance(length,x,y):
    D = 0
    for i in range(length):
        if D < fabs(x[i]-y[i]):
            D = fabs(x[i]-y[i])
    return D

p1 = distance(N,X,Y,1)
p2 = distance(N,X,Y,2)
p3 = distance(N,X,Y,3)
pinf = che_distance(N,X,Y)

print("{}\n{}\n{}\n{}".format(p1,p2,p3,pinf))


Measured memory_bytes: 5728
import itertools
 
n=int(input())
H,L=[[] for _ in range(n)],[[] for _ in range(n)]
 
for i in range(n):
  m=int(input())
  for j in range(m):
    x,y=map(int,input().split())
    if y==1:
      H[i].append(x-1)
    else:
      L[i].append(x-1)
      
N=set(range(n))
ans=0
pat=set()
for num in range(1,n+1):
  pat=pat|set(itertools.combinations(range(n),num))
for h in pat:
    h=set(h)
    num=len(h)
    nh=N-h
    t=sum([H[i] for i in h],[])
    l=sum([L[i] for i in h],[])
    if set(t)<=h and set(l)<=nh:
      ans=max(ans,num)
print(ans)

Measured memory_bytes: 10800
#include<bits/stdc++.h>
using namespace std;
int num[10];
void init()
{
    int x = 10;
    num[1] = 9;
    for (int i = 2;i < 8;i ++)
    {
        if (i&1) num[i] = num[i-1] + x * 10 - x;
        else num[i] = num[i-1];
        x *= 10;
     //   cout<<i<<'\t'<<num[i]<<endl;
    }
}
int digit(int n)
{
    int ans = 0;
    while (n) n/=10,ans ++;
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    int n,ans = 0;
    init();
    cin>>n;
    if (digit(n)&1) ans = num[digit(n)-1]+n-pow(10,digit(n)-1)+1;
    else ans = num[digit(n)];
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;


int main(void) {
	ll n; cin >> n;
	string s = to_string(n);
	ll sum = 0;
	for(auto u : s) sum += u - '0';
	if(n % sum == 0)printf("Yes\n");
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	static int i,j,cntH,cntB;
	public static void main(String[] args) {
		
		Scanner sc=new Scanner(System.in);
		int a[]=new int[4];
		int b[]=new int[4];
		while(sc.hasNextInt()){
			cntH=0;
			cntB=0;
			for( i=0;i<4;i++){a[i]=sc.nextInt();}
			for( i=0;i<4;i++){b[i]=sc.nextInt();}
			for( i=0;i<4;i++){
				if(a[i]==b[i])cntH++;			
			}
			//System.out.println(cntH);
			for(i=0;i<4;i++){
				for(j=0;j<4;j++){
					if(a[i]==b[j])cntB++;
				}
			}
		//	System.out.println(cntB);
			System.out.println(cntH+" "+(cntB-cntH));
		}
	}
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const ll MOD = 1000000007;
const int MN = 70;
const int MX = 1000010;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

bool ex[MX], ey[MX];
ll f[MN][MN];

int main() {
	int H, W, N;
	cin >> H >> W >> N;

	vector<pii> pt(N);

	vi xs, ys;
	xs.pb(0); xs.pb(H); ys.pb(0); ys.pb(W);

	rep(i, N) {
		cin >> pt[i].fi >> pt[i].se;
		ex[pt[i].fi] = ey[pt[i].se] = 1;
		xs.pb(pt[i].fi); xs.pb(pt[i].fi + 1);
		ys.pb(pt[i].se); ys.pb(pt[i].se + 1);
	}

	sort(ALL(xs)); sort(ALL(ys));
	xs.erase(unique(ALL(xs)), xs.end()); ys.erase(unique(ALL(ys)), ys.end());

	int sx = xs.size(), sy = ys.size();

	rep(i, N) {
		int p = lower_bound(ALL(xs), pt[i].fi) - xs.begin();
		int q = lower_bound(ALL(ys), pt[i].se) - ys.begin();
		f[p][q] = -1;
	}

	rep(i, sx-1) {
		rep(j, sy-1) {
			if (f[i][j] != -1) {
				f[i][j] = (ll)(xs[i+1] - xs[i]) * (ys[j+1] - ys[j]) % MOD;
			}
		}
	}

	ll ret = 0;
	rep(i, sx-1) {
		rep(j, sy-1) if (f[i][j] != -1) {
			queue<pii> que;
			que.push(mp(i, j));

			vector<vi> d(sx, vi(sy));
			rep(ii, sx) rep(jj, sy) d[ii][jj] = -1;
			d[i][j] = 0;

			while (!que.empty()) {
				pii p = que.front(); que.pop();
				int x = p.fi, y = p.se;
				rep(dir, 4) {
					int nx = x + dx[dir], ny = y + dy[dir];
					if (nx >= 0 && nx < sx-1 && ny >= 0 && ny < sy-1 && f[nx][ny] != -1 && d[nx][ny] == -1) {
						d[nx][ny] = d[x][y] + 1;
						que.push(mp(nx, ny));
					}
				}
			}

			rep(p, sx) {
				rep(q, sy) {
					if (d[p][q] != -1) {
						ret = (ret + f[p][q] * f[i][j] % MOD * d[p][q]) % MOD;
					}
				}
			}
		}
	}

	ret = (MOD + 1) / 2 * ret % MOD;

	sort(ALL(pt));
	int p = 0;

	rep(i, H-1) {
		if (!ex[i] && !ex[i+1]) {
			while (p < N && pt[p].fi <= i) {
				++p;
			}
			ll nx = ((ll)W * (i + 1) - p) % MOD;
			ll ny = ((ll)W * (H - i - 1) - (N - p)) % MOD;
			ret = (ret + nx * ny) % MOD;
		}
	}

	p = 0;
	rep(i, N) swap(pt[i].fi, pt[i].se);
	sort(ALL(pt));

	rep(i, W-1) {
		if (!ey[i] && !ey[i+1]) {
			while (p < N && pt[p].fi <= i) {
				++p;
			}
			ll nx = ((ll)H * (i + 1) - p) % MOD;
			ll ny = ((ll)H * (W - i - 1) - (N - p)) % MOD;
			ret = (ret + nx * ny) % MOD;	
		}
	}

	cout << ret << endl;
	return 0;
}

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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fill(a,v) memset(a,v,sizeof(a))
#define d1(a) cout << a << "\n"
#define d2(a,b) cout << a << " " << b << "\n"
#define d3(a,b,c) cout << a << " " << b << " " << c << "\n"
#define d4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << "\n"
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

int32_t main(){
	fast;
	int n;
	cin >> n;
	string s;
	cin >> s;
	s = "#" + s;

	int R[n+5] = {0} , G[n+5] = {0} , B[n+5] = {0};
	for(int i=1 ; i<=n ; i++){
		R[i] = R[i-1];
		G[i] = G[i-1];
		B[i] = B[i-1];
		if(s[i] == 'R'){
			R[i]++;
		}
		else if(s[i] == 'G'){
			G[i]++;
		}
		else{
			B[i]++;
		}
	}
	int ans = 0;
	for(int i=1 ; i<=n ; i++){
		if(s[i] == 'R'){
			ans += G[i] * (B[n] - B[i]);
			ans += B[i] * (G[n] - G[i]);
		}
		else if(s[i] == 'G'){
			ans += R[i] * (B[n] - B[i]);
			ans += B[i] * (R[n] - R[i]);
		}
		else {
			ans += G[i] * (R[n] - R[i]);
			ans += R[i] * (G[n] - G[i]);
		}
		int l = i-1 , r = i+1;
			while(l >= 1 && r <= n)
			{
				if(s[l] != s[i] && s[r] != s[i] && s[l] != s[r])
					ans--;
				l--;
				r++;
			}
	}
	cout << ans;
}

Measured memory_bytes: 3676
def div(n):
    div_pair = []
    for i in range(1,  int(n ** 0.5 +1)):
        if n % i == 0:
            diff = abs(n // i - i)
            div_pair.append([diff, i, n // i])
    return div_pair


n = int(input())
l = sorted(div(n))
ans = l[0][2] + l[0][1] - 2
print(ans)


Measured memory_bytes: 3648
#include <cstdio>
#include <algorithm>
#define N 50
using namespace std;

int n,ans,a[N+5];

inline int read(){
	int s=0,t=1;
	char c=getchar();
	while((c<'0'||c>'9')&&c!='-')c=getchar();
	if(c=='-')t=-1,c=getchar();
	while(c>='0'&&c<='9')s=(s<<1)+(s<<3)+(c^48),c=getchar();
	return s*t;
}

int main(void){
	n=read();
	for(int i=1;i<=n;i++)
	a[i]=read();
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++)
		if(i!=j)ans+=a[i]*a[j]; 
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import lru_cache, reduce
from math import gcd
from operator import add, itemgetter, mul, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


r = int(sys.stdin.buffer.readline())
a = r * 2 * math.pi
print(a)


Measured memory_bytes: 27224
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	int t; cin >> t;
	while (t--) {
		LL n, k; cin >> n >> k;
		VL x(n); rep(i, n)cin >> x[i];
		VL d(n - 1); rep(i, n - 1)d[i] = x[i + 1] - x[i];
		sort(all(d));

		LL ans = 0;
		rep(i, n - k) {
			ans += d[i];
		}
		Cout(ans);
	}
}


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

int main()
{
    int  n,k;
    cin >> n>>k;
    int count=1;
   for(int i=0;i<n;i++){
       if(count>=k){
           count+=k;
       }
       else{
           count*=2;
       }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  string s;
  cin >> s;
  reverse(rng(s));
  s += '0';
  int N = sz(s);
  vi dp(2,INF);
  dp[0] = 0;
  rep(i,N) {
    vi dp2(2,INF);
    int x = s[i]-'0';
    rep(j,2) {
      x += j;
      rep(k,10) {
        int nj = 0;
        int b = k-x;
        if(b<0) {
          nj = 1;
          b += 10;
        }
        chmin(dp2[nj],dp[j]+k+b);
      }
    }
    dp = dp2;
  }
  cout << dp[0] << endl;
  return 0;
}

Measured memory_bytes: 1412
const main = input => {
  const [x, y] = input.trim().split(' ').map(x => parseInt(x))
  const group = {
    1: 1,
    2: 3,
    3: 1,
    4: 2,
    5: 1,
    6: 2,
    7: 1,
    8: 1,
    9: 2,
    10: 1,
    11: 2,
    12: 1,
  }

  if (group[x] === group[y]) {
    console.log('Yes')
  } else {
    console.log('No')
  }
}

// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 29364
#include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;
#define pi 3.141592653589793283462
int main(){
    int a,b,c;
	int p=0;
	cin>>a>>b>>c;
	for(int i=a;i<=b;i++){
	    if(c%i==0)
	       ++p;
	    }
	cout<<p<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void){
    int N,tmp;
    int cnt = 0;
    int i,j,mini;

    scanf("%d" ,&N);
    int num[N];

    for(i = 0;i < N;i++){
        scanf("%d", &num[i]);
    }

    for(i = 0; i < N;i++){
        mini = i;
        for(j = i;j < N;j++){
        	if(num[j] < num[mini]){
        		mini = j;
        	}
        }

        if(i != mini){
        	tmp = num[mini];
	        num[mini] = num[i];
	        num[i] = tmp;
	        cnt++;
        }
    }

    for(i = 0; i < N - 1;i++){
        printf("%d ", num[i]);
    }
    printf("%d\n%d\n", num[N-1], cnt);

    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> iP;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = 99999999;
const int MAX_N = int(1e5) + 5;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)

int main() {
    int a,b,c,d,e,f,w=0,s=0;
    cin >> a >> b >> c >> d >> e >> f;

    REP(ai,30){
        if(ai*a*100>f)break;
        REP(bi,30){
            if((ai*a+bi*b)*100>f)break;
            REP(ci,3000){
                int wt = (ai*a+bi*b)*100, st = ci*c;
                if(wt+st>f)break;
                if((wt/100)*e<st)break;
                int di=0;
                while(wt+st+(di+1)*d<=f && (wt/100)*e>=st+(di+1)*d)di++;
                st += di*d;
                if(w==0 || s*(wt+st)<(st)*(w+s)){
                    w = wt;
                    s = st;
                }
            }
        }
    }
    cout << w+s << " " << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int m,n;
	char k[10010];
	cin>>m>>n;
	cin>>k;
	for(int i=0;i<m;++i){
		if(k[i]<'0'||k[i]>'9'){
			cout<<"No"<<endl;
			return 0;
		}
	}
	if(k[m]!='-'){
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=m+1;i<=m+n;++i){
		if(k[i]<'0'||k[i]>'9'){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

using namespace std;

int shop[100001] = {0};
int main(){
    int d;
    while(scanf("%d",&d),d){
        int n;
        scanf("%d",&n);

        int m;
        scanf("%d",&m);

        memset(shop,0,sizeof(shop));

        shop[0] = 0;
        shop[1] = d;

        for(int i = 2;i < n+1; i++){
            scanf("%d",&shop[i]);
        }
        sort(shop,shop+1+n);

        int ans = 0;
        for(int i = 0;i < m; i++){
            int x = 0;
            scanf("%d",&x);

            int a = abs(x - *(lower_bound(shop,shop+n+1,x)-1));
            int b = abs(x - *(lower_bound(shop,shop+n+1,x)));

            int mi = min(a,b);
            ans += mi;
        }

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

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

int main()
{
  int n;
  while( cin >> n, n ) {
    int a, b, c, d;
    int sum = 0;

    while( n-- ) {
      int size = 0;
      cin >> a >> b >> c >> d;
      size += a + b + c;
      
      if( size <= 60 && d <= 2 ) {
	sum += 600;
      } 
      else if( size <= 80 && d <= 5 ) {
	sum += 800;
      }
      else if( size <= 100 && d <= 10 ) {
	sum += 1000;
      }
      else if( size <= 120 && d <= 15 ) {
	sum += 1200;
      }
      else if( size <= 140 && d <= 20 ) {
	sum += 1400;
      }
      else if( size <= 160 && d <= 25 ) {
	sum += 1600;
      }
    }

    cout << sum << endl;
  }

}

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

int main() {
  int X,f_X,X_r = 10;
  
  cin >> X;
  f_X = X%10;
  
  rep(i,8) {
    X_r *= 10;
       f_X += (X%X_r)/(X_r/10);
    }
  
  if (X%f_X == 0){
     cout << "Yes" << endl;
   }
   else{
     cout << "No" <<endl;
   }
    
  
}

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

#define pb         push_back

const int INF = 100000000;
const int N = 300000;

int Eratos[N];

void era(){
	for(int i=0; i<N; i++){
		Eratos[i] = 1;
	}

	Eratos[0] = Eratos[1] = 0;
	for(int i=2; i*i<=N; i++){
		if(Eratos[i] == 0) continue;
		for(int j=2; i*j < N; j++){
			Eratos[j*i] = 0;
		}
	}
}

int main(void) {
	era();
	int n; 
	while(cin >> n, n){
		if(n == 0) break;

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

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

int main(){
  int n,a;
  cin>>n>>a;
  if(n%500<=a){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}

};

int main() {
	int n, t, in;
	ll  ans = 1;
	cin >> n >> t;
	vi v(n);
	vi vsum(100001, 0);
	rep(i, n) {
		cin >> v[i];
		vsum[v[i]]++;
	}
	sort(all(v));
	range(i, 1, vsum.size()) {
		vsum[i] += vsum[i - 1];
	}
	rep(i, n) {
		ans *= (i + 1 - vsum[max(v[i] - t-1, 0)]);
		ans %= MOD; 
	}
	cout << ans << endl;
}



Measured memory_bytes: 3620
import java.util.*;

public class Main {

	static int[] tree = null;
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	tree = new int[N+1];

    	for(int i = 1; i < N+1; i++){
        	tree[i] = sc.nextInt();
        }

        BuildMaxHeap();

        for(int i=1;i < tree.length;i++){System.out.print(" " + tree[i]);}
        System.out.println();
    }

    private static void BuildMaxHeap(){
    	for (int i = (tree.length-1)/2;i>=1;i--){
    		conMaxHeap(i);}
    }
    
    private static void conMaxHeap(int key){
    	int left  = left(key);
    	int right = right(key);
    	int largest = key;
    	if(left  < tree.length){ if(tree[largest] < tree[left] ){largest = left ;}}
    	if(right < tree.length){ if(tree[largest] < tree[right]){largest = right;}}
    	if(largest != key)     { swap(key,largest); conMaxHeap(largest);}
    }

    private static void swap(int i,int j){int temp = tree[i]; tree[i] = tree[j]; tree[j] = temp;}
    private static int left(int i){return 2 * i;}
    private static int right(int i){return 2 * i + 1;}
}

Measured memory_bytes: 169760
#include <iostream>
#include <utility>
#include <cmath>
using namespace std;

int main() {
    bool field[1001][1001];
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 1001; j++) {
            for (int k = 0; k < 1001; k++) {
                field[j][k] = false;
            }
        }
        int x = 0, y = 0;
        while (true) {
            int dx, dy;
            cin >> dx >> dy;
            if ((dx | dy) == 0) {
                break;
            }
            x += dx;
            y += dy;
            field[y][x] = true;
        }
        double maxDistance = 0;
        pair<int, int> treasure(0, 0);
        for (int y = 0; y < 1001; y++) {
            for (int x = 0; x < 1001; x++) {
                if (field[y][x]) {
                    double distance = sqrt(x * x + y * y);
                    if (maxDistance < distance || (maxDistance == distance && treasure.first < x)) {
                        maxDistance = distance;
                        treasure.first = x;
                        treasure.second = y;
                    }
                }
            }
        }
        cout << treasure.first << " " << treasure.second << endl;
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>
#include <vector>
#include <cstring>
#include <map>

using namespace std;

bool used[10];
bool tabu[10];
int keisu[10];
int ans;
int cnt; // 文字数
int n;

void dfs(int k, int sum){
    if (k == cnt) {
        if (sum == 0) {
            ans++;
        }
        return;
    }
    
    for (int i = 0; i < 10; i++) {
        if (used[i] || (i == 0 && tabu[k])) {
            continue;
        }
        used[i] = true;
        dfs(k + 1, sum + i * keisu[k]);
        used[i] = false;
    }
    return;
}

int main(){
    while (cin >> n, n) {
        map<char, int> id;
        vector<string> str(n);
        cnt = 0;
        ans = 0;
        
        for (int i = 0; i < 10; i++) {
            used[i] = false;
            tabu[i] = false;
            keisu[i] = 0;
        }

        for(int i = 0; i < n; i++){
            cin >> str[i];
            string s = str[i];
            for (int j = 0; j < s.size(); j++) {
                if (id.count(s[j]) == 0) {
                    id[s[j]] = cnt++;
                }
                if (j == 0 && s.size() > 1) { // 0にならない記号か
                    tabu[id[s[j]]] = true;
                }
                if (i != n - 1) {
                    keisu[id[s[j]]] += pow(10, s.size() - j - 1);
                }else{
                    keisu[id[s[j]]] -= pow(10, s.size() - j - 1);
                }
            }
        }
        dfs(0, 0);
        cout << ans << endl;
    }
}

Measured memory_bytes: 1256