akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] a = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            int count = 0;
            for(int i = 0; i<N;i++){
                if((i+1) %2 != 0 && a[i]%2 != 0){
                    count++;
                }
            }
            Console.WriteLine(count);
        }
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 27544
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> state;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }
int ceil(int a,int b){
  // a/bの切り上げを考える
  return (a+b-1)/b;
}



int main(){ 
  ll a,b,v,w,t;
  cin >> a >> v >> b >> w >> t;
  if(a < b)
    cout << ((b + w * t <= a + v * t)?"YES":"NO") << endl;
  else if(a > b)
        cout << ((b - w * t >= a - v * t)?"YES":"NO") << endl;
  else cout << "YES" << endl;
}



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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
#define A 0
#define T 1
#define G 2
#define C 3

vector<ll> pw2(51,1);
vector<ll> pw10(19,1);

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}
ll myceil(ll x,ll y){
	if(x<=y) return 1;
	else if(x%y==0) return x/y;
	else return x/y+1;
}

//a,b x
int main(){
	//A:0 T:1 G:2 C:3
	ll N; cin>>N;
	ll dp[101][4][4][4];
	rep1(n,N)rep(i,4)rep(j,4)rep(k,4) dp[n][i][j][k]=0;//全初期化
	rep(i,4)rep(j,4)rep(k,4) dp[3][i][j][k]=1;//3のみ
	//GAC,ACG,AGC
	dp[3][2][0][3]=0;
	dp[3][0][3][2]=0;
	dp[3][0][2][3]=0;

	for(int i=4;i<=N;i++)rep(a,4)rep(b,4)rep(c,4){
		if(a==A && c==G){
			rep(j,4) dp[i][b][c][j]=(dp[i][b][c][j]+dp[i-1][a][b][c])%MOD;
			dp[i][b][c][3]=0; //A?G'C'
		}
		else if(a==A && b==G){
			rep(j,4) dp[i][b][c][j]=(dp[i][b][c][j]+dp[i-1][a][b][c])%MOD;
			dp[i][b][c][3]=0; //AG?'C'
		}
		else if(b==G && c==A){
			rep(j,4) dp[i][b][c][j]=(dp[i][b][c][j]+dp[i-1][a][b][c])%MOD;
			dp[i][b][c][3]=0; //GA'C'
		}
		else if(b==A && c==G){
			rep(j,4) dp[i][b][c][j]=(dp[i][b][c][j]+dp[i-1][a][b][c])%MOD;
			dp[i][b][c][3]=0; //AG'C'
		}
		else if(b==A && c==C){
			rep(j,4) dp[i][b][c][j]=(dp[i][b][c][j]+dp[i-1][a][b][c])%MOD;
			dp[i][b][c][2]=0; //AC'G'
		}
		else rep(j,4) dp[i][b][c][j]=(dp[i][b][c][j]+dp[i-1][a][b][c])%MOD;
	}
	ll ans=0;
	rep(i,4)rep(j,4)rep(k,4) ans=(ans+dp[N][i][j][k])%MOD;	
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

ll k;

int main(){
    //input
    cin >> k;

    ll n;

    if(k<100){
        n=2;
    }
    else n=50;
    ll c = k/n;
    ll d = k%n;
    cout << n << endl;
    rep(i,d){
        cout << n-1+c+n-d+1 << ' ';
    }
    rep(i,n-d-1){
        cout << n-1+c-d << ' ';
    }
    cout << n-1+c-d << endl;


    return 0;
}



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

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define eps 1e-9
#define fast_cin ios_base::sync_with_stdio(false)

const int MOD = 1e9+7;

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

int main()
{
	//freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);
	fast_cin;
	int n; cin >> n;
	int cnt4 = 0,cnt2 = 0,cnt1 = 0;
	for (int i = 0; i < n; ++i)
	{
		ll a; cin >> a;
		if (a % 2)
		{
			cnt1++;		
		}
		
		else if (a % 4 == 0)
		{
			cnt4++;
		}
		else {
			cnt2++;
		}
	}
	if (cnt2 == 0)
	{
		if (cnt4 >= cnt1 - 1)
		{
			cout << "Yes";
		}
		else
			cout << "No";
	}
	else{
		if (cnt4 >= cnt1)
		{
			cout << "Yes";
		}
		else
			cout << "No";
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define INF ((int)1e9+5)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;

int MOD;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}
LL exp(int a, int b){
    LL res = 1;
    LL sum = a;
    while(b){
        if(b&1)res = (res * sum) % MOD;
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

int main(){
	int N, M;
	cin >> N >> M;
	map<int, LL> m;
	m[0]=1;
	LL ans = 0;
	LL sum = 0;
	REP(i, N){
		LL d;
		cin >> d;
		sum += d;
		ans += m[sum%M];
		++m[sum%M];
	}
	cout << ans << endl;
}


Measured memory_bytes: 4224
flag = 1
while True:
    a, b = map(int, input().split())
    if a == b == 0:
        quit()
    if flag == 0:
        print()
    else:
        flag = 0
    count = 0
    for i in range(a, b+1):
        if i % 400 == 0:
            print(i)
            count += 1
        elif i % 100 != 0 and i % 4 == 0:
            print(i)
            count += 1
    if count == 0:
        print('NA')


Measured memory_bytes: 5716
#include<stdio.h>

int main(void){
    char st[255];

    //キーボードから読み込み
    scanf("%c",st);

    if(st[0]=='A'){
        printf("T\n");
    }else if(st[0]=='C'){
        printf("G\n");
    }else if(st[0]=='G'){
        printf("C\n");
    }else if(st[0]=='T'){
        printf("A\n");
    }
    return 0;
}

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

const int N = 305;

int n, m, ans, dp[N][N], add[N][N];
string s[N];

int solve(int l, int r) {
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= n; j++) {
			add[i][j] = 0;
			dp[i][j] = 0;
		}
	for (int d = 0; d < n; d++) {
		for (int h = 1; h + d <= n; h++) 
			add[h][h + d] = add[h - 1][h + d - 1] + (s[h - 1][l] == s[h - 1 + d][r]);
		for (int h = d + 1; h <= n; h++) 
			add[h][h - d] = add[h - 1][h - d - 1] + (s[h - 1][l] == s[h - 1 - d][r]);
	}
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++) 
			dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + add[i][j];
	return dp[n][n];
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> s[i];
	for (int i = 0; i + 1 < m; i++)
		ans += solve(i, i + 1);
	cout << ans;
}


Measured memory_bytes: 4456
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
typedef pair<int,int>P;
 
int main() {
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  if(a>=k){
    cout<<k<<endl;
  }
  else if(a+b>=k){
    cout<<a<<endl;
  }
  else{
    cout<<a-k+a+b<<endl;
  }
}
  

Measured memory_bytes: 3520
n = int(input())
A = [*map(int, input().split())]
MOD = (10**9)+7
ans = 0

# print(A)

sum_a = [0] * (n+1)
for i in range(n):
    sum_a[i+1] = sum_a[i] + A[i]

# print(sum_a)

for i in range(n):
    ai = A[i]
    ans = (ans + ai*(sum_a[-1] - sum_a[i+1])) % MOD
    # print(sum_a[-1], sum_a[i+1],sum_a[-1] - sum_a[i+1] )

# for i in range(n):
#     for j in range(i+1, n):
#         ans = (ans + A[i]*A[j]%MOD) % MOD
ans = (ans + MOD) % MOD
print(ans)


Measured memory_bytes: 31388
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int n;
    cin >> n;
    vector<int> A(n);
    REP(i, n) {
        cin >> A[i];
    }
    bitset<2001> bs(1);
    REP(i, n) {
        bitset<2001> tmp = bs;
        REP(j, 2000) {
            if (bs[j] && j + A[i] <= 2000) {
                tmp[j + A[i]] = 1;
            }
        }
        bs = tmp;
    }
    int q;
    cin >> q;
    REP(_, q) {
        int m;
        cin >> m;
        string res = bs[m] ? "yes" : "no";
        cout << res << endl;
    }

    return 0;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;

    ll ans = 0;
    ll s = std::min(N, M / 2);
    ans += s;
    M -= s * 2;
    ans += M / 4;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = sorted(''.join(sorted(list(input()))) for i in range(N))
# N(10+log_2(10)+10)
ans = 0
sep = []
for i in range(N-1): # N*4
    if  S[i] != S[i+1]:
        sep.append(i+1)
sep.append(N)
# print(sep)
count = []
prev = 0
for i in sep: # len(set(N))*2 <= N*2
    count.append(i-prev)
    prev = i
# print(count)
for i in count: # N*2 (similarly)
    ans += i*(i-1)//2
print(ans)

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

using namespace std;

int main()
{
   int n,k;
   cin>>n>>k;
   vector<int>v(n+1);
   for(int i=0;i<k;i++){
      int d;
      cin>>d;
      for(int j=0;j<d;j++){
        int a;
        cin>>a;
        v[a]=d;
      }
   }
   int cnt=0;
   for(int i=1;i<=n;i++){
      if(!v[i])++cnt;
   }
   cout<<cnt<<endl;
}


Measured memory_bytes: 3628
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

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

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n;cin>>n;
    vector<ll>a(n);
    for(int i=0;i<n;i++)
    {cin>>a[i];a[i]--;}
    ll ans=0;
    for(int i=0;i<n;i++){
        if(a[a[i]]==i&&a[i]>i)
            ans++;
    }
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------









Measured memory_bytes: 1024
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n;
	cin>>n;
	int MA,MB;
	cin>>MA>>MB;
	vvint vv;
	initvv(vv, 500, 500, INF);
	vv[0][0] = 0;
	rep(i,n){
		int a,b,c;
		cin>>a>>b>>c;
		vvint next=vv;
		rep(i,500){
			rep(j,500){
				if(i-a>=0&&j-b>=0) mins(next[i][j], vv[i-a][j-b]+c);
			}
		}
		vv = next;
	}
	int ans = INF;
	rep(i,500){
		rep(j,500){
			if(vv[i][j] == INF) continue;
			if(i+j==0) continue;
			int aa = i/__gcd(i,j);
			int bb = j/__gcd(i,j);
			if(aa==MA&&bb==MB){
				mins(ans, vv[i][j]);
			}
		}
	}
	if(ans==INF) ans=-1;
	cout<<ans<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 2400
#include<iostream>
int main (){
    std::cin.tie(0); 
	std::ios::sync_with_stdio(false);
    std::string S,T;std::cin >>S>>T;
    
    int ans=0;

    for (int i=0; i < S.length();++i){
        if(S[i]!=T[i]){
            ++ans;
        }
    }

    std::cout << ans;
    return 0;
}

Measured memory_bytes: 3884
import math

area = int(input())

sq = int(math.sqrt(area))
# sq <= sqrt(area)  < sq + 1
# のはずだが、浮動小数点のせいでそうなってなかった。やべぇ。
# >>> x = 999999999999999999
# >>> import math
# >>> math.sqrt(x)
# 1000000000.0
# >>> int(math.sqrt(x))
# 1000000000

if area == 10 ** 18:
    li = [0, 0, 0, 10**9, 10**9, 10**9]
elif (sq ** 2) <= area <= sq * (sq + 1):
    # li = [0, -1, sq, 0, sq * (sq + 1) - area, sq]
    li = [0, 0, sq, 1, sq * (sq + 1) - area, sq + 1]
elif sq * (sq + 1) <= area <= (sq + 1) ** 2:
    li = [0, 1, sq+1, 0, -(sq * (sq + 1) - area), sq + 1]

print(' '.join(map(str, li)))

Measured memory_bytes: 3188
a=[]
b=[]
for i in range(10):
    n=int(input())
    a.append(n)
for i in range (10,20):
    n=int(input())
    b.append(n)
a.sort()
b.sort()
print(a[7]+a[8]+a[9],b[7]+b[8]+b[9])
    



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

using namespace std;
using ll = long long int;

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

    string s;
    cin >> s;
    ll n = s.size();
    string key = "keyence";
    ll i, j;
    for(i=0; i<7; i++)
        if(s[i] != key[i]) break;
    for(j=0; j<7; j++)
        if(s[n-1-j] != key[7-1-j]) break;
    cout << (i+j >= 7 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
def resolve():
    N = int(input())
    evdi = [[] for _ in range(N)]
    for i in range(N):
        cnt = int(input())
        for _ in range(cnt):
            x, y = map(int, input().split())
            x -= 1
            evdi[i].append((x, y))

    ans = 0
    for bit in range(1 << N):
        ok = True
        for i in range(N):
            if bit >> i & 1:
                for (x, y) in evdi[i]:
                    if y == 1 and not bit >> x & 1:
                        ok = False
                        break
                    if y == 0 and bit >> x & 1:
                        ok = False
                        break
        cnt = bin(bit).count("1")
        if ok:
            ans = max(cnt, ans)
    print(ans)


if __name__ == "__main__":
    resolve()


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

int main() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  if (n > 1) ans += n * (n-1) / 2;
  if (m > 1) ans += m * (m-1) / 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
v = list(map(int, input().split()))

co = Counter([v[i] for i in range(0, len(v), 2)])
ce = Counter([v[i] for i in range(1, len(v), 2)])
co1 = co.most_common()[0]
ce1 = ce.most_common()[0]
ans = n
if co1[0] == ce1[0]:
    if len(co) > 1:
        co2 = co.most_common()[1]
        ans = min(ans, n - co2[1] - ce1[1])
    if len(ce) > 1:
        ce2 = ce.most_common()[1]
        ans = min(ans, n - co1[1] - ce2[1])
    if len(co) == 1 and len(ce) == 1:
        ans = min(ans, n - max(co1[1], ce1[1]))
else:
    ans = min(ans, n - co1[1] - ce1[1])
print(ans)

Measured memory_bytes: 18648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string a, b;
    cin >> a >> b;
 
    if (a.length() > b.length()) {
        cout << "GREATER" << endl;
    } else if (a.length() < b.length()) {
        cout << "LESS" << endl;
    } else {
        bool equal = true;
        for (int i = 0; i < a.length(); i++) {
            if (a.at(i) > b.at(i)) {
                cout << "GREATER" << endl;
                equal = false;
                break;
            } else if (a.at(i) < b.at(i)) {
                cout << "LESS" << endl;
                equal = false;
                break;
            } else {
                continue;
            }
        }
        if (equal) {
            cout << "EQUAL" << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
 
int main(){
  char a,b,c,d,e,f,g,h,i;
  cin >> a >> b >> c >> d >> e >> f >> g >> h >> i;
  cout << a << e << i << endl;
}

Measured memory_bytes: 256
n,a,b,c,d = map(int,input().split())
s = input()
s = s + "."
cant = 0
sanrenzoku = 0
for i in range(a-1,max(c-1,d-1)):
    if s[i] == "#":
        if s[i+1] == "#":
            cant = 1

if c > d:
    for i in range(b-2,d-1):
        if s[i] == ".":
            if s[i+1] == ".":
                if s[i+2] == ".":
                   sanrenzoku = 1

if cant == 1:
    print("No")
elif c > d:
    if sanrenzoku == 0:
        print("No")
    else:
        print("Yes")
else:
    print("Yes")

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
const in INF=1<<30;
#define vecvec(a,y,x) vector<vector<int>> a(y,vector<int>(x))
#define vec(a,n) vector<int> a(n);rep(i,n)cin>>a[i]

int main(){
int n;cin>>n;
  vec(a,n);
  vec(b,n);
  vec(c,n-1);
  int cnt=0;
  rep(i,n){cnt +=b[i];}
  rep(i,n-1){
    if(a[i]+1==a[i+1]){cnt +=c[a[i]-1];}
  }
  cout<<cnt;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;
int main() {
    int n;
    long hp,r=0;
    cin >> n >> hp;
    vector<long> a(n),b(n);
    for(int i=0; i<n; i++){
        cin >> a[i] >> b[i];
    }

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

    int lastI;
    for(int i=n-1; i>=0; i--){
        if(b[i] < a[n-1]){
            lastI = i + 1;
            break;
        }
    }

    int j = n-1;
    while(hp > 0){
        hp -= b[j];
        r++;
        if(j == lastI){
            if (hp <= 0) break;
            r += hp / a[n-1];
            if (hp % a[n-1] != 0) r++;
            break;
        }
        j--;
    }

    cout << r << endl;
}

Measured memory_bytes: 1792
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
			int T = Integer.parseInt(in.readLine());
			for (int i = 0; i < T; i++) {
				int N = Integer.parseInt(in.readLine());
				String str = in.readLine();
				boolean[][] book = new boolean[N + 1][2];
				for (int j = 0; j < 4 * N; j++) {
					if (str.charAt(j) == 'Y') {
						book[(j % (2 * N) + 1) / 2][j / (2 * N)] = true;
					}
				}
				int[][] dp = new int[N + 2][2];
				dp[N + 1][0] = -1;
				dp[N + 1][1] = 0;
				for (int j = N; j >= 0; j--) {
					if (!book[j][0] && !book[j][1]) {
						dp[j][0] = dp[j + 1][0] + 1;
						dp[j][1] = dp[j + 1][1] + 1;
					} else if (book[j][0] && book[j][1]) {
						dp[j][0] = 3 + dp[j + 1][1];
						dp[j][1] = 3 + Math.min(dp[j + 1][0], dp[j + 1][1]);
					} else if (book[j][0]) {
						dp[j][0] = dp[j][1] = 2 + Math.min(dp[j + 1][0], dp[j + 1][1]);
					} else {
						dp[j][0] = 3 + dp[j + 1][1];
						dp[j][1] = 2 + dp[j + 1][1];
					}
				}
				System.out.println(dp[0][0]);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 12000
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] sums = new int[n];
		for (int i = 0; i < k; i++) {
		    int num = sc.nextInt();
		    for (int j = 0; j < num; j++) {
		        sums[sc.nextInt() - 1]++;
		    }
		}
		int count = 0;
		for (int x : sums) {
		    if (x == 0) {
		        count++;
		    }
		}
		System.out.println(count);
	}
}


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

using namespace std;

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int a, b; cin >> a >> b;
	puts(a + b == 15 ? "+" : (a * b == 15 ? "*" : "x"));

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) xmax = x; return true;
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) xmin = x; return true;
    return false;
}
template<typename Val>
bool bitcheck(Val bit, size_t idx) {
    return bit & (1 << idx);
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;

void solve() {
    ll n; cin >> n;
    ll ret = n % 10;
    if (ret == 3) cout << "bon" << endl;
    else if (ret == 0 || ret == 1 || ret == 6 || ret == 8) cout << "pon" << endl;
    else cout << "hon" << endl;
}

signed main() {
    solve();
    return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if((a + b) < (c + d)){
    cout << "Right" << endl;
  }
  
  if((a + b) == (c + d)){
    cout << "Balanced" << endl;
  }
  
  if((a + b) > (c + d)){
    cout << "Left" << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC120A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c, d;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);
            if (a * c <= b)
                d = c;
            else
                d = b / a;
            Console.WriteLine(d);
            Console.ReadKey();
        }
    }
}


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

