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

using namespace std;

string s, t;

int main(void)
{
	cin >> s >> t;
	
	int ans = 0;
	for(int i = 0; i < 3; i++) if(s[i] == t[i]) ans++;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<string>
#include<bitset>
using namespace std;


int main() {
	int N, M;
	cin >> N >> M;
	int a[150];
	int sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		sum += a[i];
	}
	int pick = 0;
	for (int i = 0; i < N; i++) {
		if (a[i] * 4 * M >= sum) pick++;
	}
	if (pick >= M) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n; cin >> n;
  map<int, int> d;
  for (int i = 0; i < n; i++) {
    int a; cin >> a;
    d[a]++;
  }
  int m; cin >> m;
  map<int, int> t;
  for (int i = 0; i < m; i++) {
    int a; cin >> a;
    t[a]++;
  }
  for (auto&& i : t) if (i.second > d[i.first]) return cout << "NO" << '\n', 0;
  cout << "YES" << '\n';
}

Measured memory_bytes: 19072
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y>a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[210011];
int l[1];
int j[1];

long long x,y,z,mod=1000000007;
//string r;
char r[2];

P u[1];
queue<int> q;
//stack<int> s;
set<int> s;
map<int,int> p;

vector<int> v[1];


bool as(P a,P b)
{
  return a.x<b.x;
}



int main()
{
  scanf("%d",&a);
  x=mod*mod;
  for(int t=1;t<=a;y+=o[t],t++)
    scanf("%d",&o[t]);
  for(int t=1;t<a;t++)
  {
    z+=o[t];
    x=min(x,abs(z-(y-z)));
  }
  printf("%lld",x);
}






Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

int gcd(int m, int n) {
    if (m < n) return gcd(n,m);
    while (n) {
        m %= n;
        swap(m,n);
    }
    return m;
}

