akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<long long> vl;
typedef vector<vector<ll>> vll;
typedef vector<bool> vb;
typedef set<int> si; 
typedef queue<int> qi;
typedef stack<int> sti;
typedef priority_queue<int> pqi;
#define fori(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,b,a) for(int i = (b); i >= (a); --i)
#define all(a) (a).begin(), (a).end()
//#define __builtin_popcountll bitCountLL
//#define __builtin_popcount bitCount
//__builtin_ctz 末尾0的个数, __builtin_clz 前导0的个数
//__builtin_ffs 最后一个1的位置
#define maxn 100005
#define Mod 1000000007
const int INF = 2e9;
const ll ML = 4e18;
    
void solve() {
    int n;
    cin >> n;
    int r = 0;
    fori(i,1,n+1) {
        r = ( r * 10 + 7) % n;
        if(r == 0) {
            cout << i;
            return;
        }
    }
    cout << -1;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
	//cout.precision(30); cout << fixed;
//	freopen("D:\\data_in.txt", "r", stdin);
   
    solve();
   
    /*
    clock_t start,finish;
    start = clock();
    
    finish = clock();
    cout << "\n" << (double)(finish - start) / (double)(CLOCKS_PER_SEC) * 1000 << "ms" << endl;
    */
    return 0;
}

/***************************************************************
 question:
 idea:
 tag:
 record:
 ***************************************************************/


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

using namespace std;

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

  int k = S.length();

  int rest = 15 - k;

  int n = 0;
  for (int i = 0; i < k; i++) {
    if (S[i] == 'o') {
      n++;
    }
  }

  if (rest + n >= 8) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> PP;

vector<PP> a;
vector<PP> b;
int main() {
  int n,m;
  cin >> n >> m;
  for(int i = 0; i < m; i++) {
    int p,y;
    cin >> p >> y;
    a.push_back(PP(p,P(y,i)));
  }

  sort(a.begin(),a.end());
  int k = 1;
  int id = a[0].first;
  for(int i = 0; i < m;) {
    while(i <= m && a[i].first == id) {
      b.push_back(PP(a[i].second.second,P(id,k)));
      k++;
      i++;
    }
    
    k = 1;
    id = a[i].first;
  }

  /* for(int i = 0; i < b.size(); i++) {
    cout << b[i].first <<"   "<<b[i].second.first<<"   "<<b[i].second.second << endl;
    }*/
  sort(b.begin(),b.end());

  for(int i = 0; i < b.size(); i++) {
    int s = b[i].second.first;
    int t = b[i].second.second;
    int ss = 6, tt = 6;
    while(s > 0) {
      s /= 10;
      ss--;
    }
    while(t > 0) {
      t /= 10;
      tt--;
    }
    for(int j = 0; j < ss; j++) cout << 0;
    cout << b[i].second.first;
    for(int j = 0; j < tt; j++) cout << 0;
    cout << b[i].second.second << endl;;
  }
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 105;
const ll LINF = 1e18 + 5;
int k;
string s;
ll dp[N][2][2][4];
ll dfs(int pos, int lead, int limit, int state) 
{
	if(pos==-1) return !state;
	ll &x = dp[pos][lead][limit][state];
	if(~x) return x;
	x = 0;
	int up = limit ? s[pos]-'0' : 9;
	for(int i=0;i<=up;i++)
	{
		if(i&&state) x += dfs(pos-1, 0, limit&&i==s[pos]-'0', state-1);
		else if(i==0) x += dfs(pos-1, lead, limit&&i==s[pos]-'0', state);
	}
	return x;	
}
ll solve() 
{
	memset(dp, -1, sizeof(dp)); 
	reverse(all(s));
	int pos = sz(s);
	return dfs(pos-1, 1, 1, k);
}
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> s >> k;
 	cout << solve();
	return 0;
}


Measured memory_bytes: 256
while True:
    N,Q=map(int,raw_input().split())
    if N==Q==0:break
    L=[]
    for	i in range(N):
	en,eby,wy=raw_input().split()
	L.append((int(wy)-int(eby)+1,int(wy),en))
    L.sort()
    for	i in range(Q):
	q=input()
	for j in range(N):
            if L[j][0]<=q<=L[j][1]:
		print L[j][2],q-L[j][0]+1
		break
        else:
            print "Unknown"

Measured memory_bytes: 4420
#include<bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) REP(i,0,n)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    int ma = INT_MIN, mi = INT_MAX;
    rep(i, n) {
        int a;
        cin >> a;
        ma = max(ma, a);
        mi = min(mi, a);
    }
    cout << ma - mi << endl;
    return 0;
}