using namespace std;
using lli = int_fast64_t;
using ulli = unsigned long long;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = copy(x);cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

constexpr lli MOD = (lli)1e9 + 7;
constexpr lli LIMIT = 1000000000000000000 * 5;

int main() {
	lli A, V, B, W, T;
	cin >> A >> V;
	cin >> B >> W;
	cin >> T;
	lli sub = abs(A - B);
	if (sub > 0 && W >= V) {
		cout << "NO" << endl;
		return 0;
	}
	if ((T * (V-W)) >= sub) {
		cout << "YES" << endl;
		return 0;
	}

	cout << "NO" << endl;
	return 0;
}



Measured memory_bytes: 3596
n=int(input())
num=list(map(int,input().split()))
cnt=0
def cnt_2(n):
  cnt=0
  while n>1:
    if n%2==0:
      n//=2
      cnt+=1
    else:
      break
  return cnt
    
for i in num:
  cnt+=cnt_2(i)
print(cnt)

Measured memory_bytes: 4148
#include <iostream>

int check(long long int a[], long long int n, int k)
{
  int i = k;
  int inc = 0;
  while (a[i+1] -a[i]>=0 && i != n-1) {
    i++;
    inc++;
  }
  int j = k;
  int dec = 0;
  while (a[j+1] - a[j] <= 0 && j != n-1) {
    j++;
    dec++;
  }
  std::cerr << "i: " << i << " j: " << j << std::endl;
  return inc > dec ? inc+1 : dec+1; 
}

