akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int check(string s) {
	int i = 1;
	while ( i < s.size()) {
		if ( s.substr(0,i)==s.substr(i, s.size()-i)){
			return 1;
		}
		++i;
	}
	return 0;
}

int main() {
	string s;
	int ans;


	cin >> s;

	while (true)
	{
		s.pop_back();
		if (check(s)) {
			cout << s.size() << endl;
			return 0;
		}
	}
	return 0;

}

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

using namespace std;

int main(void) {
    long n, m;
    cin >> n >> m;

    priority_queue<long> q;
    for(int i=0; i<n; i++) {
        long a;
        cin >> a;
        q.push(a);
    }

    for(int i=0; i<m; i++) {
        long t = q.top(); q.pop();
        t /= 2;
        q.push(t);
    }

    long r = 0;
    while(!q.empty())
        r += q.top(), q.pop();

    cout << r << endl;

}


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

int N = 1000001;
int prime_array[1000001];

void Eratosthenes(){
  for(int i = 0; i < N; i++){
    prime_array[i] = 1;
  }
  for(int i = 2; i < sqrt(N); i++){
    if(prime_array[i]){
      for(int j = 0; i * (j + 2) < N; j++){
	prime_array[i *(j + 2)] = 0;
      }
    }
  }
  
  for(int i = 2; i < N; i++){
    if(prime_array[i]){
      //cout << i << endl;
    }
  }
}

int main()
{
  Eratosthenes();
  int n;

  while( cin >> n, n ) {
    int cnt = 0;
    for(int i=2; i<=n/2; i++) {
      if( prime_array[i] && prime_array[n-i] ) cnt++;
    }

    cout << cnt << endl;
  }

}

Measured memory_bytes: 5064
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv vector<int>
#define endl "\n"
#define test(i) cout<<i<<endl
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())

void file(){
    #ifdef LOCAL
    freopen("demo.in","r",stdin);
    freopen("demo.out","w",stdout);
    #endif
}

void test_case(){
    lld n,m;
    cin>>n>>m;
    test(min(n%m,m-n%m));
}