void solve() {
    int n;
    cin >> n;
    VLL a(n);
    REP(i,0,n) cin >> a[i];
    VI cnt(n+1);
    int unit = sqrt(n) + 1;
    int ans = 0;
    REP(i,0,(n + unit - 1)/unit) {
        int g = -1;
        REP(j,0,n) {
            if (j / unit == i) continue;
            if (g < 0) g = a[j];
            else g = gcd(g, a[j]);
        }
        REP(j,0,unit) {
            if (i * unit + j >= n) break;
            int sg = -1;
            REP(k,0,unit) {
                if (j == k) continue;
                if (i * unit + k >= n) break;
                if (sg < 0) sg = a[i * unit + k];
                else sg = gcd(sg, a[i * unit + k]);
            }
            if (sg > -1 && g > -1) ans = max(ans, gcd(g, sg));
            else if (g < 0) ans = max(ans, sg);
        }
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 1536
def main():
    N = int(input())
    a = [i for i in map(int, input().split())]
    a = sorted(a, reverse=True)
    alice = sum([j for i, j in enumerate(a) if i % 2 == 0])
    bob = sum([j for i, j in enumerate(a) if i % 2 != 0])
    print(alice - bob)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb push_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int N, K, V[50]; cin >> N >> K;
  REP(i, N) cin >> V[i];
  int ans = -1145141919810;
  for(int a = 0; a <= min(N, K); a++){
    for(int b = 0; b <= min(N, K)-a; b++){
      int era = max(0ll, K-a-b);
      int sum = 0;
      vector<int> minus;
      REP(i, a){
        sum += V[i];
        if(V[i] < 0) minus.pb(V[i]);
      }
      for(int i = N-1; i >= N-b; i--){
        sum += V[i];
        if(V[i] < 0) minus.pb(V[i]);
      }
      sort(ALL(minus));
      REP(i, min(era, (int)minus.size())){
        sum += abs(minus[i]);
      }
      ans = max(ans, sum);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <codecvt>

using namespace std;

int main(){
  string o, e;
  string str;
  cin >> o >> e;
  for(int i=0;i<=o.length() && i<=e.length(); i++){
        str += o.substr(i,1);
        str += e.substr(i,1);
  }
  cout << str << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int count = 0;
		for(int i = 0; i < s.length() - 1 - i; i++){
			if(s.charAt(i) != s.charAt(s.length() - 1 - i)){
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 23760
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define F_ first
#define S_ second
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

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

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N;
	while(true){
		cin >> N;
		if(!N) break;
		int ans=0;
		REP(i,1,N){
			int s=i;
			REP(j,i+1,N){
				s+=j;
				if(s==N){
					++ans;
					break;
				}else if(s>N) break;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#include <stdio.h>

int main(void)
{
	int a;
	int age;
	int i , j;
	int hist[7];
	int check;
	
	scanf("%d", &a);
	
	while (a != 0){
		for(i = 0; i < 7; i++){
			hist[i] = 0;
		}
		
		for (i = 0; i < a; i++){
			check = 0;
			scanf("%d", &age);
			for (j = 0; j < 6; j++){
				if (age < (j + 1) * 10){
					hist[j]++;
					check = 1;
				}
				if (check == 1){
					break;
				}
			}
			
			if (check != 1){
				hist[6]++;
			}
		}
	
	for(i = 0; i < 7; i++){
		printf("%d\n", hist[i]);
	}
	
	scanf("%d", &a);
	
	}
	return (0);
}

Measured memory_bytes: 404
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    string s;
    cin >> s;
    ll n = s.size();
    cout << s.substr(0, n - 8) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
#define MAX_N 123500
int prime[MAX_N*2];
void eratos()
{
	for(int i=0;i<MAX_N*2;i++)prime[i]=1;
	prime[0]=prime[1]=0;
	for(int i=2;i*i<=MAX_N*2;i++)if(prime[i])
	{
		for(int j=i*2;j<=MAX_N*2;j+=i)prime[j]=0;
	}
	return;
}
int main()
{
	eratos();
	for(int i=1;i<MAX_N*2;i++)prime[i]+=prime[i-1];
	while(1)
	{
		int n;
		scanf("%d",&n);
		if(n==0)break;
		printf("%d\n",prime[2*n]-prime[n]);
	}
	return 0;
}

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

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

  int total = 0;
  int candy = 1;
  for (int i = 1; i <= N; i++){
    total += candy;
    candy += 1;
  }
  cout << total << endl;
}

Measured memory_bytes: 3492
#include <bits/stdc++.h>
using namespace std;
bool willBeOn(int switchPattern,int lamp, int parity){
    int sum = 0;
    for(;switchPattern>0; switchPattern>>=1,lamp>>=1){
        if(lamp%2)
            sum += switchPattern%2;
    }
    if(sum%2 == parity){
        return true;
    }
    else{
        return false;
    }
}
int main(void){
    int N,M;
    cin>>N>>M;
    vector<int> lamp(M);
    vector<int> pari(M);
    for(int i = 0; i<M; i++){
        int k,buf; cin>>k;
        for(int j = 0; j<k; j++){
            cin>>buf;
            lamp[i] += 1<<(buf-1);
        }
    }
    for(int i = 0; i<M; i++){
        cin>>pari[i];
    }
    int ans = 0;
    for(int switchPattern = 0; switchPattern < pow(2,N); switchPattern++){
        bool ok = true;
        for(int m = 0; m<M; m++){
            bool add = willBeOn(switchPattern,lamp[m],pari[m]);
            ok &= add;
            //cout<<switchPattern<<":"<<lamp[m]<<":"<<pari[m]<<":"<<add<<endl;
        }
        ans += ok;
    }
    cout<<ans<<endl;
    return 0;
}

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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	ll a,b;
	char ch;
	cin>>a>>ch>>b;
	if(ch=='+')
		cout<<a+b<<endl;
	else
		cout<<a-b<<endl;
	return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

#include <array>

struct D {
	UL z;
	UL mul;
	vector<array<UL, 26>> V;
	UL match;
	UL isMatch(UL p) {
		UL t = 0;
		rep(c, 26) if (V[p][c] == 0) t++;
		return (t == 25) ? 1 : 0;
	}
	void init(UL z_, UL mul_, string& S) {
		z = z_; mul = mul_;
		V.resize(z);
		rep(i, S.size()) V[i % z][S[i] - 'a']++;
		match = 0;
		rep(i, z) match += isMatch(i);
	}
	void upd(UL p, UL c, UL pre) {
		p %= z;
		match -= isMatch(p);
		V[p][pre]--;
		V[p][c]++;
		match += isMatch(p);
	}
	UL query() {
		if (match == z) return mul;
		return 1;
	}
};


int main() {
	UL N, Q; cin >> N >> Q;
	string S; cin >> S;
	vector<D> G;
	{
		UL n = N;
		for (UL i = 2; i <= n; i++) {
			UL t = 0;
			while (n % i == 0) { t++; n /= i; }
			UL cy = 1;
			rep(tt, t) {
				cy *= i;
				G.push_back(D());
				G.back().init(N / cy, i, S);
			}
		}
	}
	rep(q, Q) {
		UL p; char c; cin >> p >> c; p--;
		UL ans = 1;
		for (D& d : G) {
			d.upd(p, c - 'a', S[p] - 'a');
			ans *= d.query();
		}
		S[p] = c;
		cout << N / ans << endl;
	}

	return 0;
}



Measured memory_bytes: 18216
#include <iostream>

using namespace std;
int main() {
  bool exist=false;
 int N;
 cin >> N;
 int D1[110],D2[110];
 for(int i=0;i<N;i++){
   cin >> D1[i]>> D2[i];
 }
 for(int i=0;i<N-2;i++){
   if(D1[i]==D2[i]&&D1[i+1]==D2[i+1]&&D1[i+2]==D2[i+2]){
     exist = true;
   }
 }
 if(exist){
   cout << "Yes"<< endl;
 }else{
   cout << "No"<< endl;
 }
  return 0;
} 

Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

int n, C, fir, L[7];

int F[257][311][311];

int A1[257], A2[257], B[33][33], tim = -1;

int main() {
    scanf("%d%d", &n, &C);
    for(int i = 0; i < n; i++) scanf("%d", &L[i]);
    for(int i = 0; i < (1 << (n - 1)); i++)
        for(int j = 0; j < (1 << (n - 1)); j++)
            if(__builtin_popcount(i) == __builtin_popcount(j)) {
                A1[++tim] = i;
                A2[tim] = j;
                B[i][j] = tim;
            }
    sort(L, L + n);
    fir = L[n - 1];
    memset(F, 0, sizeof F);
    F[0][0][0] = 1;
    for(int S = 0; S < tim; S++) {
        int s = A1[S], s2 = A2[S];
            for(int i = 0; i < C * n; i++)
                for(int k = 0; k <= i; k++) if(F[S][i][k])
                    for(int nxt = 0; nxt < n - 1; nxt++) if(!((s >> nxt) & 1))
                        for(int nxt2 = 0; nxt2 < n - 1; nxt2++) if(!((s2 >> nxt2) & 1))
                            for(int j = i / n * n + (nxt2 + 1) + (nxt2 + 1 < i % n) * n; j < C * n; j += n)
                                F[B[s + (1 << nxt)][s2 + (1 << nxt2)]][j][k >= j - L[nxt] * n ? j : k] += F[S][i][k];
    }
    long long ans = 0, s = 1;
    for(int i = (C - fir) * n; i < C * n; i++)
        for(int j = (C - fir) * n; j <= i; j++)
            ans += F[tim][i][j];
    for(int i = 1; i < n; i++) s *= i;
    printf("%.15lf\n", ans / pow(C, n - 1) / s);
    return 0;
}


Measured memory_bytes: 97280
#include<bits/stdc++.h>
using namespace std;
int A,B,C,D;
int main(){
  cin>>A>>B>>C>>D;
  if(A+B==C+D)cout<<"Balanced"<<endl;
  else if(A+B>C+D)cout<<"Left"<<endl;
  else cout<<"Right"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <string.h>
#include <string>
#include <cmath>
#include <cstdio>
#include <functional>
#include <map>
#include <typeinfo>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;


int main()
{
  int n;
  char s[60];
  
  scanf("%d", &n);
  scanf("%s", s);
  
  int res = 0;
  
  for(int i = 0; i < n; i++)
    if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')
      res++;
  
  printf("%d\n", res);
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
    string S;

    cin >> S;

    for(int i = 0; i < S.size(); i++) {
        for(int j = 0; j < i; j++) {
            if(S[i] == S[j]) {
                cout << "no" << endl;
                return 0;
            }
        }
    }
    cout << "yes" << endl;
}

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

static const int N = 1000;
static int dp[N + 1][N + 1];

int lcs(string x, string y)
{
    int m = x.length();
    int n = y.length();
    x = ' ' + x;
    y = ' ' + y;

    dp[0][0] = 0;
    for (int i = 1; i <= m; i++)
        dp[i][0] = 0;
    for (int j = 1; j <= n; j++)
        dp[0][j] = 0;

    int res = 0;
    for (int i = 1; i <= m; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            if (x[i] == y[j])
                dp[i][j] = dp[i - 1][j - 1] + 1;
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }

    return dp[m][n];
}

int main()
{
    int n;
    cin >> n;
    string x1, x2;
    for (int i = 0; i < n; i++)
    {
        cin >> x1 >> x2;
        cout << lcs(x1, x2) << endl;
    }
    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string N;
  cin >> N;
  N = "0" + N;
  vector<vector<int>> dp(N.size() + 1, vector<int>(2, 1 << 28));
  dp[0][0] = 0;
  for (int i = 0; i < (int)N.size(); i++) {
    dp[i + 1][0] = min(dp[i][0] + N[i] - '0', dp[i][1] + 10 - (N[i] - '0'));
    dp[i + 1][1] =
        min(dp[i][0] + N[i] - '0' + 1, dp[i][1] + 10 - (N[i] - '0') - 1);
  }
  cout << dp[N.size()][0] << '\n';
  return 0;
}


Measured memory_bytes: 55880
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n;
    string s;
    cin >> n >> s;
    vvint dp(n+1, vint(n+1, 0));
    rrep(i, n) rrep(j, n) {
        if (s[i] != s[j]) dp[i][j] = 0;
        else dp[i][j] = dp[i+1][j+1] + 1;
    }

    int ans = 0;
    rep(i, n) rep(j, n) {
        if (i >= j) continue;
        ans = max(ans, min(dp[i][j], j-i));
    }

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

Measured memory_bytes: 98176
#include <iostream>
#include <string>
using namespace std;
int main() {
	int h,w,a,b;
	for(;;){
		cin>>h>>w;
		if(h==0 && w==0){
			return 0;
		}
		a=h;
		b=w;
		for(w=b;w>0;w=w-1){
			cout<<"#";
		}
		cout<<endl;
		for(h=a;h>2;h=h-1){
			cout<<"#";
			for(w=b;w>2;w=w-1){
				cout<<".";
			}
			cout<<"#"<<endl;
		}	
		for(w=b;w>0;w=w-1){
			cout<<"#";
		}
		cout<<endl<<endl;	
	}
}



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

struct in
{
	int num;
	int xnum;
};

int main()
{
	int n,x;
	int count = 0;
	int i = 0;
	in nyuryoku[1000];

	while (1)
	{
		cin >> n >> x;

		if (n == 0 && x == 0)
		{
			break;
		}
		else
		{
			nyuryoku[i].num = n;
			nyuryoku[i].xnum = x;
			i++;
		}
	}

	for (int in = 0; in < i; in++)
	{
		for (int i1 = 1; i1 <= nyuryoku[in].num - 2; i1++)
		{
			for (int i2 = i1 + 1; i2<=nyuryoku[in].num - 1; i2++)
			{
				for (int i3 = i2 + 1; i3 <= nyuryoku[in].num; i3++)
				{
					if (i1 + i2 + i3 == nyuryoku[in].xnum)
					{
						count++;
					}
				}
			}
		}
		cout << count << endl;
		count = 0;
	}
	return 0;
}

Measured memory_bytes: 3056
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);

void main()
{
    long w, h, n;
    scan(w, h, n);
    // writeln(w, h, n);
    auto tmp = new long[][](w, h);
    foreach (i; 0 .. tmp.length)
        tmp[i][] = 1;
    // writeln(tmp);
    //白1黒0
    foreach (i; 0 .. n)
    {
        long x, y, a;
        scan(x, y, a);
        // writeln(x, y, a);
        if (a == 1)
        {
            foreach (j; 0 .. x)
            {
                foreach (k; 0 .. h)
                {
                    tmp[j][k] = 0;
                }

            }

        }
        if (a == 2)
        {
            foreach (j; x .. w)
            {
                foreach (k; 0 .. h)
                {
                    tmp[j][k] = 0;
                }

            }

        }
        if (a == 3)
        {
            foreach (j; 0 .. w)
            {
                foreach (k; 0 .. y)
                {
                    tmp[j][k] = 0;
                }

            }

        }

        if (a == 4)
        {
            foreach (j; 0 .. w)
            {
                foreach (k; y .. h)
                {

                    tmp[j][k] = 0;
                }

            }
        }
        // writeln(tmp);
    }
    long ans;
    foreach (i; 0 .. tmp.length)
    {
        ans += sum(tmp[i]);
    }
    writeln(ans);
}

// long[string] AA;
// auto SS = ["AC", "WA", "AC"];

// foreach (S; SS)
// {
//     // if (S in AA)
//     // {
//     //     AA[S] = AA[S] + 1;
//     // }
//     // else
//     // {
//     //     AA[S] = 1;
//     // }
//     AA[S] = AA.get(S, 0) + 1;
// }
// }

// long get(long[string] aa, string key, long defaultValue)
// {
//     if (key in aa)
//     {
//         return aa[key];
//     }
//     else
//     {
//         return defaultValue;
//     }
// }

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}


Measured memory_bytes: 3672
#include <stdio.h>
#include <stdlib.h>

int compare(const void *a,const void *b){
  return *(int *)a - *(int *)b;
}

int main(){
  int n;
  scanf("%d",&n);
  int d[100000];
  for(int i=0;i<n;i++){
    scanf("%d",d+i);
  }
  qsort(d,n,sizeof(int),compare);
  printf("%d\n",d[n/2]-d[n/2 -1]);
  return 0;
}

Measured memory_bytes: 892
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n, m, l;
		n = scan.nextInt();
		m = scan.nextInt();
		l = scan.nextInt();
		int[][] matA = new int[n][m];
		int[][] matB = new int[m][l];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				matA[i][j] = scan.nextInt();
			}
		}
		for (int j = 0; j < m; j++) {
			for (int k = 0; k < l; k++) {
				matB[j][k] = scan.nextInt();
			}
		}
		for (int i = 0; i < n; i++) {
			for (int k = 0; k < l; k++) {
				long c = 0;
				for (int j = 0; j < m; j++) {
					c += matA[i][j] * matB[j][k];
				}
				if (k != l - 1) {
					sb.append(c + " ");
				} else {
					sb.append(c + "\n");
				}
			}
		}
		System.out.print(sb);
	}
}

Measured memory_bytes: 51888
n=int(input())
s=v=w=0
for _ in range(n):
  t,x,y=map(int,input().split())
  dt,dx,dy=t-s,x-v,y-w
  if (dt+dx+dy)%2>0 or dt<abs(dx)+abs(dy): print('No'); break
  s,v,w=t,x,y
else: print('Yes')

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X; cin >> X;
    int ans = 1;
    REP(i, 2, 50) {
        int num = i * i;
        while(num <= X) {
            ans = max(ans, num);
            num *= i;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for (ll i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--)
#define IREP(i, n) IFOR(i, n, 0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(), greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v)                                                              \
  cout << #v << "=(" << v[0];                                                  \
  FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; }                     \
  cout << ")" << endl;
#define mdebug(m)                                                              \
  cout << #m << "=" << endl;                                                   \
  REP(i_debug, m.size()) {                                                     \
    REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; }    \
    cout << endl;                                                              \
  }
#define Lower_bound(v, x)                                                      \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define ld long double
// #define f first
// #define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;

template <typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) {
  REP(i, a.size()) {
    cin >> a[i];
    a[i]--;
  }
}

int main() {
  ll N, K;
  cin >> N >> K;
  vec A(N);
  REP(i, N) {
    cin >> A[i];
    A[i]--;
  }

  vec visitedK(N, -1);

  ll currentpos = 0;
  bool loop_found = false;
  while (K > 0) {
    if (!loop_found && visitedK[currentpos] > 0) {
      ll mod = visitedK[currentpos] - K;
      // debug(mod);
      // debug(currentpos);
      K %= mod;
      if (K == 0)
        break;
      loop_found = true;
    } else if (!loop_found) {
      visitedK[currentpos] = K;
    }
    K--;
    currentpos = A[currentpos];
  }

  cout << currentpos + 1 << endl;
  return 0;
}


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

typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main() {
    ll n,s;
    cin>>n>>s;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    vector<mint> q(s+1);
    mint ans=0;
    rep(i,n){
      //Lがiにくる
      q[0]+=1;
      vector<mint> q2(s+1);
      //Lがi-1以下、Rがi
      q2=q;
      rep(j,s+1){
        if(j+a[i]<=s) q2[j+a[i]]+=q[j];
      }
      q=q2;
      ans+=q[s];


    }
cout<<ans<<endl;
}


Measured memory_bytes: 384
let () =
  let rec loop () =
    match read_line () with
      "-" -> ()
    | cards -> 
       let m = read_int () in
       let rec shuffle n cards =
         match n with
           0 -> print_endline cards
         | i -> let h = read_int () in
                let bottom = String.sub cards 0 h in
                let top = String.sub cards h @@ String.length cards - h  in
                shuffle (n-1) (top ^ bottom)
       in
       shuffle m cards;
       loop ()
  in
  loop ()
;;


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N-1);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  for(int i=0;i<N;i++){
    cin >> B.at(i);
  }
  for(int i=0;i<N-1;i++){
    cin >> C.at(i);
  }
  
  int sum=0;
  for(int i=0;i<N;i++){
    sum += B.at(i);
  }

  for(int i=0;i<N-1;i++){
    if(A.at(i)+1 == A.at(i+1)){
      sum += C.at(A.at(i)-1);
    }
  }
  
  cout << sum << endl;
  return 0;
}


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

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

    vector<int> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }
    sort(l.begin(), l.end(), greater<int>());

    int ans = 0;
    for (int i = 0; i < k; i++) {
        ans += l[i];
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
x = int(input())

s =[2]

if x==2:
    print(x)
    exit()
else:
    for i in range(3,int(x/2),2):
        if all(i%k!=0 for k in s):
            s.append(i)

while any(x%k==0 for k in s):
  x+=1
else:
  print(x)

Measured memory_bytes: 3188
#include <iostream>
  #include <complex>
  #include <vector>
  #include <string>
  #include <algorithm>
  #include <cstdio>
  #include <numeric>
  #include <cstring>
  #include <ctime>
  #include <cstdlib>
  #include <set>
  #include <map>
  #include <unordered_map>
  #include <unordered_set>
  #include <list>
  #include <cmath>
  #include <bitset>
  #include <cassert>
  #include <queue>
  #include <stack>
  #include <deque>
 #include <iomanip>

  using namespace std;
   

//abcdefghijklmnopqrstuvwxyz
//ABCDEFGHIJKLMNOPQRSTUVWXYZ
  typedef long long ll;
  typedef long double lld;
  typedef string str;
  typedef unsigned long long ull;
  ll INF = INT_MAX;
  ll mod = 998244353;
  lld PI = 3.141592653;

// const int N = 2e5 + 5;

// int a[N];
// int n,k;



// void solve(){

// string s;
// cin>>s;


// }
 

  int main()
  {
      ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
      
      int n;
      cin>>n;
      vector<int> a(n);
      for (int i = 0;i<n;i++) cin>>a[i];
      sort(a.rbegin(), a.rend());
      ll ans = 0;
      int cnt = 0;
      ans+=a[0];
      int now = 1;
      for (int i = 2;i<n;i++){
        ans+=a[now];
        cnt++;
        if (cnt==2){
          cnt = 0;
          now++;
        }
      }
cout<<ans<<"\n";
}



Measured memory_bytes: 3636
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <cmath>

using namespace std;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mp make_pair
#define all(a) (a).begin(), (a).end()
typedef long long ll;

template<typename T>
void vdeb(vector<T> &da){
    int size=da.size();
    for(int i=0;i<size;i++){
        if(i==size-1){
            cout << da[i] << endl;
        }
        else{
            cout << da[i] << ' ';
        }
    }
}

ll nap(int now, vector<ll> &x, vector<ll> &y){
    vector<ll> dp(now + 1,0);
    rip(i,now + 1,0){
        dp[i] = i;
        rip(j,3,0){
            if(i - x[j] < 0){
                continue;
            }
            dp[i] = max(dp[i], dp[i - x[j]] + y[j]);
        }
    }
    //vdeb(dp);
    return dp[now];
}

int main(){
    int n;
    cin >> n;
    vector<vector<ll>> da(n,vector<ll>(n));
    rip(i,n,0){
        rip(j,n,0){
            cin >> da[i][j];
        }
    }
    auto dp = da;
    rip(i,n,0){
        rip(j,n,0){
            rip(k,n,0){
                dp[j][k] = min(dp[j][k], dp[j][i] + dp[i][k]);
            }
        }
    }
    if(da != dp){
        cout << -1 << endl;
        return 0;
    }
    ll ans = 0;
    rip(i,n,0){
        rip(j,n,0){
            ans = ans + (ll)da[i][j];
        }
    }
    rip(i,n,0){
        rip(j,n,0){
            rip(k,n,0){
                if(da[i][k] + da[k][j] == da[i][j] && i!=k && j!=k){
                    ans -= da[i][j];
                    break;
                }
            }
        }
    }
    cout << ans/2 << endl;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long int n;
    string ans;
    cin>>n;
    while(n){
        n--;
        ans+='a'+n%26;
        n/=26;
    }
    reverse(ans.begin(), ans.end());
    cout<<ans<<endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

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

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
edges = {}
p = {}
done_nodes = set()

def dfs(target_node, keisyo_point):
    global p
    done_nodes.add(target_node)
    p[target_node] += keisyo_point
    next_node = edges[target_node]
    if not next_node:
        return
    else:
        for next in next_node:
            #edges[next].pop(edges[next].index(target_node))
            #dfs(next, p[target_node])
            if next in done_nodes:
                pass
            else:
                dfs(next, p[target_node])

def main():
    global edges, p
    n, q = map(int, input().split())
    edges = {e: [] for e in range(1, n+1)}
    for _ in range(n - 1):
        a, b = tuple(map(int, input().split()))
        edges[a].append(b)
        edges[b].append(a)
    p = {e: 0 for e in range(1, n+1)}
    for _ in range(q):
        p1, x1 = map(int, input().split())
        p[p1] += x1

    dfs(1, 0)
    for i1 in range(1, n + 1):
        print(p[i1], end=' ')

if __name__ == '__main__':
    main()

Measured memory_bytes: 276716
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        StringBuilder ans = new StringBuilder();
        int begin,end;
        String op;
        sb.append(br.readLine());
        int q = Integer.parseInt(br.readLine());
        while(q-->0){
            String str[] = br.readLine().split(" ");
            op = str[0];
            begin = Integer.parseInt(str[1]);
            end = Integer.parseInt(str[2])+1;
            if(op.equals("print")){
                ans.append(sb.substring(begin, end)).append("\n");
            }else if(op.equals("reverse")){
                StringBuilder sb2 = new StringBuilder(sb.substring(begin,end));
                sb.replace(begin, end, sb2.reverse().toString());
            }else{
                sb.replace(begin, end, str[3]);
            }
        }
        System.out.print(ans);
    }
}

