akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
  double n;
  cin>>n;
  double odd=0;
  double ans;
  for(int i=1;i<=n;i++)
  {
    if(i%2!=0)
    {
        odd=odd+1;
        
    }
  }
  
  
  ans=odd/n;
  std::cout << std::setprecision(10);
  std::cout<<ans<<endl;
  return 0;
}
  

Measured memory_bytes: 256
//#include<bits/stdc++.h>
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<algorithm>
#include<set>
#include<vector>
#include<queue>
#include<cmath>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<ctime>
#include<map>
#include<stack>
#include<string>
using namespace std;
#define ll long long
const int inf = 0x3f3f3f3f;
const int maxn =105;
int n,k;
int v[20];
bool f(int x)
{
	while(x)
	{
		int m=x%10;
		if(v[m]==1)return 0;
		x/=10;
	}
	return 1;
}
int main(void)
{
	cin>>n>>k;
	for(int i=1;i<=k;i++)
	{
		int a;
		cin>>a;
		v[a]=1;
	}
	while(1)
	{
		if(f(n))
		{
			cout<<n<<endl;
			return 0;
		}
		n++;
	}
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N;
  	cin >> N;
  	int a[N];
  	for(int i=0;i<N;i++){
      cin >> a[i];
    }
    int count=0,light=1,flag=-1;
  	for(int i=0;i<N;i++){
      light = a[light-1];
      count++;
      if(light == 2){
        flag = 1;
        break;
      }
    }
  	if(flag == -1){
      cout << flag << endl;
    }else{
  	  cout << count << endl;
    }
}
  

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

using namespace std;

const int ch = -32;
string s;
int main()
{
    getline(cin, s);
    for(int i = 0;i < (int)s.size();i++)
    {
        if(s[i] >= 97 && s[i] <= 122)s[i] = s[i] - 32;
        else if(s[i] <= 90 && s[i] >= 65)s[i] = s[i] + 32;
    }
    cout << s << '\n';
    return 0;
}



Measured memory_bytes: 3172
#include <iostream>
#include <iomanip> // setprecision
#include <cmath>

using namespace std;
typedef long long ll;
const double long PI = acos(-1);

void solve() {
  string S, week_day[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  cin >> S;
  ll ans;
  for (ans=0;ans<7;ans++){
    if (S == week_day[ans]) {
      break;
    }
  }
  cout << (7 - ans) << endl;
}

int main(void) {
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import std.regex;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;
enum long MOD = 10L^^9+7;

void main() {
  long N, M;
  scanln(N, M);
  writeln(N*(N-1)/2 + M*(M-1)/2);
}

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


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep);

  string line = readln.chomp;
  static if (__VERSION__ >= 2074) {
    line.formattedRead!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "line.formattedRead(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(void){
long h;
  scanf("%ld",&h);
  int jou=0;
  while(h>1){
	h/=2;
    jou++;
  }
  long ans=1*(pow(2,jou+1)-1);
  printf("%ld",ans);
  
  return 0;
}
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b) cout<<c<<endl;
    else if(a==c) cout<<b<<endl;
    else cout<<a<<endl;
}

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

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n){
        for(int i = 0;i < n;i++)par[i] = i;
    }
    
    int root(int x){
        if(par[x] == x)return x;
        return par[x] = root(par[x]);
    }
    
    void unite(int x,int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry)return;
        par[rx] = ry;
    }
    
    bool same(int x,int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
    int n,m;
    cin >> n >> m;
    int a[m],b[m];
    
    UnionFind tree(n);
    
    for(int i = 0;i < m;i++){
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
        
        int mx = max(a[i],b[i]),mn = min(a[i],b[i]);
        tree.unite(mx,mn);
    }
    
    int alina = 0;
    map<int,int> mp;
    for(int i = 0;i < n;i++){
        int gray = tree.root(i);
        mp[gray]++;
    }
    
    for(auto p : mp){
        if(p.second > alina)alina = p.second;
    }
    
    cout << alina << endl;
}

Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	string s;
	cin >> s;
	s.erase(s.size() - 1);
	int n = s.size();
	rep(i, n) {
		if (s.size() % 2 == 0) {
			string t = s.substr(0, s.size() / 2);
			if (s == t + t) {
				cout << s.size() << endl;
				return 0;
			}
		}
		s.erase(s.size() - 1);
	}

	return 0;
}


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