int main()
{
  long long int n;
  std::cin >> n;
  long long int a[n];
  for ( int i = 0; i < n; i++ ) {
    std::cin >> a[i];
  }
  if ( n==1 ) {
    std::cout << "1\n";
    return 0;
  }

  int ans = 0;
  for (int i = 0; i < n;) {
    if ( i == n-1 ) {
      ans++;
      break;
    }
    std::cerr << "i: " << i;
    i += check(a, n, i);
    ans++;
    std::cerr << "i: " << i;
  }
  
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    int times;
    cin >> times;

    for (int i = 0;i < times; i++) {
        int a, b, c;
        cin >> a >> b >> c;

        double a2, b2, c2;
        a2 = pow(a,2);
        b2 = pow(b,2);
        c2 = pow(c,2);

        if (a2 == b2 + c2 || b2 == a2 + c2 || c2 == a2 + b2) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1156
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio
    
    int n,m;
    cin >> n >> m;
    int arr[5];
    memset(arr,-1,sizeof(arr));
    
    for(int i=0;i<m;i++) {
        int x,y;
        cin >> x >> y;
        if(arr[x]!=-1 and arr[x]!=y) {
            cout << -1 << endl;
            return 0;
        }
        arr[x] = y;
    }
    
    if(n==1) {
        if(arr[1]!=-1)
        cout << arr[1];
        else
        cout << 0 ;
        return 0;
    }
    
    if(arr[1]==0) {
            cout << -1 << endl;
            return 0;
        }
    
    if(arr[1]==-1)
    cout << 1;
    else
    cout << arr[1];
    for(int i=2;i<=n;i++) {
        if(arr[i]!=-1)
        cout  << arr[i];
        else
        cout << 0;
    }
    
	return 0;
    
}


Measured memory_bytes: 8832
#include <stdio.h>

int primes[1000000];

void Sieve(){
    for(int i= 2; i < 1000000; i++){
        primes[i] = 1;
    }
    primes[1] = 0;    
    for(int i = 2; i < 1000; i++){
        if(primes[i] == 1)
            for(int j=i; j*i < 1000000;j++){
                primes[j*i] = 0;
            }
    }     
}

int IsPrime(int x){
    return primes[x];
}

int main(void){
    Sieve();
    int n, c;
    while(scanf("%d", &n)!= EOF){
        c = 0;
        for(int i = 2; i <= n; i++){
        if(IsPrime(i)==1)
            c++;
        }
        printf("%d\n", c);
    }
    return 0;
    
    
}



Measured memory_bytes: 5620
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    String s = sc.next();

    if (s.substring(0, N/2).equals(s.substring(N/2, N))) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }    
  }
}