Measured memory_bytes: 24780
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function root(par::Vector{Int},x::Int)
    index=par[x]
    while par[index]!=index
        index=par[index]
    end
    return index
end

function unite(par::Vector{Int},siz::Vector{Int},x::Int,y::Int)
    rx,ry=root(par,x),root(par,y)
    if rx==ry
        return 0
    elseif rx>ry
        rx,ry=ry,rx
    end
    tmp=siz[rx]*siz[ry]
    par[ry]=rx
    siz[rx]+=siz[ry]
    return tmp
end

function same(par::Vector{Int},x::Int,y::Int)
    return root(par,x)==root(par,y)
end

function main()
    n,m=parseMap(split(readline()))
    data=[parseMap(split(readline())) for i in 1:m]
    par=[i for i in 1:n]    # 親を格納する配列
    siz=[1 for i in 1:n]    # 各点を親とするUnion-Findの大きさ

    res=(n-1)n÷2
    ans=[0 for i in 1:m]

    for i in m:-1:1
        ans[i]=res
        res-=unite(par,siz,data[i][1],data[i][2])
    end
    println(join(ans,"\n"))
end
main()

Measured memory_bytes: 160956
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n, m;
ll e[101010];
bool flag[202020];
vector<ll> ans;
int main(){
    cin>>n>>m;
    REP(i, 0, m) cin>>e[i];

    RREP(i, 0, m){
        if(!flag[e[i]]){
            ans.emplace_back(e[i]);
            flag[e[i]]=true;
        }
    }
    REP(i, 1, n+1){
        if(!flag[i]) ans.emplace_back(i);
    }

    REP(i, 0, ans.size()){
        cout<<ans[i]<<endl;
    }
    return 0;
}


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

