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

template <typename T> void chmin(T&x,const T &y)
{
	if(x>y)x=y;
}
template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
typedef long long s64;
typedef unsigned long long u64;
typedef unsigned int u32;
typedef pair<int,int> pii;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define rep0(i,l,r) for(int i=l;i<r;++i)
#define gc (c=getchar())
int read()
{
	char c;
	while(gc<'-');
	if(c=='-')
	{
		int x=gc-'0';
		while(gc>='0')x=x*10+c-'0';
		return -x;
	}
	int x=c-'0';
	while(gc>='0')x=x*10+c-'0';
	return x;
}
#undef gc

const int N=1e5+5,D=998244353;
int a[N],p[N],b[N];
bool vis[N];

int main()
{
#ifdef kcz
	freopen("1.in","r",stdin);//freopen("1.out","w",stdout);
#endif
	int n;
	cin>>n;
	rep(i,1,n)scanf("%d",a+i);
	sort(a+1,a+n+1);
	s64 ans=1;
	rep(i,1,n)(ans*=__gcd(a[i],i-1))%=D; 
	cout<<ans;	
}


Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] arr = new int[N];
        for(int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }
 
        int res = 0;
        while(N > 0) {
            N = N - K;
            res++;
            if(N==0) {
                break;
            }
            N++;
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 48872
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
#define N 200010
inline int read(){
    int 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<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
int n,head[N],cnt,siz[N];
ll dp[N],fac[N],inv[N],ans[N];
struct Edge{
	int to,nxt;
}edge[N<<1];
void add(int a,int b){
	++cnt;
	edge[cnt].to=b;
	edge[cnt].nxt=head[a];
	head[a]=cnt;
}
ll C(int n,int m){
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
void dfs1(int u,int fa){
	int tot=0;
	dp[u]=siz[u]=1;
	for(int i=head[u];i;i=edge[i].nxt){
		int v=edge[i].to;
		if(v==fa)continue;
		dfs1(v,u);
		siz[u]+=siz[v];
		dp[u]=dp[u]*dp[v]%mod;
	}
	tot=siz[u]-1;
	for(int i=head[u];i;i=edge[i].nxt){
		int v=edge[i].to;
		if(v==fa)continue;
		dp[u]=dp[u]*C(tot,siz[v])%mod;
		tot-=siz[v];
	}
}
ll qpow(ll a,ll b){
	ll ans=1;
	while(b){
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
void init(int n){
	fac[0]=1;
	for(int i=1;i<=n;++i){
		fac[i]=fac[i-1]*i%mod;
	}
	inv[n]=qpow(fac[n],mod-2);
	for(int i=n-1;i>=0;--i){
		inv[i]=inv[i+1]*(i+1)%mod;
	}
}
void dfs2(int u,int fa){
	if(u^1){
		ans[u]=ans[fa]*qpow(C(n-1,siz[u]),mod-2)%mod*C(n-1,n-siz[u])%mod;
	}
	for(int i=head[u];i;i=edge[i].nxt){
		int v=edge[i].to;
		if(v==fa)continue;
		dfs2(v,u);
	}
}
int main(){
	n=read();
	for(int i=1;i<n;++i){
		int u=read(),v=read();
		add(u,v),add(v,u);
	}
	init(n);
	dfs1(1,0);
	ans[1]=dp[1];
	dfs2(1,0);
	for(int i=1;i<=n;++i){
		printf("%lld\n",ans[i]);
	}
	
	return 0;
}


Measured memory_bytes: 13696
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int main() {
	in(int, N);
	in(string, s, t);
	for (int i = 0; i <= N; ++i) {
		if (s.substr(i, s.size() - i) == t.substr(0, s.size() - i)) {
			cout << i + N << endl;
			return 0;
		}
	}
	return 0;
}


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

// * XYツ催?標
#define X real()
#define Y imag()

// * ツ点ツづ個表ツ個サ
typedef complex<double> P;
// * ツ仰鳴容ツつキツづゥツ古ォツ債キツε?
const double EPS = 1e-10;
// * Infinity
const double INF = 1e12;
// * ツ円ツ偲シツ猟ヲ
const double PI = acos(-1.0);
// * Infinity 2
const P INF_P(INF,INF);
// * complex<double> ツづ個渉?渉伉づーツ津ィツ義ツつキツづゥ
namespace std {
	bool operator < (const P& a, const P& b) {
		return (real(a) != real(b))? real(a) < real(b) : imag(a) < imag(b);
	}
}
// * ツ禿?静?(dot product) : aツ・b = |a||b|cosツδヲ
double dot(P a, P b) {
	return real( conj(a) * b );
}
// * ツ外ツ静?(cross product) : aツ×b = |a||b|sinツδヲ
double cross(P a, P b) {
	return imag( conj(a) * b ) ;
}


int main(){
	int n;
	for(int t=1 ; scanf("%d", &n) , n ; t++ ){
		vector<P> v;
		for(int i=0 ; i < n ; i++ ){
			int x, y;
			scanf("%d %d", &x, &y);
			v.push_back( P(x,y) );
		}
		double s = 0.0;
		for(int i=0 ; i < v.size() ; i++ ) {
			s += 0.5 * (v[(i+1)%v.size()].X - v[i].X) * (v[i].Y + v[(i+1)%v.size()].Y);
		}
		printf("%d %.1f\n", t , abs(s) );
	}
}

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

int main()
{
    string r,g,b;
    cin >> r >> g >> b;
    int ans = stoi(r+g+b);
    if(ans%4 == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
///17571@nith.ac.in @Ankit Verma
#include <bits/stdc++.h>
using namespace std;
#define ff          first
#define ss          second
#define pb          push_back
#define MP          make_pair
#define int         long long
#define ll          long long
#define inf         0x3f3f3f3f
#define MOD         1000000007
#define ld          long double
#define eb          emplace_back
#define pii         pair<int,int>
#define ull         unsigned long long
#define all(v)      v.begin(), v.end()
#define f(i,x,n)    for(int i=x;i<n;i++)
#define fr(i,x,n)   for(int i=x;i>=n;i--)
#define fastio      ios::sync_with_stdio(false)

#define n_l '\n'
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cout << to_string(H) << " | "; dbgm(T...); } 
#define debug(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl

void IO() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

int32_t main() {
    IO();
    fastio;
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n; cin >> n;
    vector <int> ar(n);
    for (int i = 1; i <= 200; i++) {
    	for (int j = 1; j <= 200; j++) {
    		for (int k = 1; k <= 200; k++) {
    			int res = (i * i + j * j + k * k + i * j + j * k + k * i);
    			if (res <= n)
    			ar[res]++;
    		}
    	}
    }
    for (int i = 1; i <= n; i++) {
    	cout << ar[i] << endl;
    }
    

    return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h> 
using namespace std; 
#define int long long
# define pii pair<int,int>
const int maxn=10000007;
int prime[maxn];
signed main() { 
    #ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,k;
	cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++)cin>>arr[i];
	sort(arr,arr+n);
	int s=0;
	for(int i=0;i<k;i++)s+=arr[i];
		cout<<s;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

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

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n){
        cin >> a[i];
    }
    int G = a[0];
    rep(i, 1, n){
        G = gcd(G, a[i]);
    }
    cout << G << endl;
}

Measured memory_bytes: 1024
//    Unmesh Kumar
//    CSE'22 IIT Roorkee

#include <iostream>
#include <bits/stdc++.h>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <map>
#include <iterator>
#include <iomanip>
#include <queue>
#include <utility>
#include <set>

using namespace std;
#define ll long long int
#define c(x) ll x;cin>>x
#define cc(x,y) ll x,y;cin>>x>>y
#define ccc(x,y,z) ll x,y,z; cin>>x>>y>>z
#define db long double
#define fast cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false)
#define inf 200000000000000
#define mod 1000000007
#define eps 1e-7
#define PI 3.1415926535897932385
#define pb push_back
#define bitc  __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
#define len(x) (ll)(x).size()
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define print(arr,n) rep(i,n) cout<<arr[i]<<" "; cout<<endl
#define print2(arr,n,m) rep(i,n){ rep(j,m) cout<<arr[i][j]<<" "; cout<<endl; }
#define dyn1(arr,n) ll* arr=new ll[n]; rep(i,n) arr[i]=0;
#define dyn2(arr,n,m) ll** arr=new ll*[(n)]; rep(i,n) arr[i]=new ll[m]; rep(i,n) rep(j,m) arr[i][j]=0
#define carr(arr,n) rep(i,n) cin>>arr[i]
#define carr2(arr,n,m) rep(i,n) rep(j,m) cin>>arr[i][j]
#define debug(a) cout<<" :: "<<#a<<" == "<<a<<endl
#define debug2(a,b) cout<<" :: "<<#a<<" == "<<a<<" :: "<<#b<<" == "<<b<<endl
typedef pair<int,int> ii;
typedef vector<ii> vii;

inline ll maxim(ll a,ll b) {if(a>b) return a; else return b;}
inline ll minim(ll a,ll b) {if(a<b) return a; else return b;}
inline bool equals(double a, double b){ return fabs(a - b) < 1e-9; }
ll gcd(ll a, ll b){ return b==0 ? a : gcd(b, a%b); }


ll binpow(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1) res = (res * a);
        a = (a * a);
        b >>= 1;
    }
    return res;
}

int modInverse(int a, int m)
{
    int m0 = m;
    int y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        int q = a / m;
        int t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

ll refri[1000005];
ll mic[1000005];


int main()
{
  fast;
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  cout<<setprecision(10)<<fixed;
  cc(a,b);
  c(m);
  carr(refri,a);
  carr(mic,b);
  ll mino=100000000000;
  rep(o,m)
  {
    cc(x,y);
    c(d);
    mino=minim(mino,refri[x-1]+mic[y-1]-d);
  }
  sort(refri,refri+a);
  sort(mic,mic+b);
  mino=minim(mino,refri[0]+mic[0]);
  cout<<mino<<endl;
  return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <typeinfo>
#include <cmath>
#include <vector>
using namespace std;

int N;
vector<vector<int>> x;
vector<vector<bool>> y;

// i: HonestとUnkindの組み合わせ
int canExist(int i)
{
  bool ok = true;
  // j: 何番目の人か
  for (int j = 0; j < N; j++)
  {
    // j番目の人が正直な場合
    if (i & (1 << j))
    {
      // k: j番目の人の何番目の主張か
      for (int k = 0; k < x[j].size(); k++)
      {
        // j番目の人のk番目の主張の検証
        if (y[j][k])
        {
          if (i & (1 << x[j][k]))
          {
          }
          else
          {
            ok = false;
            break;
          }
        }
        else
        {
          if (i & (1 << x[j][k]))
          {
            ok = false;
            break;
          }
          else
          {
          }
        }
      }
    }
    if (!ok)
    {
      break;
    }
  }
  return ok;
}

int numOfHonest(int i)
{
  int ans = 0;
  for (int j = 0; j < N; j++)
  {
    if (i & (1 << j))
    {
      ans++;
    }
  }
  return ans;
}

int main()
{
  cin >> N;
  x.resize(N);
  y.resize(N);
  for (int i = 0; i < N; i++)
  {
    int A;
    cin >> A;
    x[i].resize(A);
    y[i].resize(A);

    for (int j = 0; j < A; j++)
    {
      int X, Y;
      cin >> X >> Y;
      x[i][j] = X - 1;
      y[i][j] = Y;
    }
  }

  int ans = 0;

  for (int i = 0; i < (1 << N); i++)
  {
    if (canExist(i))
    {
      int num = numOfHonest(i);
      if (ans < num)
      {
        ans = num;
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<=(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  int x,y;
  cin>>x>>y;
  bool ex=false;
  rep(i,50){
    if(i*2+4*(x-i)==y)
      ex=true;
  }
  if(ex)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

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

const int mod = 1e9+7;

void solve(){
	int n, k;
	cin >> n >> k;
	
	int a[n+1]={};
	
	for(int i=1; i<=n; i++) {
		cin >> a[i];
	}
	
	int dp[n+1][k+1]={};
	
	dp[0][0]=1;
	for(int i=1; i<=k; i++)
		dp[0][i]=0;	
		
	for(int i=1; i<=n; i++){
		vector<int> sum(k+1);
		sum[0]=dp[i-1][0];
		
		for(int j=1; j<=k; j++)
			sum[j] = (sum[j-1] + dp[i-1][j] ) % mod;
		
		for(int j=0; j<=k; j++){
			if(j <= a[i])
				dp[i][j]=sum[j];
			else {
				int non_exist = j-a[i]-1;
				dp[i][j] = (sum[j] - sum[non_exist] + mod) % mod;
			}
		}
		sum.clear();
	}
		
	cout << dp[n][k] << "\n";
	
	
}

int main(){
	solve();
}


Measured memory_bytes: 43356
#include<bits/stdc++.h>
#define ll long long int
#define ss second
#define ff first
#define pb push_back
#define all(v) v.begin(),v.end()
#define unik(v)  v.erase(unique(v.begin(),v.end()),v.end())
using namespace std;
typedef pair<int, int> pii;
const ll mod = 998244353;
const int sz = 200000 + 3, inf = 1e9 + 10;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int n, m;
	cin >> n >> m;
	int ans = (n * (n - 1)) / 2 + (m * (m - 1)) / 2;
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,f,x,y,l,n;
	scanf("%d",&l);
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	x=a/c;
	y=b/d;
	if(a%c>0){
		x=x+1;
	}
	if(b%d>0){
		y=y+1;
	}
	if(x>y){
		n=l-x;
		printf("%d\n",n);
	}
	else{
		n=l-y;
		printf("%d\n",n);
	}
	
	return 0;
}



Measured memory_bytes: 2688
#include <stdio.h>
#define REP(i, n) for(i = 0; i < n; ++i)
#define FOR(i, a, b) for(i = a; i < b; ++i)
#define BORDER 400

void yes_or_no(char boolean){
    if(boolean){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
}

int main(){
    int n, i;
    scanf("%d", &n);
    int a[n];

    REP(i, n){
        scanf("%d", &a[i]);
    }

    if(n % 2){
        for(i = n - 1; i >= 0; i -= 2){
            printf("%d ", a[i]);
        }
        for(i = 1; i < n - 2; i += 2){
            printf("%d ", a[i]);
        }
        if(n > 1) printf("%d\n", a[n - 2]);

    }else{
        for(i = n - 1; i >= 0; i -= 2){
            printf("%d ", a[i]);
        }
        for(i = 0; i < n - 2; i += 2){
            printf("%d ", a[i]);
        }
        if(n > 1) printf("%d\n", a[n - 2]);
    }
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned int ui32;
const long long INFLL = 1e18;

using namespace std;

const int MAXN = 2 * 300;

char f[MAXN + 1][MAXN + 1];
bitset<MAXN + 1> dp[MAXN + 1][MAXN + 1];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("input.txt", "w", stdout);

    int n;
    cin >> n;

    if (n == 1) {
        cout << 1 << "\n";
        return 0;
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> f[i][j];
        }
    }

    for (int i = 0; i < 2 * n; i++) {
        for (int j = 0; j < 2 * n; j++) {
            if (i >= n) {
                f[i][j] = f[i - n][j];
            }
            if (j >= n) {
                f[i][j] = f[i][j - n];
            }
        }
    }

    int ans = 0;
    for (int i = 2 * n - 1; i >= 0; i--) {
        for (int j = 2 * n - 1; j >= 0; j--) {
            for (int len = 0; len <= n; len++) {
                if (len <= 1) {
                    dp[len][i][j] = 1;
                    continue;
                }
                if (j + len - 1 >= 2 * n || i + len - 1 >= 2 * n) {
                    break;
                }
                if (f[i][j + len - 1] != f[i + len - 1][j]) {
                    break;
                }
                if (len <= n && dp[len - 1][i + 1][j + 1]) {
                    dp[len][i][j] = 1;
                    if (len == n && i < n && j < n) {
                        ++ans;
                    }
                }
            }
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 14976
import sys

def main():
    N=int(input())
    W=[input() for i in range(0,N)]
    flag=0
    for i in range(0,N-1):
        if W[i][len(W[i])-1]!=W[i+1][0]:
            flag=1
            break
    memo=[]
    memo_append=memo.append
    for i in range(0,N):
        if W[i] in memo:
            flag=1
            break
        else:
            memo_append(W[i])
    if flag==0:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<stdio.h>
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}
int main() {
	long long int n, s[5000] = {},m,min=10000000,count=0,x;
	scanf("%lld%lld%lld", &n, &m,&x);
	for (int i = 1; i <= m; i++) {
		scanf("%lld", &s[i]);
		
		if (s[i] < x) {
			count++;
		}
	}
	printf("%lld", small(count,m-count));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>*/
 
#define pb push_back
#define mp make_pair
#define sz(s) ((int)(s.size()))
#define all(s) s.begin(), s.end()
#define rep(i, a, n) for (int i = a; i <= n; ++i)
#define per(i, n, a) for (int i = n; i >= a; --i)
#define onlycin ios_base::sync_with_stdio(false); cin.tie(0) 
using namespace std;
// using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
/*typedef tree<
pair < int, int >,
null_type,
less< pair < int, int > >,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;*/
// find_by_order() order_of_key()
const int MAXN = (int)5e5+228;
const char nxtl = '\n';
const int mod = (int)1e9+7;
const double eps = (double)1e-7;
template<typename T> inline bool updmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
template<typename T> inline bool updmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}

int n, dp[55][5][5];
string s1, s2;

int main() {
	#ifdef accepted
		freopen(".in", "r", stdin);
		freopen(".out", "w", stdout);
	#endif
	onlycin;
	cin >> n;
	cin >> s1 >> s2;
	if(s1[0] == s2[0]) {
		rep(i, 0, 2) dp[0][i][i] = 1;
	} else {
		rep(i, 0, 2) {
			rep(j, 0, 2) {
				if(i != j) dp[0][i][j] = 1;
			}
		}
	}
	rep(i, 1, n - 1) {
		rep(c1, 0, 2) {
			rep(c2, 0, 2) {
				if(!dp[i - 1][c1][c2]) continue;
				if(s1[i] == s2[i]) {
					rep(c3, 0, 2) {
						if(c3 != c1 && c3 != c2)
							(dp[i][c3][c3] += dp[i - 1][c1][c2]) %= mod;
					}
				} else if(s1[i] == s1[i - 1]) {
					assert(s2[i] == s2[i - 1]);
					(dp[i][c1][c2] += dp[i - 1][c1][c2]) %= mod;
				} else {
					rep(c3, 0, 2) {
						rep(c4, 0, 2) {
							if(c3 != c4 && c3 != c1 && c4 != c2) (dp[i][c3][c4] += dp[i - 1][c1][c2]) %= mod;
						}
					}
				}
			}
		}
	}
	int res = 0;
	rep(c1, 0, 2) {
		rep(c2,0, 2) (res += dp[n - 1][c1][c2]) %= mod;
	}
	cout << res << nxtl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define LL long long 
#define LD long double
string s,t;
LL a,b,c;
int main()
{
	cin>>a>>b>>c;
	if(a>=c)
	{
		a-=c;
	}
	else 
	{
		c-=a;
		a=0;
		b=max(b-c,0ll);
	}
	cout<<a<<" "<<b<<endl;
}

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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  for (int i=0; i<k; i++) {
    if (a>=b && a>=c) a*=2;
    else if (b>=a && b>=c) b*=2;
    else c*=2;
  }
  cout << a+b+c;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;

int main(){
    int N;
    cin >> N;
    for(int i= 1; i<=9; i++){
        for(int j=1; j<=9; j++){
            if(i*j == N){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
typedef pair<int ,int>P;
int h,w;
vector<int>m[100] ;
int d[100][100];
int main(){
	while(1) {
		cin >> w >> h;

		if(w == 0)
			break;

		REP(i,100) {
			m[i].clear();
		}


		REP(i,2 * h - 1) {
			if(i % 2 == 0) {
				REP(j,w - 1) {
					m[i].pb(-1);
					m[i].pb(-1);
					cin >> *(m[i].end() - 1);
				}
				m[i].pb(-1);
			}else {
				REP(j,w) {
					m[i].pb(-1);
					cin >> *(m[i].end() - 1);
					m[i].pb(-1);
				}
			}
		}
		REP(i,h){
			REP(j,w){
				d[i][j] = -1;
			}
		}

		queue<P> que;

		que.push(P(0,0));
		d[0][0] = 1;
		while(d[h-1][w-1] == -1 && !que.empty()){
			P masu = que.front();
			que.pop();

			REP(i,4){
				int x = masu.fi * 2 +dx[i];
				int y = masu.sc * 2 +dy[i];
				if (0 <=  x && x <2 * h -1 && 0 <= y && y <=2 * w - 1 && m[x][y]== 0){
					//すすめる
					x += dx[i];
					y += dy[i];

					if(d[x/2][y/2] > -1)continue;

					d[x/2][y/2] = d[masu.fi][masu.sc]+1;

					que.push(P(x / 2,y / 2));

				}

			}

		}
		if(d[h-1][w-1] == -1) cout << 0 << endl;
		else cout <<d[h-1][w-1] <<endl; 
	}

	return 0;
}



Measured memory_bytes: 3056
// not solved by myself
import java.util.*;
import java.util.Map.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int As[] = new int[N];

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

        HashMap<Integer,Integer> maps = new HashMap<>();
        for(int a : As) {
            if (maps.keySet().contains(a)) {
                int nums = maps.get(a);
                maps.put(a, nums + 1);
            } else {
                maps.put(a, 1);
            }
        }

        List<Entry<Integer,Integer>> entries = new ArrayList<Entry<Integer,Integer>>(maps.entrySet());

        Collections.sort(entries, new Comparator<Entry<Integer, Integer>>() {
            @Override
            public int compare(Entry<Integer, Integer> o1, Entry<Integer, Integer> o2) {
                return -o1.getValue().compareTo(o2.getValue());
            }
        });

        int sum = 0;
        for(int i = K;i < entries.size();i++)
            sum += entries.get(i).getValue();


        System.out.println(sum);

    }

     public static long max(int[] ar,int size){
        long max = 0;
        for(int i = 0; i< size;i++)
            if(max < ar[i])
                max = ar[i];
        return max;
    }


    public static long max(List<Long> ar){
        long max = 0;
        for(int i = 0; i< ar.size();i++)
            if(max < ar.get(i))
                max = ar.get(i);
        return max;
    }

    public static Integer min(List<Integer> ar){
        int min = 10000;
        int index = 0;
        for(int i = 0; i< ar.size();i++){
            if(min > ar.get(i)){
                min = ar.get(i);
                index = i;
            }
        }
        return min;
    }


    public static long gcd(long m, long n) {
        if(m == 0)
            return n;
        if(n == 0)
            return m;
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

}





Measured memory_bytes: 91640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author toshibablack
 */

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for(int i=(a);i<=(b);++i)
#define REP(i, n) for(int i=0;i<n;++i)
#define FOREACH(x, a) for(auto& (x) : (a))
#define ALL(a) (a).begin(),(a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x,0,sizeof(x))
#define MINF(x) memset(x,0x3f,sizeof(x))
#define MMINUS(a) memset(a,0xff,sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double EPS = 1.0/LINF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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;
}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

using namespace std;

class DPeopleOnALine {
public:
    int N, M;
    struct edge { int to, w; };
    vector<edge> G[ten(5)+1];
    ll val[ten(5)+1]{0};
    bool search[ten(5)+1]{false};
    int cnt = 0;

    void solve(std::istream& in, std::ostream& out) {
        in >> N >> M;
        REP(i, M) {
            int l, r, w; in >> l >> r >> w;
            G[l].push_back((edge){r, w});
            G[r].push_back((edge){l, -w});
        }

        FOR(i, 1, N) {
            if (!search[i]) {
                dfs(i, 0);
            }
        }

        bool ok = true;
        FOR(i, 1, N) {
            FOREACH(e, G[i]) {
                if (val[e.to] - val[i] != e.w) {
                    ok = false;
                    break;
                }
            }
            if (!ok) break;
        }

        if (ok) {
            OUT("Yes");
        } else {
            OUT("No");
        }
    }

    void dfs(int s, int sv) {
        val[s] = sv;
        search[s] = true;
        cnt++;
        FOREACH(e, G[s]) {
            if (!search[e.to]) {
                dfs(e.to, sv + e.w);
            }
        }
    }
};


int main() {
    DPeopleOnALine solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

int min(int a, int b){
  return (a > b)?b:a;
}

int main(){
  int n,i,j;
  scanf("%d",&n);
  int dp[n+1][n+1],p[n+1];
  for (i=0;i<=n;i++){
    for(j=0;j<=n;j++){
      if(i==j)dp[i][j] = 0;
      else dp[i][j]=1e9;
    }
  }
  int tmp;
  for (i=0;i<n-1;i++){
    scanf("%d %d",&p[i],&tmp);
  }
  scanf("%d %d",&p[n - 1],&p[n]);

  for (int k=1;k<=n;k++){
    for (i=0;i+k<=n;i++){
      int end=i+k-1;
      for (j=1;j<k;j++){
        dp[i][end]=min(dp[i][end],dp[i][end-j]+dp[end-j+1][end]+p[i]*p[end-j+1]*p[end + 1]);
      }
    }
  }
  printf("%d\n",dp[0][n-1]);
  return 0;
}





Measured memory_bytes: 2112
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
   int a;
   vector<int> vec;
   int sum = 3;
    for(int i = 0; i < 3; i++){
        cin >> a;
        if( find(vec.begin(), vec.end(), a) != vec.end()){
            sum--;
        }
        vec.push_back(a);
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define intt long long
#define FAST_READ ios_base::sync_with_stdio(0);cin.tie(0);
#define in(n) scanf("%d",&a);
#define out(n) printf("%d\n",a);
#define SIZE 100001
#define INF INT_MAX
#define F first
#define S second

using namespace std;



int main()
{
    FAST_READ;
    int a,b,c;
    cin>>a>>b>>c;
    int ans;
    ans = min(abs(b-a) + abs(c - b) , abs(c- a) + abs(b - c));
    ans = min(ans , abs(a - b) + abs(c - a));
    ans = min(ans , abs(c- b) + abs(a - c));
    ans = min(ans , abs(c- a) + abs(b - a));
    ans = min(ans , abs(c - b) + abs(b - a));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/


int main(){
    string s; cin >> s;
    vector<string> t = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    for(int i = 0; i < t.size(); i++){
        if(t[i] == s)cout << 7 - i << endl;
    }
}

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

int main() {
  int n;
  int bus_stop[]={0,1,2,3,4,5,6,7,8,9,5,4,3,2,1,0,1,2,3,4,5,6,7,8,9};
  scanf("%d", &n);
  while(n--) {
    int get, off;
    scanf("%d %d", &get, &off);
    int i;
    for((get<6 && get>off) ? i=(15-get):i=get; bus_stop[i]!=off; i++) {
      printf("%d ", bus_stop[i]);
    }
    printf("%d\n", off);
  }
}

Measured memory_bytes: 1028
#include<iostream>
using namespace std;
int main(){
  int a,b,f=1;
  cin>>a>>b;
  string s;
  cin>>s;
  int i;
  for(i=0;i<a;i++)if(s[i]<'0'||s[i]>'9')f=0;
  if(s[i]!='-')f=0;
  for(i=a+1;i<a+b+1;i++)if(s[i]<'0'||s[i]>'9')f=0;
  if(f==1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define tcase int _; cin >> _; while(_--)
const int MAX = 1e6;

int n, m;
int uf[MAX], rnk[MAX];

int find(int i) {
	return uf[i] == i ? i : uf[i] = find(uf[i]);
}

void join(int a, int b) {
	int aa = find(a);
	int bb = find(b);
	if(aa == bb) return;
	uf[aa] = bb;
	rnk[bb] += rnk[aa] + 1;
}

void solve() {
	memset(rnk, 0, sizeof rnk);
	cin >> n >> m;
	for(int i=1; i<=n; i++) uf[i] = i;
	for(int i=0; i<m; i++) {
		int a, b;
		cin >> a >> b;
		join(a, b);
	}
	int ans=0;
	for(int i=1; i<=n; i++) ans = max(ans, rnk[i]);
	cout << ans+1;
}

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

 	solve();

  	return 0;
}



Measured memory_bytes: 8324
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

vector<int> result;
vector<int> op;

bool dfs(int n, int i, vector<int> &var) {
  if (var[0] < 0 || var[1] < 0 || var[2] < 0) {
    return false;
  }
  if (i >= n) {
    return true;
  }

  int j = op[i];
  int k = (j + 1) % 3;

  rep(_, 2) {
    result.push_back(j);
    var[j]++;
    var[k]--;
    if (dfs(n, i + 1, var)) {
      return true;
    }
    result.pop_back();
    var[j]--;
    var[k]++;
    swap(j, k);
  }

  return false;
}

int main() {
  int N;
  vector<int> var(3);
  cin >> N >> var[0] >> var[1] >> var[2];

  rep(i, N) {
    string s;
    cin >> s;

    if (s == "AB") {
      op.push_back(0);
    } else if (s == "BC") {
      op.push_back(1);
    } else {
      op.push_back(2);
    }
  }

  if (dfs(N, 0, var)) {
    cout << "Yes\n";
    rep(i, N) { cout << (char)("ABC"[result[i]]) << "\n"; }
  } else {
    cout << "No\n";
  }
  cerr << var[0] << " " << var[1] << " " << var[2] << "\n";

  return 0;
}

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

int main() {
	int n; cin >> n;
	vector<int> l(n);
	int ans = 0;
	for(int i=0;i<n;i++){
		cin >> l[i];
	}
	sort(l.begin(),l.end());
	for(int i=n-1;i>=2;i--){
		for(int j=i-1;j>=1;j--){
			ans += (l.begin()+j) - upper_bound(l.begin(), l.begin()+j, l[i]-l[j]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {

    val In = io.StdIn.readLine()
    val A= In.split(" ")

    var sum: Int = 0

    for ( i: Int <- A(0).toInt to A(1).toInt ) {
      var n: String = i.toString
      if ( n(0) == n(4) && n(1) == n(3) )
        sum += 1
      
    }
    
    print(sum)
 
  }

}


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

const int N = 1e5 + 7;

int a[N];
int n, m;

int main() {
	cin >> n >> m;
	while (m--) {
		int x, y;
		cin >> x >> y;
		a[x]++;
		a[y]++;
	}
	for (int i = 1; i <= n; i++) 
		if (a[i] % 2) {
			cout << "NO";
			return 0;
		}
	cout << "YES";

	return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

double EPS = 1e-10;

double add(double a, double b){
	if(abs(a+b) < EPS * (abs(a) + abs(b))) return 0;
	return a+b;
}

struct P {
	double x,y;
	P() {}
	P(double x, double y) : x(x), y(y) {
	}
	P operator + (P p) {
		return P(add(x, p.x), add(y, p.y));
	}
	P operator - (P p) {
		return P(add(x, -p.x), add(y, -p.y));
	}
	P operator * (double d) {
		return P(x*d, y*d);
	}
	double dot(P p){
		return add(x*p.x, y*p.y);
	}
	double det(P p){
		return add(x*p.y, -y*p.x);
	}
};

bool cmp_x(const P& p, const P& q){
	if(p.x != q.x) return p.x < q.x;
	return p.y < q.y;
}

vector<P> convex_hull(P* ps, int n){
	sort(ps, ps+n, cmp_x);
	int k=0;

	vector<P> qs(n*2);
	for(int i=0; i<n; i++){
		while(k>1 && (qs[k-1] - qs[k-2]).det(ps[i] - qs[k-1])<=0) k--;
		qs[k++] = ps[i];
	}

	for(int i=n-2, t=k; i>=0; i--){
		while(k>t && (qs[k-1] - qs[k-2]).det(ps[i] - qs[k-1])<=0) k--;
		qs[k++] = ps[i];
	}
	qs.resize(k-1);
	return qs;
}

int N;
P ps[100];
P ps2[100];

int main(){
	scanf("%d", &N);
	for(int i=0;i<N; i++){
		int x,y;
		scanf("%d %d", &x, &y);
		ps[i] = P(x,y);
		ps2[i] = P(x,y);
	}

	vector<P> qs = convex_hull(ps, N);

	pair<double,double> vec[N];
	double deg[N];

	for(int i=0;i<qs.size();i++){
		double x1,y1,d;
		if(i<qs.size()-1){
			x1 = qs[i+1].x - qs[i].x;
			y1 = qs[i+1].y - qs[i].y;
			d = sqrt(x1*x1+y1*y1);
			vec[i] = make_pair(y1/d,-x1/d);
		}else{
			x1 = qs[0].x - qs[i].x;
			y1 = qs[0].y - qs[i].y;
			d = sqrt(x1*x1+y1*y1);
			vec[i] = make_pair(y1/d,-x1/d);
		}
	}

	for(int i=0;i<qs.size();i++){
		double cosin;
		if(i<qs.size()-1){
			cosin = vec[i].first*vec[i+1].first + vec[i].second*vec[i+1].second;
			deg[i] = acos(cosin);
		}else{
			cosin = vec[i].first*vec[0].first + vec[i].second*vec[0].second;
			deg[i] = acos(cosin);
		}

	}


	double ans[N];
	for(int i=0;i<N;i++) ans[i] = 0;

	for(int i=0;i<qs.size();i++){
		int num = i;

		for(int j=0;j<N;j++){
			if(ps2[j].x == qs[i].x && ps2[j].y == qs[i].y) num = j;
		}
		if(i>0){
			ans[num] = deg[i-1]/(2*M_PI);
		}else{
			ans[num] = deg[qs.size()-1]/(2*M_PI);
		}


	}

	for(int i=0;i<N;i++){
		printf("%f\n", ans[i]);
	}


	return 0;
}


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

int n;
bool F[100][10];
int P[100][11];

int solve(int k) {
  int res = 0;
  rep(i, n) {
    int cnt = 0;
    rep(j, 10) {
      if (F[i][j] && (1 & (k >> j))) ++cnt;
    }
    res += P[i][cnt];
  }
  return res;
}

int main() {
  cin >> n;
  rep(i, n)rep(j, 10) cin >> F[i][j];
  rep(i, n)rep(j, 11) cin >> P[i][j];
  int ans = -1e9;
  for (int i = 1; i < (1 << 10); ++i) {
    ans = max(ans, solve(i));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
using namespace std;
const int N=5005;
int n,k,P,x[N],f[N];
int main(){
	scanf("%d%d",&n,&P);
	rep(i,2,n/2+1)x[i]=i-1;
	rep(i,n/2+2,n)x[i]=n-i+2;
	f[0]=1;
	rep(i,2,n)rep(j,x[i],n)(f[j]+=f[j-x[i]])%=P;
	rep(i,0,n-1)(k+=1LL*(n-i)*f[i]%P)%=P;
	printf("%d\n",k);
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        char temp = s[i] - 'A';
        int nextn = (temp + n)%26;
        char ans = 'A' + nextn;
        cout << ans;        
    }       
}

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


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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

#define rep0(i, n) for (i = 0; i < n; i++)
#define rep(s, i, n) for (i = s; i < n; i++)
using namespace std;

long long N;
long long ans = 0;

int main()
{
    int i, j;
    cin >> N;

    rep(1, i, 1 + N)
    {
        ans += (2 * i + ((N / i) - 1) * i) * (N / i) / 2;
    }

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

Measured memory_bytes: 3636
import math
from collections import defaultdict
ml=lambda:map(float,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())

"""========main code==============="""

a,b,c=ml()
if(a+b+c>=22):
    print("bust")
else:
    print("win")

Measured memory_bytes: 38384
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimize("02")
using namespace std;
const int maxn=1e5+5;
long long n,m,x; 

int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin>>n>>m;
	cout<<(n*(n-1)/2)+(m*(m-1)/2);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;
typedef int Weight;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
// ツ経ツ路ツつ「ツづァツづ按つ「ツづつォ
const int M = 20;
Weight best[1<<M][M];

Weight shortestHamiltonPath(Matrix w, int s) {
  int n = w.size();
  int N = 1 << n;
  REP(S,N) REP(i,n) best[S][i] = INF;
  best[1<<s][s] = 0;
  REP(S,N) REP(k,n) REP(i,n) if (S&(1<<i))
    REP(j,n)
      best[S|(1<<j)][j] = min(best[S|(1<<j)][j], best[S][i] + w[i][j]);
  Weight res = INF;
  REP(i, n) {
    res = min(res, best[N-1][i] + w[i][s]);
  }
  return res;
}

int main() {
  int n;
  while(cin>>n,n) {
    map<string, int> mp[n];
    map<string, int> mi;
    REP(i, n) {
      int k;
      cin >> k;
      REP(j, k) {
        string s; int v;
        cin >> s >> v;
        mp[i][s] = v;
        if (mi.count(s) == 0) mi[s] = v;
        else if (mi[s] > v) mi[s] = v;
      }
    }
    int q;cin >> q;
    int mask[n];
    memset(mask, 0, sizeof(mask));
    int ans1 = 0;
    bool dame = 0;
    REP(i, q) {
      string s;
      cin >> s;
      if (mi.count(s) == 0) {
        dame = 1;
        continue;
      }
      ans1 += mi[s];
      REP(j, n) {
        if (mp[j][s] == mi[s]) mask[j] |= 1<<i;
      }
    }
    int m;
    cin >> m;
    Matrix g(n+1, Array(n+1, INF));
    REP(i, m) {
      int s, t, d;
      cin >> s >> t >> d;
      g[s][t] = d;
      g[t][s] = d;
    }
    
    if (dame) {
      cout << "impossible" << endl;
      continue;
    }
    // REP(i, n+1) {
    //   REP(j, n+1) {
    //     cout << g[i][j] << " ";
    //   }
    //   cout << endl;
    // }cout << endl;
    int res = INF;
    REP(S, 1<<n) {
      int buy = 0;
      int num = 0;
      REP(i, n) {
        if (S>>i&1) {
          buy |= mask[i];
          num++;
        }
      }
      if (buy != (1<<q)-1) continue;
      Matrix sub(num+1, Array(num+1, INF));
      int y = 0;
      REP(i, n) {
        if (!(S>>i&1)) continue;
        sub[y+1][0] = g[i+1][0];
        sub[0][y+1] = g[0][i+1];
        int x = 0;
        REP(j, n) {
          if (!(S>>j&1)) continue;
          sub[y+1][x+1] = g[i+1][j+1];
          x++;
        }
        y++;
      }
      
      // REP(i, num+1) {
      //   REP(j, num+1) {
      //     cout << sub[i][j] << " ";
      //   }
      //   cout << endl;
      // }cout << endl;
      res = min(res, shortestHamiltonPath(sub, 0));
    }
    if (res == INF) {
      cout << "impossible" << endl;
    } else {
      cout << ans1 << " " << res << endl;
    }
  }
}

Measured memory_bytes: 1100
import sys 
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

N,M=map(int,input().split())
g = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)

F = [-1 for _ in range(N)]
def dfs(s,f):
    global F
    global g
    F[s] = f
    for d in g[s]:
        if  F[d] == -1:
            if f == 1:
                if not dfs(d,0):
                    return False
            else:
                if not dfs(d,1):
                    return False
        else:
            if F[d] == f:
                return False
    return True

if dfs(0,0):
    f1 = F.count(1)
    f0 = F.count(0)
    print(f1*f0-M)
else:
    print(N*(N-1)//2 - M)


Measured memory_bytes: 31196
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto X = aryread();
    long ans = long.max;
    foreach (x; 1 .. 100 + 1)
    {
        long s;
        foreach (i; 0 .. N)
        {
            s += (X[i] - x) ^^ 2;
        }
        ans = ans.min(s);
    }
    writeln(ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<fstream>
using namespace std;
string s;
int dp[(1<<26)+1];
long long now=0;
int main(){
	cin>>s;
	memset(dp,63,sizeof(dp));
	dp[0]=0;
	for(int i=0;i<=s.length()-1;i++){
		now^=(1<<(s[i]-'a'));
		for(int j=0;j<=25;j++){
			if((now^(1<<j))!=now){
				dp[now]=min(dp[now],dp[now^(1<<j)]+1);
			}
		}
	}
	cout<<max(1,dp[now])<<endl;
	return 0;
}
/*

in:
abcabcxabcx

out:
3

*/

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

int main()
{
    int N,K;
    cin >> N>>K;

    vector<int> vec(N);

    for (int i = 0; i < K; i++) {
        int d;
        cin >> d;
        int A;
        for (int j = 0; j < d;j++) {
            cin >> A;
            vec.at(A - 1) = vec.at(A - 1) + 1;
        }
    }

    int count = 0;
    for (int i = 0; i < N;i++) {
        if (vec.at(i)==0) {
            count = count + 1;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 3628
// AOJ 0310: Frame
// 2017.11.14 bal4u@uu

#include <stdio.h>

#define MAX 302

int map[MAX][MAX];
int sr[MAX][MAX], sc[MAX][MAX];

char buf[2000], *p;
int getint()
{
	int n = 0;
	if (*p == '-') {
		p++; while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
		return -n;
	}
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, r, c, s, i, ans;

	fgets(p=buf, 10, stdin), n = getint();
	for (r = 0; r < n; r++) {
		fgets(p=buf, 2000, stdin);
		for (c = 0; c < n; c++) map[r][c] = getint(), p++;
	}
	for (r = 0; r < n; r++) {
		sr[r][0] = 0, sc[r][0] = 0;
		for (c = 1; c <= n; c++) {
			sr[r][c] = sr[r][c-1] + map[r][c-1];
			sc[r][c] = sc[r][c-1] + map[c-1][r];
		}
	}
	ans = 0;
	for (r = 0; r < n; r++) for (c = r; c < n; c++) {
		if (sr[r][c+1] - sr[r][r] > ans) ans = sr[r][c+1]-sr[r][r];
		if (c == r) continue;
		s = sc[0][c+1] - sc[0][r];
		for (i = 1; i < n; i++) {
			int u, v;
			u = v = sc[i][c+1] - sc[i][r];
			if (s > 0) u += s;
			if (u > ans) ans = u;
			if (s + map[r][i] + map[c][i] < v) s = v;
			else s += map[r][i] + map[c][i];
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2832