Measured memory_bytes: 25300
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n, m; cin>>n>>m;
    vector<int> g[410];
    int x[100010], y[100010];
    for(int i=0; i<m; i++){
        cin>>x[i]>>y[i]; x[i]--; y[i]--;
        g[x[i]].push_back(i);
        g[y[i]].push_back(i);
    }
    vector<int> e[410];
    bool dame[410]={};
    for(int i=0; i<n; i++){
        bool nuo[410]={};
        nuo[i]=1;
        for(int j=m-1; j>=0; j--){
            if(!nuo[x[j]] && !nuo[y[j]]) continue;
            if(nuo[x[j]] && nuo[y[j]]){
                dame[i]=1;
                break;
            }
            nuo[x[j]]=nuo[y[j]]=1;
            e[i].push_back(j);
        }
    }
    int ans=0;
    for(int i=0; i<n; i++){
        if(dame[i]) continue;
        for(int j=i+1; j<n; j++){
            if(dame[j]) continue;
            bool ok=1;
            vector<int> eij=e[i];
            for(auto k:e[j]) eij.push_back(k);
            sort(eij.begin(), eij.end());
            eij.erase(unique(eij.begin(), eij.end()), eij.end());
            bool nuo[410]={};
            nuo[i]=nuo[j]=1;
            for(int k=(int)eij.size()-1; k>=0; k--){
                int t=eij[k];
                if(nuo[x[t]] && nuo[y[t]]){
                    ok=0; break;
                }
                nuo[x[t]]=nuo[y[t]]=1;
            }
            if(ok) ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2304
N = int(input())
Ws = [input() for _ in range(N)]

ans = True
w = set([Ws[0]])
for i in range(1, N):
    if Ws[i - 1][-1] != Ws[i][0]:
        ans = False
        break
    if Ws[i] in w:
        ans = False
        break
    w.add(Ws[i])

print("Yes" if ans else "No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    vector<vector<int>> m(10,vector<int>(10,0));
    int n;
    cin >> n;
    for(int i = 1;i <= n;i++){
        string s = to_string(i);
        int sen = s[0] - '0';
        int matu = s[s.size() - 1] - '0';
        //cout << "sen:" << sen << "matu:" << matu << endl;
        m.at(sen).at(matu) += 1;
    }
    long long int sum = 0;
    for(int i = 0;i < 10;i++){
        for(int j = 0;j < 10;j++){
            //cout << m.at(i).at(j) << " ";
            sum += m.at(i).at(j) * m.at(j).at(i);
        }
        //cout << endl;
    }

    cout << sum << endl;


    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

struct edge{
  int to,cost;
};

vector< edge > G[10000];
int d[10000];
int visited[10000];

int V,E;

int main(){
  cin>>V>>E;
  for(int i=0;i<E;i++){
    int a,b,c;
    cin>>a>>b>>c;
    G[a].push_back( (edge){b,c} );
    G[b].push_back( (edge){a,c} );
  }
  for(int i=0;i<V;i++){
    d[i]=1e9;
    visited[i]=0;
  }
  d[0]=0;
  priority_queue< P , vector<P> , greater<P> > Q;
  Q.push( P(0,0) );
  
  while(!Q.empty()){
    P p=Q.top();
    Q.pop();
    int pos=p.second;
    int cost=p.first;
    visited[pos]=1;
    if(d[pos]<cost)continue;
    for(int i=0;i<(int)G[pos].size();i++){
      edge e=G[pos][i];
      if(visited[e.to])continue;
      if(d[e.to]>e.cost){
        d[e.to]=e.cost;
        Q.push(P(e.cost,e.to));
      }
    }
  }
  int ans=0;
  for(int i=0;i<V;i++)ans+=d[i];
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 6252
require 'pp'

def gets; ARGF.gets; end

class Solver

  def main
    w, a, b = gets.chomp.split.map(&:to_i)

    a, b =  [a, b].sort
    # puts a
    # puts b

    ans = if a + w < b
            b - (a + w)
          else
            0
          end
    puts ans
  end
end

if __FILE__ == $0
  Solver.new.main
end


Measured memory_bytes: 4092
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	permutation
# CreatedDate:  2020-07-08 19:01:42 +0900
# LastModified: 2020-07-08 19:17:50 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
from itertools import permutations as nPr
from copy import deepcopy


def main():
    n = int(input())
    a = list(map(int, input().split()))
    s = sorted(deepcopy(a))
    p = list(nPr(s))
    inde = p.index(tuple(a))
#    print(p)
#    print(inde)
    if inde!=0:
        print(p[inde-1][0], end="")
        for i in range(1, n):
            print(" {}".format(p[inde-1][i]), end="")
        print()
    print(p[inde][0], end="")
    for i in range(1, n):
        print(" {}".format(p[inde][i]), end="")
    print()
    if inde!=len(p)-1:
        print(p[inde+1][0], end="")
        for i in range(1, n):
            print(" {}".format(p[inde+1][i]), end="")
        print()
    


if __name__ == "__main__":
    main()



Measured memory_bytes: 52944
use std::io;
use std::io::Read;

fn main() {
    let mut stdin = io::stdin();
    let mut lines = String::new();
    let _ = stdin.read_to_string(&mut lines);
    let vec = lines.lines().collect::<Vec<&str>>();
    let s = vec[0];

    let mut ncnt = 0;
    let mut scnt = 0;
    let mut ecnt = 0;
    let mut wcnt = 0;
    for i in s.chars() {
        match i {
            'N' => { ncnt += 1; },
            'S' => { scnt += 1; },
            'E' => { ecnt += 1; },
            'W' => { wcnt += 1; }
            _ => {}
        }
    }
    if (ncnt == 0 && scnt != 0) ||
        (scnt == 0 && ncnt != 0) ||
        (ecnt == 0 && wcnt != 0) ||
        (wcnt == 0 && ecnt != 0){
            println!("No");
        } else {
            println!("Yes");
        }
}



Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
int a, b;
int main(){
	cin >> a >> b;
	if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)	cout << "Possible";
	else	cout << "Impossible";
	return 0;
}


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

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    
    int n;
    cin >> n;
    int a[n], b[n], c[n];
    for (int i = 0; i < n; i++)
        cin >> a[i] >> b[i] >> c[i];

    int dp[n + 1][3];
    dp[0][0] = 0; // points gained, last activity was A
    dp[0][1] = 0; // points gained, last activity was B
    dp[0][2] = 0; // points gained, last activity was C

    for (int i = 1; i <= n; i++)
    {
        dp[i][0] = 0;
        dp[i][1] = 0;
        dp[i][2] = 0;
        
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i - 1];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i - 1];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i - 1];
    }
    cout << max(max(dp[n][0], dp[n][1]), dp[n][2]);
    return 0;
}