int main(){
    fastio;
    file();
    // int T;
    // cin>>T;
    // for(int nr=1;nr<=T;++nr) {
    //     cout<<"Case #"<<nr<<": ";
		test_case();
    // }
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

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

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

int main() {
   bool a = false, b = false;
   string s;
   cin >> s;
   rep (i, s.size()) {
      if (s[i] == 'C') a = true;
      if (a) {
         if(s[i] == 'F') b = true;
      }
   }

   if (a&&b) {
      puts("Yes");
   } else {
      puts("No");
   }

   return 0;
}

Measured memory_bytes: 768
def main():
  k = int(input())
  kint = 7 % k
  before = 7 % k
  if k == 1 or k == 7:
    print(1)
    exit()
  for i in range(k):
    x = (before * 10) % k
    before = x
    kint += x
    kint = kint % k
    if kint % k == 0:
      print(i + 2)
      exit()
  print(-1)
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 9016
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll INF = 1e14;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;

int N,M;
vector<int> graph[100];

bool dfs(int a,int b) {
    bool count[100];
    for(int i = 0;i < N;i++) {
        count[i] = false;
    }
    queue<int> que;
    que.push(0);
    while(!que.empty()) {
        int A = que.front();
        que.pop();
        count[A] = true;
        for(int i = 0;i < graph[A].size();i++) {
            if(A == a && graph[A].at(i) == b) {
                continue;
            }
            else if(A == b && graph[A].at(i) == a) {
                continue;
            }
            else if(count[graph[A].at(i)] == true) {
                continue;
            }
            que.push(graph[A].at(i));
        }
    }
    bool ans = true;
    for(int i = 0;i < N;i++) {
        if(count[i] == false) {
            ans = false;
        }
    }
    return ans;
}

int main() {
    cin >> N >> M;
    vector<P> vec(M);
    for(int i = 0;i < M;i++) {
        int A, B;
        cin >> A >> B;
        vec.at(i) = P(A - 1, B - 1);
        graph[A - 1].push_back(B - 1);
        graph[B - 1].push_back(A - 1);
    }
    int ret = 0;
    for(int i = 0;i < M;i++) {
        if(dfs(vec[i].first,vec[i].second) == false) {
            ret++;
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
using namespace std;
int main(){
 
int x,y;
 
cin >> x >> y;
 
if( y!=100){
if( x==0){
cout << y;
}else if(x==1){
cout << 100*y;
}else{
	cout << 10000*y;
}
}else{
if( x==0){
cout << y+1;
}else if(x==1){
cout << 100*y+100;
}else{
	cout << 10000*y+10000;
}
 
}
 
return 0;

}

Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/dp_a

#include <iostream>
#include <vector>
#include <tuple>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

void debug_out() {};
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif

static const ll INF = 1001001001;
struct C1 {
    ll N_{};
    ll K_{};
    vector<ll> v_{};
    vector<ll> dp_{};
    explicit C1(ll K, vector<ll> v) : N_(v.size()), K_(K), v_(move(v)){}
    ll resolve() {
        dp_.resize(N_, 0);
        for(ll i=0; i < N_; ++i) {
            if(i == 0) {
                dp_[i] = 0;
            } else {
                ll min_cost = INF;
                for(ll j = i - K_; j < i; ++j) {
                    if (j < 0) {
                        continue;
                    }
                    min_cost = min(min_cost, dp_[j] + abs(v_[j] - v_[i]));
                }
                dp_[i] = min_cost;
            }
        }
        return dp_[N_-1];
    }
};

int main() {
    ll N, K;
    cin >> N >> K ;
    vector<ll> v{};
    for (int i=0; i < N; ++i) {
        ll x;
        cin >> x;
        v.emplace_back(x);
    }
    C1 c{K, move(v)};
    cout << c.resolve() << endl;
    return 0;
}


Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin >> s;
	replace(s.begin(), s.end(), '?', 'D');
	cout << s << '\n';
	return 0;
}

Measured memory_bytes: 3784
n, m = list(map(int, input().split(' ')))
val = [-1 for _ in range(n)]
failed = False
for _ in range(m):
    s, c = list(map(int, input().split(' ')))

    if val[s-1] == -1:
        val[s-1] = c
    elif val[s-1] == c:
        val[s-1] = c
    else:
        print(-1)
        failed = True
        break
if n == 1 and val[0] == -1:
    print(0)
    failed = True
elif val[0] == 0 and not(failed):
    if n == 1:
        print(0)
    else:
        print(-1)
    failed = True
elif val[0] == -1:
    val[0] = 1
out = str(val[0])
if not(failed):
    for i in range(1, n):
        if val[i] == -1:
            val[i] = 0
        out += str(val[i])

    print(int(out))


Measured memory_bytes: 3064
#include <stdio.h>

int main() {
  char cells[3];
  int count = 0;
  
  scanf("%s", cells);
  
  for (int i = 0; i < 3; i++) {
    if (cells[i] == '1') count++;
  }
  
  printf("%d\n", count);  
  return 0;
}

Measured memory_bytes: 1696
#include<stdio.h>
int main(void)
{
	int a,s,d,f,g,h,j,i,z;
	int a2,s2,d2;
	for(i=1;i<=3;i++){
		scanf("%d %d %d %d %d %d",&a,&s,&d,&g,&h,&j);
		f=(j+h*60+g*3600)-(d+s*60+a*3600);
		d2=f%60;
		z=f/60;
		s2=z%60;
		a2=z/60;
		printf("%d %d %d\n",a2,s2,d2);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(n) for(ll i=0; i<n; i++)

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

  string s;
  if(a==b)
  {
    if(a != c) s = "Yes";
    else s = "No";
  } else {
    if(b==c || a==c) s = "Yes";
    else s = "No";
  }

  cout << s << endl;

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#define abs(x) ((x>0)?x:(-(x)))
int H, W, D, A;
int Q, L, R;
int px[90000], py[90000];
int d[90000];
int main(){
        scanf("%d %d %d", &H, &W, &D );
        for (int i=0; i<H; i++)
                for (int j=0; j<W; j++){
                        scanf ("%d", &A);
                        px[A]=i, py[A]=j;
                }
        for (int i=D+1; i<=H*W; i++)
                d[i]=d[i-D]+abs(px[i]-px[i-D])+abs(py[i]-py[i-D]);
        scanf("%d", &Q);
        while (Q--){
                scanf("%d %d ", &L, &R);
                printf("%d\n", d[R]-d[L]);
        }
}

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

int main(){
  string s;
  cin>>s;
  int ans1=1,ans2=s.size();
  int i=0;
  
  while(s[i]!='A'){
    ans1++;
    i++;
   }
  i=0;
  while(s[s.size()-1-i]!='Z'){
      ans2--; 
    i++;
  }
  cout<<ans2-ans1+1<<endl;
}


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

int main() {
  int num, limit;
  std::map<int,int> data;
  std::cin >> num >> limit;
  for (int i=0; i<num; i++) {
    int temp_num;
    std::cin >> temp_num;
    if(data.count(temp_num)) {
      data.at(temp_num)++;
    }
    else {
      data[temp_num] = 1;
    }
  }
  
  std::priority_queue<int, std::vector<int>, std::greater<int>> queue;
  for (auto p:data) {
    int temp_num = p.second;
    queue.push(temp_num);
  }
  
  int sum=0;
  if(data.size() <= limit) {
    std::cout << 0 << std::endl;
  }
  else {
    for (int i=0; i<data.size()-limit; i++) {
      sum += queue.top();
      queue.pop();
    }
    std::cout << sum << std::endl;
  }
}

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

#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define lg long long
#define db double
#define lb(x) ((x)&-(x))
#define ft first
#define sd second

#define HII cerr<<"HI"<<endl
#define LLLINE cerr<<"@@@@@@@@@@@@@@@@@@@@"<<endl

template <class _T_>
void read(_T_& d){
	d=0;int f=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar())if(c=='-')f*=-1;
	for(;c>='0'&&c<='9';c=getchar())d=d*10+c-'0';
	d*=f;
}

/************************************************/
#define MN 500005
int n;
int fr[MN],nex[MN],vi[MN],tot=0;
void add(int x,int y){
	nex[++tot]=fr[x];fr[x]=tot;vi[tot]=y;
}

int d[MN];
void dfs(int x,int fa){
	for(int i=fr[x];i;i=nex[i]){
		if(!d[vi[i]])d[vi[i]]=d[x]+1,dfs(vi[i],x);
	}
}
int main(){
	read(n);
	for(int i=1,x,y;i<n;++i){
		read(x);read(y);
		add(x,y);add(y,x);
	}
	for(int i=1;i<=n;++i)d[i]=0;
	d[1]=1;
	dfs(1,1);
	int mx=1;
	for(int i=1;i<=n;++i)if(d[i]>d[mx])mx=i;
	for(int i=1;i<=n;++i){
		d[i]=0;
	}
	d[mx]=1;
	dfs(mx,mx);
	int L=0;
	for(int i=1;i<=n;++i)L=max(L,d[i]);
	L%=3;
	if(L==1||L==0)return puts("First"),0;
	puts("Second");
	return 0;
}


Measured memory_bytes: 11904
/*                    */
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
lint gcd(lint a, lint b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
lint lcm(lint a, lint b) { return a * b / my::gcd(a, b); }
}  // namespace my
/*                    */

void solve(vector<int> &ima, vector<vector<int>> &tonari,
           vector<int> &shirube) {
  if (ima.empty()) return;
  vector<int> tsugi;
  for (auto &imai : ima) {
    for (auto &tonarij : tonari.at(imai)) {
      if (tonarij == 0) continue;
      if (shirube.at(tonarij) == -1) {
        shirube.at(tonarij) = imai;
        tsugi.push_back(tonarij);
      }
    }
  }
  solve(tsugi, tonari, shirube);
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> tonari(n);
  vector<int> shirube(n, -1);
  for (int i = 0; i < m; i++) {
    int tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    tmp1--;
    tmp2--;
    tonari.at(tmp1).push_back(tmp2);
    tonari.at(tmp2).push_back(tmp1);
  }

  vector<int> init = {0};
  solve(init, tonari, shirube);

  cout << "Yes" << endl;
  for (int i = 1; i < shirube.size(); i++) {
    cout << ++shirube.at(i) << endl;
  }
}

Measured memory_bytes: 23008
N=int(input())
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)
def lcm(x,y):
    return x*y//gcd(x,y)
ans=1
for _ in range(N):
  T=int(input())
  ans=lcm(ans,T)
print(ans)

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define MAX 100100
#define NIL -1
using namespace std;

typedef struct node{
  int parent, left, right;
}Node;

Node T[MAX];

int seekroot(int id){
    while (T[id].parent != NIL){
        id = T[id].parent;
    }
    return id;
}

void PreParse(int id){
    if (id == NIL){
        return;
    }
    cout << " " << id;
    PreParse(T[id].left);
    PreParse(T[id].right);
}

void InParse(int id){
    if (id == NIL){
        return;
    }
    InParse(T[id].left);
    cout << " " << id;
    InParse(T[id].right);
}

void PostParse(int id){
    if (id == NIL){
        return;
    }
    PostParse(T[id].left);
    PostParse(T[id].right);
    cout << " " << id;
}

int main(){
    int n;
    cin >> n;
    rep(i, n){// init
        T[i].parent = NIL;
        T[i].left = NIL;
        T[i].right = NIL;
    }

    int id;
    int l;
    int r; 

    rep(i, n){
        cin >> id >> l >> r;
        if (l != -1){
            T[id].left = l;
            T[l].parent = id;
        }
        if (r != -1){
            T[id].right = r;
            T[r].parent = id;
        }
    }
    
    int root = seekroot(0);

    cout << "Preorder" << endl;
    PreParse(root);
    cout << endl;

    cout << "Inorder" << endl;
    InParse(root);
    cout << endl;

    cout << "Postorder" << endl;
    PostParse(root);
    cout << endl;

    return 0;
}


Measured memory_bytes: 3084
#include <iostream>

int main(void){
  int a[2];
  std::cin >> a[0] >> a[1];
  int sum=0;
  for(int i=0;i<2;i++){
    if(a[i]==1){
      sum += 300000;
    }else if(a[i]==2){
      sum += 200000;
    }else if(a[i]==3){
      sum += 100000;
    }
  }
  if(a[0]==1&&a[1]==1){
    sum+=400000;
  }
  std::cout << sum;
}


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

using namespace std;

#define ll long long
#define mod 1000000007

int
main(void){
	int n, m; cin >> n >> m;
	vector<string> grid(n);
	for(int i = 0; i < n; i++) cin >> grid[i];
	vector<vector<ll> > dp(n, vector<ll> (m));
	dp[0][0] = 1;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(grid[i][j] == '#') continue;
			if(i - 1 >= 0) dp[i][j] += dp[i - 1][j];
			if(j - 1 >= 0) dp[i][j] += dp[i][j - 1];
			dp[i][j] %= mod;
		}
	}
	
	cout << dp[n - 1][m - 1];
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

//dp[i][j],i前の日にしたもの,j:index
lli dp[3][101000];
vector<lli> a[3];

int main(){

	lli n;
	cin>>n;

	REP(i,0,3)a[i].resize(n);
	REP(i,0,n)REP(j,0,3)cin>>a[j][i];

	REP(i,0,3)dp[i][0]=a[i][0];

	//j before,k,after
	REP(i,0,n-1)REP(j,0,3)REP(k,0,3){
		if(j==k)continue;
		dp[k][i+1] = max(dp[j][i]+a[k][i+1],dp[k][i+1]);
	}

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


    return 0;
}


Measured memory_bytes: 4992
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;
double eps = 1e-11;

int main() {
    while (true) {
        string s1, s2;
        cin >> s1;
        if (s1 == ".") {
            break;
        }
        cin >> s2;
        vector<char> s1ch[210];
        vector<char> s2ch[210];
        int num1 = 0;
        int len1 = s1.size();
        for (int i = 0; i < len1; i++) {
            if (s1[i] == '"') {
                num1++;
            } else {
                s1ch[num1].push_back(s1[i]);
            }
        }
        int num2 = 0;
        int len2 = s2.size();
        for (int i = 0; i < len2; i++) {
            if (s2[i] == '"') {
                num2++;
            } else {
                s2ch[num2].push_back(s2[i]);
            }
        }
        int mark = 0;
        if (num1 != num2) {
            mark = 2;
        }
        for (int i = 0; i <= num1; i++) {
            bool m = true;
            int a = s1ch[i].size();
            int b = s2ch[i].size();
            if (a != b) {
                m = false;
            } else {
                for (int j = 0; j < a; j++) {
                    if (s1ch[i][j] != s2ch[i][j]) {
                        m = false;
                    }
                }
            }
            if (!m) {
                if (i % 2 == 0) {
                    mark = 2;
                } else {
                    if (mark < 2) {
                        mark++;
                    }
                }
            }
        }
        if (mark == 0) {
            cout << "IDENTICAL" << endl;
        } else if (mark == 1) {
            cout << "CLOSE" << endl;
        } else {
            cout << "DIFFERENT" << endl;
        }
    }
}



Measured memory_bytes: 3184
#include <stdio.h>

using namespace std;

int main()
{
    int d,t,s;
    scanf("%d %d %d",&d,&t,&s);
    double f;
    f = (double)d/s;
    if(f>t)
    {
        printf("No");
    }
    else{
        printf("Yes");
    }
    return 0;
}


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

signed main(){
  int A,B,C;
  cin>>A>>B>>C;
  int num=A*100+B*10+C;
  string ans="NO";
  if(num%4==0)ans="YES";
  cout<<ans<<endl;
}

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

int main(){
  int a,b,k;
  cin >> a >> b >> k;
  int count=0;
  for(int i=100;i>=1;i--){
    if(a%i==0&&b%i==0){
      count++;
    }
    if(count==k&&a%i==0&&b%i==0){
      cout << i << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
 
using namespace std;
 
typedef unsigned long long ll;
typedef pair<int, int> pair_;
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
 
int main(){
   string s;
   cin >> s;

   int n,m;
   int ans_1=1;
   int ans_2=1;
   int ans_3=1;

   n = s.size();
   int n_1 = (n-1)/2;
   int n_3 = (n+3)/2;

   rep(i, n_1/2){
       if(s[i] == s[n_1-i-1]) continue;
       else {
           ans_1 = 0;
           break;
       }
   }
    int jcount = 0;
    for(int j = n_3 -1; j < (n-n_3)/2;j++){
       if(s[j] == s[n-j-1]) continue;
       else {
           ans_1 = 0;
           break;
       }
       j++;
   }
    rep(i, n/2){
       if(s[i] == s[n-i-1]) continue;
       else {
           ans_3 = 0;
           break;
       }
   }

    if((ans_1 == 1)&&(ans_2==1)&&(ans_3==1)){
        cout << "Yes";
    }
    else cout << "No";

    return 0;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
//#include <functional>
#include <queue>
//#include <stack>
//#include <set>
#include <cmath>
//#include <bitset>
#include <map>
using namespace std;
typedef long long ll;

int main() {
  int N,M;
  cin >> N >> M;
  ll A[N];
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  vector<pair<ll, ll> > pairs(M);
  for(int i=0; i<M; i++){
    ll tmp_B, tmp_C;
    cin >> tmp_B >> tmp_C;
    pairs[i] = make_pair(tmp_C, tmp_B);
  }
  //小さい順
  //一つ目が数字 二つ目が枚数
  sort(pairs.begin(), pairs.end());
  sort(A,A+N);
  ll ans = 0;
  int n=N;
  int index=M-1;
  int A_index=N-1;
  while(n>0){
    //Aを使う
    if(A[A_index] > pairs[index].first){
      ans += A[A_index];
      n--;
      A_index--;
    }
    //Cを使う
    else{
      //C
      ans += pairs[index].first * pairs[index].second;
      n -= pairs[index].second;
      index--;
      if(n<0){
	ans -= pairs[index+1].first * abs(n);      
      }
    }
    //    cout << A_index << " " << index << endl;
    //    cout << ans << endl;
  }
  cout << ans << endl;

  

  return 0;

}


Measured memory_bytes: 2560
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;


int main(int argc, const char * argv[]) {
  int n;
  cin >> n;

  vector<int> v(n);
  vector<int> c(n);
  for(int i = 0; i < n; i++){
    cin >> v.at(i);
  }
  for(int i = 0; i < n; i++){
    cin >> c.at(i);
  }
  
  int result = 0;
  for(int i = 0; i < n; i++){
    if(v.at(i) > c.at(i)){
      result += v.at(i) - c.at(i);
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#Nは頂点数, Mは辺数(2 <= N <= 1000, 1 <= M <= min(N(N-1, 2000)))
#頂点1から頂点Nに移動して、移動スコアを最大にする
#->移動スコアを正負反転させれば最短経路問題
#->負閉路を考慮してベルマンフォード法を利用
INF = 1 << 50

N,M = map(int,input().split())

#辺を登録
Sides = []
for i in range (M):
    Side = list(map(int,input().split()))
    Sides.append(Side)
#コストを反転
    Sides[i][2] = Sides[i][2] * (-1)

#各頂点の最短距離を初期化
Vertexes = [INF]*(N+1)
Vertexes[1] = 0

#負閉路のチェック用
negative = [False] * (N+1)

#ベルマンフォード法による最短距離探索
for count in range(N):
    for i in range(M):
        from_v = Sides[i][0]
        to_v = Sides[i][1]
        cost = Sides[i][2]
        if (Vertexes[to_v] > Vertexes[from_v]+cost):
#N回目の更新で更新された場合は負閉路あり
            if(count==N-1):
                negative[to_v] = True
            else:
                Vertexes[to_v] = Vertexes[from_v]+cost

#負閉路が終点までにあるか確認
for count in range(N-1):
    flag = 0
    for i in range(M):
        from_v = Sides[i][0]
        to_v = Sides[i][1]
        if negative[from_v] and negative[to_v] is False:
            negative[to_v] = True
            flag = 1
    if flag ==0:
        break

if negative[N]:
    print('inf')
else:
    print(-Vertexes[N])

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
struct node
{
  int d,co,flag;
  node (int d, int co, int flag) : d(d) , co(co),flag(flag) {}
  friend bool operator < (const node a,const node b)
  {
    return a.d < b.d;
  }
};
multiset<int>M;
vector<node>V;
int main()
{
  int n,m;
  scanf("%d%d",&n,&m);
  for(int i = 0 ; i < n ; i++)
  {
    int s,e,co;
    scanf("%d%d%d",&s,&e,&co);
    V.push_back(node(s-co,co,0));
    V.push_back(node(e-co,co,1));
  }
  sort(V.begin(),V.end());
  int k = 0;
  while(m--)
  {
    int q;
    scanf("%d",&q);
    while(k < V.size())
    {
      if(V[k].d <= q)
      {
        if(V[k].flag) M.erase(M.find(V[k].co));
        else M.insert(V[k].co); 
        k++;
      }
      else break;
     
    }
    int ans = - 1;
    if(M.size()) ans = *M.begin();
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 15340
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int cnt_zero = 0, cnt_one = 0;
		for(int i = 0; i < S.length(); i++) {
			if(S.charAt(i) == '0') cnt_zero++;
			else cnt_one++;
		}
		System.out.println(2 * Math.min(cnt_zero, cnt_one));
	}
}

Measured memory_bytes: 23988
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int N;
	cin>>N;
	vector<vector<int>> G(10005);
	rep(i,N-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	vector<int> c(N);
	rep(i,N){
		cin>>c[i];
	}
	sort(all(c));
	queue<int> q;
	vector<int> ansv(N),used(N,0);
	ansv[0] = c[N-1];
	used[0] = 1;
	print(c);
	print(ansv);
	print(used);
	q.push(0);
	int ans = 0;
	int now = N-2;
	while(!q.empty()||now>=0){
		int v = q.front();q.pop();
		cerr<<v;
		print(G[v]);
		for(int u :G[v]){
			if(used[u])continue;
			//cerr<<"		"<<u<<endl;
			q.push(u);
			used[u] = 1;
			ans += c[now];
			ansv[u] = c[now];
			now--;
		}
	}
	cout<<ans<<endl;
	rep(i,N){
		if(i == N-1)cout<<ansv[i]<<endl;
		else cout<<ansv[i]<<" ";
	}
}

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

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

    string s;
    cin >> s;

    int count = 0;

    for(int i = 0;i<n-2;i++){
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        long n = long.Parse(Console.ReadLine());
        if (n % 2 == 1)
        {
            Console.WriteLine(0);
            return;
        }
        long res = 0;
        for (long i = 10; i <= n; i *= 5)
        {
            res += n / i;
        }
        Console.WriteLine(res);
    }
}

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

int main(){
    string n; cin >> n;
    for(int i=0;i<3;i++){
        if(n.at(i) == '1') {n.at(i) = '9';}
        else{n.at(i) = '1';}
    }
    for(int i=0;i<3;i++){
        cout << n.at(i);
    }
    cout << endl;
}

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

using ll = long long;

int main() {
    ll N, S, W, Q;
    while(cin >> N >> S >> W >> Q, N) {
        vector<ll> a(N);
        ll g = S;
        for(int i = 0; i < N; ++i) {
            a[i] = (g / 7) % 10;
            if(g % 2 == 0) {
                g /= 2;
            } else {
                g = (g / 2) ^ W;
            }
        }

        vector<ll> sum(N+1);
        ll k = 1;
        for(int i = N - 1; i >= 0; --i) {
            sum[i] = (a[i] * k + sum[i + 1]) % Q;
            k = (k * 10) % Q;
        }

        ll res = 0;
        if(Q == 2 || Q == 5) {
            ll cnt = 0;
            for(int i = 0; i < N; ++i) {
                cnt += a[i] != 0;
                if(a[i] % Q == 0) {
                    res += cnt;
                }
            }
        } else {
            map<ll, ll> m;
            for(int i = 0; i < N; ++i) {
                if(a[i] != 0) {
                    m[sum[i]]++;
                }
                res += m[sum[i + 1]];
            }
        }

        cout << res << endl;
    }
}


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

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

    string s,t;
    cin>>s>>t;

    string z="";

    for(int i=0;i<n;i++)
    {
        z.push_back(s[i]);
        z.push_back(t[i]);
    }

    cout<<z<<endl;


}


Measured memory_bytes: 256
import collections

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

c = collections.Counter(l)

num = list(c.keys())
val = list(c.values())

ans = 0

for i in range(len(num) - 2):
    for j in range(len(num) - 2 - i):
        for k in range(len(num) - 2 - i -j):
            sel = [num[i],num[i + j + 1],num[i + j + 2 + k]]
            if 2 * max(sel) < sum(sel):
                ans += val[i]*val[i + j + 1]*val[i + j + 2 + k]

print(ans)


Measured memory_bytes: 9444
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 1234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

std::string A, B;

int main()
{
    in >> A >> B;
    
    if (A.length() > B.length()) { out << "GREATER" << std::endl; }
    else if (A.length() < B.length()) { out << "LESS" << std::endl; }
    else
    {
        rep(i, A.length())
        {
            if ((A[i] - '0') > (B[i] - '0'))
            {
                out << "GREATER" << std::endl;
                return 0;
            }
            if ((A[i] - '0') < (B[i] - '0'))
            {
                out << "LESS" << std::endl;
                return 0;
            }
        }
        out << "EQUAL" << std::endl;
    }
	return 0;
}

Measured memory_bytes: 256
import java.security.KeyStore.TrustedCertificateEntry
import java.util
import java.util.regex.Pattern
import java.util.{ArrayList, Collections, Comparator, List => JList}

import scala.math._
import scala.collection.mutable
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.util.{Failure, Success, Try}

object Main{
  val LINE_SEPARATOR = "\n"
  def main(args: Array[String]): Unit = {
    if (sys.env.getOrElse("TEST", "")=="1"){
      println(test());
    }else{
      val input=io.Source.stdin.getLines().mkString(LINE_SEPARATOR);
      println(solve(input).trim());
    }
  }

  def init (nRows: Int, nCols: Int, default: Int) = Array.tabulate(nRows,nCols)( (x,y) =>  default)

  def sortIgnoreCase1(list: JList[String]): JList[String] = {
    val r = new ArrayList[String](list)
    Collections.sort(r, new Comparator[String] {
      override def compare(o1: String, o2: String): Int = o1.compareToIgnoreCase(o2)
    })
    r
  }

  def solve(input: String): String = {
    val a = input.split(" ").head
    val b = input.split(" ").tail.head
    val aLong = a.toLong
    val bLong = b.replace(".","").toLong
    val res = (aLong * bLong).toString.dropRight(2)
    if (res == "") "0" else res
  }

  def divisors(n: Long): Vector[Long] = {
    val halfList = (1 to sqrt(n).toInt).toVector.filter(_ % n == 0).map(_.toLong)
    val reversedList = if (sqrt(n).floor == sqrt(n)) halfList.reverse.tail.map(n/_) else halfList.reverse.map(n/_)
    halfList ++ reversedList
  }

  def gcd(m: Long, n: Long): Long = n match {
    case 0 => m
    case _ => gcd(n, m % n)
  }
  def lcm(a: Long, b: Long): Long = a * b / gcd(a, b)

  val tests=List(
    """198 1.10""".stripMargin -> """217
                                    |
                                                     |
                                                     |
                                                     |
                                                     |
                                        |
                                   |
                                |""".stripMargin,
    """1 0.01""".stripMargin -> """0
                                                 |
                                                 |
                                                 |
                                                 |
                                                 |
                                                 |
                                                 |""".stripMargin,
    """1000000000000000 9.99""".stripMargin -> """9990000000000000
                                         |
                               |""".stripMargin,
    s"""0 0""" -> """0""",
    """999999999999999 9.99""".stripMargin -> """9989999999999990"""
  )

  def test():String= {
    return tests.map{case (i,o)=>(i.trim(),o.trim())}
      .zipWithIndex.map{
      case ((input,outputExpect),i)=>{
        val output=solve(input).trim();
        s"test${i+1}:"+(if(output==outputExpect){
          "Passed"
        }else{
          s"Failed\nexpect:\n${outputExpect}\noutput:\n${output}"
        })
      }}
      .mkString("\n");
  }
}

Measured memory_bytes: 55364
char s[];main(){double*q=s,b;for(;~scanf("%s",s);getchar()<14&&printf("%f\n",*q))sscanf(s,"%lf",q+1)-1?b=*q--,*q=*s&1?*s-47?*s-45?*q+b:*q-b:*q/b:*q*b:*++q;}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	string s; cin >> s;
	ll w = 0, ans = 0;
	rep(i, s.size()) {
		if (s[i] == 'W') {
			ans += i - w;
			++w;
		}
	}
	cout << ans << "\n";
		
	return 0;
}

Measured memory_bytes: 720
#include<cstdio>

int main(){
    char c;
    bool N=0,S=0,E=0,W=0;
    do{
        c=getchar();
        N|=c=='N',S|=c=='S',E|=c=='E',W|=c=='W';
    }while(c!='\n');
    if(N==S&&E==W) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=998244353, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string X;
    cin >> N >> X;
    vector<ll> f(N+1);
	for(int k=1;k<=N;k+=2)if(N%k==0){
		int L=N/k;
		bool fl=1;
		for(int i=0; i < N && fl ;i++){
			if(X[i]=='1'){
				if(i < L || X[i-L] == '1'){
					(f[L] += (i < L)? modpow(2LL,L-i-1): 1LL) %= mod;
				}
			}
			if(i >= L && X[i] == X[i-L]) fl = 0;
		}
		if(fl) (f[L] += 1) %= mod;
	}
	int ans=0;
	for(int i=1;i<=N;i++) if(N % i == 0 && N / i % 2 == 1 && f[i]){
		(ans += (f[i] * i * 2)%mod ) %= mod;
		for(int j=i*2;j<=N;j+=i) (f[j] -= f[i]) %= mod;
	}
    cout << (ans + mod) % mod << endl;
    return 0;
}


Measured memory_bytes: 2196
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define endl '\n'
#define INF 1e9+7
#define all(x) x.begin(),x.end()
using namespace std;
using namespace __gnu_pbds;
using ll=long long;
using pii=pair<int,int>;
using ppi=pair<pii,int>;
using oset=tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>;

template<typename T>
void _print(vector<T> x) {for(auto e:x) cerr<<e<<",";}
template<typename T>
void _print(T x) {cerr<<x;}

void dbg() {cerr<<endl;}
template<typename Head,typename... Tail>
void dbg(Head H,Tail... T) {
    _print(H);
    if(sizeof...(T)) cerr<<",";
    else cerr<<"\"]";
    dbg(T...);
}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:[\"",dbg(__VA_ARGS__)

int main () {
    ios::sync_with_stdio(false); cin.tie(0);
    int n; cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    int ans=0;

    for(int i=0;i<n;i++) {
        for(int j=i+1;j<n;j++) {
            for(int k=j+1;k<n;k++) {
                vector<int> temp(3);
                temp[0]=a[i]; temp[1]=a[j]; temp[2]=a[k];
                sort(all(temp));
                if(temp[0]!=temp[2] and temp[1]!=temp[2] and temp[0]!=temp[1] and temp[0]+temp[1]>temp[2]) {
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
const int N=2e5+5;
const int mod=1e9+7;
 
int main(){
    int x;
    cin>>x;
    printf("%.3f",x*4*asin(1));
 
return 0;
}

Measured memory_bytes: 3748
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

using ll = long long;
using p = pair<ll, ll>;
constexpr ll INF = 1LL << 62;

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

    ll N;
    cin >> N;

    vector<ll> dp(N + 1, INF);
    dp[0] = 0;
    for (ll i = 1; i <= N; i++) {
        dp[i] = min(dp[i], dp[i - 1] + 1);
        for (ll j = 6; i - j >= 0; j *= 6) {
            dp[i] = min(dp[i], dp[i - j] + 1);
        }
        for (ll j = 9; i - j >= 0; j *= 9) {
            dp[i] = min(dp[i], dp[i - j] + 1);
        }
    }

    /*
    for (ll i = 0; i < N; i++) {
        dp[i + 1] = min(dp[i + 1], dp[i] + 1);
        for (ll j = 6; i + j <= N; j *= 6) {
            dp[i + j] = min(dp[i + j], dp[i] + 1);
        }
        for (ll j = 9; i + j <= N; j *= 9) {
            dp[i + j] = min(dp[i + j], dp[i] + 1);
        }
    }
    */

    cout << dp[N] << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;

int main() {
  string w;
  cin>>w;
  map<char,int>k;
  for(int i=0;i<w.size();i++){
    k[w[i]]++;
  }
  for(auto a:k){
    if(a.second%2!=0){cout<<"No"<<endl;return 0;}
  }
  cout<<"Yes"<<endl;
  return 0;}

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

int main(){
	int a,b,c;
	int ans;
	
	string cunning="7767555555555555555555";
	
	for(int i=0;i<104;i++){
		cin>>a>>b;c=a+b;
		//-----test-----
		if(i<cunning.size()){
			cout<<cunning[i]<<endl;
			continue;
		}
		//--------------
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define N 5005
int n,m;
LL s1[N],ans,f[N];
int a[N][205],lg[N],mx[205][N][20];
inline int read()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+(c^48);c=getchar();}
	return x*f;
}
inline int Max(int i,int l,int r)
{
	int l1=lg[r-l+1];
	return max(mx[i][l][l1],mx[i][r-(1<<l1)+1][l1]);
}
inline void dfs(int l,int r,int L,int R)
{
	if(l>r)
		return;
	int mid=(l+r)/2,x1;
	LL m1=0;
	for(int i=L;i<=min(mid,R);i++)
	{
		LL ml=s1[i]-s1[mid];
		for(int j=1;j<=m;j++)
			ml+=Max(j,i,mid);
		if(ml>m1)
			m1=ml,x1=i;
	}
	f[mid]=m1;
	dfs(l,mid-1,L,x1);
	dfs(mid+1,r,x1,R);
}
int main()
{
	//freopen("restaurants.in","r",stdin)
	//freopen("restaurants.out","w",stdout);
	scanf("%d%d",&n,&m);
	for(int i=2;i<=n;i++)
		scanf("%lld",&s1[i]),s1[i]+=s1[i-1],lg[i]=lg[i>>1]+1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			mx[j][i][0]=read();
	for(int i=1;i<=m;i++)
		for(int k=1;k<20;k++)
			for(int j=1;j+(1<<(k-1))<=n;j++)
				mx[i][j][k]=max(mx[i][j][k-1],mx[i][j+(1<<(k-1))][k-1]);
	dfs(1,n,1,n);
	for(int i=1;i<=n;i++)
		ans=max(ans,f[i]);
	printf("%lld\n",ans);
}

Measured memory_bytes: 81792
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

ll d = 998244353;
vector <vector<ll>>dp(3001, vector<ll>(3001, 0));




int main(void){
    ll n; cin >> n;
    ll s; cin >> s;
    vector <ll> as;
    REP(i, n){
        ll a; cin>>a;
        as.push_back(a);
    }
    dp[0][0] = 1;
    REP(i, n){
        ll a = as[i];
        REP(j, s+1){
            if (j+a <= s){
                dp[i+1][j+a] += dp[i][j];
                dp[i+1][j+a] %= d;
            }
            dp[i+1][j] += dp[i][j] * 2;
            dp[i+1][j] %= d;
        }
    }
    cout << dp[n][s] << endl;
    return 0;
}

Measured memory_bytes: 74140
#include <stdio.h>

#define N 100

int main(){
  int A[N][N];
  int i,j,k,n,u,v;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      A[u][v]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j){
        printf(" ");
      }
      printf("%d",A[i][j]);
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { cout << '\n'; }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << ' ' << val;
            return *this;
        }
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy operator<<(T&& val)
    {
        cout << val;
        return {};
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
                first = false;
            }
            cout << x;
        }
    }
};

int main()
{
    input in;
    output out;

    auto N = in.read<int>();

    int n = 0, kudaku = 0;

    in.online<int>(N, [&](int a) {
        if (a == n + 1) {
            n++;
        } else {
            kudaku++;
        }
    });

    out << (n == 0 ? -1 : kudaku);

    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 rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
#define vecmin(A) *min_element(A.begin(),A.end())
#define vecmax(A) *max_element(A.begin(),A.end())
typedef long long ll;

int main(){
  int n,m,x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n,vector<int>(m));
  rep(i,n){
    cin >> c[i];
    rep(j,m) cin >> a[i][j];
  }
  int ans = pow(10,9);
  rep(i,pow(2,n)){//i...bits
    int cost = 0;
    vector<int> skill(m);
    rep(j,n){//j...books
      bool bit = (i >> j)&1;
      if(bit){
        cost += c[j];
        rep(k,m){//k...skills in book
          skill[k] += a[j][k];
        }//k
      }
    }//j
    bool fail_at_least = 0;
    rep(j,m){
      if(skill[j] < x) fail_at_least = 1;
    }//j
    if(!fail_at_least){
      ans = min(ans,cost);
    }
  }//i
  if(ans == pow(10,9)) cout << -1 << endl;
  else cout << ans << endl;
}


Measured memory_bytes: 4048
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int counter = 1;
  for(int i = 0; i < s.length()-1; i++){
    if(s[i] != s[i+1]){
      counter++;
    }
  }
  cout << counter << endl;
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;
public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        int[] array=new int[3];
        array[0]=Integer.parseInt(st.nextToken());
        array[1]=Integer.parseInt(st.nextToken());
        array[2]=Integer.parseInt(st.nextToken());
        Arrays.sort(array);
        if(array[2]==array[0]+array[1]){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
        
    }
}

Measured memory_bytes: 8148