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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    map<int, int> cnt;
    vector<int> num;
    for(int i=0; i<N; ++i) {
        cin >> A[i];
        cnt[A[i]] += 1;
        if(cnt[A[i]] == 1) num.push_back(A[i]);
    }

    if(N % 3) {
        if(cnt[0] == N) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else {
        if(num.size() > 3) cout << "No" << endl;
        else if(num.size() == 3) {
            if(cnt[num[0]] == N/3 && cnt[num[1]] == N/3 && cnt[num[2]] == N/3 && (num[0]^num[1]) == num[2]) cout << "Yes" << endl;
            else cout << "No" << endl;
        } else if(num.size() == 2) {
            if(num[0] == 0 && cnt[num[1]] == 2 * cnt[num[0]]) cout << "Yes" << endl;
            else if(num[1] == 0 && cnt[num[0]] == 2 * cnt[num[1]]) cout << "Yes" << endl;
            else cout << "No" << endl;
        } else {
            if(num[0] == 0) cout << "Yes" << endl;
            else cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 4472
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i,n) cin >> v[i];
    ll  ans = 0;
    rep(i,n){
        while(v[i]%2==0){
            ans++;
            v[i]/=2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
import itertools as ite
import math

INF = 10 ** 18

while True:
    M, W = map(int, raw_input().split())
    if M == 0:
        break
    bm = map(int, raw_input().split())
    bw = map(int, raw_input().split())
    if M < W:
        M, W = W, M
        bm, bw = bw, bm
    DP = [0] * (1 << M)
    for i in range(1 << M):
        cnt = 0
        for j in range(M):
            if i & (1 << j):
                cnt += 1
        if cnt > W:
            continue
        for j in range(M):
            if i & (1 << j):
                num = abs(bw[cnt - 1] - bm[j]) * (abs(bw[cnt - 1] - bm[j]) - 30) ** 2
                DP[i] = max(DP[i], DP[i - (1 << j)] + num)
    print max(DP)



Measured memory_bytes: 4968
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int n, d;
	cin >> n >> d;
	int ans = 0;
	for(int i = 0; i < n; i++){
		int x,y;
		cin >> x >> y;
		if(x * x + y * y <= d * d) ans++;
	}
	cout << ans;
}

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

/* common subsequence path recording */

const int maxn = 3005;
int dp[maxn][maxn]; int nxt[maxn][maxn][2]; string val[maxn][maxn], s,t;

int dfs(const int i, const int j)
{
    if (i >= s.size() || j >= t.size())
        return 0;
    int& ans = dp[i][j];
    if (-1 == ans) {
        ans = 0;
        if (s[i] == t[j]) {
            const int res = dfs(i+1,j+1)+1;
            if (res > ans) {
                ans = res;
                nxt[i][j][0] = i+1; nxt[i][j][1] = j+1; val[i][j] = s[i];
            }
        }
        else {
            const int re1 = dfs(i+1,j);
            if (re1 > ans) {
                ans = re1; nxt[i][j][0] = i+1; nxt[i][j][1] = j;
            }
            const int re2 = dfs(i,j+1);
            if (re2 > ans) {
                ans = re2; nxt[i][j][0] = i; nxt[i][j][1] = j+1;
            }
        }
    }
    return ans;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    while (cin >> s >> t) {
        memset(dp,-1,sizeof(dp));
        FOR(i,0,s.size()+1) FOR(j,0,t.size()+1)
            nxt[i][j][0] = -1, nxt[i][j][1] = -1, val[i][j] = "";
        int i = 0, j = 0; string ans;
        dfs(i,j);
        while (i >= 0 && j >= 0) {
            /* printf("%d %d\n",i,j); */
            ans += val[i][j];
            const int *x = &nxt[i][j][0];
            i = x[0]; j = x[1];
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 392044
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<pair<int,int>> a, b;
	rep(i, n)
	{
		string s; cin >> s;
		int l = 0, r = 0, cnt = 0;
		rep(j, s.size())
		{
			if (s[j] == ')')++cnt;
			else --cnt;
			chmax(l, cnt);
		}
		cnt = 0;
		rrep(j, s.size())
		{
			if (s[j] == '(')++cnt;
			else --cnt;
			chmax(r, cnt);
		}
		if (r >= l)a.push_back(make_pair(l, r));
		else b.push_back(make_pair(r, l));
	}
	sort(all(a));
	sort(all(b), greater<pair<int, int>>());
	bool ok = true;
	int now = 0;
	for (auto p : a)
	{
		now += p.first;
		if (now > 0)ok = false;
		now -= p.second;
	}
	for (auto p : b)
	{
		now += p.second;
		if (now > 0)ok = false;
		now -= p.first;
	}
	if (now != 0)ok = false;
	if (ok)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 11336
#include<bits/stdc++.h>
using namespace std;
long long func(string &a,string &b)
{
    long long t=0,i,n=a.size();
    for(i=0;i<n;i++)
        if(a[i]!=b[i])
            t++;
    return t;
}
int main()
{
    long long n,i,j,k=1e9;
    string s,t;
    cin>>s>>t;
    n=s.size();j=t.size();
    for(i=0;i<=n-j;i++)
    {
        string S=s.substr(i,j);
        k=min(k,func(S,t));
    }
    cout<<k<<'\n';
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  int a;
  if(N % 2 == 0) {
    a = N / 2;
  }
  else {
    a = N /2 + 1;
  }
  cout << a << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
 
using namespace std;
typedef pair<int, int> pii;
pii dxdy[]={{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
char fld[20][20];
int d[20][20];
const int inf=1e8;
 
int main(){
 
   while(1){
      int W, H;
      cin>> W>> H;
      if(!(H||W)) break;
      int sx, sy;
      for(int i=0; i<H; i++){
         for(int j=0; j<W; j++){
            cin>> fld[i][j];
            if(fld[i][j]=='@'){
               sy=i;
               sx=j;
            }
         }
      }
 
      for(int i=0; i<H; i++)for(int j=0; j<W; j++)d[i][j]=inf;
      queue<pii> Q;
      Q.push(pii(sy, sx));
      d[sy][sx]=0;
      while(!Q.empty()){
         pii now=Q.front(); Q.pop();
         for(pii dd: dxdy){
            int ni=now.first+dd.first;
            int nj=now.second+dd.second;
            if(!(0<=ni&&ni<H&&0<=nj&&nj<W)) continue;
            if(fld[ni][nj]=='#') continue;
            if(d[ni][nj]<=d[now.first][now.second]+1) continue;
            d[ni][nj]=d[now.first][now.second]+1;
            Q.push(pii(ni, nj));
         }
      }
 
      int ans=0;
      for(int i=0; i<H; i++)for(int j=0; j<W; j++){
         ans+=(d[i][j]!=inf);
      }
 
      cout<< ans<< endl;
   }
 
   return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a+b==c || b+c==a || c+a==b) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>	
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
#define INF 2000000000000000
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define mk make_pair
#define en endl
#define RE return 0
#define int ll
#define P pair<int,int>
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int gcd(int a,int b){if(a%b==0){return b;}else return gcd(b,a%b);}
int lcm(int a,int b){if(a==0){return b;} return a/gcd(a,b)*b;}

int a[300005];
vector<int> ve;
int how_much[300005];  // n個ある時の総和

signed main(){
	int n; cin>>n;
	priority_queue<int> smaller; // おおきい順　総量を小さくしたい
	priority_queue<int,vector<int>, greater<int> > bigger; // 小さい順　大きくしたい
	int sum=0,sum1=0;
	for(int i=1; i<=3*n; i++){
		cin>>a[i];
		if(i<=n){
			bigger.push(a[i]);
			sum1+=a[i];
		}else if(2*n+1<=i){ 
			smaller.push(a[i]);
			sum+=a[i];
		}
	}
	how_much[2*n+1]=sum;
	for(int i=2*n; i>=n+1; i--){
		smaller.push(a[i]);
		int big=smaller.top(); smaller.pop();
		sum-=big-a[i];
		how_much[i]=sum;
	}
	
	int ans=sum1-how_much[n+1];
	for(int i=n+1; i<=2*n; i++){
		bigger.push(a[i]);
		int small=bigger.top(); bigger.pop();
		sum1+=a[i]-small;
		ans=max(ans, sum1-how_much[i+1]);
	}
	cout<<ans<<en;
}




Measured memory_bytes: 5364
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
using ll = long long;
const int INF=1001001001;
const double PI=3.14159265358979323846; 
 
int main(){
  double a;
  cin >> a;
  a = 2.0*a*PI;
  cout << fixed << setprecision(10);
  cout << a << endl;
  
  return 0;
}


Measured memory_bytes: 3776
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		
		int a = Integer.parseInt(scan.next());
		int b = Integer.parseInt(scan.next());
		int sum = a+b;
		if(a+b >= 24)sum -= 24;
		
		System.out.println(sum);
		

	}

}

Measured memory_bytes: 21972
N = int(input())
A = list(map(int, input().split()))
m = 1
z = 0
for i in range(N):
  if A[i] < 0:
    m *= -1
    A[i] = (-1) * A[i]
  if A[i] == 0:
    z = 1
print(sum(A) + (m - 1) * min(A))

Measured memory_bytes: 14252
#include <iostream>

using namespace std;

int main() {
	int a, b, v, h, tmp;
	char x;
	cin>>v;
	cin>>h;

	int num[v];
	//initialize array
	for(int i=0; i<v; i++){ num[i] = i+1; }
	
	for(int i=0; i<h; i++){
		cin>>a>>x>>b;
		swap(num[a-1], num[b-1]);
	}
	for(int i=0; i<v; i++) cout<<num[i]<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node *Node;

#define NIL NULL

Node root;
int num=0;

void insert(Node);
void inorder(Node);
void preorder(Node);

int main(){
  char command[20];
  int i,n,v,j;
  Node z;
  
  //root->key = -1;
  
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%s",command);
    if(strcmp(command,"insert") == 0){
      scanf("%d",&v);
      z = malloc(sizeof(struct node));
      z->key = v;
      z->left = NIL;
      z->right = NIL;
      insert(z);
    }
    else if(strcmp(command,"print") == 0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    
  
  }

  
  return 0;
}

void insert(Node z){
  Node y = NIL;
  Node x = root;
  num++;
  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 root){
  if(root != NIL){
    inorder(root->left);
    printf(" %d",root->key);
    inorder(root->right);
  }

}

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



Measured memory_bytes: 25136
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  string s;
  ll cnt=0;
  cin >> s;
  ll n = s.size();
  char prev='0';
  for(int i=0;i<n;){
    cnt++;
    if(s[i]!=prev){
      prev = s[i];
      i++;
    }else{
      if(i==n-1){
        cnt--;
      }
      i+=2;
      prev = '0';
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;
#define SIZE 13
int N,M,X;
int POW[SIZE],a[SIZE];
int b[SIZE][SIZE],c[SIZE];
int main(){
	POW[0] = 1;
	for(int i = 1; i < SIZE; i++){
		POW[i] = POW[i-1]*2;
	}
	scanf("%d %d %d",&N,&M,&X);
	for(int i = 0; i < N; i++){
		scanf("%d",&a[i]);
		for(int j = 0; j < M; j++){
			scanf("%d",&b[i][j]);
		}
	}	
	int ans = BIG_NUM;
	bool FLG;
	for(int i = 0; i < POW[N]; i++){
		memset(c,0,sizeof(c)); 
		int sum = 0;
		for(int j = 0; j < N; j++){
			if(i & POW[j]){
				sum += a[j];
				for(int k = 0; k < M; k++){
					c[k] += b[j][k];
				}
			}
		} 
		FLG = true;
		for(int j = 0; j < M; j++){
			if(c[j] < X){
				FLG = false;
				break;
			}
		}
		if(FLG) ans = min(ans,sum);
	}
	if(ans == BIG_NUM) printf("-1\n");
	else printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3788
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long int;
 
#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define MOD 1000000007 //10^9+7
//#define MOD 1
 
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
const int MAX = 1000;
 
ll table[MAX][MAX];
 
// テーブルを作る前処理
void COMinit() {
    table[0][0] = table[0][1] = 1;
    FOR(i, 1, MAX-1){
      FOR(j, 0, i+1){
        if(j==0) table[i][j] = 1;
        else if(j == i+1) table[i][j] = 1;
        else table[i][j] = table[i-1][j-1]+table[i-1][j];
      }
    }
}
 
// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return table[n-1][k];
}

void sosuu(ll n, vector<ll> &v){

  vector<ll> num(n, 0);

  FOR(i, 1, sqrt(n)){
    if(num[i]==0){
      FOR(j, 0, n/i){
        num[i+(j*i)] = 1;
      }
    }
  }
  REP(i, n){
    if(num[i]==0) v.push_back(i+1);
  }
}


int main(void){
 
   ll a,b,c;
   cin>>a>>b>>c;

    vector<ll> v(3);
    v[0] = a;
    v[1] = b;
    v[2] = c;
    sort(v.begin(), v.end());

    ll ans = min((v[2]-v[1]), (v[2]-v[0]));
    if((v[2] - v[0]-ans)%2==0) ans +=(v[2]-v[0]-ans)/2;
    else ans += (v[2]-v[0]-ans)/2 + 2;
    cout<<ans<<endl;

    
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;

int main(){
	int x = 0,y = 0,z = 0;
	int ans = 0;
	scanf("%d %d %d",&x,&y,&z);
	ans = x/(z + y);
	if(x - ans*(y + z) >= 0&&x - ans*(y + z) < z){ 
		ans = ans - 1;
		printf("%d\n",ans);
	}
	else printf("%d\n",ans);
	return 0;
	}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;

int main()
{
    fast;

   ll a,b;
   cin>>a>>b;
   cout<<6-(a+b)<<endl;


   }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << -1 << "\n"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if (0) cerr

const int N = 2e5 + 7, MOD = 1e9 + 7;

pi pt[N];
int deg[N] = { 1 };
map <pi, int> line;

int gcd(int a, int b) {
    a = abs(a); b = abs(b);
    while (b > 0) {
        a %= b;
        swap(a, b);
    }
    return a;
}

void solve() {
    loop1(i, N - 1)
        deg[i] = (deg[i - 1] << 1) % MOD;
    int n, cntz = 0, cntv = 0, cnth = 0; cin >> n;
    loop(i, n) {
        cin >> pt[i].F >> pt[i].S;
        if (pt[i].F == 0 || pt[i].S == 0) {
            if (pt[i].F == 0 && pt[i].S == 0)
                ++cntz;
            else if (pt[i].F == 0)
                ++cntv;
            else
                ++cnth;
        }
        else {
            if (pt[i].F < 0) {
                pt[i].F *= -1;
                pt[i].S *= -1;
            }
            int g = gcd(pt[i].F, pt[i].S);
            pt[i].F /= g; pt[i].S /= g;
            ++line[pt[i]];
        }
    }
    int ans = (deg[cntv] + deg[cnth] - 1) % MOD;
    for (auto it : line) {
        pi p = it.F, rp = { -p.S, p.F };
        if (rp.F < 0) {
            rp.F *= -1; rp.S *= -1;
        }
        if (line.find(rp) == line.end())
            ans = ans * deg[it.S] % MOD;
        else if (p.S > 0)
            ans = ans * (deg[it.S] + deg[line[rp]] - 1) % MOD;
    }
    cout << (ans + cntz - 1 + MOD) % MOD;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}


Measured memory_bytes: 20776
#include<stdio.h>
int main(){
  int n,i,x=0,y=0;
  char s[101];
  scanf("%d%s",&n,s);
  for(i=0;i<n;i++){y+=1-(s[i]==')')*2;x=x<y?x:y;}
  for(i=0;i<-x;i++)printf("(");printf("%s",s);for(i=0;i<y-x;i++)printf(")");
}


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

using namespace std;

struct Vector {
  double x, y;
  Vector() {}
  Vector(double x, double y): x(x), y(y) {}
  Vector operator+(Vector v) { return Vector(x + v.x, y + v.y); }
  Vector operator-(Vector v) { return Vector(x - v.x, y - v.y); }
  Vector operator*(double k) { return Vector(x * k, y * k); }
  Vector operator/(double k) { return Vector(x / k, y / k); }
  bool operator==(Vector v)  { return abs(x - v.x) < 1e-10 && abs(y - v.y) < 1e-10; }
  friend void input(Vector &v) { cin >> v.x >> v.y; }
  friend double norm(Vector v) { return dot(v, v); }
  friend double  abs(Vector v) { return sqrt(norm(v)); }
  friend double   dot(Vector v1, Vector v2) { return v1.x * v2.x + v1.y * v2.y; }
  friend double cross(Vector v1, Vector v2) { return v1.x * v2.y - v1.y * v2.x; }
  friend void show(Vector v) { if (abs(v.x) < 1e-10) v.x = 0.0; if (abs(v.y) < 1e-10) v.y = 0.0; printf("%.10f %.10f\n", v.x, v.y); }
  friend bool ccw(Vector v, Vector v1, Vector v2) { return cross(v1 - v, v2 - v) > 1e-10; }
  friend bool  cw(Vector v, Vector v1, Vector v2) { return cross(v1 - v, v2 - v) < -1e-10; }
  friend bool parallel(Vector v1, Vector v2) { return abs(cross(v1, v2)) < 1e-10; }
  friend bool onLine(Vector v, Vector v1, Vector v2) { return v == v1 || v == v2 || (parallel(v1 - v, v2 - v) && dot(v1 - v, v2 - v) < -1e-10); }
  friend int direct(Vector v1, Vector v2, Vector v) { if (ccw(v1, v2, v)) return  1; if ( cw(v1, v2, v)) return -1; if (dot(v2 - v1, v - v1) < -1e-10) return  2; if (dot(v1 - v2, v - v2) < -1e-10) return -2; return 0; }
};
typedef Vector Point;

int main(void) {
  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    Point p[4];
    for (int j = 0; j < 4; j++) {
      input(p[j]);
    }
    cout << (parallel(p[0] - p[1], p[2] - p[3]) ? "YES" : "NO") << endl;
  }

  return 0;
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
char a[100001];
vector<int>l,r;
bool cmp(int a,int b){
    return a > b;
}
int main(){
    int n , m;
    cin >> n >> m;
    int ans1=0,ans2=0;
    for ( int i = 1 ; i <= n ; i++ ) {
        cin >> a[i];
        if ( a[i] == a[i-1]) {
            ans1++ ;
            ans2++ ;
        }
    }
   
    for ( int i = 1 ; i <= n; ) {
    	//cout << i << endl ;
        if( a[i] == 'L' ) {
            int cnt=0;
            if ( a[i-1] == 'R' ) {
                cnt++;
            }
            while ( (i <= n ) && ( a[i] == 'L' ) ) {
                i++;
            }
            if( ( i <= n ) && ( a[i] == 'R' ) ) {
                cnt++;
            }
            l.push_back(cnt);
        }
        if ( a[i] == 'R' ) {
            int cnt=0;
            if( a[i-1] =='L' ){
                cnt++;
            }
            while ( ( i <= n ) && ( a[i] == 'R') ) {
                i++;
            }
            if( (i <= n) && ( a[i] == 'L' ) ) {
                cnt++;
            }
            r.push_back(cnt);
        }
    }
    
    sort(r.begin() , r.end() , cmp );
    sort(l.begin() , l.end() , cmp );
    int temp=m;
    for ( int i = 0 ; i < l.size() ; i++ ) {
        //cout << l[i] << " " ;
        if( temp > 0){
            ans1 += l[i] ;
            temp-- ;
        }
    }
    //cout << endl ;
    temp=m;
    for( int i = 0 ; i < r.size() ; i++ ) {
        //cout << r[i] << " " ;
        if ( temp > 0 ) {
            ans2 += r[i] ;
            temp--;
        }
    }
    cout << max( ans1 , ans2 ) << endl ;

}


Measured memory_bytes: 892
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N, A, B;
  cin >> N >> A >> B;
  long train = N * A;
  cout << min(train, B) << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
#include <cctype>
#include <fstream>   // ifstream, ofstream
#include <sstream>   // istringstream
using namespace std;
using ll = long long;
const int mod = 1000000007;

ll gcd(ll a, ll b){return b ? gcd(b,a%b) : a;};//最大公約数
ll lcm(ll a, ll b){return a*b/gcd(a,b);};//最小公倍数
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
typedef pair<string,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
//ll a[100000];
//ll dom[100001];
int p[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(){
   ll a;
   cin>>a;
  cout<<p[a-1];
  return 0;
}

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

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////


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

	vector<ll> A(N + 1);
	repn(i, N) cin >> A[i];

	ll cnt = 0;
	repn(i, N) {
		if (A[i] % 2 != 0) { cnt++; }
	}

	if (cnt % 2 == 0) { cout << "YES"; }
	else { cout << "NO"; }

	system("PAUSE");

}





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

int main()
{
	int n,m;
	cin >> n >> m;
	if(m==1)
	{
		cout<<0<<endl;
		return 0;
	}
	vector<int> a(m);
	for(int i = 0;i<m;i++)cin >> a[i];
	sort(a.begin(),a.end());
	vector<int> div(m-1);
	for(int i = 0;i<m-1;i++)
	{
		div[i] = a[i+1]-a[i];
	}
	sort(div.begin(),div.end());
	ll ans = 0;
	for(int i = 0;i<max(0,(int)div.size()-(n-1));i++)
	{
		if(i<div.size())
		ans += div[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define re register
using namespace std;

inline int read(){
	re int ans = 0;re bool f = 1;re char ch = getchar();
	while(ch<'0'||ch>'9'){if (ch=='-')f = 0;ch = getchar();}
	while(ch>='0'&&ch<='9'){
		ans = (ans<<3)+(ans<<1)+(ch^48);
		ch = getchar();
	}
	return f?ans:~(ans-1);
}

signed main(void){
	
	int a,b,c;
	a = read();b=read();c = read();
	swap(a,b);
	swap(a,c);
	printf("%d %d %d\n", a,b,c);
	return 0;
}

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

int main() {
  int A,B,C,c5=0,c7=0;
  cin >> A >> B >> C;
  if(A==5){
       c5++;
  }
  if(A==7){
       c7++;
  }
  if(B==5){
       c5++;
  }
  if(B==7){
       c7++;
  }
  if(C==5){
       c5++;
  }
  if(C==7){
       c7++;
  }
  if(c5==2 && c7==1){
       cout << "YES";
  }
  else{
       cout << "NO";
  }
return 0;
}

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

using namespace std;

typedef long long  ll;

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

    vector<int> abc(3);
    for (int i = 0; i < 3; ++i)
        cin >> abc[i];
    sort(abc.begin(), abc.end());

    if (abc[0] == 5 && abc[1] == 5 && abc[2] == 7)
        cout << "YES\n";
    else
        cout << "NO\n";

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
for i in range(n):
	a[i] = a[i] - i - 1
a.sort()


c = n // 2
b = a[c]

sum = 0

for i in range(n):
	if i <= c:
		sum += b - a[i]
	else:
		sum += a[i] - b

print(sum)

Measured memory_bytes: 25200
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++) 
#define rrep(i,n) for(int i = 1; i <= (int)(n); i++) 
#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    ll a,b,n;
    cin >> a >> b >> n;
    ll x;
    if(n >= b-1) x = b-1;
    else x = n;
    ll ans = (a * x / b) - a * (x / b);
    cout << ans << endl;
}

Measured memory_bytes: 3576
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<long int, long int>

int main(){
    int n, k;
    cin >> n >> k;
    if(k > ((n-1) * (n-2)) / 2){
        cout << -1 << endl;
        return 0;
    }
    vector<P> e;
    for (int i = 1; i < n; i++){
        for (int j = i + 1; j <= n; j++){
            e.push_back(P(i, j));
        }
    }
    rep(i, k) e.pop_back();
    cout << e.size() << endl;
    rep(i, e.size()){
        cout << e[i].first << " " << e[i].second << endl;
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define modulo 1000000007
typedef long long int ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int main(){
	int a,b;
	cin >> a >> b;

	bool crit(true);
	int k;

	if(a<b){
		if((b-a)%2==0) k = a + (b-a)/2;
		else crit = false;
	}
	else{
		if((a-b)%2==0) k = b + (a-b)/2;
		else crit = false;
	}

	if(crit) cout << k << endl;
	else cout << "IMPOSSIBLE" << endl;
}

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

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;cin>>S;
  int ans=0;
  repeat(i,S.length()){
    ans += S[i]=='+'? 1:-1;
  }
  cout << ans << endl;
  return 0;
}


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

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n, k = rli()
    lh = rli()
    print(sum(1 for h in lh if h >= k))


if __name__ == '__main__':
    main()


Measured memory_bytes: 11904
import std.stdio, std.math;
void main() {
	real a, b, c;
	"%f %f %f".readf(&a, &b, &c);
	c = c * PI / 180.0L;
	"%.8f".writefln((a * b * sin(c)) / 2.0L);
	"%.8f".writefln(a + b + (a^^2 + b^^2 - 2.0L * a * b * cos(c)).sqrt);
	"%.8f".writefln(b * sin(c));
}

Measured memory_bytes: 2564
ans = ""
for i in range(10000):
    H,W = map(int,input().split())
    if H==0 and W == 0:
        break
    else:
        for j in range(H):
            for _ in range(W):
                ans += "#"
            print(ans)
            ans = ""
            if j == H-1:
              print("")


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

int main()
{
  int N, B=0, cnt=0;
  long long sum=0, sum2=0, sum3=0;
  cin >> N;
  vector<int> A(N);
  rep(i, N){
    cin >> A.at(i);
    sum=sum+A.at(i);
  }
  rep(i, N){
    sum2=sum2+A.at(i);
    if(sum%2==0 && sum/2==sum2){
      cnt==0;
      B=1;
      break;
    }
    else if(sum2>sum/2){
      sum2=sum2-A.at(i);
      for(int j=N-1; j>i; j--) sum3=sum3+A.at(j);
      cnt=min(sum2,sum3)+A.at(i)-max(sum2, sum3);
      B=1;
      break;
    }
    if(B==1) break;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define fastio  cin.sync_with_stdio(0); cin.tie(0);cin.exceptions(cin.failbit);
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a,v) memset(a, v, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1e9+7;
const int N=2e5+5;
int main() {
   
    fastio;
    int T=1;
    // cin>>T;
    while(T--){
        ll n;cin>>n;
        vector<ll> v(n+1,1);
        for(ll i=2;i<=n;i++){
            for(ll j=i;j<=n;j=j+i){
                v[j]++;
            }
        }
        ll ans=0;
        for(ll i=1;i<=n;i++){
            ans+=(i*v[i]);
        }
        cout<<ans;
    }   
    timecalculater();
    return 0;   
} 

Measured memory_bytes: 81364
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define append push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  vector<bool> prime(101,true);
  prime[1] = false;
  for(int i = 2; i*i <= 100; i++) {
    if (!prime[i]) continue;
    for(int j = i*2; j <= 100; j += i) {
      prime[j] = false;
    }
  }
  vector<int> div(100,0);
  int n;
  cin >> n;
  if (n <= 9) {
    cout << 0 << endl;
    return 0;
  }
  rep(i,2,n+1) {
    if (!prime[i]) continue;
    int p = i;
    while(n/p != 0) {
      div[i] += n/p;
      p *= i;
    }
  }
  int cnt2 = 0,cnt4 = 0,cnt14 = 0,cnt24 = 0,cnt74 = 0;
  rep(i,2,100) {
    if (div[i] >= 74) cnt74++;
    if (div[i] >= 24) cnt24++;
    if (div[i] >= 14) cnt14++;
    if (div[i] >= 4) cnt4++;
    if (div[i] >= 2) cnt2++;
  }
  int ans = 0;
  ans += cnt74;
  ans += cnt24*(cnt2-1);
  ans += cnt14*(cnt4-1);
  ans += ((cnt4*(cnt4-1))/2) * (cnt2-2);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<deque>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<iomanip>
#include<sstream>
using namespace std;

#define pi acos(-1.0)
#define ms(x,n) memset(x,n,sizeof(x));
#define pb push_back

typedef long long ll;//string::npos
typedef long long iint;

ll gcd(ll a,ll b) {
	return a%b==0?b:gcd(b,a%b);
}
ll lcm(ll x,ll y) {
	ll z=gcd(x,y);
	return x*y/z;
}
const int MAXX=2e5+5;
const int INF=1e7+5;
const int mod=998244353;

//vector<int> vt;
//pair<int,int> p;
//map<int,int> m;
void insert_sort(int r[],int n){
	int i,j;
	for(i=2;i<=n;i++){
		r[0]=r[i];
		for(j=i-1;r[j]>r[0];j--){
			r[j+1]=r[j];
		}
		r[j+1]=r[0];
	}
}
int main() {
	ios::sync_with_stdio(false);
	iint n,x;
	cin>>n;
	queue<iint> q;
	for(int i=1;i<=9;i++)
		q.push(i);
	for(int i=1;i<=n;i++){
		x=q.front();q.pop();
		if(x%10!=0) q.push(10*x+x%10-1);
		q.push(10*x+x%10);
		if(x%10!=9) q.push(10*x+x%10+1);
	}
	cout<<x<<endl;
}



Measured memory_bytes: 1792
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_6-A: Counting Sort

#include <cstdio>

static void print_ints(const int as[], const unsigned int n)
{
  auto out_sep = "";
  for (auto i = 0u; i < n; ++i) {
    std::printf("%s%d", out_sep, as[i]);
    out_sep = " ";
  }
  std::printf("\n");
}

static const unsigned int MAX_VALUE= 10000u;
static void counting_sort(int as[], int bs[], const unsigned int n)
{
  int cs[MAX_VALUE+1] ={0};
  for (auto i = 0u; i < n; ++i) {
    auto a = as[i];
    ++cs[a];
  }
  --cs[0]; // 0-based
  for (auto i = 1u; i < MAX_VALUE+1; ++i) {
    cs[i] += cs[i-1];
  }
  for (int j = n-1; j >= 0; --j) {
    auto a = as[j];
    bs[cs[a]--] = a;
  }
}

int main()
{
  unsigned int n;
  std::scanf("%u", &n);
  int as[n], bs[n];
  for (auto i = 0u; i < n; ++i) {
    std::scanf("%d", &as[i]);
  }

  counting_sort(as, bs, n);
  print_ints(bs, n);
}

// eof

Measured memory_bytes: 18364
N = int(input())
S = input()

num_r, num_g = S.count('R'), S.count('G')
num_b = N - num_r - num_g
max_ans = num_r * num_g * num_b
count_not_ans = 0
S = list(S)

for i in range(N):
    for j in range(i+1, N):
        k = 2 * j - i
        if (0 <= k <= N-1) and len(set([S[i], S[j], S[k]])) == 3:
            count_not_ans += 1

print(max_ans - count_not_ans)


Measured memory_bytes: 68720
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int INF = 1e9 +7;

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    REP(i, n - 1){
        cin >> b[i];
    }
    
    a[0] = b[0];
    a[n - 1] = b[n - 2];
    REP(i, n - 2){
        a[i + 1] = min(b[i], b[i + 1]);
    }

    int ans = 0;
    REP(i, n){
        ans += a[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ri register int
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
using namespace std;
inline int read(){
	ri x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^'0'),c=getchar();
	return x*f;
}
int n,m,d;
char c[4]={'R','Y','G','B'};
int main()
{
	n=read();m=read();d=read();
	rep(i,1,n){rep(j,1,m){
		ri x=i+j+m,y=i-j+m;
		putchar(c[((x/d)&1)<<1|((y/d)&1)]);
	}puts("");}
	return 0; 
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int X = sc.nextInt();

    int ans = 0;
    int minM = Integer.MAX_VALUE;
    for (int i = 0; i < N; i++) {
      int m = sc.nextInt();
      X -= m;
      ans++;
      if (m < minM) {
        minM = m;
      }
    }
    
    ans += X/minM;
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 23124
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
cnt = 0

for n in range(N):
    sum = C
    A = list(map(int, input().split()))
    for m in range(M):
        sum += A[m]*B[m]
    if sum > 0:
        cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
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 All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    char c;
    cin >> c;
    if(c > 'Z') {
        cout << 'a' << endl;
    } else {
        cout << 'A' << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
/**
 *    author:  tourist
 *    created: 17.12.2019 17:41:54       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, w;
  cin >> n >> w;
  int mx = 1000 * n;
  vector<long long> dp(mx + 1, w + 1);
  dp[0] = 0;
  while (n--) {
    int x, y;
    cin >> x >> y;
    for (int i = mx - y; i >= 0; i--) {
      dp[i + y] = min(dp[i + y], dp[i] + x);
    }
  }
  for (int i = mx; i >= 0; i--) {
    if (dp[i] <= w) {
      cout << i << '\n';
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
long long lcm(long long a, long long b)
{
    return a * b / gcd(a, b);
}
int main()
{
  long long n, m, ans = 0;
  cin >> n >> m;
  vector<long long> a(n);
  for(int i=0;i<n;i++){
  	cin >> a[i];
  }
  sort(a.begin(), a.end());
  
  long long l = a[0];
  int cnt = 0;
  while(l%2 == 0){
  	l /= 2;
  	cnt++;
  }
  
  bool flag = 1;
  long long tw = pow(2, cnt);
  long long x = tw/2;
  
  for(int i=0;i<n;i++){
  	if(a[i]%tw == 0){
  		if(a[i]%(2*tw)==0){
  			ans = 0;
  			flag = 0;
  			break;
  		}else{
  			a[i] /= tw;
  		}
  	}else{
  		ans = 0;
  		flag = 0;
  		break;
  	}
  }
  
  for(int i=0;i<n;i++){
  	x = lcm(x, a[i]);
  	if(m<x){
  		flag = 0;
  		ans = 0;
  		break;
  	}
  }
  
  
  
  
  if(flag){
	ans = (m-x)/(2*x);
	ans++;
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <functional>
#include <list>
#include <utility>
#include <map>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))
const ll mod = 1000000007;
const double eps = 1e-10;
const int MAX = 200000;

int main() {
	int n,r;
	cin >> n >>  r;
  if (n >= 10) {
    cout << r << endl;
  } else {
    cout << r + (10 - n) * 100 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}


int main(void) {
    int i,j;
    int n,m;
    cin >> n >> m;
    vector<pii> p(m);
    rep(i,m)cin >> p[i].first >> p[i].second;
    sort(all(p));
    vector<vi> ans(n,vi(2));
    rep(i,n)ans[i][0] = ans[i][1] = i;//閉区間
    rep(i,m){
        int arm = p[i].second-1;
        int x = min(ans[arm][0],ans[arm+1][0]);
        int y = max(ans[arm][1],ans[arm+1][1]);
        ans[arm][0] = ans[arm+1][0] = x;
        ans[arm][1] = ans[arm+1][1] = y;
    }
    rep(i,n){
        cout << ans[i][1] - ans[i][0]+1;
        if(i<n-1)cout << " ";
        else cout << endl;
    }


}



Measured memory_bytes: 14428
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	ex := make([]float64, n)
	for i := 0; i < n; i++ {
		var p float64
		fmt.Scan(&p)
		ex[i] = (p + 1) / 2.0
	}

	sum := 0.0
	for i := 0; i < k; i++ {
		sum += ex[i]
	}

	first := 0
	last := k
	max := sum
	for last < n {
		sum = sum - ex[first] + ex[last]
		first++
		last++
		if sum > max {
			max = sum
		}
	}
	fmt.Printf("%.12f\n", max)
}


Measured memory_bytes: 4992