Measured memory_bytes: 2560
# "ヒント: 累積和"ってのを見てしまったのでもうわかるしかなくなってしまった
# たぶん右側が西、左側が東
# 選んだときに自分より右側にいて西を向いてるやつの数+左側にいて東を向いているやつの数
# 左端からみていって自分がWだったら[i+1]=1+[i]（右側にあふれる注意）ちがったら[i]
# 右端からみていって自分がEだったら[i-1]=1+[i]（左側にあふれる注意）（reverseしろや）ちがったら[i]
n = gets.chomp.to_i
s = gets.chomp.chars
w_arr = Array.new(n, 0)
e_arr = Array.new(n, 0)
1.upto(n) do |i|
  break if i==n
  if s[i-1] == "W"
    e_arr[i] = e_arr[i-1]+1
  else
    e_arr[i] = e_arr[i-1]
  end
end
(n-1).downto(0) do |i|
  break if i==0
  if s[i] == "E"
    w_arr[i-1] = w_arr[i]+1
  else
    w_arr[i-1] = w_arr[i]
  end
end
# p w_arr
# p e_arr
ans = 10**8
n.times do |i|
  ans = [ans, w_arr[i]+e_arr[i]].min
end
puts ans

Measured memory_bytes: 32140
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char[]ss = S.toCharArray();
         
        Arrays.sort(ss); 	
        int ans = 0;
        for(int i=0; i<S.length()-1; i++) {
        	if((ss[i+1])-ss[i] >= 2){
        		ans = ss[i]+1;
        		break;
        	}
        }
        if(ss[0] != 'a') {
        	System.out.println("a");
        }else if(ans == 0) {
        	if(ss[S.length()-1] == 'z') {
        		System.out.println("None");
        	}else {
        		System.out.println((char)(ss[S.length()-1]+1));
        	}
        }else {
        		System.out.println((char)ans);
    }
}
}


