akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    string S;
    cin >> S;
    int ans = 1000;
    rep(i, 0, S.length() - 2)
    {
        string s;
        rep(j, 0, 3)
        {
            s += S[i + j];
        }
        int num = atoi(s.c_str());
        chmin(ans, abs(753 - num));
    }
    cout << ans << endl;
}


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

    #define      pb    push_back
    #define      ff    first
    #define      ss    second
    #define      ll    long long int
    #define      endl  "\n"
    #define      FASTIO        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


    #define      TEST    int t ; cin >> t ; while( t -- )

    const ll big = 10e7 + 11 ;
    const double PI  =3.141592653589793238463;

    int  main (  ) {

        FASTIO ;

        double n ;
        cin >> n ;

        double ans = 2.0 * PI * n ;

        cout << setprecision( 10 ) << fixed << ans ;

        return  0 ;
    }


Measured memory_bytes: 3780
#include<cstdio>

int main(int argc, char const *argv[])
{
    int H, W;
    while(1){
        scanf("%d %d", &H, &W);
        if(H==0 && W==0) break;

        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                printf("#");
            }
            printf("\n");
        }
        
        printf("\n");
    }

    return 0;
}



Measured memory_bytes: 2536
#include <bits/stdc++.h>
using namespace std;
string S;
int Sn=0;
int main(){
  cin >> S;
  for(int i=0;i<S.size();i++){
    Sn+=S[i]-'0';
  }
  if(stoi(S)%Sn==0){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

using namespace std;
using ll = long long;

void Main() {
	int N; cin >> N;
	vector<int> Ls(N);
	REP(i,N) cin >> Ls[i];
	sort(Ls.begin(), Ls.end());
	int res = 0;
	REP(i,N) {
		for (int j = i + 1; j < N; ++j) {
			int idx = lower_bound(Ls.begin(), Ls.end(), Ls[i] + Ls[j]) - Ls.begin();
			for (int k = j + 1; k < idx; ++k) {
				if (Ls[j] < Ls[i] + Ls[k] && Ls[i] < Ls[j] + Ls[k]) {
					++res;
				}
			}
		}
	}
	cout << res << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include <stdio.h>

int f[44];
int fibo(int n){
  int i;
  f[0]=1;
  f[1]=1;
  if(n>1)
    for(i=2;i<=n;i++) f[i]=f[i-2]+f[i-1];
  return f[n];
}
int main(int argc, char const *argv[]) {
  int n;
  scanf("%d",&n);
  printf("%d\n",fibo(n));
  return 0;
}

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

#define fs first
#define se second
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int main() {
	int a, b;
	char c;

	cin >> a >> c >> b;
	cout << (c == '+' ? a + b : a - b) << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD ((int)(1e9+7))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double

int ans=0,c=0;

int32_t main()
{
	IOS
	int n;cin>>n;
	vector<int>H(n+10),dp(n+10,1e15);
	for(int i=1;i<=n;i++)cin>>H[i];
	dp[1]=0;
	for(int i=1;i<=n;i++)
	{
		dp[i+1]=min(dp[i+1],dp[i]+abs(H[i]-H[i+1]));
		dp[i+2]=min(dp[i+2],dp[i]+abs(H[i]-H[i+2]));
	}
	cout<<dp[n]<<endl;
		
}
			
	
	
	
	
	

	

	

	
		


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define INF 1000000000
using namespace std;
int dp(int i,int bits);
int n,m;
vector<int>vec[100009];
int p[1009];

int main(){
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int k;
    cin>>k;
    for(int j=0;j<k;j++){
      int s;
      cin>>s;
      vec[i].push_back(s);
    }
  }
  for(int i=0;i<m;i++){
    cin>>p[i];
  }
  cout<<dp(0,0)<<endl;
  return(0);
}

int dp(int i,int bits){
  int rec=0;
  if(i==n){
    int t=0;
    for(int j=0;j<m;j++){
      int cnt=0;
      for(int k=0;k<vec[j].size();k++){
	cnt+=(bits>>(vec[j][k]-1))&1;
      }
      if(cnt%2==p[j])t++;
    }
    if(t==m)return 1;
    else return 0;
  }
  rec+=dp(i+1,bits);
  rec+=dp(i+1,bits|(1<<i));
  return rec;
}


Measured memory_bytes: 2560
#include<iostream>
using namespace std;
const int INF=2000000000;
const int SIZE=100000;

int L[SIZE/2+2][2],R[SIZE/2+2][2];

void merge(int A[][2],int left,int mid,int right)
{
	int n1=mid-left;
	int n2=right-mid;
	int i,j;
	for(i=0;i<n1;i++)
	{
		L[i][0]=A[left+i][0];
		L[i][1]=A[left+i][1];
	}
	for(i=0;i<n2;i++)
	{
		R[i][0]=A[mid+i][0];
		R[i][1]=A[mid+i][1];
	}
	L[n1][0]=R[n2][0]=INF;
	i=j=0;
	for(int k=left;k<right;k++)
	{
		if(L[i][0]<=R[j][0])
		{
			A[k][0]=L[i][0];
			A[k][1]=L[i++][1];
		}
		else
		{
			A[k][0]=R[j][0];
			A[k][1]=R[j++][1];
		}
	}
}

void mergesort(int A[][2],int left,int right)
{
	if(left+1<right)
	{
		int mid=(left+right)/2;
		mergesort(A,left,mid);
		mergesort(A,mid,right);
		merge(A,left,mid,right);
	}
}
int partition(int A[][2],int p,int r)
{
	int x=A[r][0];
	int i=p-1;
	int sto;
	for(int j=p;j<r;j++)
	{
		if(A[j][0]<=x)
		{
			sto=A[++i][0];
			A[i][0]=A[j][0];
			A[j][0]=sto;
			sto=A[i][1];
			A[i][1]=A[j][1];
			A[j][1]=sto;
		}
	}
	sto=A[++i][0];
	A[i][0]=A[r][0];
	A[r][0]=sto;
	sto=A[i][1];
	A[i][1]=A[r][1];
	A[r][1]=sto;
	return i;
}

void quicksort(int A[][2],int p,int r)//r is often n-1
{
	if(p<r)
	{
		int q=partition(A,p,r);
		quicksort(A,p,q-1);
		quicksort(A,q+1,r);
	}
	return;
}

int chai(char a)
{
	if(a=='S')return 0;
	else if(a=='H')return 1;
	else if(a=='C')return 2;
	else return 3;
}

char chac(int a)
{
	if(a==0)return 'S';
	else if(a==1)return 'H';
	else if(a==2)return 'C';
	else return 'D';
}

int main()
{
	int n;cin>>n;
	int A[SIZE][2],B[SIZE][2];
	int b;char c;
	for(int i=0;i<n;i++)
	{
		cin>>c>>b;
		A[i][0]=B[i][0]=b;
		A[i][1]=B[i][1]=chai(c);
	}
	
	mergesort(B,0,n);
	quicksort(A,0,n-1);
	
	bool flag=false;
	for(int i=0;i<n;i++)if(A[i][1]!=B[i][1]){flag=true;break;}
	
	if(flag)cout<<"Not stable"<<endl;
	else cout<<"Stable"<<endl;
	
	for(int i=0;i<n;i++)cout<<chac(A[i][1])<<" "<<A[i][0]<<endl;
	
	return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int n, k;
	vector<int> a(26);
	string p;
	cin >> n >> k;
	for(int i=0; i<n; i++){
		cin >> p;
		a[p[0]-'A']++;
	}
	int ans=0;
	while (true) {
		sort(a.rbegin(), a.rend());
		if (a[k-1] == 0) break;
		for (int i=0; i<k; i++) a[i]--;
		ans++;
	}
 
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
//#include <bits/stdc++.h>
using namespace std;
int main()
{
        int a,b,c;
        while(cin>>a>>b>>c)
        {
            int ans=b/a;
            if(ans>=c)
                cout<<c<<endl;
            else
                cout<<b/a<<endl;

        }
        return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
/*
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};
*/
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

//デバッグ
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};


ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}


//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

ll N;
bool a[22][22];
ll female[22][1<<22];

int main(){
  cin >> N;
  rep(i, N)rep(j, N) cin >> a[i][j];
  female[0][(1<<N)-1] = 1;
  rep(i, N){
    rep(j, N){
      if(a[i][j] == 0) continue;
      rep(k, 1<<N){
        if(female[i][k] == 0) continue;
        if((k>>j) & 1){
          female[i+1][k^(1<<j)] += female[i][k];
          female[i+1][k^(1<<j)] %= MOD;
        }
      }
    }
  }
  cout << female[N][0] << endl;
}


Measured memory_bytes: 327936
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  sort(ALL(a));
  cout << a[n-1]-a[0] << endl;
  return 0;
}

Measured memory_bytes: 256
import math
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
def ans(r):
  c = 0
  nn = list(range(1,n+1))
  for i in range(n):
    c += (nn.index(r[i])-1) * math.factorial(n-i-1)
    nn.remove(r[i])
  return c
print(abs(ans(p)-ans(q)))

Measured memory_bytes: 3064
def cc
    n = gets.chomp.to_i#.map{|x| x.to_i}
    m = gets.chomp.split(/\s/).map{|x| x.to_i}
    y = gets.chomp.split(/\s/).map{|x| x.to_i}

    cnt = 0
    for i in 1..n
        j = i - 1

        if m[j] >= y[j]
            cnt += y[j]
        else
            y[j] -= m[j]
            cnt += m[j]

            if y[j] > 0
                if m[i] >= y[j]
                    m[i] -= y[j]
                    cnt += y[j]
                else
                    cnt += m[i]
                    m[i] = 0
                end
            end
        end
    end

    puts cnt
end

cc

Measured memory_bytes: 17676
def read():
    N = int(input().strip())
    A = []
    X = []
    Y = []
    for i in range(N):
        
        a = int(input().strip())
        A.append(a)
        x = [-1 for i in range(a)]
        y = [-1 for i in range(a)]
        for i in range(a):
            x[i], y[i] = list(map(int, input().strip().split()))
            x[i] -= 1
        X.append(x)
        Y.append(y)
    return N, A, X, Y

def is_honest(ptn, x):
    return (ptn >> x) & 1

def count_honest(ptn, N):
    count = 0
    for i in range(N):
        if is_honest(ptn, i):
            count += 1
    return count

def check_ptn(ptn, N, A, X, Y):
    count = 0
    for i in range(N):
        if is_honest(ptn, i) == 1:
            for x, y in zip(X[i], Y[i]):
                if is_honest(ptn, x) != y:
                    return False
    return True


def solve(N, A, X, Y):
    ptns = 1 << N
    max_honest = 0
    for ptn in range(ptns):
        if check_ptn(ptn, N, A, X, Y):
            n_honest = count_honest(ptn, N)
            if n_honest > max_honest:
                max_honest = n_honest
    return max_honest

if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long a,v,b,w,t,j,k;
    cin>>a>>v>>b>>w>>t;
    j=fabs(a-b);
    if(a==b){
        cout<<"YES";
        return 0;
    }
    if(v<=w){
        cout<<"NO";
        return 0;
    }
    k=(v-w)*t;
    if(k>=j) cout<<"YES";
    else cout<<"NO";
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>

using namespace std;
int main() {
    int a, b = 0;
    string s;
    cin >> a;
    s = to_string(a);
    for(int i = 0; i < s.size(); i++) {
        int c = s[i] - '0';
        b += c;
    }
    if (a % b == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
 
#define pb push_back
#define nl puts ("")
#define sp printf ( " " )
#define phl printf ( "hello\n" )
#define ff first
#define ss second
#define POPCOUNT __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
#define MP make_pair
#define FOR(i,x,y) for(vlong i = (x) ; i <= (y) ; ++i)
#define ROF(i,x,y) for(vlong i = (y) ; i >= (x) ; --i)
#define CLR(x,y) memset(x,y,sizeof(x))
#define UNIQUE(V) (V).erase(unique((V).begin(),(V).end()),(V).end())
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1)
#define SQ(x) ((x)*(x))
#define ABS(x) ((x)<0?-(x):(x))
#define FABS(x) ((x)+eps<0?-(x):(x))
#define ALL(x) (x).begin(),(x).end()
#define LCM(x,y) (((x)/gcd((x),(y)))*(y))
#define SZ(x) ((vlong)(x).size())
#define NORM(x) if(x>=mod) x-=mod;if(x<0) x+=mod;
#define MOD(x,y) (((x)*(y))%mod)
#define ODD(x) (((x)&1)==0?(0):(1))
#define Set(N,cur) N=(N|(1LL<<cur))
#define Reset(N,cur) N=(N&(~(1LL<<cur)))
#define Check(N,cur) (!((N&(1LL<<cur))==0))
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define dump(x) cerr<<"~ "<<#x<<" = "<<x<<endl
//Imran addition
#define rep(i,n) for(int i = 1; i <= n; i++)
#define mem CLR
#define pf printf
#define sc scanf
#define endl "\n"
#define gi(k) scanf("%d",&k)
#define gl(k) scanf("%lld",&k)
#define NMAX 2147483647
#define LMAX 9223372036854775807LL
 
using namespace std;
 
 
#define LL long long
#define LLU long long unsigned int
typedef long long vlong;
typedef unsigned long long uvlong;
typedef pair < int, int > pii;
typedef pair < vlong, vlong > pll;
typedef vector<int> vi;
typedef vector<vlong> vl;
typedef vector<pll> vll;
 
inline vlong gcd ( vlong a, vlong b ) {
    a = ABS ( a ); b = ABS ( b );
    while ( b ) { a = a % b; swap ( a, b ); } return a;
}
 
 
const vlong inf = 2147383647;
const vlong mod = 1000000007;
const double pi = 2 * acos ( 0.0 );
const double eps = 1e-9;
 
#define N 100005

int amax,bmax,a[N],b[N];
pii ar[N],br[N]; 
 
int main () {
 
 	#ifdef forthright48
    freopen ( "00_input.txt", "r", stdin ); //freopen ( "00_output.txt", "w", stdout );
 	#endif
 
	int n,x,ans;
    cin >> n;

    rep(i,n) {
        gi(x);

        if(i & 1) {
            a[x]++;
        }

        else {
            b[x]++;
        }
    }

    rep(i,1e5) {
        ar[i] = MP(a[i],i);
        br[i] = MP(b[i],i);
    }

    int high = 1e5;

    sort(ar+1, ar+high+1);
    sort(br+1, br+high+1);

    amax = ar[high].ff;
    bmax = br[high].ff;

    if(ar[high].ss == br[high].ss) {
        
        if(ar[high].ff-ar[high-1].ff > br[high].ff-br[high-1].ff) {
            bmax = br[high-1].ff;
        }

        else {
            amax = ar[high-1].ff;
        }
    }


    n /= 2;

    ans = n-amax + n-bmax;

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

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG

using namespace std;
typedef long long ll;
typedef vector<ll> vel;
typedef vector<string> ves;
typedef vector<int> vei;
typedef vector<vector<ll>> vvel;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main() {
    ll n;cin>>n;
    vel a(n);
    ll ans=0;
    ll roop=0;
    for(ll i=0;i<n;i++) {
        cin>>a[i];
    }
   sort(a.begin(), a.end(), greater<ll>());
    if(n%2==1) {
        roop=n/2;
    ans+=a[0];
    REP(i,1,roop) {
        ans+=(a[i])*2;
    }
    ans+=a[roop];
    }
    else {
        roop=n/2;
        ans+=a[0];
        REP(i,1,roop) {
            ans+=(a[i])*2;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

struct UnionFind {
    vector<int> data;

    UnionFind(int sz) { data.assign(sz, -1); }

    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return (false);
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    int find(int k) {
        if (data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }

    int size(int k) { return (-data[find(k)]); }

    bool same(int x, int y) { return find(x) == find(y); }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    int n, k, l;
    cin >> n >> k >> l;
    UnionFind uf1(n), uf2(n);
    for (i = 0; i < k; i++) {
        int p, q;
        cin >> p >> q;
        p--;
        q--;
        uf1.unite(p, q);
    }
    for (i = 0; i < l; i++) {
        int p, q;
        cin >> p >> q;
        p--;
        q--;
        uf2.unite(p, q);
    }
    map<P, ll> m;
    for (i = 0; i < n; i++) {
        m[P(uf1.find(i), uf2.find(i))]++;
    }
    for (i = 0; i < n; i++) {
        cout << m[P(uf1.find(i), uf2.find(i))] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 16024
S = input()

if S == 'SUN':
  ans=7
elif S == 'MON':
  ans = 6
elif S == 'TUE':
  ans = 5
elif S == 'WED':
  ans = 4
elif S == 'THU':
  ans = 3
elif S == 'FRI':
  ans = 2
elif S == 'SAT':
  ans = 1
  
print(ans)

Measured memory_bytes: 38384
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int a=sc.nextInt(),b=sc.nextInt();
    if(a+b>=10){
      System.out.println("error");
    }else{
      System.out.println(a+b);
    }
  }
}


Measured memory_bytes: 22736
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
 
int main(){
  long long a,b,v,w,t;
  cin >> a >> v >> b >> w >> t ;
  long long c;

  c = b - a;
  if(c < 0){
    c = c * -1;
  }
  if(b < 0){
    b = b * -1;
  }
  c = c + t * w ;
  if(t * v >= c){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }






  
 
 
  }

Measured memory_bytes: 3636
// #includes {{{
#ifdef MY_DEBUG
#include "header/header.hpp"
#else
#include <bits/stdc++.h>
#endif

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

template<class T>
constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity():(numeric_limits<T>::max()/2);

int __inf_ignore(){
	int t = inf<int>;
	return t;
}

typedef pair<int,int> pii;

#ifdef MY_DEBUG
#include"print.hpp"
#include"debug.hpp"
#endif
// }}}

//{{{ gcd and inverse
#define __GCD_H
Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
}
// a x + b y = gcd(a, b)
Int extgcd(Int a, Int b, Int &x, Int &y) {
	Int g = a; x = 1; y = 0;
	if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
	return g;
}
Int invMod(Int a, Int m) {
	Int x, y;
	if (extgcd(a, m, x, y) == 1) return (x + m) % m;
	else                         return 0; // unsolvable
}
//}}}

Int A;
Int B;
Int C;
Int D;

void solve(){
	A--;
	Int S = 0;
	S += B/C - A/C;
	S += B/D - A/D;
	Int E = C*D/gcd(C,D);
	S -= B/E - A/E;
	S = B - A - S;
	cout<<S<<endl;
}

//{{{ main fucnction
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> A;
    cin >> B;
    cin >> C;
    cin >> D;
	solve();
	return 0;
}

//}}}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include <vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

int main() {
	string S, T;
	cin >> S >> T;

	int a[26] = { 0 }, b[26] = { 0 };
	REP(i, S.length()) {
		a[S[i] - 97]++;
		b[T[i] - 97]++;
	}

	sort(a, a + 26);
	sort(b, b + 26);
	bool f = true;
	REP(i, 26) {
		if (a[i] != b[i]) {
			f = false;
			break;
		}
	}

	if (f) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 776
N = int(input())
F = [list(input().split()) for i in range(N)]
P = [list(map(int,input().split())) for i in range(N)]
F2 = [int("".join(F[i]), 2) for i in range(N)]

ans = - 10**10

def cost(i) :
    tem = 0
    for j in range(N) :
        d = bin(i & F2[j]).count("1")
        tem += P[j][d]
    return tem

for i in range(1, 2**10) :
    ans = max(ans, cost(i))

print(ans)


Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n,m;
    cin >> n >> m;
    if(n == m)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a_list = list(map(int, input().split()))
total_m = sum(a_list)
r_list = []
for a in a_list:
	if a < total_m/(4*m):
		continue
	r_list.append(a)
r = 'No' if len(r_list) < m else 'Yes'
print(r)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair < int,int > PII;
typedef pair < ll,ll > PLL;
#define pb push_back
//#all(x) (x).begin(),(x).end()

//int const N = 1;
int const MOD = 1e9 + 7;

ll bigmod(ll a, ll b)
{
    if(b==0)
        return 1 % MOD;
    ll x = bigmod(a,b/2);
    x = (x * x) % MOD;
    if(b%2)
        x = (x * a) % MOD;
    return x;
}

int const N = 1e5 + 10;

ll n;// h[N];
ll dp[N][4] ;
ll ara[N][5] ;



int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //memset(dp,-1,sizeof dp);
    cin >> n;
    for(int i = 1; i <= n; i++)
    for(int j = 0; j < 3; j++)
        cin >> ara[i][j] ;

    for(int i = 0; i < 3; i++) dp[0][i] = 0;

    for(int i = 1; i <= n; i++)
    {
        for(int k = 0; k < 3; k++)
        {

            for(int kk = 0; kk < 3; kk++)
            {
                if(kk != k)
                    dp[i][k] = max(dp[i][k],dp[i-1][kk]);
            }
            dp[i][k] += ara[i][k] ;
        }
    }
    cout << *max_element(dp[n], dp[n] + 3) << '\n';
    return 0;
}




Measured memory_bytes: 7296
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=110,mod=1e9+7;
inline int Pow(int x,int y) { int res=1; for(;y;y>>=1,x=x*(ll)x%mod) if(y&1) res=res*(ll)x%mod; return res; }
int f[N][N][2],vis[N][N],h[N],minv[N][N],n;
void sol(int l,int r) {
	if(vis[l][r]) return;
	vis[l][r]=1;
	minv[l][r]=1e9;
	for(int i=l;i<=r;++i) minv[l][r]=min(minv[l][r],h[i]);
	int lst=l-1,tot=0;
	f[l][r][0]=f[l][r][1]=1;
	for(int i=l;i<=r+1;++i) if(h[i]==minv[l][r]||i==r+1) {
		int L=lst+1,R=i-1; lst=i;
		if(L<=R) {
			sol(L,R);
			f[l][r][0]=f[l][r][0]*(ll)f[L][R][0]%mod*Pow(2,minv[L][R]-minv[l][r]-1)%mod;
			f[l][r][1]=f[l][r][1]*(ll)(f[L][R][0]*(ll)Pow(2,minv[L][R]-minv[l][r])%mod+f[L][R][1])%mod;
			tot+=R-L+1;
		}
	}
	f[l][r][0]=f[l][r][0]*2ll%mod;
	f[l][r][1]=(f[l][r][1]*(ll)Pow(2,r-l+1-tot)%mod-f[l][r][0])%mod;
}		
	
int main() {
	rd(n);
	for(int i=1;i<=n;++i) rd(h[i]);
	sol(1,n);
	int ans=(f[1][n][0]*(ll)Pow(2,minv[1][n]-1)%mod+f[1][n][1])%mod;
	printf("%d",(ans+mod)%mod);
	return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, k, a[200000];

template<typename T> class SegTree {
private:
	T * a = NULL;
	int M, S;
	T (*F)(T, T);
	T I;

public:
	// [0, size) が使用可能になる、func が演算、id は単位元
	void init(int size, T (*func)(T, T), T id) {
		assert(size > 0);
		M = size;
		F = func;
		I = id;
		S = 1;
		while(S < size) { S *= 2; }
		delete[] a;
		a = new T[S * 2];
		inc(i, S * 2) { a[i] = I; }
	}
	
	// 参照（値を変更した後は calc() を呼ぶこと）
	T & operator[](int p) {
		assert(inID(p, 0, M));
		p += S;
		return a[p];
	}
	
	// テーブルの再計算
	void calc() {
		decID(i, 1, S) {
			a[i] = F(a[i * 2], a[i * 2 + 1]);
		}
	}
	
	// a[p] を v に変更し再計算
	void update(int p, T v) {
		assert(inID(p, 0, M));
		p += S;
		a[p] = v;
		while(p != 1) {
			p /= 2;
			a[p] = F(a[p * 2], a[p * 2 + 1]);
		}
	}
	
	// [l, r) に f を適用した結果を返す
	T range(int l, int r) {
		assert(inID(l, 0, M));
		assert(inII(r, 0, M));
		assert(l <= r);
		l += S;
		r += S;
		
		T v = I, w = I;
		while(l < r) {
			if(l + 1 == r) { v = F(v, a[l]); break; }
			
			if(l % 2 == 1) { v = F(v, a[l]); }
			if(r % 2 == 1) { w = F(a[r - 1], w); }
			
			l = (l + 1) / 2;
			r = r / 2;
		}
		
		return F(v, w);
	}
};

template<typename T> T add(T x, T y) { return x + y; }

int main() {
	cin >> n >> k;
	inc(i, n) { cin >> a[i]; }
	
	vector<pair<LL, int>> vp;
	LL sum = 0;
	vp.EB(sum, 0);
	inc(i, n) {
		sum += a[i] - k;
		vp.EB(sum, i + 1);
	}
	sort(ALL(vp));
	
	LL ans = 0;
	SegTree<int> st;
	st.init(n + 1, add, 0);
	inc(i, vp.size()) {
		ans += st.range(0, vp[i].SE);
		st.update(vp[i].SE, 1);
	}
	
	cout << ans << endl;
	
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(2e5) + 5;
#define REP(i, n) for (int i = 0; i < n; i++)

ull n, x, cum[MAX_N]{};

int main() {
    cin >> n >> x;
    ull a;
    REP(i,n){
        cin >> a;
        cum[i+1] += cum[i]+a;
    }
    ull ans = LLINF;
    for(ull i=1;i<=n;i++){
        ull tmp = 5*cum[n], k = n-i;
        while(1){
            if(k<=i)break;
            k -= i;
            tmp += 2*cum[k];
        }
        tmp += (n+i)*x;
        ans = min(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
ai = lambda: list(map(int,input().split()))
ai_ = lambda: [int(x)-1 for x in input().split()]

n = int(input())

path = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = ai_()
    path[a].append(b)
    path[b].append(a)

from collections import deque
q = deque()
q.append(0)

d1 = [float('inf') for _ in range(n)]
d1[0] = 0
w = set()
while q:
    v = q.popleft()
    w.add(v)
    for vv in path[v]:
        if vv not in w:
            d1[vv] = d1[v] + 1
            q.append(vv)


q = deque()
q.append(n-1)

dn = [float('inf') for _ in range(n)]
dn[n-1] = 0
w = set()
while q:
    v = q.popleft()
    w.add(v)
    for vv in path[v]:
        if vv not in w:
            dn[vv] = dn[v] + 1
            q.append(vv)


d = [1 if d1[v] <= dn[v] else -1 for v in range(n)]

if sum(d) > 0:
    print('Fennec')
else:
    print('Snuke')


Measured memory_bytes: 38444
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
using ll = long long;

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

    int N;
    string S;
    cin >> N >> S;
    int ans = 1;
    for (int i=0; i<N-1; i++) {
        char ch1 = S[i];
        char ch2 = S[i+1];
        if (ch1 != ch2){
            ans += 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int N, M; cin >> N >> M; 
	long long dp[310][310][310] = {}; // i日目，初訪問順に番号をつけたとき，0に戻れるのがjまでで最大kまで進んでいる
	long long mod = 1000000007; 
	dp[0][0][0] = 1; 
	for(int i = 0; i < M; i++){
		for(int j = 0; j <= min(i, N-1); j++){
			for(int k = j; k <= min(i, N-1); k++){
				dp[i+1][j][k] += dp[i][j][k] * (k - j) % mod; 
				dp[i+1][j][k] %= mod; 
				dp[i+1][k][k] += dp[i][j][k] * (j + 1) % mod; 
				dp[i+1][k][k] %= mod;
				dp[i+1][j][k+1] += dp[i][j][k] * (N - k - 1) % mod; 
				dp[i+1][j][k+1] %= mod; 
			}
		}
	}
	cout << dp[M][N-1][N-1] << "\n"; 
}

Measured memory_bytes: 236352
import java.util.Scanner;

public class Main
{
  public static void main(String[] args)
  {
    try (Scanner scanner = new Scanner(System.in))
    {
      while (scanner.hasNextLine())
      {
        int f = Integer.valueOf(scanner.nextLine());
        System.out.println(solver(f));
      }
    }
  }

  private static int solver(int f)
  {
    return (f - 30) / 2;
  }
}



Measured memory_bytes: 26132
package main

import "fmt"

func main() {
	a := make([][][]int, 4)
	for i := 0; i < 4; i++ {
		a[i] = make([][]int, 3)
		for j := 0; j < 3; j++ {
			a[i][j] = make([]int, 10)
		}
	}

	var n int
	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		var b, f, r, v int
		fmt.Scan(&b, &f, &r, &v)

		a[b-1][f-1][r-1] += v
	}

	for i := 0; i < 4; i++ {
		for j := 0; j < 3; j++ {
			for k := 0; k < 10; k++ {
				fmt.Printf(" %d", a[i][j][k])
			}
			fmt.Println()
		}
		if i < 3 {
			fmt.Println("####################")
		}
	}
}



Measured memory_bytes: 1132
import sys
def solve():
    N = int(input())
    moveN = 10000000000000000000
    for i in range(1, N + 1):
        if i ** 2 > N: break
        if N % i == 0:
            moveN = min(i + (N // i) - 2, moveN)
    print(moveN)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
vector<vector<int> > d; 
ll power(ll a,int n){
  if(n==0)
    return 1;
  if((n%2)==0)
    return (power((a*a)%mod,n/2))%mod;
  else
    return (a*(power((a*a)%mod,n/2))%mod)%mod;    
}
double sqrt1(double a){
    double l=0;
    double h=a;
    double m;
    double ans;
    while((h-l)>=1e-8){
       m=(h+l)/2;
       if((m*m)<a){
             ans=m;
             l=m;
       }
       else if(m*m==a){
             ans=m;
             break;
       }
       else{
          h=m;
       }
    }
    return ans;
}
int main(){
FASTIO
ll n,a,b;
cin>>n>>a>>b;
ll ans=(n/(a+b))*a;
ll c=n%(a+b);
ans+=(min(c,a));
cout<<ans;
return 0;
}

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

int main() {
   int x1, y1, x2, y2;
   cin >> x1 >> y1 >> x2 >> y2;
   int x3, y3, x4, y4;

   x3 = x2 - (y2 - y1);
   y3 = y2 + (x2 - x1);

   x4 = x1 - (y2 - y1);
   y4 = y1 + (x2 - x1);

   
   cout << x3 << " " << y3 << " " <<  x4 << " " << y4 << endl;
   return 0;
}


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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで降順
#define pb push_back
#define fst first
#define snd second
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>T add(const T &a, const T &b){return (a+b)%mod;}

signed main(){
  string s; cin >> s;
  vvi dp(s.size(),vi(s.size()+1,0));
  rep(i,s.size()) dp[i][0] = 1;
  FOR(w,1,s.size()+1){ // 幅
    dump(w);
    if(w % 3 != 0) continue;
    
    rep(l,s.size()-w+1){
      dump(l);
      if(s[l] != 'm' or s[l+w-1] != 'w') continue;
      for(int xw = 0; xw != w; xw += 3){ // xw:Xの幅
	if(s[l+xw+1] != 'e') continue;
	if(dp[l+1][xw] == 1 and dp[l+xw+2][w-3-xw] == 1){
	  dp[l][w] = 1;
	  break;
	}
      }
    }
  }
  if(dp[0][s.size()]) cout << "Cat\n";
  else cout << "Rabbit\n";
}


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

int flag_num(int N)
{
    int flag_num = 0;
    for (int i=0; i<=log2(N); i++)
    {
        if (N & (1<<i)) flag_num++;
    }
    return flag_num;
}

int check(int who, int fact)
{
    if (fact & (1<<who)) return 1;
    else return 0;
}

int main()
{
    // 入力受け取り
    int N;
    cin >> N;
    vector<vector<int>> statements(N, vector<int>(N, -1));
    for (int i=0; i<N; i++)
    {
        int A;
        cin >> A;
        statements[i].resize(A);
        for (int j=0; j<A; j++)
        {
            int x, y;
            cin >> x >> y;
            statements[i][x-1] = y;
        }
    }
    
    // 正直者の組み合わせについて全探索．
    int honest_maxnum = 0;
    for (int i=0; i<(1<<N); i++)
    {
        int honest_num = flag_num(i);
        bool possible = true;
        for (int j=0; j<N; j++)
        {
            if (check(j, i))
            {
                for (int k=0; k<N; k++)
                {
                    if (statements[j][k]!=-1) possible = (statements[j][k]==check(k, i));
                    if (!possible) break;
                }
            }
            if (!possible) break;
        }
        if (possible)
        {
            honest_maxnum = max(honest_maxnum, honest_num);
        }
    }
    cout << honest_maxnum << endl;

}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<iostream>
typedef long long ll;
char a[2000010];
ll cnt[26];
int main(){
	scanf("%s",a);
	ll len=strlen(a),ans=len*(len-1)/2ll+1ll;
	for(int i=0;i<len;i++)cnt[a[i]-'a']++;
	for(int i=0;i<26;i++)ans-=cnt[i]*(cnt[i]-1ll)/2ll;
	std::cout<<ans<<std::endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
int a[100005];
void solve(){
    int x; 
    cin>>x; 
    ll a = x/500;
    x%=500;
    ll b = x/5;
    ll z = a*1000+b*5;
    cout<<z<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1;
//	cin>> t;
	while(t--)solve();
	return 0;
}


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

int main(){

  int N;
  cin>>N;
  int A[16],x[16][16],y[16][16];
  int hone[16];
  for(int i=0;i<N;i++){
    cin>>A[i];
    for(int j=0;j<A[i];j++){
      cin>>x[i][j]>>y[i][j];
    }
  }
  int all=pow(2,N);
  bool esc=0;
  int cnt=0;
  int MAX=0;
      int decll=all;

  
  for(int i=0;i<all;i++){
    decll--;
    esc=0;cnt=0;
    
    for(int j=0;j<N;j++){
     //         cout<<decll/(int)pow(2,N-j-1)<<endl;

      if((decll/(int)pow(2,N-j-1)) % 2==1){//jさんが正直
        hone[j]=1;
      }
      else if((decll/(int)pow(2,N-j-1)) % 2==0){
        hone[j]=0;
      }
    // cout<<hone[j]<<endl;
    }
    
    for(int j=0;j<N;j++){
      if(hone[j]==1){
      for(int k=0;k<A[j];k++){
        if(hone[x[j][k]-1]!=y[j][k])esc=1;
        if(esc)break;
      }
      if(esc)break;
    }

/*      if(hone[j]==0){
      for(int k=0;k<A[j];k++){
        if(hone[x[j][k]-1]==y[j][k])esc=1;
        if(esc)break;
      }
      if(esc)break;
    }*/
    }    
    if(esc)continue;
    else if(!esc){
      for(int j=0;j<N;j++){
        if(hone[j]==1)cnt++;
      }
    }
    MAX=max(MAX,cnt);
  }
  
  cout<<MAX<<endl;
  
  
}

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

int main(){
	unsigned int n,wait,sum,t;
	vector<unsigned int> milk;
	while(cin >> n && n){
		milk.clear();
		wait = sum = 0;
		for(int i=0;i<n;i++){
			cin >> t;
			milk.push_back(t);
		}
		sort(milk.begin(),milk.end());
		for(int i=0;i<n;i++){
			sum += wait;
			wait += milk[i];
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 0
from collections import deque
N,U,V = map(int, input().split())
U,V = U-1, V-1
E = [[] for _ in range(N)]

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

def BFS(root):
  D = [ 0 for _ in range(N) ]
  visited = [False for _ in range(N)]
  willSearch = [ False for _ in range(N)]
  Q = deque()
  Q.append(root)
  willSearch[root] = True
  while len(Q) > 0:
    now = Q.pop()
    visited[now] = True
    for nx in E[now]:
      if visited[nx] or willSearch[nx]:
        continue
      willSearch[nx] = True
      D[nx] = D[now] + 1
      Q.append(nx)
  return D

UD = BFS(U)
VD = BFS(V)

#print(UD)
#print(VD)

#初手で青木くんのPOINTにしか行けないケース
if E[U] == [V]:
  print(0)
  exit(0)
  
ans=0
 
for i in range(N):
    if UD[i]<=VD[i]:
        ans=max(ans,VD[i]-1)

print(ans)

Measured memory_bytes: 111984
from collections import deque

op = ['+', '-', '*', '/']

s = deque()

A = input().split(' ')
for a in A:
    if a not in op:
        s.append(int(a))
    elif a == '+':
        n1 = s.pop()
        n2 = s.pop()
        s.append(n2 + n1)
    elif a == '-':
        n1 = s.pop()
        n2 = s.pop()
        s.append(n2 - n1)
    elif a == '*':
        n1 = s.pop()
        n2 = s.pop()
        s.append(n2 * n1)
    elif a == '/':
        n1 = s.pop()
        n2 = s.pop()
        s.append(n2 / n1)
print(s.pop())



Measured memory_bytes: 6000
#include<bits/stdc++.h>
using namespace std;
const int MAXN=510;
int N,M,Q;
int DP[MAXN][MAXN];
int main()
{
	scanf("%d%d%d",&N,&M,&Q);
	while(M--)
	{
		int L,R;
		scanf("%d%d",&L,&R);
		++DP[L][R];
	}
	for(int LEN=1;LEN<=N;LEN++)
	{
		for(int I=1;I+LEN<=N;I++)
		{
			int J=I+LEN;
			DP[I][J]+=(DP[I+1][J]+DP[I][J-1]-DP[I+1][J-1]);
		}
	}
	while(Q--)
	{
		int p,q;
		scanf("%d%d",&p,&q);
		printf("%d\n",DP[p][q]);
	}
	return 0;
}

Measured memory_bytes: 1920
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        
        int d,r;
        double f = 0;

        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        d = a / b;
        r = a % b;
        f = (double)a / b;
        
        
        System.out.println(d + " " + r + " " + (String.format("%.5f",f)));
    }
}



Measured memory_bytes: 26480
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chkmax(T& a,T b){return a<b?a=b,1:0;}
template<class T> inline bool chkmin(T& a,T b){return a>b?a=b,1:0;}
template<typename T> inline T& read(T& x){
    static char c; bool flag=0;
    while(!isdigit(c=getchar())) if(c=='-') flag=1;
    for(x=c-'0';isdigit(c=getchar());(x*=10)+=c-'0');
    if(flag) x=-x;
    return x;
}
const int maxn=10010,maxm=2000010;
struct node{
    int w,pos,op;
    bool operator < (const node& rhs) const{
        return w<rhs.w;
    }
} p[maxn<<1];
int n,now;
int dfn[maxn<<1],low[maxn<<1],sccno[maxn<<1],cnt,cur;
int head[maxn<<1],nxt[maxm],to[maxm],e;
void ae(int x,int y){
    to[++e]=y; nxt[e]=head[x]; head[x]=e;
}
stack<int> stk;
void dfs(int u){
    dfn[u]=low[u]=++cur;
    stk.push(u);
    for(int i=head[u];i;i=nxt[i]){
        int v=to[i];
        if(!dfn[v]) dfs(v),chkmin(low[u],low[v]);
        else if(!sccno[v]) chkmin(low[u],dfn[v]);
    }
    if(dfn[u]==low[u]){
        ++cnt; int x;
        do{
            x=stk.top(); stk.pop();
            sccno[x]=cnt;
        } while(x!=u);
    }
}
void Tarjan(){
    cnt=cur=0;
    memset(sccno,0,sizeof sccno);
    memset(dfn,0,sizeof dfn);
    for(int i=2;i<=(n<<1|1);i++) if(!dfn[i]) dfs(i);
}
bool check(int dis){
    memset(head,0,sizeof head); e=0;
    for(int i=1;i<=n*2;i++)
        for(int j=i+1;j<=min(n*2,i+50);j++)
            if(p[j].w-p[i].w<dis){
                ae(p[i].pos<<1|p[i].op,p[j].pos<<1|(p[j].op^1));
                ae(p[j].pos<<1|p[j].op,p[i].pos<<1|(p[i].op^1));
            }
    Tarjan();
    for(int i=1;i<=n;i++) if(sccno[i<<1]==sccno[i<<1|1]) return 0;
    return 1;
}
int main(){
    read(n);
    int L=0,R=0;
    for(int i=1;i<=n;i++){
        chkmax(R,read(p[++now].w)); p[now].pos=i; p[now].op=0;
        chkmax(R,read(p[++now].w)); p[now].pos=i; p[now].op=1;
    }
    R=R/(n-1)+10;
    sort(p+1,p+now+1);
    while(L<R){
        int mid=(L+R+1)>>1;
        if(check(mid)) L=mid;
        else R=mid-1;
    }
    printf("%d\n",L);
    return 0;
}


Measured memory_bytes: 17408
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

int gcd(int x, int y) {
    if (x < 0) {
      return y;
    } else if (y < 0) {
      return x;
    }
  
	if (x < y) {
		swap(x, y);
    }

	/* ユークリッドの互除法 */
  	int r = x % y;
	while(r!=0){
    	x = y;
    	y = r;
   		r = x % y;
  	}

	return y;
}


int multi_gcd(vector<int> &ar, int n, int max) {
    //printf("multi_gcd: n:%d, max:%d\n", n, max);
  	int r = -1;
	for (int i=0; i<ar.size(); i++) {
        int y = ar[i];
        if (i==n) {
        	y = -1;
        }
        r = gcd(r, y);
      	if (max!=-1 && r < max) {
          return r;
        }
    }
  	return r;
}


int main(int argc, char* argv[]) {

  	int n;
  	cin >> n;

	vector<int> ar(n);
  	for (int i=0; i<n; i++) {
    	cin >> ar[i];
    }
	
  	vector<int> lr(n);
	for (int i=0; i<n; i++) {
      	if (i==0) {
        	lr[i] = ar[i];
        } else {
	    	lr[i] = gcd(lr[i-1], ar[i]);
        }
    }
  	
  	vector<int> rr(n);
  	for (int i=n-1; i>=0; i--) {
    	if (i==n-1) {
        	rr[i] = ar[i];
        } else {
        	rr[i] = gcd(rr[i+1], ar[i]);
        }
    }
 
  	
  	int max = -1;
  	for (int i=0; i<n; i++) {
      	int ret;
      	if (i==0) {
			ret = rr[i+1];
        } else if (i==n-1) {
          	ret = lr[i-1];
        } else {
	    	ret = gcd(lr[i-1], rr[i+1]);
        }
        
      	if (max < ret) {
          	max = ret;
        }
    }

  	cout << max << endl;
  	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
  char s[2000];
  cin >> s;
  int n=0,w=0;
  for(int i=0;i<strlen(s);i++){
	if(n==0&&s[i]=='N')n=1;
    if(n==1&&s[i]=='S')n=2;
    if(w==0&&s[i]=='W')w=1;
    if(w==1&&s[i]=='E')w=2;
  }
  if(n==2&&w==2){
    cout << "Yes";
    return 0;
  }
  n=0;
  w=0;
  for(int i=0;i<strlen(s);i++){
	if(n==0&&s[i]=='S')n=1;
    if(n==1&&s[i]=='N')n=2;
    if(w==0&&s[i]=='W')w=1;
    if(w==1&&s[i]=='E')w=2;
  }
  if(n==2&&w==2){
    cout << "Yes";
    return 0;
  }
  n=0;
  w=0;
  for(int i=0;i<strlen(s);i++){
	if(n==0&&s[i]=='S')n=1;
    if(n==1&&s[i]=='N')n=2;
    if(w==0&&s[i]=='E')w=1;
    if(w==1&&s[i]=='W')w=2;
  }
  if(n==2&&w==2){
    cout << "Yes";
    return 0;
  }
  n=0;
  w=0;
  for(int i=0;i<strlen(s);i++){
	if(n==0&&s[i]=='N')n=1;
    if(n==1&&s[i]=='S')n=2;
    if(w==0&&s[i]=='E')w=1;
    if(w==1&&s[i]=='W')w=2;
  }
  if(n==2&&w==2){
    cout << "Yes";
    return 0;
  }
  n=0;
  for(int i=0;i<strlen(s);i++){
	if(n==0&&s[i]=='N')n=1;
    if(n==1&&s[i]=='S')n=2;
    if(s[i]=='W'||s[i]=='E'){
      n=0;
      break;
    }
  }
  if(n==2){
    cout << "Yes";
    return 0;
  }
  n=0;
  for(int i=0;i<strlen(s);i++){
	if(n==0&&s[i]=='S')n=1;
    if(n==1&&s[i]=='N')n=2;
    if(s[i]=='W'||s[i]=='E'){
      n=0;
      break;
    }
  }
  if(n==2){
    cout << "Yes";
    return 0;
  }
  n=0;
  for(int i=0;i<strlen(s);i++){
	if(n==0&&s[i]=='W')n=1;
    if(n==1&&s[i]=='E')n=2;
    if(s[i]=='N'||s[i]=='S'){
      n=0;
      break;
    }
  }
  if(n==2){
    cout << "Yes";
    return 0;
  }
  n=0;
  for(int i=0;i<strlen(s);i++){
	if(n==0&&s[i]=='E')n=1;
    if(n==1&&s[i]=='W')n=2;
    if(s[i]=='N'||s[i]=='S'){
      n=0;
      break;
    }
  }
  if(n==2){
    cout << "Yes";
    return 0;
  }
  cout << "No";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int area = a * b;
		int length = 2 * (a + b);
		System.out.println(area + " " + length);
	}
}


Measured memory_bytes: 26400