akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

int main(){

    /*---------*/
    /*  input  */
    /*---------*/

    int D;
    cin >> D;

    int i,j;
    vector<int> c(26+1);
    for( i = 1; i <= 26; i++ ){
        cin >> c[i];
    }

    vector< vector<int> > s(D+1, vector<int>(26+1));
    for( i = 1; i <= D; i++ ){
        for( j = 1; j <= 26; j++ ){
            cin >> s[i][j];
        }
    }

/*
    vector<int> t(365+1);
    for( i = 1; i <= D; i++ ){
        cin >> t[i];
    }
*/

    /*--------*/
    /*  calc  */
    /*--------*/

    long long int p = 0;
    int m = 0;
    int d;   // d: 1 --> D(365)
    vector<int> last(26+1);
    vector<int> real_last(26+1);
    long long int total = 0;
    long long int score;
    long long int ans = -10000000000;
    int x,k,tmp;

    for( d = 1; d <= D; d++ ){

        //ans = -100000000000;

        for( i = 1; i <= 26; i++ ){
            for( k = 1; k <= 26; k++ ) last[k] = real_last[k];
            p = s[d][i];
            // minus
            //m = 0;
            // last[]を更新
            //tmp = last[i];  // 記憶
            last[i] = d;
            if( i == 1 ){
                m = 0;
                for( j = 1; j <= 26; j++ ){
                    m += c[j] * ( d - last[j] );
                }
                ans = p - m;
                x = 1;
            }
            else{
                m = m + c[i-1]*(d-last[i-1]) - c[i]*(d-tmp);
                score = p - m;
                if( score > ans ){
                    x = i;
                    ans = score;
                }
                //else last[i] = tmp;
            }
        }
        // real_last[]を更新
        real_last[ x ] = d;
        cout << x << endl;
    }

       

}


Measured memory_bytes: 3696
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll M =1e9+7;
const int N = 1e5+7;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

vector<int> adj[N];
bool vis[N]={0};

void dfs(int x)
{
    vis[x]=1;
        
    for(auto it:adj[x])   
    if(!vis[it])
    dfs(it);
        
}


int main()
{
    int n,m;
    scf(n),scf(m);
    
    rep(i,0,m)
    {
        int x,y;
        scf(x),scf(y);

        adj[x].pb(y);
        adj[y].pb(x);
    }

    rep(i,1,n+1)
    {   
        int l=adj[i].size();


        prin(l);
    }

    
}

Measured memory_bytes: 6136
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define sort_v(a) sort(a.begin(), a.end())

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    string s;
    int m = INF;

    cin >> s;
    for (int i = 0; i < s.size() - 2; i++)
    {
        string tmp;
        rep(j, 0, 3)
        {
            tmp += s[i + j];
        }
        int num = stoi(tmp);
        m = min(m, abs(num - 753));
    }
    cout << m << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int w[102],b[102];
pair<int,int>dp[102][100002];

