akhauriyash/Code-Regression huggingface dataset:
/*
 * DATE : 2017-07-01
 * Algo :
*/
#include<bits/stdc++.h>
using namespace std;
/*------- Constants---- */

#define Long                    long long
#define Ulong                   unsigned long long
#define FOR(I,A,B)              for(long long i=0; i < n ; i++ )
#define REP(i,n)                for(long long i=0; i < n ; i++ )
#define mp                      make_pair
#define pb                      push_back
#define all(x)                  (x).begin(),(x).end()
#define PI                      acos(-1.0)
#define EPS                     1e-9
#define F                       first
#define S                       second
#define di(x)                   int x; input(x)
#define in(x)                   input(x)
#define in2(x,y)                in(x),in(y)
#define in3(x,y,z)              in(x),in2(y,z)
#define lc                      ((n)<<1)
#define rc                      ((n)<<1|1)
#define db(x)                   cout << #x << " -> " << x << endl;
#define ms(ara_name,value)      memset(ara_name,value,sizeof(ara_name))
#define IO                      ios_base::sync_with_stdio(0);cin.tie(0)
#define READ                    freopen("in.txt","r",stdin)
#define WRITE                   freopen("out.txt","w",stdout)
template<class T> inline void input(T &x) {
    register char c = getchar();x = 0;
    int neg = 0;
    for(; ((c<48 || c>57) && c != '-'); c = getchar());
    if(c=='-'){neg = 1;c = getchar();}
    for(; c>47 && c<58 ; c = getchar()){x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x = -x;
}
inline long long bigmod(long long p,long long e,long long M){
    long long ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

/***************************** END OF TEMPLATE *******************************/
const int N = 1001;

int main()
{

    int n;
    cin >> n;
    deque<int> dq;
    for(int i = 0; i < n; i ++ ) {
        int x;
        cin >>x;
        if(i%2 == 0 ) dq.push_back(x);
        else dq.push_front(x);
    }
    vector<int> ans;
    while(!dq.empty()) ans.push_back(dq.front()), dq.pop_front();
    if(n%2) reverse(all(ans));
    for(auto x: ans) printf("%d ",x);

    return 0;
}


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

vector<pe> prime_factorize(ll num)
{
    vector<pe> result;

    for (ll i = 2; i * i <= num; i++)
    {
        if (num % i != 0)
            continue;
        ll e = 0;

        while (num % i == 0)
        {
            e++;
            num /= i;
        }

        result.push_back({i, e});
    }

    if (num != 1)
        result.push_back({num, 1});
    return result;
}

int main(void)
{
    ll N, P;
    cin >> N >> P;
    vector<pe> result = prime_factorize(P);
    ll len = result.size();
    ll ans = 1;
    for(ll i = 0; i < len; i++){
        ll num = result[i].first;
        ll order = result[i].second;
        if(order >= N){
            ll time = order / N;
            ans *= pow(num, time);
        }
    }

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


Measured memory_bytes: 3844
#include <iostream>
using namespace std;
int main()
{
	char cor[16];
	char input[16];
	cor[0] = 'C';
	cor[1] = 'O';
	cor[2] = 'D';
	cor[3] = 'E';
	cor[4] = 'F';
	cor[5] = 'E';
	cor[6] = 'S';
	cor[7] = 'T';
	cor[8] = 'I';
	cor[9] = 'V';
	cor[10] = 'A';
	cor[11] = 'L';
	cor[12] = '2';
	cor[13] = '0';
	cor[14] = '1';
	cor[15] = '6';
	int num = 0;
	for (int i = 0; i < 16; i++)
	{
		cin >> input[i];
		if (input[i] != cor[i])
		{
			num++;
		}
	}
	cout << num;
	return 0;
}


Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    MOD = 10**9 + 7
    count = 0
    for i in range(N-1):
        for j in range(i+1, N):
            if A[i] == A[j]:
                continue
            elif A[i] > A[j]:
                count += K + K*(K-1) // 2
            else:
                k = K - 1
                count += k + k*(k-1) // 2
        count %= MOD

    print(count)
    



main()

Measured memory_bytes: 3188
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#include <string>

using namespace std;

// stringをintに
// string a = "123";
// stoi(a)
//
// intをstringに
// int a = 123;
// to_string(a)
//
// charをintに
// char a = '1';
// (int)a - 48 // asciiコードを値にする

// stringのソート
// string str = "abccba";
// sort(str.begin(), str.end());
//
// ハッシュテーブル
// unordered_map<string, int> mp;
// mp["aabbcc"] = 0;

// 配列Aにcinする
//int main() {
//  int N;
//  cin >> N;
//  vector<int> A(N);
//  for (int i = 0; i < N; i++) {
//    cin >> A.at(i);
//  }
//  return 0;
//}

// 標準入出力
//int main() {
//	int a, b;
//	cin >> a >> b;
//  if (a * b % 2 == 0) {
//	  cout << "Even" << endl;
//  } else {
//	  cout << "Odd" << endl;
//  }
//  return 0;
//}

// 文字列を1文字ずつループ
int main() {
  string str;
  cin >> str;
  int sum = 0;
  bool flag = true;
  for(int i = 0; i < (int)str.size(); ++i){
    char ch = str[i];

    if (i % 2 != 0) {
      if (!(ch == 'L' || ch == 'U' || ch == 'D')) {
        flag = false;
        break;
      }
    } else {
      if (!(ch == 'R' || ch == 'U' || ch == 'D')) {
        flag = false;
        break;
      }
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

class Edge
{
public:
    int to, score;
    Edge(int to, int score){
        this->to = to;
        this->score = score;
    }
};

const int INF = INT_MAX / 2;

int main()
{
    int n, m, p;
    cin >> n >> m >> p;
    vector<vector<Edge> > edges(n), edges2(n);
    for(int i=0; i<m; ++i){
        int a, b, c;
        cin >> a >> b >> c;
        -- a;
        -- b;
        c -= p;
        edges[a].push_back(Edge(b, c));
        edges2[b].push_back(Edge(a, c));
    }

    vector<bool> isAccess(n, true);
    for(int i=0; i<2; ++i){
        int init = (i == 0) ? 0 : n-1;
        queue<int> q;
        vector<bool> v(n, false);
        q.push(init);
        v[init] = true;
        while(!q.empty()){
            int a = q.front();
            q.pop();
            for(const Edge& e : edges[a]){
                if(!v[e.to]){
                    q.push(e.to);
                    v[e.to] = true;
                }
            }
        }
        for(int i=0; i<n; ++i)
            isAccess[i] = isAccess[i] & v[i];
        edges.swap(edges2);
    }

    int times = 0;
    vector<int> dp(n, -INF);
    dp[0] = 0;
    for(;;){
        bool isUpdate = false;
        for(int a=0; a<n; ++a){
            if(!isAccess[a])
                continue;
            for(const Edge& e : edges[a]){
                if(!isAccess[e.to])
                    continue;
                int score = dp[a] + e.score;
                if(score > dp[e.to]){
                    dp[e.to] = score;
                    isUpdate = true;
                }
            }
        }

        if(!isUpdate)
            break;
        ++ times;
        if(times == n){
            cout << -1 << endl;
            return 0;
        }
    }

    cout << max(0, dp[n-1]) << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i=s;i<n;++i)
#define drep(i,s,n) for (int i=n;i>=s;--i)
#define all(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;

int gcd(int a,int b)
{if (a%b == 0) return(b);
 else          return(gcd(b,a%b));}
int lcm(int a,int b)
{return a*b/gcd(a,b);}
void printv(vector<auto> v) {cout<<'[';rep(i,0,v.size()){cout<<v[i]<<',';}cout<<']'<<endl;}
void printvv(vector<vector<auto>> vv)
{
  cout<<'['<<endl;
  rep(q,0,vv.size()){cout<<'[';rep(p,0,vv.at(q).size())cout<<vv.at(q).at(p)<<',';cout <<']'<<endl;}
  cout<<']'<<endl;
}
void solve(); int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}
int step_x[] = {-1,0,0,1};
int step_y[] = {0,-1,1,0};
ll INF=10e12;
//------------------------------------------------------------
ll x;
void solve() {
  cin>>x;

  ll a=0,b=0;

  while (true)
  {
    b=0;
    bool flag=false;
    ll currentx = x-pow(a,5);

    if(currentx==0)
    {b=0;break;}
    else if (currentx<0)
    {
      while (true)
      {
        ++b;
        ll b5 = -1*pow(b,5);

        if(b5<currentx) break;
        else if(b5==currentx) {flag=true; break;}
      }
      if(flag) break;
    }
    else
    {
      while (true)
      {
        --b;
        ll b5 = -1*pow(b,5);

        if(b5>currentx) break;
        else if(b5==currentx) {flag=true; break;}
      }
      if(flag) break;
    }

    ++a;
  }

  cout << a<<' '<<b<<endl;

  return;
}


Measured memory_bytes: 4044
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
lst1 = list(map(int,readline().split()))

lst1.sort(reverse=True)
ans = 0
idx = 0
remain = 1
for i in range(n):
    if i == 0:
        continue
    if remain:
        remain -= 1
    else:
        remain = 1
        idx += 1
    ans += lst1[idx]
    


print(ans)

Measured memory_bytes: 93004
//temp##############################################

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void strInit(char str[]);//str[]を0で初期化
void extIntStr(char str[],int data[]);//str[]から数値(int)を抽出しdata[]に順次格納
void incsort(int data[],int len);//data[]を昇順ソート
void decsort(int data[],int len);//data[]を降順ソート
void printIntArray(int data[],int len);//data[]をprint

void strInit(char str[]){
    int len=strlen(str);
    for(int i=0;i<len;i++){
        str[i]=0;
    }
}

void extIntStr(char str[],int data[]){
    int length=strlen(str);
    str[length-1]=' ';
    char buff[12];
    int j,index;
    index=j=0;
    for(int i=0;i<length;i++){
        if(str[i]!=' '){
            buff[j++]=str[i];
        }else{
            data[index++]=atoi(buff);
            strInit(buff);
            j=0;
        }
    }
}

void incsort(int data[],int len){
    for(int i=0;i<len-1;i++){
        for(int j=i+1;j<len;j++){
            if(data[i]>data[j]){
                int tmp=data[i];
                data[i]=data[j];
                data[j]=tmp;
            }
        }
    }
}

void decsort(int data[],int len){
    for(int i=0;i<len-1;i++){
        for(int j=i+1;j<len;j++){
            if(data[i]<data[j]){
                int tmp=data[i];
                data[i]=data[j];
                data[j]=tmp;
            }
        }
    }
}

void printIntArray(int data[],int len){
    for(int i=0;i<len;i++){
        printf("%d\n",data[i]);
    }
}

//temp##############################################

int main(){
    int n;
    scanf("%d ",&n);
    int *data;
    data=(int*)malloc(sizeof(int)*n);
    char *get;
    get=(char*)malloc(sizeof(char)*11*n+1);
    fgets(get,11*n+1,stdin);
    extIntStr(get,data);
    free(get);
    int ans=0;
    int flag=1;
    for(int i=0;i<n-1;i++){
        ans+=data[i+1]-data[i];
        if(ans>0){
            ans=0;
        } else if(ans<-1){
            flag=0;
            break;
        }
    }
    if(flag)printf("Yes");
    else printf("No");
    free(data);
}


Measured memory_bytes: 1664
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#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>

#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>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

//constexpr int inf = 2147483647;
//constexpr int64_t inf64 = 9223372036854775807;
//constexpr int mod = 1e9+7;

bool f(int n) {
  string s = to_string(n);
  if(s.size() % 2 == 1) return true;
  return false;
}

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

  int n;
  cin >> n;

  int res = 0;
  rep(i,n) if(f(i+1)) res++;

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
  var L, R int
  fmt.Scan(&L, &R)
  ans:=2018

  for i:=L; i<L+673; i++ {
    if i > R-1 {
      break
    }
    for j:=L+1; j<L+673; j++ {
      if j > R {
      break
      }
      tmp := (i*j)%2019
    	if tmp < ans {
      	ans = tmp
   		 }
    }
  }
  fmt.Println(ans)
}

Measured memory_bytes: 1752
#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

typedef unordered_map<int,unordered_map<int,int>> double_map;

int dfs(double_map &g, int pos, int end, int flow, vector<bool> &arrived) {
    if(pos==end) return flow;
    arrived[pos] = true;
    for(pair<int,int> p : g[pos]) {
        int next = p.first;
        int capacity = p.second;
        if(!arrived[next]&&capacity>0) {
            int res = dfs(g,next,end,min(flow,capacity),arrived);
            if(res>0) {
                g[pos][next] -= res;
                g[next][pos] += res;
                if(g[pos][next]<=0) g[pos].erase(next);
                return res;
            }
        }
    }
    return 0;
}

int max_flow(int v, double_map &g, int s, int e) {
    int ans = 0;
    while(true) {
        vector<bool> arrived(v);
        int flow = dfs(g,s,e,1<<30,arrived);
        if(flow<=0) break;
        else ans += flow;
    }
    return ans;
}

int main() {
    int h,w;
    cin >> h >> w;
    int tx,ty;
    int sx,sy;

    double_map g;
    for(int i = 0; i < h; i++) {
      string s;
      cin >> s;
      for(int j = 0; j < w; j++) {
        char c = s.at(j);
        if(c!='.') {
          g[1+i][1+h+j] = 1;
          g[1+h+j][1+i] = 1;
        }
        if(c=='S') {
          sx = j; sy = i;
          g[0][1+i] = 10001;
          g[0][1+h+j] = 10001;
        }else if(c=='T') {
          tx = j; ty = i;
          g[1+i][1+h+w] = 10001;
          g[1+h+j][1+h+w] = 10001;
        }
      }
    }
    if(tx==sx||ty==sy) {
      cout << -1 << endl;
      return 0;
    }

    int ans = max_flow(1+h+w+1,g,0,1+h+w);
    cout << ans << endl;
}


Measured memory_bytes: 1280
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  string s;
  while(getline(cin, s) && s!= "."){
    bool ok = true;
    stack<char> stk;
    REP(i, s.size()){
      if(s[i] == '(' || s[i] == '['){
        stk.push(s[i]);
      }else if(s[i] == ')' || s[i] == ']'){
        if(stk.empty()){
          ok = false;
          break;
        }
        char t = stk.top(); stk.pop();
        if(t == '(' && s[i] == ']'){
          ok = false;
           break;
        }
        if(t == '[' && s[i] == ')'){
          ok = false;
           break;
        }
      }
    }
    if(ok && stk.empty()) cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }

  return 0;
}

Measured memory_bytes: 0
/** coder Mohammad Al-Hussein *_^ */
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define mp make_pair
#define All(v) v.begin(),v.end()
#define mod  1000000007
#define write freopen("output.txt","w",stdout)
#define read freopen("test (1).txt","r",stdin)
#define FIO std::ios_base::sync_with_stdio(false);
using namespace std;
int a[105][105];
int main()
{
    int W,H,n;
    cin >> W >> H >> n;
    while(n--)
    {
        int x,y,c;
        cin >> x >> y >> c;

        if(c == 1)
            for(int i=1; i<=H; i++)
                for(int j=1; j<=x; j++)
                    a[i][j] = 1;

        if(c == 2)
            for(int i=1; i<=H; i++)
                for(int j=x+1; j<=W; j++)
                    a[i][j] = 1;

        if(c == 3)
            for(int i=1; i<=y; i++)
                for(int j=1; j<=W; j++)
                    a[i][j] = 1;

        if(c == 4)
            for(int i=y+1; i<=H; i++)
                for(int j=1; j<=W; j++)
                    a[i][j] = 1;

//        for(int i=1; i<=H; i++)
//        {
//            for(int j=1; j<=W; j++)
//                cout << a[i][j] << " ";
//            cout << '\n';
//        }
    }
    int sum = 0;
    for(int i=1;i<=H;i++)
        for(int j=1;j<=W;j++)
        sum += (!a[i][j]);

    cout << sum << endl;




    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int x, y, temp;
	while(1){
		scanf("%d %d", &x, &y);	
		if(x == 0 && y == 0) break;
		else if(x>y){
			temp = x;
			x = y;
			y = temp;
		}
		printf("%d %d\n", x, y);
	}
	return 0;
}



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

#define REP(i, n) for (int i = 0; i < n; ++i)

int main(void){
    const char c[4] = {'A', 'C', 'G', 'T'}, cc[4] = {'T', 'G', 'C', 'A'};
    char b;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> b;
    REP(i, 4) {
        if (b == c[i]) {
            cout << cc[i] << "\n";
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int a, b, c; scanf("%d%d%d", &a, &b, &c);
	int ans = 0;
	FOR(i, a, b+1) if(i%c == 0) ans++;
	printf("%d\n", ans);
}


Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
int a[101];
int main()
{
	int n,m;
	cin>>n>>m;
	double sum=0;
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	double line=sum/(4*m)*1.0;
	int num=0;
	for (int i=1;i<=n;i++)
	{
		if (a[i]>=line)
		{
			num++;
		}
	}
	if (num>=m)
	{
		cout<<"Yes"<<endl;
	}
	if (num<m)
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include<bitset>
#include<cstdlib>
#include<set>
#include<unordered_map>
#define l(x) (x<<1)
#define r(x) ((x<<1)|1)
#define low(x) (x&(-x))
#define IL inline
#define reg register
#define LL long long
#define N 500010
#define MOD 998244353
#define MO 1000000007
#define INF 0x3f3f3f3f
using namespace std;

int T,n,m,i,j,k,x,y,z,Ans,sum,cnt;
int a[N],b[N];
char c[N];

struct Data{
	int x,y;
}d[N];

IL int Abs(int x){return (x<0)?-x:x;}
IL void Swap(int &a,int &b){a^=b^=a^=b;}
IL int Min(int a,int b){return (a<b)?a:b;}
IL int Max(int a,int b){return (a>b)?a:b;}
IL bool cmp(const Data a,const Data b){return a.x<b.x;}

IL LL Mi(LL x,LL y){
	LL p=x,t=1,Res=1;
	for (;t<=y;(t&y)?Res=(Res*p)%MOD:0,p=(p*p)%MOD,t<<=1);
	return Res;
}

IL int read(){
	int p=0,f=1;	char	c=getchar();
	while (c<48||c>57)	{if (c=='-')	f=-1;	c=getchar();}
	while (c>=48&&c<=57)	p=(p<<1)+(p<<3)+c-48,c=getchar();
	return p*f;
}

int main(){
	#ifdef __Marvolo
	freopen("zht.in","r",stdin);
	freopen("zht.out","w",stdout);
	#endif
	x=read();	y=read();	z=read();
	if (y*z>=x)	puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
string s;
int main()
{
	cin>>s;
	if((s[0]==s[1]&&s[1]==s[2])||(s[1]==s[2]&&s[2]==s[3]))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n; cin >> n;
    set<int> s;
    rep(i, n) {
        int a; cin >> a;
        auto it = s.find(a);
        if (it != s.end()) s.erase(a);
        else s.insert(a);
    }
    cout << s.size() << endl;
}


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

int64_t MOD = 1000000007;
double PI = 3.141592653589793;

int main()
{
    string N;
    cin >> N;
    int ans = 0;
    for (int i = 0; i < N.size(); i++)
    {
        ans += (N[i] - '0');
        ans %= 9;
    }
    if (ans == 0)
        cout << "Yes";
    else
        cout << "No";
}

Measured memory_bytes: 3776
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <string.h>

using namespace std;

struct Point {
  int y;
  int x;
  int cost;
  Point() {;}
  Point(int y1, int x1, int c) : y(y1), x(x1), cost(c) {;}
};

int width;
int height;

char str[100];
char tile[30][30];
int dist[11][10];
int dirty_y[10];
int dirty_x[10];
int map[30][30];
bool check[30][30];
int dirty_tile;
int memo[1024][10];

int calc(int depth, int visit, int where) {
  if (memo[visit][where] != -1) { return memo[visit][where]; }
  if (depth == dirty_tile) { return 0; }
  int ret = 0x0f0f0f0f;
  for (int i = 0; i < dirty_tile; i++) {
    if (visit & (1 << i)) { continue; }
    int next_visit = visit | (1 << i);
    ret = min(ret, calc(depth + 1, next_visit, i) + dist[where][i]);
  }
  return memo[visit][where] = ret;
}

int main() {
  while (scanf("%d %d", &width, &height), width != 0 && height != 0) {
    fgets(str, 99, stdin);
    for (int i = 0; i < height; i++) {
      fgets(tile[i], 29, stdin);
    }
    int start_y;
    int start_x;
    dirty_tile = 0;
    for (int y = 0; y < height; y++) {
      for (int x = 0; x < width; x++) {
        if (tile[y][x] == '*') {
          dirty_y[dirty_tile] = y;
          dirty_x[dirty_tile] = x;
          map[y][x] = dirty_tile;
          dirty_tile++;
        } else if (tile[y][x] == 'o') {
          start_y = y;
          start_x = x;
        }
      }
    }
    dirty_y[dirty_tile] = start_y;
    dirty_x[dirty_tile] = start_x;
    map[start_y][start_x] = dirty_tile;
    memset(dist, -1, sizeof(dist));
    static const int dy[4] = { 1, -1, 0, 0 };
    static const int dx[4] = { 0, 0, 1, -1 };
    for (int i = 0; i < dirty_tile + 1; i++) {
      queue<Point> que;
      que.push(Point(dirty_y[i], dirty_x[i], 0));
      memset(check, false, sizeof(check));
      while (!que.empty()) {
        Point now = que.front();
        que.pop();
        if (check[now.y][now.x]) { continue; }
        check[now.y][now.x] = true;
        if (tile[now.y][now.x] == '*') {
          dist[i][map[now.y][now.x]] = now.cost;
        }
        for (int i = 0; i < 4; i++) {
          int ny = now.y + dy[i];
          int nx = now.x + dx[i];
          if (ny < 0 || ny >= height || nx < 0 || nx >= width || check[ny][nx] || tile[ny][nx] == 'x') { continue; }
          que.push(Point(ny, nx, now.cost + 1));
        }
      }
    }
    for (int i = 0; i < dirty_tile; i++) {
      if (dist[dirty_tile][i] == -1) {
        puts("-1");
        goto next_loop;
      }
    }
    memset(memo, -1, sizeof(memo));
    printf("%d\n", calc(0, 0, dirty_tile));
next_loop:
    ;
  }
}

Measured memory_bytes: 968
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N,X,Y = map(int,readline().split())
ans = [0]*N
for i in range(1,N):
    for j in range(i+1,N+1):
        dist = min(j-i,abs(i-X)+1+abs(j-Y),abs(i-Y)+1+abs(j-X))
        ans[dist]+=1
print('\n'.join(str(n) for n in ans[1:]))

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

int main(){
  int N;
  cin >> N;
  
  vector<int> L(N);
  for (int i=0; i<N; i++){
    cin >> L.at(i);
  }
  
  int cnt = 0;
  for (int i = 0; i < N; i++){
    for (int j = i+1; j < N; j++){
      for (int k = j+1; k < N; k++){
        if (L.at(i) == L.at(j)
            || L.at(j) == L.at(k)
            || L.at(k) == L.at(i)){
          continue;
        } else {
          int max_L = max(L.at(i), max(L.at(j), L.at(k)));
          int min_L = min(L.at(i), min(L.at(j), L.at(k)));
          int mid_L = L.at(i)+L.at(j)+L.at(k) - max_L - min_L;
          if (max_L < min_L + mid_L) cnt++;
        }
      }
    }
  }
      cout << cnt;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<map>
#define ll long long
#define ull unsigned long long 
#define inf 0x3f3f3f3f
#define maxn 40000010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20];
	int len=0;
	if(x<0)putchar('-'),x=-x;
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
std::map<std::pair<ull,ull>,int>cnt;
char s[40];
int n;
int main()
{
	n=read();
	scanf("%s",s);
	for(int i=0;i<1<<n;i++){
		ull t1=0,t2=0;
		for(int j=0;j<n;j++)
			if(i&(1<<j))t1=t1*233+s[j];
			else t2=t2*2333+s[j];
		++cnt[std::make_pair(t1,t2)];
	}
	ll ans=0;
	for(int i=0;i<1<<n;i++){
		ull t1=0,t2=0;
		for(int j=0;j<n;j++)
			if(i&(1<<j))t1=t1*233+s[2*n-1-j];
			else t2=t2*2333+s[2*n-1-j];
		ans+=cnt[std::make_pair(t1,t2)];
	}
	writeln(ans);
	return 0;
}

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

using namespace std;

int top_digit(int i) {
  int d = 0;
  while (i > 0) {
    d = i % 10;
    i /= 10;
  }
  return d;
}

int tail_digit(int i) { return i % 10; }

int main() {
  int N;
  cin >> N;
  vector<vector<long long>> D(10, vector<long long>(10));
  for (int i = 1; i <= N; i++) {
    D[top_digit(i)][tail_digit(i)]++;
  }
  long long ans = 0;
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      ans += D[i][j] * D[j][i];
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
  int x,k;
  cin>>k>>x;
  if(k*500>=x) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	int n,m;
	cin >> n >> m;
	if(m%n == 0)
	{
		int ans = m/n;
		cout << ans << "\n";
	}
	else
	{
		int x = m/n;
		int ans = 1;
		for(int i = 2; i <= x; i++)
		{
			if(m%i == 0)
			ans = max(ans,i);
		}
		cout << ans << "\n";
	}
}

Measured memory_bytes: 256
#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, m, x;
	cin >> n>>m>> x;
	int t;
	int rc = 0,lc=0;
	rep(i, m) {
		cin >> t;
		if (t < x)rc++;
		else lc++;
	}
	cout << min(rc, lc) << endl;


}



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

N,M=map(int,input().split())
#- 1要望 a→c,b→c分断要望に対して、a<bならb→cだけ考慮すればいい -#
want_list = [0]*(N+1)
for _ in range(M):
    a,b = map(int,input().split())
    want_list[b]=max(want_list[b],a)


#-分断した時の橋とindexと要望を見比べて、要望を満たしていないならカウントする-#
cnt = 0
cutNo = 0
for idx,val in enumerate(want_list):
    if val >cutNo:
        cutNo = idx-1
        cnt += 1
print(cnt)


Measured memory_bytes: 11832
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;

    if(a * b % 2 == 0)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 17.08.2019 15:25:05       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  set<pair<int, int>> s;
  for (int i = 0; i < n; i++) {
    s.emplace(b[i], i);
  }
  long long ans = 0;
  while (!s.empty()) {
    int i = s.rbegin()->second;
    s.erase(--s.end());
    int step = b[(i + 1) % n] + b[(i + n - 1) % n];
    if ((b[i] - a[i]) % step == 0) {
      ans += (b[i] - a[i]) / step;
      b[i] = a[i];
      continue;
    }
    if (step >= b[i]) {
      cout << -1 << '\n';
      return 0;
    }
    ans += b[i] / step;
    b[i] %= step;
    if (b[i] < a[i]) {
      cout << -1 << '\n';
      return 0;
    }
    s.emplace(b[i], i);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 11264
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <math.h>
int main()
{   long long i,n,cnt=0,ans=0;
    char s[200002];
    scanf("%s",s);
    n=strlen(s);
    for(i=0;i<n;i++){
        if(s[i]=='B'){
            cnt++;
            //printf("s[%lld]is B cnt=%lld,ans=%lld\n",i,cnt,ans);
        }if(s[i]=='W'){
            ans+=cnt;
            //printf("s[%lld]is W cnt=%lld,ans=%lld\n",i,cnt,ans);
        }
    }
    printf("%lld",ans);

    return 0;
}


Measured memory_bytes: 384
import sys

n = int(input())
d1 = []
d2 = []
count = 0
for i in range(n):
    a, b = map(int, input().split())
    d1.append(a)
    d2.append(b)

for j in range(n-2):
    count = 0
    if d1[j] == d2[j]:
        count += 1
        if d1[j+1] == d2[j+1]:
            count += 1
            if d1[j+2] == d2[j+2]:
                count += 1
                print("Yes")
                sys.exit()

if count < 3:
    print("No")

Measured memory_bytes: 9144
class ModCombination:
    """
    nCk (mod m)を扱うクラス
    """

    def __init__(self, mod, n_max):
        """
        イニシャライザ
        予め 1~nの階乗と階乗の逆元を計算しておく
        :param mod: 法
        :param n_max: nの最大値(100,000で約1秒)
        """
        self.mod = mod
        self.n_max = n_max
        self.facts = [1, 1]
        self.inverses = [None, 1]
        self.fact_inverses = [1, 1]

        for i in range(2, self.n_max + 1):
            self.facts.append(self.facts[i - 1] * i % self.mod)
            # self.inverses.append(mod_inverse(i, self.mod))
            self.inverses.append(
                self.mod - self.inverses[self.mod % i] *
                (self.mod // i) % self.mod
            )
            self.fact_inverses.append(
                self.fact_inverses[i - 1] * self.inverses[i] % self.mod
            )

    def mod_combination(self, n, k):
        """
        nCk (mod m)を計算する
        :param n: n
        :param k: k
        :return: nCk (mod m)
        """
        if k > n:
            raise ValueError
        elif k == n:
            return 1
        elif k == 0:
            return 1

        denominator = self.fact_inverses[k] * self.fact_inverses[n - k] % self.mod
        return self.facts[n] * denominator % self.mod


def mod_pow(a, n, mod):
    """
    二分累乗法による a^n (mod m)の実装
    :param a: 累乗の底
    :param n: 累乗の指数
    :param mod: 法
    :return: a^n (mod m)
    """

    result = 1
    a_n = a
    while n > 0:
        if n & 1:
            result = result * a_n % mod
        a_n = a_n * a_n % mod
        n >>= 1
    return result


MOD = 10 ** 9 + 7
K = int(input())
S = input()

n = len(S)

comb = ModCombination(mod=MOD, n_max=n + K)

ans = 0
for i in range(K + 1):
    ans += (mod_pow(25, i, MOD) * comb.mod_combination(i + n - 1, n - 1)) % MOD * mod_pow(26, K - i, MOD)
    ans %= MOD

print(ans)


Measured memory_bytes: 253592
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    string s,t; cin >> s >> t;
    rep(i,s.size()+10){
        if(s == t)return puts("Yes")*0;
        string g;
        g+= t.back();
        t.pop_back();
        g += t;
        t = g;
    }
    cout << "No" << endl;
}




Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
using ll = long long;
using namespace std;

/*
ll GCD(ll a, ll b) {
return b ? GCD(b, a%b) : a;
}

sort(a, a + N, greater<int>())   // descend
sort(a, a+N)                    //  ascend


** nCk
void comb(vector<vector <long long int > > &v) {
for (int i = 0; i < v.size(); i++) {
v[i][0] = 1;
v[i][i] = 1;
}
for (int k = 1; k < v.size(); k++) {
for (int j = 1; j < k; j++) {
v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
}
}
}


** main内でnCn~nC0 生成 **
vector<vector<long long int> > v(n + 1, vector<long long int>(n + 1, 0));
comb(v);


*/



int main() {
	string s;
	cin >> s;
	ll cnt = 0;
	rep(i,0,s.length()-1){
		if (s[i] != s[i + 1]) cnt++;
	}
	cout << cnt;
}


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


int keta(){

int i,d,n1,n2,sum,c;

int a,b;

while(cin >> n1 >> n2){
    if(n1 == -1 or n2 == -1)  break;
   while(n1 < 0 or n1 > 1000000 or n2 < 0 or n2 > 1000000){
      cin >> n1 >> n2;
   }
   if(n1 >= 0 and n1 <= 1000000 and n2 >= 0 and n2 <= 1000000){
       a=n1;
       b=n2;
       c=0;
       sum=a+b;
       while((sum/10)!=0){
           c++;
           sum=sum/10;
        }
       cout << c+1 << "\n";
   }
}
return 0;
}

int main(){

keta();


    return 0;
}

Measured memory_bytes: 1160
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn main() {
    let v: Vec<u32> = read_vec();
    let (n,m) = (v[0],v[1]);
    let a: Vec<Vec<i32>> = read_vec2(n);
    let mut b: Vec<i32> = Vec::new();
    for _ in 0..m {
        b.push(read());
    }

    let t: Vec<i32> = a.iter().map(|x|{
        x.iter().zip(&b).map(|(i,j)| {
            i * j
        }).sum()
    }).collect();

    for x in t {
        println!("{}", x);
    }
}



Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

int ans[510][510];

void solve(int l,int r,int depth){
	//cout << l << " " << r << endl;
	if(r - l == 1) return;
	solve(l,(l + r) / 2,depth + 1);
	solve((l + r) / 2,r,depth + 1);
	for(int i = l;i < (l + r) / 2;i++){
		for(int j = (l + r) / 2;j < r;j++){
			ans[i][j] = depth;
		}
	}
}

signed main(){
	int n;
	cin >> n;
	solve(0,n,1);
	for(int i = 0;i < n;i++){
		for(int j = i + 1;j < n;j++) cout << ((j == i + 1) ? "" : " ") << ans[i][j];
		cout << endl;
	}
}

Measured memory_bytes: 2432
/* ex 7_1
   yumizmiz */

#include <stdio.h>

//二次元座標を表現する構造体
typedef struct point{
  int x_elem;
  int y_elem;
}point;

point shift_point(point point1, point point2){
    point point3;
    //point1=>point2に行く方向のベクトルを求めて，90度反時計回りに回転させた方向ベクトルをpoint2に足せば，次の正方形の頂点の位置がわかる．
    point3.x_elem = point2.x_elem - (point2.y_elem - point1.y_elem);
    point3.y_elem = point2.y_elem + (point2.x_elem - point1.x_elem);
    return point3;
}

int main(void){
    //正方形の四点
    point point1, point2, point3, point4;
    scanf("%d %d %d %d", &point1.x_elem, &point1.y_elem, &point2.x_elem, &point2.y_elem);
    
    point3 = shift_point(point1, point2);
    point4 = shift_point(point2, point3);

    printf("%d %d %d %d\n", point3.x_elem, point3.y_elem, point4.x_elem, point4.y_elem);
    return 0;
}

Measured memory_bytes: 1704
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
input = sys.stdin.buffer.readline

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

# A[i]: iの次の要素
# M: 何個先まで調べたいか
class Doubling(object):
    def __init__(self,A,M):
        self.N = len(A)
        self.kmax = M.bit_length()
        # nex[i][k]: i番目の2^k先
        self.nex = [[-1]*self.kmax for _ in range(N)]
        for i in range(N):
            self.nex[i][0] = A[i]
        
        for k in range(1,self.kmax):
            for i in range(N):
                if self.nex[i][k-1] == -1:
                    self.nex[i][k] = -1
                else:
                    self.nex[i][k] = self.nex[self.nex[i][k-1]][k-1]
    
    # i番目の要素のx個先
    def query(self,i,x):
        for k in range(self.kmax)[::-1]:
            if i == -1:
                break
            if (x >> k) & 1:
                i = self.nex[i][k]
        return i

N,K = LI()
A = LI()
A = list(map(lambda x: x-1, A))

d = Doubling(A,K)
print(d.query(0,K)+1)

Measured memory_bytes: 199880
N, M = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(N)]

dp = [[0]*3 for _ in range(M)]
ans = [0]*8

for roop in range(8):
    a, b, c = 1, 1, 1
    if roop&1 == 1:
        a = -1
    if (roop>>1)&1 == 1:
        b = -1
    if (roop>>2)&1 == 1:
        c = -1
    dp = [[-a*10**20, -b*10**20, -c*10**20] for _ in range(M+1)]
    dp[0][0] = 0
    dp[0][1] = 0
    dp[0][2] = 0
    for i in range(N):
        for j in range(min(i, M-1), -1, -1):
            if a*(dp[j][0]+S[i][0])+b*(dp[j][1]+S[i][1])+c*(dp[j][2]+S[i][2]) > a*dp[j+1][0]+b*dp[j+1][1]+c*dp[j+1][2]:
                dp[j+1][0] = dp[j][0] + S[i][0]
                dp[j+1][1] = dp[j][1] + S[i][1]
                dp[j+1][2] = dp[j][2] + S[i][2]
    ans[roop] = a*dp[M][0]+b*dp[M][1]+c*dp[M][2]

print(max(ans))

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

using namespace std;

#define int long long
#define nl '\n'

#define st first
#define nd second
#define ins insert

#define pb push_back
#define mp make_pair

#define hashmap unordered_map
#define hashset unordered_set

signed main(){
	int n; cin >> n; hashset<string> ans;
	for (int i = 0; i < n; i++){
		string s; cin >> s; ans.ins(s);
	}
	cout << ans.size();
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 998244353LL
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;


#define maxn 300005

const int mxBit = 28 ;
int a[maxn] , b[maxn] ;

int main()
{
    int n ;

    scanf("%d",&n) ;
    for(int i=1 ; i<=n ; i++) scanf("%d",&a[i]) ;
    for(int i=1 ; i<=n ; i++) scanf("%d",&b[i]) ;

    int ans = 0 ;

    for(int i=0 ; i<=mxBit ; i++)
    {
        int all = (1<<(i+1)) - 1 ;
        vector <int> v ;
        for(int j=1 ; j<=n ; j++)
        {
            v.pb( (b[j]&all) ) ;
        }
        sort( v.begin() , v.end() ) ;

        i64 c = 0 ;

        for(int j=1 ; j<=n ; j++)
        {
            int val = (a[j]&all) ;
            int r = (1<<i) ;
            int r1 = r-val , r3 = ( r +(1<<(i+1)) - val ) ;
            r += ( ( 1<<i ) -1 ) ;
            int r2 = r - val , r4 = ( r+(1<<(i+1)) - val ) ;

      //      printf("%d %d %d %d %d %d %d %d %d\n",i,j,r1,r2,r3,r4,val,all,a[j]) ;

            c += ( upper_bound( v.begin() , v.end() , r2 ) - lower_bound(v.begin(),v.end(),r1) ) ;
            c += ( upper_bound( v.begin() , v.end() , r4 ) - lower_bound(v.begin(),v.end(),r3) ) ;
        }

     //   printf("%lld\n",c) ;

        if( c%2 ) ans |= (1<<i) ;
    }

    printf("%d\n",ans) ;

    return 0 ;
}


Measured memory_bytes: 3676
n, m = map(int, input().split(" "))

count = [0 for x in range(0, n)]
ac_list = set()
ans_ac = 0
ans_pn = 0
for i in range(0, m):
    ps, s = input().split(" ")
    ps = int(ps)

    if s == "AC":
        if ps not in ac_list:
            ans_pn += count[ps - 1]
            ans_ac += 1
            ac_list.add(ps)

    else:  # WA
        count[ps - 1] += 1

print("%d %d" % (ans_ac, ans_pn))


Measured memory_bytes: 12796
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    int n;
    cin >>n;
    vector<int> p(n);
    rep(i,n){
        cin >>p[i];
        p[i] = (p[i]-1==i);
    }

    int st = 0;
    int ans = 0;
    while(st<n){
        if(p[st]==0) ++st;
        else{
            int i=st;
            while(i<n && p[i]==1) ++i;
            int d=i-st;
            ans += (d+1)/2;
            st=i;
        }
    }
    cout << ans << endl;
    return 0;
}


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

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

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

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

ll A[100005];

int main()
{
    int N;
    cin >> N;
    REP(i, N)
    {
        cin >> A[i];
    }
    sort(A, A + N, [](ll a, ll b) { return a > b; });
    vector<ll> v;
    FOR(i, N, 1)
    {
        if (A[i] == A[i - 1])
        {
            v.push_back(A[i++]);
            continue;
        }
    }
    v.push_back(0);
    v.push_back(0);
    cout << v[0] * v[1] << endl;
    return 0;
}

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

typedef long long ll;

int main(){
    ll x,y;
    cin>>x>>y;
    ll p=1;
    ll cnt=0;
    while(true){
        cnt++;
        p=p*2;
        if(p*x>y){
            break;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double EPS = 1e-8;

int main(){
	string str;
	char conv;
	while(cin>>str){
		cin >> conv;

		if(conv == 'X') break;
		//under score
		if(count(str.begin(),str.end(),'_')){
			if(conv == 'L'){
				//str[0] = 'A' + (str[0]-'a');
				string res="";
				for(int i=0;i+1<str.size();i++){
					if(str[i]=='_' && ('a' <= str[i+1] && str[i+1] <= 'z')){
						str[i+1]='A'+(str[i+1]-'a');
						i++;
					}
				}

				string::iterator it = remove(str.begin(),str.end(),'_');
				str.erase(it,str.end());
			}
			else if(conv == 'U'){
				str[0] = 'A' + (str[0]-'a');
				for(int i=0;i+1<str.size();i++){
					if(str[i]=='_' && ('a' <= str[i+1] && str[i+1] <= 'z')){
						str[i+1]='A'+(str[i+1]-'a');
						i++;
					}
				}

				string::iterator it = remove(str.begin(),str.end(),'_');
				str.erase(it,str.end());
			}
		}
		//Upper CamelCase
		else if('A' <= str[0] && str[0] <= 'Z'){
			if(conv == 'L'){
				str[0] = 'a' + (str[0]-'A');
			}
			else if(conv == 'D'){
				string res="";
				str[0] = 'a' + (str[0]-'A');

				res.push_back(str[0]);
				for(int i=1;i<str.size();i++){
					if('A' <= str[i] && str[i] <= 'Z'){
						res.push_back('_');
						res.push_back('a' + (str[i]-'A'));
					}
					else{
						res.push_back(str[i]);
					}
				}

				str = res;
			}

		}
		//Lower CamelCase
		else{
			if(conv == 'U'){
				str[0] = 'A' + (str[0]-'a');
			}
			else if(conv == 'D'){
				string res="";
				str[0] = 'a' + (str[0]-'a');
				res.push_back(str[0]);
				for(int i=1;i<str.size();i++){
					if('A' <= str[i] && str[i] <= 'Z'){
						res.push_back('_');
						res.push_back('a' + str[i]-'A');
					}
					else{
						res.push_back(str[i]);
					}
				}
				str = res;
			}
		}

		cout << str << endl;
	}
}

Measured memory_bytes: 0