akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))
#define LLONG_MAX numeric_limits<long long>::max()
#define INT_MAX numeric_limits<int>::max()

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
} point;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " " << p.second << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}


template <typename T>
void say(vector<T>& vec, string pad = " ") {
	for (const T& elem : vec)
		cout << elem << pad;
}


/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	string N;
	cin >> N;
	
	int ans = 0;
	bool nine = true;
	for (int i = 0; i < N.length(); i++) {
		if (i == 0) ans += int(N[i] - '0');
		else {
			ans += 9;
			if (N[i] != '9') nine = false;
		}
	}

	if (!nine) ans--;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
long long f(long long a) {
	long long res[] = {a,1LL,a+1LL,0LL};
	return res[a%4LL];
}
long long f2(long long a, long long b) {
	return f(b)^f(a-1LL);
}
int main(){
	long long a,b;
	cin>>a>>b;
	if(a==0){
		if(b==0)puts("0");
		else cout<<f2(1,b)<<endl;
		return 0;
	}
	cout<<f2(a,b)<<endl;;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner s=new Scanner(System.in);
		int[] a=new int[10];
		for(int i=0;i<10;i++)a[i]=s.nextInt();
		Arrays.sort(a);
		System.out.println(a[9]);
		System.out.println(a[8]);
		System.out.println(a[7]);
	}
}

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

int main(void){
    string N;
    cin >> N;
    
    for(int i = 0; i < N.size(); i++){
        if(N[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
 
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
 
void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}
 
void solve(){
    ll x;
    cin>>x;
    map<ll,ll> mp;
    mp[0]=0;
    ll b=1;
    while(true){
        ll b5=pow(b,5);
        mp[b5]=b;
        mp[-b5]=-b;
        b++;
        if(mp.find(b5-x)==mp.end()) continue;
        cout<< b-1 << " " << mp[b5-x]<<en;
        return;
    }
}
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    solve();
    //ll t;cin>>t;REP(i,t) solve();
 
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

ll mypow(ll x, ll y){
  ll ans = 1;
  rep(i, 0, y) ans = ans * x;
  return ans;
}

int main(){
  ll k;
  cin >> k;
  vector<vvll> luna(10000, vvll(10, vll(0)));
  ll count = 0;
  ll keta = 0;
  luna[keta][0] = {0};
  ll ans;
  while(true){
    rep(i, 1, 10){
      if(keta == 0){
        ll now = i;
        luna[keta][i].push_back(now);
        count++;
        ans = now;
        if(count == k) goto OUT;
      }
      else{
        if(i == 1){
          if(keta == 1){
            luna[keta][i].push_back(10);
            count++;
            ans = 10;
            if(count == k) goto OUT;
          }
          rep(j, 0, keta - 1){
            rep(x, 0, 2){
              vrep(y, luna[j][x]){
                ll now = mypow(10, keta) + y;
                luna[keta][i].push_back(now);
                count++;
                ans = now;
                if(count == k) goto OUT;
              } 
            }
          }
        }
        rep(j, -1, 2){
          if(i + j < 10 && i + j > 0){
            vrep(y, luna[keta - 1][i + j]){
              ll now = mypow(10, keta) * i + y;
              luna[keta][i].push_back(now);
              count++;
              ans = now;
              if(count == k) goto OUT;
            }
          }
        }
      }
    }
    keta++;
  }

  OUT:
  cout << ans << endl;
}


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

using namespace std;

typedef long long int ll;
typedef long long unsigned int llu;
#define tc long long int t; cin>>t; while(t--)
#define  sync ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define mpi unordered_map<ll, ll>
#define mpc unordered_map<char, ll>
#define map_loop(it,m) for(auto it = m.begin(); it!=m.end(); it++)
#define rep(i,n) for(ll i=0;i<n;i++)



template<typename... T>
void read(T&... args){
  ((cin>>args), ...);
}

template<typename... T>
void write(T... args){
  ((cout<<args<<" "), ...);
}


int main(){
  
  sync;
  float r;
  read(r);
  
  printf("%.5f\n",2*3.1415*r);
  
}


Measured memory_bytes: 3756
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	v := make([]int, n)
	c := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&v[i])
	}
	for i := 0; i < n; i++ {
		fmt.Scan(&c[i])
	}

	var ret int
	for i := 0; i < n; i++ {
		if v[i]-c[i] > 0 {
			ret += v[i] - c[i]
		}
	}

	fmt.Println(ret)
}


Measured memory_bytes: 512
#include<stdio.h>
main()
{
	long long n,m,i,j,s=0,k;
	scanf("%lld %lld",&n,&m);
	for(i=m;i<=n+1;i++)
	{
		for(j=0;j<i;j++)
		{
			s=s+n-j-j;
		}
		s=s+1;
	}
	printf("%lld",s%1000000007);
 } 