struct node_t {
	int key;
	struct node_t *parent;
	struct node_t *left;
	struct node_t *right;
};
typedef struct node_t Node;

Node *tree_insert(Node *top, Node *z) {
	Node *y, *x;

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

int tree_find(Node *node, int key) {
	if (node == NULL)
		return 0;
	if (node->key == key)
		return 1;
	if (key < node->key)
		return tree_find(node->left, key);
	return tree_find(node->right, key);
}

void inorder_walk(Node *node) {
	if (node->left != NULL) {
		inorder_walk(node->left);
	}
	printf(" %d", node->key);
	if (node->right != NULL) {
		inorder_walk(node->right);
	}
}

void preorder_walk(Node *node) {
	printf(" %d", node->key);
	if (node->left != NULL) {
		preorder_walk(node->left);
	}
	if (node->right != NULL) {
		preorder_walk(node->right);
	}
}

int main(void) {
	int n, i, key;
	char cmd[20];
	Node *top = NULL, *p;

	scanf("%d ", &n);
	for (i = 0; i < n; i++) {
		scanf("%s %d ", cmd, &key);
		if (cmd[0] == 'i') {
			p = malloc(sizeof(Node));
			p->key = key;
			p->parent = p->left = p->right = NULL;
			top = tree_insert(top, p);
		} else if (cmd[0] == 'f') {
			puts(tree_find(top, key) ? "yes" : "no");
		} else {
			inorder_walk(top);
			putchar('\n');
			preorder_walk(top);
			putchar('\n');
		}
	}
	return 0;
}



Measured memory_bytes: 20460
/*
    なるべく諦めない！
    なせば大抵なんとかなる！
*/

#define VERNIY st();int ver=0,niy=0,hbk=0

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <float.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <functional>
#include <set>
#include <stack>
#define LLU unsigned long long int
#define LL long long int
using namespace std;
#define Lfmax DBL_MAX
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vpd vector<pair<int,int>>
#define vLL vector<long long int>
#define vpLL vector<pair<long long int,long long int>>
#define vLLU vector<unsigned long long int>
#define vpLLU vector<pair<unsigned long long int,unsigned long long int>>
#define pd pair<int,int>
#define pLL pair<long long int,long long int>
#define pLLU pair<unsigned long long int,unsigned long long int>
#define qd queue<int>
#define qpd queue<pair<int,int>>
#define maxpqd priority_queue<int>
#define minpqd priority_queue<int, vector<int>, greater<int>>
#define fr front
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; ++a)
#define forineq(a,b,c) for(int a=b ; a<=c ; ++a)
#define forde(a,b,c) for(int a=b ; a>=c ; --a)
#define UPC(oo) (oo>='A' && oo<='Z')
#define LWC(oo) (oo>='a' && oo<='z')
#define DGT(oo) (oo>='0' && oo<='9')
#define UPCVOC(oo) (oo=='A' || oo=='E' || oo=='I' || oo=='U' || oo=='O')
#define LWCVOC(oo) (oo=='a' || oo=='e' || oo=='i' || oo=='u' || oo=='o')
#define filein freopen("in.txt","r",stdin);
#define fileout freopen("out.txt","w",stdout);

inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void sctlld(LL &a,LL &b,LL &c){scanf("%I64d %I64d %I64d",&a,&b,&c);}
inline void scdlld(LL &a,LL &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(LL &a){scanf("%I64d",&a);}
inline void scllu(LLU &a){scanf("%I64u",&a);}
inline void scdllu(LLU &a,LLU &b){scanf("%I64u %I64u",&a,&b);}
inline void sctllu(LLU &a,LLU &b,LLU &c){scanf("%I64u %I64u %I64u",&a,&b,&c);}

template<class Ver>
inline void prd(Ver a){cout<<a<<"\n";};
template<class Ver>
inline void prdd(Ver a,Ver b){cout<<a<<" "<<b<<"\n";};
template<class Ver>
inline void prtd(Ver a, Ver b, Ver c){cout<<a<<" "<<b<<" "<<c<<"\n";};

inline void debug(){printf("asd\n");}
template<class Ver>
inline void debugd(Ver a){cout<<"--- "<<a<<endl;};
template<class Ver>
inline void debugdd(Ver a,Ver b){cout<<"--- "<<a<<" "<<b<<endl;};
template<class Ver>
inline void debugtd(Ver a,Ver b,Ver c){cout<<"--- "<<a<<" "<<b<<" "<<c<<endl;};

#define grav 9.8
#define pi 3.14159265
#define MOD 1000000007

void st()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

int main()
{
	VERNIY;
	string a;
	cin>>a;
	a="2018"+a.substr(4);
	cout<<a<<endl;
	return 0;
}

/*
    なるべく諦めない！
    なせば大抵なんとかなる！
*/



Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=2e5+10;
int a[maxn],b[maxn],na[maxn],nb[maxn];
int n;

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
    int ans=0;
    for(int i=0;i<=28;i++)
    {
        for(int j=1;j<=n;j++){
            na[j]=a[j]&((1<<(i+1))-1);
            nb[j]=b[j]&((1<<(i+1))-1);
        }
        sort(nb+1,nb+1+n);
        int t1=1<<i,t2=2*t1,t3=3*t1,t4=4*t1;
        int now=0;
        for(int j=1;j<=n;j++){
            now^=(lower_bound(nb+1,nb+1+n,t2-na[j])-lower_bound(nb+1,nb+1+n,t1-na[j]))&1;
            now^=(lower_bound(nb+1,nb+1+n,t4-na[j])-lower_bound(nb+1,nb+1+n,t3-na[j]))&1;
        }
        ans+=now<<i;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

char get(int a, int b, int c) {
    long long x, y, z, l, r, m;
    
    l = 0, r = max(a, b), m = (l + r) / 2;
    
    while (r - l > 1) {
        long long a1 = (a + m - 1) / m;
        long long a2 = a;
        long long b1 = (b + m - 1) / m;
        long long b2 = b;
        
        if (a1 > b2 + 1 || b1 > a2 + 1) {
            l = m;
            m = (l + r) / 2;
        } else {
            r = m;
            m = (l + r) / 2;
        }
    }
    
    x = r;
    
    l = 0, r = a / x + 1, m = (l + r) / 2;
    
    while (r - l > 1) {
        long long aa = a - m * x;
        long long bb = b - m;
        
        if (aa < 0 || bb < 0 || bb > aa * x) {
            r = m;
            m = (l + r) / 2;
        } else {
            l = m;
            m = (l + r) / 2;
        }
    }
    
    y = l;
    
    if (c < y * (x + 1)) {
        if (c % (x + 1) == x) {
            return 'B';
        } else {
            return 'A';
        }
    }
    
    a -= y * x;
    b -= y;
    c -= y * (x + 1);
    
    z = (b - 1) / x;
    
    if (c < a - z) {
        return 'A';
    } else if (c < a - z + b - z * x) {
        return 'B';
    } else {
        c -= a - z + b - z * x;
        if (c % (x + 1) == 0) {
            return 'A';
        } else {
            return 'B';
        }
    }
}

int main() {
    int q, i, j;
    
    scanf("%d", &q);
    
    for (i = 0; i < q; i++) {
        int a, b, c, d;
        
        scanf("%d %d %d %d", &a, &b, &c, &d);
        
        for (j = c; j <= d; j++) putchar(get(a, b, j - 1));
        puts("");
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

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

  int r = 0;
  int len = n + 1;
  ll sum = 0;
  for (int l = 0; l < n; l++) {
    while (r < n && sum < s) {
      sum += a.at(r);
      r++;
    }
    if (sum < s) break;
    len = min(len, r - l);
    if (r == l) r++;
    else sum -= a.at(l);
  }
  if (len < n + 1) cout << len << endl;
  else cout << 0 << endl;
}



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

using namespace std;

/**
 *  Name: Chris M. Perez
 *  University: Interamerican University Metro Campus
 *
**/

#define endl '\n'
#define MOD 10E9
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define gcd(x , y) __gcd(x , y)
#define all(x) (x).begin() , (x).end()
#define forn(i , a , b) for(int i=(a);i<(b);i++)
#define forrange(j , a , b) for(int j=(a);j<=(b);j++)
#define nestedforn(i , a , b , j , c , d) for(int i=(a);i<=(b);i++) for(int j=(c);j<=(d);j++)
#define sort_all(x) sort(all(x))
#define zeros_at_beginning(x) __builtin_clz(x)
#define zeros_at_end(x) __builtin_ctz(x)
#define ones(x) __builtin_popcount(x)
#define parity_even_or_odd_ones __builtin_parity(x)
#define PI 3.141592653589793


                                                          
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;  

#ifdef LOCAL_DEFINE
  freopen("input.txt" , "rt" , stdin);
#endif
   
  int p; cin >> p;
  int q; cin >> q;
  int r; cin >> r;
  int x = p + q + r;
  int y = max(p , max(q , r));
  cout << x - y << endl;
     
#ifdef LOCAL_DEFINE 
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int R = sc.nextInt();
      if(R<1200){
        System.out.println("ABC");
      }else if(R<2800){
        System.out.println("ARC");
      }else{
        System.out.println("AGC");
      }
    }
}

Measured memory_bytes: 35640
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout(n) cout << fixed << setprecision(n)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acosl(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int n;
int A[30];
int q;
bool s[20*2000+10];


signed main(){
    cin >> n;
    rep(i, 0, n) cin >> A[i];
    rep(i, 0, 1<<n){
        int x = 0;
        rep(j, 0, n) if((i>>j)&1) x += A[j];
        s[x] = true;
    }
    cin >> q;
    while(q--){
        int m;
        cin >> m;
        if(s[m]) cout << "yes" << endl;
        else cout << "no" << endl;
    }

    return 0;
}


Measured memory_bytes: 3100
#ifdef __GNUG__
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG // ArrayOutofBounds
#else
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#endif
#define rep(i, N) for (int i = 0; i < N; i++) //制御変数iを用いてN回転
using namespace std;
using ll = long long;
//0:上 1:左 2:下 3:右
const int di[] = { -1, 0, 1, 0};
const int dj[] = { 0, -1, 0, 1};

int main() {
    ll a, b, c, d, max = 0;
    cin >> a >> b >> c >> d;
    max = a * c;
    if (max < a * d) max = a * d;
    if (max < b * c) max = b * c;
    if (max < b * d) max = b * d;
    cout << max << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const int MX = 505;

template<typename T> void read(T &x)
{
	x = 0;
	char c = getchar();
	bool f = 0;
	while(!isdigit(c) && c!='-') c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
	if(f) x = -x;
}

struct NODE
{
	int l, r, typ;

	NODE (const int &l0 = 0, const int &r0 = 0) : l(l0), r(r0) {typ = (l0>=1);}

	int key() const {return typ ? l*1000+r : r*1000;}

	bool operator < (const NODE &t) const {return key() < t.key();}
};

int n;
ll mod;
NODE seq[MX];
ll f[MX][MX];
int t1[MX], t2[MX];

ll calc(int k)
{
	memset(f, 0, sizeof(f));
	f[0][0] = 1;
	for(int i=1; i<=n*2; i++)
	{
		for(int j=0; j<=t2[i]&&j<=k; j++)
		{
			if(seq[i].l)
			{
				f[i][j] = f[i-1][j] * (seq[i].r - (t1[2*n] + t2[i-1] + (k-j))) % mod;
				if(j) f[i][j] = (f[i][j] + f[i-1][j-1] * (seq[i].l - (t1[i-1] + (j-1)))) % mod;
			}
			else
			{
				f[i][j] = f[i-1][j] * (seq[i].r - (t1[i-1] + j)) % mod;
			}
		}
	}
	return f[n*2][k];
}

int main()
{
	read(n), read(mod);
	int l = n*2-1, r = n*2-1;
	for(int i=0; i<n*2; i++)
	{
		while(l>=0 && l*l+i*i>=n*n) l--;
		while(r>=0 && r*r+i*i>4*n*n) r--;
		seq[i+1] = NODE(l+1, r+1);
	}
	sort(seq+1, seq+n*2+1);
	for(int i=1; i<=n*2; i++)
	{
		if(seq[i].l) t2[i]++;
		else t1[i]++;
		t1[i] += t1[i-1];
		t2[i] += t2[i-1];
	}
	ll ans = 0;
	for(int i=0; i<=n; i++)
	{
		if(i&1) ans -= calc(i);
		else ans += calc(i);
	}
	printf("%lld\n", (ans%mod+mod) % mod);
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}
typedef pair<int, int> pii;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
const int N = 1005;
int n, m;
vector<string>ar;
queue<pii>q;
int cost[N + 2][N + 2];
bool valid(int x, int y){
  if (x >= 0 && x < n && y >= 0 && y < m){
    if (cost[x][y] == -1){
      return true;
    }
  }
  return false;
}
void F(){
  while (!q.empty()){
    int ux = q.front().first;
    int uy = q.front().second;
    q.pop();
    for (int i = 0; i < 4; i++){
      int vx = ux + dx[i];
      int vy = uy + dy[i];
      if (valid(vx, vy)){
        cost[vx][vy] = cost[ux][uy] + 1;
        q.push({vx, vy});
      }
    }
  }
}
int main(){
  FASTER;
  memset(cost, -1, sizeof cost);
  cin >> n >> m;
  ar.resize(n);
  for (int i = 0; i < n; i++){
    cin >> ar[i];
  }
  for (int i = 0; i < n; i++){
    for (int j = 0; j < m; j++){
      if (ar[i][j] == '#'){
        q.push({i, j});
        cost[i][j] = 0;
      }
    }
  }
  F();
  int mx = 0;
  for (int i = 0; i < n; i++){
    for (int j = 0; j < m; j++){
      //cout << cost[i][j] << ' ';
      mx = max(mx, cost[i][j]);      
    }
    //cout << '\n';
  }
  //cout << '\n';
  cout << mx << '\n';
  return 0;
}

Measured memory_bytes: 13456
s = input()
for i in range(8):
    op = list("-".join(list(s)))
    for j in range(3):
        if i & (1 << j):
            op[j + j + 1] = '+'
    op = "".join(op)
    if eval(op) == 7:
        print(op + "=7")
        break


Measured memory_bytes: 2940
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]


for i in range(N):
    if xyh[i][2] > 0:
        xx, yy, hh = xyh[i][0], xyh[i][1], xyh[i][2]
        break

for cx in range(101):
    for cy in range(101):
        H = hh + abs(cx-xx) + abs(cy-yy)
        count = 0
        for i in range(N):
            x = xyh[i][0]
            y = xyh[i][1]
            h = xyh[i][2]
            if max(H - abs(x - cx) - abs(y - cy), 0) == h:
                count += 1
        if count == N:
            print(cx, cy, H)
            exit()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
template<class T> inline istream& operator >> (istream & c, vector<T> & A) {rep(i, A.size()) c >> A[i];return c;}
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<int> cnt(n);
	rep(i, n) {
		int a;
		cin >> a;
		a--;
		cnt[a]++;
	}
	sort(all(cnt));
	int now = 0;
	rep(i, n) if (cnt[i] != 0) now++;
	if (now <= k) {
		cout << 0 << endl;
		return 0;
	}
	int ans = 0;
	rep(i, n) {
		if (!cnt[i]) continue;
		now--;
		ans += cnt[i];
		if (now <= k) break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main()
{
    Hello
    int n, happ = 0;
    cin >> n;
    while(true){
        if(n - 500 >= 0){
            n -= 500;
            happ += 1000;
        }
        else break;
    }
    while(true){
        if(n - 5 >= 0){
            n -= 5;
            happ += 5;
        }
        else break;
    }
    cout << happ;
    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr double EPS = 1e-9;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
// gcdも呼ぶ！！！
ll ngcd(vector<ll> a){
    ll d;
    d = a[0];
    for(int i = 1; i < a.size() && d != 1; i++) d = gcd(a[i], d);
    return d;
}

int main() {

    int n,k;
    cin>>n>>k;
    vll v(n);
    rep(i,n)cin>>v[i];
    int gcd =ngcd(v);
    bool ch=0;
    rep(i,n){
        if(v[i] < k)continue;
        else if(v[i] == k)ch=1;
        if(v[i]%gcd == k%gcd)ch=1;
    }
    if(ch)fin("POSSIBLE");
    else fin("IMPOSSIBLE");
}



Measured memory_bytes: 1792
N,M = map(int,input().split())
KL = [list(map(int,input().split())) for _ in [0]*N]

E = [[] for _ in [0]*(N+M)]
for i,kl in enumerate(KL):
    for l in kl[1:]:
        E[i].append(N+l-1)
        E[N+l-1].append(i)

def dist_bfs(N,E,start):
    d = [-1]*N
    d[start] = 0
    q = [start]
    while q:
        i = q.pop()
        di = d[i]
        for j in E[i]:
            if d[j]!=-1:continue
            d[j] = di+1
            q.append(j)
    return d

d = dist_bfs(N+M,E,0)
ans = d[:N].count(-1)==0
print("YES" if ans else "NO")

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pii> vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<pair<ll,ll> > > vvpll;
typedef vector<bool> vb;
typedef map<int,int> mii;
typedef map<char,int> mci;
typedef map<ll,ll> mll;

#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) x.begin() , x.end()
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define F first
#define S second
#define left (node << 1)
#define right (node << 1) + 1
// #define mod 998244353
#define mod 1000000007 

#define trace1(x)                       cerr<<#x<<": "<<x<<endl
#define trace2(x, y)                    cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)                 cerr<<#x<<": " <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(x, y, z , t)             cerr<<#x<<": " <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#t<<": "<<t<<endl
#define trace5(x, y, z , t , u)         cerr<<#x<<": " <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#t<<": "<<t<<" | "<<#u<<": "<<u<<endl
#define trace6(x, y, z , t , u , v)     cerr<<#x<<": " <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#t<<": "<<t<<" | "<<#u<<": "<<u<<" | "<<#v<<": "<<v<<endl

#define repa(i,sta,end,inc) for(int i = sta ; i <= end ; i += inc)
#define repb(i,sta,end,inc) for(int i = sta ; i >= end ; i -= inc)

ll power(ll x , ll y , ll z){ll res = 1;x %= z;while(y){if(y&1){res = res * x % z;}x = x*x % z;y /= 2;}return res%z;}
ll gcd(ll a , ll b){return (b == 0 ? a : gcd(b , a % b));}

void solve(){
    int n;
    cin >> n;
    int a[n];
    repa(i , 0 , n-1 , 1)cin >> a[i];
    int res = (1<<30);
    repa(i , 1 , 100 , 1){
        int sum = 0;
        repa(j , 0 , n-1 , 1){
            sum += (a[j] - i) * (a[j] - i);
        }
        res = min(res , sum);
    }
    cout << res << endl;
}


int main(){
    FIO;
    int tc = 1;
    // cin >> tc;
    repa ( i , 1 , tc , 1){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <set>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
    ll N;
	cin >> N;
	vector<int> ans;
	if(N==0) cout << 0 << endl;
	else{
		while(N!=0){
			ll tmp=N%(-2);
			N/=(-2);
			if(tmp<0){
				tmp+=2;
				N++;
			}
			ans.push_back(tmp);
		}
		ll size=ans.size();
		for(int i=0; i<size; i++){
			cout << ans[size-i-1];
		}
		cout << endl;
	}
	

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
    //freopen("input.txt", "r", stdin);
    int a, b;
    scanf("%d %d", &a ,&b);
    if (a <= 0 && b >= 0)
    {
        printf("Zero");
        return 0;
    }
    if (a > 0)
    {
        printf("Positive");
        return 0;
    }
    int len = b - a + 1;
    if (len % 2 == 0)
    {
        printf("Positive");
    }
    else
    {
        printf("Negative");
    }
}


Measured memory_bytes: 764
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static void ABC085D();

#if 1
int main()
{
	ABC085D();
	fflush(stdout);
	return 0;
}
#endif

class ABC085Ddata {
public:
	LLONG damage = 0;
	LLONG id = 0;

	static bool sort_dmg(const ABC085Ddata& a, const ABC085Ddata& b) {
		return a.damage > b.damage;
	}
};
static void ABC085D()
{
	LLONG N, H;
	getint(N, H);

	std::vector<ABC085Ddata> an((int)N), bn((int)N);
	for (int i = 0; i < N; i++) {
		getint(an[i].damage, bn[i].damage);
		an[i].id = bn[i].id = i;
	}

	std::sort(an.begin(), an.end(), ABC085Ddata::sort_dmg);
	std::sort(bn.begin(), bn.end(), ABC085Ddata::sort_dmg);
	
	int throwCount = 0;
	for (int i = 0; i < N; i++) {
		if (an[0].damage < bn[i].damage) {
			throwCount++;
		}
		else {
			break;
		}
	}

	std::vector<LLONG> thDmgs(throwCount + 1, 0);
	for (int t = 1; t <= throwCount; t++) {
		thDmgs[t] = thDmgs[t - 1] + bn[t - 1].damage;
	}
	
	LLONG rest = H;
	LLONG attackCount = 0;
	for (int i = 1; i <= throwCount; i++) {
		attackCount = i; 
		if (thDmgs[i] >= rest) {
			break;
		}
	}
	rest = std::max<LLONG>((LLONG)0, rest - thDmgs[attackCount]);

	attackCount += rest / an[0].damage;
	if (rest % an[0].damage) attackCount++;

	printf("%lld\n", attackCount);
}


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


int main()
{
    int n,k;
    cin>>n>>k;
    if(n<=k)
    {
        cout<<1<<endl;
    }
    else{
        if(n%k==0)
        {
            cout<<n/k<<endl;
        }
        else
        {
            cout<<(n/k+1)<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// const INF: u128 = 1000000000;

fn main() {
    // 尺取法
    input! {
        n: u128,
        m: u128,
        k: u128,
        a: [u128;n],
        b: [u128;m],
    }
    let mut ans = 0;
    let mut time = 0;

    for b_item in b.iter() {
        time += b_item;
    }

    let mut j = m;

    for i in 0..(n + 1) {
        while j > 0 && time > k {
            j -= 1;
            time -= b[j as usize];
        }

        if time > k {
            break;
        }

        ans = std::cmp::max(ans, i + j);

        if i == n {
            break;
        }

        time += a[i as usize];
    }

    println!("{}", ans);
}


Measured memory_bytes: 12484
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
#include <stack>

using namespace std;
double T_area(double x1,double y1, double x2, double y2, double x3, double y3);

int main(){
    stack<int> st;    // int型のスタック
    int n;
    while(scanf("%d",&n)!=EOF){
        if(n!=0){
            st.push(n);
        }else{
            cout << st.top() << "\n";
            st.pop();
        }
    }
    
    
}

Measured memory_bytes: 1208
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	ll a = in(), b = in();
	if (b % a == 0) {
		cout << a + b << endl;
	} else {
		cout << b - a << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
signed main(){
  int a;
  cin>>a;
  vector<P> b(a);
  
  rep(i,a){
    int c;
    cin>>c;
    b.at(i)=make_pair(c,i);
  }
  sort(all(b));
  rep(i,a)
    cout<<b.at(i).second+1<<' ';
  }

Measured memory_bytes: 2432
//coins
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    double ptr[n];
    for(int i=0;i<n;i++) cin>>ptr[i];
    double dp[n+1];
    memset(dp,0,sizeof(dp));
    dp[0]=1;
    //dp[i][j] represents the probaility of i heads , when j coins are tossed
    for(int coin =0; coin<n; ++coin){
        for(int i=coin+1;i>-1;--i){
            dp[i] = (i==0 ? 
                    0: dp[i-1] * ptr[coin]) + dp[i] *(1-ptr[coin]);
        }
    }

    double sum=0;
    //for(int i=0;i<n;i++) cout<<dp[i]<<" "; cout<<endl;
    for(int i=n-(n)/2;i<=n;i++) sum+=dp[i];
    //printf("%10lf\n", sum);
    cout<< setprecision(11);
    cout<<sum<<endl;
    return 0;

}

/*
5
0.42 0.01 0.42 0.99 0.42
*/

Measured memory_bytes: 3804
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        Vector<Integer> primes = getPrimes();
        
        while (true) {
            int N = sc.nextInt();
            if (N == 0) break;
            
            int count = 0;
            
            for (int i = 0; i < primes.size(); i++) {
                int p = primes.get(i);
                if (p > N / 2) break;
                if (primes.contains(N - p)) {
                    count++;
                }
            }
            
            System.out.println(count);
        }
    }
    
    public static Vector<Integer> getPrimes() {
        Vector<Integer> primes = new Vector<Integer>();
        boolean[] isPrime = new boolean[32769];
        Arrays.fill(isPrime, true);
        for (long i = 2; i < 32769; i++) {
            if (!isPrime[(int)i]) continue;
            for (long j = i * i; j < 32769; j += i) {
                isPrime[(int)j] = false;
            }
        }
        for (int i = 2; i < 32769; i++) {
            if (isPrime[i]) {
                primes.add(i);
            }
        }
        return primes;
    }
}




Measured memory_bytes: 27512
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: u64,
        k: u64,
    }

    let mut ans = 0.0;
    for i in 1..n + 1 {
        if i >= k {
            ans += 1.0 / n as f64;
            continue;
        }

        let streak = (k as f64 / i as f64).log2().ceil();
        ans += (1.0 / n as f64) * 0.5_f64.powf(streak);
        // println!("{} {}, {}", i, streak, 0.5_f64.powf(streak));
    }
    println!("{}", ans);
}


Measured memory_bytes: 2896
#!usr/bin/env python3
from collections import defaultdict
import math
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
def IIR(n): return [II() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
mod = 1000000007

#A
"""
n,a,b = LI()
ans = [min(a,b),max(0,a+b-n)]
print(ans[0],ans[1])
"""

#B
"""
n = II()
a = S()
b = S()
c = S()
ans = 0
for i in range(n):
    if a[i] == b[i]:
        if b[i] == c[i]:
            continue
        else:
            ans += 1
    else:
        if b[i] == c[i] or c[i] == a[i]:
            ans += 1
        else:
            ans += 2
print(ans)
"""

#C
"""
n = II()
c = LIR(n)
c.sort(key = lambda x:-x[0]-x[1])
ans = 0
i = 0
for i in range(n):
    x,y = c.pop(0)
    if i%2 == 0:
        ans += x
    else:
        ans -= y
print(ans)
"""

#D
import queue
n,m = LI()
c = LIR(n-1+m)
for i in range(n-1+m):
    c[i][0] -= 1
    c[i][1] -= 1
v = [[] for i in range(n)]
ins = [0 for i in range(n)]
for a,b in c:
    v[a].append(b)
    ins[b] += 1
ans = [-1 for i in range(n)]
q = queue.Queue()
for i in range(n):
    if ins[i] == 0:
        q.put(i)
while not q.empty():
    i = q.get()
    for j in v[i]:
        ans[j] = i
        ins[j] -= 1
        if ins[j] == 0:
            q.put(j)
for i in ans:
    print(i+1)
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 86868
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <limits>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;++a) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define print_double(val,a) cout << fixed << setprecision(a) << val << endl;
ll mod = 1e9 + 7;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
int a=0;
cin>>a;
string str=to_string(a);
int ans=0;
for(int i=0;i<str.length();i++){
	ans+=stoi(str.substr(i,1));
}
if(a%ans==0){cout<<"Yes"<<endl;}
else{cout<<"No"<<endl;}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fi first
#define se second
#define MOD 1000000007
vector <int> adj[200001];
bool visited[200001];
int cnt;
void dfs (int cur){
	visited[cur]=true, cnt++;
	for (int i=0; i<adj[cur].size(); i++){
		if (!visited[adj[cur][i]]) dfs(adj[cur][i]);
	}
}
int main(){
	int a, b, x, y, maxi=-1;
	cin>>a>>b;
	while (b--){
		cin>>x>>y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	for (int i=1; i<=a; i++){
		if (!visited[i]){
			dfs(i);
			maxi=max(maxi, cnt);
			cnt=0;
		}
	}
	cout<<maxi<<endl;
}

Measured memory_bytes: 20952
a = list(map(int, input().split()))
b = [a[i] - a[i+1] for i in range(2)]

for i in range(2):
    c = list(map(int, input().split()))
    d = [c[i] - c[i+1] for i in range(2)]
    if b != d:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 3064
from collections import defaultdict as dd

s = input().strip()
coll = dd(int)

for el in s:
    coll[el] += 1


condition = (
    min(coll["N"], coll["S"]) == 0 and
    max(coll["N"], coll["S"]) != 0 or
    min(coll["E"], coll["W"]) == 0 and
    max(coll["E"], coll["W"]) != 0)

if condition:
    print("No")
else:
    print("Yes")



Measured memory_bytes: 3316