int main()
{
    int n,we,i,j,sum,total,ans;
    scanf("%d %d",&n,&we);
    total=0;
    for(i=1; i<=n; i++)
    {
        scanf("%d %d",&w[i],&b[i]);
        total+=b[i];
    }
    ans=sum=0;
    for(i=1; i<=n; i++)
    {
        for(j=1; j<=total; j++)
        {
            if(b[i]>j)dp[i][j]=dp[i-1][j];
            else
            {
                if(dp[i-1][j-b[i]].first+w[i]<=we)
                {
                    if(b[i]+dp[i-1][j-b[i]].second>=dp[i-1][j].second)
                    {
                        if(b[i]+dp[i-1][j-b[i]].second==dp[i-1][j].second
                            && dp[i-1][j-b[i]].first+w[i]>=dp[i-1][j].first)dp[i][j]=dp[i-1][j];
                        else
                        {
                            dp[i][j].first=dp[i-1][j-b[i]].first+w[i];
                            dp[i][j].second=dp[i-1][j-b[i]].second+b[i];
                        }
                        ans=max(ans,dp[i][j].second);
                    }
                    else dp[i][j]=dp[i-1][j];
                }
                else dp[i][j]=dp[i-1][j];
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 81728
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n,m = LI()
    a = [LI() for _ in range(n)]
    b = [LI() for _ in range(m)]
    r = []
    for ai in a:
        mi = -1
        mm = inf
        for i in range(m):
            bi = b[i]
            t = abs(ai[0]-bi[0]) + abs(ai[1]-bi[1])
            if t < mm:
                mi = i+1
                mm = t
        r.append(mi)

    return '\n'.join(map(str, r))



print(main())


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vdbl;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int> > vvint;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef priority_queue<int, vector<int>, greater<int> > spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll> > spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int> > bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll> > bpqll;        //大きい順に取り出し

#define REP(i, n) for (int(i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, b) for (int(i) = a; (i) < (int)b; i++)
#define IREP(i, v) for (auto i = v.begin(); i != v.end(); i++)
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[8] = {1, 0, -1, 0, 1, -1, 1, -1};
const int dy[8] = {0, 1, 0, -1, -1, 1, 1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes()
{
    cout << "Yes" << endl;
}
void no()
{
    cout << "No" << endl;
}
//-----------------------------------------
vll yakusuu(ll n){
    vll ret ;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            ret.push_back(i) ;
            if(i*i!=n){
                ret.push_back(n/i) ;
            }
        }
    }
    sort(ALL(ret)) ;
    return ret ;
}



//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n ;
    cin >> n ;
    vll a = yakusuu(n) ;
    ll ans = 0 ;
    REP(i,SZ(a)){
        a[i]-- ;
        if(a[i]!=0){
            if(n/a[i]==n%a[i]){
                ans += a[i] ;
            }
        }
    }

    cout << ans <<endl ;

    

    return 0;
}


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


ll mod = 998244353;

int main(){
    int N;
    cin >> N;
    vector<int> dist(N, 0);
    for (int i = 0; i < N; i++) {
        int d;
        cin >> d;
        if (i == 0 && d != 0) {
            cout << 0 << endl;
            return 0;
        }
        dist[d]++;
    }
    if (dist[0] >= 2) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    for (int i = 1; i <= N-1; i++) {
        for (int j = 0; j < dist[i]; j++) {
            ans = (ans * dist[i-1]) % mod;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
//                                 Alisher_2211
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        # include <bits/stdc++.h>
# define  long          long long
# define  all(vc)       vc.begin(),vc.end()
# define  allr(vc)      vc.rbegin(),vc.rend()
# define  pb            push_back
# define  fi            first 
# define  se            second
# define  pi            pair <long, long>    
# define  lcm(a, b)     (a * b) / __gcd(a, b)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        using namespace std;
void read(){freopen("input.txt" , "r" , stdin );freopen("output.txt", "w" , stdout );}
long f(long n){
    return n * (n - 1) / 2;
}
void solve(){
      long l, r, d;
      cin >> l >> r >> d;
      long ans = 0;
      for (int i = l; i <= r; ++i){
            if( i % d == 0 ) ans ++;
      }
      cout << ans;
}
int32_t main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); 
        long T = 1;
        //cin >> T;
        while( T-- ){
            solve();
            cout<<'\n';
        }
cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}

Measured memory_bytes: 3752
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(x) cerr << #x << " == " << (x) << '\n';
#define all(X) X.begin(), X.end()
#define sz(X) (int)X.size()

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;

mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

// xz

int main()
{ _
    int n, k; cin >> n >> k;
    vi p(n); vector c(n, 0LL);
    for (int i = 0; i < n; ++i)
    {
        cin >> p[i]; --p[i];
    }
    for (int i = 0; i < n; ++i)
        cin >> c[i];

    vector sum(n, 0LL);
    vi vis(n, 0), size(n, 0);

    for (int i = 0; i < n; ++i)
    {
        if (vis[i]) continue;
        for (int j = i; !vis[j]; vis[j] = 1, j = p[j])
            sum[i] += c[j], size[i] += 1;
        for (int j = p[i]; j != i; j = p[j])
            sum[j] = sum[i], size[j] = size[i];
    }

    ll ans = -LINF;
    for (int i = 0; i < n; ++i)
    {
        ll cur = 0;
        for (int j = i, t = 0; t < min(k, size[i]); ++t, j = p[j])
        {
            cur += c[j];
            ans = max(ans, cur);
            ans = max(ans, cur + sum[i] * ((k - t - 1) / size[i]));
        }
    }

    cout << ans << endl;

    exit(0);
}



Measured memory_bytes: 3816
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(1){
		string s; cin >> s;
		if(s=="#")break;
		int h=1,w=0;
		for(int i=0;i<s.size();i++){
			if(s[i]=='/')h++;
		}
		for(int i=0;i<s.size();i++){
			if(s[i]=='/')break;
			if(s[i]=='b')w++;
			else w+=s[i]-'0';
		}
		vector<vector<char>> fi(h,vector<char>(w,'.'));
		int y=0,x=0;
		for(int i=0;i<s.size();i++){
			if(s[i]=='/')y++,x=0;
			else if(s[i]=='b'){
				fi[y][x]='#';
				x++;
			}
			else{
				x+=s[i]-'0';
			}
		}
		int a,b,c,d; cin >> a >> b >> c >> d;
		a--; b--; c--; d--;
		fi[a][b]='.';
		fi[c][d]='#';
		for(int i=0;i<h;i++){
			char num='0';
			for(int j=0;j<w;j++){
				if(fi[i][j]=='#'){
					if(num!='0')printf("%c",num );
					printf("b");
					num='0';
				}
				else num++;
			}
			if(num!='0')printf("%c",num );
			if(i+1!=h)printf("/");
		}
		printf("\n");
	}
}



Measured memory_bytes: 3220
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

#define PI 3.141592653589793238
#define INF 1050000000

using namespace std;



//cout << fixed << setprecision(15) << << endl;
//cout << << endl;

int main() {

	int N;

	cin >> N;

  	int a,b;
  
  	a = N%10;
  	b = N/10;
  
  	if(a == 9 || b == 9 ){
		cout << "Yes" << endl;
    }else{
      	cout << "No" << endl;
    }

	
	return 0;
}

Measured memory_bytes: 256
import numpy as np

h, w = map(int,input().split())

maze = []
for i in range(h):
    row = list(input())
    if "#" in row:
        maze.append(row)
        
maze = np.array(maze)
maze = np.rot90(maze)

ans = []
for row in maze:
    if "#" in row:
        ans.append(row)
        
ans = np.rot90(ans, -1)

for r in ans:
    print("".join(r))

Measured memory_bytes: 27300
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;

int main()
{
    int k, t; cin>>k>>t;
    multiset<int> a;
    for(int i=0; i<t; ++i) {
        int e; cin>>e; a.insert(e);
    }
    while (a.size()>1) {
        auto x=*begin(a);
        auto y=*rbegin(a);
        a.erase(begin(a));
        a.erase(a.find(y));
        if (x>1) a.insert(x-1);
        if (y>1) a.insert(y-1);
    }
    cout<<(a.size() ? *begin(a)-1 : 0)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

#define long long long // for codeforces

int main(){
  int l,n;
  cin>>l>>n;

  long val = 0;
  rep(i,n){
    int x,w;
    cin>>x>>w;
    val += x*w;
  }

  if (val==0) cout << 0 << endl;
  else {
    cout << 1 << endl;
    if (val>0){
      cout << "-1 " << val << endl;
    } else {
      cout << "1 " << -val << endl;
    }
  }

  return 0;
}



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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint ans=0;
    REP(i, 3) {
        lint x;
        cin >> x;
        ans+=x;
    }

    cout << ((ans<22)? "win":"bust")<<"\n";

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int judge(int b[],int n){
	int i;
	for(i=0;i<n;i++)if(b[i]!=i+1)break;
	if(i==n)return 1;
	else return 0;
}
int func(int b[],int n){
	int i,cid;
	cid=0;
	for(i=0;i<n;i++){
		if(b[i]>1){
			b[cid]=b[i]-1;
			cid++;
		}
	}
	b[cid]=n;
	return cid+1;
}
int b[20005];
int main(){
	int i,n,c,f;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<n;i++)scanf("%d",&b[i]);
		c=0;
		while(c<=10000){
			//if(judge(b,n)==1)break;
			f=judge(b,n);
			//printf("%d\n",f);
			if(f==1)break;

			n=func(b,n);
			//for(i=0;i<n;i++)printf("%d ",b[i]);
			//printf("\n");

			c++;
		}
		if(c==10001)printf("-1\n");
		else printf("%d\n",c);
	}
	return 0;
}

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

using namespace std;

int main() {
    int m1, d1, m2, d2;
    cin >> m1 >> d1;
    cin >> m2 >> d2;
    auto ans = (m1 != m2) ? 1 : 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
 
N,M,L = map(int,input().split())
 
A = [list(map(int,input().split())) for i in range(N)] #N*M配列の取得
B = [list(map(int,input().split())) for i in range(M)] #M*L配列の取得
ANS = [[0]*L for i in range(N)] #N*L
 
 
for x in range(N):
    for y in range(L):
        for z in range(M):
            ANS[x][y] += B[z][y]*A[x][z]
 
for row in range(N):
    print("%d"%ANS[row][0],end = "")
    for col in range(1,L):
        print(" %d"%(ANS[row][col]),end = "")
    print()


Measured memory_bytes: 7064
#include<stdio.h>
int n, C[101000], Mod = 1000000007, res = 1;
int main(){
    scanf("%d",&n);
    int i, a, t = n-1;
    for(i=1;i<=n;i++){
        scanf("%d",&a);
        C[a]++;
    }
    for(i=1;i<=n;i++){
        C[t<0?-t:t]--;
        t-=2;
    }
    for(i=0;i<n;i++){
        if(C[i]){
            printf("0\n");
            return 0;
        }
        if(i%2)res=res*2%Mod;
    }
    printf("%d\n",res);
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
int main(){
   string card[3];
   int point[3] = {0,0,0};
   int next = 0;
   string out = "ABC";
   for(int i=0;i<3;i++) cin >> card[i];

   while(true){
      if(card[next].size() == point[next]){
         cout << out[next] << endl;
         break;
      }
      int tmp = point[next];
      point[next]++;
      next = card[next][tmp] - 'a';
   }
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    A--; B--; C--; D--;
    string S;
    cin >> S;
    bool bad = false;
    for(int i=B;i<=D-1;i++){
        if(S[i]=='#' && S[i+1]=='#') bad = true;
    }
    for(int i=A;i<=C-1;i++){
        if(S[i]=='#' && S[i+1]=='#') bad = true;
    }
    if(C>D){
        bool good = false;
        for(int i=B-1;i<=D-2+1;i++){
            if(S[i]=='.' && S[i+1]=='.' && S[i+2]=='.') good = true;
        }
        bad |= !good;
    }
    if(bad) cout<<"No"<<endl;
    else    cout<<"Yes"<<endl;

    return 0;
}

Measured memory_bytes: 640
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
t = list(input())
lt = len(t)
cnt = 0
for i in range(lt-1,-1,-1):
    if t[i] == 'D':
        pass
    elif t[i] == 'P':
        pass
    elif t[i] == '?':
        if i+1 < lt:
            if t[i+1] == 'D':
                if i-1 < lt:
                    if t[i-1] == 'P':
                        t[i] = 'D'
                    else:
                        t[i] = 'P'
                else:
                    t[i] = 'P'
            elif t[i+1] == 'P':
                t[i] = 'D'
        else:
            t[i] = 'D'
print(*t,sep='')


Measured memory_bytes: 15580
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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(a>b){a=b;return 1;}return 0;}

ll n,k;
ll a[100010];

ll gcd(ll a, ll b) {
  int t;
  while ( b != 0 ) {        
    t = a%b; a = b; b = t;  
  }
  return a;                 
}
ll coprime(ll a, ll b) {
  return (gcd(a, b) == 1);
}

int
main(void){  
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin >> n >> k;
  REP(i,n) cin >> a[i];
  
  sort(a, a+n, greater<ll>());
  ll res = 0LL;
  REP(i,n){
    res = gcd(res, a[i]);
  }
  if(k%res==0 && k <= a[0]) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  
  return 0;
}


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

int gcd(int a, int b){
	if (b == 0)
		return a;

	return gcd(b, a%b);
}


int main(){

	while (true){
		int a, b;
		cin >> a >> b;

		if (cin.eof())
			break;

		int g = gcd(a, b);
		cout << g << " " << a / g*b << endl;
	}

	return 0;
}

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

char hennkann(char c,int n){
  string a="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
 rep(k,27){
   if(a[k]==c){
     c=a[k+n];
     break;
   }
  }
  return c;
}


int main() {
  int n;
  string s;
  cin>>n>>s;
  ////////////////////
  int x=s.size();
  rep(i,x){
    s[i]=hennkann(s[i],n);
      cout<<s[i];
  }
  cout<<endl;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rep1(i, n) for(ll i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){
  int x,y;
  cin >> x >> y;
  int a = 4*x-y;
  int b = -2*x+y;
  bool ab = (a>=0)&&(b>=0);
  if(ab && b%2==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3608
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

const MOD: usize = 1e9 as usize + 7;

#[allow(dead_code)]
pub struct ModFactorial {
    fact: Vec<usize>,
    inv: Vec<usize>,
    finv: Vec<usize>,
}
impl ModFactorial {
    pub fn new(max_value: usize) -> Self {
        let mut fact = vec![0; max_value + 1];
        let mut inv = vec![0; max_value + 1];
        let mut finv = vec![0; max_value + 1];
        fact[0] = 1;
        fact[1] = 1;
        finv[0] = 1;
        finv[1] = 1;
        inv[1] = 1;
        for i in 2..max_value + 1 {
            fact[i] = fact[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
        ModFactorial {
            fact: fact,
            inv: inv,
            finv: finv,
        }
    }
    pub fn combination(&self, n: usize, k: usize) -> usize {
        // assert!(n >= k);
        if n < k {
            return 0
        }
        self.fact[n] * self.finv[n - k] % MOD * self.finv[k] % MOD
    }
}


fn main() {
    input!{
      n: usize,
      k: usize,
    }

    let fact = ModFactorial::new(n);

    for i in 1..k+1 {
        let mut ans = fact.combination(n-k+1, i);
        ans *= fact.combination(k-1, i-1);
        ans %= MOD;
        println!("{}", ans);
    }
}


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

int main(){
    char ch;
    char counter[26] = {};
    while (scanf("%c", &ch) != EOF){
        ch = tolower(ch);
        if (isalpha(ch)){
            int num = ch - 'a';
            counter[num]++;
        }
    }

    for (int i = 0; i < 26; i++){
        printf("%c : %d\n", i + 'a', counter[i]);
    }

    return 0;
}


Measured memory_bytes: 2744
import sys
input=sys.stdin.readline

def main():
    S = input().strip()
    S = S.replace("BC","D")
    ans = 0
    a = 0
    for c in S:
        if c == "A":
            a += 1
        elif c == "D":
            ans += a
        else:
            a = 0
        
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3500
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ll n;
	cin>>n;
	ll t = n+1;
	ll a[t] = {0};
	while(--n){
		ll in;
		cin>>in;
		a[in]++;		
	}
	for(ll i=1;i<t;i++){
		cout<<a[i]<<endl;
	}
	
}

Measured memory_bytes: 5128
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,m; cin >> n >> m;
	if(n+m==0){
		cout << 0 << endl;
	}
	else if(n+m>0){
		cout << 1 << endl;
	}
	else{
		cout << -1 << endl;
	}
}


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

int main() {
  int N;
  cin >> N;
  for (int i = 1; i < 10; i++) {
    if (N <= 111 * i) {
      cout << 111 * i << endl;
      break;
    }
  }
  return 0;
}



Measured memory_bytes: 256
# coding: utf-8
# Here your code !
employeeSalesList = []

def resetDataset():
    del employeeSalesList[0 : len(employeeSalesList) + 1]

def readDataCount():
    return int(input())

def searchEmployeeSales(employeeId):
    for data in employeeSalesList:
        if data[0] == employeeId:
            return data
    
    newData = [employeeId, 0]
    employeeSalesList.append(newData)
    return newData

answerList = []
def printEmployeeOfDataset():
    found = False
    for data in employeeSalesList:
        if data[1] >= 1000000:
            answerList.append(data[0])
            found = True
    if not found:
        answerList.append("NA")

resetDataset()
dataCount = readDataCount()
while dataCount > 0:
    for _ in range(dataCount):
        employeeId, price, volume = list(map(int, input().split(" ")))
        employeeSales = searchEmployeeSales(employeeId)
        employeeSales[1] += price * volume
    printEmployeeOfDataset()
    resetDataset()
    dataCount = readDataCount()

for row in answerList:
    print(row)

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

vector<vector<int>> G(200000);
vector<int> ch_num(200000);
vector<bool> done(200000);
int dfs(int v, vector<int> &ts) {
    if (done.at(v)) return 0;

    done.at(v) = true;
    ts.push_back(v);

    if (G.at(v).size() == 0) return 1;

    int num = 0;
    for (int i = 0; i < (int)G.at(v).size(); i++) {
        num += dfs(G.at(v).at(i), ts);
    }
    ch_num.at(v) = num;
    return num + 1;
}

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> ts(0);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G.at(a).push_back(b);
        G.at(b).push_back(a);
    }

    dfs(0, ts);
    
    vector<int> root_index(n);
    for (int i = 0; i < n; i++) {
        root_index.at(ts.at(i)) = i;
    }

    vector<long long> sum(n + 1); 
    for (int i = 0; i < q; i++) {
        long long p, x;
        cin >> p >> x;
        p--;
        sum.at(root_index.at(p)) += x;
        sum.at(root_index.at(p) + ch_num.at(p) + 1) -= x;
    }

    long long s = 0;
    vector<long long> ans(n);
    for (int i = 0; i < n; i++) {
        s += sum.at(i);
        ans.at(ts.at(i)) = s;
    }

    for (int i = 0; i < n; i++) {
        cout << ans.at(i);
        if (i < n - 1) cout << " ";
    }
    cout << endl;
}            

Measured memory_bytes: 31476
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
//#include <bits/stdc++.h>

#define all(v) v.begin(), v.end()
typedef long long ll;
#define rep(i, z, n) for(int i = z; i < n; i++)
//const int INF = 1<<29;
const ll MOD = 1000000007;
#define P pair<int, int>
using namespace std;


int main(){
    string S;
    cin >> S;
    cout << S;
    if(S.at(S.size() - 1) == 's'){
        cout << "es" << endl;
    }
    else{
        cout << "s" << endl;
    }
}

Measured memory_bytes: 3628
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 

*/
/* }}} */

#include <bits/stdc++.h>
using namespace std;

// #define int long long

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = 999999999;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << '\n';
}
template <typename T>
void print(T x) {
  std::cout << x << '\n';
}

/* }}} */

typedef pair<double, double> P;

double cross(P& a, P& b) {
  return a.Fi * b.Se - a.Se * b.Fi;
}

P operator +(P& a, P& b) {
  return mp(a.Fi + b.Fi, a.Se + b.Se);
}
P operator -(P& a, P& b) {
  return mp(a.Fi - b.Fi, a.Se - b.Se);
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  P n[3];
  P p;

  while (cin >> n[0].Fi >> n[0].Se) {
    RREP(i, 2) cin >> n[i].Fi >> n[i].Se;
    cin >> p.Fi >> p.Se;
    bool flg = true;
    P v[] = {n[1] - n[0], n[2] - n[1], n[0] - n[2]};
    int check = 0;
    REP(i, 3) {
      P t = p - n[i];
      check += (cross(v[i], t) > 0) ? 1 : -1;
    }
    if (check == 3 || check == -3) print("YES");
    else print("NO");
  }

  return 0;
}

Measured memory_bytes: 1212
from heapq import heapify, heappush, heappop
import sys
input = sys.stdin.readline

INF = float('inf')

def solve():
    N, M = map(int, input().split())
    Es = []
    for _ in range(M):
        L, R, C = map(int, input().split())
        L, R = L-1, R-1
        Es.append((L, R, C))

    Es.sort()

    PQ = [(0, 0)]

    dists = [INF] * N
    iE = 0
    for tm in range(N):
        while PQ:
            dist, R = PQ[0]
            if tm <= R:
                break
            heappop(PQ)
        else:
            return -1

        dists[tm] = dist
        while iE < M and Es[iE][0] == tm:
            L, R, C = Es[iE]
            heappush(PQ, (dist+C, R))
            iE += 1

    return dists[-1]


print(solve())


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

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

ll days(ll y, int m, int d){
	if(m < 3) y--, m += 12;
	return 365 * (y % 7) + y / 4 - y / 100 + y / 400 + (153 * m + 8) / 5 + d;
}

int main(){
	ll y, m, d, Y, M, D;
	map<pi, ll> memo, prev;
	
	
	cin >> y >> m >> d >> Y >> M >> D;
	if(d > 13){
		d = 1;
		if(++m > 12) m = 1, y++;
	}
	while(d < 13) d++;
	
	if(D < 13){
		D = 31;
		if(--M < 1) M = 12, Y--;
	}
	while(D > 13) D--;
	
	
	ll ans = 0;
	bool flag = 0;
	while(y < Y || y == Y && m <= M){
		
		if(days(y, m, d) % 7 != 5){
			if(++m > 12) m = 1, y++;
			continue;
		}
		ans++;
		if(!flag && memo.count(pi(y % 2800, m))){
			
			ll dy = y - prev[pi(y % 2800, m)];
			ll da = ans - memo[pi(y % 2800, m)];
			
			ll t = (Y - y) / dy;
			t = max(t - 10, 0ll);
			y += dy * t;
			ans += da * t;
			flag = 1;
		}
		
		memo[pi(y % 2800, m)] = ans;
		prev[pi(y % 2800, m)] = y;
		if(++m > 12) m = 1, y++;
	}
	
	cout << ans << endl;
	
	return 0;
}


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

using namespace std;

typedef pair<int,int> pi;

const int mod = 1e9+7;
const int maxn = 200010;

int n, C = 1, ans = 0;
pi a[maxn];
int b[maxn], sum[maxn<<2], cnt[maxn<<2], K[maxn<<2];

int qpow(int x, int y) {
	int ret = 1;
	while (y) {
		if (y & 1) ret = 1LL * ret * x % mod;
		x = 1LL * x * x % mod;
		y >>= 1;
	}
	return ret;
}

void pushUp(int rt) {
	sum[rt] = (sum[rt<<1] + sum[rt<<1|1]) % mod;
	cnt[rt] = cnt[rt<<1] + cnt[rt<<1|1];
}

void modify(int rt, int k) {
	sum[rt] = 1LL * sum[rt] * k % mod;
	K[rt] = 1LL * K[rt] * k % mod;
}

void pushDown(int rt) {
	if (K[rt] != 1) {
		modify(rt<<1, K[rt]);
		modify(rt<<1|1, K[rt]);
		K[rt] = 1;
	}
}

void update(int p, int v, int l, int r, int rt) {
	if (l == r) {
		sum[rt] = (sum[rt] + v) % mod;
		cnt[rt] ++;
		return;
	}
	pushDown(rt);
	int m = (l + r) >> 1;
	if (p <= m) update(p, v, l, m, rt<<1);
	else update(p, v, m+1, r, rt<<1|1);
	pushUp(rt);
}

int query(int L, int R, int l, int r, int rt) {
	if (L > R) return 0;
	if (L <= l && r <= R) return sum[rt];
	int ret = 0;
	pushDown(rt);
	int m = (l + r) >> 1;
	if (L <= m) ret = (ret + query(L, R, l, m, rt<<1)) % mod;
	if (R > m) ret = (ret + query(L, R, m+1, r, rt<<1|1)) % mod;
	return ret;
}

int query_cnt(int L, int R, int l, int r, int rt) {
	if (L > R) return 0;
	if (L <= l && r <= R) return cnt[rt];
	int ret = 0;
	int m = (l + r) >> 1;
	if (L <= m) ret = ret + query_cnt(L, R, l, m, rt<<1);
	if (R > m) ret = ret + query_cnt(L, R, m+1, r, rt<<1|1);
	return ret;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i].first);
		a[i].second = i;
	}
	sort(a+1, a+n+1);
	for (int i = 1; i <= n; i++) {
		if (a[i].first-i+1 <= 0) {
			puts("0");
			return 0;
		}
		b[i] = 1LL*(a[i].first-i)*qpow(a[i].first-i+1, mod-2)%mod;
	}
	for (int i = 1; i <= n; i++) C = 1LL * C * (a[i].first-i+1) % mod;
	for (int i = 1; i <= n; i++) {
		int v = 1LL*(mod+1)/2*C%mod*qpow(a[i].first-i+1, mod-2)%mod;
		ans = (ans + 1LL*v*query(1, a[i].second-1, 1, n, 1)%mod)%mod;
		ans = ((ans + 1LL*C*query_cnt(a[i].second+1, n, 1, n, 1)%mod)%mod+mod-1LL*v*query(a[i].second+1, n, 1, n, 1)%mod)%mod;
		K[1] = 1LL * K[1] * b[i] % mod;
		sum[1] = 1LL * sum[1] * b[i] % mod;
		update(a[i].second, a[i].first-i, 1, n, 1);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 11904
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include<list>
#include<map>
#include<utility>
#include<tuple>
#include<numeric>
#include<set>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),a.end()
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<string> w;
	bool first = 1;
	char c;

	rep(i, n) {
		string x;
		if (first) {
			first = false;
			cin >> x;
			w.push_back(x);
			c = x.back();
		}
		else {
			cin >> x;
			if (x.front() != c) {
				cout << "No" << endl;
				return 0;
			}
			else if (find(all(w), x) != w.end()) {//monndaiari
				cout << "No" << endl;
				return 0;
			}
			else {
				w.push_back(x);
				c = x.back();
			}

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


}

Measured memory_bytes: 256
array = gets.chomp.split("").map(&:to_i)
answer = "No"

array_2 = []

array.each do |number|
  array_2.push(number)
end

array.pop
array_2.shift

answer = "Yes" if array.uniq.length == 1 || array_2.uniq.length == 1

puts answer

Measured memory_bytes: 3836
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n;
    int count = 0;
    cin >> n;
    vector<int> p;
    for (int i = 0; i < n; i++){
        int input;
        cin >> input;
        p.push_back(input);
    }
    for (int i = 0; i < n-2; i++){
        if (p[i]<=p[i+1] && p[i+1]<p[i+2]){
            count = count + 1;
        } else if (p[i]>p[i+1] && p[i+1]>=p[i+2]) {
            count = count + 1;
        }
    }
    cout << count << "\n";
    return 0;
}

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

int a[11],t[11];
vector<int>b[11];
int c[50];
int ans[11];
int d;
void f(int x)
{
    d=0;
    while(x)
    {
        c[d++]=x%2;
        x/=2;
    }
}
int main()
{
    int n,m,u,x;
    int cnt=0;
    scanf("%d%d",&n,&m);
    int k=pow(2,n);
    for(int i=1;i<=m;i++)
    {
        scanf("%d",&u);
        for(int j=1;j<=u;j++)
        {
            scanf("%d",&x);
            b[x].push_back(i);
        }
    }

    for(int i=1;i<=m;i++)scanf("%d",&t[i]);

    for(int i=0;i<k;i++)
    {
        memset(c,0,sizeof c);
        memset(ans,0,sizeof ans);
        f(i);
        for(int j=0;j<n;j++)
        {
            if(c[j]==0)continue;
            int sz=b[j+1].size();
            for(int u=0;u<sz;u++)
            {
                ans[b[j+1][u]]++;
            }
        }
        int ok=1;

        for(int j=1;j<=m;j++)
        {
            if(ans[j]%2!=t[j])
            {
                 ok=0;break;
            }
        }
        if(ok)cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <cmath>

#define pb push_back
#define ll long long
using namespace std;


vector<vector<int>> t;


map<pair<int,int>, int> colours;
vector<pair<int,int>> edg;

ll count = -1;

void dfs(int v, int p, int c) {
    int color = 0;
    ll mx = t[v].size();
    count = max(count, mx);
    for (int u : t[v]) {
        if (u != p) {
            if (color == c) color++;
            colours[{u,v}] = colours[{v, u}] = color;
            dfs(u, v, color);
            color++;
        }
    }
}

int main() {
    int n; cin >> n;
    t.assign(n, {});
    for (int i = 0; i < n - 1; i++) {
        int x, y; cin >> x >> y; x--; y--;
        t[x].pb(y);
        t[y].pb(x);
        edg.pb({x,y});
    }
    dfs(0, -1, -1);
    cout << count << endl;
    for (auto e : edg) {
        cout << colours[e] + 1 << endl;
    }

}

Measured memory_bytes: 20344
c;main(n){while(~scanf("%d",&n)){int m[15][15]={0},x=n/2,y=x+1;for(;c<n*n;m[x++%n][y++%n]=++c)for(;m[x%n][y%n];y++)x--;for(y=-1;++y<n;putchar(10))for(c=x=0;x<n;)printf("%4d",m[x++][y]);}}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-
import numpy as np

def solve():
    H, W = map(int, input().split())
    M = np.array([list(input())])
    for h in range(H-1):
        M = np.vstack((M,np.array([list(input())])))

    h = np.where(~(M == '.').all(axis=1))[0]
    v = np.where(~(M == '.').all(axis=0))[0]
    M = M[h,:][:,v]

    return '\n'.join([''.join([b for b in a]) for a in M])

if __name__ == '__main__':
    print(solve())

Measured memory_bytes: 21628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a;
    long long b=1;
    cin>>a;
    for(int i=1;i<=a;i++)
    {
        b*=i;
        b%=1000000007;
    }
    cout<<b;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[]v = new int[n];
    int[]c = new int[n];
      
    for(int i=0; i<n; i++) {
       	v[i] = sc.nextInt(); 
    }
    for(int i=0; i<n; i++) {
       	c[i] = sc.nextInt(); 
    }
    int all = 0;
    for(int i=0; i<n; i++) {
    	if(v[i] - c[i] > 0){  
    		all += v[i] - c[i];
    }
    }
	System.out.println(all);
    }
}


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

int main(){
    char num[200010];
    scanf("%s", num);
    int len= strlen(num);
    int sum=0;
    for (int i=0; i<len; ++i)
        sum+=num[i]-'0';
    
    if(sum%9==0)
        printf("Yes");
    else
        printf("No");
    return 0;
}

Measured memory_bytes: 1892
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) std::cout << (x) << std::endl
typedef long long ll;