Measured memory_bytes: 2152
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <unordered_map>
//typedef long long LL;
//typedef long double LD;
using namespace std;

//#define MOD 1000000007

int main() {
    int n;
    int m;
    vector<pair<int, int>> sc;
    int tmp_s;
    int tmp_c;
    int ans_c_100=-1;
    int ans_c_10=-1;
    int ans_c_1=-1;
    int ans=1000;
    int min_value=1;
    int max_value;

    cin >> n >> m;
    for(int i=0; i<m; i++){
        cin >> tmp_s >> tmp_c;
        sc.push_back(make_pair(tmp_s, tmp_c));
    }
    if(n==1){
        min_value=0;
        max_value=9;
    }else{
        for(int i=1; i<n; i++){
            min_value*=10;
        }
        max_value=min_value*10-1;
    }

    for(int i=0; i<m; i++){
        int tmp=n+1-sc[i].first;
        if(tmp==3){
            if(ans_c_100==-1){
                ans_c_100=sc[i].second;
            }else if(ans_c_100==sc[i].second){
                continue;
            }else{
                ans=-1;
                }
        }else if(tmp==2){
            if(ans_c_10==-1){
                ans_c_10=sc[i].second;
            }else if(ans_c_10==sc[i].second){
                continue;
            }else{
                ans=-1;
            }     
        }else{
            if(ans_c_1==-1){
                ans_c_1=sc[i].second;
            }else if(ans_c_1==sc[i].second){
                continue;
            }else{
                ans=-1;
            }    
        }
    }

    //cout << ans_c_100 << " " << ans_c_10 << " " << ans_c_1 << endl;
    //cout << ans << endl;
    //cout << min_value << " " << max_value << endl;
    if(ans!=-1){
        for(int i=min_value; i<=max_value; i++){
            int tmp=i;
            if(ans_c_1!=-1 && ans_c_1!=tmp%10){
                continue;
            }
            tmp/=10;
            if(ans_c_10!=-1 && ans_c_10!=tmp%10){
                continue;
            }
            tmp/=10;
            if(ans_c_100!=-1 && ans_c_100!=tmp%10){
                continue;
            }
            //cout << tmp << endl;   
            //cout << i << endl;
            if(i<ans){
                ans=i;
            }
        }
    }
    if(ans==1000){
        ans=-1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
// abc052_b
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int n,ans=0,x=0;
  string s;
  cin >> n >> s;
  for(int i=0;i<n;i++) {
    if(s[i] == 'I') {
      x++;
    } else {
      x--;
    }
    ans = max(x,ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import std.conv, std.stdio;
import std.algorithm, std.array, std.range, std.string;
enum p = 26;

void main()
{
    (readln.chomp.to!ulong - 1).solve.writeln;
}

private:

auto solve(ulong n)
{
    long a = p;
    auto i = 1;
    while (a <= n)
    {
        n -= a;
        a *= p;
        i += 1;
    }
    return n.to26ary(i);
}

unittest
{
    foreach (i; 0..1000)
        i.solve.write(" ");
    foreach (i; 999_9999_9999_9000..1000_0000_0000_0002)
        i.solve.write(" ");
}

auto to26ary(ulong n, int i)
{
    string ret;
    foreach (_; 0..i)
    {
        ret = cast(char)('a' + (n % p)) ~ ret;
        n /= p;
    }
    return ret;
}


Measured memory_bytes: 2740
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.14159265358979
#define coutdb cout<<fixed<<setprecision(50)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

#define int long long

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int N, d, c, sum = 0, digit = 0; cin >> N;
  REP(i, N){
    cin >> d >> c;
    sum += d*c;
    digit += c;
  }
  cout << digit-1 + (sum-1)/9 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}

ll d[1000000];
ll cnt;

ll ans[10];
int main(){
	ll h,w,n;
	scanf("%lld%lld%lld",&h,&w,&n);
	while(n--){
		ll x,y;
		scanf("%lld%lld",&x,&y);
		rep(dx,-1,2)rep(dy,-1,2)d[cnt++]=((x+dx)<<32)|(y+dy);
	}
	sortup(d,cnt);
	
	int c=1;
	rep(i,0,cnt){
		if(d[i]==d[i+1])c++;
		else{
			int x,y;
			x=d[i]>>32;
			y=d[i]&0xFFFFFFFF;
			if(2<=x&&x<=h-1&&2<=y&&y<=w-1)ans[c]++;
			c=1;
		}
	}
	ll s=0;
	rep(i,1,10)s+=ans[i];
	ans[0]=(h-2)*(w-2)-s;
	rep(i,0,10)printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 14332
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <unistd.h>
#include <bits/stdc++.h>

#define pii pair<int,int>
#define REP(i, n) for (long long i = 0; i < (n); i++) 
using namespace std;

using Graph = vector<vector<int>>;

typedef long long ll;
static const ll INF = 1000000000000000000LL;
static const ll MOD = 1000000007;


int main()
{
    string s;
    cin >> s;

    for(int i =0; i < s.size(); ++i)
    {
        cout << 'x';
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

const ll MOD = 1e9 + 7;

int main(){
    string s;
    cin >> s;
    map<char, int> mp;
    rep(i, s.size()) {
        mp[s[i]]++;
    }
    bool ans = true;
    for( auto i = mp.begin(); i != mp.end() ; ++i ) {
        if (i->second != 2) ans = false;
    }
    if (ans==true) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

scale = 20
h = 0
gauge = 2 ** scale
import bisect
while gauge > 0:
  h += gauge
  tmp = 0
  for i in range(n):
    b = bisect.bisect_left(a,h-a[i])
    tmp += n - b
  if tmp >= m:
    pass
  else:
    h -= gauge
  gauge //= 2
#print(h)

ans = 0
num = 0
cum = [0]
for i in range(n):
  cum.append(cum[-1]+a[-1-i])
cum.reverse()
for i in range(n):
  b = bisect.bisect_left(a,h-a[i])
  ans += cum[b]
  ans += a[i] * (n-b)
  num += n - b
  #print(b,ans,num)
ans -= (num-m) * h
#print(cum)
print(ans)

Measured memory_bytes: 59916
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[100010];
map<int,int> H;

int LIS(){
	vector<int> V;
	for(int i=0;i<N;i++){
		int p=distance(V.begin(),upper_bound(V.begin(),V.end(),A[i]));
		if(p==V.size()){
			V.push_back(A[i]);
		}
		else{
			V[p]=A[i];
		}
	}
	return V.size();
}

signed main(){
	cin>>N;
	vector<int> B;
	REP(i,N){
		cin>>A[i];
	}
	reverse(A,A+N);
	int ans=LIS();
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2168
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif


int n;

int main() {
	const double pi = acos(-1), eps = 1e-8;
	scanf("%d", &n);
	double now = 0, x = 0, y = 0;
	int ans = 0,t=0;
	do {
		++ans;
		x += cos(now);
		y += sin(now);
		now += n*pi/180;
	} while (fabs(x)>eps||fabs(y)>eps);
	printf("%d\n", ans);
}









Measured memory_bytes: 4096
#include <iostream> 
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue> 
using namespace std;
struct Node {
	Node *l,*r;
	int st,ed,mi,lazy,val;
}*root,pool[404040];
int tot;
long long pre[202020];
inline void Build(Node *&now,int st,int ed) {
	now = &pool[++tot];
	now->st = st;
	now->ed = ed;
	now->lazy = 0;
	if (st == ed) {
		now->mi = 0;
		now->val = st;
		return ;
	}
	int mid = ((st+ed)>>1);
	Build(now->l,st,mid);
	Build(now->r,mid+1,ed);
	now->mi = min(now->l->mi,now->r->mi);
}
inline void down(Node* now) {
	if (!now->lazy)
		return ;
	now->l->lazy = now->lazy;
	now->r->lazy = now->lazy;
	now->l->mi = now->l->st - now->lazy;
	now->r->mi = now->r->st - now->lazy;
	now->l->val = now->r->val = now->lazy;
	now->lazy = 0;
}
inline void Cover(Node *now,int st,int ed,int val) {
	if (now->st > ed || now->ed < st)
		return ;
	if (now->st >= st && now->ed <= ed) {
		now->lazy = val;
		now->mi = now->st-val;
		now->val = val;
		return ;
	}
	down(now);
	Cover(now->l,st,ed,val);
	Cover(now->r,st,ed,val);
	now->mi = min(now->l->mi,now->r->mi);
}

inline int query(Node *now,int pos) {
	if (now->st >= pos && now->ed <= pos) {
		return now->val;
	}
	down(now);
	if (now->l->ed >= pos)
		return query(now->l,pos);
	return query(now->r,pos);
}
int a[201001],n,b[202020],c[202020],m;
long long ans,sum[202020] = {0};
int main() {
	scanf("%d%d",&n,&m);
	Build(root,1,m);
	for (int i = 1;i <= n; i++) {
		scanf("%d%d",&a[i],&b[i]);
		if (a[i] == 1)
			Cover(root,a[i],b[i],-1000000);
		else
			Cover(root,a[i],b[i],query(root,a[i]-1));
		if (root->mi+i >= 1000000)
			printf("-1\n");
		else
			printf("%d\n",i+root->mi);
	}
	return 0;
}
/*
2
1 2
99999 999
*/

Measured memory_bytes: 20944
/*Ankon Ghosh
  KUET,ECE 2K16*/
#include<bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
///#include <ext/pb_ds/detail/standard_policies.hpp>*/
///using namespace __gnu_pbds;
using namespace std;
using ll=long long;
#define inf 1e16
#define MAX 100005
#define mod 998244353
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define Case(i) printf("Case %lld: ",i)
#define setpre(number) cout<<fixed<<setprecision(10)<<number<<endl
#define pf(a) printf("%lld ",a)
#define pff(a,b) printf("%lld %lld\n",a,b)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define LOOP(x,y) for(ll i=x;i<=y;i++)
#define RFOR(i,n) for(ll i=n-1;i>=0;i--)
#define RFOR1(i,n) for(ll i=n;i>0;i--)
#define RLOOP(x,y) for(ll i=y;i>=x;i--)
#define m_p make_pair
#define ff first
#define ss second
#define p_b push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define output freopen("output.txt","w",stdout)
map<ll,ll>mp1,mp;
vector<pair<ll,pair<ll,ll> > >vpp1;
vector<pair<ll,ll> >vpp,vp1;
vector<ll>v,v1,v2,fin;
map<pair<ll,ll>,bool>mbb;
map<ll,bool>mb,mb1;
ll a,b,c,n,d,e,f,ta,sum=0,cnt=0,m,l,req,sz,maxi,k;
priority_queue<ll>pq;
ll solve()
{
    ///cout<<"ankon"<<endl;
    while(!pq.empty())
    {
        ///cout<<pq.size()<<endl;
        if(pq.size()==1) return pq.top();
        else
        {
            ll x=pq.top();
            pq.pop();
            ll y=pq.top();
            pq.pop();
            ll rem=x%y;
           /// cout<<x<<" "<<y<<" "<<rem<<endl;
            if(rem==1) return 1;
            if(rem==0LL)
            {
                pq.push(y);
            }
            else
            {
                pq.push(y);
                pq.push(rem);
            }
        }
    }
}
int main()
{
    fast;
    cin>>n;
    FOR(i,n)
    {
        cin>>a;
        pq.push(a);
    }
    ll ans=solve();
    cout<<ans<<endl;
    return 0;
}

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

#define NAME "I - Coins"
#define show(x) cout << (#x) << " is " << (x) << endl
#define ll long long
#define ms(arr,val) memset(arr,val,sizeof(arr))
#define len length()

const int maxn = 2999;
double a[maxn+1];
double dp[maxn+1][maxn+1];
int main(){
    //ifstream cin(NAME".inp");
    //ofstream cout(NAME".out");
    int n;
    cin>>n;
    for(int i = 1;i<=n;i++) cin>>a[i];
    ms(dp,0);
    dp[0][0]=1;
    for(int i = 1;i<=n;i++)
        for(int j=0;j<=i;j++){
            dp[i][j] = dp[i-1][j]*(1.0-a[i]);
            if (j>0) dp[i][j]+= dp[i-1][j-1]*a[i];
        }

    double ans = 0;
    for(int i=n/2+1;i<=n;i++) ans+= dp[n][i];
    cout<<setprecision(10)<<fixed<<ans;
}



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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

class vtx{
public:
	int x, y; // x in [1..C] ,  [y in 1..R]
	char c;
	vector<int> nv;
	vtx(){ x=-1, y=-1; nv.clear();}
};

using Graph = vector<vtx>;

int H, W, N;
vector<int> seen;

int bfs(Graph &G, int s, int g){
	queue<int> que;
	seen.assign(N, -1);
	seen[s] = 0;
	que.push(s);
	while(!que.empty()){
		int v = que.front(); que.pop();
		for(int next_v : G[v].nv){
			if(seen[next_v] >= 0) continue;
			seen[next_v] = seen[v] + 1;
			que.push(next_v);
		}
	}
	return seen[g];
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> H >> W;
	N = H * W;
	Graph G(N);

	for(int i=1; i<=H; i++){
		for(int j=1; j<=W; j++){
			int pos = (i - 1) * W + (j - 1);
			G[pos].x = j, G[pos].y = i;
			cin >> G[pos].c;
		}
	}

	for(int pos = 0; pos < G.size(); pos++){
		if(G[pos].c != '#'){
			for(int k=0; k<4; k++){
				int npos = -1;
				if(k==0 && G[pos].x<W) npos = pos + 1; //右
				if(k==1 && G[pos].x>1) npos = pos - 1; //右
				if(k==2 && G[pos].y<H) npos = pos + W; //上
				if(k==4 && G[pos].y>1) npos = pos - W; //下
				if(npos >=0 && npos<G.size() && G[npos].c != '#'){
					G[pos].nv.push_back(npos);
					G[npos].nv.push_back(pos);
				}
			}
		}
	}

	int ans = 0;
	for(int s=0; s<G.size(); s++){ //start
		if(G[s].c == '#'){
			continue;
		}
		for(int g=0; g<G.size(); g++){ //goal
			if(G[g].c == '#'){
				continue;
			}
			int d = bfs(G, s, g);
			if(d > ans){
				ans = d;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <math.h>
 
using namespace std;
 
int main(){
    double a,b,c,degree,S;
    scanf("%lf %lf %lf",&a,&b,&degree);
    S = (0.5)*a*b*sin(M_PI*degree/180);
    c = sqrt(a*a+b*b-2*a*b*cos(M_PI*degree/180));
    printf("%.8lf\n",S);
    printf("%.8lf\n",a+b+c);
    printf("%.8lf\n",2*S/a);
}


Measured memory_bytes: 2900
#include<stdio.h>
#include<string.h>
int main(void)
{
	int a,b;
	char c[2];
	scanf("%d",&a);
	scanf("%s",c);
	scanf("%d",&b);
	if (c[0] == 43) {
		printf("%d\n",a + b);
	}else {
		printf("%d\n",a-b);
	}
	return 0;
}

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

ll N;
ll cnt = 0;
int length;

int hand[3] = {3, 5, 7};

void dfs(int n, ll ans) {
    // cout << ans << endl;

    if(333 <= ans && ans <= N) {
        bool f_3 = false;
        bool f_5 = false;
        bool f_7 = false;
        if(to_string(ans).find("3") != std::string::npos) f_3 = true;
        if(to_string(ans).find("5") != std::string::npos) f_5 = true;
        if(to_string(ans).find("7") != std::string::npos) f_7 = true;
        if((f_3 + f_5 + f_7) == 3) {
            cnt++;
        }
    }
    if(n == length) {
        return;
    }
    for(int i = 0; i < 3; i++) {
        dfs(n + 1, ans + hand[i] * pow(10, n));
    }
}
int main() {
    vector<int> flags(3, 0);
    cin >> N;

    // while(N / 10) {
    //     nums.push_back(N % 10);
    //     N /= 10;
    // }
    // nums.push_back(N % 10);
    length = to_string(N).size();
    dfs(0, 0);
    cout << cnt << endl;
    cin >> N;
    return 0;
}

Measured memory_bytes: 256
const p = (...args) => {
  process.env.NODE_ENV === "test" ? console.log(...args) : ""
}

const solve = (as) => {
  let r = 0
  let fNeg = as.filter((a) => a < 0)
  let zeroNum = as.filter((a, i) => {
    return a == 0
  })
  let min = Math.min(...as.map((a) => Math.abs(a)))
  let sum = as.reduce((a, b) => Math.abs(a) + Math.abs(b), 0)
  if (fNeg.length % 2 == 0 || zeroNum > 0) {
    return sum
  } else {
    return sum - min * 2
  }
}
const main = (input) => {
  const [n, as] = input.split("\n")
  return solve(as.split(" ").map(Number))
}

if (process.env.NODE_ENV !== "test") {
  const input = require("fs").readFileSync("/dev/stdin", "utf8")
  console.log(main(input.trim()))
}

if (process.env.NODE_ENV === "test") {
  // module.exports = (input) => solve(input.trim())
  // main(``)
  // solve(1, [2, 3, 4])
}


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

int main() {

  string S;
  cin >> S;
  vector<char> data(S.size());

  for(int i = 1; i <= S.size(); i++){
    data.at(i-1) = S.at(S.size()-i);
  }

  int count = 0;
  for(int i = 0; i < S.size(); i++){
    if(S.at(i) != data.at(i)){
      count++;
    }
  }

  cout << count/2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <ctime>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppiii;
typedef vector<int> vi;
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RREP(i,x) for(int i=(x)-1;i>=0;i--)
#define RFOR(i,c) for(auto i=(c).rbegin();i!=(c).rend();++i)
#define ALL(container) container.begin(), container.end()
#define SZ(container) ((int)container.size())

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;

main(){
	int M, T, P, R;
	while(cin >> M >> T >> P >> R, M){
		vector<ppiii> lis(T);
		vector< vector<int> > wa(T+1, vector<int>(P+1, 0));
		REP(i, T) lis[i] = ppiii(pii(0, 0), -i-1);
		REP(i, R){
			int m, t, p, j;
			cin >> m >> t >> p >> j;
			if(j) wa[t][p]++;
			else{
				lis[t-1].first.first --;
				lis[t-1].first.second += m + wa[t][p]*20;
			}
		}
		sort(lis.begin(), lis.end());
		cout << -lis[0].second;
		for(int i=1;i<T;i++){
			cout << (lis[i-1].first==lis[i].first?"=":",")<<-lis[i].second;
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int A[100];
int V[100];
int C[100];

int main(){
    int N;
    cin >> N;
    REP(i,N){
        int v;
        cin >> v;
        V[i] = v;
    }
    REP(i,N){
        int v;
        cin >> v;
        C[i] = v;
    }

    REP(i,N){
        A[i] = V[i] - C[i];
    }

    sort(A, A+N, greater<int>());

    int ans = 0;
    REP(i,N){
        int a = A[i];
        if(a < 0) break;
        ans += a;
    }

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


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000000000000;
const int mod = 1000000007;
int test[12345678];
signed main() {
	vector<vector<int>> v(123456); map<int, int> cost;
	int n, m, hi, a, b, c, cnt = 0, ans = 0; string s, t;
	cin >> n;
	for (int h = 0; h < n; h++) {
		cin >> a; test[h] = a; cost[a + h]++;
	}
	for (int h = 0; h < n; h++) {
		if (h - test[h] >= 0) {
			ans += cost[h - test[h]];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 21400
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n; cin >> n;
	vi a(n);
	vll cnt(n,0);
	rep(i,n){
		cin >> a[i];
		cnt[a[i]-1]++;
	}
//	rep(i,n)cout << cnt[i] << endl;	
//	cout << endl;
	ll sum = 0;
	rep(i,n){
		sum += cnt[i]*(cnt[i]-1)/2;
//		cout << cnt[i]*(cnt[i]-1)/2 << endl;
	}
//	cout << sum << endl << endl;
	rep(i,n){
		ll ans = sum - cnt[a[i]-1]*(cnt[a[i]-1]-1)/2 + (cnt[a[i]-1]-1)*(cnt[a[i]-1]-2)/2;
		cout << ans << endl;
	}
}




Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
long long n,a[200005],sum,x;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum=sum xor a[i];
	}
	for(int i=1;i<=n;i++){
		x=sum xor a[i];
		cout<<x<<" ";
	}
	return 0;
}

Measured memory_bytes: 5144
#include <bits/stdc++.h>
#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 pb push_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
const int inf = 1e9;
const int mod = 1e9+7;

ll n, a[50];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  FOR(i, 0, n) cin >> a[i];
  ll count, ans=0;
  bool z=true;
  while (z){
    count = 0;
    z = false;
    FOR(i, 0, n){
      if(a[i] > n-1){
        z = true;
        count += a[i]/n;
      }
    }
    ans += count;
    FOR(i, 0, n){
      if(a[i] > n-1){
        a[i] += count-a[i]/n*(n+1);
      }else{
        a[i] += count;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (int i=0; i<n; ++i)
#define all(c) begin(c),end(c)
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*
全部の数の約数とりたい


各桁毎の素数の数一覧
範囲	0の数	素数の個数
10まで	10^1	1	4
100まで	10^2	2	25
1000まで	10^3	3	168
1万まで	10^4	4	1229
10万まで	10^5	5	9592
100万まで	10^6	6	78498
1000*10^6まで
*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  int N; cin>>N;
  vector<int> A(N,0);
  rep(i,N) cin>>A[i];
  int ans = 2;
  map<int,int> MP;
  rep(k,N){
    int a = A[k];
    for(int i=2; i*i<=a; i++){
      if (a%i == 0){
        if (MP[i]>0)
          ans = 1;
        MP[i]++;
        while (a%i == 0)
          a /= i;
      }
    }
    if (a>1){
      if (MP[a] > 0)
        ans = 1;
      MP[a]++;
    }
  }
  if (ans == 2){
    cout << "pairwise coprime" <<endl;
    return 0;
  }
  for(auto v: MP){
    if (v.second == N){
      cout << "not coprime" <<endl;
      return 0;
    }
  }
  cout << "setwise coprime" << endl;
}


Measured memory_bytes: 10740
#include<iostream>
using namespace std;
int main(){
  int a[5],k;
  bool f=true;
  for(int i=0;i<5;i++) cin >> a[i];
  cin >> k;
  for(int i=0;i<5;i++){
    for(int j=i+1;j<5;j++){
      if(a[j]-a[i]>k){
        f=false;
        break;
      }
    }
    if(f==false){
      break;
    }
  }
  if(f) cout <<"Yay!\n";
  else cout << ":(\n";
}
  


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

int main() {
  int k, n;
  cin >> k >> n;
  vector<int>a(n);
  rep(i,n) cin >> a[i];
  vector<int>val(n);
  rep(i,n-1){
    val[i]=a[i+1]-a[i];
  }
  val[n-1]=k-a[n-1]+a[0];
  sort(val.rbegin(), val.rend());
  cout << k-val[0] << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define lint long long
using namespace std;
lint readint() {
	char c = getchar_unlocked();
	lint ans = 0;
	while ('0' <= c && c <= '9') {
		ans = ans * 10 + c - '0';
		c = getchar_unlocked();
	}
	return ans;
}
char ch[1024];
void writeint(lint x) {
	int ptr = 0;
	while (x) {
		ch[ptr++] = (x % 10) + '0';
		x /= 10;
	}
	while (ptr) {
		putchar_unlocked(ch[--ptr]);
	}
	putchar_unlocked(' ');
}
int q,m=1000000007;
lint x,y,f[99]={0,1,1};
int main(){
	q=readint();
	rep(i,96)f[i+3]=f[i+1]+f[i+2];
	rep(i,q){
		x=readint();y=readint();
		if(x>y)swap(x,y);
		if(y<=2){
			writeint(1);writeint(y==1?1:x==1?2:4);
			continue;
		}
		rep(j,99){
			if(x<f[j]||y<f[j+1]){
				lint a=x==1?2:1;
				rep(k,j-2){
					lint n=f[j-1]+f[j-3-k]*f[k+2],m=f[j]+f[j-2-k]*f[k+2];
					if(n<=x&&m<=y)a+=(y-m)/n+1;
				}
				if(f[j]<=x){
					a++;
					rep(k,j-2)a+=(x-f[j])/(f[j-2-k]*f[k+2]);
				}
				writeint(j-2);writeint(a%m);
				break;
			}
		}
	}
}

Measured memory_bytes: 4340
# -*- coding: utf-8 -*-
import sys

H,W=map(int, sys.stdin.readline().split())
A=[ map(int, sys.stdin.readline().split()) for _ in range(H) ]
B=[ map(int, sys.stdin.readline().split()) for _ in range(H) ]

for h in range(H):
    for w in range(W):
        A[h][w]=abs(A[h][w]-B[h][w])

dp=[ [ 0 for _ in range(W) ] for __ in range(H) ]

Center=80*80      #中心地のセット マイナスの値もセットできるようにbitsetのゼロを80*80+1桁目に置く

#初期化
r,c=0,0
val=A[r][c]
dp[r][c]=1<<val+Center

D=[(1,0),(0,1)]

for r in range(H):
    for c in range(W):
        for dr,dc in D: #横に1つ移動か、下に1つ移動
            if r+dr<H and c+dc<W:   #移動しようとするマスが存在するならばif文内の処理を行う
                next_r=r+dr
                next_c=c+dc
                next_val=A[next_r][next_c]
                dp[next_r][next_c]|=dp[r][c]<<next_val  #次のマスの値が+の場合は、bitshift全体を左にシフト
                dp[next_r][next_c]|=dp[r][c]>>next_val  #次のマスの値が-の場合は、bitshift全体を右にシフト

ans=float("inf")
for i in range(Center*2):
    bit=dp[H-1][W-1]>>i&1
    if bit==1:
        ans=min(ans,abs(i-Center))

print ans


Measured memory_bytes: 44572
#include<bits/stdc++.h>
using namespace std;
#define rep(i, N) for(int i = 0; i< N; i++)
int main() {
    int X, Y; cin >> X >> Y;
    if(Y%2 == 0 && Y/2 >= X && Y/2 <= X*2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3488
import java.util.*;

public class Main {

	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		int[] sortedArr = new int[n];
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextInt();
		    sortedArr[i] = arr[i];
		}
		Arrays.sort(sortedArr);
		int first = sortedArr[n - 1];
		int second = sortedArr[n - 2];
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
		    if (arr[i] == first) {
		        sb.append(second);
		    } else {
		        sb.append(first);
		    }
		    sb.append("\n");
		}
		System.out.print(sb);
	}
}


Measured memory_bytes: 93176
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
 
 
 
 


ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}



int main()
{
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    map<ll,int> mp;
    ll sum=0;
    for(int i=0;i<n;i++)
    {
         sum+=a[i];
         mp[sum]++;
    }
    ll res=0;
    for(auto it:mp)
    {
         if(it.first==0){
              res+=1LL*it.second;
              if(it.second>=2)
              res+=1LL*(it.second)*(it.second-1)/2;
         }
         else
         {
              int ct=it.second;
              if(ct>=2){
                   res+=1LL*(ct)*(ct-1)/2;
              }
         }
    }
    cout<<res;
}















 














 
 

















Measured memory_bytes: 14336
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,M;
int main(){
    cin>>N>>M;
    string ans;
    ans.resize(N);
    for(ll i=0;i<N;i++){
        ans[i]='-';
    }
    for(ll i=0;i<M;i++){
        ll s,c;
        cin>>s>>c;
        if(N!=1 && s==1 && c==0){
            cout<<-1<<endl;
            return 0;
        }
        if(ans[s-1]=='-' || ans[s-1]==c+'0'){
            ans[s-1]=c+'0';
        }else{
            cout<<-1<<endl;
            return 0;
        }
    }
    if(ans[0]=='-'){
        ans[0]='1';
        if(N==1){
            ans[0]='0';
        }
    }
    for(ll i=1;i<N;i++){
        if(ans[i]=='-'){
            ans[i]='0';
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const int MAXN = 102;
const int MAXW = 1e5 + 10;

ll dp[MAXN][MAXW];

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	
	int N, W;
	cin >> N >> W;
	
	vector<int> w(N + 1), v(N + 1);
	for (int i = 1; i <= N; i++)
		cin >> w[i] >> v[i];
	
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= W; j++) {
			dp[i][j] = dp[i-1][j];
			if (j >= w[i])
				dp[i][j] = max(dp[i][j], v[i] + dp[i - 1][j - w[i]]);
		}
	}

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


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

const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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

	ll a,b,c,d;
	
	//cout << "test" << "\n";

	cin >> a >> b >> c >> d;
	
	ll ans=b-a+1;
	
	ll share=1;
	int i=max(c,d),j=min(c,d),r;
	
	
	while(1){
		r=i%j;
		if(r){
			i=j;
			j=r;
		}
		else {
			share=j;
			break;
		}
	}
	
	//cout << share << "\n";
		
	
		
	
	
	ll e=c*d/share;
	
	ans-=(b/c+b/d-b/e);
	//cout << ans << "\n";
	a--;
	//ans+=a;
	ans+=(a/c+a/d-a/e);
	

	cout << ans << "\n";

	return 0;
}


//vector<int> a(n);  sort(a.begin(),a.end());
//cout << "test" << "\n";


//g++ -o a a.cpp


Measured memory_bytes: 256
# problem 4
# Snuke the wizard
N, Q = map(int, input().split())
S = list(input())
que = [tuple(input().split()) for _ in range(Q)]


def isout_l(X):
    # 左にはみ出るか
    if X == 0:
        return True
    now = X-1
    for alpha, dire in que:
        if S[now] == alpha:
            if dire == "R":
                now += 1
                if now == N:
                    return False
            else:
                now -= 1
                if now == -1:
                    return True
    return False


def isout_r(X):
    # 右にはみ出るか
    if X == N+1:
        return True
    now = X-1
    for alpha, dire in que:
        if S[now] == alpha:
            if dire == "R":
                now += 1
                if now == N:
                    return True
            else:
                now -= 1
                if now == -1:
                    return False
    return False


l_limit = 0  # 左にはみ出さない物の最も小さい番目
if isout_l(1) == False:
    l_limit = 1

elif isout_l(N) == True:
    l_limit = N+1
else:
    l = 1
    r = N
    while r-l > 1:
        Med = (l+r)//2
        if isout_l(Med):
            l = Med
        else:
            r = Med
    l_limit = r

r_limit = 0  # みぎにはみ出さない最も大きい番目
if isout_r(N) == False:
    r_limit = N
elif isout_r(1) == True:
    r_limit = 0

else:
    l = 0
    r = N+1
    while r-l > 1:
        Med = (r+l)//2
        if isout_r(Med):
            r = Med
        else:
            l = Med
        r_limit = l
print(r_limit-l_limit+1)

Measured memory_bytes: 19120
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <iomanip>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

class BIT {
    // Binary Indexed Tree : 数列要素1つへの加算、数列のある地点までの累積和を高速に計算
    public:
    std::vector<int> data;
    BIT() {}
    BIT(const int size) {
        // 想定されるサイズの2倍の値を入れた方がいいかもしれない。
        data.resize(size, 0);
    }
    int sum(int i) const {
        int s = 0;
        while (i > 0) {
            s += data[i];
            i = i & (i-1); // iの最後のビットを引く。
        }
        return s;
    }

    void add(int i, int x) {
        while (i < data.size()) {
            data[i] += x;
            i += i - (i & (i-1)); // iの最後のビットを加算する。
        }
    }
};

const int MAX_N = 200050;
int N;
long long K;
long long a[MAX_N], b[MAX_N];

int c[MAX_N];

BIT bit = BIT(MAX_N * 2);

int main(int argc, char **argv) {
    std::cin >> N >> K;

    for (int i = 1; i <= N; i++) {
        std::cin >> a[i];
    }

    for (int i = 1; i <= N; i++) {
        a[i] = a[i] - K;
    }

    b[0] = 0;

    for (int i = 1; i <= N; i++) {
        b[i] = b[i-1] + a[i];
    }

    std::vector<long long> tmp;
    for (int i = 0; i <= N; i++) {
        tmp.push_back(b[i]);
    }

    std::sort(tmp.begin(), tmp.end());

    int tmp_num = 1;
    std::unordered_map<long long, int> mp;

    for (int i = 0; i < tmp.size(); i++) {
        if (mp.find(tmp[i]) == mp.end()) {
            mp[tmp[i]] = tmp_num;
            tmp_num++;
        }
    }

    for (int i = 0; i <= N; i++) {
        c[i] = mp[b[i]];
    }

    long long ret = 0;

    for (int i = 0; i <= N; i++) {
        //std::cout << i << " " << c[i] << std::endl;
        ret += bit.sum(c[i]);
        bit.add(c[i], 1);
    }

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



Measured memory_bytes: 15600