Measured memory_bytes: 256
s = input()
ans = 1
for i in range(len(s)//2):
    if s[i] != s[-1-i]:
        ans = 0
        break
for i in range(len(s)//2//2):
    if s[i] != s[len(s)//2-1-i]:
        ans = 0
if ans == 0:
    print("No")
else:
    print("Yes")

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

int main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if (a + b + c >= 22)
		printf("bust");
	else if (a + b + c <= 21)
		printf("win");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=100000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    string s,t;cin>>s>>t;
    unordered_map<char,string> m,mm;
    string ans="Yes";
    for(ll i=0;i<s.size();i++){
        if(m[s[i]].size()!=0){
            if(m[s[i]][0]!=t[i]){
                ans="No";
            }
        }else{
            m[s[i]]=t[i];
        }
    }
    for(ll i=0;i<t.size();i++){
        if(mm[t[i]].size()!=0){
            if(mm[t[i]][0]!=s[i]){
                ans="No";
            }
        }else{
            mm[t[i]]=s[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}



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

int main() {
  int A;
  int B;
  char op;
  cin >> A >> op >> B;
  
  int sum = 0;
  int dec = 0;

  if (op == '+') {
    sum = A + B;
    cout << sum << endl;  
  }
  else if (op == '-') {
    dec = A - B;
    cout << dec << endl;
  }
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        c: [[i32; 3]; 3],
    }
    for a1 in 0..101 {
        let b1 = c[0][0] - a1;
        let b2 = c[1][0] - a1;
        let b3 = c[2][0] - a1;
        let a2 = c[0][1] - b1;
        let a3 = c[0][2] - b1;
        if a2 + b2 == c[1][1] &&
           a2 + b3 == c[2][1] &&
           a3 + b2 == c[1][2] &&
           a3 + b3 == c[2][2] {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//string s;
char s[500010];
int pre[500010];
ll ans=0;
int main()
{
    memset(pre,0,sizeof(pre));
    scanf("%s",s+1);
    int len = strlen(s+1)+1;
    for(int i=len-1; i; --i)
    {
        if(s[i]=='<')
            pre[i]=0;
        else
            pre[i]=pre[i+1]+1;
    }
    for(int i=1; i<len; ++i)
    {
        if(s[i]=='<')
            pre[i+1]=max(pre[i+1],pre[i]+1);
    }
    for(int i=1; i<=len; i++)
    {
        ans+=pre[i];
    }
    //cout<<ans<<endl;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2688
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int[] a = new int[9];
    boolean[] b = new boolean[9];
    for (int i=0; i<9; i++){
      a[i] = scan.nextInt();
      b[i] = false;
    }

    int n = scan.nextInt();
    for (int j=0; j<n; j++){
      int t = scan.nextInt();
      for (int k=0;k<9;k++){
        if (a[k] == t){
          b[k] = true;
          continue;
        }
      }
    }

    for (int i=0; i<3; i+=1){
      if ((b[i] == true)&&(b[i+3] == true)&&(b[i+6] == true)){
        System.out.println("Yes");
        return;
      }
    }

    for (int i=0; i<7; i+=3){
      if ((b[i] == true)&&(b[i+1] == true)&&(b[i+2] == true)){
        System.out.println("Yes");
        return;
      }
    }

    if ((b[0] == true)&&(b[4] == true)&&(b[8] == true)){
      System.out.println("Yes");
      return;
    }

    if ((b[2] == true)&&(b[4] == true)&&(b[6] == true)){
      System.out.println("Yes");
      return;
    }

    System.out.println("No");
  }
}


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    while(true){
        C -= B;
        if(C<=0){
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if(A<=0){
            cout << "No" << endl;
            break;
        }
    }
}


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

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

  int ac = 0;
  int wa = 0;
  int tle = 0;
  int re = 0;

  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s == "AC") {
      ac++;
    } else if (s == "WA") {
      wa++;
    } else if (s == "TLE") {
      tle++;
    } else if (s == "RE") {
      re++;
    }
  }

  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
vector<int> v[5050];
vector<ll> dp[5050][2];
int sz[5050];
ll a[5050];
void dfs(int x,int p){
    sz[x]=0;
    dp[x][0].resize(1);
    dp[x][1].resize(1);
    for(auto to:v[x]){
        if(to==p)continue;
        dfs(to,x);
        vector<ll> ret0(sz[x]+sz[to]+1,longinf),ret1(sz[x]+sz[to]+1,longinf);
        rep(i,sz[x]+1)rep(j,sz[to]+1){
            ret0[i+j]=min(ret0[i+j],min(dp[x][0][i],dp[x][1][i])+min(dp[to][0][j],dp[to][1][j]));
            ret1[i+j]=min(ret1[i+j],dp[x][1][i]+dp[to][1][j]);
        }
        sz[x]+=sz[to];
        dp[x][0]=ret0;
        dp[x][1]=ret1;
    }
    ++sz[x];
    dp[x][0].push_back(longinf);
    dp[x][1].push_back(longinf);
    for(int i=sz[x]-1;i>=0;--i){
        dp[x][0][i+1]+=a[x];
        if(dp[x][0][i]+a[x]<0)dp[x][0][i+1]=min(dp[x][0][i+1],0LL);
        if(dp[x][1][i]<longinf&&a[x]>0)dp[x][0][i+1]=min(dp[x][0][i+1],0LL);
        if(a[x]>0){
            dp[x][1][i+1]+=a[x];
            if(dp[x][1][i]<longinf||dp[x][0][i]+a[x]<0)dp[x][1][i+1]=0;
        }
        else {
            if(dp[x][1][i]+a[x]<0||dp[x][0][i]+a[x]<0)dp[x][1][i+1]=0;
            else dp[x][1][i+1]=longinf;
        }
    }
    dp[x][0][0]+=a[x];
    dp[x][1][0]=(a[x]>0?min(longinf,dp[x][1][0]+a[x]):longinf);
}



int main(){
    int n;
    cin>>n;
    rep(i,n)cin>>a[i];
    rep(i,n-1){
        int x,y;
        cin>>x>>y;
        --x;--y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs(0,-1);
    rep(i,n+1){
        if(dp[0][0][i]<0||dp[0][1][i]<longinf){
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 225664
/* ex3_4
   kento_titech*/
#include<stdio.h>
int main(void){
    int i;
    int N,n,r;
    scanf("%d",&N);
    for(i=1;i<10;++i){
        n=N/i;
        r=N%i;
        if(0<n && n<10 && r==0){
            printf("Yes\n");
            break;
        }
    }
    if(i==10){
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define fst first
#define scd second
long long gcd(long long x, long long y)
{
	if(x < y)
	{
		swap(x, y);
	}
	if(y == 0)
	{
		return x;
	}
	return gcd(y, x % y);
}
signed main()
{
	long long a, b;
	scanf("%lld%lld", &a, &b);
	printf("%lld\n", a * b / gcd(a, b));
}


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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define inf 100000000000010
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool isprime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

struct CustomCompare
{
    bool operator()(const int& lhs, const int& rhs)
    {
        return lhs < rhs;
    }
};

bool comp(pair<ll, ll>a,pair<ll,ll>b)
{
    return a.fi>=b.fi;
}

ll builtin_popcount(ll x)
{
    ll cnt = 0;
    for(ll i=60;i>=0;i--)
    {
        if((1LL<<i)&x)cnt++;
    }
    return cnt;
}

ll addmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a+b)%mod;
}
ll mulmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
/*
const int mxn = 5*(1e6) +10;
vi spf(mxn);
void sieve()
{
    for(ll i =0;i<mxn;i++)spf[i]  = i;
    for(ll i=2;i<mxn;i+=2)spf[i] = 2;
    for(ll i = 3;i*i<mxn;i++)
    {
        if(spf[i]==i)
        {
            for(ll j = i*i;j<mxn;j+=i)
            {
                if(spf[j]==j)spf[j] = i;
            }
        }
    }
}
*/

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
ll l,r,d; cin>>l>>r>>d;
ll x = r/d,y = (l-1)/d;
cout<<x-y<<endl;
return 0;

}
/*
1
8
1 7 3 4 7 6 2 9
*/


Measured memory_bytes: 3628
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(int i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

struct node {
	int id;
	int state;
	vector<int> link;
	vector<ll> cost;
};

void setstate(vector<node>& nod, int s) {
	for (node& n : nod)n.state = -1;
	nod[s].state = 1;
}

void search(vector<node>& nod, int s, ll m, vector<int>& dst) {
	for (int i = 0; i < nod[s].link.size(); ++i) {
		int c = nod[s].link[i];
		if (nod[c].state != -1) continue;

		nod[c].state = 1;
		if (nod[s].cost[i] <= m) {
			dst.push_back(nod[c].id);
			search(nod, c, m - nod[s].cost[i], dst);
		}
	}
}

int main() {
	ll N, M, L;
	cin >> N >> M >> L;
	vector<node> nod(N);
	vector<vector<ll>> g(N),d(N);
	vector<int> link;
	ll inf = (ll)1e18;
	REP(i, 0, N) {
		g[i].resize(N, inf);
		d[i].resize(N, inf);
	}
	REP(i, 0, M) {
		ll a, b,c;
		cin >> a >> b>>c;
		--a; --b;
		g[a][b] = c;
		g[b][a] = c;
	}
	REP(k, 0, N)REP(i, 0, N)REP(j, 0, N)g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
	REP(i, 0, N) REP(j, 0, N) if (g[i][j] <= L) d[i][j] = 1;
	REP(k, 0, N)REP(i, 0, N)REP(j, 0, N)d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	ll Q;
	cin >> Q;
	REP(i, 0, Q) {
		ll s, t;
		cin >> s >> t;
		--s; --t;
		ll ans = d[s][t];
		if (ans >= inf) PRI(-1);
		else PRI(ans - 1);
	}
	return 0;
}




Measured memory_bytes: 5012
#include<bits/stdc++.h>
#define rg register 
using namespace std;
int main(){
	rg int n,k,cnt,h;
	scanf("%d%d",&n,&k);
	for(rg int i=0;i<n;++i){
		scanf("%d",&h);
		if(h>=k) cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 256
import itertools
n, m = map(int, input().split())
path =[[False]*n for i in range(n)]
for i in range(m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  path[a][b] = True
  path[b][a] = True
ans = 0
for i in itertools.permutations(range(n), n):
  if i[0] == 0:
    for j in range(n):
      if j == n - 1:
        ans += 1
        break
      if not path[i[j]][i[j+1]]:
        break
        
print(ans)

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

void Main()
{
  int a;
  cin >> a;
  cout << a + a*a + a*a*a << endl;
}

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


Measured memory_bytes: 3648
from itertools import permutations

s = int(input())

alist = [int(x) for x in input().split(maxsplit=(s-1))]
blist = [int(x) for x in input().split(maxsplit=(s-1))]

if alist == blist:
    print(0)
else:
    perm = permutations(sorted(alist))

    count = 1
    a = 0
    b = 0
    for i in list(perm):
        if alist == list(i):
            a = count
            pass
        elif blist == list(i):
            b = count
            pass
        count += 1

    print(abs(a-b))


Measured memory_bytes: 8052
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define endl '\n'
using ll=long long;
 
const int INF=1e9+5;
const ll lim=(ll)3e16;
const int N=3e3+5;
const int mod=1e9+7;
const ll oo=1e18+5;
 
int n;
vector<ll> dp;
vector<ll> pre;

void go(int id,const vector<int>& tmp,ll score,int mask,int add_mem){
	if(id==(int)tmp.size()){
		dp[mask]=max(dp[mask],score+pre[add_mem]);
		return;
	}
	go(id+1,tmp,score,mask,add_mem);
	go(id+1,tmp,score,mask^(1<<tmp[id]),add_mem^(1<<tmp[id]));
}

int main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
	cin>>n;
	vector<vector<ll>> in(n,vector<ll>(n));
	for(int i=0;i<n;++i){
		for(int j=0;j<n;++j){
			cin>>in[i][j];
		}
	}
	pre.resize(1<<n);
	for(int mask=0;mask<(1<<n);++mask){
		for(int i=0;i<n;++i){
			if(mask&(1<<i)){
				for(int j=i+1;j<n;++j){
					if(mask&(1<<j)){
						pre[mask]+=in[i][j];
					}
				}
			}
		}
	}
	// dp[mask] the total score if we grouped rabbits from mask already
	dp.resize(1<<n,-oo);
	dp[0]=0;
	for(int mask=0;mask<(1<<n);++mask){
		vector<int> tmp;
		for(int i=0;i<n;++i){
			if(!(mask&(1<<i))){
				tmp.push_back(i);
			}
		}
		go(0,tmp,dp[mask],mask,0);
	}
	cout<<dp[(1<<n)-1];
	return 0;
}



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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> grid(h);
  for (auto&& e : grid) {
    cin >> e;
  }

  string res = "Yes";
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (grid[i][j] == '#') {
        bool b1 = i > 0 && grid[i - 1][j] == '#';
        bool b2 = j > 0 && grid[i][j - 1] == '#';
        bool b3 = i + 1 < h && grid[i + 1][j] == '#';
        bool b4 = j + 1 < w && grid[i][j + 1] == '#';
        if (!(b1 || b2 || b3 || b4)) {
          res = "No";
        }
      }
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N,M;
  cin >> N >> M;
  vector<string> A(N),B(M);
  rep(i,N) cin >> A[i];
  rep(j,M) cin >> B[j];
  bool ans = true;
  rep(i,N-M+1)
  {
    rep(j,N-M+1)
    {
      ans = true;
      rep(k,M)
      {
        rep(l,M)
        {
          if(B[k][l]!=A[i+k][j+l])
          {
            ans = false;
          }
        }
      }
      if(ans==true)
      {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3608
import heapq

buf = []
heapq.heapify(buf)

k,t = map(int,input().split())
arr = list(map(int,input().split()))

for a in arr:
    heapq.heappush(buf,-a)

ans = 0

bef = None
while True:
    if not bef and len(buf) == 0:
        break
    if len(buf) == 0:
        ans += abs(bef)
        break
    else:
        top = heapq.heappop(buf)
        if bef:
            heapq.heappush(buf,bef)

        if top == -1:
            bef = None
        else:
            top += 1
            bef = top




    # print(buf,bef)


print(ans)

Measured memory_bytes: 44120
#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;

int log(int x, int k){

      if(x) return 1 + log(x / k, k);
      else return 0;

}

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int x, k;
      cin >> x;
      cin >> k;
      cout << log(x, k);

}


Measured memory_bytes: 256
module.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";var r=n(1);n(2)(r.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,n){"use strict";var r=n(3),i=n(5);t.exports=function(t){var e=new r(t);i(e)}},function(t,e,n){"use strict";var r=n(4);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new r(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,n){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,n){"use strict";t.exports=function(t){var e=t.in();console.log(e*e*e)}}]);


Measured memory_bytes: 15428
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
typedef long long ll;
typedef pair<int,int> Pii;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int n=s.size();
	
	for(int i=0;i<n-2;i++){
		if(s[i]==s[i+1]){
			cout<<i+1<<" "<<i+2<<endl;
			return 0;
		}else if(s[i]==s[i+2]){
			cout<<i+1<<" "<<i+3<<endl;
			return 0;
		}
	}
	if(s[n-2]==s[n-1]){
		cout<<n-1<<" "<<n<<endl;
		return 0;
	}
	cout<<"-1 -1"<<endl;
	return 0;
	
}
	

Measured memory_bytes: 512
N= input()
list=[ int(N[i]) for i in range(4)]

tmp = list[0]+list[1]+list[2]+list[3]
if tmp == 7:
    print("%d+%d+%d+%d=7"%(list[0],list[1],list[2],list[3]))
else:
    tmp = tmp - 2*list[3]
    if tmp == 7:
        print("%d+%d+%d-%d=7"%(list[0],list[1],list[2],list[3]))
    else:
       tmp = tmp - 2*list[2]
       if tmp == 7:
            print("%d+%d-%d-%d=7"%(list[0],list[1],list[2],list[3]))
       else:
           tmp = tmp + 2*list[3]
           if tmp == 7:
                print("%d+%d-%d+%d=7"%(list[0],list[1],list[2],list[3]))
           else:
              tmp = tmp - 2*list[1]
              if tmp == 7:
                  print("%d-%d-%d+%d=7"%(list[0],list[1],list[2],list[3]))
              else:
                 tmp = tmp + 2*list[2]
                 if tmp == 7:
                     print("%d-%d+%d+%d=7"%(list[0],list[1],list[2],list[3]))
                 else:
                    tmp = tmp - 2*list[3]
                    if tmp == 7:
                        print("%d-%d+%d-%d=7"%(list[0],list[1],list[2],list[3]))
                    else:
                            print("%d-%d-%d-%d=7"%(list[0],list[1],list[2],list[3]))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b;
    cin>>a>>b;
    if(a*b%2==0)
        cout<<"Even"<<endl;
    else
        cout<<"Odd"<<endl;

//main();
    return 0;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
 
int main(){
  int n, a[120000], b, c=1;
  cin >> n;
  rep(i, n) {
    cin >> b;
    a[b-1] = c;
    c++;
  }
  rep(i, n) {
    cout << a[i] << ' ';
  }
}

Measured memory_bytes: 1152
n = int(input())
s = [0] * n
t = [0] * n
for i in range(n):
  s[i], t[i] = input().split()
  t[i] = int(t[i])
x = input()

sleep = False
time = 0
for i in range(n):
  if sleep:
    time += t[i]
  elif s[i] == x:
    sleep = True

print(time)

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}

#define MAX 500000
int L[MAX/2 + 2], R[MAX/2 + 2];
int cnt;


signed main()
{   
    gearup;
    map<string,string> mp;
    mp["Sunny"] = "Cloudy";
    mp["Cloudy"] = "Rainy";
    mp["Rainy"] = "Sunny";
    string s; cin >> s;
    cout << mp[s] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
int main() {
  int n, x;
  cin >> n >> x;
  if(500*n>=x) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //int:2*10**9
typedef long double ld;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define vec2(name,i,j) vector<vector<ll>> name(i,vector<ll>(j))
#define vec2f(name,i,j,k) vector<vector<ll>> name(i,vector<ll>(j,k))
#define vec3(name,i,j,k) vector<vector<vector<ll>>> name(i,vector<vector<ll>>(j,vector<ll>(k)))
#define vec3f(name,i,j,k,l) vector<vector<vector<ll>>> name(i,vector<vector<ll>>(j,vector<ll>(k,l)))
#define vec4(name,i,j,k,l) vector<vector<vector<vector<ll>>>> name(i,vector<vector<vector<ll>>>(j,vector<vector<ll>>(k,vector<ll>(l))))
#define vec4f(name,i,j,k,l,m) vector<vector<vector<vector<ll>>>> name(i,vector<vector<vector<ll>>>(j,vector<vector<ll>>(k,vector<ll>(l,m))))
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653
#define INF 100000000000000 //14
//cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);

int main(){
    ll x, y; cin >> x >> y;
    if (y<2*x||y>4*x||y%2) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
typedef long long ll;

const int MAX_N = 1e5 + 1;

ll A[MAX_N];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }
    ll k = N * (N + 1) / 2;
    if (sum % k) {
        cout << "NO" << endl;
        return 0;
    }
    k = sum / k;
    ll kk = 0;
    for (int i = 0; i < N; i++) {
        ll d = A[(i + 1) % N] - A[i] - k;
        if (d == 0) continue;
        else if (d < 0) {
            if (d % N) {
                cout << "NO" << endl;
                return 0;
            }
            else kk -= d / N;
        }
        else {
            cout << "NO" << endl;
            return 0;
        }
    }
    if (kk != k) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int l;
#define fastIO              ios::sync_with_stdio(false), cin.tie(0)
#define pf                  push_front
#define pb                  push_back
#define popb                pop_back()
#define popf                pop_front()
#define loop(i,n)           for(int i=0;i<n;i++)
#define loop1(i,n)           for(int i=1;i<n;i++)
#define loopx(i,x,n)        for(int i=x;i<n;i++)
#define loopr(i,n)          for(int i=n-1;i>=0;i--)
#define loop1e(i,n)          for(int i=1;i<=n;i++)
#define loopxe(i,x,n)          for(int i=x;i<=n;i++)
#define F first
#define S second
#define LB lower_bound
#define UB upper_bound
#define vc vector
#define vll vector<long long>
#define pll pair<long long,long long>
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define INT_BITS 32
#define  st                  l t; cin>>t;
#define  sn                  l n; cin>>n;
//#define  unordered_map<l,l>  u;
#define MOD1 1000
l maxproduct(l a[],l n)
{
    if(n==0)
    return -1;
    l c_max = a[0];
    l c_min = a[0];
    l f_max = a[0];
    loop1(i,n)
    {
        l tmp = c_max;
        c_max = max(max(c_max*a[i],c_min*a[i]),a[i]);
        c_min = min(min(tmp*a[i],c_min*a[i]),a[i]);
        if(c_max>f_max)
        f_max = c_max;
    }
    return f_max;

}
l solve(l a[], l n)
{
    l dp[n];
    dp[0]=0;
    dp[1] = abs(a[0]-a[1]);
    for(l i=2;i<n;i++)
    {
        l x = dp[i-1] + abs(a[i]-a[i-1]);
        l y = dp[i-2] + abs(a[i]-a[i-2]);
        dp[i] = min(x,y);
    }
    return dp[n-1];

}
int main() {
    fastIO;
	//st;
	//while(t--)
    //{
       l n;
       cin>>n;
       l a[n];
       loop(i,n)
       cin>>a[i];
        cout<<solve(a,n)<<"\n";
      //      }
	return 0;
}


Measured memory_bytes: 1792
a, b = map(int, input().split())

if a==1 or b==1:
  if a>b:
    print('Bob')
  elif b>a:
    print('Alice')
  else:
    print('Draw')
else:
  if a>b:
    print('Alice')
  elif b>a:
    print('Bob')
  else:
    print('Draw')

Measured memory_bytes: 9096
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   string s,t;
   cin >> s >> t;
   int n = s.length();
   if(s == t.substr(0,n)){
      cout << "Yes\n";
   }else{
      cout << "No\n";
   }
   return 0;
}

Measured memory_bytes: 3668
from sys import stdin
from itertools import combinations
from math import factorial
import numpy as np
import math
import bisect

n = int(stdin.readline().rstrip())

c = [0]*n#次の駅までの時間
s = [0]*n#開通してからの時間
f = [0]*n#次の列車が来るまでの間隔

for i in range(1,n):
    c[i],s[i],f[i] = [int(x) for x in stdin.readline().rstrip().split()]

for j in range(n):
    time = 0
    fi = [0]*n
    for i in range(1+j,n):
        if time < s[i]:
            time = s[i]
        elif time%f[i] != 0:
            time += f[i]-time%f[i]
        time += c[i]
        fi[i] = time
    print(fi[-1])

Measured memory_bytes: 12528
#!/usr/bin/env python3
n,k,c = map(int, input().split())
S = input()
inds = [i for i,s in enumerate(S) if s == "o"]
ls = []
prev = -100000000
cnt = 0
for i in inds:
    if i - prev > c:
        ls.append(i)
        prev = i
        cnt += 1 
    if cnt > k:break

rs = []
cnt = 0
prev = 1000000000
for i in inds[::-1]:
    if prev - i > c:
        rs.append(i)
        prev = i    
        cnt += 1 
    if cnt > k:break

ans = []
cnt = 0
for l,r in zip(ls,rs[::-1]):
    if l == r:
        print(l+1)
        cnt += 1
if cnt == 0:
    print()

Measured memory_bytes: 17484
//Prison 

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end()
#define pb push_back
const int inf = 2147483647;

signed main (){
    int n,m;cin>>n>>m;
    int left=1,right=n;
    rep(i,0,m){
        int l,r;
        cin>>l>>r;
        left=max(left,l);
        right=min(right,r);
    }
    cout << (right-left+1<0 ? 0 : right-left+1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int n, k;
    cin >> n >> k;
    priority_queue<P> que;
    for(int i = 0; i < n; ++i){
        int t, d;
        cin >> t >> d;
        --t;
        que.emplace(d, t);
    }
    map<int, int> cnt;
    multiset<int> st;
    vector<vector<int>> pre(n);
    ll S = 0;
    while(k-- > 0){
        P p = que.top();
        que.pop();
        S += p.first;
        ++cnt[p.second];
        st.emplace(p.first);
        pre[p.second].emplace_back(p.first);
    }
    for(int i = 0; i < n; ++i){
        if(!pre[i].size())  continue;
        sort(pre[i].rbegin(), pre[i].rend());
        st.erase(st.find(pre[i][0]));
    }
    S += (ll)cnt.size() * cnt.size();
    ll ans = S;
    while(!st.empty() && !que.empty()){
        P p = que.top();
        que.pop();
        if(cnt.find(p.second) != cnt.end()) continue;
        S -= (ll)cnt.size() * cnt.size();
        S -= *(st.begin());
        st.erase(st.begin());
        S += p.first;
        ++cnt[p.second];
        S += (ll)cnt.size() * cnt.size();
        chmax(ans, S);
    }
    cout << ans << endl;
}

Measured memory_bytes: 12660
const fs = require('fs')
const reader = (s: string) => (s.split(/\n/))
 
function Main(input: string) {

  const aaa = reader(input);
  //const [N,L] = aaa[0].split(' ').map(i =>(parseInt(i,10)));
  aaa.shift();
  const iii = aaa.sort();

  let moji = '';
  aaa.forEach(a=>{
    moji = moji + a
  });

  console.log(moji);


}
 
Main(fs.readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
const int M = 1000000007;

int main() {
    int n, t;
    cin >> n >> t;
    int M = 1000000007;
    int ans = M;
    for (int i = 0; i < n; ++i) {
        int c, s;
        cin >> c >> s;
        if (s <= t) {
            ans = min(ans, c);
        }
    }
    if (ans == M) {
        cout << "TLE\n";
    }
    else {
        cout << ans << "\n";
    }
    return 0;
}


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

count = [0]*n
calc = [0]*n
for i in a:
    count[i-1] +=1
for i in range(n):
    if count[i] ==0 or count[i] ==1:
        continue
    else:
        calc[i] = int(count[i]*(count[i]-1)/2)
ans = sum(calc)

for i in range(n):
    print(ans- int(count[a[i]-1]*((count[a[i]-1]-1)/2)) + int((count[a[i]-1]-1)*((count[a[i]-1]-2)/2)))




Measured memory_bytes: 85324
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

int count(char c) {
  if (c == 'a') return 0;
  else return 'z' + 1 - c;
}

int main(int argc, char* argv[])
{
  string s;
  cin >> s;
  ll k;
  cin >> k;
  int n = s.size();
/*
  for(int i = 0; i < n; i++){
    if(s[i] == 'a') continue;
    if('z' - s[i] + 1 <= k){
      k -= 'z' - s[i] + 1;
      s[i] = 'a';
    }
  }
*/
  rep(i, n) {
    if (s[i] == 'a') continue;
    int num = count(s[i]);
    if ('z' - s[i] + 1 <= k) {
      k -= 'z' - s[i] + 1;
      s[i] = 'a';
    }
    if (k == 0) break;
  }

  // 最後に残った K を処分
  if (k > 0) {
    k %= 26;
    s[n - 1] += k;

    if (s[n - 1] > 'z') s[n - 1] -= 26;
  }

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>

using namespace std;

int main(void) {
  int i, j, K;
  string S, tmp, prev_S;
  cin >> S;
  
  K = 0;
  tmp = "";
  prev_S = "";
  for(i = 0; i < S.size(); i++) {
    tmp += S[i];
    if(tmp != prev_S) {
      K++;
      prev_S = tmp;
      tmp = "";
    }
  }
  
  cout << K << endl;
  
  return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>

int main()
{
  int N, A;
  std::cin >> N >> A;

  std::vector<int> xs;
  for(int i=0; i<N; i++)
  {
    int x;
    std::cin >> x;
    x -= A;
    xs.push_back(x);
  }

  std::sort(xs.begin(), xs.end());
 
  const int zeroCount = std::count(xs.begin(), xs.end(), 0);
  auto lowers = std::vector<int>(xs.begin(), std::lower_bound(xs.begin(), xs.end(), 0));
  auto highers = std::vector<int>(std::upper_bound(xs.begin(), xs.end(), 0), xs.end());

  std::vector<long long> lowerSumPattern(2501,0);
  lowerSumPattern[0] = 1;
  for(const auto& e : lowers)
  {
    for(int i=2500-std::abs(e); 0<=i; i--)
    {
      lowerSumPattern[i+std::abs(e)] += lowerSumPattern[i];
    }
  }
  
  std::vector<long long> higherSumPattern(2501,0);
  higherSumPattern[0] = 1;
  for(const auto& e : highers)
  {
    for(int i=2500-e; 0<=i; i--)
    {
      higherSumPattern[i+e] += higherSumPattern[i];
    }
  }

  long long count = 0;
  for(int i=1; i<=2500; i++) { count += lowerSumPattern[i] * higherSumPattern[i]; }

  long long result = (1LL<<zeroCount)-1 + (1LL<<zeroCount)*count;
  std::cout << result << std::endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <ostream>

void print_array(const int a[], int n) {
  for (int i = 0; i < n; ++i) {
    if (i > 0)
      std::cout << " ";
    std::cout << a[i];
  }
  std::cout << std::endl;
}

int main(int argc, char *argv[]) {
  int n;
  std::cin >> n;
  int a[10];
  for (int i = 0; i < n; ++i)
    a[i] = i + 1;

  do {
    print_array(a, n);
  } while (std::next_permutation(a, a + n));
}



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

int32_t main()
{
	int i,h,n,sum=0;
	cin>>h>>n;
	int a[n];
	for(i=0;i<n;i++)cin>>a[i],sum+=a[i];
	
	if(h<=sum)cout<<"Yes\n";
	else cout<<"No\n";

	
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"

using namespace std;
using ll = long long;

constexpr int MOD = 1e9 + 7;
int h, w;

template <typename T, typename U>
int cul_path(const T &s, int sx, int sy, U &memo)
{
	if (memo[sx][sy] >= 0)
		return memo[sx][sy];
	int ret = 0;
	if (sx + 1 < h)
	{
		if (s[sx + 1][sy] != '#')
		{
			ret += cul_path(s, sx + 1, sy, memo);
		}
	}
	if (sy + 1 < w)
	{
		if (s[sx][sy + 1] != '#')
		{
			ret += cul_path(s, sx, sy + 1, memo);
		}
	}
	return memo[sx][sy] = ret % MOD;
}

int main()
{
	cin >> h >> w;
	vector<string> s(h);
	for (int i = 0; i < h; ++i)
	{
		cin >> s[i];
	}
	vector<vector<int>> memo(h, vector<int>(w, -1));
	memo[h - 1][w - 1] = 1;
	cout << cul_path(s, 0, 0, memo) << endl;
}

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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;

const ll MOD = 1000000007;

int main() {
	int n;
	string s;
	map<string, int> um;

	cin >> n;
	int ma = 0;

	REP(i,n) {
		cin >> s;
		if(um.count(s) > 0) {
			um[s] = um[s] + 1;
			if(ma < um[s]) ma = um[s];
		} else {
			um.insert(make_pair(s, 1));
			if(ma < um.count(s)) ma = um.count(s);
		}
	}

	PQR<string> ps;
	// for (auto const& [k, v] : um) {
	// 	if(v == ma) {
	// 		ps.push(k);
	// 	}
	// }
	// auto itr = begin(ps);
	// while(itr != end(ps) {
	// 	if(itr->second == ma) {
	// 		ps.push(itr->first);
	// 	}
	// 	itr = next(itr, 1);
	// }


	for(auto itr = um.begin(); itr != um.end(); ++itr) {
		if(ma == itr->second) {
			ps.push(itr->first);
		}
    }
	while (!ps.empty()) {
		cout << ps.top() << endl;
		ps.pop();
	}


	return 0;
}



Measured memory_bytes: 27636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int a;
	string s;
	cin >> a;
	cin >> s;
	if(a<3200){
		s = "red";
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
dp = [0 for _ in range(N+1)]
skip = {}

for _ in range(M):
    skip[int(input())] = 1

dp[1] = 1
if N >= 2:
    dp[2] = 2

if 1 in skip:
    dp[1] = 0
    if N >= 2:
        dp[2] = 1
if 2 in skip:
    if N >= 2:
        dp[2] = 0

for i in range(3, N+1):
    if i in skip:
        continue
    dp[i] = (dp[i-1] + dp[i-2]) % 1000000007

print(dp[N])


Measured memory_bytes: 84500