int main(void) {
    long long N, K;
    cin >> N >> K;

    long long ans = (N / K) * (N / K) * (N / K);
    if (K % 2 == 0) {
        ans += ((N + K / 2) / K) * ((N + K / 2) / K) * ((N + K / 2) / K);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main()
{
	string w, W, t, T;

	cin >> w;

	int count = 0;
	while (true) {

		cin >> t;

		if (t == "END_OF_TEXT") break;

		int count2 = 0, j = 0;
		for (int i = 0; i < t.length(); i++) {
			if (t.length() == w.length()) {
				if (t[i] == w[j] || t[i] == toupper(w[j])) {
					count2++;
					j++;
				}
				else {
					count2 = 0;
					j = 0;
				}
				if (count2 == w.length()) count++;
			}
		}
	}

	cout << count << "\n";
}

Measured memory_bytes: 1192
#include <iostream>
#include <fstream>
using namespace std;
const int nmax=1005;
string s[nmax],ans1[nmax],ans2[nmax];
int n,m,i,j;
int main()
{
    //freopen("data.in","r",stdin);
    cin>>n>>m;
    for(i=1;i<=n;i++)
        cin>>s[i];
    for(i=1;i<=n;i++)
        ans1[i]=ans2[i]=s[i];
    for(i=1;i<=n;i++)
        ans1[i][0]=ans2[i][m-1]='#';
    for(i=1;i<=n;i+=2)
        for(j=1;j<m-1;j++)
            ans1[i][j]='#';
    for(i=2;i<=n;i+=2)
        for(j=1;j<m-1;j++)
           ans2[i][j]='#';
    for(i=1;i<=n;i++)
        cout<<ans1[i]<<'\n';
    cout<<'\n';
    for(i=1;i<=n;i++)
        cout<<ans2[i]<<'\n';
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define gc getchar()
#define root 1,1,n
#define lc cur<<1
#define rc lc|1
#define lson lc,l,mid
#define rson rc,mid+1,r
using namespace std;
typedef long long ll;
const int mod=1000000007;
const int N=200009;
int n,a[N],cnt[N],sum=1,tg[N<<2],Ans,inv2;
vector<int> q[N];
struct node
{
	int sum,num;
	node(int sum=0,int num=0):sum(sum),num(num){}
	friend node operator +(const node &A,const node &B)
	{
		return node((A.sum+B.sum)%mod,A.num+B.num);
	}
}val[N<<2];
int read()
{
	int x=1;
	char ch;
	while (ch=gc,ch<'0'||ch>'9') if (ch=='-') x=-1;
	int s=ch-'0';
	while (ch=gc,ch>='0'&&ch<='9') s=s*10+ch-'0';
	return s*x;
}
int ksm(int x,int y,int ret=1)
{
	for (;y;y>>=1,x=(ll)x*x%mod)
		if (y&1) ret=(ll)ret*x%mod;
	return ret;
}
void add(int cur,int x)
{
	val[cur].sum=(ll)val[cur].sum*x%mod,tg[cur]=(ll)tg[cur]*x%mod;
}
void down(int cur)
{
	if (tg[cur]==1) return;
	add(lc,tg[cur]),add(rc,tg[cur]);
	tg[cur]=1;
}
void ins(int cur,int l,int r,int x,int y)
{
	if (l==r)
	{
		val[cur]=node(y,1);
		return;
	}
	int mid=(l+r>>1);
	down(cur);
	if (x<=mid) ins(lson,x,y);
	else ins(rson,x,y);
	val[cur]=val[lc]+val[rc];
}
node qry(int cur,int l,int r,int L,int R)
{
	if (L<=l&&R>=r) return val[cur];
	int mid=(l+r>>1);
	down(cur);
	node ret=node(0,0);
	if (L<=mid) ret=ret+qry(lson,L,R);
	if (R>mid) ret=ret+qry(rson,L,R);
	return ret;
}
int main()
{
	inv2=(mod+1)/2;
	n=read();
	for (int i=1;i<=n;i++) cnt[a[i]=read()]++,q[a[i]].push_back(i);
	for (int i=n-1;i;i--) cnt[i]+=cnt[i+1];
	for (int i=1;i<=n;i++)
	{
		cnt[i]-=n-i;
		if (cnt[i]<=0)
		{
			puts("0");
			return 0;
		}
		sum=(ll)sum*cnt[i]%mod;
	}
	for (int i=0;i<(N<<2);i++) tg[i]=1;
	for (int i=n;i;i--)
	{
		for (int j:q[i])
		{
			node now=qry(root,j,n);
			Ans=(Ans+(ll)now.sum*inv2)%mod;
			now=qry(root,1,j);
			Ans=(Ans+(ll)now.num*sum%mod-(ll)now.sum*inv2%mod+mod)%mod;
		}
		int sz=q[i].size();
		Ans=(Ans+(ll)sz*(sz-1)/2%mod*sum%mod*inv2%mod)%mod;
		for (int j:q[i]) ins(root,j,sum);
		add(1,(ll)(cnt[i]-1)*ksm(cnt[i],mod-2)%mod);
	}
	printf("%d\n",Ans);
	return 0;
}


Measured memory_bytes: 22144
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		long[]A = new long[N];
		string[] str = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			A[i] = long.Parse(str[i]);
		}
		long mod = 1000000007;
		long ans = 0;
		if(A[0]==0){
			ans = 3;
			int a1 = 1;
			int a2 = 0;
			int a3 = 0;
			for(var i=1;i<N;i++){
				if(A[i]==a1){
					if(A[i]==a2){
						if(A[i]==a3){
							ans = ans * 3 % mod;
							a1++;
						} else {
							ans = ans * 2 % mod;
							a1++;
						}
					} else {
						if(A[i]==a3){
							ans = ans * 2 % mod;
							a1++;
						} else {
							ans = ans * 1 % mod;
							a1++;
						}
					}
				} else {
					if(A[i]==a2){
						if(A[i]==a3){
							ans = ans * 2 % mod;
							a2++;
						} else {
							ans = ans * 1 % mod;
							a2++;
						}
					} else {
						if(A[i]==a3){
							ans = ans * 1 % mod;
							a3++;
						} else {
							ans = 0;
						}
					}
				}
              	//Console.Error.WriteLine(ans+" "+a1+" "+a2+" "+a3);
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 19296
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 07/14/20 20:57:13
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

constexpr ll MOD = 1e9+7;

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

  int n; cin>>n;
  string s; cin>>s;
  ll ans = 1;
  for (int m = 2; m <= n; m++)
    (ans *= m) %= MOD;
  int l = 1, r = 0;
  bool cl = true;
  for (int i = 1; i < 2*n; i++) {
    if (s[i] == s[i-1]) {
      cl = !cl;
    }
    if (!cl) {
      (ans *= l-r) %= MOD;
    }
    if (cl)
      l++;
    else
      r++;
  }
  if (cl or l != r or s[0] == 'W' or s[2*n-1] == 'W') {
    cout << 0 << endl;
  } else {
    cout << ans << endl;
  }

  return 0;
}


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

int main() {
    int n;
    cin >> n;
    long r = 0;
    for(int i = 1; i <= n; i++) {
        int x = n / i;
        r += long(x + 1) * x / 2 * i;
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 3600