int main() {
    int A, B;
    cin >> A >> B;
    if (A == B) {
        cout << "Draw" << endl;
        return 0;
    }
    if (A == 1) {
        cout << "Alice" << endl;
        return 0;
    }
    if (B == 1) {
        cout << "Bob" << endl;
        return 0;
    }
    if (A < B) {
        cout << "Bob" << endl;
    } else {
        cout << "Alice" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define N 100

int main(void){
    
    char str_base[N];
    char str [N+100];
    char str_in[N];
    
    scanf("%s",str_base);
    
    strcpy(str,str_base);
    strcat(str,str_base);
    
    scanf("%s",str_in);
    
    if(strstr(str,str_in)==NULL){
        printf("No\n");
    }else{
        printf("Yes\n");
    }return 0;
}

Measured memory_bytes: 540
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long
#define f first
#define sc second
bool cmp(int a, int b) {
    return a < b;
}
void solve() {
    int n, tot = 0;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        tot = (tot ^ a[i]);
    }
    for (int i = 0; i < n; i++) {
        cout << (tot ^ a[i]) << " ";
    }
    return;
}
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int t = 1;
    //cin >> t;
    while(t--)
    solve();
}


Measured memory_bytes: 4236
A, B = [input() for i in range(2)]
if len(A) > len(B):
    print("GREATER")
elif len(A) < len(B):
    print("LESS")
elif A == B:
    print("EQUAL")
else:
    if sorted([A,B])[0] == A :
        print("LESS")
    else:
        print("GREATER")

Measured memory_bytes: 3060