Measured memory_bytes: 39172
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <math.h>
#include <map>
#include <numeric>
#include <stack>
#include <queue>
#include <functional>
#include <stdio.h>
#define ll long long
#define pl pair<ll,ll>
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vvvl vector<vector<vector<ll> > >
#define vd vector<double>
#define vvd vector<vector<double> >
#define vvvd vector<vector<vector<double> > >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define vvvb vector<vector<vector<bool> > >
#define rep(i,a) for(ll i = 0;i<a;++i)
#define rrep(i,a) for(ll i = a;i>=0;--i)
#define mod 1000000007
#define inf 10010010010
using namespace std;

pl func(ll x){
	pl ret;
	ret.second = x % 10;
	while (x / 10) x /= 10;
	ret.first = x;
	return ret;
}

int main(){
	ll n; cin >> n;
	vvl ngo(11, vl(11, 0));
	rep(i, n+1){
		pl a = func(i);
		ngo[a.first][a.second]++;
	}
	ll ans = 0;
	rep(i, 10) rep(j, 10) if (j*i) ans += ngo[i][j] * ngo[j][i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int  x1, x2, y1, y2;

  scanf("%d %d %d %d", &x1, &y1, &x2, &y2);

  printf("%d ", x2 + (y1-y2) );
  printf("%d ", y2 + (x2-x1) );
  printf("%d ", x1 + (y1-y2) );
  printf("%d\n", y1 + (x2-x1) );

  return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

const ll INF = 1001001001001001LL;

ll dp[20][150010];

int main() {
   ll D, G;
   cin >> D >> G;
   G /= 100;
   fill(dp[0], dp[20], INF);

   dp[0][0] = 0;
   for (ll i = 0; i < D; i++) {
      ll p, c;
      cin >> p >> c;
      c /= 100;
      for (ll k = 0; k <= p; k++) {
         ll is_comp = (k == p ? c : 0);

         ll point = k*(i+1) + is_comp;
         for (ll j = 0; j <= G; j++) {
            ll nj = min(G, j + point);
            chmin(dp[i+1][nj], dp[i][j]+k);
         }
      }
   }

   cout << dp[D][G] << endl;

   return 0;
}

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

int main(){
	int n,i,ans=0;
	string s;
	char h=0;

	cin>>n>>s;

	for(i=0;i<n;i++){

		if(s[i]!=h){
			ans++;
		}

		h=s[i];
	}

	cout<<ans<<endl;

	return 0;
}

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

int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++) scanf("%d", &A[i]);
    sort(A.begin(), A.end());
    
    for(int i=0;i<N;i++){
        if(i) printf(" ");
        printf("%d", A[i]);
    }
    cout<<endl;
    
    return 0;
}


Measured memory_bytes: 10692